Skip to content

Commit 23f820b

Browse files
committed
fix: update webhook and service SDK calls for 9.0.0 breaking changes
1 parent 9d55a66 commit 23f820b

File tree

11 files changed

+163
-155
lines changed

11 files changed

+163
-155
lines changed

src/lib/stores/project-services.ts

Lines changed: 98 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,116 @@
11
import { writable } from 'svelte/store';
2-
import { ApiService, type Models } from '@appwrite.io/console';
2+
import { ServiceId, type Models } from '@appwrite.io/console';
33

44
export type Service = {
55
label: string;
6-
method: ApiService;
6+
method: ServiceId;
77
value: boolean | null;
88
};
99

10+
function projectServiceRows(project: Models.Project | null): Service[] {
11+
const rows: Service[] = [
12+
{
13+
label: 'Account',
14+
method: ServiceId.Account,
15+
value: project?.serviceStatusForAccount ?? null
16+
},
17+
{
18+
label: 'Avatars',
19+
method: ServiceId.Avatars,
20+
value: project?.serviceStatusForAvatars ?? null
21+
},
22+
{
23+
label: 'Databases',
24+
method: ServiceId.Databases,
25+
value: project?.serviceStatusForDatabases ?? null
26+
},
27+
{
28+
label: 'Functions',
29+
method: ServiceId.Functions,
30+
value: project?.serviceStatusForFunctions ?? null
31+
},
32+
{
33+
label: 'GraphQL',
34+
method: ServiceId.Graphql,
35+
value: project?.serviceStatusForGraphql ?? null
36+
},
37+
{
38+
label: 'Health',
39+
method: ServiceId.Health,
40+
value: project?.serviceStatusForHealth ?? null
41+
},
42+
{
43+
label: 'Locale',
44+
method: ServiceId.Locale,
45+
value: project?.serviceStatusForLocale ?? null
46+
},
47+
{
48+
label: 'Messaging',
49+
method: ServiceId.Messaging,
50+
value: project?.serviceStatusForMessaging ?? null
51+
},
52+
{
53+
label: 'Migrations',
54+
method: ServiceId.Migrations,
55+
value: project?.serviceStatusForMigrations ?? null
56+
},
57+
{
58+
label: 'Project',
59+
method: ServiceId.Project,
60+
value: project?.serviceStatusForProject ?? null
61+
},
62+
// @todo Re-enable when Proxy is ready for public release.
63+
// {
64+
// label: 'Proxy',
65+
// method: ServiceId.Proxy,
66+
// value: project?.serviceStatusForProxy ?? null
67+
// },
68+
{
69+
label: 'Sites',
70+
method: ServiceId.Sites,
71+
value: project?.serviceStatusForSites ?? null
72+
},
73+
{
74+
label: 'Storage',
75+
method: ServiceId.Storage,
76+
value: project?.serviceStatusForStorage ?? null
77+
},
78+
{
79+
label: 'TablesDB',
80+
method: ServiceId.Tablesdb,
81+
value: project?.serviceStatusForTablesdb ?? null
82+
},
83+
{
84+
label: 'Teams',
85+
method: ServiceId.Teams,
86+
value: project?.serviceStatusForTeams ?? null
87+
},
88+
{
89+
label: 'Users',
90+
method: ServiceId.Users,
91+
value: project?.serviceStatusForUsers ?? null
92+
}
93+
// @todo Re-enable when VCS is ready for public release.
94+
// {
95+
// label: 'VCS',
96+
// method: ServiceId.Vcs,
97+
// value: project?.serviceStatusForVcs ?? null
98+
// }
99+
];
100+
101+
return rows.sort((a, b) => a.label.localeCompare(b.label));
102+
}
103+
10104
function createServices() {
11105
const { subscribe, set } = writable({
12-
list: [
13-
{
14-
label: 'Account',
15-
method: ApiService.Account,
16-
value: null
17-
},
18-
{
19-
label: 'Avatars',
20-
method: ApiService.Avatars,
21-
value: null
22-
},
23-
{
24-
label: 'Databases',
25-
method: ApiService.Databases,
26-
value: null
27-
},
28-
{
29-
label: 'Functions',
30-
method: ApiService.Functions,
31-
value: null
32-
},
33-
{
34-
label: 'Locale',
35-
method: ApiService.Locale,
36-
value: null
37-
},
38-
{
39-
label: 'Messaging',
40-
method: ApiService.Messaging,
41-
value: null
42-
},
43-
{
44-
label: 'Storage',
45-
method: ApiService.Storage,
46-
value: null
47-
},
48-
{
49-
label: 'Teams',
50-
method: ApiService.Teams,
51-
value: null
52-
},
53-
{
54-
label: 'Users',
55-
method: ApiService.Users,
56-
value: null
57-
},
58-
{
59-
label: 'GraphQL',
60-
method: ApiService.Graphql,
61-
value: null
62-
}
63-
]
106+
list: projectServiceRows(null)
64107
});
65108

66109
return {
67110
subscribe,
68111
set,
69112
load: (project: Models.Project) => {
70-
const list = [
71-
{
72-
label: 'Account',
73-
method: ApiService.Account,
74-
value: project.serviceStatusForAccount
75-
},
76-
{
77-
label: 'Avatars',
78-
method: ApiService.Avatars,
79-
value: project.serviceStatusForAvatars
80-
},
81-
{
82-
label: 'Databases',
83-
method: ApiService.Databases,
84-
value: project.serviceStatusForDatabases
85-
},
86-
{
87-
label: 'Functions',
88-
method: ApiService.Functions,
89-
value: project.serviceStatusForFunctions
90-
},
91-
{
92-
label: 'Locale',
93-
method: ApiService.Locale,
94-
value: project.serviceStatusForLocale
95-
},
96-
{
97-
label: 'Messaging',
98-
method: ApiService.Messaging,
99-
value: project.serviceStatusForMessaging
100-
},
101-
{
102-
label: 'Storage',
103-
method: ApiService.Storage,
104-
value: project.serviceStatusForStorage
105-
},
106-
{
107-
label: 'Teams',
108-
method: ApiService.Teams,
109-
value: project.serviceStatusForTeams
110-
},
111-
{
112-
label: 'Users',
113-
method: ApiService.Users,
114-
value: project.serviceStatusForUsers
115-
}
116-
];
117-
set({ list });
113+
set({ list: projectServiceRows(project) });
118114
}
119115
};
120116
}

