fix SDK type errors: VectorsDB, IndexType, DatabaseType, pink-svelte update

This commit is contained in:
Prem Palanisamy
2026-03-20 11:25:29 +00:00
parent 5c3360727a
commit fa0dff4cf8
14 changed files with 62 additions and 64 deletions
+2 -2
View File
@@ -10,7 +10,7 @@
"@appwrite.io/pink-icons": "0.25.0",
"@appwrite.io/pink-icons-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-icons-svelte@bfe7ce3",
"@appwrite.io/pink-legacy": "^1.0.3",
"@appwrite.io/pink-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@df765cc",
"@appwrite.io/pink-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@bfe7ce3",
"@codemirror/autocomplete": "^6.19.0",
"@codemirror/commands": "^6.9.0",
"@codemirror/lang-javascript": "^6.2.4",
@@ -129,7 +129,7 @@
"@appwrite.io/pink-legacy": ["@appwrite.io/pink-legacy@1.0.3", "", { "dependencies": { "@appwrite.io/pink-icons": "1.0.0", "the-new-css-reset": "^1.11.2" } }, "sha512-GGde5fmPhs+s6/3aFeMPc/kKADG/gTFkYQSy6oBN8pK0y0XNCLrZZgBv+EBbdhwdtqVEWXa0X85Mv9w7jcIlwQ=="],
"@appwrite.io/pink-svelte": ["@appwrite.io/pink-svelte@https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@df765cc", { "dependencies": { "@appwrite.io/pink-icons-svelte": "2.0.0-RC.1", "@floating-ui/dom": "^1.6.13", "@melt-ui/pp": "^0.3.2", "@melt-ui/svelte": "^0.86.6", "@tanstack/svelte-virtual": "^3.13.10", "ansicolor": "^2.0.3", "d3": "^7.9.0", "fuse.js": "^7.1.0", "pretty-bytes": "^6.1.1", "shiki": "^1.18.0", "svelte-motion": "^0.12.2", "svelte-sonner": "^0.3.28" }, "peerDependencies": { "svelte": "^4.0.0" } }],
"@appwrite.io/pink-svelte": ["@appwrite.io/pink-svelte@https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@bfe7ce3", { "dependencies": { "@appwrite.io/pink-icons-svelte": "2.0.0-RC.1", "@floating-ui/dom": "^1.6.13", "@melt-ui/pp": "^0.3.2", "@melt-ui/svelte": "^0.86.6", "@tanstack/svelte-virtual": "^3.13.10", "ansicolor": "^2.0.3", "d3": "^7.9.0", "fuse.js": "^7.1.0", "pretty-bytes": "^6.1.1", "shiki": "^1.18.0", "svelte-motion": "^0.12.2", "svelte-sonner": "^0.3.28" }, "peerDependencies": { "svelte": "^4.0.0" } }],
"@asamuzakjp/css-color": ["@asamuzakjp/css-color@3.2.0", "", { "dependencies": { "@csstools/css-calc": "^2.1.3", "@csstools/css-color-parser": "^3.0.9", "@csstools/css-parser-algorithms": "^3.0.4", "@csstools/css-tokenizer": "^3.0.3", "lru-cache": "^10.4.3" } }, "sha512-K1A6z8tS3XsmCMM86xoWdn7Fkdn9m6RSVtocUrJYIwZnFVkng/PvkEoWtOWmP+Scc6saYWHWZYbndEEXxl24jw=="],
+1 -1
View File
@@ -24,7 +24,7 @@
"@appwrite.io/pink-icons": "0.25.0",
"@appwrite.io/pink-icons-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-icons-svelte@bfe7ce3",
"@appwrite.io/pink-legacy": "^1.0.3",
"@appwrite.io/pink-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@df765cc",
"@appwrite.io/pink-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@bfe7ce3",
"@codemirror/autocomplete": "^6.19.0",
"@codemirror/commands": "^6.9.0",
"@codemirror/lang-javascript": "^6.2.4",
+1 -1
View File
@@ -77,7 +77,7 @@ export async function generateFields(
}
case 'documentsdb': /* doesn't need any fields */
case 'vectordb': /* vector embeddings + metadata defined at collection creation */ {
case 'vectorsdb': /* vector embeddings + metadata defined at collection creation */ {
/* no individual field creation needed */
return [];
}
+2 -2
View File
@@ -26,7 +26,7 @@ import {
DocumentsDB,
Realtime,
Organizations,
VectorDB
VectorsDB
} from '@appwrite.io/console';
import { Sources } from '$lib/sdk/sources';
import {
@@ -138,7 +138,7 @@ const sdkForProject = {
sites: new Sites(clientProject),
tablesDB: new TablesDB(clientProject),
documentsDB: new DocumentsDB(clientProject),
vectorDB: new VectorDB(clientProject),
vectorsDB: new VectorsDB(clientProject),
console: new Console(clientProject) // for suggestions API
};
@@ -13,7 +13,7 @@ import {
toSupportiveIndex
} from './terminology';
import type { IndexType, Models, OrderBy } from '@appwrite.io/console';
import type { Models, OrderBy, TablesDBIndexType, DocumentsDBIndexType } from '@appwrite.io/console';
export type DatabaseSdkResult = {
create: (
@@ -87,7 +87,7 @@ export type DatabaseSdkResult = {
databaseId: string;
entityId: string;
key: string;
type: IndexType;
type: string;
attributes: string[];
lengths?: number[];
orders?: OrderBy[];
@@ -126,7 +126,7 @@ export function useDatabaseSdk(
case 'documentsdb': {
return await baseSdk.documentsDB.create(params);
}
case 'vectordb':
case 'vectorsdb':
throw new Error('Database type not supported yet');
default:
throw new Error('Unknown database type');
@@ -168,7 +168,7 @@ export function useDatabaseSdk(
return toSupportiveEntity(table);
}
case 'vectordb':
case 'vectorsdb':
throw new Error('Database type not supported yet');
default:
throw new Error('Unknown database type');
@@ -187,7 +187,7 @@ export function useDatabaseSdk(
await baseSdk.documentsDB.listCollections(params);
return { total, entities: collections.map(toSupportiveEntity) };
}
case 'vectordb':
case 'vectorsdb':
throw new Error(`Database type not supported yet`);
default:
throw new Error(`Unknown database type`);
@@ -212,7 +212,7 @@ export function useDatabaseSdk(
return toSupportiveEntity(collection);
}
case 'vectordb':
case 'vectorsdb':
throw new Error(`Database type not supported yet`);
default:
throw new Error(`Unknown database type`);
@@ -226,7 +226,7 @@ export function useDatabaseSdk(
return await baseSdk.tablesDB.delete(params);
case 'documentsdb':
return await baseSdk.documentsDB.delete(params);
case 'vectordb':
case 'vectorsdb':
throw new Error('Database type not supported yet');
default:
throw new Error(`Unknown database type`);
@@ -246,7 +246,7 @@ export function useDatabaseSdk(
databaseId: params.databaseId,
collectionId: params.entityId
});
case 'vectordb':
case 'vectorsdb':
throw new Error('Database type not supported yet');
default:
throw new Error(`Unknown database type`);
@@ -272,7 +272,7 @@ export function useDatabaseSdk(
data: params.data,
permissions: params.permissions
});
case 'vectordb':
case 'vectorsdb':
throw new Error('Database type not supported yet');
default:
throw new Error(`Unknown database type`);
@@ -298,7 +298,7 @@ export function useDatabaseSdk(
data: params.data,
permissions: params.permissions
});
case 'vectordb':
case 'vectorsdb':
throw new Error('Database type not supported yet');
default:
throw new Error(`Unknown database type`);
@@ -322,7 +322,7 @@ export function useDatabaseSdk(
documentId: params.recordId,
permissions: params.permissions
});
case 'vectordb':
case 'vectorsdb':
throw new Error('Database type not supported yet');
default:
throw new Error(`Unknown database type`);
@@ -348,7 +348,7 @@ export function useDatabaseSdk(
});
return toSupportiveRecord(document);
}
case 'vectordb':
case 'vectorsdb':
throw new Error('Database type not supported yet');
default:
throw new Error(`Unknown database type`);
@@ -374,7 +374,7 @@ export function useDatabaseSdk(
});
return { total, records: documents.map(toSupportiveRecord) };
}
case 'vectordb':
case 'vectorsdb':
throw new Error('Database type not supported yet');
default:
throw new Error(`Unknown database type`);
@@ -389,7 +389,7 @@ export function useDatabaseSdk(
databaseId: params.databaseId,
tableId: params.entityId,
key: params.key,
type: params.type,
type: params.type as TablesDBIndexType,
columns: params.attributes,
lengths: params.lengths,
orders: params.orders
@@ -401,14 +401,14 @@ export function useDatabaseSdk(
databaseId: params.databaseId,
collectionId: params.entityId,
key: params.key,
type: params.type,
type: params.type as DocumentsDBIndexType,
attributes: params.attributes,
lengths: params.lengths,
orders: params.orders
});
return toSupportiveIndex(index);
}
case 'vectordb':
case 'vectorsdb':
throw new Error('Database type not supported yet');
default:
throw new Error(`Unknown database type`);
@@ -1,15 +1,15 @@
import type { Page } from '@sveltejs/kit';
import { capitalize, plural } from '$lib/helpers/string';
import { AppwriteException, type IndexType, type Models } from '@appwrite.io/console';
import { AppwriteException, type DatabasesIndexType, type Models } from '@appwrite.io/console';
import type { Attributes, Collection, Columns, Table } from '$database/store';
import type { Term, TerminologyResult, TerminologyShape } from '$database/(entity)/helpers/types';
type BaseTerminology = typeof baseTerminology;
type ImplementedDBTypes = Omit<BaseTerminology, 'vectordb' | 'legacy'>;
/* manual type for the time being because vectordb is pending */
export type DatabaseType = 'legacy' | 'tablesdb' | 'documentsdb' | 'vectordb';
/* manual type for the time being because vectorsdb is pending */
export type DatabaseType = 'legacy' | 'tablesdb' | 'documentsdb' | 'vectorsdb';
export type RecordType = ImplementedDBTypes[keyof ImplementedDBTypes]['record'];
@@ -28,7 +28,7 @@ export type Record = Partial<Models.Document | Models.Row> & {
export type Index = Partial<Models.Index | Models.ColumnIndex> & {
fields: Models.Index['attributes'] | Models.ColumnIndex['columns'];
type: IndexType;
type: string;
};
export type EntityList = {
@@ -95,7 +95,7 @@ const terminologyData = Object.fromEntries(
export function toSupportiveIndex(index: Models.Index | Models.ColumnIndex): Index {
return {
...index,
type: index.type as IndexType,
type: index.type as DatabasesIndexType,
fields: (index as Models.Index).attributes ?? (index as Models.ColumnIndex).columns ?? []
};
}
@@ -1,8 +1,8 @@
<script module lang="ts">
import { IndexType, OrderBy } from '@appwrite.io/console';
import { DatabasesIndexType, OrderBy } from '@appwrite.io/console';
export type CreateIndexesCallbackType = {
key: string;
type: IndexType;
type: string;
fields: string[];
lengths: (number | null)[];
orders: OrderBy[];
@@ -39,14 +39,14 @@
let key = $state('');
let initializedForOpen = $state(false);
let selectedType = $state<IndexType>(IndexType.Key);
let selectedType = $state<DatabasesIndexType>(DatabasesIndexType.Key);
const { dependencies, terminology } = getTerminologies();
const fieldOptions = $derived(
entity.fields
.filter((field) => {
if (selectedType === IndexType.Spatial) {
if (selectedType === DatabasesIndexType.Spatial) {
// keep only spatial
return isSpatialType(field);
}
@@ -67,15 +67,15 @@
}> = $state([{ value: '', order: null, length: null }]);
const types = [
{ value: IndexType.Key, label: 'Key' },
{ value: IndexType.Unique, label: 'Unique' },
{ value: IndexType.Fulltext, label: 'Fulltext' },
{ value: IndexType.Spatial, label: 'Spatial' }
{ value: DatabasesIndexType.Key, label: 'Key' },
{ value: DatabasesIndexType.Unique, label: 'Unique' },
{ value: DatabasesIndexType.Fulltext, label: 'Fulltext' },
{ value: DatabasesIndexType.Spatial, label: 'Spatial' }
];
// order options derived from selected type
let orderOptions = $derived.by(() =>
selectedType === IndexType.Spatial
selectedType === DatabasesIndexType.Spatial
? [
{ value: OrderBy.Asc, label: 'ASC' },
{ value: OrderBy.Desc, label: 'DESC' },
@@ -91,7 +91,7 @@
// and the field already is not spatial type
$effect(() => {
const firstField = entity.fields.find((field) => field.key === fieldList.at(0)?.value);
if (selectedType === IndexType.Spatial && firstField && !isSpatialType(firstField)) {
if (selectedType === DatabasesIndexType.Spatial && firstField && !isSpatialType(firstField)) {
fieldList = [{ value: '', order: null, length: null }];
}
});
@@ -112,7 +112,7 @@
const isSpatial = field.length && isSpatialType(field[0]);
const order = isSpatial ? null : OrderBy.Asc;
selectedType = isSpatial ? IndexType.Spatial : IndexType.Key;
selectedType = isSpatial ? DatabasesIndexType.Spatial : DatabasesIndexType.Key;
fieldList = externalFieldKey
? [{ value: externalFieldKey, order, length: null }]
@@ -122,7 +122,7 @@
}
const addFieldDisabled = $derived(
selectedType === IndexType.Spatial ||
selectedType === DatabasesIndexType.Spatial ||
!fieldList.at(-1)?.value ||
(!fieldList.at(-1)?.order && fieldList.at(-1)?.order !== null)
);
@@ -153,7 +153,7 @@
export async function create() {
const fieldType = terminology.field.lower.singular;
if (!key || !selectedType || (selectedType !== IndexType.Spatial && addFieldDisabled)) {
if (!key || !selectedType || (selectedType !== DatabasesIndexType.Spatial && addFieldDisabled)) {
addNotification({
type: 'error',
message: `Selected ${fieldType} key or type invalid`
@@ -232,7 +232,7 @@
required
options={[
// allow system fields only for non-spatial index types
...(selectedType === IndexType.Spatial
...(selectedType === DatabasesIndexType.Spatial
? []
: [
{ value: '$id', label: '$id', leadingIcon: IconFingerPrint },
@@ -262,7 +262,7 @@
bind:value={field.order}
placeholder="Select order" />
{#if selectedType === IndexType.Key}
{#if selectedType === DatabasesIndexType.Key}
<InputNumber
id={`length-${index}`}
label={index === 0 ? 'Length' : undefined}
@@ -6,7 +6,7 @@
import { Modal } from '$lib/components';
import { type Entity, SideSheet } from '$database/(entity)';
import { isSmallViewport } from '$lib/stores/viewport';
import { IndexType, OrderBy } from '@appwrite.io/console';
import { DatabasesIndexType, OrderBy, TablesDBIndexType } from '@appwrite.io/console';
import { capitalize } from '$lib/helpers/string';
import type { Columns } from '$database/store';
import { isRelationship } from '../table-[table]/rows/store';
@@ -67,7 +67,7 @@
indexes = mockSuggestions.columns.slice(0, 3).map((column, index) => ({
key: column.name,
type: IndexType.Key,
type: DatabasesIndexType.Key,
fields: [column.name],
orders: index === 2 ? OrderBy.Desc : OrderBy.Asc,
lengths: []
@@ -84,7 +84,7 @@
indexes = suggestions.indexes.map((index) => {
return {
key: index.columns[0],
type: index.type as IndexType,
type: index.type as DatabasesIndexType,
orders: (index.orders?.[0] as OrderBy) || OrderBy.Asc,
fields: index.columns,
lengths: index.lengths ?? []
@@ -112,7 +112,7 @@
if (indexes.length < MAX_INDEXES) {
indexes.push({
key: '',
type: IndexType.Key,
type: DatabasesIndexType.Key,
orders: OrderBy.Asc,
fields: [],
lengths: null
@@ -133,9 +133,9 @@
}
}
function getOrderOptions(selectedType: IndexType) {
function getOrderOptions(selectedType: DatabasesIndexType) {
const base = [OrderBy.Asc, OrderBy.Desc];
const values = selectedType === IndexType.Spatial ? [...base, null] : base;
const values = selectedType === DatabasesIndexType.Spatial ? [...base, null] : base;
return values.map((order) => ({
label: order ? capitalize(String(order)) : 'None',
@@ -165,7 +165,7 @@
// prepare lengths array
let lengths: (number | null)[];
if (index.type === IndexType.Key) {
if (index.type === DatabasesIndexType.Key) {
// only validate if it's a key index
lengths = index.fields.map((columnKey, i) => {
const maxSize = columnMap.get(columnKey);
@@ -239,7 +239,7 @@
databaseId: table.databaseId,
tableId: table.$id,
key: uniqueIndexKey,
type: index.type,
type: index.type as TablesDBIndexType,
columns: index.fields,
lengths,
...(orders.length ? { orders } : {})
@@ -291,7 +291,7 @@
return false; // close the sheet!
}
const typeOptions = Object.values(IndexType).map((type) => ({
const typeOptions = Object.values(DatabasesIndexType).map((type) => ({
label: capitalize(type),
value: type
}));
@@ -1,5 +1,5 @@
import { writable } from 'svelte/store';
import { IndexType, OrderBy } from '@appwrite.io/console';
import { OrderBy } from '@appwrite.io/console';
import { columnOptions } from '../table-[table]/columns/store';
export type EntityColumnSuggestions = {
@@ -34,7 +34,7 @@ export type IndexOrder = OrderBy | null;
export type SuggestedIndexSchema = {
key: string;
type: IndexType;
type: string;
orders: IndexOrder;
fields: string[];
lengths?: number[] | undefined;
@@ -1,6 +1,7 @@
<script lang="ts">
import { page } from '$app/state';
import { sdk } from '$lib/stores/sdk';
import type { DocumentsDBIndexType } from '@appwrite.io/console';
import type { PageProps } from './$types';
import {
type CreateIndexesCallbackType,
@@ -25,7 +26,7 @@
await documentsDB.createIndex({
...params,
key: index.key,
type: index.type,
type: index.type as DocumentsDBIndexType,
attributes: index.fields,
lengths: index.lengths,
orders: index.orders
@@ -21,6 +21,7 @@
import { goto, invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import { type RealtimeResponse, realtime, sdk } from '$lib/stores/sdk';
import type { TablesDBIndexType } from '@appwrite.io/console';
import { onMount } from 'svelte';
import {
columnsOrder,
@@ -565,7 +566,7 @@
databaseId: page.params.database,
tableId: page.params.table,
key: index.key,
type: index.type,
type: index.type as TablesDBIndexType,
columns: index.fields,
lengths: index.lengths,
orders: index.orders
@@ -2,6 +2,7 @@
import { page } from '$app/state';
import { onDestroy } from 'svelte';
import { sdk } from '$lib/stores/sdk';
import type { TablesDBIndexType } from '@appwrite.io/console';
import { isCloud } from '$lib/system';
import type { PageProps } from './$types';
import { canWriteTables } from '$lib/stores/roles';
@@ -30,7 +31,7 @@
await tablesDB.createIndex({
...params,
key: index.key,
type: index.type,
type: index.type as TablesDBIndexType,
columns: index.fields,
lengths: index.lengths,
orders: index.orders
@@ -984,13 +984,9 @@
</Id>
<Popover let:show let:hide portal padding="none">
{@const opacityValue =
showExpandIconForId === index ? '1' : '0'}
<button
on:mouseenter={show}
on:mouseleave={hide}
style:opacity={opacityValue}
style:transition="opacity 225ms ease-in-out">
on:mouseleave={hide}>
<Button.Button
size="xs"
icon
@@ -1036,7 +1032,6 @@
</Popover>
</Layout.Stack>
</Spreadsheet.Cell>
</button>
{:else}
<Spreadsheet.Cell {root} {isEditable} column={columnId}>
{#if columnId === '$createdAt' || columnId === '$updatedAt'}
@@ -31,7 +31,7 @@ export function getDatabaseTypeTitle(database: Models.Database) {
return 'TablesDB';
case 'documentsdb':
return 'DocumentsDB';
case 'vectordb':
return 'VectorDB';
case 'vectorsdb':
return 'VectorsDB';
}
}