⚡ (engine) Improve engine overall robustness
This commit is contained in:
11
packages/models/features/blocks/baseSchemas.ts
Normal file
11
packages/models/features/blocks/baseSchemas.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const blockBaseSchema = z.object({
|
||||
id: z.string(),
|
||||
groupId: z.string(),
|
||||
outgoingEdgeId: z.string().optional(),
|
||||
})
|
||||
|
||||
export const optionBaseSchema = z.object({
|
||||
variableId: z.string().optional(),
|
||||
})
|
@ -1,5 +1,6 @@
|
||||
import { z } from 'zod'
|
||||
import { blockBaseSchema, BubbleBlockType } from '../shared'
|
||||
import { blockBaseSchema } from '../baseSchemas'
|
||||
import { BubbleBlockType } from './enums'
|
||||
|
||||
export const audioBubbleContentSchema = z.object({
|
||||
url: z.string().optional(),
|
@ -1,5 +1,6 @@
|
||||
import { blockBaseSchema, BubbleBlockType } from '../shared'
|
||||
import { z } from 'zod'
|
||||
import { blockBaseSchema } from '../baseSchemas'
|
||||
import { BubbleBlockType } from './enums'
|
||||
|
||||
export const embedBubbleContentSchema = z.object({
|
||||
url: z.string().optional(),
|
7
packages/models/features/blocks/bubbles/enums.ts
Normal file
7
packages/models/features/blocks/bubbles/enums.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export enum BubbleBlockType {
|
||||
TEXT = 'text',
|
||||
IMAGE = 'image',
|
||||
VIDEO = 'video',
|
||||
EMBED = 'embed',
|
||||
AUDIO = 'audio',
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
import { z } from 'zod'
|
||||
import { blockBaseSchema, BubbleBlockType } from '../shared'
|
||||
import { blockBaseSchema } from '../baseSchemas'
|
||||
import { BubbleBlockType } from './enums'
|
||||
|
||||
export const imageBubbleContentSchema = z.object({
|
||||
url: z.string().optional(),
|
@ -1,6 +1,7 @@
|
||||
export * from './bubbleBlock'
|
||||
export * from './text'
|
||||
export * from './image'
|
||||
export * from './video'
|
||||
export * from './embed'
|
||||
export * from './audio'
|
||||
export * from './embed'
|
||||
export * from './enums'
|
||||
export * from './image'
|
||||
export * from './schemas'
|
||||
export * from './text'
|
||||
export * from './video'
|
@ -1,5 +1,6 @@
|
||||
import { blockBaseSchema, BubbleBlockType } from '../shared'
|
||||
import { z } from 'zod'
|
||||
import { blockBaseSchema } from '../baseSchemas'
|
||||
import { BubbleBlockType } from './enums'
|
||||
|
||||
export const defaultTextBubbleContent: TextBubbleContent = {
|
||||
html: '',
|
5
packages/models/features/blocks/bubbles/video/enums.ts
Normal file
5
packages/models/features/blocks/bubbles/video/enums.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export enum VideoBubbleContentType {
|
||||
URL = 'url',
|
||||
YOUTUBE = 'youtube',
|
||||
VIMEO = 'vimeo',
|
||||
}
|
2
packages/models/features/blocks/bubbles/video/index.ts
Normal file
2
packages/models/features/blocks/bubbles/video/index.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './enums'
|
||||
export * from './schemas'
|
@ -1,11 +1,7 @@
|
||||
import { blockBaseSchema, BubbleBlockType } from '../shared'
|
||||
import { z } from 'zod'
|
||||
|
||||
export enum VideoBubbleContentType {
|
||||
URL = 'url',
|
||||
YOUTUBE = 'youtube',
|
||||
VIMEO = 'vimeo',
|
||||
}
|
||||
import { blockBaseSchema } from '../../baseSchemas'
|
||||
import { BubbleBlockType } from '../enums'
|
||||
import { VideoBubbleContentType } from './enums'
|
||||
|
||||
export const videoBubbleContentSchema = z.object({
|
||||
url: z.string().optional(),
|
@ -1,7 +1,7 @@
|
||||
export * from './blocks'
|
||||
export * from './baseSchemas'
|
||||
export * from './bubbles'
|
||||
export * from './inputs'
|
||||
export * from './logic'
|
||||
export * from './integrations'
|
||||
export * from './item'
|
||||
export * from './shared'
|
||||
export * from './logic'
|
||||
export * from './schemas'
|
||||
export * from './start'
|
@ -1,12 +1,9 @@
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
blockBaseSchema,
|
||||
InputBlockType,
|
||||
defaultButtonLabel,
|
||||
optionBaseSchema,
|
||||
itemBaseSchema,
|
||||
ItemType,
|
||||
} from '../shared'
|
||||
import { ItemType } from '../../items/enums'
|
||||
import { itemBaseSchema } from '../../items/baseSchemas'
|
||||
import { optionBaseSchema, blockBaseSchema } from '../baseSchemas'
|
||||
import { defaultButtonLabel } from './constants'
|
||||
import { InputBlockType } from './enums'
|
||||
|
||||
export const choiceInputOptionsSchema = optionBaseSchema.and(
|
||||
z.object({
|
1
packages/models/features/blocks/inputs/constants.ts
Normal file
1
packages/models/features/blocks/inputs/constants.ts
Normal file
@ -0,0 +1 @@
|
||||
export const defaultButtonLabel = 'Send'
|
@ -1,10 +1,7 @@
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
blockBaseSchema,
|
||||
InputBlockType,
|
||||
defaultButtonLabel,
|
||||
optionBaseSchema,
|
||||
} from '../shared'
|
||||
import { optionBaseSchema, blockBaseSchema } from '../baseSchemas'
|
||||
import { defaultButtonLabel } from './constants'
|
||||
import { InputBlockType } from './enums'
|
||||
|
||||
export const dateInputOptionsSchema = optionBaseSchema.and(
|
||||
z.object({
|
@ -1,10 +1,7 @@
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
defaultButtonLabel,
|
||||
InputBlockType,
|
||||
optionBaseSchema,
|
||||
blockBaseSchema,
|
||||
} from '../shared'
|
||||
import { optionBaseSchema, blockBaseSchema } from '../baseSchemas'
|
||||
import { defaultButtonLabel } from './constants'
|
||||
import { InputBlockType } from './enums'
|
||||
import { textInputOptionsBaseSchema } from './text'
|
||||
|
||||
export const emailInputOptionsSchema = optionBaseSchema
|
12
packages/models/features/blocks/inputs/enums.ts
Normal file
12
packages/models/features/blocks/inputs/enums.ts
Normal file
@ -0,0 +1,12 @@
|
||||
export enum InputBlockType {
|
||||
TEXT = 'text input',
|
||||
NUMBER = 'number input',
|
||||
EMAIL = 'email input',
|
||||
URL = 'url input',
|
||||
DATE = 'date input',
|
||||
PHONE = 'phone number input',
|
||||
CHOICE = 'choice input',
|
||||
PAYMENT = 'payment input',
|
||||
RATING = 'rating input',
|
||||
FILE = 'file input',
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
import { z } from 'zod'
|
||||
import { InputBlockType, optionBaseSchema, blockBaseSchema } from '../shared'
|
||||
import { optionBaseSchema, blockBaseSchema } from '../baseSchemas'
|
||||
import { InputBlockType } from './enums'
|
||||
|
||||
export const fileInputOptionsSchema = optionBaseSchema.and(
|
||||
z.object({
|
@ -1,11 +1,13 @@
|
||||
export * from './inputBlock'
|
||||
export * from './text'
|
||||
export * from './email'
|
||||
export * from './number'
|
||||
export * from './url'
|
||||
export * from './date'
|
||||
export * from './choice'
|
||||
export * from './constants'
|
||||
export * from './date'
|
||||
export * from './email'
|
||||
export * from './enums'
|
||||
export * from './file'
|
||||
export * from './number'
|
||||
export * from './payment'
|
||||
export * from './phone'
|
||||
export * from './rating'
|
||||
export * from './file'
|
||||
export * from './schemas'
|
||||
export * from './text'
|
||||
export * from './url'
|
@ -1,10 +1,7 @@
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
defaultButtonLabel,
|
||||
InputBlockType,
|
||||
optionBaseSchema,
|
||||
blockBaseSchema,
|
||||
} from '../shared'
|
||||
import { optionBaseSchema, blockBaseSchema } from '../baseSchemas'
|
||||
import { defaultButtonLabel } from './constants'
|
||||
import { InputBlockType } from './enums'
|
||||
import { textInputOptionsBaseSchema } from './text'
|
||||
|
||||
export const numberInputOptionsSchema = optionBaseSchema
|
3
packages/models/features/blocks/inputs/payment/enums.ts
Normal file
3
packages/models/features/blocks/inputs/payment/enums.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export enum PaymentProvider {
|
||||
STRIPE = 'Stripe',
|
||||
}
|
2
packages/models/features/blocks/inputs/payment/index.ts
Normal file
2
packages/models/features/blocks/inputs/payment/index.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './enums'
|
||||
export * from './schemas'
|
@ -1,5 +1,7 @@
|
||||
import { z } from 'zod'
|
||||
import { InputBlockType, optionBaseSchema, blockBaseSchema } from '../shared'
|
||||
import { optionBaseSchema, blockBaseSchema } from '../../baseSchemas'
|
||||
import { InputBlockType } from '../enums'
|
||||
import { PaymentProvider } from './enums'
|
||||
|
||||
export type CreditCardDetails = {
|
||||
number: string
|
||||
@ -8,10 +10,6 @@ export type CreditCardDetails = {
|
||||
cvc: string
|
||||
}
|
||||
|
||||
export enum PaymentProvider {
|
||||
STRIPE = 'Stripe',
|
||||
}
|
||||
|
||||
export const paymentInputOptionsSchema = optionBaseSchema.and(
|
||||
z.object({
|
||||
provider: z.nativeEnum(PaymentProvider),
|
@ -1,10 +1,7 @@
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
defaultButtonLabel,
|
||||
InputBlockType,
|
||||
optionBaseSchema,
|
||||
blockBaseSchema,
|
||||
} from '../shared'
|
||||
import { optionBaseSchema, blockBaseSchema } from '../baseSchemas'
|
||||
import { defaultButtonLabel } from './constants'
|
||||
import { InputBlockType } from './enums'
|
||||
import { textInputOptionsBaseSchema } from './text'
|
||||
|
||||
export const phoneNumberInputOptionsSchema = optionBaseSchema
|
@ -1,10 +1,7 @@
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
defaultButtonLabel,
|
||||
InputBlockType,
|
||||
optionBaseSchema,
|
||||
blockBaseSchema,
|
||||
} from '../shared'
|
||||
import { optionBaseSchema, blockBaseSchema } from '../baseSchemas'
|
||||
import { defaultButtonLabel } from './constants'
|
||||
import { InputBlockType } from './enums'
|
||||
|
||||
export const defaultRatingInputOptions: RatingInputOptions = {
|
||||
buttonType: 'Numbers',
|
@ -1,5 +1,4 @@
|
||||
import { z } from 'zod'
|
||||
import { optionBaseSchema } from '../shared'
|
||||
import { choiceInputOptionsSchema, choiceInputSchema } from './choice'
|
||||
import { dateInputOptionsSchema, dateInputSchema } from './date'
|
||||
import { emailInputOptionsSchema, emailInputSchema } from './email'
|
||||
@ -13,6 +12,7 @@ import { ratingInputOptionsSchema, ratingInputBlockSchema } from './rating'
|
||||
import { textInputOptionsSchema, textInputSchema } from './text'
|
||||
import { fileInputOptionsSchema, fileInputStepSchema } from './file'
|
||||
import { urlInputOptionsSchema, urlInputSchema } from './url'
|
||||
import { optionBaseSchema } from '../baseSchemas'
|
||||
|
||||
export type OptionBase = z.infer<typeof optionBaseSchema>
|
||||
|
@ -1,10 +1,7 @@
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
defaultButtonLabel,
|
||||
InputBlockType,
|
||||
optionBaseSchema,
|
||||
blockBaseSchema,
|
||||
} from '../shared'
|
||||
import { blockBaseSchema, optionBaseSchema } from '../baseSchemas'
|
||||
import { defaultButtonLabel } from './constants'
|
||||
import { InputBlockType } from './enums'
|
||||
|
||||
export const textInputOptionsBaseSchema = z.object({
|
||||
labels: z.object({
|
@ -1,10 +1,7 @@
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
defaultButtonLabel,
|
||||
InputBlockType,
|
||||
optionBaseSchema,
|
||||
blockBaseSchema,
|
||||
} from '../shared'
|
||||
import { optionBaseSchema, blockBaseSchema } from '../baseSchemas'
|
||||
import { defaultButtonLabel } from './constants'
|
||||
import { InputBlockType } from './enums'
|
||||
import { textInputOptionsBaseSchema } from './text'
|
||||
|
||||
export const urlInputOptionsSchema = optionBaseSchema
|
@ -1,5 +1,6 @@
|
||||
import { z } from 'zod'
|
||||
import { blockBaseSchema, IntegrationBlockType } from '../shared'
|
||||
import { blockBaseSchema } from '../baseSchemas'
|
||||
import { IntegrationBlockType } from './enums'
|
||||
|
||||
export const chatwootOptionsSchema = z.object({
|
||||
baseUrl: z.string(),
|
10
packages/models/features/blocks/integrations/enums.ts
Normal file
10
packages/models/features/blocks/integrations/enums.ts
Normal file
@ -0,0 +1,10 @@
|
||||
export enum IntegrationBlockType {
|
||||
GOOGLE_SHEETS = 'Google Sheets',
|
||||
GOOGLE_ANALYTICS = 'Google Analytics',
|
||||
WEBHOOK = 'Webhook',
|
||||
EMAIL = 'Email',
|
||||
ZAPIER = 'Zapier',
|
||||
MAKE_COM = 'Make.com',
|
||||
PABBLY_CONNECT = 'Pabbly',
|
||||
CHATWOOT = 'Chatwoot',
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
import { z } from 'zod'
|
||||
import { blockBaseSchema, IntegrationBlockType } from '../shared'
|
||||
import { blockBaseSchema } from '../baseSchemas'
|
||||
import { IntegrationBlockType } from './enums'
|
||||
|
||||
export const googleAnalyticsOptionsSchema = z.object({
|
||||
trackingId: z.string().optional(),
|
@ -0,0 +1,5 @@
|
||||
export enum GoogleSheetsAction {
|
||||
GET = 'Get data from sheet',
|
||||
INSERT_ROW = 'Insert a row',
|
||||
UPDATE_ROW = 'Update a row',
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
export * from './enums'
|
||||
export * from './schemas'
|
@ -1,13 +1,9 @@
|
||||
import { z } from 'zod'
|
||||
import { ComparisonOperators, LogicalOperator } from '../logic/condition'
|
||||
import { blockBaseSchema, IntegrationBlockType } from '../shared'
|
||||
import { ComparisonOperators, LogicalOperator } from '../../logic/condition'
|
||||
import cuid from 'cuid'
|
||||
|
||||
export enum GoogleSheetsAction {
|
||||
GET = 'Get data from sheet',
|
||||
INSERT_ROW = 'Insert a row',
|
||||
UPDATE_ROW = 'Update a row',
|
||||
}
|
||||
import { IntegrationBlockType } from '../enums'
|
||||
import { GoogleSheetsAction } from './enums'
|
||||
import { blockBaseSchema } from '../../baseSchemas'
|
||||
|
||||
const cellSchema = z.object({
|
||||
column: z.string().optional(),
|
||||
@ -62,10 +58,10 @@ const googleSheetsUpdateRowOptionsSchema = googleSheetsOptionsBaseSchema.and(
|
||||
})
|
||||
)
|
||||
|
||||
export const googleSheetsOptionsSchema = googleSheetsOptionsBaseSchema
|
||||
.or(googleSheetsGetOptionsSchema)
|
||||
export const googleSheetsOptionsSchema = googleSheetsGetOptionsSchema
|
||||
.or(googleSheetsInsertRowOptionsSchema)
|
||||
.or(googleSheetsUpdateRowOptionsSchema)
|
||||
.or(googleSheetsOptionsBaseSchema)
|
||||
|
||||
export const googleSheetsBlockSchema = blockBaseSchema.and(
|
||||
z.object({
|
@ -1,9 +1,10 @@
|
||||
export * from './integrationBlock'
|
||||
export * from './webhook'
|
||||
export * from './googleAnalytics'
|
||||
export * from './pabblyConnect'
|
||||
export * from './makeCom'
|
||||
export * from './zapier'
|
||||
export * from './sendEmail'
|
||||
export * from './googleSheets'
|
||||
export * from './chatwoot'
|
||||
export * from './enums'
|
||||
export * from './googleAnalytics'
|
||||
export * from './googleSheets'
|
||||
export * from './makeCom'
|
||||
export * from './pabblyConnect'
|
||||
export * from './schemas'
|
||||
export * from './sendEmail'
|
||||
export * from './webhook'
|
||||
export * from './zapier'
|
@ -1,5 +1,6 @@
|
||||
import { z } from 'zod'
|
||||
import { blockBaseSchema, IntegrationBlockType } from '../shared'
|
||||
import { blockBaseSchema } from '../baseSchemas'
|
||||
import { IntegrationBlockType } from './enums'
|
||||
import { webhookOptionsSchema } from './webhook'
|
||||
|
||||
export const makeComBlockSchema = blockBaseSchema.and(
|
@ -1,5 +1,6 @@
|
||||
import { z } from 'zod'
|
||||
import { blockBaseSchema, IntegrationBlockType } from '../shared'
|
||||
import { blockBaseSchema } from '../baseSchemas'
|
||||
import { IntegrationBlockType } from './enums'
|
||||
import { webhookOptionsSchema } from './webhook'
|
||||
|
||||
export const pabblyConnectBlockSchema = blockBaseSchema.and(
|
@ -7,7 +7,7 @@ import {
|
||||
import {
|
||||
googleSheetsOptionsSchema,
|
||||
googleSheetsBlockSchema,
|
||||
} from './googleSheets'
|
||||
} from './googleSheets/schemas'
|
||||
import { makeComBlockSchema } from './makeCom'
|
||||
import { pabblyConnectBlockSchema } from './pabblyConnect'
|
||||
import { sendEmailOptionsSchema, sendEmailBlockSchema } from './sendEmail'
|
@ -1,5 +1,6 @@
|
||||
import { z } from 'zod'
|
||||
import { blockBaseSchema, IntegrationBlockType } from '../shared'
|
||||
import { blockBaseSchema } from '../baseSchemas'
|
||||
import { IntegrationBlockType } from './enums'
|
||||
|
||||
export const sendEmailOptionsSchema = z.object({
|
||||
credentialsId: z.string(),
|
@ -1,5 +1,6 @@
|
||||
import { z } from 'zod'
|
||||
import { blockBaseSchema, IntegrationBlockType } from '../shared'
|
||||
import { blockBaseSchema } from '../baseSchemas'
|
||||
import { IntegrationBlockType } from './enums'
|
||||
|
||||
const variableForTestSchema = z.object({
|
||||
id: z.string(),
|
@ -1,5 +1,6 @@
|
||||
import { z } from 'zod'
|
||||
import { blockBaseSchema, IntegrationBlockType } from '../shared'
|
||||
import { blockBaseSchema } from '../baseSchemas'
|
||||
import { IntegrationBlockType } from './enums'
|
||||
import { webhookOptionsSchema } from './webhook'
|
||||
|
||||
export const zapierBlockSchema = blockBaseSchema.and(
|
@ -1,5 +1,6 @@
|
||||
import { z } from 'zod'
|
||||
import { LogicBlockType, blockBaseSchema } from '../shared'
|
||||
import { blockBaseSchema } from '../baseSchemas'
|
||||
import { LogicBlockType } from './enums'
|
||||
|
||||
export const codeOptionsSchema = z.object({
|
||||
name: z.string(),
|
@ -1,10 +1,8 @@
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
itemBaseSchema,
|
||||
ItemType,
|
||||
LogicBlockType,
|
||||
blockBaseSchema,
|
||||
} from '../shared'
|
||||
import { ItemType } from '../../items/enums'
|
||||
import { itemBaseSchema } from '../../items/baseSchemas'
|
||||
import { blockBaseSchema } from '../baseSchemas'
|
||||
import { LogicBlockType } from './enums'
|
||||
|
||||
export enum LogicalOperator {
|
||||
OR = 'OR',
|
7
packages/models/features/blocks/logic/enums.ts
Normal file
7
packages/models/features/blocks/logic/enums.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export enum LogicBlockType {
|
||||
SET_VARIABLE = 'Set variable',
|
||||
CONDITION = 'Condition',
|
||||
REDIRECT = 'Redirect',
|
||||
CODE = 'Code',
|
||||
TYPEBOT_LINK = 'Typebot link',
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
export * from './logicBlock'
|
||||
export * from './code'
|
||||
export * from './condition'
|
||||
export * from './enums'
|
||||
export * from './logicBlock'
|
||||
export * from './redirect'
|
||||
export * from './setVariable'
|
||||
export * from './typebotLink'
|
@ -1,5 +1,6 @@
|
||||
import { z } from 'zod'
|
||||
import { LogicBlockType, blockBaseSchema } from '../shared'
|
||||
import { blockBaseSchema } from '../baseSchemas'
|
||||
import { LogicBlockType } from './enums'
|
||||
|
||||
export const redirectOptionsSchema = z.object({
|
||||
url: z.string().optional(),
|
@ -1,5 +1,6 @@
|
||||
import { z } from 'zod'
|
||||
import { LogicBlockType, blockBaseSchema } from '../shared'
|
||||
import { blockBaseSchema } from '../baseSchemas'
|
||||
import { LogicBlockType } from './enums'
|
||||
|
||||
export const setVariableOptionsSchema = z.object({
|
||||
variableId: z.string().optional(),
|
@ -1,5 +1,6 @@
|
||||
import { z } from 'zod'
|
||||
import { LogicBlockType, blockBaseSchema } from '../shared'
|
||||
import { blockBaseSchema } from '../baseSchemas'
|
||||
import { LogicBlockType } from './enums'
|
||||
|
||||
export const typebotLinkOptionsSchema = z.object({
|
||||
typebotId: z.string().optional(),
|
@ -1,21 +1,28 @@
|
||||
import {
|
||||
InputBlockOptions,
|
||||
IntegrationBlockOptions,
|
||||
Item,
|
||||
LogicBlockOptions,
|
||||
} from '.'
|
||||
import { BubbleBlock, bubbleBlockSchema } from './bubbles'
|
||||
import { ChoiceInputBlock, InputBlock, inputBlockSchema } from './inputs'
|
||||
import { IntegrationBlock, integrationBlockSchema } from './integrations'
|
||||
import { ConditionBlock, LogicBlock, logicBlockSchema } from './logic'
|
||||
import { z } from 'zod'
|
||||
import { BubbleBlockType } from './bubbles/enums'
|
||||
import { BubbleBlock, bubbleBlockSchema } from './bubbles/schemas'
|
||||
import { ChoiceInputBlock } from './inputs/choice'
|
||||
import { InputBlockType } from './inputs/enums'
|
||||
import {
|
||||
BubbleBlockType,
|
||||
InputBlockType,
|
||||
LogicBlockType,
|
||||
blockBaseSchema,
|
||||
IntegrationBlockType,
|
||||
} from './shared'
|
||||
InputBlock,
|
||||
InputBlockOptions,
|
||||
inputBlockSchema,
|
||||
} from './inputs/schemas'
|
||||
import { IntegrationBlockType } from './integrations/enums'
|
||||
import {
|
||||
IntegrationBlock,
|
||||
IntegrationBlockOptions,
|
||||
integrationBlockSchema,
|
||||
} from './integrations/schemas'
|
||||
import { ConditionBlock } from './logic/condition'
|
||||
import { LogicBlockType } from './logic/enums'
|
||||
import {
|
||||
LogicBlock,
|
||||
LogicBlockOptions,
|
||||
logicBlockSchema,
|
||||
} from './logic/logicBlock'
|
||||
import { blockBaseSchema } from './baseSchemas'
|
||||
import { startBlockSchema } from './start/schemas'
|
||||
|
||||
export type DraggableBlock =
|
||||
| BubbleBlock
|
||||
@ -55,15 +62,6 @@ export type BlockWithItems = ConditionBlock | ChoiceInputBlock
|
||||
|
||||
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
|
1
packages/models/features/blocks/start/index.ts
Normal file
1
packages/models/features/blocks/start/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './schemas'
|
11
packages/models/features/blocks/start/schemas.ts
Normal file
11
packages/models/features/blocks/start/schemas.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { z } from 'zod'
|
||||
import { blockBaseSchema } from '../baseSchemas'
|
||||
|
||||
export const startBlockSchema = blockBaseSchema.and(
|
||||
z.object({
|
||||
type: z.literal('start'),
|
||||
label: z.string(),
|
||||
})
|
||||
)
|
||||
|
||||
export type StartBlock = z.infer<typeof startBlockSchema>
|
@ -1,21 +1,23 @@
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
audioBubbleContentSchema,
|
||||
BubbleBlockType,
|
||||
embedBubbleContentSchema,
|
||||
googleAnalyticsOptionsSchema,
|
||||
imageBubbleContentSchema,
|
||||
inputBlockSchema,
|
||||
paymentInputRuntimeOptionsSchema,
|
||||
redirectOptionsSchema,
|
||||
textBubbleContentSchema,
|
||||
videoBubbleContentSchema,
|
||||
} from './blocks'
|
||||
import { publicTypebotSchema } from './publicTypebot'
|
||||
import { ChatSession as ChatSessionPrisma } from 'db'
|
||||
import { schemaForType } from './utils'
|
||||
import { resultSchema } from './result'
|
||||
import { logSchema, resultSchema } from './result'
|
||||
import { typebotSchema } from './typebot'
|
||||
import {
|
||||
BubbleBlockType,
|
||||
textBubbleContentSchema,
|
||||
imageBubbleContentSchema,
|
||||
videoBubbleContentSchema,
|
||||
audioBubbleContentSchema,
|
||||
embedBubbleContentSchema,
|
||||
} from './blocks/bubbles'
|
||||
|
||||
const typebotInSessionStateSchema = publicTypebotSchema.pick({
|
||||
id: true,
|
||||
@ -156,6 +158,13 @@ export const sendMessageInputSchema = z.object({
|
||||
|
||||
const runtimeOptionsSchema = paymentInputRuntimeOptionsSchema.optional()
|
||||
|
||||
const replyLogSchema = logSchema
|
||||
.pick({
|
||||
status: true,
|
||||
description: true,
|
||||
})
|
||||
.and(z.object({ details: z.unknown().optional() }))
|
||||
|
||||
export const chatReplySchema = z.object({
|
||||
messages: z.array(chatMessageSchema),
|
||||
input: inputBlockSchema
|
||||
@ -188,6 +197,7 @@ export const chatReplySchema = z.object({
|
||||
.optional(),
|
||||
resultId: z.string().optional(),
|
||||
dynamicTheme: dynamicThemeSchema.optional(),
|
||||
logs: z.array(replyLogSchema).optional(),
|
||||
})
|
||||
|
||||
export type ChatSession = z.infer<typeof chatSessionSchema>
|
||||
@ -200,3 +210,4 @@ export type CodeToExecute = z.infer<typeof codeToExecuteSchema>
|
||||
export type StartParams = z.infer<typeof startParamsSchema>
|
||||
export type RuntimeOptions = z.infer<typeof runtimeOptionsSchema>
|
||||
export type StartTypebot = z.infer<typeof startTypebotSchema>
|
||||
export type ReplyLog = z.infer<typeof replyLogSchema>
|
9
packages/models/features/items/baseSchemas.ts
Normal file
9
packages/models/features/items/baseSchemas.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const itemBaseSchema = z.object({
|
||||
id: z.string(),
|
||||
blockId: z.string(),
|
||||
outgoingEdgeId: z.string().optional(),
|
||||
})
|
||||
|
||||
export type ItemBase = z.infer<typeof itemBaseSchema>
|
4
packages/models/features/items/enums.ts
Normal file
4
packages/models/features/items/enums.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export enum ItemType {
|
||||
BUTTON,
|
||||
CONDITION,
|
||||
}
|
4
packages/models/features/items/index.ts
Normal file
4
packages/models/features/items/index.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export * from './baseSchemas'
|
||||
export * from './enums'
|
||||
export * from './schemas'
|
||||
export * from './types'
|
7
packages/models/features/items/schemas.ts
Normal file
7
packages/models/features/items/schemas.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { z } from 'zod'
|
||||
import { buttonItemSchema } from '../blocks/inputs/choice'
|
||||
import { conditionItemSchema } from '../blocks/logic/condition'
|
||||
|
||||
const itemSchema = buttonItemSchema.or(conditionItemSchema)
|
||||
|
||||
export type Item = z.infer<typeof itemSchema>
|
5
packages/models/features/items/types.ts
Normal file
5
packages/models/features/items/types.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export type ItemIndices = {
|
||||
blockIndex: number
|
||||
groupIndex: number
|
||||
itemIndex: number
|
||||
}
|
5
packages/models/features/typebot/theme/enums.ts
Normal file
5
packages/models/features/typebot/theme/enums.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export enum BackgroundType {
|
||||
COLOR = 'Color',
|
||||
IMAGE = 'Image',
|
||||
NONE = 'None',
|
||||
}
|
2
packages/models/features/typebot/theme/index.ts
Normal file
2
packages/models/features/typebot/theme/index.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './enums'
|
||||
export * from './schemas'
|
@ -1,4 +1,5 @@
|
||||
import { z } from 'zod'
|
||||
import { BackgroundType } from './enums'
|
||||
|
||||
const avatarPropsSchema = z.object({
|
||||
isEnabled: z.boolean(),
|
||||
@ -16,7 +17,7 @@ const inputColorsSchema = containerColorsSchema.and(
|
||||
})
|
||||
)
|
||||
|
||||
const chatThemeSchema = z.object({
|
||||
export const chatThemeSchema = z.object({
|
||||
hostAvatar: avatarPropsSchema.optional(),
|
||||
guestAvatar: avatarPropsSchema.optional(),
|
||||
hostBubbles: containerColorsSchema,
|
||||
@ -25,12 +26,6 @@ const chatThemeSchema = z.object({
|
||||
inputs: inputColorsSchema,
|
||||
})
|
||||
|
||||
export enum BackgroundType {
|
||||
COLOR = 'Color',
|
||||
IMAGE = 'Image',
|
||||
NONE = 'None',
|
||||
}
|
||||
|
||||
const backgroundSchema = z.object({
|
||||
type: z.nativeEnum(BackgroundType),
|
||||
content: z.string().optional(),
|
@ -8,3 +8,4 @@ export * from './features/credentials'
|
||||
export * from './features/webhooks'
|
||||
export * from './features/chat'
|
||||
export * from './features/workspace'
|
||||
export * from './features/items'
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "models",
|
||||
"version": "1.0.0",
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"main": "./index.ts",
|
||||
"types": "./index.ts",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
|
@ -1,14 +0,0 @@
|
||||
import { z } from 'zod'
|
||||
import { itemBaseSchema } from './shared'
|
||||
import { buttonItemSchema } from './inputs'
|
||||
import { conditionItemSchema } from './logic'
|
||||
|
||||
export type ItemIndices = {
|
||||
blockIndex: number
|
||||
groupIndex: number
|
||||
itemIndex: number
|
||||
}
|
||||
const itemSchema = buttonItemSchema.or(conditionItemSchema)
|
||||
|
||||
export type ItemBase = z.infer<typeof itemBaseSchema>
|
||||
export type Item = z.infer<typeof itemSchema>
|
@ -1,64 +0,0 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const blockBaseSchema = z.object({
|
||||
id: z.string(),
|
||||
groupId: z.string(),
|
||||
outgoingEdgeId: z.string().optional(),
|
||||
})
|
||||
|
||||
export const defaultButtonLabel = 'Send'
|
||||
|
||||
export const optionBaseSchema = z.object({
|
||||
variableId: z.string().optional(),
|
||||
})
|
||||
|
||||
export const itemBaseSchema = z.object({
|
||||
id: z.string(),
|
||||
blockId: z.string(),
|
||||
outgoingEdgeId: z.string().optional(),
|
||||
})
|
||||
|
||||
export enum ItemType {
|
||||
BUTTON,
|
||||
CONDITION,
|
||||
}
|
||||
|
||||
export enum BubbleBlockType {
|
||||
TEXT = 'text',
|
||||
IMAGE = 'image',
|
||||
VIDEO = 'video',
|
||||
EMBED = 'embed',
|
||||
AUDIO = 'audio',
|
||||
}
|
||||
|
||||
export enum InputBlockType {
|
||||
TEXT = 'text input',
|
||||
NUMBER = 'number input',
|
||||
EMAIL = 'email input',
|
||||
URL = 'url input',
|
||||
DATE = 'date input',
|
||||
PHONE = 'phone number input',
|
||||
CHOICE = 'choice input',
|
||||
PAYMENT = 'payment input',
|
||||
RATING = 'rating input',
|
||||
FILE = 'file input',
|
||||
}
|
||||
|
||||
export enum LogicBlockType {
|
||||
SET_VARIABLE = 'Set variable',
|
||||
CONDITION = 'Condition',
|
||||
REDIRECT = 'Redirect',
|
||||
CODE = 'Code',
|
||||
TYPEBOT_LINK = 'Typebot link',
|
||||
}
|
||||
|
||||
export enum IntegrationBlockType {
|
||||
GOOGLE_SHEETS = 'Google Sheets',
|
||||
GOOGLE_ANALYTICS = 'Google Analytics',
|
||||
WEBHOOK = 'Webhook',
|
||||
EMAIL = 'Email',
|
||||
ZAPIER = 'Zapier',
|
||||
MAKE_COM = 'Make.com',
|
||||
PABBLY_CONNECT = 'Pabbly',
|
||||
CHATWOOT = 'Chatwoot',
|
||||
}
|
Reference in New Issue
Block a user