@launchdarkly/js-client-sdk-common 1.19.1 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/dist/cjs/api/datasource/DataSourceEntry.d.ts +45 -0
- package/dist/cjs/api/datasource/DataSourceEntry.d.ts.map +1 -0
- package/dist/cjs/api/datasource/FDv2ConnectionMode.d.ts +30 -0
- package/dist/cjs/api/datasource/FDv2ConnectionMode.d.ts.map +1 -0
- package/dist/cjs/api/datasource/LDClientDataSystemOptions.d.ts +75 -0
- package/dist/cjs/api/datasource/LDClientDataSystemOptions.d.ts.map +1 -0
- package/dist/cjs/api/datasource/ModeDefinition.d.ts +21 -0
- package/dist/cjs/api/datasource/ModeDefinition.d.ts.map +1 -0
- package/dist/cjs/api/datasource/index.d.ts +5 -0
- package/dist/cjs/api/datasource/index.d.ts.map +1 -0
- package/dist/cjs/api/index.d.ts +1 -0
- package/dist/cjs/api/index.d.ts.map +1 -1
- package/dist/cjs/configuration/Configuration.d.ts +0 -1
- package/dist/cjs/configuration/Configuration.d.ts.map +1 -1
- package/dist/cjs/configuration/validateOptions.d.ts +95 -0
- package/dist/cjs/configuration/validateOptions.d.ts.map +1 -0
- package/dist/cjs/datasource/ConnectionModeConfig.d.ts +19 -0
- package/dist/cjs/datasource/ConnectionModeConfig.d.ts.map +1 -0
- package/dist/cjs/datasource/DataSourceConfig.d.ts +1 -0
- package/dist/cjs/datasource/DataSourceConfig.d.ts.map +1 -1
- package/dist/cjs/datasource/Endpoints.d.ts +21 -0
- package/dist/cjs/datasource/Endpoints.d.ts.map +1 -0
- package/dist/cjs/datasource/LDClientDataSystemOptions.d.ts +20 -0
- package/dist/cjs/datasource/LDClientDataSystemOptions.d.ts.map +1 -0
- package/dist/cjs/datasource/StateDebounceManager.d.ts +92 -0
- package/dist/cjs/datasource/StateDebounceManager.d.ts.map +1 -0
- package/dist/cjs/datasource/fdv2/AsyncQueue.d.ts +2 -0
- package/dist/cjs/datasource/fdv2/AsyncQueue.d.ts.map +1 -0
- package/dist/cjs/datasource/fdv2/Conditions.d.ts +73 -0
- package/dist/cjs/datasource/fdv2/Conditions.d.ts.map +1 -0
- package/dist/cjs/datasource/fdv2/FDv2DataSource.d.ts +52 -0
- package/dist/cjs/datasource/fdv2/FDv2DataSource.d.ts.map +1 -0
- package/dist/cjs/datasource/fdv2/FDv2Requestor.d.ts +45 -0
- package/dist/cjs/datasource/fdv2/FDv2Requestor.d.ts.map +1 -0
- package/dist/cjs/datasource/fdv2/FDv2SourceResult.d.ts +82 -0
- package/dist/cjs/datasource/fdv2/FDv2SourceResult.d.ts.map +1 -0
- package/dist/cjs/datasource/fdv2/Initializer.d.ts +40 -0
- package/dist/cjs/datasource/fdv2/Initializer.d.ts.map +1 -0
- package/dist/cjs/datasource/fdv2/PollingBase.d.ts +2 -0
- package/dist/cjs/datasource/fdv2/PollingBase.d.ts.map +1 -0
- package/dist/cjs/datasource/fdv2/PollingInitializer.d.ts +2 -0
- package/dist/cjs/datasource/fdv2/PollingInitializer.d.ts.map +1 -0
- package/dist/cjs/datasource/fdv2/PollingSynchronizer.d.ts +2 -0
- package/dist/cjs/datasource/fdv2/PollingSynchronizer.d.ts.map +1 -0
- package/dist/cjs/datasource/fdv2/SourceManager.d.ts +88 -0
- package/dist/cjs/datasource/fdv2/SourceManager.d.ts.map +1 -0
- package/dist/cjs/datasource/fdv2/StreamingFDv2Base.d.ts +11 -0
- package/dist/cjs/datasource/fdv2/StreamingFDv2Base.d.ts.map +1 -0
- package/dist/cjs/datasource/fdv2/StreamingInitializerFDv2.d.ts +2 -0
- package/dist/cjs/datasource/fdv2/StreamingInitializerFDv2.d.ts.map +1 -0
- package/dist/cjs/datasource/fdv2/StreamingSynchronizerFDv2.d.ts +2 -0
- package/dist/cjs/datasource/fdv2/StreamingSynchronizerFDv2.d.ts.map +1 -0
- package/dist/cjs/datasource/fdv2/Synchronizer.d.ts +49 -0
- package/dist/cjs/datasource/fdv2/Synchronizer.d.ts.map +1 -0
- package/dist/cjs/datasource/fdv2/index.d.ts +16 -0
- package/dist/cjs/datasource/fdv2/index.d.ts.map +1 -0
- package/dist/cjs/datasource/flagEvalMapper.d.ts +31 -0
- package/dist/cjs/datasource/flagEvalMapper.d.ts.map +1 -0
- package/dist/cjs/index.cjs +187 -40
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/types/index.d.ts +15 -0
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/esm/api/datasource/DataSourceEntry.d.ts +45 -0
- package/dist/esm/api/datasource/DataSourceEntry.d.ts.map +1 -0
- package/dist/esm/api/datasource/FDv2ConnectionMode.d.ts +30 -0
- package/dist/esm/api/datasource/FDv2ConnectionMode.d.ts.map +1 -0
- package/dist/esm/api/datasource/LDClientDataSystemOptions.d.ts +75 -0
- package/dist/esm/api/datasource/LDClientDataSystemOptions.d.ts.map +1 -0
- package/dist/esm/api/datasource/ModeDefinition.d.ts +21 -0
- package/dist/esm/api/datasource/ModeDefinition.d.ts.map +1 -0
- package/dist/esm/api/datasource/index.d.ts +5 -0
- package/dist/esm/api/datasource/index.d.ts.map +1 -0
- package/dist/esm/api/index.d.ts +1 -0
- package/dist/esm/api/index.d.ts.map +1 -1
- package/dist/esm/configuration/Configuration.d.ts +0 -1
- package/dist/esm/configuration/Configuration.d.ts.map +1 -1
- package/dist/esm/configuration/validateOptions.d.ts +95 -0
- package/dist/esm/configuration/validateOptions.d.ts.map +1 -0
- package/dist/esm/datasource/ConnectionModeConfig.d.ts +19 -0
- package/dist/esm/datasource/ConnectionModeConfig.d.ts.map +1 -0
- package/dist/esm/datasource/DataSourceConfig.d.ts +1 -0
- package/dist/esm/datasource/DataSourceConfig.d.ts.map +1 -1
- package/dist/esm/datasource/Endpoints.d.ts +21 -0
- package/dist/esm/datasource/Endpoints.d.ts.map +1 -0
- package/dist/esm/datasource/LDClientDataSystemOptions.d.ts +20 -0
- package/dist/esm/datasource/LDClientDataSystemOptions.d.ts.map +1 -0
- package/dist/esm/datasource/StateDebounceManager.d.ts +92 -0
- package/dist/esm/datasource/StateDebounceManager.d.ts.map +1 -0
- package/dist/esm/datasource/fdv2/AsyncQueue.d.ts +2 -0
- package/dist/esm/datasource/fdv2/AsyncQueue.d.ts.map +1 -0
- package/dist/esm/datasource/fdv2/Conditions.d.ts +73 -0
- package/dist/esm/datasource/fdv2/Conditions.d.ts.map +1 -0
- package/dist/esm/datasource/fdv2/FDv2DataSource.d.ts +52 -0
- package/dist/esm/datasource/fdv2/FDv2DataSource.d.ts.map +1 -0
- package/dist/esm/datasource/fdv2/FDv2Requestor.d.ts +45 -0
- package/dist/esm/datasource/fdv2/FDv2Requestor.d.ts.map +1 -0
- package/dist/esm/datasource/fdv2/FDv2SourceResult.d.ts +82 -0
- package/dist/esm/datasource/fdv2/FDv2SourceResult.d.ts.map +1 -0
- package/dist/esm/datasource/fdv2/Initializer.d.ts +40 -0
- package/dist/esm/datasource/fdv2/Initializer.d.ts.map +1 -0
- package/dist/esm/datasource/fdv2/PollingBase.d.ts +2 -0
- package/dist/esm/datasource/fdv2/PollingBase.d.ts.map +1 -0
- package/dist/esm/datasource/fdv2/PollingInitializer.d.ts +2 -0
- package/dist/esm/datasource/fdv2/PollingInitializer.d.ts.map +1 -0
- package/dist/esm/datasource/fdv2/PollingSynchronizer.d.ts +2 -0
- package/dist/esm/datasource/fdv2/PollingSynchronizer.d.ts.map +1 -0
- package/dist/esm/datasource/fdv2/SourceManager.d.ts +88 -0
- package/dist/esm/datasource/fdv2/SourceManager.d.ts.map +1 -0
- package/dist/esm/datasource/fdv2/StreamingFDv2Base.d.ts +11 -0
- package/dist/esm/datasource/fdv2/StreamingFDv2Base.d.ts.map +1 -0
- package/dist/esm/datasource/fdv2/StreamingInitializerFDv2.d.ts +2 -0
- package/dist/esm/datasource/fdv2/StreamingInitializerFDv2.d.ts.map +1 -0
- package/dist/esm/datasource/fdv2/StreamingSynchronizerFDv2.d.ts +2 -0
- package/dist/esm/datasource/fdv2/StreamingSynchronizerFDv2.d.ts.map +1 -0
- package/dist/esm/datasource/fdv2/Synchronizer.d.ts +49 -0
- package/dist/esm/datasource/fdv2/Synchronizer.d.ts.map +1 -0
- package/dist/esm/datasource/fdv2/index.d.ts +16 -0
- package/dist/esm/datasource/fdv2/index.d.ts.map +1 -0
- package/dist/esm/datasource/flagEvalMapper.d.ts +31 -0
- package/dist/esm/datasource/flagEvalMapper.d.ts.map +1 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.mjs +185 -42
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/types/index.d.ts +15 -0
- package/dist/esm/types/index.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { FDv2SourceResult } from './FDv2SourceResult';
|
|
2
|
+
export declare const DEFAULT_FALLBACK_TIMEOUT_MS: number;
|
|
3
|
+
export declare const DEFAULT_RECOVERY_TIMEOUT_MS: number;
|
|
4
|
+
/**
|
|
5
|
+
* The type of condition that fired, determining the orchestrator's response.
|
|
6
|
+
* - `'fallback'`: move to the next available synchronizer
|
|
7
|
+
* - `'recovery'`: reset to the primary synchronizer
|
|
8
|
+
*/
|
|
9
|
+
export type ConditionType = 'fallback' | 'recovery';
|
|
10
|
+
/**
|
|
11
|
+
* A timed condition that races against `synchronizer.next()`. When the
|
|
12
|
+
* condition fires, it produces a {@link ConditionType} that the orchestration
|
|
13
|
+
* loop uses to decide what to do.
|
|
14
|
+
*/
|
|
15
|
+
export interface Condition {
|
|
16
|
+
/** Resolves when the condition fires. Created at construction time. */
|
|
17
|
+
readonly promise: Promise<ConditionType>;
|
|
18
|
+
/**
|
|
19
|
+
* Inform the condition about a synchronizer result. Some conditions use
|
|
20
|
+
* this to start or cancel their timers.
|
|
21
|
+
*/
|
|
22
|
+
inform(result: FDv2SourceResult): void;
|
|
23
|
+
/** Cancel any pending timers and clean up. */
|
|
24
|
+
close(): void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A group of conditions managed together. The group races all conditions
|
|
28
|
+
* and broadcasts results to all of them.
|
|
29
|
+
*/
|
|
30
|
+
export interface ConditionGroup {
|
|
31
|
+
/** Race all conditions. `undefined` if no conditions exist. */
|
|
32
|
+
readonly promise: Promise<ConditionType> | undefined;
|
|
33
|
+
/** Broadcast a result to all conditions. */
|
|
34
|
+
inform(result: FDv2SourceResult): void;
|
|
35
|
+
/** Close all conditions. */
|
|
36
|
+
close(): void;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Creates a fallback condition. The condition starts a timer when an
|
|
40
|
+
* `interrupted` status is received and cancels it when a `changeSet` is
|
|
41
|
+
* received. If the timer fires, the condition resolves with `'fallback'`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function createFallbackCondition(timeoutMs: number): Condition;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a recovery condition. The condition starts a timer immediately
|
|
46
|
+
* and resolves with `'recovery'` when it fires. It ignores all `inform()`
|
|
47
|
+
* calls.
|
|
48
|
+
*/
|
|
49
|
+
export declare function createRecoveryCondition(timeoutMs: number): Condition;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a group of conditions that are managed together.
|
|
52
|
+
*
|
|
53
|
+
* @param conditions The conditions to group.
|
|
54
|
+
*/
|
|
55
|
+
export declare function createConditionGroup(conditions: Condition[]): ConditionGroup;
|
|
56
|
+
/**
|
|
57
|
+
* Determines which conditions to create based on the synchronizer's position
|
|
58
|
+
* and availability.
|
|
59
|
+
*
|
|
60
|
+
* - If there is only one available synchronizer, no conditions are needed
|
|
61
|
+
* (there is nowhere to fall back to).
|
|
62
|
+
* - If the current synchronizer is the primary (first available), only a
|
|
63
|
+
* fallback condition is created.
|
|
64
|
+
* - If the current synchronizer is non-primary, both fallback and recovery
|
|
65
|
+
* conditions are created.
|
|
66
|
+
*
|
|
67
|
+
* @param availableSyncCount Number of available (non-blocked) synchronizers.
|
|
68
|
+
* @param isPrime Whether the current synchronizer is the primary.
|
|
69
|
+
* @param fallbackTimeoutMs Fallback condition timeout.
|
|
70
|
+
* @param recoveryTimeoutMs Recovery condition timeout.
|
|
71
|
+
*/
|
|
72
|
+
export declare function getConditions(availableSyncCount: number, isPrime: boolean, fallbackTimeoutMs?: number, recoveryTimeoutMs?: number): ConditionGroup;
|
|
73
|
+
//# sourceMappingURL=Conditions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Conditions.d.ts","sourceRoot":"","sources":["../../../src/datasource/fdv2/Conditions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,eAAO,MAAM,2BAA2B,QAAgB,CAAC;AACzD,eAAO,MAAM,2BAA2B,QAAgB,CAAC;AA2BzD;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,UAAU,CAAC;AAEpD;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,uEAAuE;IACvE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IAEzC;;;OAGG;IACH,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAEvC,8CAA8C;IAC9C,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,SAAS,CAAC;IAErD,4CAA4C;IAC5C,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAEvC,4BAA4B;IAC5B,KAAK,IAAI,IAAI,CAAC;CACf;AA4ED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAQpE;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAEpE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG,cAAc,CAY5E;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAC3B,kBAAkB,EAAE,MAAM,EAC1B,OAAO,EAAE,OAAO,EAChB,iBAAiB,GAAE,MAAoC,EACvD,iBAAiB,GAAE,MAAoC,GACtD,cAAc,CAahB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { internal, LDLogger } from '@launchdarkly/js-sdk-common';
|
|
2
|
+
import { DataSourceStatusManager } from '../DataSourceStatusManager';
|
|
3
|
+
import { InitializerFactory, SynchronizerSlot } from './SourceManager';
|
|
4
|
+
/**
|
|
5
|
+
* Callback invoked when the orchestrator produces a changeSet payload.
|
|
6
|
+
*/
|
|
7
|
+
export type DataCallback = (payload: internal.Payload) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Configuration for the {@link FDv2DataSource} orchestrator.
|
|
10
|
+
*/
|
|
11
|
+
export interface FDv2DataSourceConfig {
|
|
12
|
+
/** Ordered list of initializer factories. */
|
|
13
|
+
initializerFactories: InitializerFactory[];
|
|
14
|
+
/** Ordered list of synchronizer slots with state. */
|
|
15
|
+
synchronizerSlots: SynchronizerSlot[];
|
|
16
|
+
/** Callback to deliver payloads to the consuming layer. */
|
|
17
|
+
dataCallback: DataCallback;
|
|
18
|
+
/** Status manager for reporting data source state transitions. */
|
|
19
|
+
statusManager: DataSourceStatusManager;
|
|
20
|
+
/**
|
|
21
|
+
* Getter for the current selector (basis) string. The selector is managed
|
|
22
|
+
* externally by the consuming layer — the orchestrator reads it via this
|
|
23
|
+
* getter and passes it through to source factories.
|
|
24
|
+
*/
|
|
25
|
+
selectorGetter: () => string | undefined;
|
|
26
|
+
/** Optional logger. */
|
|
27
|
+
logger?: LDLogger;
|
|
28
|
+
/** Fallback condition timeout in ms (default 120s). */
|
|
29
|
+
fallbackTimeoutMs?: number;
|
|
30
|
+
/** Recovery condition timeout in ms (default 300s). */
|
|
31
|
+
recoveryTimeoutMs?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The FDv2 data source orchestrator. Coordinates initializers and
|
|
35
|
+
* synchronizers to provide a resilient flag data pipeline.
|
|
36
|
+
*/
|
|
37
|
+
export interface FDv2DataSource {
|
|
38
|
+
/**
|
|
39
|
+
* Start the orchestration loop. Returns a promise that resolves when
|
|
40
|
+
* initialization is complete (first basis data received or all initializers
|
|
41
|
+
* exhausted with data). The orchestration loop continues running in the
|
|
42
|
+
* background after the promise resolves, driving synchronizers.
|
|
43
|
+
*/
|
|
44
|
+
start(): Promise<void>;
|
|
45
|
+
/** Close the orchestrator. Stops all active sources. */
|
|
46
|
+
close(): void;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Creates an {@link FDv2DataSource} orchestrator.
|
|
50
|
+
*/
|
|
51
|
+
export declare function createFDv2DataSource(config: FDv2DataSourceConfig): FDv2DataSource;
|
|
52
|
+
//# sourceMappingURL=FDv2DataSource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FDv2DataSource.d.ts","sourceRoot":"","sources":["../../../src/datasource/fdv2/FDv2DataSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AASrE,OAAO,EAAuB,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAE5F;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,OAAO,KAAK,IAAI,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,6CAA6C;IAC7C,oBAAoB,EAAE,kBAAkB,EAAE,CAAC;IAE3C,qDAAqD;IACrD,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;IAEtC,2DAA2D;IAC3D,YAAY,EAAE,YAAY,CAAC;IAE3B,kEAAkE;IAClE,aAAa,EAAE,uBAAuB,CAAC;IAEvC;;;;OAIG;IACH,cAAc,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IAEzC,uBAAuB;IACvB,MAAM,CAAC,EAAE,QAAQ,CAAC;IAElB,uDAAuD;IACvD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,uDAAuD;IACvD,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB,wDAAwD;IACxD,KAAK,IAAI,IAAI,CAAC;CACf;AAMD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,cAAc,CA0QjF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Encoding, LDHeaders, Requests, ServiceEndpoints } from '@launchdarkly/js-sdk-common';
|
|
2
|
+
import { DataSourcePaths } from '../DataSourceConfig';
|
|
3
|
+
/**
|
|
4
|
+
* Response from an FDv2 poll request, providing access to status code,
|
|
5
|
+
* headers, and body.
|
|
6
|
+
*/
|
|
7
|
+
export interface FDv2PollResponse {
|
|
8
|
+
status: number;
|
|
9
|
+
headers: {
|
|
10
|
+
get(name: string): string | null;
|
|
11
|
+
};
|
|
12
|
+
body: string | null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Makes HTTP requests to FDv2 polling endpoints and returns full response
|
|
16
|
+
* information including status code and headers.
|
|
17
|
+
*/
|
|
18
|
+
export interface FDv2Requestor {
|
|
19
|
+
/**
|
|
20
|
+
* Perform a poll request.
|
|
21
|
+
*
|
|
22
|
+
* @param basis Optional opaque state string from the most recent
|
|
23
|
+
* `payload-transferred` event, enabling delta-based updates.
|
|
24
|
+
* @returns The full HTTP response.
|
|
25
|
+
*/
|
|
26
|
+
poll(basis?: string): Promise<FDv2PollResponse>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates an {@link FDv2Requestor} for client-side FDv2 polling.
|
|
30
|
+
*
|
|
31
|
+
* @param plainContextString The JSON-serialized evaluation context.
|
|
32
|
+
* @param serviceEndpoints Service endpoint configuration.
|
|
33
|
+
* @param paths FDv2 polling endpoint paths.
|
|
34
|
+
* @param requests Platform HTTP abstraction.
|
|
35
|
+
* @param encoding Platform encoding abstraction.
|
|
36
|
+
* @param baseHeaders Default HTTP headers (e.g. authorization).
|
|
37
|
+
* @param baseQueryParams Additional query parameters to include on every request.
|
|
38
|
+
* @param usePost If true, use POST with context in body instead of GET with
|
|
39
|
+
* context in URL path.
|
|
40
|
+
*/
|
|
41
|
+
export declare function makeFDv2Requestor(plainContextString: string, serviceEndpoints: ServiceEndpoints, paths: DataSourcePaths, requests: Requests, encoding: Encoding, baseHeaders?: LDHeaders, baseQueryParams?: {
|
|
42
|
+
key: string;
|
|
43
|
+
value: string;
|
|
44
|
+
}[], usePost?: boolean): FDv2Requestor;
|
|
45
|
+
//# sourceMappingURL=FDv2Requestor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FDv2Requestor.d.ts","sourceRoot":"","sources":["../../../src/datasource/fdv2/FDv2Requestor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAER,SAAS,EACT,QAAQ,EACR,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE;QAAE,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAC9C,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;OAMG;IACH,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACjD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAC/B,kBAAkB,EAAE,MAAM,EAC1B,gBAAgB,EAAE,gBAAgB,EAClC,KAAK,EAAE,eAAe,EACtB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,WAAW,CAAC,EAAE,SAAS,EACvB,eAAe,CAAC,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,EAClD,OAAO,CAAC,EAAE,OAAO,GAChB,aAAa,CA0Cf"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { internal } from '@launchdarkly/js-sdk-common';
|
|
2
|
+
import DataSourceStatusErrorInfo from '../DataSourceStatusErrorInfo';
|
|
3
|
+
/**
|
|
4
|
+
* Possible states for a status result from an FDv2 data source.
|
|
5
|
+
*
|
|
6
|
+
* - `interrupted`: Transient error; synchronizer will retry automatically.
|
|
7
|
+
* - `shutdown`: Graceful shutdown; no further results will be produced.
|
|
8
|
+
* - `terminal_error`: Unrecoverable error; no further results will be produced.
|
|
9
|
+
* - `goodbye`: Server-initiated disconnect; no further results will be produced.
|
|
10
|
+
*/
|
|
11
|
+
export type SourceState = 'interrupted' | 'shutdown' | 'terminal_error' | 'goodbye';
|
|
12
|
+
/**
|
|
13
|
+
* A change set result containing a processed FDv2 payload.
|
|
14
|
+
*/
|
|
15
|
+
export interface ChangeSetResult {
|
|
16
|
+
type: 'changeSet';
|
|
17
|
+
payload: internal.Payload;
|
|
18
|
+
fdv1Fallback: boolean;
|
|
19
|
+
environmentId?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A status result indicating a state transition (error, shutdown, goodbye).
|
|
23
|
+
*/
|
|
24
|
+
export interface StatusResult {
|
|
25
|
+
type: 'status';
|
|
26
|
+
state: SourceState;
|
|
27
|
+
errorInfo?: DataSourceStatusErrorInfo;
|
|
28
|
+
reason?: string;
|
|
29
|
+
fdv1Fallback: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The result type for FDv2 initializers and synchronizers.
|
|
33
|
+
*
|
|
34
|
+
* An initializer produces a single result, while a synchronizer produces a
|
|
35
|
+
* stream of results. Each result is either a change set (containing a payload
|
|
36
|
+
* of flag data) or a status (indicating a state transition like an error or
|
|
37
|
+
* shutdown).
|
|
38
|
+
*/
|
|
39
|
+
export type FDv2SourceResult = ChangeSetResult | StatusResult;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a change set result containing processed flag data.
|
|
42
|
+
*/
|
|
43
|
+
export declare function changeSet(payload: internal.Payload, fdv1Fallback: boolean, environmentId?: string): FDv2SourceResult;
|
|
44
|
+
/**
|
|
45
|
+
* Creates an interrupted status result. Indicates a transient error; the
|
|
46
|
+
* synchronizer will attempt to recover automatically.
|
|
47
|
+
*
|
|
48
|
+
* When used with an initializer, this is still a terminal state.
|
|
49
|
+
*/
|
|
50
|
+
export declare function interrupted(errorInfo: DataSourceStatusErrorInfo, fdv1Fallback: boolean): FDv2SourceResult;
|
|
51
|
+
/**
|
|
52
|
+
* Creates a shutdown status result. Indicates the data source was closed
|
|
53
|
+
* gracefully and will not produce any further results.
|
|
54
|
+
*/
|
|
55
|
+
export declare function shutdown(): FDv2SourceResult;
|
|
56
|
+
/**
|
|
57
|
+
* Creates a terminal error status result. Indicates an unrecoverable error;
|
|
58
|
+
* the data source will not produce any further results.
|
|
59
|
+
*/
|
|
60
|
+
export declare function terminalError(errorInfo: DataSourceStatusErrorInfo, fdv1Fallback: boolean): FDv2SourceResult;
|
|
61
|
+
/**
|
|
62
|
+
* Creates a goodbye status result. Indicates the server has instructed the
|
|
63
|
+
* client to disconnect.
|
|
64
|
+
*/
|
|
65
|
+
export declare function goodbye(reason: string, fdv1Fallback: boolean): FDv2SourceResult;
|
|
66
|
+
/**
|
|
67
|
+
* Helper to create a {@link DataSourceStatusErrorInfo} from an HTTP status code.
|
|
68
|
+
*/
|
|
69
|
+
export declare function errorInfoFromHttpError(statusCode: number): DataSourceStatusErrorInfo;
|
|
70
|
+
/**
|
|
71
|
+
* Helper to create a {@link DataSourceStatusErrorInfo} from a network error.
|
|
72
|
+
*/
|
|
73
|
+
export declare function errorInfoFromNetworkError(message: string): DataSourceStatusErrorInfo;
|
|
74
|
+
/**
|
|
75
|
+
* Helper to create a {@link DataSourceStatusErrorInfo} from invalid data.
|
|
76
|
+
*/
|
|
77
|
+
export declare function errorInfoFromInvalidData(message: string): DataSourceStatusErrorInfo;
|
|
78
|
+
/**
|
|
79
|
+
* Helper to create a {@link DataSourceStatusErrorInfo} for unknown errors.
|
|
80
|
+
*/
|
|
81
|
+
export declare function errorInfoFromUnknown(message: string): DataSourceStatusErrorInfo;
|
|
82
|
+
//# sourceMappingURL=FDv2SourceResult.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FDv2SourceResult.d.ts","sourceRoot":"","sources":["../../../src/datasource/fdv2/FDv2SourceResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAE5E,OAAO,yBAAyB,MAAM,8BAA8B,CAAC;AAErE;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,UAAU,GAAG,gBAAgB,GAAG,SAAS,CAAC;AAEpF;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,WAAW,CAAC;IACnB,SAAS,CAAC,EAAE,yBAAyB,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG,eAAe,GAAG,YAAY,CAAC;AAE9D;;GAEG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,QAAQ,CAAC,OAAO,EACzB,YAAY,EAAE,OAAO,EACrB,aAAa,CAAC,EAAE,MAAM,GACrB,gBAAgB,CAElB;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,SAAS,EAAE,yBAAyB,EACpC,YAAY,EAAE,OAAO,GACpB,gBAAgB,CAElB;AAED;;;GAGG;AACH,wBAAgB,QAAQ,IAAI,gBAAgB,CAE3C;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,yBAAyB,EACpC,YAAY,EAAE,OAAO,GACpB,gBAAgB,CAElB;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,gBAAgB,CAE/E;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,yBAAyB,CAOpF;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,yBAAyB,CAMpF;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,yBAAyB,CAMnF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,yBAAyB,CAM/E"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { FDv2SourceResult } from './FDv2SourceResult';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for an asynchronous data source initializer.
|
|
4
|
+
*
|
|
5
|
+
* An initializer runs once and produces a single result. If successful, the
|
|
6
|
+
* result contains a change set with flag data. If it fails, the result
|
|
7
|
+
* contains a status describing the error.
|
|
8
|
+
*
|
|
9
|
+
* Once `run()` resolves, the initializer is complete and should not be
|
|
10
|
+
* called again. Use `close()` to cancel a pending run.
|
|
11
|
+
*
|
|
12
|
+
* ```
|
|
13
|
+
* [START]
|
|
14
|
+
* │
|
|
15
|
+
* ▼
|
|
16
|
+
* ┌─────────┐
|
|
17
|
+
* │ RUNNING │──┐
|
|
18
|
+
* └─────────┘ │
|
|
19
|
+
* │ │ │ │ └──► SHUTDOWN ──► [END]
|
|
20
|
+
* │ │ │ └─────► INTERRUPTED ──► [END]
|
|
21
|
+
* │ │ └────────► CHANGESET ──► [END]
|
|
22
|
+
* │ └───────────► TERMINAL_ERROR ──► [END]
|
|
23
|
+
* └──────────────► GOODBYE ──► [END]
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export interface Initializer {
|
|
27
|
+
/**
|
|
28
|
+
* Run the initializer to completion.
|
|
29
|
+
*
|
|
30
|
+
* This method is intended to be called only a single time for an instance.
|
|
31
|
+
* @returns The result of the initializer.
|
|
32
|
+
*/
|
|
33
|
+
run(): Promise<FDv2SourceResult>;
|
|
34
|
+
/**
|
|
35
|
+
* Close the initializer. If `run()` is in progress, it will resolve with
|
|
36
|
+
* a shutdown result.
|
|
37
|
+
*/
|
|
38
|
+
close(): void;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=Initializer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Initializer.d.ts","sourceRoot":"","sources":["../../../src/datasource/fdv2/Initializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;OAKG;IACH,GAAG,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAEjC;;;OAGG;IACH,KAAK,IAAI,IAAI,CAAC;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PollingBase.d.ts","sourceRoot":"","sources":["../../../src/datasource/fdv2/PollingBase.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PollingInitializer.d.ts","sourceRoot":"","sources":["../../../src/datasource/fdv2/PollingInitializer.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PollingSynchronizer.d.ts","sourceRoot":"","sources":["../../../src/datasource/fdv2/PollingSynchronizer.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Initializer } from './Initializer';
|
|
2
|
+
import { Synchronizer } from './Synchronizer';
|
|
3
|
+
/**
|
|
4
|
+
* Factory function that creates an {@link Initializer} instance.
|
|
5
|
+
*
|
|
6
|
+
* @param selectorGetter Returns the current selector (basis) string, or
|
|
7
|
+
* `undefined` if no selector is available.
|
|
8
|
+
*/
|
|
9
|
+
export type InitializerFactory = (selectorGetter: () => string | undefined) => Initializer;
|
|
10
|
+
/**
|
|
11
|
+
* Factory function that creates a {@link Synchronizer} instance.
|
|
12
|
+
*
|
|
13
|
+
* @param selectorGetter Returns the current selector (basis) string, or
|
|
14
|
+
* `undefined` if no selector is available.
|
|
15
|
+
*/
|
|
16
|
+
export type SynchronizerFactory = (selectorGetter: () => string | undefined) => Synchronizer;
|
|
17
|
+
/**
|
|
18
|
+
* State of a synchronizer slot.
|
|
19
|
+
* - `'available'`: can be selected for use.
|
|
20
|
+
* - `'blocked'`: has been blocked (e.g., terminal error or not yet activated).
|
|
21
|
+
*/
|
|
22
|
+
export type SynchronizerSlotState = 'available' | 'blocked';
|
|
23
|
+
/**
|
|
24
|
+
* A slot in the synchronizer list, wrapping a factory with state metadata.
|
|
25
|
+
*/
|
|
26
|
+
export interface SynchronizerSlot {
|
|
27
|
+
readonly factory: SynchronizerFactory;
|
|
28
|
+
readonly isFDv1Fallback: boolean;
|
|
29
|
+
state: SynchronizerSlotState;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Creates a {@link SynchronizerSlot}.
|
|
33
|
+
*
|
|
34
|
+
* @param factory The synchronizer factory function.
|
|
35
|
+
* @param options Optional configuration.
|
|
36
|
+
* @param options.isFDv1Fallback Whether this slot is the FDv1 fallback adapter.
|
|
37
|
+
* FDv1 slots start `'blocked'` by default.
|
|
38
|
+
* @param options.initialState Override the initial state (defaults to
|
|
39
|
+
* `'blocked'` for FDv1 slots, `'available'` otherwise).
|
|
40
|
+
*/
|
|
41
|
+
export declare function createSynchronizerSlot(factory: SynchronizerFactory, options?: {
|
|
42
|
+
isFDv1Fallback?: boolean;
|
|
43
|
+
initialState?: SynchronizerSlotState;
|
|
44
|
+
}): SynchronizerSlot;
|
|
45
|
+
/**
|
|
46
|
+
* Manages the state of initializers and synchronizers, tracks which source
|
|
47
|
+
* is active, and handles source transitions.
|
|
48
|
+
*/
|
|
49
|
+
export interface SourceManager {
|
|
50
|
+
/**
|
|
51
|
+
* Get the next initializer and set it as the active source.
|
|
52
|
+
* Closes the previous active source. Returns `undefined` when all
|
|
53
|
+
* initializers are exhausted.
|
|
54
|
+
*/
|
|
55
|
+
getNextInitializerAndSetActive(): Initializer | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Get the next available (non-blocked) synchronizer and set it as the
|
|
58
|
+
* active source. Closes the previous active source. Returns `undefined`
|
|
59
|
+
* when all available synchronizers have been visited.
|
|
60
|
+
*/
|
|
61
|
+
getNextAvailableSynchronizerAndSetActive(): Synchronizer | undefined;
|
|
62
|
+
/** Mark the current synchronizer as blocked (e.g., after terminal error). */
|
|
63
|
+
blockCurrentSynchronizer(): void;
|
|
64
|
+
/** Reset the synchronizer index to -1 so the next call starts from the beginning. */
|
|
65
|
+
resetSourceIndex(): void;
|
|
66
|
+
/** Block all non-FDv1 synchronizers and unblock FDv1 synchronizers. */
|
|
67
|
+
fdv1Fallback(): void;
|
|
68
|
+
/** True if the current synchronizer is the first available (primary). */
|
|
69
|
+
isPrimeSynchronizer(): boolean;
|
|
70
|
+
/** Count of synchronizers in `'available'` state. */
|
|
71
|
+
getAvailableSynchronizerCount(): number;
|
|
72
|
+
/** True if any synchronizer slot is marked as an FDv1 fallback. */
|
|
73
|
+
hasFDv1Fallback(): boolean;
|
|
74
|
+
/** Close the active source and mark the manager as shut down. */
|
|
75
|
+
close(): void;
|
|
76
|
+
/** True if {@link close} has been called. */
|
|
77
|
+
readonly isShutdown: boolean;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Creates a {@link SourceManager} that coordinates initializer and
|
|
81
|
+
* synchronizer lifecycle.
|
|
82
|
+
*
|
|
83
|
+
* @param initializerFactories Ordered list of initializer factories.
|
|
84
|
+
* @param synchronizerSlots Ordered list of synchronizer slots with state.
|
|
85
|
+
* @param selectorGetter Closure that returns the current selector string.
|
|
86
|
+
*/
|
|
87
|
+
export declare function createSourceManager(initializerFactories: InitializerFactory[], synchronizerSlots: SynchronizerSlot[], selectorGetter: () => string | undefined): SourceManager;
|
|
88
|
+
//# sourceMappingURL=SourceManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SourceManager.d.ts","sourceRoot":"","sources":["../../../src/datasource/fdv2/SourceManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,cAAc,EAAE,MAAM,MAAM,GAAG,SAAS,KAAK,WAAW,CAAC;AAE3F;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,cAAc,EAAE,MAAM,MAAM,GAAG,SAAS,KAAK,YAAY,CAAC;AAE7F;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG,WAAW,GAAG,SAAS,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;IACtC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,KAAK,EAAE,qBAAqB,CAAC;CAC9B;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,mBAAmB,EAC5B,OAAO,CAAC,EAAE;IACR,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,qBAAqB,CAAC;CACtC,GACA,gBAAgB,CAIlB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,8BAA8B,IAAI,WAAW,GAAG,SAAS,CAAC;IAE1D;;;;OAIG;IACH,wCAAwC,IAAI,YAAY,GAAG,SAAS,CAAC;IAErE,6EAA6E;IAC7E,wBAAwB,IAAI,IAAI,CAAC;IAEjC,qFAAqF;IACrF,gBAAgB,IAAI,IAAI,CAAC;IAEzB,uEAAuE;IACvE,YAAY,IAAI,IAAI,CAAC;IAErB,yEAAyE;IACzE,mBAAmB,IAAI,OAAO,CAAC;IAE/B,qDAAqD;IACrD,6BAA6B,IAAI,MAAM,CAAC;IAExC,mEAAmE;IACnE,eAAe,IAAI,OAAO,CAAC;IAE3B,iEAAiE;IACjE,KAAK,IAAI,IAAI,CAAC;IAEd,6CAA6C;IAC7C,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,oBAAoB,EAAE,kBAAkB,EAAE,EAC1C,iBAAiB,EAAE,gBAAgB,EAAE,EACrC,cAAc,EAAE,MAAM,MAAM,GAAG,SAAS,GACvC,aAAa,CAsGf"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FDv2SourceResult } from './FDv2SourceResult';
|
|
2
|
+
/**
|
|
3
|
+
* Handler invoked when a legacy `"ping"` event is received on the stream.
|
|
4
|
+
* The implementation should perform an FDv2 poll request (e.g. via
|
|
5
|
+
* {@link poll} from PollingBase) and return the processed result.
|
|
6
|
+
*/
|
|
7
|
+
export interface PingHandler {
|
|
8
|
+
/** Perform a poll and return the processed result. */
|
|
9
|
+
handlePing(): Promise<FDv2SourceResult>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=StreamingFDv2Base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StreamingFDv2Base.d.ts","sourceRoot":"","sources":["../../../src/datasource/fdv2/StreamingFDv2Base.ts"],"names":[],"mappings":"AAeA,OAAO,EAML,gBAAgB,EAKjB,MAAM,oBAAoB,CAAC;AAE5B;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,sDAAsD;IACtD,UAAU,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StreamingInitializerFDv2.d.ts","sourceRoot":"","sources":["../../../src/datasource/fdv2/StreamingInitializerFDv2.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StreamingSynchronizerFDv2.d.ts","sourceRoot":"","sources":["../../../src/datasource/fdv2/StreamingSynchronizerFDv2.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { FDv2SourceResult } from './FDv2SourceResult';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for an asynchronous data source synchronizer.
|
|
4
|
+
*
|
|
5
|
+
* A synchronizer runs continuously and produces a stream of results via
|
|
6
|
+
* successive calls to `next()`. When it experiences a temporary failure,
|
|
7
|
+
* it emits an INTERRUPTED result while attempting to recover. When it
|
|
8
|
+
* receives data, it emits a CHANGESET result. When shut down gracefully,
|
|
9
|
+
* it emits a SHUTDOWN result.
|
|
10
|
+
*
|
|
11
|
+
* `next()` is intended to be driven by a single caller, with one outstanding
|
|
12
|
+
* call at a time. Once SHUTDOWN or TERMINAL_ERROR has been produced, no
|
|
13
|
+
* further calls to `next()` should be made.
|
|
14
|
+
*
|
|
15
|
+
* ```
|
|
16
|
+
* [START]
|
|
17
|
+
* │
|
|
18
|
+
* ▼
|
|
19
|
+
* ┌─────────┐
|
|
20
|
+
* ┌─►│ RUNNING │──┐
|
|
21
|
+
* │ └─────────┘ │
|
|
22
|
+
* │ │ │ │ │ └──► SHUTDOWN ──────► [END]
|
|
23
|
+
* │ │ │ │ └─────► TERMINAL_ERROR ► [END]
|
|
24
|
+
* │ │ │ └────────► GOODBYE ───────┐
|
|
25
|
+
* │ │ └───────────► CHANGESET ─────┤
|
|
26
|
+
* │ └──────────────► INTERRUPTED ───┤
|
|
27
|
+
* └───────────────────────────────────┘
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export interface Synchronizer {
|
|
31
|
+
/**
|
|
32
|
+
* Get the next result from the stream.
|
|
33
|
+
*
|
|
34
|
+
* This method is intended to be driven by a single caller, and for there
|
|
35
|
+
* to be a single outstanding call at any given time.
|
|
36
|
+
*
|
|
37
|
+
* Once SHUTDOWN or TERMINAL_ERROR has been produced, no further calls to
|
|
38
|
+
* `next()` should be made.
|
|
39
|
+
*
|
|
40
|
+
* @returns A promise that resolves when the next result is available.
|
|
41
|
+
*/
|
|
42
|
+
next(): Promise<FDv2SourceResult>;
|
|
43
|
+
/**
|
|
44
|
+
* Close the synchronizer. The next call to `next()` will resolve with a
|
|
45
|
+
* shutdown result.
|
|
46
|
+
*/
|
|
47
|
+
close(): void;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=Synchronizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Synchronizer.d.ts","sourceRoot":"","sources":["../../../src/datasource/fdv2/Synchronizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;;;;;OAUG;IACH,IAAI,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAElC;;;OAGG;IACH,KAAK,IAAI,IAAI,CAAC;CACf"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type { AsyncQueue } from './AsyncQueue';
|
|
2
|
+
export { createAsyncQueue } from './AsyncQueue';
|
|
3
|
+
export type { FDv2PollResponse, FDv2Requestor } from './FDv2Requestor';
|
|
4
|
+
export { makeFDv2Requestor } from './FDv2Requestor';
|
|
5
|
+
export type { ChangeSetResult, FDv2SourceResult, SourceState, StatusResult, } from './FDv2SourceResult';
|
|
6
|
+
export { changeSet, errorInfoFromHttpError, errorInfoFromInvalidData, errorInfoFromNetworkError, errorInfoFromUnknown, goodbye, interrupted, shutdown, terminalError, } from './FDv2SourceResult';
|
|
7
|
+
export type { Initializer } from './Initializer';
|
|
8
|
+
export type { Synchronizer } from './Synchronizer';
|
|
9
|
+
export { poll } from './PollingBase';
|
|
10
|
+
export { createPollingInitializer } from './PollingInitializer';
|
|
11
|
+
export { createPollingSynchronizer } from './PollingSynchronizer';
|
|
12
|
+
export type { PingHandler, StreamingFDv2Base } from './StreamingFDv2Base';
|
|
13
|
+
export { createStreamingBase } from './StreamingFDv2Base';
|
|
14
|
+
export { createStreamingInitializer } from './StreamingInitializerFDv2';
|
|
15
|
+
export { createStreamingSynchronizer } from './StreamingSynchronizerFDv2';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/datasource/fdv2/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,SAAS,EACT,sBAAsB,EACtB,wBAAwB,EACxB,yBAAyB,EACzB,oBAAoB,EACpB,OAAO,EACP,WAAW,EACX,QAAQ,EACR,aAAa,GACd,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { internal } from '@launchdarkly/js-sdk-common';
|
|
2
|
+
import { ItemDescriptor } from '../flag-manager/ItemDescriptor';
|
|
3
|
+
import { FlagEvaluationResult } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* ObjProcessor for the `flagEval` object kind. Used by the protocol handler to
|
|
6
|
+
* process objects received in `put-object` events.
|
|
7
|
+
*
|
|
8
|
+
* Client-side evaluation results are already in their final form (pre-evaluated
|
|
9
|
+
* by the server), so no transformation is needed — this is a passthrough.
|
|
10
|
+
*/
|
|
11
|
+
export declare function processFlagEval(object: unknown): FlagEvaluationResult;
|
|
12
|
+
/**
|
|
13
|
+
* Converts an FDv2 {@link internal.Update} with `kind: 'flagEval'` into an
|
|
14
|
+
* {@link ItemDescriptor} suitable for {@link FlagManager}.
|
|
15
|
+
*
|
|
16
|
+
* For put updates the envelope `version` is used as the {@link ItemDescriptor.version}
|
|
17
|
+
* and as {@link Flag.version}. The rest of the fields are spread from the
|
|
18
|
+
* {@link FlagEvaluationResult} object.
|
|
19
|
+
*
|
|
20
|
+
* For delete updates a tombstone descriptor is created with `deleted: true`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function flagEvalUpdateToItemDescriptor(update: internal.Update): ItemDescriptor;
|
|
23
|
+
/**
|
|
24
|
+
* Converts an array of FDv2 payload updates into a map of flag key to
|
|
25
|
+
* {@link ItemDescriptor}. Only `flagEval` kind updates are processed;
|
|
26
|
+
* unrecognized kinds are silently ignored.
|
|
27
|
+
*/
|
|
28
|
+
export declare function flagEvalPayloadToItemDescriptors(updates: internal.Update[]): {
|
|
29
|
+
[key: string]: ItemDescriptor;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=flagEvalMapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flagEvalMapper.d.ts","sourceRoot":"","sources":["../../src/datasource/flagEvalMapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,oBAAoB,CAErE;AAED;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,GAAG,cAAc,CAqBtF;AAED;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,EAAE,GAAG;IAC5E,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAC;CAC/B,CAUA"}
|