|
1 | 1 | <script module lang="ts"> |
2 | | - import { DatabasesIndexType, OrderBy } from '@appwrite.io/console'; |
| 2 | + import { TablesDBIndexType, OrderBy } from '@appwrite.io/console'; |
3 | 3 | export type CreateIndexesCallbackType = { |
4 | 4 | key: string; |
5 | | - type: DatabasesIndexType; |
| 5 | + type: TablesDBIndexType; |
6 | 6 | fields: string[]; |
7 | 7 | lengths: (number | null)[]; |
8 | 8 | orders: OrderBy[]; |
|
40 | 40 |
|
41 | 41 | let key = $state(''); |
42 | 42 | let initializedForOpen = $state(false); |
43 | | - let selectedType = $state<DatabasesIndexType>(DatabasesIndexType.Key); |
| 43 | + let selectedType = $state<TablesDBIndexType>(TablesDBIndexType.Key); |
44 | 44 |
|
45 | 45 | const { dependencies, terminology } = getTerminologies(); |
46 | 46 |
|
47 | 47 | const fieldOptions = $derived( |
48 | 48 | entity.fields |
49 | 49 | .filter((field) => { |
50 | | - if (selectedType === DatabasesIndexType.Spatial) { |
| 50 | + if (selectedType === TablesDBIndexType.Spatial) { |
51 | 51 | // keep only spatial |
52 | 52 | return isSpatialType(field); |
53 | 53 | } |
|
69 | 69 |
|
70 | 70 | const types = $derived( |
71 | 71 | [ |
72 | | - { value: DatabasesIndexType.Key, label: 'Key' }, |
73 | | - { value: DatabasesIndexType.Unique, label: 'Unique' }, |
74 | | - { value: DatabasesIndexType.Fulltext, label: 'Fulltext' }, |
75 | | - { value: DatabasesIndexType.Spatial, label: 'Spatial' } |
| 72 | + { value: TablesDBIndexType.Key, label: 'Key' }, |
| 73 | + { value: TablesDBIndexType.Unique, label: 'Unique' }, |
| 74 | + { value: TablesDBIndexType.Fulltext, label: 'Fulltext' }, |
| 75 | + { value: TablesDBIndexType.Spatial, label: 'Spatial' } |
76 | 76 | ].filter((type) => { |
77 | 77 | if ( |
78 | | - type.value === DatabasesIndexType.Spatial && |
| 78 | + type.value === TablesDBIndexType.Spatial && |
79 | 79 | !$regionalConsoleVariables?.supportForSpatials |
80 | 80 | ) |
81 | 81 | return false; |
|
85 | 85 |
|
86 | 86 | // order options derived from selected type |
87 | 87 | let orderOptions = $derived.by(() => |
88 | | - selectedType === DatabasesIndexType.Spatial |
| 88 | + selectedType === TablesDBIndexType.Spatial |
89 | 89 | ? [ |
90 | 90 | { value: OrderBy.Asc, label: 'ASC' }, |
91 | 91 | { value: OrderBy.Desc, label: 'DESC' }, |
|
102 | 102 | $effect(() => { |
103 | 103 | const firstField = entity.fields.find((field) => field.key === fieldList.at(0)?.value); |
104 | 104 | if ( |
105 | | - selectedType === DatabasesIndexType.Spatial && |
| 105 | + selectedType === TablesDBIndexType.Spatial && |
106 | 106 | firstField && |
107 | 107 | !isSpatialType(firstField) |
108 | 108 | ) { |
|
126 | 126 | const isSpatial = field.length && isSpatialType(field[0]); |
127 | 127 | const order = isSpatial ? null : OrderBy.Asc; |
128 | 128 |
|
129 | | - selectedType = isSpatial ? DatabasesIndexType.Spatial : DatabasesIndexType.Key; |
| 129 | + selectedType = isSpatial ? TablesDBIndexType.Spatial : TablesDBIndexType.Key; |
130 | 130 |
|
131 | 131 | fieldList = externalFieldKey |
132 | 132 | ? [{ value: externalFieldKey, order, length: null }] |
|
136 | 136 | } |
137 | 137 |
|
138 | 138 | const addFieldDisabled = $derived( |
139 | | - selectedType === DatabasesIndexType.Spatial || |
| 139 | + selectedType === TablesDBIndexType.Spatial || |
140 | 140 | !fieldList.at(-1)?.value || |
141 | 141 | (!fieldList.at(-1)?.order && fieldList.at(-1)?.order !== null) |
142 | 142 | ); |
|
170 | 170 | if ( |
171 | 171 | !key || |
172 | 172 | !selectedType || |
173 | | - (selectedType !== DatabasesIndexType.Spatial && addFieldDisabled) |
| 173 | + (selectedType !== TablesDBIndexType.Spatial && addFieldDisabled) |
174 | 174 | ) { |
175 | 175 | addNotification({ |
176 | 176 | type: 'error', |
|
250 | 250 | required |
251 | 251 | options={[ |
252 | 252 | // allow system fields only for non-spatial index types |
253 | | - ...(selectedType === DatabasesIndexType.Spatial |
| 253 | + ...(selectedType === TablesDBIndexType.Spatial |
254 | 254 | ? [] |
255 | 255 | : [ |
256 | 256 | { value: '$id', label: '$id', leadingIcon: IconFingerPrint }, |
|
280 | 280 | bind:value={field.order} |
281 | 281 | placeholder="Select order" /> |
282 | 282 |
|
283 | | - {#if selectedType === DatabasesIndexType.Key} |
| 283 | + {#if selectedType === TablesDBIndexType.Key} |
284 | 284 | <InputNumber |
285 | 285 | id={`length-${index}`} |
286 | 286 | label={index === 0 ? 'Length' : undefined} |
|
0 commit comments