Replace the deterministic 100/200ms retry schedule with full-jitter exponential
backoff, jitter MAX_BATCH_WAIT_MS by ±20% to desynchronize concurrent flushes,
and log when a flush exhausts all retries.
Helpers extracted to utils/backoff.ts so they can be reused.
Co-authored-by: Cursor <cursoragent@cursor.com>
The SDK key validation now uses a regex (/^vf_(?:server|client)_/) to require
the format vf_server_* or vf_client_* instead of accepting any string starting
with vf_. This prevents false positives with third-party service identifiers
that happen to start with vf_ (e.g., Stripe identity flow IDs like
vf_1PyHgVLpWuMxVFx...).
Adds isValidSdkKey() helper function and updates parseSdkKeyFromFlagsConnectionString()
to use the stricter validation. Updates all tests to use valid SDK key formats.
* use __no_flags__ to handle precompute with empty flags
* handle __no_flags__ in serialize
* add __no_flags__ handling to sveltekit
* avoid returning undefined when defaultValue is set
This could only happen on precomputed flags in case of bad usage.
* add error messages
* test console logs
* update changeset
* Return meaningful result from prepareFlagsDefinitions
- Add PrepareFlagsDefinitionsResult discriminated union type that indicates whether definitions were created
- Change prepareFlagsDefinitions return type from Promise<void> to Promise<PrepareFlagsDefinitionsResult>
- Return { created: false, reason: 'no-sdk-keys' } when no SDK keys are found
- Return { created: true, sdkKeysCount: N } when definitions are successfully created
- Add tests for both return paths to verify the function communicates its result properly
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
* Add changeset for prepareFlagsDefinitions result type
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
* Replace version param with userAgentSuffix in prepare-flags-definitions
Changed the API to use a cleaner approach:
- Removed `version?: string` option in favor of `userAgentSuffix?: string`
- Now imports package version directly from package.json
- Constructs user-agent as: `@vercel/prepare-flags-definitions/{pkgVersion} {suffix}`
- Allows consumers (e.g., vercel-cli, vercel-api) to add context to the header
Added tests verifying both default and suffixed user-agent headers.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
* add changeset
---------
Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
* Extract @vercel/prepare-flags-definitions package
Extract the core flag definitions preparation logic from the Vercel CLI into a standalone, reusable package. This includes:
- prepareFlagsDefinitions() function that collects SDK keys from env, fetches definitions, and writes to node_modules
- hashSdkKey() helper for SHA-256 hashing
- generateDefinitionsModule() for JS module generation with deduplication and lazy parsing
Follows repo conventions: pnpm workspaces, tsup, vitest, ES modules with CJS fallback.
* Add JSDoc comments from original CLI source
* Add inline comments from original CLI source
* Add optional output parameter with debug logging
* Add output.time for datafile fetching
* Add changeset for @vercel/prepare-flags-definitions
* Added new comparators: (not_)contains and case-insensitive versions
* Switched to "ci" option instead of creating new condition for every ci-case
* Cleanup
* More cleanup
* Some more cleanup & finetuning
Made-with: Cursor
* Changeset
* Switch options key to just "i" and also allow for passing "i" as string instead of options object
* Apply suggestions from code review
* Update packages/vercel-flags-core/src/evaluate.ts
Co-authored-by: Dominik Ferber <dominik.ferber@gmail.com>
* naming
* Renaming
---------
Co-authored-by: Dominik Ferber <dominik.ferber@gmail.com>
* Add CJS support for @vercel/flags-core
Update tsup config to build both ESM and CJS formats, and update package.json exports to use import/require conditions with separate entry points for CommonJS consumers.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
* changeset
---------
Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>