Simplified blocks file structure

This commit is contained in:
Emir Karabeg
2025-01-17 16:20:16 -08:00
parent 1820a9be10
commit a14e9fc8aa
12 changed files with 39 additions and 41 deletions
+2 -2
View File
@@ -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',
-29
View File
@@ -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
View File
@@ -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 -1
View File
@@ -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
+1 -1
View File
@@ -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: {},