1 | |
2 | * list all available scripts |
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 | first_parent_hash: string | undefined, |
14 | last_parent_hash: string | undefined, |
15 | parent_hash: string | undefined, |
16 | show_archived: string | undefined, |
17 | is_template: string | undefined, |
18 | kind: string | undefined, |
19 | starred_only: string | undefined |
20 | ) { |
21 | const url = new URL(`${BASE_URL}/api/w/${workspace}/scripts/list`); |
22 | for (const [k, v] of [ |
23 | ["page", page], |
24 | ["per_page", per_page], |
25 | ["order_desc", order_desc], |
26 | ["created_by", created_by], |
27 | ["path_start", path_start], |
28 | ["path_exact", path_exact], |
29 | ["first_parent_hash", first_parent_hash], |
30 | ["last_parent_hash", last_parent_hash], |
31 | ["parent_hash", parent_hash], |
32 | ["show_archived", show_archived], |
33 | ["is_template", is_template], |
34 | ["kind", kind], |
35 | ["starred_only", starred_only], |
36 | ]) { |
37 | if (v !== undefined) { |
38 | url.searchParams.append(k, v); |
39 | } |
40 | } |
41 | const response = await fetch(url, { |
42 | method: "GET", |
43 | headers: { |
44 | Authorization: "Bearer " + WM_TOKEN, |
45 | }, |
46 | body: undefined, |
47 | }); |
48 | return await response.json(); |
49 | } |
50 |
|