@launchdarkly/js-client-sdk-common 1.7.0 → 1.8.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 +27 -0
- package/dist/DataManager.d.ts +49 -0
- package/dist/DataManager.d.ts.map +1 -0
- package/dist/DataManager.js +98 -0
- package/dist/DataManager.js.map +1 -0
- package/dist/LDClientImpl.d.ts +9 -44
- package/dist/LDClientImpl.d.ts.map +1 -1
- package/dist/LDClientImpl.js +18 -144
- package/dist/LDClientImpl.js.map +1 -1
- package/dist/api/LDClient.d.ts +0 -14
- package/dist/api/LDClient.d.ts.map +1 -1
- package/dist/api/LDOptions.d.ts +7 -10
- package/dist/api/LDOptions.d.ts.map +1 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +1 -0
- package/dist/api/index.js.map +1 -1
- package/dist/configuration/Configuration.d.ts +57 -16
- package/dist/configuration/Configuration.d.ts.map +1 -1
- package/dist/configuration/Configuration.js +13 -7
- package/dist/configuration/Configuration.js.map +1 -1
- package/dist/configuration/index.d.ts +2 -2
- package/dist/configuration/index.d.ts.map +1 -1
- package/dist/configuration/index.js +4 -1
- package/dist/configuration/index.js.map +1 -1
- package/dist/configuration/validators.d.ts.map +1 -1
- package/dist/configuration/validators.js +1 -9
- package/dist/configuration/validators.js.map +1 -1
- package/dist/context/addAutoEnv.d.ts +2 -2
- package/dist/context/addAutoEnv.d.ts.map +1 -1
- package/dist/context/addAutoEnv.js +5 -6
- package/dist/context/addAutoEnv.js.map +1 -1
- package/dist/context/ensureKey.js +1 -1
- package/dist/context/ensureKey.js.map +1 -1
- package/dist/crypto/digest.d.ts +3 -0
- package/dist/crypto/digest.d.ts.map +1 -0
- package/dist/crypto/digest.js +14 -0
- package/dist/crypto/digest.js.map +1 -0
- package/dist/diagnostics/createDiagnosticsInitConfig.d.ts +1 -1
- package/dist/diagnostics/createDiagnosticsInitConfig.d.ts.map +1 -1
- package/dist/diagnostics/createDiagnosticsInitConfig.js +2 -2
- package/dist/diagnostics/createDiagnosticsInitConfig.js.map +1 -1
- package/dist/diagnostics/createDiagnosticsManager.d.ts +1 -1
- package/dist/diagnostics/createDiagnosticsManager.d.ts.map +1 -1
- package/dist/events/createEventProcessor.d.ts +3 -3
- package/dist/events/createEventProcessor.d.ts.map +1 -1
- package/dist/events/createEventProcessor.js +2 -2
- package/dist/events/createEventProcessor.js.map +1 -1
- package/dist/flag-manager/FlagManager.d.ts +29 -15
- package/dist/flag-manager/FlagManager.d.ts.map +1 -1
- package/dist/flag-manager/FlagManager.js +10 -36
- package/dist/flag-manager/FlagManager.js.map +1 -1
- package/dist/flag-manager/FlagPersistence.d.ts +2 -1
- package/dist/flag-manager/FlagPersistence.d.ts.map +1 -1
- package/dist/flag-manager/FlagPersistence.js +5 -5
- package/dist/flag-manager/FlagPersistence.js.map +1 -1
- package/dist/flag-manager/FlagStore.d.ts.map +1 -1
- package/dist/flag-manager/FlagStore.js +4 -1
- package/dist/flag-manager/FlagStore.js.map +1 -1
- package/dist/index.d.ts +12 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/polling/PollingProcessor.d.ts.map +1 -1
- package/dist/polling/PollingProcessor.js +22 -5
- package/dist/polling/PollingProcessor.js.map +1 -1
- package/dist/polling/Requestor.d.ts +16 -1
- package/dist/polling/Requestor.d.ts.map +1 -1
- package/dist/polling/Requestor.js +6 -8
- package/dist/polling/Requestor.js.map +1 -1
- package/dist/storage/namespaceUtils.d.ts +7 -7
- package/dist/storage/namespaceUtils.d.ts.map +1 -1
- package/dist/storage/namespaceUtils.js +10 -9
- package/dist/storage/namespaceUtils.js.map +1 -1
- package/dist/streaming/DataSourceConfig.d.ts +20 -0
- package/dist/streaming/DataSourceConfig.d.ts.map +1 -0
- package/dist/streaming/DataSourceConfig.js +3 -0
- package/dist/streaming/DataSourceConfig.js.map +1 -0
- package/dist/streaming/StreamingProcessor.d.ts +33 -0
- package/dist/streaming/StreamingProcessor.d.ts.map +1 -0
- package/dist/streaming/StreamingProcessor.js +126 -0
- package/dist/streaming/StreamingProcessor.js.map +1 -0
- package/dist/streaming/index.d.ts +4 -0
- package/dist/streaming/index.d.ts.map +1 -0
- package/dist/streaming/index.js +6 -0
- package/dist/streaming/index.js.map +1 -0
- package/package.json +2 -2
|
@@ -3,23 +3,11 @@ import { FlagsChangeCallback } from './FlagUpdater';
|
|
|
3
3
|
import { ItemDescriptor } from './ItemDescriptor';
|
|
4
4
|
/**
|
|
5
5
|
* Top level manager of flags for the client. LDClient should be using this
|
|
6
|
-
*
|
|
6
|
+
* interface and not any of the specific instances managed by it. Updates from
|
|
7
7
|
* data sources should be directed to the [init] and [upsert] methods of this
|
|
8
|
-
*
|
|
8
|
+
* interface.
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
11
|
-
private readonly timeStamper;
|
|
12
|
-
private flagStore;
|
|
13
|
-
private flagUpdater;
|
|
14
|
-
private flagPersistence;
|
|
15
|
-
/**
|
|
16
|
-
* @param platform implementation of various platform provided functionality
|
|
17
|
-
* @param sdkKey that will be used to distinguish different environments
|
|
18
|
-
* @param maxCachedContexts that specifies the max number of contexts that will be cached in persistence
|
|
19
|
-
* @param logger used for logging various messages
|
|
20
|
-
* @param timeStamper exists for testing purposes
|
|
21
|
-
*/
|
|
22
|
-
constructor(platform: Platform, sdkKey: string, maxCachedContexts: number, logger: LDLogger, timeStamper?: () => number);
|
|
10
|
+
export interface FlagManager {
|
|
23
11
|
/**
|
|
24
12
|
* Attempts to get a flag by key from the current flags.
|
|
25
13
|
*/
|
|
@@ -55,4 +43,30 @@ export default class FlagManager {
|
|
|
55
43
|
*/
|
|
56
44
|
off(callback: FlagsChangeCallback): void;
|
|
57
45
|
}
|
|
46
|
+
export default class DefaultFlagManager implements FlagManager {
|
|
47
|
+
private readonly timeStamper;
|
|
48
|
+
private flagStore;
|
|
49
|
+
private flagUpdater;
|
|
50
|
+
private flagPersistencePromise;
|
|
51
|
+
/**
|
|
52
|
+
* @param platform implementation of various platform provided functionality
|
|
53
|
+
* @param sdkKey that will be used to distinguish different environments
|
|
54
|
+
* @param maxCachedContexts that specifies the max number of contexts that will be cached in persistence
|
|
55
|
+
* @param logger used for logging various messages
|
|
56
|
+
* @param timeStamper exists for testing purposes
|
|
57
|
+
*/
|
|
58
|
+
constructor(platform: Platform, sdkKey: string, maxCachedContexts: number, logger: LDLogger, timeStamper?: () => number);
|
|
59
|
+
private initPersistence;
|
|
60
|
+
get(key: string): ItemDescriptor | undefined;
|
|
61
|
+
getAll(): {
|
|
62
|
+
[key: string]: ItemDescriptor;
|
|
63
|
+
};
|
|
64
|
+
init(context: Context, newFlags: {
|
|
65
|
+
[key: string]: ItemDescriptor;
|
|
66
|
+
}): Promise<void>;
|
|
67
|
+
upsert(context: Context, key: string, item: ItemDescriptor): Promise<boolean>;
|
|
68
|
+
loadCached(context: Context): Promise<boolean>;
|
|
69
|
+
on(callback: FlagsChangeCallback): void;
|
|
70
|
+
off(callback: FlagsChangeCallback): void;
|
|
71
|
+
}
|
|
58
72
|
//# sourceMappingURL=FlagManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlagManager.d.ts","sourceRoot":"","sources":["../../src/flag-manager/FlagManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAK1E,OAAoB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,WAAW;
|
|
1
|
+
{"version":3,"file":"FlagManager.d.ts","sourceRoot":"","sources":["../../src/flag-manager/FlagManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,6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,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAI5C,MAAM,IAAI;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;KAAE;IAIrC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlF,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;IAI7E,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAIpD,EAAE,CAAC,QAAQ,EAAE,mBAAmB,GAAG,IAAI;IAIvC,GAAG,CAAC,QAAQ,EAAE,mBAAmB,GAAG,IAAI;CAGzC"}
|
|
@@ -4,13 +4,7 @@ const namespaceUtils_1 = require("../storage/namespaceUtils");
|
|
|
4
4
|
const FlagPersistence_1 = require("./FlagPersistence");
|
|
5
5
|
const FlagStore_1 = require("./FlagStore");
|
|
6
6
|
const FlagUpdater_1 = require("./FlagUpdater");
|
|
7
|
-
|
|
8
|
-
* Top level manager of flags for the client. LDClient should be using this
|
|
9
|
-
* class and not any of the specific instances managed by it. Updates from
|
|
10
|
-
* data sources should be directed to the [init] and [upsert] methods of this
|
|
11
|
-
* class.
|
|
12
|
-
*/
|
|
13
|
-
class FlagManager {
|
|
7
|
+
class DefaultFlagManager {
|
|
14
8
|
/**
|
|
15
9
|
* @param platform implementation of various platform provided functionality
|
|
16
10
|
* @param sdkKey that will be used to distinguish different environments
|
|
@@ -21,54 +15,34 @@ class FlagManager {
|
|
|
21
15
|
constructor(platform, sdkKey, maxCachedContexts, logger, timeStamper = () => Date.now()) {
|
|
22
16
|
this.timeStamper = timeStamper;
|
|
23
17
|
this.flagStore = new FlagStore_1.DefaultFlagStore();
|
|
24
|
-
const environmentNamespace = (0, namespaceUtils_1.namespaceForEnvironment)(platform.crypto, sdkKey);
|
|
25
18
|
this.flagUpdater = new FlagUpdater_1.default(this.flagStore, logger);
|
|
26
|
-
this.
|
|
19
|
+
this.flagPersistencePromise = this.initPersistence(platform, sdkKey, maxCachedContexts, logger, timeStamper);
|
|
20
|
+
}
|
|
21
|
+
async initPersistence(platform, sdkKey, maxCachedContexts, logger, timeStamper = () => Date.now()) {
|
|
22
|
+
const environmentNamespace = await (0, namespaceUtils_1.namespaceForEnvironment)(platform.crypto, sdkKey);
|
|
23
|
+
return new FlagPersistence_1.default(platform, environmentNamespace, maxCachedContexts, this.flagStore, this.flagUpdater, logger, timeStamper);
|
|
27
24
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Attempts to get a flag by key from the current flags.
|
|
30
|
-
*/
|
|
31
25
|
get(key) {
|
|
32
26
|
return this.flagStore.get(key);
|
|
33
27
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Gets all the current flags.
|
|
36
|
-
*/
|
|
37
28
|
getAll() {
|
|
38
29
|
return this.flagStore.getAll();
|
|
39
30
|
}
|
|
40
|
-
/**
|
|
41
|
-
* Initializes the flag manager with data from a data source.
|
|
42
|
-
* Persistence initialization is handled by {@link FlagPersistence}
|
|
43
|
-
*/
|
|
44
31
|
async init(context, newFlags) {
|
|
45
|
-
return this.
|
|
32
|
+
return (await this.flagPersistencePromise).init(context, newFlags);
|
|
46
33
|
}
|
|
47
|
-
/**
|
|
48
|
-
* Attempt to update a flag. If the flag is for the wrong context, or
|
|
49
|
-
* it is of an older version, then an update will not be performed.
|
|
50
|
-
*/
|
|
51
34
|
async upsert(context, key, item) {
|
|
52
|
-
return this.
|
|
35
|
+
return (await this.flagPersistencePromise).upsert(context, key, item);
|
|
53
36
|
}
|
|
54
|
-
/**
|
|
55
|
-
* Asynchronously load cached values from persistence.
|
|
56
|
-
*/
|
|
57
37
|
async loadCached(context) {
|
|
58
|
-
return this.
|
|
38
|
+
return (await this.flagPersistencePromise).loadCached(context);
|
|
59
39
|
}
|
|
60
|
-
/**
|
|
61
|
-
* Register a flag change callback.
|
|
62
|
-
*/
|
|
63
40
|
on(callback) {
|
|
64
41
|
this.flagUpdater.on(callback);
|
|
65
42
|
}
|
|
66
|
-
/**
|
|
67
|
-
* Unregister a flag change callback.
|
|
68
|
-
*/
|
|
69
43
|
off(callback) {
|
|
70
44
|
this.flagUpdater.off(callback);
|
|
71
45
|
}
|
|
72
46
|
}
|
|
73
|
-
exports.default =
|
|
47
|
+
exports.default = DefaultFlagManager;
|
|
74
48
|
//# sourceMappingURL=FlagManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlagManager.js","sourceRoot":"","sources":["../../src/flag-manager/FlagManager.ts"],"names":[],"mappings":";;AAEA,8DAAoE;AACpE,uDAAgD;AAChD,2CAA+C;AAC/C,+CAAiE;
|
|
1
|
+
{"version":3,"file":"FlagManager.js","sourceRoot":"","sources":["../../src/flag-manager/FlagManager.ts"],"names":[],"mappings":";;AAEA,8DAAoE;AACpE,uDAAgD;AAChD,2CAA+C;AAC/C,+CAAiE;AAgDjE,MAAqB,kBAAkB;IAKrC;;;;;;OAMG;IACH,YACE,QAAkB,EAClB,MAAc,EACd,iBAAyB,EACzB,MAAgB,EACC,cAA4B,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;QAA5C,gBAAW,GAAX,WAAW,CAAiC;QAhBvD,cAAS,GAAG,IAAI,4BAAgB,EAAE,CAAC;QAkBzC,IAAI,CAAC,WAAW,GAAG,IAAI,qBAAW,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAC3D,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC,eAAe,CAChD,QAAQ,EACR,MAAM,EACN,iBAAiB,EACjB,MAAM,EACN,WAAW,CACZ,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,eAAe,CAC3B,QAAkB,EAClB,MAAc,EACd,iBAAyB,EACzB,MAAgB,EAChB,cAA4B,GAAG,EA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;
|
|
17
17
|
private readonly timeStamper;
|
|
18
18
|
private contextIndex;
|
|
19
|
-
private indexKey
|
|
19
|
+
private indexKey?;
|
|
20
|
+
private indexKeyPromise;
|
|
20
21
|
constructor(platform: Platform, environmentNamespace: string, maxCachedContexts: number, flagStore: FlagStore, flagUpdater: FlagUpdater, logger: LDLogger, timeStamper?: () => number);
|
|
21
22
|
/**
|
|
22
23
|
* Inits flag persistence for the provided context with the provided flags. This will result
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlagPersistence.d.ts","sourceRoot":"","sources":["../../src/flag-manager/FlagPersistence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAK1E,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;
|
|
1
|
+
{"version":3,"file":"FlagPersistence.d.ts","sourceRoot":"","sources":["../../src/flag-manager/FlagPersistence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAK1E,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;IAMhC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IACrC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAX9B,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,QAAQ,CAAC,CAAS;IAC1B,OAAO,CAAC,eAAe,CAAkB;gBAGtB,QAAQ,EAAE,QAAQ,EAClB,oBAAoB,EAAE,MAAM,EAC5B,iBAAiB,EAAE,MAAM,EACzB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,QAAQ,EAChB,WAAW,GAAE,MAAM,MAAyB;IAK/D;;;OAGG;IACG,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAKxF;;;;OAIG;IACG,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;IAQnF;;;OAGG;IACG,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;YA4CtC,SAAS;YAqBT,UAAU;CA4BzB"}
|
|
@@ -16,7 +16,7 @@ class FlagPersistence {
|
|
|
16
16
|
this.flagUpdater = flagUpdater;
|
|
17
17
|
this.logger = logger;
|
|
18
18
|
this.timeStamper = timeStamper;
|
|
19
|
-
this.
|
|
19
|
+
this.indexKeyPromise = (0, namespaceUtils_1.namespaceForContextIndex)(this.environmentNamespace);
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* Inits flag persistence for the provided context with the provided flags. This will result
|
|
@@ -44,7 +44,7 @@ class FlagPersistence {
|
|
|
44
44
|
*/
|
|
45
45
|
async loadCached(context) {
|
|
46
46
|
var _a, _b, _c, _d;
|
|
47
|
-
const storageKey = (0, namespaceUtils_1.namespaceForContextData)(this.platform.crypto, this.environmentNamespace, context);
|
|
47
|
+
const storageKey = await (0, namespaceUtils_1.namespaceForContextData)(this.platform.crypto, this.environmentNamespace, context);
|
|
48
48
|
let flagsJson = await ((_a = this.platform.storage) === null || _a === void 0 ? void 0 : _a.get(storageKey));
|
|
49
49
|
if (flagsJson === null || flagsJson === undefined) {
|
|
50
50
|
// Fallback: in version <10.3.1 flag data was stored under the canonical key, check
|
|
@@ -79,7 +79,7 @@ class FlagPersistence {
|
|
|
79
79
|
if (this.contextIndex !== undefined) {
|
|
80
80
|
return this.contextIndex;
|
|
81
81
|
}
|
|
82
|
-
const json = await ((_a = this.platform.storage) === null || _a === void 0 ? void 0 : _a.get(this.
|
|
82
|
+
const json = await ((_a = this.platform.storage) === null || _a === void 0 ? void 0 : _a.get(await this.indexKeyPromise));
|
|
83
83
|
if (!json) {
|
|
84
84
|
this.contextIndex = new ContextIndex_1.default();
|
|
85
85
|
return this.contextIndex;
|
|
@@ -97,12 +97,12 @@ class FlagPersistence {
|
|
|
97
97
|
async storeCache(context) {
|
|
98
98
|
var _a, _b;
|
|
99
99
|
const index = await this.loadIndex();
|
|
100
|
-
const storageKey = (0, namespaceUtils_1.namespaceForContextData)(this.platform.crypto, this.environmentNamespace, context);
|
|
100
|
+
const storageKey = await (0, namespaceUtils_1.namespaceForContextData)(this.platform.crypto, this.environmentNamespace, context);
|
|
101
101
|
index.notice(storageKey, this.timeStamper());
|
|
102
102
|
const pruned = index.prune(this.maxCachedContexts);
|
|
103
103
|
await Promise.all(pruned.map(async (it) => { var _a; return (_a = this.platform.storage) === null || _a === void 0 ? void 0 : _a.clear(it.id); }));
|
|
104
104
|
// store index
|
|
105
|
-
await ((_a = this.platform.storage) === null || _a === void 0 ? void 0 : _a.set(this.
|
|
105
|
+
await ((_a = this.platform.storage) === null || _a === void 0 ? void 0 : _a.set(await this.indexKeyPromise, index.toJson()));
|
|
106
106
|
const allFlags = this.flagStore.getAll();
|
|
107
107
|
// mapping item descriptors to flags
|
|
108
108
|
const flags = Object.entries(allFlags).reduce((acc, [key, descriptor]) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlagPersistence.js","sourceRoot":"","sources":["../../src/flag-manager/FlagPersistence.ts"],"names":[],"mappings":";;AAEA,8DAA8F;AAE9F,iDAA0C;AAK1C;;;;GAIG;AACH,MAAqB,eAAe;
|
|
1
|
+
{"version":3,"file":"FlagPersistence.js","sourceRoot":"","sources":["../../src/flag-manager/FlagPersistence.ts"],"names":[],"mappings":";;AAEA,8DAA8F;AAE9F,iDAA0C;AAK1C;;;;GAIG;AACH,MAAqB,eAAe;IAKlC,YACmB,QAAkB,EAClB,oBAA4B,EAC5B,iBAAyB,EACzB,SAAoB,EACpB,WAAwB,EACxB,MAAgB,EAChB,cAA4B,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;QAN5C,aAAQ,GAAR,QAAQ,CAAU;QAClB,yBAAoB,GAApB,oBAAoB,CAAQ;QAC5B,sBAAiB,GAAjB,iBAAiB,CAAQ;QACzB,cAAS,GAAT,SAAS,CAAW;QACpB,gBAAW,GAAX,WAAW,CAAa;QACxB,WAAM,GAAN,MAAM,CAAU;QAChB,gBAAW,GAAX,WAAW,CAAiC;QAE7D,IAAI,CAAC,eAAe,GAAG,IAAA,yCAAwB,EAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IAC7E,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,IAAI,CAAC,OAAgB,EAAE,QAA2C;QACtE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACzC,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,OAAgB,EAAE,GAAW,EAAE,IAAoB;QAC9D,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE;YAC/C,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YAC/B,OAAO,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AAO,0CAAE,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA,CAAC;IACxD,CAAC;CACF;AAxID,kCAwIC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlagStore.d.ts","sourceRoot":"","sources":["../../src/flag-manager/FlagStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;GAEG;AACH,MAAM,CAAC,OAAO,WAAW,SAAS;IAChC,IAAI,CAAC,QAAQ,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;KAAE,GAAG,IAAI,CAAC;IACxD,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC1D,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAAC;IAC7C,MAAM,IAAI;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;KAAE,CAAC;CAC7C;AAED;;GAEG;AACH,qBAAa,gBAAiB,YAAW,SAAS;IAChD,OAAO,CAAC,KAAK,CAAyC;IAEtD,IAAI,CAAC,QAAQ,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;KAAE;IAUhD,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc;IAIlD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;
|
|
1
|
+
{"version":3,"file":"FlagStore.d.ts","sourceRoot":"","sources":["../../src/flag-manager/FlagStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;GAEG;AACH,MAAM,CAAC,OAAO,WAAW,SAAS;IAChC,IAAI,CAAC,QAAQ,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;KAAE,GAAG,IAAI,CAAC;IACxD,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC1D,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAAC;IAC7C,MAAM,IAAI;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;KAAE,CAAC;CAC7C;AAED;;GAEG;AACH,qBAAa,gBAAiB,YAAW,SAAS;IAChD,OAAO,CAAC,KAAK,CAAyC;IAEtD,IAAI,CAAC,QAAQ,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;KAAE;IAUhD,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc;IAIlD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAO5C,MAAM,IAAI;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;KAAE;CAG5C"}
|
|
@@ -18,7 +18,10 @@ class DefaultFlagStore {
|
|
|
18
18
|
this.flags[key] = update;
|
|
19
19
|
}
|
|
20
20
|
get(key) {
|
|
21
|
-
|
|
21
|
+
if (Object.prototype.hasOwnProperty.call(this.flags, key)) {
|
|
22
|
+
return this.flags[key];
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
22
25
|
}
|
|
23
26
|
getAll() {
|
|
24
27
|
return this.flags;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlagStore.js","sourceRoot":"","sources":["../../src/flag-manager/FlagStore.ts"],"names":[],"mappings":";;;AAYA;;GAEG;AACH,MAAa,gBAAgB;IAA7B;QACU,UAAK,GAAsC,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"FlagStore.js","sourceRoot":"","sources":["../../src/flag-manager/FlagStore.ts"],"names":[],"mappings":";;;AAYA;;GAEG;AACH,MAAa,gBAAgB;IAA7B;QACU,UAAK,GAAsC,EAAE,CAAC;IA0BxD,CAAC;IAxBC,IAAI,CAAC,QAA2C;QAC9C,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAC1C,CAAC,GAAoC,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;YACpD,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;YAChB,OAAO,GAAG,CAAC;QACb,CAAC,EACD,EAAE,CACH,CAAC;IACJ,CAAC;IAED,cAAc,CAAC,GAAW,EAAE,MAAsB;QAChD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;IAC3B,CAAC;IAED,GAAG,CAAC,GAAW;QACb,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE;YACzD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACxB;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF;AA3BD,4CA2BC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
|
+
import { LDClientInternalOptions } from './configuration/Configuration';
|
|
1
2
|
import LDClientImpl from './LDClientImpl';
|
|
3
|
+
import LDEmitter from './LDEmitter';
|
|
4
|
+
import Requestor from './polling/Requestor';
|
|
2
5
|
export * from '@launchdarkly/js-sdk-common';
|
|
3
6
|
export * as platform from '@launchdarkly/js-sdk-common';
|
|
4
|
-
export type { LDEvaluationDetail, LDEvaluationDetailTyped, LDClient, LDOptions, ConnectionMode, } from './api';
|
|
5
|
-
export {
|
|
7
|
+
export type { LDEvaluationDetail, LDEvaluationDetailTyped, LDClient, LDOptions, ConnectionMode, LDIdentifyOptions, } from './api';
|
|
8
|
+
export type { DataManager, DataManagerFactory } from './DataManager';
|
|
9
|
+
export type { FlagManager } from './flag-manager/FlagManager';
|
|
10
|
+
export type { Configuration } from './configuration/Configuration';
|
|
11
|
+
export type { LDEmitter };
|
|
12
|
+
export { DataSourcePaths } from './streaming';
|
|
13
|
+
export { BaseDataManager } from './DataManager';
|
|
14
|
+
export { Requestor };
|
|
15
|
+
export { LDClientImpl, LDClientInternalOptions };
|
|
6
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAE5C,cAAc,6BAA6B,CAAC;AAE5C,OAAO,KAAK,QAAQ,MAAM,6BAA6B,CAAC;AAMxD,YAAY,EACV,kBAAkB,EAClB,uBAAuB,EACvB,QAAQ,EACR,SAAS,EACT,cAAc,EACd,iBAAiB,GAClB,MAAM,OAAO,CAAC;AAEf,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACrE,YAAY,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,YAAY,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,YAAY,EAAE,SAAS,EAAE,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,9 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.LDClientImpl = exports.platform = void 0;
|
|
17
|
+
exports.LDClientImpl = exports.Requestor = exports.BaseDataManager = exports.platform = void 0;
|
|
18
18
|
const LDClientImpl_1 = require("./LDClientImpl");
|
|
19
19
|
exports.LDClientImpl = LDClientImpl_1.default;
|
|
20
|
+
const Requestor_1 = require("./polling/Requestor");
|
|
21
|
+
exports.Requestor = Requestor_1.default;
|
|
20
22
|
__exportStar(require("@launchdarkly/js-sdk-common"), exports);
|
|
21
23
|
exports.platform = require("@launchdarkly/js-sdk-common");
|
|
24
|
+
var DataManager_1 = require("./DataManager");
|
|
25
|
+
Object.defineProperty(exports, "BaseDataManager", { enumerable: true, get: function () { return DataManager_1.BaseDataManager; } });
|
|
22
26
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,iDAA0C;AA+BjC,uBA/BF,sBAAY,CA+BE;AA7BrB,mDAA4C;AA2BnC,oBA3BF,mBAAS,CA2BE;AAzBlB,8DAA4C;AAE5C,0DAAwD;AAsBxD,6CAAgD;AAAvC,8GAAA,eAAe,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PollingProcessor.d.ts","sourceRoot":"","sources":["../../src/polling/PollingProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"PollingProcessor.d.ts","sourceRoot":"","sources":["../../src/polling/PollingProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,cAAc,EAGf,MAAM,6BAA6B,CAAC;AAMrC,MAAM,MAAM,mBAAmB,GAAG,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,CAAC"}
|
|
@@ -6,14 +6,31 @@ const Requestor_1 = require("./Requestor");
|
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
8
|
class PollingProcessor {
|
|
9
|
-
constructor(
|
|
9
|
+
constructor(plainContextString, dataSourceConfig, requests, encoding, dataHandler, errorHandler, logger) {
|
|
10
|
+
this.plainContextString = plainContextString;
|
|
11
|
+
this.dataSourceConfig = dataSourceConfig;
|
|
10
12
|
this.dataHandler = dataHandler;
|
|
11
13
|
this.errorHandler = errorHandler;
|
|
14
|
+
this.logger = logger;
|
|
12
15
|
this.stopped = false;
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
const path = dataSourceConfig.useReport
|
|
17
|
+
? dataSourceConfig.paths.pathReport(encoding, plainContextString)
|
|
18
|
+
: dataSourceConfig.paths.pathGet(encoding, plainContextString);
|
|
19
|
+
const parameters = [];
|
|
20
|
+
if (this.dataSourceConfig.withReasons) {
|
|
21
|
+
parameters.push({ key: 'withReasons', value: 'true' });
|
|
22
|
+
}
|
|
23
|
+
const uri = (0, js_sdk_common_1.getPollingUri)(dataSourceConfig.serviceEndpoints, path, parameters);
|
|
24
|
+
this.pollInterval = dataSourceConfig.pollInterval;
|
|
25
|
+
let method = 'GET';
|
|
26
|
+
const headers = Object.assign({}, dataSourceConfig.baseHeaders);
|
|
27
|
+
let body;
|
|
28
|
+
if (dataSourceConfig.useReport) {
|
|
29
|
+
method = 'REPORT';
|
|
30
|
+
headers['content-type'] = 'application/json';
|
|
31
|
+
body = plainContextString; // context is in body for REPORT
|
|
32
|
+
}
|
|
33
|
+
this.requestor = new Requestor_1.default(requests, uri, headers, method, body);
|
|
17
34
|
}
|
|
18
35
|
async poll() {
|
|
19
36
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PollingProcessor.js","sourceRoot":"","sources":["../../src/polling/PollingProcessor.ts"],"names":[],"mappings":";;AAAA,+
|
|
1
|
+
{"version":3,"file":"PollingProcessor.js","sourceRoot":"","sources":["../../src/polling/PollingProcessor.ts"],"names":[],"mappings":";;AAAA,+DAUqC;AAIrC,2CAAwD;AAIxD;;GAEG;AACH,MAAqB,gBAAgB;IASnC,YACmB,kBAA0B,EAC1B,gBAAyC,EAC1D,QAAkB,EAClB,QAAkB,EACD,WAAmC,EACnC,YAAkC,EAClC,MAAiB;QANjB,uBAAkB,GAAlB,kBAAkB,CAAQ;QAC1B,qBAAgB,GAAhB,gBAAgB,CAAyB;QAGzC,gBAAW,GAAX,WAAW,CAAwB;QACnC,iBAAY,GAAZ,YAAY,CAAsB;QAClC,WAAM,GAAN,MAAM,CAAW;QAf5B,YAAO,GAAG,KAAK,CAAC;QAiBtB,MAAM,IAAI,GAAG,gBAAgB,CAAC,SAAS;YACrC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,EAAE,kBAAkB,CAAC;YACjE,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;QAEjE,MAAM,UAAU,GAAqC,EAAE,CAAC;QACxD,IAAI,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE;YACrC,UAAU,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;SACxD;QAED,MAAM,GAAG,GAAG,IAAA,6BAAa,EAAC,gBAAgB,CAAC,gBAAgB,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;QAC/E,IAAI,CAAC,YAAY,GAAG,gBAAgB,CAAC,YAAY,CAAC;QAElD,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,MAAM,OAAO,q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C;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACtB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;CACF;AA1GD,mCA0GC"}
|
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
import { HttpErrorResponse } from '@launchdarkly/js-sdk-common';
|
|
1
|
+
import { HttpErrorResponse, Requests } from '@launchdarkly/js-sdk-common';
|
|
2
2
|
export declare class LDRequestError extends Error implements HttpErrorResponse {
|
|
3
3
|
status?: number;
|
|
4
4
|
constructor(message: string, status?: number);
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Note: The requestor is implemented independently from polling such that it can be used to
|
|
8
|
+
* make a one-off request.
|
|
9
|
+
*/
|
|
10
|
+
export default class Requestor {
|
|
11
|
+
private requests;
|
|
12
|
+
private readonly uri;
|
|
13
|
+
private readonly headers;
|
|
14
|
+
private readonly method;
|
|
15
|
+
private readonly body?;
|
|
16
|
+
constructor(requests: Requests, uri: string, headers: {
|
|
17
|
+
[key: string]: string;
|
|
18
|
+
}, method: string, body?: string | undefined);
|
|
19
|
+
requestPayload(): Promise<string>;
|
|
20
|
+
}
|
|
6
21
|
//# sourceMappingURL=Requestor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Requestor.d.ts","sourceRoot":"","sources":["../../src/polling/Requestor.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"Requestor.d.ts","sourceRoot":"","sources":["../../src/polling/Requestor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAM1E,qBAAa,cAAe,SAAQ,KAAM,YAAW,iBAAiB;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;gBAEX,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAK7C;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,SAAS;IAE1B,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;gBAJd,QAAQ,EAAE,QAAQ,EACT,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,EAClC,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,oBAAQ;IAG1B,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;CAkBxC"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LDRequestError = void 0;
|
|
4
|
-
// eslint-disable-next-line max-classes-per-file
|
|
5
|
-
const js_sdk_common_1 = require("@launchdarkly/js-sdk-common");
|
|
6
4
|
function isOk(status) {
|
|
7
5
|
return status >= 200 && status <= 299;
|
|
8
6
|
}
|
|
@@ -17,22 +15,22 @@ exports.LDRequestError = LDRequestError;
|
|
|
17
15
|
/**
|
|
18
16
|
* Note: The requestor is implemented independently from polling such that it can be used to
|
|
19
17
|
* make a one-off request.
|
|
20
|
-
*
|
|
21
|
-
* @internal
|
|
22
18
|
*/
|
|
23
19
|
class Requestor {
|
|
24
|
-
constructor(
|
|
20
|
+
constructor(requests, uri, headers, method, body) {
|
|
25
21
|
this.requests = requests;
|
|
26
22
|
this.uri = uri;
|
|
27
|
-
this.headers =
|
|
28
|
-
this.
|
|
23
|
+
this.headers = headers;
|
|
24
|
+
this.method = method;
|
|
25
|
+
this.body = body;
|
|
29
26
|
}
|
|
30
27
|
async requestPayload() {
|
|
31
28
|
let status;
|
|
32
29
|
try {
|
|
33
30
|
const res = await this.requests.fetch(this.uri, {
|
|
34
|
-
method: this.
|
|
31
|
+
method: this.method,
|
|
35
32
|
headers: this.headers,
|
|
33
|
+
body: this.body,
|
|
36
34
|
});
|
|
37
35
|
if (isOk(res.status)) {
|
|
38
36
|
return await res.text();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Requestor.js","sourceRoot":"","sources":["../../src/polling/Requestor.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Requestor.js","sourceRoot":"","sources":["../../src/polling/Requestor.ts"],"names":[],"mappings":";;;AAGA,SAAS,IAAI,CAAC,MAAc;IAC1B,OAAO,MAAM,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG,CAAC;AACxC,CAAC;AAED,MAAa,cAAe,SAAQ,KAAK;IAGvC,YAAY,OAAe,EAAE,MAAe;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF;AARD,wCAQC;AAED;;;GAGG;AACH,MAAqB,SAAS;IAC5B,YACU,QAAkB,EACT,GAAW,EACX,OAAkC,EAClC,MAAc,EACd,IAAa;QAJtB,aAAQ,GAAR,QAAQ,CAAU;QACT,QAAG,GAAH,GAAG,CAAQ;QACX,YAAO,GAAP,OAAO,CAA2B;QAClC,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAS;IAC7B,CAAC;IAEJ,KAAK,CAAC,cAAc;QAClB,IAAI,MAA0B,CAAC;QAC/B,IAAI;YACF,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE;gBAC9C,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB,CAAC,CAAC;YACH,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;gBACpB,OAAO,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;aACzB;YACD,qDAAqD;YACrD,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;SACrB;QAAC,OAAO,GAAQ,EAAE;YACjB,MAAM,IAAI,cAAc,CAAC,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,CAAC,CAAC;SACxC;QACD,MAAM,IAAI,cAAc,CAAC,2BAA2B,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC;IACxE,CAAC;CACF;AA3BD,4BA2BC"}
|
|
@@ -2,9 +2,9 @@ import { Context, Crypto } from '@launchdarkly/js-sdk-common';
|
|
|
2
2
|
export type Namespace = 'LaunchDarkly' | 'AnonymousKeys' | 'ContextKeys' | 'ContextIndex';
|
|
3
3
|
export declare function concatNamespacesAndValues(parts: {
|
|
4
4
|
value: Namespace | string;
|
|
5
|
-
transform: (value: string) => string
|
|
6
|
-
}[]): string
|
|
7
|
-
export declare function namespaceForEnvironment(crypto: Crypto, sdkKey: string): string
|
|
5
|
+
transform: (value: string) => Promise<string>;
|
|
6
|
+
}[]): Promise<string>;
|
|
7
|
+
export declare function namespaceForEnvironment(crypto: Crypto, sdkKey: string): Promise<string>;
|
|
8
8
|
/**
|
|
9
9
|
* @deprecated prefer {@link namespaceForGeneratedContextKey}. At one time we only generated keys for
|
|
10
10
|
* anonymous contexts and they were namespaced in LaunchDarkly_AnonymousKeys. Eventually we started
|
|
@@ -13,8 +13,8 @@ export declare function namespaceForEnvironment(crypto: Crypto, sdkKey: string):
|
|
|
13
13
|
* when the data under the LaunchDarkly_AnonymousKeys namespace is merged with data under the
|
|
14
14
|
* LaunchDarkly_ContextKeys namespace.
|
|
15
15
|
*/
|
|
16
|
-
export declare function namespaceForAnonymousGeneratedContextKey(kind: string): string
|
|
17
|
-
export declare function namespaceForGeneratedContextKey(kind: string): string
|
|
18
|
-
export declare function namespaceForContextIndex(environmentNamespace: string): string
|
|
19
|
-
export declare function namespaceForContextData(crypto: Crypto, environmentNamespace: string, context: Context): string
|
|
16
|
+
export declare function namespaceForAnonymousGeneratedContextKey(kind: string): Promise<string>;
|
|
17
|
+
export declare function namespaceForGeneratedContextKey(kind: string): Promise<string>;
|
|
18
|
+
export declare function namespaceForContextIndex(environmentNamespace: string): Promise<string>;
|
|
19
|
+
export declare function namespaceForContextData(crypto: Crypto, environmentNamespace: string, context: Context): Promise<string>;
|
|
20
20
|
//# sourceMappingURL=namespaceUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespaceUtils.d.ts","sourceRoot":"","sources":["../../src/storage/namespaceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"namespaceUtils.d.ts","sourceRoot":"","sources":["../../src/storage/namespaceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAI9D,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG,eAAe,GAAG,aAAa,GAAG,cAAc,CAAC;AAW1F,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE;IAAE,KAAK,EAAE,SAAS,GAAG,MAAM,CAAC;IAAC,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;CAAE,EAAE,GACpF,OAAO,CAAC,MAAM,CAAC,CAGjB;AAED,wBAAsB,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAK7F;AAED;;;;;;;GAOG;AACH,wBAAsB,wCAAwC,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAM5F;AAED,wBAAsB,+BAA+B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAMnF;AAED,wBAAsB,wBAAwB,CAAC,oBAAoB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAK5F;AAED,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,MAAM,EACd,oBAAoB,EAAE,MAAM,EAC5B,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,MAAM,CAAC,CAKjB"}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.namespaceForContextData = exports.namespaceForContextIndex = exports.namespaceForGeneratedContextKey = exports.namespaceForAnonymousGeneratedContextKey = exports.namespaceForEnvironment = exports.concatNamespacesAndValues = void 0;
|
|
4
|
+
const digest_1 = require("../crypto/digest");
|
|
4
5
|
/**
|
|
5
6
|
* Hashes the input and encodes it as base64
|
|
6
7
|
*/
|
|
7
8
|
function hashAndBase64Encode(crypto) {
|
|
8
|
-
return (input) => crypto.createHash('sha256').update(input)
|
|
9
|
+
return async (input) => (0, digest_1.default)(crypto.createHash('sha256').update(input), 'base64');
|
|
9
10
|
}
|
|
10
|
-
const noop = (input) => input; // no-op transform
|
|
11
|
-
function concatNamespacesAndValues(parts) {
|
|
12
|
-
const processedParts = parts.map((part) => part.transform(part.value)); // use the transform from each part to transform the value
|
|
11
|
+
const noop = async (input) => input; // no-op transform
|
|
12
|
+
async function concatNamespacesAndValues(parts) {
|
|
13
|
+
const processedParts = await Promise.all(parts.map((part) => part.transform(part.value))); // use the transform from each part to transform the value
|
|
13
14
|
return processedParts.join('_');
|
|
14
15
|
}
|
|
15
16
|
exports.concatNamespacesAndValues = concatNamespacesAndValues;
|
|
16
|
-
function namespaceForEnvironment(crypto, sdkKey) {
|
|
17
|
+
async function namespaceForEnvironment(crypto, sdkKey) {
|
|
17
18
|
return concatNamespacesAndValues([
|
|
18
19
|
{ value: 'LaunchDarkly', transform: noop },
|
|
19
20
|
{ value: sdkKey, transform: hashAndBase64Encode(crypto) }, // hash sdk key and encode it
|
|
@@ -28,7 +29,7 @@ exports.namespaceForEnvironment = namespaceForEnvironment;
|
|
|
28
29
|
* when the data under the LaunchDarkly_AnonymousKeys namespace is merged with data under the
|
|
29
30
|
* LaunchDarkly_ContextKeys namespace.
|
|
30
31
|
*/
|
|
31
|
-
function namespaceForAnonymousGeneratedContextKey(kind) {
|
|
32
|
+
async function namespaceForAnonymousGeneratedContextKey(kind) {
|
|
32
33
|
return concatNamespacesAndValues([
|
|
33
34
|
{ value: 'LaunchDarkly', transform: noop },
|
|
34
35
|
{ value: 'AnonymousKeys', transform: noop },
|
|
@@ -36,7 +37,7 @@ function namespaceForAnonymousGeneratedContextKey(kind) {
|
|
|
36
37
|
]);
|
|
37
38
|
}
|
|
38
39
|
exports.namespaceForAnonymousGeneratedContextKey = namespaceForAnonymousGeneratedContextKey;
|
|
39
|
-
function namespaceForGeneratedContextKey(kind) {
|
|
40
|
+
async function namespaceForGeneratedContextKey(kind) {
|
|
40
41
|
return concatNamespacesAndValues([
|
|
41
42
|
{ value: 'LaunchDarkly', transform: noop },
|
|
42
43
|
{ value: 'ContextKeys', transform: noop },
|
|
@@ -44,14 +45,14 @@ function namespaceForGeneratedContextKey(kind) {
|
|
|
44
45
|
]);
|
|
45
46
|
}
|
|
46
47
|
exports.namespaceForGeneratedContextKey = namespaceForGeneratedContextKey;
|
|
47
|
-
function namespaceForContextIndex(environmentNamespace) {
|
|
48
|
+
async function namespaceForContextIndex(environmentNamespace) {
|
|
48
49
|
return concatNamespacesAndValues([
|
|
49
50
|
{ value: environmentNamespace, transform: noop },
|
|
50
51
|
{ value: 'ContextIndex', transform: noop },
|
|
51
52
|
]);
|
|
52
53
|
}
|
|
53
54
|
exports.namespaceForContextIndex = namespaceForContextIndex;
|
|
54
|
-
function namespaceForContextData(crypto, environmentNamespace, context) {
|
|
55
|
+
async function namespaceForContextData(crypto, environmentNamespace, context) {
|
|
55
56
|
return concatNamespacesAndValues([
|
|
56
57
|
{ value: environmentNamespace, transform: noop },
|
|
57
58
|
{ value: context.canonicalKey, transform: hashAndBase64Encode(crypto) }, // hash and encode canonical key
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespaceUtils.js","sourceRoot":"","sources":["../../src/storage/namespaceUtils.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"namespaceUtils.js","sourceRoot":"","sources":["../../src/storage/namespaceUtils.ts"],"names":[],"mappings":";;;AAEA,6CAAsC;AAItC;;GAEG;AACH,SAAS,mBAAmB,CAAC,MAAc;IACzC,OAAO,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,IAAA,gBAAM,EAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,CAAC;AACtF,CAAC;AAED,MAAM,IAAI,GAAG,KAAK,EAAE,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,kBAAkB;AAExD,KAAK,UAAU,yBAAyB,CAC7C,KAAqF;IAErF,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,0DAA0D;IACrJ,OAAO,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClC,CAAC;AALD,8DAKC;AAEM,KAAK,UAAU,uBAAuB,CAAC,MAAc,EAAE,MAAc;IAC1E,OAAO,yBAAyB,CAAC;QAC/B,EAAE,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE;QAC1C,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,mBAAmB,CAAC,MAAM,CAAC,EAAE,EAAE,6BAA6B;KACzF,CAAC,CAAC;AACL,CAAC;AALD,0DAKC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,wCAAwC,CAAC,IAAY;IACzE,OAAO,yBAAyB,CAAC;QAC/B,EAAE,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE;QAC1C,EAAE,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE;QAC3C,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,+EAA+E;KAClH,CAAC,CAAC;AACL,CAAC;AAND,4FAMC;AAEM,KAAK,UAAU,+BAA+B,CAAC,IAAY;IAChE,OAAO,yBAAyB,CAAC;QAC/B,EAAE,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE;QAC1C,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,EAAE;QACzC,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,+EAA+E;KAClH,CAAC,CAAC;AACL,CAAC;AAND,0EAMC;AAEM,KAAK,UAAU,wBAAwB,CAAC,oBAA4B;IACzE,OAAO,yBAAyB,CAAC;QAC/B,EAAE,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,IAAI,EAAE;QAChD,EAAE,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE;KAC3C,CAAC,CAAC;AACL,CAAC;AALD,4DAKC;AAEM,KAAK,UAAU,uBAAuB,CAC3C,MAAc,EACd,oBAA4B,EAC5B,OAAgB;IAEhB,OAAO,yBAAyB,CAAC;QAC/B,EAAE,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,IAAI,EAAE;QAChD,EAAE,KAAK,EAAE,OAAO,CAAC,YAAY,EAAE,SAAS,EAAE,mBAAmB,CAAC,MAAM,CAAC,EAAE,EAAE,gCAAgC;KAC1G,CAAC,CAAC;AACL,CAAC;AATD,0DASC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Encoding, LDHeaders, ServiceEndpoints } from '@launchdarkly/js-sdk-common';
|
|
2
|
+
export interface DataSourceConfig {
|
|
3
|
+
credential: string;
|
|
4
|
+
serviceEndpoints: ServiceEndpoints;
|
|
5
|
+
baseHeaders: LDHeaders;
|
|
6
|
+
withReasons: boolean;
|
|
7
|
+
useReport: boolean;
|
|
8
|
+
paths: DataSourcePaths;
|
|
9
|
+
}
|
|
10
|
+
export interface PollingDataSourceConfig extends DataSourceConfig {
|
|
11
|
+
pollInterval: number;
|
|
12
|
+
}
|
|
13
|
+
export interface StreamingDataSourceConfig extends DataSourceConfig {
|
|
14
|
+
initialRetryDelayMillis: number;
|
|
15
|
+
}
|
|
16
|
+
export interface DataSourcePaths {
|
|
17
|
+
pathGet(encoding: Encoding, plainContextString: string): string;
|
|
18
|
+
pathReport(encoding: Encoding, plainContextString: string): string;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=DataSourceConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataSourceConfig.d.ts","sourceRoot":"","sources":["../../src/streaming/DataSourceConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAEpF,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,WAAW,EAAE,SAAS,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,eAAe,CAAC;CACxB;AAED,MAAM,WAAW,uBAAwB,SAAQ,gBAAgB;IAC/D,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,yBAA0B,SAAQ,gBAAgB;IACjE,uBAAuB,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,GAAG,MAAM,CAAC;IAChE,UAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,GAAG,MAAM,CAAC;CACpE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataSourceConfig.js","sourceRoot":"","sources":["../../src/streaming/DataSourceConfig.ts"],"names":[],"mappings":""}
|