@ -19,7 +19,7 @@ export const chatwootOptionsSchema = z.object({
|
||||
.optional(),
|
||||
})
|
||||
|
||||
export const chatwootBlockSchema = blockBaseSchema.and(
|
||||
export const chatwootBlockSchema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([IntegrationBlockType.CHATWOOT]),
|
||||
options: chatwootOptionsSchema,
|
||||
|
@ -10,7 +10,7 @@ export const googleAnalyticsOptionsSchema = z.object({
|
||||
value: z.number().optional(),
|
||||
})
|
||||
|
||||
export const googleAnalyticsBlockSchema = blockBaseSchema.and(
|
||||
export const googleAnalyticsBlockSchema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([IntegrationBlockType.GOOGLE_ANALYTICS]),
|
||||
options: googleAnalyticsOptionsSchema,
|
||||
|
@ -29,7 +29,13 @@ const rowsFilterComparisonSchema = z.object({
|
||||
value: z.string().optional(),
|
||||
})
|
||||
|
||||
const googleSheetsGetOptionsSchema = googleSheetsOptionsBaseSchema.and(
|
||||
const initialGoogleSheetsOptionsSchema = googleSheetsOptionsBaseSchema.merge(
|
||||
z.object({
|
||||
action: z.undefined(),
|
||||
})
|
||||
)
|
||||
|
||||
const googleSheetsGetOptionsSchema = googleSheetsOptionsBaseSchema.merge(
|
||||
z.object({
|
||||
action: z.enum([GoogleSheetsAction.GET]),
|
||||
// TODO: remove referenceCell once migrated to filtering
|
||||
@ -42,14 +48,14 @@ const googleSheetsGetOptionsSchema = googleSheetsOptionsBaseSchema.and(
|
||||
})
|
||||
)
|
||||
|
||||
const googleSheetsInsertRowOptionsSchema = googleSheetsOptionsBaseSchema.and(
|
||||
const googleSheetsInsertRowOptionsSchema = googleSheetsOptionsBaseSchema.merge(
|
||||
z.object({
|
||||
action: z.enum([GoogleSheetsAction.INSERT_ROW]),
|
||||
cellsToInsert: z.array(cellSchema),
|
||||
})
|
||||
)
|
||||
|
||||
const googleSheetsUpdateRowOptionsSchema = googleSheetsOptionsBaseSchema.and(
|
||||
const googleSheetsUpdateRowOptionsSchema = googleSheetsOptionsBaseSchema.merge(
|
||||
z.object({
|
||||
action: z.enum([GoogleSheetsAction.UPDATE_ROW]),
|
||||
cellsToUpsert: z.array(cellSchema),
|
||||
@ -57,12 +63,14 @@ const googleSheetsUpdateRowOptionsSchema = googleSheetsOptionsBaseSchema.and(
|
||||
})
|
||||
)
|
||||
|
||||
export const googleSheetsOptionsSchema = googleSheetsGetOptionsSchema
|
||||
.or(googleSheetsInsertRowOptionsSchema)
|
||||
.or(googleSheetsUpdateRowOptionsSchema)
|
||||
.or(googleSheetsOptionsBaseSchema)
|
||||
export const googleSheetsOptionsSchema = z.discriminatedUnion('action', [
|
||||
googleSheetsGetOptionsSchema,
|
||||
googleSheetsInsertRowOptionsSchema,
|
||||
googleSheetsUpdateRowOptionsSchema,
|
||||
initialGoogleSheetsOptionsSchema,
|
||||
])
|
||||
|
||||
export const googleSheetsBlockSchema = blockBaseSchema.and(
|
||||
export const googleSheetsBlockSchema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([IntegrationBlockType.GOOGLE_SHEETS]),
|
||||
options: googleSheetsOptionsSchema,
|
||||
|
@ -4,7 +4,6 @@ export * from './googleAnalytics'
|
||||
export * from './googleSheets'
|
||||
export * from './makeCom'
|
||||
export * from './pabblyConnect'
|
||||
export * from './schemas'
|
||||
export * from './sendEmail'
|
||||
export * from './webhook'
|
||||
export * from './zapier'
|
||||
|
@ -3,7 +3,7 @@ import { blockBaseSchema } from '../baseSchemas'
|
||||
import { IntegrationBlockType } from './enums'
|
||||
import { webhookOptionsSchema } from './webhook'
|
||||
|
||||
export const makeComBlockSchema = blockBaseSchema.and(
|
||||
export const makeComBlockSchema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([IntegrationBlockType.MAKE_COM]),
|
||||
options: webhookOptionsSchema,
|
||||
|
@ -3,7 +3,7 @@ import { blockBaseSchema } from '../baseSchemas'
|
||||
import { IntegrationBlockType } from './enums'
|
||||
import { webhookOptionsSchema } from './webhook'
|
||||
|
||||
export const pabblyConnectBlockSchema = blockBaseSchema.and(
|
||||
export const pabblyConnectBlockSchema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([IntegrationBlockType.PABBLY_CONNECT]),
|
||||
options: webhookOptionsSchema,
|
||||
|
@ -1,23 +0,0 @@
|
||||
import { z } from 'zod'
|
||||
import { chatwootBlockSchema } from './chatwoot'
|
||||
import { googleAnalyticsBlockSchema } from './googleAnalytics'
|
||||
import { googleSheetsBlockSchema } from './googleSheets/schemas'
|
||||
import { makeComBlockSchema } from './makeCom'
|
||||
import { openAIBlockSchema } from './openai'
|
||||
import { pabblyConnectBlockSchema } from './pabblyConnect'
|
||||
import { sendEmailBlockSchema } from './sendEmail'
|
||||
import { webhookBlockSchema } from './webhook'
|
||||
import { zapierBlockSchema } from './zapier'
|
||||
|
||||
export const integrationBlockSchema = googleSheetsBlockSchema
|
||||
.or(googleAnalyticsBlockSchema)
|
||||
.or(webhookBlockSchema)
|
||||
.or(sendEmailBlockSchema)
|
||||
.or(zapierBlockSchema)
|
||||
.or(makeComBlockSchema)
|
||||
.or(pabblyConnectBlockSchema)
|
||||
.or(chatwootBlockSchema)
|
||||
.or(openAIBlockSchema)
|
||||
|
||||
export type IntegrationBlock = z.infer<typeof integrationBlockSchema>
|
||||
export type IntegrationBlockOptions = IntegrationBlock['options']
|
@ -15,7 +15,7 @@ export const sendEmailOptionsSchema = z.object({
|
||||
attachmentsVariableId: z.string().optional(),
|
||||
})
|
||||
|
||||
export const sendEmailBlockSchema = blockBaseSchema.and(
|
||||
export const sendEmailBlockSchema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([IntegrationBlockType.EMAIL]),
|
||||
options: sendEmailOptionsSchema,
|
||||
|
@ -21,7 +21,7 @@ export const webhookOptionsSchema = z.object({
|
||||
isCustomBody: z.boolean().optional(),
|
||||
})
|
||||
|
||||
export const webhookBlockSchema = blockBaseSchema.and(
|
||||
export const webhookBlockSchema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([IntegrationBlockType.WEBHOOK]),
|
||||
options: webhookOptionsSchema,
|
||||
|
@ -3,7 +3,7 @@ import { blockBaseSchema } from '../baseSchemas'
|
||||
import { IntegrationBlockType } from './enums'
|
||||
import { webhookOptionsSchema } from './webhook'
|
||||
|
||||
export const zapierBlockSchema = blockBaseSchema.and(
|
||||
export const zapierBlockSchema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([IntegrationBlockType.ZAPIER]),
|
||||
options: webhookOptionsSchema,
|
||||
|
Reference in New Issue
Block a user