Files
windmill/frontend/src/lib/scripts.ts
T
2022-07-05 11:26:13 +02:00

22 lines
639 B
TypeScript

import { get } from 'svelte/store'
import type { Schema } from './common'
import { ScriptService } from './gen'
import { inferArgs } from './infer'
import { workspaceStore } from './stores'
import { emptySchema } from './utils'
export async function loadSchema(path: string): Promise<Schema> {
if (path.startsWith('hub/')) {
const code = await ScriptService.getHubScriptContentByPath({ path })
const schema = emptySchema()
await inferArgs('deno', code, schema)
return schema
} else {
const script = await ScriptService.getScriptByPath({
workspace: get(workspaceStore)!,
path: path ?? ''
})
return script.schema
}
}