From b09873b15507e1f2981dacbd717c77791f7a76ca Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Tue, 13 Jun 2023 13:31:39 +0200 Subject: [PATCH] fix: infer schema for script without schema in flows --- frontend/src/lib/scripts.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/scripts.ts b/frontend/src/lib/scripts.ts index fa77031beb..4b6476ae91 100644 --- a/frontend/src/lib/scripts.ts +++ b/frontend/src/lib/scripts.ts @@ -32,13 +32,23 @@ export async function loadSchema(path: string, hash?: string): Promise { 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 } }