diff --git a/package.json b/package.json index 33a208bc8..41cb4e77c 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ }, "dependencies": { "@ai-sdk/svelte": "^1.1.24", - "@appwrite.io/console": "https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@8836b0c", + "@appwrite.io/console": "https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@935b30f", "@appwrite.io/pink-icons": "0.25.0", "@appwrite.io/pink-icons-svelte": "^2.0.0-RC.1", "@appwrite.io/pink-legacy": "^1.0.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 62e34ccfb..058e6c09d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,8 +12,8 @@ importers: specifier: ^1.1.24 version: 1.1.24(svelte@5.25.3)(zod@3.24.3) '@appwrite.io/console': - specifier: https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@8836b0c - version: https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@8836b0c + specifier: https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@935b30f + version: https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@935b30f '@appwrite.io/pink-icons': specifier: 0.25.0 version: 0.25.0 @@ -257,8 +257,8 @@ packages: '@analytics/type-utils@0.6.2': resolution: {integrity: sha512-TD+xbmsBLyYy/IxFimW/YL/9L2IEnM7/EoV9Aeh56U64Ify8o27HJcKjo38XY9Tcn0uOq1AX3thkKgvtWvwFQg==} - '@appwrite.io/console@https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@8836b0c': - resolution: {tarball: https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@8836b0c} + '@appwrite.io/console@https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@935b30f': + resolution: {tarball: https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@935b30f} version: 1.9.0 '@appwrite.io/pink-icons-svelte@https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@fee5c539136e15c93cd3f2398d25cb217caa8dc8': @@ -3644,7 +3644,7 @@ snapshots: '@analytics/type-utils@0.6.2': {} - '@appwrite.io/console@https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@8836b0c': {} + '@appwrite.io/console@https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@935b30f': {} '@appwrite.io/pink-icons-svelte@https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@fee5c539136e15c93cd3f2398d25cb217caa8dc8(svelte@5.25.3)': dependencies: diff --git a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/document-[document]/+page.svelte b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/document-[document]/+page.svelte index 31db52abd..7d7781727 100644 --- a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/document-[document]/+page.svelte +++ b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/document-[document]/+page.svelte @@ -11,15 +11,17 @@ import type { Models } from '@appwrite.io/console'; import { Dependencies } from '$lib/constants'; import { invalidate } from '$app/navigation'; - import { doc } from './store'; import { collection, type Attributes } from '../store'; import AttributeItem from './attributeItem.svelte'; import { isRelationship, isRelationshipToMany } from './attributes/store'; import { deepClone } from '$lib/helpers/object'; + export let data; + + const document = data.document; const databaseId = page.params.database; - const collectionId = page.params.collection; const documentId = page.params.document; + const collectionId = page.params.collection; function initWork() { const prohibitedKeys = [ @@ -31,12 +33,12 @@ '$updatedAt' ]; - const filteredKeys = Object.keys($doc).filter((key) => { + const filteredKeys = Object.keys(document).filter((key) => { return !prohibitedKeys.includes(key); }); const result = filteredKeys.reduce((obj, key) => { - obj[key] = $doc[key]; + obj[key] = document[key]; return obj; }, {}); @@ -72,42 +74,46 @@ } } - function compareAttributes( - attribute: Attributes, - $work: Models.Document, - $doc: Models.Document - ) { - if (!attribute) { + function compareAttributes(attr: Attributes, related: Models.Document, doc: Models.Document) { + if (!attr) { return false; } - const workAttribute = $work?.[attribute.key]; - const docAttribute = $doc?.[attribute.key]; + const documentAttribute = doc?.[attr.key]; + const relatedAttribute = related?.[attr.key]; - if (attribute.array) { - return !symmetricDifference(Array.from(workAttribute), Array.from(docAttribute)).length; + // undefined for a second, not sure why! + if (documentAttribute === undefined || relatedAttribute === undefined) { + return false; } - if (isRelationship(attribute)) { - if (isRelationshipToMany(attribute as Models.AttributeRelationship)) { - const workIds = workAttribute.map((doc: string | Record) => + if (attr.array) { + return !symmetricDifference(Array.from(relatedAttribute), Array.from(documentAttribute)) + .length; + } + + if (isRelationship(attr)) { + if (isRelationshipToMany(attr as Models.AttributeRelationship)) { + const workIds = relatedAttribute.map((doc: string | Record) => typeof doc === 'string' ? doc : doc.$id ); - const relatedIds = docAttribute.map((doc: string | Record) => + const relatedIds = documentAttribute.map((doc: string | Record) => typeof doc === 'string' ? doc : doc.$id ); return !symmetricDifference(workIds, relatedIds).length; } else { const workId = - typeof workAttribute === 'string' ? workAttribute : workAttribute?.$id; + typeof relatedAttribute === 'string' ? relatedAttribute : relatedAttribute?.$id; const relatedId = - typeof docAttribute === 'string' ? docAttribute : docAttribute?.$id; + typeof documentAttribute === 'string' + ? documentAttribute + : documentAttribute?.$id; return workId === relatedId; } } - return workAttribute === docAttribute; + return relatedAttribute === documentAttribute; } @@ -117,7 +123,7 @@ {#if $collection?.attributes?.length} - {#each $collection.attributes as attribute} + {#each $collection.attributes as attribute (attribute.key)} {@const label = attribute.key} {label} @@ -128,7 +134,7 @@ diff --git a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/document-[document]/attributeItem.svelte b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/document-[document]/attributeItem.svelte index 61b52948e..aba323380 100644 --- a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/document-[document]/attributeItem.svelte +++ b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/document-[document]/attributeItem.svelte @@ -61,7 +61,7 @@ {:else} - {#each [...formValues[attribute.key].keys()] as index} + {#each [...(formValues[attribute.key]?.keys() ?? [])] as index}