0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

feat(schemas): add cloudflare hostnames configs (#3902)

This commit is contained in:
wangsijie 2023-05-26 11:44:10 +08:00 committed by GitHub
parent ff4fb5e56f
commit 2cab3787c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 3 deletions

View file

@ -0,0 +1,5 @@
---
"@logto/schemas": minor
---
Add cloudflare configurations to system

View file

@ -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<typeof hostnameProviderDataGuard>;
export enum CloudflareKey {
HostnameProvider = 'cloudflareHostnameProvider',
}
export type CloudflareType = {
[CloudflareKey.HostnameProvider]: HostnameProviderData;
};
export const cloudflareGuard: Readonly<{
[key in CloudflareKey]: ZodType<CloudflareType[key]>;
}> = 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,
});