2023-01-25 11:27:47 +01:00
|
|
|
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'
|
2022-06-11 07:27:38 +02:00
|
|
|
import {
|
2023-01-25 11:27:47 +01:00
|
|
|
InputBlock,
|
2022-06-11 07:27:38 +02:00
|
|
|
InputBlockOptions,
|
2023-01-25 11:27:47 +01:00
|
|
|
inputBlockSchema,
|
|
|
|
} from './inputs/schemas'
|
|
|
|
import { IntegrationBlockType } from './integrations/enums'
|
|
|
|
import {
|
|
|
|
IntegrationBlock,
|
2022-06-11 07:27:38 +02:00
|
|
|
IntegrationBlockOptions,
|
2023-01-25 11:27:47 +01:00
|
|
|
integrationBlockSchema,
|
|
|
|
} from './integrations/schemas'
|
|
|
|
import { ConditionBlock } from './logic/condition'
|
|
|
|
import { LogicBlockType } from './logic/enums'
|
2022-06-11 07:27:38 +02:00
|
|
|
import {
|
2023-01-25 11:27:47 +01:00
|
|
|
LogicBlock,
|
|
|
|
LogicBlockOptions,
|
|
|
|
logicBlockSchema,
|
|
|
|
} from './logic/logicBlock'
|
|
|
|
import { blockBaseSchema } from './baseSchemas'
|
|
|
|
import { startBlockSchema } from './start/schemas'
|
2022-06-11 07:27:38 +02:00
|
|
|
|
|
|
|
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>
|
|
|
|
|
|
|
|
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>
|