Skip to content

Commit a1f9344

Browse files
Add TS definitions for Configs SDK
AI-Session-Id: 87d19fcc-b2ce-4a99-8f24-ec04210abecb AI-Tool: claude-code AI-Model: unknown
1 parent 8ec6a80 commit a1f9344

1 file changed

Lines changed: 110 additions & 1 deletion

File tree

types/splitio.d.ts

Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ declare namespace SplitIO {
509509
/**
510510
* Metadata type for SDK update events.
511511
*/
512-
type SdkUpdateMetadataType = 'FLAGS_UPDATE' | 'SEGMENTS_UPDATE';
512+
type SdkUpdateMetadataType = 'CONFIGS_UPDATE' | 'FLAGS_UPDATE' | 'SEGMENTS_UPDATE';
513513

514514
/**
515515
* Metadata for the ready events emitted when the SDK is ready to evaluate feature flags.
@@ -2284,4 +2284,113 @@ declare namespace SplitIO {
22842284
*/
22852285
split(featureFlagName: string): SplitViewAsync;
22862286
}
2287+
2288+
/**
2289+
* Fallback configuration objects returned by the `client.getConfig` method when the SDK is not ready or the provided config name is not found.
2290+
*/
2291+
type FallbackConfigs = {
2292+
/**
2293+
* Fallback config for all config names.
2294+
*/
2295+
global?: Config;
2296+
/**
2297+
* Fallback configs for specific config names. It takes precedence over the global fallback config.
2298+
*/
2299+
byName?: {
2300+
[configName: string]: Config;
2301+
};
2302+
}
2303+
2304+
/**
2305+
* Configs SDK settings.
2306+
*/
2307+
interface ConfigsClientSettings {
2308+
/**
2309+
* Your SDK key.
2310+
*
2311+
* @see {@link https://developer.harness.io/docs/feature-management-experimentation/management-and-administration/account-settings/api-keys/}
2312+
*/
2313+
authorizationKey: string;
2314+
/**
2315+
* Configs definitions refresh rate for polling, in seconds.
2316+
*
2317+
* @defaultValue `60`
2318+
*/
2319+
configsRefreshRate?: number;
2320+
/**
2321+
* Logging level.
2322+
*
2323+
* @defaultValue `'NONE'`
2324+
*/
2325+
logLevel?: LogLevel;
2326+
/**
2327+
* Time in seconds until SDK ready timeout is emitted.
2328+
*
2329+
* @defaultValue `10`
2330+
*/
2331+
timeout?: number;
2332+
/**
2333+
* Custom endpoints to replace the default ones used by the SDK.
2334+
*/
2335+
urls?: UrlSettings;
2336+
/**
2337+
* Fallback configuration objects returned by the `client.getConfig` method when the SDK is not ready or the provided config name is not found.
2338+
*/
2339+
fallbackConfigs?: FallbackConfigs;
2340+
}
2341+
2342+
/**
2343+
* Target for a config evaluation.
2344+
*/
2345+
interface Target {
2346+
/**
2347+
* The key of the target.
2348+
*/
2349+
key: SplitKey;
2350+
/**
2351+
* The attributes of the target.
2352+
*
2353+
* @defaultValue `undefined`
2354+
*/
2355+
attributes?: Attributes;
2356+
}
2357+
2358+
type JsonValue = string | number | boolean | null | JsonObject | JsonArray;
2359+
type JsonArray = JsonValue[];
2360+
type JsonObject = { [key: string]: JsonValue; };
2361+
2362+
/**
2363+
* Config definition.
2364+
*/
2365+
interface Config {
2366+
/**
2367+
* The name of the variant.
2368+
*/
2369+
variant: string;
2370+
/**
2371+
* The config value, a raw JSON object.
2372+
*/
2373+
value: JsonObject;
2374+
}
2375+
2376+
/**
2377+
* Configs SDK client interface.
2378+
*/
2379+
interface ConfigsClient extends IStatusInterface {
2380+
/**
2381+
* Destroys the client.
2382+
*
2383+
* @returns A promise that resolves once all clients are destroyed.
2384+
*/
2385+
destroy(): Promise<void>;
2386+
/**
2387+
* Gets the config object for a given config name and optional target. If no target is provided, the default variant of the config is returned.
2388+
*
2389+
* @param name - The name of the config we want to get.
2390+
* @param target - The target of the config evaluation.
2391+
* @param options - An object of type EvaluationOptions for advanced evaluation options.
2392+
* @returns The config object.
2393+
*/
2394+
getConfig(name: string, target?: Target, options?: EvaluationOptions): Config;
2395+
}
22872396
}

0 commit comments

Comments
 (0)