mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
fix: update proxy rule status handling and improve variable ID generation in function and site creation
This commit is contained in:
@@ -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:
|
||||
|
||||
+9
-2
@@ -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'];
|
||||
}
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
@@ -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
|
||||
|
||||
+1
@@ -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
|
||||
|
||||
+1
@@ -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
|
||||
|
||||
+1
@@ -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
|
||||
|
||||
+1
-2
@@ -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(
|
||||
|
||||
+1
-1
@@ -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),
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+2
@@ -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);
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+1
@@ -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
|
||||
|
||||
+1
@@ -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(
|
||||
|
||||
+1
-1
@@ -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),
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user