@ -30,14 +30,14 @@ const conditionContentSchema = z.object({
|
||||
comparisons: z.array(comparisonSchema),
|
||||
})
|
||||
|
||||
export const conditionItemSchema = itemBaseSchema.and(
|
||||
export const conditionItemSchema = itemBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.literal(ItemType.CONDITION),
|
||||
content: conditionContentSchema,
|
||||
})
|
||||
)
|
||||
|
||||
export const conditionBlockSchema = blockBaseSchema.and(
|
||||
export const conditionBlockSchema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([LogicBlockType.CONDITION]),
|
||||
items: z.array(conditionItemSchema),
|
||||
|
@ -1,7 +1,6 @@
|
||||
export * from './script'
|
||||
export * from './condition'
|
||||
export * from './enums'
|
||||
export * from './logicBlock'
|
||||
export * from './redirect'
|
||||
export * from './setVariable'
|
||||
export * from './typebotLink'
|
||||
|
@ -7,7 +7,7 @@ export const jumpOptionsSchema = z.object({
|
||||
blockId: z.string().optional(),
|
||||
})
|
||||
|
||||
export const jumpBlockSchema = blockBaseSchema.and(
|
||||
export const jumpBlockSchema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([LogicBlockType.JUMP]),
|
||||
options: jumpOptionsSchema,
|
||||
|
@ -1,26 +0,0 @@
|
||||
import { z } from 'zod'
|
||||
import { scriptOptionsSchema, scriptBlockSchema } from './script'
|
||||
import { conditionBlockSchema } from './condition'
|
||||
import { redirectOptionsSchema, redirectBlockSchema } from './redirect'
|
||||
import { setVariableOptionsSchema, setVariableBlockSchema } from './setVariable'
|
||||
import { typebotLinkOptionsSchema, typebotLinkBlockSchema } from './typebotLink'
|
||||
import { waitBlockSchema, waitOptionsSchema } from './wait'
|
||||
import { jumpBlockSchema, jumpOptionsSchema } from './jump'
|
||||
|
||||
const logicBlockOptionsSchema = scriptOptionsSchema
|
||||
.or(redirectOptionsSchema)
|
||||
.or(setVariableOptionsSchema)
|
||||
.or(typebotLinkOptionsSchema)
|
||||
.or(waitOptionsSchema)
|
||||
.or(jumpOptionsSchema)
|
||||
|
||||
export const logicBlockSchema = scriptBlockSchema
|
||||
.or(conditionBlockSchema)
|
||||
.or(redirectBlockSchema)
|
||||
.or(typebotLinkBlockSchema)
|
||||
.or(setVariableBlockSchema)
|
||||
.or(waitBlockSchema)
|
||||
.or(jumpBlockSchema)
|
||||
|
||||
export type LogicBlock = z.infer<typeof logicBlockSchema>
|
||||
export type LogicBlockOptions = z.infer<typeof logicBlockOptionsSchema>
|
@ -7,7 +7,7 @@ export const redirectOptionsSchema = z.object({
|
||||
isNewTab: z.boolean(),
|
||||
})
|
||||
|
||||
export const redirectBlockSchema = blockBaseSchema.and(
|
||||
export const redirectBlockSchema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([LogicBlockType.REDIRECT]),
|
||||
options: redirectOptionsSchema,
|
||||
|
@ -8,7 +8,7 @@ export const scriptOptionsSchema = z.object({
|
||||
shouldExecuteInParentContext: z.boolean().optional(),
|
||||
})
|
||||
|
||||
export const scriptBlockSchema = blockBaseSchema.and(
|
||||
export const scriptBlockSchema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([LogicBlockType.SCRIPT]),
|
||||
options: scriptOptionsSchema,
|
||||
|
@ -8,7 +8,7 @@ export const setVariableOptionsSchema = z.object({
|
||||
isCode: z.boolean().optional(),
|
||||
})
|
||||
|
||||
export const setVariableBlockSchema = blockBaseSchema.and(
|
||||
export const setVariableBlockSchema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([LogicBlockType.SET_VARIABLE]),
|
||||
options: setVariableOptionsSchema,
|
||||
|
@ -7,7 +7,7 @@ export const typebotLinkOptionsSchema = z.object({
|
||||
groupId: z.string().optional(),
|
||||
})
|
||||
|
||||
export const typebotLinkBlockSchema = blockBaseSchema.and(
|
||||
export const typebotLinkBlockSchema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([LogicBlockType.TYPEBOT_LINK]),
|
||||
options: typebotLinkOptionsSchema,
|
||||
|
@ -6,7 +6,7 @@ export const waitOptionsSchema = z.object({
|
||||
secondsToWaitFor: z.string().optional(),
|
||||
})
|
||||
|
||||
export const waitBlockSchema = blockBaseSchema.and(
|
||||
export const waitBlockSchema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([LogicBlockType.WAIT]),
|
||||
options: waitOptionsSchema,
|
||||
|
Reference in New Issue
Block a user