0

Create Flow

by
Published today

Deploy a new flow at a path that holds none, from its OpenFlow value (modules, failure module, ...) and optional input schema.

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
/**
14
 * Create Flow
15
 * Deploy a new flow at a path that holds none, from its OpenFlow value (modules, failure module, ...) and optional input schema.
16
 */
17
export async function main(
18
  path: string,
19
  summary: string,
20
  value: { [key: string]: any },
21
  schema: { [key: string]: any } | undefined,
22
  description: string | undefined
23
) {
24
  return await wmill.FlowService.createFlow({
25
    workspace: wmill.getWorkspace(),
26
    requestBody: {
27
      path,
28
      summary,
29
      description: description || undefined,
30
      value: value as any,
31
      schema: schema && Object.keys(schema).length ? schema : undefined,
32
    },
33
  })
34
}
35