update app

Script windmill Verified

by admin ยท 8/13/2023

The script

Submitted by admin Typescript (fetch-only)
Verified 370 days ago
1
/**
2
 * update app
3
 *
4
 */
5
export async function main(
6
  workspace: string,
7
  path: string,
8
  body: {
9
    path?: string;
10
    summary?: string;
11
    value?: unknown;
12
    policy?: {
13
      triggerables?: { [k: string]: { [k: string]: unknown } };
14
      execution_mode?: "viewer" | "publisher" | "anonymous";
15
      on_behalf_of?: string;
16
      on_behalf_of_email?: string;
17
      [k: string]: unknown;
18
    };
19
    deployment_message?: string;
20
    [k: string]: unknown;
21
  }
22
) {
23
  const url = new URL(`${BASE_URL}/api/w/${workspace}/apps/update/${path}`);
24

25
  const response = await fetch(url, {
26
    method: "POST",
27
    headers: {
28
      "Content-Type": "application/json",
29
      Authorization: "Bearer " + WM_TOKEN,
30
    },
31
    body: JSON.stringify(body),
32
  });
33
  if (!response.ok) {
34
    const text = await response.text();
35
    throw new Error(`${response.status} ${text}`);
36
  }
37
  return await response.text();
38
}
39