@launchdarkly/cloudflare-server-sdk 2.2.0-alpha → 2.2.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.
@@ -1,3 +1,8 @@
1
+ import { KVNamespace } from '@cloudflare/workers-types';
2
+ import { LDOptions, LDClient } from '@launchdarkly/js-server-sdk-common-edge';
3
+ export * from '@launchdarkly/js-server-sdk-common-edge';
4
+ export { LDClient } from '@launchdarkly/js-server-sdk-common-edge';
5
+
1
6
  /**
2
7
  * This is the API reference for the Cloudflare LaunchDarkly SDK.
3
8
  *
@@ -8,10 +13,7 @@
8
13
  *
9
14
  * @packageDocumentation
10
15
  */
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 };
16
+
15
17
  /**
16
18
  * Creates an instance of the Cloudflare LaunchDarkly client.
17
19
  *
@@ -23,15 +25,16 @@ export type { LDClient };
23
25
  * (`new LDClient()/new LDClientImpl()/new LDClient()`); the SDK does not currently support
24
26
  * this.
25
27
  *
26
- * @param clientSideID
27
- * The client side ID. This is only used to query the kvNamespace above,
28
- * not to connect with LaunchDarkly servers.
29
28
  * @param kvNamespace
30
29
  * The Cloudflare KV configured for LaunchDarkly.
30
+ * @param sdkKey
31
+ * The client side SDK key. This is only used to query the kvNamespace above,
32
+ * not to connect with LaunchDarkly servers.
31
33
  * @param options
32
34
  * Optional configuration settings. The only supported option is logger.
33
35
  * @return
34
36
  * The new {@link LDClient} instance.
35
37
  */
36
- export declare const init: (clientSideID: string, kvNamespace: KVNamespace, options?: LDOptions) => LDClient;
37
- //# sourceMappingURL=index.d.ts.map
38
+ declare const init: (sdkKey: string, kvNamespace: KVNamespace, options?: LDOptions) => LDClient;
39
+
40
+ export { init };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@launchdarkly/cloudflare-server-sdk",
3
- "version": "2.2.0-alpha",
3
+ "version": "2.2.1",
4
4
  "description": "Cloudflare LaunchDarkly SDK",
5
5
  "homepage": "https://github.com/launchdarkly/js-core/tree/main/packages/sdk/cloudflare",
6
6
  "repository": {
@@ -17,34 +17,43 @@
17
17
  ],
18
18
  "type": "module",
19
19
  "exports": {
20
- "require": "./dist/cjs/src/index.js",
21
- "import": "./dist/esm/src/index.js"
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/esm/index.js",
22
+ "require": "./dist/cjs/index.js"
22
23
  },
23
- "main": "./dist/cjs/src/index.js",
24
- "types": "./dist/cjs/src/index.d.ts",
24
+ "main": "./dist/cjs/index.js",
25
+ "types": "./dist/index.d.ts",
25
26
  "files": [
26
27
  "dist"
27
28
  ],
28
29
  "scripts": {
29
- "build": "../../../scripts/build-package.sh",
30
30
  "clean": "rimraf dist",
31
+ "rb": "rollup -c --configPlugin typescript",
32
+ "rbw": "yarn rb --watch",
33
+ "build": "yarn clean && yarn rb",
31
34
  "tsw": "yarn tsc --watch",
32
35
  "start": "rimraf dist && yarn tsw",
33
36
  "lint": "eslint . --ext .ts",
34
37
  "prettier": "prettier --write '**/*.@(js|ts|tsx|json|css)' --ignore-path ../../../.prettierignore",
35
38
  "test": "NODE_OPTIONS=\"--experimental-vm-modules --no-warnings\" jest --ci --runInBand",
36
39
  "coverage": "yarn test --coverage",
37
- "check": "yarn prettier && yarn lint && yarn build && yarn test && yarn doc"
40
+ "check": "yarn prettier && yarn lint && yarn build && yarn test"
38
41
  },
39
42
  "dependencies": {
40
43
  "@cloudflare/workers-types": "^4.20230321.0",
41
- "@launchdarkly/js-server-sdk-common-edge": "1.1.0-alpha",
42
44
  "crypto-js": "^4.1.1"
43
45
  },
