1 | |
2 | * list all flows |
3 | * |
4 | */ |
5 | export async function main( |
6 | workspace: string, |
7 | page: string | undefined, |
8 | per_page: string | undefined, |
9 | order_desc: string | undefined, |
10 | created_by: string | undefined, |
11 | path_start: string | undefined, |
12 | path_exact: string | undefined, |
13 | show_archived: string | undefined, |
14 | starred_only: string | undefined |
15 | ) { |
16 | const url = new URL(`${BASE_URL}/api/w/${workspace}/flows/list`); |
17 | for (const [k, v] of [ |
18 | ["page", page], |
19 | ["per_page", per_page], |
20 | ["order_desc", order_desc], |
21 | ["created_by", created_by], |
22 | ["path_start", path_start], |
23 | ["path_exact", path_exact], |
24 | ["show_archived", show_archived], |
25 | ["starred_only", starred_only], |
26 | ]) { |
27 | if (v !== undefined && v !== "") { |
28 | url.searchParams.append(k, v); |
29 | } |
30 | } |
31 | const response = await fetch(url, { |
32 | method: "GET", |
33 | headers: { |
34 | Authorization: "Bearer " + WM_TOKEN, |
35 | }, |
36 | body: undefined, |
37 | }); |
38 | if (!response.ok) { |
39 | const text = await response.text(); |
40 | throw new Error(`${response.status} ${text}`); |
41 | } |
42 | return await response.json(); |
43 | } |
44 |
|