-
Notifications
You must be signed in to change notification settings - Fork 59
feat: expose js sdk identity without proxy wrappers #1377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c158739
feat: expose js sdk identity without proxy wrappers
jonathannorris 887dc1a
fix: remove angular framework client cache
jonathannorris 9fd6125
feat: add client metadata options overloads
jonathannorris 5b22a3f
refactor: inline framework-aware client helpers
jonathannorris cbe0b10
fix: preserve server getClient context overloads
jonathannorris 4143071
feat: split sdk family from runtime paradigm
jonathannorris d8d88c8
refactor: remove unused server framework mutator
jonathannorris c32450a
refactor: keep framework metadata internal
jonathannorris 763eb68
refactor: dedupe framework metadata helpers
jonathannorris 8ba671c
fix: normalize empty angular domains
jonathannorris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,21 @@ | ||
| import type { Client, EvaluationContext } from '@openfeature/server-sdk'; | ||
| import { OpenFeature } from '@openfeature/server-sdk'; | ||
|
|
||
| type FrameworkMetadataClient = Client & { | ||
| setFrameworkMetadata?: (framework: 'nest') => Client; | ||
| }; | ||
|
|
||
| /** | ||
| * Returns a domain scoped or the default OpenFeature client with the given context. | ||
| * @param {string} domain The domain of the OpenFeature client. | ||
| * @param {EvaluationContext} context The evaluation context of the client. | ||
| * @returns {Client} The OpenFeature client. | ||
| */ | ||
| export function getClientForEvaluation(domain?: string, context?: EvaluationContext) { | ||
| return domain ? OpenFeature.getClient(domain, context) : OpenFeature.getClient(context); | ||
| return setNestFrameworkMetadata(domain ? OpenFeature.getClient(domain, context) : OpenFeature.getClient(context)); | ||
| } | ||
|
|
||
| function setNestFrameworkMetadata(client: Client): Client { | ||
| (client as FrameworkMetadataClient).setFrameworkMetadata?.('nest'); | ||
| return client; | ||
| } | ||
|
jonathannorris marked this conversation as resolved.
Outdated
|
||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,10 @@ import * as React from 'react'; | |
| import type { ReactFlagEvaluationOptions } from '../options'; | ||
| import { Context } from '../internal'; | ||
|
|
||
| type FrameworkMetadataClient = Client & { | ||
| setFrameworkMetadata?: (framework: 'react') => Client; | ||
| }; | ||
|
|
||
| type ClientOrDomain = | ||
| | { | ||
| /** | ||
|
|
@@ -32,7 +36,22 @@ type ProviderProps = { | |
| * @returns {OpenFeatureProvider} context provider | ||
| */ | ||
| export function OpenFeatureProvider({ client, domain, children, ...options }: ProviderProps) { | ||
| const stableClient = React.useMemo(() => client || OpenFeature.getClient(domain), [client, domain]); | ||
| const stableClient = React.useMemo(() => { | ||
| if (client) { | ||
| return setReactFrameworkMetadata(client); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This mutates a user-provided client that might also be used elsewhere, this seems problematic? |
||
| } | ||
|
|
||
| return setReactFrameworkMetadata(OpenFeature.getClient(domain)); | ||
| }, [client, domain]); | ||
|
|
||
| return <Context.Provider value={{ client: stableClient, options }}>{children}</Context.Provider>; | ||
| } | ||
|
|
||
| function setReactFrameworkMetadata(client: Client): Client { | ||
| // When a caller provides an existing client, preserve that instance but mark it | ||
| // as React-backed so metadata stays aligned with provider-created clients. | ||
| // The cast is needed because `setFrameworkMetadata` is an internal method on the | ||
| // SDK-owned client implementation, not part of the public `Client` interface. | ||
| (client as FrameworkMetadataClient).setFrameworkMetadata?.('react'); | ||
| return client; | ||
| } | ||
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.