1 | |
2 | type Clickup = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Create List View |
7 | * Add a List, Board, Calendar, Table, Timeline, Workload, Activity, Map, Chat, or Gantt view to a List. |
8 | */ |
9 | export async function main( |
10 | auth: Clickup, |
11 | list_id: string, |
12 | body: { |
13 | name: string; |
14 | type: string; |
15 | grouping: { |
16 | field: string; |
17 | dir: number; |
18 | collapsed: string[]; |
19 | ignore: false | true; |
20 | }; |
21 | divide: { field?: null; dir?: null; collapsed: false | true }; |
22 | sorting: { fields: string[] }; |
23 | filters: { |
24 | op: string; |
25 | fields: string[]; |
26 | search: string; |
27 | show_closed: false | true; |
28 | }; |
29 | columns: { fields: string[] }; |
30 | team_sidebar: { |
31 | assignees: string[]; |
32 | assigned_comments: false | true; |
33 | unassigned_tasks: false | true; |
34 | }; |
35 | settings: { |
36 | show_task_locations: false | true; |
37 | show_subtasks: number; |
38 | show_subtask_parent_names: false | true; |
39 | show_closed_subtasks: false | true; |
40 | show_assignees: false | true; |
41 | show_images: false | true; |
42 | collapse_empty_columns: string; |
43 | me_comments: false | true; |
44 | me_subtasks: false | true; |
45 | me_checklists: false | true; |
46 | }; |
47 | }, |
48 | ) { |
49 | const url = new URL(`https://api.clickup.com/api/v2/list/${list_id}/view`); |
50 |
|
51 | const response = await fetch(url, { |
52 | method: "POST", |
53 | headers: { |
54 | "Content-Type": "application/json", |
55 | Authorization: auth.token, |
56 | }, |
57 | body: JSON.stringify(body), |
58 | }); |
59 | if (!response.ok) { |
60 | const text = await response.text(); |
61 | throw new Error(`${response.status} ${text}`); |
62 | } |
63 | return await response.json(); |
64 | } |
65 |
|