-
Notifications
You must be signed in to change notification settings - Fork 44
feat: Add environment role support #1454
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
base: main
Are you sure you want to change the base?
Conversation
Greptile OverviewGreptile SummaryThis PR adds comprehensive support for Environment Roles in the Authorization module, along with PATCH HTTP method support across the SDK. Key Changes:
Implementation Quality:
Security & Compliance:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant WorkOS
participant Authorization
participant FetchHttpClient
participant API as WorkOS API
Note over Client,API: Create Environment Role
Client->>WorkOS: workos.authorization.createEnvironmentRole(options)
WorkOS->>Authorization: createEnvironmentRole(options)
Authorization->>Authorization: serializeCreateEnvironmentRoleOptions(options)
Authorization->>WorkOS: workos.post('/authorization/roles', serialized)
WorkOS->>WorkOS: requireApiKey()
WorkOS->>FetchHttpClient: client.post(path, entity, headers)
FetchHttpClient->>API: POST /authorization/roles
API-->>FetchHttpClient: 201 EnvironmentRoleResponse
FetchHttpClient-->>WorkOS: HttpClientResponse
WorkOS-->>Authorization: { data: EnvironmentRoleResponse }
Authorization->>Authorization: deserializeEnvironmentRole(data)
Authorization-->>Client: EnvironmentRole
Note over Client,API: Update Environment Role (PATCH)
Client->>WorkOS: workos.authorization.updateEnvironmentRole(slug, options)
WorkOS->>Authorization: updateEnvironmentRole(slug, options)
Authorization->>Authorization: serializeUpdateEnvironmentRoleOptions(options)
Authorization->>WorkOS: workos.patch(`/authorization/roles/${slug}`, serialized)
WorkOS->>WorkOS: requireApiKey()
WorkOS->>FetchHttpClient: client.patch(path, entity, headers)
FetchHttpClient->>API: PATCH /authorization/roles/:slug
API-->>FetchHttpClient: 200 EnvironmentRoleResponse
FetchHttpClient-->>WorkOS: HttpClientResponse
WorkOS-->>Authorization: { data: EnvironmentRoleResponse }
Authorization->>Authorization: deserializeEnvironmentRole(data)
Authorization-->>Client: EnvironmentRole
Note over Client,API: List Environment Roles
Client->>WorkOS: workos.authorization.listEnvironmentRoles(options)
WorkOS->>Authorization: listEnvironmentRoles(options)
Authorization->>WorkOS: workos.get('/authorization/roles', { query: options })
WorkOS->>WorkOS: requireApiKey()
WorkOS->>FetchHttpClient: client.get(path, headers)
FetchHttpClient->>API: GET /authorization/roles
API-->>FetchHttpClient: 200 EnvironmentRoleListResponse
FetchHttpClient-->>WorkOS: HttpClientResponse
WorkOS-->>Authorization: { data: EnvironmentRoleListResponse }
Authorization->>Authorization: deserializeEnvironmentRole() for each
Authorization-->>Client: EnvironmentRoleList
|
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.
5 files reviewed, no comments
mattgd
left a comment
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.
Left one comment for consideration, but looks good otherwise!
| async addEnvironmentRolePermission( | ||
| slug: string, | ||
| permissionSlug: string, | ||
| ): Promise<EnvironmentRole> { |
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.
Since these are both string types, it may be clearer to make this an object parameter to prevent parameter confusion. Not sure if you'd want to make changes to the other method signatures to align.
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.
Yeah this is a JS style question which I'm not sure about. For POST I figured since organizationId is related to the path and not the object being created it should be a separate argument. Similar to this one, I figured since slug is related to the path and not the object, having them separate here made sense.
Description
Documentation
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.