1 | |
2 | * create app |
3 | * |
4 | */ |
5 | export async function main( |
6 | workspace: string, |
7 | body: { |
8 | path: string; |
9 | value: unknown; |
10 | summary: string; |
11 | policy: { |
12 | triggerables?: { [k: string]: { [k: string]: unknown } }; |
13 | execution_mode?: "viewer" | "publisher" | "anonymous"; |
14 | on_behalf_of?: string; |
15 | on_behalf_of_email?: string; |
16 | [k: string]: unknown; |
17 | }; |
18 | draft_only?: boolean; |
19 | deployment_message?: string; |
20 | [k: string]: unknown; |
21 | } |
22 | ) { |
23 | const url = new URL(`${BASE_URL}/api/w/${workspace}/apps/create`); |
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 |
|