fix: infer schema for script without schema in flows

This commit is contained in:
Ruben Fiszel
2023-06-13 13:31:39 +02:00
parent 6ebdd50455
commit b09873b155

View File

@@ -32,13 +32,23 @@ export async function loadSchema(path: string, hash?: string): Promise<Schema> {
workspace: get(workspaceStore)!,
hash
})
return script.schema as any
return inferSchemaIfNecessary(script)
} else {
const script = await ScriptService.getScriptByPath({
workspace: get(workspaceStore)!,
path: path ?? ''
})
return inferSchemaIfNecessary(script)
}
}
async function inferSchemaIfNecessary(script: Script) {
if (script.schema) {
return script.schema as any
} else {
const newSchema = emptySchema()
await inferArgs(script.language, script.content ?? '', newSchema)
return newSchema
}
}