//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.FlowService.listFlowPaths({
workspace: wmill.getWorkspace(),
})
return paths.map((p) => ({ value: p, label: p }))
}
/**
* Update Flow
* Deploy a new version of a flow from its whole OpenFlow value. An empty summary, description or schema keeps the current one. Inline steps get their lockfiles in the background, so a run started right away may still run the previous version.
*/
export async function main(
path: DynSelect_path,
value: { [key: string]: any },
schema: { [key: string]: any } | undefined,
summary: string | undefined,
description: string | undefined
) {
const workspace = wmill.getWorkspace()
const current = await wmill.FlowService.getFlowByPath({ workspace, path })
return await wmill.FlowService.updateFlow({
workspace,
path,
requestBody: {
path,
summary: summary || current.summary,
description: description || current.description,
value: value as any,
schema: schema && Object.keys(schema).length ? schema : current.schema,
},
})
}
Submitted by hugo989 5 hours ago