@launchdarkly/cloudflare-server-sdk 2.0.0 → 2.0.2
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 +30 -0
- package/LICENSE +13 -0
- package/README.md +2 -4
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/createPlatformInfo.js +1 -1
- package/dist/cjs/src/createPlatformInfo.js.map +1 -1
- package/dist/cjs/src/index.d.ts.map +1 -1
- package/dist/cjs/src/index.js +1 -2
- package/dist/cjs/src/index.js.map +1 -1
- package/dist/esm/package.json +1 -1
- package/dist/esm/src/createPlatformInfo.js +1 -1
- package/dist/esm/src/createPlatformInfo.js.map +1 -1
- package/dist/esm/src/index.d.ts.map +1 -1
- package/dist/esm/src/index.js +2 -3
- package/dist/esm/src/index.js.map +1 -1
- package/package.json +12 -4
- package/dist/cjs/src/createFeatureStore.d.ts +0 -5
- package/dist/cjs/src/createFeatureStore.d.ts.map +0 -1
- package/dist/cjs/src/createFeatureStore.js +0 -62
- package/dist/cjs/src/createFeatureStore.js.map +0 -1
- package/dist/cjs/src/utils/mockKV.d.ts +0 -4
- package/dist/cjs/src/utils/mockKV.d.ts.map +0 -1
- package/dist/cjs/src/utils/mockKV.js +0 -11
- package/dist/cjs/src/utils/mockKV.js.map +0 -1
- package/dist/esm/src/createFeatureStore.d.ts +0 -5
- package/dist/esm/src/createFeatureStore.d.ts.map +0 -1
- package/dist/esm/src/createFeatureStore.js +0 -60
- package/dist/esm/src/createFeatureStore.js.map +0 -1
- package/dist/esm/src/utils/mockKV.d.ts +0 -4
- package/dist/esm/src/utils/mockKV.d.ts.map +0 -1
- package/dist/esm/src/utils/mockKV.js +0 -9
- package/dist/esm/src/utils/mockKV.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,36 @@ All notable changes to the LaunchDarkly SDK for Cloudflare Workers will be docum
|
|
|
8
8
|
* dependencies
|
|
9
9
|
* @launchdarkly/js-server-sdk-common-edge bumped from 0.0.2 to 0.0.3
|
|
10
10
|
|
|
11
|
+
## [2.0.2](https://github.com/launchdarkly/js-core/compare/cloudflare-server-sdk-v2.0.1...cloudflare-server-sdk-v2.0.2) (2023-04-28)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* fixed bug where the feature store does not deserialize KV values… ([#107](https://github.com/launchdarkly/js-core/issues/107)) ([68113b7](https://github.com/launchdarkly/js-core/commit/68113b7ac39f70a92b291eb2c0eda3b7d78145fc))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Dependencies
|
|
20
|
+
|
|
21
|
+
* The following workspace dependencies were updated
|
|
22
|
+
* dependencies
|
|
23
|
+
* @launchdarkly/js-server-sdk-common-edge bumped from 1.0.1 to 1.0.2
|
|
24
|
+
|
|
25
|
+
## [2.0.1](https://github.com/launchdarkly/js-core/compare/cloudflare-server-sdk-v2.0.0...cloudflare-server-sdk-v2.0.1) (2023-04-27)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* add licence and fix missing package.json fields. ([c586398](https://github.com/launchdarkly/js-core/commit/c5863980c5bf4ee2a7590dfc4f7c575045d669b0))
|
|
31
|
+
* Ensure top level commands work correctly ([#105](https://github.com/launchdarkly/js-core/issues/105)) ([762571f](https://github.com/launchdarkly/js-core/commit/762571ff851558d229e4d29ba40a9c16b89f2a8d))
|
|
32
|
+
* remove beta text from cloudflare sdk readme. ([c586398](https://github.com/launchdarkly/js-core/commit/c5863980c5bf4ee2a7590dfc4f7c575045d669b0))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Dependencies
|
|
36
|
+
|
|
37
|
+
* The following workspace dependencies were updated
|
|
38
|
+
* dependencies
|
|
39
|
+
* @launchdarkly/js-server-sdk-common-edge bumped from 1.0.0 to 1.0.1
|
|
40
|
+
|
|
11
41
|
## [2.0.0](https://github.com/launchdarkly/js-core/compare/cloudflare-server-sdk-v0.0.4...cloudflare-server-sdk-v2.0.0) (2023-04-26)
|
|
12
42
|
|
|
13
43
|
|
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2022 Catamorphic, Co.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
The LaunchDarkly Cloudflare SDK is designed primarily for use in multi-user Cloudflare workers. It follows the server-side LaunchDarkly model for multi-user contexts. It is not intended for use in desktop and embedded systems applications.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
This SDK is a replacement of [launchdarkly-cloudflare-edge-sdk](https://github.com/launchdarkly/cloudflare-edge-sdk). Please consider updating your application to use this package instead.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
For more information, see the [complete reference guide for this SDK](https://docs.launchdarkly.com/sdk/server-side/cloudflare).
|
|
14
14
|
|
|
15
15
|
## Install
|
|
16
16
|
|
|
@@ -49,8 +49,6 @@ export default {
|
|
|
49
49
|
|
|
50
50
|
See the full [example app](https://github.com/launchdarkly/js-core/tree/main/packages/sdk/cloudflare/example).
|
|
51
51
|
|
|
52
|
-
Read the [complete reference guide for this SDK](https://docs.launchdarkly.com/sdk/server-side/cloudflare).
|
|
53
|
-
|
|
54
52
|
## Developing this SDK
|
|
55
53
|
|
|
56
54
|
```shell
|
package/dist/cjs/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPlatformInfo.js","sourceRoot":"","sources":["../../../src/createPlatformInfo.ts"],"names":[],"mappings":";;AAEA,kDAAgD;AAEhD,MAAM,sBAAsB;IAC1B,YAAY;QACV,OAAO;YACL,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"createPlatformInfo.js","sourceRoot":"","sources":["../../../src/createPlatformInfo.ts"],"names":[],"mappings":";;AAEA,kDAAgD;AAEhD,MAAM,sBAAsB;IAC1B,YAAY;QACV,OAAO;YACL,IAAI,EAAE,YAAY;SACnB,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO;YACL,IAAI,EAAJ,mBAAI;YACJ,OAAO,EAAP,sBAAO;SACR,CAAC;IACJ,CAAC;CACF;AAED,MAAM,kBAAkB,GAAG,GAAG,EAAE,CAAC,IAAI,sBAAsB,EAAE,CAAC;AAE9D,kBAAe,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAIL,QAAQ,EACR,SAAS,EACV,MAAM,yCAAyC,CAAC;AAGjD,cAAc,yCAAyC,CAAC;AAExD,YAAY,EAAE,QAAQ,EAAE,CAAC;AAEzB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,IAAI,WAAY,MAAM,eAAe,WAAW,YAAW,SAAS,aAOhF,CAAC"}
|
package/dist/cjs/src/index.js
CHANGED
|
@@ -16,7 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.init = void 0;
|
|
18
18
|
const js_server_sdk_common_edge_1 = require("@launchdarkly/js-server-sdk-common-edge");
|
|
19
|
-
const createFeatureStore_1 = require("./createFeatureStore");
|
|
20
19
|
const createPlatformInfo_1 = require("./createPlatformInfo");
|
|
21
20
|
__exportStar(require("@launchdarkly/js-server-sdk-common-edge"), exports);
|
|
22
21
|
/**
|
|
@@ -43,7 +42,7 @@ __exportStar(require("@launchdarkly/js-server-sdk-common-edge"), exports);
|
|
|
43
42
|
const init = (sdkKey, kvNamespace, options = {}) => {
|
|
44
43
|
var _a;
|
|
45
44
|
const logger = (_a = options.logger) !== null && _a !== void 0 ? _a : js_server_sdk_common_edge_1.BasicLogger.get();
|
|
46
|
-
return (0, js_server_sdk_common_edge_1.init)(sdkKey, (0, createPlatformInfo_1.default)(), Object.assign({ featureStore:
|
|
45
|
+
return (0, js_server_sdk_common_edge_1.init)(sdkKey, (0, createPlatformInfo_1.default)(), Object.assign({ featureStore: new js_server_sdk_common_edge_1.EdgeFeatureStore(kvNamespace, sdkKey, 'Cloudflare', logger), logger }, options));
|
|
47
46
|
};
|
|
48
47
|
exports.init = init;
|
|
49
48
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAWA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAWA,uFAMiD;AACjD,6DAAsD;AAEtD,0EAAwD;AAIxD;;;;;;;;;;;;;;;;;;;;GAoBG;AACI,MAAM,IAAI,GAAG,CAAC,MAAc,EAAE,WAAwB,EAAE,UAAqB,EAAE,EAAE,EAAE;;IACxF,MAAM,MAAM,GAAG,MAAA,OAAO,CAAC,MAAM,mCAAI,uCAAW,CAAC,GAAG,EAAE,CAAC;IACnD,OAAO,IAAA,gCAAQ,EAAC,MAAM,EAAE,IAAA,4BAAkB,GAAE,kBAC1C,YAAY,EAAE,IAAI,4CAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,EAC7E,MAAM,IACH,OAAO,EACV,CAAC;AACL,CAAC,CAAC;AAPW,QAAA,IAAI,QAOf"}
|
package/dist/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPlatformInfo.js","sourceRoot":"","sources":["../../../src/createPlatformInfo.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,sBAAsB;IAC1B,YAAY;QACV,OAAO;YACL,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"createPlatformInfo.js","sourceRoot":"","sources":["../../../src/createPlatformInfo.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,sBAAsB;IAC1B,YAAY;QACV,OAAO;YACL,IAAI,EAAE,YAAY;SACnB,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO;YACL,IAAI;YACJ,OAAO;SACR,CAAC;IACJ,CAAC;CACF;AAED,MAAM,kBAAkB,GAAG,GAAG,EAAE,CAAC,IAAI,sBAAsB,EAAE,CAAC;AAE9D,eAAe,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAIL,QAAQ,EACR,SAAS,EACV,MAAM,yCAAyC,CAAC;AAGjD,cAAc,yCAAyC,CAAC;AAExD,YAAY,EAAE,QAAQ,EAAE,CAAC;AAEzB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,IAAI,WAAY,MAAM,eAAe,WAAW,YAAW,SAAS,aAOhF,CAAC"}
|
package/dist/esm/src/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { BasicLogger, init as initEdge, } from '@launchdarkly/js-server-sdk-common-edge';
|
|
2
|
-
import createFeatureStore from './createFeatureStore';
|
|
1
|
+
import { BasicLogger, EdgeFeatureStore, init as initEdge, } from '@launchdarkly/js-server-sdk-common-edge';
|
|
3
2
|
import createPlatformInfo from './createPlatformInfo';
|
|
4
3
|
export * from '@launchdarkly/js-server-sdk-common-edge';
|
|
5
4
|
/**
|
|
@@ -26,6 +25,6 @@ export * from '@launchdarkly/js-server-sdk-common-edge';
|
|
|
26
25
|
export const init = (sdkKey, kvNamespace, options = {}) => {
|
|
27
26
|
var _a;
|
|
28
27
|
const logger = (_a = options.logger) !== null && _a !== void 0 ? _a : BasicLogger.get();
|
|
29
|
-
return initEdge(sdkKey, createPlatformInfo(), Object.assign({ featureStore:
|
|
28
|
+
return initEdge(sdkKey, createPlatformInfo(), Object.assign({ featureStore: new EdgeFeatureStore(kvNamespace, sdkKey, 'Cloudflare', logger), logger }, options));
|
|
30
29
|
};
|
|
31
30
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,WAAW,EACX,IAAI,IAAI,QAAQ,GAGjB,MAAM,yCAAyC,CAAC;AACjD,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,IAAI,IAAI,QAAQ,GAGjB,MAAM,yCAAyC,CAAC;AACjD,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAEtD,cAAc,yCAAyC,CAAC;AAIxD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,MAAc,EAAE,WAAwB,EAAE,UAAqB,EAAE,EAAE,EAAE;;IACxF,MAAM,MAAM,GAAG,MAAA,OAAO,CAAC,MAAM,mCAAI,WAAW,CAAC,GAAG,EAAE,CAAC;IACnD,OAAO,QAAQ,CAAC,MAAM,EAAE,kBAAkB,EAAE,kBAC1C,YAAY,EAAE,IAAI,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,EAC7E,MAAM,IACH,OAAO,EACV,CAAC;AACL,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@launchdarkly/cloudflare-server-sdk",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Cloudflare LaunchDarkly SDK",
|
|
5
|
+
"homepage": "https://github.com/launchdarkly/js-core/tree/main/packages/sdk/cloudflare",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/launchdarkly/js-core.git"
|
|
9
|
+
},
|
|
10
|
+
"license": "Apache-2.0",
|
|
5
11
|
"packageManager": "yarn@3.4.1",
|
|
6
12
|
"keywords": [
|
|
7
13
|
"launchdarkly",
|
|
@@ -17,21 +23,23 @@
|
|
|
17
23
|
"main": "./dist/cjs/src/index.js",
|
|
18
24
|
"types": "./dist/cjs/src/index.d.ts",
|
|
19
25
|
"files": [
|
|
20
|
-
"
|
|
26
|
+
"dist"
|
|
21
27
|
],
|
|
22
28
|
"scripts": {
|
|
23
29
|
"doc": "../../../scripts/build-doc.sh .",
|
|
24
30
|
"build": "../../../scripts/build-package.sh",
|
|
31
|
+
"clean": "rimraf dist",
|
|
25
32
|
"tsw": "yarn tsc --watch",
|
|
26
33
|
"start": "rimraf dist && yarn tsw",
|
|
27
34
|
"lint": "eslint . --ext .ts",
|
|
28
35
|
"prettier": "prettier --write '**/*.@(js|ts|tsx|json|css)' --ignore-path ../../../.prettierignore",
|
|
29
|
-
"test": "NODE_OPTIONS=\"--experimental-vm-modules --no-warnings\" jest --ci --runInBand
|
|
36
|
+
"test": "NODE_OPTIONS=\"--experimental-vm-modules --no-warnings\" jest --ci --runInBand",
|
|
37
|
+
"coverage": "yarn test --coverage",
|
|
30
38
|
"check": "yarn prettier && yarn lint && yarn build && yarn test && yarn doc"
|
|
31
39
|
},
|
|
32
40
|
"dependencies": {
|
|
33
41
|
"@cloudflare/workers-types": "^4.20230321.0",
|
|
34
|
-
"@launchdarkly/js-server-sdk-common-edge": "1.0.
|
|
42
|
+
"@launchdarkly/js-server-sdk-common-edge": "1.0.2",
|
|
35
43
|
"crypto-js": "^4.1.1"
|
|
36
44
|
},
|
|
37
45
|
"devDependencies": {
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { KVNamespace } from '@cloudflare/workers-types';
|
|
2
|
-
import { LDLogger, LDFeatureStore } from '@launchdarkly/js-server-sdk-common-edge';
|
|
3
|
-
declare const createFeatureStore: (kvNamespace: KVNamespace, sdkKey: string, logger: LDLogger) => LDFeatureStore;
|
|
4
|
-
export default createFeatureStore;
|
|
5
|
-
//# sourceMappingURL=createFeatureStore.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createFeatureStore.d.ts","sourceRoot":"","sources":["../../../src/createFeatureStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAEL,QAAQ,EACR,cAAc,EAKf,MAAM,yCAAyC,CAAC;AAEjD,QAAA,MAAM,kBAAkB,gBAAiB,WAAW,UAAU,MAAM,UAAU,QAAQ,mBA8DrF,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const js_server_sdk_common_edge_1 = require("@launchdarkly/js-server-sdk-common-edge");
|
|
4
|
-
const createFeatureStore = (kvNamespace, sdkKey, logger) => {
|
|
5
|
-
const key = `LD-Env-${sdkKey}`;
|
|
6
|
-
const store = {
|
|
7
|
-
get(kind, flagKey, callback = js_server_sdk_common_edge_1.noop) {
|
|
8
|
-
logger.debug(`Requesting ${flagKey} from ${key}`);
|
|
9
|
-
kvNamespace
|
|
10
|
-
.get(key, { type: 'json' })
|
|
11
|
-
.then((i) => {
|
|
12
|
-
if (i === null) {
|
|
13
|
-
logger.error('Feature data not found in KV.');
|
|
14
|
-
}
|
|
15
|
-
const kindKey = kind.namespace === 'features' ? 'flags' : kind.namespace;
|
|
16
|
-
const item = i;
|
|
17
|
-
callback(item[kindKey][flagKey]);
|
|
18
|
-
})
|
|
19
|
-
.catch((err) => {
|
|
20
|
-
logger.error(err);
|
|
21
|
-
callback(null);
|
|
22
|
-
});
|
|
23
|
-
},
|
|
24
|
-
all(kind, callback = js_server_sdk_common_edge_1.noop) {
|
|
25
|
-
const kindKey = kind.namespace === 'features' ? 'flags' : kind.namespace;
|
|
26
|
-
logger.debug(`Requesting all ${kindKey} data from KV.`);
|
|
27
|
-
kvNamespace
|
|
28
|
-
.get(key, { type: 'json' })
|
|
29
|
-
.then((i) => {
|
|
30
|
-
if (i === null) {
|
|
31
|
-
logger.error('Feature data not found in KV.');
|
|
32
|
-
}
|
|
33
|
-
const item = i;
|
|
34
|
-
callback(item[kindKey]);
|
|
35
|
-
})
|
|
36
|
-
.catch((err) => {
|
|
37
|
-
logger.error(err);
|
|
38
|
-
callback({});
|
|
39
|
-
});
|
|
40
|
-
},
|
|
41
|
-
initialized(callback = js_server_sdk_common_edge_1.noop) {
|
|
42
|
-
kvNamespace.get(key).then((item) => {
|
|
43
|
-
const result = item !== null;
|
|
44
|
-
logger.debug(`Is ${key} initialized? ${result}`);
|
|
45
|
-
callback(result);
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
init(allData, callback) {
|
|
49
|
-
callback();
|
|
50
|
-
},
|
|
51
|
-
getDescription() {
|
|
52
|
-
return 'Cloudflare';
|
|
53
|
-
},
|
|
54
|
-
// unused
|
|
55
|
-
close: js_server_sdk_common_edge_1.noop,
|
|
56
|
-
delete: js_server_sdk_common_edge_1.noop,
|
|
57
|
-
upsert: js_server_sdk_common_edge_1.noop,
|
|
58
|
-
};
|
|
59
|
-
return store;
|
|
60
|
-
};
|
|
61
|
-
exports.default = createFeatureStore;
|
|
62
|
-
//# sourceMappingURL=createFeatureStore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createFeatureStore.js","sourceRoot":"","sources":["../../../src/createFeatureStore.ts"],"names":[],"mappings":";;AACA,uFAQiD;AAEjD,MAAM,kBAAkB,GAAG,CAAC,WAAwB,EAAE,MAAc,EAAE,MAAgB,EAAE,EAAE;IACxF,MAAM,GAAG,GAAG,UAAU,MAAM,EAAE,CAAC;IAC/B,MAAM,KAAK,GAAmB;QAC5B,GAAG,CACD,IAAc,EACd,OAAe,EACf,WAAqD,gCAAI;YAEzD,MAAM,CAAC,KAAK,CAAC,cAAc,OAAO,SAAS,GAAG,EAAE,CAAC,CAAC;YAClD,WAAW;iBACR,GAAG,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iBAC1B,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;gBACV,IAAI,CAAC,KAAK,IAAI,EAAE;oBACd,MAAM,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;iBAC/C;gBACD,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,KAAK,UAAU,C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AK,IAAI,CAAC;gBAC7B,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,iBAAiB,MAAM,EAAE,CAAC,CAAC;gBACjD,QAAQ,CAAC,MAAM,CAAC,CAAC;YACnB,CAAC,CAAC,CAAC;QACL,CAAC;QACD,IAAI,CAAC,OAAkC,EAAE,QAAoB;YAC3D,QAAQ,EAAE,CAAC;QACb,CAAC;QACD,cAAc;YACZ,OAAO,YAAY,CAAC;QACtB,CAAC;QAED,SAAS;QACT,KAAK,EAAE,gCAAI;QACX,MAAM,EAAE,gCAAI;QACZ,MAAM,EAAE,gCAAI;KACb,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,kBAAe,kBAAkB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mockKV.d.ts","sourceRoot":"","sources":["../../../../src/utils/mockKV.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7D,QAAA,MAAM,MAAM,EAAE,WAAW,CAAC,MAAM,CAM/B,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const mockKV = {
|
|
4
|
-
get: jest.fn(),
|
|
5
|
-
list: jest.fn(),
|
|
6
|
-
put: jest.fn(),
|
|
7
|
-
getWithMetadata: jest.fn(),
|
|
8
|
-
delete: jest.fn(),
|
|
9
|
-
};
|
|
10
|
-
exports.default = mockKV;
|
|
11
|
-
//# sourceMappingURL=mockKV.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mockKV.js","sourceRoot":"","sources":["../../../../src/utils/mockKV.ts"],"names":[],"mappings":";;AAEA,MAAM,MAAM,GAAwB;IAClC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;IACd,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;IACf,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;IACd,eAAe,EAAE,IAAI,CAAC,EAAE,EAAE;IAC1B,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;CAClB,CAAC;AAEF,kBAAe,MAAM,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { KVNamespace } from '@cloudflare/workers-types';
|
|
2
|
-
import { LDLogger, LDFeatureStore } from '@launchdarkly/js-server-sdk-common-edge';
|
|
3
|
-
declare const createFeatureStore: (kvNamespace: KVNamespace, sdkKey: string, logger: LDLogger) => LDFeatureStore;
|
|
4
|
-
export default createFeatureStore;
|
|
5
|
-
//# sourceMappingURL=createFeatureStore.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createFeatureStore.d.ts","sourceRoot":"","sources":["../../../src/createFeatureStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAEL,QAAQ,EACR,cAAc,EAKf,MAAM,yCAAyC,CAAC;AAEjD,QAAA,MAAM,kBAAkB,gBAAiB,WAAW,UAAU,MAAM,UAAU,QAAQ,mBA8DrF,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { noop, } from '@launchdarkly/js-server-sdk-common-edge';
|
|
2
|
-
const createFeatureStore = (kvNamespace, sdkKey, logger) => {
|
|
3
|
-
const key = `LD-Env-${sdkKey}`;
|
|
4
|
-
const store = {
|
|
5
|
-
get(kind, flagKey, callback = noop) {
|
|
6
|
-
logger.debug(`Requesting ${flagKey} from ${key}`);
|
|
7
|
-
kvNamespace
|
|
8
|
-
.get(key, { type: 'json' })
|
|
9
|
-
.then((i) => {
|
|
10
|
-
if (i === null) {
|
|
11
|
-
logger.error('Feature data not found in KV.');
|
|
12
|
-
}
|
|
13
|
-
const kindKey = kind.namespace === 'features' ? 'flags' : kind.namespace;
|
|
14
|
-
const item = i;
|
|
15
|
-
callback(item[kindKey][flagKey]);
|
|
16
|
-
})
|
|
17
|
-
.catch((err) => {
|
|
18
|
-
logger.error(err);
|
|
19
|
-
callback(null);
|
|
20
|
-
});
|
|
21
|
-
},
|
|
22
|
-
all(kind, callback = noop) {
|
|
23
|
-
const kindKey = kind.namespace === 'features' ? 'flags' : kind.namespace;
|
|
24
|
-
logger.debug(`Requesting all ${kindKey} data from KV.`);
|
|
25
|
-
kvNamespace
|
|
26
|
-
.get(key, { type: 'json' })
|
|
27
|
-
.then((i) => {
|
|
28
|
-
if (i === null) {
|
|
29
|
-
logger.error('Feature data not found in KV.');
|
|
30
|
-
}
|
|
31
|
-
const item = i;
|
|
32
|
-
callback(item[kindKey]);
|
|
33
|
-
})
|
|
34
|
-
.catch((err) => {
|
|
35
|
-
logger.error(err);
|
|
36
|
-
callback({});
|
|
37
|
-
});
|
|
38
|
-
},
|
|
39
|
-
initialized(callback = noop) {
|
|
40
|
-
kvNamespace.get(key).then((item) => {
|
|
41
|
-
const result = item !== null;
|
|
42
|
-
logger.debug(`Is ${key} initialized? ${result}`);
|
|
43
|
-
callback(result);
|
|
44
|
-
});
|
|
45
|
-
},
|
|
46
|
-
init(allData, callback) {
|
|
47
|
-
callback();
|
|
48
|
-
},
|
|
49
|
-
getDescription() {
|
|
50
|
-
return 'Cloudflare';
|
|
51
|
-
},
|
|
52
|
-
// unused
|
|
53
|
-
close: noop,
|
|
54
|
-
delete: noop,
|
|
55
|
-
upsert: noop,
|
|
56
|
-
};
|
|
57
|
-
return store;
|
|
58
|
-
};
|
|
59
|
-
export default createFeatureStore;
|
|
60
|
-
//# sourceMappingURL=createFeatureStore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createFeatureStore.js","sourceRoot":"","sources":["../../../src/createFeatureStore.ts"],"names":[],"mappings":"AACA,OAAO,EAOL,IAAI,GACL,MAAM,yCAAyC,CAAC;AAEjD,MAAM,kBAAk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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mockKV.js","sourceRoot":"","sources":["../../../../src/utils/mockKV.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAwB;IAClC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;IACd,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;IACf,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;IACd,eAAe,EAAE,IAAI,CAAC,EAAE,EAAE;IAC1B,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;CAClB,CAAC;AAEF,eAAe,MAAM,CAAC"}
|