2
0

♻️ Introduce typebot v6 with events (#1013)

Closes #885
This commit is contained in:
Baptiste Arnaud
2023-11-08 15:34:16 +01:00
committed by GitHub
parent 68e4fc71fb
commit 35300eaf34
634 changed files with 58971 additions and 31449 deletions

View File

@ -0,0 +1,5 @@
import { AudioBubbleBlock } from './schema'
export const defaultAudioBubbleContent = {
isAutoplayEnabled: true,
} as const satisfies AudioBubbleBlock['content']

View File

@ -0,0 +1 @@
export * from './schema'

View File

@ -1,6 +1,6 @@
import { z } from 'zod'
import { blockBaseSchema } from '../baseSchemas'
import { BubbleBlockType } from './enums'
import { blockBaseSchema } from '../../shared'
import { BubbleBlockType } from '../constants'
export const audioBubbleContentSchema = z.object({
url: z.string().optional(),
@ -10,11 +10,9 @@ export const audioBubbleContentSchema = z.object({
export const audioBubbleBlockSchema = blockBaseSchema.merge(
z.object({
type: z.enum([BubbleBlockType.AUDIO]),
content: audioBubbleContentSchema,
content: audioBubbleContentSchema.optional(),
})
)
export const defaultAudioBubbleContent = {}
export type AudioBubbleBlock = z.infer<typeof audioBubbleBlockSchema>
export type AudioBubbleContent = z.infer<typeof audioBubbleContentSchema>

View File

@ -1,21 +0,0 @@
import { z } from 'zod'
import { variableStringSchema } from '../../utils'
import { blockBaseSchema } from '../baseSchemas'
import { BubbleBlockType } from './enums'
export const embedBubbleContentSchema = z.object({
url: z.string().optional(),
height: z.number().or(variableStringSchema),
})
export const embedBubbleBlockSchema = blockBaseSchema.merge(
z.object({
type: z.enum([BubbleBlockType.EMBED]),
content: embedBubbleContentSchema,
})
)
export const defaultEmbedBubbleContent: EmbedBubbleContent = { height: 400 }
export type EmbedBubbleBlock = z.infer<typeof embedBubbleBlockSchema>
export type EmbedBubbleContent = z.infer<typeof embedBubbleContentSchema>

View File

@ -0,0 +1,5 @@
import { EmbedBubbleBlock } from './schema'
export const defaultEmbedBubbleContent = {
height: 400,
} as const satisfies EmbedBubbleBlock['content']

View File

@ -0,0 +1 @@
export * from './schema'

View File

@ -0,0 +1,18 @@
import { z } from 'zod'
import { variableStringSchema } from '../../../utils'
import { blockBaseSchema } from '../../shared'
import { BubbleBlockType } from '../constants'
export const embedBubbleContentSchema = z.object({
url: z.string().optional(),
height: z.number().or(variableStringSchema).optional(),
})
export const embedBubbleBlockSchema = blockBaseSchema.merge(
z.object({
type: z.enum([BubbleBlockType.EMBED]),
content: embedBubbleContentSchema.optional(),
})
)
export type EmbedBubbleBlock = z.infer<typeof embedBubbleBlockSchema>

View File

@ -0,0 +1,7 @@
import { ImageBubbleBlock } from './schema'
export const defaultImageBubbleContent = {
clickLink: {
alt: 'Bubble image',
},
} as const satisfies ImageBubbleBlock['content']

View File

@ -0,0 +1 @@
export * from './schema'

View File

@ -1,6 +1,6 @@
import { z } from 'zod'
import { blockBaseSchema } from '../baseSchemas'
import { BubbleBlockType } from './enums'
import { BubbleBlockType } from '../constants'
import { blockBaseSchema } from '../../shared'
export const imageBubbleContentSchema = z.object({
url: z.string().optional(),
@ -15,11 +15,8 @@ export const imageBubbleContentSchema = z.object({
export const imageBubbleBlockSchema = blockBaseSchema.merge(
z.object({
type: z.enum([BubbleBlockType.IMAGE]),
content: imageBubbleContentSchema,
content: imageBubbleContentSchema.optional(),
})
)
export const defaultImageBubbleContent: ImageBubbleContent = {}
export type ImageBubbleBlock = z.infer<typeof imageBubbleBlockSchema>
export type ImageBubbleContent = z.infer<typeof imageBubbleContentSchema>

View File

@ -3,4 +3,4 @@ export * from './embed'
export * from './image'
export * from './text'
export * from './video'
export * from './enums'
export * from './schema'

View File

@ -0,0 +1,21 @@
import { z } from 'zod'
import { audioBubbleBlockSchema } from './audio'
import { embedBubbleBlockSchema } from './embed'
import { imageBubbleBlockSchema } from './image'
import { textBubbleBlockSchema } from './text'
import { videoBubbleBlockSchema } from './video'
export const bubbleBlockSchemas = [
textBubbleBlockSchema,
imageBubbleBlockSchema,
videoBubbleBlockSchema,
embedBubbleBlockSchema,
audioBubbleBlockSchema,
] as const
export const bubbleBlockSchema = z.discriminatedUnion('type', [
...bubbleBlockSchemas,
])
export type BubbleBlock = z.infer<typeof bubbleBlockSchema>
export type BubbleBlockContent = BubbleBlock['content']

View File

@ -0,0 +1 @@
export * from './schema'

View File

@ -1,22 +1,18 @@
import { z } from 'zod'
import { blockBaseSchema } from '../baseSchemas'
import { BubbleBlockType } from './enums'
import type { TElement } from '@udecode/plate-common'
export const defaultTextBubbleContent: TextBubbleContent = {
richText: [],
}
import { blockBaseSchema } from '../../shared'
import { BubbleBlockType } from '../constants'
export const textBubbleContentSchema = z.object({
html: z.string().optional(),
richText: z.array(z.any()),
richText: z.array(z.any()).optional(),
plainText: z.string().optional(),
})
export const textBubbleBlockSchema = blockBaseSchema.merge(
z.object({
type: z.enum([BubbleBlockType.TEXT]),
content: textBubbleContentSchema,
content: textBubbleContentSchema.optional(),
})
)
@ -24,6 +20,5 @@ export type TextBubbleBlock = Omit<
z.infer<typeof textBubbleBlockSchema>,
'content'
> & {
content: { richText: TElement[]; html?: string; plainText?: string }
content?: { richText?: TElement[]; html?: string; plainText?: string }
}
export type TextBubbleContent = TextBubbleBlock['content']

View File

@ -3,3 +3,7 @@ export enum VideoBubbleContentType {
YOUTUBE = 'youtube',
VIMEO = 'vimeo',
}
export const defaultVideoBubbleContent = {
height: 400,
} as const

View File

@ -1,2 +1 @@
export * from './enums'
export * from './schemas'
export * from './schema'

View File

@ -1,8 +1,8 @@
import { z } from 'zod'
import { blockBaseSchema } from '../../baseSchemas'
import { BubbleBlockType } from '../enums'
import { VideoBubbleContentType } from './enums'
import { blockBaseSchema } from '../../shared'
import { VideoBubbleContentType } from './constants'
import { variableStringSchema } from '../../../utils'
import { BubbleBlockType } from '../constants'
export const videoBubbleContentSchema = z.object({
url: z.string().optional(),
@ -14,11 +14,8 @@ export const videoBubbleContentSchema = z.object({
export const videoBubbleBlockSchema = blockBaseSchema.merge(
z.object({
type: z.enum([BubbleBlockType.VIDEO]),
content: videoBubbleContentSchema,
content: videoBubbleContentSchema.optional(),
})
)
export const defaultVideoBubbleContent: VideoBubbleContent = {}
export type VideoBubbleBlock = z.infer<typeof videoBubbleBlockSchema>
export type VideoBubbleContent = z.infer<typeof videoBubbleContentSchema>