Files
sim/blocks/types.ts

56 lines
1.3 KiB
TypeScript

import type { SVGProps } from 'react'
import type { JSX } from 'react'
export type BlockIcon = (props: SVGProps<SVGSVGElement>) => JSX.Element
export type BlockCategory = 'basic' | 'advanced'
export type OutputType = 'string' | 'number' | 'json' | 'boolean' | 'any'
export type ParamType = 'string' | 'number' | 'boolean' | 'json'
export type SubBlockType = 'short-input' | 'long-input' | 'dropdown' | 'slider' | 'table' | 'code'
export type SubBlockLayout = 'full' | 'half'
export interface SubBlockConfig {
id: string
title: string
type: SubBlockType
layout?: SubBlockLayout
options?: string[]
min?: number
max?: number
columns?: string[]
placeholder?: string
password?: boolean
}
export type OutputTypeConfig = OutputType | {
default: OutputType
dependsOn: {
subBlockId: string
condition: {
whenEmpty: OutputType
whenFilled: OutputType
}
}
}
export interface BlockConfig {
type: string
toolbar: {
title: string
description: string
bgColor: string
icon: BlockIcon
category: BlockCategory
}
tools: {
access: string[]
config?: {
tool: (params: Record<string, any>) => string
}
}
workflow: {
outputType: OutputTypeConfig
subBlocks: SubBlockConfig[]
inputs?: Record<string, ParamType>
}
}