0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-20 21:32:31 -05:00

fix(schemas): set domain status enum guard (#3958)

This commit is contained in:
wangsijie 2023-06-08 12:07:15 +09:00 committed by GitHub
parent d13cb277eb
commit 62d3acfc7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 10 deletions

View file

@ -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: [],
};

View file

@ -266,3 +266,12 @@ export const cloudflareDataGuard = z
.catchall(z.unknown());
export type CloudflareData = z.infer<typeof cloudflareDataGuard>;
export enum DomainStatus {
PendingVerification = 'PendingVerification',
PendingSsl = 'PendingSsl',
Active = 'Active',
Error = 'Error',
}
export const domainStatusGuard = z.nativeEnum(DomainStatus);

View file

@ -19,10 +19,3 @@ export const domainResponseGuard = Domains.guard.pick({
});
export type DomainResponse = z.infer<typeof domainResponseGuard>;
export enum DomainStatus {
PendingVerification = 'PendingVerification',
PendingSsl = 'PendingSsl',
Active = 'Active',
Error = 'Error',
}

View file

@ -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 */,