diff --git a/.oagen-manifest.json b/.oagen-manifest.json index ba29803e3..00a1b36f2 100644 --- a/.oagen-manifest.json +++ b/.oagen-manifest.json @@ -1,7 +1,7 @@ { "version": 2, "language": "node", - "generatedAt": "2026-06-01T17:59:24.986Z", + "generatedAt": "2026-06-16T16:51:34.175Z", "files": [ "src/api-keys/interfaces/create-validation-options.interface.ts", "src/api-keys/interfaces/delete-api-key-options.interface.ts", @@ -82,6 +82,22 @@ "src/groups/serializers/index.ts", "src/groups/serializers/update-group.serializer.ts", "src/groups/serializers/user-organization-membership-base-list-data.serializer.ts", + "src/organization-domains/fixtures/create-organization-domain.json", + "src/organization-domains/fixtures/organization-domain.json", + "src/organization-domains/interfaces/create-organization-domain.interface.ts", + "src/organization-domains/interfaces/delete-organization-domain-options.interface.ts", + "src/organization-domains/interfaces/get-organization-domain-options.interface.ts", + "src/organization-domains/interfaces/index.ts", + "src/organization-domains/interfaces/organization-domain-state.interface.ts", + "src/organization-domains/interfaces/organization-domain-verification-strategy.interface.ts", + "src/organization-domains/interfaces/organization-domain.interface.ts", + "src/organization-domains/interfaces/verify-organization-domain-options.interface.ts", + "src/organization-domains/organization-domains.spec.ts", + "src/organization-domains/organization-domains.ts", + "src/organization-domains/serializers.spec.ts", + "src/organization-domains/serializers/create-organization-domain.serializer.ts", + "src/organization-domains/serializers/index.ts", + "src/organization-domains/serializers/organization-domain.serializer.ts", "src/radar/fixtures/radar-list-entry-already-present-response.json", "src/radar/fixtures/radar-standalone-assess-request.json", "src/radar/fixtures/radar-standalone-delete-radar-list-entry-request.json", diff --git a/src/events/events.spec.ts b/src/events/events.spec.ts index 2c9a16685..0b1ec28be 100644 --- a/src/events/events.spec.ts +++ b/src/events/events.spec.ts @@ -911,8 +911,8 @@ describe('Event', () => { state: OrganizationDomainState.Pending, domain: 'example.com', object: 'organization_domain', - createdAt: '2026-04-06T06:24:06.749Z', - updatedAt: '2026-04-06T06:24:06.749Z', + createdAt: new Date('2026-04-06T06:24:06.749Z'), + updatedAt: new Date('2026-04-06T06:24:06.749Z'), organizationId: 'org_01TESTORGANIZATION', verificationStrategy: OrganizationDomainVerificationStrategy.Manual, }, @@ -969,8 +969,8 @@ describe('Event', () => { state: OrganizationDomainState.Failed, domain: 'example.com', object: 'organization_domain', - createdAt: '2026-03-07T02:24:56.621Z', - updatedAt: '2026-04-06T02:25:00.494Z', + createdAt: new Date('2026-03-07T02:24:56.621Z'), + updatedAt: new Date('2026-04-06T02:25:00.494Z'), organizationId: 'org_01TESTORGANIZATION', verificationToken: 'FAKETOKEN', verificationStrategy: OrganizationDomainVerificationStrategy.Dns, diff --git a/src/organization-domains/fixtures/create-organization-domain.json b/src/organization-domains/fixtures/create-organization-domain.json new file mode 100644 index 000000000..ce43a5f2f --- /dev/null +++ b/src/organization-domains/fixtures/create-organization-domain.json @@ -0,0 +1,4 @@ +{ + "domain": "foo-corp.com", + "organization_id": "org_01EHQMYV6MBK39QC5PZXHY59C3" +} diff --git a/src/organization-domains/fixtures/get-organization-domain-pending.json b/src/organization-domains/fixtures/get-organization-domain-pending.json deleted file mode 100644 index 3b27c577c..000000000 --- a/src/organization-domains/fixtures/get-organization-domain-pending.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "object": "organization_domain", - "id": "org_domain_01HD50K7EPWCMNPGMKXKKE14XT", - "organization_id": "org_01JR8C1EHCRPV4B4XP4W2B9X1M", - "domain": "workos.com", - "state": "pending", - "verification_token": "F06PGMsZIO0shrveGWuGxgCj7", - "verification_strategy": "dns" -} diff --git a/src/organization-domains/fixtures/get-organization-domain-verified.json b/src/organization-domains/fixtures/get-organization-domain-verified.json deleted file mode 100644 index fd9cde4b2..000000000 --- a/src/organization-domains/fixtures/get-organization-domain-verified.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "object": "organization_domain", - "id": "org_domain_01HCZRAP3TPQ0X0DKJHR32TATG", - "organization_id": "org_01JR8C1EHCRPV4B4XP4W2B9X1M", - "domain": "workos.com", - "state": "verified", - "verification_token": null, - "verification_strategy": "manual" -} diff --git a/src/organization-domains/fixtures/organization-domain.json b/src/organization-domains/fixtures/organization-domain.json new file mode 100644 index 000000000..9bc0c0a13 --- /dev/null +++ b/src/organization-domains/fixtures/organization-domain.json @@ -0,0 +1,12 @@ +{ + "object": "organization_domain", + "id": "org_domain_01EHZNVPK2QXHMVWCEDQEKY69A", + "organization_id": "org_01HE8GSH8FQPASKSY27THRKRBP", + "domain": "foo-corp.com", + "state": "pending", + "verification_prefix": "superapp-domain-verification-z3kjny", + "verification_token": "m5Oztg3jdK4NJLgs8uIlIprMw", + "verification_strategy": "dns", + "created_at": "2026-01-15T12:00:00.000Z", + "updated_at": "2026-01-15T12:00:00.000Z" +} diff --git a/src/organization-domains/interfaces/create-organization-domain-options.interface.ts b/src/organization-domains/interfaces/create-organization-domain-options.interface.ts index 70b1fe643..1bd272273 100644 --- a/src/organization-domains/interfaces/create-organization-domain-options.interface.ts +++ b/src/organization-domains/interfaces/create-organization-domain-options.interface.ts @@ -2,8 +2,3 @@ export interface CreateOrganizationDomainOptions { domain: string; organizationId: string; } - -export interface SerializedCreateOrganizationDomainOptions { - domain: string; - organization_id: string; -} diff --git a/src/organization-domains/interfaces/create-organization-domain.interface.ts b/src/organization-domains/interfaces/create-organization-domain.interface.ts new file mode 100644 index 000000000..4a32ea2c1 --- /dev/null +++ b/src/organization-domains/interfaces/create-organization-domain.interface.ts @@ -0,0 +1,13 @@ +// This file is auto-generated by oagen. Do not edit. + +export interface CreateOrganizationDomain { + /** The domain to add to the organization. */ + domain: string; + /** The ID of the organization to add the domain to. */ + organizationId: string; +} + +export interface CreateOrganizationDomainResponse { + domain: string; + organization_id: string; +} diff --git a/src/organization-domains/interfaces/delete-organization-domain-options.interface.ts b/src/organization-domains/interfaces/delete-organization-domain-options.interface.ts new file mode 100644 index 000000000..6f494220f --- /dev/null +++ b/src/organization-domains/interfaces/delete-organization-domain-options.interface.ts @@ -0,0 +1,6 @@ +// This file is auto-generated by oagen. Do not edit. + +export interface DeleteOrganizationDomainOptions { + /** Unique identifier of the organization domain. */ + id: string; +} diff --git a/src/organization-domains/interfaces/get-organization-domain-options.interface.ts b/src/organization-domains/interfaces/get-organization-domain-options.interface.ts new file mode 100644 index 000000000..a3083a3eb --- /dev/null +++ b/src/organization-domains/interfaces/get-organization-domain-options.interface.ts @@ -0,0 +1,6 @@ +// This file is auto-generated by oagen. Do not edit. + +export interface GetOrganizationDomainOptions { + /** Unique identifier of the organization domain. */ + id: string; +} diff --git a/src/organization-domains/interfaces/index.ts b/src/organization-domains/interfaces/index.ts index ad473a3e3..121be8e22 100644 --- a/src/organization-domains/interfaces/index.ts +++ b/src/organization-domains/interfaces/index.ts @@ -1,3 +1,11 @@ +// This file is auto-generated by oagen. Do not edit. + export * from './create-organization-domain-options.interface'; -export * from './organization-domain.interface'; +export * from './create-organization-domain.interface'; +export * from './delete-organization-domain-options.interface'; +export * from './get-organization-domain-options.interface'; +export * from './organization-domain-state.interface'; export * from './organization-domain-verification-failed.interface'; +export * from './organization-domain-verification-strategy.interface'; +export * from './organization-domain.interface'; +export * from './verify-organization-domain-options.interface'; diff --git a/src/organization-domains/interfaces/organization-domain-state.interface.ts b/src/organization-domains/interfaces/organization-domain-state.interface.ts new file mode 100644 index 000000000..5fab2d658 --- /dev/null +++ b/src/organization-domains/interfaces/organization-domain-state.interface.ts @@ -0,0 +1,9 @@ +// This file is auto-generated by oagen. Do not edit. + +export enum OrganizationDomainState { + Failed = 'failed', + LegacyVerified = 'legacy_verified', + Pending = 'pending', + Unverified = 'unverified', + Verified = 'verified', +} diff --git a/src/organization-domains/interfaces/organization-domain-verification-strategy.interface.ts b/src/organization-domains/interfaces/organization-domain-verification-strategy.interface.ts new file mode 100644 index 000000000..9a8591f28 --- /dev/null +++ b/src/organization-domains/interfaces/organization-domain-verification-strategy.interface.ts @@ -0,0 +1,6 @@ +// This file is auto-generated by oagen. Do not edit. + +export enum OrganizationDomainVerificationStrategy { + Dns = 'dns', + Manual = 'manual', +} diff --git a/src/organization-domains/interfaces/organization-domain.interface.ts b/src/organization-domains/interfaces/organization-domain.interface.ts index 1ac7d1d46..a58f889e0 100644 --- a/src/organization-domains/interfaces/organization-domain.interface.ts +++ b/src/organization-domains/interfaces/organization-domain.interface.ts @@ -1,46 +1,40 @@ -export enum OrganizationDomainState { - Verified = 'verified', - Pending = 'pending', - Failed = 'failed', -} +// This file is auto-generated by oagen. Do not edit. -export enum OrganizationDomainVerificationStrategy { - Dns = 'dns', - Manual = 'manual', -} +import type { OrganizationDomainState } from './organization-domain-state.interface'; +import type { OrganizationDomainVerificationStrategy } from './organization-domain-verification-strategy.interface'; export interface OrganizationDomain { /** Distinguishes the organization domain object. */ object: 'organization_domain'; /** Unique identifier of the organization domain. */ id: string; - /** Domain for the organization domain. */ - domain: string; /** ID of the parent Organization. */ organizationId: string; + /** Domain for the organization domain. */ + domain: string; /** Verification state of the domain. */ - state: OrganizationDomainState; + state?: OrganizationDomainState; + /** The prefix used in DNS verification. */ + verificationPrefix?: string; /** Validation token to be used in DNS TXT record. */ verificationToken?: string; /** Strategy used to verify the domain. */ - verificationStrategy: OrganizationDomainVerificationStrategy; - /** The prefix used in DNS verification. */ - verificationPrefix?: string; + verificationStrategy?: OrganizationDomainVerificationStrategy; /** An ISO 8601 timestamp. */ - createdAt: string; + createdAt: Date; /** An ISO 8601 timestamp. */ - updatedAt: string; + updatedAt: Date; } export interface OrganizationDomainResponse { object: 'organization_domain'; id: string; - domain: string; organization_id: string; - state: OrganizationDomainState; - verification_token?: string; - verification_strategy: OrganizationDomainVerificationStrategy; + domain: string; + state?: OrganizationDomainState; verification_prefix?: string; + verification_token?: string; + verification_strategy?: OrganizationDomainVerificationStrategy; created_at: string; updated_at: string; } diff --git a/src/organization-domains/interfaces/verify-organization-domain-options.interface.ts b/src/organization-domains/interfaces/verify-organization-domain-options.interface.ts new file mode 100644 index 000000000..5be1a759b --- /dev/null +++ b/src/organization-domains/interfaces/verify-organization-domain-options.interface.ts @@ -0,0 +1,6 @@ +// This file is auto-generated by oagen. Do not edit. + +export interface VerifyOrganizationDomainOptions { + /** Unique identifier of the organization domain. */ + id: string; +} diff --git a/src/organization-domains/organization-domains.spec.ts b/src/organization-domains/organization-domains.spec.ts index b6ff09120..3da2f9a72 100644 --- a/src/organization-domains/organization-domains.spec.ts +++ b/src/organization-domains/organization-domains.spec.ts @@ -1,110 +1,97 @@ +// This file is auto-generated by oagen. Do not edit. + import fetch from 'jest-fetch-mock'; -import { fetchOnce, fetchURL, fetchBody } from '../common/utils/test-utils'; +import { + fetchOnce, + fetchURL, + fetchMethod, + fetchBody, +} from '../common/utils/test-utils'; import { WorkOS } from '../workos'; -import getOrganizationDomainPending from './fixtures/get-organization-domain-pending.json'; -import getOrganizationDomainVerified from './fixtures/get-organization-domain-verified.json'; -import { OrganizationDomainState } from './interfaces'; + +import organizationDomainFixture from './fixtures/organization-domain.json'; const workos = new WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU'); +function expectOrganizationDomain(result: any) { + expect(result.object).toBe('organization_domain'); + expect(result.id).toBe('org_domain_01EHZNVPK2QXHMVWCEDQEKY69A'); + expect(result.organizationId).toBe('org_01HE8GSH8FQPASKSY27THRKRBP'); + expect(result.domain).toBe('foo-corp.com'); + expect(result.createdAt.toISOString()).toBe('2026-01-15T12:00:00.000Z'); + expect(result.updatedAt.toISOString()).toBe('2026-01-15T12:00:00.000Z'); +} + describe('OrganizationDomains', () => { beforeEach(() => fetch.resetMocks()); - describe('getOrganizationDomain', () => { - it('requests an Organization Domain', async () => { - fetchOnce(getOrganizationDomainVerified); - - const subject = await workos.organizationDomains.getOrganizationDomain( - 'org_domain_01HCZRAP3TPQ0X0DKJHR32TATG', - ); - - expect(fetchURL()).toContain( - '/organization_domains/org_domain_01HCZRAP3TPQ0X0DKJHR32TATG', - ); - expect(subject.id).toEqual('org_domain_01HCZRAP3TPQ0X0DKJHR32TATG'); - expect(subject.domain).toEqual('workos.com'); - expect(subject.organizationId).toEqual('org_01JR8C1EHCRPV4B4XP4W2B9X1M'); - expect(subject.state).toEqual(OrganizationDomainState.Verified); - expect(subject.verificationToken).toBeNull(); - expect(subject.verificationStrategy).toEqual('manual'); - }); + describe('createOrganizationDomain', () => { + it('sends the correct request and returns result', async () => { + fetchOnce(organizationDomainFixture); - it('requests an Organization Domain', async () => { - fetchOnce(getOrganizationDomainPending); + const result = await workos.organizationDomains.createOrganizationDomain({ + domain: 'test_domain', + organizationId: 'organization_id_01234', + }); - const subject = await workos.organizationDomains.getOrganizationDomain( - 'org_domain_01HD50K7EPWCMNPGMKXKKE14XT', + expect(fetchMethod()).toBe('POST'); + expect(new URL(String(fetchURL())).pathname).toBe( + '/organization_domains', ); - - expect(fetchURL()).toContain( - '/organization_domains/org_domain_01HD50K7EPWCMNPGMKXKKE14XT', + expect(fetchBody()).toEqual( + expect.objectContaining({ + domain: 'test_domain', + organization_id: 'organization_id_01234', + }), ); - expect(subject.id).toEqual('org_domain_01HD50K7EPWCMNPGMKXKKE14XT'); - expect(subject.domain).toEqual('workos.com'); - expect(subject.organizationId).toEqual('org_01JR8C1EHCRPV4B4XP4W2B9X1M'); - expect(subject.state).toEqual(OrganizationDomainState.Pending); - expect(subject.verificationToken).toEqual('F06PGMsZIO0shrveGWuGxgCj7'); - expect(subject.verificationStrategy).toEqual('dns'); + expectOrganizationDomain(result); }); }); - describe('verifyOrganizationDomain', () => { - it('start Organization Domain verification flow', async () => { - fetchOnce(getOrganizationDomainPending); + describe('getOrganizationDomain', () => { + it('returns the expected result', async () => { + fetchOnce(organizationDomainFixture); - const subject = await workos.organizationDomains.verifyOrganizationDomain( - 'org_domain_01HD50K7EPWCMNPGMKXKKE14XT', - ); + const result = await workos.organizationDomains.getOrganizationDomain({ + id: 'test_id', + }); - expect(fetchURL()).toContain( - '/organization_domains/org_domain_01HD50K7EPWCMNPGMKXKKE14XT/verify', + expect(fetchMethod()).toBe('GET'); + expect(new URL(String(fetchURL())).pathname).toBe( + '/organization_domains/test_id', ); - expect(subject.id).toEqual('org_domain_01HD50K7EPWCMNPGMKXKKE14XT'); - expect(subject.domain).toEqual('workos.com'); - expect(subject.organizationId).toEqual('org_01JR8C1EHCRPV4B4XP4W2B9X1M'); - expect(subject.state).toEqual(OrganizationDomainState.Pending); - expect(subject.verificationToken).toEqual('F06PGMsZIO0shrveGWuGxgCj7'); - expect(subject.verificationStrategy).toEqual('dns'); + expectOrganizationDomain(result); }); }); - describe('createOrganizationDomain', () => { - it('creates an Organization Domain', async () => { - fetchOnce(getOrganizationDomainPending); - - const subject = await workos.organizationDomains.createOrganizationDomain( - { - organizationId: 'org_01EHT88Z8J8795GZNQ4ZP1J81T', - domain: 'workos.com', - }, - ); + describe('deleteOrganizationDomain', () => { + it('sends a DELETE request', async () => { + fetchOnce({}, { status: 204 }); - expect(fetchURL()).toContain('/organization_domains'); - expect(fetchBody()).toEqual({ - domain: 'workos.com', - organization_id: 'org_01EHT88Z8J8795GZNQ4ZP1J81T', + await workos.organizationDomains.deleteOrganizationDomain({ + id: 'test_id', }); - expect(subject.id).toEqual('org_domain_01HD50K7EPWCMNPGMKXKKE14XT'); - expect(subject.domain).toEqual('workos.com'); - expect(subject.organizationId).toEqual('org_01JR8C1EHCRPV4B4XP4W2B9X1M'); - expect(subject.state).toEqual(OrganizationDomainState.Pending); - expect(subject.verificationToken).toEqual('F06PGMsZIO0shrveGWuGxgCj7'); - expect(subject.verificationStrategy).toEqual('dns'); + expect(fetchMethod()).toBe('DELETE'); + expect(new URL(String(fetchURL())).pathname).toBe( + '/organization_domains/test_id', + ); }); }); - describe('deleteOrganizationDomain', () => { - it('deletes an Organization Domain', async () => { - fetchOnce(); + describe('verifyOrganizationDomain', () => { + it('returns the expected result', async () => { + fetchOnce(organizationDomainFixture); - await workos.organizationDomains.deleteOrganizationDomain( - 'org_domain_01HCZRAP3TPQ0X0DKJHR32TATG', - ); + const result = await workos.organizationDomains.verifyOrganizationDomain({ + id: 'test_id', + }); - expect(fetchURL()).toContain( - '/organization_domains/org_domain_01HCZRAP3TPQ0X0DKJHR32TATG', + expect(fetchMethod()).toBe('POST'); + expect(new URL(String(fetchURL())).pathname).toBe( + '/organization_domains/test_id/verify', ); + expectOrganizationDomain(result); }); }); }); diff --git a/src/organization-domains/organization-domains.ts b/src/organization-domains/organization-domains.ts index 67193ddcc..d2a8649a6 100644 --- a/src/organization-domains/organization-domains.ts +++ b/src/organization-domains/organization-domains.ts @@ -1,88 +1,99 @@ -import { WorkOS } from '../workos'; -import { - CreateOrganizationDomainOptions, +// This file is auto-generated by oagen. Do not edit. + +import type { WorkOS } from '../workos'; +import type { CreateOrganizationDomainOptions } from './interfaces/create-organization-domain-options.interface'; +import type { GetOrganizationDomainOptions } from './interfaces/get-organization-domain-options.interface'; +import type { DeleteOrganizationDomainOptions } from './interfaces/delete-organization-domain-options.interface'; +import type { VerifyOrganizationDomainOptions } from './interfaces/verify-organization-domain-options.interface'; +import type { OrganizationDomain, OrganizationDomainResponse, -} from './interfaces'; -import { serializeCreateOrganizationDomainOptions } from './serializers/create-organization-domain-options.serializer'; +} from './interfaces/organization-domain.interface'; +import type { CreateOrganizationDomainResponse } from './interfaces/create-organization-domain.interface'; import { deserializeOrganizationDomain } from './serializers/organization-domain.serializer'; +import { serializeCreateOrganizationDomain } from './serializers/create-organization-domain.serializer'; export class OrganizationDomains { constructor(private readonly workos: WorkOS) {} + /** + * Create an Organization Domain + * + * Creates a new Organization Domain. + * @param options - Object containing domain, organizationId. + * @param options.domain - The domain to add to the organization. + * @example "foo-corp.com" + * @param options.organizationId - The ID of the organization to add the domain to. + * @example "org_01EHQMYV6MBK39QC5PZXHY59C3" + * @returns {Promise} + * @throws {ConflictException} 409 + */ + async createOrganizationDomain( + options: CreateOrganizationDomainOptions, + ): Promise { + const payload = options; + const { data } = await this.workos.post< + OrganizationDomainResponse, + CreateOrganizationDomainResponse + >('/organization_domains', serializeCreateOrganizationDomain(payload)); + return deserializeOrganizationDomain(data); + } + /** * Get an Organization Domain * * Get the details of an existing organization domain. - * @param id - Unique identifier of the organization domain. - * - * @example - * "org_domain_01EHZNVPK2QXHMVWCEDQEKY69A" - * + * @param options - The request options. + * @param options.id - Unique identifier of the organization domain. + * @example "org_domain_01EHZNVPK2QXHMVWCEDQEKY69A" * @returns {Promise} * @throws {NotFoundException} 404 */ - async getOrganizationDomain(id: string): Promise { + async getOrganizationDomain( + options: GetOrganizationDomainOptions, + ): Promise { + const { id } = options; const { data } = await this.workos.get( - `/organization_domains/${id}`, + `/organization_domains/${encodeURIComponent(id)}`, ); - return deserializeOrganizationDomain(data); } /** - * Verify an Organization Domain - * - * Initiates verification process for an Organization Domain. - * @param id - Unique identifier of the organization domain. - * - * @example - * "org_domain_01EHZNVPK2QXHMVWCEDQEKY69A" + * Delete an Organization Domain * - * @returns {Promise} - * @throws {BadRequestException} 400 + * Permanently deletes an organization domain. It cannot be undone. + * @param options - The request options. + * @param options.id - Unique identifier of the organization domain. + * @example "org_domain_01EHZNVPK2QXHMVWCEDQEKY69A" + * @returns {Promise} + * @throws {NotFoundException} 404 */ - async verifyOrganizationDomain(id: string): Promise { - const { data } = await this.workos.post( - `/organization_domains/${id}/verify`, - {}, - ); - - return deserializeOrganizationDomain(data); + async deleteOrganizationDomain( + options: DeleteOrganizationDomainOptions, + ): Promise { + const { id } = options; + await this.workos.delete(`/organization_domains/${encodeURIComponent(id)}`); } /** - * Create an Organization Domain + * Verify an Organization Domain * - * Creates a new Organization Domain. - * @param payload - Object containing domain, organizationId. + * Initiates verification process for an Organization Domain. + * @param options - The request options. + * @param options.id - Unique identifier of the organization domain. + * @example "org_domain_01EHZNVPK2QXHMVWCEDQEKY69A" * @returns {Promise} - * @throws {ConflictException} 409 + * @throws {BadRequestException} 400 */ - async createOrganizationDomain( - payload: CreateOrganizationDomainOptions, + async verifyOrganizationDomain( + options: VerifyOrganizationDomainOptions, ): Promise { + const { id } = options; const { data } = await this.workos.post( - `/organization_domains`, - serializeCreateOrganizationDomainOptions(payload), + `/organization_domains/${encodeURIComponent(id)}/verify`, + {}, ); - return deserializeOrganizationDomain(data); } - - /** - * Delete an Organization Domain - * - * Permanently deletes an organization domain. It cannot be undone. - * @param id - Unique identifier of the organization domain. - * - * @example - * "org_domain_01EHZNVPK2QXHMVWCEDQEKY69A" - * - * @returns {Promise} - * @throws {NotFoundException} 404 - */ - async deleteOrganizationDomain(id: string): Promise { - await this.workos.delete(`/organization_domains/${id}`); - } } diff --git a/src/organization-domains/serializers.spec.ts b/src/organization-domains/serializers.spec.ts new file mode 100644 index 000000000..16d4ad666 --- /dev/null +++ b/src/organization-domains/serializers.spec.ts @@ -0,0 +1,25 @@ +// This file is auto-generated by oagen. Do not edit. + +import { serializeCreateOrganizationDomain } from './serializers/create-organization-domain.serializer'; +import { deserializeOrganizationDomain } from './serializers/organization-domain.serializer'; +import type { CreateOrganizationDomainResponse } from './interfaces/create-organization-domain.interface'; +import type { OrganizationDomainResponse } from './interfaces/organization-domain.interface'; +import createOrganizationDomainFixture from './fixtures/create-organization-domain.json'; +import organizationDomainFixture from './fixtures/organization-domain.json'; + +describe('CreateOrganizationDomainSerializer', () => { + it('serializes correctly', () => { + const fixture = + createOrganizationDomainFixture as CreateOrganizationDomainResponse; + const serialized = serializeCreateOrganizationDomain(fixture as any); + expect(serialized).toBeDefined(); + }); +}); + +describe('OrganizationDomainSerializer', () => { + it('deserializes correctly', () => { + const fixture = organizationDomainFixture as OrganizationDomainResponse; + const deserialized = deserializeOrganizationDomain(fixture); + expect(deserialized).toBeDefined(); + }); +}); diff --git a/src/organization-domains/serializers/create-organization-domain-options.serializer.ts b/src/organization-domains/serializers/create-organization-domain-options.serializer.ts deleted file mode 100644 index 54f4bbf92..000000000 --- a/src/organization-domains/serializers/create-organization-domain-options.serializer.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { - CreateOrganizationDomainOptions, - SerializedCreateOrganizationDomainOptions, -} from '../interfaces'; - -export const serializeCreateOrganizationDomainOptions = ( - options: CreateOrganizationDomainOptions, -): SerializedCreateOrganizationDomainOptions => ({ - domain: options.domain, - organization_id: options.organizationId, -}); diff --git a/src/organization-domains/serializers/create-organization-domain.serializer.ts b/src/organization-domains/serializers/create-organization-domain.serializer.ts new file mode 100644 index 000000000..89ca96c23 --- /dev/null +++ b/src/organization-domains/serializers/create-organization-domain.serializer.ts @@ -0,0 +1,13 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { + CreateOrganizationDomain, + CreateOrganizationDomainResponse, +} from '../interfaces/create-organization-domain.interface'; + +export const serializeCreateOrganizationDomain = ( + model: CreateOrganizationDomain, +): CreateOrganizationDomainResponse => ({ + domain: model.domain, + organization_id: model.organizationId, +}); diff --git a/src/organization-domains/serializers/index.ts b/src/organization-domains/serializers/index.ts new file mode 100644 index 000000000..ffafa6e70 --- /dev/null +++ b/src/organization-domains/serializers/index.ts @@ -0,0 +1,4 @@ +// This file is auto-generated by oagen. Do not edit. + +export * from './create-organization-domain.serializer'; +export * from './organization-domain.serializer'; diff --git a/src/organization-domains/serializers/organization-domain-verification-failed.serializer.ts b/src/organization-domains/serializers/organization-domain-verification-failed.serializer.ts index c3fcb8551..96fd7c75e 100644 --- a/src/organization-domains/serializers/organization-domain-verification-failed.serializer.ts +++ b/src/organization-domains/serializers/organization-domain-verification-failed.serializer.ts @@ -2,10 +2,7 @@ import { OrganizationDomainVerificationFailed, OrganizationDomainVerificationFailedResponse, } from '../interfaces'; -import { - deserializeOrganizationDomain, - serializeOrganizationDomain, -} from './organization-domain.serializer'; +import { deserializeOrganizationDomain } from './organization-domain.serializer'; export const deserializeOrganizationDomainVerificationFailed = ( organizationDomainVerificationFailed: OrganizationDomainVerificationFailedResponse, @@ -15,12 +12,3 @@ export const deserializeOrganizationDomainVerificationFailed = ( organizationDomainVerificationFailed.organization_domain, ), }); - -export const serializeOrganizationDomainVerificationFailed = ( - organizationDomainVerificationFailed: OrganizationDomainVerificationFailed, -): OrganizationDomainVerificationFailedResponse => ({ - reason: organizationDomainVerificationFailed.reason, - organization_domain: serializeOrganizationDomain( - organizationDomainVerificationFailed.organizationDomain, - ), -}); diff --git a/src/organization-domains/serializers/organization-domain.serializer.ts b/src/organization-domains/serializers/organization-domain.serializer.ts index dcabaff40..d044b945e 100644 --- a/src/organization-domains/serializers/organization-domain.serializer.ts +++ b/src/organization-domains/serializers/organization-domain.serializer.ts @@ -1,39 +1,21 @@ -import { OrganizationDomain, OrganizationDomainResponse } from '../interfaces'; +// This file is auto-generated by oagen. Do not edit. + +import type { + OrganizationDomain, + OrganizationDomainResponse, +} from '../interfaces/organization-domain.interface'; export const deserializeOrganizationDomain = ( - organizationDomain: OrganizationDomainResponse, + response: OrganizationDomainResponse, ): OrganizationDomain => ({ - object: organizationDomain.object, - id: organizationDomain.id, - domain: organizationDomain.domain, - organizationId: organizationDomain.organization_id, - state: organizationDomain.state, - ...(organizationDomain.verification_token !== undefined && { - verificationToken: organizationDomain.verification_token, - }), - verificationStrategy: organizationDomain.verification_strategy, - ...(organizationDomain.verification_prefix !== undefined && { - verificationPrefix: organizationDomain.verification_prefix, - }), - createdAt: organizationDomain.created_at, - updatedAt: organizationDomain.updated_at, -}); - -export const serializeOrganizationDomain = ( - organizationDomain: OrganizationDomain, -): OrganizationDomainResponse => ({ - object: organizationDomain.object, - id: organizationDomain.id, - domain: organizationDomain.domain, - organization_id: organizationDomain.organizationId, - state: organizationDomain.state, - ...(organizationDomain.verificationToken !== undefined && { - verification_token: organizationDomain.verificationToken, - }), - verification_strategy: organizationDomain.verificationStrategy, - ...(organizationDomain.verificationPrefix !== undefined && { - verification_prefix: organizationDomain.verificationPrefix, - }), - created_at: organizationDomain.createdAt, - updated_at: organizationDomain.updatedAt, + object: response.object, + id: response.id, + organizationId: response.organization_id, + domain: response.domain, + state: response.state, + verificationPrefix: response.verification_prefix, + verificationToken: response.verification_token, + verificationStrategy: response.verification_strategy, + createdAt: new Date(response.created_at), + updatedAt: new Date(response.updated_at), }); diff --git a/src/organizations/fixtures/get-organization.json b/src/organizations/fixtures/get-organization.json index df462296b..6b567e9f9 100644 --- a/src/organizations/fixtures/get-organization.json +++ b/src/organizations/fixtures/get-organization.json @@ -8,9 +8,12 @@ "domain": "example.com", "object": "organization_domain", "id": "org_domain_01EHT88Z8WZEFWYPM6EC9BX2R8", + "organization_id": "org_01EHT88Z8J8795GZNQ4ZP1J81T", "state": "verified", "verification_strategy": "dns", - "verification_token": "xB8SeACdKJQP9DP4CahU4YuQZ" + "verification_token": "xB8SeACdKJQP9DP4CahU4YuQZ", + "created_at": "2023-07-17T20:07:20.055Z", + "updated_at": "2023-07-17T20:07:20.055Z" } ], "metadata": {} diff --git a/src/organizations/organizations.spec.ts b/src/organizations/organizations.spec.ts index 1014611ae..f145c2451 100644 --- a/src/organizations/organizations.spec.ts +++ b/src/organizations/organizations.spec.ts @@ -232,10 +232,13 @@ describe('Organizations', () => { { object: 'organization_domain', id: 'org_domain_01EHT88Z8WZEFWYPM6EC9BX2R8', + organizationId: 'org_01EHT88Z8J8795GZNQ4ZP1J81T', domain: 'example.com', state: 'verified', verificationStrategy: 'dns', verificationToken: 'xB8SeACdKJQP9DP4CahU4YuQZ', + createdAt: new Date('2023-07-17T20:07:20.055Z'), + updatedAt: new Date('2023-07-17T20:07:20.055Z'), }, ]); });