[core] add functions module to core + types

This commit is contained in:
Salakar 2018-05-05 19:25:52 +01:00
parent ca068dbbab
commit 30f23316c4
5 changed files with 17 additions and 2 deletions

View File

@ -16,6 +16,7 @@ import Crash, { NAMESPACE as CrashNamespace } from '../crash';
import Crashlytics, { NAMESPACE as CrashlyticsNamespace } from '../crashlytics';
import Database, { NAMESPACE as DatabaseNamespace } from '../database';
import Firestore, { NAMESPACE as FirestoreNamespace } from '../firestore';
import Functions, { NAMESPACE as FunctionsNamespace } from '../functions';
import InstanceId, { NAMESPACE as InstanceIdNamespace } from '../iid';
import Invites, { NAMESPACE as InvitesNamespace } from '../invites';
import Links, { NAMESPACE as LinksNamespace } from '../links';
@ -45,6 +46,7 @@ export default class App {
crashlytics: () => Crashlytics;
database: () => Database;
firestore: () => Firestore;
functions: () => Functions;
iid: () => InstanceId;
invites: () => Invites;
links: () => Links;
@ -85,6 +87,7 @@ export default class App {
this.crashlytics = APPS.appModule(this, CrashlyticsNamespace, Crashlytics);
this.database = APPS.appModule(this, DatabaseNamespace, Database);
this.firestore = APPS.appModule(this, FirestoreNamespace, Firestore);
this.functions = APPS.appModule(this, FunctionsNamespace, Functions);
this.iid = APPS.appModule(this, InstanceIdNamespace, InstanceId);
this.invites = APPS.appModule(this, InvitesNamespace, Invites);
this.links = APPS.appModule(this, LinksNamespace, Links);

View File

@ -38,6 +38,10 @@ import {
statics as FirestoreStatics,
MODULE_NAME as FirestoreModuleName,
} from '../firestore';
import {
statics as FunctionsStatics,
MODULE_NAME as FunctionsModuleName,
} from '../functions';
import {
statics as InstanceIdStatics,
MODULE_NAME as InstanceIdModuleName,
@ -81,6 +85,7 @@ import type {
DatabaseModule,
FirebaseOptions,
FirestoreModule,
FunctionsModule,
InstanceIdModule,
InvitesModule,
LinksModule,
@ -102,6 +107,7 @@ class Firebase {
crashlytics: CrashlyticsModule;
database: DatabaseModule;
firestore: FirestoreModule;
functions: FunctionsModule;
iid: InstanceIdModule;
invites: InvitesModule;
links: LinksModule;
@ -146,6 +152,11 @@ class Firebase {
FirestoreStatics,
FirestoreModuleName
);
this.functions = APPS.moduleAndStatics(
'functions',
FunctionsStatics,
FunctionsModuleName
);
this.iid = APPS.moduleAndStatics(
'iid',
InstanceIdStatics,

View File

@ -16,7 +16,7 @@ type HttpsCallableResult = {
type HttpsCallable = (data?: any) => Promise<HttpsCallableResult>;
export default class Analytics extends ModuleBase {
export default class Functions extends ModuleBase {
constructor(app: App) {
super(app, {
moduleName: MODULE_NAME,

View File

@ -84,6 +84,7 @@ export type FirebaseNamespace =
| 'crashlytics'
| 'database'
| 'firestore'
| 'functions'
| 'iid'
| 'invites'
| 'links'

View File

@ -107,7 +107,7 @@ export default {
const _name = (name || DEFAULT_APP_NAME).toUpperCase();
// return an existing app if found
// todo in v4 remove deprecation and throw an error
// TODO in v5 remove deprecation and throw an error
if (APPS[_name]) {
console.warn(INTERNALS.STRINGS.WARN_INITIALIZE_DEPRECATION);
return APPS[_name];