Skip to content

Commit d95ba37

Browse files
committed
Fix Indextype sdk compatibility
1 parent 36a578c commit d95ba37

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

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

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

Lines changed: 16 additions & 16 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: DatabasesIndexType;
66
fields: string[];
77
lengths: (number | null)[];
88
orders: OrderBy[];
@@ -40,14 +40,14 @@
4040
4141
let key = $state('');
4242
let initializedForOpen = $state(false);
43-
let selectedType = $state<IndexType>(IndexType.Key);
43+
let selectedType = $state<DatabasesIndexType>(DatabasesIndexType.Key);
4444
4545
const { dependencies, terminology } = getTerminologies();
4646
4747
const fieldOptions = $derived(
4848
entity.fields
4949
.filter((field) => {
50-
if (selectedType === IndexType.Spatial) {
50+
if (selectedType === DatabasesIndexType.Spatial) {
5151
// keep only spatial
5252
return isSpatialType(field);
5353
}
@@ -69,20 +69,20 @@
6969
7070
const types = $derived(
7171
[
72-
{ value: IndexType.Key, label: 'Key' },
73-
{ value: IndexType.Unique, label: 'Unique' },
74-
{ value: IndexType.Fulltext, label: 'Fulltext' },
75-
{ value: IndexType.Spatial, label: 'Spatial' }
72+
{ value: DatabasesIndexType.Key, label: 'Key' },
73+
{ value: DatabasesIndexType.Unique, label: 'Unique' },
74+
{ value: DatabasesIndexType.Fulltext, label: 'Fulltext' },
75+
{ value: DatabasesIndexType.Spatial, label: 'Spatial' }
7676
].filter((type) => {
77-
if (type.value === IndexType.Spatial && !$regionalConsoleVariables?.supportForSpatials)
77+
if (type.value === DatabasesIndexType.Spatial && !$regionalConsoleVariables?.supportForSpatials)
7878
return false;
7979
return true;
8080
})
8181
);
8282
8383
// order options derived from selected type
8484
let orderOptions = $derived.by(() =>
85-
selectedType === IndexType.Spatial
85+
selectedType === DatabasesIndexType.Spatial
8686
? [
8787
{ value: OrderBy.Asc, label: 'ASC' },
8888
{ value: OrderBy.Desc, label: 'DESC' },
@@ -98,7 +98,7 @@
9898
// and the field already is not spatial type
9999
$effect(() => {
100100
const firstField = entity.fields.find((field) => field.key === fieldList.at(0)?.value);
101-
if (selectedType === IndexType.Spatial && firstField && !isSpatialType(firstField)) {
101+
if (selectedType === DatabasesIndexType.Spatial && firstField && !isSpatialType(firstField)) {
102102
fieldList = [{ value: '', order: null, length: null }];
103103
}
104104
});
@@ -119,7 +119,7 @@
119119
const isSpatial = field.length && isSpatialType(field[0]);
120120
const order = isSpatial ? null : OrderBy.Asc;
121121
122-
selectedType = isSpatial ? IndexType.Spatial : IndexType.Key;
122+
selectedType = isSpatial ? DatabasesIndexType.Spatial : DatabasesIndexType.Key;
123123
124124
fieldList = externalFieldKey
125125
? [{ value: externalFieldKey, order, length: null }]
@@ -129,7 +129,7 @@
129129
}
130130
131131
const addFieldDisabled = $derived(
132-
selectedType === IndexType.Spatial ||
132+
selectedType === DatabasesIndexType.Spatial ||
133133
!fieldList.at(-1)?.value ||
134134
(!fieldList.at(-1)?.order && fieldList.at(-1)?.order !== null)
135135
);
@@ -160,7 +160,7 @@
160160
export async function create() {
161161
const fieldType = terminology.field.lower.singular;
162162
163-
if (!key || !selectedType || (selectedType !== IndexType.Spatial && addFieldDisabled)) {
163+
if (!key || !selectedType || (selectedType !== DatabasesIndexType.Spatial && addFieldDisabled)) {
164164
addNotification({
165165
type: 'error',
166166
message: `Selected ${fieldType} key or type invalid`
@@ -239,7 +239,7 @@
239239
required
240240
options={[
241241
// allow system fields only for non-spatial index types
242-
...(selectedType === IndexType.Spatial
242+
...(selectedType === DatabasesIndexType.Spatial
243243
? []
244244
: [
245245
{ value: '$id', label: '$id', leadingIcon: IconFingerPrint },
@@ -269,7 +269,7 @@
269269
bind:value={field.order}
270270
placeholder="Select order" />
271271

272-
{#if selectedType === IndexType.Key}
272+
{#if selectedType === DatabasesIndexType.Key}
273273
<InputNumber
274274
id={`length-${index}`}
275275
label={index === 0 ? 'Length' : undefined}

0 commit comments

Comments
 (0)