This commit is contained in:
Siddharth Ganesan
2025-07-08 22:07:54 -07:00
parent a5883171f9
commit 0b01d4bc78
5 changed files with 16 additions and 16 deletions

View File

@@ -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<string, Record<string, any>> = {}
const subBlockValues: Record<string, Record<string, any>> = {}
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 }
)
}
}
}

View File

@@ -41,4 +41,4 @@ export async function POST(request: NextRequest) {
{ status: 500 }
)
}
}
}

View File

@@ -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,

View File

@@ -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<string, Record<string, any>>
): Record<string, any> {
@@ -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'}`
}
}
}

View File

@@ -26,7 +26,7 @@ type WorkflowYamlStore = WorkflowYamlState & WorkflowYamlActions
function getSubBlockValues() {
const workflowState = useWorkflowStore.getState()
const subBlockStore = useSubBlockStore.getState()
const subBlockValues: Record<string, Record<string, any>> = {}
Object.entries(workflowState.blocks).forEach(([blockId]) => {
subBlockValues[blockId] = {}
@@ -38,7 +38,7 @@ function getSubBlockValues() {
}
})
})
return subBlockValues
}
@@ -98,7 +98,7 @@ export const useWorkflowYamlStore = create<WorkflowYamlStore>()(
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<WorkflowYamlStore>()(
getYaml: () => {
// Initialize subscriptions on first use
initializeSubscriptions()
const currentTime = Date.now()
const { yaml, lastGenerated } = get()