//native
import * as wmill from "windmill-client"
// windmill-client errors only carry the status text: throw the response body, which says why
wmill.OpenAPI.interceptors.response.use(async (response) => {
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return response
})
export type DynSelect_path = string
export async function path() {
const paths = await wmill.ScriptService.listScriptPaths({
workspace: wmill.getWorkspace(),
})
return paths.map((p) => ({ value: p, label: p }))
}
/**
* Run Script by Path and Wait for Result
* Run a script and return its result. Holds one HTTP request open, so for runs longer than the instance's request timeout use Run Script by Path followed by Wait for Job.
*/
export async function main(
path: DynSelect_path,
args: { [key: string]: any } | undefined,
tag: string | undefined
) {
return await wmill.JobService.runWaitResultScriptByPath({
workspace: wmill.getWorkspace(),
path,
requestBody: args ?? {},
tag: tag || undefined,
})
}
Submitted by hugo989 5 hours ago