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,11 +81,8 @@ export enum OtherEmailTemplate {
export const otherEmailTemplateGuard = z.nativeEnum(OtherEmailTemplate);
export const emailServiceDataGuard = z.discriminatedUnion('provider', [
z.object({
provider: z.literal(EmailServiceProvider.SendGrid),
appId: z.string(),
appSecret: z.string(),
const emailServiceBasicConfig = {
fromName: z.string(),
fromEmail: z.string(),
templates: z.record(
verificationCodeTypeGuard.or(otherEmailTemplateGuard),
@ -94,7 +91,18 @@ export const emailServiceDataGuard = z.discriminatedUnion('provider', [
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', [
sendgridEmailServiceDataGuard,
]);
export type EmailServiceData = z.infer<typeof emailServiceDataGuard>;