feat(flags): share bulk evaluate() + give SvelteKit evaluate() (3/3)#414
Draft
dferber90 wants to merge 1 commit into
Draft
feat(flags): share bulk evaluate() + give SvelteKit evaluate() (3/3)#414dferber90 wants to merge 1 commit into
dferber90 wants to merge 1 commit into
Conversation
Extracts the bulk-evaluation orchestration into shared/evaluate.ts (`evaluateFlags` + the BULKABLE / BULK_IDENTIFY_REF markers), parameterized by how standalone flags are invoked and which errors are framework control flow. Next wraps it in its bulkStore ALS and invokes standalone flags via `flagFn()`; behavior and public .d.ts are unchanged. SvelteKit gains a real bulk `evaluate(flags, request, secret?)` (src/sveltekit/evaluate.ts) exported from flags/sveltekit and used by its `precompute`. SvelteKit's flag() now stamps `adapter`, `config`, and the bulk markers so adapters implementing `bulkDecide` resolve a whole group in one call. Adds 2 bulk-evaluate tests. Documents the framework contract (context resolution, secret strategy, isFrameworkError, invokeStandalone, output integration) in shared/README.md so adding a new framework only means writing a thin adapter. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Comment on lines
+53
to
+54
| invokeStandalone: (flagFn) => | ||
| (flagFn as (request: Request) => Promise<any>)(request), |
Contributor
There was a problem hiding this comment.
Suggested change
| invokeStandalone: (flagFn) => | |
| (flagFn as (request: Request) => Promise<any>)(request), | |
| // Thread the same resolved secret used for the bulk path's overrides so | |
| // standalone flags decrypt the override cookie consistently. Without this, | |
| // a standalone flag invoked as `flagFn(request)` (no secret) outside a | |
| // `createHandle` context would resolve its own secret via `tryGetSecret()` | |
| // (env `FLAGS_SECRET`), diverging from `resolvedSecret` when `evaluate()` | |
| // was called with a custom secret. | |
| invokeStandalone: (flagFn) => | |
| (flagFn as (request: Request, secret?: string) => Promise<any>)( | |
| request, | |
| resolvedSecret, | |
| ), |
In SvelteKit evaluate(), the resolved secret is used for the bulk path's overrides but not threaded to standalone flag invocations, so the two paths can decrypt the override cookie with different secrets within one evaluate() call.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked PR 3 of 3 · base:
shared/evaluation(#413)Extracts the bulk-evaluation orchestration into
shared/evaluate.ts(evaluateFlags+ theBULKABLE/BULK_IDENTIFY_REFmarkers), parameterized by how standalone flags are invoked and which errors are framework control flow. Next wraps it in itsbulkStoreALS and invokes standalone flags viaflagFn(); behavior and public.d.tsare unchanged.SvelteKit gains a real bulk
evaluate(flags, request, secret?)(src/sveltekit/evaluate.ts), exported fromflags/sveltekitand used by itsprecompute. SvelteKit'sflag()now stampsadapter,config, and the bulk markers so adapters implementingbulkDecideresolve a whole group in one call. Adds 2 bulk-evaluate tests.Documents the framework contract (context resolution, secret strategy,
isFrameworkError,invokeStandalone, output integration) inshared/README.mdso adding a new framework only means writing a thin adapter.Verification
123/123 tests pass · type-check · biome ·
attwgreen ·next.d.tsbyte-identical ·@flags-sdk/vercelbuilds.🤖 Generated with Claude Code