firebase-namespace.d.ts 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*! firebase-admin v12.1.1 */
  2. /*!
  3. * @license
  4. * Copyright 2017 Google Inc.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. import { AppStore } from './lifecycle';
  19. import { app, appCheck, auth, messaging, machineLearning, storage, firestore, database, instanceId, installations, projectManagement, securityRules, remoteConfig, AppOptions } from '../firebase-namespace-api';
  20. import { cert, refreshToken, applicationDefault } from './credential-factory';
  21. import App = app.App;
  22. import AppCheck = appCheck.AppCheck;
  23. import Auth = auth.Auth;
  24. import Database = database.Database;
  25. import Firestore = firestore.Firestore;
  26. import Installations = installations.Installations;
  27. import InstanceId = instanceId.InstanceId;
  28. import MachineLearning = machineLearning.MachineLearning;
  29. import Messaging = messaging.Messaging;
  30. import ProjectManagement = projectManagement.ProjectManagement;
  31. import RemoteConfig = remoteConfig.RemoteConfig;
  32. import SecurityRules = securityRules.SecurityRules;
  33. import Storage = storage.Storage;
  34. export interface FirebaseServiceNamespace<T> {
  35. (app?: App): T;
  36. [key: string]: any;
  37. }
  38. /**
  39. * Internals of a FirebaseNamespace instance.
  40. */
  41. export declare class FirebaseNamespaceInternals {
  42. private readonly appStore;
  43. constructor(appStore: AppStore);
  44. /**
  45. * Initializes the App instance.
  46. *
  47. * @param options - Optional options for the App instance. If none present will try to initialize
  48. * from the FIREBASE_CONFIG environment variable. If the environment variable contains a string
  49. * that starts with '{' it will be parsed as JSON, otherwise it will be assumed to be pointing
  50. * to a file.
  51. * @param appName - Optional name of the FirebaseApp instance.
  52. *
  53. * @returns A new App instance.
  54. */
  55. initializeApp(options?: AppOptions, appName?: string): App;
  56. /**
  57. * Returns the App instance with the provided name (or the default App instance
  58. * if no name is provided).
  59. *
  60. * @param appName - Optional name of the FirebaseApp instance to return.
  61. * @returns The App instance which has the provided name.
  62. */
  63. app(appName?: string): App;
  64. get apps(): App[];
  65. }
  66. /**
  67. * Global Firebase context object.
  68. */
  69. export declare class FirebaseNamespace {
  70. __esModule: boolean;
  71. credential: {
  72. cert: typeof cert;
  73. refreshToken: typeof refreshToken;
  74. applicationDefault: typeof applicationDefault;
  75. };
  76. SDK_VERSION: string;
  77. INTERNAL: FirebaseNamespaceInternals;
  78. Promise: any;
  79. constructor(appStore?: AppStore);
  80. /**
  81. * Gets the `Auth` service namespace. The returned namespace can be used to get the
  82. * `Auth` service for the default app or an explicitly specified app.
  83. */
  84. get auth(): FirebaseServiceNamespace<Auth>;
  85. /**
  86. * Gets the `Database` service namespace. The returned namespace can be used to get the
  87. * `Database` service for the default app or an explicitly specified app.
  88. */
  89. get database(): FirebaseServiceNamespace<Database>;
  90. /**
  91. * Gets the `Messaging` service namespace. The returned namespace can be used to get the
  92. * `Messaging` service for the default app or an explicitly specified app.
  93. */
  94. get messaging(): FirebaseServiceNamespace<Messaging>;
  95. /**
  96. * Gets the `Storage` service namespace. The returned namespace can be used to get the
  97. * `Storage` service for the default app or an explicitly specified app.
  98. */
  99. get storage(): FirebaseServiceNamespace<Storage>;
  100. /**
  101. * Gets the `Firestore` service namespace. The returned namespace can be used to get the
  102. * `Firestore` service for the default app or an explicitly specified app.
  103. */
  104. get firestore(): FirebaseServiceNamespace<Firestore>;
  105. /**
  106. * Gets the `MachineLearning` service namespace. The returned namespace can be
  107. * used to get the `MachineLearning` service for the default app or an
  108. * explicityly specified app.
  109. */
  110. get machineLearning(): FirebaseServiceNamespace<MachineLearning>;
  111. /**
  112. * Gets the `Installations` service namespace. The returned namespace can be used to get the
  113. * `Installations` service for the default app or an explicitly specified app.
  114. */
  115. get installations(): FirebaseServiceNamespace<Installations>;
  116. /**
  117. * Gets the `InstanceId` service namespace. The returned namespace can be used to get the
  118. * `Instance` service for the default app or an explicitly specified app.
  119. */
  120. get instanceId(): FirebaseServiceNamespace<InstanceId>;
  121. /**
  122. * Gets the `ProjectManagement` service namespace. The returned namespace can be used to get the
  123. * `ProjectManagement` service for the default app or an explicitly specified app.
  124. */
  125. get projectManagement(): FirebaseServiceNamespace<ProjectManagement>;
  126. /**
  127. * Gets the `SecurityRules` service namespace. The returned namespace can be used to get the
  128. * `SecurityRules` service for the default app or an explicitly specified app.
  129. */
  130. get securityRules(): FirebaseServiceNamespace<SecurityRules>;
  131. /**
  132. * Gets the `RemoteConfig` service namespace. The returned namespace can be used to get the
  133. * `RemoteConfig` service for the default app or an explicitly specified app.
  134. */
  135. get remoteConfig(): FirebaseServiceNamespace<RemoteConfig>;
  136. /**
  137. * Gets the `AppCheck` service namespace. The returned namespace can be used to get the
  138. * `AppCheck` service for the default app or an explicitly specified app.
  139. */
  140. get appCheck(): FirebaseServiceNamespace<AppCheck>;
  141. /**
  142. * Initializes the FirebaseApp instance.
  143. *
  144. * @param options - Optional options for the FirebaseApp instance.
  145. * If none present will try to initialize from the FIREBASE_CONFIG environment variable.
  146. * If the environment variable contains a string that starts with '{' it will be parsed as JSON,
  147. * otherwise it will be assumed to be pointing to a file.
  148. * @param appName - Optional name of the FirebaseApp instance.
  149. *
  150. * @returns A new FirebaseApp instance.
  151. */
  152. initializeApp(options?: AppOptions, appName?: string): App;
  153. /**
  154. * Returns the FirebaseApp instance with the provided name (or the default FirebaseApp instance
  155. * if no name is provided).
  156. *
  157. * @param appName - Optional name of the FirebaseApp instance to return.
  158. * @returns The FirebaseApp instance which has the provided name.
  159. */
  160. app(appName?: string): App;
  161. get apps(): App[];
  162. private ensureApp;
  163. }