1 | |
2 | type Vercel = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Gets a list of aliases with status for the current promote |
7 | * Get a list of aliases related to the last promote request with their mapping status |
8 | */ |
9 | export async function main( |
10 | auth: Vercel, |
11 | projectId: string, |
12 | limit: string | undefined, |
13 | since: string | undefined, |
14 | until: string | undefined, |
15 | failedOnly: string | undefined, |
16 | teamId: string | undefined, |
17 | slug: string | undefined, |
18 | ) { |
19 | const url = new URL( |
20 | `https://api.vercel.com/v1/projects/${projectId}/promote/aliases`, |
21 | ); |
22 | for (const [k, v] of [ |
23 | ["limit", limit], |
24 | ["since", since], |
25 | ["until", until], |
26 | ["failedOnly", failedOnly], |
27 | ["teamId", teamId], |
28 | ["slug", slug], |
29 | ]) { |
30 | if (v !== undefined && v !== "" && k !== undefined) { |
31 | url.searchParams.append(k, v); |
32 | } |
33 | } |
34 | const response = await fetch(url, { |
35 | method: "GET", |
36 | headers: { |
37 | Authorization: "Bearer " + auth.token, |
38 | }, |
39 | body: undefined, |
40 | }); |
41 | if (!response.ok) { |
42 | const text = await response.text(); |
43 | throw new Error(`${response.status} ${text}`); |
44 | } |
45 | return await response.json(); |
46 | } |
47 |
|