From 2cab3787c174f985c9dc2775496fabdbe93acaca Mon Sep 17 00:00:00 2001 From: wangsijie Date: Fri, 26 May 2023 11:44:10 +0800 Subject: [PATCH] feat(schemas): add cloudflare hostnames configs (#3902) --- .changeset/famous-tips-search.md | 5 ++++ packages/schemas/src/types/system.ts | 36 +++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 .changeset/famous-tips-search.md diff --git a/.changeset/famous-tips-search.md b/.changeset/famous-tips-search.md new file mode 100644 index 000000000..68b604bee --- /dev/null +++ b/.changeset/famous-tips-search.md @@ -0,0 +1,5 @@ +--- +"@logto/schemas": minor +--- + +Add cloudflare configurations to system diff --git a/packages/schemas/src/types/system.ts b/packages/schemas/src/types/system.ts index 6c22338cd..789bdbe9c 100644 --- a/packages/schemas/src/types/system.ts +++ b/packages/schemas/src/types/system.ts @@ -97,21 +97,51 @@ export const demoSocialGuard: Readonly<{ [DemoSocialKey.DemoSocial]: demoSocialDataGuard, }); +// Cloudflare Hostnames +export const hostnameProviderDataGuard = z.object({ + zoneId: z.string(), + apiToken: z.string(), // Requires zone permission for "SSL and Certificates Edit" + fallbackOrigin: z.string(), // A domain name +}); + +export type HostnameProviderData = z.infer; + +export enum CloudflareKey { + HostnameProvider = 'cloudflareHostnameProvider', +} + +export type CloudflareType = { + [CloudflareKey.HostnameProvider]: HostnameProviderData; +}; + +export const cloudflareGuard: Readonly<{ + [key in CloudflareKey]: ZodType; +}> = Object.freeze({ + [CloudflareKey.HostnameProvider]: hostnameProviderDataGuard, +}); + // Summary -export type SystemKey = AlterationStateKey | StorageProviderKey | DemoSocialKey; -export type SystemType = AlterationStateType | StorageProviderType | DemoSocialType; +export type SystemKey = AlterationStateKey | StorageProviderKey | DemoSocialKey | CloudflareKey; +export type SystemType = + | AlterationStateType + | StorageProviderType + | DemoSocialType + | CloudflareType; export type SystemGuard = typeof alterationStateGuard & typeof storageProviderGuard & - typeof demoSocialGuard; + typeof demoSocialGuard & + typeof cloudflareGuard; export const systemKeys: readonly SystemKey[] = Object.freeze([ ...Object.values(AlterationStateKey), ...Object.values(StorageProviderKey), ...Object.values(DemoSocialKey), + ...Object.values(CloudflareKey), ]); export const systemGuards: SystemGuard = Object.freeze({ ...alterationStateGuard, ...storageProviderGuard, ...demoSocialGuard, + ...cloudflareGuard, });