fix filter stuff

This commit is contained in:
KMKoushik
2025-03-08 23:04:19 +11:00
committed by KM Koushik
parent 48395915f0
commit 8b9d81ab2a
4 changed files with 62 additions and 61 deletions

View File

@@ -11,30 +11,42 @@ const route = createRoute({
required: true,
content: {
"application/json": {
schema: z.object({
to: z.string().or(z.array(z.string())),
from: z.string(),
subject: z.string().optional().openapi({ description: 'Optional when templateId is provided' }),
templateId: z.string().optional().openapi({ description: 'ID of a template from the dashboard' }),
variables: z.record(z.string()).optional(),
replyTo: z.string().or(z.array(z.string())).optional(),
cc: z.string().or(z.array(z.string())).optional(),
bcc: z.string().or(z.array(z.string())).optional(),
text: z.string().optional(),
html: z.string().optional(),
attachments: z
.array(
z.object({
filename: z.string(),
content: z.string(),
})
)
.optional(),
scheduledAt: z.string().datetime().optional(),
}).refine(
data => !!data.subject || !!data.templateId,
'Either subject or templateId should be passed.',
),
schema: z
.object({
to: z.string().or(z.array(z.string())),
from: z.string(),
subject: z
.string()
.optional()
.openapi({
description: "Optional when templateId is provided",
}),
templateId: z
.string()
.optional()
.openapi({
description: "ID of a template from the dashboard",
}),
variables: z.record(z.string()).optional(),
replyTo: z.string().or(z.array(z.string())).optional(),
cc: z.string().or(z.array(z.string())).optional(),
bcc: z.string().or(z.array(z.string())).optional(),
text: z.string().optional(),
html: z.string().optional(),
attachments: z
.array(
z.object({
filename: z.string(),
content: z.string(),
})
)
.optional(),
scheduledAt: z.string().datetime().optional(),
})
.refine(
(data) => !!data.subject || !!data.templateId,
"Either subject or templateId should be passed."
),
},
},
},
@@ -58,6 +70,7 @@ function send(app: PublicAPIApp) {
const email = await sendEmail({
...c.req.valid("json"),
teamId: team.id,
apiKeyId: team.apiKeyId,
});
return c.json({ emailId: email?.id });