9
packages/schemas/features/blocks/forged/helpers.ts
Normal file
9
packages/schemas/features/blocks/forged/helpers.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { forgedBlocks } from '@typebot.io/forge-repository/definitions'
|
||||
import { ForgedBlock } from '@typebot.io/forge-repository/types'
|
||||
import { Block } from '../schema'
|
||||
|
||||
export const isForgedBlock = (block: Block): block is ForgedBlock =>
|
||||
block.type in forgedBlocks
|
||||
export const isForgedBlockType = (
|
||||
type: Block['type']
|
||||
): type is ForgedBlock['type'] => type in forgedBlocks
|
@ -6,7 +6,7 @@ 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'
|
||||
import { forgedBlockSchemas } from '@typebot.io/forge-repository/schemas'
|
||||
|
||||
export type BlockWithOptions = Extract<Block, { options?: any }>
|
||||
|
||||
@ -34,15 +34,8 @@ export const blockSchemaV6 = z
|
||||
...inputBlockSchemas.v6,
|
||||
...logicBlockSchemas.v6,
|
||||
...integrationBlockSchemas.v6,
|
||||
...Object.values(forgedBlockSchemas),
|
||||
])
|
||||
.or(
|
||||
blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum(enabledBlocks),
|
||||
options: z.any().optional(),
|
||||
})
|
||||
)
|
||||
)
|
||||
.openapi({
|
||||
title: 'Block',
|
||||
ref: 'block',
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { enabledBlocks } from '@typebot.io/forge-repository'
|
||||
import { forgedBlockIds } from '@typebot.io/forge-repository/constants'
|
||||
import {
|
||||
Block,
|
||||
InputBlock,
|
||||
@ -62,9 +62,7 @@ export const isConditionBlock = (block: Block): block is ConditionBlock =>
|
||||
|
||||
export const isIntegrationBlock = (block: Block): block is IntegrationBlock =>
|
||||
(
|
||||
Object.values(IntegrationBlockType).concat(
|
||||
enabledBlocks as readonly any[]
|
||||
) as any[]
|
||||
Object.values(IntegrationBlockType).concat(forgedBlockIds as any[]) as any[]
|
||||
).includes(block.type)
|
||||
|
||||
export const isWebhookBlock = (block: Block): block is HttpRequestBlock =>
|
||||
|
Reference in New Issue
Block a user