Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(dss|properties): inconsistent deleted at (#1202)
Will Hutchinson637d4ac20050
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/documentMetadata.ts b/js/app/packages/service-clients/service-storage/generated/schemas/documentMetadata.tsindex 1d22049149..7add1147a0 100644--- a/js/app/packages/service-clients/service-storage/generated/schemas/documentMetadata.ts+++ b/js/app/packages/service-clients/service-storage/generated/schemas/documentMetadata.ts@@ -6,6 +6,7 @@*/import type { DocumentMetadataBranchedFromId } from './documentMetadataBranchedFromId';import type { DocumentMetadataBranchedFromVersionId } from './documentMetadataBranchedFromVersionId';+import type { DocumentMetadataDeletedAt } from './documentMetadataDeletedAt';import type { DocumentMetadataDocumentBom } from './documentMetadataDocumentBom';import type { DocumentMetadataDocumentFamilyId } from './documentMetadataDocumentFamilyId';import type { DocumentMetadataFileType } from './documentMetadataFileType';@@ -23,6 +24,8 @@ the file type */branchedFromVersionId?: DocumentMetadataBranchedFromVersionId;/** The time the document was created */createdAt: number;+ /** The time the document was deleted */+ deletedAt: DocumentMetadataDeletedAt;/** If the document is a DOCX document and unzipped, the document_bom will be present */documentBom?: DocumentMetadataDocumentBom;/** The id of the document family this document belongs to */diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/documentMetadataDeletedAt.ts b/js/app/packages/service-clients/service-storage/generated/schemas/documentMetadataDeletedAt.tsnew file mode 100644index 0000000000..e04d35391d--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/documentMetadataDeletedAt.ts@@ -0,0 +1,11 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * The time the document was deleted+ */+export type DocumentMetadataDeletedAt = number | null;diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/index.ts b/js/app/packages/service-clients/service-storage/generated/schemas/index.tsindex 34d796f0fc..43b8f1d236 100644--- a/js/app/packages/service-clients/service-storage/generated/schemas/index.ts+++ b/js/app/packages/service-clients/service-storage/generated/schemas/index.ts@@ -157,6 +157,7 @@ export * from './documentFilters';export * from './documentMetadata';export * from './documentMetadataBranchedFromId';export * from './documentMetadataBranchedFromVersionId';+export * from './documentMetadataDeletedAt';export * from './documentMetadataDocumentBom';export * from './documentMetadataDocumentFamilyId';export * from './documentMetadataFileType';@@ -455,6 +456,7 @@ export * from './soupChannelAllOf';export * from './soupChannelAllOfInteractedAt';export * from './soupChannelAllOfViewedAt';export * from './soupChat';+export * from './soupChatDeletedAt';export * from './soupChatProjectId';export * from './soupChatViewedAt';export * from './soupContact';@@ -464,6 +466,7 @@ export * from './soupContactSfsPhotoUrl';export * from './soupDocument';export * from './soupDocumentBranchedFromId';export * from './soupDocumentBranchedFromVersionId';+export * from './soupDocumentDeletedAt';export * from './soupDocumentDocumentFamilyId';export * from './soupDocumentFileType';export * from './soupDocumentProjectId';@@ -502,6 +505,7 @@ export * from './soupMessageListVisibility';export * from './soupPage';export * from './soupPageNextCursor';export * from './soupProject';+export * from './soupProjectDeletedAt';export * from './soupProjectParentId';export * from './soupProjectViewedAt';export * from './soupProperty';diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupChat.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupChat.tsindex 4f95a431d9..fa86a10a5b 100644--- a/js/app/packages/service-clients/service-storage/generated/schemas/soupChat.ts+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupChat.ts@@ -4,6 +4,7 @@* document_storage_service* OpenAPI spec version: 0.1.0*/+import type { SoupChatDeletedAt } from './soupChatDeletedAt';import type { SoupChatProjectId } from './soupChatProjectId';import type { SoupChatViewedAt } from './soupChatViewedAt';import type { SoupProperty } from './soupProperty';@@ -11,6 +12,8 @@ import type { SoupProperty } from './soupProperty';export interface SoupChat {/** The time the chat was created */createdAt: number;+ /** The time the chat was deleted */+ deletedAt: SoupChatDeletedAt;/** The chat uuid */id: string;/** Whether the chat is persistent or not */diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupChatDeletedAt.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupChatDeletedAt.tsnew file mode 100644index 0000000000..82adbaaab8--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupChatDeletedAt.ts@@ -0,0 +1,11 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * The time the chat was deleted+ */+export type SoupChatDeletedAt = number | null;diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupDocument.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupDocument.tsindex 846a5de150..cbc4f00fdc 100644--- a/js/app/packages/service-clients/service-storage/generated/schemas/soupDocument.ts+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupDocument.ts@@ -6,6 +6,7 @@*/import type { SoupDocumentBranchedFromId } from './soupDocumentBranchedFromId';import type { SoupDocumentBranchedFromVersionId } from './soupDocumentBranchedFromVersionId';+import type { SoupDocumentDeletedAt } from './soupDocumentDeletedAt';import type { SoupDocumentDocumentFamilyId } from './soupDocumentDocumentFamilyId';import type { SoupDocumentFileType } from './soupDocumentFileType';import type { SoupDocumentProjectId } from './soupDocumentProjectId';@@ -22,6 +23,8 @@ This could be either DocumentInstance or DocumentBom id depending on the file tybranchedFromVersionId?: SoupDocumentBranchedFromVersionId;/** The time the document was created */createdAt: number;+ /** The time the document was deleted */+ deletedAt: SoupDocumentDeletedAt;/** The id of the document family this document belongs to */documentFamilyId?: SoupDocumentDocumentFamilyId;/** The version of the documentdiff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupDocumentDeletedAt.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupDocumentDeletedAt.tsnew file mode 100644index 0000000000..8186255de9--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupDocumentDeletedAt.ts@@ -0,0 +1,11 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * The time the document was deleted+ */+export type SoupDocumentDeletedAt = number | null;diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupProject.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupProject.tsindex 775d762895..32fc937718 100644--- a/js/app/packages/service-clients/service-storage/generated/schemas/soupProject.ts+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupProject.ts@@ -4,6 +4,7 @@* document_storage_service* OpenAPI spec version: 0.1.0*/+import type { SoupProjectDeletedAt } from './soupProjectDeletedAt';import type { SoupProjectParentId } from './soupProjectParentId';import type { SoupProjectViewedAt } from './soupProjectViewedAt';import type { SoupProperty } from './soupProperty';@@ -11,6 +12,8 @@ import type { SoupProperty } from './soupProperty';export interface SoupProject {/** The time the project was created */createdAt: number;+ /** The time the project was deleted */+ deletedAt: SoupProjectDeletedAt;/** The id of the project */id: string;/** The name of the project */diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupProjectDeletedAt.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupProjectDeletedAt.tsnew file mode 100644index 0000000000..6dba3f16cf--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupProjectDeletedAt.ts@@ -0,0 +1,11 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * The time the project was deleted+ */+export type SoupProjectDeletedAt = number | null;diff --git a/js/app/packages/service-clients/service-storage/generated/zod.ts b/js/app/packages/service-clients/service-storage/generated/zod.tsindex f33218e772..54b741e025 100644--- a/js/app/packages/service-clients/service-storage/generated/zod.ts+++ b/js/app/packages/service-clients/service-storage/generated/zod.ts@@ -833,6 +833,10 @@ export const getUserDocumentsHandlerResponse = zod.object({createdAt: zod.number().describe('The time the document was created'),+ deletedAt: zod+ .number()+ .nullable()+ .describe('The time the document was deleted'),documentBom: zod.array(zod.object({@@ -1448,6 +1452,10 @@ export const getDocumentResponse = zod.object({'The id of the version this document branched from\nThis could be either DocumentInstance or DocumentBom id depending on\nthe file type'),createdAt: zod.number().describe('The time the document was created'),+ deletedAt: zod+ .number()+ .nullable()+ .describe('The time the document was deleted'),documentBom: zod.array(zod.object({@@ -1712,6 +1720,10 @@ export const copyDocumentHandlerResponse = zod.object({'The id of the version this document branched from\nThis could be either DocumentInstance or DocumentBom id depending on\nthe file type'),createdAt: zod.number().describe('The time the document was created'),+ deletedAt: zod+ .number()+ .nullable()+ .describe('The time the document was deleted'),documentBom: zod.array(zod.object({@@ -2043,6 +2055,10 @@ export const getDocumentVersionResponse = zod.object({'The id of the version this document branched from\nThis could be either DocumentInstance or DocumentBom id depending on\nthe file type'),createdAt: zod.number().describe('The time the document was created'),+ deletedAt: zod+ .number()+ .nullable()+ .describe('The time the document was deleted'),documentBom: zod.array(zod.object({@@ -2334,6 +2350,10 @@ export const getItemsSoupResponse = zod.object({createdAt: zod.number().describe('The time the document was created'),+ deletedAt: zod+ .number()+ .nullable()+ .describe('The time the document was deleted'),documentFamilyId: zod.number().nullish()@@ -2617,6 +2637,10 @@ export const getItemsSoupResponse = zod.object({zod.object({data: zod.object({createdAt: zod.number().describe('The time the chat was created'),+ deletedAt: zod+ .number()+ .nullable()+ .describe('The time the chat was deleted'),id: zod.string().uuid().describe('The chat uuid'),isPersistent: zod.boolean()@@ -2864,6 +2888,10 @@ export const getItemsSoupResponse = zod.object({createdAt: zod.number().describe('The time the project was created'),+ deletedAt: zod+ .number()+ .nullable()+ .describe('The time the project was deleted'),id: zod.string().uuid().describe('The id of the project'),name: zod.string().describe('The name of the project'),ownerId: zod@@ -3711,6 +3739,10 @@ export const postItemsSoupResponse = zod.object({createdAt: zod.number().describe('The time the document was created'),+ deletedAt: zod+ .number()+ .nullable()+ .describe('The time the document was deleted'),documentFamilyId: zod.number().nullish()@@ -3994,6 +4026,10 @@ export const postItemsSoupResponse = zod.object({zod.object({data: zod.object({createdAt: zod.number().describe('The time the chat was created'),+ deletedAt: zod+ .number()+ .nullable()+ .describe('The time the chat was deleted'),id: zod.string().uuid().describe('The chat uuid'),isPersistent: zod.boolean()@@ -4241,6 +4277,10 @@ export const postItemsSoupResponse = zod.object({createdAt: zod.number().describe('The time the project was created'),+ deletedAt: zod+ .number()+ .nullable()+ .describe('The time the project was deleted'),id: zod.string().uuid().describe('The id of the project'),name: zod.string().describe('The name of the project'),ownerId: zoddiff --git a/js/app/packages/service-clients/service-storage/openapi.json b/js/app/packages/service-clients/service-storage/openapi.jsonindex 865f48786e..4f86b4c37e 100644--- a/js/app/packages/service-clients/service-storage/openapi.json+++ b/js/app/packages/service-clients/service-storage/openapi.json@@ -5469,7 +5469,8 @@"owner","documentName","createdAt",- "updatedAt"+ "updatedAt",+ "deletedAt"],"properties": {"branchedFromId": {@@ -5486,6 +5487,11 @@"format": "int64","description": "The time the document was created"},+ "deletedAt": {+ "type": ["integer", "null"],+ "format": "int64",+ "description": "The time the document was deleted"+ },"documentBom": {"type": ["array", "null"],"items": {@@ -8312,6 +8318,7 @@"createdAt","updatedAt","viewedAt",+ "deletedAt","properties"],"properties": {@@ -8320,6 +8327,11 @@"format": "int64","description": "The time the chat was created"},+ "deletedAt": {+ "type": ["integer", "null"],+ "format": "int64",+ "description": "The time the chat was deleted"+ },"id": {"type": "string","format": "uuid",@@ -8394,6 +8406,7 @@"createdAt","updatedAt","viewedAt",+ "deletedAt","properties"],"properties": {@@ -8412,6 +8425,11 @@"format": "int64","description": "The time the document was created"},+ "deletedAt": {+ "type": ["integer", "null"],+ "format": "int64",+ "description": "The time the document was deleted"+ },"documentFamilyId": {"type": ["integer", "null"],"format": "int64",@@ -8788,6 +8806,7 @@"createdAt","updatedAt","viewedAt",+ "deletedAt","properties"],"properties": {@@ -8796,6 +8815,11 @@"format": "int64","description": "The time the project was created"},+ "deletedAt": {+ "type": ["integer", "null"],+ "format": "int64",+ "description": "The time the project was deleted"+ },"id": {"type": "string","format": "uuid",diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-0c36658e4c00abbd672fd1fa7934cb81f5065482c471fffa2bf248f73782a87c.json b/rust/cloud-storage/macro_db_client/.sqlx/query-0c36658e4c00abbd672fd1fa7934cb81f5065482c471fffa2bf248f73782a87c.jsonnew file mode 100644index 0000000000..75d11599e7--- /dev/null+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-0c36658e4c00abbd672fd1fa7934cb81f5065482c471fffa2bf248f73782a87c.json@@ -0,0 +1,28 @@+{+ "db_name": "PostgreSQL",+ "query": "SELECT \"userId\" as user_id, \"deletedAt\" as deleted_at FROM \"Chat\" WHERE id=$1",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "user_id",+ "type_info": "Text"+ },+ {+ "ordinal": 1,+ "name": "deleted_at",+ "type_info": "Timestamp"+ }+ ],+ "parameters": {+ "Left": [+ "Text"+ ]+ },+ "nullable": [+ false,+ true+ ]+ },+ "hash": "0c36658e4c00abbd672fd1fa7934cb81f5065482c471fffa2bf248f73782a87c"+}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-1435acbba365796ddcb6ddbef86f4ebf664cffc44082996f6b60a60373c28f75.json b/rust/cloud-storage/macro_db_client/.sqlx/query-1435acbba365796ddcb6ddbef86f4ebf664cffc44082996f6b60a60373c28f75.jsondeleted file mode 100644index d2b084cf10..0000000000--- a/rust/cloud-storage/macro_db_client/.sqlx/query-1435acbba365796ddcb6ddbef86f4ebf664cffc44082996f6b60a60373c28f75.json+++ /dev/null@@ -1,17 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n INSERT INTO entity_properties (id, entity_id, entity_type, property_definition_id, values)\n SELECT \n u.id,\n u.entity_id,\n 'TASK'::property_entity_type,\n u.property_definition_id,\n u.values\n FROM UNNEST(\n $1::UUID[],\n $2::TEXT[],\n $3::UUID[],\n $4::JSONB[]\n ) AS u(id, entity_id, property_definition_id, values)\n ON CONFLICT (entity_id, entity_type, property_definition_id)\n DO UPDATE SET \n values = EXCLUDED.values,\n updated_at = NOW()\n ",- "describe": {- "columns": [],- "parameters": {- "Left": [- "UuidArray",- "TextArray",- "UuidArray",- "JsonbArray"- ]- },- "nullable": []- },- "hash": "1435acbba365796ddcb6ddbef86f4ebf664cffc44082996f6b60a60373c28f75"-}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-63492b018803ce26db5891964a0f52f37d2f54bd8243265c6561f4423af8617c.json b/rust/cloud-storage/macro_db_client/.sqlx/query-63492b018803ce26db5891964a0f52f37d2f54bd8243265c6561f4423af8617c.jsondeleted file mode 100644index 6d97183829..0000000000--- a/rust/cloud-storage/macro_db_client/.sqlx/query-63492b018803ce26db5891964a0f52f37d2f54bd8243265c6561f4423af8617c.json+++ /dev/null@@ -1,16 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n INSERT INTO entity_properties (id, entity_id, entity_type, property_definition_id, values)\n SELECT \n u.id,\n u.entity_id,\n 'TASK'::property_entity_type,\n u.property_definition_id,\n NULL\n FROM UNNEST(\n $1::UUID[],\n $2::TEXT[],\n $3::UUID[]\n ) AS u(id, entity_id, property_definition_id)\n ON CONFLICT (entity_id, entity_type, property_definition_id)\n DO NOTHING\n ",- "describe": {- "columns": [],- "parameters": {- "Left": [- "UuidArray",- "TextArray",- "UuidArray"- ]- },- "nullable": []- },- "hash": "63492b018803ce26db5891964a0f52f37d2f54bd8243265c6561f4423af8617c"-}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-80d20d5b664dbbb320a52bf47f134534f93906716e415c54b6e3b30834973bc7.json b/rust/cloud-storage/macro_db_client/.sqlx/query-80d20d5b664dbbb320a52bf47f134534f93906716e415c54b6e3b30834973bc7.jsonnew file mode 100644index 0000000000..8d3011486c--- /dev/null+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-80d20d5b664dbbb320a52bf47f134534f93906716e415c54b6e3b30834973bc7.json@@ -0,0 +1,28 @@+{+ "db_name": "PostgreSQL",+ "query": "SELECT owner, \"deletedAt\" as deleted_at FROM \"Document\" WHERE id=$1",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "owner",+ "type_info": "Text"+ },+ {+ "ordinal": 1,+ "name": "deleted_at",+ "type_info": "Timestamp"+ }+ ],+ "parameters": {+ "Left": [+ "Text"+ ]+ },+ "nullable": [+ false,+ true+ ]+ },+ "hash": "80d20d5b664dbbb320a52bf47f134534f93906716e415c54b6e3b30834973bc7"+}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-915c50350c5513c6e1ba12eae31520046ac0e7e882d9c5ec76a3578ae4bc7d50.json b/rust/cloud-storage/macro_db_client/.sqlx/query-915c50350c5513c6e1ba12eae31520046ac0e7e882d9c5ec76a3578ae4bc7d50.jsonnew file mode 100644index 0000000000..0a2c18aa63--- /dev/null+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-915c50350c5513c6e1ba12eae31520046ac0e7e882d9c5ec76a3578ae4bc7d50.json@@ -0,0 +1,28 @@+{+ "db_name": "PostgreSQL",+ "query": "SELECT \"userId\" as user_id, \"deletedAt\" as deleted_at FROM \"Project\" WHERE id=$1",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "user_id",+ "type_info": "Text"+ },+ {+ "ordinal": 1,+ "name": "deleted_at",+ "type_info": "Timestamp"+ }+ ],+ "parameters": {+ "Left": [+ "Text"+ ]+ },+ "nullable": [+ false,+ true+ ]+ },+ "hash": "915c50350c5513c6e1ba12eae31520046ac0e7e882d9c5ec76a3578ae4bc7d50"+}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-9cd40fbb1ade51e9e0d49792839d1a363cada017252a6f653c2272608189bcc4.json b/rust/cloud-storage/macro_db_client/.sqlx/query-9cd40fbb1ade51e9e0d49792839d1a363cada017252a6f653c2272608189bcc4.jsondeleted file mode 100644index 9d717fa5f9..0000000000--- a/rust/cloud-storage/macro_db_client/.sqlx/query-9cd40fbb1ade51e9e0d49792839d1a363cada017252a6f653c2272608189bcc4.json+++ /dev/null@@ -1,28 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT property_definition_id, values\n FROM entity_properties\n WHERE entity_id = $1\n AND entity_type = 'TASK'\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "property_definition_id",- "type_info": "Uuid"- },- {- "ordinal": 1,- "name": "values",- "type_info": "Jsonb"- }- ],- "parameters": {- "Left": [- "Text"- ]- },- "nullable": [- false,- true- ]- },- "hash": "9cd40fbb1ade51e9e0d49792839d1a363cada017252a6f653c2272608189bcc4"-}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-602ab8cc5ef7a8f1756eddb3ba04498975d1bf2b14483da52fed14c2e6a9c92f.json b/rust/cloud-storage/macro_db_client/.sqlx/query-c9fce1ac31e4e4f9992809c650e85fe45f4dc1e66d4b5a846c734b308c74fa70.jsonsimilarity index 58%rename from rust/cloud-storage/macro_db_client/.sqlx/query-602ab8cc5ef7a8f1756eddb3ba04498975d1bf2b14483da52fed14c2e6a9c92f.jsonrename to rust/cloud-storage/macro_db_client/.sqlx/query-c9fce1ac31e4e4f9992809c650e85fe45f4dc1e66d4b5a846c734b308c74fa70.jsonindex 67345361bb..4c2fb23429 100644--- a/rust/cloud-storage/macro_db_client/.sqlx/query-602ab8cc5ef7a8f1756eddb3ba04498975d1bf2b14483da52fed14c2e6a9c92f.json+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-c9fce1ac31e4e4f9992809c650e85fe45f4dc1e66d4b5a846c734b308c74fa70.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n SELECT\n d.id as \"document_id\",\n d.owner as \"owner\",\n d.name as \"document_name\",\n COALESCE(di.id, db.id) as \"document_version_id!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"createdAt\"::timestamptz as \"created_at\",\n d.\"updatedAt\"::timestamptz as \"updated_at\",\n d.\"fileType\" as \"file_type\",\n db.bom_parts as \"document_bom?\",\n di.modification_data as \"modification_data?\",\n d.\"projectId\" as \"project_id?\",\n p.name as \"project_name?\",\n di.sha as \"sha?\",\n dt.sub_type as \"sub_type?: DocumentSubType\"\n FROM\n \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN LATERAL (\n SELECT\n i.id,\n i.sha,\n i.\"createdAt\",\n (\n SELECT\n imod.\"modificationData\"\n FROM\n \"DocumentInstanceModificationData\" imod\n WHERE\n imod.\"documentInstanceId\" = i.id\n ) as modification_data,\n i.\"updatedAt\"\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n AND\n i.id = $2\n ) di ON true\n LEFT JOIN LATERAL (\n SELECT\n b.id,\n (\n SELECT\n json_agg(\n json_build_object(\n 'id', bp.id,\n 'sha', bp.sha,\n 'path', bp.path\n )\n )\n FROM\n \"BomPart\" bp\n WHERE\n bp.\"documentBomId\" = b.id\n ) as bom_parts\n FROM\n \"DocumentBom\" b\n WHERE\n b.\"documentId\" = d.id\n AND\n b.id = $2\n ) db ON d.\"fileType\" = 'docx'\n LEFT JOIN LATERAL (\n SELECT\n p.name\n FROM \"Project\" p\n WHERE p.id = d.\"projectId\"\n ) p ON d.\"projectId\" IS NOT NULL\n WHERE\n d.id = $1\n LIMIT 1\n ",+ "query": "\n SELECT\n d.id as \"document_id\",\n d.owner as \"owner\",\n d.name as \"document_name\",\n COALESCE(di.id, db.id) as \"document_version_id!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"createdAt\"::timestamptz as \"created_at\",\n d.\"updatedAt\"::timestamptz as \"updated_at\",\n d.\"fileType\" as \"file_type\",\n db.bom_parts as \"document_bom?\",\n di.modification_data as \"modification_data?\",\n d.\"projectId\" as \"project_id?\",\n p.name as \"project_name?\",\n di.sha as \"sha?\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n d.\"deletedAt\"::timestamptz as deleted_at\n FROM\n \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN LATERAL (\n SELECT\n i.id,\n i.sha,\n i.\"createdAt\",\n (\n SELECT\n imod.\"modificationData\"\n FROM\n \"DocumentInstanceModificationData\" imod\n WHERE\n imod.\"documentInstanceId\" = i.id\n ) as modification_data,\n i.\"updatedAt\"\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n AND\n i.id = $2\n ) di ON true\n LEFT JOIN LATERAL (\n SELECT\n b.id,\n (\n SELECT\n json_agg(\n json_build_object(\n 'id', bp.id,\n 'sha', bp.sha,\n 'path', bp.path\n )\n )\n FROM\n \"BomPart\" bp\n WHERE\n bp.\"documentBomId\" = b.id\n ) as bom_parts\n FROM\n \"DocumentBom\" b\n WHERE\n b.\"documentId\" = d.id\n AND\n b.id = $2\n ) db ON d.\"fileType\" = 'docx'\n LEFT JOIN LATERAL (\n SELECT\n p.name\n FROM \"Project\" p\n WHERE p.id = d.\"projectId\"\n ) p ON d.\"projectId\" IS NOT NULL\n WHERE\n d.id = $1\n LIMIT 1\n ","describe": {"columns": [{@@ -91,6 +91,11 @@}}}+ },+ {+ "ordinal": 16,+ "name": "deleted_at",+ "type_info": "Timestamptz"}],"parameters": {@@ -115,8 +120,9 @@true,false,false,- false+ false,+ null]},- "hash": "602ab8cc5ef7a8f1756eddb3ba04498975d1bf2b14483da52fed14c2e6a9c92f"+ "hash": "c9fce1ac31e4e4f9992809c650e85fe45f4dc1e66d4b5a846c734b308c74fa70"}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-c4d8423378131db13674490b01c0d704ba162e0b774d06525c3fbe79a4a08b23.json b/rust/cloud-storage/macro_db_client/.sqlx/query-cc55e105bd5f6916a779d57ed7e4379c7fdaca83a33355842cf8b0b29d25a517.jsonsimilarity index 57%rename from rust/cloud-storage/macro_db_client/.sqlx/query-c4d8423378131db13674490b01c0d704ba162e0b774d06525c3fbe79a4a08b23.jsonrename to rust/cloud-storage/macro_db_client/.sqlx/query-cc55e105bd5f6916a779d57ed7e4379c7fdaca83a33355842cf8b0b29d25a517.jsonindex 5ced6a7a31..6c7c3948d2 100644--- a/rust/cloud-storage/macro_db_client/.sqlx/query-c4d8423378131db13674490b01c0d704ba162e0b774d06525c3fbe79a4a08b23.json+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-cc55e105bd5f6916a779d57ed7e4379c7fdaca83a33355842cf8b0b29d25a517.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n SELECT\n d.id as \"document_id\",\n d.owner as \"owner\",\n COALESCE(db.id, di.id) as \"document_version_id!\",\n d.name as \"document_name\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"createdAt\"::timestamptz as \"created_at\",\n d.\"updatedAt\"::timestamptz as \"updated_at\",\n d.\"fileType\" as \"file_type\",\n db.bom_parts as \"document_bom?\",\n di.modification_data as \"modification_data?\",\n d.\"projectId\" as \"project_id\",\n p.name as \"project_name?\",\n di.sha as \"sha?\",\n dt.sub_type as \"sub_type?: DocumentSubType\"\n FROM\n \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN LATERAL (\n SELECT\n i.id,\n i.sha,\n i.\"createdAt\",\n (\n SELECT\n imod.\"modificationData\"\n FROM\n \"DocumentInstanceModificationData\" imod\n WHERE\n imod.\"documentInstanceId\" = i.id\n ) as modification_data,\n i.\"updatedAt\"\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n ORDER BY\n i.\"createdAt\" DESC\n LIMIT 1\n ) di ON true\n LEFT JOIN LATERAL (\n SELECT\n b.id,\n (\n SELECT\n json_agg(\n json_build_object(\n 'id', bp.id,\n 'sha', bp.sha,\n 'path', bp.path\n )\n )\n FROM\n \"BomPart\" bp\n WHERE\n bp.\"documentBomId\" = b.id\n ) as bom_parts\n FROM\n \"DocumentBom\" b\n WHERE\n b.\"documentId\" = d.id\n ORDER BY\n b.\"createdAt\" DESC\n LIMIT 1\n ) db ON d.\"fileType\" = 'docx'\n LEFT JOIN LATERAL (\n SELECT\n p.name\n FROM \"Project\" p\n WHERE p.id = d.\"projectId\"\n ) p ON d.\"projectId\" IS NOT NULL\n WHERE\n d.id = $1\n LIMIT 1\n ",+ "query": "\n SELECT\n d.id as \"document_id\",\n d.owner as \"owner\",\n COALESCE(db.id, di.id) as \"document_version_id!\",\n d.name as \"document_name\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"createdAt\"::timestamptz as \"created_at\",\n d.\"updatedAt\"::timestamptz as \"updated_at\",\n d.\"fileType\" as \"file_type\",\n db.bom_parts as \"document_bom?\",\n di.modification_data as \"modification_data?\",\n d.\"projectId\" as \"project_id\",\n p.name as \"project_name?\",\n di.sha as \"sha?\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n d.\"deletedAt\"::timestamptz as \"deleted_at\"\n FROM\n \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN LATERAL (\n SELECT\n i.id,\n i.sha,\n i.\"createdAt\",\n (\n SELECT\n imod.\"modificationData\"\n FROM\n \"DocumentInstanceModificationData\" imod\n WHERE\n imod.\"documentInstanceId\" = i.id\n ) as modification_data,\n i.\"updatedAt\"\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n ORDER BY\n i.\"createdAt\" DESC\n LIMIT 1\n ) di ON true\n LEFT JOIN LATERAL (\n SELECT\n b.id,\n (\n SELECT\n json_agg(\n json_build_object(\n 'id', bp.id,\n 'sha', bp.sha,\n 'path', bp.path\n )\n )\n FROM\n \"BomPart\" bp\n WHERE\n bp.\"documentBomId\" = b.id\n ) as bom_parts\n FROM\n \"DocumentBom\" b\n WHERE\n b.\"documentId\" = d.id\n ORDER BY\n b.\"createdAt\" DESC\n LIMIT 1\n ) db ON d.\"fileType\" = 'docx'\n LEFT JOIN LATERAL (\n SELECT\n p.name\n FROM \"Project\" p\n WHERE p.id = d.\"projectId\"\n ) p ON d.\"projectId\" IS NOT NULL\n WHERE\n d.id = $1\n LIMIT 1\n ","describe": {"columns": [{@@ -91,6 +91,11 @@}}}+ },+ {+ "ordinal": 16,+ "name": "deleted_at",+ "type_info": "Timestamptz"}],"parameters": {@@ -114,8 +119,9 @@true,false,false,- false+ false,+ null]},- "hash": "c4d8423378131db13674490b01c0d704ba162e0b774d06525c3fbe79a4a08b23"+ "hash": "cc55e105bd5f6916a779d57ed7e4379c7fdaca83a33355842cf8b0b29d25a517"}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-f2d5d7aea9918978cd69c14f8afe24156c2fa387e001ee8eaf57e4a70a106069.json b/rust/cloud-storage/macro_db_client/.sqlx/query-f2d5d7aea9918978cd69c14f8afe24156c2fa387e001ee8eaf57e4a70a106069.jsondeleted file mode 100644index 182e0858ba..0000000000--- a/rust/cloud-storage/macro_db_client/.sqlx/query-f2d5d7aea9918978cd69c14f8afe24156c2fa387e001ee8eaf57e4a70a106069.json+++ /dev/null@@ -1,18 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n INSERT INTO entity_properties (id, entity_id, entity_type, property_definition_id, values)\n SELECT \n u.id,\n u.entity_id,\n u.entity_type::property_entity_type,\n u.property_definition_id,\n u.values\n FROM UNNEST(\n $1::UUID[],\n $2::TEXT[],\n $3::TEXT[],\n $4::UUID[],\n $5::JSONB[]\n ) AS u(id, entity_id, entity_type, property_definition_id, values)\n ON CONFLICT (entity_id, entity_type, property_definition_id)\n DO UPDATE SET \n values = EXCLUDED.values,\n updated_at = NOW()\n ",- "describe": {- "columns": [],- "parameters": {- "Left": [- "UuidArray",- "TextArray",- "TextArray",- "UuidArray",- "JsonbArray"- ]- },- "nullable": []- },- "hash": "f2d5d7aea9918978cd69c14f8afe24156c2fa387e001ee8eaf57e4a70a106069"-}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-50189a384178de7dfcede64e3a89976d6dd8fd2560196fb22630be9d1d095428.json b/rust/cloud-storage/macro_db_client/.sqlx/query-fcd4b67db8a3a8de51b0bb55880c5934f900adbadcc5549165e709cb1cd345b5.jsonsimilarity index 52%rename from rust/cloud-storage/macro_db_client/.sqlx/query-50189a384178de7dfcede64e3a89976d6dd8fd2560196fb22630be9d1d095428.jsonrename to rust/cloud-storage/macro_db_client/.sqlx/query-fcd4b67db8a3a8de51b0bb55880c5934f900adbadcc5549165e709cb1cd345b5.jsonindex 8c9ffd0c3d..51893d429f 100644--- a/rust/cloud-storage/macro_db_client/.sqlx/query-50189a384178de7dfcede64e3a89976d6dd8fd2560196fb22630be9d1d095428.json+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-fcd4b67db8a3a8de51b0bb55880c5934f900adbadcc5549165e709cb1cd345b5.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n SELECT\n d.id as document_id,\n d.owner as owner,\n d.name as document_name,\n COALESCE(db.id, di.id) as \"document_version_id!\",\n d.\"branchedFromId\" as \"branched_from_id?\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id?\",\n d.\"documentFamilyId\" as \"document_family_id?\",\n d.\"fileType\" as file_type,\n d.\"createdAt\"::timestamptz as created_at,\n d.\"updatedAt\"::timestamptz as updated_at,\n db.bom_parts as \"document_bom?\",\n di.modification_data as \"modification_data?\",\n d.\"projectId\" as \"project_id?\",\n p.name as \"project_name?\",\n di.sha as \"sha?\",\n dt.sub_type as \"sub_type?: DocumentSubType\"\n FROM\n \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN LATERAL (\n SELECT\n b.id,\n (\n SELECT\n json_agg(\n json_build_object(\n 'id', bp.id,\n 'sha', bp.sha,\n 'path', bp.path\n )\n )\n FROM\n \"BomPart\" bp\n WHERE\n bp.\"documentBomId\" = b.id\n ) as bom_parts\n FROM\n \"DocumentBom\" b\n WHERE\n b.\"documentId\" = d.id\n ORDER BY\n b.\"createdAt\" DESC\n LIMIT 1\n ) db ON d.\"fileType\" = 'docx'\n LEFT JOIN LATERAL (\n SELECT\n i.id,\n i.\"documentId\",\n i.\"sha\",\n i.\"createdAt\",\n (\n SELECT\n imod.\"modificationData\"\n FROM\n \"DocumentInstanceModificationData\" imod\n WHERE\n imod.\"documentInstanceId\" = i.id\n ) as modification_data,\n i.\"updatedAt\"\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n ORDER BY\n i.\"updatedAt\" DESC\n LIMIT 1\n ) di ON d.\"fileType\" IS DISTINCT FROM 'docx'\n LEFT JOIN \"Project\" p ON p.id = d.\"projectId\"\n WHERE\n d.\"deletedAt\" IS NULL\n ORDER BY d.\"createdAt\" DESC\n LIMIT $1 OFFSET $2\n\n ",+ "query": "\n SELECT\n d.id as document_id,\n d.owner as owner,\n d.name as document_name,\n COALESCE(db.id, di.id) as \"document_version_id!\",\n d.\"branchedFromId\" as \"branched_from_id?\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id?\",\n d.\"documentFamilyId\" as \"document_family_id?\",\n d.\"fileType\" as file_type,\n d.\"createdAt\"::timestamptz as created_at,\n d.\"updatedAt\"::timestamptz as updated_at,\n d.\"deletedAt\"::timestamptz as deleted_at,\n db.bom_parts as \"document_bom?\",\n di.modification_data as \"modification_data?\",\n d.\"projectId\" as \"project_id?\",\n p.name as \"project_name?\",\n di.sha as \"sha?\",\n dt.sub_type as \"sub_type?: DocumentSubType\"\n FROM\n \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN LATERAL (\n SELECT\n b.id,\n (\n SELECT\n json_agg(\n json_build_object(\n 'id', bp.id,\n 'sha', bp.sha,\n 'path', bp.path\n )\n )\n FROM\n \"BomPart\" bp\n WHERE\n bp.\"documentBomId\" = b.id\n ) as bom_parts\n FROM\n \"DocumentBom\" b\n WHERE\n b.\"documentId\" = d.id\n ORDER BY\n b.\"createdAt\" DESC\n LIMIT 1\n ) db ON d.\"fileType\" = 'docx'\n LEFT JOIN LATERAL (\n SELECT\n i.id,\n i.\"documentId\",\n i.\"sha\",\n i.\"createdAt\",\n (\n SELECT\n imod.\"modificationData\"\n FROM\n \"DocumentInstanceModificationData\" imod\n WHERE\n imod.\"documentInstanceId\" = i.id\n ) as modification_data,\n i.\"updatedAt\"\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n ORDER BY\n i.\"updatedAt\" DESC\n LIMIT 1\n ) di ON d.\"fileType\" IS DISTINCT FROM 'docx'\n LEFT JOIN \"Project\" p ON p.id = d.\"projectId\"\n WHERE\n d.\"deletedAt\" IS NULL\n ORDER BY d.\"createdAt\" DESC\n LIMIT $1 OFFSET $2\n\n ","describe": {"columns": [{@@ -55,31 +55,36 @@},{"ordinal": 10,+ "name": "deleted_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 11,"name": "document_bom?","type_info": "Json"},{- "ordinal": 11,+ "ordinal": 12,"name": "modification_data?","type_info": "Jsonb"},{- "ordinal": 12,+ "ordinal": 13,"name": "project_id?","type_info": "Text"},{- "ordinal": 13,+ "ordinal": 14,"name": "project_name?","type_info": "Text"},{- "ordinal": 14,+ "ordinal": 15,"name": "sha?","type_info": "Text"},{- "ordinal": 15,+ "ordinal": 16,"name": "sub_type?: DocumentSubType","type_info": {"Custom": {@@ -112,11 +117,12 @@null,null,null,+ null,true,false,false,false]},- "hash": "50189a384178de7dfcede64e3a89976d6dd8fd2560196fb22630be9d1d095428"+ "hash": "fcd4b67db8a3a8de51b0bb55880c5934f900adbadcc5549165e709cb1cd345b5"}diff --git a/rust/cloud-storage/macro_db_client/src/convert/mod.rs b/rust/cloud-storage/macro_db_client/src/convert/mod.rsindex 0fec30dec8..ef41240b92 100644--- a/rust/cloud-storage/macro_db_client/src/convert/mod.rs+++ b/rust/cloud-storage/macro_db_client/src/convert/mod.rs@@ -97,6 +97,7 @@ pub async fn get_docx_files(document_family_id: None,modification_data: None,sub_type: None,+ deleted_at: None,})}).fetch_all(db)diff --git a/rust/cloud-storage/macro_db_client/src/document/copy_document/mod.rs b/rust/cloud-storage/macro_db_client/src/document/copy_document/mod.rsindex 072f979465..0adcb7e089 100644--- a/rust/cloud-storage/macro_db_client/src/document/copy_document/mod.rs+++ b/rust/cloud-storage/macro_db_client/src/document/copy_document/mod.rs@@ -145,6 +145,7 @@ pub(in crate::document) async fn copy_docx_document(created_at: document.created_at,updated_at: document.updated_at,sub_type: None,+ deleted_at: None,})}@@ -266,13 +267,13 @@ pub(in crate::document) async fn copy_non_docx_document(created_at: document.created_at,updated_at: document.updated_at,sub_type: original_document.sub_type,+ deleted_at: None,})}#[cfg(test)]mod tests {use super::*;- use models_permissions::share_permission::access_level::AccessLevel;use sqlx::{Pool, Postgres};#[sqlx::test(fixtures(path = "../../../fixtures", scripts("basic_user_with_documents")))]diff --git a/rust/cloud-storage/macro_db_client/src/document/create_blank_docx.rs b/rust/cloud-storage/macro_db_client/src/document/create_blank_docx.rsindex 432fe8194b..ebc8d61c88 100644--- a/rust/cloud-storage/macro_db_client/src/document/create_blank_docx.rs+++ b/rust/cloud-storage/macro_db_client/src/document/create_blank_docx.rs@@ -159,6 +159,7 @@ pub async fn create_blank_docx(created_at: document_version.created_at,updated_at: document_version.updated_at,sub_type: None,+ deleted_at: None,})}diff --git a/rust/cloud-storage/macro_db_client/src/document/get_all_documents.rs b/rust/cloud-storage/macro_db_client/src/document/get_all_documents.rsindex a18bbddc2c..12a70c953a 100644--- a/rust/cloud-storage/macro_db_client/src/document/get_all_documents.rs+++ b/rust/cloud-storage/macro_db_client/src/document/get_all_documents.rs@@ -38,6 +38,7 @@ pub async fn get_all_documents(d."fileType" as file_type,d."createdAt"::timestamptz as created_at,d."updatedAt"::timestamptz as updated_at,+ d."deletedAt"::timestamptz as deleted_at,db.bom_parts as "document_bom?",di.modification_data as "modification_data?",d."projectId" as "project_id?",@@ -125,6 +126,7 @@ pub async fn get_all_documents(created_at: row.created_at,updated_at: row.updated_at,sub_type: row.sub_type,+ deleted_at: row.deleted_at,})}).fetch_all(db)diff --git a/rust/cloud-storage/macro_db_client/src/document/get_document.rs b/rust/cloud-storage/macro_db_client/src/document/get_document.rsindex afa1edb23b..eb14a33bf9 100644--- a/rust/cloud-storage/macro_db_client/src/document/get_document.rs+++ b/rust/cloud-storage/macro_db_client/src/document/get_document.rs@@ -288,7 +288,8 @@ pub async fn get_document(d."projectId" as "project_id",p.name as "project_name?",di.sha as "sha?",- dt.sub_type as "sub_type?: DocumentSubType"+ dt.sub_type as "sub_type?: DocumentSubType",+ d."deletedAt"::timestamptz as "deleted_at"FROM"Document" dLEFT JOIN document_sub_type dt ON dt.document_id = d.id@@ -371,6 +372,7 @@ pub async fn get_document(created_at: row.created_at,updated_at: row.updated_at,sub_type: row.sub_type,+ deleted_at: row.deleted_at,})}).fetch_one(db)@@ -403,7 +405,8 @@ pub async fn get_document_version(d."projectId" as "project_id?",p.name as "project_name?",di.sha as "sha?",- dt.sub_type as "sub_type?: DocumentSubType"+ dt.sub_type as "sub_type?: DocumentSubType",+ d."deletedAt"::timestamptz as deleted_atFROM"Document" dLEFT JOIN document_sub_type dt ON dt.document_id = d.id@@ -485,6 +488,7 @@ pub async fn get_document_version(created_at: row.created_at,updated_at: row.updated_at,sub_type: row.sub_type,+ deleted_at: row.deleted_at,})}).fetch_one(db)diff --git a/rust/cloud-storage/macro_db_client/src/document/get_user_documents.rs b/rust/cloud-storage/macro_db_client/src/document/get_user_documents.rsindex b36091a131..62562d554a 100644--- a/rust/cloud-storage/macro_db_client/src/document/get_user_documents.rs+++ b/rust/cloud-storage/macro_db_client/src/document/get_user_documents.rs@@ -107,7 +107,8 @@ pub async fn get_user_documents(d."projectId" as "project_id",p.name as "project_name",di.sha as "sha",- dt.sub_type as "sub_type"+ dt.sub_type as "sub_type",+ d."deletedAt"::timestamptz as deleted_atFROM"Document" dLEFT JOIN document_sub_type dt ON dt.document_id = d.iddiff --git a/rust/cloud-storage/macro_db_client/src/document/save_document.rs b/rust/cloud-storage/macro_db_client/src/document/save_document.rsindex dab9f7fca0..e38802c391 100644--- a/rust/cloud-storage/macro_db_client/src/document/save_document.rs+++ b/rust/cloud-storage/macro_db_client/src/document/save_document.rs@@ -609,6 +609,7 @@ pub async fn save_document(created_at: document_version.created_at,updated_at: document_version.updated_at,sub_type,+ deleted_at: None,})}diff --git a/rust/cloud-storage/macro_db_client/src/item_access/get.rs b/rust/cloud-storage/macro_db_client/src/item_access/get.rsindex 2e8df1ec78..2c483d2da4 100644--- a/rust/cloud-storage/macro_db_client/src/item_access/get.rs+++ b/rust/cloud-storage/macro_db_client/src/item_access/get.rs@@ -2,6 +2,45 @@ use chrono::{DateTime, Utc};use models_permissions::share_permission::access_level::AccessLevel;use models_permissions::user_item_access::UserItemAccess;+/// Gets the items owner and whether it's deleted+#[tracing::instrument(skip(db), err)]+pub async fn get_owner_and_deleted(+ db: &sqlx::Pool<sqlx::Postgres>,+ entity_id: &str,+ item_type: &str,+) -> anyhow::Result<(String, bool)> {+ let result = match item_type {+ "document" => {+ sqlx::query!(+ r#"SELECT owner, "deletedAt" as deleted_at FROM "Document" WHERE id=$1"#,+ entity_id+ )+ .map(|r| (r.owner, r.deleted_at.is_some()))+ .fetch_one(db)+ .await?+ }+ "chat" => {+ sqlx::query!(+ r#"SELECT "userId" as user_id, "deletedAt" as deleted_at FROM "Chat" WHERE id=$1"#,+ entity_id+ )+ .map(|r| (r.user_id, r.deleted_at.is_some()))+ .fetch_one(db)+ .await?+ }+ "project" => sqlx::query!(+ r#"SELECT "userId" as user_id, "deletedAt" as deleted_at FROM "Project" WHERE id=$1"#,+ entity_id+ )+ .map(|r| (r.user_id, r.deleted_at.is_some()))+ .fetch_one(db)+ .await?,+ _ => anyhow::bail!("unsupported item type"),+ };++ Ok(result)+}+/// Finds all explicit access permissions for a given user on a project and its entire parent hierarchy.#[tracing::instrument(skip(db))]pub async fn get_user_item_access_for_project(diff --git a/rust/cloud-storage/model/src/document/mod.rs b/rust/cloud-storage/model/src/document/mod.rsindex d330dda9c6..9d18cd004f 100644--- a/rust/cloud-storage/model/src/document/mod.rs+++ b/rust/cloud-storage/model/src/document/mod.rs@@ -206,6 +206,11 @@ pub struct DocumentMetadata {#[schema(value_type = i64, nullable=false)]pub updated_at: Option<chrono::DateTime<chrono::Utc>>,+ /// The time the document was deleted+ #[serde(with = "ts_seconds_option")]+ #[schema(value_type = i64, nullable=true)]+ pub deleted_at: Option<chrono::DateTime<chrono::Utc>>,+/// The sub type of the document if present.#[serde(skip_serializing_if = "Option::is_none")]pub sub_type: Option<DocumentSubType>,@@ -247,6 +252,7 @@ impl DocumentMetadata {created_at,updated_at,sub_type: None,+ deleted_at: None, // New documents should never be deleted}}@@ -287,47 +293,7 @@ impl DocumentMetadata {project_name: project_name.map(|s| s.to_string()),created_at,updated_at,- sub_type,- }- }-- #[expect(- clippy::too_many_arguments,- reason = "no good reason but too hard to fix right now"- )]- pub fn document(- document_id: &str,- document_instance_id: i64,- owner: MacroUserIdStr<'static>,- document_name: &str,- file_type: Option<&str>,- sha: &str,- modification_data: Option<serde_json::Value>,- document_family_id: Option<i64>,- branched_from_id: Option<String>,- branched_from_version_id: Option<i64>,- project_id: Option<String>,- project_name: Option<String>,- created_at: Option<chrono::DateTime<chrono::Utc>>,- updated_at: Option<chrono::DateTime<chrono::Utc>>,- sub_type: Option<DocumentSubType>,- ) -> Self {- Self {- document_id: document_id.to_string(),- owner,- document_name: document_name.to_string(),- file_type: file_type.map(|s| s.to_string()),- sha: Some(sha.to_string()),- document_version_id: document_instance_id,- document_bom: None,- modification_data,- document_family_id,- branched_from_id,- branched_from_version_id,- project_id,- project_name,- created_at,- updated_at,+ deleted_at: None, // New documents should never be deletedsub_type,}}diff --git a/rust/cloud-storage/models_soup/src/chat.rs b/rust/cloud-storage/models_soup/src/chat.rsindex 55b57a84c1..da5553a4d4 100644--- a/rust/cloud-storage/models_soup/src/chat.rs+++ b/rust/cloud-storage/models_soup/src/chat.rs@@ -41,6 +41,11 @@ pub struct SoupChat {#[cfg_attr(feature = "schema", schema(value_type = i64, nullable = true))]pub viewed_at: Option<chrono::DateTime<Utc>>,+ /// The time the chat was deleted+ #[serde(with = "chrono::serde::ts_milliseconds_option")]+ #[cfg_attr(feature = "schema", schema(value_type = i64, nullable = true))]+ pub deleted_at: Option<chrono::DateTime<Utc>>,+/// Propertiespub properties: Vec<SoupProperty>,}diff --git a/rust/cloud-storage/models_soup/src/document.rs b/rust/cloud-storage/models_soup/src/document.rsindex dcb8bdf0ee..4b1e1fe8b7 100644--- a/rust/cloud-storage/models_soup/src/document.rs+++ b/rust/cloud-storage/models_soup/src/document.rs@@ -104,6 +104,11 @@ pub struct SoupDocument {#[serde(skip_serializing_if = "Option::is_none")]pub sub_type: Option<SoupDocumentSubType>,+ /// The time the document was deleted+ #[serde(with = "chrono::serde::ts_milliseconds_option")]+ #[cfg_attr(feature = "schema", schema(value_type = i64, nullable = true))]+ pub deleted_at: Option<chrono::DateTime<Utc>>,+/// Propertiespub properties: Vec<SoupProperty>,}diff --git a/rust/cloud-storage/models_soup/src/project.rs b/rust/cloud-storage/models_soup/src/project.rsindex 9d8ceb5df7..da3cf3240e 100644--- a/rust/cloud-storage/models_soup/src/project.rs+++ b/rust/cloud-storage/models_soup/src/project.rs@@ -38,6 +38,11 @@ pub struct SoupProject {#[cfg_attr(feature = "schema", schema(value_type = i64, nullable = true))]pub viewed_at: Option<chrono::DateTime<Utc>>,+ /// The time the project was deleted+ #[serde(with = "chrono::serde::ts_milliseconds_option")]+ #[cfg_attr(feature = "schema", schema(value_type = i64, nullable = true))]+ pub deleted_at: Option<chrono::DateTime<Utc>>,+/// Propertiespub properties: Vec<SoupProperty>,}diff --git a/rust/cloud-storage/properties/src/domain/error.rs b/rust/cloud-storage/properties/src/domain/error.rsindex 84451dec16..cdc37708d8 100644--- a/rust/cloud-storage/properties/src/domain/error.rs+++ b/rust/cloud-storage/properties/src/domain/error.rs@@ -16,4 +16,8 @@ pub enum PropertiesErr {/// Repository/database errors - maps to 500#[error(transparent)]Repo(#[from] anyhow::Error),++ /// Permission service is not configured+ #[error("permission service is not configured")]+ PermissionServiceNotConfigured,}diff --git a/rust/cloud-storage/properties/src/domain/ports.rs b/rust/cloud-storage/properties/src/domain/ports.rsindex fcc63abc9f..06c2875208 100644--- a/rust/cloud-storage/properties/src/domain/ports.rs+++ b/rust/cloud-storage/properties/src/domain/ports.rs@@ -105,6 +105,13 @@ pub trait PropertiesRepo: Send + Sync + 'static {pub trait PermissionService: Send + Sync + 'static {type Err;+ /// Gets the owner of the entity and whether it's deleted+ fn get_owner_and_deleted(+ &self,+ entity_id: &str,+ entity_type: EntityType,+ ) -> impl Future<Output = Result<(String, bool), Self::Err>> + Send;+/// Check if a user has edit access to an entity./// Returns an error if the user does not have edit or owner access.fn check_entity_edit_permission(diff --git a/rust/cloud-storage/properties/src/domain/service.rs b/rust/cloud-storage/properties/src/domain/service.rsindex ab0379fe66..092752b2bb 100644--- a/rust/cloud-storage/properties/src/domain/service.rs+++ b/rust/cloud-storage/properties/src/domain/service.rs@@ -74,4 +74,11 @@ pub trait PropertiesService: Send + Sync + 'static {property_definition_id: Uuid,value: Option<SetPropertyValue>,) -> impl Future<Output = Result<(), PropertiesErr>> + Send;++ /// Gets the owner of the entity and whether it's deleted+ fn get_owner_and_deleted(+ &self,+ entity_id: &str,+ entity_type: EntityType,+ ) -> impl Future<Output = Result<(String, bool), PropertiesErr>> + Send;}diff --git a/rust/cloud-storage/properties/src/domain/service_impl/mod.rs b/rust/cloud-storage/properties/src/domain/service_impl/mod.rsindex 9237f72638..d42d166975 100644--- a/rust/cloud-storage/properties/src/domain/service_impl/mod.rs+++ b/rust/cloud-storage/properties/src/domain/service_impl/mod.rs@@ -279,4 +279,21 @@ whereOk(())}++ #[tracing::instrument(skip(self), err)]+ async fn get_owner_and_deleted(+ &self,+ entity_id: &str,+ entity_type: EntityType,+ ) -> Result<(String, bool), PropertiesErr> {+ if let Some(permission_service) = self.permission_service.as_ref() {+ let result = permission_service+ .get_owner_and_deleted(entity_id, entity_type)+ .await+ .map_err(anyhow::Error::from)?;++ return Ok(result);+ }+ Err(PropertiesErr::PermissionServiceNotConfigured)+ }}diff --git a/rust/cloud-storage/properties/src/outbound/permission_service.rs b/rust/cloud-storage/properties/src/outbound/permission_service.rsindex f408c37c8d..ebce64e679 100644--- a/rust/cloud-storage/properties/src/outbound/permission_service.rs+++ b/rust/cloud-storage/properties/src/outbound/permission_service.rs@@ -101,4 +101,24 @@ impl PermissionService for PermissionServiceImpl {Ok(())}++ #[tracing::instrument(skip(self), err)]+ async fn get_owner_and_deleted(+ &self,+ entity_id: &str,+ entity_type: EntityType,+ ) -> Result<(String, bool), Self::Err> {+ let item_type = match entity_type {+ // The following entity types are either deleted immediately or simply unsupported+ EntityType::Channel | EntityType::Company | EntityType::User | EntityType::Thread => {+ anyhow::bail!("unsupported entity type")+ }+ EntityType::Chat => "chat",+ EntityType::Document | EntityType::Task => "document",+ EntityType::Project => "project",+ };++ macro_db_client::item_access::get::get_owner_and_deleted(&self.db, entity_id, item_type)+ .await+ }}diff --git a/rust/cloud-storage/properties_db_client/.sqlx/query-0893292d05dc339bc516ddc4e2e27ee0f730dd38e1d82bd2a049d38cb7abb275.json b/rust/cloud-storage/properties_db_client/.sqlx/query-0893292d05dc339bc516ddc4e2e27ee0f730dd38e1d82bd2a049d38cb7abb275.jsonnew file mode 100644index 0000000000..34779cb42e--- /dev/null+++ b/rust/cloud-storage/properties_db_client/.sqlx/query-0893292d05dc339bc516ddc4e2e27ee0f730dd38e1d82bd2a049d38cb7abb275.json@@ -0,0 +1,58 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT\n d.id,\n d.name,\n d.owner,\n d.\"fileType\" as \"file_type\",\n d.\"projectId\" as \"project_id\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\"\n FROM\n \"Document\" d\n WHERE\n d.id = $1\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "id",+ "type_info": "Text"+ },+ {+ "ordinal": 1,+ "name": "name",+ "type_info": "Text"+ },+ {+ "ordinal": 2,+ "name": "owner",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "file_type",+ "type_info": "Text"+ },+ {+ "ordinal": 4,+ "name": "project_id",+ "type_info": "Text"+ },+ {+ "ordinal": 5,+ "name": "created_at!",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 6,+ "name": "updated_at!",+ "type_info": "Timestamptz"+ }+ ],+ "parameters": {+ "Left": [+ "Text"+ ]+ },+ "nullable": [+ false,+ false,+ false,+ true,+ true,+ null,+ null+ ]+ },+ "hash": "0893292d05dc339bc516ddc4e2e27ee0f730dd38e1d82bd2a049d38cb7abb275"+}diff --git a/rust/cloud-storage/properties_db_client/src/document_metadata/get.rs b/rust/cloud-storage/properties_db_client/src/document_metadata/get.rsindex a70a6a6f5e..beb7b1b9bd 100644--- a/rust/cloud-storage/properties_db_client/src/document_metadata/get.rs+++ b/rust/cloud-storage/properties_db_client/src/document_metadata/get.rs@@ -25,7 +25,7 @@ pub async fn get_document_metadata(FROM"Document" dWHERE- d.id = $1 AND d."deletedAt" IS NULL+ d.id = $1"#,document_id)diff --git a/rust/cloud-storage/properties_service/src/api/permissions.rs b/rust/cloud-storage/properties_service/src/api/permissions.rsindex 94c823a9b3..a54cc25189 100644--- a/rust/cloud-storage/properties_service/src/api/permissions.rs+++ b/rust/cloud-storage/properties_service/src/api/permissions.rs@@ -1,6 +1,7 @@use axum::http::StatusCode;use models_permissions::share_permission::access_level::AccessLevel;use models_properties::{EntityReference, EntityType};+use properties::PropertiesService;use thiserror::Error;use crate::api::context::ApiContext;@@ -36,6 +37,29 @@ pub async fn check_entity_view_permission(user_id: &str,entity_ref: &EntityReference,) -> Result<(), PermissionError> {+ // Check if entity is deleted+ match entity_ref.entity_type {+ EntityType::Channel | EntityType::Company | EntityType::User | EntityType::Thread => (),+ _ => {+ let (owner, deleted) = context+ .properties_service+ .get_owner_and_deleted(&entity_ref.entity_id, entity_ref.entity_type)+ .await+ .map_err(|e| PermissionError::InternalError(e.to_string()))?;++ // If you are the owner fast return+ if owner.eq(user_id) {+ return Ok(());+ }++ // If the item is deleted and you aren't the owner you are unauthorized+ if deleted {+ return Err(PermissionError::Unauthorized);+ }+ }+ }++ // If entity is deleted, if user is not owner return 401.let access_level = get_access_level(context, user_id, entity_ref).await?;match access_level {diff --git a/rust/cloud-storage/properties_service/src/api/properties/entities/get.rs b/rust/cloud-storage/properties_service/src/api/properties/entities/get.rsindex d1f91a59eb..eb6c4c7620 100644--- a/rust/cloud-storage/properties_service/src/api/properties/entities/get.rs+++ b/rust/cloud-storage/properties_service/src/api/properties/entities/get.rs@@ -82,6 +82,8 @@ pub async fn get_entity_properties();let entity_ref = models_properties::EntityReference::new(entity_id.clone(), entity_type);++ // Note: This can fail if the entity is marked with "deletedAt"crate::api::permissions::check_entity_view_permission(&context,&user_context.user_id,diff --git a/rust/cloud-storage/properties_service/src/api/properties/entities/set.rs b/rust/cloud-storage/properties_service/src/api/properties/entities/set.rsindex a2b0f6f23f..4b9533f890 100644--- a/rust/cloud-storage/properties_service/src/api/properties/entities/set.rs+++ b/rust/cloud-storage/properties_service/src/api/properties/entities/set.rs@@ -24,7 +24,9 @@ impl IntoResponse for SetEntityPropertyErr {SetEntityPropertyErr::Properties(e) => match e {PropertiesErr::Validation(_) => StatusCode::BAD_REQUEST,PropertiesErr::PermissionDenied => StatusCode::FORBIDDEN,- PropertiesErr::Repo(_) => StatusCode::INTERNAL_SERVER_ERROR,+ PropertiesErr::Repo(_) | PropertiesErr::PermissionServiceNotConfigured => {+ StatusCode::INTERNAL_SERVER_ERROR+ }},};diff --git a/rust/cloud-storage/search_processing_service/src/process/document/raw_document.rs b/rust/cloud-storage/search_processing_service/src/process/document/raw_document.rsindex f725682259..4c8f4b8fd3 100644--- a/rust/cloud-storage/search_processing_service/src/process/document/raw_document.rs+++ b/rust/cloud-storage/search_processing_service/src/process/document/raw_document.rs@@ -348,6 +348,7 @@ mod tests {created_at: None,updated_at: None,sub_type: None,+ deleted_at: None,};let markdown_result = vec![diff --git a/rust/cloud-storage/soup/.sqlx/query-05426b40fd7dcdd72313998a69a8bc0f91a8b33ca4727a8d6308cc67b7f729a2.json b/rust/cloud-storage/soup/.sqlx/query-05426b40fd7dcdd72313998a69a8bc0f91a8b33ca4727a8d6308cc67b7f729a2.jsondeleted file mode 100644index 4620b153a3..0000000000--- a/rust/cloud-storage/soup/.sqlx/query-05426b40fd7dcdd72313998a69a8bc0f91a8b33ca4727a8d6308cc67b7f729a2.json+++ /dev/null@@ -1,139 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n WITH UserAccessibleItems AS (\n SELECT DISTINCT ON (\"item_id\", \"item_type\")\n \"item_id\",\n \"item_type\"\n FROM \"UserItemAccess\" \n WHERE \"user_id\" = $1\n ORDER BY \"item_id\", \"item_type\", \n CASE \"access_level\"\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\", \n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", d.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN d.\"createdAt\"\n ELSE d.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n CASE \n WHEN dt.sub_type = 'task' \n AND ep_status.values->'value' ? $6\n THEN true \n WHEN dt.sub_type = 'task'\n THEN false\n ELSE NULL \n END as \"is_completed\"\n FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN entity_properties ep_status \n ON dt.sub_type = 'task'\n AND ep_status.entity_id = d.id \n AND ep_status.entity_type = 'TASK'\n AND ep_status.property_definition_id = $7\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = d.id \n AND uai.item_type = 'document'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = d.id \n AND uh.\"itemType\" = 'document' \n AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", c.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN c.\"createdAt\"\n ELSE c.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = c.id \n AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = c.id \n AND uh.\"itemType\" = 'chat' \n AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n \n UNION ALL\n \n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", p.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN p.\"createdAt\"\n ELSE p.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\"\n FROM \"Project\" p\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = p.id \n AND uai.item_type = 'project'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = p.id \n AND uh.\"itemType\" = 'project' \n AND uh.\"userId\" = $1\n WHERE p.\"deletedAt\" IS NULL\n )\n SELECT * \n FROM Combined\n WHERE ($4::timestamptz IS NULL)\n OR (\"sort_ts!\", \"id!\") < ($4, $5)\n ORDER BY \"sort_ts!\" DESC, \"updated_at!\" DESC\n LIMIT $3\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "item_type!",- "type_info": "Text"- },- {- "ordinal": 1,- "name": "id!",- "type_info": "Text"- },- {- "ordinal": 2,- "name": "document_version_id",- "type_info": "Text"- },- {- "ordinal": 3,- "name": "user_id!",- "type_info": "Text"- },- {- "ordinal": 4,- "name": "name!",- "type_info": "Text"- },- {- "ordinal": 5,- "name": "branched_from_id",- "type_info": "Text"- },- {- "ordinal": 6,- "name": "branched_from_version_id",- "type_info": "Int8"- },- {- "ordinal": 7,- "name": "document_family_id",- "type_info": "Int8"- },- {- "ordinal": 8,- "name": "file_type",- "type_info": "Text"- },- {- "ordinal": 9,- "name": "created_at!",- "type_info": "Timestamptz"- },- {- "ordinal": 10,- "name": "updated_at!",- "type_info": "Timestamptz"- },- {- "ordinal": 11,- "name": "project_id",- "type_info": "Text"- },- {- "ordinal": 12,- "name": "is_persistent",- "type_info": "Bool"- },- {- "ordinal": 13,- "name": "sha",- "type_info": "Text"- },- {- "ordinal": 14,- "name": "sub_type?: DocumentSubType",- "type_info": {- "Custom": {- "name": "document_sub_type_value",- "kind": {- "Enum": [- "task"- ]- }- }- }- },- {- "ordinal": 15,- "name": "viewed_at",- "type_info": "Timestamptz"- },- {- "ordinal": 16,- "name": "sort_ts!",- "type_info": "Timestamptz"- },- {- "ordinal": 17,- "name": "is_completed",- "type_info": "Bool"- }- ],- "parameters": {- "Left": [- "Text",- "Text",- "Int8",- "Timestamptz",- "Text",- "Text",- "Uuid"- ]- },- "nullable": [- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null- ]- },- "hash": "05426b40fd7dcdd72313998a69a8bc0f91a8b33ca4727a8d6308cc67b7f729a2"-}diff --git a/rust/cloud-storage/soup/.sqlx/query-1b324f7419bf6620c5eae611b237ee202fb2b3b011422dc27f351a2c3d10813c.json b/rust/cloud-storage/soup/.sqlx/query-1b324f7419bf6620c5eae611b237ee202fb2b3b011422dc27f351a2c3d10813c.jsonnew file mode 100644index 0000000000..8257f56f38--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-1b324f7419bf6620c5eae611b237ee202fb2b3b011422dc27f351a2c3d10813c.json@@ -0,0 +1,184 @@+{+ "db_name": "PostgreSQL",+ "query": "\nSELECT\n ep.id as entity_property_id,\n ep.entity_id,\n ep.entity_type as \"entity_type: EntityType\",\n ep.property_definition_id,\n ep.values as \"values: sqlx::types::JsonValue\",\n ep.created_at as entity_property_created_at,\n ep.updated_at as entity_property_updated_at,\n pd.organization_id as definition_organization_id,\n pd.user_id as definition_user_id,\n pd.display_name,\n pd.data_type as \"data_type: DataType\",\n pd.is_multi_select,\n pd.specific_entity_type as \"specific_entity_type: Option<EntityType>\",\n pd.created_at as definition_created_at,\n pd.updated_at as definition_updated_at,\n pd.is_system as definition_is_system\nFROM entity_properties ep\nINNER JOIN property_definitions pd ON ep.property_definition_id = pd.id\nWHERE (ep.entity_id, ep.entity_type) IN (\n SELECT * FROM UNNEST($1::TEXT[], $2::property_entity_type[])\n)\n",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "entity_property_id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 1,+ "name": "entity_id",+ "type_info": "Text"+ },+ {+ "ordinal": 2,+ "name": "entity_type: EntityType",+ "type_info": {+ "Custom": {+ "name": "property_entity_type",+ "kind": {+ "Enum": [+ "CHANNEL",+ "CHAT",+ "DOCUMENT",+ "PROJECT",+ "THREAD",+ "USER",+ "COMPANY",+ "TASK"+ ]+ }+ }+ }+ },+ {+ "ordinal": 3,+ "name": "property_definition_id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 4,+ "name": "values: sqlx::types::JsonValue",+ "type_info": "Jsonb"+ },+ {+ "ordinal": 5,+ "name": "entity_property_created_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 6,+ "name": "entity_property_updated_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 7,+ "name": "definition_organization_id",+ "type_info": "Int4"+ },+ {+ "ordinal": 8,+ "name": "definition_user_id",+ "type_info": "Text"+ },+ {+ "ordinal": 9,+ "name": "display_name",+ "type_info": "Text"+ },+ {+ "ordinal": 10,+ "name": "data_type: DataType",+ "type_info": {+ "Custom": {+ "name": "property_data_type",+ "kind": {+ "Enum": [+ "BOOLEAN",+ "DATE",+ "NUMBER",+ "STRING",+ "SELECT_NUMBER",+ "SELECT_STRING",+ "ENTITY",+ "LINK"+ ]+ }+ }+ }+ },+ {+ "ordinal": 11,+ "name": "is_multi_select",+ "type_info": "Bool"+ },+ {+ "ordinal": 12,+ "name": "specific_entity_type: Option<EntityType>",+ "type_info": {+ "Custom": {+ "name": "property_entity_type",+ "kind": {+ "Enum": [+ "CHANNEL",+ "CHAT",+ "DOCUMENT",+ "PROJECT",+ "THREAD",+ "USER",+ "COMPANY",+ "TASK"+ ]+ }+ }+ }+ },+ {+ "ordinal": 13,+ "name": "definition_created_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 14,+ "name": "definition_updated_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 15,+ "name": "definition_is_system",+ "type_info": "Bool"+ }+ ],+ "parameters": {+ "Left": [+ "TextArray",+ {+ "Custom": {+ "name": "property_entity_type[]",+ "kind": {+ "Array": {+ "Custom": {+ "name": "property_entity_type",+ "kind": {+ "Enum": [+ "CHANNEL",+ "CHAT",+ "DOCUMENT",+ "PROJECT",+ "THREAD",+ "USER",+ "COMPANY",+ "TASK"+ ]+ }+ }+ }+ }+ }+ }+ ]+ },+ "nullable": [+ false,+ false,+ false,+ false,+ true,+ false,+ false,+ true,+ true,+ false,+ false,+ false,+ true,+ false,+ false,+ false+ ]+ },+ "hash": "1b324f7419bf6620c5eae611b237ee202fb2b3b011422dc27f351a2c3d10813c"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-35aa1ada3371fd09902d19b1218c2034a348d30889a11f28b98a9e4a0daf4525.json b/rust/cloud-storage/soup/.sqlx/query-35aa1ada3371fd09902d19b1218c2034a348d30889a11f28b98a9e4a0daf4525.jsonnew file mode 100644index 0000000000..0bc29e54eb--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-35aa1ada3371fd09902d19b1218c2034a348d30889a11f28b98a9e4a0daf4525.json@@ -0,0 +1,177 @@+{+ "db_name": "PostgreSQL",+ "query": "\nSELECT\n ep.id as entity_property_id,\n ep.entity_id,\n ep.entity_type as \"entity_type: EntityType\",\n ep.property_definition_id,\n ep.values as \"values: sqlx::types::JsonValue\",\n ep.created_at as entity_property_created_at,\n ep.updated_at as entity_property_updated_at,\n pd.organization_id as definition_organization_id,\n pd.user_id as definition_user_id,\n pd.display_name,\n pd.data_type as \"data_type: DataType\",\n pd.is_multi_select,\n pd.specific_entity_type as \"specific_entity_type: Option<EntityType>\",\n pd.created_at as definition_created_at,\n pd.updated_at as definition_updated_at,\n pd.is_system as definition_is_system\nFROM entity_properties ep\nINNER JOIN property_definitions pd ON ep.property_definition_id = pd.id\nWHERE ep.entity_id = $1 AND ep.entity_type = $2\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "entity_property_id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 1,+ "name": "entity_id",+ "type_info": "Text"+ },+ {+ "ordinal": 2,+ "name": "entity_type: EntityType",+ "type_info": {+ "Custom": {+ "name": "property_entity_type",+ "kind": {+ "Enum": [+ "CHANNEL",+ "CHAT",+ "DOCUMENT",+ "PROJECT",+ "THREAD",+ "USER",+ "COMPANY",+ "TASK"+ ]+ }+ }+ }+ },+ {+ "ordinal": 3,+ "name": "property_definition_id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 4,+ "name": "values: sqlx::types::JsonValue",+ "type_info": "Jsonb"+ },+ {+ "ordinal": 5,+ "name": "entity_property_created_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 6,+ "name": "entity_property_updated_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 7,+ "name": "definition_organization_id",+ "type_info": "Int4"+ },+ {+ "ordinal": 8,+ "name": "definition_user_id",+ "type_info": "Text"+ },+ {+ "ordinal": 9,+ "name": "display_name",+ "type_info": "Text"+ },+ {+ "ordinal": 10,+ "name": "data_type: DataType",+ "type_info": {+ "Custom": {+ "name": "property_data_type",+ "kind": {+ "Enum": [+ "BOOLEAN",+ "DATE",+ "NUMBER",+ "STRING",+ "SELECT_NUMBER",+ "SELECT_STRING",+ "ENTITY",+ "LINK"+ ]+ }+ }+ }+ },+ {+ "ordinal": 11,+ "name": "is_multi_select",+ "type_info": "Bool"+ },+ {+ "ordinal": 12,+ "name": "specific_entity_type: Option<EntityType>",+ "type_info": {+ "Custom": {+ "name": "property_entity_type",+ "kind": {+ "Enum": [+ "CHANNEL",+ "CHAT",+ "DOCUMENT",+ "PROJECT",+ "THREAD",+ "USER",+ "COMPANY",+ "TASK"+ ]+ }+ }+ }+ },+ {+ "ordinal": 13,+ "name": "definition_created_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 14,+ "name": "definition_updated_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 15,+ "name": "definition_is_system",+ "type_info": "Bool"+ }+ ],+ "parameters": {+ "Left": [+ "Text",+ {+ "Custom": {+ "name": "property_entity_type",+ "kind": {+ "Enum": [+ "CHANNEL",+ "CHAT",+ "DOCUMENT",+ "PROJECT",+ "THREAD",+ "USER",+ "COMPANY",+ "TASK"+ ]+ }+ }+ }+ ]+ },+ "nullable": [+ false,+ false,+ false,+ false,+ true,+ false,+ false,+ true,+ true,+ false,+ false,+ false,+ true,+ false,+ false,+ false+ ]+ },+ "hash": "35aa1ada3371fd09902d19b1218c2034a348d30889a11f28b98a9e4a0daf4525"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-3e259ea5cbdcfae4334cb0125de6423fa95a0c127fbeba0a59d7096b0177c072.json b/rust/cloud-storage/soup/.sqlx/query-3e259ea5cbdcfae4334cb0125de6423fa95a0c127fbeba0a59d7096b0177c072.jsonnew file mode 100644index 0000000000..8ee9d7919b--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-3e259ea5cbdcfae4334cb0125de6423fa95a0c127fbeba0a59d7096b0177c072.json@@ -0,0 +1,52 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT\n p.id,\n p.name,\n p.\"userId\" as \"owner\",\n p.\"parentId\" as \"parent_id\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\"\n FROM\n \"Project\" p\n WHERE\n p.id = $1 AND p.\"deletedAt\" IS NULL\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "id",+ "type_info": "Text"+ },+ {+ "ordinal": 1,+ "name": "name",+ "type_info": "Text"+ },+ {+ "ordinal": 2,+ "name": "owner",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "parent_id",+ "type_info": "Text"+ },+ {+ "ordinal": 4,+ "name": "created_at!",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 5,+ "name": "updated_at!",+ "type_info": "Timestamptz"+ }+ ],+ "parameters": {+ "Left": [+ "Text"+ ]+ },+ "nullable": [+ false,+ false,+ false,+ true,+ null,+ null+ ]+ },+ "hash": "3e259ea5cbdcfae4334cb0125de6423fa95a0c127fbeba0a59d7096b0177c072"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-3f3b5a5d8734e3748d4e29d64cfa89baff99dae621e7cbd7a10017beec9485c8.json b/rust/cloud-storage/soup/.sqlx/query-3f3b5a5d8734e3748d4e29d64cfa89baff99dae621e7cbd7a10017beec9485c8.jsonnew file mode 100644index 0000000000..5c152ecd5e--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-3f3b5a5d8734e3748d4e29d64cfa89baff99dae621e7cbd7a10017beec9485c8.json@@ -0,0 +1,50 @@+{+ "db_name": "PostgreSQL",+ "query": "\nSELECT\n ep.entity_id,\n ep.entity_type as \"entity_type: EntityType\",\n ep.property_definition_id\nFROM entity_properties ep\nWHERE ep.id = $1\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "entity_id",+ "type_info": "Text"+ },+ {+ "ordinal": 1,+ "name": "entity_type: EntityType",+ "type_info": {+ "Custom": {+ "name": "property_entity_type",+ "kind": {+ "Enum": [+ "CHANNEL",+ "CHAT",+ "DOCUMENT",+ "PROJECT",+ "THREAD",+ "USER",+ "COMPANY",+ "TASK"+ ]+ }+ }+ }+ },+ {+ "ordinal": 2,+ "name": "property_definition_id",+ "type_info": "Uuid"+ }+ ],+ "parameters": {+ "Left": [+ "Uuid"+ ]+ },+ "nullable": [+ false,+ false,+ false+ ]+ },+ "hash": "3f3b5a5d8734e3748d4e29d64cfa89baff99dae621e7cbd7a10017beec9485c8"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-41682a8f6e1e2fb8836f76ca3ceab5fe676b45c9942ec0c99486c03e52733a47.json b/rust/cloud-storage/soup/.sqlx/query-41682a8f6e1e2fb8836f76ca3ceab5fe676b45c9942ec0c99486c03e52733a47.jsonnew file mode 100644index 0000000000..7eab7370d7--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-41682a8f6e1e2fb8836f76ca3ceab5fe676b45c9942ec0c99486c03e52733a47.json@@ -0,0 +1,38 @@+{+ "db_name": "PostgreSQL",+ "query": "\n INSERT INTO property_options (\n id,\n property_definition_id,\n display_order,\n number_value,\n string_value\n )\n VALUES ($1, $2, $3, $4, $5)\n RETURNING id, created_at, updated_at\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 1,+ "name": "created_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 2,+ "name": "updated_at",+ "type_info": "Timestamptz"+ }+ ],+ "parameters": {+ "Left": [+ "Uuid",+ "Uuid",+ "Int4",+ "Float8",+ "Text"+ ]+ },+ "nullable": [+ false,+ false,+ false+ ]+ },+ "hash": "41682a8f6e1e2fb8836f76ca3ceab5fe676b45c9942ec0c99486c03e52733a47"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-4df1044ff7642fbea4254b739c0ca0d8a5cc652dcec4e22d9eaf01f3cd5da22d.json b/rust/cloud-storage/soup/.sqlx/query-4df1044ff7642fbea4254b739c0ca0d8a5cc652dcec4e22d9eaf01f3cd5da22d.jsonnew file mode 100644index 0000000000..157e13c050--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-4df1044ff7642fbea4254b739c0ca0d8a5cc652dcec4e22d9eaf01f3cd5da22d.json@@ -0,0 +1,144 @@+{+ "db_name": "PostgreSQL",+ "query": "\n WITH UserAccessibleItems AS (\n SELECT DISTINCT ON (\"item_id\", \"item_type\")\n \"item_id\",\n \"item_type\"\n FROM \"UserItemAccess\" \n WHERE \"user_id\" = $1\n ORDER BY \"item_id\", \"item_type\", \n CASE \"access_level\"\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\", \n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n d.\"updatedAt\"::timestamptz as \"sort_ts!\",\n CASE\n WHEN dt.sub_type = 'task'\n AND ep_status.values->'value' ? $5\n THEN true\n WHEN dt.sub_type = 'task'\n THEN false\n ELSE NULL\n END as \"is_completed\",\n d.\"deletedAt\"::timestamptz as \"deleted_at\"\n FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN entity_properties ep_status\n ON dt.sub_type = 'task'\n AND ep_status.entity_id = d.id\n AND ep_status.entity_type = 'TASK'\n AND ep_status.property_definition_id = $6\n INNER JOIN UserAccessibleItems uai\n ON uai.item_id = d.id\n AND uai.item_type = 'document'\n LEFT JOIN \"UserHistory\" uh\n ON uh.\"itemId\" = d.id\n AND uh.\"itemType\" = 'document'\n AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id\n FROM \"DocumentBom\" b\n WHERE b.\"documentId\" = d.id\n ORDER BY b.\"createdAt\" DESC\n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha\n FROM \"DocumentInstance\" i\n WHERE i.\"documentId\" = d.id\n ORDER BY i.\"updatedAt\" DESC\n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n AND d.id = ANY($2::text[])\n\n UNION ALL\n\n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n c.\"updatedAt\"::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\",\n c.\"deletedAt\"::timestamptz as \"deleted_at\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai\n ON uai.item_id = c.id\n AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh\n ON uh.\"itemId\" = c.id\n AND uh.\"itemType\" = 'chat'\n AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n AND c.id = ANY($3::text[])\n\n UNION ALL\n\n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n p.\"updatedAt\"::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\",\n p.\"deletedAt\"::timestamptz as \"deleted_at\"\n FROM \"Project\" p\n INNER JOIN UserAccessibleItems uai\n ON uai.item_id = p.id\n AND uai.item_type = 'project'\n LEFT JOIN \"UserHistory\" uh\n ON uh.\"itemId\" = p.id\n AND uh.\"itemType\" = 'project'\n AND uh.\"userId\" = $1\n WHERE p.\"deletedAt\" IS NULL\n AND p.id = ANY($4::text[])\n )\n SELECT * \n FROM Combined\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "item_type!",+ "type_info": "Text"+ },+ {+ "ordinal": 1,+ "name": "id!",+ "type_info": "Text"+ },+ {+ "ordinal": 2,+ "name": "document_version_id",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "user_id!",+ "type_info": "Text"+ },+ {+ "ordinal": 4,+ "name": "name!",+ "type_info": "Text"+ },+ {+ "ordinal": 5,+ "name": "branched_from_id",+ "type_info": "Text"+ },+ {+ "ordinal": 6,+ "name": "branched_from_version_id",+ "type_info": "Int8"+ },+ {+ "ordinal": 7,+ "name": "document_family_id",+ "type_info": "Int8"+ },+ {+ "ordinal": 8,+ "name": "file_type",+ "type_info": "Text"+ },+ {+ "ordinal": 9,+ "name": "created_at!",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 10,+ "name": "updated_at!",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 11,+ "name": "project_id",+ "type_info": "Text"+ },+ {+ "ordinal": 12,+ "name": "is_persistent",+ "type_info": "Bool"+ },+ {+ "ordinal": 13,+ "name": "sha",+ "type_info": "Text"+ },+ {+ "ordinal": 14,+ "name": "sub_type?: DocumentSubType",+ "type_info": {+ "Custom": {+ "name": "document_sub_type_value",+ "kind": {+ "Enum": [+ "task"+ ]+ }+ }+ }+ },+ {+ "ordinal": 15,+ "name": "viewed_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 16,+ "name": "sort_ts!",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 17,+ "name": "is_completed",+ "type_info": "Bool"+ },+ {+ "ordinal": 18,+ "name": "deleted_at",+ "type_info": "Timestamptz"+ }+ ],+ "parameters": {+ "Left": [+ "Text",+ "TextArray",+ "TextArray",+ "TextArray",+ "Text",+ "Uuid"+ ]+ },+ "nullable": [+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null+ ]+ },+ "hash": "4df1044ff7642fbea4254b739c0ca0d8a5cc652dcec4e22d9eaf01f3cd5da22d"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-5fabf029c6dd06505963dab2b60eccb8ea77088f535970dbcf5f80d57a9a4c5b.json b/rust/cloud-storage/soup/.sqlx/query-5fabf029c6dd06505963dab2b60eccb8ea77088f535970dbcf5f80d57a9a4c5b.jsonnew file mode 100644index 0000000000..c853ae04b7--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-5fabf029c6dd06505963dab2b60eccb8ea77088f535970dbcf5f80d57a9a4c5b.json@@ -0,0 +1,110 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT \n id,\n organization_id,\n user_id,\n display_name,\n data_type as \"data_type: DataType\",\n is_multi_select,\n specific_entity_type as \"specific_entity_type: Option<EntityType>\",\n created_at,\n updated_at,\n is_system\n FROM property_definitions\n WHERE id = $1\n AND is_system = FALSE\n AND (\n user_id = $2\n OR ($3::int IS NOT NULL AND organization_id = $3)\n )\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 1,+ "name": "organization_id",+ "type_info": "Int4"+ },+ {+ "ordinal": 2,+ "name": "user_id",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "display_name",+ "type_info": "Text"+ },+ {+ "ordinal": 4,+ "name": "data_type: DataType",+ "type_info": {+ "Custom": {+ "name": "property_data_type",+ "kind": {+ "Enum": [+ "BOOLEAN",+ "DATE",+ "NUMBER",+ "STRING",+ "SELECT_NUMBER",+ "SELECT_STRING",+ "ENTITY",+ "LINK"+ ]+ }+ }+ }+ },+ {+ "ordinal": 5,+ "name": "is_multi_select",+ "type_info": "Bool"+ },+ {+ "ordinal": 6,+ "name": "specific_entity_type: Option<EntityType>",+ "type_info": {+ "Custom": {+ "name": "property_entity_type",+ "kind": {+ "Enum": [+ "CHANNEL",+ "CHAT",+ "DOCUMENT",+ "PROJECT",+ "THREAD",+ "USER",+ "COMPANY",+ "TASK"+ ]+ }+ }+ }+ },+ {+ "ordinal": 7,+ "name": "created_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 8,+ "name": "updated_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 9,+ "name": "is_system",+ "type_info": "Bool"+ }+ ],+ "parameters": {+ "Left": [+ "Uuid",+ "Text",+ "Int4"+ ]+ },+ "nullable": [+ false,+ true,+ true,+ false,+ false,+ false,+ true,+ false,+ false,+ false+ ]+ },+ "hash": "5fabf029c6dd06505963dab2b60eccb8ea77088f535970dbcf5f80d57a9a4c5b"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-f5327a81ef04ec4f1059515b983bbda0f8f655657c6395d9ecdb91a8cba91070.json b/rust/cloud-storage/soup/.sqlx/query-63c1f6167cbc12ae74d080e0079e3394e70746aedb30a75958096f70ff526a08.jsonsimilarity index 50%rename from rust/cloud-storage/soup/.sqlx/query-f5327a81ef04ec4f1059515b983bbda0f8f655657c6395d9ecdb91a8cba91070.jsonrename to rust/cloud-storage/soup/.sqlx/query-63c1f6167cbc12ae74d080e0079e3394e70746aedb30a75958096f70ff526a08.jsonindex 5f5171db20..6f51cc9f8a 100644--- a/rust/cloud-storage/soup/.sqlx/query-f5327a81ef04ec4f1059515b983bbda0f8f655657c6395d9ecdb91a8cba91070.json+++ b/rust/cloud-storage/soup/.sqlx/query-63c1f6167cbc12ae74d080e0079e3394e70746aedb30a75958096f70ff526a08.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": " \n WITH RECURSIVE ProjectHierarchy AS (\n SELECT p.id, uia.access_level \n FROM \"Project\" p\n JOIN \"UserItemAccess\" uia ON p.id = uia.item_id AND uia.item_type = 'project'\n WHERE uia.user_id = $1 AND p.\"deletedAt\" IS NULL\n UNION ALL\n SELECT p.id, ph.access_level\n FROM \"Project\" p \n JOIN ProjectHierarchy ph ON p.\"parentId\" = ph.id\n WHERE p.\"deletedAt\" IS NULL\n ),\n AllAccessGrants AS (\n SELECT item_id, item_type, access_level \n FROM \"UserItemAccess\" \n WHERE user_id = $1\n UNION ALL\n SELECT d.id AS item_id, 'document' AS item_type, ph.access_level\n FROM \"Document\" d \n JOIN ProjectHierarchy ph ON d.\"projectId\" = ph.id\n WHERE d.\"projectId\" IS NOT NULL AND d.\"deletedAt\" IS NULL\n UNION ALL\n SELECT c.id AS item_id, 'chat' AS item_type, ph.access_level\n FROM \"Chat\" c \n JOIN ProjectHierarchy ph ON c.\"projectId\" = ph.id\n WHERE c.\"projectId\" IS NOT NULL AND c.\"deletedAt\" IS NULL\n UNION ALL\n SELECT ph.id AS item_id, 'project' AS item_type, ph.access_level \n FROM ProjectHierarchy ph\n ),\n UserAccessibleItems AS (\n SELECT DISTINCT ON (item_id, item_type) item_id, item_type\n FROM AllAccessGrants\n ORDER BY item_id, item_type, \n CASE access_level\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", d.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN d.\"createdAt\"\n ELSE d.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n CASE \n WHEN dt.sub_type = 'task' \n AND ep_status.values->'value' ? $6\n THEN true \n WHEN dt.sub_type = 'task'\n THEN false\n ELSE NULL \n END as \"is_completed\"\n FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN entity_properties ep_status \n ON dt.sub_type = 'task'\n AND ep_status.entity_id = d.id \n AND ep_status.entity_type = 'TASK'\n AND ep_status.property_definition_id = $7\n INNER JOIN UserAccessibleItems uai ON uai.item_id = d.id AND uai.item_type = 'document'\n -- This MUST be a LEFT JOIN to support all three sort methods\n LEFT JOIN \"UserHistory\" uh ON uh.\"itemId\" = d.id AND uh.\"itemType\" = 'document' AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", c.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN c.\"createdAt\"\n ELSE c.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai ON uai.item_id = c.id AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh ON uh.\"itemId\" = c.id AND uh.\"itemType\" = 'chat' AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n\n UNION ALL\n\n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", p.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN p.\"createdAt\"\n ELSE p.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\"\n FROM \"Project\" p\n INNER JOIN UserAccessibleItems uai\n ON uai.item_id = p.id\n AND uai.item_type = 'project'\n LEFT JOIN \"UserHistory\" uh\n ON uh.\"itemId\" = p.id\n AND uh.\"itemType\" = 'project'\n AND uh.\"userId\" = $1\n WHERE p.\"deletedAt\" IS NULL\n )\n SELECT * FROM Combined\n WHERE\n ($4::timestamptz IS NULL)\n OR\n (\"sort_ts!\", \"id!\"::text) < ($4, $5)\n ORDER BY \"sort_ts!\" DESC, \"updated_at!\" DESC\n LIMIT $3\n",+ "query": " \n WITH RECURSIVE ProjectHierarchy AS (\n SELECT p.id, uia.access_level \n FROM \"Project\" p\n JOIN \"UserItemAccess\" uia ON p.id = uia.item_id AND uia.item_type = 'project'\n WHERE uia.user_id = $1 AND p.\"deletedAt\" IS NULL\n UNION ALL\n SELECT p.id, ph.access_level\n FROM \"Project\" p \n JOIN ProjectHierarchy ph ON p.\"parentId\" = ph.id\n WHERE p.\"deletedAt\" IS NULL\n ),\n AllAccessGrants AS (\n SELECT item_id, item_type, access_level \n FROM \"UserItemAccess\" \n WHERE user_id = $1\n UNION ALL\n SELECT d.id AS item_id, 'document' AS item_type, ph.access_level\n FROM \"Document\" d \n JOIN ProjectHierarchy ph ON d.\"projectId\" = ph.id\n WHERE d.\"projectId\" IS NOT NULL AND d.\"deletedAt\" IS NULL\n UNION ALL\n SELECT c.id AS item_id, 'chat' AS item_type, ph.access_level\n FROM \"Chat\" c \n JOIN ProjectHierarchy ph ON c.\"projectId\" = ph.id\n WHERE c.\"projectId\" IS NOT NULL AND c.\"deletedAt\" IS NULL\n UNION ALL\n SELECT ph.id AS item_id, 'project' AS item_type, ph.access_level \n FROM ProjectHierarchy ph\n ),\n UserAccessibleItems AS (\n SELECT DISTINCT ON (item_id, item_type) item_id, item_type\n FROM AllAccessGrants\n ORDER BY item_id, item_type, \n CASE access_level\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", d.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN d.\"createdAt\"\n ELSE d.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n CASE\n WHEN dt.sub_type = 'task'\n AND ep_status.values->'value' ? $6\n THEN true\n WHEN dt.sub_type = 'task'\n THEN false\n ELSE NULL\n END as \"is_completed\",\n d.\"deletedAt\"::timestamptz as \"deleted_at\"\n FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN entity_properties ep_status\n ON dt.sub_type = 'task'\n AND ep_status.entity_id = d.id\n AND ep_status.entity_type = 'TASK'\n AND ep_status.property_definition_id = $7\n INNER JOIN UserAccessibleItems uai ON uai.item_id = d.id AND uai.item_type = 'document'\n -- This MUST be a LEFT JOIN to support all three sort methods\n LEFT JOIN \"UserHistory\" uh ON uh.\"itemId\" = d.id AND uh.\"itemType\" = 'document' AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id\n FROM \"DocumentBom\" b\n WHERE b.\"documentId\" = d.id\n ORDER BY b.\"createdAt\" DESC\n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha\n FROM \"DocumentInstance\" i\n WHERE i.\"documentId\" = d.id\n ORDER BY i.\"updatedAt\" DESC\n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n\n UNION ALL\n\n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", c.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN c.\"createdAt\"\n ELSE c.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\",\n c.\"deletedAt\"::timestamptz as \"deleted_at\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai ON uai.item_id = c.id AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh ON uh.\"itemId\" = c.id AND uh.\"itemType\" = 'chat' AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n\n UNION ALL\n\n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", p.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN p.\"createdAt\"\n ELSE p.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\",\n p.\"deletedAt\"::timestamptz as \"deleted_at\"\n FROM \"Project\" p\n INNER JOIN UserAccessibleItems uai\n ON uai.item_id = p.id\n AND uai.item_type = 'project'\n LEFT JOIN \"UserHistory\" uh\n ON uh.\"itemId\" = p.id\n AND uh.\"itemType\" = 'project'\n AND uh.\"userId\" = $1\n WHERE p.\"deletedAt\" IS NULL\n )\n SELECT Combined.* FROM Combined\n LEFT JOIN frecency_aggregates fa\n ON fa.entity_id = Combined.\"id!\"\n AND fa.entity_type = Combined.\"item_type!\"\n AND fa.user_id = $1\n WHERE fa.id IS NULL\n AND (\n ($4::timestamptz IS NULL)\n OR\n (Combined.\"sort_ts!\", Combined.\"id!\"::text) < ($4, $5)\n )\n ORDER BY Combined.\"sort_ts!\" DESC, Combined.\"updated_at!\" DESC\n LIMIT $3\n ","describe": {"columns": [{@@ -101,6 +101,11 @@"ordinal": 17,"name": "is_completed","type_info": "Bool"+ },+ {+ "ordinal": 18,+ "name": "deleted_at",+ "type_info": "Timestamptz"}],"parameters": {@@ -132,8 +137,9 @@null,null,null,+ null,null]},- "hash": "f5327a81ef04ec4f1059515b983bbda0f8f655657c6395d9ecdb91a8cba91070"+ "hash": "63c1f6167cbc12ae74d080e0079e3394e70746aedb30a75958096f70ff526a08"}diff --git a/rust/cloud-storage/soup/.sqlx/query-732141210551d42218ce027266c6dfa3dd1f0ddb2c37493ed1235fe488073d89.json b/rust/cloud-storage/soup/.sqlx/query-732141210551d42218ce027266c6dfa3dd1f0ddb2c37493ed1235fe488073d89.jsonnew file mode 100644index 0000000000..ea49b9c1cd--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-732141210551d42218ce027266c6dfa3dd1f0ddb2c37493ed1235fe488073d89.json@@ -0,0 +1,108 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT \n id,\n organization_id,\n user_id,\n display_name,\n data_type as \"data_type: DataType\",\n is_multi_select,\n specific_entity_type as \"specific_entity_type: Option<EntityType>\",\n created_at,\n updated_at,\n is_system\n FROM property_definitions\n WHERE id = $1\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 1,+ "name": "organization_id",+ "type_info": "Int4"+ },+ {+ "ordinal": 2,+ "name": "user_id",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "display_name",+ "type_info": "Text"+ },+ {+ "ordinal": 4,+ "name": "data_type: DataType",+ "type_info": {+ "Custom": {+ "name": "property_data_type",+ "kind": {+ "Enum": [+ "BOOLEAN",+ "DATE",+ "NUMBER",+ "STRING",+ "SELECT_NUMBER",+ "SELECT_STRING",+ "ENTITY",+ "LINK"+ ]+ }+ }+ }+ },+ {+ "ordinal": 5,+ "name": "is_multi_select",+ "type_info": "Bool"+ },+ {+ "ordinal": 6,+ "name": "specific_entity_type: Option<EntityType>",+ "type_info": {+ "Custom": {+ "name": "property_entity_type",+ "kind": {+ "Enum": [+ "CHANNEL",+ "CHAT",+ "DOCUMENT",+ "PROJECT",+ "THREAD",+ "USER",+ "COMPANY",+ "TASK"+ ]+ }+ }+ }+ },+ {+ "ordinal": 7,+ "name": "created_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 8,+ "name": "updated_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 9,+ "name": "is_system",+ "type_info": "Bool"+ }+ ],+ "parameters": {+ "Left": [+ "Uuid"+ ]+ },+ "nullable": [+ false,+ true,+ true,+ false,+ false,+ false,+ true,+ false,+ false,+ false+ ]+ },+ "hash": "732141210551d42218ce027266c6dfa3dd1f0ddb2c37493ed1235fe488073d89"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-7ae5368ee01e670dcc9804096f3d3e9dcab6dcebcb601bfb1ed190dbda0ff37f.json b/rust/cloud-storage/soup/.sqlx/query-7ae5368ee01e670dcc9804096f3d3e9dcab6dcebcb601bfb1ed190dbda0ff37f.jsonnew file mode 100644index 0000000000..a33e79f60e--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-7ae5368ee01e670dcc9804096f3d3e9dcab6dcebcb601bfb1ed190dbda0ff37f.json@@ -0,0 +1,34 @@+{+ "db_name": "PostgreSQL",+ "query": "\n INSERT INTO entity_properties (id, entity_id, entity_type, property_definition_id, values)\n VALUES ($1, $2, $3, $4, $5)\n ON CONFLICT (entity_id, entity_type, property_definition_id) \n DO UPDATE SET \n values = EXCLUDED.values,\n updated_at = NOW()\n ",+ "describe": {+ "columns": [],+ "parameters": {+ "Left": [+ "Uuid",+ "Text",+ {+ "Custom": {+ "name": "property_entity_type",+ "kind": {+ "Enum": [+ "CHANNEL",+ "CHAT",+ "DOCUMENT",+ "PROJECT",+ "THREAD",+ "USER",+ "COMPANY",+ "TASK"+ ]+ }+ }+ },+ "Uuid",+ "Jsonb"+ ]+ },+ "nullable": []+ },+ "hash": "7ae5368ee01e670dcc9804096f3d3e9dcab6dcebcb601bfb1ed190dbda0ff37f"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-827b998f442f5f6cb6ff85dc35f01c5782128a4cb9a020e22ab83a24a6c2b4f5.json b/rust/cloud-storage/soup/.sqlx/query-827b998f442f5f6cb6ff85dc35f01c5782128a4cb9a020e22ab83a24a6c2b4f5.jsonnew file mode 100644index 0000000000..d172804854--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-827b998f442f5f6cb6ff85dc35f01c5782128a4cb9a020e22ab83a24a6c2b4f5.json@@ -0,0 +1,110 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT \n id,\n organization_id,\n user_id,\n display_name,\n data_type as \"data_type: DataType\",\n is_multi_select,\n specific_entity_type as \"specific_entity_type: Option<EntityType>\",\n created_at,\n updated_at,\n is_system\n FROM property_definitions\n WHERE \n ($3 AND is_system)\n OR (\n ($1::int IS NOT NULL AND organization_id = $1) \n OR ($2::text IS NOT NULL AND user_id = $2)\n )\n ORDER BY LOWER(display_name) ASC\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 1,+ "name": "organization_id",+ "type_info": "Int4"+ },+ {+ "ordinal": 2,+ "name": "user_id",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "display_name",+ "type_info": "Text"+ },+ {+ "ordinal": 4,+ "name": "data_type: DataType",+ "type_info": {+ "Custom": {+ "name": "property_data_type",+ "kind": {+ "Enum": [+ "BOOLEAN",+ "DATE",+ "NUMBER",+ "STRING",+ "SELECT_NUMBER",+ "SELECT_STRING",+ "ENTITY",+ "LINK"+ ]+ }+ }+ }+ },+ {+ "ordinal": 5,+ "name": "is_multi_select",+ "type_info": "Bool"+ },+ {+ "ordinal": 6,+ "name": "specific_entity_type: Option<EntityType>",+ "type_info": {+ "Custom": {+ "name": "property_entity_type",+ "kind": {+ "Enum": [+ "CHANNEL",+ "CHAT",+ "DOCUMENT",+ "PROJECT",+ "THREAD",+ "USER",+ "COMPANY",+ "TASK"+ ]+ }+ }+ }+ },+ {+ "ordinal": 7,+ "name": "created_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 8,+ "name": "updated_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 9,+ "name": "is_system",+ "type_info": "Bool"+ }+ ],+ "parameters": {+ "Left": [+ "Int4",+ "Text",+ "Bool"+ ]+ },+ "nullable": [+ false,+ true,+ true,+ false,+ false,+ false,+ true,+ false,+ false,+ false+ ]+ },+ "hash": "827b998f442f5f6cb6ff85dc35f01c5782128a4cb9a020e22ab83a24a6c2b4f5"+}diff --git a/rust/cloud-storage/properties_db_client/.sqlx/query-8deba8192e4d2c9e483de10142ec78795082cc722c3f8791b993ecc396ad5fbf.json b/rust/cloud-storage/soup/.sqlx/query-8deba8192e4d2c9e483de10142ec78795082cc722c3f8791b993ecc396ad5fbf.jsonsimilarity index 100%rename from rust/cloud-storage/properties_db_client/.sqlx/query-8deba8192e4d2c9e483de10142ec78795082cc722c3f8791b993ecc396ad5fbf.jsonrename to rust/cloud-storage/soup/.sqlx/query-8deba8192e4d2c9e483de10142ec78795082cc722c3f8791b993ecc396ad5fbf.jsondiff --git a/rust/cloud-storage/soup/.sqlx/query-9e45ba072fbc5266f7edba0fecb99d19192e10139d6ea089be4a3a4a7923361c.json b/rust/cloud-storage/soup/.sqlx/query-9e45ba072fbc5266f7edba0fecb99d19192e10139d6ea089be4a3a4a7923361c.jsonnew file mode 100644index 0000000000..357e50473e--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-9e45ba072fbc5266f7edba0fecb99d19192e10139d6ea089be4a3a4a7923361c.json@@ -0,0 +1,18 @@+{+ "db_name": "PostgreSQL",+ "query": "\n INSERT INTO property_options (\n id,\n property_definition_id,\n display_order,\n number_value,\n string_value\n )\n VALUES ($1, $2, $3, $4, $5)\n ",+ "describe": {+ "columns": [],+ "parameters": {+ "Left": [+ "Uuid",+ "Uuid",+ "Int4",+ "Float8",+ "Text"+ ]+ },+ "nullable": []+ },+ "hash": "9e45ba072fbc5266f7edba0fecb99d19192e10139d6ea089be4a3a4a7923361c"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-aa8ade2c95791e695f255437eb1e24960c1ffb8a804b75f533dc6e7e063f5404.json b/rust/cloud-storage/soup/.sqlx/query-9ec774ab99220caf9d64207c5546aed513a93a52ef3438c3f67485ef1ebe12c2.jsonsimilarity index 61%rename from rust/cloud-storage/soup/.sqlx/query-aa8ade2c95791e695f255437eb1e24960c1ffb8a804b75f533dc6e7e063f5404.jsonrename to rust/cloud-storage/soup/.sqlx/query-9ec774ab99220caf9d64207c5546aed513a93a52ef3438c3f67485ef1ebe12c2.jsonindex 6bec519dd0..cbd9cbef34 100644--- a/rust/cloud-storage/soup/.sqlx/query-aa8ade2c95791e695f255437eb1e24960c1ffb8a804b75f533dc6e7e063f5404.json+++ b/rust/cloud-storage/soup/.sqlx/query-9ec774ab99220caf9d64207c5546aed513a93a52ef3438c3f67485ef1ebe12c2.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n WITH RECURSIVE ProjectHierarchy AS (\n SELECT p.id, uia.access_level \n FROM \"Project\" p\n JOIN \"UserItemAccess\" uia ON p.id = uia.item_id AND uia.item_type = 'project'\n WHERE uia.user_id = $1 AND p.\"deletedAt\" IS NULL\n UNION ALL\n SELECT p.id, ph.access_level\n FROM \"Project\" p \n JOIN ProjectHierarchy ph ON p.\"parentId\" = ph.id\n WHERE p.\"deletedAt\" IS NULL\n ),\n AllAccessGrants AS (\n SELECT item_id, item_type, access_level \n FROM \"UserItemAccess\" \n WHERE user_id = $1\n UNION ALL\n SELECT d.id AS item_id, 'document' AS item_type, ph.access_level\n FROM \"Document\" d \n JOIN ProjectHierarchy ph ON d.\"projectId\" = ph.id\n WHERE d.\"projectId\" IS NOT NULL AND d.\"deletedAt\" IS NULL\n UNION ALL\n SELECT c.id AS item_id, 'chat' AS item_type, ph.access_level\n FROM \"Chat\" c \n JOIN ProjectHierarchy ph ON c.\"projectId\" = ph.id\n WHERE c.\"projectId\" IS NOT NULL AND c.\"deletedAt\" IS NULL\n UNION ALL\n SELECT ph.id AS item_id, 'project' AS item_type, ph.access_level \n FROM ProjectHierarchy ph\n ),\n UserAccessibleItems AS (\n SELECT DISTINCT ON (item_id, item_type) item_id, item_type\n FROM AllAccessGrants\n ORDER BY item_id, item_type, \n CASE access_level\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE \n WHEN dt.sub_type = 'task' \n AND ep_status.values->'value' ? $4\n THEN true \n WHEN dt.sub_type = 'task'\n THEN false\n ELSE NULL \n END as \"is_completed\"\n FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN entity_properties ep_status \n ON dt.sub_type = 'task'\n AND ep_status.entity_id = d.id \n AND ep_status.entity_type = 'TASK'\n AND ep_status.property_definition_id = $5\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = d.id \n AND uai.item_type = 'document'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = d.id \n AND uh.\"itemType\" = 'document' \n AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n AND d.id = ANY($2::text[])\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n NULL as \"is_completed\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = c.id \n AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = c.id \n AND uh.\"itemType\" = 'chat' \n AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n AND c.id = ANY($3::text[])\n )\n SELECT * \n FROM Combined\n ",+ "query": "\n WITH RECURSIVE ProjectHierarchy AS (\n SELECT p.id, uia.access_level \n FROM \"Project\" p\n JOIN \"UserItemAccess\" uia ON p.id = uia.item_id AND uia.item_type = 'project'\n WHERE uia.user_id = $1 AND p.\"deletedAt\" IS NULL\n UNION ALL\n SELECT p.id, ph.access_level\n FROM \"Project\" p \n JOIN ProjectHierarchy ph ON p.\"parentId\" = ph.id\n WHERE p.\"deletedAt\" IS NULL\n ),\n AllAccessGrants AS (\n SELECT item_id, item_type, access_level \n FROM \"UserItemAccess\" \n WHERE user_id = $1\n UNION ALL\n SELECT d.id AS item_id, 'document' AS item_type, ph.access_level\n FROM \"Document\" d \n JOIN ProjectHierarchy ph ON d.\"projectId\" = ph.id\n WHERE d.\"projectId\" IS NOT NULL AND d.\"deletedAt\" IS NULL\n UNION ALL\n SELECT c.id AS item_id, 'chat' AS item_type, ph.access_level\n FROM \"Chat\" c \n JOIN ProjectHierarchy ph ON c.\"projectId\" = ph.id\n WHERE c.\"projectId\" IS NOT NULL AND c.\"deletedAt\" IS NULL\n UNION ALL\n SELECT ph.id AS item_id, 'project' AS item_type, ph.access_level \n FROM ProjectHierarchy ph\n ),\n UserAccessibleItems AS (\n SELECT DISTINCT ON (item_id, item_type) item_id, item_type\n FROM AllAccessGrants\n ORDER BY item_id, item_type, \n CASE access_level\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE\n WHEN dt.sub_type = 'task'\n AND ep_status.values->'value' ? $4\n THEN true\n WHEN dt.sub_type = 'task'\n THEN false\n ELSE NULL\n END as \"is_completed\",\n d.\"deletedAt\"::timestamptz as \"deleted_at\"\n FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN entity_properties ep_status \n ON dt.sub_type = 'task'\n AND ep_status.entity_id = d.id \n AND ep_status.entity_type = 'TASK'\n AND ep_status.property_definition_id = $5\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = d.id \n AND uai.item_type = 'document'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = d.id \n AND uh.\"itemType\" = 'document' \n AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n AND d.id = ANY($2::text[])\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n NULL as \"is_completed\",\n c.\"deletedAt\"::timestamptz as \"deleted_at\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai\n ON uai.item_id = c.id\n AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh\n ON uh.\"itemId\" = c.id\n AND uh.\"itemType\" = 'chat'\n AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n AND c.id = ANY($3::text[])\n )\n SELECT * \n FROM Combined\n ","describe": {"columns": [{@@ -96,6 +96,11 @@"ordinal": 16,"name": "is_completed","type_info": "Bool"+ },+ {+ "ordinal": 17,+ "name": "deleted_at",+ "type_info": "Timestamptz"}],"parameters": {@@ -124,8 +129,9 @@null,null,null,+ null,null]},- "hash": "aa8ade2c95791e695f255437eb1e24960c1ffb8a804b75f533dc6e7e063f5404"+ "hash": "9ec774ab99220caf9d64207c5546aed513a93a52ef3438c3f67485ef1ebe12c2"}diff --git a/rust/cloud-storage/soup/.sqlx/query-a56dc6f0b90365d68c54ed6af215902f2635372800d9994d89a18c19c11cb69f.json b/rust/cloud-storage/soup/.sqlx/query-a56dc6f0b90365d68c54ed6af215902f2635372800d9994d89a18c19c11cb69f.jsonnew file mode 100644index 0000000000..fc43a609a0--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-a56dc6f0b90365d68c54ed6af215902f2635372800d9994d89a18c19c11cb69f.json@@ -0,0 +1,145 @@+{+ "db_name": "PostgreSQL",+ "query": "\n WITH UserAccessibleItems AS (\n SELECT DISTINCT ON (\"item_id\", \"item_type\")\n \"item_id\",\n \"item_type\"\n FROM \"UserItemAccess\" \n WHERE \"user_id\" = $1\n ORDER BY \"item_id\", \"item_type\", \n CASE \"access_level\"\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\", \n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", d.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN d.\"createdAt\"\n ELSE d.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n CASE\n WHEN dt.sub_type = 'task'\n AND ep_status.values->'value' ? $6\n THEN true\n WHEN dt.sub_type = 'task'\n THEN false\n ELSE NULL\n END as \"is_completed\",\n d.\"deletedAt\"::timestamptz as \"deleted_at\"\n FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN entity_properties ep_status\n ON dt.sub_type = 'task'\n AND ep_status.entity_id = d.id\n AND ep_status.entity_type = 'TASK'\n AND ep_status.property_definition_id = $7\n INNER JOIN UserAccessibleItems uai\n ON uai.item_id = d.id\n AND uai.item_type = 'document'\n LEFT JOIN \"UserHistory\" uh\n ON uh.\"itemId\" = d.id\n AND uh.\"itemType\" = 'document'\n AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id\n FROM \"DocumentBom\" b\n WHERE b.\"documentId\" = d.id\n ORDER BY b.\"createdAt\" DESC\n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha\n FROM \"DocumentInstance\" i\n WHERE i.\"documentId\" = d.id\n ORDER BY i.\"updatedAt\" DESC\n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n\n UNION ALL\n\n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", c.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN c.\"createdAt\"\n ELSE c.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\",\n c.\"deletedAt\"::timestamptz as \"deleted_at\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai\n ON uai.item_id = c.id\n AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh\n ON uh.\"itemId\" = c.id\n AND uh.\"itemType\" = 'chat'\n AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n\n UNION ALL\n\n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", p.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN p.\"createdAt\"\n ELSE p.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\",\n p.\"deletedAt\"::timestamptz as \"deleted_at\"\n FROM \"Project\" p\n INNER JOIN UserAccessibleItems uai\n ON uai.item_id = p.id\n AND uai.item_type = 'project'\n LEFT JOIN \"UserHistory\" uh\n ON uh.\"itemId\" = p.id\n AND uh.\"itemType\" = 'project'\n AND uh.\"userId\" = $1\n WHERE p.\"deletedAt\" IS NULL\n )\n SELECT * \n FROM Combined\n WHERE ($4::timestamptz IS NULL)\n OR (\"sort_ts!\", \"id!\") < ($4, $5)\n ORDER BY \"sort_ts!\" DESC, \"updated_at!\" DESC\n LIMIT $3\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "item_type!",+ "type_info": "Text"+ },+ {+ "ordinal": 1,+ "name": "id!",+ "type_info": "Text"+ },+ {+ "ordinal": 2,+ "name": "document_version_id",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "user_id!",+ "type_info": "Text"+ },+ {+ "ordinal": 4,+ "name": "name!",+ "type_info": "Text"+ },+ {+ "ordinal": 5,+ "name": "branched_from_id",+ "type_info": "Text"+ },+ {+ "ordinal": 6,+ "name": "branched_from_version_id",+ "type_info": "Int8"+ },+ {+ "ordinal": 7,+ "name": "document_family_id",+ "type_info": "Int8"+ },+ {+ "ordinal": 8,+ "name": "file_type",+ "type_info": "Text"+ },+ {+ "ordinal": 9,+ "name": "created_at!",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 10,+ "name": "updated_at!",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 11,+ "name": "project_id",+ "type_info": "Text"+ },+ {+ "ordinal": 12,+ "name": "is_persistent",+ "type_info": "Bool"+ },+ {+ "ordinal": 13,+ "name": "sha",+ "type_info": "Text"+ },+ {+ "ordinal": 14,+ "name": "sub_type?: DocumentSubType",+ "type_info": {+ "Custom": {+ "name": "document_sub_type_value",+ "kind": {+ "Enum": [+ "task"+ ]+ }+ }+ }+ },+ {+ "ordinal": 15,+ "name": "viewed_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 16,+ "name": "sort_ts!",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 17,+ "name": "is_completed",+ "type_info": "Bool"+ },+ {+ "ordinal": 18,+ "name": "deleted_at",+ "type_info": "Timestamptz"+ }+ ],+ "parameters": {+ "Left": [+ "Text",+ "Text",+ "Int8",+ "Timestamptz",+ "Text",+ "Text",+ "Uuid"+ ]+ },+ "nullable": [+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null+ ]+ },+ "hash": "a56dc6f0b90365d68c54ed6af215902f2635372800d9994d89a18c19c11cb69f"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-b370ac2ac7ace6911ff13454d24ff42b906dcc72b2fb4bcd783b8cb7c06ceab4.json b/rust/cloud-storage/soup/.sqlx/query-b370ac2ac7ace6911ff13454d24ff42b906dcc72b2fb4bcd783b8cb7c06ceab4.jsonnew file mode 100644index 0000000000..4ab9cd0461--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-b370ac2ac7ace6911ff13454d24ff42b906dcc72b2fb4bcd783b8cb7c06ceab4.json@@ -0,0 +1,14 @@+{+ "db_name": "PostgreSQL",+ "query": "DELETE FROM entity_properties WHERE id = $1",+ "describe": {+ "columns": [],+ "parameters": {+ "Left": [+ "Uuid"+ ]+ },+ "nullable": []+ },+ "hash": "b370ac2ac7ace6911ff13454d24ff42b906dcc72b2fb4bcd783b8cb7c06ceab4"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-b9570b07121de0df914dd0579cc92a5e92973cf114526f80dbe7ab714493090b.json b/rust/cloud-storage/soup/.sqlx/query-b9570b07121de0df914dd0579cc92a5e92973cf114526f80dbe7ab714493090b.jsonnew file mode 100644index 0000000000..4063a3122f--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-b9570b07121de0df914dd0579cc92a5e92973cf114526f80dbe7ab714493090b.json@@ -0,0 +1,146 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT \n pd.id,\n pd.organization_id,\n pd.user_id,\n pd.display_name,\n pd.data_type as \"data_type: DataType\",\n pd.is_multi_select,\n pd.specific_entity_type as \"specific_entity_type: Option<EntityType>\",\n pd.created_at,\n pd.updated_at,\n pd.is_system,\n po.id as \"option_id?\",\n po.display_order as \"option_display_order?\",\n po.number_value as option_number_value,\n po.string_value as option_string_value,\n po.created_at as \"option_created_at?\",\n po.updated_at as \"option_updated_at?\"\n FROM property_definitions pd\n LEFT JOIN property_options po ON pd.id = po.property_definition_id\n WHERE \n ($3 AND pd.is_system)\n OR (\n ($1::int IS NOT NULL AND pd.organization_id = $1) \n OR ($2::text IS NOT NULL AND pd.user_id = $2)\n )\n ORDER BY LOWER(pd.display_name), po.display_order, po.number_value, LOWER(po.string_value)\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 1,+ "name": "organization_id",+ "type_info": "Int4"+ },+ {+ "ordinal": 2,+ "name": "user_id",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "display_name",+ "type_info": "Text"+ },+ {+ "ordinal": 4,+ "name": "data_type: DataType",+ "type_info": {+ "Custom": {+ "name": "property_data_type",+ "kind": {+ "Enum": [+ "BOOLEAN",+ "DATE",+ "NUMBER",+ "STRING",+ "SELECT_NUMBER",+ "SELECT_STRING",+ "ENTITY",+ "LINK"+ ]+ }+ }+ }+ },+ {+ "ordinal": 5,+ "name": "is_multi_select",+ "type_info": "Bool"+ },+ {+ "ordinal": 6,+ "name": "specific_entity_type: Option<EntityType>",+ "type_info": {+ "Custom": {+ "name": "property_entity_type",+ "kind": {+ "Enum": [+ "CHANNEL",+ "CHAT",+ "DOCUMENT",+ "PROJECT",+ "THREAD",+ "USER",+ "COMPANY",+ "TASK"+ ]+ }+ }+ }+ },+ {+ "ordinal": 7,+ "name": "created_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 8,+ "name": "updated_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 9,+ "name": "is_system",+ "type_info": "Bool"+ },+ {+ "ordinal": 10,+ "name": "option_id?",+ "type_info": "Uuid"+ },+ {+ "ordinal": 11,+ "name": "option_display_order?",+ "type_info": "Int4"+ },+ {+ "ordinal": 12,+ "name": "option_number_value",+ "type_info": "Float8"+ },+ {+ "ordinal": 13,+ "name": "option_string_value",+ "type_info": "Text"+ },+ {+ "ordinal": 14,+ "name": "option_created_at?",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 15,+ "name": "option_updated_at?",+ "type_info": "Timestamptz"+ }+ ],+ "parameters": {+ "Left": [+ "Int4",+ "Text",+ "Bool"+ ]+ },+ "nullable": [+ false,+ true,+ true,+ false,+ false,+ false,+ true,+ false,+ false,+ false,+ false,+ false,+ true,+ true,+ false,+ false+ ]+ },+ "hash": "b9570b07121de0df914dd0579cc92a5e92973cf114526f80dbe7ab714493090b"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-14085ed173f482f88d7b9c16f85091224dda2a444649cb14fe8b44ad183ed68a.json b/rust/cloud-storage/soup/.sqlx/query-be27b72f7077a2c90876e68ab617a2c6fc2d39f2c114ad027b7c0dec7f58502a.jsonsimilarity index 51%rename from rust/cloud-storage/soup/.sqlx/query-14085ed173f482f88d7b9c16f85091224dda2a444649cb14fe8b44ad183ed68a.jsonrename to rust/cloud-storage/soup/.sqlx/query-be27b72f7077a2c90876e68ab617a2c6fc2d39f2c114ad027b7c0dec7f58502a.jsonindex dfed5a2d67..afbfe2faca 100644--- a/rust/cloud-storage/soup/.sqlx/query-14085ed173f482f88d7b9c16f85091224dda2a444649cb14fe8b44ad183ed68a.json+++ b/rust/cloud-storage/soup/.sqlx/query-be27b72f7077a2c90876e68ab617a2c6fc2d39f2c114ad027b7c0dec7f58502a.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": " \n WITH RECURSIVE ProjectHierarchy AS (\n SELECT p.id, uia.access_level \n FROM \"Project\" p\n JOIN \"UserItemAccess\" uia ON p.id = uia.item_id AND uia.item_type = 'project'\n WHERE uia.user_id = $1 AND p.\"deletedAt\" IS NULL\n UNION ALL\n SELECT p.id, ph.access_level\n FROM \"Project\" p \n JOIN ProjectHierarchy ph ON p.\"parentId\" = ph.id\n WHERE p.\"deletedAt\" IS NULL\n ),\n AllAccessGrants AS (\n SELECT item_id, item_type, access_level \n FROM \"UserItemAccess\" \n WHERE user_id = $1\n UNION ALL\n SELECT d.id AS item_id, 'document' AS item_type, ph.access_level\n FROM \"Document\" d \n JOIN ProjectHierarchy ph ON d.\"projectId\" = ph.id\n WHERE d.\"projectId\" IS NOT NULL AND d.\"deletedAt\" IS NULL\n UNION ALL\n SELECT c.id AS item_id, 'chat' AS item_type, ph.access_level\n FROM \"Chat\" c \n JOIN ProjectHierarchy ph ON c.\"projectId\" = ph.id\n WHERE c.\"projectId\" IS NOT NULL AND c.\"deletedAt\" IS NULL\n UNION ALL\n SELECT ph.id AS item_id, 'project' AS item_type, ph.access_level \n FROM ProjectHierarchy ph\n ),\n UserAccessibleItems AS (\n SELECT DISTINCT ON (item_id, item_type) item_id, item_type\n FROM AllAccessGrants\n ORDER BY item_id, item_type, \n CASE access_level\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", d.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN d.\"createdAt\"\n ELSE d.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n CASE \n WHEN dt.sub_type = 'task' \n AND ep_status.values->'value' ? $6\n THEN true \n WHEN dt.sub_type = 'task'\n THEN false\n ELSE NULL \n END as \"is_completed\"\n FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN entity_properties ep_status \n ON dt.sub_type = 'task'\n AND ep_status.entity_id = d.id \n AND ep_status.entity_type = 'TASK'\n AND ep_status.property_definition_id = $7\n INNER JOIN UserAccessibleItems uai ON uai.item_id = d.id AND uai.item_type = 'document'\n -- This MUST be a LEFT JOIN to support all three sort methods\n LEFT JOIN \"UserHistory\" uh ON uh.\"itemId\" = d.id AND uh.\"itemType\" = 'document' AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", c.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN c.\"createdAt\"\n ELSE c.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai ON uai.item_id = c.id AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh ON uh.\"itemId\" = c.id AND uh.\"itemType\" = 'chat' AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n\n UNION ALL\n\n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", p.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN p.\"createdAt\"\n ELSE p.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\"\n FROM \"Project\" p\n INNER JOIN UserAccessibleItems uai\n ON uai.item_id = p.id\n AND uai.item_type = 'project'\n LEFT JOIN \"UserHistory\" uh\n ON uh.\"itemId\" = p.id\n AND uh.\"itemType\" = 'project'\n AND uh.\"userId\" = $1\n WHERE p.\"deletedAt\" IS NULL\n )\n SELECT Combined.* FROM Combined\n LEFT JOIN frecency_aggregates fa\n ON fa.entity_id = Combined.\"id!\"\n AND fa.entity_type = Combined.\"item_type!\"\n AND fa.user_id = $1\n WHERE fa.id IS NULL\n AND (\n ($4::timestamptz IS NULL)\n OR\n (Combined.\"sort_ts!\", Combined.\"id!\"::text) < ($4, $5)\n )\n ORDER BY Combined.\"sort_ts!\" DESC, Combined.\"updated_at!\" DESC\n LIMIT $3\n ",+ "query": " \n WITH RECURSIVE ProjectHierarchy AS (\n SELECT p.id, uia.access_level \n FROM \"Project\" p\n JOIN \"UserItemAccess\" uia ON p.id = uia.item_id AND uia.item_type = 'project'\n WHERE uia.user_id = $1 AND p.\"deletedAt\" IS NULL\n UNION ALL\n SELECT p.id, ph.access_level\n FROM \"Project\" p \n JOIN ProjectHierarchy ph ON p.\"parentId\" = ph.id\n WHERE p.\"deletedAt\" IS NULL\n ),\n AllAccessGrants AS (\n SELECT item_id, item_type, access_level \n FROM \"UserItemAccess\" \n WHERE user_id = $1\n UNION ALL\n SELECT d.id AS item_id, 'document' AS item_type, ph.access_level\n FROM \"Document\" d \n JOIN ProjectHierarchy ph ON d.\"projectId\" = ph.id\n WHERE d.\"projectId\" IS NOT NULL AND d.\"deletedAt\" IS NULL\n UNION ALL\n SELECT c.id AS item_id, 'chat' AS item_type, ph.access_level\n FROM \"Chat\" c \n JOIN ProjectHierarchy ph ON c.\"projectId\" = ph.id\n WHERE c.\"projectId\" IS NOT NULL AND c.\"deletedAt\" IS NULL\n UNION ALL\n SELECT ph.id AS item_id, 'project' AS item_type, ph.access_level \n FROM ProjectHierarchy ph\n ),\n UserAccessibleItems AS (\n SELECT DISTINCT ON (item_id, item_type) item_id, item_type\n FROM AllAccessGrants\n ORDER BY item_id, item_type, \n CASE access_level\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", d.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN d.\"createdAt\"\n ELSE d.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n CASE\n WHEN dt.sub_type = 'task'\n AND ep_status.values->'value' ? $6\n THEN true\n WHEN dt.sub_type = 'task'\n THEN false\n ELSE NULL\n END as \"is_completed\",\n d.\"deletedAt\"::timestamptz as \"deleted_at\"\n FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN entity_properties ep_status\n ON dt.sub_type = 'task'\n AND ep_status.entity_id = d.id\n AND ep_status.entity_type = 'TASK'\n AND ep_status.property_definition_id = $7\n INNER JOIN UserAccessibleItems uai ON uai.item_id = d.id AND uai.item_type = 'document'\n -- This MUST be a LEFT JOIN to support all three sort methods\n LEFT JOIN \"UserHistory\" uh ON uh.\"itemId\" = d.id AND uh.\"itemType\" = 'document' AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id\n FROM \"DocumentBom\" b\n WHERE b.\"documentId\" = d.id\n ORDER BY b.\"createdAt\" DESC\n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha\n FROM \"DocumentInstance\" i\n WHERE i.\"documentId\" = d.id\n ORDER BY i.\"updatedAt\" DESC\n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n\n UNION ALL\n\n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", c.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN c.\"createdAt\"\n ELSE c.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\",\n c.\"deletedAt\"::timestamptz as \"deleted_at\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai ON uai.item_id = c.id AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh ON uh.\"itemId\" = c.id AND uh.\"itemType\" = 'chat' AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n\n UNION ALL\n\n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", p.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN p.\"createdAt\"\n ELSE p.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\",\n p.\"deletedAt\"::timestamptz as \"deleted_at\"\n FROM \"Project\" p\n INNER JOIN UserAccessibleItems uai\n ON uai.item_id = p.id\n AND uai.item_type = 'project'\n LEFT JOIN \"UserHistory\" uh\n ON uh.\"itemId\" = p.id\n AND uh.\"itemType\" = 'project'\n AND uh.\"userId\" = $1\n WHERE p.\"deletedAt\" IS NULL\n )\n SELECT * FROM Combined\n WHERE\n ($4::timestamptz IS NULL)\n OR\n (\"sort_ts!\", \"id!\"::text) < ($4, $5)\n ORDER BY \"sort_ts!\" DESC, \"updated_at!\" DESC\n LIMIT $3\n","describe": {"columns": [{@@ -101,6 +101,11 @@"ordinal": 17,"name": "is_completed","type_info": "Bool"+ },+ {+ "ordinal": 18,+ "name": "deleted_at",+ "type_info": "Timestamptz"}],"parameters": {@@ -132,8 +137,9 @@null,null,null,+ null,null]},- "hash": "14085ed173f482f88d7b9c16f85091224dda2a444649cb14fe8b44ad183ed68a"+ "hash": "be27b72f7077a2c90876e68ab617a2c6fc2d39f2c114ad027b7c0dec7f58502a"}diff --git a/rust/cloud-storage/soup/.sqlx/query-c12b511f8fbe853ce8e5489db2468ee8a07030cb234bc0a10bc014c493b8e9c2.json b/rust/cloud-storage/soup/.sqlx/query-c12b511f8fbe853ce8e5489db2468ee8a07030cb234bc0a10bc014c493b8e9c2.jsonnew file mode 100644index 0000000000..e2aa061544--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-c12b511f8fbe853ce8e5489db2468ee8a07030cb234bc0a10bc014c493b8e9c2.json@@ -0,0 +1,31 @@+{+ "db_name": "PostgreSQL",+ "query": "DELETE FROM entity_properties WHERE entity_id = $1 AND entity_type = $2",+ "describe": {+ "columns": [],+ "parameters": {+ "Left": [+ "Text",+ {+ "Custom": {+ "name": "property_entity_type",+ "kind": {+ "Enum": [+ "CHANNEL",+ "CHAT",+ "DOCUMENT",+ "PROJECT",+ "THREAD",+ "USER",+ "COMPANY",+ "TASK"+ ]+ }+ }+ }+ ]+ },+ "nullable": []+ },+ "hash": "c12b511f8fbe853ce8e5489db2468ee8a07030cb234bc0a10bc014c493b8e9c2"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-c6f8bb6a2a9cda820cf54efb5e4ff8b048d735cfcc23716612f2ee66a8c7151c.json b/rust/cloud-storage/soup/.sqlx/query-c6f8bb6a2a9cda820cf54efb5e4ff8b048d735cfcc23716612f2ee66a8c7151c.jsonnew file mode 100644index 0000000000..c6b12842de--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-c6f8bb6a2a9cda820cf54efb5e4ff8b048d735cfcc23716612f2ee66a8c7151c.json@@ -0,0 +1,14 @@+{+ "db_name": "PostgreSQL",+ "query": "DELETE FROM property_options WHERE id = $1",+ "describe": {+ "columns": [],+ "parameters": {+ "Left": [+ "Uuid"+ ]+ },+ "nullable": []+ },+ "hash": "c6f8bb6a2a9cda820cf54efb5e4ff8b048d735cfcc23716612f2ee66a8c7151c"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-dc836e7dd12a3df4a05ba072af32cb1aca7d6b8c20e636adff6fb3977577e62a.json b/rust/cloud-storage/soup/.sqlx/query-dc836e7dd12a3df4a05ba072af32cb1aca7d6b8c20e636adff6fb3977577e62a.jsonnew file mode 100644index 0000000000..2ce75f867a--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-dc836e7dd12a3df4a05ba072af32cb1aca7d6b8c20e636adff6fb3977577e62a.json@@ -0,0 +1,52 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT\n t.id,\n t.latest_inbound_message_ts as last_received,\n t.latest_outbound_message_ts as last_sent,\n first_msg.internal_date_ts as thread_started,\n first_msg.subject,\n (SELECT COUNT(*)::bigint FROM email_messages WHERE thread_id = t.id) as \"message_count!\"\n FROM\n email_threads t\n -- LATERAL join to get subject and timestamp from the first message\n LEFT JOIN LATERAL (\n SELECT internal_date_ts, subject\n FROM email_messages\n WHERE thread_id = t.id\n ORDER BY internal_date_ts ASC NULLS LAST\n LIMIT 1\n ) first_msg ON true\n WHERE\n t.id = $1\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 1,+ "name": "last_received",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 2,+ "name": "last_sent",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 3,+ "name": "thread_started",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 4,+ "name": "subject",+ "type_info": "Text"+ },+ {+ "ordinal": 5,+ "name": "message_count!",+ "type_info": "Int8"+ }+ ],+ "parameters": {+ "Left": [+ "Uuid"+ ]+ },+ "nullable": [+ false,+ true,+ true,+ true,+ true,+ null+ ]+ },+ "hash": "dc836e7dd12a3df4a05ba072af32cb1aca7d6b8c20e636adff6fb3977577e62a"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-e0b90388e3a9f7dbd1e6586cb0633b0d2d39d64dcc88a0f0c5cd310303e7dc92.json b/rust/cloud-storage/soup/.sqlx/query-e0b90388e3a9f7dbd1e6586cb0633b0d2d39d64dcc88a0f0c5cd310303e7dc92.jsonnew file mode 100644index 0000000000..a6d8c54236--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-e0b90388e3a9f7dbd1e6586cb0633b0d2d39d64dcc88a0f0c5cd310303e7dc92.json@@ -0,0 +1,140 @@+{+ "db_name": "PostgreSQL",+ "query": "\n INSERT INTO property_definitions (\n id,\n organization_id, \n user_id, \n display_name, \n data_type, \n is_multi_select,\n specific_entity_type\n )\n VALUES ($1, $2, $3, $4, $5, $6, $7)\n RETURNING \n id,\n organization_id,\n user_id,\n display_name,\n data_type as \"data_type: DataType\",\n is_multi_select,\n specific_entity_type as \"specific_entity_type: Option<EntityType>\",\n created_at,\n updated_at\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 1,+ "name": "organization_id",+ "type_info": "Int4"+ },+ {+ "ordinal": 2,+ "name": "user_id",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "display_name",+ "type_info": "Text"+ },+ {+ "ordinal": 4,+ "name": "data_type: DataType",+ "type_info": {+ "Custom": {+ "name": "property_data_type",+ "kind": {+ "Enum": [+ "BOOLEAN",+ "DATE",+ "NUMBER",+ "STRING",+ "SELECT_NUMBER",+ "SELECT_STRING",+ "ENTITY",+ "LINK"+ ]+ }+ }+ }+ },+ {+ "ordinal": 5,+ "name": "is_multi_select",+ "type_info": "Bool"+ },+ {+ "ordinal": 6,+ "name": "specific_entity_type: Option<EntityType>",+ "type_info": {+ "Custom": {+ "name": "property_entity_type",+ "kind": {+ "Enum": [+ "CHANNEL",+ "CHAT",+ "DOCUMENT",+ "PROJECT",+ "THREAD",+ "USER",+ "COMPANY",+ "TASK"+ ]+ }+ }+ }+ },+ {+ "ordinal": 7,+ "name": "created_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 8,+ "name": "updated_at",+ "type_info": "Timestamptz"+ }+ ],+ "parameters": {+ "Left": [+ "Uuid",+ "Int4",+ "Text",+ "Text",+ {+ "Custom": {+ "name": "property_data_type",+ "kind": {+ "Enum": [+ "BOOLEAN",+ "DATE",+ "NUMBER",+ "STRING",+ "SELECT_NUMBER",+ "SELECT_STRING",+ "ENTITY",+ "LINK"+ ]+ }+ }+ },+ "Bool",+ {+ "Custom": {+ "name": "property_entity_type",+ "kind": {+ "Enum": [+ "CHANNEL",+ "CHAT",+ "DOCUMENT",+ "PROJECT",+ "THREAD",+ "USER",+ "COMPANY",+ "TASK"+ ]+ }+ }+ }+ ]+ },+ "nullable": [+ false,+ true,+ true,+ false,+ false,+ false,+ true,+ false,+ false+ ]+ },+ "hash": "e0b90388e3a9f7dbd1e6586cb0633b0d2d39d64dcc88a0f0c5cd310303e7dc92"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-e3502d4611d734fa9d27c17c3adb0785d06317da255894345de287a654f24fc3.json b/rust/cloud-storage/soup/.sqlx/query-e3502d4611d734fa9d27c17c3adb0785d06317da255894345de287a654f24fc3.jsonnew file mode 100644index 0000000000..1bb390dc5d--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-e3502d4611d734fa9d27c17c3adb0785d06317da255894345de287a654f24fc3.json@@ -0,0 +1,14 @@+{+ "db_name": "PostgreSQL",+ "query": "DELETE FROM property_definitions WHERE id = $1",+ "describe": {+ "columns": [],+ "parameters": {+ "Left": [+ "Uuid"+ ]+ },+ "nullable": []+ },+ "hash": "e3502d4611d734fa9d27c17c3adb0785d06317da255894345de287a654f24fc3"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-e4f5c5a2a3a154e5b4be0cdce5d53199f09d18221d9ffd1e0bfd055b4d3da066.json b/rust/cloud-storage/soup/.sqlx/query-e4f5c5a2a3a154e5b4be0cdce5d53199f09d18221d9ffd1e0bfd055b4d3da066.jsondeleted file mode 100644index 01e3a90ccf..0000000000--- a/rust/cloud-storage/soup/.sqlx/query-e4f5c5a2a3a154e5b4be0cdce5d53199f09d18221d9ffd1e0bfd055b4d3da066.json+++ /dev/null@@ -1,139 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n WITH UserAccessibleItems AS (\n SELECT DISTINCT ON (\"item_id\", \"item_type\")\n \"item_id\",\n \"item_type\"\n FROM \"UserItemAccess\" \n WHERE \"user_id\" = $1\n ORDER BY \"item_id\", \"item_type\", \n CASE \"access_level\"\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\", \n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", d.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN d.\"createdAt\"\n ELSE d.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n CASE \n WHEN dt.sub_type = 'task' \n AND ep_status.values->'value' ? $6\n THEN true \n WHEN dt.sub_type = 'task'\n THEN false\n ELSE NULL \n END as \"is_completed\"\n FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN entity_properties ep_status \n ON dt.sub_type = 'task'\n AND ep_status.entity_id = d.id \n AND ep_status.entity_type = 'TASK'\n AND ep_status.property_definition_id = $7\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = d.id \n AND uai.item_type = 'document'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = d.id \n AND uh.\"itemType\" = 'document' \n AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n Select i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", c.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN c.\"createdAt\"\n ELSE c.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = c.id \n AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = c.id \n AND uh.\"itemType\" = 'chat' \n AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n \n UNION ALL\n \n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", p.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN p.\"createdAt\"\n ELSE p.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\"\n FROM \"Project\" p\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = p.id \n AND uai.item_type = 'project'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = p.id \n AND uh.\"itemType\" = 'project' \n AND uh.\"userId\" = $1\n WHERE p.\"deletedAt\" IS NULL\n )\n SELECT Combined.* FROM Combined\n LEFT JOIN frecency_aggregates fa\n ON fa.entity_id = Combined.\"id!\"\n AND fa.entity_type = Combined.\"item_type!\"\n AND fa.user_id = $1\n WHERE fa.id IS NULL\n AND (\n ($4::timestamptz IS NULL)\n OR\n (Combined.\"sort_ts!\", Combined.\"id!\") < ($4, $5)\n )\n ORDER BY Combined.\"sort_ts!\" DESC, Combined.\"updated_at!\" DESC\n LIMIT $3\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "item_type!",- "type_info": "Text"- },- {- "ordinal": 1,- "name": "id!",- "type_info": "Text"- },- {- "ordinal": 2,- "name": "document_version_id",- "type_info": "Text"- },- {- "ordinal": 3,- "name": "user_id!",- "type_info": "Text"- },- {- "ordinal": 4,- "name": "name!",- "type_info": "Text"- },- {- "ordinal": 5,- "name": "branched_from_id",- "type_info": "Text"- },- {- "ordinal": 6,- "name": "branched_from_version_id",- "type_info": "Int8"- },- {- "ordinal": 7,- "name": "document_family_id",- "type_info": "Int8"- },- {- "ordinal": 8,- "name": "file_type",- "type_info": "Text"- },- {- "ordinal": 9,- "name": "created_at!",- "type_info": "Timestamptz"- },- {- "ordinal": 10,- "name": "updated_at!",- "type_info": "Timestamptz"- },- {- "ordinal": 11,- "name": "project_id",- "type_info": "Text"- },- {- "ordinal": 12,- "name": "is_persistent",- "type_info": "Bool"- },- {- "ordinal": 13,- "name": "sha",- "type_info": "Text"- },- {- "ordinal": 14,- "name": "sub_type?: DocumentSubType",- "type_info": {- "Custom": {- "name": "document_sub_type_value",- "kind": {- "Enum": [- "task"- ]- }- }- }- },- {- "ordinal": 15,- "name": "viewed_at",- "type_info": "Timestamptz"- },- {- "ordinal": 16,- "name": "sort_ts!",- "type_info": "Timestamptz"- },- {- "ordinal": 17,- "name": "is_completed",- "type_info": "Bool"- }- ],- "parameters": {- "Left": [- "Text",- "Text",- "Int8",- "Timestamptz",- "Text",- "Text",- "Uuid"- ]- },- "nullable": [- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null- ]- },- "hash": "e4f5c5a2a3a154e5b4be0cdce5d53199f09d18221d9ffd1e0bfd055b4d3da066"-}diff --git a/rust/cloud-storage/soup/.sqlx/query-edce1ca1979c9bd7c42f7e89d80a8d25037d25951b1f406dddb8d62cc13f74f0.json b/rust/cloud-storage/soup/.sqlx/query-edce1ca1979c9bd7c42f7e89d80a8d25037d25951b1f406dddb8d62cc13f74f0.jsonnew file mode 100644index 0000000000..13653d45bf--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-edce1ca1979c9bd7c42f7e89d80a8d25037d25951b1f406dddb8d62cc13f74f0.json@@ -0,0 +1,185 @@+{+ "db_name": "PostgreSQL",+ "query": "\nSELECT\n ep.id as entity_property_id,\n ep.entity_id,\n ep.entity_type as \"entity_type: EntityType\",\n ep.property_definition_id,\n ep.values as \"values: sqlx::types::JsonValue\",\n ep.created_at as entity_property_created_at,\n ep.updated_at as entity_property_updated_at,\n pd.organization_id as definition_organization_id,\n pd.user_id as definition_user_id,\n pd.display_name,\n pd.data_type as \"data_type: DataType\",\n pd.is_multi_select,\n pd.specific_entity_type as \"specific_entity_type: Option<EntityType>\",\n pd.created_at as definition_created_at,\n pd.updated_at as definition_updated_at,\n pd.is_system as definition_is_system\nFROM entity_properties ep\nINNER JOIN property_definitions pd ON ep.property_definition_id = pd.id\nWHERE (ep.entity_id, ep.entity_type) IN (\n SELECT * FROM UNNEST($1::TEXT[], $2::property_entity_type[])\n)\nAND pd.id = ANY($3::UUID[])\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "entity_property_id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 1,+ "name": "entity_id",+ "type_info": "Text"+ },+ {+ "ordinal": 2,+ "name": "entity_type: EntityType",+ "type_info": {+ "Custom": {+ "name": "property_entity_type",+ "kind": {+ "Enum": [+ "CHANNEL",+ "CHAT",+ "DOCUMENT",+ "PROJECT",+ "THREAD",+ "USER",+ "COMPANY",+ "TASK"+ ]+ }+ }+ }+ },+ {+ "ordinal": 3,+ "name": "property_definition_id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 4,+ "name": "values: sqlx::types::JsonValue",+ "type_info": "Jsonb"+ },+ {+ "ordinal": 5,+ "name": "entity_property_created_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 6,+ "name": "entity_property_updated_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 7,+ "name": "definition_organization_id",+ "type_info": "Int4"+ },+ {+ "ordinal": 8,+ "name": "definition_user_id",+ "type_info": "Text"+ },+ {+ "ordinal": 9,+ "name": "display_name",+ "type_info": "Text"+ },+ {+ "ordinal": 10,+ "name": "data_type: DataType",+ "type_info": {+ "Custom": {+ "name": "property_data_type",+ "kind": {+ "Enum": [+ "BOOLEAN",+ "DATE",+ "NUMBER",+ "STRING",+ "SELECT_NUMBER",+ "SELECT_STRING",+ "ENTITY",+ "LINK"+ ]+ }+ }+ }+ },+ {+ "ordinal": 11,+ "name": "is_multi_select",+ "type_info": "Bool"+ },+ {+ "ordinal": 12,+ "name": "specific_entity_type: Option<EntityType>",+ "type_info": {+ "Custom": {+ "name": "property_entity_type",+ "kind": {+ "Enum": [+ "CHANNEL",+ "CHAT",+ "DOCUMENT",+ "PROJECT",+ "THREAD",+ "USER",+ "COMPANY",+ "TASK"+ ]+ }+ }+ }+ },+ {+ "ordinal": 13,+ "name": "definition_created_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 14,+ "name": "definition_updated_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 15,+ "name": "definition_is_system",+ "type_info": "Bool"+ }+ ],+ "parameters": {+ "Left": [+ "TextArray",+ {+ "Custom": {+ "name": "property_entity_type[]",+ "kind": {+ "Array": {+ "Custom": {+ "name": "property_entity_type",+ "kind": {+ "Enum": [+ "CHANNEL",+ "CHAT",+ "DOCUMENT",+ "PROJECT",+ "THREAD",+ "USER",+ "COMPANY",+ "TASK"+ ]+ }+ }+ }+ }+ }+ },+ "UuidArray"+ ]+ },+ "nullable": [+ false,+ false,+ false,+ false,+ true,+ false,+ false,+ true,+ true,+ false,+ false,+ false,+ true,+ false,+ false,+ false+ ]+ },+ "hash": "edce1ca1979c9bd7c42f7e89d80a8d25037d25951b1f406dddb8d62cc13f74f0"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-ffc5c6bdbf1439c09a27570cf67ce180d79d89950f58e96cc7ea62e5c5156439.json b/rust/cloud-storage/soup/.sqlx/query-ffc5c6bdbf1439c09a27570cf67ce180d79d89950f58e96cc7ea62e5c5156439.jsondeleted file mode 100644index 48607935f4..0000000000--- a/rust/cloud-storage/soup/.sqlx/query-ffc5c6bdbf1439c09a27570cf67ce180d79d89950f58e96cc7ea62e5c5156439.json+++ /dev/null@@ -1,138 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n WITH UserAccessibleItems AS (\n SELECT DISTINCT ON (\"item_id\", \"item_type\")\n \"item_id\",\n \"item_type\"\n FROM \"UserItemAccess\" \n WHERE \"user_id\" = $1\n ORDER BY \"item_id\", \"item_type\", \n CASE \"access_level\"\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\", \n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n d.\"updatedAt\"::timestamptz as \"sort_ts!\",\n CASE \n WHEN dt.sub_type = 'task' \n AND ep_status.values->'value' ? $5\n THEN true \n WHEN dt.sub_type = 'task'\n THEN false\n ELSE NULL \n END as \"is_completed\"\n FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN entity_properties ep_status \n ON dt.sub_type = 'task'\n AND ep_status.entity_id = d.id \n AND ep_status.entity_type = 'TASK'\n AND ep_status.property_definition_id = $6\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = d.id \n AND uai.item_type = 'document'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = d.id \n AND uh.\"itemType\" = 'document' \n AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n AND d.id = ANY($2::text[])\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n c.\"updatedAt\"::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = c.id \n AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = c.id \n AND uh.\"itemType\" = 'chat' \n AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n AND c.id = ANY($3::text[])\n \n UNION ALL\n \n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n p.\"updatedAt\"::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\"\n FROM \"Project\" p\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = p.id \n AND uai.item_type = 'project'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = p.id \n AND uh.\"itemType\" = 'project' \n AND uh.\"userId\" = $1\n WHERE p.\"deletedAt\" IS NULL\n AND p.id = ANY($4::text[])\n )\n SELECT * \n FROM Combined\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "item_type!",- "type_info": "Text"- },- {- "ordinal": 1,- "name": "id!",- "type_info": "Text"- },- {- "ordinal": 2,- "name": "document_version_id",- "type_info": "Text"- },- {- "ordinal": 3,- "name": "user_id!",- "type_info": "Text"- },- {- "ordinal": 4,- "name": "name!",- "type_info": "Text"- },- {- "ordinal": 5,- "name": "branched_from_id",- "type_info": "Text"- },- {- "ordinal": 6,- "name": "branched_from_version_id",- "type_info": "Int8"- },- {- "ordinal": 7,- "name": "document_family_id",- "type_info": "Int8"- },- {- "ordinal": 8,- "name": "file_type",- "type_info": "Text"- },- {- "ordinal": 9,- "name": "created_at!",- "type_info": "Timestamptz"- },- {- "ordinal": 10,- "name": "updated_at!",- "type_info": "Timestamptz"- },- {- "ordinal": 11,- "name": "project_id",- "type_info": "Text"- },- {- "ordinal": 12,- "name": "is_persistent",- "type_info": "Bool"- },- {- "ordinal": 13,- "name": "sha",- "type_info": "Text"- },- {- "ordinal": 14,- "name": "sub_type?: DocumentSubType",- "type_info": {- "Custom": {- "name": "document_sub_type_value",- "kind": {- "Enum": [- "task"- ]- }- }- }- },- {- "ordinal": 15,- "name": "viewed_at",- "type_info": "Timestamptz"- },- {- "ordinal": 16,- "name": "sort_ts!",- "type_info": "Timestamptz"- },- {- "ordinal": 17,- "name": "is_completed",- "type_info": "Bool"- }- ],- "parameters": {- "Left": [- "Text",- "TextArray",- "TextArray",- "TextArray",- "Text",- "Uuid"- ]- },- "nullable": [- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null- ]- },- "hash": "ffc5c6bdbf1439c09a27570cf67ce180d79d89950f58e96cc7ea62e5c5156439"-}diff --git a/rust/cloud-storage/soup/src/domain/service/tests.rs b/rust/cloud-storage/soup/src/domain/service/tests.rsindex f8b38f6f00..915c2b5d4b 100644--- a/rust/cloud-storage/soup/src/domain/service/tests.rs+++ b/rust/cloud-storage/soup/src/domain/service/tests.rs@@ -125,6 +125,7 @@ fn soup_document_with_is_completed(viewed_at: Default::default(),sub_type: is_completed.map(|is_completed| SoupDocumentSubType::Task { is_completed }),properties: Default::default(),+ deleted_at: None,}}diff --git a/rust/cloud-storage/soup/src/outbound/pg_soup_repo.rs b/rust/cloud-storage/soup/src/outbound/pg_soup_repo.rsindex 3143809b5a..aaeb2b7a95 100644--- a/rust/cloud-storage/soup/src/outbound/pg_soup_repo.rs+++ b/rust/cloud-storage/soup/src/outbound/pg_soup_repo.rs@@ -230,6 +230,7 @@ macro_rules! map_soup_type {r.sub_type,r.is_completed,),+ deleted_at: r.deleted_at,properties: Default::default(),},)),@@ -250,6 +251,7 @@ macro_rules! map_soup_type {created_at: r.created_at,updated_at: r.updated_at,viewed_at: r.viewed_at,+ deleted_at: r.deleted_at,properties: Default::default(),},)),@@ -269,6 +271,7 @@ macro_rules! map_soup_type {created_at: r.created_at,updated_at: r.updated_at,viewed_at: r.viewed_at,+ deleted_at: r.deleted_at,properties: Default::default(),},)),diff --git a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/by_cursor.rs b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/by_cursor.rsindex b4e7eb96a7..cf6b3b7b24 100644--- a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/by_cursor.rs+++ b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/by_cursor.rs@@ -99,42 +99,43 @@ r#"WHEN 'created_at' THEN d."createdAt"ELSE d."updatedAt"END::timestamptz as "sort_ts!",- CASE- WHEN dt.sub_type = 'task'+ CASE+ WHEN dt.sub_type = 'task'AND ep_status.values->'value' ? $6- THEN true+ THEN trueWHEN dt.sub_type = 'task'THEN false- ELSE NULL- END as "is_completed"+ ELSE NULL+ END as "is_completed",+ d."deletedAt"::timestamptz as "deleted_at"FROM "Document" dLEFT JOIN document_sub_type dt ON dt.document_id = d.id- LEFT JOIN entity_properties ep_status+ LEFT JOIN entity_properties ep_statusON dt.sub_type = 'task'- AND ep_status.entity_id = d.id+ AND ep_status.entity_id = d.idAND ep_status.entity_type = 'TASK'AND ep_status.property_definition_id = $7INNER JOIN UserAccessibleItems uai ON uai.item_id = d.id AND uai.item_type = 'document'-- This MUST be a LEFT JOIN to support all three sort methodsLEFT JOIN "UserHistory" uh ON uh."itemId" = d.id AND uh."itemType" = 'document' AND uh."userId" = $1LEFT JOIN LATERAL (- SELECT b.id- FROM "DocumentBom" b- WHERE b."documentId" = d.id- ORDER BY b."createdAt" DESC+ SELECT b.id+ FROM "DocumentBom" b+ WHERE b."documentId" = d.id+ ORDER BY b."createdAt" DESCLIMIT 1) db ON trueLEFT JOIN LATERAL (- SELECT i.id, i.sha- FROM "DocumentInstance" i- WHERE i."documentId" = d.id- ORDER BY i."updatedAt" DESC+ SELECT i.id, i.sha+ FROM "DocumentInstance" i+ WHERE i."documentId" = d.id+ ORDER BY i."updatedAt" DESCLIMIT 1) di ON trueWHERE d."deletedAt" IS NULLUNION ALL-+SELECT'chat' as "item_type!",c.id as "id!",@@ -158,7 +159,8 @@ r#"WHEN 'created_at' THEN c."createdAt"ELSE c."updatedAt"END::timestamptz as "sort_ts!",- NULL as "is_completed"+ NULL as "is_completed",+ c."deletedAt"::timestamptz as "deleted_at"FROM "Chat" cINNER JOIN UserAccessibleItems uai ON uai.item_id = c.id AND uai.item_type = 'chat'LEFT JOIN "UserHistory" uh ON uh."itemId" = c.id AND uh."itemType" = 'chat' AND uh."userId" = $1@@ -189,7 +191,8 @@ r#"WHEN 'created_at' THEN p."createdAt"ELSE p."updatedAt"END::timestamptz as "sort_ts!",- NULL as "is_completed"+ NULL as "is_completed",+ p."deletedAt"::timestamptz as "deleted_at"FROM "Project" pINNER JOIN UserAccessibleItems uaiON uai.item_id = p.id@@ -309,42 +312,43 @@ r#"WHEN 'created_at' THEN d."createdAt"ELSE d."updatedAt"END::timestamptz as "sort_ts!",- CASE- WHEN dt.sub_type = 'task'+ CASE+ WHEN dt.sub_type = 'task'AND ep_status.values->'value' ? $6- THEN true+ THEN trueWHEN dt.sub_type = 'task'THEN false- ELSE NULL- END as "is_completed"+ ELSE NULL+ END as "is_completed",+ d."deletedAt"::timestamptz as "deleted_at"FROM "Document" dLEFT JOIN document_sub_type dt ON dt.document_id = d.id- LEFT JOIN entity_properties ep_status+ LEFT JOIN entity_properties ep_statusON dt.sub_type = 'task'- AND ep_status.entity_id = d.id+ AND ep_status.entity_id = d.idAND ep_status.entity_type = 'TASK'AND ep_status.property_definition_id = $7INNER JOIN UserAccessibleItems uai ON uai.item_id = d.id AND uai.item_type = 'document'-- This MUST be a LEFT JOIN to support all three sort methodsLEFT JOIN "UserHistory" uh ON uh."itemId" = d.id AND uh."itemType" = 'document' AND uh."userId" = $1LEFT JOIN LATERAL (- SELECT b.id- FROM "DocumentBom" b- WHERE b."documentId" = d.id- ORDER BY b."createdAt" DESC+ SELECT b.id+ FROM "DocumentBom" b+ WHERE b."documentId" = d.id+ ORDER BY b."createdAt" DESCLIMIT 1) db ON trueLEFT JOIN LATERAL (- SELECT i.id, i.sha- FROM "DocumentInstance" i- WHERE i."documentId" = d.id- ORDER BY i."updatedAt" DESC+ SELECT i.id, i.sha+ FROM "DocumentInstance" i+ WHERE i."documentId" = d.id+ ORDER BY i."updatedAt" DESCLIMIT 1) di ON trueWHERE d."deletedAt" IS NULLUNION ALL-+SELECT'chat' as "item_type!",c.id as "id!",@@ -368,7 +372,8 @@ r#"WHEN 'created_at' THEN c."createdAt"ELSE c."updatedAt"END::timestamptz as "sort_ts!",- NULL as "is_completed"+ NULL as "is_completed",+ c."deletedAt"::timestamptz as "deleted_at"FROM "Chat" cINNER JOIN UserAccessibleItems uai ON uai.item_id = c.id AND uai.item_type = 'chat'LEFT JOIN "UserHistory" uh ON uh."itemId" = c.id AND uh."itemType" = 'chat' AND uh."userId" = $1@@ -399,7 +404,8 @@ r#"WHEN 'created_at' THEN p."createdAt"ELSE p."updatedAt"END::timestamptz as "sort_ts!",- NULL as "is_completed"+ NULL as "is_completed",+ p."deletedAt"::timestamptz as "deleted_at"FROM "Project" pINNER JOIN UserAccessibleItems uaiON uai.item_id = p.iddiff --git a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/by_ids.rs b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/by_ids.rsindex d1f0bf9b5d..f7a68c507d 100644--- a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/by_ids.rs+++ b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/by_ids.rs@@ -101,14 +101,15 @@ pub async fn expanded_soup_by_ids<'a>(di.sha as "sha",dt.sub_type as "sub_type?: DocumentSubType",uh."updatedAt"::timestamptz as "viewed_at",- CASE- WHEN dt.sub_type = 'task'+ CASE+ WHEN dt.sub_type = 'task'AND ep_status.values->'value' ? $4- THEN true+ THEN trueWHEN dt.sub_type = 'task'THEN false- ELSE NULL- END as "is_completed"+ ELSE NULL+ END as "is_completed",+ d."deletedAt"::timestamptz as "deleted_at"FROM "Document" dLEFT JOIN document_sub_type dt ON dt.document_id = d.idLEFT JOIN entity_properties ep_status@@ -159,14 +160,15 @@ pub async fn expanded_soup_by_ids<'a>(NULL as "sha",NULL as "sub_type",uh."updatedAt"::timestamptz as "viewed_at",- NULL as "is_completed"+ NULL as "is_completed",+ c."deletedAt"::timestamptz as "deleted_at"FROM "Chat" c- INNER JOIN UserAccessibleItems uai- ON uai.item_id = c.id+ INNER JOIN UserAccessibleItems uai+ ON uai.item_id = c.idAND uai.item_type = 'chat'- LEFT JOIN "UserHistory" uh- ON uh."itemId" = c.id- AND uh."itemType" = 'chat'+ LEFT JOIN "UserHistory" uh+ ON uh."itemId" = c.id+ AND uh."itemType" = 'chat'AND uh."userId" = $1WHERE c."deletedAt" IS NULLAND c.id = ANY($3::text[])diff --git a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/dynamic.rs b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/dynamic.rsindex f34992d030..2140bd9fab 100644--- a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/dynamic.rs+++ b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/dynamic.rs@@ -92,14 +92,15 @@ static DOCUMENT_CLAUSE: &str = r#"WHEN 'created_at' THEN d."createdAt"ELSE d."updatedAt"END::timestamptz as "sort_ts",- CASE- WHEN dt.sub_type = 'task'+ CASE+ WHEN dt.sub_type = 'task'AND ep_status.values->'value' ? $6- THEN true+ THEN trueWHEN dt.sub_type = 'task'THEN false- ELSE NULL- END as "is_completed"+ ELSE NULL+ END as "is_completed",+ d."deletedAt"::timestamptz as "deleted_at"FROM "Document" dLEFT JOIN document_sub_type dt ON dt.document_id = d.idLEFT JOIN entity_properties ep_status@@ -151,7 +152,8 @@ static CHAT_CLAUSE: &str = r#"WHEN 'created_at' THEN c."createdAt"ELSE c."updatedAt"END::timestamptz as "sort_ts",- NULL as "is_completed"+ NULL as "is_completed",+ c."deletedAt"::timestamptz as "deleted_at"FROM "Chat" cINNER JOIN UserAccessibleItems uai ON uai.item_id = c.id AND uai.item_type = 'chat'LEFT JOIN "UserHistory" uh ON uh."itemId" = c.id AND uh."itemType" = 'chat' AND uh."userId" = $1@@ -182,7 +184,8 @@ static PROJECT_CLAUSE: &str = r#"WHEN 'created_at' THEN p."createdAt"ELSE p."updatedAt"END::timestamptz as "sort_ts",- NULL as "is_completed"+ NULL as "is_completed",+ p."deletedAt"::timestamptz as "deleted_at"FROM "Project" pINNER JOIN UserAccessibleItems uaiON uai.item_id = p.id@@ -335,6 +338,7 @@ struct DocumentRow {viewed_at: Option<DateTime<Utc>>,sub_type: Option<DocumentSubType>,is_completed: Option<bool>,+ deleted_at: Option<DateTime<Utc>>,}#[derive(Debug, FromRow)]@@ -348,6 +352,7 @@ struct ChatRow {created_at: DateTime<Utc>,updated_at: DateTime<Utc>,viewed_at: Option<DateTime<Utc>>,+ deleted_at: Option<DateTime<Utc>>,}#[derive(Debug, FromRow)]@@ -359,6 +364,7 @@ struct ProjectRow {created_at: DateTime<Utc>,updated_at: DateTime<Utc>,viewed_at: Option<DateTime<Utc>>,+ deleted_at: Option<DateTime<Utc>>,}#[derive(Debug)]@@ -401,6 +407,7 @@ impl SoupRow {viewed_at,sub_type,is_completed,+ deleted_at,}) => SoupItem::Document(SoupDocument {id: Uuid::parse_str(&id).map_err(type_err)?,document_version_id: document_version_id@@ -428,6 +435,7 @@ impl SoupRow {updated_at,viewed_at,sub_type: SoupDocumentSubType::from_db(sub_type, is_completed),+ deleted_at,properties: Default::default(),}),SoupRow::Chat(ChatRow {@@ -439,6 +447,7 @@ impl SoupRow {created_at,updated_at,viewed_at,+ deleted_at,}) => SoupItem::Chat(SoupChat {id: Uuid::parse_str(&id).map_err(type_err)?,name,@@ -454,6 +463,7 @@ impl SoupRow {created_at,updated_at,viewed_at,+ deleted_at,properties: Default::default(),}),SoupRow::Project(ProjectRow {@@ -464,6 +474,7 @@ impl SoupRow {created_at,updated_at,viewed_at,+ deleted_at,}) => SoupItem::Project(SoupProject {id: Uuid::parse_str(&id).map_err(type_err)?,name,@@ -478,6 +489,7 @@ impl SoupRow {created_at,updated_at,viewed_at,+ deleted_at,properties: Default::default(),}),})diff --git a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/unexpanded/by_cursor.rs b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/unexpanded/by_cursor.rsindex 1ffb55daf1..f878a30ef8 100644--- a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/unexpanded/by_cursor.rs+++ b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/unexpanded/by_cursor.rs@@ -74,46 +74,47 @@ pub async fn unexpanded_generic_cursor_soup(WHEN 'created_at' THEN d."createdAt"ELSE d."updatedAt"END::timestamptz as "sort_ts!",- CASE- WHEN dt.sub_type = 'task'+ CASE+ WHEN dt.sub_type = 'task'AND ep_status.values->'value' ? $6- THEN true+ THEN trueWHEN dt.sub_type = 'task'THEN false- ELSE NULL- END as "is_completed"+ ELSE NULL+ END as "is_completed",+ d."deletedAt"::timestamptz as "deleted_at"FROM "Document" dLEFT JOIN document_sub_type dt ON dt.document_id = d.id- LEFT JOIN entity_properties ep_status+ LEFT JOIN entity_properties ep_statusON dt.sub_type = 'task'- AND ep_status.entity_id = d.id+ AND ep_status.entity_id = d.idAND ep_status.entity_type = 'TASK'AND ep_status.property_definition_id = $7- INNER JOIN UserAccessibleItems uai- ON uai.item_id = d.id+ INNER JOIN UserAccessibleItems uai+ ON uai.item_id = d.idAND uai.item_type = 'document'- LEFT JOIN "UserHistory" uh- ON uh."itemId" = d.id- AND uh."itemType" = 'document'+ LEFT JOIN "UserHistory" uh+ ON uh."itemId" = d.id+ AND uh."itemType" = 'document'AND uh."userId" = $1LEFT JOIN LATERAL (- SELECT b.id- FROM "DocumentBom" b- WHERE b."documentId" = d.id- ORDER BY b."createdAt" DESC+ SELECT b.id+ FROM "DocumentBom" b+ WHERE b."documentId" = d.id+ ORDER BY b."createdAt" DESCLIMIT 1) db ON trueLEFT JOIN LATERAL (- SELECT i.id, i.sha- FROM "DocumentInstance" i- WHERE i."documentId" = d.id- ORDER BY i."updatedAt" DESC+ SELECT i.id, i.sha+ FROM "DocumentInstance" i+ WHERE i."documentId" = d.id+ ORDER BY i."updatedAt" DESCLIMIT 1) di ON trueWHERE d."deletedAt" IS NULLUNION ALL-+SELECT'chat' as "item_type!",c.id as "id!",@@ -137,19 +138,20 @@ pub async fn unexpanded_generic_cursor_soup(WHEN 'created_at' THEN c."createdAt"ELSE c."updatedAt"END::timestamptz as "sort_ts!",- NULL as "is_completed"+ NULL as "is_completed",+ c."deletedAt"::timestamptz as "deleted_at"FROM "Chat" c- INNER JOIN UserAccessibleItems uai- ON uai.item_id = c.id+ INNER JOIN UserAccessibleItems uai+ ON uai.item_id = c.idAND uai.item_type = 'chat'- LEFT JOIN "UserHistory" uh- ON uh."itemId" = c.id- AND uh."itemType" = 'chat'+ LEFT JOIN "UserHistory" uh+ ON uh."itemId" = c.id+ AND uh."itemType" = 'chat'AND uh."userId" = $1WHERE c."deletedAt" IS NULL-+UNION ALL-+SELECT'project' as "item_type!",p.id as "id!",@@ -173,14 +175,15 @@ pub async fn unexpanded_generic_cursor_soup(WHEN 'created_at' THEN p."createdAt"ELSE p."updatedAt"END::timestamptz as "sort_ts!",- NULL as "is_completed"+ NULL as "is_completed",+ p."deletedAt"::timestamptz as "deleted_at"FROM "Project" p- INNER JOIN UserAccessibleItems uai- ON uai.item_id = p.id+ INNER JOIN UserAccessibleItems uai+ ON uai.item_id = p.idAND uai.item_type = 'project'- LEFT JOIN "UserHistory" uh- ON uh."itemId" = p.id- AND uh."itemType" = 'project'+ LEFT JOIN "UserHistory" uh+ ON uh."itemId" = p.id+ AND uh."itemType" = 'project'AND uh."userId" = $1WHERE p."deletedAt" IS NULL)diff --git a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/unexpanded/by_ids.rs b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/unexpanded/by_ids.rsindex e2d2c2166f..e5e954565d 100644--- a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/unexpanded/by_ids.rs+++ b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/unexpanded/by_ids.rs@@ -77,47 +77,48 @@ pub async fn unexpanded_soup_by_ids<'a>(dt.sub_type as "sub_type?: DocumentSubType",uh."updatedAt"::timestamptz as "viewed_at",d."updatedAt"::timestamptz as "sort_ts!",- CASE- WHEN dt.sub_type = 'task'+ CASE+ WHEN dt.sub_type = 'task'AND ep_status.values->'value' ? $5- THEN true+ THEN trueWHEN dt.sub_type = 'task'THEN false- ELSE NULL- END as "is_completed"+ ELSE NULL+ END as "is_completed",+ d."deletedAt"::timestamptz as "deleted_at"FROM "Document" dLEFT JOIN document_sub_type dt ON dt.document_id = d.id- LEFT JOIN entity_properties ep_status+ LEFT JOIN entity_properties ep_statusON dt.sub_type = 'task'- AND ep_status.entity_id = d.id+ AND ep_status.entity_id = d.idAND ep_status.entity_type = 'TASK'AND ep_status.property_definition_id = $6- INNER JOIN UserAccessibleItems uai- ON uai.item_id = d.id+ INNER JOIN UserAccessibleItems uai+ ON uai.item_id = d.idAND uai.item_type = 'document'- LEFT JOIN "UserHistory" uh- ON uh."itemId" = d.id- AND uh."itemType" = 'document'+ LEFT JOIN "UserHistory" uh+ ON uh."itemId" = d.id+ AND uh."itemType" = 'document'AND uh."userId" = $1LEFT JOIN LATERAL (- SELECT b.id- FROM "DocumentBom" b- WHERE b."documentId" = d.id- ORDER BY b."createdAt" DESC+ SELECT b.id+ FROM "DocumentBom" b+ WHERE b."documentId" = d.id+ ORDER BY b."createdAt" DESCLIMIT 1) db ON trueLEFT JOIN LATERAL (- SELECT i.id, i.sha- FROM "DocumentInstance" i- WHERE i."documentId" = d.id- ORDER BY i."updatedAt" DESC+ SELECT i.id, i.sha+ FROM "DocumentInstance" i+ WHERE i."documentId" = d.id+ ORDER BY i."updatedAt" DESCLIMIT 1) di ON trueWHERE d."deletedAt" IS NULLAND d.id = ANY($2::text[])UNION ALL-+SELECT'chat' as "item_type!",c.id as "id!",@@ -136,20 +137,21 @@ pub async fn unexpanded_soup_by_ids<'a>(NULL as "sub_type",uh."updatedAt"::timestamptz as "viewed_at",c."updatedAt"::timestamptz as "sort_ts!",- NULL as "is_completed"+ NULL as "is_completed",+ c."deletedAt"::timestamptz as "deleted_at"FROM "Chat" c- INNER JOIN UserAccessibleItems uai- ON uai.item_id = c.id+ INNER JOIN UserAccessibleItems uai+ ON uai.item_id = c.idAND uai.item_type = 'chat'- LEFT JOIN "UserHistory" uh- ON uh."itemId" = c.id- AND uh."itemType" = 'chat'+ LEFT JOIN "UserHistory" uh+ ON uh."itemId" = c.id+ AND uh."itemType" = 'chat'AND uh."userId" = $1WHERE c."deletedAt" IS NULLAND c.id = ANY($3::text[])-+UNION ALL-+SELECT'project' as "item_type!",p.id as "id!",@@ -168,14 +170,15 @@ pub async fn unexpanded_soup_by_ids<'a>(NULL as "sub_type",uh."updatedAt"::timestamptz as "viewed_at",p."updatedAt"::timestamptz as "sort_ts!",- NULL as "is_completed"+ NULL as "is_completed",+ p."deletedAt"::timestamptz as "deleted_at"FROM "Project" p- INNER JOIN UserAccessibleItems uai- ON uai.item_id = p.id+ INNER JOIN UserAccessibleItems uai+ ON uai.item_id = p.idAND uai.item_type = 'project'- LEFT JOIN "UserHistory" uh- ON uh."itemId" = p.id- AND uh."itemType" = 'project'+ LEFT JOIN "UserHistory" uh+ ON uh."itemId" = p.id+ AND uh."itemType" = 'project'AND uh."userId" = $1WHERE p."deletedAt" IS NULLAND p.id = ANY($4::text[])