@launchdarkly/js-client-sdk-common 1.20.0 → 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 +18 -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/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/index.cjs +75 -40
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/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/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/index.d.ts +3 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.mjs +76 -42
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -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"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -222,6 +222,74 @@ function createAsyncTaskQueue(logger) {
|
|
|
222
222
|
};
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
+
function isCompoundValidator(v) {
|
|
226
|
+
return 'validate' in v;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Validates an options object against a map of validators and defaults.
|
|
230
|
+
*
|
|
231
|
+
* If `input` is null, undefined, or not an object the defaults are returned
|
|
232
|
+
* (with a warning for non-nullish non-objects).
|
|
233
|
+
*
|
|
234
|
+
* Supports special validator types created by:
|
|
235
|
+
* - {@link validatorOf}: recursively validates nested objects
|
|
236
|
+
* - {@link arrayOf}: validates arrays with per-item validation
|
|
237
|
+
* - {@link anyOf}: accepts the first matching validator from a list
|
|
238
|
+
* - {@link recordOf}: validates objects with dynamic keys
|
|
239
|
+
*/
|
|
240
|
+
function validateOptions(input, validatorMap, defaults, logger, prefix) {
|
|
241
|
+
const result = { ...defaults };
|
|
242
|
+
if (jsSdkCommon.isNullish(input)) {
|
|
243
|
+
return result;
|
|
244
|
+
}
|
|
245
|
+
if (!jsSdkCommon.TypeValidators.Object.is(input)) {
|
|
246
|
+
logger?.warn(jsSdkCommon.OptionMessages.wrongOptionType(prefix ?? 'config', 'object', typeof input));
|
|
247
|
+
return result;
|
|
248
|
+
}
|
|
249
|
+
Object.entries(input).forEach(([key, value]) => {
|
|
250
|
+
const validator = validatorMap[key];
|
|
251
|
+
const name = prefix ? `${prefix}.${key}` : key;
|
|
252
|
+
if (!validator) {
|
|
253
|
+
logger?.warn(jsSdkCommon.OptionMessages.unknownOption(name));
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
if (jsSdkCommon.isNullish(value)) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
if (isCompoundValidator(validator)) {
|
|
260
|
+
const validated = validator.validate(value, name, logger, defaults[key]);
|
|
261
|
+
if (validated !== undefined) {
|
|
262
|
+
result[key] = validated.value;
|
|
263
|
+
}
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
if (validator.is(value)) {
|
|
267
|
+
result[key] = value;
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
// Validation failed — apply correction or fall back to default.
|
|
271
|
+
const validatorType = validator.getType();
|
|
272
|
+
if (validatorType === 'boolean') {
|
|
273
|
+
logger?.warn(jsSdkCommon.OptionMessages.wrongOptionTypeBoolean(name, typeof value));
|
|
274
|
+
result[key] = !!value;
|
|
275
|
+
}
|
|
276
|
+
else if (validatorType === 'boolean | undefined | null') {
|
|
277
|
+
logger?.warn(jsSdkCommon.OptionMessages.wrongOptionTypeBoolean(name, typeof value));
|
|
278
|
+
if (typeof value !== 'boolean' && typeof value !== 'undefined' && value !== null) {
|
|
279
|
+
result[key] = !!value;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
else if (validator instanceof jsSdkCommon.NumberWithMinimum && jsSdkCommon.TypeValidators.Number.is(value)) {
|
|
283
|
+
logger?.warn(jsSdkCommon.OptionMessages.optionBelowMinimum(name, value, validator.min));
|
|
284
|
+
result[key] = validator.min;
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
logger?.warn(jsSdkCommon.OptionMessages.wrongOptionType(name, validatorType, typeof value));
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
return result;
|
|
291
|
+
}
|
|
292
|
+
|
|
225
293
|
// eslint-disable-next-line max-classes-per-file
|
|
226
294
|
const validators = {
|
|
227
295
|
logger: jsSdkCommon.TypeValidators.Object,
|
|
@@ -291,8 +359,12 @@ class ConfigurationImpl {
|
|
|
291
359
|
this.hooks = [];
|
|
292
360
|
this.inspectors = [];
|
|
293
361
|
this.logger = ensureSafeLogger(pristineOptions.logger);
|
|
294
|
-
const
|
|
295
|
-
|
|
362
|
+
const validated = validateOptions(pristineOptions, validators, {}, this.logger);
|
|
363
|
+
Object.entries(validated).forEach(([k, v]) => {
|
|
364
|
+
if (k !== 'logger') {
|
|
365
|
+
this[k] = v;
|
|
366
|
+
}
|
|
367
|
+
});
|
|
296
368
|
this.serviceEndpoints = new jsSdkCommon.ServiceEndpoints(this.streamUri, this.baseUri, this.eventsUri, internalOptions.analyticsEventPath, internalOptions.diagnosticEventPath, internalOptions.includeAuthorizationHeader, pristineOptions.payloadFilterKey);
|
|
297
369
|
this.useReport = pristineOptions.useReport ?? false;
|
|
298
370
|
this.tags = new jsSdkCommon.ApplicationTags({ application: this.applicationInfo, logger: this.logger });
|
|
@@ -301,44 +373,6 @@ class ConfigurationImpl {
|
|
|
301
373
|
this.credentialType = internalOptions.credentialType;
|
|
302
374
|
this.getImplementationHooks = internalOptions.getImplementationHooks;
|
|
303
375
|
}
|
|
304
|
-
_validateTypesAndNames(pristineOptions) {
|
|
305
|
-
const errors = [];
|
|
306
|
-
Object.entries(pristineOptions).forEach(([k, v]) => {
|
|
307
|
-
const validator = validators[k];
|
|
308
|
-
if (validator) {
|
|
309
|
-
if (!validator.is(v)) {
|
|
310
|
-
const validatorType = validator.getType();
|
|
311
|
-
if (validatorType === 'boolean') {
|
|
312
|
-
errors.push(jsSdkCommon.OptionMessages.wrongOptionTypeBoolean(k, typeof v));
|
|
313
|
-
this[k] = !!v;
|
|
314
|
-
}
|
|
315
|
-
else if (validatorType === 'boolean | undefined | null') {
|
|
316
|
-
errors.push(jsSdkCommon.OptionMessages.wrongOptionTypeBoolean(k, typeof v));
|
|
317
|
-
if (typeof v !== 'boolean' && typeof v !== 'undefined' && v !== null) {
|
|
318
|
-
this[k] = !!v;
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
else if (validator instanceof jsSdkCommon.NumberWithMinimum && jsSdkCommon.TypeValidators.Number.is(v)) {
|
|
322
|
-
const { min } = validator;
|
|
323
|
-
errors.push(jsSdkCommon.OptionMessages.optionBelowMinimum(k, v, min));
|
|
324
|
-
this[k] = min;
|
|
325
|
-
}
|
|
326
|
-
else {
|
|
327
|
-
errors.push(jsSdkCommon.OptionMessages.wrongOptionType(k, validator.getType(), typeof v));
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
else if (k === 'logger') ;
|
|
331
|
-
else {
|
|
332
|
-
// if an option is explicitly null, coerce to undefined
|
|
333
|
-
this[k] = v ?? undefined;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
else {
|
|
337
|
-
errors.push(jsSdkCommon.OptionMessages.unknownOption(k));
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
return errors;
|
|
341
|
-
}
|
|
342
376
|
}
|
|
343
377
|
|
|
344
378
|
async function digest(hasher, encoding) {
|
|
@@ -2552,6 +2586,7 @@ exports.makeRequestor = makeRequestor;
|
|
|
2552
2586
|
exports.mobileFdv1Endpoints = mobileFdv1Endpoints;
|
|
2553
2587
|
exports.readFlagsFromBootstrap = readFlagsFromBootstrap;
|
|
2554
2588
|
exports.safeRegisterDebugOverridePlugins = safeRegisterDebugOverridePlugins;
|
|
2589
|
+
exports.validateOptions = validateOptions;
|
|
2555
2590
|
Object.keys(jsSdkCommon).forEach(function (k) {
|
|
2556
2591
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
2557
2592
|
enumerable: true,
|