2
0
Files
bot/packages/models/features/blocks/schemas.ts

77 lines
1.8 KiB
TypeScript
Raw Normal View History

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 {
InputBlock,
2022-06-11 07:27:38 +02:00
InputBlockOptions,
inputBlockSchema,
} from './inputs/schemas'
import { IntegrationBlockType } from './integrations/enums'
import {
IntegrationBlock,
2022-06-11 07:27:38 +02:00
IntegrationBlockOptions,
integrationBlockSchema,
} from './integrations/schemas'
import { ConditionBlock } from './logic/condition'
import { LogicBlockType } from './logic/enums'
2022-06-11 07:27:38 +02:00
import {
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
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>