diff --git a/.oagen-manifest.json b/.oagen-manifest.json index 1d4b9e11c..092b7341d 100644 --- a/.oagen-manifest.json +++ b/.oagen-manifest.json @@ -2,6 +2,21 @@ "version": 2, "language": "node", "files": [ + "src/admin-portal/admin-portal.spec.ts", + "src/admin-portal/admin-portal.ts", + "src/admin-portal/fixtures/generate-link.json", + "src/admin-portal/fixtures/portal-link-response.json", + "src/admin-portal/fixtures/revoke-link.json", + "src/admin-portal/interfaces/generate-link.interface.ts", + "src/admin-portal/interfaces/index.ts", + "src/admin-portal/interfaces/portal-link-response.interface.ts", + "src/admin-portal/interfaces/revoke-link-options.interface.ts", + "src/admin-portal/interfaces/revoke-link.interface.ts", + "src/admin-portal/serializers.spec.ts", + "src/admin-portal/serializers/generate-link.serializer.ts", + "src/admin-portal/serializers/index.ts", + "src/admin-portal/serializers/portal-link-response.serializer.ts", + "src/admin-portal/serializers/revoke-link.serializer.ts", "src/api-keys/interfaces/create-validation-options.interface.ts", "src/api-keys/interfaces/delete-api-key-options.interface.ts", "src/connect/connect.spec.ts", diff --git a/src/admin-portal/admin-portal.spec.ts b/src/admin-portal/admin-portal.spec.ts index ece354dac..89262cc78 100644 --- a/src/admin-portal/admin-portal.spec.ts +++ b/src/admin-portal/admin-portal.spec.ts @@ -1,9 +1,15 @@ +// This file is auto-generated by oagen. Do not edit. + import fetch from 'jest-fetch-mock'; -import { fetchBody, fetchOnce } from '../common/utils/test-utils'; +import { + fetchOnce, + fetchURL, + fetchMethod, + fetchBody, +} from '../common/utils/test-utils'; import { WorkOS } from '../workos'; -import generateLinkInvalid from './fixtures/generate-link-invalid.json'; -import portalLinkResponse from './fixtures/portal-link-response.json'; -import { GenerateLinkIntent } from '../common/interfaces'; + +import portalLinkResponseFixture from './fixtures/portal-link-response.json'; const workos = new WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU'); @@ -11,234 +17,43 @@ describe('AdminPortal', () => { beforeEach(() => fetch.resetMocks()); describe('generateLink', () => { - describe('with a valid organization', () => { - describe('with the sso intent', () => { - it('returns an Admin Portal link', async () => { - fetchOnce(portalLinkResponse, { status: 201 }); - - const { link } = await workos.adminPortal.generateLink({ - intent: GenerateLinkIntent.SSO, - organization: 'org_01EHQMYV6MBK39QC5PZXHY59C3', - returnUrl: 'https://www.example.com', - }); - - expect(fetchBody()).toEqual({ - intent: GenerateLinkIntent.SSO, - organization: 'org_01EHQMYV6MBK39QC5PZXHY59C3', - return_url: 'https://www.example.com', - }); - expect(link).toEqual( - 'https://setup.workos.com?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...', - ); - }); - }); - - describe('with the domain_verification intent', () => { - it('returns an Admin Portal link', async () => { - fetchOnce(portalLinkResponse, { status: 201 }); - - const { link } = await workos.adminPortal.generateLink({ - intent: GenerateLinkIntent.DomainVerification, - organization: 'org_01EHQMYV6MBK39QC5PZXHY59C3', - returnUrl: 'https://www.example.com', - }); - - expect(fetchBody()).toEqual({ - intent: GenerateLinkIntent.DomainVerification, - organization: 'org_01EHQMYV6MBK39QC5PZXHY59C3', - return_url: 'https://www.example.com', - }); - expect(link).toEqual( - 'https://setup.workos.com?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...', - ); - }); - }); - - describe('with the dsync intent', () => { - it('returns an Admin Portal link', async () => { - fetchOnce(portalLinkResponse, { status: 201 }); - - const { link } = await workos.adminPortal.generateLink({ - intent: GenerateLinkIntent.DSync, - organization: 'org_01EHQMYV6MBK39QC5PZXHY59C3', - returnUrl: 'https://www.example.com', - }); - - expect(fetchBody()).toEqual({ - intent: GenerateLinkIntent.DSync, - organization: 'org_01EHQMYV6MBK39QC5PZXHY59C3', - return_url: 'https://www.example.com', - }); - expect(link).toEqual( - 'https://setup.workos.com?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...', - ); - }); - }); - - describe('with the `audit_logs` intent', () => { - it('returns an Admin Portal link', async () => { - fetchOnce(portalLinkResponse, { status: 201 }); - - const { link } = await workos.adminPortal.generateLink({ - intent: GenerateLinkIntent.AuditLogs, - organization: 'org_01EHQMYV6MBK39QC5PZXHY59C3', - returnUrl: 'https://www.example.com', - }); - - expect(fetchBody()).toEqual({ - intent: GenerateLinkIntent.AuditLogs, - organization: 'org_01EHQMYV6MBK39QC5PZXHY59C3', - return_url: 'https://www.example.com', - }); - expect(link).toEqual( - 'https://setup.workos.com?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...', - ); - }); - }); - - describe('with the `log_streams` intent', () => { - it('returns an Admin Portal link', async () => { - fetchOnce(portalLinkResponse, { status: 201 }); - - const { link } = await workos.adminPortal.generateLink({ - intent: GenerateLinkIntent.LogStreams, - organization: 'org_01EHQMYV6MBK39QC5PZXHY59C3', - returnUrl: 'https://www.example.com', - }); - - expect(fetchBody()).toEqual({ - intent: GenerateLinkIntent.LogStreams, - organization: 'org_01EHQMYV6MBK39QC5PZXHY59C3', - return_url: 'https://www.example.com', - }); - expect(link).toEqual( - 'https://setup.workos.com?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...', - ); - }); - }); - describe('with the `certificate_renewal` intent', () => { - it('returns an Admin Portal link', async () => { - fetchOnce(portalLinkResponse, { status: 201 }); - - const { link } = await workos.adminPortal.generateLink({ - intent: GenerateLinkIntent.CertificateRenewal, - organization: 'org_01EHQMYV6MBK39QC5PZXHY59C3', - returnUrl: 'https://www.example.com', - }); - - expect(fetchBody()).toEqual({ - intent: GenerateLinkIntent.CertificateRenewal, - organization: 'org_01EHQMYV6MBK39QC5PZXHY59C3', - return_url: 'https://www.example.com', - }); - expect(link).toEqual( - 'https://setup.workos.com?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...', - ); - }); - }); - describe('with the `bring_your_own_key` intent', () => { - it('returns an Admin Portal link', async () => { - fetchOnce(portalLinkResponse, { status: 201 }); - - const { link } = await workos.adminPortal.generateLink({ - intent: GenerateLinkIntent.BringYourOwnKey, - organization: 'org_01EHQMYV6MBK39QC5PZXHY59C3', - returnUrl: 'https://www.example.com', - }); - - expect(fetchBody()).toEqual({ - intent: GenerateLinkIntent.BringYourOwnKey, - organization: 'org_01EHQMYV6MBK39QC5PZXHY59C3', - return_url: 'https://www.example.com', - }); - expect(link).toEqual( - 'https://setup.workos.com?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...', - ); - }); - }); - - describe('with intentOptions and adminEmails', () => { - it('serializes the new parameters correctly', async () => { - fetchOnce(portalLinkResponse, { status: 201 }); - - const { link } = await workos.adminPortal.generateLink({ - intent: GenerateLinkIntent.SSO, - organization: 'org_01EHQMYV6MBK39QC5PZXHY59C3', - returnUrl: 'https://www.example.com', - intentOptions: { - sso: { - bookmarkSlug: 'chatgpt', - providerType: 'GoogleSAML', - }, - }, - adminEmails: ['admin@example.com'], - }); - - expect(fetchBody()).toEqual({ - intent: 'sso', - organization: 'org_01EHQMYV6MBK39QC5PZXHY59C3', - return_url: 'https://www.example.com', - intent_options: { - sso: { - bookmark_slug: 'chatgpt', - provider_type: 'GoogleSAML', - }, - }, - admin_emails: ['admin@example.com'], - }); - expect(link).toEqual( - 'https://setup.workos.com?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...', - ); - }); - }); + it('sends the correct request and returns result', async () => { + fetchOnce(portalLinkResponseFixture); + + const result = await workos.adminPortal.generateLink({ + 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/init?apiToken=01EHZNVPK3SFK441A1RGBFSHRT', + ); }); + }); - describe('with an invalid organization', () => { - it('throws an error', async () => { - fetchOnce(generateLinkInvalid, { - status: 400, - headers: { 'X-Request-ID': 'a-request-id' }, - }); + describe('revokeLink', () => { + it('sends the request', async () => { + fetchOnce({}); - await expect( - workos.adminPortal.generateLink({ - intent: GenerateLinkIntent.SSO, - organization: 'bogus-id', - returnUrl: 'https://www.example.com', - }), - ).rejects.toThrow( - 'Could not find an organization with the id, bogus-id.', - ); - expect(fetchBody()).toEqual({ - intent: GenerateLinkIntent.SSO, - organization: 'bogus-id', - return_url: 'https://www.example.com', - }); + await workos.adminPortal.revokeLink({ + organization: 'test_organization', + externalUserId: 'external_user_id_01234', }); - }); - describe('with an invalid organization', () => { - it('throws an error', async () => { - fetchOnce(generateLinkInvalid, { - status: 400, - headers: { 'X-Request-ID': 'a-request-id' }, - }); - - await expect( - workos.adminPortal.generateLink({ - intent: GenerateLinkIntent.SSO, - organization: 'bogus-id', - returnUrl: 'https://www.example.com', - }), - ).rejects.toThrow( - 'Could not find an organization with the id, bogus-id.', - ); - expect(fetchBody()).toEqual({ - intent: GenerateLinkIntent.SSO, - organization: 'bogus-id', - return_url: 'https://www.example.com', - }); - }); + expect(fetchMethod()).toBe('POST'); + expect(new URL(String(fetchURL())).pathname).toBe('/portal/revoke_link'); + expect(fetchBody()).toEqual( + expect.objectContaining({ + organization: 'test_organization', + external_user_id: 'external_user_id_01234', + }), + ); }); }); }); diff --git a/src/admin-portal/admin-portal.ts b/src/admin-portal/admin-portal.ts index 3623ba317..ab06092b1 100644 --- a/src/admin-portal/admin-portal.ts +++ b/src/admin-portal/admin-portal.ts @@ -1,7 +1,17 @@ // This file is auto-generated by oagen. Do not edit. -import { WorkOS } from '../workos'; -import { GenerateLinkIntent } from '../common/interfaces'; +import type { WorkOS } from '../workos'; +import type { GenerateLink } from './interfaces/generate-link.interface'; +import type { RevokeLinkOptions } from './interfaces/revoke-link-options.interface'; +import type { + PortalLinkResponse, + PortalLinkResponseWire, +} from './interfaces/portal-link-response.interface'; +import type { GenerateLinkResponse } from './interfaces/generate-link.interface'; +import type { RevokeLinkResponse } from './interfaces/revoke-link.interface'; +import { deserializePortalLinkResponse } from './serializers/portal-link-response.serializer'; +import { serializeGenerateLink } from './serializers/generate-link.serializer'; +import { serializeRevokeLink } from './serializers/revoke-link.serializer'; export class AdminPortal { constructor(private readonly workos: WorkOS) {} @@ -10,49 +20,55 @@ export class AdminPortal { * Generate a Portal Link * * Generate a Portal Link scoped to an Organization. - * @param payload - Object containing organization. - * @returns {Promise<{ link: string; }>} + * @param options - Object containing organization. + * @param options.returnUrl - 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 [Admin Portal](https://dashboard.workos.com/admin-portal) page will be used. + * @example "https://example.com/admin-portal/return" + * @param options.successUrl - The URL to redirect the admin to when they finish setup. If not specified, the success URL configured on the [Admin Portal](https://dashboard.workos.com/admin-portal) page will be used. + * @example "https://example.com/admin-portal/success" + * @param options.organization - An [Organization](https://workos.com/docs/reference/organization) identifier. + * @example "org_01EHZNVPK3SFK441A1RGBFSHRT" + * @param options.externalUserId - The ID of the user in your application the link is generated for. The link and any Admin Portal sessions started from it can later be revoked by this ID, for example when that user is deprovisioned from your application. + * @example "user_12345" + * @param options.intent - + * 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 + * @example "sso" + * @param options.itContactEmails - The email addresses of the IT contacts to grant access to the Admin Portal for the given organization. Accepts up to 20 emails. + * @example ["it-contact@example.com"] + * @returns {Promise} * @throws {BadRequestException} 400 - * @throws 403 response from the API. + * @throws {AuthorizationException} 403 * @throws {NotFoundException} 404 * @throws {UnprocessableEntityException} 422 */ - async generateLink({ - intent, - organization, - returnUrl, - successUrl, - intentOptions, - adminEmails, - }: { - intent?: GenerateLinkIntent; - organization: string; - returnUrl?: string; - successUrl?: string; - intentOptions?: { - sso: { - bookmarkSlug?: string; - providerType?: string; - }; - }; - adminEmails?: string[]; - }): Promise<{ link: string }> { - const { data } = await this.workos.post('/portal/generate_link', { - intent, - organization, - return_url: returnUrl, - success_url: successUrl, - intent_options: intentOptions - ? { - sso: { - bookmark_slug: intentOptions.sso.bookmarkSlug, - provider_type: intentOptions.sso.providerType, - }, - } - : undefined, - admin_emails: adminEmails, - }); + async generateLink(options: GenerateLink): Promise { + const payload = options; + const { data } = await this.workos.post< + PortalLinkResponseWire, + GenerateLinkResponse + >('/portal/generate_link', serializeGenerateLink(payload)); + return deserializePortalLinkResponse(data); + } - return data; + /** + * Revoke Portal Links + * + * Revokes every Portal Link generated for the given organization with the given `external_user_id`, and immediately ends any Admin Portal sessions that were started from those links. Use this when an admin is deprovisioned from your application: unopened links stop working, and their already-open portal sessions are ended. Only links that were generated with an `external_user_id` can be revoked, so pass one to `generate_link` for every admin you may later need to deprovision. + * @returns {Promise} + * @throws {NotFoundException} 404 + * @throws {UnprocessableEntityException} 422 + */ + async revokeLink(options: RevokeLinkOptions): Promise { + const payload = options; + await this.workos.post( + '/portal/revoke_link', + serializeRevokeLink(payload), + ); } } diff --git a/src/admin-portal/fixtures/generate-link-invalid.json b/src/admin-portal/fixtures/generate-link-invalid.json deleted file mode 100644 index fc3a2f1cd..000000000 --- a/src/admin-portal/fixtures/generate-link-invalid.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "message": "Could not find an organization with the id, bogus-id." -} diff --git a/src/admin-portal/fixtures/generate-link.json b/src/admin-portal/fixtures/generate-link.json index 63bd14d7c..ac3f89e2b 100644 --- a/src/admin-portal/fixtures/generate-link.json +++ b/src/admin-portal/fixtures/generate-link.json @@ -2,12 +2,7 @@ "return_url": "https://example.com/admin-portal/return", "success_url": "https://example.com/admin-portal/success", "organization": "org_01EHZNVPK3SFK441A1RGBFSHRT", + "external_user_id": "user_12345", "intent": "sso", - "intent_options": { - "sso": { - "bookmark_slug": "chatgpt", - "provider_type": "GoogleSAML" - } - }, - "admin_emails": ["admin@example.com"] + "it_contact_emails": ["it-contact@example.com"] } diff --git a/src/admin-portal/fixtures/intent-options.json b/src/admin-portal/fixtures/intent-options.json deleted file mode 100644 index 31bad9130..000000000 --- a/src/admin-portal/fixtures/intent-options.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "sso": { - "bookmark_slug": "chatgpt", - "provider_type": "GoogleSAML" - } -} diff --git a/src/admin-portal/fixtures/portal-link-response.json b/src/admin-portal/fixtures/portal-link-response.json index 811f32a96..491b08f6b 100644 --- a/src/admin-portal/fixtures/portal-link-response.json +++ b/src/admin-portal/fixtures/portal-link-response.json @@ -1,3 +1,3 @@ { - "link": "https://setup.workos.com?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." + "link": "https://setup.workos.com/init?apiToken=01EHZNVPK3SFK441A1RGBFSHRT" } diff --git a/src/admin-portal/fixtures/revoke-link.json b/src/admin-portal/fixtures/revoke-link.json new file mode 100644 index 000000000..2e35fb487 --- /dev/null +++ b/src/admin-portal/fixtures/revoke-link.json @@ -0,0 +1,4 @@ +{ + "organization": "org_01EHZNVPK3SFK441A1RGBFSHRT", + "external_user_id": "user_12345" +} diff --git a/src/admin-portal/fixtures/sso-intent-options.json b/src/admin-portal/fixtures/sso-intent-options.json deleted file mode 100644 index 79ab315ed..000000000 --- a/src/admin-portal/fixtures/sso-intent-options.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "bookmark_slug": "chatgpt", - "provider_type": "GoogleSAML" -} diff --git a/src/admin-portal/interfaces/generate-link.interface.ts b/src/admin-portal/interfaces/generate-link.interface.ts index b76720bf4..8a5f7e9ee 100644 --- a/src/admin-portal/interfaces/generate-link.interface.ts +++ b/src/admin-portal/interfaces/generate-link.interface.ts @@ -1,18 +1,16 @@ // 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. */ + /** 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 [Admin Portal](https://dashboard.workos.com/admin-portal) 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. */ + /** The URL to redirect the admin to when they finish setup. If not specified, the success URL configured on the [Admin Portal](https://dashboard.workos.com/admin-portal) page will be used. */ successUrl?: string; /** An [Organization](https://workos.com/docs/reference/organization) identifier. */ organization: string; + /** The ID of the user in your application the link is generated for. The link and any Admin Portal sessions started from it can later be revoked by this ID, for example when that user is deprovisioned from your application. */ + externalUserId?: string; /** * * The intent of the Admin Portal. @@ -25,17 +23,15 @@ export interface GenerateLink { * - `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; - /** The email addresses of the IT admins to grant access to the Admin Portal for the given organization. Accepts up to 20 emails. */ - adminEmails?: string[]; + /** The email addresses of the IT contacts to grant access to the Admin Portal for the given organization. Accepts up to 20 emails. */ + itContactEmails?: string[]; } export interface GenerateLinkResponse { return_url?: string; success_url?: string; organization: string; + external_user_id?: string; intent?: GenerateLinkIntent; - intent_options?: IntentOptionsResponse; - admin_emails?: string[]; + it_contact_emails?: string[]; } diff --git a/src/admin-portal/interfaces/index.ts b/src/admin-portal/interfaces/index.ts index 790076022..93c4b931e 100644 --- a/src/admin-portal/interfaces/index.ts +++ b/src/admin-portal/interfaces/index.ts @@ -1,4 +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'; +export * from './revoke-link-options.interface'; +export * from './revoke-link.interface'; diff --git a/src/admin-portal/interfaces/intent-options.interface.ts b/src/admin-portal/interfaces/intent-options.interface.ts deleted file mode 100644 index 229e9e1af..000000000 --- a/src/admin-portal/interfaces/intent-options.interface.ts +++ /dev/null @@ -1,15 +0,0 @@ -// 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; -} diff --git a/src/admin-portal/interfaces/revoke-link-options.interface.ts b/src/admin-portal/interfaces/revoke-link-options.interface.ts new file mode 100644 index 000000000..69ecef3bf --- /dev/null +++ b/src/admin-portal/interfaces/revoke-link-options.interface.ts @@ -0,0 +1,8 @@ +// This file is auto-generated by oagen. Do not edit. + +export interface RevokeLinkOptions { + /** An [Organization](https://workos.com/docs/reference/organization) identifier. */ + organization: string; + /** The `external_user_id` the Portal Links were generated with for this organization. Every matching link is revoked, along with any Admin Portal sessions started from those links. */ + externalUserId: string; +} diff --git a/src/admin-portal/interfaces/revoke-link.interface.ts b/src/admin-portal/interfaces/revoke-link.interface.ts new file mode 100644 index 000000000..ae75e4a6f --- /dev/null +++ b/src/admin-portal/interfaces/revoke-link.interface.ts @@ -0,0 +1,13 @@ +// This file is auto-generated by oagen. Do not edit. + +export interface RevokeLink { + /** An [Organization](https://workos.com/docs/reference/organization) identifier. */ + organization: string; + /** The `external_user_id` the Portal Links were generated with for this organization. Every matching link is revoked, along with any Admin Portal sessions started from those links. */ + externalUserId: string; +} + +export interface RevokeLinkResponse { + organization: string; + external_user_id: string; +} diff --git a/src/admin-portal/interfaces/sso-intent-options.interface.ts b/src/admin-portal/interfaces/sso-intent-options.interface.ts deleted file mode 100644 index 6450eabb9..000000000 --- a/src/admin-portal/interfaces/sso-intent-options.interface.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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'; -} diff --git a/src/admin-portal/serializers.spec.ts b/src/admin-portal/serializers.spec.ts index c884dbebe..3bc033e7a 100644 --- a/src/admin-portal/serializers.spec.ts +++ b/src/admin-portal/serializers.spec.ts @@ -1,62 +1,24 @@ // This file is auto-generated by oagen. Do not edit. -import { - deserializeSSOIntentOptions, - serializeSSOIntentOptions, -} from './serializers/sso-intent-options.serializer'; -import { - deserializeIntentOptions, - serializeIntentOptions, -} from './serializers/intent-options.serializer'; -import { - deserializeGenerateLink, - serializeGenerateLink, -} from './serializers/generate-link.serializer'; -import { - deserializePortalLinkResponse, - serializePortalLinkResponse, -} from './serializers/portal-link-response.serializer'; -import type { SSOIntentOptionsResponse } from './interfaces/sso-intent-options.interface'; -import type { IntentOptionsResponse } from './interfaces/intent-options.interface'; +import { serializeGenerateLink } from './serializers/generate-link.serializer'; +import { deserializePortalLinkResponse } from './serializers/portal-link-response.serializer'; import type { GenerateLinkResponse } from './interfaces/generate-link.interface'; import type { PortalLinkResponseWire } from './interfaces/portal-link-response.interface'; -import ssoIntentOptionsFixture from './fixtures/sso-intent-options.json'; -import intentOptionsFixture from './fixtures/intent-options.json'; import generateLinkFixture from './fixtures/generate-link.json'; import portalLinkResponseFixture from './fixtures/portal-link-response.json'; -describe('SSOIntentOptionsSerializer', () => { - it('round-trips through serialize/deserialize', () => { - const fixture = ssoIntentOptionsFixture as SSOIntentOptionsResponse; - const deserialized = deserializeSSOIntentOptions(fixture); - const reserialized = serializeSSOIntentOptions(deserialized); - expect(reserialized).toEqual(expect.objectContaining(fixture)); - }); -}); - -describe('IntentOptionsSerializer', () => { - it('round-trips through serialize/deserialize', () => { - const fixture = intentOptionsFixture as IntentOptionsResponse; - const deserialized = deserializeIntentOptions(fixture); - const reserialized = serializeIntentOptions(deserialized); - expect(reserialized).toEqual(expect.objectContaining(fixture)); - }); -}); - describe('GenerateLinkSerializer', () => { - it('round-trips through serialize/deserialize', () => { + it('serializes correctly', () => { const fixture = generateLinkFixture as GenerateLinkResponse; - const deserialized = deserializeGenerateLink(fixture); - const reserialized = serializeGenerateLink(deserialized); - expect(reserialized).toEqual(expect.objectContaining(fixture)); + const serialized = serializeGenerateLink(fixture as any); + expect(serialized).toBeDefined(); }); }); describe('PortalLinkResponseSerializer', () => { - it('round-trips through serialize/deserialize', () => { + it('deserializes correctly', () => { const fixture = portalLinkResponseFixture as PortalLinkResponseWire; const deserialized = deserializePortalLinkResponse(fixture); - const reserialized = serializePortalLinkResponse(deserialized); - expect(reserialized).toEqual(expect.objectContaining(fixture)); + expect(deserialized).toBeDefined(); }); }); diff --git a/src/admin-portal/serializers/generate-link.serializer.ts b/src/admin-portal/serializers/generate-link.serializer.ts index c76688537..9c1cb29de 100644 --- a/src/admin-portal/serializers/generate-link.serializer.ts +++ b/src/admin-portal/serializers/generate-link.serializer.ts @@ -4,24 +4,6 @@ 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, - adminEmails: response.admin_emails, -}); export const serializeGenerateLink = ( model: GenerateLink, @@ -29,10 +11,7 @@ export const serializeGenerateLink = ( return_url: model.returnUrl, success_url: model.successUrl, organization: model.organization, + external_user_id: model.externalUserId, intent: model.intent, - intent_options: - model.intentOptions != null - ? serializeIntentOptions(model.intentOptions) - : undefined, - admin_emails: model.adminEmails, + it_contact_emails: model.itContactEmails, }); diff --git a/src/admin-portal/serializers/index.ts b/src/admin-portal/serializers/index.ts new file mode 100644 index 000000000..088da09e0 --- /dev/null +++ b/src/admin-portal/serializers/index.ts @@ -0,0 +1,5 @@ +// This file is auto-generated by oagen. Do not edit. + +export * from './generate-link.serializer'; +export * from './portal-link-response.serializer'; +export * from './revoke-link.serializer'; diff --git a/src/admin-portal/serializers/intent-options.serializer.ts b/src/admin-portal/serializers/intent-options.serializer.ts deleted file mode 100644 index a7d16e1df..000000000 --- a/src/admin-portal/serializers/intent-options.serializer.ts +++ /dev/null @@ -1,22 +0,0 @@ -// 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), -}); diff --git a/src/admin-portal/serializers/portal-link-response.serializer.ts b/src/admin-portal/serializers/portal-link-response.serializer.ts index 75a96c945..112b3e818 100644 --- a/src/admin-portal/serializers/portal-link-response.serializer.ts +++ b/src/admin-portal/serializers/portal-link-response.serializer.ts @@ -10,9 +10,3 @@ export const deserializePortalLinkResponse = ( ): PortalLinkResponse => ({ link: response.link, }); - -export const serializePortalLinkResponse = ( - model: PortalLinkResponse, -): PortalLinkResponseWire => ({ - link: model.link, -}); diff --git a/src/admin-portal/serializers/revoke-link.serializer.ts b/src/admin-portal/serializers/revoke-link.serializer.ts new file mode 100644 index 000000000..7fb9fa857 --- /dev/null +++ b/src/admin-portal/serializers/revoke-link.serializer.ts @@ -0,0 +1,11 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { + RevokeLink, + RevokeLinkResponse, +} from '../interfaces/revoke-link.interface'; + +export const serializeRevokeLink = (model: RevokeLink): RevokeLinkResponse => ({ + organization: model.organization, + external_user_id: model.externalUserId, +}); diff --git a/src/admin-portal/serializers/sso-intent-options.serializer.ts b/src/admin-portal/serializers/sso-intent-options.serializer.ts deleted file mode 100644 index 5c36252fa..000000000 --- a/src/admin-portal/serializers/sso-intent-options.serializer.ts +++ /dev/null @@ -1,20 +0,0 @@ -// 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, -});