0

Run Flow by Path

by
Published today

Queue a flow run and return its job id without waiting for it to finish.

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
 * Run Flow by Path
24
 * Queue a flow run and return its job id without waiting for it to finish.
25
 */
26
export async function main(
27
  path: DynSelect_path,
28
  args: { [key: string]: any } | undefined,
29
  scheduled_in_secs: number | undefined,
30
  tag: string | undefined
31
) {
32
  return await wmill.JobService.runFlowByPath({
33
    workspace: wmill.getWorkspace(),
34
    path,
35
    requestBody: args ?? {},
36
    scheduledInSecs: scheduled_in_secs ?? undefined,
37
    tag: tag || undefined,
38
  })
39
}
40