0

Create Script

by
Published today

Deploy a new script at a path that holds none. Its lockfile is generated in the background: a run started before it lands fails.

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 Script
15
 * Deploy a new script at a path that holds none. Its lockfile is generated in the background: a run started before it lands fails.
16
 */
17
export async function main(
18
  path: string,
19
  language:
20
    | "bun"
21
    | "python3"
22
    | "deno"
23
    | "go"
24
    | "bash"
25
    | "powershell"
26
    | "postgresql"
27
    | "mysql"
28
    | "bigquery"
29
    | "snowflake"
30
    | "mssql"
31
    | "oracledb"
32
    | "graphql"
33
    | "nativets"
34
    | "bunnative"
35
    | "php"
36
    | "rust"
37
    | "ansible"
38
    | "csharp"
39
    | "nu"
40
    | "java"
41
    | "ruby"
42
    | "rlang"
43
    | "duckdb",
44
  content: string,
45
  summary: string | undefined,
46
  description: string | undefined
47
) {
48
  return await wmill.ScriptService.createScript({
49
    workspace: wmill.getWorkspace(),
50
    requestBody: {
51
      path,
52
      language,
53
      content,
54
      summary: summary || "",
55
      description: description || undefined,
56
    },
57
  })
58
}
59