Edits history of script submission #23556 for ' Create Flow (windmill)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //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
    })
    
    /**
     * Create Flow
     * Deploy a new flow at a path that holds none, from its OpenFlow value (modules, failure module, ...) and optional input schema.
     */
    export async function main(
      path: string,
      summary: string,
      value: { [key: string]: any },
      schema: { [key: string]: any } | undefined,
      description: string | undefined
    ) {
      return await wmill.FlowService.createFlow({
        workspace: wmill.getWorkspace(),
        requestBody: {
          path,
          summary,
          description: description || undefined,
          value: value as any,
          schema: schema && Object.keys(schema).length ? schema : undefined,
        },
      })
    }
    

    Submitted by hugo989 5 hours ago