From 30f23316c4d90b949fb1d9f73feb5c515e8f85cb Mon Sep 17 00:00:00 2001 From: Salakar Date: Sat, 5 May 2018 19:25:52 +0100 Subject: [PATCH] [core] add functions module to core + types --- lib/modules/core/app.js | 3 +++ lib/modules/core/firebase.js | 11 +++++++++++ lib/modules/functions/index.js | 2 +- lib/types/index.js | 1 + lib/utils/apps.js | 2 +- 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/modules/core/app.js b/lib/modules/core/app.js index 82ea6230..c0c69af9 100644 --- a/lib/modules/core/app.js +++ b/lib/modules/core/app.js @@ -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); diff --git a/lib/modules/core/firebase.js b/lib/modules/core/firebase.js index a1eefd3d..b07ee147 100644 --- a/lib/modules/core/firebase.js +++ b/lib/modules/core/firebase.js @@ -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, diff --git a/lib/modules/functions/index.js b/lib/modules/functions/index.js index f1868e54..a6703af0 100644 --- a/lib/modules/functions/index.js +++ b/lib/modules/functions/index.js @@ -16,7 +16,7 @@ type HttpsCallableResult = { type HttpsCallable = (data?: any) => Promise; -export default class Analytics extends ModuleBase { +export default class Functions extends ModuleBase { constructor(app: App) { super(app, { moduleName: MODULE_NAME, diff --git a/lib/types/index.js b/lib/types/index.js index f59f7ca6..881d3737 100644 --- a/lib/types/index.js +++ b/lib/types/index.js @@ -84,6 +84,7 @@ export type FirebaseNamespace = | 'crashlytics' | 'database' | 'firestore' + | 'functions' | 'iid' | 'invites' | 'links' diff --git a/lib/utils/apps.js b/lib/utils/apps.js index 01c37fa7..4d5f063c 100644 --- a/lib/utils/apps.js +++ b/lib/utils/apps.js @@ -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];