@featureflip/edge 0.0.0-stage → 2.14.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/LICENSE +202 -0
- package/README.md +88 -2
- package/dist/edge-sdk/src/client.d.ts +35 -0
- package/dist/edge-sdk/src/client.d.ts.map +1 -0
- package/dist/edge-sdk/src/config.d.ts +42 -0
- package/dist/edge-sdk/src/config.d.ts.map +1 -0
- package/dist/edge-sdk/src/index.d.ts +7 -0
- package/dist/edge-sdk/src/index.d.ts.map +1 -0
- package/dist/edge-sdk/src/snapshot.d.ts +61 -0
- package/dist/edge-sdk/src/snapshot.d.ts.map +1 -0
- package/dist/edge-sdk/src/store.d.ts +21 -0
- package/dist/edge-sdk/src/store.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +947 -0
- package/dist/js-sdk/src/core/evaluator.d.ts +37 -0
- package/dist/js-sdk/src/core/evaluator.d.ts.map +1 -0
- package/dist/js-sdk/src/core/events.d.ts +77 -0
- package/dist/js-sdk/src/core/events.d.ts.map +1 -0
- package/dist/js-sdk/src/core/identity.d.ts +13 -0
- package/dist/js-sdk/src/core/identity.d.ts.map +1 -0
- package/dist/js-sdk/src/core/resolve-detail.d.ts +42 -0
- package/dist/js-sdk/src/core/resolve-detail.d.ts.map +1 -0
- package/dist/js-sdk/src/core/shared-core.d.ts +170 -0
- package/dist/js-sdk/src/core/shared-core.d.ts.map +1 -0
- package/dist/js-sdk/src/core/store.d.ts +94 -0
- package/dist/js-sdk/src/core/store.d.ts.map +1 -0
- package/dist/js-sdk/src/core/types.d.ts +128 -0
- package/dist/js-sdk/src/core/types.d.ts.map +1 -0
- package/dist/js-sdk/src/core/unevaluable.d.ts +28 -0
- package/dist/js-sdk/src/core/unevaluable.d.ts.map +1 -0
- package/dist/js-sdk/src/core/validate-snapshot.d.ts +38 -0
- package/dist/js-sdk/src/core/validate-snapshot.d.ts.map +1 -0
- package/dist/js-sdk/src/platform/browser.d.ts +5 -0
- package/dist/js-sdk/src/platform/browser.d.ts.map +1 -0
- package/dist/js-sdk/src/platform/types.d.ts +31 -0
- package/dist/js-sdk/src/platform/types.d.ts.map +1 -0
- package/package.json +56 -4
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { FlagDto, GetFlagsResponse } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Raised when a config payload violates the wire contract.
|
|
4
|
+
*
|
|
5
|
+
* Distinct from a network or JSON-syntax failure on purpose: those self-heal on the
|
|
6
|
+
* next poll or reconnect and are correctly silent, while a contract violation means
|
|
7
|
+
* the server and SDK disagree about the shape of the data and must be surfaced. The
|
|
8
|
+
* catch sites key their diagnostics off this type, mirroring ruby's
|
|
9
|
+
* `MalformedPayloadError` (#2285).
|
|
10
|
+
*/
|
|
11
|
+
export declare class MalformedPayloadError extends Error {
|
|
12
|
+
constructor(message: string);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Assert that every enum-carrying field in a config snapshot arrived as a string.
|
|
16
|
+
*
|
|
17
|
+
* TYPE-ONLY, and that restraint is load-bearing. An *unrecognised* operator string is
|
|
18
|
+
* how a newer server ships a new operator to an older SDK; every evaluator already
|
|
19
|
+
* degrades that to no-match (#2262), so rejecting it here would break this SDK against
|
|
20
|
+
* every future server. What must be rejected is a *type* violation — `0` where `"And"`
|
|
21
|
+
* belongs — because TypeScript's types are erased at runtime and nothing else in the
|
|
22
|
+
* js core would notice: `conditionLogic: 0` fails the `=== 'And'` check and silently
|
|
23
|
+
* flips a segment from ALL of its conditions to ANY of them (#2279, #2315).
|
|
24
|
+
*
|
|
25
|
+
* Unknown *properties* are ignored, for the same forward-compatibility reason.
|
|
26
|
+
*
|
|
27
|
+
* @throws {MalformedPayloadError} on the first violation found.
|
|
28
|
+
*/
|
|
29
|
+
export declare function validateSnapshot(data: GetFlagsResponse): void;
|
|
30
|
+
/**
|
|
31
|
+
* The single-flag variant, for the `flag.created` / `flag.updated` delta path. A
|
|
32
|
+
* malformed delta is dropped rather than upserted, which is what "never partially
|
|
33
|
+
* applied" means for a payload whose whole scope is one flag.
|
|
34
|
+
*
|
|
35
|
+
* @throws {MalformedPayloadError}
|
|
36
|
+
*/
|
|
37
|
+
export declare function validateFlag(flag: FlagDto): void;
|
|
38
|
+
//# sourceMappingURL=validate-snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-snapshot.d.ts","sourceRoot":"","sources":["../../../../../js-sdk/src/core/validate-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAc,MAAM,YAAY,CAAC;AAExE;;;;;;;;GAQG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAM7D;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAkBhD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../../../js-sdk/src/platform/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,wBAAgB,qBAAqB,IAAI,QAAQ,CAgChD;AAmBD,iBAAS,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAmE3C;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface EventSourceLike {
|
|
2
|
+
addEventListener(type: string, listener: (event: {
|
|
3
|
+
data: string;
|
|
4
|
+
}) => void): void;
|
|
5
|
+
close(): void;
|
|
6
|
+
readonly readyState: number;
|
|
7
|
+
}
|
|
8
|
+
export interface Platform {
|
|
9
|
+
md5(input: string): Uint8Array;
|
|
10
|
+
/**
|
|
11
|
+
* May be asynchronous: the Node platform loads its ESM-only `eventsource`
|
|
12
|
+
* dependency with a dynamic `import()`, which is what keeps the SDK's
|
|
13
|
+
* `engines.node` floor at 20.19 (see platform/node.ts). Implementations that
|
|
14
|
+
* need nothing loaded — the browser's global `EventSource` — may still return
|
|
15
|
+
* the instance directly; the core awaits either shape.
|
|
16
|
+
*/
|
|
17
|
+
createEventSource(url: string, headers: Record<string, string>): EventSourceLike | Promise<EventSourceLike>;
|
|
18
|
+
fetch(url: string, init?: RequestInit): Promise<Response>;
|
|
19
|
+
/** Extra headers the platform can inject (e.g. User-Agent on Node). */
|
|
20
|
+
readonly extraHeaders?: Record<string, string>;
|
|
21
|
+
/**
|
|
22
|
+
* The header that carries the SDK identity (`featureflip-js/<version>` plus any
|
|
23
|
+
* wrapper tokens). Node sets `User-Agent`; a browser cannot (the Fetch spec
|
|
24
|
+
* forbids it), so it uses `X-Featureflip-SDK`, which is also the default for a
|
|
25
|
+
* platform that does not say, because every runtime allows it.
|
|
26
|
+
*/
|
|
27
|
+
readonly identityHeader?: 'User-Agent' | 'X-Featureflip-SDK';
|
|
28
|
+
/** Whether the platform's EventSource implementation supports custom headers. */
|
|
29
|
+
readonly sseSupportsHeaders?: boolean;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../js-sdk/src/platform/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,GAAG,IAAI,CAAC;IAClF,KAAK,IAAI,IAAI,CAAC;IACd,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,QAAQ;IACvB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC;IAC/B;;;;;;OAMG;IACH,iBAAiB,CACf,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC9C,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC1D,uEAAuE;IACvE,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C;;;;;OAKG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,YAAY,GAAG,mBAAmB,CAAC;IAC7D,iFAAiF;IACjF,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CACvC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@featureflip/edge",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "2.14.0",
|
|
4
|
+
"description": "Cloudflare Workers SDK for Featureflip: local flag evaluation at the edge",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"feature-flags",
|
|
7
|
+
"feature-toggles",
|
|
8
|
+
"feature-management",
|
|
9
|
+
"featureflip",
|
|
10
|
+
"cloudflare-workers",
|
|
11
|
+
"edge",
|
|
12
|
+
"typescript",
|
|
13
|
+
"sdk"
|
|
14
|
+
],
|
|
15
|
+
"license": "Apache-2.0",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/canopy-labs/featureflip-edge.git"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://featureflip.io/docs/sdks/edge/",
|
|
21
|
+
"type": "module",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.mjs"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"sideEffects": false,
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "vite build",
|
|
38
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
39
|
+
"test": "vitest run",
|
|
40
|
+
"test:watch": "vitest",
|
|
41
|
+
"test:coverage": "vitest run --coverage"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@cloudflare/workers-types": "^5.20261019.1",
|
|
45
|
+
"@types/node": "^26.6.5",
|
|
46
|
+
"@typescript/typescript6": "^6.0.2",
|
|
47
|
+
"typescript": "^7.0.2",
|
|
48
|
+
"vite": "^8.3.4",
|
|
49
|
+
"vite-plugin-dts": "^5.1.2",
|
|
50
|
+
"vitest": "^5.0.5"
|
|
51
|
+
},
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=20.19.0"
|
|
54
|
+
},
|
|
55
|
+
"overrides": {
|
|
56
|
+
"lodash": ">=4.17.25"
|
|
57
|
+
}
|
|
58
|
+
}
|