ibm-appconfiguration-js-client-sdk
Version:
IBM Cloud App Configuration JavaScript Client SDK
129 lines (128 loc) • 4.79 kB
TypeScript
/**
* Copyright 2022 IBM Corp. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Feature from './models/Feature';
import Property from './models/Property';
export default class AppConfiguration {
private static instance;
private isInitialized;
private isInitializedContext;
private constructor();
/**
* Initialize the sdk to connect with your App Configuration service instance.
*
* The method throws {@link Error} if any of the params are missing or invalid.
*
* @param {string} region - REGION name where the App Configuration service instance is created.
* @param {string} guid - GUID of the App Configuration service.
* @param {string} apikey - Client SDK APIKEY of the App Configuration service.
* @memberof AppConfiguration
*/
init(region: string, guid: string, apikey: string): void;
/**
* Sets the context of the SDK.
*
* throws {@link Error} if {@link init} is not performed before calling this method.
*
* throws {@link Error} if `collectionId` is not passed or invalid.
*
* throws {@link Error} if `environmentId` is not passed or invalid.
*
* @param {string} collectionId - Id of the collection created in App Configuration service instance.
* @param {string} environmentId - Id of the environment created in App Configuration service instance.
* @return {*} \{Promise<void>\}
* @memberof AppConfiguration
*/
setContext(collectionId: string, environmentId: string): Promise<void>;
/**
* Returns the {@link Feature} object with the details of the feature flag specified by the `featureId`.
*
* throws {@link Error} if the featureId does not exists or invalid.
*
* throws {@link Error} if called before SDK is initialised.
*
* @param {string} featureId - The Feature flag Id.
* @return {*} {@link Feature} object.
* @memberof AppConfiguration
*/
getFeature(featureId: string): Feature;
/**
* Returns the object of type \{ [x: string]: Feature \} containing details of all the feature flags associated with the `collectionId`.
*
* @return {*} \{ [x: string]: {@link Feature }\}
* @memberof AppConfiguration
*/
getFeatures(): {
[x: string]: Feature;
};
/**
* Returns the {@link Property} object with the details of the property specified by the `propertyId`.
*
* throws {@link Error} if the propertyId does not exists or invalid.
*
* throws {@link Error} if called before SDK is initialised.
*
* @param {string} propertyId
* @return {*} \{Property\}
* @memberof AppConfiguration
*/
getProperty(propertyId: string): Property;
/**
* Returns the object of type \{ [x: string]: Property \} containing details of all the properties associated with the `collectionId`.
*
* @return {*} \{ [x: string]: {@link Property } \}
* @memberof AppConfiguration
*/
getProperties(): {
[x: string]: Property;
};
/**
* Instance of {@link EventEmitter} to listen to live configuration updates.
*
* @memberof AppConfiguration
*/
emitter: {
on: (event: string, fn: (...args: any[]) => void) => import("eventemitter3")<string | symbol, any>;
emit: (event: string, ...args: any[]) => boolean;
};
/**
* @internal
*
* Override the default App Configuration URL. This method should be invoked before the SDK initialization.
* ```js
* // Example
* AppConfiguration.overrideServiceUrl('https://testurl.com');
* ```
* NOTE: To be used for development purposes only.
* @param url - The base url
*/
static overrideServiceUrl(url: string): void;
/**
* Get the instance of {@link AppConfiguration}.
*
* @static
* @return {*}
* @memberof AppConfiguration
*/
static getInstance(): AppConfiguration;
static REGION_US_SOUTH: string;
static REGION_EU_GB: string;
static REGION_AU_SYD: string;
static REGION_US_EAST: string;
static REGION_EU_DE: string;
static REGION_CA_TOR: string;
static REGION_JP_TOK: string;
static REGION_JP_OSA: string;
}