|
| 1 | +/*! |
| 2 | + * Copyright 2020 Google Inc. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +import { FirebaseApp } from '../firebase-app'; |
| 18 | +import * as remoteConfigApi from './remote-config'; |
| 19 | +import * as remoteConfigClientApi from './remote-config-api-client'; |
| 20 | +import * as firebaseAdmin from '../index'; |
| 21 | + |
| 22 | +export function remoteConfig(app?: FirebaseApp): remoteConfigApi.RemoteConfig { |
| 23 | + if (typeof(app) === 'undefined') { |
| 24 | + app = firebaseAdmin.app(); |
| 25 | + } |
| 26 | + return app.remoteConfig(); |
| 27 | +} |
| 28 | + |
| 29 | +/** |
| 30 | + * We must define a namespace to make the typings work correctly. Otherwise |
| 31 | + * `admin.remoteConfig()` cannot be called like a function. Temporarily, |
| 32 | + * admin.remoteConfig is used as the namespace name because we cannot barrel |
| 33 | + * re-export the contents from remote-config, and we want it to |
| 34 | + * match the namespacing in the re-export inside src/index.d.ts |
| 35 | + */ |
| 36 | +/* eslint-disable @typescript-eslint/no-namespace */ |
| 37 | +export namespace admin.remoteConfig { |
| 38 | + // See https://github.com/microsoft/TypeScript/issues/4336 |
| 39 | + /* eslint-disable @typescript-eslint/no-unused-vars */ |
| 40 | + // See https://github.com/typescript-eslint/typescript-eslint/issues/363 |
| 41 | + export import ExplicitParameterValue = remoteConfigClientApi.ExplicitParameterValue; |
| 42 | + export import ListVersionsOptions = remoteConfigClientApi.ListVersionsOptions; |
| 43 | + export import ListVersionsResult = remoteConfigClientApi.ListVersionsResult; |
| 44 | + export import InAppDefaultValue = remoteConfigClientApi.InAppDefaultValue; |
| 45 | + export import RemoteConfigCondition = remoteConfigClientApi.RemoteConfigCondition; |
| 46 | + export import RemoteConfigParameter = remoteConfigClientApi.RemoteConfigParameter; |
| 47 | + export import RemoteConfigParameterGroup = remoteConfigClientApi.RemoteConfigParameterGroup; |
| 48 | + export import RemoteConfigParameterValue = remoteConfigClientApi.RemoteConfigParameterValue; |
| 49 | + export import RemoteConfigTemplate = remoteConfigClientApi.RemoteConfigTemplate; |
| 50 | + export import RemoteConfigUser = remoteConfigClientApi.RemoteConfigUser; |
| 51 | + export import TagColor = remoteConfigClientApi.TagColor; |
| 52 | + export import Version = remoteConfigClientApi.Version; |
| 53 | + |
| 54 | + // Allows for exposing classes as interfaces in typings |
| 55 | + /* eslint-disable @typescript-eslint/no-empty-interface */ |
| 56 | + export interface RemoteConfig extends remoteConfigApi.RemoteConfig {} |
| 57 | +} |
0 commit comments