src/routes/(console)/project-[region]-[project]/settings/updateServices.svelte

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@
1010
import { project } from '../store';
1111
import Button from '$lib/elements/forms/button.svelte';
1212
import { Dialog, Divider, Layout, Spinner } from '@appwrite.io/pink-svelte';
13-
import type { ApiService } from '@appwrite.io/console';
13+
import type { ServiceId } from '@appwrite.io/console';
14+
import { get } from 'svelte/store';
1415
1516
import { SvelteSet } from 'svelte/reactivity';
1617
1718
let isUpdatingAllServices = $state(false);
1819
let showUpdateServiceDialog = $state(false);
1920
let updateServicesEnabledMode = $state<boolean | null>(null);
2021
21-
let apiServiceUpdates = new SvelteSet<ApiService>();
22+
let apiServiceUpdates = new SvelteSet<ServiceId>();
2223
2324
const isAnyServiceUpdating = $derived(apiServiceUpdates.size > 0);
2425
const isAnyUpdateInProgress = $derived(isUpdatingAllServices || isAnyServiceUpdating);
@@ -41,10 +42,9 @@
4142
apiServiceUpdates.add(service.method);
4243
4344
try {
44-
await sdk.forConsole.projects.updateServiceStatus({
45-
projectId: $project.$id,
46-
service: service.method,
47-
status: service.value
45+
await sdk.forProject($project.region, $project.$id).project.updateServiceStatus({
46+
serviceId: service.method,
47+
enabled: service.value
4848
});
4949
5050
await invalidate(Dependencies.PROJECT);
@@ -74,10 +74,14 @@
7474
isUpdatingAllServices = true;
7575
7676
try {
77-
await sdk.forConsole.projects.updateServiceStatusAll({
78-
projectId: $project.$id,
79-
status
80-
});
77+
const projectSdk = sdk.forProject($project.region, $project.$id);
78+
for (const s of get(services).list) {
79+
if (s.value === status) continue;
80+
await projectSdk.project.updateServiceStatus({
81+
serviceId: s.method,
82+
enabled: status
83+
});
84+
}
8185
8286
await invalidate(Dependencies.PROJECT);
8387

src/routes/(console)/project-[region]-[project]/settings/webhooks/[webhook]/details.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
name: $webhook.name,
3131
events: $webhook.events,
3232
url: $webhook.url,
33-
security: $webhook.security,
33+
tls: $webhook.tls,
3434
enabled,
35-
httpUser: $webhook.httpUser || undefined,
36-
httpPass: $webhook.httpPass || undefined
35+
authUsername: $webhook.authUsername || undefined,
36+
authPassword: $webhook.authPassword || undefined
3737
});
3838
await invalidate(Dependencies.WEBHOOK);
3939
addNotification({

src/routes/(console)/project-[region]-[project]/settings/webhooks/[webhook]/regenerate.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
1414
async function regenerate() {
1515
try {
16-
await sdk.forProject(page.params.region, projectId).webhooks.updateSignature({
16+
await sdk.forProject(page.params.region, projectId).webhooks.updateSecret({
1717
webhookId: $webhook.$id
1818
});
1919
await invalidate(Dependencies.WEBHOOK);

src/routes/(console)/project-[region]-[project]/settings/webhooks/[webhook]/updateEvents.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
name: $webhook.name,
3232
events: Array.from($eventSet),
3333
url: $webhook.url,
34-
security: $webhook.security,
34+
tls: $webhook.tls,
3535
enabled: true,
36-
httpUser: $webhook.httpUser || undefined,
37-
httpPass: $webhook.httpPass || undefined
36+
authUsername: $webhook.authUsername || undefined,
37+
authPassword: $webhook.authPassword || undefined
3838
});
3939
await invalidate(Dependencies.WEBHOOK);
4040
areEventsDisabled = true;

src/routes/(console)/project-[region]-[project]/settings/webhooks/[webhook]/updateName.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
name,
2525
events: $webhook.events,
2626
url: $webhook.url,
27-
security: $webhook.security,
27+
tls: $webhook.tls,
2828
enabled: true,
29-
httpUser: $webhook.httpUser || undefined,
30-
httpPass: $webhook.httpPass || undefined
29+
authUsername: $webhook.authUsername || undefined,
30+
authPassword: $webhook.authPassword || undefined
3131
});
3232
3333
await invalidate(Dependencies.WEBHOOK);

src/routes/(console)/project-[region]-[project]/settings/webhooks/[webhook]/updateSecurity.svelte

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
import { Selector, Typography } from '@appwrite.io/pink-svelte';
1313
1414
const projectId = page.params.project;
15-
let httpUser: string = null;
16-
let httpPass: string = null;
17-
let security = false;
15+
let authUsername: string = null;
16+
let authPassword: string = null;
17+
let tls = false;
1818
1919
onMount(async () => {
20-
httpUser ??= $webhook.httpUser;
21-
httpPass ??= $webhook.httpPass;
22-
security = $webhook.security;
20+
authUsername ??= $webhook.authUsername;
21+
authPassword ??= $webhook.authPassword;
22+
tls = $webhook.tls;
2323
});
2424
2525
async function updateSecurity() {
@@ -29,10 +29,10 @@
2929
name: $webhook.name,
3030
events: $webhook.events,
3131
url: $webhook.url,
32-
security,
32+
tls,
3333
enabled: true,
34-
httpUser: httpUser || undefined,
35-
httpPass: httpPass || undefined
34+
authUsername: authUsername || undefined,
35+
authPassword: authPassword || undefined
3636
});
3737
await invalidate(Dependencies.WEBHOOK);
3838
addNotification({
@@ -60,18 +60,22 @@
6060
<Typography.Title size="s">HTTP Authentication</Typography.Title>
6161
<p class="text">Use to secure your endpoint from untrusted sources.</p>
6262
</div>
63-
<InputText label="User" id="user" placeholder="Enter username" bind:value={httpUser} />
63+
<InputText
64+
label="User"
65+
id="user"
66+
placeholder="Enter username"
67+
bind:value={authUsername} />
6468
<InputPassword
6569
label="Password"
6670
id="password"
6771
minlength={0}
6872
placeholder="Enter password"
69-
bind:value={httpPass} />
73+
bind:value={authPassword} />
7074

7175
<Selector.Checkbox
7276
id="security"
7377
label="Certificate verification (SSL/TLS)"
74-
bind:checked={security}
78+
bind:checked={tls}
7579
description="Placeholder" />
7680
<!-- <span class="u-color-text-danger">Warning:</span> Untrusted or self-signed certificates
7781
may not be secure.
@@ -85,9 +89,9 @@
8589

8690
<svelte:fragment slot="actions">
8791
<Button
88-
disabled={httpUser === $webhook.httpUser &&
89-
httpPass === $webhook.httpPass &&
90-
security === $webhook.security}
92+
disabled={authUsername === $webhook.authUsername &&
93+
authPassword === $webhook.authPassword &&
94+
tls === $webhook.tls}
9195
submit>
9296
Update
9397
</Button>

0 commit comments

Comments
 (0)