Skip to content

Node: Add OpenFeature server provider#255

Open
msiebert wants to merge 22 commits intomasterfrom
msiebert-openfeature-provider
Open

Node: Add OpenFeature server provider#255
msiebert wants to merge 22 commits intomasterfrom
msiebert-openfeature-provider

Conversation

@msiebert
Copy link
Copy Markdown
Contributor

Summary

  • Adds openfeature-server-provider/ package implementing OpenFeature server provider
  • Wraps local or remote flags provider, Symbol sentinel for flag detection
  • 32 tests, all passing

Design

  • targetingKey not special, STATIC reason, three error codes, onClose no-op

🤖 Generated with Claude Code

@msiebert msiebert self-assigned this Mar 19, 2026
@msiebert msiebert changed the title Add OpenFeature server provider Node: Add OpenFeature server provider Mar 31, 2026
Comment thread .github/workflows/tests.yml Fixed
@msiebert msiebert marked this pull request as ready for review April 3, 2026 05:06
@msiebert msiebert requested review from a team and tylerjroach April 3, 2026 05:06
Comment thread openfeature-server-provider/package.json Outdated
Comment thread .github/workflows/tests.yml Outdated
Comment thread lib/flags/local_flags.js
Comment thread openfeature-server-provider/src/MixpanelProvider.js Outdated
Comment thread openfeature-server-provider/src/MixpanelProvider.js Outdated
@msiebert msiebert requested a review from hans-lizihan April 9, 2026 22:27
@hans-lizihan
Copy link
Copy Markdown
Contributor

hmm we need docs for how to use it? also for this new sub-package, i think it's more appropriate to make it 100% ts native as well, can skip the complicated .d.ts and define all types inline

@msiebert msiebert force-pushed the msiebert-openfeature-provider branch from c225f3f to fa9572f Compare April 9, 2026 23:49
@msiebert msiebert changed the base branch from master to msiebert-sdk-changes April 9, 2026 23:50
msiebert and others added 15 commits April 10, 2026 14:03
Implement an OpenFeature provider for the Mixpanel Node SDK as a
separate package in openfeature-server-provider/. Wraps either
LocalFeatureFlagsProvider or RemoteFeatureFlagsProvider via the shared
getVariant() API.

Key design decisions:
- Uses Symbol sentinel for fallback detection (flag-not-found)
- Context set globally via initialize(), per-evaluation context ignored
- targetingKey has no special meaning
- Handles both sync (local) and async (remote) providers via await
- Reason codes: STATIC for success, ERROR for failures
- Error codes: PROVIDER_NOT_READY, FLAG_NOT_FOUND, TYPE_MISMATCH
- onClose() is a no-op
- Returns default value on all errors

Includes 32 tests covering all flag types, error cases, async
providers, context handling, and edge cases.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds PROVIDER_NOT_READY tests for string, number, and object types
(boolean was already covered), and SDK exception handling tests
verifying that getVariant failures return defaults with error codes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Merge per-evaluation context on top of init context so callers can
override or extend context at each flag evaluation, matching the
OpenFeature specification.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- shutdown() now delegates to underlying flags provider
- Add areFlagsReady() to LocalFlagsProvider, check before evaluation
- Return ErrorCode.GENERAL (not PROVIDER_NOT_READY) for exceptions
- Add context value unwrapping with whole-number float→int conversion
- Update tests for new error codes and add shutdown/readiness tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract shared _resolveTypedFlag helper to eliminate ~70 lines of
duplicated type-checking across 4 resolve methods. Fix misplaced
shutdown() that broke JSDoc association. Remove dead integer
truncation code. Fix inconsistent snake_case naming and simplify
null checks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove dangerous {value: X} unwrapping heuristic that silently destroyed
legitimate context data. Add Date-to-ISO-string conversion. Add await to
onClose shutdown. Update TypeScript declarations with optional methods.
Add files field to package.json. Add 6 context-building tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Required by repo policy — actions must be pinned to full-length
commit SHAs rather than version tags.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Track openfeature-server-provider/package-lock.json so npm ci
  works in CI
- Fix prettier formatting in test file

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
areFlagsReady() previously checked flagDefinitions.size > 0, which
incorrectly reported "not ready" when the API returned an empty flags
array. Now returns a promise that resolves after the first successful
fetch, regardless of whether flags were returned. The OpenFeature
provider awaits this promise during initialize() instead of using a
simple boolean.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
MixpanelProvider.createLocal and createRemote accept a token and config,
create the Mixpanel client internally, auto-start polling for local
configs, and expose the client via the mixpanel property.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… flag not found

Updates OpenFeature provider reason codes to match the updated spec:
- Success: STATIC → TARGETING_MATCH
- Flag not found: ERROR → DEFAULT

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…essages, fix CI

- Add JSDoc comments to MixpanelProvider public methods
- Bind @openfeature/server-sdk peer dependency to ^1.17.0
- Use npm test with coverage in CI openfeature job
- Remove unnecessary article from type mismatch error messages
- Fix areFlagsReady return type in index.d.ts (Promise<void>, not boolean)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Move openfeature-server-provider to packages/ as an npm workspace
- Convert all source and tests from JavaScript to TypeScript
- Add README adapted from the Java OpenFeature provider
- Bump main SDK version to 0.21.0 for shutdown method support
- Add shutdown() and areFlagsReady() to flag provider type declarations
- Add workspace scripts (test:all, build:workspaces) to root package.json
- Exclude packages/ from main SDK npm tarball via .npmignore

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@msiebert msiebert changed the base branch from msiebert-sdk-changes to master April 10, 2026 21:04
@msiebert msiebert force-pushed the msiebert-openfeature-provider branch from fa9572f to 4da0720 Compare April 10, 2026 21:11
msiebert and others added 2 commits April 10, 2026 14:48
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
msiebert and others added 2 commits April 10, 2026 14:56
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
All publishable targets now live under packages/. The root becomes a
private workspace orchestrator while the mixpanel npm package ships
from packages/mixpanel/ with an explicit files allowlist.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@@ -0,0 +1,17 @@
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i tsconfig and vitest thing should be on root dir

@@ -0,0 +1,2 @@
dist/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gitignore as well

msiebert and others added 3 commits April 17, 2026 12:28
- Collapse CI into single job using npm run test:all + tsc --build from
  root; drop working-directory in favor of npm workspaces
- Add root tsconfig.json solution file with project references to both
  packages; both package tsconfigs are now composite
- Hoist .gitignore to repo root (adds dist/, *.tsbuildinfo); delete the
  per-package .gitignore
- Bind mixpanel peerDep to ^0.21.0; devDep uses workspace (*)
- Add --coverage to both packages' test scripts for parity
- Add concise JSDoc to MixpanelProvider public methods

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Both workspace test scripts now emit coverage-final.json; wire it up to
codecov-action so PRs get a coverage delta comment.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move vitest and @vitest/coverage-v8 to root devDependencies so both
workspaces share a single version. Also drop typescript from the
openfeature package (already in root).

Per-package devDeps now contain only package-specific test helpers
(nock, proxyquire for mixpanel; @openfeature/core, @openfeature/server-sdk,
mixpanel workspace pin for openfeature-server-provider).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants