diff --git a/packages/core/src/__mocks__/domain.ts b/packages/core/src/__mocks__/domain.ts index ef3633e13..5da31b5f4 100644 --- a/packages/core/src/__mocks__/domain.ts +++ b/packages/core/src/__mocks__/domain.ts @@ -1,4 +1,9 @@ -import { type CloudflareData, type Domain, type DomainResponse } from '@logto/schemas'; +import { + DomainStatus, + type CloudflareData, + type Domain, + type DomainResponse, +} from '@logto/schemas'; export const mockNanoIdForDomain = 'random_string'; @@ -9,7 +14,7 @@ export const mockTenantIdForHook = 'fake_tenant'; export const mockDomainResponse: DomainResponse = { id: mockNanoIdForDomain, domain: 'logto.example.com', - status: 'pending', + status: DomainStatus.PendingVerification, errorMessage: null, dnsRecords: [], }; diff --git a/packages/schemas/src/foundations/jsonb-types.ts b/packages/schemas/src/foundations/jsonb-types.ts index 3fd715e13..82aa4eccf 100644 --- a/packages/schemas/src/foundations/jsonb-types.ts +++ b/packages/schemas/src/foundations/jsonb-types.ts @@ -266,3 +266,12 @@ export const cloudflareDataGuard = z .catchall(z.unknown()); export type CloudflareData = z.infer; + +export enum DomainStatus { + PendingVerification = 'PendingVerification', + PendingSsl = 'PendingSsl', + Active = 'Active', + Error = 'Error', +} + +export const domainStatusGuard = z.nativeEnum(DomainStatus); diff --git a/packages/schemas/src/types/domain.ts b/packages/schemas/src/types/domain.ts index 01be9816f..e8e37b15e 100644 --- a/packages/schemas/src/types/domain.ts +++ b/packages/schemas/src/types/domain.ts @@ -19,10 +19,3 @@ export const domainResponseGuard = Domains.guard.pick({ }); export type DomainResponse = z.infer; - -export enum DomainStatus { - PendingVerification = 'PendingVerification', - PendingSsl = 'PendingSsl', - Active = 'Active', - Error = 'Error', -} diff --git a/packages/schemas/tables/domains.sql b/packages/schemas/tables/domains.sql index f09ad8d87..3f0ed322e 100644 --- a/packages/schemas/tables/domains.sql +++ b/packages/schemas/tables/domains.sql @@ -3,7 +3,7 @@ create table domains ( references tenants (id) on update cascade on delete cascade, id varchar(21) not null, domain varchar(256) not null, - status varchar(32) not null default('PendingVerification'), + status varchar(32) /* @use DomainStatus */ not null default('PendingVerification'), error_message varchar(1024), dns_records jsonb /* @use DomainDnsRecords */ not null default '[]'::jsonb, cloudflare_data jsonb /* @use CloudflareData */,