@vercel/flags-core 0.1.8 → 1.0.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.
@@ -0,0 +1,157 @@
1
+ import {
2
+ createClient,
3
+ flagsClient
4
+ } from "./chunk-UQEFJL4F.js";
5
+
6
+ // src/openfeature.make.ts
7
+ import {
8
+ ErrorCode,
9
+ StandardResolutionReasons
10
+ } from "@openfeature/server-sdk";
11
+ function mapReason(reason) {
12
+ switch (reason) {
13
+ case "error" /* ERROR */:
14
+ return StandardResolutionReasons.ERROR;
15
+ case "paused" /* PAUSED */:
16
+ return StandardResolutionReasons.STATIC;
17
+ case "fallthrough" /* FALLTHROUGH */:
18
+ return StandardResolutionReasons.DEFAULT;
19
+ case "target_match" /* TARGET_MATCH */:
20
+ case "rule_match" /* RULE_MATCH */:
21
+ return StandardResolutionReasons.TARGETING_MATCH;
22
+ default:
23
+ return StandardResolutionReasons.UNKNOWN;
24
+ }
25
+ }
26
+ function make(createClient2, defaultFlagsClient) {
27
+ return class VercelProvider {
28
+ metadata = {
29
+ name: "vercel-nodejs-provider"
30
+ };
31
+ runsOn = "server";
32
+ client;
33
+ constructor(clientOrConnectionString = defaultFlagsClient) {
34
+ if (typeof clientOrConnectionString === "string") {
35
+ this.client = createClient2(clientOrConnectionString);
36
+ } else {
37
+ this.client = clientOrConnectionString;
38
+ }
39
+ }
40
+ async initialize(context) {
41
+ await this.client.initialize();
42
+ }
43
+ async onClose() {
44
+ await this.client.shutdown();
45
+ }
46
+ async resolveBooleanEvaluation(flagKey, defaultValue, context) {
47
+ const result = await this.client.evaluate(
48
+ flagKey,
49
+ defaultValue,
50
+ context
51
+ );
52
+ if (result.reason === "error" /* ERROR */) {
53
+ return {
54
+ value: defaultValue,
55
+ reason: StandardResolutionReasons.ERROR,
56
+ errorCode: ErrorCode.GENERAL,
57
+ errorMessage: result.errorMessage
58
+ };
59
+ }
60
+ if (typeof result.value !== "boolean") {
61
+ return {
62
+ value: defaultValue,
63
+ reason: StandardResolutionReasons.ERROR,
64
+ errorCode: ErrorCode.TYPE_MISMATCH,
65
+ errorMessage: `Expected boolean value for flag "${flagKey}"`
66
+ };
67
+ }
68
+ return {
69
+ value: result.value,
70
+ reason: mapReason(result.reason)
71
+ };
72
+ }
73
+ async resolveStringEvaluation(flagKey, defaultValue, context) {
74
+ const result = await this.client.evaluate(
75
+ flagKey,
76
+ defaultValue,
77
+ context
78
+ );
79
+ if (result.reason === "error" /* ERROR */) {
80
+ return {
81
+ value: defaultValue,
82
+ reason: StandardResolutionReasons.ERROR,
83
+ errorCode: ErrorCode.GENERAL,
84
+ errorMessage: result.errorMessage
85
+ };
86
+ }
87
+ if (typeof result.value !== "string") {
88
+ return {
89
+ value: defaultValue,
90
+ reason: StandardResolutionReasons.ERROR,
91
+ errorCode: ErrorCode.TYPE_MISMATCH,
92
+ errorMessage: `Expected string value for flag "${flagKey}"`
93
+ };
94
+ }
95
+ return {
96
+ value: result.value,
97
+ reason: mapReason(result.reason),
98
+ errorMessage: result.errorMessage
99
+ };
100
+ }
101
+ async resolveNumberEvaluation(flagKey, defaultValue, context) {
102
+ const result = await this.client.evaluate(
103
+ flagKey,
104
+ defaultValue,
105
+ context
106
+ );
107
+ if (result.reason === "error" /* ERROR */) {
108
+ return {
109
+ value: defaultValue,
110
+ reason: StandardResolutionReasons.ERROR,
111
+ errorCode: ErrorCode.GENERAL,
112
+ errorMessage: result.errorMessage
113
+ };
114
+ }
115
+ if (typeof result.value !== "number") {
116
+ return {
117
+ value: defaultValue,
118
+ reason: StandardResolutionReasons.ERROR,
119
+ errorCode: ErrorCode.TYPE_MISMATCH,
120
+ errorMessage: `Expected number value for flag "${flagKey}"`
121
+ };
122
+ }
123
+ return {
124
+ value: result.value,
125
+ reason: mapReason(result.reason),
126
+ errorMessage: result.errorMessage
127
+ };
128
+ }
129
+ async resolveObjectEvaluation(flagKey, defaultValue, context) {
130
+ const result = await this.client.evaluate(
131
+ flagKey,
132
+ defaultValue,
133
+ context
134
+ );
135
+ if (result.reason === "error" /* ERROR */) {
136
+ return {
137
+ value: defaultValue,
138
+ reason: StandardResolutionReasons.ERROR,
139
+ errorCode: ErrorCode.GENERAL,
140
+ errorMessage: result.errorMessage
141
+ };
142
+ }
143
+ return {
144
+ value: result.value,
145
+ reason: mapReason(result.reason),
146
+ errorMessage: result.errorMessage
147
+ };
148
+ }
149
+ };
150
+ }
151
+
152
+ // src/openfeature.next-js.ts
153
+ var VercelProvider = make(createClient, flagsClient);
154
+ export {
155
+ VercelProvider
156
+ };
157
+ //# sourceMappingURL=openfeature.next-js.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/openfeature.make.ts","../src/openfeature.next-js.ts"],"sourcesContent":["/**\n * OpenFeature provider for Next.js App Router\n *\n * There is also openfeature.default.ts which targets default runtimes.\n * If you update this file, please update openfeature.default.ts as well.\n *\n * This file should stay equivalent to openfeature.default.ts, except that it\n * imports from index.next-js to get cached functions.\n */\n\nimport {\n ErrorCode,\n type EvaluationContext,\n type JsonValue,\n type Provider,\n type ProviderMetadata,\n type ResolutionDetails,\n type ResolutionReason,\n StandardResolutionReasons,\n} from '@openfeature/server-sdk';\nimport { type FlagsClient, ResolutionReason as Reason } from './types';\n\nfunction mapReason(reason: Reason): ResolutionReason {\n switch (reason) {\n case Reason.ERROR:\n return StandardResolutionReasons.ERROR;\n case Reason.PAUSED:\n return StandardResolutionReasons.STATIC;\n case Reason.FALLTHROUGH:\n return StandardResolutionReasons.DEFAULT;\n case Reason.TARGET_MATCH:\n case Reason.RULE_MATCH:\n return StandardResolutionReasons.TARGETING_MATCH;\n default:\n return StandardResolutionReasons.UNKNOWN;\n }\n}\n\nexport function make(\n createClient: (sdkKeyOrConnectionString: string) => FlagsClient,\n defaultFlagsClient: FlagsClient,\n) {\n return class VercelProvider implements Provider {\n readonly metadata: ProviderMetadata = {\n name: 'vercel-nodejs-provider',\n } as const;\n\n readonly runsOn = 'server';\n readonly client: FlagsClient;\n\n constructor();\n constructor(client: FlagsClient);\n constructor(connectionString: string);\n constructor(\n clientOrConnectionString: FlagsClient | string = defaultFlagsClient,\n ) {\n if (typeof clientOrConnectionString === 'string') {\n this.client = createClient(clientOrConnectionString);\n } else {\n this.client = clientOrConnectionString;\n }\n }\n\n async initialize(context?: EvaluationContext): Promise<void> {\n await this.client.initialize();\n }\n\n async onClose() {\n await this.client.shutdown();\n }\n\n async resolveBooleanEvaluation(\n flagKey: string,\n defaultValue: boolean,\n context: EvaluationContext,\n ): Promise<ResolutionDetails<boolean>> {\n const result = await this.client.evaluate<boolean>(\n flagKey,\n defaultValue,\n context,\n );\n\n if (result.reason === Reason.ERROR) {\n return {\n value: defaultValue,\n reason: StandardResolutionReasons.ERROR,\n errorCode: ErrorCode.GENERAL,\n errorMessage: result.errorMessage,\n };\n }\n\n if (typeof result.value !== 'boolean') {\n return {\n value: defaultValue,\n reason: StandardResolutionReasons.ERROR,\n errorCode: ErrorCode.TYPE_MISMATCH,\n errorMessage: `Expected boolean value for flag \"${flagKey}\"`,\n };\n }\n\n return {\n value: result.value,\n reason: mapReason(result.reason),\n };\n }\n\n async resolveStringEvaluation(\n flagKey: string,\n defaultValue: string,\n context: EvaluationContext,\n ): Promise<ResolutionDetails<string>> {\n const result = await this.client.evaluate<string>(\n flagKey,\n defaultValue,\n context,\n );\n\n if (result.reason === Reason.ERROR) {\n return {\n value: defaultValue,\n reason: StandardResolutionReasons.ERROR,\n errorCode: ErrorCode.GENERAL,\n errorMessage: result.errorMessage,\n };\n }\n\n if (typeof result.value !== 'string') {\n return {\n value: defaultValue,\n reason: StandardResolutionReasons.ERROR,\n errorCode: ErrorCode.TYPE_MISMATCH,\n errorMessage: `Expected string value for flag \"${flagKey}\"`,\n };\n }\n\n return {\n value: result.value,\n reason: mapReason(result.reason),\n errorMessage: result.errorMessage,\n };\n }\n\n async resolveNumberEvaluation(\n flagKey: string,\n defaultValue: number,\n context: EvaluationContext,\n ): Promise<ResolutionDetails<number>> {\n const result = await this.client.evaluate<number>(\n flagKey,\n defaultValue,\n context,\n );\n\n if (result.reason === Reason.ERROR) {\n return {\n value: defaultValue,\n reason: StandardResolutionReasons.ERROR,\n errorCode: ErrorCode.GENERAL,\n errorMessage: result.errorMessage,\n };\n }\n\n if (typeof result.value !== 'number') {\n return {\n value: defaultValue,\n reason: StandardResolutionReasons.ERROR,\n errorCode: ErrorCode.TYPE_MISMATCH,\n errorMessage: `Expected number value for flag \"${flagKey}\"`,\n };\n }\n\n return {\n value: result.value,\n reason: mapReason(result.reason),\n errorMessage: result.errorMessage,\n };\n }\n\n async resolveObjectEvaluation<T extends JsonValue>(\n flagKey: string,\n defaultValue: T,\n context: EvaluationContext,\n ): Promise<ResolutionDetails<T>> {\n const result = await this.client.evaluate<T>(\n flagKey,\n defaultValue,\n context,\n );\n\n if (result.reason === Reason.ERROR) {\n return {\n value: defaultValue,\n reason: StandardResolutionReasons.ERROR,\n errorCode: ErrorCode.GENERAL,\n errorMessage: result.errorMessage,\n };\n }\n\n return {\n value: result.value,\n reason: mapReason(result.reason),\n errorMessage: result.errorMessage,\n };\n }\n };\n}\n","/**\n * OpenFeature provider for Next.js App Router\n *\n * There is also openfeature.default.ts which targets default runtimes.\n * If you update this file, please update openfeature.default.ts as well.\n *\n * This file should stay equivalent to openfeature.default.ts, except that it\n * imports from index.next-js to get cached functions.\n */\n\nimport { createClient, flagsClient } from './index.next-js';\nimport { make } from './openfeature.make';\n\nexport const VercelProvider = make(createClient, flagsClient);\n"],"mappings":";;;;;;AAUA;AAAA,EACE;AAAA,EAOA;AAAA,OACK;AAGP,SAAS,UAAU,QAAkC;AACnD,UAAQ,QAAQ;AAAA,IACd;AACE,aAAO,0BAA0B;AAAA,IACnC;AACE,aAAO,0BAA0B;AAAA,IACnC;AACE,aAAO,0BAA0B;AAAA,IACnC;AAAA,IACA;AACE,aAAO,0BAA0B;AAAA,IACnC;AACE,aAAO,0BAA0B;AAAA,EACrC;AACF;AAEO,SAAS,KACdA,eACA,oBACA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IACF;AAAA,EACF;AACF;;;AChMO,IAAM,iBAAiB,KAAK,cAAc,WAAW;","names":["createClient"]}
@@ -1,10 +1,134 @@
1
- interface ConnectionOptions {
2
- edgeConfigId: string;
3
- edgeConfigToken: string;
4
- edgeConfigItemKey: string | null;
5
- env: string | null;
1
+ /**
2
+ * Options for stream connection behavior
3
+ */
4
+ type StreamOptions = {
5
+ /** Timeout in ms to wait for initial stream connection before falling back */
6
+ initTimeoutMs: number;
7
+ };
8
+ /**
9
+ * Options for polling behavior
10
+ */
11
+ type PollingOptions = {
12
+ /** Interval in ms between polling requests */
13
+ intervalMs: number;
14
+ /** Timeout in ms to wait for initial poll before falling back */
15
+ initTimeoutMs: number;
16
+ };
17
+ /** Input type for creating a datafile (without metrics) */
18
+ type DatafileInput = Packed.Data & {
19
+ /**
20
+ * If a data source is used with a specific sdk key then
21
+ * the sdk key or data source might contain information
22
+ * about the environment to be evaluated
23
+ */
24
+ environment: string;
25
+ /** Vercel project id of the source of these flags */
6
26
  projectId: string;
27
+ /**
28
+ * Some older responses might return a string instead of a number. Both will be timestamps.
29
+ */
30
+ configUpdatedAt?: number | string;
31
+ };
32
+ /** Datafile with metrics attached (returned by the client) */
33
+ type Datafile = DatafileInput & {
34
+ /** Metrics about how the data was retrieved */
35
+ metrics: Metrics;
36
+ };
37
+ /** Flag Definitions of a Vercel project */
38
+ type BundledDefinitions = DatafileInput & {
39
+ /** when the data was last updated */
40
+ configUpdatedAt: number;
41
+ /** hash of the data */
42
+ digest: string;
43
+ /** version number of the dat */
44
+ revision: number;
45
+ };
46
+ /**
47
+ * Metrics about how data was retrieved and evaluated
48
+ */
49
+ type Metrics = {
50
+ /** Time in ms to read the datafile */
51
+ readMs: number;
52
+ /** Where the data came from */
53
+ source: 'in-memory' | 'embedded' | 'remote';
54
+ /** Whether data was already cached, or stale (fallback used) */
55
+ cacheStatus: 'HIT' | 'MISS' | 'STALE';
56
+ /** Whether the stream is currently connected */
57
+ connectionState: 'connected' | 'disconnected';
58
+ /** Time in ms for the pure flag evaluation logic (only present on EvaluationResult) */
59
+ evaluationMs?: number;
60
+ };
61
+ /**
62
+ * DataSource interface for the Vercel Flags client
63
+ */
64
+ interface DataSource {
65
+ /**
66
+ * Initialize the data source by fetching the initial file or setting up polling or
67
+ * subscriptions.
68
+ *
69
+ * @see https://openfeature.dev/specification/sections/providers#requirement-241
70
+ */
71
+ initialize: () => Promise<void>;
72
+ /**
73
+ * Returns the in-memory data file, which was loaded from initialize and maybe updated from streams.
74
+ */
75
+ read(): Promise<Datafile>;
76
+ /**
77
+ * End polling or subscriptions. Flush any remaining data.
78
+ */
79
+ shutdown(): void;
80
+ /**
81
+ * Return the actual datafile containing flag definitions.
82
+ */
83
+ getDatafile(): Promise<Datafile>;
84
+ /**
85
+ * Returns the bundled fallback definitions.
86
+ * Throws FallbackNotFoundError if the fallback file doesn't exist.
87
+ * Throws FallbackEntryNotFoundError if the file exists but has no entry for the SDK key.
88
+ */
89
+ getFallbackDatafile?(): Promise<BundledDefinitions>;
7
90
  }
91
+ /**
92
+ * A client for Vercel Flags
93
+ */
94
+ type FlagsClient = {
95
+ /**
96
+ * Origin information for this client (provider and sdkKey)
97
+ */
98
+ origin?: {
99
+ provider: string;
100
+ sdkKey: string;
101
+ };
102
+ /**
103
+ * Evaluate a feature flag
104
+ *
105
+ * Requires initialize() to have been called and awaited first.
106
+ *
107
+ * @param flagKey
108
+ * @param defaultValue
109
+ * @param entities
110
+ * @returns
111
+ */
112
+ evaluate: <T = Value, E = Record<string, unknown>>(flagKey: string, defaultValue?: T, entities?: E) => Promise<EvaluationResult<T>>;
113
+ /**
114
+ * Retrieve the latest datafile during startup, and set up subscriptions if needed.
115
+ */
116
+ initialize(): void | Promise<void>;
117
+ /**
118
+ * Facilitates a clean shutdown process which may include flushing telemetry information, or closing remote connections.
119
+ */
120
+ shutdown(): void | Promise<void>;
121
+ /**
122
+ * Returns the actual datafile containing flag definitions
123
+ */
124
+ getDatafile(): Promise<Datafile>;
125
+ /**
126
+ * Returns the bundled fallback definitions.
127
+ * Throws FallbackNotFoundError if the fallback file doesn't exist.
128
+ * Throws FallbackEntryNotFoundError if the file exists but has no entry for the SDK key.
129
+ */
130
+ getFallbackDatafile(): Promise<BundledDefinitions>;
131
+ };
8
132
  type EvaluationParams<T> = {
9
133
  entities?: Record<string, unknown>;
10
134
  environment: string;
@@ -28,7 +152,7 @@ declare enum ErrorCode {
28
152
  FLAG_NOT_FOUND = "FLAG_NOT_FOUND"
29
153
  }
30
154
  /**
31
- * The detailed result of a flag evaluation as returned by the `evaluate` function.
155
+ * The detailed result of a flag evaluation as returned by the client's `evaluate` function.
32
156
  */
33
157
  type EvaluationResult<T> = {
34
158
  /**
@@ -45,14 +169,19 @@ type EvaluationResult<T> = {
45
169
  reason: Exclude<ResolutionReason, ResolutionReason.ERROR>;
46
170
  errorMessage?: never;
47
171
  errorCode?: never;
172
+ /** Metrics about the evaluation (optional) */
173
+ metrics?: Metrics;
48
174
  } | {
49
175
  reason: ResolutionReason.ERROR;
50
176
  errorMessage: string;
51
177
  errorCode?: ErrorCode;
178
+ outcomeType?: never;
52
179
  /**
53
- * In cases of errors this is the he defaultValue if one was provided
180
+ * In cases of errors this is the defaultValue if one was provided
54
181
  */
55
182
  value?: T;
183
+ /** Metrics about the evaluation (optional) */
184
+ metrics?: Metrics;
56
185
  };
57
186
  type FlagKey = string;
58
187
  type EnvironmentKey = string;
@@ -373,54 +502,4 @@ declare namespace Packed {
373
502
  };
374
503
  }
375
504
 
376
- /**
377
- * DataSource interface for the Vercel Flags client
378
- */
379
- interface DataSource {
380
- /**
381
- * The datafile
382
- */
383
- getData(): Promise<Packed.Data>;
384
- /**
385
- * The project for which these flags were loaded for
386
- */
387
- projectId?: string;
388
- /**
389
- * Initialize the data source by fetching the initial file or setting up polling or
390
- * subscriptions.
391
- *
392
- * @see https://openfeature.dev/specification/sections/providers#requirement-241
393
- */
394
- initialize?: () => Promise<void>;
395
- /**
396
- * End polling or subscriptions.
397
- */
398
- shutdown?(): void;
399
- }
400
-
401
- type FlagsClient = {
402
- environment: string;
403
- dataSource: DataSource;
404
- evaluate: <T = Value, E = Record<string, unknown>>(flagKey: string, defaultValue?: T, entities?: E) => Promise<EvaluationResult<T>>;
405
- initialize(): void | Promise<void>;
406
- shutdown(): void | Promise<void>;
407
- };
408
- /**
409
- * Creates a Vercel Flags client
410
- *
411
- * @example
412
- * const edgeConfigClient = createClient('');
413
- * const flagsClient = createClient({
414
- * dataSource: new EdgeConfigDataSource({
415
- * edgeConfigItemKey: 'flags',
416
- * edgeConfigClient,
417
- * }),
418
- * environment: 'production',
419
- * });
420
- */
421
- declare function createClient({ environment, dataSource, }: {
422
- environment: string;
423
- dataSource: DataSource;
424
- }): FlagsClient;
425
-
426
- export { type ConnectionOptions as C, type DataSource as D, type EvaluationParams as E, type FlagsClient as F, Packed as P, ResolutionReason as R, type EvaluationResult as a, createClient as c };
505
+ export { type BundledDefinitions as B, type DatafileInput as D, type EvaluationParams as E, type FlagsClient as F, type PollingOptions as P, ResolutionReason as R, type StreamOptions as S, type DataSource as a, type Datafile as b, type EvaluationResult as c, Packed as d };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/flags-core",
3
- "version": "0.1.8",
3
+ "version": "1.0.0",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -9,24 +9,30 @@
9
9
  "type": "module",
10
10
  "exports": {
11
11
  ".": {
12
- "import": "./dist/index.js",
13
- "require": "./dist/index.cjs"
12
+ "next-js": {
13
+ "types": "./dist/index.next-js.d.ts",
14
+ "default": "./dist/index.next-js.js"
15
+ },
16
+ "types": "./dist/index.default.d.ts",
17
+ "default": "./dist/index.default.js"
14
18
  },
15
19
  "./openfeature": {
16
- "import": "./dist/openfeature.js",
17
- "require": "./dist/openfeature.cjs"
20
+ "next-js": {
21
+ "types": "./dist/openfeature.next-js.d.ts",
22
+ "default": "./dist/openfeature.next-js.js"
23
+ },
24
+ "types": "./dist/openfeature.default.d.ts",
25
+ "default": "./dist/openfeature.default.js"
18
26
  }
19
27
  },
20
- "main": "./dist/index.js",
28
+ "main": "./dist/index.default.js",
21
29
  "typesVersions": {
22
30
  "*": {
23
31
  ".": [
24
- "dist/*.d.ts",
25
- "dist/*.d.cts"
32
+ "dist/index.default.d.ts"
26
33
  ],
27
- "./openfeature": [
28
- "dist/openfeature.d.ts",
29
- "dist/openfeature.d.cts"
34
+ "openfeature": [
35
+ "dist/openfeature.default.d.ts"
30
36
  ]
31
37
  }
32
38
  },
@@ -35,26 +41,32 @@
35
41
  "CHANGELOG.md"
36
42
  ],
37
43
  "dependencies": {
44
+ "@vercel/functions": "^3.3.6",
38
45
  "jose": "5.2.1",
39
- "js-xxhash": "4.0.0",
40
- "@vercel/edge-config": "^1.4.3"
46
+ "js-xxhash": "4.0.0"
41
47
  },
42
48
  "devDependencies": {
49
+ "@arethetypeswrong/cli": "0.18.2",
43
50
  "@types/node": "20.11.17",
44
51
  "msw": "2.6.4",
45
- "tsup": "8.0.1",
52
+ "next": "16.1.6",
53
+ "tsup": "8.5.1",
46
54
  "typescript": "5.6.3",
47
- "vite": "6.0.3",
48
- "vitest": "2.1.8",
49
- "flags": "4.0.2"
55
+ "vite": "6.4.1",
56
+ "vitest": "2.1.9",
57
+ "flags": "4.0.3"
50
58
  },
51
59
  "peerDependencies": {
52
- "flags": "*",
53
- "@openfeature/server-sdk": "1.18.0"
60
+ "next": "*",
61
+ "@openfeature/server-sdk": "1.18.0",
62
+ "flags": "*"
54
63
  },
55
64
  "peerDependenciesMeta": {
56
65
  "@openfeature/server-sdk": {
57
66
  "optional": true
67
+ },
68
+ "next": {
69
+ "optional": true
58
70
  }
59
71
  },
60
72
  "publishConfig": {