Simplified block types and changed conditional to function

This commit is contained in:
Emir Karabeg
2025-01-16 18:06:43 -08:00
parent 483fa354bf
commit 1287fd3311
8 changed files with 41 additions and 55 deletions
-37
View File
@@ -1,37 +0,0 @@
import { ConditionalIcon } from '@/components/icons'
import { BlockConfig } from '../types/block'
export const ConditionalBlock: BlockConfig = {
type: 'conditional',
toolbar: {
title: 'Conditional',
description: 'Add branching logic',
bgColor: '#FF972F',
icon: ConditionalIcon,
category: 'basic',
},
workflow: {
outputType: 'boolean',
subBlocks: [
{
id: 'conditionType',
title: 'Condition Type',
type: 'dropdown',
layout: 'full',
options: [
'Equals',
'Contains',
'Greater Than',
'Less Than',
'Regular Expression',
],
},
{
id: 'value',
title: 'Value',
type: 'short-input',
layout: 'full',
},
],
},
}
+24
View File
@@ -0,0 +1,24 @@
import { CodeIcon } from '@/components/icons'
import { BlockConfig } from '../types/block'
export const FunctionBlock: BlockConfig = {
type: 'function',
toolbar: {
title: 'Function',
description: 'Add custom logic',
bgColor: '#FF8D2F',
icon: CodeIcon,
category: 'basic',
},
workflow: {
outputType: 'json',
subBlocks: [
{
id: 'code',
title: 'Code',
type: 'code',
layout: 'full',
},
],
},
}
+10 -8
View File
@@ -1,27 +1,29 @@
import { BlockConfig, BlockType } from '../types/block'
import { BlockConfig } from '../types/block'
// Import blocks
import { AgentBlock } from './agent'
import { ApiBlock } from './api'
import { ConditionalBlock } from './conditional'
import { FunctionBlock } from './function'
// Export individual blocks
export { AgentBlock, ApiBlock, ConditionalBlock }
// Export blocks for ease of use
export { AgentBlock, ApiBlock, FunctionBlock }
// Combined blocks registry
export const BLOCKS: BlockConfig[] = [
AgentBlock,
ApiBlock,
ConditionalBlock,
FunctionBlock,
]
// Helper functions
export const getBlock = (type: BlockType): BlockConfig | undefined =>
export const getBlock = (type: string): BlockConfig | undefined =>
BLOCKS.find(block => block.type === type)
export const getBlocksByCategory = (category: 'basic' | 'advanced'): BlockConfig[] =>
BLOCKS.filter(block => block.toolbar.category === category)
export const getAllBlockTypes = (): BlockType[] =>
export const getAllBlockTypes = (): string[] =>
BLOCKS.map(block => block.type)
export const isValidBlockType = (type: string): type is BlockType =>
export const isValidBlockType = (type: string): type is string =>
BLOCKS.some(block => block.type === type)
+1 -2
View File
@@ -1,7 +1,6 @@
import type { SVGProps } from 'react'
import type { JSX } from 'react'
export type BlockType = 'agent' | 'api' | 'conditional'
export type BlockIcon = (props: SVGProps<SVGSVGElement>) => JSX.Element
export type BlockCategory = 'basic' | 'advanced'
export type OutputType = 'string' | 'number' | 'json' | 'boolean'
@@ -34,7 +33,7 @@ export type OutputTypeConfig = OutputType | {
}
export interface BlockConfig {
type: BlockType
type: string
toolbar: {
title: string
description: string