Skip to content

Commit fa0dff4

Browse files
committed
fix SDK type errors: VectorsDB, IndexType, DatabaseType, pink-svelte update
1 parent 5c33607 commit fa0dff4

14 files changed

Lines changed: 62 additions & 64 deletions

File tree

bun.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"@appwrite.io/pink-icons": "0.25.0",
2525
"@appwrite.io/pink-icons-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-icons-svelte@bfe7ce3",
2626
"@appwrite.io/pink-legacy": "^1.0.3",
27-
"@appwrite.io/pink-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@df765cc",
27+
"@appwrite.io/pink-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@bfe7ce3",
2828
"@codemirror/autocomplete": "^6.19.0",
2929
"@codemirror/commands": "^6.9.0",
3030
"@codemirror/lang-javascript": "^6.2.4",

src/lib/helpers/faker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export async function generateFields(
7777
}
7878

7979
case 'documentsdb': /* doesn't need any fields */
80-
case 'vectordb': /* vector embeddings + metadata defined at collection creation */ {
80+
case 'vectorsdb': /* vector embeddings + metadata defined at collection creation */ {
8181
/* no individual field creation needed */
8282
return [];
8383
}

src/lib/stores/sdk.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
DocumentsDB,
2727
Realtime,
2828
Organizations,
29-
VectorDB
29+
VectorsDB
3030
} from '@appwrite.io/console';
3131
import { Sources } from '$lib/sdk/sources';
3232
import {
@@ -138,7 +138,7 @@ const sdkForProject = {
138138
sites: new Sites(clientProject),
139139
tablesDB: new TablesDB(clientProject),
140140
documentsDB: new DocumentsDB(clientProject),
141-
vectorDB: new VectorDB(clientProject),
141+
vectorsDB: new VectorsDB(clientProject),
142142
console: new Console(clientProject) // for suggestions API
143143
};
144144

src/routes/(console)/project-[region]-[project]/databases/database-[database]/(entity)/helpers/sdk.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
toSupportiveIndex
1414
} from './terminology';
1515

16-
import type { IndexType, Models, OrderBy } from '@appwrite.io/console';
16+
import type { Models, OrderBy, TablesDBIndexType, DocumentsDBIndexType } from '@appwrite.io/console';
1717

