✨ Introducing The Forge (#1072)
The Forge allows anyone to easily create their own Typebot Block. Closes #380
This commit is contained in:
@ -1,11 +1,12 @@
|
||||
import { z } from 'zod'
|
||||
import { blockBaseSchema } from './shared'
|
||||
import { startBlockSchema } from './start/schemas'
|
||||
import { Item, ItemV6 } from '../items/schema'
|
||||
import { ItemV6 } from '../items/schema'
|
||||
import { bubbleBlockSchemas } from './bubbles/schema'
|
||||
import { LogicBlock, logicBlockSchemas } from './logic/schema'
|
||||
import { InputBlock, inputBlockSchemas } from './inputs/schema'
|
||||
import { IntegrationBlock, integrationBlockSchemas } from './integrations'
|
||||
import { enabledBlocks } from '@typebot.io/forge-repository'
|
||||
|
||||
export type BlockWithOptions = Extract<Block, { options?: any }>
|
||||
|
||||
@ -27,12 +28,21 @@ export const blockSchemaV5 = z.discriminatedUnion('type', [
|
||||
])
|
||||
export type BlockV5 = z.infer<typeof blockSchemaV5>
|
||||
|
||||
export const blockSchemaV6 = z.discriminatedUnion('type', [
|
||||
...bubbleBlockSchemas,
|
||||
...inputBlockSchemas.v6,
|
||||
...logicBlockSchemas.v6,
|
||||
...integrationBlockSchemas.v6,
|
||||
])
|
||||
export const blockSchemaV6 = z
|
||||
.discriminatedUnion('type', [
|
||||
...bubbleBlockSchemas,
|
||||
...inputBlockSchemas.v6,
|
||||
...logicBlockSchemas.v6,
|
||||
...integrationBlockSchemas.v6,
|
||||
])
|
||||
.or(
|
||||
blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum(enabledBlocks),
|
||||
options: z.any().optional(),
|
||||
})
|
||||
)
|
||||
)
|
||||
export type BlockV6 = z.infer<typeof blockSchemaV6>
|
||||
|
||||
const blockSchema = blockSchemaV5.or(blockSchemaV6)
|
||||
|
@ -60,6 +60,24 @@ const embedMessageSchema = z.object({
|
||||
.merge(z.object({ height: z.number().optional() })),
|
||||
})
|
||||
|
||||
const displayEmbedBubbleSchema = z.object({
|
||||
waitForEventFunction: z
|
||||
.object({
|
||||
args: z.record(z.string(), z.unknown()),
|
||||
content: z.string(),
|
||||
})
|
||||
.optional(),
|
||||
initFunction: z.object({
|
||||
args: z.record(z.string(), z.unknown()),
|
||||
content: z.string(),
|
||||
}),
|
||||
})
|
||||
const customEmbedSchema = z.object({
|
||||
type: z.literal('custom-embed'),
|
||||
content: displayEmbedBubbleSchema,
|
||||
})
|
||||
export type CustomEmbedBubble = z.infer<typeof customEmbedSchema>
|
||||
|
||||
export const chatMessageSchema = z
|
||||
.object({ id: z.string() })
|
||||
.and(
|
||||
@ -69,6 +87,7 @@ export const chatMessageSchema = z
|
||||
videoMessageSchema,
|
||||
audioMessageSchema,
|
||||
embedMessageSchema,
|
||||
customEmbedSchema,
|
||||
])
|
||||
)
|
||||
export type ChatMessage = z.infer<typeof chatMessageSchema>
|
||||
@ -242,6 +261,19 @@ export const clientSideActionSchema = z
|
||||
pixel: pixelOptionsSchema,
|
||||
})
|
||||
)
|
||||
.or(
|
||||
z.object({
|
||||
stream: z.literal(true),
|
||||
})
|
||||
)
|
||||
.or(
|
||||
z.object({
|
||||
codeToExecute: z.object({
|
||||
args: z.record(z.string(), z.unknown()),
|
||||
content: z.string(),
|
||||
}),
|
||||
})
|
||||
)
|
||||
)
|
||||
|
||||
const typebotInChatReplyPick = {
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { z } from 'zod'
|
||||
import { stripeCredentialsSchema } from './blocks/inputs/payment/schema'
|
||||
import { googleSheetsCredentialsSchema } from './blocks/integrations/googleSheets/schema'
|
||||
import { openAICredentialsSchema } from './blocks/integrations/openai'
|
||||
import { smtpCredentialsSchema } from './blocks/integrations/sendEmail'
|
||||
import { whatsAppCredentialsSchema } from './whatsapp'
|
||||
import { zemanticAiCredentialsSchema } from './blocks'
|
||||
import { openAICredentialsSchema } from './blocks/integrations/openai'
|
||||
|
||||
export const credentialsSchema = z.discriminatedUnion('type', [
|
||||
smtpCredentialsSchema,
|
||||
|
Reference in New Issue
Block a user