mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-24 00:00:46 +00:00
22 lines
639 B
TypeScript
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
|
|
}
|
|
}
|