Skip to content

Commit 2f102ff

Browse files
authored
Merge pull request #2932 from appwrite/fix-project-variables
Fix project variables missing param
2 parents 5251384 + 62e5f03 commit 2f102ff

10 files changed

Lines changed: 55 additions & 39 deletions

File tree

bun.lock

Lines changed: 2 additions & 3 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
@@ -20,7 +20,7 @@
2020
},
2121
"dependencies": {
2222
"@ai-sdk/svelte": "^1.1.24",
23-
"@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@69509a7",
23+
"@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@83fd10c",
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",

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/routes/(console)/project-[region]-[project]/databases/database-[database]/(entity)/helpers/sdk.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export function useDatabaseSdk(
6666
const { total, tables } = await baseSdk.tablesDB.listTables(params);
6767
return { total, entities: tables.map(toSupportiveEntity) };
6868
}
69-
case 'vectordb':
69+
case 'vectorsdb':
7070
case 'documentsdb':
7171
throw new Error(`Database type not supported yet`);
7272
default:
@@ -85,7 +85,7 @@ export function useDatabaseSdk(
8585
return toSupportiveEntity(table);
8686
}
8787
case 'documentsdb':
88-
case 'vectordb':
88+
case 'vectorsdb':
8989
throw new Error(`Database type not supported yet`);
9090
default:
9191
throw new Error(`Unknown database type`);
@@ -98,7 +98,7 @@ export function useDatabaseSdk(
9898
case 'tablesdb':
9999
return await baseSdk.tablesDB.delete(params);
100100
case 'documentsdb':
101-
case 'vectordb':
101+
case 'vectorsdb':
102102
throw new Error(`Database type not supported yet`);
103103
default:
104104
throw new Error(`Unknown database type`);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { AppwriteException, type Models } from '@appwrite.io/console';
55
import type { Attributes, Columns, Table } from '$database/table-[table]/store';
66
import type { Term, TerminologyResult, TerminologyShape } from '$database/(entity)/helpers/types';
77

8-
export type DatabaseType = 'legacy' | 'tablesdb' | 'documentsdb' | 'vectordb';
8+
export type DatabaseType = Models.Database['type'];
99

1010
export type Entity = Partial<Models.Collection | Table> & {
1111
indexes?: Index[];
@@ -45,7 +45,7 @@ export const baseTerminology = {
4545
field: 'attribute',
4646
record: 'document'
4747
},
48-
vectordb: {}
48+
vectorsdb: {}
4949
} as const;
5050

5151
const createTerm = (singular: string, pluralForm: string): Term => {

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

Lines changed: 27 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 { TablesDBIndexType, OrderBy } from '@appwrite.io/console';
33
export type CreateIndexesCallbackType = {
44
key: string;
5-
type: IndexType;
5+
type: TablesDBIndexType;
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<TablesDBIndexType>(TablesDBIndexType.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 === TablesDBIndexType.Spatial) {
5151
// keep only spatial
5252
return isSpatialType(field);
5353
}
@@ -69,20 +69,23 @@
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: TablesDBIndexType.Key, label: 'Key' },
73+
{ value: TablesDBIndexType.Unique, label: 'Unique' },
74+
{ value: TablesDBIndexType.Fulltext, label: 'Fulltext' },
75+
{ value: TablesDBIndexType.Spatial, label: 'Spatial' }
7676
].filter((type) => {
77-
if (type.value === IndexType.Spatial && !$regionalConsoleVariables?.supportForSpatials)
77+
if (
78+
type.value === TablesDBIndexType.Spatial &&
79+
!$regionalConsoleVariables?.supportForSpatials
80+
)
7881
return false;
7982
return true;
8083
})
8184
);
8285
8386
// order options derived from selected type
8487
let orderOptions = $derived.by(() =>
85-
selectedType === IndexType.Spatial
88+
selectedType === TablesDBIndexType.Spatial
8689
? [
8790
{ value: OrderBy.Asc, label: 'ASC' },
8891
{ value: OrderBy.Desc, label: 'DESC' },
@@ -98,7 +101,11 @@
98101
// and the field already is not spatial type
99102
$effect(() => {
100103
const firstField = entity.fields.find((field) => field.key === fieldList.at(0)?.value);
101-
if (selectedType === IndexType.Spatial && firstField && !isSpatialType(firstField)) {
104+
if (
105+
selectedType === TablesDBIndexType.Spatial &&
106+
firstField &&
107+
!isSpatialType(firstField)
108+
) {
102109
fieldList = [{ value: '', order: null, length: null }];
103110
}
104111
});
@@ -119,7 +126,7 @@
119126
const isSpatial = field.length && isSpatialType(field[0]);
120127
const order = isSpatial ? null : OrderBy.Asc;
121128
122-
selectedType = isSpatial ? IndexType.Spatial : IndexType.Key;
129+
selectedType = isSpatial ? TablesDBIndexType.Spatial : TablesDBIndexType.Key;
123130
124131
fieldList = externalFieldKey
125132
? [{ value: externalFieldKey, order, length: null }]
@@ -129,7 +136,7 @@
129136
}
130137
131138
const addFieldDisabled = $derived(
132-
selectedType === IndexType.Spatial ||
139+
selectedType === TablesDBIndexType.Spatial ||
133140
!fieldList.at(-1)?.value ||
134141
(!fieldList.at(-1)?.order && fieldList.at(-1)?.order !== null)
135142
);
@@ -160,7 +167,11 @@
160167
export async function create() {
161168
const fieldType = terminology.field.lower.singular;
162169
163-
if (!key || !selectedType || (selectedType !== IndexType.Spatial && addFieldDisabled)) {
170+
if (
171+
!key ||
172+
!selectedType ||
173+
(selectedType !== TablesDBIndexType.Spatial && addFieldDisabled)
174+
) {
164175
addNotification({
165176
type: 'error',
166177
message: `Selected ${fieldType} key or type invalid`
@@ -239,7 +250,7 @@
239250
required
240251
options={[
241252
// allow system fields only for non-spatial index types
242-
...(selectedType === IndexType.Spatial
253+
...(selectedType === TablesDBIndexType.Spatial
243254
? []
244255
: [
245256
{ value: '$id', label: '$id', leadingIcon: IconFingerPrint },
@@ -269,7 +280,7 @@
269280
bind:value={field.order}
270281
placeholder="Select order" />
271282

272-
{#if selectedType === IndexType.Key}
283+
{#if selectedType === TablesDBIndexType.Key}
273284
<InputNumber
274285
id={`length-${index}`}
275286
label={index === 0 ? 'Length' : undefined}

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { Modal } from '$lib/components';
77
import { type Entity, SideSheet } from '$database/(entity)';
88
import { isSmallViewport } from '$lib/stores/viewport';
9-
import { IndexType, OrderBy } from '@appwrite.io/console';
9+
import { TablesDBIndexType, OrderBy } from '@appwrite.io/console';
1010
import { capitalize } from '$lib/helpers/string';
1111
import { type Columns } from '../table-[table]/store';
1212
import { isRelationship } from '../table-[table]/rows/store';
@@ -68,7 +68,7 @@
6868
6969
indexes = mockSuggestions.columns.slice(0, 3).map((column, index) => ({
7070
key: column.name,
71-
type: IndexType.Key,
71+
type: TablesDBIndexType.Key,
7272
fields: [column.name],
7373
orders: index === 2 ? OrderBy.Desc : OrderBy.Asc,
7474
lengths: []
@@ -85,7 +85,7 @@
8585
indexes = suggestions.indexes.map((index) => {
8686
return {
8787
key: index.columns[0],
88-
type: index.type as IndexType,
88+
type: index.type as TablesDBIndexType,
8989
orders: (index.orders?.[0] as OrderBy) || OrderBy.Asc,
9090
fields: index.columns,
9191
lengths: index.lengths ?? []
@@ -113,7 +113,7 @@
113113
if (indexes.length < MAX_INDEXES) {
114114
indexes.push({
115115
key: '',
116-
type: IndexType.Key,
116+
type: TablesDBIndexType.Key,
117117
orders: OrderBy.Asc,
118118
fields: [],
119119
lengths: null
@@ -134,9 +134,9 @@
134134
}
135135
}
136136
137-
function getOrderOptions(selectedType: IndexType) {
137+
function getOrderOptions(selectedType: TablesDBIndexType) {
138138
const base = [OrderBy.Asc, OrderBy.Desc];
139-
const values = selectedType === IndexType.Spatial ? [...base, null] : base;
139+
const values = selectedType === TablesDBIndexType.Spatial ? [...base, null] : base;
140140
141141
return values.map((order) => ({
142142
label: order ? capitalize(String(order)) : 'None',
@@ -166,7 +166,7 @@
166166
167167
// prepare lengths array
168168
let lengths: (number | null)[];
169-
if (index.type === IndexType.Key) {
169+
if (index.type === TablesDBIndexType.Key) {
170170
// only validate if it's a key index
171171
lengths = index.fields.map((columnKey, i) => {
172172
const maxSize = columnMap.get(columnKey);
@@ -293,9 +293,12 @@
293293
}
294294
295295
const typeOptions = $derived(
296-
Object.values(IndexType)
296+
Object.values(TablesDBIndexType)
297297
.filter((type) => {
298-
if (type === IndexType.Spatial && !$regionalConsoleVariables?.supportForSpatials)
298+
if (
299+
type === TablesDBIndexType.Spatial &&
300+
!$regionalConsoleVariables?.supportForSpatials
301+
)
299302
return false;
300303
return true;
301304
})

src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/store.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { writable } from 'svelte/store';
2-
import { IndexType, OrderBy } from '@appwrite.io/console';
2+
import { TablesDBIndexType, OrderBy } from '@appwrite.io/console';
33
import { columnOptions } from '../table-[table]/columns/store';
44

55
export type TableColumnSuggestions = {
@@ -34,7 +34,7 @@ export type IndexOrder = OrderBy | null;
3434

3535
export type SuggestedIndexSchema = {
3636
key: string;
37-
type: IndexType;
37+
type: TablesDBIndexType;
3838
orders: IndexOrder;
3939
fields: string[];
4040
lengths?: number[] | undefined;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import UpdateVariables from '../updateVariables.svelte';
1717
import { page } from '$app/state';
1818
import UpdateLabels from './updateLabels.svelte';
19+
import { ID } from '@appwrite.io/console';
1920
2021
export let data;
2122
@@ -59,7 +60,7 @@
5960
async function sdkCreateVariable(key: string, value: string, secret: boolean) {
6061
await sdk
6162
.forProject(page.params.region, page.params.project)
62-
.projectApi.createVariable({ key, value, secret });
63+
.projectApi.createVariable({ variableId: ID.unique(), key, value, secret });
6364
await invalidate(Dependencies.PROJECT_VARIABLES);
6465
}
6566

src/routes/(console)/project-[region]-[project]/updateVariables.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts">
22
import { sdk } from '$lib/stores/sdk';
3-
import type { Models } from '@appwrite.io/console';
3+
import { ID, type Models } from '@appwrite.io/console';
44
import { Button } from '$lib/elements/forms';
55
import { CardGrid, Empty, Output, PaginationInline } from '$lib/components';
66
import UploadVariables from './uploadVariablesModal.svelte';
@@ -172,6 +172,7 @@
172172
await sdk
173173
.forProject(page.params.region, page.params.project)
174174
.projectApi.createVariable({
175+
variableId: ID.unique(),
175176
key: variable.key,
176177
value: variable.value,
177178
secret: variable.secret
@@ -195,6 +196,7 @@
195196
await sdk
196197
.forProject(page.params.region, page.params.project)
197198
.projectApi.createVariable({
199+
variableId: ID.unique(),
198200
key: variable.key,
199201
value: variable.value,
200202
secret: variable.secret

0 commit comments

Comments
 (0)