Repository navigation
feat(feature-flags): Align rule and target management with API contracts #1719
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
Open
stanleyphu
wants to merge
2
commits into
main
Choose a base branch
from
codex/auth-7099-rule-management
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { FlagRule, FlagTargetMembership } from './interfaces'; | ||
|
|
||
| /** A rule was created, but adding one of its targets failed. */ | ||
| export class CreateRuleWithTargetsError extends Error { | ||
| readonly name = 'CreateRuleWithTargetsError'; | ||
|
|
||
| constructor( | ||
| readonly rule: FlagRule, | ||
| /** Memberships confirmed by the API before the failure. */ | ||
| readonly targets: FlagTargetMembership[], | ||
| readonly failedTargetId: string, | ||
| cause: unknown, | ||
| ) { | ||
| super('The rule was created, but adding a target failed.', { cause }); | ||
| } | ||
| } |
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
7 changes: 7 additions & 0 deletions
7
src/feature-flags/interfaces/create-flag-rule-options.interface.ts
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 |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| export interface CreateFlagRuleOptions { | ||
| /** The feature flag's slug. */ | ||
| flagSlug: string; | ||
| /** An organization, user, or registered custom target type. */ | ||
| targetType: string; | ||
| value: boolean; | ||
| } |
5 changes: 5 additions & 0 deletions
5
src/feature-flags/interfaces/create-flag-target-options.interface.ts
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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| export interface CreateFlagTargetOptions { | ||
| /** The rule determines the flag, target type, and value. */ | ||
| ruleId: string; | ||
| targetId: string; | ||
| } |
12 changes: 12 additions & 0 deletions
12
src/feature-flags/interfaces/create-rule-with-targets-options.interface.ts
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 |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { CreateFlagRuleOptions } from './create-flag-rule-options.interface'; | ||
| import { FlagRule } from './flag-rule.interface'; | ||
| import { FlagTargetMembership } from './flag-target-membership.interface'; | ||
|
|
||
| export interface CreateRuleWithTargetsOptions extends CreateFlagRuleOptions { | ||
| targetIds: string[]; | ||
| } | ||
|
|
||
| export interface CreateRuleWithTargetsResult { | ||
| rule: FlagRule; | ||
| targets: FlagTargetMembership[]; | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| export interface FlagRule { | ||
| object: 'flag_rule'; | ||
| id: string; | ||
| flagId: string; | ||
| flagSlug: string; | ||
| environmentId: string; | ||
| /** Null for rules that match every context. */ | ||
| targetType: string | null; | ||
| /** Rules are evaluated in ascending position order. */ | ||
| position: number; | ||
| valueType: 'boolean'; | ||
| value: boolean; | ||
| createdAt: string; | ||
| updatedAt: string; | ||
| } | ||
|
|
||
| export interface FlagRuleResponse { | ||
| object: 'flag_rule'; | ||
| id: string; | ||
| flag_id: string; | ||
| flag_slug: string; | ||
| environment_id: string; | ||
| target_type: string | null; | ||
| position: number; | ||
| value_type: 'boolean'; | ||
| value: boolean; | ||
| created_at: string; | ||
| updated_at: string; | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current API rejects this
POST /flag_targetspayload: it does not yet acceptrule_idand requiresflag_slugandtarget_type. Direct calls tocreateFlagTargettherefore return a 400.createRuleWithTargetscreates the rule first, then fails on its first membership and leaves an empty rule to reconcile. This needs the AUTH-7084 API deployment and a successful end-to-end check before release.Prompt To Fix With AI