refactor: ♻️ Rename step to block
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
import { Block, Edge, Settings, Theme, Variable } from './typebot'
|
||||
import { Group, Edge, Settings, Theme, Variable } from './typebot'
|
||||
import { PublicTypebot as PublicTypebotFromPrisma } from 'db'
|
||||
|
||||
export type PublicTypebot = Omit<
|
||||
PublicTypebotFromPrisma,
|
||||
| 'blocks'
|
||||
| 'groups'
|
||||
| 'theme'
|
||||
| 'settings'
|
||||
| 'variables'
|
||||
@ -11,7 +11,7 @@ export type PublicTypebot = Omit<
|
||||
| 'createdAt'
|
||||
| 'updatedAt'
|
||||
> & {
|
||||
blocks: Block[]
|
||||
groups: Group[]
|
||||
variables: Variable[]
|
||||
edges: Edge[]
|
||||
theme: Theme
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Result as ResultFromPrisma } from 'db'
|
||||
import { Answer, VariableWithValue } from '.'
|
||||
import { InputStepType } from './typebot/steps/shared'
|
||||
import { InputBlockType } from './typebot/blocks/shared'
|
||||
|
||||
export type Result = Omit<ResultFromPrisma, 'createdAt' | 'variables'> & {
|
||||
createdAt: string
|
||||
@ -16,8 +16,8 @@ export type ResultValues = Pick<
|
||||
|
||||
export type ResultHeaderCell = {
|
||||
label: string
|
||||
stepId?: string
|
||||
stepType?: InputStepType
|
||||
blockId?: string
|
||||
blockType?: InputBlockType
|
||||
isLong?: boolean
|
||||
variableId?: string
|
||||
}
|
||||
|
78
packages/models/src/typebot/blocks/blocks.ts
Normal file
78
packages/models/src/typebot/blocks/blocks.ts
Normal file
@ -0,0 +1,78 @@
|
||||
import {
|
||||
InputBlockOptions,
|
||||
IntegrationBlockOptions,
|
||||
Item,
|
||||
LogicBlockOptions,
|
||||
} from '.'
|
||||
import { BubbleBlock, bubbleBlockSchema } from './bubble'
|
||||
import { InputBlock, inputBlockSchema } from './input'
|
||||
import { IntegrationBlock, integrationBlockSchema } from './integration'
|
||||
import { ConditionBlock, LogicBlock, logicBlockSchema } from './logic'
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
BubbleBlockType,
|
||||
InputBlockType,
|
||||
IntegrationBlockType,
|
||||
LogicBlockType,
|
||||
blockBaseSchema,
|
||||
} from './shared'
|
||||
|
||||
export type DraggableBlock =
|
||||
| BubbleBlock
|
||||
| InputBlock
|
||||
| LogicBlock
|
||||
| IntegrationBlock
|
||||
|
||||
export type BlockType =
|
||||
| 'start'
|
||||
| BubbleBlockType
|
||||
| InputBlockType
|
||||
| LogicBlockType
|
||||
| IntegrationBlockType
|
||||
|
||||
export type DraggableBlockType =
|
||||
| BubbleBlockType
|
||||
| InputBlockType
|
||||
| LogicBlockType
|
||||
| IntegrationBlockType
|
||||
|
||||
export type BlockWithOptions =
|
||||
| InputBlock
|
||||
| Exclude<LogicBlock, ConditionBlock>
|
||||
| IntegrationBlock
|
||||
|
||||
export type BlockWithOptionsType =
|
||||
| InputBlockType
|
||||
| Exclude<LogicBlockType, LogicBlockType.CONDITION>
|
||||
| IntegrationBlockType
|
||||
|
||||
export type BlockOptions =
|
||||
| InputBlockOptions
|
||||
| LogicBlockOptions
|
||||
| IntegrationBlockOptions
|
||||
|
||||
export type BlockWithItems = Omit<Block, 'items'> & { items: Item[] }
|
||||
|
||||
export type BlockBase = z.infer<typeof blockBaseSchema>
|
||||
|
||||
const startBlockSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.literal('start'),
|
||||
label: z.string(),
|
||||
})
|
||||
)
|
||||
|
||||
export type StartBlock = z.infer<typeof startBlockSchema>
|
||||
|
||||
export type BlockIndices = {
|
||||
groupIndex: number
|
||||
blockIndex: number
|
||||
}
|
||||
|
||||
export const blockSchema = startBlockSchema
|
||||
.or(bubbleBlockSchema)
|
||||
.or(inputBlockSchema)
|
||||
.or(logicBlockSchema)
|
||||
.or(integrationBlockSchema)
|
||||
|
||||
export type Block = z.infer<typeof blockSchema>
|
18
packages/models/src/typebot/blocks/bubble/bubble.ts
Normal file
18
packages/models/src/typebot/blocks/bubble/bubble.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { z } from 'zod'
|
||||
import { embedBubbleContentSchema, embedBubbleBlockSchema } from './embed'
|
||||
import { imageBubbleContentSchema, imageBubbleBlockSchema } from './image'
|
||||
import { textBubbleContentSchema, textBubbleBlockSchema } from './text'
|
||||
import { videoBubbleContentSchema, videoBubbleBlockSchema } from './video'
|
||||
|
||||
export const bubbleBlockContentSchema = textBubbleContentSchema
|
||||
.or(imageBubbleContentSchema)
|
||||
.or(videoBubbleContentSchema)
|
||||
.or(embedBubbleContentSchema)
|
||||
|
||||
export const bubbleBlockSchema = textBubbleBlockSchema
|
||||
.or(imageBubbleBlockSchema)
|
||||
.or(videoBubbleBlockSchema)
|
||||
.or(embedBubbleBlockSchema)
|
||||
|
||||
export type BubbleBlock = z.infer<typeof bubbleBlockSchema>
|
||||
export type BubbleBlockContent = z.infer<typeof bubbleBlockContentSchema>
|
@ -1,4 +1,4 @@
|
||||
import { stepBaseSchema, BubbleStepType } from '../shared'
|
||||
import { blockBaseSchema, BubbleBlockType } from '../shared'
|
||||
import { z } from 'zod'
|
||||
|
||||
export const embedBubbleContentSchema = z.object({
|
||||
@ -6,14 +6,14 @@ export const embedBubbleContentSchema = z.object({
|
||||
height: z.number(),
|
||||
})
|
||||
|
||||
export const embedBubbleStepSchema = stepBaseSchema.and(
|
||||
export const embedBubbleBlockSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([BubbleStepType.EMBED]),
|
||||
type: z.enum([BubbleBlockType.EMBED]),
|
||||
content: embedBubbleContentSchema,
|
||||
})
|
||||
)
|
||||
|
||||
export const defaultEmbedBubbleContent: EmbedBubbleContent = { height: 400 }
|
||||
|
||||
export type EmbedBubbleStep = z.infer<typeof embedBubbleStepSchema>
|
||||
export type EmbedBubbleBlock = z.infer<typeof embedBubbleBlockSchema>
|
||||
export type EmbedBubbleContent = z.infer<typeof embedBubbleContentSchema>
|
@ -1,18 +1,18 @@
|
||||
import { z } from 'zod'
|
||||
import { stepBaseSchema, BubbleStepType } from '../shared'
|
||||
import { blockBaseSchema, BubbleBlockType } from '../shared'
|
||||
|
||||
export const imageBubbleContentSchema = z.object({
|
||||
url: z.string().optional(),
|
||||
})
|
||||
|
||||
export const imageBubbleStepSchema = stepBaseSchema.and(
|
||||
export const imageBubbleBlockSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([BubbleStepType.IMAGE]),
|
||||
type: z.enum([BubbleBlockType.IMAGE]),
|
||||
content: imageBubbleContentSchema,
|
||||
})
|
||||
)
|
||||
|
||||
export const defaultImageBubbleContent: ImageBubbleContent = {}
|
||||
|
||||
export type ImageBubbleStep = z.infer<typeof imageBubbleStepSchema>
|
||||
export type ImageBubbleBlock = z.infer<typeof imageBubbleBlockSchema>
|
||||
export type ImageBubbleContent = z.infer<typeof imageBubbleContentSchema>
|
@ -1,4 +1,4 @@
|
||||
import { stepBaseSchema, BubbleStepType } from '../shared'
|
||||
import { blockBaseSchema, BubbleBlockType } from '../shared'
|
||||
import { z } from 'zod'
|
||||
|
||||
export const defaultTextBubbleContent: TextBubbleContent = {
|
||||
@ -15,11 +15,11 @@ export const textBubbleContentSchema = z.object({
|
||||
|
||||
export type TextBubbleContent = z.infer<typeof textBubbleContentSchema>
|
||||
|
||||
export const textBubbleStepSchema = stepBaseSchema.and(
|
||||
export const textBubbleBlockSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([BubbleStepType.TEXT]),
|
||||
type: z.enum([BubbleBlockType.TEXT]),
|
||||
content: textBubbleContentSchema,
|
||||
})
|
||||
)
|
||||
|
||||
export type TextBubbleStep = z.infer<typeof textBubbleStepSchema>
|
||||
export type TextBubbleBlock = z.infer<typeof textBubbleBlockSchema>
|
@ -1,4 +1,4 @@
|
||||
import { stepBaseSchema, BubbleStepType } from '../shared'
|
||||
import { blockBaseSchema, BubbleBlockType } from '../shared'
|
||||
import { z } from 'zod'
|
||||
|
||||
export enum VideoBubbleContentType {
|
||||
@ -13,14 +13,14 @@ export const videoBubbleContentSchema = z.object({
|
||||
type: z.nativeEnum(VideoBubbleContentType).optional(),
|
||||
})
|
||||
|
||||
export const videoBubbleStepSchema = stepBaseSchema.and(
|
||||
export const videoBubbleBlockSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([BubbleStepType.VIDEO]),
|
||||
type: z.enum([BubbleBlockType.VIDEO]),
|
||||
content: videoBubbleContentSchema,
|
||||
})
|
||||
)
|
||||
|
||||
export const defaultVideoBubbleContent: VideoBubbleContent = {}
|
||||
|
||||
export type VideoBubbleStep = z.infer<typeof videoBubbleStepSchema>
|
||||
export type VideoBubbleBlock = z.infer<typeof videoBubbleBlockSchema>
|
||||
export type VideoBubbleContent = z.infer<typeof videoBubbleContentSchema>
|
@ -1,4 +1,4 @@
|
||||
export * from './steps'
|
||||
export * from './blocks'
|
||||
export * from './bubble'
|
||||
export * from './input'
|
||||
export * from './logic'
|
@ -1,7 +1,7 @@
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
stepBaseSchema,
|
||||
InputStepType,
|
||||
blockBaseSchema,
|
||||
InputBlockType,
|
||||
defaultButtonLabel,
|
||||
optionBaseSchema,
|
||||
itemBaseSchema,
|
||||
@ -20,9 +20,9 @@ export const defaultChoiceInputOptions: ChoiceInputOptions = {
|
||||
isMultipleChoice: false,
|
||||
}
|
||||
|
||||
export const choiceInputSchema = stepBaseSchema.and(
|
||||
export const choiceInputSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([InputStepType.CHOICE]),
|
||||
type: z.enum([InputBlockType.CHOICE]),
|
||||
items: z.array(z.any()),
|
||||
options: choiceInputOptionsSchema,
|
||||
})
|
||||
@ -36,5 +36,5 @@ export const buttonItemSchema = itemBaseSchema.and(
|
||||
)
|
||||
|
||||
export type ButtonItem = z.infer<typeof buttonItemSchema>
|
||||
export type ChoiceInputStep = z.infer<typeof choiceInputSchema>
|
||||
export type ChoiceInputBlock = z.infer<typeof choiceInputSchema>
|
||||
export type ChoiceInputOptions = z.infer<typeof choiceInputOptionsSchema>
|
@ -1,7 +1,7 @@
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
stepBaseSchema,
|
||||
InputStepType,
|
||||
blockBaseSchema,
|
||||
InputBlockType,
|
||||
defaultButtonLabel,
|
||||
optionBaseSchema,
|
||||
} from '../shared'
|
||||
@ -18,9 +18,9 @@ export const dateInputOptionsSchema = optionBaseSchema.and(
|
||||
})
|
||||
)
|
||||
|
||||
export const dateInputSchema = stepBaseSchema.and(
|
||||
export const dateInputSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([InputStepType.DATE]),
|
||||
type: z.enum([InputBlockType.DATE]),
|
||||
options: dateInputOptionsSchema,
|
||||
})
|
||||
)
|
||||
@ -31,5 +31,5 @@ export const defaultDateInputOptions: DateInputOptions = {
|
||||
labels: { button: defaultButtonLabel, from: 'From:', to: 'To:' },
|
||||
}
|
||||
|
||||
export type DateInputStep = z.infer<typeof dateInputSchema>
|
||||
export type DateInputBlock = z.infer<typeof dateInputSchema>
|
||||
export type DateInputOptions = z.infer<typeof dateInputOptionsSchema>
|
@ -1,9 +1,9 @@
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
defaultButtonLabel,
|
||||
InputStepType,
|
||||
InputBlockType,
|
||||
optionBaseSchema,
|
||||
stepBaseSchema,
|
||||
blockBaseSchema,
|
||||
} from '../shared'
|
||||
import { textInputOptionsBaseSchema } from './text'
|
||||
|
||||
@ -15,9 +15,9 @@ export const emailInputOptionsSchema = optionBaseSchema
|
||||
})
|
||||
)
|
||||
|
||||
export const emailInputSchema = stepBaseSchema.and(
|
||||
export const emailInputSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([InputStepType.EMAIL]),
|
||||
type: z.enum([InputBlockType.EMAIL]),
|
||||
options: emailInputOptionsSchema,
|
||||
})
|
||||
)
|
||||
@ -31,5 +31,5 @@ export const defaultEmailInputOptions: EmailInputOptions = {
|
||||
"This email doesn't seem to be valid. Can you type it again?",
|
||||
}
|
||||
|
||||
export type EmailInputStep = z.infer<typeof emailInputSchema>
|
||||
export type EmailInputBlock = z.infer<typeof emailInputSchema>
|
||||
export type EmailInputOptions = z.infer<typeof emailInputOptionsSchema>
|
@ -7,15 +7,15 @@ import { numberInputOptionsSchema, numberInputSchema } from './number'
|
||||
import { paymentInputOptionsSchema, paymentInputSchema } from './payment'
|
||||
import {
|
||||
phoneNumberInputOptionsSchema,
|
||||
phoneNumberInputStepSchema,
|
||||
phoneNumberInputBlockSchema,
|
||||
} from './phone'
|
||||
import { ratingInputOptionsSchema, ratingInputStepSchema } from './rating'
|
||||
import { ratingInputOptionsSchema, ratingInputBlockSchema } from './rating'
|
||||
import { textInputOptionsSchema, textInputSchema } from './text'
|
||||
import { urlInputOptionsSchema, urlInputSchema } from './url'
|
||||
|
||||
export type OptionBase = z.infer<typeof optionBaseSchema>
|
||||
|
||||
export const inputStepOptionsSchema = textInputOptionsSchema
|
||||
export const inputBlockOptionsSchema = textInputOptionsSchema
|
||||
.or(choiceInputOptionsSchema)
|
||||
.or(emailInputOptionsSchema)
|
||||
.or(numberInputOptionsSchema)
|
||||
@ -25,15 +25,15 @@ export const inputStepOptionsSchema = textInputOptionsSchema
|
||||
.or(paymentInputOptionsSchema)
|
||||
.or(ratingInputOptionsSchema)
|
||||
|
||||
export const inputStepSchema = textInputSchema
|
||||
export const inputBlockSchema = textInputSchema
|
||||
.or(numberInputSchema)
|
||||
.or(emailInputSchema)
|
||||
.or(urlInputSchema)
|
||||
.or(dateInputSchema)
|
||||
.or(phoneNumberInputStepSchema)
|
||||
.or(phoneNumberInputBlockSchema)
|
||||
.or(choiceInputSchema)
|
||||
.or(paymentInputSchema)
|
||||
.or(ratingInputStepSchema)
|
||||
.or(ratingInputBlockSchema)
|
||||
|
||||
export type InputStep = z.infer<typeof inputStepSchema>
|
||||
export type InputStepOptions = z.infer<typeof inputStepOptionsSchema>
|
||||
export type InputBlock = z.infer<typeof inputBlockSchema>
|
||||
export type InputBlockOptions = z.infer<typeof inputBlockOptionsSchema>
|
@ -1,9 +1,9 @@
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
defaultButtonLabel,
|
||||
InputStepType,
|
||||
InputBlockType,
|
||||
optionBaseSchema,
|
||||
stepBaseSchema,
|
||||
blockBaseSchema,
|
||||
} from '../shared'
|
||||
import { textInputOptionsBaseSchema } from './text'
|
||||
|
||||
@ -17,9 +17,9 @@ export const numberInputOptionsSchema = optionBaseSchema
|
||||
})
|
||||
)
|
||||
|
||||
export const numberInputSchema = stepBaseSchema.and(
|
||||
export const numberInputSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([InputStepType.NUMBER]),
|
||||
type: z.enum([InputBlockType.NUMBER]),
|
||||
options: numberInputOptionsSchema,
|
||||
})
|
||||
)
|
||||
@ -28,5 +28,5 @@ export const defaultNumberInputOptions: NumberInputOptions = {
|
||||
labels: { button: defaultButtonLabel, placeholder: 'Type a number...' },
|
||||
}
|
||||
|
||||
export type NumberInputStep = z.infer<typeof numberInputSchema>
|
||||
export type NumberInputBlock = z.infer<typeof numberInputSchema>
|
||||
export type NumberInputOptions = z.infer<typeof numberInputOptionsSchema>
|
@ -1,5 +1,5 @@
|
||||
import { z } from 'zod'
|
||||
import { InputStepType, optionBaseSchema, stepBaseSchema } from '../shared'
|
||||
import { InputBlockType, optionBaseSchema, blockBaseSchema } from '../shared'
|
||||
|
||||
export type CreditCardDetails = {
|
||||
number: string
|
||||
@ -32,9 +32,9 @@ export const paymentInputOptionsSchema = optionBaseSchema.and(
|
||||
})
|
||||
)
|
||||
|
||||
export const paymentInputSchema = stepBaseSchema.and(
|
||||
export const paymentInputSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([InputStepType.PAYMENT]),
|
||||
type: z.enum([InputBlockType.PAYMENT]),
|
||||
options: paymentInputOptionsSchema,
|
||||
})
|
||||
)
|
||||
@ -45,5 +45,5 @@ export const defaultPaymentInputOptions: PaymentInputOptions = {
|
||||
currency: 'USD',
|
||||
}
|
||||
|
||||
export type PaymentInputStep = z.infer<typeof paymentInputSchema>
|
||||
export type PaymentInputBlock = z.infer<typeof paymentInputSchema>
|
||||
export type PaymentInputOptions = z.infer<typeof paymentInputOptionsSchema>
|
@ -1,9 +1,9 @@
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
defaultButtonLabel,
|
||||
InputStepType,
|
||||
InputBlockType,
|
||||
optionBaseSchema,
|
||||
stepBaseSchema,
|
||||
blockBaseSchema,
|
||||
} from '../shared'
|
||||
import { textInputOptionsBaseSchema } from './text'
|
||||
|
||||
@ -16,9 +16,9 @@ export const phoneNumberInputOptionsSchema = optionBaseSchema
|
||||
})
|
||||
)
|
||||
|
||||
export const phoneNumberInputStepSchema = stepBaseSchema.and(
|
||||
export const phoneNumberInputBlockSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([InputStepType.PHONE]),
|
||||
type: z.enum([InputBlockType.PHONE]),
|
||||
options: phoneNumberInputOptionsSchema,
|
||||
})
|
||||
)
|
||||
@ -32,7 +32,7 @@ export const defaultPhoneInputOptions: PhoneNumberInputOptions = {
|
||||
"This phone number doesn't seem to be valid. Can you type it again?",
|
||||
}
|
||||
|
||||
export type PhoneNumberInputStep = z.infer<typeof phoneNumberInputStepSchema>
|
||||
export type PhoneNumberInputBlock = z.infer<typeof phoneNumberInputBlockSchema>
|
||||
export type PhoneNumberInputOptions = z.infer<
|
||||
typeof phoneNumberInputOptionsSchema
|
||||
>
|
@ -1,9 +1,9 @@
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
defaultButtonLabel,
|
||||
InputStepType,
|
||||
InputBlockType,
|
||||
optionBaseSchema,
|
||||
stepBaseSchema,
|
||||
blockBaseSchema,
|
||||
} from '../shared'
|
||||
|
||||
export const defaultRatingInputOptions: RatingInputOptions = {
|
||||
@ -30,12 +30,12 @@ export const ratingInputOptionsSchema = optionBaseSchema.and(
|
||||
})
|
||||
)
|
||||
|
||||
export const ratingInputStepSchema = stepBaseSchema.and(
|
||||
export const ratingInputBlockSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.literal(InputStepType.RATING),
|
||||
type: z.literal(InputBlockType.RATING),
|
||||
options: ratingInputOptionsSchema,
|
||||
})
|
||||
)
|
||||
|
||||
export type RatingInputStep = z.infer<typeof ratingInputStepSchema>
|
||||
export type RatingInputBlock = z.infer<typeof ratingInputBlockSchema>
|
||||
export type RatingInputOptions = z.infer<typeof ratingInputOptionsSchema>
|
@ -1,9 +1,9 @@
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
defaultButtonLabel,
|
||||
InputStepType,
|
||||
InputBlockType,
|
||||
optionBaseSchema,
|
||||
stepBaseSchema,
|
||||
blockBaseSchema,
|
||||
} from '../shared'
|
||||
|
||||
export const textInputOptionsBaseSchema = z.object({
|
||||
@ -26,12 +26,12 @@ export const defaultTextInputOptions: TextInputOptions = {
|
||||
labels: { button: defaultButtonLabel, placeholder: 'Type your answer...' },
|
||||
}
|
||||
|
||||
export const textInputSchema = stepBaseSchema.and(
|
||||
export const textInputSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([InputStepType.TEXT]),
|
||||
type: z.enum([InputBlockType.TEXT]),
|
||||
options: textInputOptionsSchema,
|
||||
})
|
||||
)
|
||||
|
||||
export type TextInputStep = z.infer<typeof textInputSchema>
|
||||
export type TextInputBlock = z.infer<typeof textInputSchema>
|
||||
export type TextInputOptions = z.infer<typeof textInputOptionsSchema>
|
@ -1,9 +1,9 @@
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
defaultButtonLabel,
|
||||
InputStepType,
|
||||
InputBlockType,
|
||||
optionBaseSchema,
|
||||
stepBaseSchema,
|
||||
blockBaseSchema,
|
||||
} from '../shared'
|
||||
import { textInputOptionsBaseSchema } from './text'
|
||||
|
||||
@ -15,9 +15,9 @@ export const urlInputOptionsSchema = optionBaseSchema
|
||||
})
|
||||
)
|
||||
|
||||
export const urlInputSchema = stepBaseSchema.and(
|
||||
export const urlInputSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([InputStepType.URL]),
|
||||
type: z.enum([InputBlockType.URL]),
|
||||
options: urlInputOptionsSchema,
|
||||
})
|
||||
)
|
||||
@ -31,5 +31,5 @@ export const defaultUrlInputOptions: UrlInputOptions = {
|
||||
"This URL doesn't seem to be valid. Can you type it again?",
|
||||
}
|
||||
|
||||
export type UrlInputStep = z.infer<typeof urlInputSchema>
|
||||
export type UrlInputBlock = z.infer<typeof urlInputSchema>
|
||||
export type UrlInputOptions = z.infer<typeof urlInputOptionsSchema>
|
@ -1,5 +1,5 @@
|
||||
import { z } from 'zod'
|
||||
import { IntegrationStepType, stepBaseSchema } from '../shared'
|
||||
import { IntegrationBlockType, blockBaseSchema } from '../shared'
|
||||
|
||||
export const googleAnalyticsOptionsSchema = z.object({
|
||||
trackingId: z.string().optional(),
|
||||
@ -9,16 +9,16 @@ export const googleAnalyticsOptionsSchema = z.object({
|
||||
value: z.number().optional(),
|
||||
})
|
||||
|
||||
export const googleAnalyticsStepSchema = stepBaseSchema.and(
|
||||
export const googleAnalyticsBlockSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([IntegrationStepType.GOOGLE_ANALYTICS]),
|
||||
type: z.enum([IntegrationBlockType.GOOGLE_ANALYTICS]),
|
||||
options: googleAnalyticsOptionsSchema,
|
||||
})
|
||||
)
|
||||
|
||||
export const defaultGoogleAnalyticsOptions: GoogleAnalyticsOptions = {}
|
||||
|
||||
export type GoogleAnalyticsStep = z.infer<typeof googleAnalyticsStepSchema>
|
||||
export type GoogleAnalyticsBlock = z.infer<typeof googleAnalyticsBlockSchema>
|
||||
export type GoogleAnalyticsOptions = z.infer<
|
||||
typeof googleAnalyticsOptionsSchema
|
||||
>
|
@ -1,5 +1,5 @@
|
||||
import { z } from 'zod'
|
||||
import { IntegrationStepType, stepBaseSchema } from '../shared'
|
||||
import { IntegrationBlockType, blockBaseSchema } from '../shared'
|
||||
|
||||
export enum GoogleSheetsAction {
|
||||
GET = 'Get data from sheet',
|
||||
@ -53,16 +53,16 @@ export const googleSheetsOptionsSchema = googleSheetsOptionsBaseSchema
|
||||
.or(googleSheetsInsertRowOptionsSchema)
|
||||
.or(googleSheetsUpdateRowOptionsSchema)
|
||||
|
||||
export const googleSheetsStepSchema = stepBaseSchema.and(
|
||||
export const googleSheetsBlockSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([IntegrationStepType.GOOGLE_SHEETS]),
|
||||
type: z.enum([IntegrationBlockType.GOOGLE_SHEETS]),
|
||||
options: googleSheetsOptionsSchema,
|
||||
})
|
||||
)
|
||||
|
||||
export const defaultGoogleSheetsOptions: GoogleSheetsOptions = {}
|
||||
|
||||
export type GoogleSheetsStep = z.infer<typeof googleSheetsStepSchema>
|
||||
export type GoogleSheetsBlock = z.infer<typeof googleSheetsBlockSchema>
|
||||
export type GoogleSheetsOptions = z.infer<typeof googleSheetsOptionsSchema>
|
||||
export type GoogleSheetsOptionsBase = z.infer<
|
||||
typeof googleSheetsOptionsBaseSchema
|
@ -0,0 +1,32 @@
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
googleAnalyticsOptionsSchema,
|
||||
googleAnalyticsBlockSchema,
|
||||
} from './googleAnalytics'
|
||||
import {
|
||||
googleSheetsOptionsSchema,
|
||||
googleSheetsBlockSchema,
|
||||
} from './googleSheets'
|
||||
import { makeComBlockSchema } from './makeCom'
|
||||
import { pabblyConnectBlockSchema } from './pabblyConnect'
|
||||
import { sendEmailOptionsSchema, sendEmailBlockSchema } from './sendEmail'
|
||||
import { webhookOptionsSchema, webhookBlockSchema } from './webhook'
|
||||
import { zapierBlockSchema } from './zapier'
|
||||
|
||||
const integrationBlockOptionsSchema = googleSheetsOptionsSchema
|
||||
.or(googleAnalyticsOptionsSchema)
|
||||
.or(webhookOptionsSchema)
|
||||
.or(sendEmailOptionsSchema)
|
||||
|
||||
export const integrationBlockSchema = googleSheetsBlockSchema
|
||||
.or(googleAnalyticsBlockSchema)
|
||||
.or(webhookBlockSchema)
|
||||
.or(sendEmailBlockSchema)
|
||||
.or(zapierBlockSchema)
|
||||
.or(makeComBlockSchema)
|
||||
.or(pabblyConnectBlockSchema)
|
||||
|
||||
export type IntegrationBlock = z.infer<typeof integrationBlockSchema>
|
||||
export type IntegrationBlockOptions = z.infer<
|
||||
typeof integrationBlockOptionsSchema
|
||||
>
|
13
packages/models/src/typebot/blocks/integration/makeCom.ts
Normal file
13
packages/models/src/typebot/blocks/integration/makeCom.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { z } from 'zod'
|
||||
import { IntegrationBlockType, blockBaseSchema } from '../shared'
|
||||
import { webhookOptionsSchema } from './webhook'
|
||||
|
||||
export const makeComBlockSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([IntegrationBlockType.MAKE_COM]),
|
||||
options: webhookOptionsSchema,
|
||||
webhookId: z.string(),
|
||||
})
|
||||
)
|
||||
|
||||
export type MakeComBlock = z.infer<typeof makeComBlockSchema>
|
@ -0,0 +1,13 @@
|
||||
import { z } from 'zod'
|
||||
import { IntegrationBlockType, blockBaseSchema } from '../shared'
|
||||
import { webhookOptionsSchema } from './webhook'
|
||||
|
||||
export const pabblyConnectBlockSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([IntegrationBlockType.PABBLY_CONNECT]),
|
||||
options: webhookOptionsSchema,
|
||||
webhookId: z.string(),
|
||||
})
|
||||
)
|
||||
|
||||
export type PabblyConnectBlock = z.infer<typeof pabblyConnectBlockSchema>
|
@ -1,5 +1,5 @@
|
||||
import { z } from 'zod'
|
||||
import { IntegrationStepType, stepBaseSchema } from '../shared'
|
||||
import { IntegrationBlockType, blockBaseSchema } from '../shared'
|
||||
|
||||
export const sendEmailOptionsSchema = z.object({
|
||||
credentialsId: z.string(),
|
||||
@ -11,9 +11,9 @@ export const sendEmailOptionsSchema = z.object({
|
||||
bcc: z.array(z.string()).optional(),
|
||||
})
|
||||
|
||||
export const sendEmailStepSchema = stepBaseSchema.and(
|
||||
export const sendEmailBlockSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([IntegrationStepType.EMAIL]),
|
||||
type: z.enum([IntegrationBlockType.EMAIL]),
|
||||
options: sendEmailOptionsSchema,
|
||||
})
|
||||
)
|
||||
@ -23,5 +23,5 @@ export const defaultSendEmailOptions: SendEmailOptions = {
|
||||
recipients: [],
|
||||
}
|
||||
|
||||
export type SendEmailStep = z.infer<typeof sendEmailStepSchema>
|
||||
export type SendEmailBlock = z.infer<typeof sendEmailBlockSchema>
|
||||
export type SendEmailOptions = z.infer<typeof sendEmailOptionsSchema>
|
@ -1,5 +1,5 @@
|
||||
import { z } from 'zod'
|
||||
import { IntegrationStepType, stepBaseSchema } from '../shared'
|
||||
import { IntegrationBlockType, blockBaseSchema } from '../shared'
|
||||
|
||||
const variableForTestSchema = z.object({
|
||||
id: z.string(),
|
||||
@ -20,9 +20,9 @@ export const webhookOptionsSchema = z.object({
|
||||
isCustomBody: z.boolean().optional(),
|
||||
})
|
||||
|
||||
export const webhookStepSchema = stepBaseSchema.and(
|
||||
export const webhookBlockSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([IntegrationStepType.WEBHOOK]),
|
||||
type: z.enum([IntegrationBlockType.WEBHOOK]),
|
||||
options: webhookOptionsSchema,
|
||||
webhookId: z.string(),
|
||||
})
|
||||
@ -35,7 +35,7 @@ export const defaultWebhookOptions: Omit<WebhookOptions, 'webhookId'> = {
|
||||
isCustomBody: false,
|
||||
}
|
||||
|
||||
export type WebhookStep = z.infer<typeof webhookStepSchema>
|
||||
export type WebhookBlock = z.infer<typeof webhookBlockSchema>
|
||||
export type WebhookOptions = z.infer<typeof webhookOptionsSchema>
|
||||
export type ResponseVariableMapping = z.infer<
|
||||
typeof responseVariableMappingSchema
|
13
packages/models/src/typebot/blocks/integration/zapier.ts
Normal file
13
packages/models/src/typebot/blocks/integration/zapier.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { z } from 'zod'
|
||||
import { IntegrationBlockType, blockBaseSchema } from '../shared'
|
||||
import { webhookOptionsSchema } from './webhook'
|
||||
|
||||
export const zapierBlockSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([IntegrationBlockType.ZAPIER]),
|
||||
options: webhookOptionsSchema,
|
||||
webhookId: z.string(),
|
||||
})
|
||||
)
|
||||
|
||||
export type ZapierBlock = z.infer<typeof zapierBlockSchema>
|
@ -5,7 +5,7 @@ import { conditionItemSchema } from './logic'
|
||||
|
||||
export type ItemIndices = {
|
||||
blockIndex: number
|
||||
stepIndex: number
|
||||
groupIndex: number
|
||||
itemIndex: number
|
||||
}
|
||||
const itemScema = buttonItemSchema.or(conditionItemSchema)
|
@ -1,19 +1,19 @@
|
||||
import { z } from 'zod'
|
||||
import { LogicStepType, stepBaseSchema } from '../shared'
|
||||
import { LogicBlockType, blockBaseSchema } from '../shared'
|
||||
|
||||
export const codeOptionsSchema = z.object({
|
||||
name: z.string(),
|
||||
content: z.string().optional(),
|
||||
})
|
||||
|
||||
export const codeStepSchema = stepBaseSchema.and(
|
||||
export const codeBlockSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([LogicStepType.CODE]),
|
||||
type: z.enum([LogicBlockType.CODE]),
|
||||
options: codeOptionsSchema,
|
||||
})
|
||||
)
|
||||
|
||||
export const defaultCodeOptions: CodeOptions = { name: 'Code snippet' }
|
||||
|
||||
export type CodeStep = z.infer<typeof codeStepSchema>
|
||||
export type CodeBlock = z.infer<typeof codeBlockSchema>
|
||||
export type CodeOptions = z.infer<typeof codeOptionsSchema>
|
@ -2,8 +2,8 @@ import { z } from 'zod'
|
||||
import {
|
||||
itemBaseSchema,
|
||||
ItemType,
|
||||
LogicStepType,
|
||||
stepBaseSchema,
|
||||
LogicBlockType,
|
||||
blockBaseSchema,
|
||||
} from '../shared'
|
||||
|
||||
export enum LogicalOperator {
|
||||
@ -39,9 +39,9 @@ export const conditionItemSchema = itemBaseSchema.and(
|
||||
})
|
||||
)
|
||||
|
||||
export const conditionStepSchema = stepBaseSchema.and(
|
||||
export const conditionBlockSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([LogicStepType.CONDITION]),
|
||||
type: z.enum([LogicBlockType.CONDITION]),
|
||||
items: z.array(conditionItemSchema),
|
||||
options: z.object({}),
|
||||
})
|
||||
@ -54,5 +54,5 @@ export const defaultConditionContent: ConditionContent = {
|
||||
|
||||
export type ConditionItem = z.infer<typeof conditionItemSchema>
|
||||
export type Comparison = z.infer<typeof comparisonSchema>
|
||||
export type ConditionStep = z.infer<typeof conditionStepSchema>
|
||||
export type ConditionBlock = z.infer<typeof conditionBlockSchema>
|
||||
export type ConditionContent = z.infer<typeof conditionContentSchema>
|
20
packages/models/src/typebot/blocks/logic/logic.ts
Normal file
20
packages/models/src/typebot/blocks/logic/logic.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { z } from 'zod'
|
||||
import { codeOptionsSchema, codeBlockSchema } from './code'
|
||||
import { conditionBlockSchema } from './condition'
|
||||
import { redirectOptionsSchema, redirectBlockSchema } from './redirect'
|
||||
import { setVariableOptionsSchema, setVariableBlockSchema } from './setVariable'
|
||||
import { typebotLinkOptionsSchema, typebotLinkBlockSchema } from './typebotLink'
|
||||
|
||||
const logicBlockOptionsSchema = codeOptionsSchema
|
||||
.or(redirectOptionsSchema)
|
||||
.or(setVariableOptionsSchema)
|
||||
.or(typebotLinkOptionsSchema)
|
||||
|
||||
export const logicBlockSchema = codeBlockSchema
|
||||
.or(conditionBlockSchema)
|
||||
.or(redirectBlockSchema)
|
||||
.or(typebotLinkBlockSchema)
|
||||
.or(setVariableBlockSchema)
|
||||
|
||||
export type LogicBlock = z.infer<typeof logicBlockSchema>
|
||||
export type LogicBlockOptions = z.infer<typeof logicBlockOptionsSchema>
|
@ -1,19 +1,19 @@
|
||||
import { z } from 'zod'
|
||||
import { LogicStepType, stepBaseSchema } from '../shared'
|
||||
import { LogicBlockType, blockBaseSchema } from '../shared'
|
||||
|
||||
export const redirectOptionsSchema = z.object({
|
||||
url: z.string().optional(),
|
||||
isNewTab: z.boolean(),
|
||||
})
|
||||
|
||||
export const redirectStepSchema = stepBaseSchema.and(
|
||||
export const redirectBlockSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([LogicStepType.REDIRECT]),
|
||||
type: z.enum([LogicBlockType.REDIRECT]),
|
||||
options: redirectOptionsSchema,
|
||||
})
|
||||
)
|
||||
|
||||
export const defaultRedirectOptions: RedirectOptions = { isNewTab: false }
|
||||
|
||||
export type RedirectStep = z.infer<typeof redirectStepSchema>
|
||||
export type RedirectBlock = z.infer<typeof redirectBlockSchema>
|
||||
export type RedirectOptions = z.infer<typeof redirectOptionsSchema>
|
@ -1,5 +1,5 @@
|
||||
import { z } from 'zod'
|
||||
import { LogicStepType, stepBaseSchema } from '../shared'
|
||||
import { LogicBlockType, blockBaseSchema } from '../shared'
|
||||
|
||||
export const setVariableOptionsSchema = z.object({
|
||||
variableId: z.string().optional(),
|
||||
@ -7,14 +7,14 @@ export const setVariableOptionsSchema = z.object({
|
||||
isCode: z.boolean().optional(),
|
||||
})
|
||||
|
||||
export const setVariableStepSchema = stepBaseSchema.and(
|
||||
export const setVariableBlockSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([LogicStepType.SET_VARIABLE]),
|
||||
type: z.enum([LogicBlockType.SET_VARIABLE]),
|
||||
options: setVariableOptionsSchema,
|
||||
})
|
||||
)
|
||||
|
||||
export const defaultSetVariablesOptions: SetVariableOptions = {}
|
||||
|
||||
export type SetVariableStep = z.infer<typeof setVariableStepSchema>
|
||||
export type SetVariableBlock = z.infer<typeof setVariableBlockSchema>
|
||||
export type SetVariableOptions = z.infer<typeof setVariableOptionsSchema>
|
@ -1,19 +1,19 @@
|
||||
import { z } from 'zod'
|
||||
import { LogicStepType, stepBaseSchema } from '../shared'
|
||||
import { LogicBlockType, blockBaseSchema } from '../shared'
|
||||
|
||||
export const typebotLinkOptionsSchema = z.object({
|
||||
typebotId: z.string().optional(),
|
||||
blockId: z.string().optional(),
|
||||
groupId: z.string().optional(),
|
||||
})
|
||||
|
||||
export const typebotLinkStepSchema = stepBaseSchema.and(
|
||||
export const typebotLinkBlockSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([LogicStepType.TYPEBOT_LINK]),
|
||||
type: z.enum([LogicBlockType.TYPEBOT_LINK]),
|
||||
options: typebotLinkOptionsSchema,
|
||||
})
|
||||
)
|
||||
|
||||
export const defaultTypebotLinkOptions: TypebotLinkOptions = {}
|
||||
|
||||
export type TypebotLinkStep = z.infer<typeof typebotLinkStepSchema>
|
||||
export type TypebotLinkBlock = z.infer<typeof typebotLinkBlockSchema>
|
||||
export type TypebotLinkOptions = z.infer<typeof typebotLinkOptionsSchema>
|
@ -1,8 +1,8 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const stepBaseSchema = z.object({
|
||||
export const blockBaseSchema = z.object({
|
||||
id: z.string(),
|
||||
blockId: z.string(),
|
||||
groupId: z.string(),
|
||||
outgoingEdgeId: z.string().optional(),
|
||||
})
|
||||
|
||||
@ -14,7 +14,7 @@ export const optionBaseSchema = z.object({
|
||||
|
||||
export const itemBaseSchema = z.object({
|
||||
id: z.string(),
|
||||
stepId: z.string(),
|
||||
blockId: z.string(),
|
||||
outgoingEdgeId: z.string().optional(),
|
||||
})
|
||||
|
||||
@ -23,14 +23,14 @@ export enum ItemType {
|
||||
CONDITION,
|
||||
}
|
||||
|
||||
export enum BubbleStepType {
|
||||
export enum BubbleBlockType {
|
||||
TEXT = 'text',
|
||||
IMAGE = 'image',
|
||||
VIDEO = 'video',
|
||||
EMBED = 'embed',
|
||||
}
|
||||
|
||||
export enum InputStepType {
|
||||
export enum InputBlockType {
|
||||
TEXT = 'text input',
|
||||
NUMBER = 'number input',
|
||||
EMAIL = 'email input',
|
||||
@ -42,7 +42,7 @@ export enum InputStepType {
|
||||
RATING = 'rating input',
|
||||
}
|
||||
|
||||
export enum LogicStepType {
|
||||
export enum LogicBlockType {
|
||||
SET_VARIABLE = 'Set variable',
|
||||
CONDITION = 'Condition',
|
||||
REDIRECT = 'Redirect',
|
||||
@ -50,7 +50,7 @@ export enum LogicStepType {
|
||||
TYPEBOT_LINK = 'Typebot link',
|
||||
}
|
||||
|
||||
export enum IntegrationStepType {
|
||||
export enum IntegrationBlockType {
|
||||
GOOGLE_SHEETS = 'Google Sheets',
|
||||
GOOGLE_ANALYTICS = 'Google Analytics',
|
||||
WEBHOOK = 'Webhook',
|
@ -1,5 +1,5 @@
|
||||
export * from './typebot'
|
||||
export * from './steps'
|
||||
export * from './blocks'
|
||||
export * from './theme'
|
||||
export * from './settings'
|
||||
export * from './variable'
|
||||
|
@ -1,18 +0,0 @@
|
||||
import { z } from 'zod'
|
||||
import { embedBubbleContentSchema, embedBubbleStepSchema } from './embed'
|
||||
import { imageBubbleContentSchema, imageBubbleStepSchema } from './image'
|
||||
import { textBubbleContentSchema, textBubbleStepSchema } from './text'
|
||||
import { videoBubbleContentSchema, videoBubbleStepSchema } from './video'
|
||||
|
||||
export const bubbleStepContentSchema = textBubbleContentSchema
|
||||
.or(imageBubbleContentSchema)
|
||||
.or(videoBubbleContentSchema)
|
||||
.or(embedBubbleContentSchema)
|
||||
|
||||
export const bubbleStepSchema = textBubbleStepSchema
|
||||
.or(imageBubbleStepSchema)
|
||||
.or(videoBubbleStepSchema)
|
||||
.or(embedBubbleStepSchema)
|
||||
|
||||
export type BubbleStep = z.infer<typeof bubbleStepSchema>
|
||||
export type BubbleStepContent = z.infer<typeof bubbleStepContentSchema>
|
@ -1,32 +0,0 @@
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
googleAnalyticsOptionsSchema,
|
||||
googleAnalyticsStepSchema,
|
||||
} from './googleAnalytics'
|
||||
import {
|
||||
googleSheetsOptionsSchema,
|
||||
googleSheetsStepSchema,
|
||||
} from './googleSheets'
|
||||
import { makeComStepSchema } from './makeCom'
|
||||
import { pabblyConnectStepSchema } from './pabblyConnect'
|
||||
import { sendEmailOptionsSchema, sendEmailStepSchema } from './sendEmail'
|
||||
import { webhookOptionsSchema, webhookStepSchema } from './webhook'
|
||||
import { zapierStepSchema } from './zapier'
|
||||
|
||||
const integrationStepOptionsSchema = googleSheetsOptionsSchema
|
||||
.or(googleAnalyticsOptionsSchema)
|
||||
.or(webhookOptionsSchema)
|
||||
.or(sendEmailOptionsSchema)
|
||||
|
||||
export const integrationStepSchema = googleSheetsStepSchema
|
||||
.or(googleAnalyticsStepSchema)
|
||||
.or(webhookStepSchema)
|
||||
.or(sendEmailStepSchema)
|
||||
.or(zapierStepSchema)
|
||||
.or(makeComStepSchema)
|
||||
.or(pabblyConnectStepSchema)
|
||||
|
||||
export type IntegrationStep = z.infer<typeof integrationStepSchema>
|
||||
export type IntegrationStepOptions = z.infer<
|
||||
typeof integrationStepOptionsSchema
|
||||
>
|
@ -1,13 +0,0 @@
|
||||
import { z } from 'zod'
|
||||
import { IntegrationStepType, stepBaseSchema } from '../shared'
|
||||
import { webhookOptionsSchema } from './webhook'
|
||||
|
||||
export const makeComStepSchema = stepBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([IntegrationStepType.MAKE_COM]),
|
||||
options: webhookOptionsSchema,
|
||||
webhookId: z.string(),
|
||||
})
|
||||
)
|
||||
|
||||
export type MakeComStep = z.infer<typeof makeComStepSchema>
|
@ -1,13 +0,0 @@
|
||||
import { z } from 'zod'
|
||||
import { IntegrationStepType, stepBaseSchema } from '../shared'
|
||||
import { webhookOptionsSchema } from './webhook'
|
||||
|
||||
export const pabblyConnectStepSchema = stepBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([IntegrationStepType.PABBLY_CONNECT]),
|
||||
options: webhookOptionsSchema,
|
||||
webhookId: z.string(),
|
||||
})
|
||||
)
|
||||
|
||||
export type PabblyConnectStep = z.infer<typeof pabblyConnectStepSchema>
|
@ -1,13 +0,0 @@
|
||||
import { z } from 'zod'
|
||||
import { IntegrationStepType, stepBaseSchema } from '../shared'
|
||||
import { webhookOptionsSchema } from './webhook'
|
||||
|
||||
export const zapierStepSchema = stepBaseSchema.and(
|
||||
z.object({
|
||||
type: z.enum([IntegrationStepType.ZAPIER]),
|
||||
options: webhookOptionsSchema,
|
||||
webhookId: z.string(),
|
||||
})
|
||||
)
|
||||
|
||||
export type ZapierStep = z.infer<typeof zapierStepSchema>
|
@ -1,20 +0,0 @@
|
||||
import { z } from 'zod'
|
||||
import { codeOptionsSchema, codeStepSchema } from './code'
|
||||
import { conditionStepSchema } from './condition'
|
||||
import { redirectOptionsSchema, redirectStepSchema } from './redirect'
|
||||
import { setVariableOptionsSchema, setVariableStepSchema } from './setVariable'
|
||||
import { typebotLinkOptionsSchema, typebotLinkStepSchema } from './typebotLink'
|
||||
|
||||
const logicStepOptionsSchema = codeOptionsSchema
|
||||
.or(redirectOptionsSchema)
|
||||
.or(setVariableOptionsSchema)
|
||||
.or(typebotLinkOptionsSchema)
|
||||
|
||||
export const logicStepSchema = codeStepSchema
|
||||
.or(conditionStepSchema)
|
||||
.or(redirectStepSchema)
|
||||
.or(typebotLinkStepSchema)
|
||||
.or(setVariableStepSchema)
|
||||
|
||||
export type LogicStep = z.infer<typeof logicStepSchema>
|
||||
export type LogicStepOptions = z.infer<typeof logicStepOptionsSchema>
|
@ -1,74 +0,0 @@
|
||||
import {
|
||||
InputStepOptions,
|
||||
IntegrationStepOptions,
|
||||
Item,
|
||||
LogicStepOptions,
|
||||
} from '.'
|
||||
import { BubbleStep, bubbleStepSchema } from './bubble'
|
||||
import { InputStep, inputStepSchema } from './input'
|
||||
import { IntegrationStep, integrationStepSchema } from './integration'
|
||||
import { ConditionStep, LogicStep, logicStepSchema } from './logic'
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
BubbleStepType,
|
||||
InputStepType,
|
||||
IntegrationStepType,
|
||||
LogicStepType,
|
||||
stepBaseSchema,
|
||||
} from './shared'
|
||||
|
||||
export type DraggableStep = BubbleStep | InputStep | LogicStep | IntegrationStep
|
||||
|
||||
export type StepType =
|
||||
| 'start'
|
||||
| BubbleStepType
|
||||
| InputStepType
|
||||
| LogicStepType
|
||||
| IntegrationStepType
|
||||
|
||||
export type DraggableStepType =
|
||||
| BubbleStepType
|
||||
| InputStepType
|
||||
| LogicStepType
|
||||
| IntegrationStepType
|
||||
|
||||
export type StepWithOptions =
|
||||
| InputStep
|
||||
| Exclude<LogicStep, ConditionStep>
|
||||
| IntegrationStep
|
||||
|
||||
export type StepWithOptionsType =
|
||||
| InputStepType
|
||||
| Exclude<LogicStepType, LogicStepType.CONDITION>
|
||||
| IntegrationStepType
|
||||
|
||||
export type StepOptions =
|
||||
| InputStepOptions
|
||||
| LogicStepOptions
|
||||
| IntegrationStepOptions
|
||||
|
||||
export type StepWithItems = Omit<Step, 'items'> & { items: Item[] }
|
||||
|
||||
export type StepBase = z.infer<typeof stepBaseSchema>
|
||||
|
||||
const startStepSchema = stepBaseSchema.and(
|
||||
z.object({
|
||||
type: z.literal('start'),
|
||||
label: z.string(),
|
||||
})
|
||||
)
|
||||
|
||||
export type StartStep = z.infer<typeof startStepSchema>
|
||||
|
||||
export type StepIndices = {
|
||||
blockIndex: number
|
||||
stepIndex: number
|
||||
}
|
||||
|
||||
export const stepSchema = startStepSchema
|
||||
.or(bubbleStepSchema)
|
||||
.or(inputStepSchema)
|
||||
.or(logicStepSchema)
|
||||
.or(integrationStepSchema)
|
||||
|
||||
export type Step = z.infer<typeof stepSchema>
|
@ -1,28 +1,28 @@
|
||||
import { z } from 'zod'
|
||||
import { settingsSchema } from './settings'
|
||||
import { stepSchema } from './steps'
|
||||
import { blockSchema } from './blocks'
|
||||
import { themeSchema } from './theme'
|
||||
import { variableSchema } from './variable'
|
||||
|
||||
const blockSchema = z.object({
|
||||
const groupSchema = z.object({
|
||||
id: z.string(),
|
||||
title: z.string(),
|
||||
graphCoordinates: z.object({
|
||||
x: z.number(),
|
||||
y: z.number(),
|
||||
}),
|
||||
steps: z.array(stepSchema),
|
||||
blocks: z.array(blockSchema),
|
||||
})
|
||||
|
||||
const sourceSchema = z.object({
|
||||
groupId: z.string(),
|
||||
blockId: z.string(),
|
||||
stepId: z.string(),
|
||||
itemId: z.string().optional(),
|
||||
})
|
||||
|
||||
const targetSchema = z.object({
|
||||
blockId: z.string(),
|
||||
stepId: z.string().optional(),
|
||||
groupId: z.string(),
|
||||
blockId: z.string().optional(),
|
||||
})
|
||||
|
||||
const edgeSchema = z.object({
|
||||
@ -32,9 +32,10 @@ const edgeSchema = z.object({
|
||||
})
|
||||
|
||||
const typebotSchema = z.object({
|
||||
version: z.enum(['2']).optional(),
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
blocks: z.array(blockSchema),
|
||||
groups: z.array(groupSchema),
|
||||
edges: z.array(edgeSchema),
|
||||
variables: z.array(variableSchema),
|
||||
theme: themeSchema,
|
||||
@ -53,4 +54,4 @@ export type Typebot = z.infer<typeof typebotSchema>
|
||||
export type Target = z.infer<typeof targetSchema>
|
||||
export type Source = z.infer<typeof sourceSchema>
|
||||
export type Edge = z.infer<typeof edgeSchema>
|
||||
export type Block = z.infer<typeof blockSchema>
|
||||
export type Group = z.infer<typeof groupSchema>
|
||||
|
Reference in New Issue
Block a user