1818
export type DatabaseSdkResult = {
1919
create: (
@@ -87,7 +87,7 @@ export type DatabaseSdkResult = {
8787
databaseId: string;
8888
entityId: string;
8989
key: string;
90-
type: IndexType;
90+
type: string;
9191
attributes: string[];
9292
lengths?: number[];
9393
orders?: OrderBy[];
@@ -126,7 +126,7 @@ export function useDatabaseSdk(
126126
case 'documentsdb': {
127127
return await baseSdk.documentsDB.create(params);
128128
}
129-
case 'vectordb':
129+
case 'vectorsdb':
130130
throw new Error('Database type not supported yet');
131131
default:
132132
throw new Error('Unknown database type');
@@ -168,7 +168,7 @@ export function useDatabaseSdk(
168168

169169
return toSupportiveEntity(table);
170170
}
171-
case 'vectordb':
171+
case 'vectorsdb':
172172
throw new Error('Database type not supported yet');
173173
default:
174174
throw new Error('Unknown database type');
@@ -187,7 +187,7 @@ export function useDatabaseSdk(
187187
await baseSdk.documentsDB.listCollections(params);
188188
return { total, entities: collections.map(toSupportiveEntity) };
189189
}
190-
case 'vectordb':
190+
case 'vectorsdb':
191191
throw new Error(`Database type not supported yet`);
192192
default:
193193
throw new Error(`Unknown database type`);
@@ -212,7 +212,7 @@ export function useDatabaseSdk(
212212

213213
return toSupportiveEntity(collection);
214214
}
215-
case 'vectordb':
215+
case 'vectorsdb':
216216
throw new Error(`Database type not supported yet`);
217217
default:
218218
throw new Error(`Unknown database type`);
@@ -226,7 +226,7 @@ export function useDatabaseSdk(
226226
return await baseSdk.tablesDB.delete(params);
227227
case 'documentsdb':
228228
return await baseSdk.documentsDB.delete(params);
229-
case 'vectordb':
229+
case 'vectorsdb':
230230
throw new Error('Database type not supported yet');
231231
default:
232232
throw new Error(`Unknown database type`);
@@ -246,7 +246,7 @@ export function useDatabaseSdk(
246246
databaseId: params.databaseId,
247247
collectionId: params.entityId
248248
});
249-
case 'vectordb':
249+
case 'vectorsdb':
250250
throw new Error('Database type not supported yet');
251251
default:
252252
throw new Error(`Unknown database type`);
@@ -272,7 +272,7 @@ export function useDatabaseSdk(
272272
data: params.data,
273273
permissions: params.permissions
274274
});
275-
case 'vectordb':
275+
case 'vectorsdb':
276276
throw new Error('Database type not supported yet');
277277
default:
278278
throw new Error(`Unknown database type`);
@@ -298,7 +298,7 @@ export function useDatabaseSdk(
298298
data: params.data,
299299
permissions: params.permissions
300300
});
301-
case 'vectordb':
301+
case 'vectorsdb':
302302
throw new Error('Database type not supported yet');
303303
default:
304304
throw new Error(`Unknown database type`);
@@ -322,7 +322,7 @@ export function useDatabaseSdk(
322322
documentId: params.recordId,
323323
permissions: params.permissions
324324
});
325-
case 'vectordb':
325+
case 'vectorsdb':
326326
throw new Error('Database type not supported yet');
327327
default:
328328
throw new Error(`Unknown database type`);
@@ -348,7 +348,7 @@ export function useDatabaseSdk(
348348
});
349349
return toSupportiveRecord(document);
350350
}
351-
case 'vectordb':
351+
case 'vectorsdb':
352352
throw new Error('Database type not supported yet');
353353
default:
354354
throw new Error(`Unknown database type`);
@@ -374,7 +374,7 @@ export function useDatabaseSdk(
374374
});
375375
return { total, records: documents.map(toSupportiveRecord) };
376376
}
377-
case 'vectordb':
377+
case 'vectorsdb':
378378
throw new Error('Database type not supported yet');
379379
default:
380380
throw new Error(`Unknown database type`);
@@ -389,7 +389,7 @@ export function useDatabaseSdk(
389389
databaseId: params.databaseId,
390390
tableId: params.entityId,
391391
key: params.key,
392-
type: params.type,
392+
type: params.type as TablesDBIndexType,
393393
columns: params.attributes,
394394
lengths: params.lengths,
395395
orders: params.orders
@@ -401,14 +401,14 @@ export function useDatabaseSdk(
401401
databaseId: params.databaseId,
402402
collectionId: params.entityId,
403403
key: params.key,
404-
type: params.type,
404+
type: params.type as DocumentsDBIndexType,
405405
attributes: params.attributes,
406406
lengths: params.lengths,
407407
orders: params.orders
408408
});
409409
return toSupportiveIndex(index);
410410
}
411-
case 'vectordb':
411+
case 'vectorsdb':
412412
throw new Error('Database type not supported yet');
413413
default:
414414
throw new Error(`Unknown database type`);

src/routes/(console)/project-[region]-[project]/databases/database-[database]/(entity)/helpers/terminology.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import type { Page } from '@sveltejs/kit';
22

33
import { capitalize, plural } from '$lib/helpers/string';
4-
import { AppwriteException, type IndexType, type Models } from '@appwrite.io/console';
4+
import { AppwriteException, type DatabasesIndexType, type Models } from '@appwrite.io/console';
55
import type { Attributes, Collection, Columns, Table } from '$database/store';
66
import type { Term, TerminologyResult, TerminologyShape } from '$database/(entity)/helpers/types';
77

88
type BaseTerminology = typeof baseTerminology;
99
type ImplementedDBTypes = Omit<BaseTerminology, 'vectordb' | 'legacy'>;
1010

11-
/* manual type for the time being because vectordb is pending */
12-
export type DatabaseType = 'legacy' | 'tablesdb' | 'documentsdb' | 'vectordb';
11+
/* manual type for the time being because vectorsdb is pending */
12+
export type DatabaseType = 'legacy' | 'tablesdb' | 'documentsdb' | 'vectorsdb';
1313

1414
export type RecordType = ImplementedDBTypes[keyof ImplementedDBTypes]['record'];
1515

