Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 40 additions & 44 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Documentation: http://docs.launchdarkly.com/docs/node-sdk-reference
*/

declare module 'ldclient-node' {
declare module "ldclient-node" {
/**
* The LaunchDarkly static global.
*/
Expand All @@ -26,7 +26,6 @@ declare module 'ldclient-node' {
[key: string]: LDFlagValue,
};

/**
/**
* LaunchDarkly initialization options.
*/
Expand Down Expand Up @@ -67,15 +66,15 @@ declare module 'ldclient-node' {

/**
* Configures a logger for warnings and errors generated by the SDK.
*
*
* This can be a custom logger or an instance of winston.Logger
*/
logger?: LDLogger | object;


/**
* Feature store used by the LaunchDarkly client, defaults to in memory storage.
*
*
* The SDK provides an in memory feature store as well as a redis feature store.
*/
feature_store?: LDFeatureStore;
Expand Down Expand Up @@ -192,132 +191,132 @@ declare module 'ldclient-node' {

/**
* The LaunchDarkly client logger interface.
*
*
* The client will output informational debugging messages to the logger.
* Internally, this logger defaults to an instance of winston.Logger, which takes
* logs a variadic sequence of variables.
* See: https://github.com/winstonjs/winston
*
*
*/
export interface LDLogger {
/**
* The error logger.
*
*
* @param args
* A sequence of any javascript variables
*/
error: (...args: any[]) => void
error: (...args: any[]) => void;

/**
* The warning logger.
*
*
* @param args
* A sequence of any javascript variables
*/
warn: (...args: any[]) => void
warn: (...args: any[]) => void;

/**
* The info logger.
*
*
* @param args
* A sequence of any javascript variables
*/
info: (...args: any[]) => void
info: (...args: any[]) => void;

/**
* The debug logger.
*
*
* @param args
* A sequence of any javascript variables
*/
debug: (...args: any[]) => void
debug: (...args: any[]) => void;
}

/**
* The LaunchDarkly client feature store.
*
*
* The client uses this internally to store flag updates it
* receives from LaunchDarkly.
*/
export interface LDFeatureStore {
/**
* Get a flag's value.
*
*
* @param key
* The flag key
*
*
* @param callback
* Will be called with the resulting flag.
*/
get: (key: string, callback: (res: LDFlagValue) => void) => void
get: (key: string, callback: (res: LDFlagValue) => void) => void;

/**
* Get all flags.
*
*
* @param callback
* Will be called with the resulting flag set.
*/
all: (callback: (err: any, res: LDFlagSet) => void) => void
all: (callback: (err: any, res: LDFlagSet) => void) => void;

/**
* Initialize the store.
*
*
* @param flags
* Populate the store with an initial flag set.
*
*
* @param callback
* Will be called when the store has been initialized.
*/
init: (flags: LDFlagSet, callback?: () => void) => void
init: (flags: LDFlagSet, callback?: () => void) => void;

/**
* Delete a key from the store.
*
*
* @param key
* The flag key.
*
*
* @param version
* The next version to increment the flag. The store should not update
* a newer version with an older version.
*
*
* @param callback
* Will be called when the delete operation is complete.
*/
delete: (key: string, version: string, callback?: () => void) => void
delete: (key: string, version: string, callback?: () => void) => void;

/**
* Upsert a flag to the store.
*
*
* @param key
* The flag key.
*
*
* @param flag
* The feature flag for the corresponding key.
*
*
* @param callback
* Will be called after the upsert operation is complete.
*/
upsert: (key: string, flag: LDFlag, callback?: () => void) => void
upsert: (key: string, flag: LDFlag, callback?: () => void) => void;

/**
* Is the store initialized?
*
*
* @param callback
* Will be called when the store is initialized.
*
*
* @returns
* Truthy if the cache is already initialized.
*
*
*/
initialized: (callback?: (err) => void) => bool
initialized: (callback?: (err) => void) => bool;

/**
* Close the feature store.
*
*
* @returns
* The store instance.
*/
close: () => LDFeatureStore
close: () => LDFeatureStore;
}

/**
Expand Down Expand Up @@ -366,7 +365,7 @@ declare module 'ldclient-node' {
/**
*
* The secure_mode_hash method computes an HMAC signature of a user signed with the client's SDK key.
*
*
* If you're using our JavaScript SDK for client-side flags, this
* method generates the signature you need for secure mode.
*
Expand All @@ -383,7 +382,7 @@ declare module 'ldclient-node' {


/**
*
*
* @returns Whether the client is configured in offline mode.
*/
is_offline: () => boolean;
Expand Down Expand Up @@ -419,14 +418,11 @@ declare module 'ldclient-node' {

/**
* Flush the queue
*
*
* Internally, the LaunchDarkly SDK keeps an event queue for track and identify calls.
* These are flushed periodically (see configuration option: flush_interval)
* and when the queue size limit (see configuration option: capacity) is reached.
*/
flush: (callback:(err: any, res: boolean) => void) => void;
flush: (callback: (err: any, res: boolean) => void) => void;
}


}