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

fix(schemas): fix sendgrid email service config (#4093)

This commit is contained in:
Darcy Ye 2023-06-28 18:02:10 +08:00 committed by GitHub
parent 740e482aed
commit 3d3c82b1c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -81,20 +81,28 @@ export enum OtherEmailTemplate {
export const otherEmailTemplateGuard = z.nativeEnum(OtherEmailTemplate);
const emailServiceBasicConfig = {
fromName: z.string(),
fromEmail: z.string(),
templates: z.record(
verificationCodeTypeGuard.or(otherEmailTemplateGuard),
z.object({
subject: z.string(),
content: z.string(),
})
),
};
export const sendgridEmailServiceDataGuard = z.object({
provider: z.literal(EmailServiceProvider.SendGrid),
apiKey: z.string(),
...emailServiceBasicConfig,
});
export type SendgridEmailServiceData = z.infer<typeof sendgridEmailServiceDataGuard>;
export const emailServiceDataGuard = z.discriminatedUnion('provider', [
z.object({
provider: z.literal(EmailServiceProvider.SendGrid),
appId: z.string(),
appSecret: z.string(),
fromEmail: z.string(),
templates: z.record(
verificationCodeTypeGuard.or(otherEmailTemplateGuard),
z.object({
subject: z.string(),
content: z.string(),
})
),
}),
sendgridEmailServiceDataGuard,
]);
export type EmailServiceData = z.infer<typeof emailServiceDataGuard>;