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
feat(documents): move from is_task to sub_type (#487)
Will Hutchinson2fe0cb70b977
diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lockindex 2674ebeb72..c0221f6b10 100644--- a/rust/cloud-storage/Cargo.lock+++ b/rust/cloud-storage/Cargo.lock@@ -2601,6 +2601,7 @@ dependencies = ["comms_service_client","connection_gateway","cool_asserts",+ "document_sub_type","dynamodb_client","email","email_service_client",@@ -2675,6 +2676,17 @@ dependencies = ["tracing",]+[[package]]+name = "document_sub_type"+version = "0.1.0"+dependencies = [+ "serde",+ "sqlx",+ "strum",+ "thiserror 2.0.17",+ "utoipa",+]+[[package]]name = "document_text_extractor"version = "0.1.0"@@ -4835,6 +4847,7 @@ dependencies = ["async-trait","cached","chrono",+ "document_sub_type","futures","macro_user_id","macro_uuid",@@ -5334,6 +5347,7 @@ dependencies = ["axum","base64 0.22.1","chrono",+ "document_sub_type","model-error-response","model_file_type","model_user",@@ -5552,6 +5566,7 @@ name = "models_search"version = "0.1.0"dependencies = ["chrono",+ "document_sub_type","item_filters","models_opensearch","opensearch_client",@@ -5577,6 +5592,7 @@ version = "0.1.0"dependencies = ["anyhow","chrono",+ "document_sub_type","doppleganger","email","macro_user_id",@@ -7492,6 +7508,7 @@ dependencies = ["chrono","comms_service_client","document_storage_service_client",+ "document_sub_type","email_service_client","futures","http-body-util",@@ -8094,6 +8111,7 @@ dependencies = ["axum-extra","chrono","cool_asserts",+ "document_sub_type","doppleganger","either","email",diff --git a/rust/cloud-storage/Cargo.toml b/rust/cloud-storage/Cargo.tomlindex fddae0aac4..e053f5a745 100644--- a/rust/cloud-storage/Cargo.toml+++ b/rust/cloud-storage/Cargo.toml@@ -24,6 +24,7 @@ members = ["document_storage_service","document_storage_service_client","document_text_extractor",+ "document_sub_type","docx_unzip_handler","dynamodb_client","email_db_client",diff --git a/rust/cloud-storage/document_storage_service/Cargo.toml b/rust/cloud-storage/document_storage_service/Cargo.tomlindex b70bd7913a..6526e7b6e0 100644--- a/rust/cloud-storage/document_storage_service/Cargo.toml+++ b/rust/cloud-storage/document_storage_service/Cargo.toml@@ -109,6 +109,7 @@ utoipa = { workspace = true, features = ["axum_extras"] }utoipa-swagger-ui = { workspace = true, features = ["axum"] }uuid = { workspace = true }zip = { workspace = true }+document_sub_type = { path = "../document_sub_type" }[dev-dependencies]cool_asserts = "2"diff --git a/rust/cloud-storage/document_storage_service/src/api/documents/copy_document/copy_document_v2.rs b/rust/cloud-storage/document_storage_service/src/api/documents/copy_document/copy_document_v2.rsindex 16fc58d8fa..07c1ff82a3 100644--- a/rust/cloud-storage/document_storage_service/src/api/documents/copy_document/copy_document_v2.rs+++ b/rust/cloud-storage/document_storage_service/src/api/documents/copy_document/copy_document_v2.rs@@ -1,5 +1,6 @@use crate::api::context::ApiContext;use axum::{http::StatusCode, response::Response};+use document_sub_type::DocumentSubType;use macro_db_client::history::upsert_user_history;use model::document::response::{DocumentResponse, DocumentResponseMetadata};use model::{document::FileTypeExt, sync_service::SyncServiceVersionID};@@ -293,7 +294,7 @@ pub async fn copy_document<'a>(}// Copy task properties if the original document is a task- if original_document_metadata.is_task+ if original_document_metadata.sub_type == Some(DocumentSubType::Task)&& let Err(e) = ctx.system_properties_service.copy_task_properties(diff --git a/rust/cloud-storage/document_storage_service/src/api/documents/create_document/create_document_v2.rs b/rust/cloud-storage/document_storage_service/src/api/documents/create_document/create_document_v2.rsindex ba5cf271c2..91bd7c0e47 100644--- a/rust/cloud-storage/document_storage_service/src/api/documents/create_document/create_document_v2.rs+++ b/rust/cloud-storage/document_storage_service/src/api/documents/create_document/create_document_v2.rs@@ -1,6 +1,7 @@use crate::api::context::ApiContext;use axum::http::StatusCode;use chrono::{DateTime, Utc};+use document_sub_type::DocumentSubType;use model::document::response::CreateDocumentResponseData;use model::document::response::{DocumentResponse, DocumentResponseMetadata};use model::document::{ContentType, FileType, build_cloud_storage_bucket_document_key};@@ -179,7 +180,7 @@ pub async fn create_document(.await;// Attach task properties if creating a task- if document_response_metadata.is_task+ if document_response_metadata.sub_type == Some(DocumentSubType::Task)&& let Err(e) = ctx.system_properties_service.attach_task_properties(vec![document_response_metadata.document_id.clone()])diff --git a/rust/cloud-storage/document_storage_service/src/api/documents/get_batch_preview.rs b/rust/cloud-storage/document_storage_service/src/api/documents/get_batch_preview.rsindex 6b3cb772a1..c5b8cefd88 100644--- a/rust/cloud-storage/document_storage_service/src/api/documents/get_batch_preview.rs+++ b/rust/cloud-storage/document_storage_service/src/api/documents/get_batch_preview.rs@@ -57,7 +57,7 @@ pub async fn get_batch_preview_handler(file_type: preview_data.file_type.clone(),owner: preview_data.owner.clone(),updated_at: preview_data.updated_at,- is_task: preview_data.is_task,+ sub_type: preview_data.sub_type,})}DocumentPreviewV2::DoesNotExist(preview_data) => {diff --git a/rust/cloud-storage/document_storage_service/src/api/swagger.rs b/rust/cloud-storage/document_storage_service/src/api/swagger.rsindex 74c03d9b01..7755fbce35 100644--- a/rust/cloud-storage/document_storage_service/src/api/swagger.rs+++ b/rust/cloud-storage/document_storage_service/src/api/swagger.rs@@ -65,6 +65,7 @@ use crate::{},},};+use document_sub_type::DocumentSubType;use model::document::response::{CreateDocumentRequest, CreateDocumentResponse, CreateDocumentResponseData,DocumentResponseMetadata,@@ -296,6 +297,8 @@ use utoipa::OpenApi;SoupLabelType,PostSoupRequest,+ DocumentSubType,+// Permissions V2models_permissions::share_permission::access_level::AccessLevel,diff --git a/rust/cloud-storage/document_sub_type/Cargo.toml b/rust/cloud-storage/document_sub_type/Cargo.tomlnew file mode 100644index 0000000000..2411e397c7--- /dev/null+++ b/rust/cloud-storage/document_sub_type/Cargo.toml@@ -0,0 +1,12 @@+[package]+edition = "2024"+name = "document_sub_type"+publish = false+version = "0.1.0"++[dependencies]+serde = { workspace = true }+sqlx = { workspace = true }+strum = { workspace = true }+thiserror = { workspace = true }+utoipa = { workspace = true }diff --git a/rust/cloud-storage/document_sub_type/src/lib.rs b/rust/cloud-storage/document_sub_type/src/lib.rsnew file mode 100644index 0000000000..3239e6f03c--- /dev/null+++ b/rust/cloud-storage/document_sub_type/src/lib.rs@@ -0,0 +1,24 @@+//! This crate contains the document sub type enum and various logic for it++/// The document sub type enum represents all values of document sub types.+/// These values should match the `document_sub_type_value` table in macrodb.+#[derive(+ serde::Serialize,+ serde::Deserialize,+ Eq,+ PartialEq,+ Debug,+ utoipa::ToSchema,+ Clone,+ Copy,+ sqlx::Type,+ strum::EnumString,+ strum::Display,+)]+#[serde(rename_all = "lowercase")]+#[strum(serialize_all = "snake_case")]+#[sqlx(type_name = "\"document_sub_type_value\"", rename_all = "lowercase")]+pub enum DocumentSubType {+ /// A task document+ Task,+}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-7245c15f8766cf7f511fa11cf0a43e61ed6d4ff1eb25bd94a2870cc762a33f78.json b/rust/cloud-storage/macro_db_client/.sqlx/query-0bc3b351e5f4470da1cb41695bca968ed273018cf47e421794f284595c88bc11.jsonsimilarity index 54%rename from rust/cloud-storage/macro_db_client/.sqlx/query-7245c15f8766cf7f511fa11cf0a43e61ed6d4ff1eb25bd94a2870cc762a33f78.jsonrename to rust/cloud-storage/macro_db_client/.sqlx/query-0bc3b351e5f4470da1cb41695bca968ed273018cf47e421794f284595c88bc11.jsonindex 3c59d2dd25..7cedf91bdc 100644--- a/rust/cloud-storage/macro_db_client/.sqlx/query-7245c15f8766cf7f511fa11cf0a43e61ed6d4ff1eb25bd94a2870cc762a33f78.json+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-0bc3b351e5f4470da1cb41695bca968ed273018cf47e421794f284595c88bc11.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.document_id IS NOT NULL) as \"is_task!\"\n FROM\n \"Document\" d\n LEFT JOIN document_task 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 d.\"fileType\" IS DISTINCT FROM 'docx'\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 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 d.\"fileType\" IS DISTINCT FROM 'docx'\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": [{@@ -80,8 +80,17 @@},{"ordinal": 15,- "name": "is_task!",- "type_info": "Bool"+ "name": "sub_type?: DocumentSubType",+ "type_info": {+ "Custom": {+ "name": "document_sub_type_value",+ "kind": {+ "Enum": [+ "task"+ ]+ }+ }+ }}],"parameters": {@@ -106,8 +115,8 @@true,false,false,- null+ false]},- "hash": "7245c15f8766cf7f511fa11cf0a43e61ed6d4ff1eb25bd94a2870cc762a33f78"+ "hash": "0bc3b351e5f4470da1cb41695bca968ed273018cf47e421794f284595c88bc11"}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-1f4e2a83d6a137cc6e15e4facb94e404a5aa8a301e9c28e0d5680b79a18da4fd.json b/rust/cloud-storage/macro_db_client/.sqlx/query-1f4e2a83d6a137cc6e15e4facb94e404a5aa8a301e9c28e0d5680b79a18da4fd.jsondeleted file mode 100644index f56b186c03..0000000000--- a/rust/cloud-storage/macro_db_client/.sqlx/query-1f4e2a83d6a137cc6e15e4facb94e404a5aa8a301e9c28e0d5680b79a18da4fd.json+++ /dev/null@@ -1,22 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT document_id FROM document_task WHERE document_id = $1\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "document_id",- "type_info": "Text"- }- ],- "parameters": {- "Left": [- "Text"- ]- },- "nullable": [- false- ]- },- "hash": "1f4e2a83d6a137cc6e15e4facb94e404a5aa8a301e9c28e0d5680b79a18da4fd"-}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-5b9295bd6d3093e90710529c92fdef5bd20eda2603cf884e0fb0363b1ee1b529.json b/rust/cloud-storage/macro_db_client/.sqlx/query-2bf28d45227f03eba0a150305f096efe2d02b0955f9e407822975c0429f91a99.jsonsimilarity index 51%rename from rust/cloud-storage/macro_db_client/.sqlx/query-5b9295bd6d3093e90710529c92fdef5bd20eda2603cf884e0fb0363b1ee1b529.jsonrename to rust/cloud-storage/macro_db_client/.sqlx/query-2bf28d45227f03eba0a150305f096efe2d02b0955f9e407822975c0429f91a99.jsonindex 530b70cf25..d69146274e 100644--- a/rust/cloud-storage/macro_db_client/.sqlx/query-5b9295bd6d3093e90710529c92fdef5bd20eda2603cf884e0fb0363b1ee1b529.json+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-2bf28d45227f03eba0a150305f096efe2d02b0955f9e407822975c0429f91a99.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.\"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 (dt.document_id IS NOT NULL) as \"is_task!\"\n FROM\n \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\n LEFT JOIN LATERAL (\n SELECT\n b.id\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.\"createdAt\",\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 WHERE d.\"projectId\" = $1 AND d.\"deletedAt\" IS NULL\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.\"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 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 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.\"createdAt\",\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 WHERE d.\"projectId\" = $1 AND d.\"deletedAt\" IS NULL\n ","describe": {"columns": [{@@ -45,8 +45,17 @@},{"ordinal": 8,- "name": "is_task!",- "type_info": "Bool"+ "name": "sub_type?: DocumentSubType",+ "type_info": {+ "Custom": {+ "name": "document_sub_type_value",+ "kind": {+ "Enum": [+ "task"+ ]+ }+ }+ }}],"parameters": {@@ -63,8 +72,8 @@null,null,true,- null+ false]},- "hash": "5b9295bd6d3093e90710529c92fdef5bd20eda2603cf884e0fb0363b1ee1b529"+ "hash": "2bf28d45227f03eba0a150305f096efe2d02b0955f9e407822975c0429f91a99"}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-2c704ca8ff6085f844e5cab2e9d340d36e19a599a7e8180b97a63387653b4b5a.json b/rust/cloud-storage/macro_db_client/.sqlx/query-2c704ca8ff6085f844e5cab2e9d340d36e19a599a7e8180b97a63387653b4b5a.jsondeleted file mode 100644index 6568db15d0..0000000000--- a/rust/cloud-storage/macro_db_client/.sqlx/query-2c704ca8ff6085f844e5cab2e9d340d36e19a599a7e8180b97a63387653b4b5a.json+++ /dev/null@@ -1,112 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n WITH UserHistories AS (\n SELECT\n h.\"itemId\" as item_id,\n h.\"itemType\" as item_type\n FROM \"UserHistory\" h\n WHERE h.\"userId\" = $1\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 d.\"deletedAt\"::timestamptz as \"deleted_at\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n (dt.document_id IS NOT NULL) as \"is_task!\"\n FROM \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\n INNER JOIN UserHistories uh ON uh.item_id = d.id AND uh.item_type = 'document'\n LEFT JOIN LATERAL (\n SELECT\n b.id\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 true\n LEFT JOIN LATERAL (\n SELECT\n i.id,\n i.\"documentId\",\n i.\"sha\",\n i.\"createdAt\",\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 true\n UNION ALL\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.\"deletedAt\"::timestamptz as \"deleted_at\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n false as \"is_task\"\n FROM \"Chat\" c\n INNER JOIN UserHistories uh ON uh.item_id = c.id AND uh.item_type = 'chat'\n UNION ALL\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 p.\"deletedAt\"::timestamptz as \"deleted_at\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n false as \"is_task\"\n FROM \"Project\" p\n INNER JOIN UserHistories uh ON uh.item_id = p.id AND uh.item_type = 'project'\n )\n SELECT * FROM Combined\n ORDER BY updated_at DESC\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": "deleted_at",- "type_info": "Timestamptz"- },- {- "ordinal": 13,- "name": "is_persistent",- "type_info": "Bool"- },- {- "ordinal": 14,- "name": "sha",- "type_info": "Text"- },- {- "ordinal": 15,- "name": "is_task!",- "type_info": "Bool"- }- ],- "parameters": {- "Left": [- "Text"- ]- },- "nullable": [- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null- ]- },- "hash": "2c704ca8ff6085f844e5cab2e9d340d36e19a599a7e8180b97a63387653b4b5a"-}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-4c4e9d8ac53e7c3ef292d337af8bcdb2a09a3e4fffa3ca0af2db49180ecc05e6.json b/rust/cloud-storage/macro_db_client/.sqlx/query-4c4e9d8ac53e7c3ef292d337af8bcdb2a09a3e4fffa3ca0af2db49180ecc05e6.jsonnew file mode 100644index 0000000000..2b186622c5--- /dev/null+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-4c4e9d8ac53e7c3ef292d337af8bcdb2a09a3e4fffa3ca0af2db49180ecc05e6.json@@ -0,0 +1,121 @@+{+ "db_name": "PostgreSQL",+ "query": "\n WITH PinnedItems AS (\n SELECT\n p.\"pinnedItemId\" as pin_item_id,\n p.\"pinnedItemType\" as pin_item_type,\n p.\"pinIndex\" as pin_index\n FROM \"Pin\" p\n WHERE p.\"userId\" = $1\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 di.sha as \"sha\",\n NULL as \"is_persistent\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n pi.pin_index as \"pin_index\"\n FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n INNER JOIN PinnedItems pi ON pi.pin_item_id = d.id AND pi.pin_item_type = 'document'\n LEFT JOIN LATERAL (\n SELECT\n b.id\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 true\n LEFT JOIN LATERAL (\n SELECT\n i.id,\n i.\"documentId\",\n i.\"sha\",\n i.\"createdAt\",\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 true\n UNION ALL\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 NULL as \"sha\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as sub_type,\n pi.pin_index as \"pin_index\"\n FROM \"Chat\" c\n INNER JOIN PinnedItems pi ON pi.pin_item_id = c.id AND pi.pin_item_type = 'chat'\n UNION ALL\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 \"sha\",\n NULL as \"is_persistent\",\n NULL as sub_type,\n pi.pin_index as \"pin_index\"\n FROM \"Project\" p\n INNER JOIN PinnedItems pi ON pi.pin_item_id = p.id AND pi.pin_item_type = 'project'\n )\n SELECT * FROM Combined\n ORDER BY pin_index ASC\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": "sha",+ "type_info": "Text"+ },+ {+ "ordinal": 13,+ "name": "is_persistent",+ "type_info": "Bool"+ },+ {+ "ordinal": 14,+ "name": "sub_type?: DocumentSubType",+ "type_info": {+ "Custom": {+ "name": "document_sub_type_value",+ "kind": {+ "Enum": [+ "task"+ ]+ }+ }+ }+ },+ {+ "ordinal": 15,+ "name": "pin_index",+ "type_info": "Int4"+ }+ ],+ "parameters": {+ "Left": [+ "Text"+ ]+ },+ "nullable": [+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null+ ]+ },+ "hash": "4c4e9d8ac53e7c3ef292d337af8bcdb2a09a3e4fffa3ca0af2db49180ecc05e6"+}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-317713a06e38e92d9f99d4170cac7e566e4a76412bae191404ecec4ca88e23e4.json b/rust/cloud-storage/macro_db_client/.sqlx/query-50189a384178de7dfcede64e3a89976d6dd8fd2560196fb22630be9d1d095428.jsonsimilarity index 53%rename from rust/cloud-storage/macro_db_client/.sqlx/query-317713a06e38e92d9f99d4170cac7e566e4a76412bae191404ecec4ca88e23e4.jsonrename to rust/cloud-storage/macro_db_client/.sqlx/query-50189a384178de7dfcede64e3a89976d6dd8fd2560196fb22630be9d1d095428.jsonindex 07e84cead5..8c9ffd0c3d 100644--- a/rust/cloud-storage/macro_db_client/.sqlx/query-317713a06e38e92d9f99d4170cac7e566e4a76412bae191404ecec4ca88e23e4.json+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-50189a384178de7dfcede64e3a89976d6dd8fd2560196fb22630be9d1d095428.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.document_id IS NOT NULL) as \"is_task!\"\n FROM\n \"Document\" d\n LEFT JOIN document_task 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 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": [{@@ -80,8 +80,17 @@},{"ordinal": 15,- "name": "is_task!",- "type_info": "Bool"+ "name": "sub_type?: DocumentSubType",+ "type_info": {+ "Custom": {+ "name": "document_sub_type_value",+ "kind": {+ "Enum": [+ "task"+ ]+ }+ }+ }}],"parameters": {@@ -106,8 +115,8 @@true,false,false,- null+ false]},- "hash": "317713a06e38e92d9f99d4170cac7e566e4a76412bae191404ecec4ca88e23e4"+ "hash": "50189a384178de7dfcede64e3a89976d6dd8fd2560196fb22630be9d1d095428"}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-5f836243295a3d3de05ee966cbdf68f20831b1a073af32d703705a7e7fea55af.json b/rust/cloud-storage/macro_db_client/.sqlx/query-5f836243295a3d3de05ee966cbdf68f20831b1a073af32d703705a7e7fea55af.jsondeleted file mode 100644index 86888a61b9..0000000000--- a/rust/cloud-storage/macro_db_client/.sqlx/query-5f836243295a3d3de05ee966cbdf68f20831b1a073af32d703705a7e7fea55af.json+++ /dev/null@@ -1,14 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n INSERT INTO document_task (document_id)\n VALUES ($1)\n ",- "describe": {- "columns": [],- "parameters": {- "Left": [- "Text"- ]- },- "nullable": []- },- "hash": "5f836243295a3d3de05ee966cbdf68f20831b1a073af32d703705a7e7fea55af"-}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-5f8364286a90dd18dc9e33ebd36f48fb8907db9900b2b2c353a9191e5a8a6584.json b/rust/cloud-storage/macro_db_client/.sqlx/query-5f8364286a90dd18dc9e33ebd36f48fb8907db9900b2b2c353a9191e5a8a6584.jsondeleted file mode 100644index 293f470cb1..0000000000--- a/rust/cloud-storage/macro_db_client/.sqlx/query-5f8364286a90dd18dc9e33ebd36f48fb8907db9900b2b2c353a9191e5a8a6584.json+++ /dev/null@@ -1,41 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n INSERT INTO \"DocumentInstance\" (\"documentId\", \"sha\")\n VALUES ($1, $2)\n RETURNING id, sha, \"createdAt\"::timestamptz as created_at, \"updatedAt\"::timestamptz as updated_at;\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "id",- "type_info": "Int8"- },- {- "ordinal": 1,- "name": "sha",- "type_info": "Text"- },- {- "ordinal": 2,- "name": "created_at",- "type_info": "Timestamptz"- },- {- "ordinal": 3,- "name": "updated_at",- "type_info": "Timestamptz"- }- ],- "parameters": {- "Left": [- "Text",- "Text"- ]- },- "nullable": [- false,- false,- null,- null- ]- },- "hash": "5f8364286a90dd18dc9e33ebd36f48fb8907db9900b2b2c353a9191e5a8a6584"-}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-8756736b577078b90b45ec16b248fafb2ad74dfda7306b3475d924542ee7605d.json b/rust/cloud-storage/macro_db_client/.sqlx/query-8756736b577078b90b45ec16b248fafb2ad74dfda7306b3475d924542ee7605d.jsondeleted file mode 100644index 3d0c052133..0000000000--- a/rust/cloud-storage/macro_db_client/.sqlx/query-8756736b577078b90b45ec16b248fafb2ad74dfda7306b3475d924542ee7605d.json+++ /dev/null@@ -1,28 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n INSERT INTO \"Document\" (owner, name, \"fileType\", \"documentFamilyId\", \"branchedFromId\", \"branchedFromVersionId\", \"projectId\")\n VALUES ($1, $2, $3, $4, $5, $6, $7)\n RETURNING id;\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "id",- "type_info": "Text"- }- ],- "parameters": {- "Left": [- "Text",- "Text",- "Text",- "Int8",- "Text",- "Int8",- "Text"- ]- },- "nullable": [- false- ]- },- "hash": "8756736b577078b90b45ec16b248fafb2ad74dfda7306b3475d924542ee7605d"-}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-93935a8c0070822f6c16478613b59117517588d8b433000bcd6c29857a8d3bdc.json b/rust/cloud-storage/macro_db_client/.sqlx/query-93935a8c0070822f6c16478613b59117517588d8b433000bcd6c29857a8d3bdc.jsonnew file mode 100644index 0000000000..639a4e7878--- /dev/null+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-93935a8c0070822f6c16478613b59117517588d8b433000bcd6c29857a8d3bdc.json@@ -0,0 +1,121 @@+{+ "db_name": "PostgreSQL",+ "query": "\n WITH UserHistories AS (\n SELECT\n h.\"itemId\" as item_id,\n h.\"itemType\" as item_type\n FROM \"UserHistory\" h\n WHERE h.\"userId\" = $1\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 d.\"deletedAt\"::timestamptz as \"deleted_at\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n dt.sub_type as \"sub_type?: DocumentSubType\"\n FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n INNER JOIN UserHistories uh ON uh.item_id = d.id AND uh.item_type = 'document'\n LEFT JOIN LATERAL (\n SELECT\n b.id\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 true\n LEFT JOIN LATERAL (\n SELECT\n i.id,\n i.\"documentId\",\n i.\"sha\",\n i.\"createdAt\",\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 true\n UNION ALL\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.\"deletedAt\"::timestamptz as \"deleted_at\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\"\n FROM \"Chat\" c\n INNER JOIN UserHistories uh ON uh.item_id = c.id AND uh.item_type = 'chat'\n UNION ALL\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 p.\"deletedAt\"::timestamptz as \"deleted_at\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\"\n FROM \"Project\" p\n INNER JOIN UserHistories uh ON uh.item_id = p.id AND uh.item_type = 'project'\n )\n SELECT * FROM Combined\n ORDER BY updated_at DESC\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": "deleted_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 13,+ "name": "is_persistent",+ "type_info": "Bool"+ },+ {+ "ordinal": 14,+ "name": "sha",+ "type_info": "Text"+ },+ {+ "ordinal": 15,+ "name": "sub_type?: DocumentSubType",+ "type_info": {+ "Custom": {+ "name": "document_sub_type_value",+ "kind": {+ "Enum": [+ "task"+ ]+ }+ }+ }+ }+ ],+ "parameters": {+ "Left": [+ "Text"+ ]+ },+ "nullable": [+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null+ ]+ },+ "hash": "93935a8c0070822f6c16478613b59117517588d8b433000bcd6c29857a8d3bdc"+}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-9e506dc5e6ce5381990d8258bfda1102377246f0a58ab49801b7fa12ab400560.json b/rust/cloud-storage/macro_db_client/.sqlx/query-9e506dc5e6ce5381990d8258bfda1102377246f0a58ab49801b7fa12ab400560.jsonnew file mode 100644index 0000000000..4e0f6bd106--- /dev/null+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-9e506dc5e6ce5381990d8258bfda1102377246f0a58ab49801b7fa12ab400560.json@@ -0,0 +1,24 @@+{+ "db_name": "PostgreSQL",+ "query": "\n INSERT INTO document_sub_type (document_id, sub_type)\n VALUES ($1, $2)\n ",+ "describe": {+ "columns": [],+ "parameters": {+ "Left": [+ "Text",+ {+ "Custom": {+ "name": "document_sub_type_value",+ "kind": {+ "Enum": [+ "task"+ ]+ }+ }+ }+ ]+ },+ "nullable": []+ },+ "hash": "9e506dc5e6ce5381990d8258bfda1102377246f0a58ab49801b7fa12ab400560"+}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-509366e20760bbad7e094429de614fd01d041aa084effbee6a272e4f61fa61ba.json b/rust/cloud-storage/macro_db_client/.sqlx/query-a8a1349f82cbd20fdde8e1ba926ab48263f4082ee3b67b8512f25fba38b158c9.jsonsimilarity index 53%rename from rust/cloud-storage/macro_db_client/.sqlx/query-509366e20760bbad7e094429de614fd01d041aa084effbee6a272e4f61fa61ba.jsonrename to rust/cloud-storage/macro_db_client/.sqlx/query-a8a1349f82cbd20fdde8e1ba926ab48263f4082ee3b67b8512f25fba38b158c9.jsonindex be44bc0760..6ddddbd7b0 100644--- a/rust/cloud-storage/macro_db_client/.sqlx/query-509366e20760bbad7e094429de614fd01d041aa084effbee6a272e4f61fa61ba.json+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-a8a1349f82cbd20fdde8e1ba926ab48263f4082ee3b67b8512f25fba38b158c9.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.document_id IS NOT NULL) as \"is_task!\"\n FROM\n \"Document\" d\n LEFT JOIN document_task 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 d.\"fileType\" IS DISTINCT FROM 'docx'\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 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 d.\"fileType\" IS DISTINCT FROM 'docx'\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": [{@@ -80,8 +80,17 @@},{"ordinal": 15,- "name": "is_task!",- "type_info": "Bool"+ "name": "sub_type?: DocumentSubType",+ "type_info": {+ "Custom": {+ "name": "document_sub_type_value",+ "kind": {+ "Enum": [+ "task"+ ]+ }+ }+ }}],"parameters": {@@ -105,8 +114,8 @@true,false,false,- null+ false]},- "hash": "509366e20760bbad7e094429de614fd01d041aa084effbee6a272e4f61fa61ba"+ "hash": "a8a1349f82cbd20fdde8e1ba926ab48263f4082ee3b67b8512f25fba38b158c9"}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-cd03404aa4732898d67a1d88abd2e11691b9647640780c5d5c26e4e399c7a8d5.json b/rust/cloud-storage/macro_db_client/.sqlx/query-b672f4dd120709c604651093444b9e5f204b1e059e7426d244aba0d87f21ae4d.jsonsimilarity index 63%rename from rust/cloud-storage/macro_db_client/.sqlx/query-cd03404aa4732898d67a1d88abd2e11691b9647640780c5d5c26e4e399c7a8d5.jsonrename to rust/cloud-storage/macro_db_client/.sqlx/query-b672f4dd120709c604651093444b9e5f204b1e059e7426d244aba0d87f21ae4d.jsonindex bd2ce31111..00e2d2c154 100644--- a/rust/cloud-storage/macro_db_client/.sqlx/query-cd03404aa4732898d67a1d88abd2e11691b9647640780c5d5c26e4e399c7a8d5.json+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-b672f4dd120709c604651093444b9e5f204b1e059e7426d244aba0d87f21ae4d.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n SELECT\n d.id as document_id,\n d.name as document_name,\n d.\"fileType\" as file_type,\n d.owner as owner,\n d.\"updatedAt\"::timestamptz as \"updated_at\",\n (dt.document_id IS NOT NULL) as \"is_task!\"\n FROM \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\n WHERE\n d.\"id\" = ANY($1)\n ",+ "query": "\n SELECT\n d.id as document_id,\n d.name as document_name,\n d.\"fileType\" as file_type,\n d.owner as owner,\n d.\"updatedAt\"::timestamptz as \"updated_at\",\n dt.sub_type as \"sub_type?: DocumentSubType\"\n FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n WHERE\n d.\"id\" = ANY($1)\n ","describe": {"columns": [{@@ -30,8 +30,17 @@},{"ordinal": 5,- "name": "is_task!",- "type_info": "Bool"+ "name": "sub_type?: DocumentSubType",+ "type_info": {+ "Custom": {+ "name": "document_sub_type_value",+ "kind": {+ "Enum": [+ "task"+ ]+ }+ }+ }}],"parameters": {@@ -45,8 +54,8 @@true,false,null,- null+ true]},- "hash": "cd03404aa4732898d67a1d88abd2e11691b9647640780c5d5c26e4e399c7a8d5"+ "hash": "b672f4dd120709c604651093444b9e5f204b1e059e7426d244aba0d87f21ae4d"}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-bdf007b9a0df2ea5463e92c0f32afbfe820d2ecdfdd53cef99423a3e2f288cd8.json b/rust/cloud-storage/macro_db_client/.sqlx/query-bdf007b9a0df2ea5463e92c0f32afbfe820d2ecdfdd53cef99423a3e2f288cd8.jsondeleted file mode 100644index 9883669606..0000000000--- a/rust/cloud-storage/macro_db_client/.sqlx/query-bdf007b9a0df2ea5463e92c0f32afbfe820d2ecdfdd53cef99423a3e2f288cd8.json+++ /dev/null@@ -1,88 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\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.\"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 d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n (dt.document_id IS NOT NULL) as \"is_task!\"\n FROM \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\n LEFT JOIN LATERAL (\n SELECT\n b.id\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 true\n LEFT JOIN LATERAL (\n SELECT\n i.id\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 true\n WHERE d.owner = $1 AND d.\"deletedAt\" IS NOT NULL\n UNION ALL\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 \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at\",\n c.\"updatedAt\"::timestamptz as \"updated_at\",\n c.\"deletedAt\"::timestamptz as \"deleted_at\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n false as \"is_task\"\n FROM \"Chat\" c\n WHERE c.\"userId\" = $1 AND c.\"deletedAt\" IS NOT NULL\n UNION ALL\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 \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at\",\n p.\"updatedAt\"::timestamptz as \"updated_at\",\n p.\"deletedAt\"::timestamptz as \"deleted_at\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n false as \"is_task\"\n FROM \"Project\" p\n WHERE p.\"userId\" = $1 AND p.\"deletedAt\" IS NOT NULL\n ORDER BY deleted_at DESC\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": "file_type",- "type_info": "Text"- },- {- "ordinal": 6,- "name": "created_at",- "type_info": "Timestamptz"- },- {- "ordinal": 7,- "name": "updated_at",- "type_info": "Timestamptz"- },- {- "ordinal": 8,- "name": "deleted_at",- "type_info": "Timestamptz"- },- {- "ordinal": 9,- "name": "project_id",- "type_info": "Text"- },- {- "ordinal": 10,- "name": "is_persistent",- "type_info": "Bool"- },- {- "ordinal": 11,- "name": "is_task!",- "type_info": "Bool"- }- ],- "parameters": {- "Left": [- "Text"- ]- },- "nullable": [- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null- ]- },- "hash": "bdf007b9a0df2ea5463e92c0f32afbfe820d2ecdfdd53cef99423a3e2f288cd8"-}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-d3cad313940f62e92c58011860b89ea382239b9cf86f5d24779814361aface7d.json b/rust/cloud-storage/macro_db_client/.sqlx/query-d3cad313940f62e92c58011860b89ea382239b9cf86f5d24779814361aface7d.jsondeleted file mode 100644index 9e4898540b..0000000000--- a/rust/cloud-storage/macro_db_client/.sqlx/query-d3cad313940f62e92c58011860b89ea382239b9cf86f5d24779814361aface7d.json+++ /dev/null@@ -1,112 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n WITH PinnedItems AS (\n SELECT\n p.\"pinnedItemId\" as pin_item_id,\n p.\"pinnedItemType\" as pin_item_type,\n p.\"pinIndex\" as pin_index\n FROM \"Pin\" p\n WHERE p.\"userId\" = $1\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 di.sha as \"sha\",\n NULL as \"is_persistent\",\n (dt.document_id IS NOT NULL) as \"is_task!\",\n pi.pin_index as \"pin_index\"\n FROM \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\n INNER JOIN PinnedItems pi ON pi.pin_item_id = d.id AND pi.pin_item_type = 'document'\n LEFT JOIN LATERAL (\n SELECT\n b.id\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 true\n LEFT JOIN LATERAL (\n SELECT\n i.id,\n i.\"documentId\",\n i.\"sha\",\n i.\"createdAt\",\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 true\n UNION ALL\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 NULL as \"sha\",\n c.\"isPersistent\" as \"is_persistent\",\n false as \"is_task\",\n pi.pin_index as \"pin_index\"\n FROM \"Chat\" c\n INNER JOIN PinnedItems pi ON pi.pin_item_id = c.id AND pi.pin_item_type = 'chat'\n UNION ALL\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 \"sha\",\n NULL as \"is_persistent\",\n false as \"is_task\",\n pi.pin_index as \"pin_index\"\n FROM \"Project\" p\n INNER JOIN PinnedItems pi ON pi.pin_item_id = p.id AND pi.pin_item_type = 'project'\n )\n SELECT * FROM Combined\n ORDER BY pin_index ASC\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": "sha",- "type_info": "Text"- },- {- "ordinal": 13,- "name": "is_persistent",- "type_info": "Bool"- },- {- "ordinal": 14,- "name": "is_task!",- "type_info": "Bool"- },- {- "ordinal": 15,- "name": "pin_index",- "type_info": "Int4"- }- ],- "parameters": {- "Left": [- "Text"- ]- },- "nullable": [- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null- ]- },- "hash": "d3cad313940f62e92c58011860b89ea382239b9cf86f5d24779814361aface7d"-}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-da98ce3985fbf5eaed5300bb94b3354c7b4bd005b9e5657a702bd39846ff0917.json b/rust/cloud-storage/macro_db_client/.sqlx/query-da98ce3985fbf5eaed5300bb94b3354c7b4bd005b9e5657a702bd39846ff0917.jsonnew file mode 100644index 0000000000..3c55abed30--- /dev/null+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-da98ce3985fbf5eaed5300bb94b3354c7b4bd005b9e5657a702bd39846ff0917.json@@ -0,0 +1,24 @@+{+ "db_name": "PostgreSQL",+ "query": "\n INSERT INTO document_sub_type (document_id, sub_type) \n VALUES ($1, $2)\n ",+ "describe": {+ "columns": [],+ "parameters": {+ "Left": [+ "Text",+ {+ "Custom": {+ "name": "document_sub_type_value",+ "kind": {+ "Enum": [+ "task"+ ]+ }+ }+ }+ ]+ },+ "nullable": []+ },+ "hash": "da98ce3985fbf5eaed5300bb94b3354c7b4bd005b9e5657a702bd39846ff0917"+}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-df66b4b4b3bf596c9e27e1be73cfaab7a53abb772234e4cacea1b404f301d503.json b/rust/cloud-storage/macro_db_client/.sqlx/query-df66b4b4b3bf596c9e27e1be73cfaab7a53abb772234e4cacea1b404f301d503.jsonnew file mode 100644index 0000000000..a23b840c5a--- /dev/null+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-df66b4b4b3bf596c9e27e1be73cfaab7a53abb772234e4cacea1b404f301d503.json@@ -0,0 +1,97 @@+{+ "db_name": "PostgreSQL",+ "query": "\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.\"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 d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n dt.sub_type as \"sub_type?: DocumentSubType\"\n FROM \"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 FROM\n \"DocumentBom\" b\n WHERE\n b.\"documentId\" = d.id\n ORDER BY\n b.\"createdAt\" DESC\n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT\n i.id\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 true\n WHERE d.owner = $1 AND d.\"deletedAt\" IS NOT NULL\n UNION ALL\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 \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at\",\n c.\"updatedAt\"::timestamptz as \"updated_at\",\n c.\"deletedAt\"::timestamptz as \"deleted_at\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sub_type\"\n FROM \"Chat\" c\n WHERE c.\"userId\" = $1 AND c.\"deletedAt\" IS NOT NULL\n UNION ALL\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 \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at\",\n p.\"updatedAt\"::timestamptz as \"updated_at\",\n p.\"deletedAt\"::timestamptz as \"deleted_at\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sub_type\"\n FROM \"Project\" p\n WHERE p.\"userId\" = $1 AND p.\"deletedAt\" IS NOT NULL\n ORDER BY deleted_at DESC\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": "file_type",+ "type_info": "Text"+ },+ {+ "ordinal": 6,+ "name": "created_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 7,+ "name": "updated_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 8,+ "name": "deleted_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 9,+ "name": "project_id",+ "type_info": "Text"+ },+ {+ "ordinal": 10,+ "name": "is_persistent",+ "type_info": "Bool"+ },+ {+ "ordinal": 11,+ "name": "sub_type?: DocumentSubType",+ "type_info": {+ "Custom": {+ "name": "document_sub_type_value",+ "kind": {+ "Enum": [+ "task"+ ]+ }+ }+ }+ }+ ],+ "parameters": {+ "Left": [+ "Text"+ ]+ },+ "nullable": [+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null+ ]+ },+ "hash": "df66b4b4b3bf596c9e27e1be73cfaab7a53abb772234e4cacea1b404f301d503"+}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-81900e6129d69cfb027846be355850b8a4183e3a3c8d767895c91379dde90e62.json b/rust/cloud-storage/macro_db_client/.sqlx/query-f61fae90a53682f217091f1ecbdaa60d2eb5b7b0ff90863b0d0dc288779a5f7f.jsonsimilarity index 68%rename from rust/cloud-storage/macro_db_client/.sqlx/query-81900e6129d69cfb027846be355850b8a4183e3a3c8d767895c91379dde90e62.jsonrename to rust/cloud-storage/macro_db_client/.sqlx/query-f61fae90a53682f217091f1ecbdaa60d2eb5b7b0ff90863b0d0dc288779a5f7f.jsonindex 1fb946a15b..54d8bc401c 100644--- a/rust/cloud-storage/macro_db_client/.sqlx/query-81900e6129d69cfb027846be355850b8a4183e3a3c8d767895c91379dde90e62.json+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-f61fae90a53682f217091f1ecbdaa60d2eb5b7b0ff90863b0d0dc288779a5f7f.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n SELECT\n c.\"id\" as \"item_id!\",\n c.\"owner\" as \"owner\",\n c.\"fileType\" as \"file_type\",\n c.\"name\" as \"file_name\",\n c.\"createdAt\" as \"created_at!\",\n c.\"updatedAt\" as \"updated_at!\",\n c.\"deletedAt\" as \"deleted_at?\",\n uh.\"updatedAt\" as \"viewed_at?\",\n c.\"projectId\" as \"project_id?\",\n (dt.document_id IS NOT NULL) as \"is_task!\"\n FROM\n \"Document\" c\n LEFT JOIN document_task dt ON dt.document_id = c.id\n LEFT JOIN\n \"UserHistory\" uh ON uh.\"itemId\" = c.\"id\"\n AND uh.\"userId\" = $1\n AND uh.\"itemType\" = 'document'\n WHERE\n c.\"id\" = ANY($2)\n ORDER BY\n c.\"updatedAt\" DESC\n ",+ "query": "\n SELECT\n c.\"id\" as \"item_id!\",\n c.\"owner\" as \"owner\",\n c.\"fileType\" as \"file_type\",\n c.\"name\" as \"file_name\",\n c.\"createdAt\" as \"created_at!\",\n c.\"updatedAt\" as \"updated_at!\",\n c.\"deletedAt\" as \"deleted_at?\",\n uh.\"updatedAt\" as \"viewed_at?\",\n c.\"projectId\" as \"project_id?\",\n dt.sub_type as \"sub_type?: DocumentSubType\"\n FROM\n \"Document\" c\n LEFT JOIN document_sub_type dt ON dt.document_id = c.id\n LEFT JOIN\n \"UserHistory\" uh ON uh.\"itemId\" = c.\"id\"\n AND uh.\"userId\" = $1\n AND uh.\"itemType\" = 'document'\n WHERE\n c.\"id\" = ANY($2)\n ORDER BY\n c.\"updatedAt\" DESC\n ","describe": {"columns": [{@@ -50,8 +50,17 @@},{"ordinal": 9,- "name": "is_task!",- "type_info": "Bool"+ "name": "sub_type?: DocumentSubType",+ "type_info": {+ "Custom": {+ "name": "document_sub_type_value",+ "kind": {+ "Enum": [+ "task"+ ]+ }+ }+ }}],"parameters": {@@ -70,8 +79,8 @@true,false,true,- null+ false]},- "hash": "81900e6129d69cfb027846be355850b8a4183e3a3c8d767895c91379dde90e62"+ "hash": "f61fae90a53682f217091f1ecbdaa60d2eb5b7b0ff90863b0d0dc288779a5f7f"}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-fab6b92c5781874261b3c3ca673d0bf0ad8155e25cf77aa57dafdcb133f30509.json b/rust/cloud-storage/macro_db_client/.sqlx/query-fab6b92c5781874261b3c3ca673d0bf0ad8155e25cf77aa57dafdcb133f30509.jsonnew file mode 100644index 0000000000..1f209218c3--- /dev/null+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-fab6b92c5781874261b3c3ca673d0bf0ad8155e25cf77aa57dafdcb133f30509.json@@ -0,0 +1,31 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT sub_type as \"sub_type: DocumentSubType\" FROM document_sub_type WHERE document_id = $1\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "sub_type: DocumentSubType",+ "type_info": {+ "Custom": {+ "name": "document_sub_type_value",+ "kind": {+ "Enum": [+ "task"+ ]+ }+ }+ }+ }+ ],+ "parameters": {+ "Left": [+ "Text"+ ]+ },+ "nullable": [+ false+ ]+ },+ "hash": "fab6b92c5781874261b3c3ca673d0bf0ad8155e25cf77aa57dafdcb133f30509"+}diff --git a/rust/cloud-storage/macro_db_client/Cargo.toml b/rust/cloud-storage/macro_db_client/Cargo.tomlindex e4db61c2ff..30694dd3e5 100644--- a/rust/cloud-storage/macro_db_client/Cargo.toml+++ b/rust/cloud-storage/macro_db_client/Cargo.toml@@ -38,3 +38,4 @@ tokio = { workspace = true }tracing = { workspace = true }user_quota = { path = "../user_quota" }uuid = { workspace = true }+document_sub_type = { path = "../document_sub_type" }diff --git a/rust/cloud-storage/macro_db_client/migrations/20251205213515_create_document_sub_type.sql b/rust/cloud-storage/macro_db_client/migrations/20251205213515_create_document_sub_type.sqlnew file mode 100644index 0000000000..1ccdc1af26--- /dev/null+++ b/rust/cloud-storage/macro_db_client/migrations/20251205213515_create_document_sub_type.sql@@ -0,0 +1,13 @@+-- Create the document sub type enum+CREATE TYPE document_sub_type_value AS ENUM ('task');++-- Create the document_sub_type table+CREATE TABLE "document_sub_type"+(+ "document_id" TEXT NOT NULL,+ "sub_type" document_sub_type_value NOT NULL,++ CONSTRAINT "document_sub_type_pkey" PRIMARY KEY ("document_id"),+ CONSTRAINT "document_sub_type_document_id_fkey" FOREIGN KEY ("document_id")+ REFERENCES "Document" ("id") ON DELETE CASCADE ON UPDATE CASCADE+);diff --git a/rust/cloud-storage/macro_db_client/src/activity/get_recent_activities.rs b/rust/cloud-storage/macro_db_client/src/activity/get_recent_activities.rsindex 9596019ecf..3d567ad810 100644--- a/rust/cloud-storage/macro_db_client/src/activity/get_recent_activities.rs+++ b/rust/cloud-storage/macro_db_client/src/activity/get_recent_activities.rs@@ -1,6 +1,6 @@-use sqlx::{Pool, Postgres, Row};-+use document_sub_type::DocumentSubType;use model::{activity::Activity, chat::Chat, document::BasicDocument};+use sqlx::{Pool, Postgres, Row};#[tracing::instrument(skip(db))]pub async fn get_recent_activities(@@ -56,10 +56,10 @@ pub async fn get_recent_activities(d."projectId" as "project_id",NULL as "is_persistent",di.sha as "sha",- (dt.document_id IS NOT NULL) as "is_task"+ dt.sub_type as "sub_type"FROM"Document" d- LEFT JOIN document_task dt ON dt.document_id = d.id+ LEFT JOIN document_sub_type dt ON dt.document_id = d.idLEFT JOIN LATERAL (SELECTb.id@@ -104,7 +104,7 @@ pub async fn get_recent_activities(c."projectId" as "project_id",c."isPersistent" as "is_persistent",NULL as "sha",- false as "is_task!"+ NULL as "sub_type"FROM "Chat" cWHERE c."userId" = $1 AND c."deletedAt" IS NULLORDER BY updated_at DESC@@ -128,7 +128,7 @@ pub async fn get_recent_activities(let created_at: Option<chrono::DateTime<chrono::Utc>> = r.get("created_at");let updated_at: Option<chrono::DateTime<chrono::Utc>> = r.get("updated_at");let project_id: Option<String> = r.get("project_id");- let is_task: bool = r.get("is_task");+ let sub_type: Option<DocumentSubType> = r.get("sub_type");match row_type.as_ref() {"document" => {@@ -147,7 +147,7 @@ pub async fn get_recent_activities(branched_from_id: r.get("branched_from_id"),branched_from_version_id: r.get("branched_from_version_id"),project_id,- is_task,+ sub_type,}))}"chat" => Some(Activity::Chat(Chat {diff --git a/rust/cloud-storage/macro_db_client/src/convert/mod.rs b/rust/cloud-storage/macro_db_client/src/convert/mod.rsindex 2d31dddd5a..043115351a 100644--- a/rust/cloud-storage/macro_db_client/src/convert/mod.rs+++ b/rust/cloud-storage/macro_db_client/src/convert/mod.rs@@ -92,7 +92,7 @@ pub async fn get_docx_files(branched_from_version_id: None,document_family_id: None,modification_data: None,- is_task: false,+ sub_type: None,}).fetch_all(db).await?;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 f161caeadf..fad0f01a8c 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@@ -1,6 +1,7 @@use crate::{document::document_bom::create_bom_parts, share_permission::create::create_document_permission,};+use document_sub_type::DocumentSubType;use model::document::{BomPart, DocumentMetadata, FileType, IDWithTimeStamps, VersionIDWithTimeStamps,VersionIDWithTimeStampsNoSha,@@ -142,7 +143,7 @@ pub(in crate::document) async fn copy_docx_document(document_bom: Some(saved_bom_parts),created_at: document.created_at,updated_at: document.updated_at,- is_task: false, // docx documents are not tasks+ sub_type: None,})}@@ -234,13 +235,14 @@ pub(in crate::document) async fn copy_non_docx_document(None};- if original_document.is_task {+ if original_document.sub_type == Some(DocumentSubType::Task) {sqlx::query!(r#"- INSERT INTO document_task (document_id)- VALUES ($1)+ INSERT INTO document_sub_type (document_id, sub_type)+ VALUES ($1, $2)"#,- document.id+ document.id,+ DocumentSubType::Task as _,).execute(transaction.as_mut()).await?;@@ -262,7 +264,7 @@ pub(in crate::document) async fn copy_non_docx_document(modification_data: original_modification_data,created_at: document.created_at,updated_at: document.updated_at,- is_task: original_document.is_task,+ sub_type: original_document.sub_type,})}@@ -291,7 +293,7 @@ mod tests {None,None,None,- false,+ None,),"macro|[email protected]","new name",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 ea02571504..465a82321d 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@@ -156,7 +156,7 @@ pub async fn create_blank_docx(modification_data: None,created_at: document_version.created_at,updated_at: document_version.updated_at,- is_task: false, // docx documents are not tasks+ sub_type: None,})}diff --git a/rust/cloud-storage/macro_db_client/src/document/create_document.rs b/rust/cloud-storage/macro_db_client/src/document/create_document.rsdeleted file mode 100644index 8a486dcce1..0000000000--- a/rust/cloud-storage/macro_db_client/src/document/create_document.rs+++ /dev/null@@ -1,265 +0,0 @@-use models_permissions::share_permission::SharePermissionV2;-use sqlx::{Pool, Postgres};--use crate::history::upsert_item_last_accessed;-use crate::history::upsert_user_history;-use crate::share_permission::create::create_document_permission;-use model::document::DocumentMetadata;-use model::document::FileType;-use model::document::ID;-use model::document::VersionID;-use model::document::VersionIDWithTimeStamps;-use tracing::instrument;--/// Creates a new document-/// This includes a document, document instance, share permission, document-/// permission and document family.-#[instrument(skip(db))]-#[expect(clippy::too_many_arguments, reason = "too annoying to fix right now")]-pub async fn create_document(- db: Pool<Postgres>,- sha: &str,- document_name: &str,- user_id: &str,- file_type: Option<FileType>,- document_family_id: Option<i64>,- branched_from_id: Option<&str>,- branched_from_version_id: Option<i64>,- project_id: Option<&str>,- share_permission: &SharePermissionV2,-) -> anyhow::Result<DocumentMetadata> {- tracing::trace!("creating document");- let mut transaction = db.begin().await?;-- // Get project name if the project id exists- let project_name = if let Some(project_id) = project_id {- let project = sqlx::query!(- r#"- SELECT name FROM "Project" WHERE id = $1- "#,- project_id,- )- .fetch_one(&mut *transaction)- .await- .map_err(|err| {- tracing::error!(error=?err, project_id=%project_id, "unable to get project");- err- })?;-- Some(project.name)- } else {- None- };-- let document = sqlx::query_as!(- ID,- r#"- INSERT INTO "Document" (owner, name, "fileType", "documentFamilyId", "branchedFromId", "branchedFromVersionId", "projectId")- VALUES ($1, $2, $3, $4, $5, $6, $7)- RETURNING id;- "#,- user_id,- document_name,- file_type.map(|file_type| file_type.clone().as_str().to_string()),- document_family_id,- branched_from_id,- branched_from_version_id,- project_id,- )- .fetch_one(&mut *transaction)- .await- .map_err(|err| {- tracing::error!(error=?err, "unable to create document");- err- })?;-- let updated_document_family_id = match document_family_id {- Some(document_family_id) => document_family_id,- None => {- let document_family = sqlx::query_as!(- VersionID,- r#"- INSERT INTO "DocumentFamily" ("rootDocumentId")- VALUES ($1)- RETURNING id;- "#,- &document.id,- )- .fetch_one(&mut *transaction)- .await- .map_err(|err| {- tracing::error!(error=?err, document_id=?document.id, "unable to create document family");- anyhow::Error::msg("unable to create document family")- })?;-- let _ = sqlx::query!(- r#"- UPDATE "Document" SET "documentFamilyId" = $1 WHERE id = $2;- "#,- document_family.id,- document.id- )- .execute(&mut *transaction)- .await- .map_err(|err| {- tracing::error!(error=?err, document_id=?document.id, "unable to update document family for document");- anyhow::Error::msg("unable to update document family")- })?;- document_family.id- }- };-- // Docx documents have their versions associated with a DocumentBom- // whereas all other file types use DocumentInstance- let document_version = match file_type {- Some(FileType::Docx) => {- let document_bom = sqlx::query!(- r#"- INSERT INTO "DocumentBom" ("documentId")- VALUES ($1)- RETURNING id, "createdAt"::timestamptz as created_at, "updatedAt"::timestamptz as updated_at;- "#,- &document.id,- )- .fetch_one(&mut *transaction)- .await?;-- VersionIDWithTimeStamps {- id: document_bom.id,- created_at: document_bom.created_at,- updated_at: document_bom.updated_at,- sha: sha.to_string(),- }- }- _ => {- sqlx::query_as!(- VersionIDWithTimeStamps,- r#"- INSERT INTO "DocumentInstance" ("documentId", "sha")- VALUES ($1, $2)- RETURNING id, sha, "createdAt"::timestamptz as created_at, "updatedAt"::timestamptz as updated_at;- "#,- &document.id,- sha,- )- .fetch_one(&mut *transaction)- .await?- }- };-- create_document_permission(&mut transaction, &document.id, share_permission).await?;-- // Add item to user history for creator- upsert_user_history(&mut transaction, user_id, &document.id, "document").await?;- upsert_item_last_accessed(&mut transaction, &document.id, "document").await?;-- if let Err(err) = transaction.commit().await {- tracing::error!(- error=?err,- document_id=?document.id,- "transaction error",- );- return Err(anyhow::Error::msg("unable to create document"));- }-- Ok(DocumentMetadata::new_document(- &document.id,- document_version.id,- user_id,- document_name,- file_type,- document_version.sha.as_str(),- Some(updated_document_family_id),- branched_from_id,- branched_from_version_id,- project_id,- project_name.as_deref(),- document_version.created_at,- document_version.updated_at,- false, // TODO: @daniel please update this when you add in task creation in create document- // endpoint- ))-}--#[cfg(test)]-mod tests {- use super::*;- use sqlx::{Pool, Postgres};-- #[sqlx::test(fixtures(path = "../../fixtures", scripts("basic_user_with_documents")))]- async fn test_create_document(pool: Pool<Postgres>) -> anyhow::Result<()> {- sqlx::query!(- r#"INSERT INTO "Project" ("id", "name", "userId") VALUES ($1, $2, $3)"#,- "project-one",- "name",- "macro|[email protected]"- )- .execute(&pool)- .await?;-- // document exists- let document_metadata = create_document(- pool.clone(),- "sha",- "document-name",- "macro|[email protected]",- Some(FileType::Pdf),- None,- None,- None,- Some("project-one"),- &SharePermissionV2::default(),- )- .await?;-- assert_eq!(document_metadata.document_id.is_empty(), false);- assert_eq!(document_metadata.document_name, "document-name".to_string());- assert_eq!(document_metadata.owner, "macro|[email protected]".to_string());- assert_eq!(document_metadata.project_id.as_deref(), Some("project-one"));- assert_eq!(document_metadata.project_name.as_deref(), Some("name"));-- // document exists- let document_metadata = create_document(- pool.clone(),- "sha",- "document-name",- "macro|[email protected]",- Some(FileType::Docx),- None,- None,- None,- None,- &SharePermissionV2::default(),- )- .await?;-- assert!(!document_metadata.document_id.is_empty());- assert_eq!(document_metadata.document_name, "document-name".to_string());- assert_eq!(document_metadata.owner, "macro|[email protected]".to_string());-- Ok(())- }- #[sqlx::test(fixtures(path = "../../fixtures", scripts("basic_user_with_documents")))]- async fn test_create_document_no_user(pool: Pool<Postgres>) {- // document exists- let document_metadata = create_document(- pool.clone(),- "sha",- "document-name",- "macro|[email protected]",- Some(FileType::Pdf),- None,- None,- None,- None,- &SharePermissionV2::default(),- )- .await;-- assert_eq!(document_metadata.is_err(), true);- assert_eq!(- document_metadata.err().unwrap().to_string(),- "error returned from database: insert or update on table \"Document\" violates foreign key constraint \"Document_owner_fkey\"".to_string()- );- }-}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 e4141a2adb..3f7f7c439b 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@@ -1,6 +1,6 @@-use sqlx::{Pool, Postgres};-+use document_sub_type::DocumentSubType;use model::document::DocumentMetadata;+use sqlx::{Pool, Postgres};/// Used to get all documents in a paginated format#[tracing::instrument(skip(db))]@@ -43,10 +43,10 @@ pub async fn get_all_documents(d."projectId" as "project_id?",p.name as "project_name?",di.sha as "sha?",- (dt.document_id IS NOT NULL) as "is_task!"+ dt.sub_type as "sub_type?: DocumentSubType"FROM"Document" d- LEFT JOIN document_task dt ON dt.document_id = d.id+ LEFT JOIN document_sub_type dt ON dt.document_id = d.idLEFT JOIN LATERAL (SELECTb.id,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 e375711f8b..9479c3a734 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@@ -1,5 +1,6 @@use sqlx::{Pool, Postgres, Transaction};+use document_sub_type::DocumentSubType;use model::document::{BomPart, DocumentBasic, DocumentMetadata};/// Gets the documents name@@ -245,10 +246,10 @@ pub async fn get_document(d."projectId" as "project_id",p.name as "project_name?",di.sha as "sha?",- (dt.document_id IS NOT NULL) as "is_task!"+ dt.sub_type as "sub_type?: DocumentSubType"FROM"Document" d- LEFT JOIN document_task dt ON dt.document_id = d.id+ LEFT JOIN document_sub_type dt ON dt.document_id = d.idLEFT JOIN LATERAL (SELECTi.id,@@ -339,10 +340,10 @@ pub async fn get_document_version(d."projectId" as "project_id?",p.name as "project_name?",di.sha as "sha?",- (dt.document_id IS NOT NULL) as "is_task!"+ dt.sub_type as "sub_type?: DocumentSubType"FROM"Document" d- LEFT JOIN document_task dt ON dt.document_id = d.id+ LEFT JOIN document_sub_type dt ON dt.document_id = d.idLEFT JOIN LATERAL (SELECTi.id,diff --git a/rust/cloud-storage/macro_db_client/src/document/get_document_history.rs b/rust/cloud-storage/macro_db_client/src/document/get_document_history.rsindex 021fd40a76..e4fb64ed57 100644--- a/rust/cloud-storage/macro_db_client/src/document/get_document_history.rs+++ b/rust/cloud-storage/macro_db_client/src/document/get_document_history.rs@@ -1,4 +1,5 @@use chrono::{DateTime, Utc};+use document_sub_type::DocumentSubType;use std::collections::HashMap;#[derive(Debug, Clone, Default)]@@ -21,8 +22,8 @@ pub struct DocumentHistoryInfo {pub project_id: Option<String>,/// Deleted atpub deleted_at: Option<DateTime<Utc>>,- /// Whether the document is a task- pub is_task: bool,+ /// The sub type of the document if present. This is only applicable for md documents.+ pub sub_type: Option<DocumentSubType>,}/// Gets document history information including when a user last viewed each document@@ -49,10 +50,10 @@ pub async fn get_document_history_info(c."deletedAt" as "deleted_at?",uh."updatedAt" as "viewed_at?",c."projectId" as "project_id?",- (dt.document_id IS NOT NULL) as "is_task!"+ dt.sub_type as "sub_type?: DocumentSubType"FROM"Document" c- LEFT JOIN document_task dt ON dt.document_id = c.id+ LEFT JOIN document_sub_type dt ON dt.document_id = c.idLEFT JOIN"UserHistory" uh ON uh."itemId" = c."id"AND uh."userId" = $1@@ -85,7 +86,7 @@ pub async fn get_document_history_info(deleted_at: row.deleted_at.map(|dt| DateTime::<Utc>::from_naive_utc_and_offset(dt, Utc)),- is_task: row.is_task,+ sub_type: row.sub_type,};(row.item_id, info)})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 961cd2f017..b36091a131 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,10 +107,10 @@ pub async fn get_user_documents(d."projectId" as "project_id",p.name as "project_name",di.sha as "sha",- (dt.document_id IS NOT NULL) as "is_task"+ dt.sub_type as "sub_type"FROM"Document" d- LEFT JOIN document_task dt ON dt.document_id = d.id+ LEFT JOIN document_sub_type dt ON dt.document_id = d.idLEFT JOIN LATERAL (SELECTb.id,diff --git a/rust/cloud-storage/macro_db_client/src/document/initialize_onboarding_documents.rs b/rust/cloud-storage/macro_db_client/src/document/initialize_onboarding_documents.rsindex b2ef8dfa26..6a3cdd968c 100644--- a/rust/cloud-storage/macro_db_client/src/document/initialize_onboarding_documents.rs+++ b/rust/cloud-storage/macro_db_client/src/document/initialize_onboarding_documents.rs@@ -155,7 +155,7 @@ pub async fn create_onboarding_documents(created_at: None,updated_at: None,deleted_at: None,- is_task: false,+ sub_type: None,});});@@ -219,6 +219,6 @@ pub async fn create_onboarding_docx(created_at: None,updated_at: None,deleted_at: None,- is_task: false,+ sub_type: None,})}diff --git a/rust/cloud-storage/macro_db_client/src/document/mod.rs b/rust/cloud-storage/macro_db_client/src/document/mod.rsindex 3517356b40..af547ecb45 100644--- a/rust/cloud-storage/macro_db_client/src/document/mod.rs+++ b/rust/cloud-storage/macro_db_client/src/document/mod.rs@@ -1,4 +1,3 @@-mod create_document;mod delete_document;mod get_document;mod get_document_list;@@ -11,7 +10,6 @@ pub mod v2;pub mod copy_document;pub mod document_bom;-pub use create_document::*;pub use delete_document::*;pub use get_document::*;pub use get_document_list::*;diff --git a/rust/cloud-storage/macro_db_client/src/document/preview.rs b/rust/cloud-storage/macro_db_client/src/document/preview.rsindex 5c28fce262..4d8aa547fb 100644--- a/rust/cloud-storage/macro_db_client/src/document/preview.rs+++ b/rust/cloud-storage/macro_db_client/src/document/preview.rs@@ -1,5 +1,6 @@use std::collections::HashSet;+use document_sub_type::DocumentSubType;use model::document::{DocumentPreviewData, DocumentPreviewV2, WithDocumentId};#[tracing::instrument(skip(db))]@@ -16,9 +17,9 @@ pub async fn batch_get_document_preview_v2(d."fileType" as file_type,d.owner as owner,d."updatedAt"::timestamptz as "updated_at",- (dt.document_id IS NOT NULL) as "is_task!"+ dt.sub_type as "sub_type?: DocumentSubType"FROM "Document" d- LEFT JOIN document_task dt ON dt.document_id = d.id+ LEFT JOIN document_sub_type dt ON dt.document_id = d.idWHEREd."id" = ANY($1)"#,diff --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 52d5e90767..4db6ad1de4 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@@ -1,3 +1,4 @@+use document_sub_type::DocumentSubType;use sqlx::{PgPool, Postgres, Transaction, types::Uuid};use model::document::{@@ -562,12 +563,13 @@ pub async fn save_document(}};- let is_task = sqlx::query!(+ let sub_type: Option<DocumentSubType> = sqlx::query!(r#"- SELECT document_id FROM document_task WHERE document_id = $1+ SELECT sub_type as "sub_type: DocumentSubType" FROM document_sub_type WHERE document_id = $1"#,document_id)+ .map(|row| row.sub_type).fetch_optional(&mut *transaction).await?;@@ -592,7 +594,7 @@ pub async fn save_document(project_name,created_at: document_version.created_at,updated_at: document_version.updated_at,- is_task: is_task.is_some(),+ sub_type,})}diff --git a/rust/cloud-storage/macro_db_client/src/document/v2/create.rs b/rust/cloud-storage/macro_db_client/src/document/v2/create.rsindex 8c6659f4cb..60dd883207 100644--- a/rust/cloud-storage/macro_db_client/src/document/v2/create.rs+++ b/rust/cloud-storage/macro_db_client/src/document/v2/create.rs@@ -1,5 +1,6 @@use crate::history::{upsert_item_last_accessed_timestamp, upsert_user_history_timestamp};use crate::share_permission::create::create_document_permission;+use document_sub_type::DocumentSubType;use model::document::DocumentMetadata;use model::document::FileType;use model::document::ID;@@ -127,7 +128,7 @@ pub async fn create_document_txn(.id};- if is_task {+ let sub_type: Option<DocumentSubType> = if is_task {if file_type != Some(FileType::Md) {return Err(anyhow::anyhow!("is_task is only applicable for md documents"@@ -136,14 +137,19 @@ pub async fn create_document_txn(sqlx::query!(r#"- INSERT INTO document_task (document_id)- VALUES ($1)+ INSERT INTO document_sub_type (document_id, sub_type)+ VALUES ($1, $2)"#,- document_id+ document_id,+ DocumentSubType::Task as _).execute(&mut **transaction).await?;- }++ Some(DocumentSubType::Task)+ } else {+ None+ };// Docx documents have their versions associated with a DocumentBom// whereas all other file types use DocumentInstance@@ -229,7 +235,7 @@ pub async fn create_document_txn(project_name,document_version.created_at,document_version.updated_at,- is_task,+ sub_type,))}diff --git a/rust/cloud-storage/macro_db_client/src/history/mod.rs b/rust/cloud-storage/macro_db_client/src/history/mod.rsindex 494e955ac4..ca28f433c1 100644--- a/rust/cloud-storage/macro_db_client/src/history/mod.rs+++ b/rust/cloud-storage/macro_db_client/src/history/mod.rs@@ -4,6 +4,7 @@ mod upsert_history;pub use delete_history::*;pub use upsert_history::*;+use document_sub_type::DocumentSubType;use model::item::{Item,map_item::{map_chat_item, map_document_item, map_project_item},@@ -37,9 +38,9 @@ pub async fn get_user_history(db: &Pool<Postgres>, user_id: &str) -> anyhow::Resd."deletedAt"::timestamptz as "deleted_at",NULL as "is_persistent",di.sha as "sha",- (dt.document_id IS NOT NULL) as "is_task!"+ dt.sub_type as "sub_type?: DocumentSubType"FROM "Document" d- LEFT JOIN document_task dt ON dt.document_id = d.id+ LEFT JOIN document_sub_type dt ON dt.document_id = d.idINNER JOIN UserHistories uh ON uh.item_id = d.id AND uh.item_type = 'document'LEFT JOIN LATERAL (SELECT@@ -84,7 +85,7 @@ pub async fn get_user_history(db: &Pool<Postgres>, user_id: &str) -> anyhow::Resc."deletedAt"::timestamptz as "deleted_at",c."isPersistent" as "is_persistent",NULL as "sha",- false as "is_task"+ NULL as "sub_type"FROM "Chat" cINNER JOIN UserHistories uh ON uh.item_id = c.id AND uh.item_type = 'chat'UNION ALL@@ -104,7 +105,7 @@ pub async fn get_user_history(db: &Pool<Postgres>, user_id: &str) -> anyhow::Resp."deletedAt"::timestamptz as "deleted_at",NULL as "is_persistent",NULL as "sha",- false as "is_task"+ NULL as "sub_type"FROM "Project" pINNER JOIN UserHistories uh ON uh.item_id = p.id AND uh.item_type = 'project')@@ -129,7 +130,7 @@ pub async fn get_user_history(db: &Pool<Postgres>, user_id: &str) -> anyhow::Resr.branched_from_id,r.branched_from_version_id,r.project_id,- r.is_task,+ r.sub_type,).map_err(|e| sqlx::Error::TypeNotFound {type_name: e.to_string(),diff --git a/rust/cloud-storage/macro_db_client/src/pins/mod.rs b/rust/cloud-storage/macro_db_client/src/pins/mod.rsindex e9265afadf..995c0b8fb6 100644--- a/rust/cloud-storage/macro_db_client/src/pins/mod.rs+++ b/rust/cloud-storage/macro_db_client/src/pins/mod.rs@@ -1,4 +1,5 @@use anyhow::Context;+use document_sub_type::DocumentSubType;use sqlx::{Pool, Postgres};use model::{@@ -79,10 +80,10 @@ pub async fn get_pins(db: Pool<Postgres>, user_id: &str) -> anyhow::Result<Vec<Pd."projectId" as "project_id",di.sha as "sha",NULL as "is_persistent",- (dt.document_id IS NOT NULL) as "is_task!",+ dt.sub_type as "sub_type?: DocumentSubType",pi.pin_index as "pin_index"FROM "Document" d- LEFT JOIN document_task dt ON dt.document_id = d.id+ LEFT JOIN document_sub_type dt ON dt.document_id = d.idINNER JOIN PinnedItems pi ON pi.pin_item_id = d.id AND pi.pin_item_type = 'document'LEFT JOIN LATERAL (SELECT@@ -126,7 +127,7 @@ pub async fn get_pins(db: Pool<Postgres>, user_id: &str) -> anyhow::Result<Vec<Pc."projectId" as "project_id",NULL as "sha",c."isPersistent" as "is_persistent",- false as "is_task",+ NULL as sub_type,pi.pin_index as "pin_index"FROM "Chat" cINNER JOIN PinnedItems pi ON pi.pin_item_id = c.id AND pi.pin_item_type = 'chat'@@ -146,7 +147,7 @@ pub async fn get_pins(db: Pool<Postgres>, user_id: &str) -> anyhow::Result<Vec<Pp."parentId" as "project_id",NULL as "sha",NULL as "is_persistent",- false as "is_task",+ NULL as sub_type,pi.pin_index as "pin_index"FROM "Project" pINNER JOIN PinnedItems pi ON pi.pin_item_id = p.id AND pi.pin_item_type = 'project'@@ -178,7 +179,7 @@ pub async fn get_pins(db: Pool<Postgres>, user_id: &str) -> anyhow::Result<Vec<Pr.branched_from_id,r.branched_from_version_id,r.project_id,- r.is_task,+ r.sub_type,).map_err(|e| sqlx::Error::TypeNotFound {type_name: e.to_string(),diff --git a/rust/cloud-storage/macro_db_client/src/projects/get_project/get_sub_items.rs b/rust/cloud-storage/macro_db_client/src/projects/get_project/get_sub_items.rsindex 69d4e78861..d0ad72f8ba 100644--- a/rust/cloud-storage/macro_db_client/src/projects/get_project/get_sub_items.rs+++ b/rust/cloud-storage/macro_db_client/src/projects/get_project/get_sub_items.rs@@ -1,3 +1,4 @@+use document_sub_type::DocumentSubType;use model::{chat::Chat, document::BasicDocument, project::Project};/// Gets all deleted sub-projects of a given project.@@ -85,10 +86,10 @@ pub async fn get_sub_documents(d."createdAt"::timestamptz as created_at,d."updatedAt"::timestamptz as updated_at,d."projectId" as "project_id?",- (dt.document_id IS NOT NULL) as "is_task!"+ dt.sub_type as "sub_type?: DocumentSubType"FROM"Document" d- LEFT JOIN document_task dt ON dt.document_id = d.id+ LEFT JOIN document_sub_type dt ON dt.document_id = d.idLEFT JOIN LATERAL (SELECTb.id@@ -133,7 +134,7 @@ pub async fn get_sub_documents(created_at: row.created_at,updated_at: row.updated_at,deleted_at: None, // Don't care about the deleted_at- is_task: row.is_task,+ sub_type: row.sub_type,}}).fetch_all(transaction.as_mut())diff --git a/rust/cloud-storage/macro_db_client/src/recents/deleted.rs b/rust/cloud-storage/macro_db_client/src/recents/deleted.rsindex 8b1519d5fd..d76ec67785 100644--- a/rust/cloud-storage/macro_db_client/src/recents/deleted.rs+++ b/rust/cloud-storage/macro_db_client/src/recents/deleted.rs@@ -1,3 +1,4 @@+use document_sub_type::DocumentSubType;use model::item::{Item,map_item::{map_chat_item, map_document_item, map_project_item},@@ -25,9 +26,9 @@ pub async fn get_recently_deleted(d."deletedAt"::timestamptz as "deleted_at",d."projectId" as "project_id",NULL as "is_persistent",- (dt.document_id IS NOT NULL) as "is_task!"+ dt.sub_type as "sub_type?: DocumentSubType"FROM "Document" d- LEFT JOIN document_task dt ON dt.document_id = d.id+ LEFT JOIN document_sub_type dt ON dt.document_id = d.idLEFT JOIN LATERAL (SELECTb.id@@ -64,7 +65,7 @@ pub async fn get_recently_deleted(c."deletedAt"::timestamptz as "deleted_at",c."projectId" as "project_id",c."isPersistent" as "is_persistent",- false as "is_task"+ NULL as "sub_type"FROM "Chat" cWHERE c."userId" = $1 AND c."deletedAt" IS NOT NULLUNION ALL@@ -80,7 +81,7 @@ pub async fn get_recently_deleted(p."deletedAt"::timestamptz as "deleted_at",p."parentId" as "project_id",NULL as "is_persistent",- false as "is_task"+ NULL as "sub_type"FROM "Project" pWHERE p."userId" = $1 AND p."deletedAt" IS NOT NULLORDER BY deleted_at DESC@@ -103,7 +104,7 @@ pub async fn get_recently_deleted(None, // don't care about branched_from_idNone, // don't care about branched_from_version_idr.project_id,- r.is_task,+ r.sub_type,).map_err(|e| sqlx::Error::TypeNotFound {type_name: e.to_string(),diff --git a/rust/cloud-storage/model/Cargo.toml b/rust/cloud-storage/model/Cargo.tomlindex 88063246a0..099c1f2bdc 100644--- a/rust/cloud-storage/model/Cargo.toml+++ b/rust/cloud-storage/model/Cargo.toml@@ -34,3 +34,4 @@ thiserror.workspace = truetracing = { workspace = true }utoipa = { workspace = true, features = ["axum_extras", "chrono"] }uuid = { workspace = true }+document_sub_type = { path = "../document_sub_type" }diff --git a/rust/cloud-storage/model/src/activity/map_item.rs b/rust/cloud-storage/model/src/activity/map_item.rsindex 03fa42ce55..cf57a3ae73 100644--- a/rust/cloud-storage/model/src/activity/map_item.rs+++ b/rust/cloud-storage/model/src/activity/map_item.rs@@ -1,3 +1,5 @@+use document_sub_type::DocumentSubType;+use crate::{chat::Chat, document::BasicDocument};#[expect(@@ -17,7 +19,7 @@ pub fn map_document_item(branched_from_id: Option<String>,branched_from_version_id: Option<i64>,project_id: Option<String>,- is_task: bool,+ sub_type: Option<DocumentSubType>,) -> anyhow::Result<BasicDocument> {Ok(BasicDocument {document_id: id,@@ -33,7 +35,7 @@ pub fn map_document_item(branched_from_id,branched_from_version_id,project_id,- is_task,+ sub_type,})}diff --git a/rust/cloud-storage/model/src/document/mod.rs b/rust/cloud-storage/model/src/document/mod.rsindex f07669cd7f..e52d32cf94 100644--- a/rust/cloud-storage/model/src/document/mod.rs+++ b/rust/cloud-storage/model/src/document/mod.rs@@ -1,6 +1,7 @@use chrono::serde::ts_seconds_option;pub mod list;pub mod response;+use document_sub_type::DocumentSubType;use utoipa::ToSchema;mod file_type;@@ -85,9 +86,9 @@ pub struct BasicDocument {#[schema(value_type = i64, nullable=true)]pub deleted_at: Option<chrono::DateTime<chrono::Utc>>,- /// Whether or not the document is a task.- /// This is only applicable for md documents.- pub is_task: bool,+ /// The sub type of the document if present.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub sub_type: Option<DocumentSubType>,}#[derive(sqlx::FromRow, serde::Serialize, serde::Deserialize, Eq, PartialEq, Debug, Clone)]@@ -116,7 +117,6 @@ pub struct BackfillSearchDocumentInformation {pub owner: String,pub file_type: FileType,}-#[derive(sqlx::FromRow,serde::Serialize,@@ -181,9 +181,9 @@ pub struct DocumentMetadata {#[schema(value_type = i64, nullable=false)]pub updated_at: Option<chrono::DateTime<chrono::Utc>>,- /// Whether or not the document is a task.- /// This is only applicable for md documents.- pub is_task: bool,+ /// The sub type of the document if present.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub sub_type: Option<DocumentSubType>,}impl DocumentMetadata {@@ -221,7 +221,7 @@ impl DocumentMetadata {project_name,created_at,updated_at,- is_task: false,+ sub_type: None,}}@@ -244,7 +244,7 @@ impl DocumentMetadata {project_name: Option<&str>,created_at: Option<chrono::DateTime<chrono::Utc>>,updated_at: Option<chrono::DateTime<chrono::Utc>>,- is_task: bool,+ sub_type: Option<DocumentSubType>,) -> Self {Self {document_id: document_id.to_string(),@@ -262,7 +262,7 @@ impl DocumentMetadata {project_name: project_name.map(|s| s.to_string()),created_at,updated_at,- is_task,+ sub_type,}}@@ -285,7 +285,7 @@ impl DocumentMetadata {project_name: Option<String>,created_at: Option<chrono::DateTime<chrono::Utc>>,updated_at: Option<chrono::DateTime<chrono::Utc>>,- is_task: bool,+ sub_type: Option<DocumentSubType>,) -> Self {Self {document_id: document_id.to_string(),@@ -303,7 +303,7 @@ impl DocumentMetadata {project_name,created_at,updated_at,- is_task,+ sub_type,}}}@@ -333,9 +333,9 @@ pub struct DocumentPreviewData {#[serde(with = "ts_seconds_option")]#[schema(value_type = i64, nullable=false)]pub updated_at: Option<chrono::DateTime<chrono::Utc>>,- /// Whether or not the document is a task.- /// This is only applicable for md documents.- pub is_task: bool,+ /// The sub type of the document if present.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub sub_type: Option<DocumentSubType>,}#[derive(diff --git a/rust/cloud-storage/model/src/document/response/mod.rs b/rust/cloud-storage/model/src/document/response/mod.rsindex 2d3aae99a8..46a70817e6 100644--- a/rust/cloud-storage/model/src/document/response/mod.rs+++ b/rust/cloud-storage/model/src/document/response/mod.rs@@ -1,5 +1,6 @@mod location;+use document_sub_type::DocumentSubType;pub use location::*;use std::str::FromStr;@@ -127,9 +128,9 @@ pub struct DocumentResponseMetadata {#[serde(with = "ts_seconds_option")]#[schema(value_type = i64, nullable=false)]pub updated_at: Option<chrono::DateTime<chrono::Utc>>,- /// Whether or not the document is a task.- /// This is only applicable for md documents.- pub is_task: bool,+ /// The sub type of the document if present.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub sub_type: Option<DocumentSubType>,}impl DocumentResponseMetadata {@@ -149,7 +150,7 @@ impl DocumentResponseMetadata {document_family_id: document_metadata.document_family_id,created_at: document_metadata.created_at,updated_at: document_metadata.updated_at,- is_task: document_metadata.is_task,+ sub_type: document_metadata.sub_type,}}diff --git a/rust/cloud-storage/model/src/item/map_item.rs b/rust/cloud-storage/model/src/item/map_item.rsindex 870d6f08f5..ede9958d92 100644--- a/rust/cloud-storage/model/src/item/map_item.rs+++ b/rust/cloud-storage/model/src/item/map_item.rs@@ -1,3 +1,5 @@+use document_sub_type::DocumentSubType;+use crate::{chat::Chat, document::BasicDocument, project::Project};#[expect(@@ -18,7 +20,7 @@ pub fn map_document_item(branched_from_id: Option<String>,branched_from_version_id: Option<i64>,project_id: Option<String>,- is_task: bool,+ sub_type: Option<DocumentSubType>,) -> anyhow::Result<BasicDocument> {Ok(BasicDocument {document_id: id,@@ -34,7 +36,7 @@ pub fn map_document_item(branched_from_id,branched_from_version_id,project_id,- is_task,+ sub_type,})}diff --git a/rust/cloud-storage/models_search/Cargo.toml b/rust/cloud-storage/models_search/Cargo.tomlindex d18b930696..c470c5d067 100644--- a/rust/cloud-storage/models_search/Cargo.toml+++ b/rust/cloud-storage/models_search/Cargo.toml@@ -14,3 +14,4 @@ serde = { workspace = true }serde_json = { workspace = true }strum = { workspace = true }utoipa = { workspace = true }+document_sub_type = { path = "../document_sub_type" }diff --git a/rust/cloud-storage/models_search/src/document.rs b/rust/cloud-storage/models_search/src/document.rsindex 34934da490..5ca1f61f7b 100644--- a/rust/cloud-storage/models_search/src/document.rs+++ b/rust/cloud-storage/models_search/src/document.rs@@ -1,3 +1,4 @@+use document_sub_type::DocumentSubType;use item_filters::DocumentFilters;use schemars::JsonSchema;use serde::{Deserialize, Serialize};@@ -37,8 +38,8 @@ pub struct DocumentSearchResponseItem {pub document_name: String,/// The file type of the documentpub file_type: Option<String>,- /// Whether the document is a task- pub is_task: bool,+ /// The sub type of the document if present.+ pub sub_type: Option<DocumentSubType>,/// The search results for the document/// This may be empty if the search result match was on the document name onlypub document_search_results: Vec<DocumentSearchResult>,diff --git a/rust/cloud-storage/models_soup/Cargo.toml b/rust/cloud-storage/models_soup/Cargo.tomlindex 1d5c6b4f72..4b295999eb 100644--- a/rust/cloud-storage/models_soup/Cargo.toml+++ b/rust/cloud-storage/models_soup/Cargo.toml@@ -20,3 +20,4 @@ serde = { workspace = true }strum = { workspace = true }utoipa = { workspace = true, optional = true }uuid = { workspace = true }+document_sub_type = { path = "../document_sub_type" }diff --git a/rust/cloud-storage/models_soup/src/document.rs b/rust/cloud-storage/models_soup/src/document.rsindex 8065b3e2ec..98f5aad473 100644--- a/rust/cloud-storage/models_soup/src/document.rs+++ b/rust/cloud-storage/models_soup/src/document.rs@@ -1,4 +1,5 @@use chrono::Utc;+use document_sub_type::DocumentSubType;use macro_user_id::user_id::MacroUserIdStr;use uuid::Uuid;@@ -62,7 +63,7 @@ pub struct SoupDocument {#[cfg_attr(feature = "schema", schema(value_type = i64, nullable = true))]pub viewed_at: Option<chrono::DateTime<Utc>>,- /// Whether or not the document is a task.- /// This is only applicable for md documents.- pub is_task: bool,+ /// The sub type of the document if present.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub sub_type: Option<DocumentSubType>,}diff --git a/rust/cloud-storage/search_service/Cargo.toml b/rust/cloud-storage/search_service/Cargo.tomlindex 89024f3ddc..8135a13e90 100644--- a/rust/cloud-storage/search_service/Cargo.toml+++ b/rust/cloud-storage/search_service/Cargo.toml@@ -41,6 +41,7 @@ utoipa-swagger-ui = { workspace = true }item_filters = { path = "../item_filters" }thiserror = { workspace = true }models_opensearch = { path = "../models_opensearch" }+document_sub_type = { path = "../document_sub_type" }[dev-dependencies]macro_auth = { path = "../macro_auth", features = ["testing"] }diff --git a/rust/cloud-storage/search_service/src/api/search/document.rs b/rust/cloud-storage/search_service/src/api/search/document.rsindex 1d13d5af58..d6c0de5ee1 100644--- a/rust/cloud-storage/search_service/src/api/search/document.rs+++ b/rust/cloud-storage/search_service/src/api/search/document.rs@@ -154,7 +154,7 @@ pub fn construct_search_result(document_name: info.file_name,owner_id: info.owner,file_type: info.file_type,- is_task: info.is_task,+ sub_type: info.sub_type,document_search_results: hits,},})diff --git a/rust/cloud-storage/search_service/src/api/search/document/test.rs b/rust/cloud-storage/search_service/src/api/search/document/test.rsindex 6c598a16f7..50afaad2a6 100644--- a/rust/cloud-storage/search_service/src/api/search/document/test.rs+++ b/rust/cloud-storage/search_service/src/api/search/document/test.rs@@ -44,7 +44,7 @@ fn test_construct_search_result_single_document() {file_name: "Test Document".to_string(),owner: "user1".to_string(),deleted_at: None,- is_task: false,+ sub_type: None,},);@@ -124,7 +124,7 @@ fn test_construct_search_result_multiple_nodes_same_document() {owner: "user_1".to_string(),deleted_at: None,file_type: Some("pdf".to_string()),- is_task: false,+ sub_type: None,},);@@ -419,7 +419,7 @@ fn test_document_history_deleted() {file_type: Some("pdf".to_string()),owner: "user_1".to_string(),file_name: "name".to_string(),- is_task: false,+ sub_type: None,},);diff --git a/rust/cloud-storage/search_service/src/api/swagger.rs b/rust/cloud-storage/search_service/src/api/swagger.rsindex 16a8f12bde..f049d2df26 100644--- a/rust/cloud-storage/search_service/src/api/swagger.rs+++ b/rust/cloud-storage/search_service/src/api/swagger.rs@@ -1,3 +1,4 @@+use document_sub_type::DocumentSubType;use utoipa::OpenApi;use crate::api::{health, search};@@ -61,6 +62,7 @@ use models_search::{MatchType, SearchHighlight};EmptyResponse,MatchType,SearchHighlight,+ DocumentSubType,// DocumentFileType, DocumentSearchRequest, DocumentSearchResult, DocumentSearchResponseItem, DocumentSearchResponse,diff --git a/rust/cloud-storage/soup/.sqlx/query-459855355e37d708a9d6118da102a4457168c72c972bbad8d4748a2cb269b0e5.json b/rust/cloud-storage/soup/.sqlx/query-459855355e37d708a9d6118da102a4457168c72c972bbad8d4748a2cb269b0e5.jsondeleted file mode 100644index f52e6e3f78..0000000000--- a/rust/cloud-storage/soup/.sqlx/query-459855355e37d708a9d6118da102a4457168c72c972bbad8d4748a2cb269b0e5.json+++ /dev/null@@ -1,122 +0,0 @@-{- "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.document_id IS NOT NULL) as \"is_task!\",\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 FROM \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\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 false as \"is_task\",\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 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 false as \"is_task\",\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 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": [- {- "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": "is_task!",- "type_info": "Bool"- },- {- "ordinal": 15,- "name": "viewed_at",- "type_info": "Timestamptz"- },- {- "ordinal": 16,- "name": "sort_ts!",- "type_info": "Timestamptz"- }- ],- "parameters": {- "Left": [- "Text",- "Text",- "Int8",- "Timestamptz",- "Text"- ]- },- "nullable": [- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null- ]- },- "hash": "459855355e37d708a9d6118da102a4457168c72c972bbad8d4748a2cb269b0e5"-}diff --git a/rust/cloud-storage/soup/.sqlx/query-4636b3a76ef00d0fc743f3bff7ccd78991dc75ec953c61a96ef107df174b2a89.json b/rust/cloud-storage/soup/.sqlx/query-4636b3a76ef00d0fc743f3bff7ccd78991dc75ec953c61a96ef107df174b2a89.jsondeleted file mode 100644index 6206d8d77c..0000000000--- a/rust/cloud-storage/soup/.sqlx/query-4636b3a76ef00d0fc743f3bff7ccd78991dc75ec953c61a96ef107df174b2a89.json+++ /dev/null@@ -1,122 +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.document_id IS NOT NULL) as \"is_task!\",\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 FROM \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\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 false as \"is_task\",\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 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 false as \"is_task\",\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 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": "is_task!",- "type_info": "Bool"- },- {- "ordinal": 15,- "name": "viewed_at",- "type_info": "Timestamptz"- },- {- "ordinal": 16,- "name": "sort_ts!",- "type_info": "Timestamptz"- }- ],- "parameters": {- "Left": [- "Text",- "Text",- "Int8",- "Timestamptz",- "Text"- ]- },- "nullable": [- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null- ]- },- "hash": "4636b3a76ef00d0fc743f3bff7ccd78991dc75ec953c61a96ef107df174b2a89"-}diff --git a/rust/cloud-storage/soup/.sqlx/query-50f36bd210dc628eafa42eeaba1f2e5ddeb8d28b19270e843dd3b6420c3f4653.json b/rust/cloud-storage/soup/.sqlx/query-50f36bd210dc628eafa42eeaba1f2e5ddeb8d28b19270e843dd3b6420c3f4653.jsonnew file mode 100644index 0000000000..ad794e1904--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-50f36bd210dc628eafa42eeaba1f2e5ddeb8d28b19270e843dd3b6420c3f4653.json@@ -0,0 +1,131 @@+{+ "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 FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\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 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 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"+ }+ ],+ "parameters": {+ "Left": [+ "Text",+ "Text",+ "Int8",+ "Timestamptz",+ "Text"+ ]+ },+ "nullable": [+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null+ ]+ },+ "hash": "50f36bd210dc628eafa42eeaba1f2e5ddeb8d28b19270e843dd3b6420c3f4653"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-688f7bb9d9bbf0bc1e5a7e6a4aeb19c80824db2df3df2fc22e15c48af8ef6413.json b/rust/cloud-storage/soup/.sqlx/query-688f7bb9d9bbf0bc1e5a7e6a4aeb19c80824db2df3df2fc22e15c48af8ef6413.jsonnew file mode 100644index 0000000000..afca3974ff--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-688f7bb9d9bbf0bc1e5a7e6a4aeb19c80824db2df3df2fc22e15c48af8ef6413.json@@ -0,0 +1,131 @@+{+ "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 FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\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 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 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"+ }+ ],+ "parameters": {+ "Left": [+ "Text",+ "Text",+ "Int8",+ "Timestamptz",+ "Text"+ ]+ },+ "nullable": [+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null+ ]+ },+ "hash": "688f7bb9d9bbf0bc1e5a7e6a4aeb19c80824db2df3df2fc22e15c48af8ef6413"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-68e324da11741f98e638a23ba950e89f44afd3c4e26ee90e59904ea77bf1f981.json b/rust/cloud-storage/soup/.sqlx/query-68e324da11741f98e638a23ba950e89f44afd3c4e26ee90e59904ea77bf1f981.jsondeleted file mode 100644index 608288bfdc..0000000000--- a/rust/cloud-storage/soup/.sqlx/query-68e324da11741f98e638a23ba950e89f44afd3c4e26ee90e59904ea77bf1f981.json+++ /dev/null@@ -1,122 +0,0 @@-{- "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.document_id IS NOT NULL) as \"is_task!\",\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 FROM \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\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 false as \"is_task\",\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 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 false as \"is_task\",\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 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": [- {- "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": "is_task!",- "type_info": "Bool"- },- {- "ordinal": 15,- "name": "viewed_at",- "type_info": "Timestamptz"- },- {- "ordinal": 16,- "name": "sort_ts!",- "type_info": "Timestamptz"- }- ],- "parameters": {- "Left": [- "Text",- "Text",- "Int8",- "Timestamptz",- "Text"- ]- },- "nullable": [- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null- ]- },- "hash": "68e324da11741f98e638a23ba950e89f44afd3c4e26ee90e59904ea77bf1f981"-}diff --git a/rust/cloud-storage/soup/.sqlx/query-70e96ea014a65745e18085a6d6ee8efe50102744d45efd6cd01838d69361871d.json b/rust/cloud-storage/soup/.sqlx/query-70e96ea014a65745e18085a6d6ee8efe50102744d45efd6cd01838d69361871d.jsonnew file mode 100644index 0000000000..2d5f53971a--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-70e96ea014a65745e18085a6d6ee8efe50102744d45efd6cd01838d69361871d.json@@ -0,0 +1,131 @@+{+ "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 FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\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 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 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": [+ {+ "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"+ }+ ],+ "parameters": {+ "Left": [+ "Text",+ "Text",+ "Int8",+ "Timestamptz",+ "Text"+ ]+ },+ "nullable": [+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null+ ]+ },+ "hash": "70e96ea014a65745e18085a6d6ee8efe50102744d45efd6cd01838d69361871d"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-738f9b58274f884ba0276d6c64baef93ee515506157e3aaccca06f708ee4dc2d.json b/rust/cloud-storage/soup/.sqlx/query-738f9b58274f884ba0276d6c64baef93ee515506157e3aaccca06f708ee4dc2d.jsonnew file mode 100644index 0000000000..e51903bed0--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-738f9b58274f884ba0276d6c64baef93ee515506157e3aaccca06f708ee4dc2d.json@@ -0,0 +1,131 @@+{+ "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 FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\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 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 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": [+ {+ "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"+ }+ ],+ "parameters": {+ "Left": [+ "Text",+ "Text",+ "Int8",+ "Timestamptz",+ "Text"+ ]+ },+ "nullable": [+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null+ ]+ },+ "hash": "738f9b58274f884ba0276d6c64baef93ee515506157e3aaccca06f708ee4dc2d"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-798bee060040707282eea0e9204b73f859ebb7de05deefba7f5e03019be71ee5.json b/rust/cloud-storage/soup/.sqlx/query-798bee060040707282eea0e9204b73f859ebb7de05deefba7f5e03019be71ee5.jsondeleted file mode 100644index a89c9bd33a..0000000000--- a/rust/cloud-storage/soup/.sqlx/query-798bee060040707282eea0e9204b73f859ebb7de05deefba7f5e03019be71ee5.json+++ /dev/null@@ -1,121 +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.document_id IS NOT NULL) as \"is_task!\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n d.\"updatedAt\"::timestamptz as \"sort_ts!\"\n FROM \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\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 false as \"is_task\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n c.\"updatedAt\"::timestamptz as \"sort_ts!\"\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 false as \"is_task\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n p.\"updatedAt\"::timestamptz as \"sort_ts!\"\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": "is_task!",- "type_info": "Bool"- },- {- "ordinal": 15,- "name": "viewed_at",- "type_info": "Timestamptz"- },- {- "ordinal": 16,- "name": "sort_ts!",- "type_info": "Timestamptz"- }- ],- "parameters": {- "Left": [- "Text",- "TextArray",- "TextArray",- "TextArray"- ]- },- "nullable": [- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null- ]- },- "hash": "798bee060040707282eea0e9204b73f859ebb7de05deefba7f5e03019be71ee5"-}diff --git a/rust/cloud-storage/soup/.sqlx/query-d3e11b3bf100dd1eb5fb77bc34d73a660f5e9cef395665bdd4e55a786261f2af.json b/rust/cloud-storage/soup/.sqlx/query-b1d22e50a96c22f0e887e594c17b058c7affaddbeb727707eb860ec8ff511235.jsonsimilarity index 62%rename from rust/cloud-storage/soup/.sqlx/query-d3e11b3bf100dd1eb5fb77bc34d73a660f5e9cef395665bdd4e55a786261f2af.jsonrename to rust/cloud-storage/soup/.sqlx/query-b1d22e50a96c22f0e887e594c17b058c7affaddbeb727707eb860ec8ff511235.jsonindex c500afa018..ab38d5ed61 100644--- a/rust/cloud-storage/soup/.sqlx/query-d3e11b3bf100dd1eb5fb77bc34d73a660f5e9cef395665bdd4e55a786261f2af.json+++ b/rust/cloud-storage/soup/.sqlx/query-b1d22e50a96c22f0e887e594c17b058c7affaddbeb727707eb860ec8ff511235.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.document_id IS NOT NULL) as \"is_task!\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\"\n FROM \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\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 false as \"is_task\",\n uh.\"updatedAt\"::timestamptz as \"viewed_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 ",+ "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 FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\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 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": [{@@ -75,8 +75,17 @@},{"ordinal": 14,- "name": "is_task!",- "type_info": "Bool"+ "name": "sub_type?: DocumentSubType",+ "type_info": {+ "Custom": {+ "name": "document_sub_type_value",+ "kind": {+ "Enum": [+ "task"+ ]+ }+ }+ }},{"ordinal": 15,@@ -110,5 +119,5 @@null]},- "hash": "d3e11b3bf100dd1eb5fb77bc34d73a660f5e9cef395665bdd4e55a786261f2af"+ "hash": "b1d22e50a96c22f0e887e594c17b058c7affaddbeb727707eb860ec8ff511235"}diff --git a/rust/cloud-storage/soup/.sqlx/query-d8658c4258ac6b3e9508a4c38b52c807d046220a7bd0db09e279ece161a586e6.json b/rust/cloud-storage/soup/.sqlx/query-d8658c4258ac6b3e9508a4c38b52c807d046220a7bd0db09e279ece161a586e6.jsondeleted file mode 100644index b69959befc..0000000000--- a/rust/cloud-storage/soup/.sqlx/query-d8658c4258ac6b3e9508a4c38b52c807d046220a7bd0db09e279ece161a586e6.json+++ /dev/null@@ -1,122 +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.document_id IS NOT NULL) as \"is_task!\",\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 FROM \"Document\" d\n LEFT JOIN document_task dt ON dt.document_id = d.id\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 false as \"is_task\",\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 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 false as \"is_task\",\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 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": "is_task!",- "type_info": "Bool"- },- {- "ordinal": 15,- "name": "viewed_at",- "type_info": "Timestamptz"- },- {- "ordinal": 16,- "name": "sort_ts!",- "type_info": "Timestamptz"- }- ],- "parameters": {- "Left": [- "Text",- "Text",- "Int8",- "Timestamptz",- "Text"- ]- },- "nullable": [- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null- ]- },- "hash": "d8658c4258ac6b3e9508a4c38b52c807d046220a7bd0db09e279ece161a586e6"-}diff --git a/rust/cloud-storage/soup/.sqlx/query-fa139f4c10ab3adb0f4beb6205604f4f1a8b45ecb1a11e6d729375b2426e9e93.json b/rust/cloud-storage/soup/.sqlx/query-fa139f4c10ab3adb0f4beb6205604f4f1a8b45ecb1a11e6d729375b2426e9e93.jsonnew file mode 100644index 0000000000..42d8607305--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-fa139f4c10ab3adb0f4beb6205604f4f1a8b45ecb1a11e6d729375b2426e9e93.json@@ -0,0 +1,130 @@+{+ "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 FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\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 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 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"+ }+ ],+ "parameters": {+ "Left": [+ "Text",+ "TextArray",+ "TextArray",+ "TextArray"+ ]+ },+ "nullable": [+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null+ ]+ },+ "hash": "fa139f4c10ab3adb0f4beb6205604f4f1a8b45ecb1a11e6d729375b2426e9e93"+}diff --git a/rust/cloud-storage/soup/Cargo.toml b/rust/cloud-storage/soup/Cargo.tomlindex 6bcfb99f32..8cb98ef163 100644--- a/rust/cloud-storage/soup/Cargo.toml+++ b/rust/cloud-storage/soup/Cargo.toml@@ -47,6 +47,7 @@ tokio = { workspace = true, features = ["macros"], optional = true }tracing = { workspace = true }utoipa = { workspace = true, optional = true }uuid = { workspace = true }+document_sub_type = { path = "../document_sub_type" }[dev-dependencies]cool_asserts = "2"diff --git a/rust/cloud-storage/soup/src/domain/service/tests.rs b/rust/cloud-storage/soup/src/domain/service/tests.rsindex 35c8b6a178..aec79915fc 100644--- a/rust/cloud-storage/soup/src/domain/service/tests.rs+++ b/rust/cloud-storage/soup/src/domain/service/tests.rs@@ -1,6 +1,7 @@use crate::domain::ports::MockSoupRepo;use chrono::Days;use cool_asserts::assert_matches;+use document_sub_type::DocumentSubType;use email::domain::models::{EmailErr, EnrichedEmailThreadPreview, PreviewView};use frecency::domain::models::FrecencyPageResponse;use frecency::domain::ports::MockFrecencyQueryService;@@ -87,7 +88,7 @@ fn soup_document_uuid_with_updated(id: Uuid, updated_at: DateTime<Utc>) -> SoupDcreated_at: Default::default(),updated_at,viewed_at: Default::default(),- is_task: false,+ sub_type: Some(DocumentSubType::Task),}}diff --git a/rust/cloud-storage/soup/src/outbound/pg_soup_repo.rs b/rust/cloud-storage/soup/src/outbound/pg_soup_repo.rsindex 01d7f0cfb5..93ab22b815 100644--- a/rust/cloud-storage/soup/src/outbound/pg_soup_repo.rs+++ b/rust/cloud-storage/soup/src/outbound/pg_soup_repo.rs@@ -167,7 +167,7 @@ macro_rules! map_soup_type {created_at: r.created_at,updated_at: r.updated_at,viewed_at: r.viewed_at,- is_task: r.is_task,+ sub_type: r.sub_type,},)),"chat" => Ok(::models_soup::item::SoupItem::Chat(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 0a2e7d8635..4b94b471ca 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@@ -1,5 +1,6 @@use crate::map_soup_type;use crate::outbound::pg_soup_repo::type_err;+use document_sub_type::DocumentSubType;use macro_user_id::cowlike::CowLike;use macro_user_id::user_id::MacroUserIdStr;use models_pagination::{Frecency, Query, SimpleSortMethod};@@ -86,7 +87,7 @@ r#"d."projectId" as "project_id",NULL as "is_persistent",di.sha as "sha",- (dt.document_id IS NOT NULL) as "is_task!",+ dt.sub_type as "sub_type?: DocumentSubType",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", d."updatedAt")@@ -95,7 +96,7 @@ r#"ELSE d."updatedAt"END::timestamptz as "sort_ts!"FROM "Document" d- LEFT JOIN document_task dt ON dt.document_id = d.id+ LEFT JOIN document_sub_type dt ON dt.document_id = d.idINNER 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" = $1@@ -132,7 +133,7 @@ r#"c."projectId" as "project_id",c."isPersistent" as "is_persistent",NULL as "sha",- false as "is_task",+ NULL as "sub_type",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", c."updatedAt")@@ -162,7 +163,7 @@ r#"p."parentId" as "project_id",NULL as "is_persistent",NULL as "sha",- false as "is_task",+ NULL as "sub_type",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", p."updatedAt")@@ -274,7 +275,7 @@ r#"d."projectId" as "project_id",NULL as "is_persistent",di.sha as "sha",- (dt.document_id IS NOT NULL) as "is_task!",+ dt.sub_type as "sub_type?: DocumentSubType",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", d."updatedAt")@@ -283,7 +284,7 @@ r#"ELSE d."updatedAt"END::timestamptz as "sort_ts!"FROM "Document" d- LEFT JOIN document_task dt ON dt.document_id = d.id+ LEFT JOIN document_sub_type dt ON dt.document_id = d.idINNER 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" = $1@@ -320,7 +321,7 @@ r#"c."projectId" as "project_id",c."isPersistent" as "is_persistent",NULL as "sha",- false as "is_task",+ NULL as "sub_type",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", c."updatedAt")@@ -350,7 +351,7 @@ r#"p."parentId" as "project_id",NULL as "is_persistent",NULL as "sha",- false as "is_task",+ NULL as "sub_type",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", p."updatedAt")diff --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 6c1842569d..5566d4a53d 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@@ -1,4 +1,5 @@use crate::{map_soup_type, outbound::pg_soup_repo::type_err};+use document_sub_type::DocumentSubType;use macro_user_id::{cowlike::CowLike, user_id::MacroUserIdStr};use model_entity::{Entity, EntityType};use models_soup::item::SoupItem;@@ -91,10 +92,10 @@ pub async fn expanded_soup_by_ids<'a>(d."projectId" as "project_id",NULL as "is_persistent",di.sha as "sha",- (dt.document_id IS NOT NULL) as "is_task!",+ dt.sub_type as "sub_type?: DocumentSubType",uh."updatedAt"::timestamptz as "viewed_at"FROM "Document" d- LEFT JOIN document_task dt ON dt.document_id = d.id+ LEFT JOIN document_sub_type dt ON dt.document_id = d.idINNER JOIN UserAccessibleItems uaiON uai.item_id = d.idAND uai.item_type = 'document'@@ -136,7 +137,7 @@ pub async fn expanded_soup_by_ids<'a>(c."projectId" as "project_id",c."isPersistent" as "is_persistent",NULL as "sha",- false as "is_task",+ NULL as "sub_type",uh."updatedAt"::timestamptz as "viewed_at"FROM "Chat" cINNER JOIN UserAccessibleItems uaidiff --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 c19810bd82..ca4663e4cf 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@@ -4,6 +4,7 @@use std::str::FromStr;use chrono::{DateTime, Utc};+use document_sub_type::DocumentSubType;use filter_ast::Expr;use item_filters::ast::{EntityFilterAst, chat::ChatLiteral, document::DocumentLiteral, project::ProjectLiteral,@@ -77,7 +78,7 @@ static DOCUMENT_CLAUSE: &str = r#"d."projectId" as "project_id",NULL as "is_persistent",di.sha as "sha",- (dt.document_id IS NOT NULL) as "is_task",+ dt.sub_type as "sub_type",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", d."updatedAt")@@ -86,7 +87,7 @@ static DOCUMENT_CLAUSE: &str = r#"ELSE d."updatedAt"END::timestamptz as "sort_ts"FROM "Document" d- LEFT JOIN document_task dt ON dt.document_id = d.id+ LEFT JOIN document_sub_type dt ON dt.document_id = d.idINNER 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" = $1@@ -123,7 +124,7 @@ static CHAT_CLAUSE: &str = r#"c."projectId" as "project_id",c."isPersistent" as "is_persistent",NULL as "sha",- false as "is_task",+ NULL as "sub_type",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", c."updatedAt")@@ -153,7 +154,7 @@ static PROJECT_CLAUSE: &str = r#"p."parentId" as "project_id",NULL as "is_persistent",NULL as "sha",- false as "is_task",+ NULL as "sub_type",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", p."updatedAt")@@ -311,7 +312,7 @@ struct DocumentRow {created_at: DateTime<Utc>,updated_at: DateTime<Utc>,viewed_at: Option<DateTime<Utc>>,- is_task: bool,+ sub_type: Option<DocumentSubType>,}#[derive(Debug, FromRow)]@@ -376,7 +377,7 @@ impl SoupRow {created_at,updated_at,viewed_at,- is_task,+ sub_type,}) => SoupItem::Document(SoupDocument {id: Uuid::parse_str(&id).map_err(type_err)?,document_version_id: document_version_id@@ -403,7 +404,7 @@ impl SoupRow {created_at,updated_at,viewed_at,- is_task,+ sub_type,}),SoupRow::Chat(ChatRow {id,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 aa037b7ebe..93cf37426d 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@@ -1,4 +1,5 @@use crate::{map_soup_type, outbound::pg_soup_repo::type_err};+use document_sub_type::DocumentSubType;use macro_user_id::{cowlike::CowLike, user_id::MacroUserIdStr};use models_pagination::{Query, SimpleSortMethod};use models_soup::item::SoupItem;@@ -58,7 +59,7 @@ pub async fn unexpanded_generic_cursor_soup(d."projectId" as "project_id",NULL as "is_persistent",di.sha as "sha",- (dt.document_id IS NOT NULL) as "is_task!",+ dt.sub_type as "sub_type?: DocumentSubType",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", d."updatedAt")@@ -67,7 +68,7 @@ pub async fn unexpanded_generic_cursor_soup(ELSE d."updatedAt"END::timestamptz as "sort_ts!"FROM "Document" d- LEFT JOIN document_task dt ON dt.document_id = d.id+ LEFT JOIN document_sub_type dt ON dt.document_id = d.idINNER JOIN UserAccessibleItems uaiON uai.item_id = d.idAND uai.item_type = 'document'@@ -108,7 +109,7 @@ pub async fn unexpanded_generic_cursor_soup(c."projectId" as "project_id",c."isPersistent" as "is_persistent",NULL as "sha",- false as "is_task",+ NULL as "sub_type",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", c."updatedAt")@@ -143,7 +144,7 @@ pub async fn unexpanded_generic_cursor_soup(p."parentId" as "project_id",NULL as "is_persistent",NULL as "sha",- false as "is_task",+ NULL as "sub_type",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", p."updatedAt")@@ -232,7 +233,7 @@ pub async fn no_frecency_unexpanded_generic_cursor_soup(d."projectId" as "project_id",NULL as "is_persistent",di.sha as "sha",- (dt.document_id IS NOT NULL) as "is_task!",+ dt.sub_type as "sub_type?: DocumentSubType",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", d."updatedAt")@@ -241,7 +242,7 @@ pub async fn no_frecency_unexpanded_generic_cursor_soup(ELSE d."updatedAt"END::timestamptz as "sort_ts!"FROM "Document" d- LEFT JOIN document_task dt ON dt.document_id = d.id+ LEFT JOIN document_sub_type dt ON dt.document_id = d.idINNER JOIN UserAccessibleItems uaiON uai.item_id = d.idAND uai.item_type = 'document'@@ -282,7 +283,7 @@ pub async fn no_frecency_unexpanded_generic_cursor_soup(c."projectId" as "project_id",c."isPersistent" as "is_persistent",NULL as "sha",- false as "is_task",+ NULL as "sub_type",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", c."updatedAt")@@ -317,7 +318,7 @@ pub async fn no_frecency_unexpanded_generic_cursor_soup(p."parentId" as "project_id",NULL as "is_persistent",NULL as "sha",- false as "is_task",+ NULL as "sub_type",uh."updatedAt"::timestamptz as "viewed_at",CASE $2WHEN 'viewed_updated' THEN COALESCE(uh."updatedAt", p."updatedAt")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 f60cf1703a..b2a1b2154f 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@@ -1,4 +1,5 @@use crate::{map_soup_type, outbound::pg_soup_repo::type_err};+use document_sub_type::DocumentSubType;use macro_user_id::{cowlike::CowLike, user_id::MacroUserIdStr};use model_entity::{Entity, EntityType};use models_soup::item::SoupItem;@@ -66,11 +67,11 @@ pub async fn unexpanded_soup_by_ids<'a>(d."projectId" as "project_id",NULL as "is_persistent",di.sha as "sha",- (dt.document_id IS NOT NULL) as "is_task!",+ dt.sub_type as "sub_type?: DocumentSubType",uh."updatedAt"::timestamptz as "viewed_at",d."updatedAt"::timestamptz as "sort_ts!"FROM "Document" d- LEFT JOIN document_task dt ON dt.document_id = d.id+ LEFT JOIN document_sub_type dt ON dt.document_id = d.idINNER JOIN UserAccessibleItems uaiON uai.item_id = d.idAND uai.item_type = 'document'@@ -112,7 +113,7 @@ pub async fn unexpanded_soup_by_ids<'a>(c."projectId" as "project_id",c."isPersistent" as "is_persistent",NULL as "sha",- false as "is_task",+ NULL as "sub_type",uh."updatedAt"::timestamptz as "viewed_at",c."updatedAt"::timestamptz as "sort_ts!"FROM "Chat" c@@ -143,7 +144,7 @@ pub async fn unexpanded_soup_by_ids<'a>(p."parentId" as "project_id",NULL as "is_persistent",NULL as "sha",- false as "is_task",+ NULL as "sub_type",uh."updatedAt"::timestamptz as "viewed_at",p."updatedAt"::timestamptz as "sort_ts!"FROM "Project" p