1 | |
2 | type Supabase = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Applies project addon |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Supabase, |
11 | ref: string, |
12 | body: { |
13 | addon_variant: |
14 | | "ci_micro" |
15 | | "ci_small" |
16 | | "ci_medium" |
17 | | "ci_large" |
18 | | "ci_xlarge" |
19 | | "ci_2xlarge" |
20 | | "ci_4xlarge" |
21 | | "ci_8xlarge" |
22 | | "ci_12xlarge" |
23 | | "ci_16xlarge" |
24 | | "ci_24xlarge" |
25 | | "ci_24xlarge_optimized_cpu" |
26 | | "ci_24xlarge_optimized_memory" |
27 | | "ci_24xlarge_high_memory" |
28 | | "ci_48xlarge" |
29 | | "ci_48xlarge_optimized_cpu" |
30 | | "ci_48xlarge_optimized_memory" |
31 | | "ci_48xlarge_high_memory" |
32 | | "cd_default" |
33 | | "pitr_7" |
34 | | "pitr_14" |
35 | | "pitr_28" |
36 | | "ipv4_default"; |
37 | addon_type: |
38 | | "custom_domain" |
39 | | "compute_instance" |
40 | | "pitr" |
41 | | "ipv4" |
42 | | "auth_mfa_phone" |
43 | | "auth_mfa_web_authn" |
44 | | "log_drain"; |
45 | }, |
46 | ) { |
47 | const url = new URL(`https://api.supabase.com/v1/projects/${ref}/billing/addons`); |
48 |
|
49 | const response = await fetch(url, { |
50 | method: "PATCH", |
51 | headers: { |
52 | "Content-Type": "application/json", |
53 | Authorization: "Bearer " + auth.token, |
54 | }, |
55 | body: JSON.stringify(body), |
56 | }); |
57 | if (!response.ok) { |
58 | const text = await response.text(); |
59 | throw new Error(`${response.status} ${text}`); |
60 | } |
61 | return await response.text(); |
62 | } |
63 |
|