2023-12-22 09:13:53 +01:00
|
|
|
import { z } from '../zod'
|
2023-11-08 15:34:16 +01:00
|
|
|
import { stripeCredentialsSchema } from './blocks/inputs/payment/schema'
|
|
|
|
import { googleSheetsCredentialsSchema } from './blocks/integrations/googleSheets/schema'
|
2023-03-09 08:46:36 +01:00
|
|
|
import { smtpCredentialsSchema } from './blocks/integrations/sendEmail'
|
2023-08-29 10:01:28 +02:00
|
|
|
import { whatsAppCredentialsSchema } from './whatsapp'
|
2024-07-16 15:11:48 +02:00
|
|
|
import { forgedCredentialsSchemas } from '@typebot.io/forge-repository/credentials'
|
2023-03-09 08:46:36 +01:00
|
|
|
|
2024-07-16 15:11:48 +02:00
|
|
|
const credentialsSchema = z.discriminatedUnion('type', [
|
2023-03-09 08:46:36 +01:00
|
|
|
smtpCredentialsSchema,
|
|
|
|
googleSheetsCredentialsSchema,
|
|
|
|
stripeCredentialsSchema,
|
2023-08-29 10:01:28 +02:00
|
|
|
whatsAppCredentialsSchema,
|
2024-07-16 15:11:48 +02:00
|
|
|
...Object.values(forgedCredentialsSchemas),
|
2023-03-09 08:46:36 +01:00
|
|
|
])
|
|
|
|
|
|
|
|
export type Credentials = z.infer<typeof credentialsSchema>
|
2024-07-16 15:11:48 +02:00
|
|
|
|
|
|
|
export const credentialsTypes = [
|
|
|
|
'smtp',
|
|
|
|
'google sheets',
|
|
|
|
'stripe',
|
|
|
|
'whatsApp',
|
|
|
|
...(Object.keys(forgedCredentialsSchemas) as Array<
|
|
|
|
keyof typeof forgedCredentialsSchemas
|
|
|
|
>),
|
|
|
|
] as const
|
|
|
|
|
|
|
|
export const credentialsTypeSchema = z.enum(credentialsTypes)
|