-
Notifications
You must be signed in to change notification settings - Fork 44
Add support for feature flags management API #1420
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
Conversation
Greptile OverviewGreptile SummaryAdded comprehensive feature flags management API support to the WorkOS SDK. This PR introduces a new Key changes:
Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Client
participant WorkOS
participant FeatureFlags
participant HttpClient
participant API as WorkOS API
Note over Client,API: List Feature Flags
Client->>WorkOS: featureFlags.listFeatureFlags(options)
WorkOS->>FeatureFlags: listFeatureFlags(options)
FeatureFlags->>HttpClient: fetchAndDeserialize('/feature-flags')
HttpClient->>API: GET /feature-flags
API-->>HttpClient: List response with feature flags
HttpClient-->>FeatureFlags: Deserialized list
FeatureFlags-->>WorkOS: AutoPaginatable<FeatureFlag>
WorkOS-->>Client: Feature flags list
Note over Client,API: Get Feature Flag
Client->>WorkOS: featureFlags.getFeatureFlag(slug)
WorkOS->>FeatureFlags: getFeatureFlag(slug)
FeatureFlags->>HttpClient: workos.get(`/feature-flags/${slug}`)
HttpClient->>API: GET /feature-flags/:slug
API-->>HttpClient: Feature flag response
HttpClient-->>FeatureFlags: FeatureFlagResponse
FeatureFlags->>FeatureFlags: deserializeFeatureFlag()
FeatureFlags-->>WorkOS: FeatureFlag
WorkOS-->>Client: Feature flag
Note over Client,API: Enable/Disable Feature Flag
Client->>WorkOS: featureFlags.enableFeatureFlag(slug)
WorkOS->>FeatureFlags: enableFeatureFlag(slug)
FeatureFlags->>HttpClient: workos.put(`/feature-flags/${slug}/enable`)
HttpClient->>API: PUT /feature-flags/:slug/enable
API-->>HttpClient: Updated feature flag
HttpClient-->>FeatureFlags: FeatureFlagResponse
FeatureFlags->>FeatureFlags: deserializeFeatureFlag()
FeatureFlags-->>WorkOS: FeatureFlag
WorkOS-->>Client: Updated feature flag
Note over Client,API: Add/Remove Flag Target
Client->>WorkOS: featureFlags.addFlagTarget(slug, targetId)
WorkOS->>FeatureFlags: addFlagTarget(slug, targetId)
FeatureFlags->>HttpClient: workos.post(`/feature-flags/${slug}/targets/${targetId}`)
HttpClient->>API: POST /feature-flags/:slug/targets/:targetId
API-->>HttpClient: 204 No Content
HttpClient-->>FeatureFlags: void
FeatureFlags-->>WorkOS: void
WorkOS-->>Client: Success
|
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.
18 files reviewed, no comments
d45ee70 to
147c2bc
Compare
This matches our API which always returns description for flags. When there is no description, we return an empty string.
147c2bc to
c4b37e6
Compare
src/feature-flags/feature-flags.ts
Outdated
| async addFlagTarget(slug: string, targetId: string): Promise<void> { | ||
| await this.workos.post(`/feature-flags/${slug}/targets/${targetId}`, {}); | ||
| } | ||
|
|
||
| async removeFlagTarget(slug: string, targetId: string): Promise<void> { | ||
| await this.workos.delete(`/feature-flags/${slug}/targets/${targetId}`); | ||
| } |
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.
Did you consider making slug and targetId named arguments instead of positional arguments? The order of those arguments aren't particularly obvious, so I'm wondering if addFlagTarget({ slug: 'my-feature', targetId: 'user_foobar' }) might be more foolproof.
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.
I agree - I think named arguments makes more sense here. Updated the PR to do this
## Description Includes: - #1417 - #1420 ## Documentation Does this require changes to the WorkOS Docs? E.g. the [API Reference](https://workos.com/docs/reference) or code snippets need updates. ``` [ ] Yes ``` If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required. <!-- av pr metadata This information is embedded by the av CLI when creating PRs to track the status of stacks when using Aviator. Please do not delete or edit this section of the PR. ``` {"parent":"main","parentHead":"","trunk":"main"} ``` -->
Description
listFeatureFlags(GET /feature-flags)getFeatureFlag(GET /feature-flags/:slug)enableFeatureFlag(PUT /feature-flags/:slug/enable)disableFeatureFlag(PUT /feature-flags/:slug/disable)addFlagTarget(POST /feature-flags/:slug/targets/:targetId)removeFlagTarget(DELETE /feature-flags/:slug/targets/:targetId)FeatureFlaginterface to addtags,enabledanddefaultValuefieldsFeatureFlag.descriptionto be a required field to match the API responseDocumentation
Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.
If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.