@launchdarkly/js-sdk-common 2.18.0 → 2.20.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 +14 -0
- package/dist/cjs/api/platform/Requests.d.ts +1 -0
- package/dist/cjs/api/platform/Requests.d.ts.map +1 -1
- package/dist/cjs/api/subsystem/DataSystem/CallbackHandler.d.ts.map +1 -1
- package/dist/cjs/api/subsystem/DataSystem/DataSource.d.ts +17 -1
- package/dist/cjs/api/subsystem/DataSystem/DataSource.d.ts.map +1 -1
- package/dist/cjs/datasource/CompositeDataSource.d.ts +7 -2
- package/dist/cjs/datasource/CompositeDataSource.d.ts.map +1 -1
- package/dist/cjs/datasource/errors.d.ts +9 -0
- package/dist/cjs/datasource/errors.d.ts.map +1 -1
- package/dist/cjs/datasource/index.d.ts +2 -2
- package/dist/cjs/datasource/index.d.ts.map +1 -1
- package/dist/cjs/index.cjs +141 -40
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/internal/fdv2/FDv1PayloadAdaptor.d.ts +43 -0
- package/dist/cjs/internal/fdv2/FDv1PayloadAdaptor.d.ts.map +1 -0
- package/dist/cjs/internal/fdv2/index.d.ts +2 -1
- package/dist/cjs/internal/fdv2/index.d.ts.map +1 -1
- package/dist/cjs/internal/fdv2/payloadProcessor.d.ts.map +1 -1
- package/dist/cjs/internal/fdv2/proto.d.ts +18 -6
- package/dist/cjs/internal/fdv2/proto.d.ts.map +1 -1
- package/dist/cjs/options/ServiceEndpoints.d.ts +2 -2
- package/dist/cjs/options/ServiceEndpoints.d.ts.map +1 -1
- package/dist/esm/api/platform/Requests.d.ts +1 -0
- package/dist/esm/api/platform/Requests.d.ts.map +1 -1
- package/dist/esm/api/subsystem/DataSystem/CallbackHandler.d.ts.map +1 -1
- package/dist/esm/api/subsystem/DataSystem/DataSource.d.ts +17 -1
- package/dist/esm/api/subsystem/DataSystem/DataSource.d.ts.map +1 -1
- package/dist/esm/datasource/CompositeDataSource.d.ts +7 -2
- package/dist/esm/datasource/CompositeDataSource.d.ts.map +1 -1
- package/dist/esm/datasource/errors.d.ts +9 -0
- package/dist/esm/datasource/errors.d.ts.map +1 -1
- package/dist/esm/datasource/index.d.ts +2 -2
- package/dist/esm/datasource/index.d.ts.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.mjs +141 -41
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/internal/fdv2/FDv1PayloadAdaptor.d.ts +43 -0
- package/dist/esm/internal/fdv2/FDv1PayloadAdaptor.d.ts.map +1 -0
- package/dist/esm/internal/fdv2/index.d.ts +2 -1
- package/dist/esm/internal/fdv2/index.d.ts.map +1 -1
- package/dist/esm/internal/fdv2/payloadProcessor.d.ts.map +1 -1
- package/dist/esm/internal/fdv2/proto.d.ts +18 -6
- package/dist/esm/internal/fdv2/proto.d.ts.map +1 -1
- package/dist/esm/options/ServiceEndpoints.d.ts +2 -2
- package/dist/esm/options/ServiceEndpoints.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -40,7 +40,7 @@ export declare function getStreamingUri(endpoints: ServiceEndpoints, path: strin
|
|
|
40
40
|
* @param path The path to the resource, devoid of any query parameters or hrefs.
|
|
41
41
|
* @param parameters The query parameters. These query parameters must already have the appropriate encoding applied. This function WILL NOT apply it for you.
|
|
42
42
|
*/
|
|
43
|
-
export declare function getPollingUri(endpoints: ServiceEndpoints, path: string, parameters
|
|
43
|
+
export declare function getPollingUri(endpoints: ServiceEndpoints, path: string, parameters?: {
|
|
44
44
|
key: string;
|
|
45
45
|
value: string;
|
|
46
46
|
}[]): string;
|
|
@@ -51,7 +51,7 @@ export declare function getPollingUri(endpoints: ServiceEndpoints, path: string,
|
|
|
51
51
|
* @param path The path to the resource, devoid of any query parameters or hrefs.
|
|
52
52
|
* @param parameters The query parameters. These query parameters must already have the appropriate encoding applied. This function WILL NOT apply it for you.
|
|
53
53
|
*/
|
|
54
|
-
export declare function getEventsUri(endpoints: ServiceEndpoints, path: string, parameters
|
|
54
|
+
export declare function getEventsUri(endpoints: ServiceEndpoints, path: string, parameters?: {
|
|
55
55
|
key: string;
|
|
56
56
|
value: string;
|
|
57
57
|
}[]): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceEndpoints.d.ts","sourceRoot":"","sources":["../../src/options/ServiceEndpoints.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAgB;IAEnC,OAAc,cAAc,SAAqC;IAEjE,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,OAAO,EAAE,MAAM,CAAC;IAChC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1C;;;;OAIG;IACH,SAAgB,kBAAkB,EAAE,MAAM,CAAC;IAE3C;;;;OAIG;IACH,SAAgB,mBAAmB,EAAE,MAAM,CAAC;IAG5C,SAAgB,0BAA0B,EAAE,OAAO,CAAC;gBAGlD,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,MAAM,GAAE,MAAwC,EAChD,kBAAkB,GAAE,MAAgB,EACpC,mBAAmB,GAAE,MAAsB,EAC3C,0BAA0B,GAAE,OAAc,EAC1C,gBAAgB,CAAC,EAAE,MAAM;CAU5B;AAWD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,gBAAgB,EAC3B,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,GAC3C,MAAM,CASR;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,gBAAgB,EAC3B,IAAI,EAAE,MAAM,EACZ,UAAU,
|
|
1
|
+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,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAExB;;OAEG;IACH,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;CACtB;AAED,MAAM,WAAW,OAAO;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,uBAAuB;IACtC;;;;;;;;;OASG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,YAAY,EAAE,OAAO,CAAC;IAEtB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,QAAQ;IACvB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEzD,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,GAAG,WAAW,CAAC;IAEtF,0BAA0B,IAAI,uBAAuB,CAAC;IAEtD;;OAEG;IACH,UAAU,CAAC,IAAI,OAAO,CAAC;IAEvB;;OAEG;IACH,cAAc,CAAC,IAAI,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CallbackHandler.d.ts","sourceRoot":"","sources":["../../../../src/api/subsystem/DataSystem/CallbackHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C;;;;GAIG;AACH,qBAAa,eAAe;IAIxB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAJlC,OAAO,CAAC,SAAS,CAAkB;gBAGhB,aAAa,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,EAClD,eAAe,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,CAAC,EAAE,GAAG,KAAK,IAAI;IAGhF,OAAO;IAID,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG;
|
|
1
|
+
{"version":3,"file":"CallbackHandler.d.ts","sourceRoot":"","sources":["../../../../src/api/subsystem/DataSystem/CallbackHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C;;;;GAIG;AACH,qBAAa,eAAe;IAIxB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAJlC,OAAO,CAAC,SAAS,CAAkB;gBAGhB,aAAa,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,EAClD,eAAe,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,CAAC,EAAE,GAAG,KAAK,IAAI;IAGhF,OAAO;IAID,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG;IAQrC,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,CAAC,EAAE,GAAG;CAOvD"}
|
|
@@ -1,21 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @experimental
|
|
3
|
+
* This feature is not stable and not subject to any backwards compatibility guarantees or semantic
|
|
4
|
+
* versioning. It is not suitable for production usage.
|
|
5
|
+
*/
|
|
1
6
|
export declare enum DataSourceState {
|
|
2
7
|
Valid = 0,
|
|
3
8
|
Initializing = 1,
|
|
4
9
|
Interrupted = 2,
|
|
5
10
|
Closed = 3
|
|
6
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* @experimental
|
|
14
|
+
* This feature is not stable and not subject to any backwards compatibility guarantees or semantic
|
|
15
|
+
* versioning. It is not suitable for production usage.
|
|
16
|
+
*/
|
|
7
17
|
export interface DataSource {
|
|
8
18
|
/**
|
|
9
19
|
* May be called any number of times, if already started, has no effect
|
|
10
20
|
* @param dataCallback that will be called when data arrives, may be called multiple times.
|
|
11
21
|
* @param statusCallback that will be called when data source state changes or an unrecoverable error
|
|
12
22
|
* has been encountered.
|
|
23
|
+
* @param selectorGetter that can be invoked to provide the FDv2 selector/basis if one exists
|
|
13
24
|
*/
|
|
14
|
-
start(dataCallback: (basis: boolean, data: any) => void, statusCallback: (status: DataSourceState, err?: any) => void): void;
|
|
25
|
+
start(dataCallback: (basis: boolean, data: any) => void, statusCallback: (status: DataSourceState, err?: any) => void, selectorGetter?: () => string | undefined): void;
|
|
15
26
|
/**
|
|
16
27
|
* May be called any number of times, if already stopped, has no effect. Datasource will not make any additional callbacks after stop returns.
|
|
17
28
|
*/
|
|
18
29
|
stop(): void;
|
|
19
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* @experimental
|
|
33
|
+
* This feature is not stable and not subject to any backwards compatibility guarantees or semantic
|
|
34
|
+
* versioning. It is not suitable for production usage.
|
|
35
|
+
*/
|
|
20
36
|
export type LDDataSourceFactory = () => DataSource;
|
|
21
37
|
//# sourceMappingURL=DataSource.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataSource.d.ts","sourceRoot":"","sources":["../../../../src/api/subsystem/DataSystem/DataSource.ts"],"names":[],"mappings":"AACA,oBAAY,eAAe;IAEzB,KAAK,IAAA;IAEL,YAAY,IAAA;IAEZ,WAAW,IAAA;IAEX,MAAM,IAAA;CACP;AAED,MAAM,WAAW,UAAU;IACzB
|
|
1
|
+
{"version":3,"file":"DataSource.d.ts","sourceRoot":"","sources":["../../../../src/api/subsystem/DataSystem/DataSource.ts"],"names":[],"mappings":"AACA;;;;GAIG;AACH,oBAAY,eAAe;IAEzB,KAAK,IAAA;IAEL,YAAY,IAAA;IAEZ,WAAW,IAAA;IAEX,MAAM,IAAA;CACP;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;OAMG;IACH,KAAK,CACH,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,EACjD,cAAc,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,CAAC,EAAE,GAAG,KAAK,IAAI,EAC5D,cAAc,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,GACxC,IAAI,CAAC;IAER;;OAEG;IACH,IAAI,IAAI,IAAI,CAAC;CACd;AAED;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,UAAU,CAAC"}
|
|
@@ -25,6 +25,7 @@ export declare class CompositeDataSource implements DataSource {
|
|
|
25
25
|
private _initPhaseActive;
|
|
26
26
|
private _initFactories;
|
|
27
27
|
private _syncFactories;
|
|
28
|
+
private _fdv1Synchronizers;
|
|
28
29
|
private _stopped;
|
|
29
30
|
private _externalTransitionPromise;
|
|
30
31
|
private _externalTransitionResolve?;
|
|
@@ -32,9 +33,13 @@ export declare class CompositeDataSource implements DataSource {
|
|
|
32
33
|
/**
|
|
33
34
|
* @param initializers factories to create {@link DataSystemInitializer}s, in priority order.
|
|
34
35
|
* @param synchronizers factories to create {@link DataSystemSynchronizer}s, in priority order.
|
|
36
|
+
* @param fdv1Synchronizers factories to fallback to if we need to fallback to FDv1.
|
|
37
|
+
* @param _logger for logging
|
|
38
|
+
* @param _transitionConditions to control automated transition between datasources. Typically only used for testing.
|
|
39
|
+
* @param _backoff to control delay between transitions. Typically only used for testing.
|
|
35
40
|
*/
|
|
36
|
-
constructor(initializers: LDDataSourceFactory[], synchronizers: LDDataSourceFactory[], _logger?: LDLogger | undefined, _transitionConditions?: TransitionConditions, _backoff?: Backoff);
|
|
37
|
-
start(dataCallback: (basis: boolean, data: any) => void, statusCallback: (status: DataSourceState, err?: any) => void): Promise<void>;
|
|
41
|
+
constructor(initializers: LDDataSourceFactory[], synchronizers: LDDataSourceFactory[], fdv1Synchronizers: LDDataSourceFactory[], _logger?: LDLogger | undefined, _transitionConditions?: TransitionConditions, _backoff?: Backoff);
|
|
42
|
+
start(dataCallback: (basis: boolean, data: any) => void, statusCallback: (status: DataSourceState, err?: any) => void, selectorGetter?: () => string | undefined): Promise<void>;
|
|
38
43
|
stop(): Promise<void>;
|
|
39
44
|
private _reset;
|
|
40
45
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompositeDataSource.d.ts","sourceRoot":"","sources":["../../src/datasource/CompositeDataSource.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EACL,UAAU,EACV,eAAe,EACf,mBAAmB,EACpB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,OAAO,EAAkB,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"CompositeDataSource.d.ts","sourceRoot":"","sources":["../../src/datasource/CompositeDataSource.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EACL,UAAU,EACV,eAAe,EACf,mBAAmB,EACpB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,OAAO,EAAkB,MAAM,WAAW,CAAC;AAOpD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG,UAAU,GAAG,SAAS,GAAG,MAAM,CAAC;AAE1E;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;KAChC,CAAC,IAAI,eAAe,CAAC,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,U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olean;
|
|
15
15
|
constructor(kind: DataSourceErrorKind, message: string, code?: number, recoverable?: boolean);
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* This is a short term error and will be removed once FDv2 adoption is sufficient.
|
|
19
|
+
*/
|
|
20
|
+
export declare class LDFlagDeliveryFallbackError extends Error {
|
|
21
|
+
readonly kind: DataSourceErrorKind;
|
|
22
|
+
readonly code?: number;
|
|
23
|
+
readonly recoverable: boolean;
|
|
24
|
+
constructor(kind: DataSourceErrorKind, message: string, code?: number);
|
|
25
|
+
}
|
|
17
26
|
export type StreamingErrorHandler = (err: LDStreamingError) => void;
|
|
18
27
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/datasource/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,cAAe,SAAQ,KAAK;IACvC,SAAgB,IAAI,EAAE,mBAAmB,CAAC;IAC1C,SAAgB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChC,SAAgB,WAAW,EAAE,OAAO,CAAC;gBAEzB,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,WAAW,UAAO;CAO5F;AAED,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,SAAgB,IAAI,EAAE,mBAAmB,CAAC;IAC1C,SAAgB,IAAI,CAAC,EAAE,MAAM,CAAC;IAC9B,SAAgB,WAAW,EAAE,OAAO,CAAC;gBAEzB,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,WAAW,UAAO;CAO1F;AAED,MAAM,MAAM,qBAAqB,GAAG,CAAC,GAAG,EAAE,gBAAgB,KAAK,IAAI,CAAC"}
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/datasource/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,cAAe,SAAQ,KAAK;IACvC,SAAgB,IAAI,EAAE,mBAAmB,CAAC;IAC1C,SAAgB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChC,SAAgB,WAAW,EAAE,OAAO,CAAC;gBAEzB,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,WAAW,UAAO;CAO5F;AAED,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,SAAgB,IAAI,EAAE,mBAAmB,CAAC;IAC1C,SAAgB,IAAI,CAAC,EAAE,MAAM,CAAC;IAC9B,SAAgB,WAAW,EAAE,OAAO,CAAC;gBAEzB,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,WAAW,UAAO;CAO1F;AAED;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,SAAgB,IAAI,EAAE,mBAAmB,CAAC;IAC1C,SAAgB,IAAI,CAAC,EAAE,MAAM,CAAC;IAC9B,SAAgB,WAAW,EAAE,OAAO,CAAC;gBAEzB,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;CAOtE;AAED,MAAM,MAAM,qBAAqB,GAAG,CAAC,GAAG,EAAE,gBAAgB,KAAK,IAAI,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Backoff, DefaultBackoff } from './Backoff';
|
|
2
2
|
import { CompositeDataSource } from './CompositeDataSource';
|
|
3
3
|
import { DataSourceErrorKind } from './DataSourceErrorKinds';
|
|
4
|
-
import { LDFileDataSourceError, LDPollingError, LDStreamingError, StreamingErrorHandler } from './errors';
|
|
5
|
-
export { Backoff, CompositeDataSource, DefaultBackoff, DataSourceErrorKind, LDFileDataSourceError, LDPollingError, LDStreamingError, StreamingErrorHandler, };
|
|
4
|
+
import { LDFileDataSourceError, LDFlagDeliveryFallbackError, LDPollingError, LDStreamingError, StreamingErrorHandler } from './errors';
|
|
5
|
+
export { Backoff, CompositeDataSource, DefaultBackoff, DataSourceErrorKind, LDFileDataSourceError, LDFlagDeliveryFallbackError, LDPollingError, LDStreamingError, StreamingErrorHandler, };
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/datasource/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,gBAAgB,EAChB,qBAAqB,GACtB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/datasource/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EACL,qBAAqB,EACrB,2BAA2B,EAC3B,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,qBAAqB,EACrB,2BAA2B,EAC3B,cAAc,EACd,gBAAgB,EAChB,qBAAqB,GACtB,CAAC"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import AttributeReference from './AttributeReference';
|
|
2
2
|
import Context from './Context';
|
|
3
3
|
import ContextFilter from './ContextFilter';
|
|
4
|
-
import { Backoff, CompositeDataSource, DataSourceErrorKind, DefaultBackoff, LDFileDataSourceError, LDPollingError, LDStreamingError, StreamingErrorHandler } from './datasource';
|
|
4
|
+
import { Backoff, CompositeDataSource, DataSourceErrorKind, DefaultBackoff, LDFileDataSourceError, LDFlagDeliveryFallbackError, LDPollingError, LDStreamingError, StreamingErrorHandler } from './datasource';
|
|
5
5
|
export * from './api';
|
|
6
6
|
export * from './validators';
|
|
7
7
|
export * from './logging';
|
|
@@ -9,5 +9,5 @@ export * from './options';
|
|
|
9
9
|
export * from './utils';
|
|
10
10
|
export * as internal from './internal';
|
|
11
11
|
export * from './errors';
|
|
12
|
-
export { AttributeReference, Context, ContextFilter, CompositeDataSource, DataSourceErrorKind, Backoff, DefaultBackoff, LDPollingError, LDStreamingError, StreamingErrorHandler, LDFileDataSourceError, };
|
|
12
|
+
export { AttributeReference, Context, ContextFilter, CompositeDataSource, DataSourceErrorKind, Backoff, DefaultBackoff, LDPollingError, LDStreamingError, StreamingErrorHandler, LDFileDataSourceError, LDFlagDeliveryFallbackError, };
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAEtB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AAExB,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,cAAc,UAAU,CAAC;AAEzB,OAAO,EACL,kBAAkB,EAClB,OAAO,EACP,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,OAAO,EACP,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EACrB,2BAA2B,EAC3B,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAEtB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AAExB,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,cAAc,UAAU,CAAC;AAEzB,OAAO,EACL,kBAAkB,EAClB,OAAO,EACP,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,OAAO,EACP,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,2BAA2B,GAC5B,CAAC"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -949,8 +949,6 @@ class CallbackHandler {
|
|
|
949
949
|
if (this._disabled) {
|
|
950
950
|
return;
|
|
951
951
|
}
|
|
952
|
-
// TODO: SDK-1044 track selector for future synchronizer to use
|
|
953
|
-
// report data up
|
|
954
952
|
this._dataCallback(basis, data);
|
|
955
953
|
}
|
|
956
954
|
async statusHandler(status, err) {
|
|
@@ -962,6 +960,11 @@ class CallbackHandler {
|
|
|
962
960
|
}
|
|
963
961
|
|
|
964
962
|
// TODO: refactor client-sdk to use this enum
|
|
963
|
+
/**
|
|
964
|
+
* @experimental
|
|
965
|
+
* This feature is not stable and not subject to any backwards compatibility guarantees or semantic
|
|
966
|
+
* versioning. It is not suitable for production usage.
|
|
967
|
+
*/
|
|
965
968
|
var DataSourceState;
|
|
966
969
|
(function (DataSourceState) {
|
|
967
970
|
// Positive confirmation of connection/data receipt
|
|
@@ -1062,6 +1065,43 @@ class DataSourceList {
|
|
|
1062
1065
|
}
|
|
1063
1066
|
}
|
|
1064
1067
|
|
|
1068
|
+
class LDFileDataSourceError extends Error {
|
|
1069
|
+
constructor(message) {
|
|
1070
|
+
super(message);
|
|
1071
|
+
this.name = 'LaunchDarklyFileDataSourceError';
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
class LDPollingError extends Error {
|
|
1075
|
+
constructor(kind, message, status, recoverable = true) {
|
|
1076
|
+
super(message);
|
|
1077
|
+
this.kind = kind;
|
|
1078
|
+
this.status = status;
|
|
1079
|
+
this.name = 'LaunchDarklyPollingError';
|
|
1080
|
+
this.recoverable = recoverable;
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
class LDStreamingError extends Error {
|
|
1084
|
+
constructor(kind, message, code, recoverable = true) {
|
|
1085
|
+
super(message);
|
|
1086
|
+
this.kind = kind;
|
|
1087
|
+
this.code = code;
|
|
1088
|
+
this.name = 'LaunchDarklyStreamingError';
|
|
1089
|
+
this.recoverable = recoverable;
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
/**
|
|
1093
|
+
* This is a short term error and will be removed once FDv2 adoption is sufficient.
|
|
1094
|
+
*/
|
|
1095
|
+
class LDFlagDeliveryFallbackError extends Error {
|
|
1096
|
+
constructor(kind, message, code) {
|
|
1097
|
+
super(message);
|
|
1098
|
+
this.kind = kind;
|
|
1099
|
+
this.code = code;
|
|
1100
|
+
this.name = 'LDFlagDeliveryFallbackError';
|
|
1101
|
+
this.recoverable = false;
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1065
1105
|
const DEFAULT_FALLBACK_TIME_MS = 2 * 60 * 1000;
|
|
1066
1106
|
const DEFAULT_RECOVERY_TIME_MS = 5 * 60 * 1000;
|
|
1067
1107
|
/**
|
|
@@ -1072,8 +1112,12 @@ class CompositeDataSource {
|
|
|
1072
1112
|
/**
|
|
1073
1113
|
* @param initializers factories to create {@link DataSystemInitializer}s, in priority order.
|
|
1074
1114
|
* @param synchronizers factories to create {@link DataSystemSynchronizer}s, in priority order.
|
|
1115
|
+
* @param fdv1Synchronizers factories to fallback to if we need to fallback to FDv1.
|
|
1116
|
+
* @param _logger for logging
|
|
1117
|
+
* @param _transitionConditions to control automated transition between datasources. Typically only used for testing.
|
|
1118
|
+
* @param _backoff to control delay between transitions. Typically only used for testing.
|
|
1075
1119
|
*/
|
|
1076
|
-
constructor(initializers, synchronizers, _logger, _transitionConditions = {
|
|
1120
|
+
constructor(initializers, synchronizers, fdv1Synchronizers, _logger, _transitionConditions = {
|
|
1077
1121
|
[DataSourceState.Valid]: {
|
|
1078
1122
|
durationMS: DEFAULT_RECOVERY_TIME_MS,
|
|
1079
1123
|
transition: 'recover',
|
|
@@ -1109,8 +1153,9 @@ class CompositeDataSource {
|
|
|
1109
1153
|
this._initPhaseActive = initializers.length > 0; // init phase if we have initializers
|
|
1110
1154
|
this._initFactories = new DataSourceList(false, initializers);
|
|
1111
1155
|
this._syncFactories = new DataSourceList(true, synchronizers);
|
|
1156
|
+
this._fdv1Synchronizers = new DataSourceList(true, fdv1Synchronizers);
|
|
1112
1157
|
}
|
|
1113
|
-
async start(dataCallback, statusCallback) {
|
|
1158
|
+
async start(dataCallback, statusCallback, selectorGetter) {
|
|
1114
1159
|
if (!this._stopped) {
|
|
1115
1160
|
// don't allow multiple simultaneous runs
|
|
1116
1161
|
this._logger?.info('CompositeDataSource already running. Ignoring call to start.');
|
|
@@ -1147,12 +1192,18 @@ class CompositeDataSource {
|
|
|
1147
1192
|
// When we get a status update, we want to fallback if it is an error. We also want to schedule a transition for some
|
|
1148
1193
|
// time in the future if this status remains for some duration (ex: Recover to primary synchronizer after the secondary
|
|
1149
1194
|
// synchronizer has been Valid for some time). These scheduled transitions are configurable in the constructor.
|
|
1150
|
-
this._logger?.debug(`CompositeDataSource received state ${state} from underlying data source
|
|
1195
|
+
this._logger?.debug(`CompositeDataSource received state ${state} from underlying data source. Err is ${err}`);
|
|
1151
1196
|
if (err || state === DataSourceState.Closed) {
|
|
1152
1197
|
callbackHandler.disable();
|
|
1153
|
-
if (err
|
|
1198
|
+
if (err?.recoverable === false) {
|
|
1154
1199
|
// don't use this datasource's factory again
|
|
1200
|
+
this._logger?.debug(`Culling data source due to err ${err}`);
|
|
1155
1201
|
cullDSFactory?.();
|
|
1202
|
+
// this error indicates we should fallback to only using FDv1 synchronizers
|
|
1203
|
+
if (err instanceof LDFlagDeliveryFallbackError) {
|
|
1204
|
+
this._logger?.debug(`Falling back to FDv1`);
|
|
1205
|
+
this._syncFactories = this._fdv1Synchronizers;
|
|
1206
|
+
}
|
|
1156
1207
|
}
|
|
1157
1208
|
sanitizedStatusCallback(state, err);
|
|
1158
1209
|
this._consumeCancelToken(cancelScheduledTransition);
|
|
@@ -1179,7 +1230,7 @@ class CompositeDataSource {
|
|
|
1179
1230
|
}
|
|
1180
1231
|
}
|
|
1181
1232
|
});
|
|
1182
|
-
currentDS.start((basis, data) => callbackHandler.dataHandler(basis, data), (status, err) => callbackHandler.statusHandler(status, err));
|
|
1233
|
+
currentDS.start((basis, data) => callbackHandler.dataHandler(basis, data), (status, err) => callbackHandler.statusHandler(status, err), selectorGetter);
|
|
1183
1234
|
}
|
|
1184
1235
|
else {
|
|
1185
1236
|
// we don't have a data source to use!
|
|
@@ -1200,8 +1251,8 @@ class CompositeDataSource {
|
|
|
1200
1251
|
// stop the underlying datasource before transitioning to next state
|
|
1201
1252
|
currentDS?.stop();
|
|
1202
1253
|
if (transitionRequest.err && transitionRequest.transition !== 'stop') {
|
|
1203
|
-
// if the transition was due to an error, throttle the transition
|
|
1204
|
-
const delay = this._backoff.fail();
|
|
1254
|
+
// if the transition was due to an error we're not in the initializer phase, throttle the transition. Fallback between initializers is not throttled.
|
|
1255
|
+
const delay = this._initPhaseActive ? 0 : this._backoff.fail();
|
|
1205
1256
|
const { promise, cancel: cancelDelay } = this._cancellableDelay(delay);
|
|
1206
1257
|
this._cancelTokens.push(cancelDelay);
|
|
1207
1258
|
const delayedTransition = promise.then(() => {
|
|
@@ -1236,6 +1287,7 @@ class CompositeDataSource {
|
|
|
1236
1287
|
this._initPhaseActive = this._initFactories.length() > 0; // init phase if we have initializers;
|
|
1237
1288
|
this._initFactories.reset();
|
|
1238
1289
|
this._syncFactories.reset();
|
|
1290
|
+
this._fdv1Synchronizers.reset();
|
|
1239
1291
|
this._externalTransitionPromise = new Promise((tr) => {
|
|
1240
1292
|
this._externalTransitionResolve = tr;
|
|
1241
1293
|
});
|
|
@@ -1270,6 +1322,11 @@ class CompositeDataSource {
|
|
|
1270
1322
|
break;
|
|
1271
1323
|
case 'fallback':
|
|
1272
1324
|
default:
|
|
1325
|
+
// if asked to fallback after using all init factories, switch to sync factories
|
|
1326
|
+
if (this._initPhaseActive && this._initFactories.pos() >= this._initFactories.length()) {
|
|
1327
|
+
this._initPhaseActive = false;
|
|
1328
|
+
this._syncFactories.reset();
|
|
1329
|
+
}
|
|
1273
1330
|
if (this._initPhaseActive) {
|
|
1274
1331
|
isPrimary = this._initFactories.pos() === 0;
|
|
1275
1332
|
factory = this._initFactories.next();
|
|
@@ -1361,31 +1418,6 @@ var DataSourceErrorKind;
|
|
|
1361
1418
|
DataSourceErrorKind["InvalidData"] = "INVALID_DATA";
|
|
1362
1419
|
})(DataSourceErrorKind || (DataSourceErrorKind = {}));
|
|
1363
1420
|
|
|
1364
|
-
class LDFileDataSourceError extends Error {
|
|
1365
|
-
constructor(message) {
|
|
1366
|
-
super(message);
|
|
1367
|
-
this.name = 'LaunchDarklyFileDataSourceError';
|
|
1368
|
-
}
|
|
1369
|
-
}
|
|
1370
|
-
class LDPollingError extends Error {
|
|
1371
|
-
constructor(kind, message, status, recoverable = true) {
|
|
1372
|
-
super(message);
|
|
1373
|
-
this.kind = kind;
|
|
1374
|
-
this.status = status;
|
|
1375
|
-
this.name = 'LaunchDarklyPollingError';
|
|
1376
|
-
this.recoverable = recoverable;
|
|
1377
|
-
}
|
|
1378
|
-
}
|
|
1379
|
-
class LDStreamingError extends Error {
|
|
1380
|
-
constructor(kind, message, code, recoverable = true) {
|
|
1381
|
-
super(message);
|
|
1382
|
-
this.kind = kind;
|
|
1383
|
-
this.code = code;
|
|
1384
|
-
this.name = 'LaunchDarklyStreamingError';
|
|
1385
|
-
this.recoverable = recoverable;
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1388
|
-
|
|
1389
1421
|
/* eslint-disable import/prefer-default-export */
|
|
1390
1422
|
/**
|
|
1391
1423
|
* Enable / disable Auto environment attributes. When enabled, the SDK will automatically
|
|
@@ -1868,7 +1900,7 @@ class ServiceEndpoints {
|
|
|
1868
1900
|
}
|
|
1869
1901
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1870
1902
|
ServiceEndpoints.DEFAULT_EVENTS = 'https://events.launchdarkly.com';
|
|
1871
|
-
function getWithParams(uri, parameters) {
|
|
1903
|
+
function getWithParams(uri, parameters = []) {
|
|
1872
1904
|
if (parameters.length === 0) {
|
|
1873
1905
|
return uri;
|
|
1874
1906
|
}
|
|
@@ -1897,7 +1929,7 @@ function getStreamingUri(endpoints, path, parameters) {
|
|
|
1897
1929
|
* @param path The path to the resource, devoid of any query parameters or hrefs.
|
|
1898
1930
|
* @param parameters The query parameters. These query parameters must already have the appropriate encoding applied. This function WILL NOT apply it for you.
|
|
1899
1931
|
*/
|
|
1900
|
-
function getPollingUri(endpoints, path, parameters) {
|
|
1932
|
+
function getPollingUri(endpoints, path, parameters = []) {
|
|
1901
1933
|
const canonicalizedPath = canonicalizePath(path);
|
|
1902
1934
|
const combinedParameters = [...parameters];
|
|
1903
1935
|
if (endpoints.payloadFilterKey) {
|
|
@@ -1912,7 +1944,7 @@ function getPollingUri(endpoints, path, parameters) {
|
|
|
1912
1944
|
* @param path The path to the resource, devoid of any query parameters or hrefs.
|
|
1913
1945
|
* @param parameters The query parameters. These query parameters must already have the appropriate encoding applied. This function WILL NOT apply it for you.
|
|
1914
1946
|
*/
|
|
1915
|
-
function getEventsUri(endpoints, path, parameters) {
|
|
1947
|
+
function getEventsUri(endpoints, path, parameters = []) {
|
|
1916
1948
|
const canonicalizedPath = canonicalizePath(path);
|
|
1917
1949
|
return getWithParams(`${endpoints.events}/${canonicalizedPath}`, parameters);
|
|
1918
1950
|
}
|
|
@@ -2922,6 +2954,68 @@ class EventFactoryBase {
|
|
|
2922
2954
|
}
|
|
2923
2955
|
}
|
|
2924
2956
|
|
|
2957
|
+
const PAYLOAD_ID = 'FDv1Fallback';
|
|
2958
|
+
function fdv1PayloadAdaptor(processor) {
|
|
2959
|
+
return {
|
|
2960
|
+
_processor: processor,
|
|
2961
|
+
_selector: '',
|
|
2962
|
+
useSelector(selector) {
|
|
2963
|
+
this._selector = selector;
|
|
2964
|
+
return this;
|
|
2965
|
+
},
|
|
2966
|
+
processFullTransfer(data) {
|
|
2967
|
+
const events = [
|
|
2968
|
+
{
|
|
2969
|
+
event: 'server-intent',
|
|
2970
|
+
data: {
|
|
2971
|
+
payloads: [
|
|
2972
|
+
{
|
|
2973
|
+
id: PAYLOAD_ID,
|
|
2974
|
+
target: 1,
|
|
2975
|
+
intentCode: 'xfer-full',
|
|
2976
|
+
reason: 'payload-missing',
|
|
2977
|
+
},
|
|
2978
|
+
],
|
|
2979
|
+
},
|
|
2980
|
+
},
|
|
2981
|
+
];
|
|
2982
|
+
Object.entries(data?.flags || []).forEach(([key, flag]) => {
|
|
2983
|
+
events.push({
|
|
2984
|
+
event: 'put-object',
|
|
2985
|
+
data: {
|
|
2986
|
+
kind: 'flag',
|
|
2987
|
+
key,
|
|
2988
|
+
version: flag.version || 1,
|
|
2989
|
+
object: flag,
|
|
2990
|
+
},
|
|
2991
|
+
});
|
|
2992
|
+
});
|
|
2993
|
+
Object.entries(data?.segments || []).forEach(([key, segment]) => {
|
|
2994
|
+
events.push({
|
|
2995
|
+
event: 'put-object',
|
|
2996
|
+
data: {
|
|
2997
|
+
kind: 'segment',
|
|
2998
|
+
key,
|
|
2999
|
+
version: segment.version || 1,
|
|
3000
|
+
object: segment,
|
|
3001
|
+
},
|
|
3002
|
+
});
|
|
3003
|
+
});
|
|
3004
|
+
events.push({
|
|
3005
|
+
event: 'payload-transferred',
|
|
3006
|
+
data: {
|
|
3007
|
+
// IMPORTANT: the selector MUST be empty or "live" data synchronizers
|
|
3008
|
+
// will not work as it would try to resume from a bogus state.
|
|
3009
|
+
state: this._selector,
|
|
3010
|
+
version: 1,
|
|
3011
|
+
id: PAYLOAD_ID,
|
|
3012
|
+
},
|
|
3013
|
+
});
|
|
3014
|
+
this._processor.processEvents(events);
|
|
3015
|
+
},
|
|
3016
|
+
};
|
|
3017
|
+
}
|
|
3018
|
+
|
|
2925
3019
|
/**
|
|
2926
3020
|
* A FDv2 PayloadProcessor can be used to parse payloads from a stream of FDv2 events. It will send payloads
|
|
2927
3021
|
* to the PayloadListeners as the payloads are received. Invalid series of events may be dropped silently,
|
|
@@ -2952,7 +3046,7 @@ class PayloadProcessor {
|
|
|
2952
3046
|
}
|
|
2953
3047
|
// at the time of writing this, it was agreed upon that SDKs could assume exactly 1 element in this list. In the future, a negotiation of protocol version will be required to remove this assumption.
|
|
2954
3048
|
const payload = data.payloads[0];
|
|
2955
|
-
switch (payload?.
|
|
3049
|
+
switch (payload?.intentCode) {
|
|
2956
3050
|
case 'xfer-full':
|
|
2957
3051
|
this._tempBasis = true;
|
|
2958
3052
|
break;
|
|
@@ -2965,6 +3059,7 @@ class PayloadProcessor {
|
|
|
2965
3059
|
break;
|
|
2966
3060
|
default:
|
|
2967
3061
|
// unrecognized intent code, return
|
|
3062
|
+
this._logger?.warn(`Unable to process intent code '${payload?.intentCode}'.`);
|
|
2968
3063
|
return;
|
|
2969
3064
|
}
|
|
2970
3065
|
this._tempId = payload?.id;
|
|
@@ -3022,8 +3117,12 @@ class PayloadProcessor {
|
|
|
3022
3117
|
};
|
|
3023
3118
|
this._processPayloadTransferred = (data) => {
|
|
3024
3119
|
// if the following properties haven't been provided by now, we should reset
|
|
3025
|
-
if (
|
|
3026
|
-
|
|
3120
|
+
if (
|
|
3121
|
+
// server intent hasn't been received yet.
|
|
3122
|
+
!this._tempId ||
|
|
3123
|
+
// selector can be an empty string if we are using a file data initilizer
|
|
3124
|
+
data.state === null ||
|
|
3125
|
+
data.state === undefined ||
|
|
3027
3126
|
!data.version) {
|
|
3028
3127
|
this._resetAll(); // a reset is best defensive action since payload transferred terminates a payload
|
|
3029
3128
|
return;
|
|
@@ -3226,6 +3325,7 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
3226
3325
|
ErrorKinds: ErrorKinds$1,
|
|
3227
3326
|
EventFactoryBase: EventFactoryBase,
|
|
3228
3327
|
EventProcessor: EventProcessor,
|
|
3328
|
+
FDv1PayloadAdaptor: fdv1PayloadAdaptor,
|
|
3229
3329
|
InputCustomEvent: InputCustomEvent,
|
|
3230
3330
|
InputEvalEvent: InputEvalEvent,
|
|
3231
3331
|
InputIdentifyEvent: InputIdentifyEvent,
|
|
@@ -3243,5 +3343,5 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
3243
3343
|
shouldSample: shouldSample
|
|
3244
3344
|
});
|
|
3245
3345
|
|
|
3246
|
-
export { ApplicationTags, AttributeReference, AutoEnvAttributes, BasicLogger, ClientContext, CompositeDataSource, Context, ContextFilter, DataSourceErrorKind, DateValidator, DefaultBackoff, FactoryOrInstance, Function, KindValidator, LDClientError, LDFileDataSourceError, LDPollingError, LDStreamingError, LDTimeoutError, LDUnexpectedResponseError, NullableBoolean, NumberWithMinimum, OptionMessages, SafeLogger, ServiceEndpoints, StringMatchingRegex, Type, TypeArray, TypeValidators, base64UrlEncode, cancelableTimedPromise, clone, createSafeLogger, debounce, deepCompact, defaultHeaders, fastDeepEqual, getEventsUri, getPollingUri, getStreamingUri, httpErrorMessage, index as internal, isHttpLocallyRecoverable, isHttpRecoverable, noop, secondsToMillis, shouldRetry, sleep, index$1 as subsystem, timedPromise };
|
|
3346
|
+
export { ApplicationTags, AttributeReference, AutoEnvAttributes, BasicLogger, ClientContext, CompositeDataSource, Context, ContextFilter, DataSourceErrorKind, DateValidator, DefaultBackoff, FactoryOrInstance, Function, KindValidator, LDClientError, LDFileDataSourceError, LDFlagDeliveryFallbackError, LDPollingError, LDStreamingError, LDTimeoutError, LDUnexpectedResponseError, NullableBoolean, NumberWithMinimum, OptionMessages, SafeLogger, ServiceEndpoints, StringMatchingRegex, Type, TypeArray, TypeValidators, base64UrlEncode, cancelableTimedPromise, clone, createSafeLogger, debounce, deepCompact, defaultHeaders, fastDeepEqual, getEventsUri, getPollingUri, getStreamingUri, httpErrorMessage, index as internal, isHttpLocallyRecoverable, isHttpRecoverable, noop, secondsToMillis, shouldRetry, sleep, index$1 as subsystem, timedPromise };
|
|
3247
3347
|
//# sourceMappingURL=index.mjs.map
|