mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
Simplified block types and changed conditional to function
This commit is contained in:
@@ -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',
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
@@ -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
@@ -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,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
|
||||
|
||||
Reference in New Issue
Block a user