mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
Simplified blocks file structure
This commit is contained in:
@@ -18,9 +18,9 @@ import ReactFlow, {
|
||||
getSmoothStepPath,
|
||||
} from 'reactflow'
|
||||
import 'reactflow/dist/style.css'
|
||||
import { getBlock } from '../../../blocks/configs'
|
||||
import { getBlock } from '../../../blocks'
|
||||
import { WorkflowBlock } from '../components/workflow-block/workflow-block'
|
||||
import { BlockConfig } from '../../../blocks/types/block'
|
||||
import { BlockConfig } from '../../../blocks/types'
|
||||
import { useWorkflowStore } from '@/stores/workflow/workflow-store'
|
||||
import { initializeStateLogger } from '@/stores/workflow/state-logger'
|
||||
import { Serializer } from '@/serializer'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { BlockConfig } from '../../../../blocks/types/block'
|
||||
import type { BlockConfig } from '../../../../blocks/types'
|
||||
|
||||
export type ToolbarBlockProps = {
|
||||
config: BlockConfig
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { SubBlockConfig } from '../../../../../../blocks/types/block'
|
||||
import { SubBlockConfig } from '../../../../../../blocks/types'
|
||||
import { Label } from '@/components/ui/label'
|
||||
import { ShortInput } from './components/short-input'
|
||||
import { LongInput } from './components/long-input'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Card } from '@/components/ui/card'
|
||||
import { BlockConfig, SubBlockConfig } from '../../../../blocks/types/block'
|
||||
import { BlockConfig, SubBlockConfig } from '../../../../blocks/types'
|
||||
import { SubBlock } from './components/sub-block/sub-block'
|
||||
import { Handle, Position } from 'reactflow'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { AgentIcon } from '@/components/icons'
|
||||
import { BlockConfig } from '../types/block'
|
||||
import { BlockConfig } from '../types'
|
||||
|
||||
export const AgentBlock: BlockConfig = {
|
||||
type: 'agent',
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ApiIcon } from '@/components/icons'
|
||||
import { BlockConfig } from '../types/block'
|
||||
import { BlockConfig } from '../types'
|
||||
|
||||
export const ApiBlock: BlockConfig = {
|
||||
type: 'api',
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CodeIcon } from '@/components/icons'
|
||||
import { BlockConfig } from '../types/block'
|
||||
import { BlockConfig } from '../types'
|
||||
|
||||
export const FunctionBlock: BlockConfig = {
|
||||
type: 'function',
|
||||
@@ -1,29 +0,0 @@
|
||||
import { BlockConfig } from '../types/block'
|
||||
|
||||
// Import blocks
|
||||
import { AgentBlock } from './agent'
|
||||
import { ApiBlock } from './api'
|
||||
import { FunctionBlock } from './function'
|
||||
|
||||
// Export blocks for ease of use
|
||||
export { AgentBlock, ApiBlock, FunctionBlock }
|
||||
|
||||
// Combined blocks registry
|
||||
export const BLOCKS: BlockConfig[] = [
|
||||
AgentBlock,
|
||||
ApiBlock,
|
||||
FunctionBlock,
|
||||
]
|
||||
|
||||
// Helper functions
|
||||
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 = (): string[] =>
|
||||
BLOCKS.map(block => block.type)
|
||||
|
||||
export const isValidBlockType = (type: string): type is string =>
|
||||
BLOCKS.some(block => block.type === type)
|
||||
+29
-2
@@ -1,2 +1,29 @@
|
||||
export * from './types/block'
|
||||
export * from './configs'
|
||||
import { BlockConfig } from './types'
|
||||
|
||||
// Import blocks
|
||||
import { AgentBlock } from './blocks/agent'
|
||||
import { ApiBlock } from './blocks/api'
|
||||
import { FunctionBlock } from './blocks/function'
|
||||
|
||||
// Export blocks for ease of use
|
||||
export { AgentBlock, ApiBlock, FunctionBlock }
|
||||
|
||||
// Combined blocks registry
|
||||
export const BLOCKS: BlockConfig[] = [
|
||||
AgentBlock,
|
||||
ApiBlock,
|
||||
FunctionBlock,
|
||||
]
|
||||
|
||||
// Helper functions
|
||||
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 = (): string[] =>
|
||||
BLOCKS.map(block => block.type)
|
||||
|
||||
export const isValidBlockType = (type: string): type is string =>
|
||||
BLOCKS.some(block => block.type === type)
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Node, Edge } from 'reactflow'
|
||||
import { OutputType, SubBlockType } from '@/blocks/types/block'
|
||||
import { OutputType, SubBlockType } from '@/blocks/block'
|
||||
|
||||
export interface Position {
|
||||
x: number
|
||||
|
||||
@@ -2,7 +2,7 @@ import { create } from 'zustand'
|
||||
import { devtools } from 'zustand/middleware'
|
||||
import { Edge } from 'reactflow'
|
||||
import { Position, WorkflowStore } from './types'
|
||||
import { getBlock } from '@/blocks/configs'
|
||||
import { getBlock } from '@/blocks'
|
||||
|
||||
const initialState = {
|
||||
blocks: {},
|
||||
|
||||
Reference in New Issue
Block a user