@vercel/flags-core 1.8.1 → 1.9.0-0fd2f41-20260915094243

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,5 +1,5 @@
1
- import { V as VariantId, R as ResolutionReason, D as DatafileInput, S as StreamOptions, P as PollingOptions, M as MetricEnvironment, C as ControllerInterface, a as Datafile, B as BundledDefinitions, e as experimental_ReportExposures, E as EvaluationParams, b as EvaluationResult, F as FlagsClient } from './types-CIONStRG.js';
2
- export { c as Packed, d as Value, f as experimental_EvaluationOptions, g as experimental_ExperimentAssignment, h as experimental_Exposure } from './types-CIONStRG.js';
1
+ import { V as VariantId, R as ResolutionReason, D as DatafileInput, S as StreamOptions, P as PollingOptions, M as MetricEnvironment, C as ControllerInterface, a as Datafile, B as BundledDefinitions, e as experimental_ReportExposures, E as EvaluationParams, b as EvaluationResult, F as FlagsClient } from './types-w8u8i22D.js';
2
+ export { c as Packed, d as Value, f as experimental_EvaluationOptions, g as experimental_ExperimentAssignment, h as experimental_Exposure } from './types-w8u8i22D.js';
3
3
 
4
4
  interface TrackEvaluationOptions {
5
5
  flagKey: string;
@@ -98,6 +98,11 @@ type ControllerOptions = {
98
98
  * - Uses polling exclusively
99
99
  * - Same fallback chains as streaming mode
100
100
  *
101
+ * **Runtime - vercel mode** (request context has matching x-vercel-flags-config-versions header)
102
+ * - Uses the header value to determine if the current data is fresh
103
+ * - Revalidates in the background if the header value is within 10 seconds of the current configUpdatedAt
104
+ * - Blocking fetch if header is newer than current configUpdatedAt
105
+ *
101
106
  * **Runtime — offline mode** (neither stream nor polling):
102
107
  * - Init fallback: constructor datafile → bundled → one-time fetch → throw
103
108
  * - Read fallback: in-memory value → constructor datafile → bundled → one-time fetch → throw
@@ -111,6 +116,7 @@ declare class Controller implements ControllerInterface {
111
116
  private streamSource;
112
117
  private pollingSource;
113
118
  private bundledSource;
119
+ private headerSource;
114
120
  private usageTracker;
115
121
  private isFirstGetData;
116
122
  private buildDataPromise;
@@ -123,6 +129,7 @@ declare class Controller implements ControllerInterface {
123
129
  private onStreamDisconnected;
124
130
  private onPollData;
125
131
  private onPollError;
132
+ private onFetchedData;
126
133
  private wireSourceEvents;
127
134
  private unwireSourceEvents;
128
135
  private transition;
@@ -7,7 +7,7 @@ import {
7
7
  evaluate,
8
8
  flagsClient,
9
9
  resetDefaultFlagsClient
10
- } from "./chunk-5BWCBI7I.js";
10
+ } from "./chunk-FEALIMCH.js";
11
11
  export {
12
12
  Controller,
13
13
  FallbackEntryNotFoundError,
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkCKL562EUcjs = require('./chunk-CKL562EU.cjs');
10
+ var _chunkZUO5MVUDcjs = require('./chunk-ZUO5MVUD.cjs');
11
11
 
12
12
 
13
13
 
@@ -18,5 +18,5 @@ var _chunkCKL562EUcjs = require('./chunk-CKL562EU.cjs');
18
18
 
19
19
 
20
20
 
21
- exports.Controller = _chunkCKL562EUcjs.Controller; exports.FallbackEntryNotFoundError = _chunkCKL562EUcjs.FallbackEntryNotFoundError; exports.FallbackNotFoundError = _chunkCKL562EUcjs.FallbackNotFoundError; exports.FlagNetworkDataSource = _chunkCKL562EUcjs.Controller; exports.Reason = _chunkCKL562EUcjs.ResolutionReason; exports.createClient = _chunkCKL562EUcjs.createClient; exports.evaluate = _chunkCKL562EUcjs.evaluate; exports.flagsClient = _chunkCKL562EUcjs.flagsClient; exports.resetDefaultFlagsClient = _chunkCKL562EUcjs.resetDefaultFlagsClient;
21
+ exports.Controller = _chunkZUO5MVUDcjs.Controller; exports.FallbackEntryNotFoundError = _chunkZUO5MVUDcjs.FallbackEntryNotFoundError; exports.FallbackNotFoundError = _chunkZUO5MVUDcjs.FallbackNotFoundError; exports.FlagNetworkDataSource = _chunkZUO5MVUDcjs.Controller; exports.Reason = _chunkZUO5MVUDcjs.ResolutionReason; exports.createClient = _chunkZUO5MVUDcjs.createClient; exports.evaluate = _chunkZUO5MVUDcjs.evaluate; exports.flagsClient = _chunkZUO5MVUDcjs.flagsClient; exports.resetDefaultFlagsClient = _chunkZUO5MVUDcjs.resetDefaultFlagsClient;
22
22
  //# sourceMappingURL=index.next-js.cjs.map
@@ -1,5 +1,5 @@
1
- import { V as VariantId, R as ResolutionReason, D as DatafileInput, S as StreamOptions, P as PollingOptions, M as MetricEnvironment, C as ControllerInterface, a as Datafile, B as BundledDefinitions, e as experimental_ReportExposures, E as EvaluationParams, b as EvaluationResult, F as FlagsClient } from './types-CIONStRG.cjs';
2
- export { c as Packed, d as Value, f as experimental_EvaluationOptions, g as experimental_ExperimentAssignment, h as experimental_Exposure } from './types-CIONStRG.cjs';
1
+ import { V as VariantId, R as ResolutionReason, D as DatafileInput, S as StreamOptions, P as PollingOptions, M as MetricEnvironment, C as ControllerInterface, a as Datafile, B as BundledDefinitions, e as experimental_ReportExposures, E as EvaluationParams, b as EvaluationResult, F as FlagsClient } from './types-w8u8i22D.cjs';
2
+ export { c as Packed, d as Value, f as experimental_EvaluationOptions, g as experimental_ExperimentAssignment, h as experimental_Exposure } from './types-w8u8i22D.cjs';
3
3
 
4
4
  interface TrackEvaluationOptions {
5
5
  flagKey: string;
@@ -98,6 +98,11 @@ type ControllerOptions = {
98
98
  * - Uses polling exclusively
99
99
  * - Same fallback chains as streaming mode
100
100
  *
101
+ * **Runtime - vercel mode** (request context has matching x-vercel-flags-config-versions header)
102
+ * - Uses the header value to determine if the current data is fresh
103
+ * - Revalidates in the background if the header value is within 10 seconds of the current configUpdatedAt
104
+ * - Blocking fetch if header is newer than current configUpdatedAt
105
+ *
101
106
  * **Runtime — offline mode** (neither stream nor polling):
102
107
  * - Init fallback: constructor datafile → bundled → one-time fetch → throw
103
108
  * - Read fallback: in-memory value → constructor datafile → bundled → one-time fetch → throw
@@ -111,6 +116,7 @@ declare class Controller implements ControllerInterface {
111
116
  private streamSource;
112
117
  private pollingSource;
113
118
  private bundledSource;
119
+ private headerSource;
114
120
  private usageTracker;
115
121
  private isFirstGetData;
116
122
  private buildDataPromise;
@@ -123,6 +129,7 @@ declare class Controller implements ControllerInterface {
123
129
  private onStreamDisconnected;
124
130
  private onPollData;
125
131
  private onPollError;
132
+ private onFetchedData;
126
133
  private wireSourceEvents;
127
134
  private unwireSourceEvents;
128
135
  private transition;
@@ -1,5 +1,5 @@
1
- import { V as VariantId, R as ResolutionReason, D as DatafileInput, S as StreamOptions, P as PollingOptions, M as MetricEnvironment, C as ControllerInterface, a as Datafile, B as BundledDefinitions, e as experimental_ReportExposures, E as EvaluationParams, b as EvaluationResult, F as FlagsClient } from './types-CIONStRG.js';
2
- export { c as Packed, d as Value, f as experimental_EvaluationOptions, g as experimental_ExperimentAssignment, h as experimental_Exposure } from './types-CIONStRG.js';
1
+ import { V as VariantId, R as ResolutionReason, D as DatafileInput, S as StreamOptions, P as PollingOptions, M as MetricEnvironment, C as ControllerInterface, a as Datafile, B as BundledDefinitions, e as experimental_ReportExposures, E as EvaluationParams, b as EvaluationResult, F as FlagsClient } from './types-w8u8i22D.js';
2
+ export { c as Packed, d as Value, f as experimental_EvaluationOptions, g as experimental_ExperimentAssignment, h as experimental_Exposure } from './types-w8u8i22D.js';
3
3
 
4
4
  interface TrackEvaluationOptions {
5
5
  flagKey: string;
@@ -98,6 +98,11 @@ type ControllerOptions = {
98
98
  * - Uses polling exclusively
99
99
  * - Same fallback chains as streaming mode
100
100
  *
101
+ * **Runtime - vercel mode** (request context has matching x-vercel-flags-config-versions header)
102
+ * - Uses the header value to determine if the current data is fresh
103
+ * - Revalidates in the background if the header value is within 10 seconds of the current configUpdatedAt
104
+ * - Blocking fetch if header is newer than current configUpdatedAt
105
+ *
101
106
  * **Runtime — offline mode** (neither stream nor polling):
102
107
  * - Init fallback: constructor datafile → bundled → one-time fetch → throw
103
108
  * - Read fallback: in-memory value → constructor datafile → bundled → one-time fetch → throw
@@ -111,6 +116,7 @@ declare class Controller implements ControllerInterface {
111
116
  private streamSource;
112
117
  private pollingSource;
113
118
  private bundledSource;
119
+ private headerSource;
114
120
  private usageTracker;
115
121
  private isFirstGetData;
116
122
  private buildDataPromise;
@@ -123,6 +129,7 @@ declare class Controller implements ControllerInterface {
123
129
  private onStreamDisconnected;
124
130
  private onPollData;
125
131
  private onPollError;
132
+ private onFetchedData;
126
133
  private wireSourceEvents;
127
134
  private unwireSourceEvents;
128
135
  private transition;
@@ -7,7 +7,7 @@ import {
7
7
  evaluate,
8
8
  flagsClient,
9
9
  resetDefaultFlagsClient
10
- } from "./chunk-DYSF37WV.js";
10
+ } from "./chunk-XFCAUSUZ.js";
11
11
  export {
12
12
  Controller,
13
13
  FallbackEntryNotFoundError,
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
2
2
 
3
3
 
4
- var _chunkCVDAHZHKcjs = require('./chunk-CVDAHZHK.cjs');
4
+ var _chunkOXUU7M2Acjs = require('./chunk-OXUU7M2A.cjs');
5
5
 
6
6
  // src/openfeature.make.ts
7
7
 
@@ -150,7 +150,7 @@ function make(createClient2, defaultFlagsClient) {
150
150
  }
151
151
 
152
152
  // src/openfeature.default.ts
153
- var VercelProvider = make(_chunkCVDAHZHKcjs.createClient, _chunkCVDAHZHKcjs.flagsClient);
153
+ var VercelProvider = make(_chunkOXUU7M2Acjs.createClient, _chunkOXUU7M2Acjs.flagsClient);
154
154
 
155
155
 
156
156
  exports.VercelProvider = VercelProvider;
@@ -1,4 +1,4 @@
1
- import { F as FlagsClient } from './types-CIONStRG.cjs';
1
+ import { F as FlagsClient } from './types-w8u8i22D.cjs';
2
2
  import * as _openfeature_server_sdk from '@openfeature/server-sdk';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { F as FlagsClient } from './types-CIONStRG.js';
1
+ import { F as FlagsClient } from './types-w8u8i22D.js';
2
2
  import * as _openfeature_server_sdk from '@openfeature/server-sdk';
3
3
 
4
4
  /**
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createClient,
3
3
  flagsClient
4
- } from "./chunk-5BWCBI7I.js";
4
+ } from "./chunk-FEALIMCH.js";
5
5
 
6
6
  // src/openfeature.make.ts
7
7
  import {
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
2
2
 
3
3
 
4
- var _chunkCKL562EUcjs = require('./chunk-CKL562EU.cjs');
4
+ var _chunkZUO5MVUDcjs = require('./chunk-ZUO5MVUD.cjs');
5
5
 
6
6
  // src/openfeature.make.ts
7
7
 
@@ -150,7 +150,7 @@ function make(createClient2, defaultFlagsClient) {
150
150
  }
151
151
 
152
152
  // src/openfeature.next-js.ts
153
- var VercelProvider = make(_chunkCKL562EUcjs.createClient, _chunkCKL562EUcjs.flagsClient);
153
+ var VercelProvider = make(_chunkZUO5MVUDcjs.createClient, _chunkZUO5MVUDcjs.flagsClient);
154
154
 
155
155
 
156
156
  exports.VercelProvider = VercelProvider;
@@ -1,4 +1,4 @@
1
- import { F as FlagsClient } from './types-CIONStRG.cjs';
1
+ import { F as FlagsClient } from './types-w8u8i22D.cjs';
2
2
  import * as _openfeature_server_sdk from '@openfeature/server-sdk';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { F as FlagsClient } from './types-CIONStRG.js';
1
+ import { F as FlagsClient } from './types-w8u8i22D.js';
2
2
  import * as _openfeature_server_sdk from '@openfeature/server-sdk';
3
3
 
4
4
  /**
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createClient,
3
3
  flagsClient
4
- } from "./chunk-DYSF37WV.js";
4
+ } from "./chunk-XFCAUSUZ.js";
5
5
 
6
6
  // src/openfeature.make.ts
7
7
  import {
@@ -59,7 +59,7 @@ type Metrics = {
59
59
  /** Whether the stream is currently connected */
60
60
  connectionState: 'connected' | 'disconnected';
61
61
  /** The current operating mode of the client */
62
- mode: 'streaming' | 'polling' | 'build' | 'offline';
62
+ mode: 'streaming' | 'polling' | 'build' | 'vercel' | 'offline';
63
63
  /** Time in ms for the pure flag evaluation logic (only present on EvaluationResult) */
64
64
  evaluationMs?: number;
65
65
  };
@@ -156,9 +156,11 @@ type FlagsClient<Entities = Record<string, unknown>> = {
156
156
  sdkKey?: string;
157
157
  };
158
158
  /**
159
- * Evaluate a feature flag
159
+ * Evaluate a feature flag.
160
160
  *
161
- * Requires initialize() to have been called and awaited first.
161
+ * Initializes the client automatically on first use. Initialization failures
162
+ * are caught so evaluation can try its fallback sources and defaultValue.
163
+ * With request-scoped Vercel OIDC, call this inside a request handler.
162
164
  *
163
165
  * @param flagKey
164
166
  * @param defaultValue
@@ -173,7 +175,9 @@ type FlagsClient<Entities = Record<string, unknown>> = {
173
175
  * Avoids the per-flag overhead of separate `evaluate()` invocations (in particular,
174
176
  * the parallel promises and repeated datafile reads they would entail).
175
177
  *
176
- * Requires initialize() to have been called and awaited first.
178
+ * Initializes the client automatically on first use. Initialization failures
179
+ * are caught so evaluation can try its fallback sources and default values.
180
+ * With request-scoped Vercel OIDC, call this inside a request handler.
177
181
  *
178
182
  * @param flags Array of `{ key, defaultValue? }` entries to evaluate.
179
183
  * @param entities Shared entities used for every flag in the bulk call.
@@ -193,7 +197,13 @@ type FlagsClient<Entities = Record<string, unknown>> = {
193
197
  entities?: E;
194
198
  }) => Promise<void>;
195
199
  /**
196
- * Retrieve the latest datafile during startup, and set up subscriptions if needed.
200
+ * Load flag definitions and set up subscriptions if needed.
201
+ *
202
+ * Optional: evaluate() and bulkEvaluate() initialize automatically. This method
203
+ * rejects if initialization fails, while evaluation can still try fallbacks.
204
+ * With request-scoped Vercel OIDC, call this inside a request handler, not at
205
+ * module scope. Creating the client at module scope is safe; starting and
206
+ * caching an initialization promise there can run before a token is available.
197
207
  */
198
208
  initialize(): void | Promise<void>;
199
209
  /**
@@ -59,7 +59,7 @@ type Metrics = {
59
59
  /** Whether the stream is currently connected */
60
60
  connectionState: 'connected' | 'disconnected';
61
61
  /** The current operating mode of the client */
62
- mode: 'streaming' | 'polling' | 'build' | 'offline';
62
+ mode: 'streaming' | 'polling' | 'build' | 'vercel' | 'offline';
63
63
  /** Time in ms for the pure flag evaluation logic (only present on EvaluationResult) */
64
64
  evaluationMs?: number;
65
65
  };
@@ -156,9 +156,11 @@ type FlagsClient<Entities = Record<string, unknown>> = {
156
156
  sdkKey?: string;
157
157
  };
158
158
  /**
159
- * Evaluate a feature flag
159
+ * Evaluate a feature flag.
160
160
  *
161
- * Requires initialize() to have been called and awaited first.
161
+ * Initializes the client automatically on first use. Initialization failures
162
+ * are caught so evaluation can try its fallback sources and defaultValue.
163
+ * With request-scoped Vercel OIDC, call this inside a request handler.
162
164
  *
163
165
  * @param flagKey
164
166
  * @param defaultValue
@@ -173,7 +175,9 @@ type FlagsClient<Entities = Record<string, unknown>> = {
173
175
  * Avoids the per-flag overhead of separate `evaluate()` invocations (in particular,
174
176
  * the parallel promises and repeated datafile reads they would entail).
175
177
  *
176
- * Requires initialize() to have been called and awaited first.
178
+ * Initializes the client automatically on first use. Initialization failures
179
+ * are caught so evaluation can try its fallback sources and default values.
180
+ * With request-scoped Vercel OIDC, call this inside a request handler.
177
181
  *
178
182
  * @param flags Array of `{ key, defaultValue? }` entries to evaluate.
179
183
  * @param entities Shared entities used for every flag in the bulk call.
@@ -193,7 +197,13 @@ type FlagsClient<Entities = Record<string, unknown>> = {
193
197
  entities?: E;
194
198
  }) => Promise<void>;
195
199
  /**
196
- * Retrieve the latest datafile during startup, and set up subscriptions if needed.
200
+ * Load flag definitions and set up subscriptions if needed.
201
+ *
202
+ * Optional: evaluate() and bulkEvaluate() initialize automatically. This method
203
+ * rejects if initialization fails, while evaluation can still try fallbacks.
204
+ * With request-scoped Vercel OIDC, call this inside a request handler, not at
205
+ * module scope. Creating the client at module scope is safe; starting and
206
+ * caching an initialization promise there can run before a token is available.
197
207
  */
198
208
  initialize(): void | Promise<void>;
199
209
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/flags-core",
3
- "version": "1.8.1",
3
+ "version": "1.9.0-0fd2f41-20260915094243",
4
4
  "description": "A server-side client for Vercel Flags",
5
5
  "keywords": [
6
6
  "vercel",