diff --git a/apps/sim/app/api/tools/get-user-workflow/route.ts b/apps/sim/app/api/tools/get-user-workflow/route.ts index ae67b1882..dea7b254e 100644 --- a/apps/sim/app/api/tools/get-user-workflow/route.ts +++ b/apps/sim/app/api/tools/get-user-workflow/route.ts @@ -1,10 +1,10 @@ -import { NextRequest, NextResponse } from 'next/server' +import { eq } from 'drizzle-orm' +import { type NextRequest, NextResponse } from 'next/server' import { createLogger } from '@/lib/logs/console-logger' +import { loadWorkflowFromNormalizedTables } from '@/lib/workflows/db-helpers' +import { generateWorkflowYaml } from '@/lib/workflows/yaml-generator' import { db } from '@/db' import { workflow as workflowTable } from '@/db/schema' -import { eq } from 'drizzle-orm' -import { generateWorkflowYaml } from '@/lib/workflows/yaml-generator' -import { loadWorkflowFromNormalizedTables } from '@/lib/workflows/db-helpers' const logger = createLogger('GetUserWorkflowAPI') @@ -38,7 +38,7 @@ export async function POST(request: NextRequest) { // Try to load from normalized tables first, fallback to JSON blob let workflowState: any = null - let subBlockValues: Record> = {} + const subBlockValues: Record> = {} const normalizedData = await loadWorkflowFromNormalizedTables(workflowId) if (normalizedData) { @@ -48,7 +48,7 @@ export async function POST(request: NextRequest) { loops: normalizedData.loops, parallels: normalizedData.parallels, } - + // Extract subblock values from normalized data Object.entries(normalizedData.blocks).forEach(([blockId, block]) => { subBlockValues[blockId] = {} @@ -64,7 +64,7 @@ export async function POST(request: NextRequest) { // For JSON blob, subblock values are embedded in the block state Object.entries((workflowState.blocks as any) || {}).forEach(([blockId, block]) => { subBlockValues[blockId] = {} - Object.entries(((block as any).subBlocks || {})).forEach(([subBlockId, subBlock]) => { + Object.entries((block as any).subBlocks || {}).forEach(([subBlockId, subBlock]) => { if ((subBlock as any).value !== undefined) { subBlockValues[blockId][subBlockId] = (subBlock as any).value } @@ -129,4 +129,4 @@ export async function POST(request: NextRequest) { { status: 500 } ) } -} \ No newline at end of file +} diff --git a/apps/sim/app/api/workflows/yaml/convert/route.ts b/apps/sim/app/api/workflows/yaml/convert/route.ts index 7bb70b7de..4da955add 100644 --- a/apps/sim/app/api/workflows/yaml/convert/route.ts +++ b/apps/sim/app/api/workflows/yaml/convert/route.ts @@ -41,4 +41,4 @@ export async function POST(request: NextRequest) { { status: 500 } ) } -} \ No newline at end of file +} diff --git a/apps/sim/lib/copilot/tools.ts b/apps/sim/lib/copilot/tools.ts index 12552e6d5..11a5330b4 100644 --- a/apps/sim/lib/copilot/tools.ts +++ b/apps/sim/lib/copilot/tools.ts @@ -99,7 +99,7 @@ const getUserWorkflowTool: CopilotTool = { const activeWorkflowId = registry.activeWorkflowId const activeWorkflow = activeWorkflowId ? registry.workflows[activeWorkflowId] : null - let metadata = undefined + let metadata if (activeWorkflow) { metadata = { workflowId: activeWorkflowId, diff --git a/apps/sim/lib/workflows/yaml-generator.ts b/apps/sim/lib/workflows/yaml-generator.ts index f216d4d06..a1fd7d30d 100644 --- a/apps/sim/lib/workflows/yaml-generator.ts +++ b/apps/sim/lib/workflows/yaml-generator.ts @@ -24,7 +24,7 @@ interface YamlWorkflow { * This version works without client-side stores by using the provided subblock values */ function extractBlockInputs( - blockState: BlockState, + blockState: BlockState, blockId: string, subBlockValues?: Record> ): Record { @@ -189,4 +189,4 @@ export function generateWorkflowYaml( logger.error('Failed to generate workflow YAML:', error) return `# Error generating YAML: ${error instanceof Error ? error.message : 'Unknown error'}` } -} \ No newline at end of file +} diff --git a/apps/sim/stores/workflows/yaml/store.ts b/apps/sim/stores/workflows/yaml/store.ts index 5e0209987..69c62fc3a 100644 --- a/apps/sim/stores/workflows/yaml/store.ts +++ b/apps/sim/stores/workflows/yaml/store.ts @@ -26,7 +26,7 @@ type WorkflowYamlStore = WorkflowYamlState & WorkflowYamlActions function getSubBlockValues() { const workflowState = useWorkflowStore.getState() const subBlockStore = useSubBlockStore.getState() - + const subBlockValues: Record> = {} Object.entries(workflowState.blocks).forEach(([blockId]) => { subBlockValues[blockId] = {} @@ -38,7 +38,7 @@ function getSubBlockValues() { } }) }) - + return subBlockValues } @@ -98,7 +98,7 @@ export const useWorkflowYamlStore = create()( generateYaml: () => { // Initialize subscriptions on first use initializeSubscriptions() - + const workflowState = useWorkflowStore.getState() const subBlockValues = getSubBlockValues() const yaml = generateWorkflowYaml(workflowState, subBlockValues) @@ -112,7 +112,7 @@ export const useWorkflowYamlStore = create()( getYaml: () => { // Initialize subscriptions on first use initializeSubscriptions() - + const currentTime = Date.now() const { yaml, lastGenerated } = get()