@launchdarkly/cloudflare-server-sdk 0.0.1
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 +25 -0
- package/README.md +57 -0
- package/dist/cjs/package.json +5 -0
- package/dist/cjs/src/createFeatureStore.d.ts +5 -0
- package/dist/cjs/src/createFeatureStore.d.ts.map +1 -0
- package/dist/cjs/src/createFeatureStore.js +62 -0
- package/dist/cjs/src/createFeatureStore.js.map +1 -0
- package/dist/cjs/src/createPlatformInfo.d.ts +8 -0
- package/dist/cjs/src/createPlatformInfo.d.ts.map +1 -0
- package/dist/cjs/src/createPlatformInfo.js +19 -0
- package/dist/cjs/src/createPlatformInfo.js.map +1 -0
- package/dist/cjs/src/index.d.ts +37 -0
- package/dist/cjs/src/index.d.ts.map +1 -0
- package/dist/cjs/src/index.js +49 -0
- package/dist/cjs/src/index.js.map +1 -0
- package/dist/cjs/src/utils/mockKV.d.ts +4 -0
- package/dist/cjs/src/utils/mockKV.d.ts.map +1 -0
- package/dist/cjs/src/utils/mockKV.js +11 -0
- package/dist/cjs/src/utils/mockKV.js.map +1 -0
- package/dist/esm/package.json +5 -0
- package/dist/esm/src/createFeatureStore.d.ts +5 -0
- package/dist/esm/src/createFeatureStore.d.ts.map +1 -0
- package/dist/esm/src/createFeatureStore.js +60 -0
- package/dist/esm/src/createFeatureStore.js.map +1 -0
- package/dist/esm/src/createPlatformInfo.d.ts +8 -0
- package/dist/esm/src/createPlatformInfo.d.ts.map +1 -0
- package/dist/esm/src/createPlatformInfo.js +17 -0
- package/dist/esm/src/createPlatformInfo.js.map +1 -0
- package/dist/esm/src/index.d.ts +37 -0
- package/dist/esm/src/index.d.ts.map +1 -0
- package/dist/esm/src/index.js +31 -0
- package/dist/esm/src/index.js.map +1 -0
- package/dist/esm/src/utils/mockKV.d.ts +4 -0
- package/dist/esm/src/utils/mockKV.d.ts.map +1 -0
- package/dist/esm/src/utils/mockKV.js +9 -0
- package/dist/esm/src/utils/mockKV.js.map +1 -0
- package/package.json +57 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the LaunchDarkly SDK for Cloudflare Workers will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org).
|
|
4
|
+
|
|
5
|
+
## 0.0.1 (2023-04-19)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* cloudflare sdk base ([#74](https://github.com/launchdarkly/js-core/issues/74)) ([add0c63](https://github.com/launchdarkly/js-core/commit/add0c6312c253752d2766cfd499b5134e87a17fb))
|
|
11
|
+
* create sdk-server-edge package ([#83](https://github.com/launchdarkly/js-core/issues/83)) ([0578190](https://github.com/launchdarkly/js-core/commit/0578190123e2712b50774ca3087c7577ef2b9eb2))
|
|
12
|
+
* fix typedoc and export common types ([#81](https://github.com/launchdarkly/js-core/issues/81)) ([daefb60](https://github.com/launchdarkly/js-core/commit/daefb60fb63ac9d2ebd4fea0fadaa0263b0b84ae))
|
|
13
|
+
* support cjs and esm for cloudflare and edge common ([#87](https://github.com/launchdarkly/js-core/issues/87)) ([bab593c](https://github.com/launchdarkly/js-core/commit/bab593cdd9ff8e8881259a21f24c35088e7092bc))
|
|
14
|
+
|
|
15
|
+
## [1.0.0] - 2022-10-13
|
|
16
|
+
|
|
17
|
+
Bump `launchdarkly-node-server-sdk` and move SDK out of beta.
|
|
18
|
+
|
|
19
|
+
## [0.1.1] - 2022-07-07
|
|
20
|
+
|
|
21
|
+
Fix TypeScript definition
|
|
22
|
+
|
|
23
|
+
## [0.1.0] - 2021-10-19
|
|
24
|
+
|
|
25
|
+
This is the first public release of the LaunchDarkly Cloudflare Edge SDK. The SDK is considered to be unsupported and in beta until release 1.0.0.
|
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# LaunchDarkly Cloudflare SDK
|
|
2
|
+
|
|
3
|
+
[![NPM][sdk-server-cloudflare-npm-badge]][sdk-server-cloudflare-npm-link]
|
|
4
|
+
[![Actions Status][sdk-server-cloudflare-ci-badge]][sdk-server-cloudflare-ci]
|
|
5
|
+
[](https://launchdarkly.github.io/js-core/packages/sdk/server-cloudflare/docs/)
|
|
6
|
+
|
|
7
|
+
This library supports using Cloudflare [Workers KV](https://developers.cloudflare.com/workers/learning/how-kv-works) to replace the default in-memory feature store of the [LaunchDarkly Node.js SDK](https://github.com/launchdarkly/cloudflare-server-sdk).
|
|
8
|
+
|
|
9
|
+
For more information, see the [SDK features guide](https://docs.launchdarkly.com/sdk/features/storing-data).
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```shell
|
|
14
|
+
npm i @launchdarkly/cloudflare-server-sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
or yarn:
|
|
18
|
+
|
|
19
|
+
```shell
|
|
20
|
+
yarn add -D @launchdarkly/cloudflare-server-sdk
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quickstart
|
|
24
|
+
|
|
25
|
+
Initialize the ldClient with the [Cloudflare KV namespace](https://developers.cloudflare.com/workers/runtime-apis/kv#kv-bindings) and your client side sdk key:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { init } from '@launchdarkly/cloudflare-server-sdk';
|
|
29
|
+
|
|
30
|
+
const ldClient = init(KV_NAMESPACE, 'YOUR CLIENT-SIDE SDK KEY');
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
To learn more, head straight to the [complete reference guide for this SDK](https://docs.launchdarkly.com/sdk/server-side/cloudflare).
|
|
34
|
+
|
|
35
|
+
## Developing this SDK
|
|
36
|
+
|
|
37
|
+
```shell
|
|
38
|
+
# at js-core repo root
|
|
39
|
+
yarn && yarn build && cd packages/sdk/cloudflare
|
|
40
|
+
|
|
41
|
+
# run tests
|
|
42
|
+
yarn test
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## About LaunchDarkly
|
|
46
|
+
|
|
47
|
+
- LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
|
|
48
|
+
- Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.
|
|
49
|
+
- Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
|
|
50
|
+
- Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
|
|
51
|
+
- Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline.
|
|
52
|
+
- LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Read [our documentation](https://docs.launchdarkly.com/sdk) for a complete list.
|
|
53
|
+
- Explore LaunchDarkly
|
|
54
|
+
- [launchdarkly.com](https://www.launchdarkly.com/ 'LaunchDarkly Main Website') for more information
|
|
55
|
+
- [docs.launchdarkly.com](https://docs.launchdarkly.com/ 'LaunchDarkly Documentation') for our documentation and SDK reference guides
|
|
56
|
+
- [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ 'LaunchDarkly API Documentation') for our API documentation
|
|
57
|
+
- [blog.launchdarkly.com](https://blog.launchdarkly.com/ 'LaunchDarkly Blog Documentation') for the latest product updates
|
|
@@ -0,0 +1,5 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;gBACzE,MAAM,IAAI,GAAG,CAAuB,CAAC;gBACrC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;YACnC,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBACb,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAClB,QAAQ,CAAC,IAAI,CAAC,CAAC;YACjB,CAAC,CAAC,CAAC;QACP,CAAC;QACD,GAAG,CAAC,IAAc,EAAE,WAAkD,gCAAI;YACxE,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;YACzE,MAAM,CAAC,KAAK,CAAC,kBAAkB,OAAO,gBAAgB,CAAC,CAAC;YACxD,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,IAAI,GAAG,CAAuB,CAAC;gBACrC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YAC1B,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBACb,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAClB,QAAQ,CAAC,EAAE,CAAC,CAAC;YACf,CAAC,CAAC,CAAC;QACP,CAAC;QACD,WAAW,CAAC,WAA6C,gCAAI;YAC3D,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;gBACjC,MAAM,MAAM,GAAG,IAAI,KAAK,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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Info, PlatformData, SdkData } from '@launchdarkly/js-server-sdk-common-edge';
|
|
2
|
+
declare class CloudflarePlatformInfo implements Info {
|
|
3
|
+
platformData(): PlatformData;
|
|
4
|
+
sdkData(): SdkData;
|
|
5
|
+
}
|
|
6
|
+
declare const createPlatformInfo: () => CloudflarePlatformInfo;
|
|
7
|
+
export default createPlatformInfo;
|
|
8
|
+
//# sourceMappingURL=createPlatformInfo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPlatformInfo.d.ts","sourceRoot":"","sources":["../../../src/createPlatformInfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AAI3F,cAAM,sBAAuB,YAAW,IAAI;IAC1C,YAAY,IAAI,YAAY;IAM5B,OAAO,IAAI,OAAO;CAMnB;AAED,QAAA,MAAM,kBAAkB,8BAAqC,CAAC;AAE9D,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const package_json_1 = require("../package.json");
|
|
4
|
+
class CloudflarePlatformInfo {
|
|
5
|
+
platformData() {
|
|
6
|
+
return {
|
|
7
|
+
name: 'Cloudflare worker',
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
sdkData() {
|
|
11
|
+
return {
|
|
12
|
+
name: package_json_1.name,
|
|
13
|
+
version: package_json_1.version,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const createPlatformInfo = () => new CloudflarePlatformInfo();
|
|
18
|
+
exports.default = createPlatformInfo;
|
|
19
|
+
//# sourceMappingURL=createPlatformInfo.js.map
|
|
@@ -0,0 +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,mBAAmB;SAC1B,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"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is the API reference for the Cloudflare LaunchDarkly SDK.
|
|
3
|
+
*
|
|
4
|
+
* In typical usage, you will call {@link init} once at startup time to obtain an instance of
|
|
5
|
+
* {@link LDClient}, which provides access to all of the SDK's functionality.
|
|
6
|
+
*
|
|
7
|
+
* For more information, see the SDK reference guide.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
import type { KVNamespace } from '@cloudflare/workers-types';
|
|
12
|
+
import { LDClient, LDOptions } from '@launchdarkly/js-server-sdk-common-edge';
|
|
13
|
+
export * from '@launchdarkly/js-server-sdk-common-edge';
|
|
14
|
+
export type { LDClient };
|
|
15
|
+
/**
|
|
16
|
+
* Creates an instance of the Cloudflare LaunchDarkly client.
|
|
17
|
+
*
|
|
18
|
+
* Applications should instantiate a single instance for the lifetime of the worker.
|
|
19
|
+
* The client will begin attempting to connect to the configured Cloudflare KV as
|
|
20
|
+
* soon as it is created. To determine when it is ready to use, call {@link LDClient.waitForInitialization}.
|
|
21
|
+
*
|
|
22
|
+
* **Important:** Do **not** try to instantiate `LDClient` with its constructor
|
|
23
|
+
* (`new LDClient()/new LDClientImpl()/new LDClient()`); the SDK does not currently support
|
|
24
|
+
* this.
|
|
25
|
+
*
|
|
26
|
+
* @param kvNamespace
|
|
27
|
+
* The Cloudflare KV configured for LaunchDarkly.
|
|
28
|
+
* @param sdkKey
|
|
29
|
+
* The client side SDK key. This is only used to query the kvNamespace above,
|
|
30
|
+
* not to connect with LaunchDarkly servers.
|
|
31
|
+
* @param options
|
|
32
|
+
* Optional configuration settings. The only supported option is logger.
|
|
33
|
+
* @return
|
|
34
|
+
* The new {@link LDClient} instance.
|
|
35
|
+
*/
|
|
36
|
+
export declare const init: (sdkKey: string, kvNamespace: KVNamespace, options?: LDOptions) => LDClient;
|
|
37
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,EAGL,QAAQ,EACR,SAAS,EACV,MAAM,yCAAyC,CAAC;AAIjD,cAAc,yCAAyC,CAAC;AAExD,YAAY,EAAE,QAAQ,EAAE,CAAC;AAEzB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,IAAI,WAAY,MAAM,eAAe,WAAW,YAAW,SAAS,aAOhF,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.init = void 0;
|
|
18
|
+
const js_server_sdk_common_edge_1 = require("@launchdarkly/js-server-sdk-common-edge");
|
|
19
|
+
const createFeatureStore_1 = require("./createFeatureStore");
|
|
20
|
+
const createPlatformInfo_1 = require("./createPlatformInfo");
|
|
21
|
+
__exportStar(require("@launchdarkly/js-server-sdk-common-edge"), exports);
|
|
22
|
+
/**
|
|
23
|
+
* Creates an instance of the Cloudflare LaunchDarkly client.
|
|
24
|
+
*
|
|
25
|
+
* Applications should instantiate a single instance for the lifetime of the worker.
|
|
26
|
+
* The client will begin attempting to connect to the configured Cloudflare KV as
|
|
27
|
+
* soon as it is created. To determine when it is ready to use, call {@link LDClient.waitForInitialization}.
|
|
28
|
+
*
|
|
29
|
+
* **Important:** Do **not** try to instantiate `LDClient` with its constructor
|
|
30
|
+
* (`new LDClient()/new LDClientImpl()/new LDClient()`); the SDK does not currently support
|
|
31
|
+
* this.
|
|
32
|
+
*
|
|
33
|
+
* @param kvNamespace
|
|
34
|
+
* The Cloudflare KV configured for LaunchDarkly.
|
|
35
|
+
* @param sdkKey
|
|
36
|
+
* The client side SDK key. This is only used to query the kvNamespace above,
|
|
37
|
+
* not to connect with LaunchDarkly servers.
|
|
38
|
+
* @param options
|
|
39
|
+
* Optional configuration settings. The only supported option is logger.
|
|
40
|
+
* @return
|
|
41
|
+
* The new {@link LDClient} instance.
|
|
42
|
+
*/
|
|
43
|
+
const init = (sdkKey, kvNamespace, options = {}) => {
|
|
44
|
+
var _a;
|
|
45
|
+
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: (0, createFeatureStore_1.default)(kvNamespace, sdkKey, logger), logger }, options));
|
|
47
|
+
};
|
|
48
|
+
exports.init = init;
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAWA,uFAKiD;AACjD,6DAAsD;AACtD,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,IAAA,4BAAkB,EAAC,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,EAC7D,MAAM,IACH,OAAO,EACV,CAAC;AACL,CAAC,CAAC;AAPW,QAAA,IAAI,QAOf"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,5 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFeatureStore.js","sourceRoot":"","sources":["../../../src/createFeatureStore.ts"],"names":[],"mappings":"AACA,OAAO,EAOL,IAAI,GACL,MAAM,yCAAyC,CAAC;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,IAAI;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,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;gBACzE,MAAM,IAAI,GAAG,CAAuB,CAAC;gBACrC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;YACnC,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBACb,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAClB,QAAQ,CAAC,IAAI,CAAC,CAAC;YACjB,CAAC,CAAC,CAAC;QACP,CAAC;QACD,GAAG,CAAC,IAAc,EAAE,WAAkD,IAAI;YACxE,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;YACzE,MAAM,CAAC,KAAK,CAAC,kBAAkB,OAAO,gBAAgB,CAAC,CAAC;YACxD,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,IAAI,GAAG,CAAuB,CAAC;gBACrC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YAC1B,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBACb,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAClB,QAAQ,CAAC,EAAE,CAAC,CAAC;YACf,CAAC,CAAC,CAAC;QACP,CAAC;QACD,WAAW,CAAC,WAA6C,IAAI;YAC3D,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;gBACjC,MAAM,MAAM,GAAG,IAAI,KAAK,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,IAAI;QACX,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,IAAI;KACb,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Info, PlatformData, SdkData } from '@launchdarkly/js-server-sdk-common-edge';
|
|
2
|
+
declare class CloudflarePlatformInfo implements Info {
|
|
3
|
+
platformData(): PlatformData;
|
|
4
|
+
sdkData(): SdkData;
|
|
5
|
+
}
|
|
6
|
+
declare const createPlatformInfo: () => CloudflarePlatformInfo;
|
|
7
|
+
export default createPlatformInfo;
|
|
8
|
+
//# sourceMappingURL=createPlatformInfo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPlatformInfo.d.ts","sourceRoot":"","sources":["../../../src/createPlatformInfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AAI3F,cAAM,sBAAuB,YAAW,IAAI;IAC1C,YAAY,IAAI,YAAY;IAM5B,OAAO,IAAI,OAAO;CAMnB;AAED,QAAA,MAAM,kBAAkB,8BAAqC,CAAC;AAE9D,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { name, version } from '../package.json';
|
|
2
|
+
class CloudflarePlatformInfo {
|
|
3
|
+
platformData() {
|
|
4
|
+
return {
|
|
5
|
+
name: 'Cloudflare worker',
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
sdkData() {
|
|
9
|
+
return {
|
|
10
|
+
name,
|
|
11
|
+
version,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const createPlatformInfo = () => new CloudflarePlatformInfo();
|
|
16
|
+
export default createPlatformInfo;
|
|
17
|
+
//# sourceMappingURL=createPlatformInfo.js.map
|
|
@@ -0,0 +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,mBAAmB;SAC1B,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"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is the API reference for the Cloudflare LaunchDarkly SDK.
|
|
3
|
+
*
|
|
4
|
+
* In typical usage, you will call {@link init} once at startup time to obtain an instance of
|
|
5
|
+
* {@link LDClient}, which provides access to all of the SDK's functionality.
|
|
6
|
+
*
|
|
7
|
+
* For more information, see the SDK reference guide.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
import type { KVNamespace } from '@cloudflare/workers-types';
|
|
12
|
+
import { LDClient, LDOptions } from '@launchdarkly/js-server-sdk-common-edge';
|
|
13
|
+
export * from '@launchdarkly/js-server-sdk-common-edge';
|
|
14
|
+
export type { LDClient };
|
|
15
|
+
/**
|
|
16
|
+
* Creates an instance of the Cloudflare LaunchDarkly client.
|
|
17
|
+
*
|
|
18
|
+
* Applications should instantiate a single instance for the lifetime of the worker.
|
|
19
|
+
* The client will begin attempting to connect to the configured Cloudflare KV as
|
|
20
|
+
* soon as it is created. To determine when it is ready to use, call {@link LDClient.waitForInitialization}.
|
|
21
|
+
*
|
|
22
|
+
* **Important:** Do **not** try to instantiate `LDClient` with its constructor
|
|
23
|
+
* (`new LDClient()/new LDClientImpl()/new LDClient()`); the SDK does not currently support
|
|
24
|
+
* this.
|
|
25
|
+
*
|
|
26
|
+
* @param kvNamespace
|
|
27
|
+
* The Cloudflare KV configured for LaunchDarkly.
|
|
28
|
+
* @param sdkKey
|
|
29
|
+
* The client side SDK key. This is only used to query the kvNamespace above,
|
|
30
|
+
* not to connect with LaunchDarkly servers.
|
|
31
|
+
* @param options
|
|
32
|
+
* Optional configuration settings. The only supported option is logger.
|
|
33
|
+
* @return
|
|
34
|
+
* The new {@link LDClient} instance.
|
|
35
|
+
*/
|
|
36
|
+
export declare const init: (sdkKey: string, kvNamespace: KVNamespace, options?: LDOptions) => LDClient;
|
|
37
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,EAGL,QAAQ,EACR,SAAS,EACV,MAAM,yCAAyC,CAAC;AAIjD,cAAc,yCAAyC,CAAC;AAExD,YAAY,EAAE,QAAQ,EAAE,CAAC;AAEzB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,IAAI,WAAY,MAAM,eAAe,WAAW,YAAW,SAAS,aAOhF,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BasicLogger, init as initEdge, } from '@launchdarkly/js-server-sdk-common-edge';
|
|
2
|
+
import createFeatureStore from './createFeatureStore';
|
|
3
|
+
import createPlatformInfo from './createPlatformInfo';
|
|
4
|
+
export * from '@launchdarkly/js-server-sdk-common-edge';
|
|
5
|
+
/**
|
|
6
|
+
* Creates an instance of the Cloudflare LaunchDarkly client.
|
|
7
|
+
*
|
|
8
|
+
* Applications should instantiate a single instance for the lifetime of the worker.
|
|
9
|
+
* The client will begin attempting to connect to the configured Cloudflare KV as
|
|
10
|
+
* soon as it is created. To determine when it is ready to use, call {@link LDClient.waitForInitialization}.
|
|
11
|
+
*
|
|
12
|
+
* **Important:** Do **not** try to instantiate `LDClient` with its constructor
|
|
13
|
+
* (`new LDClient()/new LDClientImpl()/new LDClient()`); the SDK does not currently support
|
|
14
|
+
* this.
|
|
15
|
+
*
|
|
16
|
+
* @param kvNamespace
|
|
17
|
+
* The Cloudflare KV configured for LaunchDarkly.
|
|
18
|
+
* @param sdkKey
|
|
19
|
+
* The client side SDK key. This is only used to query the kvNamespace above,
|
|
20
|
+
* not to connect with LaunchDarkly servers.
|
|
21
|
+
* @param options
|
|
22
|
+
* Optional configuration settings. The only supported option is logger.
|
|
23
|
+
* @return
|
|
24
|
+
* The new {@link LDClient} instance.
|
|
25
|
+
*/
|
|
26
|
+
export const init = (sdkKey, kvNamespace, options = {}) => {
|
|
27
|
+
var _a;
|
|
28
|
+
const logger = (_a = options.logger) !== null && _a !== void 0 ? _a : BasicLogger.get();
|
|
29
|
+
return initEdge(sdkKey, createPlatformInfo(), Object.assign({ featureStore: createFeatureStore(kvNamespace, sdkKey, logger), logger }, options));
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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;AACtD,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,kBAAkB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,EAC7D,MAAM,IACH,OAAO,EACV,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@launchdarkly/cloudflare-server-sdk",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Cloudflare LaunchDarkly SDK",
|
|
5
|
+
"packageManager": "yarn@3.4.1",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"launchdarkly",
|
|
8
|
+
"cloudflare",
|
|
9
|
+
"edge",
|
|
10
|
+
"worker"
|
|
11
|
+
],
|
|
12
|
+
"type": "module",
|
|
13
|
+
"exports": {
|
|
14
|
+
"require": "./dist/cjs/src/index.js",
|
|
15
|
+
"import": "./dist/esm/src/index.js"
|
|
16
|
+
},
|
|
17
|
+
"main": "./dist/cjs/src/index.js",
|
|
18
|
+
"types": "./dist/cjs/src/index.d.ts",
|
|
19
|
+
"files": [
|
|
20
|
+
"/dist"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"doc": "../../../scripts/build-doc.sh .",
|
|
24
|
+
"build": "../../../scripts/build-package.sh",
|
|
25
|
+
"tsw": "yarn tsc --watch",
|
|
26
|
+
"start": "rimraf dist && yarn tsw",
|
|
27
|
+
"lint": "eslint . --ext .ts",
|
|
28
|
+
"prettier": "prettier --write '**/*.@(js|ts|tsx|json|css)' --ignore-path ../../../.prettierignore",
|
|
29
|
+
"test": "NODE_OPTIONS=\"--experimental-vm-modules --no-warnings\" jest --ci --runInBand --coverage",
|
|
30
|
+
"check": "yarn prettier && yarn lint && yarn build && yarn test && yarn doc"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@cloudflare/workers-types": "^4.20230321.0",
|
|
34
|
+
"@launchdarkly/js-server-sdk-common-edge": "0.0.1",
|
|
35
|
+
"crypto-js": "^4.1.1"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/crypto-js": "^4.1.1",
|
|
39
|
+
"@types/jest": "^29.5.0",
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
|
41
|
+
"@typescript-eslint/parser": "^5.57.0",
|
|
42
|
+
"eslint": "^8.37.0",
|
|
43
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
44
|
+
"eslint-config-airbnb-typescript": "^17.0.0",
|
|
45
|
+
"eslint-config-prettier": "^8.8.0",
|
|
46
|
+
"eslint-plugin-import": "^2.27.5",
|
|
47
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
48
|
+
"jest": "^29.5.0",
|
|
49
|
+
"launchdarkly-js-test-helpers": "^2.2.0",
|
|
50
|
+
"miniflare": "^2.13.0",
|
|
51
|
+
"prettier": "^2.8.7",
|
|
52
|
+
"rimraf": "^5.0.0",
|
|
53
|
+
"ts-jest": "^29.1.0",
|
|
54
|
+
"typedoc": "0.23.26",
|
|
55
|
+
"typescript": "^5.0.3"
|
|
56
|
+
}
|
|
57
|
+
}
|