2022-06-11 07:27:38 +02:00
|
|
|
import {
|
|
|
|
InputBlockOptions,
|
|
|
|
IntegrationBlockOptions,
|
|
|
|
Item,
|
|
|
|
LogicBlockOptions,
|
|
|
|
} from '.'
|
2022-11-15 11:02:26 +01:00
|
|
|
import { BubbleBlock, bubbleBlockSchema } from './bubbles'
|
2022-12-23 11:30:39 +01:00
|
|
|
import { ChoiceInputBlock, InputBlock, inputBlockSchema } from './inputs'
|
2022-11-15 11:02:26 +01:00
|
|
|
import { IntegrationBlock, integrationBlockSchema } from './integrations'
|
2022-06-11 07:27:38 +02:00
|
|
|
import { ConditionBlock, LogicBlock, logicBlockSchema } from './logic'
|
|
|
|
import { z } from 'zod'
|
|
|
|
import {
|
|
|
|
BubbleBlockType,
|
|
|
|
InputBlockType,
|
|
|
|
LogicBlockType,
|
|
|
|
blockBaseSchema,
|
2022-11-15 11:02:26 +01:00
|
|
|
IntegrationBlockType,
|
2022-06-11 07:27:38 +02:00
|
|
|
} 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
|
|
|
|
|
2022-12-23 11:30:39 +01:00
|
|
|
export type BlockWithItems = ConditionBlock | ChoiceInputBlock
|
2022-06-11 07:27:38 +02:00
|
|
|
|
|
|
|
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>
|