Skip to content

Commit e37f362

Browse files
committed
Lint
1 parent bb9291a commit e37f362

File tree

6 files changed

+48
-36
lines changed

6 files changed

+48
-36
lines changed

apps/sim/app/api/workflows/[id]/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
110110
parallelsCount: Object.keys(normalizedData.parallels).length,
111111
loops: normalizedData.loops,
112112
})
113-
113+
114114
// Debug: Log sample block data from normalized tables
115115
const sampleBlockId = Object.keys(normalizedData.blocks)[0]
116116
if (sampleBlockId) {
117117
logger.debug(`[${requestId}] Sample block from normalized tables:`, {
118118
blockId: sampleBlockId,
119119
block: normalizedData.blocks[sampleBlockId],
120-
subBlocks: normalizedData.blocks[sampleBlockId]?.subBlocks
120+
subBlocks: normalizedData.blocks[sampleBlockId]?.subBlocks,
121121
})
122122
}
123123
// Use normalized table data - reconstruct complete state object

apps/sim/app/api/workflows/[id]/state/route.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,19 @@ export async function PUT(request: NextRequest, { params }: { params: Promise<{
8585
return NextResponse.json({ error: 'Access denied' }, { status: 403 })
8686
}
8787

88-
// Save to normalized tables
88+
// Save to normalized tables
8989
logger.info(`[${requestId}] Saving workflow ${workflowId} state to normalized tables`)
90-
90+
9191
// Debug: Log sample block data being received
9292
const sampleBlockId = Object.keys(state.blocks)[0]
9393
if (sampleBlockId) {
9494
logger.debug(`[${requestId}] Sample block data received:`, {
9595
blockId: sampleBlockId,
9696
block: state.blocks[sampleBlockId],
97-
subBlocks: state.blocks[sampleBlockId]?.subBlocks
97+
subBlocks: state.blocks[sampleBlockId]?.subBlocks,
9898
})
9999
}
100-
100+
101101
// Ensure all required fields are present for WorkflowState type
102102
const workflowState = {
103103
blocks: state.blocks,
@@ -111,7 +111,7 @@ export async function PUT(request: NextRequest, { params }: { params: Promise<{
111111
hasActiveSchedule: state.hasActiveSchedule || false,
112112
hasActiveWebhook: state.hasActiveWebhook || false,
113113
}
114-
114+
115115
const saveResult = await saveWorkflowToNormalizedTables(workflowId, workflowState)
116116

117117
if (!saveResult.success) {

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/control-bar/components/import-controls/import-controls.tsx

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,22 +117,26 @@ export function ImportControls({ disabled = false }: ImportControlsProps) {
117117
// Import the YAML into the new workflow BEFORE navigation (creates complete state and saves directly to DB)
118118
// This avoids timing issues with workflow reload during navigation
119119
logger.info('Importing YAML into new workflow before navigation')
120-
const result = await importWorkflowFromYaml(yamlContent, {
121-
addBlock: collaborativeAddBlock,
122-
addEdge: collaborativeAddEdge,
123-
applyAutoLayout: () => {
124-
// Trigger auto layout
125-
window.dispatchEvent(new CustomEvent('trigger-auto-layout'))
120+
const result = await importWorkflowFromYaml(
121+
yamlContent,
122+
{
123+
addBlock: collaborativeAddBlock,
124+
addEdge: collaborativeAddEdge,
125+
applyAutoLayout: () => {
126+
// Trigger auto layout
127+
window.dispatchEvent(new CustomEvent('trigger-auto-layout'))
128+
},
129+
setSubBlockValue: (blockId: string, subBlockId: string, value: any) => {
130+
// Use the collaborative function - the same one called when users type into fields
131+
collaborativeSetSubblockValue(blockId, subBlockId, value)
132+
},
133+
getExistingBlocks: () => {
134+
// For a new workflow, we'll get the starter block from the server
135+
return {}
136+
},
126137
},
127-
setSubBlockValue: (blockId: string, subBlockId: string, value: any) => {
128-
// Use the collaborative function - the same one called when users type into fields
129-
collaborativeSetSubblockValue(blockId, subBlockId, value)
130-
},
131-
getExistingBlocks: () => {
132-
// For a new workflow, we'll get the starter block from the server
133-
return {}
134-
},
135-
}, newWorkflowId) // Pass the new workflow ID to import into
138+
newWorkflowId
139+
) // Pass the new workflow ID to import into
136140

137141
// Navigate to the new workflow AFTER import is complete
138142
if (result.success) {

apps/sim/lib/workflows/db-helpers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ export async function loadWorkflowFromNormalizedTables(
6969
parentId,
7070
extent,
7171
}
72-
72+
7373
// Debug: Log sample block subBlocks from database
7474
if (block.type === 'agent') {
7575
logger.debug(`Loaded ${block.type} block from database:`, {
7676
blockId: block.id,
77-
subBlocks: block.subBlocks
77+
subBlocks: block.subBlocks,
7878
})
7979
}
8080
})
@@ -175,7 +175,7 @@ export async function saveWorkflowToNormalizedTables(
175175
logger.debug(`Saving ${blockInserts.length} blocks. Sample block:`, {
176176
blockId: blockInserts[0].id,
177177
type: blockInserts[0].type,
178-
subBlocks: blockInserts[0].subBlocks
178+
subBlocks: blockInserts[0].subBlocks,
179179
})
180180
}
181181

apps/sim/stores/workflows/registry/store.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,10 @@ export const useWorkflowRegistry = create<WorkflowRegistry>()(
475475
})
476476

477477
// Debug: Log what values are being extracted from the database
478-
logger.debug(`Extracted subblock values from database for workflow ${id}:`, subblockValues)
478+
logger.debug(
479+
`Extracted subblock values from database for workflow ${id}:`,
480+
subblockValues
481+
)
479482

480483
// Update subblock store for this workflow
481484
useSubBlockStore.setState((state) => ({
@@ -484,7 +487,7 @@ export const useWorkflowRegistry = create<WorkflowRegistry>()(
484487
[id]: subblockValues,
485488
},
486489
}))
487-
490+
488491
// Debug: Verify SubBlockStore was updated
489492
const updatedValues = useSubBlockStore.getState().workflowValues[id]
490493
logger.debug(`SubBlockStore updated for workflow ${id}:`, updatedValues)

apps/sim/stores/workflows/yaml/importer.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -378,15 +378,18 @@ export async function importWorkflowFromYaml(
378378

379379
// Get the existing workflow state (to preserve starter blocks if they exist)
380380
let existingBlocks: Record<string, any> = {}
381-
381+
382382
if (targetWorkflowId) {
383383
// For target workflow, fetch from API
384384
try {
385385
const response = await fetch(`/api/workflows/${targetWorkflowId}`)
386386
if (response.ok) {
387387
const workflowData = await response.json()
388388
existingBlocks = workflowData.data?.state?.blocks || {}
389-
logger.debug(`Fetched existing blocks for target workflow ${targetWorkflowId}:`, Object.keys(existingBlocks))
389+
logger.debug(
390+
`Fetched existing blocks for target workflow ${targetWorkflowId}:`,
391+
Object.keys(existingBlocks)
392+
)
390393
}
391394
} catch (error) {
392395
logger.warn(`Failed to fetch existing blocks for workflow ${targetWorkflowId}:`, error)
@@ -395,7 +398,7 @@ export async function importWorkflowFromYaml(
395398
// For active workflow, use from store
396399
existingBlocks = workflowActions.getExistingBlocks()
397400
}
398-
401+
399402
const existingStarterBlocks = Object.values(existingBlocks).filter(
400403
(block: any) => block.type === 'starter'
401404
)
@@ -413,8 +416,10 @@ export async function importWorkflowFromYaml(
413416
if (!activeWorkflowId) {
414417
return { success: false, errors: ['No active workflow'], warnings: [] }
415418
}
416-
417-
logger.info(`Importing YAML into workflow: ${activeWorkflowId} ${targetWorkflowId ? '(specified target)' : '(active workflow)'}`)
419+
420+
logger.info(
421+
`Importing YAML into workflow: ${activeWorkflowId} ${targetWorkflowId ? '(specified target)' : '(active workflow)'}`
422+
)
418423

419424
// Build complete blocks object
420425
const completeBlocks: Record<string, any> = {}
@@ -615,11 +620,11 @@ export async function importWorkflowFromYaml(
615620
// Save directly to database via API
616621
logger.info('Saving complete workflow state directly to database...')
617622
logger.debug('Sample block being saved:', {
618-
firstBlockId: Object.keys(completeBlocks)[0],
623+
firstBlockId: Object.keys(completeBlocks)[0],
619624
firstBlock: Object.values(completeBlocks)[0],
620-
firstBlockSubBlocks: Object.values(completeBlocks)[0]?.subBlocks
625+
firstBlockSubBlocks: Object.values(completeBlocks)[0]?.subBlocks,
621626
})
622-
627+
623628
const response = await fetch(`/api/workflows/${activeWorkflowId}/state`, {
624629
method: 'PUT',
625630
headers: {
@@ -654,7 +659,7 @@ export async function importWorkflowFromYaml(
654659
[activeWorkflowId]: completeSubBlockValues,
655660
},
656661
}))
657-
662+
658663
// Verify SubBlockStore was updated
659664
const subBlockStoreValues = useSubBlockStore.getState().workflowValues[activeWorkflowId]
660665
logger.debug('SubBlockStore after update:', subBlockStoreValues)

0 commit comments

Comments
 (0)