-
Notifications
You must be signed in to change notification settings - Fork 54
feat(oagen[1/2]): Add new endpoints to the SDK via autogeneration #1535
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
gjtorikian
wants to merge
17
commits into
main
Choose a base branch
from
oagen/1/new-apis
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
17 commits
Select commit
Hold shift + click to select a range
ef07008
Introduce AdminPortal
gjtorikian 44a8b01
Introduce Permissions
gjtorikian 13677c0
Introduce Radar
gjtorikian 9f071dc
Introduce Webhook events
gjtorikian 675fb15
Introduce WorkOS Connect
gjtorikian 60c3f6f
Update test-utils to include more helpers
gjtorikian 44e142e
feat(node): wire new services into WorkOS client
gjtorikian 2b5ca3c
feat(node): add generated model dependencies for new services
gjtorikian 2226944
handle discriminated enums better
gjtorikian e7fb5b2
correctly load non-paginated arrays
gjtorikian f38daaa
reshape Connect SDK under workos.connect namespace
gjtorikian a823cc3
adjust properties to the proper location
gjtorikian 76e03ad
preserve filter options across paginated pages
gjtorikian 00d3936
translate paginated list options to wire (snake_case) keys
gjtorikian e324772
expose deprecation + connect types, flag listPermissions return shape
gjtorikian 7ec1297
trashed unused permissions file
gjtorikian 2dacf34
fix prettier formatting on generated and hand-maintained files
gjtorikian 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // This file is auto-generated by oagen. Do not edit. | ||
|
|
||
| import fetch from 'jest-fetch-mock'; | ||
| import { | ||
| fetchOnce, | ||
| fetchURL, | ||
| fetchMethod, | ||
| fetchBody, | ||
| testUnauthorized, | ||
| } from '../common/utils/test-utils'; | ||
| import { WorkOS } from '../workos'; | ||
|
|
||
| import portalLinkResponseFixture from './fixtures/portal-link-response.fixture.json'; | ||
|
|
||
| const workos = new WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU'); | ||
|
|
||
| describe('AdminPortal', () => { | ||
| beforeEach(() => fetch.resetMocks()); | ||
|
|
||
| describe('generatePortalLink', () => { | ||
| it('sends the correct request and returns result', async () => { | ||
| fetchOnce(portalLinkResponseFixture); | ||
|
|
||
| const result = await workos.adminPortal.generatePortalLink({ | ||
| organization: 'test_organization', | ||
| }); | ||
|
|
||
| expect(fetchMethod()).toBe('POST'); | ||
| expect(new URL(String(fetchURL())).pathname).toBe( | ||
| '/portal/generate_link', | ||
| ); | ||
| expect(fetchBody()).toEqual( | ||
| expect.objectContaining({ organization: 'test_organization' }), | ||
| ); | ||
| expect(result.link).toBe( | ||
| 'https://setup.workos.com?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...', | ||
| ); | ||
| }); | ||
|
|
||
| testUnauthorized(() => | ||
| workos.adminPortal.generatePortalLink({ | ||
| organization: 'test_organization', | ||
| }), | ||
| ); | ||
| }); | ||
| }); |
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,32 @@ | ||
| // This file is auto-generated by oagen. Do not edit. | ||
|
|
||
| import type { WorkOS } from '../workos'; | ||
| import type { | ||
| PortalLinkResponse, | ||
| PortalLinkResponseWire, | ||
| } from './interfaces/portal-link-response.interface'; | ||
| import type { GenerateLink } from './interfaces/generate-link.interface'; | ||
| import { deserializePortalLinkResponse } from './serializers/portal-link-response.serializer'; | ||
| import { serializeGenerateLink } from './serializers/generate-link.serializer'; | ||
|
|
||
| export class AdminPortal { | ||
| constructor(private readonly workos: WorkOS) {} | ||
|
|
||
| /** | ||
| * Generate a Portal Link | ||
| * | ||
| * Generate a Portal Link scoped to an Organization. | ||
| * @param payload - Object containing organization. | ||
| * @returns {PortalLinkResponse} | ||
| * @throws {BadRequestException} 400 | ||
| * @throws {NotFoundException} 404 | ||
| * @throws {UnprocessableEntityException} 422 | ||
| */ | ||
| async generatePortalLink(payload: GenerateLink): Promise<PortalLinkResponse> { | ||
| const { data } = await this.workos.post<PortalLinkResponseWire>( | ||
| '/portal/generate_link', | ||
| serializeGenerateLink(payload), | ||
| ); | ||
| return deserializePortalLinkResponse(data); | ||
| } | ||
| } |
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 @@ | ||
| { | ||
| "return_url": "https://example.com/admin-portal/return", | ||
| "success_url": "https://example.com/admin-portal/success", | ||
| "organization": "org_01EHZNVPK3SFK441A1RGBFSHRT", | ||
| "intent": "sso", | ||
| "intent_options": { | ||
| "sso": { | ||
| "bookmark_slug": "chatgpt", | ||
| "provider_type": "GoogleSAML" | ||
| } | ||
| } | ||
| } |
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,6 @@ | ||
| { | ||
| "sso": { | ||
| "bookmark_slug": "chatgpt", | ||
| "provider_type": "GoogleSAML" | ||
| } | ||
| } |
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,3 @@ | ||
| { | ||
| "link": "https://setup.workos.com?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." | ||
| } |
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,4 @@ | ||
| { | ||
| "bookmark_slug": "chatgpt", | ||
| "provider_type": "GoogleSAML" | ||
| } |
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,38 @@ | ||
| // This file is auto-generated by oagen. Do not edit. | ||
|
|
||
| import type { | ||
| IntentOptions, | ||
| IntentOptionsResponse, | ||
| } from './intent-options.interface'; | ||
| import type { GenerateLinkIntent } from '../../common/interfaces/generate-link-intent.interface'; | ||
|
|
||
| export interface GenerateLink { | ||
| /** The URL to go to when an admin clicks on your logo in the Admin Portal. If not specified, the return URL configured on the [Redirects](https://dashboard.workos.com/redirects) page will be used. */ | ||
| returnUrl?: string; | ||
| /** The URL to redirect the admin to when they finish setup. If not specified, the success URL configured on the [Redirects](https://dashboard.workos.com/redirects) page will be used. */ | ||
| successUrl?: string; | ||
| /** An [Organization](https://workos.com/docs/reference/organization) identifier. */ | ||
| organization: string; | ||
| /** | ||
| * | ||
| * The intent of the Admin Portal. | ||
| * - `sso` - Launch Admin Portal for creating SSO connections | ||
| * - `dsync` - Launch Admin Portal for creating Directory Sync connections | ||
| * - `audit_logs` - Launch Admin Portal for viewing Audit Logs | ||
| * - `log_streams` - Launch Admin Portal for creating Log Streams | ||
| * - `domain_verification` - Launch Admin Portal for Domain Verification | ||
| * - `certificate_renewal` - Launch Admin Portal for renewing SAML Certificates | ||
| * - `bring_your_own_key` - Launch Admin Portal for configuring Bring Your Own Key | ||
| */ | ||
| intent?: GenerateLinkIntent; | ||
| /** Options to configure the Admin Portal based on the intent. */ | ||
| intentOptions?: IntentOptions; | ||
| } | ||
|
|
||
| export interface GenerateLinkResponse { | ||
| return_url?: string; | ||
| success_url?: string; | ||
| organization: string; | ||
| intent?: GenerateLinkIntent; | ||
| intent_options?: IntentOptionsResponse; | ||
| } |
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,6 @@ | ||
| // This file is auto-generated by oagen. Do not edit. | ||
|
|
||
| export * from './generate-link.interface'; | ||
| export * from './intent-options.interface'; | ||
| export * from './portal-link-response.interface'; | ||
| export * from './sso-intent-options.interface'; |
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,15 @@ | ||
| // This file is auto-generated by oagen. Do not edit. | ||
|
|
||
| import type { | ||
| SSOIntentOptions, | ||
| SSOIntentOptionsResponse, | ||
| } from './sso-intent-options.interface'; | ||
|
|
||
| export interface IntentOptions { | ||
| /** SSO-specific options for the Admin Portal. */ | ||
| sso: SSOIntentOptions; | ||
| } | ||
|
|
||
| export interface IntentOptionsResponse { | ||
| sso: SSOIntentOptionsResponse; | ||
| } |
10 changes: 10 additions & 0 deletions
10
src/admin-portal/interfaces/portal-link-response.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,10 @@ | ||
| // This file is auto-generated by oagen. Do not edit. | ||
|
|
||
| export interface PortalLinkResponse { | ||
| /** An ephemeral link to initiate the Admin Portal. */ | ||
| link: string; | ||
| } | ||
|
|
||
| export interface PortalLinkResponseWire { | ||
| link: string; | ||
| } |
13 changes: 13 additions & 0 deletions
13
src/admin-portal/interfaces/sso-intent-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,13 @@ | ||
| // This file is auto-generated by oagen. Do not edit. | ||
|
|
||
| export interface SSOIntentOptions { | ||
| /** The bookmark slug to use for SSO. */ | ||
| bookmarkSlug?: string; | ||
| /** The SSO provider type to configure. */ | ||
| providerType?: 'GoogleSAML'; | ||
| } | ||
|
|
||
| export interface SSOIntentOptionsResponse { | ||
| bookmark_slug?: string; | ||
| provider_type?: 'GoogleSAML'; | ||
| } |
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,36 @@ | ||
| // This file is auto-generated by oagen. Do not edit. | ||
|
|
||
| import type { | ||
| GenerateLink, | ||
| GenerateLinkResponse, | ||
| } from '../interfaces/generate-link.interface'; | ||
| import { | ||
| deserializeIntentOptions, | ||
| serializeIntentOptions, | ||
| } from './intent-options.serializer'; | ||
|
|
||
| export const deserializeGenerateLink = ( | ||
| response: GenerateLinkResponse, | ||
| ): GenerateLink => ({ | ||
| returnUrl: response.return_url, | ||
| successUrl: response.success_url, | ||
| organization: response.organization, | ||
| intent: response.intent, | ||
| intentOptions: | ||
| response.intent_options != null | ||
| ? deserializeIntentOptions(response.intent_options) | ||
| : undefined, | ||
| }); | ||
|
|
||
| export const serializeGenerateLink = ( | ||
| model: GenerateLink, | ||
| ): GenerateLinkResponse => ({ | ||
| return_url: model.returnUrl, | ||
| success_url: model.successUrl, | ||
| organization: model.organization, | ||
| intent: model.intent, | ||
| intent_options: | ||
| model.intentOptions != null | ||
| ? serializeIntentOptions(model.intentOptions) | ||
| : undefined, | ||
| }); |
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,22 @@ | ||
| // This file is auto-generated by oagen. Do not edit. | ||
|
|
||
| import type { | ||
| IntentOptions, | ||
| IntentOptionsResponse, | ||
| } from '../interfaces/intent-options.interface'; | ||
| import { | ||
| deserializeSSOIntentOptions, | ||
| serializeSSOIntentOptions, | ||
| } from './sso-intent-options.serializer'; | ||
|
|
||
| export const deserializeIntentOptions = ( | ||
| response: IntentOptionsResponse, | ||
| ): IntentOptions => ({ | ||
| sso: deserializeSSOIntentOptions(response.sso), | ||
| }); | ||
|
|
||
| export const serializeIntentOptions = ( | ||
| model: IntentOptions, | ||
| ): IntentOptionsResponse => ({ | ||
| sso: serializeSSOIntentOptions(model.sso), | ||
| }); |
18 changes: 18 additions & 0 deletions
18
src/admin-portal/serializers/portal-link-response.serializer.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,18 @@ | ||
| // This file is auto-generated by oagen. Do not edit. | ||
|
|
||
| import type { | ||
| PortalLinkResponse, | ||
| PortalLinkResponseWire, | ||
| } from '../interfaces/portal-link-response.interface'; | ||
|
|
||
| export const deserializePortalLinkResponse = ( | ||
| response: PortalLinkResponseWire, | ||
| ): PortalLinkResponse => ({ | ||
| link: response.link, | ||
| }); | ||
|
|
||
| export const serializePortalLinkResponse = ( | ||
| model: PortalLinkResponse, | ||
| ): PortalLinkResponseWire => ({ | ||
| link: model.link, | ||
| }); |
20 changes: 20 additions & 0 deletions
20
src/admin-portal/serializers/sso-intent-options.serializer.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,20 @@ | ||
| // This file is auto-generated by oagen. Do not edit. | ||
|
|
||
| import type { | ||
| SSOIntentOptions, | ||
| SSOIntentOptionsResponse, | ||
| } from '../interfaces/sso-intent-options.interface'; | ||
|
|
||
| export const deserializeSSOIntentOptions = ( | ||
| response: SSOIntentOptionsResponse, | ||
| ): SSOIntentOptions => ({ | ||
| bookmarkSlug: response.bookmark_slug, | ||
| providerType: response.provider_type, | ||
| }); | ||
|
|
||
| export const serializeSSOIntentOptions = ( | ||
| model: SSOIntentOptions, | ||
| ): SSOIntentOptionsResponse => ({ | ||
| bookmark_slug: model.bookmarkSlug, | ||
| provider_type: model.providerType, | ||
| }); |
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
13 changes: 13 additions & 0 deletions
13
src/authorization/interfaces/update-organization-role.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,13 @@ | ||
| // This file is auto-generated by oagen. Do not edit. | ||
|
|
||
| export interface UpdateOrganizationRole { | ||
| /** A descriptive name for the role. */ | ||
| name?: string; | ||
| /** An optional description of the role's purpose. */ | ||
| description?: string | null; | ||
| } | ||
|
|
||
| export interface UpdateOrganizationRoleResponse { | ||
| name?: string; | ||
| description?: string | null; | ||
| } |
20 changes: 20 additions & 0 deletions
20
src/authorization/serializers/update-organization-role.serializer.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,20 @@ | ||
| // This file is auto-generated by oagen. Do not edit. | ||
|
|
||
| import type { | ||
| UpdateOrganizationRole, | ||
| UpdateOrganizationRoleResponse, | ||
| } from '../interfaces/update-organization-role.interface'; | ||
|
|
||
| export const deserializeUpdateOrganizationRole = ( | ||
| response: UpdateOrganizationRoleResponse, | ||
| ): UpdateOrganizationRole => ({ | ||
| name: response.name, | ||
| description: response.description ?? null, | ||
| }); | ||
|
|
||
| export const serializeUpdateOrganizationRole = ( | ||
| model: UpdateOrganizationRole, | ||
| ): UpdateOrganizationRoleResponse => ({ | ||
| name: model.name, | ||
| description: model.description ?? null, | ||
| }); |
4 changes: 4 additions & 0 deletions
4
src/common/fixtures/authentication-factor-totp-2.fixture.json
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,4 @@ | ||
| { | ||
| "issuer": "WorkOS", | ||
| "user": "user@example.com" | ||
| } |
13 changes: 13 additions & 0 deletions
13
src/common/interfaces/authentication-factor-totp-2.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,13 @@ | ||
| // This file is auto-generated by oagen. Do not edit. | ||
|
|
||
| export interface AuthenticationFactorTotp2 { | ||
| /** Your application or company name displayed in the user's authenticator app. Defaults to your WorkOS team name. */ | ||
| issuer: string; | ||
| /** The user's account name displayed in their authenticator app. Defaults to the user's email. */ | ||
| user: string; | ||
| } | ||
|
|
||
| export interface AuthenticationFactorTotp2Response { | ||
| issuer: string; | ||
| user: 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.
issue: This returns
PermissionListwhich is different from whatworkos.permissions.listwill return (AutoPaginatable). This is technically a breaking change.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.
Couple of things:
workos.permissionsin feat(oagen[2/2]): Update existing SDK modules with generated types, docs, and serializers #1536 (comment), but didn't cherry-pick the change back into this branchAuthorization.listPermissionswas still exported with the same signature and return type, so I'm not sure how this is breaking. The newworkos.permissions.list(which, again, is no longer introduced) would have worked around this by providingAutoPaginatable<Permission>in an alternate method.