@@ -28,7 +28,7 @@ export type Record = Partial<Models.Document | Models.Row> & {
2828

2929
export type Index = Partial<Models.Index | Models.ColumnIndex> & {
3030
fields: Models.Index['attributes'] | Models.ColumnIndex['columns'];
31-
type: IndexType;
31+
type: string;
3232
};
3333

3434
export type EntityList = {
@@ -95,7 +95,7 @@ const terminologyData = Object.fromEntries(
9595
export function toSupportiveIndex(index: Models.Index | Models.ColumnIndex): Index {
9696
return {
9797
...index,
98-
type: index.type as IndexType,
98+
type: index.type as DatabasesIndexType,
9999
fields: (index as Models.Index).attributes ?? (index as Models.ColumnIndex).columns ?? []
100100
};
101101
}

src/routes/(console)/project-[region]-[project]/databases/database-[database]/(entity)/views/indexes/create.svelte

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script module lang="ts">
2-
import { IndexType, OrderBy } from '@appwrite.io/console';
2+
import { DatabasesIndexType, OrderBy } from '@appwrite.io/console';
33
export type CreateIndexesCallbackType = {
44
key: string;
5-
type: IndexType;
5+
type: string;
66
fields: string[];
77
lengths: (number | null)[];
88
orders: OrderBy[];
@@ -39,14 +39,14 @@
3939
4040
let key = $state('');
4141
let initializedForOpen = $state(false);
42-
let selectedType = $state<IndexType>(IndexType.Key);
42+
let selectedType = $state<DatabasesIndexType>(DatabasesIndexType.Key);
4343
4444
const { dependencies, terminology } = getTerminologies();
4545
4646
const fieldOptions = $derived(
4747
entity.fields
4848
.filter((field) => {
49-
if (selectedType === IndexType.Spatial) {
49+
if (selectedType === DatabasesIndexType.Spatial) {
5050
// keep only spatial
5151
return isSpatialType(field);
5252
}
@@ -67,15 +67,15 @@
6767
}> = $state([{ value: '', order: null, length: null }]);
6868
6969
const types = [
70-
{ value: IndexType.Key, label: 'Key' },
71-
{ value: IndexType.Unique, label: 'Unique' },
72-
{ value: IndexType.Fulltext, label: 'Fulltext' },
73-
{ value: IndexType.Spatial, label: 'Spatial' }
70+
{ value: DatabasesIndexType.Key, label: 'Key' },
71+
{ value: DatabasesIndexType.Unique, label: 'Unique' },
72+
{ value: DatabasesIndexType.Fulltext, label: 'Fulltext' },
73+
{ value: DatabasesIndexType.Spatial, label: 'Spatial' }
7474
];
7575
7676
// order options derived from selected type
7777
let orderOptions = $derived.by(() =>
78-
selectedType === IndexType.Spatial
78+
selectedType === DatabasesIndexType.Spatial
7979
? [
8080
{ value: OrderBy.Asc, label: 'ASC' },
8181
{ value: OrderBy.Desc, label: 'DESC' },
@@ -91,7 +91,7 @@
9191
// and the field already is not spatial type
9292
$effect(() => {
9393
const firstField = entity.fields.find((field) => field.key === fieldList.at(0)?.value);
94-
if (selectedType === IndexType.Spatial && firstField && !isSpatialType(firstField)) {
94+
if (selectedType === DatabasesIndexType.Spatial && firstField && !isSpatialType(firstField)) {
9595
fieldList = [{ value: '', order: null, length: null }];
9696
}
9797
});
@@ -112,7 +112,7 @@
112112
const isSpatial = field.length && isSpatialType(field[0]);
113113
const order = isSpatial ? null : OrderBy.Asc;
114114
115-
selectedType = isSpatial ? IndexType.Spatial : IndexType.Key;
115+
selectedType = isSpatial ? DatabasesIndexType.Spatial : DatabasesIndexType.Key;
116116
117117
fieldList = externalFieldKey
118118
? [{ value: externalFieldKey, order, length: null }]
@@ -122,7 +122,7 @@
122122
}
123123
124124
const addFieldDisabled = $derived(
125-
selectedType === IndexType.Spatial ||
125+
selectedType === DatabasesIndexType.Spatial ||
126126
!fieldList.at(-1)?.value ||
127127
(!fieldList.at(-1)?.order && fieldList.at(-1)?.order !== null)
128128
);
@@ -153,7 +153,7 @@
153153
export async function create() {
154154
const fieldType = terminology.field.lower.singular;
155155
156-
if (!key || !selectedType || (selectedType !== IndexType.Spatial && addFieldDisabled)) {
156+
if (!key || !selectedType || (selectedType !== DatabasesIndexType.Spatial && addFieldDisabled)) {
157157
addNotification({
158158
type: 'error',
159159
message: `Selected ${fieldType} key or type invalid`
@@ -232,7 +232,7 @@
232232
required
233233
options={[
234234
// allow system fields only for non-spatial index types
235-
...(selectedType === IndexType.Spatial
235+
...(selectedType === DatabasesIndexType.Spatial
236236
? []
237237
: [
238238
{ value: '$id', label: '$id', leadingIcon: IconFingerPrint },
@@ -262,7 +262,7 @@
262262
bind:value={field.order}
263263
placeholder="Select order" />
264264

265-
{#if selectedType === IndexType.Key}
265+
{#if selectedType === DatabasesIndexType.Key}
266266
<InputNumber
267267
id={`length-${index}`}
268268
label={index === 0 ? 'Length' : undefined}

0 commit comments

Comments
 (0)