Skip to content

Commit cc4c3a6

Browse files
committed
Clarify scope enum usage
1 parent b877967 commit cc4c3a6

5 files changed

Lines changed: 49 additions & 51 deletions

File tree

src/routes/(console)/project-[region]-[project]/overview/(components)/create.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
import { addNotification } from '$lib/stores/notifications';
1515
import { writable } from 'svelte/store';
1616
import Scopes from '../api-keys/scopes.svelte';
17-
import { ID, type ProjectKeyScopes as ScopesType } from '@appwrite.io/console';
17+
import { ID, type ProjectKeyScopes } from '@appwrite.io/console';
1818
import { page } from '$app/state';
1919
import { copy } from '$lib/helpers/copy';
2020
2121
let showExitModal = false;
2222
let formComponent: Form;
2323
let isSubmitting = writable(false);
2424
25-
let scopes: ScopesType[] = [];
25+
let scopes: ProjectKeyScopes[] = [];
2626
let name = '';
2727
let expire: string | null = null;
2828

src/routes/(console)/project-[region]-[project]/overview/(components)/keyDetails.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import { project } from '../../store';
1313
import Delete from './delete.svelte';
1414
import UpdateExpirationDate from './updateExpirationDate.svelte';
15-
import type { Models, ProjectKeyScopes as ScopesType } from '@appwrite.io/console';
15+
import type { Models, ProjectKeyScopes } from '@appwrite.io/console';
1616
import { symmetricDifference } from '$lib/helpers/array';
1717
import Scopes from '../api-keys/scopes.svelte';
1818
import { InteractiveText, Layout, Typography } from '@appwrite.io/pink-svelte';
@@ -21,7 +21,7 @@
2121
export let keyType: 'api' | 'dev' = 'api';
2222
2323
let name: string = null;
24-
let scopes: ScopesType[] = null;
24+
let scopes: ProjectKeyScopes[] = null;
2525
2626
let showDelete = false;
2727
const isApiKey = keyType === 'api';
@@ -32,7 +32,7 @@
3232
onMount(() => {
3333
name ??= key.name;
3434
if (isApiKey) {
35-
scopes ??= (key as Models.Key).scopes as ScopesType[];
35+
scopes ??= (key as Models.Key).scopes as ProjectKeyScopes[];
3636
}
3737
});
3838

src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
}
2727
</script>
2828

