0

Update Flow

by
Published today

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.

Script windmill Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 4 hours ago
1
//native
2

3
import * as wmill from "windmill-client"
4

5
// windmill-client errors only carry the status text: throw the response body, which says why
6
wmill.OpenAPI.interceptors.response.use(async (response) => {
7
  if (!response.ok) {
8
    throw new Error(`${response.status} ${await response.text()}`)
9
  }
10
  return response
11
})
12

13
export type DynSelect_path = string
14

15
export async function path() {
16
  const paths = await wmill.FlowService.listFlowPaths({
17
    workspace: wmill.getWorkspace(),
18
  })
19
  return paths.map((p) => ({ value: p, label: p }))
20
}
21

22
/**
23
 * Update Flow
24
 * 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.
25
 */
26
export async function main(
27
  path: DynSelect_path,
28
  value: { [key: string]: any },
29
  schema: { [key: string]: any } | undefined,
30
  summary: string | undefined,
31
  description: string | undefined
32
) {
33
  const workspace = wmill.getWorkspace()
34
  const current = await wmill.FlowService.getFlowByPath({ workspace, path })
35
  return await wmill.FlowService.updateFlow({
36
    workspace,
37
    path,
38
    requestBody: {
39
      path,
40
      summary: summary || current.summary,
41
      description: description || current.description,
42
      value: value as any,
43
      schema: schema && Object.keys(schema).length ? schema : current.schema,
44
    },
45
  })
46
}
47