index.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*! firebase-admin v12.1.1 */
  2. "use strict";
  3. /*!
  4. * Copyright 2020 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. Object.defineProperty(exports, "__esModule", { value: true });
  19. exports.getRemoteConfig = exports.RemoteConfig = exports.PercentConditionOperator = void 0;
  20. /**
  21. * Firebase Remote Config.
  22. *
  23. * @packageDocumentation
  24. */
  25. const app_1 = require("../app");
  26. const remote_config_1 = require("./remote-config");
  27. var remote_config_api_1 = require("./remote-config-api");
  28. Object.defineProperty(exports, "PercentConditionOperator", { enumerable: true, get: function () { return remote_config_api_1.PercentConditionOperator; } });
  29. var remote_config_2 = require("./remote-config");
  30. Object.defineProperty(exports, "RemoteConfig", { enumerable: true, get: function () { return remote_config_2.RemoteConfig; } });
  31. /**
  32. * Gets the {@link RemoteConfig} service for the default app or a given app.
  33. *
  34. * `getRemoteConfig()` can be called with no arguments to access the default
  35. * app's `RemoteConfig` service or as `getRemoteConfig(app)` to access the
  36. * `RemoteConfig` service associated with a specific app.
  37. *
  38. * @example
  39. * ```javascript
  40. * // Get the `RemoteConfig` service for the default app
  41. * const defaultRemoteConfig = getRemoteConfig();
  42. * ```
  43. *
  44. * @example
  45. * ```javascript
  46. * // Get the `RemoteConfig` service for a given app
  47. * const otherRemoteConfig = getRemoteConfig(otherApp);
  48. * ```
  49. *
  50. * @param app - Optional app for which to return the `RemoteConfig` service.
  51. * If not provided, the default `RemoteConfig` service is returned.
  52. *
  53. * @returns The default `RemoteConfig` service if no
  54. * app is provided, or the `RemoteConfig` service associated with the provided
  55. * app.
  56. */
  57. function getRemoteConfig(app) {
  58. if (typeof app === 'undefined') {
  59. app = (0, app_1.getApp)();
  60. }
  61. const firebaseApp = app;
  62. return firebaseApp.getOrInitService('remoteConfig', (app) => new remote_config_1.RemoteConfig(app));
  63. }
  64. exports.getRemoteConfig = getRemoteConfig;