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:
parent
740e482aed
commit
3d3c82b1c5
1 changed files with 21 additions and 13 deletions
|
@ -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>;
|
||||
|
|
Loading…
Reference in a new issue