fix: update proxy rule status handling and improve variable ID generation in function and site creation

This commit is contained in:
ArnabChatterjee20k
2026-05-07 13:02:36 +05:30
parent 33a77b4c08
commit fb0138e690
24 changed files with 34 additions and 22 deletions
-4
View File
@@ -13,10 +13,6 @@ export function isProxyRuleVerified(status: ProxyRuleStatusValue): boolean {
}
export function normalizeProxyRuleStatus(status: ProxyRuleStatusValue): ProxyRuleStatusValue {
if (status === ProxyRuleStatus.Created) {
return ProxyRuleStatus.Unverified;
}
return status;
}
@@ -43,7 +43,7 @@
try {
selectedProxyRule = await sdk
.forProject(page.params.region, page.params.project)
.proxy.updateRuleVerification({ ruleId: selectedProxyRule.$id });
.proxy.updateRuleStatus({ ruleId: selectedProxyRule.$id });
await invalidate(Dependencies.DOMAINS);
show = false;
@@ -218,8 +218,8 @@ async function updateProjectOAuth({
clientSecret: getSecret('clientSecret'),
wellKnownURL: getDetail('wellKnownURL'),
authorizationURL: getDetail('authorizationURL'),
tokenUrl: getDetail('tokenUrl'),
userInfoUrl: getDetail('userInfoUrl'),
tokenURL: getDetail('tokenUrl'),
userInfoURL: getDetail('userInfoUrl'),
enabled
});
case OAuthProvider.Okta:
@@ -15,6 +15,7 @@
import { Dependencies } from '$lib/constants';
import { tick } from 'svelte';
import { isRelationship, isRelationshipToMany, buildPayload } from './store';
import type { RowValue } from './store';
import { hash } from '$lib/helpers/string';
type CreateRow = {
@@ -70,7 +71,7 @@
function prepareRowPayload(createRowObject: CreateRow): object {
const { row, columns } = createRowObject;
const payload = structuredClone(row) as Record<string, unknown>;
const payload = structuredClone(row) as Record<string, RowValue>;
for (const column of columns) {
if (isRelationship(column) && !isRelationshipToMany(column)) {
@@ -79,7 +80,13 @@
if (value && typeof value === 'object') {
if (Array.isArray(value)) {
payload[key] = value.map((item) => item?.$id).filter(Boolean);
payload[key] = value
.map((item) =>
item && typeof item === 'object' && '$id' in item
? (item.$id as string)
: null
)
.filter(Boolean);
} else {
payload[key] = (value as { $id: string })['$id'];
}
@@ -7,7 +7,7 @@ type RowPrimitive = string | number | bigint | boolean | null | undefined;
interface RowObject {
[key: string]: RowValue;
}
type RowValue = RowPrimitive | RowValue[] | RowObject;
export type RowValue = RowPrimitive | RowValue[] | RowObject;
export function isRelationshipToMany(field: Field) {
if (!field) return false;
@@ -121,6 +121,7 @@
const promises = variables.map((variable) =>
sdk.forProject(page.params.region, page.params.project).functions.createVariable({
functionId: func.$id,
variableId: ID.unique(),
key: variable.key,
value: variable.value,
secret: variable.secret
@@ -90,6 +90,7 @@
const promises = variables.map((variable) =>
sdk.forProject(page.params.region, page.params.project).functions.createVariable({
functionId: func.$id,
variableId: ID.unique(),
key: variable.key,
value: variable.value,
secret: variable?.secret ?? false
@@ -132,6 +132,7 @@
const promises = variables.map((variable) =>
sdk.forProject(page.params.region, page.params.project).functions.createVariable({
functionId: func.$id,
variableId: ID.unique(),
key: variable.key,
value: variable.value,
secret: variable?.secret ?? false
@@ -190,6 +190,7 @@
.forProject(page.params.region, page.params.project)
.functions.createVariable({
functionId: func.$id,
variableId: ID.unique(),
key: variable.name,
value: variable.value,
secret: variable?.secret ?? false
@@ -31,8 +31,7 @@ export const load: PageLoad = async ({ depends, params, url, route, parent }) =>
Query.orderDesc(''),
Query.orderDesc('$updatedAt'),
...parsedQueries.values()
],
search: search || undefined
]
});
const organizationDomains = await fetchOrganizationDomainsForRules(
@@ -73,7 +73,7 @@
try {
proxyRule = await sdk
.forProject(page.params.region, page.params.project)
.proxy.updateRuleVerification({ ruleId });
.proxy.updateRuleStatus({ ruleId });
await Promise.all([
invalidate(Dependencies.DOMAINS),
@@ -68,7 +68,7 @@
try {
selectedProxyRule = await sdk
.forProject(page.params.region, page.params.project)
.proxy.updateRuleVerification({ ruleId: selectedProxyRule.$id });
.proxy.updateRuleStatus({ ruleId: selectedProxyRule.$id });
await invalidate(Dependencies.FUNCTION_DOMAINS);
show = false;
@@ -24,6 +24,7 @@
import UpdateVariables from '$routes/(console)/project-[region]-[project]/updateVariables.svelte';
import { page } from '$app/state';
import { Link } from '$lib/elements';
import { ID } from '@appwrite.io/console';
export let data;
let showAlert = true;
@@ -31,6 +32,7 @@
const sdkCreateVariable = async (key: string, value: string, secret?: boolean) => {
await sdk.forProject(page.params.region, page.params.project).functions.createVariable({
functionId: data.function.$id,
variableId: ID.unique(),
key,
value,
secret
@@ -25,8 +25,7 @@ export const load: PageLoad = async ({ depends, url, route, params, parent }) =>
Query.equal('type', RuleType.API),
Query.equal('trigger', RuleTrigger.MANUAL),
Query.orderDesc('$updatedAt')
],
search: search || undefined
]
});
const organizationDomains = await fetchOrganizationDomainsForRules(rules, organization.$id);
@@ -72,7 +72,7 @@
try {
proxyRule = await sdk
.forProject(page.params.region, page.params.project)
.proxy.updateRuleVerification({ ruleId });
.proxy.updateRuleStatus({ ruleId });
await invalidate(Dependencies.DOMAINS);
await goto(routeBase);
@@ -68,7 +68,7 @@
try {
selectedProxyRule = await sdk
.forProject(page.params.region, page.params.project)
.proxy.updateRuleVerification({ ruleId: selectedProxyRule.$id });
.proxy.updateRuleStatus({ ruleId: selectedProxyRule.$id });
await invalidate(Dependencies.DOMAINS);
show = false;
@@ -171,6 +171,7 @@
const promises = variables.map((variable) =>
sdk.forProject(page.params.region, page.params.project).sites.createVariable({
siteId: site.$id,
variableId: ID.unique(),
key: variable.key,
value: variable.value,
secret: variable.secret
@@ -93,6 +93,7 @@
const promises = variables.map((variable) =>
sdk.forProject(page.params.region, page.params.project).sites.createVariable({
siteId: site.$id,
variableId: ID.unique(),
key: variable.key,
value: variable.value,
secret: variable?.secret ?? false
@@ -143,6 +143,7 @@
const promises = variables.map((variable) =>
sdk.forProject(page.params.region, page.params.project).sites.createVariable({
siteId: site.$id,
variableId: ID.unique(),
key: variable.key,
value: variable.value,
secret: variable?.secret ?? false
@@ -151,6 +151,7 @@
const promises = variables.map((variable) =>
sdk.forProject(page.params.region, page.params.project).sites.createVariable({
siteId: site.$id,
variableId: ID.unique(),
key: variable.name,
value: variable.value,
secret: variable?.secret ?? false
@@ -30,8 +30,7 @@ export const load = async ({ params, depends, url, route, parent }) => {
Query.orderDesc(''),
Query.orderDesc('$updatedAt'),
...parsedQueries.values()
],
search: search || undefined
]
});
const organizationDomains = await fetchOrganizationDomainsForRules(
@@ -72,7 +72,7 @@
try {
proxyRule = await sdk
.forProject(page.params.region, page.params.project)
.proxy.updateRuleVerification({ ruleId });
.proxy.updateRuleStatus({ ruleId });
await Promise.all([
invalidate(Dependencies.DOMAINS),
@@ -68,7 +68,7 @@
try {
selectedProxyRule = await sdk
.forProject(page.params.region, page.params.project)
.proxy.updateRuleVerification({ ruleId: selectedProxyRule.$id });
.proxy.updateRuleStatus({ ruleId: selectedProxyRule.$id });
await invalidate(Dependencies.SITES_DOMAINS);
show = false;
@@ -17,12 +17,14 @@
import UpdateVariables from '$routes/(console)/project-[region]-[project]/updateVariables.svelte';
import UpdateLogging from './updateLogging.svelte';
import UpdateDeploymentRetention from './updateDeploymentRetention.svelte';
import { ID } from '@appwrite.io/console';
export let data;
const sdkCreateVariable = async (key: string, value: string, secret: boolean) => {
await sdk.forProject(page.params.region, page.params.project).sites.createVariable({
siteId: page.params.site,
variableId: ID.unique(),
key,
value,
secret