123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.defaultNamespace = exports.FirebaseNamespace = exports.FirebaseNamespaceInternals = void 0;
- const lifecycle_1 = require("./lifecycle");
- const credential_factory_1 = require("./credential-factory");
- const index_1 = require("../utils/index");
- class FirebaseNamespaceInternals {
- constructor(appStore) {
- this.appStore = appStore;
- }
-
- initializeApp(options, appName) {
- const app = this.appStore.initializeApp(options, appName);
- return extendApp(app);
- }
-
- app(appName) {
- const app = this.appStore.getApp(appName);
- return extendApp(app);
- }
-
- get apps() {
- return this.appStore.getApps().map((app) => extendApp(app));
- }
- }
- exports.FirebaseNamespaceInternals = FirebaseNamespaceInternals;
- const firebaseCredential = {
- cert: credential_factory_1.cert, refreshToken: credential_factory_1.refreshToken, applicationDefault: credential_factory_1.applicationDefault
- };
- class FirebaseNamespace {
-
- constructor(appStore) {
-
-
- this.__esModule = true;
-
- this.credential = firebaseCredential;
- this.SDK_VERSION = (0, index_1.getSdkVersion)();
-
-
-
- this.Promise = Promise;
- this.INTERNAL = new FirebaseNamespaceInternals(appStore ?? new lifecycle_1.AppStore());
- }
-
- get auth() {
- const fn = (app) => {
- return this.ensureApp(app).auth();
- };
- const auth = require('../auth/auth').Auth;
- return Object.assign(fn, { Auth: auth });
- }
-
- get database() {
- const fn = (app) => {
- return this.ensureApp(app).database();
- };
-
- return Object.assign(fn, require('@firebase/database-compat/standalone'));
- }
-
- get messaging() {
- const fn = (app) => {
- return this.ensureApp(app).messaging();
- };
- const messaging = require('../messaging/messaging').Messaging;
- return Object.assign(fn, { Messaging: messaging });
- }
-
- get storage() {
- const fn = (app) => {
- return this.ensureApp(app).storage();
- };
- const storage = require('../storage/storage').Storage;
- return Object.assign(fn, { Storage: storage });
- }
-
- get firestore() {
- let fn = (app) => {
- return this.ensureApp(app).firestore();
- };
-
- const firestore = require('@google-cloud/firestore');
- fn = Object.assign(fn, firestore.Firestore);
-
-
- Object.defineProperty(fn, 'v1beta1', {
- get: () => {
- return firestore.v1beta1;
- },
- });
- Object.defineProperty(fn, 'v1', {
- get: () => {
- return firestore.v1;
- },
- });
- return fn;
- }
-
- get machineLearning() {
- const fn = (app) => {
- return this.ensureApp(app).machineLearning();
- };
- const machineLearning = require('../machine-learning/machine-learning').MachineLearning;
- return Object.assign(fn, { MachineLearning: machineLearning });
- }
-
- get installations() {
- const fn = (app) => {
- return this.ensureApp(app).installations();
- };
- const installations = require('../installations/installations').Installations;
- return Object.assign(fn, { Installations: installations });
- }
-
- get instanceId() {
- const fn = (app) => {
- return this.ensureApp(app).instanceId();
- };
- const instanceId = require('../instance-id/instance-id').InstanceId;
- return Object.assign(fn, { InstanceId: instanceId });
- }
-
- get projectManagement() {
- const fn = (app) => {
- return this.ensureApp(app).projectManagement();
- };
- const projectManagement = require('../project-management/project-management').ProjectManagement;
- return Object.assign(fn, { ProjectManagement: projectManagement });
- }
-
- get securityRules() {
- const fn = (app) => {
- return this.ensureApp(app).securityRules();
- };
- const securityRules = require('../security-rules/security-rules').SecurityRules;
- return Object.assign(fn, { SecurityRules: securityRules });
- }
-
- get remoteConfig() {
- const fn = (app) => {
- return this.ensureApp(app).remoteConfig();
- };
- const remoteConfig = require('../remote-config/remote-config').RemoteConfig;
- return Object.assign(fn, { RemoteConfig: remoteConfig });
- }
-
- get appCheck() {
- const fn = (app) => {
- return this.ensureApp(app).appCheck();
- };
- const appCheck = require('../app-check/app-check').AppCheck;
- return Object.assign(fn, { AppCheck: appCheck });
- }
-
-
- initializeApp(options, appName) {
- return this.INTERNAL.initializeApp(options, appName);
- }
-
- app(appName) {
- return this.INTERNAL.app(appName);
- }
-
- get apps() {
- return this.INTERNAL.apps;
- }
- ensureApp(app) {
- if (typeof app === 'undefined') {
- app = this.app();
- }
- return app;
- }
- }
- exports.FirebaseNamespace = FirebaseNamespace;
- exports.defaultNamespace = new FirebaseNamespace(lifecycle_1.defaultAppStore);
- function extendApp(app) {
- const result = app;
- if (result.__extended) {
- return result;
- }
- result.auth = () => {
- const fn = require('../auth/index').getAuth;
- return fn(app);
- };
- result.appCheck = () => {
- const fn = require('../app-check/index').getAppCheck;
- return fn(app);
- };
- result.database = (url) => {
- const fn = require('../database/index').getDatabaseWithUrl;
- return fn(url, app);
- };
- result.messaging = () => {
- const fn = require('../messaging/index').getMessaging;
- return fn(app);
- };
- result.storage = () => {
- const fn = require('../storage/index').getStorage;
- return fn(app);
- };
- result.firestore = () => {
- const fn = require('../firestore/index').getFirestore;
- return fn(app);
- };
- result.instanceId = () => {
- const fn = require('../instance-id/index').getInstanceId;
- return fn(app);
- };
- result.installations = () => {
- const fn = require('../installations/index').getInstallations;
- return fn(app);
- };
- result.machineLearning = () => {
- const fn = require('../machine-learning/index').getMachineLearning;
- return fn(app);
- };
- result.projectManagement = () => {
- const fn = require('../project-management/index').getProjectManagement;
- return fn(app);
- };
- result.securityRules = () => {
- const fn = require('../security-rules/index').getSecurityRules;
- return fn(app);
- };
- result.remoteConfig = () => {
- const fn = require('../remote-config/index').getRemoteConfig;
- return fn(app);
- };
- result.__extended = true;
- return result;
- }
|