Skip to content

Commit c768722

Browse files
ArnabChatterjee20kpremtsd-code
authored andcommitted
fix: update proxy rule status handling and improve variable ID generation in function and site creation
1 parent b0d92f5 commit c768722

24 files changed

Lines changed: 73 additions & 23 deletions

File tree

src/lib/components/domains/status.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ export function isProxyRuleVerified(status: ProxyRuleStatusValue): boolean {
1313
}
1414

1515
export function normalizeProxyRuleStatus(status: ProxyRuleStatusValue): ProxyRuleStatusValue {
16-
if (status === ProxyRuleStatus.Created) {
17-
return ProxyRuleStatus.Unverified;
18-
}
19-
2016
return status;
2117
}
2218

src/lib/components/domains/viewLogsModal.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
try {
4444
selectedProxyRule = await sdk
4545
.forProject(page.params.region, page.params.project)
46-
.proxy.updateRuleVerification({ ruleId: selectedProxyRule.$id });
46+
.proxy.updateRuleStatus({ ruleId: selectedProxyRule.$id });
4747
4848
await invalidate(Dependencies.DOMAINS);
4949
show = false;

src/routes/(console)/project-[region]-[project]/auth/updateOAuth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ async function updateProjectOAuth({
218218
clientSecret: getSecret('clientSecret'),
219219
wellKnownURL: getDetail('wellKnownURL'),
220220
authorizationURL: getDetail('authorizationURL'),
221-
tokenUrl: getDetail('tokenUrl'),
222-
userInfoUrl: getDetail('userInfoUrl'),
221+
tokenURL: getDetail('tokenUrl'),
222+
userInfoURL: getDetail('userInfoUrl'),
223223
enabled
224224
});
225225
case OAuthProvider.Okta:

src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/rows/create.svelte

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
import { invalidate } from '$app/navigation';
1515
import { Dependencies } from '$lib/constants';
1616
import { tick } from 'svelte';
17-
import { isRelationship, isRelationshipToMany } from './store';
17+
import { isRelationship, isRelationshipToMany, buildPayload } from './store';
18+
import type { RowValue } from './store';
1819
import { hash } from '$lib/helpers/string';
1920
2021
type CreateRow = {
@@ -70,7 +71,7 @@
7071
function prepareRowPayload(createRowObject: CreateRow): object {
7172
const { row, columns } = createRowObject;
7273
73-
const payload = structuredClone(row);
74+
const payload = structuredClone(row) as Record<string, RowValue>;
7475
7576
for (const column of columns) {
7677
if (isRelationship(column) && !isRelationshipToMany(column)) {
@@ -79,15 +80,21 @@
7980
8081
if (value && typeof value === 'object') {
8182
if (Array.isArray(value)) {
82-
payload[key] = value.map((item) => item?.$id).filter(Boolean);
83+
payload[key] = value
84+
.map((item) =>
85+
item && typeof item === 'object' && '$id' in item
86+
? (item.$id as string)
87+
: null
88+
)
89+
.filter(Boolean);
8390
} else {
8491
payload[key] = (value as { $id: string })['$id'];
8592
}
8693
}
8794
}
8895
}
8996
90-
return payload;
97+
return buildPayload(columns, payload);
9198
}
9299
93100
async function create(): Promise<boolean> {

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import type { Column } from '$lib/helpers/types';
33
import { type Models } from '@appwrite.io/console';
44
import type { Attributes, Columns } from '../../store';
55

6+
type RowPrimitive = string | number | bigint | boolean | null | undefined;
7+
interface RowObject {
8+
[key: string]: RowValue;
9+
}
10+
export type RowValue = RowPrimitive | RowValue[] | RowObject;
11+
612
export function isRelationshipToMany(field: Field) {
713
if (!field) return false;
814
if (!isRelationship(field)) return false;
@@ -50,3 +56,35 @@ export function isSpatialType(
5056

5157
return spatialTypes.includes(field.type.toLowerCase());
5258
}
59+
60+
function castBigIntValue(value: RowValue): RowValue {
61+
if (value === null || value === undefined || value === '') {
62+
return value;
63+
}
64+
65+
return String(value);
66+
}
67+
68+
export function buildPayload<T extends Record<string, RowValue>>(
69+
fields: Field[] | undefined,
70+
row: T
71+
): T {
72+
const payload = structuredClone(row) as Record<string, RowValue>;
73+
74+
for (const field of fields ?? []) {
75+
if (field.type !== 'bigint') {
76+
continue;
77+
}
78+
79+
const value = payload[field.key];
80+
81+
if (field.array && Array.isArray(value)) {
82+
payload[field.key] = value.map((item) => castBigIntValue(item));
83+
continue;
84+
}
85+
86+
payload[field.key] = castBigIntValue(value);
87+
}
88+
89+
return payload as T;
90+
}

src/routes/(console)/project-[region]-[project]/functions/create-function/deploy/+page.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
const promises = variables.map((variable) =>
122122
sdk.forProject(page.params.region, page.params.project).functions.createVariable({
123123
functionId: func.$id,
124+
variableId: ID.unique(),
124125
key: variable.key,
125126
value: variable.value,
126127
secret: variable.secret

src/routes/(console)/project-[region]-[project]/functions/create-function/manual/+page.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
const promises = variables.map((variable) =>
9191
sdk.forProject(page.params.region, page.params.project).functions.createVariable({
9292
functionId: func.$id,
93+
variableId: ID.unique(),
9394
key: variable.key,
9495
value: variable.value,
9596
secret: variable?.secret ?? false

src/routes/(console)/project-[region]-[project]/functions/create-function/repository-[repository]/+page.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
const promises = variables.map((variable) =>
133133
sdk.forProject(page.params.region, page.params.project).functions.createVariable({
134134
functionId: func.$id,
135+
variableId: ID.unique(),
135136
key: variable.key,
136137
value: variable.value,
137138
secret: variable?.secret ?? false

src/routes/(console)/project-[region]-[project]/functions/create-function/template-[template]/+page.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@
190190
.forProject(page.params.region, page.params.project)
191191
.functions.createVariable({
192192
functionId: func.$id,
193+
variableId: ID.unique(),
193194
key: variable.name,
194195
value: variable.value,
195196
secret: variable?.secret ?? false

src/routes/(console)/project-[region]-[project]/functions/function-[function]/domains/+page.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ export const load: PageLoad = async ({ depends, params, url, route, parent }) =>
3131
Query.orderDesc(''),
3232
Query.orderDesc('$updatedAt'),
3333
...parsedQueries.values()
34-
],
35-
search: search || undefined
34+
]
3635
});
3736

3837
const organizationDomains = await fetchOrganizationDomainsForRules(

0 commit comments

Comments
 (0)