29-
<script lang="ts">
29+
<script lang="ts" generics="ScopeValue extends ProjectKeyScopes | Scopes">
3030
import { onMount } from 'svelte';
3131
import { isCloud } from '$lib/system';
3232
import { Button } from '$lib/elements/forms';
@@ -48,8 +48,6 @@
4848
} from '@appwrite.io/pink-svelte';
4949
import type { ProjectKeyScopes, Scopes } from '@appwrite.io/console';
5050
51-
type ScopeValue = ProjectKeyScopes | Scopes;
52-
5351
let { scopes = $bindable([]) }: { scopes: ScopeValue[] } = $props();
5452
5553
let allScopesList: ScopeDefinition[] = $state([]);
@@ -194,10 +192,10 @@
194192
});
195193
}
196194
197-
function generateSyncedScopes(activeScopesObj: Record<string, boolean>): Scopes[] {
195+
function generateSyncedScopes(activeScopesObj: Record<string, boolean>): ScopeValue[] {
198196
return Object.entries(activeScopesObj)
199197
.filter(([scope, isActive]) => isActive && scopeCatalog.has(scope))
200-
.map(([scope]) => scope as Scopes);
198+
.map(([scope]) => scope as ScopeValue);
201199
}
202200
</script>
203201

src/routes/(console)/project-[region]-[project]/settings/migrations/+page.svelte

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import Details from './details.svelte';
1515
import ExportModal from './exportModal.svelte';
1616
import { readOnly } from '$lib/stores/billing';
17-
import { ID, ProjectKeyScopes as Scopes, type Models } from '@appwrite.io/console';
17+
import { ID, ProjectKeyScopes, type Models } from '@appwrite.io/console';
1818
import { canWriteProjects } from '$lib/stores/roles';
1919
import {
2020
IconCloud,
@@ -92,23 +92,23 @@
9292
keyId: ID.unique(),
9393
name: `[AUTO-GENERATED] Migration ${new Date().toISOString()}`,
9494
scopes: [
95-
Scopes.UsersRead,
96-
Scopes.TeamsRead,
97-
Scopes.DatabasesRead,
98-
Scopes.CollectionsRead /* legacy */,
99-
Scopes.AttributesRead /* legacy */,
100-
Scopes.IndexesRead,
101-
Scopes.DocumentsRead /* legacy */,
102-
Scopes.TablesRead,
103-
Scopes.ColumnsRead,
104-
Scopes.RowsRead,
105-
Scopes.FilesRead,
106-
Scopes.BucketsRead,
107-
Scopes.FunctionsRead,
108-
Scopes.ExecutionsRead,
109-
Scopes.LocaleRead,
110-
Scopes.AvatarsRead,
111-
Scopes.HealthRead
95+
ProjectKeyScopes.UsersRead,
96+
ProjectKeyScopes.TeamsRead,
97+
ProjectKeyScopes.DatabasesRead,
98+
ProjectKeyScopes.CollectionsRead /* legacy */,
99+
ProjectKeyScopes.AttributesRead /* legacy */,
100+
ProjectKeyScopes.IndexesRead,
101+
ProjectKeyScopes.DocumentsRead /* legacy */,
102+
ProjectKeyScopes.TablesRead,
103+
ProjectKeyScopes.ColumnsRead,
104+
ProjectKeyScopes.RowsRead,
105+
ProjectKeyScopes.FilesRead,
106+
ProjectKeyScopes.BucketsRead,
107+
ProjectKeyScopes.FunctionsRead,
108+
ProjectKeyScopes.ExecutionsRead,
109+
ProjectKeyScopes.LocaleRead,
110+
ProjectKeyScopes.AvatarsRead,
111+
ProjectKeyScopes.HealthRead
112112
]
113113
});
114114

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

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import { sdk } from '$lib/stores/sdk';
1111
import { user } from '$lib/stores/user';
1212
import { organization } from '$lib/stores/organization';
13-
import { ID, ProjectKeyScopes as Scopes } from '@appwrite.io/console';
13+
import { ID, ProjectKeyScopes } from '@appwrite.io/console';
1414
1515
export let show = false;
1616
@@ -94,28 +94,28 @@
9494
keyId: ID.unique(),
9595
name: `[AUTO-GENERATED] Migration ${new Date().toISOString()}`,
9696
scopes: [
97-
Scopes.UsersRead,
98-
Scopes.TeamsRead,
99-
Scopes.DatabasesRead,
100-
Scopes.CollectionsRead /* legacy */,
101-
Scopes.AttributesRead /* legacy */,
102-
Scopes.IndexesRead,
103-
Scopes.DocumentsRead /* legacy */,
104-
Scopes.TablesRead,
105-
Scopes.ColumnsRead,
106-
Scopes.RowsRead,
107-
Scopes.FilesRead,
108-
Scopes.BucketsRead,
109-
Scopes.FunctionsRead,
110-
Scopes.ExecutionsRead,
111-
Scopes.SitesRead,
112-
Scopes.ProvidersRead,
113-
Scopes.TopicsRead,
114-
Scopes.SubscribersRead,
115-
Scopes.MessagesRead,
116-
Scopes.LocaleRead,
117-
Scopes.AvatarsRead,
118-
Scopes.HealthRead
97+
ProjectKeyScopes.UsersRead,
98+
ProjectKeyScopes.TeamsRead,
99+
ProjectKeyScopes.DatabasesRead,
100+
ProjectKeyScopes.CollectionsRead /* legacy */,
101+
ProjectKeyScopes.AttributesRead /* legacy */,
102+
ProjectKeyScopes.IndexesRead,
103+
ProjectKeyScopes.DocumentsRead /* legacy */,
104+
ProjectKeyScopes.TablesRead,
105+
ProjectKeyScopes.ColumnsRead,
106+
ProjectKeyScopes.RowsRead,
107+
ProjectKeyScopes.FilesRead,
108+
ProjectKeyScopes.BucketsRead,
109+
ProjectKeyScopes.FunctionsRead,
110+
ProjectKeyScopes.ExecutionsRead,
111+
ProjectKeyScopes.SitesRead,
112+
ProjectKeyScopes.ProvidersRead,
113+
ProjectKeyScopes.TopicsRead,
114+
ProjectKeyScopes.SubscribersRead,
115+
ProjectKeyScopes.MessagesRead,
116+
ProjectKeyScopes.LocaleRead,
117+
ProjectKeyScopes.AvatarsRead,
118+
ProjectKeyScopes.HealthRead
119119
]
120120
});
121121

0 commit comments

Comments
 (0)