run a one-off dependencies job

Script windmill Verified

by hugo697 ยท 3/6/2024

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 370 days ago
1
/**
2
 * run a one-off dependencies job
3
 *
4
 */
5
export async function main(
6
  workspace: string,
7
  body: {
8
    raw_scripts: {
9
      raw_code: string;
10
      path: string;
11
      language:
12
        | "python3"
13
        | "deno"
14
        | "go"
15
        | "bash"
16
        | "powershell"
17
        | "postgresql"
18
        | "mysql"
19
        | "bigquery"
20
        | "snowflake"
21
        | "mssql"
22
        | "graphql"
23
        | "nativets"
24
        | "bun";
25
      [k: string]: unknown;
26
    }[];
27
    entrypoint: string;
28
    [k: string]: unknown;
29
  }
30
) {
31
  const url = new URL(`${BASE_URL}/api/w/${workspace}/jobs/run/dependencies`);
32

33
  const response = await fetch(url, {
34
    method: "POST",
35
    headers: {
36
      "Content-Type": "application/json",
37
      Authorization: "Bearer " + WM_TOKEN,
38
    },
39
    body: JSON.stringify(body),
40
  });
41
  if (!response.ok) {
42
    const text = await response.text();
43
    throw new Error(`${response.status} ${text}`);
44
  }
45
  return await response.json();
46
}
47