44
46
  "devDependencies": {
47
+ "@launchdarkly/js-server-sdk-common-edge": "2.0.0",
48
+ "@rollup/plugin-commonjs": "^25.0.4",
49
+ "@rollup/plugin-json": "^6.0.0",
50
+ "@rollup/plugin-node-resolve": "^15.2.1",
51
+ "@rollup/plugin-terser": "^0.4.3",
52
+ "@rollup/plugin-typescript": "^11.1.3",
45
53
  "@trivago/prettier-plugin-sort-imports": "^4.1.1",
46
54
  "@types/crypto-js": "^4.1.1",
47
55
  "@types/jest": "^29.5.0",
56
+ "@types/rollup-plugin-generate-package-json": "^3.2.3",
48
57
  "@typescript-eslint/eslint-plugin": "^6.1.0",
49
58
  "@typescript-eslint/parser": "^6.1.0",
50
59
  "eslint": "^8.45.0",
@@ -57,9 +66,17 @@
57
66
  "launchdarkly-js-test-helpers": "^2.2.0",
58
67
  "miniflare": "^2.13.0",
59
68
  "prettier": "^3.0.0",
60
- "rimraf": "^5.0.0",
69
+ "rimraf": "^5.0.1",
70
+ "rollup": "^3.29.2",
71
+ "rollup-plugin-dts": "^6.0.2",
72
+ "rollup-plugin-esbuild": "^5.0.0",
73
+ "rollup-plugin-filesize": "^10.0.0",
74
+ "rollup-plugin-generate-package-json": "^3.2.0",
61
75
  "ts-jest": "^29.1.0",
62
76
  "typedoc": "0.25.0",
63
77
  "typescript": "5.1.6"
64
- }
78
+ },
79
+ "bundledDependencies": [
80
+ "@launchdarkly/js-server-sdk-common-edge"
81
+ ]
65
82
  }
