Skip to content

Commit 2db5337

Browse files
committed
fix: infer schema for script without schema in flows
1 parent 7e774fb commit 2db5337

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

frontend/src/lib/scripts.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,23 @@ export async function loadSchema(path: string, hash?: string): Promise<Schema> {
3232
workspace: get(workspaceStore)!,
3333
hash
3434
})
35-
return script.schema as any
35+
return inferSchemaIfNecessary(script)
3636
} else {
3737
const script = await ScriptService.getScriptByPath({
3838
workspace: get(workspaceStore)!,
3939
path: path ?? ''
4040
})
41+
return inferSchemaIfNecessary(script)
42+
}
43+
}
44+
45+
async function inferSchemaIfNecessary(script: Script) {
46+
if (script.schema) {
4147
return script.schema as any
48+
} else {
49+
const newSchema = emptySchema()
50+
await inferArgs(script.language, script.content ?? '', newSchema)
51+
return newSchema
4252
}
4353
}
4454

0 commit comments

Comments
 (0)