@@ -1,5 +0,0 @@
1
- {
2
- "name": "@launchdarkly/cloudflare-server-sdk",
3
- "version": "2.2.0-alpha",
4
- "type": "commonjs"
5
- }
@@ -1,8 +0,0 @@
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
@@ -1 +0,0 @@
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;CAOnB;AAED,QAAA,MAAM,kBAAkB,8BAAqC,CAAC;AAE9D,eAAe,kBAAkB,CAAC"}
@@ -1,20 +0,0 @@
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',
8
- };
9
- }
10
- sdkData() {
11
- return {
12
- name: package_json_1.name,
13
- version: package_json_1.version,
14
- userAgentBase: 'CloudflareEdgeSDK',
15
- };
16
- }
17
- }
18
- const createPlatformInfo = () => new CloudflarePlatformInfo();
19
- exports.default = createPlatformInfo;
20
- //# sourceMappingURL=createPlatformInfo.js.map
@@ -1 +0,0 @@
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;YACP,aAAa,EAAE,mBAAmB;SACnC,CAAC;IACJ,CAAC;CACF;AAED,MAAM,kBAAkB,GAAG,GAAG,EAAE,CAAC,IAAI,sBAAsB,EAAE,CAAC;AAE9D,kBAAe,kBAAkB,CAAC"}
@@ -1 +0,0 @@
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;AAE7D,OAAO,EAIL,QAAQ,EACR,SAAS,EACV,MAAM,yCAAyC,CAAC;AAIjD,cAAc,yCAAyC,CAAC;AAExD,YAAY,EAAE,QAAQ,EAAE,CAAC;AAEzB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,IAAI,iBAAkB,MAAM,eAAe,WAAW,YAAW,SAAS,aAOtF,CAAC"}
@@ -1,48 +0,0 @@
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 createPlatformInfo_1 = require("./createPlatformInfo");
20
- __exportStar(require("@launchdarkly/js-server-sdk-common-edge"), exports);
21
- /**
22
- * Creates an instance of the Cloudflare LaunchDarkly client.
23
- *
24
- * Applications should instantiate a single instance for the lifetime of the worker.
25
- * The client will begin attempting to connect to the configured Cloudflare KV as
26
- * soon as it is created. To determine when it is ready to use, call {@link LDClient.waitForInitialization}.
27
- *
28
- * **Important:** Do **not** try to instantiate `LDClient` with its constructor
29
- * (`new LDClient()/new LDClientImpl()/new LDClient()`); the SDK does not currently support
30
- * this.
31
- *
32
- * @param clientSideID
33
- * The client side ID. This is only used to query the kvNamespace above,
34
- * not to connect with LaunchDarkly servers.
35
- * @param kvNamespace
36
- * The Cloudflare KV configured for LaunchDarkly.
37
- * @param options
38
- * Optional configuration settings. The only supported option is logger.
39
- * @return
40
- * The new {@link LDClient} instance.
41
- */
42
- const init = (clientSideID, kvNamespace, options = {}) => {
43
- var _a;
44
- const logger = (_a = options.logger) !== null && _a !== void 0 ? _a : js_server_sdk_common_edge_1.BasicLogger.get();
45
- return (0, js_server_sdk_common_edge_1.init)(clientSideID, (0, createPlatformInfo_1.default)(), Object.assign({ featureStore: new js_server_sdk_common_edge_1.EdgeFeatureStore(kvNamespace, clientSideID, 'Cloudflare', logger), logger }, options));
46
- };
47
- exports.init = init;
48
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAYA,uFAMiD;AAEjD,6DAAsD;AAEtD,0EAAwD;AAIxD;;;;;;;;;;;;;;;;;;;;GAoBG;AACI,MAAM,IAAI,GAAG,CAAC,YAAoB,EAAE,WAAwB,EAAE,UAAqB,EAAE,EAAE,EAAE;;IAC9F,MAAM,MAAM,GAAG,MAAA,OAAO,CAAC,MAAM,mCAAI,uCAAW,CAAC,GAAG,EAAE,CAAC;IACnD,OAAO,IAAA,gCAAQ,EAAC,YAAY,EAAE,IAAA,4BAAkB,GAAE,kBAChD,YAAY,EAAE,IAAI,4CAAgB,CAAC,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,CAAC,EACnF,MAAM,IACH,OAAO,EACV,CAAC;AACL,CAAC,CAAC;AAPW,QAAA,IAAI,QAOf"}
@@ -1,5 +0,0 @@
1
- {
2
- "name": "@launchdarkly/cloudflare-server-sdk",
3
- "version": "2.2.0-alpha",
4
- "type": "module"
5
- }
@@ -1,8 +0,0 @@
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
@@ -1 +0,0 @@
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;CAOnB;AAED,QAAA,MAAM,kBAAkB,8BAAqC,CAAC;AAE9D,eAAe,kBAAkB,CAAC"}
@@ -1,18 +0,0 @@
1
- import { name, version } from '../package.json';
2
- class CloudflarePlatformInfo {
3
- platformData() {
4
- return {
5
- name: 'Cloudflare',
6
- };
7
- }
8
- sdkData() {
9
- return {
10
- name,
11
- version,
12
- userAgentBase: 'CloudflareEdgeSDK',
13
- };
14
- }
15
- }
16
- const createPlatformInfo = () => new CloudflarePlatformInfo();
17
- export default createPlatformInfo;
18
- //# sourceMappingURL=createPlatformInfo.js.map
@@ -1 +0,0 @@
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;YACP,aAAa,EAAE,mBAAmB;SACnC,CAAC;IACJ,CAAC;CACF;AAED,MAAM,kBAAkB,GAAG,GAAG,EAAE,CAAC,IAAI,sBAAsB,EAAE,CAAC;AAE9D,eAAe,kBAAkB,CAAC"}
@@ -1,37 +0,0 @@
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 clientSideID
27
- * The client side ID. This is only used to query the kvNamespace above,
28
- * not to connect with LaunchDarkly servers.
29
- * @param kvNamespace
30
- * The Cloudflare KV configured for LaunchDarkly.
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: (clientSideID: string, kvNamespace: KVNamespace, options?: LDOptions) => LDClient;
37
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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;AAE7D,OAAO,EAIL,QAAQ,EACR,SAAS,EACV,MAAM,yCAAyC,CAAC;AAIjD,cAAc,yCAAyC,CAAC;AAExD,YAAY,EAAE,QAAQ,EAAE,CAAC;AAEzB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,IAAI,iBAAkB,MAAM,eAAe,WAAW,YAAW,SAAS,aAOtF,CAAC"}
@@ -1,30 +0,0 @@
1
- import { BasicLogger, EdgeFeatureStore, init as initEdge, } from '@launchdarkly/js-server-sdk-common-edge';
2
- import createPlatformInfo from './createPlatformInfo';
3
- export * from '@launchdarkly/js-server-sdk-common-edge';
4
- /**
5
- * Creates an instance of the Cloudflare LaunchDarkly client.
6
- *
7
- * Applications should instantiate a single instance for the lifetime of the worker.
8
- * The client will begin attempting to connect to the configured Cloudflare KV as
9
- * soon as it is created. To determine when it is ready to use, call {@link LDClient.waitForInitialization}.
10
- *
11
- * **Important:** Do **not** try to instantiate `LDClient` with its constructor
12
- * (`new LDClient()/new LDClientImpl()/new LDClient()`); the SDK does not currently support
13
- * this.
14
- *
15
- * @param clientSideID
16
- * The client side ID. This is only used to query the kvNamespace above,
17
- * not to connect with LaunchDarkly servers.
18
- * @param kvNamespace
19
- * The Cloudflare KV configured for LaunchDarkly.
20
- * @param options
21
- * Optional configuration settings. The only supported option is logger.
22
- * @return
23
- * The new {@link LDClient} instance.
24
- */
25
- export const init = (clientSideID, kvNamespace, options = {}) => {
26
- var _a;
27
- const logger = (_a = options.logger) !== null && _a !== void 0 ? _a : BasicLogger.get();
28
- return initEdge(clientSideID, createPlatformInfo(), Object.assign({ featureStore: new EdgeFeatureStore(kvNamespace, clientSideID, 'Cloudflare', logger), logger }, options));
29
- };
30
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,IAAI,IAAI,QAAQ,GAGjB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAEtD,cAAc,yCAAyC,CAAC;AAIxD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,YAAoB,EAAE,WAAwB,EAAE,UAAqB,EAAE,EAAE,EAAE;;IAC9F,MAAM,MAAM,GAAG,MAAA,OAAO,CAAC,MAAM,mCAAI,WAAW,CAAC,GAAG,EAAE,CAAC;IACnD,OAAO,QAAQ,CAAC,YAAY,EAAE,kBAAkB,EAAE,kBAChD,YAAY,EAAE,IAAI,gBAAgB,CAAC,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,CAAC,EACnF,MAAM,IACH,OAAO,EACV,CAAC;AACL,CAAC,CAAC"}