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
add [properties] - add isCompleted flag for documents (#748)
Daniel Kweond0140a9e020e
diff --git a/js/app/packages/app/component/EntityActionsMenuItems.tsx b/js/app/packages/app/component/EntityActionsMenuItems.tsxindex 2e11045326..4cf5307318 100644--- a/js/app/packages/app/component/EntityActionsMenuItems.tsx+++ b/js/app/packages/app/component/EntityActionsMenuItems.tsx@@ -92,7 +92,7 @@ export const EntityActionsMenuItems = (props: EntityActionsMenuItemsProps) => {const { fileType, id, subType } = props.entity;splitManager.createNewSplit({content: {- type: fileTypeToBlockName(subType ?? fileType),+ type: fileTypeToBlockName(subType?.type ?? fileType),id,},referredFrom: 'entity-actions-menu',diff --git a/js/app/packages/app/component/ItemDragAndDrop.tsx b/js/app/packages/app/component/ItemDragAndDrop.tsxindex 6255409acb..c9dc5a3d83 100644--- a/js/app/packages/app/component/ItemDragAndDrop.tsx+++ b/js/app/packages/app/component/ItemDragAndDrop.tsx@@ -28,7 +28,7 @@ export function ItemDragOverlay() {if (!data) return 'default';if (data.type === 'document') {- return fileTypeToBlockName(data.subType ?? data.fileType, true);+ return fileTypeToBlockName(data.subType?.type ?? data.fileType, true);}if (data.type === 'channel') {diff --git a/js/app/packages/app/component/UnifiedListView.tsx b/js/app/packages/app/component/UnifiedListView.tsxindex 5d471fd08b..01f1bfb53f 100644--- a/js/app/packages/app/component/UnifiedListView.tsx+++ b/js/app/packages/app/component/UnifiedListView.tsx@@ -1113,7 +1113,7 @@ export function UnifiedListView(props: UnifiedListViewProps) {let entityPath: string;if (entity.type === 'document') {const { fileType, subType } = entity;- const blockName = fileTypeToBlockName(subType ?? fileType);+ const blockName = fileTypeToBlockName(subType?.type ?? fileType);entityPath = `/app/${blockName}/${entity.id}`;} else {entityPath = `/app/${entity.type}/${entity.id}`;diff --git a/js/app/packages/app/component/command/KonsoleItem.tsx b/js/app/packages/app/component/command/KonsoleItem.tsxindex 73b1932c8e..58769b713b 100644--- a/js/app/packages/app/component/command/KonsoleItem.tsx+++ b/js/app/packages/app/component/command/KonsoleItem.tsx@@ -263,7 +263,7 @@ type ItemPreview = {id: string;name: string;fileType?: BasicDocumentFileType;- subType?: BasicDocumentSubType;+ subType?: BasicDocumentSubType | null;itemType: Item['type'];};@@ -444,7 +444,7 @@ function getCommandItemBlockName(): BlockName | BlockAlias | undefined {if (item.type === 'item') {if (item.data.itemType === 'document') {- if (item.data.subType === 'task') {+ if (item.data.subType?.type === 'task') {return 'task';}if (item.data.fileType) {@@ -512,14 +512,14 @@ export function filterItemByCategory(item: CommandItemCard) {return (item.type === 'item' &&item.data.itemType === 'document' &&- item.data.subType !== 'task' &&+ item.data.subType?.type !== 'task' &&fileTypeToBlockName(item.data.fileType) === 'md');case 'Tasks':return (item.type === 'item' &&item.data.itemType === 'document' &&- item.data.subType === 'task'+ item.data.subType?.type === 'task');case 'Chats':return item.type === 'item' && item.data.itemType === 'chat';diff --git a/js/app/packages/app/component/soupContextHelpers.ts b/js/app/packages/app/component/soupContextHelpers.tsindex 758e474bac..2e1396a71e 100644--- a/js/app/packages/app/component/soupContextHelpers.ts+++ b/js/app/packages/app/component/soupContextHelpers.ts@@ -116,7 +116,7 @@ async function openDocument(} = options;const { id, fileType, subType } = entity;- const blockName = fileTypeToBlockName(subType ?? fileType);+ const blockName = fileTypeToBlockName(subType?.type ?? fileType);// Create or replace split based on openInNewSplit optionconst handle = openInNewSplitdiff --git a/js/app/packages/block-md/component/ComposeTask.tsx b/js/app/packages/block-md/component/ComposeTask.tsxindex 6fa54806a3..a07e1651b9 100644--- a/js/app/packages/block-md/component/ComposeTask.tsx+++ b/js/app/packages/block-md/component/ComposeTask.tsx@@ -187,7 +187,10 @@ function TaskToastPreview(props: { title: string; body: string; id: string }) {<EntityIcon targetType="task" /><span class="text-base font-medium">{props.title ||- itemToSafeName({ type: 'document', subType: 'task' })}+ itemToSafeName({+ type: 'document',+ subType: { type: 'task' },+ })}</span></div><div class="text-ink-muted text-sm h-fit max-h-18 w-full truncate">diff --git a/js/app/packages/core/component/DocumentPreview.tsx b/js/app/packages/core/component/DocumentPreview.tsxindex d7c0ecc386..06155f56f3 100644--- a/js/app/packages/core/component/DocumentPreview.tsx+++ b/js/app/packages/core/component/DocumentPreview.tsx@@ -582,7 +582,7 @@ export function PopupPreview(props: {<EntityIcontargetType={type === 'document'- ? (subType ?? fileType)+ ? (subType?.type ?? fileType): type}size="md"diff --git a/js/app/packages/core/component/ItemPreview.tsx b/js/app/packages/core/component/ItemPreview.tsxindex 382ca8c125..370066a688 100644--- a/js/app/packages/core/component/ItemPreview.tsx+++ b/js/app/packages/core/component/ItemPreview.tsx@@ -12,9 +12,9 @@ import TrashSimple from '@icon/duotone/trash-simple-duotone.svg';import User from '@icon/duotone/user-duotone.svg';import ThreeUsersIcon from '@icon/duotone/users-three-duotone.svg';import LoadingSpinner from '@icon/regular/spinner.svg';+import type { NamedSubType } from '@macro-entity';import type { ChannelType } from '@service-cognition/generated/schemas/channelType';import type { ItemType } from '@service-storage/client';-import type { BasicDocumentSubType } from '@service-storage/generated/schemas';import type { FileType } from '@service-storage/generated/schemas/fileType';import {insertProjectIntoHistory,@@ -71,7 +71,7 @@ function useItemPreviewData(props: ItemPreviewProps) {type: ItemPreviewProps['itemType'],id: string,fileType?: FileType,- subType?: BasicDocumentSubType,+ subType?: NamedSubType,altKey?: boolean) {if (type === 'project') {@@ -211,7 +211,7 @@ export function ItemPreview(props: ItemPreviewProps) {{(accessibleItem) => {const itemData = accessibleItem();const fileType = itemData.fileType;- const subType = itemData.subType;+ const subType = itemData.subType?.type;const navHandlers =useSplitNavigationHandler<HTMLButtonElement>((e) =>onPreviewClick(@@ -281,7 +281,7 @@ export function InlineItemPreview(props: ItemPreviewProps) {{(accessibleItem) => {const itemData = accessibleItem();const fileType = itemData.fileType;- const subType = itemData.subType;+ const subType = itemData.subType?.type;return (<span class="inline-flex items-center gap-1"><span class="w-4 h-4">diff --git a/js/app/packages/core/component/LexicalMarkdown/component/decorator/DocumentCard.tsx b/js/app/packages/core/component/LexicalMarkdown/component/decorator/DocumentCard.tsxindex 5a329ceaa2..e55f149474 100644--- a/js/app/packages/core/component/LexicalMarkdown/component/decorator/DocumentCard.tsx+++ b/js/app/packages/core/component/LexicalMarkdown/component/decorator/DocumentCard.tsx@@ -341,7 +341,7 @@ export function DocumentCard(props: DocumentCardDecoratorProps) {<EntityIcontargetType={props.item.type === 'document'- ? (props.item.subType ?? props.item.fileType)+ ? (props.item.subType?.type ?? props.item.fileType): props.item.type}size="sm"diff --git a/js/app/packages/core/component/LexicalMarkdown/component/decorator/DocumentMention.tsx b/js/app/packages/core/component/LexicalMarkdown/component/decorator/DocumentMention.tsxindex c73e6c5803..57c249e0db 100644--- a/js/app/packages/core/component/LexicalMarkdown/component/decorator/DocumentMention.tsx+++ b/js/app/packages/core/component/LexicalMarkdown/component/decorator/DocumentMention.tsx@@ -131,7 +131,7 @@ function InlinePreview(props: {fallback={<EntityIcontargetType={- type === 'document' ? (subType ?? fileType) : type+ type === 'document' ? (subType?.type ?? fileType) : type}size="fill"theme={diff --git a/js/app/packages/core/component/LexicalMarkdown/utils/mentionsUtils.ts b/js/app/packages/core/component/LexicalMarkdown/utils/mentionsUtils.tsindex 26dc8e750f..45a561ace1 100644--- a/js/app/packages/core/component/LexicalMarkdown/utils/mentionsUtils.ts+++ b/js/app/packages/core/component/LexicalMarkdown/utils/mentionsUtils.ts@@ -69,7 +69,7 @@ export const getCombinedEntityBlockName = (case 'item':if (item.data.type === 'document')return fileTypeToBlockName(- item.data.subType || item.data.fileType,+ item.data.subType?.type ?? item.data.fileType,icon);if (item.data.type === 'chat') return 'chat';diff --git a/js/app/packages/core/component/Properties/component/modal/shared/PropertyEntitySelector.tsx b/js/app/packages/core/component/Properties/component/modal/shared/PropertyEntitySelector.tsxindex 8541ff2049..60f9e48f49 100644--- a/js/app/packages/core/component/Properties/component/modal/shared/PropertyEntitySelector.tsx+++ b/js/app/packages/core/component/Properties/component/modal/shared/PropertyEntitySelector.tsx@@ -138,7 +138,10 @@ function getEntityType(entity: CombinedEntity): string {case 'channel':return 'CHANNEL';case 'item':- if (entity.data.type === 'document' && entity.data.subType === 'task') {+ if (+ entity.data.type === 'document' &&+ entity.data.subType?.type === 'task'+ ) {return 'TASK';}return entity.data.type.toUpperCase();@@ -176,7 +179,7 @@ function getEntityIcon(entity: CombinedEntity) {case 'item': {const blockName =entity.data.type === 'document'- ? entity.data.subType === 'task'+ ? entity.data.subType?.type === 'task'? 'task': fileTypeToBlockName(entity.data.fileType, true): entity.data.type === 'chat'@@ -321,7 +324,9 @@ export function PropertyEntitySelector(props: EntityInputProps) {if (specificEntityType === 'TASK') {return history()- .filter((item) => item.type === 'document' && item.subType === 'task')+ .filter(+ (item) => item.type === 'document' && item.subType?.type === 'task'+ ).map(entityMapper('item'));}@@ -331,7 +336,7 @@ export function PropertyEntitySelector(props: EntityInputProps) {.filter((item) =>item.type.toUpperCase() === specificEntityType &&- !(item.type === 'document' && item.subType === 'task')+ !(item.type === 'document' && item.subType?.type === 'task')).map(entityMapper('item'));}diff --git a/js/app/packages/core/component/Properties/hooks/usePropertyEntityDisplay.tsx b/js/app/packages/core/component/Properties/hooks/usePropertyEntityDisplay.tsxindex cb85eb9339..9d31e7cad3 100644--- a/js/app/packages/core/component/Properties/hooks/usePropertyEntityDisplay.tsx+++ b/js/app/packages/core/component/Properties/hooks/usePropertyEntityDisplay.tsx@@ -154,7 +154,7 @@ export function usePropertyEntityDisplay(}// Tasks are documents with subType 'task'- if (previewItem.subType === 'task') {+ if (previewItem.subType?.type === 'task') {return <CoreEntityIcon targetType="task" size="xs" />;}@@ -214,7 +214,7 @@ export function usePropertyEntityDisplay(return null;}// Tasks are documents with subType 'task'- if (previewItem.subType === 'task') {+ if (previewItem.subType?.type === 'task') {return 'task';}return previewItem.fileType || null;diff --git a/js/app/packages/core/component/Properties/hooks/useTaskProperties.ts b/js/app/packages/core/component/Properties/hooks/useTaskProperties.tsindex 2232f3e65e..5586e45002 100644--- a/js/app/packages/core/component/Properties/hooks/useTaskProperties.ts+++ b/js/app/packages/core/component/Properties/hooks/useTaskProperties.ts@@ -1,3 +1,4 @@+import type { SubType } from '@macro-entity';import { useBulkEntityPropertiesQuery } from '@queries/properties/bulk';import { createMemo } from 'solid-js';import { SYSTEM_PROPERTY_IDS } from '../constants';@@ -8,7 +9,7 @@ export type TaskPropertiesStore = Record<string, Property[]>;interface Entity {id: string;type: string;- subType?: string | null;+ subType?: SubType;}const TASK_PROPERTY_DEFINITION_IDS = [@@ -19,8 +20,8 @@ const TASK_PROPERTY_DEFINITION_IDS = [function isTaskEntity(entity: Entity-): entity is Entity & { type: 'document'; subType: 'task' } {- return entity.type === 'document' && entity.subType === 'task';+): entity is Entity & { type: 'document'; subType: { type: 'task' } } {+ return entity.type === 'document' && entity.subType?.type === 'task';}export function useTaskProperties(diff --git a/js/app/packages/core/constant/allBlocks.ts b/js/app/packages/core/constant/allBlocks.tsindex 51a109769d..277dd494d5 100644--- a/js/app/packages/core/constant/allBlocks.ts+++ b/js/app/packages/core/constant/allBlocks.ts@@ -6,6 +6,7 @@ import {type FileTypeString,type MimeType,} from '@core/block';+import type { SubType } from '@macro-entity';import type { ItemType } from '@service-storage/client';import type { BasicDocumentFileType } from '@service-storage/generated/schemas/basicDocumentFileType';import { ENABLE_DOCX_TO_PDF } from './featureFlags';@@ -205,7 +206,7 @@ export function blockNameToDefaultFile(block?: BlockName | string | null) {type ItemLike = {type: ItemType;fileType?: BasicDocumentFileType;- subType?: string | null;+ subType?: SubType;name?: string;};@@ -214,15 +215,16 @@ type ItemLike = {* @example* itemToBlockName({ type: 'document', fileType: 'docx' }) // 'write'* itemToBlockName({ type: 'document', fileType: 'py' }) // 'code'- * itemToBlockName({ type: 'document', fileType: 'md', subType: 'task' }) // 'task'+ * itemToBlockName({ type: 'document', fileType: 'md', subType: { type: 'task', is_completed: false } }) // 'task'* itemToBlockName({ type: 'chat' }) // 'chat'* @return The block name or undefined if there is no appropriate block.*/export function itemToBlockName(item: ItemLike): BlockName | BlockAlias | undefined {- if (item.subType && isBlockAlias(item.subType)) {- return item.subType;+ const subTypeName = item.subType?.type;+ if (subTypeName && isBlockAlias(subTypeName)) {+ return subTypeName;}if (item.fileType) {return fileTypeToBlockName(item.fileType);diff --git a/js/app/packages/core/signal/preview.ts b/js/app/packages/core/signal/preview.tsindex f3f025dc16..c38fa1dfa1 100644--- a/js/app/packages/core/signal/preview.ts+++ b/js/app/packages/core/signal/preview.ts@@ -1,12 +1,12 @@import { itemToSafeName } from '@core/constant/allBlocks';import { debounce } from '@core/util/debounce';import { isErr } from '@core/util/maybeResult';+import type { SubType } from '@macro-entity';import { cognitionApiServiceClient } from '@service-cognition/client';import type { ChannelType } from '@service-cognition/generated/schemas/channelType';import { commsServiceClient } from '@service-comms/client';import { emailClient } from '@service-email/client';import { type ItemType, storageServiceClient } from '@service-storage/client';-import type { DocumentSubType } from '@service-storage/generated/schemas';import type { FileType } from '@service-storage/generated/schemas/fileType';import { syncServiceClient } from '@service-sync/client';import { type Accessor, createEffect, createSignal } from 'solid-js';@@ -36,7 +36,7 @@ export type PreviewItemAccess = {loading: false;name: string;fileType?: FileType;- subType?: DocumentSubType;+ subType?: SubType;channelType?: never;} & BasePreviewItem<Exclude<ItemType, 'project'>>;@@ -54,7 +54,7 @@ export type PreviewDocumentAccess = {loading: false;name: string;fileType: FileType;- subType?: DocumentSubType;+ subType?: SubType;channelType?: never;} & BasePreviewItem<'document'>;diff --git a/js/app/packages/core/util/getItemBlockName.ts b/js/app/packages/core/util/getItemBlockName.tsindex f7616823f2..67d0c90890 100644--- a/js/app/packages/core/util/getItemBlockName.ts+++ b/js/app/packages/core/util/getItemBlockName.ts@@ -3,6 +3,6 @@ import type { Item } from '@service-storage/generated/schemas/item';export function getItemBlockName(item: Item, icon?: boolean) {if (item.type === 'document')- return fileTypeToBlockName(item.subType ?? item.fileType, icon);+ return fileTypeToBlockName(item.subType?.type ?? item.fileType, icon);return item.type;}diff --git a/js/app/packages/macro-entity/src/queries/search.ts b/js/app/packages/macro-entity/src/queries/search.tsindex 0b7f52b199..64717db618 100644--- a/js/app/packages/macro-entity/src/queries/search.ts+++ b/js/app/packages/macro-entity/src/queries/search.ts@@ -194,7 +194,7 @@ const useMapSearchResponseItem = () => {}return {type: 'document',- subType: result.sub_type ?? undefined,+ subType: result.sub_type === 'task' ? { type: 'task' } : null,id: result.document_id,name: result.name || blockNameToDefaultFile(result.file_type),ownerId: result.owner_id,diff --git a/js/app/packages/macro-entity/src/types/entity.ts b/js/app/packages/macro-entity/src/types/entity.tsindex e17e03956f..ed20a85ecd 100644--- a/js/app/packages/macro-entity/src/types/entity.ts+++ b/js/app/packages/macro-entity/src/types/entity.ts@@ -36,17 +36,26 @@ export type ChatEntity = EntityBase & {projectId?: string;};+/** Named sub types - currently only 'task' */+export type NamedSubType = 'task';++/** SubType for documents - currently only tasks */+export type SubType = {+ type: NamedSubType;+ is_completed?: boolean;+} | null;+export type BaseDocumentEntity = EntityBase & {type: 'document';fileType?: string;projectId?: string;- subType?: string;+ subType?: SubType;};export type TaskEntity = EntityBase & {type: 'document';fileType: 'md';- subType: 'task';+ subType: { type: 'task'; is_completed?: boolean };projectId?: string;};@@ -59,8 +68,6 @@ export type MarkdownEntity = EntityBase & {export type DocumentEntity = BaseDocumentEntity | MarkdownEntity;-export type NamedSubType = 'task';-export const getEntityProjectId = (e: EntityData): string | false => {return 'projectId' in e ? (e.projectId ?? false) : false;};@@ -111,19 +118,19 @@ export const isTaskEntity = (entity: EntityData): entity is TaskEntity => {return (entity.type === 'document' &&entity.fileType === 'md' &&- entity.subType === 'task'+ entity.subType?.type === 'task');};export const isPureDocumentEntity = (entity: EntityData): entity is DocumentEntity => {- return entity.type === 'document' && !entity.subType;+ return entity.type === 'document' && entity.subType?.type !== 'task';};export type EntityType = EntityData['type'];-export type ExpandedEntityType = EntityType | NamedSubType;+export type ExpandedEntityType = EntityType | 'task';export type EntityOf<K extends EntityType> = Extract<EntityData, { type: K }>;diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/basicDocument.ts b/js/app/packages/service-clients/service-storage/generated/schemas/basicDocument.tsindex 1492e01326..7de77c30a9 100644--- a/js/app/packages/service-clients/service-storage/generated/schemas/basicDocument.ts+++ b/js/app/packages/service-clients/service-storage/generated/schemas/basicDocument.ts@@ -11,7 +11,7 @@ import type { BasicDocumentDocumentFamilyId } from './basicDocumentDocumentFamilimport type { BasicDocumentFileType } from './basicDocumentFileType';import type { BasicDocumentProjectId } from './basicDocumentProjectId';import type { BasicDocumentSha } from './basicDocumentSha';-import type { BasicDocumentSubType } from './basicDocumentSubType';+import type { BasicDocumentSubTypeProperty } from './basicDocumentSubTypeProperty';import type { BasicDocumentType } from './basicDocumentType';export interface BasicDocument {@@ -44,7 +44,7 @@ the file type *//** If the document is a PDF, this is the SHA of the pdfIf the document is a DOCX, this will not be present */sha?: BasicDocumentSha;- subType?: BasicDocumentSubType;+ subType?: BasicDocumentSubTypeProperty;/** The time the document instance / document BOM was updated */updatedAt: number;type: BasicDocumentType;diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/basicDocumentSubType.ts b/js/app/packages/service-clients/service-storage/generated/schemas/basicDocumentSubType.tsindex 03cda11227..d33c9979ce 100644--- a/js/app/packages/service-clients/service-storage/generated/schemas/basicDocumentSubType.ts+++ b/js/app/packages/service-clients/service-storage/generated/schemas/basicDocumentSubType.ts@@ -4,6 +4,10 @@* document_storage_service* OpenAPI spec version: 0.1.0*/-import type { DocumentSubType } from './documentSubType';+import type { BasicDocumentSubTypeOneOf } from './basicDocumentSubTypeOneOf';-export type BasicDocumentSubType = null | DocumentSubType;+/**+ * Sub type of a document with associated properties encoded in each variant.+This ensures type-safety: task properties only exist when the document is a task.+ */+export type BasicDocumentSubType = BasicDocumentSubTypeOneOf;diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/basicDocumentSubTypeOneOf.ts b/js/app/packages/service-clients/service-storage/generated/schemas/basicDocumentSubTypeOneOf.tsnew file mode 100644index 0000000000..cb8c7d6853--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/basicDocumentSubTypeOneOf.ts@@ -0,0 +1,17 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */+import type { BasicDocumentSubTypeOneOfType } from './basicDocumentSubTypeOneOfType';++/**+ * A task document with its associated properties+ */+export type BasicDocumentSubTypeOneOf = {+ /** Whether the task is completed.+True if the Status property is set to "Completed". */+ is_completed: boolean;+ type: BasicDocumentSubTypeOneOfType;+};diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/basicDocumentSubTypeOneOfType.ts b/js/app/packages/service-clients/service-storage/generated/schemas/basicDocumentSubTypeOneOfType.tsnew file mode 100644index 0000000000..5956f36fbc--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/basicDocumentSubTypeOneOfType.ts@@ -0,0 +1,14 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */++export type BasicDocumentSubTypeOneOfType = typeof BasicDocumentSubTypeOneOfType[keyof typeof BasicDocumentSubTypeOneOfType];+++// eslint-disable-next-line @typescript-eslint/no-redeclare+export const BasicDocumentSubTypeOneOfType = {+ task: 'task',+} as const;diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/basicDocumentSubTypeProperty.ts b/js/app/packages/service-clients/service-storage/generated/schemas/basicDocumentSubTypeProperty.tsnew file mode 100644index 0000000000..c0ca7e502c--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/basicDocumentSubTypeProperty.ts@@ -0,0 +1,9 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */+import type { BasicDocumentSubType } from './basicDocumentSubType';++export type BasicDocumentSubTypeProperty = null | BasicDocumentSubType;diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/documentPreviewData.ts b/js/app/packages/service-clients/service-storage/generated/schemas/documentPreviewData.tsindex f2216f7776..01ccb69859 100644--- a/js/app/packages/service-clients/service-storage/generated/schemas/documentPreviewData.ts+++ b/js/app/packages/service-clients/service-storage/generated/schemas/documentPreviewData.ts@@ -5,7 +5,7 @@* OpenAPI spec version: 0.1.0*/import type { DocumentPreviewDataFileType } from './documentPreviewDataFileType';-import type { DocumentPreviewDataSubType } from './documentPreviewDataSubType';+import type { DocumentPreviewDataSubTypeProperty } from './documentPreviewDataSubTypeProperty';export interface DocumentPreviewData {/** The document id */@@ -16,7 +16,7 @@ export interface DocumentPreviewData {file_type?: DocumentPreviewDataFileType;/** The id of the owner of the document */owner: string;- sub_type?: DocumentPreviewDataSubType;+ sub_type?: DocumentPreviewDataSubTypeProperty;/** The time the document was last updated */updated_at: number;}diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/documentPreviewDataSubType.ts b/js/app/packages/service-clients/service-storage/generated/schemas/documentPreviewDataSubType.tsindex 76eaf4f9b6..61ccc93263 100644--- a/js/app/packages/service-clients/service-storage/generated/schemas/documentPreviewDataSubType.ts+++ b/js/app/packages/service-clients/service-storage/generated/schemas/documentPreviewDataSubType.ts@@ -4,6 +4,10 @@* document_storage_service* OpenAPI spec version: 0.1.0*/-import type { DocumentSubType } from './documentSubType';+import type { DocumentPreviewDataSubTypeOneOf } from './documentPreviewDataSubTypeOneOf';-export type DocumentPreviewDataSubType = null | DocumentSubType;+/**+ * The sub type of a document preview with associated properties.+Task-related properties are encoded within the variant to ensure valid states.+ */+export type DocumentPreviewDataSubType = DocumentPreviewDataSubTypeOneOf;diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/documentPreviewDataSubTypeOneOf.ts b/js/app/packages/service-clients/service-storage/generated/schemas/documentPreviewDataSubTypeOneOf.tsnew file mode 100644index 0000000000..ffbb7b3a7f--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/documentPreviewDataSubTypeOneOf.ts@@ -0,0 +1,17 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */+import type { DocumentPreviewDataSubTypeOneOfType } from './documentPreviewDataSubTypeOneOfType';++/**+ * A task document with completion status+ */+export type DocumentPreviewDataSubTypeOneOf = {+ /** Whether the task is completed.+True if the Status property is set to "Completed". */+ is_completed: boolean;+ type: DocumentPreviewDataSubTypeOneOfType;+};diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/documentPreviewDataSubTypeOneOfType.ts b/js/app/packages/service-clients/service-storage/generated/schemas/documentPreviewDataSubTypeOneOfType.tsnew file mode 100644index 0000000000..fb41fd7e46--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/documentPreviewDataSubTypeOneOfType.ts@@ -0,0 +1,14 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */++export type DocumentPreviewDataSubTypeOneOfType = typeof DocumentPreviewDataSubTypeOneOfType[keyof typeof DocumentPreviewDataSubTypeOneOfType];+++// eslint-disable-next-line @typescript-eslint/no-redeclare+export const DocumentPreviewDataSubTypeOneOfType = {+ task: 'task',+} as const;diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/documentPreviewDataSubTypeProperty.ts b/js/app/packages/service-clients/service-storage/generated/schemas/documentPreviewDataSubTypeProperty.tsnew file mode 100644index 0000000000..bdc9940e83--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/documentPreviewDataSubTypeProperty.ts@@ -0,0 +1,9 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */+import type { DocumentPreviewDataSubType } from './documentPreviewDataSubType';++export type DocumentPreviewDataSubTypeProperty = null | DocumentPreviewDataSubType;diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/index.ts b/js/app/packages/service-clients/service-storage/generated/schemas/index.tsindex cd50931951..789cd77caa 100644--- a/js/app/packages/service-clients/service-storage/generated/schemas/index.ts+++ b/js/app/packages/service-clients/service-storage/generated/schemas/index.ts@@ -48,6 +48,9 @@ export * from './basicDocumentFileType';export * from './basicDocumentProjectId';export * from './basicDocumentSha';export * from './basicDocumentSubType';+export * from './basicDocumentSubTypeOneOf';+export * from './basicDocumentSubTypeOneOfType';+export * from './basicDocumentSubTypeProperty';export * from './basicDocumentType';export * from './bomPart';export * from './channel';@@ -167,6 +170,9 @@ export * from './documentPreview';export * from './documentPreviewData';export * from './documentPreviewDataFileType';export * from './documentPreviewDataSubType';+export * from './documentPreviewDataSubTypeOneOf';+export * from './documentPreviewDataSubTypeOneOfType';+export * from './documentPreviewDataSubTypeProperty';export * from './documentPreviewOneOf';export * from './documentPreviewOneOfAllOf';export * from './documentPreviewOneOfAllOfType';@@ -432,6 +438,9 @@ export * from './soupDocumentFileType';export * from './soupDocumentProjectId';export * from './soupDocumentSha';export * from './soupDocumentSubType';+export * from './soupDocumentSubTypeOneOf';+export * from './soupDocumentSubTypeOneOfType';+export * from './soupDocumentSubTypeProperty';export * from './soupDocumentViewedAt';export * from './soupEmailThreadPreview';export * from './soupEmailThreadPreviewMetadata';diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupDocument.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupDocument.tsindex 59feec8b7b..1123953299 100644--- a/js/app/packages/service-clients/service-storage/generated/schemas/soupDocument.ts+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupDocument.ts@@ -10,7 +10,7 @@ import type { SoupDocumentDocumentFamilyId } from './soupDocumentDocumentFamilyIimport type { SoupDocumentFileType } from './soupDocumentFileType';import type { SoupDocumentProjectId } from './soupDocumentProjectId';import type { SoupDocumentSha } from './soupDocumentSha';-import type { SoupDocumentSubType } from './soupDocumentSubType';+import type { SoupDocumentSubTypeProperty } from './soupDocumentSubTypeProperty';import type { SoupDocumentViewedAt } from './soupDocumentViewedAt';export interface SoupDocument {@@ -39,7 +39,7 @@ This could be the document_instance_id or document_bom_id depending on the file/** If the document is a PDF, this is the SHA of the pdfIf the document is a DOCX, this will not be present */sha?: SoupDocumentSha;- subType?: SoupDocumentSubType;+ subType?: SoupDocumentSubTypeProperty;/** The time the document instance / document BOM was updated */updatedAt: number;/** The time the document was last viewed */diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupDocumentSubType.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupDocumentSubType.tsindex 0a6e7055e6..ea66b7aeef 100644--- a/js/app/packages/service-clients/service-storage/generated/schemas/soupDocumentSubType.ts+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupDocumentSubType.ts@@ -4,6 +4,10 @@* document_storage_service* OpenAPI spec version: 0.1.0*/-import type { DocumentSubType } from './documentSubType';+import type { SoupDocumentSubTypeOneOf } from './soupDocumentSubTypeOneOf';-export type SoupDocumentSubType = null | DocumentSubType;+/**+ * Sub type of a document with associated properties encoded in each variant.+This ensures type-safety: task properties only exist when the document is a task.+ */+export type SoupDocumentSubType = SoupDocumentSubTypeOneOf;diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupDocumentSubTypeOneOf.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupDocumentSubTypeOneOf.tsnew file mode 100644index 0000000000..1131fd12d3--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupDocumentSubTypeOneOf.ts@@ -0,0 +1,17 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */+import type { SoupDocumentSubTypeOneOfType } from './soupDocumentSubTypeOneOfType';++/**+ * A task document with its associated properties+ */+export type SoupDocumentSubTypeOneOf = {+ /** Whether the task is completed.+True if the Status property is set to "Completed". */+ is_completed: boolean;+ type: SoupDocumentSubTypeOneOfType;+};diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupDocumentSubTypeOneOfType.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupDocumentSubTypeOneOfType.tsnew file mode 100644index 0000000000..6d2f3e1c39--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupDocumentSubTypeOneOfType.ts@@ -0,0 +1,14 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */++export type SoupDocumentSubTypeOneOfType = typeof SoupDocumentSubTypeOneOfType[keyof typeof SoupDocumentSubTypeOneOfType];+++// eslint-disable-next-line @typescript-eslint/no-redeclare+export const SoupDocumentSubTypeOneOfType = {+ task: 'task',+} as const;diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupDocumentSubTypeProperty.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupDocumentSubTypeProperty.tsnew file mode 100644index 0000000000..6689d45fdd--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupDocumentSubTypeProperty.ts@@ -0,0 +1,9 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */+import type { SoupDocumentSubType } from './soupDocumentSubType';++export type SoupDocumentSubTypeProperty = null | SoupDocumentSubType;diff --git a/js/app/packages/service-clients/service-storage/generated/zod.ts b/js/app/packages/service-clients/service-storage/generated/zod.tsindex addbea6340..554e098be0 100644--- a/js/app/packages/service-clients/service-storage/generated/zod.ts+++ b/js/app/packages/service-clients/service-storage/generated/zod.ts@@ -35,7 +35,10 @@ export const getRecentActivityHandlerResponse = zod.object({"owner": zod.string().describe('The owner of the document'),"projectId": zod.string().nullish().describe('The id of the project that this document belongs to'),"sha": zod.string().nullish().describe('If the document is a PDF, this is the SHA of the pdf\nIf the document is a DOCX, this will not be present'),- "subType": zod.union([zod.null(),zod.enum(['task']).describe('The document sub type enum represents all values of document sub types.\nThese values should match the `document_sub_type_value` table in macrodb.')]).optional(),+ "subType": zod.union([zod.null(),zod.object({+ "is_completed": zod.boolean().describe('Whether the task is completed.\nTrue if the Status property is set to \"Completed\".'),+ "type": zod.enum(['task'])+}).describe('A task document with its associated properties').describe('Sub type of a document with associated properties encoded in each variant.\nThis ensures type-safety: task properties only exist when the document is a task.')]).optional(),"updatedAt": zod.number().describe('The time the document instance / document BOM was updated'),"type": zod.enum(['document'])})@@ -769,7 +772,10 @@ export const getBatchPreviewHandlerResponse = zod.object({"document_name": zod.string().describe('The name of the document'),"file_type": zod.string().nullish().describe('The file type of the document (e.g. pdf, docx)'),"owner": zod.string().describe('The id of the owner of the document'),- "sub_type": zod.union([zod.null(),zod.enum(['task']).describe('The document sub type enum represents all values of document sub types.\nThese values should match the `document_sub_type_value` table in macrodb.')]).optional(),+ "sub_type": zod.union([zod.null(),zod.object({+ "is_completed": zod.boolean().describe('Whether the task is completed.\nTrue if the Status property is set to \"Completed\".'),+ "type": zod.enum(['task'])+}).describe('A task document with completion status').describe('The sub type of a document preview with associated properties.\nTask-related properties are encoded within the variant to ensure valid states.')]).optional(),"updated_at": zod.number().describe('The time the document was last updated')}).and(zod.object({"type": zod.enum(['access'])@@ -1141,7 +1147,10 @@ export const getHistoryHandlerResponse = zod.object({"owner": zod.string().describe('The owner of the document'),"projectId": zod.string().nullish().describe('The id of the project that this document belongs to'),"sha": zod.string().nullish().describe('If the document is a PDF, this is the SHA of the pdf\nIf the document is a DOCX, this will not be present'),- "subType": zod.union([zod.null(),zod.enum(['task']).describe('The document sub type enum represents all values of document sub types.\nThese values should match the `document_sub_type_value` table in macrodb.')]).optional(),+ "subType": zod.union([zod.null(),zod.object({+ "is_completed": zod.boolean().describe('Whether the task is completed.\nTrue if the Status property is set to \"Completed\".'),+ "type": zod.enum(['task'])+}).describe('A task document with its associated properties').describe('Sub type of a document with associated properties encoded in each variant.\nThis ensures type-safety: task properties only exist when the document is a task.')]).optional(),"updatedAt": zod.number().describe('The time the document instance / document BOM was updated'),"type": zod.enum(['document'])}),zod.object({@@ -1248,7 +1257,10 @@ export const getItemsSoupResponse = zod.object({"ownerId": zod.string().describe('The owner of the document'),"projectId": zod.string().uuid().nullish().describe('The id of the project that this document belongs to'),"sha": zod.string().nullish().describe('If the document is a PDF, this is the SHA of the pdf\nIf the document is a DOCX, this will not be present'),- "subType": zod.union([zod.null(),zod.enum(['task']).describe('The document sub type enum represents all values of document sub types.\nThese values should match the `document_sub_type_value` table in macrodb.')]).optional(),+ "subType": zod.union([zod.null(),zod.object({+ "is_completed": zod.boolean().describe('Whether the task is completed.\nTrue if the Status property is set to \"Completed\".'),+ "type": zod.enum(['task'])+}).describe('A task document with its associated properties').describe('Sub type of a document with associated properties encoded in each variant.\nThis ensures type-safety: task properties only exist when the document is a task.')]).optional(),"updatedAt": zod.number().describe('The time the document instance / document BOM was updated'),"viewedAt": zod.number().nullable().describe('The time the document was last viewed')}),@@ -1453,7 +1465,10 @@ export const postItemsSoupResponse = zod.object({"ownerId": zod.string().describe('The owner of the document'),"projectId": zod.string().uuid().nullish().describe('The id of the project that this document belongs to'),"sha": zod.string().nullish().describe('If the document is a PDF, this is the SHA of the pdf\nIf the document is a DOCX, this will not be present'),- "subType": zod.union([zod.null(),zod.enum(['task']).describe('The document sub type enum represents all values of document sub types.\nThese values should match the `document_sub_type_value` table in macrodb.')]).optional(),+ "subType": zod.union([zod.null(),zod.object({+ "is_completed": zod.boolean().describe('Whether the task is completed.\nTrue if the Status property is set to \"Completed\".'),+ "type": zod.enum(['task'])+}).describe('A task document with its associated properties').describe('Sub type of a document with associated properties encoded in each variant.\nThis ensures type-safety: task properties only exist when the document is a task.')]).optional(),"updatedAt": zod.number().describe('The time the document instance / document BOM was updated'),"viewedAt": zod.number().nullable().describe('The time the document was last viewed')}),@@ -1626,7 +1641,10 @@ export const getPinsHandlerResponse = zod.object({"owner": zod.string().describe('The owner of the document'),"projectId": zod.string().nullish().describe('The id of the project that this document belongs to'),"sha": zod.string().nullish().describe('If the document is a PDF, this is the SHA of the pdf\nIf the document is a DOCX, this will not be present'),- "subType": zod.union([zod.null(),zod.enum(['task']).describe('The document sub type enum represents all values of document sub types.\nThese values should match the `document_sub_type_value` table in macrodb.')]).optional(),+ "subType": zod.union([zod.null(),zod.object({+ "is_completed": zod.boolean().describe('Whether the task is completed.\nTrue if the Status property is set to \"Completed\".'),+ "type": zod.enum(['task'])+}).describe('A task document with its associated properties').describe('Sub type of a document with associated properties encoded in each variant.\nThis ensures type-safety: task properties only exist when the document is a task.')]).optional(),"updatedAt": zod.number().describe('The time the document instance / document BOM was updated'),"type": zod.enum(['document'])}),zod.object({@@ -1664,7 +1682,10 @@ export const getPinsHandlerResponse = zod.object({"owner": zod.string().describe('The owner of the document'),"projectId": zod.string().nullish().describe('The id of the project that this document belongs to'),"sha": zod.string().nullish().describe('If the document is a PDF, this is the SHA of the pdf\nIf the document is a DOCX, this will not be present'),- "subType": zod.union([zod.null(),zod.enum(['task']).describe('The document sub type enum represents all values of document sub types.\nThese values should match the `document_sub_type_value` table in macrodb.')]).optional(),+ "subType": zod.union([zod.null(),zod.object({+ "is_completed": zod.boolean().describe('Whether the task is completed.\nTrue if the Status property is set to \"Completed\".'),+ "type": zod.enum(['task'])+}).describe('A task document with its associated properties').describe('Sub type of a document with associated properties encoded in each variant.\nThis ensures type-safety: task properties only exist when the document is a task.')]).optional(),"updatedAt": zod.number().describe('The time the document instance / document BOM was updated'),"type": zod.enum(['document'])}),zod.object({@@ -1986,7 +2007,10 @@ export const getProjectContentHandlerResponse = zod.object({"owner": zod.string().describe('The owner of the document'),"projectId": zod.string().nullish().describe('The id of the project that this document belongs to'),"sha": zod.string().nullish().describe('If the document is a PDF, this is the SHA of the pdf\nIf the document is a DOCX, this will not be present'),- "subType": zod.union([zod.null(),zod.enum(['task']).describe('The document sub type enum represents all values of document sub types.\nThese values should match the `document_sub_type_value` table in macrodb.')]).optional(),+ "subType": zod.union([zod.null(),zod.object({+ "is_completed": zod.boolean().describe('Whether the task is completed.\nTrue if the Status property is set to \"Completed\".'),+ "type": zod.enum(['task'])+}).describe('A task document with its associated properties').describe('Sub type of a document with associated properties encoded in each variant.\nThis ensures type-safety: task properties only exist when the document is a task.')]).optional(),"updatedAt": zod.number().describe('The time the document instance / document BOM was updated'),"type": zod.enum(['document'])}),zod.object({@@ -2085,7 +2109,10 @@ export const recentlyDeletedResponse = zod.object({"owner": zod.string().describe('The owner of the document'),"projectId": zod.string().nullish().describe('The id of the project that this document belongs to'),"sha": zod.string().nullish().describe('If the document is a PDF, this is the SHA of the pdf\nIf the document is a DOCX, this will not be present'),- "subType": zod.union([zod.null(),zod.enum(['task']).describe('The document sub type enum represents all values of document sub types.\nThese values should match the `document_sub_type_value` table in macrodb.')]).optional(),+ "subType": zod.union([zod.null(),zod.object({+ "is_completed": zod.boolean().describe('Whether the task is completed.\nTrue if the Status property is set to \"Completed\".'),+ "type": zod.enum(['task'])+}).describe('A task document with its associated properties').describe('Sub type of a document with associated properties encoded in each variant.\nThis ensures type-safety: task properties only exist when the document is a task.')]).optional(),"updatedAt": zod.number().describe('The time the document instance / document BOM was updated'),"type": zod.enum(['document'])}),zod.object({diff --git a/js/app/packages/service-clients/service-storage/openapi.json b/js/app/packages/service-clients/service-storage/openapi.jsonindex 4073c246a2..0d086a6533 100644--- a/js/app/packages/service-clients/service-storage/openapi.json+++ b/js/app/packages/service-clients/service-storage/openapi.json@@ -4182,8 +4182,8 @@"oneOf": [{ "type": "null" },{- "$ref": "#/components/schemas/DocumentSubType",- "description": "The sub type of the document if present."+ "$ref": "#/components/schemas/BasicDocumentSubType",+ "description": "The sub type of the document if present.\nTask-related properties are encoded within the variant."}]},@@ -4194,6 +4194,23 @@}}},+ "BasicDocumentSubType": {+ "oneOf": [+ {+ "type": "object",+ "description": "A task document with its associated properties",+ "required": ["is_completed", "type"],+ "properties": {+ "is_completed": {+ "type": "boolean",+ "description": "Whether the task is completed.\nTrue if the Status property is set to \"Completed\"."+ },+ "type": { "type": "string", "enum": ["task"] }+ }+ }+ ],+ "description": "Sub type of a document with associated properties encoded in each variant.\nThis ensures type-safety: task properties only exist when the document is a task."+ },"BomPart": {"type": "object","required": ["id", "sha", "path"],@@ -5026,8 +5043,8 @@"oneOf": [{ "type": "null" },{- "$ref": "#/components/schemas/DocumentSubType",- "description": "The sub type of the document if present."+ "$ref": "#/components/schemas/DocumentPreviewDataSubType",+ "description": "The sub type of the document if present.\nTask-related properties are encoded within the variant."}]},@@ -5038,6 +5055,23 @@}}},+ "DocumentPreviewDataSubType": {+ "oneOf": [+ {+ "type": "object",+ "description": "A task document with completion status",+ "required": ["is_completed", "type"],+ "properties": {+ "is_completed": {+ "type": "boolean",+ "description": "Whether the task is completed.\nTrue if the Status property is set to \"Completed\"."+ },+ "type": { "type": "string", "enum": ["task"] }+ }+ }+ ],+ "description": "The sub type of a document preview with associated properties.\nTask-related properties are encoded within the variant to ensure valid states."+ },"DocumentResponse": {"type": "object","required": ["documentMetadata"],@@ -7284,8 +7318,8 @@"oneOf": [{ "type": "null" },{- "$ref": "#/components/schemas/DocumentSubType",- "description": "The sub type of the document if present."+ "$ref": "#/components/schemas/SoupDocumentSubType",+ "description": "The sub type of the document if present.\nTask-related properties are encoded within the variant."}]},@@ -7301,6 +7335,23 @@}}},+ "SoupDocumentSubType": {+ "oneOf": [+ {+ "type": "object",+ "description": "A task document with its associated properties",+ "required": ["is_completed", "type"],+ "properties": {+ "is_completed": {+ "type": "boolean",+ "description": "Whether the task is completed.\nTrue if the Status property is set to \"Completed\"."+ },+ "type": { "type": "string", "enum": ["task"] }+ }+ }+ ],+ "description": "Sub type of a document with associated properties encoded in each variant.\nThis ensures type-safety: task properties only exist when the document is a task."+ },"SoupEmailThreadPreview": {"type": "object","required": [diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lockindex fdc7dadc03..98a78932f9 100644--- a/rust/cloud-storage/Cargo.lock+++ b/rust/cloud-storage/Cargo.lock@@ -5053,6 +5053,7 @@ dependencies = ["serde","serde_json","sqlx",+ "system_properties","thiserror 2.0.17","tokio","tracing",@@ -8407,6 +8408,7 @@ dependencies = ["serde","serde_json","sqlx",+ "system_properties","thiserror 2.0.17","tokio","tower 0.5.2",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 c5b8cefd88..68ff9d0432 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@@ -9,7 +9,7 @@ use anyhow::Result;use axum::extract::State;use axum::response::{IntoResponse, Response};use axum::{Extension, extract::Json};-use model::document::{DocumentPreview, DocumentPreviewData, DocumentPreviewV2, WithDocumentId};+use model::document::{DocumentPreview, DocumentPreviewV2, WithDocumentId};use model::response::{GenericErrorResponse, GenericResponse};use model::user::UserContext;use reqwest::StatusCode;@@ -50,16 +50,7 @@ pub async fn get_batch_preview_handler(let result: Vec<DocumentPreview> = document_preview_results.iter().map(|d| match d {- DocumentPreviewV2::Found(preview_data) => {- DocumentPreview::Access(DocumentPreviewData {- document_id: preview_data.document_id.clone(),- document_name: preview_data.document_name.clone(),- file_type: preview_data.file_type.clone(),- owner: preview_data.owner.clone(),- updated_at: preview_data.updated_at,- sub_type: preview_data.sub_type,- })- }+ DocumentPreviewV2::Found(preview_data) => DocumentPreview::Access(preview_data.clone()),DocumentPreviewV2::DoesNotExist(preview_data) => {DocumentPreview::DoesNotExist(WithDocumentId {document_id: preview_data.document_id.clone(),diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-033759a1748c41359a8cf5204f457eed63182d21b432b58fd25b7524d1dc0092.json b/rust/cloud-storage/macro_db_client/.sqlx/query-033759a1748c41359a8cf5204f457eed63182d21b432b58fd25b7524d1dc0092.jsonnew file mode 100644index 0000000000..8e2e7ae90a--- /dev/null+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-033759a1748c41359a8cf5204f457eed63182d21b432b58fd25b7524d1dc0092.json@@ -0,0 +1,87 @@+{+ "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.sub_type as \"sub_type?: DocumentSubType\",\n CASE \n WHEN dt.sub_type = 'task' \n AND ep_status.values->'value' ? $2\n THEN true \n WHEN dt.sub_type = 'task'\n THEN false\n ELSE NULL \n END as \"is_completed\"\n FROM\n \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN entity_properties ep_status \n ON dt.sub_type = 'task'\n AND ep_status.entity_id = d.id \n AND ep_status.entity_type = 'TASK'\n AND ep_status.property_definition_id = $3\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": [+ {+ "ordinal": 0,+ "name": "document_id",+ "type_info": "Text"+ },+ {+ "ordinal": 1,+ "name": "owner",+ "type_info": "Text"+ },+ {+ "ordinal": 2,+ "name": "document_name",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "document_version_id!",+ "type_info": "Int8"+ },+ {+ "ordinal": 4,+ "name": "file_type?",+ "type_info": "Text"+ },+ {+ "ordinal": 5,+ "name": "created_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 6,+ "name": "updated_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 7,+ "name": "project_id?",+ "type_info": "Text"+ },+ {+ "ordinal": 8,+ "name": "sub_type?: DocumentSubType",+ "type_info": {+ "Custom": {+ "name": "document_sub_type_value",+ "kind": {+ "Enum": [+ "task"+ ]+ }+ }+ }+ },+ {+ "ordinal": 9,+ "name": "is_completed",+ "type_info": "Bool"+ }+ ],+ "parameters": {+ "Left": [+ "Text",+ "Text",+ "Uuid"+ ]+ },+ "nullable": [+ false,+ false,+ false,+ null,+ true,+ null,+ null,+ true,+ false,+ null+ ]+ },+ "hash": "033759a1748c41359a8cf5204f457eed63182d21b432b58fd25b7524d1dc0092"+}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-0e124775055015b822196bac04d7421635befe41752d32bceaf5ab66e9215cc8.json b/rust/cloud-storage/macro_db_client/.sqlx/query-0e124775055015b822196bac04d7421635befe41752d32bceaf5ab66e9215cc8.jsonindex a1c4c0d402..aa9502aa59 100644--- a/rust/cloud-storage/macro_db_client/.sqlx/query-0e124775055015b822196bac04d7421635befe41752d32bceaf5ab66e9215cc8.json+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-0e124775055015b822196bac04d7421635befe41752d32bceaf5ab66e9215cc8.json@@ -37,9 +37,9 @@"kind": {"Enum": ["view",- "comment","edit",- "owner"+ "owner",+ "comment"]}}diff --git a/rust/cloud-storage/properties/.sqlx/query-1435acbba365796ddcb6ddbef86f4ebf664cffc44082996f6b60a60373c28f75.json b/rust/cloud-storage/macro_db_client/.sqlx/query-1435acbba365796ddcb6ddbef86f4ebf664cffc44082996f6b60a60373c28f75.jsonsimilarity index 100%rename from rust/cloud-storage/properties/.sqlx/query-1435acbba365796ddcb6ddbef86f4ebf664cffc44082996f6b60a60373c28f75.jsonrename to rust/cloud-storage/macro_db_client/.sqlx/query-1435acbba365796ddcb6ddbef86f4ebf664cffc44082996f6b60a60373c28f75.jsondiff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-18d2885f4c7a6ffd835a5d661ec5e81dd143cd4a51873e92050a0beedbbb86cb.json b/rust/cloud-storage/macro_db_client/.sqlx/query-18d2885f4c7a6ffd835a5d661ec5e81dd143cd4a51873e92050a0beedbbb86cb.jsonindex 6c17e2c89d..4860ae3ec1 100644--- a/rust/cloud-storage/macro_db_client/.sqlx/query-18d2885f4c7a6ffd835a5d661ec5e81dd143cd4a51873e92050a0beedbbb86cb.json+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-18d2885f4c7a6ffd835a5d661ec5e81dd143cd4a51873e92050a0beedbbb86cb.json@@ -22,9 +22,9 @@"kind": {"Enum": ["view",- "comment","edit",- "owner"+ "owner",+ "comment"]}}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-2611958405cf94c91ef85a09da00b0a8701621b42e4c57e74d2da40062d577d4.json b/rust/cloud-storage/macro_db_client/.sqlx/query-2611958405cf94c91ef85a09da00b0a8701621b42e4c57e74d2da40062d577d4.jsonnew file mode 100644index 0000000000..afc95c996f--- /dev/null+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-2611958405cf94c91ef85a09da00b0a8701621b42e4c57e74d2da40062d577d4.json@@ -0,0 +1,129 @@+{+ "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 CASE \n WHEN dt.sub_type = 'task' \n AND ep_status.values->'value' ? $2\n THEN true \n WHEN dt.sub_type = 'task'\n THEN false\n ELSE NULL \n END as \"is_completed\"\n FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN entity_properties ep_status \n ON dt.sub_type = 'task'\n AND ep_status.entity_id = d.id \n AND ep_status.entity_type = 'TASK'\n AND ep_status.property_definition_id = $3\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 NULL as \"is_completed\"\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 NULL as \"is_completed\"\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"+ },+ {+ "ordinal": 16,+ "name": "is_completed",+ "type_info": "Bool"+ }+ ],+ "parameters": {+ "Left": [+ "Text",+ "Text",+ "Uuid"+ ]+ },+ "nullable": [+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null+ ]+ },+ "hash": "2611958405cf94c91ef85a09da00b0a8701621b42e4c57e74d2da40062d577d4"+}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-270c1f7ab00df1095282625b0766522d883948bc3589eb9a70fffa7787710bbf.json b/rust/cloud-storage/macro_db_client/.sqlx/query-270c1f7ab00df1095282625b0766522d883948bc3589eb9a70fffa7787710bbf.jsonindex 602ce4228d..69cb81d4c7 100644--- a/rust/cloud-storage/macro_db_client/.sqlx/query-270c1f7ab00df1095282625b0766522d883948bc3589eb9a70fffa7787710bbf.json+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-270c1f7ab00df1095282625b0766522d883948bc3589eb9a70fffa7787710bbf.json@@ -15,9 +15,9 @@"kind": {"Enum": ["view",- "comment","edit",- "owner"+ "owner",+ "comment"]}}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-2bf28d45227f03eba0a150305f096efe2d02b0955f9e407822975c0429f91a99.json b/rust/cloud-storage/macro_db_client/.sqlx/query-2bf28d45227f03eba0a150305f096efe2d02b0955f9e407822975c0429f91a99.jsondeleted file mode 100644index d69146274e..0000000000--- a/rust/cloud-storage/macro_db_client/.sqlx/query-2bf28d45227f03eba0a150305f096efe2d02b0955f9e407822975c0429f91a99.json+++ /dev/null@@ -1,79 +0,0 @@-{- "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.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": [- {- "ordinal": 0,- "name": "document_id",- "type_info": "Text"- },- {- "ordinal": 1,- "name": "owner",- "type_info": "Text"- },- {- "ordinal": 2,- "name": "document_name",- "type_info": "Text"- },- {- "ordinal": 3,- "name": "document_version_id!",- "type_info": "Int8"- },- {- "ordinal": 4,- "name": "file_type?",- "type_info": "Text"- },- {- "ordinal": 5,- "name": "created_at",- "type_info": "Timestamptz"- },- {- "ordinal": 6,- "name": "updated_at",- "type_info": "Timestamptz"- },- {- "ordinal": 7,- "name": "project_id?",- "type_info": "Text"- },- {- "ordinal": 8,- "name": "sub_type?: DocumentSubType",- "type_info": {- "Custom": {- "name": "document_sub_type_value",- "kind": {- "Enum": [- "task"- ]- }- }- }- }- ],- "parameters": {- "Left": [- "Text"- ]- },- "nullable": [- false,- false,- false,- null,- true,- null,- null,- true,- false- ]- },- "hash": "2bf28d45227f03eba0a150305f096efe2d02b0955f9e407822975c0429f91a99"-}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-4c4e9d8ac53e7c3ef292d337af8bcdb2a09a3e4fffa3ca0af2db49180ecc05e6.json b/rust/cloud-storage/macro_db_client/.sqlx/query-4c4e9d8ac53e7c3ef292d337af8bcdb2a09a3e4fffa3ca0af2db49180ecc05e6.jsondeleted file mode 100644index 2b186622c5..0000000000--- a/rust/cloud-storage/macro_db_client/.sqlx/query-4c4e9d8ac53e7c3ef292d337af8bcdb2a09a3e4fffa3ca0af2db49180ecc05e6.json+++ /dev/null@@ -1,121 +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.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-530ba9c14f6f9e857023f66fa06cf632d4f2122183631ee8ae15902cd870cac3.json b/rust/cloud-storage/macro_db_client/.sqlx/query-530ba9c14f6f9e857023f66fa06cf632d4f2122183631ee8ae15902cd870cac3.jsonindex 51a42b64cb..daf0b4f790 100644--- a/rust/cloud-storage/macro_db_client/.sqlx/query-530ba9c14f6f9e857023f66fa06cf632d4f2122183631ee8ae15902cd870cac3.json+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-530ba9c14f6f9e857023f66fa06cf632d4f2122183631ee8ae15902cd870cac3.json@@ -37,9 +37,9 @@"kind": {"Enum": ["view",- "comment","edit",- "owner"+ "owner",+ "comment"]}}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-5959ff0d2410e3f2599a53bc1bf0de19c2d6e90cb030f64dccf965a0515b467e.json b/rust/cloud-storage/macro_db_client/.sqlx/query-5959ff0d2410e3f2599a53bc1bf0de19c2d6e90cb030f64dccf965a0515b467e.jsonnew file mode 100644index 0000000000..334a1ac1ac--- /dev/null+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-5959ff0d2410e3f2599a53bc1bf0de19c2d6e90cb030f64dccf965a0515b467e.json@@ -0,0 +1,105 @@+{+ "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 CASE \n WHEN dt.sub_type = 'task' \n AND ep_status.values->'value' ? $2\n THEN true \n WHEN dt.sub_type = 'task'\n THEN false\n ELSE NULL \n END as \"is_completed\"\n FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN entity_properties ep_status \n ON dt.sub_type = 'task'\n AND ep_status.entity_id = d.id \n AND ep_status.entity_type = 'TASK'\n AND ep_status.property_definition_id = $3\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 NULL as \"is_completed\"\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 NULL as \"is_completed\"\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"+ ]+ }+ }+ }+ },+ {+ "ordinal": 12,+ "name": "is_completed",+ "type_info": "Bool"+ }+ ],+ "parameters": {+ "Left": [+ "Text",+ "Text",+ "Uuid"+ ]+ },+ "nullable": [+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null+ ]+ },+ "hash": "5959ff0d2410e3f2599a53bc1bf0de19c2d6e90cb030f64dccf965a0515b467e"+}diff --git a/rust/cloud-storage/properties/.sqlx/query-63492b018803ce26db5891964a0f52f37d2f54bd8243265c6561f4423af8617c.json b/rust/cloud-storage/macro_db_client/.sqlx/query-63492b018803ce26db5891964a0f52f37d2f54bd8243265c6561f4423af8617c.jsonsimilarity index 100%rename from rust/cloud-storage/properties/.sqlx/query-63492b018803ce26db5891964a0f52f37d2f54bd8243265c6561f4423af8617c.jsonrename to rust/cloud-storage/macro_db_client/.sqlx/query-63492b018803ce26db5891964a0f52f37d2f54bd8243265c6561f4423af8617c.jsondiff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-8b7e81c3b4f31c86100de517e1978a1879039b7230aa83df18f583106c97a18f.json b/rust/cloud-storage/macro_db_client/.sqlx/query-8b7e81c3b4f31c86100de517e1978a1879039b7230aa83df18f583106c97a18f.jsonnew file mode 100644index 0000000000..06dcafa73e--- /dev/null+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-8b7e81c3b4f31c86100de517e1978a1879039b7230aa83df18f583106c97a18f.json@@ -0,0 +1,129 @@+{+ "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 CASE \n WHEN dt.sub_type = 'task' \n AND ep_status.values->'value' ? $2\n THEN true \n WHEN dt.sub_type = 'task'\n THEN false\n ELSE NULL \n END as \"is_completed\"\n FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN entity_properties ep_status \n ON dt.sub_type = 'task'\n AND ep_status.entity_id = d.id \n AND ep_status.entity_type = 'TASK'\n AND ep_status.property_definition_id = $3\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 NULL as \"is_completed\"\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 NULL as \"is_completed\"\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"+ ]+ }+ }+ }+ },+ {+ "ordinal": 16,+ "name": "is_completed",+ "type_info": "Bool"+ }+ ],+ "parameters": {+ "Left": [+ "Text",+ "Text",+ "Uuid"+ ]+ },+ "nullable": [+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null+ ]+ },+ "hash": "8b7e81c3b4f31c86100de517e1978a1879039b7230aa83df18f583106c97a18f"+}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-93935a8c0070822f6c16478613b59117517588d8b433000bcd6c29857a8d3bdc.json b/rust/cloud-storage/macro_db_client/.sqlx/query-93935a8c0070822f6c16478613b59117517588d8b433000bcd6c29857a8d3bdc.jsondeleted file mode 100644index 639a4e7878..0000000000--- a/rust/cloud-storage/macro_db_client/.sqlx/query-93935a8c0070822f6c16478613b59117517588d8b433000bcd6c29857a8d3bdc.json+++ /dev/null@@ -1,121 +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.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/properties/.sqlx/query-9cd40fbb1ade51e9e0d49792839d1a363cada017252a6f653c2272608189bcc4.json b/rust/cloud-storage/macro_db_client/.sqlx/query-9cd40fbb1ade51e9e0d49792839d1a363cada017252a6f653c2272608189bcc4.jsonsimilarity index 100%rename from rust/cloud-storage/properties/.sqlx/query-9cd40fbb1ade51e9e0d49792839d1a363cada017252a6f653c2272608189bcc4.jsonrename to rust/cloud-storage/macro_db_client/.sqlx/query-9cd40fbb1ade51e9e0d49792839d1a363cada017252a6f653c2272608189bcc4.jsondiff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-b4edf0877afce79c1811f30b172520e11c357ef671da3ae1a651be27d01984a3.json b/rust/cloud-storage/macro_db_client/.sqlx/query-b4edf0877afce79c1811f30b172520e11c357ef671da3ae1a651be27d01984a3.jsonindex 4235a97747..78eac67010 100644--- a/rust/cloud-storage/macro_db_client/.sqlx/query-b4edf0877afce79c1811f30b172520e11c357ef671da3ae1a651be27d01984a3.json+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-b4edf0877afce79c1811f30b172520e11c357ef671da3ae1a651be27d01984a3.json@@ -37,9 +37,9 @@"kind": {"Enum": ["view",- "comment","edit",- "owner"+ "owner",+ "comment"]}}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-b672f4dd120709c604651093444b9e5f204b1e059e7426d244aba0d87f21ae4d.json b/rust/cloud-storage/macro_db_client/.sqlx/query-b672f4dd120709c604651093444b9e5f204b1e059e7426d244aba0d87f21ae4d.jsondeleted file mode 100644index 00e2d2c154..0000000000--- a/rust/cloud-storage/macro_db_client/.sqlx/query-b672f4dd120709c604651093444b9e5f204b1e059e7426d244aba0d87f21ae4d.json+++ /dev/null@@ -1,61 +0,0 @@-{- "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.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": [- {- "ordinal": 0,- "name": "document_id",- "type_info": "Text"- },- {- "ordinal": 1,- "name": "document_name",- "type_info": "Text"- },- {- "ordinal": 2,- "name": "file_type",- "type_info": "Text"- },- {- "ordinal": 3,- "name": "owner",- "type_info": "Text"- },- {- "ordinal": 4,- "name": "updated_at",- "type_info": "Timestamptz"- },- {- "ordinal": 5,- "name": "sub_type?: DocumentSubType",- "type_info": {- "Custom": {- "name": "document_sub_type_value",- "kind": {- "Enum": [- "task"- ]- }- }- }- }- ],- "parameters": {- "Left": [- "TextArray"- ]- },- "nullable": [- false,- false,- true,- false,- null,- true- ]- },- "hash": "b672f4dd120709c604651093444b9e5f204b1e059e7426d244aba0d87f21ae4d"-}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-cfbec090ff3b62415ec0c215aa52bdafe162fb8c8fd217a8fcaf613e39525b0f.json b/rust/cloud-storage/macro_db_client/.sqlx/query-cfbec090ff3b62415ec0c215aa52bdafe162fb8c8fd217a8fcaf613e39525b0f.jsonnew file mode 100644index 0000000000..56f1ffeb77--- /dev/null+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-cfbec090ff3b62415ec0c215aa52bdafe162fb8c8fd217a8fcaf613e39525b0f.json@@ -0,0 +1,69 @@+{+ "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.sub_type as \"sub_type?: DocumentSubType\",\n CASE \n WHEN dt.sub_type = 'task' \n AND ep_status.values->'value' ? $2\n THEN true \n WHEN dt.sub_type = 'task'\n THEN false\n ELSE NULL \n END as \"is_completed\"\n FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN entity_properties ep_status \n ON dt.sub_type = 'task'\n AND ep_status.entity_id = d.id \n AND ep_status.entity_type = 'TASK'\n AND ep_status.property_definition_id = $3\n WHERE\n d.\"id\" = ANY($1)\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "document_id!",+ "type_info": "Text"+ },+ {+ "ordinal": 1,+ "name": "document_name!",+ "type_info": "Text"+ },+ {+ "ordinal": 2,+ "name": "file_type",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "owner!",+ "type_info": "Text"+ },+ {+ "ordinal": 4,+ "name": "updated_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 5,+ "name": "sub_type?: DocumentSubType",+ "type_info": {+ "Custom": {+ "name": "document_sub_type_value",+ "kind": {+ "Enum": [+ "task"+ ]+ }+ }+ }+ },+ {+ "ordinal": 6,+ "name": "is_completed",+ "type_info": "Bool"+ }+ ],+ "parameters": {+ "Left": [+ "TextArray",+ "Text",+ "Uuid"+ ]+ },+ "nullable": [+ true,+ true,+ true,+ true,+ null,+ false,+ null+ ]+ },+ "hash": "cfbec090ff3b62415ec0c215aa52bdafe162fb8c8fd217a8fcaf613e39525b0f"+}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-d1d1519e0bdb30ddcbaa6d602bc04617613bb21df0e7728150e74b4125d28a59.json b/rust/cloud-storage/macro_db_client/.sqlx/query-d1d1519e0bdb30ddcbaa6d602bc04617613bb21df0e7728150e74b4125d28a59.jsonindex 12ed677b43..a427d7bdea 100644--- a/rust/cloud-storage/macro_db_client/.sqlx/query-d1d1519e0bdb30ddcbaa6d602bc04617613bb21df0e7728150e74b4125d28a59.json+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-d1d1519e0bdb30ddcbaa6d602bc04617613bb21df0e7728150e74b4125d28a59.json@@ -13,9 +13,9 @@"kind": {"Enum": ["view",- "comment","edit",- "owner"+ "owner",+ "comment"]}}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-df66b4b4b3bf596c9e27e1be73cfaab7a53abb772234e4cacea1b404f301d503.json b/rust/cloud-storage/macro_db_client/.sqlx/query-df66b4b4b3bf596c9e27e1be73cfaab7a53abb772234e4cacea1b404f301d503.jsondeleted file mode 100644index a23b840c5a..0000000000--- a/rust/cloud-storage/macro_db_client/.sqlx/query-df66b4b4b3bf596c9e27e1be73cfaab7a53abb772234e4cacea1b404f301d503.json+++ /dev/null@@ -1,97 +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.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/properties/.sqlx/query-f2d5d7aea9918978cd69c14f8afe24156c2fa387e001ee8eaf57e4a70a106069.json b/rust/cloud-storage/macro_db_client/.sqlx/query-f2d5d7aea9918978cd69c14f8afe24156c2fa387e001ee8eaf57e4a70a106069.jsonsimilarity index 100%rename from rust/cloud-storage/properties/.sqlx/query-f2d5d7aea9918978cd69c14f8afe24156c2fa387e001ee8eaf57e4a70a106069.jsonrename to rust/cloud-storage/macro_db_client/.sqlx/query-f2d5d7aea9918978cd69c14f8afe24156c2fa387e001ee8eaf57e4a70a106069.jsondiff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-fab2fcdcfa7c81426ffddfb934b7c5eade3811d3ec8b5ab962c3dc9fd7886e9b.json b/rust/cloud-storage/macro_db_client/.sqlx/query-fab2fcdcfa7c81426ffddfb934b7c5eade3811d3ec8b5ab962c3dc9fd7886e9b.jsonindex 02598512d9..6c9131a493 100644--- a/rust/cloud-storage/macro_db_client/.sqlx/query-fab2fcdcfa7c81426ffddfb934b7c5eade3811d3ec8b5ab962c3dc9fd7886e9b.json+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-fab2fcdcfa7c81426ffddfb934b7c5eade3811d3ec8b5ab962c3dc9fd7886e9b.json@@ -37,9 +37,9 @@"kind": {"Enum": ["view",- "comment","edit",- "owner"+ "owner",+ "comment"]}}diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-fef80a0b809980ea8efbf49087aff2dd8c12edd081ad759855474fd9a4d1916d.json b/rust/cloud-storage/macro_db_client/.sqlx/query-fef80a0b809980ea8efbf49087aff2dd8c12edd081ad759855474fd9a4d1916d.jsonindex 055f08f556..a3c1720287 100644--- a/rust/cloud-storage/macro_db_client/.sqlx/query-fef80a0b809980ea8efbf49087aff2dd8c12edd081ad759855474fd9a4d1916d.json+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-fef80a0b809980ea8efbf49087aff2dd8c12edd081ad759855474fd9a4d1916d.json@@ -13,9 +13,9 @@"kind": {"Enum": ["view",- "comment","edit",- "owner"+ "owner",+ "comment"]}}diff --git a/rust/cloud-storage/macro_db_client/Cargo.toml b/rust/cloud-storage/macro_db_client/Cargo.tomlindex 30694dd3e5..3da5353750 100644--- a/rust/cloud-storage/macro_db_client/Cargo.toml+++ b/rust/cloud-storage/macro_db_client/Cargo.toml@@ -39,3 +39,4 @@ tracing = { workspace = true }user_quota = { path = "../user_quota" }uuid = { workspace = true }document_sub_type = { path = "../document_sub_type" }+system_properties = { path = "../system_properties" }diff --git a/rust/cloud-storage/macro_db_client/fixtures/tasks_with_is_completed.sql b/rust/cloud-storage/macro_db_client/fixtures/tasks_with_is_completed.sqlnew file mode 100644index 0000000000..d39c0f0d29--- /dev/null+++ b/rust/cloud-storage/macro_db_client/fixtures/tasks_with_is_completed.sql@@ -0,0 +1,83 @@+-- This fixture creates documents with task sub_type and entity_properties+-- to test the is_completed field in soup queries.+--+-- Documents:+-- - task-completed: Task with Status = "Completed" -> is_completed = true+-- - task-incomplete: Task with Status != "Completed" -> is_completed = false+-- - task-no-status: Task with no Status property -> is_completed = false+-- - regular-doc: Regular document (not a task) -> is_completed = NULL++-- Disable foreign key constraints temporarily+SET session_replication_role = 'replica';++INSERT INTO public."User" ("id", "email", "stripeCustomerId")+VALUES ('macro|[email protected]', '[email protected]', 'stripe_id');++-- Task with Status = "Completed"+INSERT INTO public."Document" ("id", "name", "fileType", "owner", "createdAt", "updatedAt")+VALUES ('11111111-1111-1111-1111-111111111111', 'Completed Task', 'txt', 'macro|[email protected]', '2024-01-01 10:00:00', '2024-01-02 11:00:00');++INSERT INTO public."document_sub_type" ("document_id", "sub_type")+VALUES ('11111111-1111-1111-1111-111111111111', 'task');++-- Task with Status != "Completed" (e.g., "In Progress")+INSERT INTO public."Document" ("id", "name", "fileType", "owner", "createdAt", "updatedAt")+VALUES ('22222222-2222-2222-2222-222222222222', 'Incomplete Task', 'txt', 'macro|[email protected]', '2024-01-01 11:00:00', '2024-01-02 12:00:00');++INSERT INTO public."document_sub_type" ("document_id", "sub_type")+VALUES ('22222222-2222-2222-2222-222222222222', 'task');++-- Task with no Status property+INSERT INTO public."Document" ("id", "name", "fileType", "owner", "createdAt", "updatedAt")+VALUES ('33333333-3333-3333-3333-333333333333', 'Task No Status', 'txt', 'macro|[email protected]', '2024-01-01 12:00:00', '2024-01-02 13:00:00');++INSERT INTO public."document_sub_type" ("document_id", "sub_type")+VALUES ('33333333-3333-3333-3333-333333333333', 'task');++-- Regular document (not a task)+INSERT INTO public."Document" ("id", "name", "fileType", "owner", "createdAt", "updatedAt")+VALUES ('44444444-4444-4444-4444-444444444444', 'Regular Document', 'pdf', 'macro|[email protected]', '2024-01-01 13:00:00', '2024-01-02 14:00:00');++-- Document instances (needed for the query to run)+INSERT INTO public."DocumentInstance" ("documentId", "sha")+VALUES ('11111111-1111-1111-1111-111111111111', 'sha-completed'),+ ('22222222-2222-2222-2222-222222222222', 'sha-incomplete'),+ ('33333333-3333-3333-3333-333333333333', 'sha-no-status'),+ ('44444444-4444-4444-4444-444444444444', 'sha-regular');++-- Give the user access to all documents+INSERT INTO public."UserItemAccess" ("id", "user_id", "item_id", "item_type", "access_level")+VALUES (gen_random_uuid(), 'macro|[email protected]', '11111111-1111-1111-1111-111111111111', 'document', 'owner'),+ (gen_random_uuid(), 'macro|[email protected]', '22222222-2222-2222-2222-222222222222', 'document', 'owner'),+ (gen_random_uuid(), 'macro|[email protected]', '33333333-3333-3333-3333-333333333333', 'document', 'owner'),+ (gen_random_uuid(), 'macro|[email protected]', '44444444-4444-4444-4444-444444444444', 'document', 'owner');++-- Entity properties: Status for completed task+-- Status property definition ID: '00000001-0000-0000-0000-000000000002'+-- Completed status option ID: '00000001-0000-0000-0002-000000000004'+INSERT INTO public."entity_properties" ("id", "entity_id", "entity_type", "property_definition_id", "values")+VALUES (+ gen_random_uuid(),+ '11111111-1111-1111-1111-111111111111',+ 'TASK',+ '00000001-0000-0000-0000-000000000002',+ '{"type": "SelectOption", "value": ["00000001-0000-0000-0002-000000000004"]}'::jsonb+);++-- Entity properties: Status for incomplete task (e.g., "In Progress" option)+-- Using a different status option ID (assuming "In Progress" exists)+INSERT INTO public."entity_properties" ("id", "entity_id", "entity_type", "property_definition_id", "values")+VALUES (+ gen_random_uuid(),+ '22222222-2222-2222-2222-222222222222',+ 'TASK',+ '00000001-0000-0000-0000-000000000002',+ '{"type": "SelectOption", "value": ["00000001-0000-0000-0000-000000000001"]}'::jsonb+);++-- No entity_properties entry for task-no-status (to test false case)+-- No entity_properties entry for regular-doc (to test NULL case)++-- Re-enable foreign key constraints+SET session_replication_role = 'origin';+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 2dbf2bdcc1..b10d43f522 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,7 +1,12 @@use document_sub_type::DocumentSubType;use macro_user_id::{cowlike::CowLike, user_id::MacroUserIdStr};-use model::{activity::Activity, chat::Chat, document::BasicDocument};+use model::{+ activity::Activity,+ chat::Chat,+ document::{BasicDocument, BasicDocumentSubType},+};use sqlx::{Pool, Postgres, Row};+use system_properties::{StatusOption, SystemPropertyKey};#[tracing::instrument(skip(db))]pub async fn get_recent_activities(@@ -41,6 +46,9 @@ pub async fn get_recent_activities(return Ok((vec![], 0));}+ let status_property_id = SystemPropertyKey::STATUS_UUID;+ let completed_option_id = StatusOption::COMPLETED_UUID.to_string();+let query = r#"SELECT'document' as type,@@ -57,10 +65,23 @@ pub async fn get_recent_activities(d."projectId" as "project_id",NULL as "is_persistent",di.sha as "sha",- dt.sub_type as "sub_type"+ dt.sub_type as "sub_type",+ CASE+ WHEN dt.sub_type = 'task'+ AND ep_status.values->'value' ? $4+ THEN true+ WHEN dt.sub_type = 'task'+ THEN false+ ELSE NULL+ END as "is_completed"FROM"Document" dLEFT JOIN document_sub_type dt ON dt.document_id = d.id+ LEFT JOIN entity_properties ep_status+ ON dt.sub_type = 'task'+ AND ep_status.entity_id = d.id+ AND ep_status.entity_type = 'TASK'+ AND ep_status.property_definition_id = $5LEFT JOIN LATERAL (SELECTb.id@@ -105,7 +126,8 @@ pub async fn get_recent_activities(c."projectId" as "project_id",c."isPersistent" as "is_persistent",NULL as "sha",- NULL as "sub_type"+ NULL as "sub_type",+ NULL as "is_completed"FROM "Chat" cWHERE c."userId" = $1 AND c."deletedAt" IS NULLORDER BY updated_at DESC@@ -116,6 +138,8 @@ pub async fn get_recent_activities(.bind(user_id).bind(limit).bind(offset)+ .bind(&completed_option_id)+ .bind(status_property_id).fetch_all(&mut *transaction).await?;@@ -134,6 +158,7 @@ pub async fn get_recent_activities(match row_type.as_ref() {"document" => {let document_version_id: String = r.get("document_version_id");+ let is_completed: Option<bool> = r.get("is_completed");Some(Activity::Document(BasicDocument {document_id: id,owner: MacroUserIdStr::parse_from_str(&user_id).ok()?.into_owned(),@@ -148,7 +173,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,- sub_type,+ sub_type: BasicDocumentSubType::from_db(sub_type, is_completed),}))}"chat" => Some(Activity::Chat(Chat {diff --git a/rust/cloud-storage/macro_db_client/src/document/preview.rs b/rust/cloud-storage/macro_db_client/src/document/preview.rsindex 4d8aa547fb..a0af633a7b 100644--- a/rust/cloud-storage/macro_db_client/src/document/preview.rs+++ b/rust/cloud-storage/macro_db_client/src/document/preview.rs@@ -1,33 +1,82 @@use std::collections::HashSet;use document_sub_type::DocumentSubType;-use model::document::{DocumentPreviewData, DocumentPreviewV2, WithDocumentId};+use model::document::{+ DocumentPreviewData, DocumentPreviewDataSubType, DocumentPreviewV2, WithDocumentId,+};+use system_properties::{StatusOption, SystemPropertyKey};++/// Intermediate struct for SQL row mapping with compile-time validation.+#[derive(sqlx::FromRow)]+struct PreviewQueryResult {+ document_id: String,+ file_type: Option<String>,+ document_name: String,+ owner: String,+ updated_at: Option<chrono::DateTime<chrono::Utc>>,+ sub_type: Option<DocumentSubType>,+ is_completed: Option<bool>,+}++impl From<PreviewQueryResult> for DocumentPreviewData {+ fn from(row: PreviewQueryResult) -> Self {+ Self {+ document_id: row.document_id,+ file_type: row.file_type,+ document_name: row.document_name,+ owner: row.owner,+ updated_at: row.updated_at,+ sub_type: DocumentPreviewDataSubType::from_db(row.sub_type, row.is_completed),+ }+ }+}#[tracing::instrument(skip(db))]pub async fn batch_get_document_preview_v2(db: &sqlx::Pool<sqlx::Postgres>,document_ids: &[String],) -> anyhow::Result<Vec<DocumentPreviewV2>> {- let found_documents: Vec<DocumentPreviewData> = sqlx::query_as!(- DocumentPreviewData,+ let status_property_id = SystemPropertyKey::STATUS_UUID;+ let completed_option_id = StatusOption::COMPLETED_UUID.to_string();++ let rows: Vec<PreviewQueryResult> = sqlx::query_as!(+ PreviewQueryResult,r#"SELECT- d.id as document_id,- d.name as document_name,+ d.id as "document_id!",+ d.name as "document_name!",d."fileType" as file_type,- d.owner as owner,+ d.owner as "owner!",d."updatedAt"::timestamptz as "updated_at",- dt.sub_type as "sub_type?: DocumentSubType"+ dt.sub_type as "sub_type?: DocumentSubType",+ CASE+ WHEN dt.sub_type = 'task'+ AND ep_status.values->'value' ? $2+ THEN true+ WHEN dt.sub_type = 'task'+ THEN false+ ELSE NULL+ END as "is_completed"FROM "Document" dLEFT JOIN document_sub_type dt ON dt.document_id = d.id+ LEFT JOIN entity_properties ep_status+ ON dt.sub_type = 'task'+ AND ep_status.entity_id = d.id+ AND ep_status.entity_type = 'TASK'+ AND ep_status.property_definition_id = $3WHEREd."id" = ANY($1)"#,document_ids,+ completed_option_id,+ status_property_id,).fetch_all(db).await?;+ let found_documents: Vec<DocumentPreviewData> =+ rows.into_iter().map(DocumentPreviewData::from).collect();+let found_docs: HashSet<String> = found_documents.iter().map(|row| row.document_id.clone())diff --git a/rust/cloud-storage/macro_db_client/src/history/mod.rs b/rust/cloud-storage/macro_db_client/src/history/mod.rsindex ca28f433c1..71649c8776 100644--- a/rust/cloud-storage/macro_db_client/src/history/mod.rs+++ b/rust/cloud-storage/macro_db_client/src/history/mod.rs@@ -9,10 +9,14 @@ use model::item::{Item,map_item::{map_chat_item, map_document_item, map_project_item},};+use system_properties::{StatusOption, SystemPropertyKey};/// Gets a users recently opened history.#[tracing::instrument(skip(db))]pub async fn get_user_history(db: &Pool<Postgres>, user_id: &str) -> anyhow::Result<Vec<Item>> {+ let status_property_id = SystemPropertyKey::STATUS_UUID;+ let completed_option_id = StatusOption::COMPLETED_UUID.to_string();+let result: Vec<Item> = sqlx::query!(r#"WITH UserHistories AS (@@ -38,9 +42,22 @@ 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.sub_type as "sub_type?: DocumentSubType"+ dt.sub_type as "sub_type?: DocumentSubType",+ CASE+ WHEN dt.sub_type = 'task'+ AND ep_status.values->'value' ? $2+ THEN true+ WHEN dt.sub_type = 'task'+ THEN false+ ELSE NULL+ END as "is_completed"FROM "Document" dLEFT JOIN document_sub_type dt ON dt.document_id = d.id+ LEFT JOIN entity_properties ep_status+ ON dt.sub_type = 'task'+ AND ep_status.entity_id = d.id+ AND ep_status.entity_type = 'TASK'+ AND ep_status.property_definition_id = $3INNER JOIN UserHistories uh ON uh.item_id = d.id AND uh.item_type = 'document'LEFT JOIN LATERAL (SELECT@@ -85,7 +102,8 @@ 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",- NULL as "sub_type"+ NULL as "sub_type",+ NULL as "is_completed"FROM "Chat" cINNER JOIN UserHistories uh ON uh.item_id = c.id AND uh.item_type = 'chat'UNION ALL@@ -105,7 +123,8 @@ 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",- NULL as "sub_type"+ NULL as "sub_type",+ NULL as "is_completed"FROM "Project" pINNER JOIN UserHistories uh ON uh.item_id = p.id AND uh.item_type = 'project')@@ -113,6 +132,8 @@ pub async fn get_user_history(db: &Pool<Postgres>, user_id: &str) -> anyhow::ResORDER BY updated_at DESC"#,user_id,+ completed_option_id,+ status_property_id,).try_map(|r| match r.item_type.as_ref() {"document" => {@@ -131,6 +152,7 @@ pub async fn get_user_history(db: &Pool<Postgres>, user_id: &str) -> anyhow::Resr.branched_from_version_id,r.project_id,r.sub_type,+ r.is_completed,).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 995c0b8fb6..e30cfa3118 100644--- a/rust/cloud-storage/macro_db_client/src/pins/mod.rs+++ b/rust/cloud-storage/macro_db_client/src/pins/mod.rs@@ -1,6 +1,7 @@use anyhow::Context;use document_sub_type::DocumentSubType;use sqlx::{Pool, Postgres};+use system_properties::{StatusOption, SystemPropertyKey};use model::{activity::map_item::{map_chat_item, map_document_item},@@ -55,6 +56,9 @@ pub async fn get_pins(db: Pool<Postgres>, user_id: &str) -> anyhow::Result<Vec<Preturn Ok(vec![]);}+ let status_property_id = SystemPropertyKey::STATUS_UUID;+ let completed_option_id = StatusOption::COMPLETED_UUID.to_string();+let result: Vec<PinnedItem> = sqlx::query!(r#"WITH PinnedItems AS (@@ -81,9 +85,22 @@ pub async fn get_pins(db: Pool<Postgres>, user_id: &str) -> anyhow::Result<Vec<Pdi.sha as "sha",NULL as "is_persistent",dt.sub_type as "sub_type?: DocumentSubType",- pi.pin_index as "pin_index"+ pi.pin_index as "pin_index",+ CASE+ WHEN dt.sub_type = 'task'+ AND ep_status.values->'value' ? $2+ THEN true+ WHEN dt.sub_type = 'task'+ THEN false+ ELSE NULL+ END as "is_completed"FROM "Document" dLEFT JOIN document_sub_type dt ON dt.document_id = d.id+ LEFT JOIN entity_properties ep_status+ ON dt.sub_type = 'task'+ AND ep_status.entity_id = d.id+ AND ep_status.entity_type = 'TASK'+ AND ep_status.property_definition_id = $3INNER JOIN PinnedItems pi ON pi.pin_item_id = d.id AND pi.pin_item_type = 'document'LEFT JOIN LATERAL (SELECT@@ -128,7 +145,8 @@ pub async fn get_pins(db: Pool<Postgres>, user_id: &str) -> anyhow::Result<Vec<PNULL as "sha",c."isPersistent" as "is_persistent",NULL as sub_type,- pi.pin_index as "pin_index"+ pi.pin_index as "pin_index",+ NULL as "is_completed"FROM "Chat" cINNER JOIN PinnedItems pi ON pi.pin_item_id = c.id AND pi.pin_item_type = 'chat'UNION ALL@@ -148,14 +166,17 @@ pub async fn get_pins(db: Pool<Postgres>, user_id: &str) -> anyhow::Result<Vec<PNULL as "sha",NULL as "is_persistent",NULL as sub_type,- pi.pin_index as "pin_index"+ pi.pin_index as "pin_index",+ NULL as "is_completed"FROM "Project" pINNER JOIN PinnedItems pi ON pi.pin_item_id = p.id AND pi.pin_item_type = 'project')SELECT * FROM CombinedORDER BY pin_index ASC"#,- user_id+ user_id,+ completed_option_id,+ status_property_id,).try_map(|r| {let pin_index: i32 =@@ -180,6 +201,7 @@ pub async fn get_pins(db: Pool<Postgres>, user_id: &str) -> anyhow::Result<Vec<Pr.branched_from_version_id,r.project_id,r.sub_type,+ r.is_completed,).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 4517ccf965..6210556601 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,6 +1,11 @@use document_sub_type::DocumentSubType;use macro_user_id::{cowlike::CowLike, user_id::MacroUserIdStr};-use model::{chat::Chat, document::BasicDocument, project::Project};+use model::{+ chat::Chat,+ document::{BasicDocument, BasicDocumentSubType},+ project::Project,+};+use system_properties::{StatusOption, SystemPropertyKey};/// Gets all deleted sub-projects of a given project./// Includes the root project itself as well.@@ -76,6 +81,9 @@ pub async fn get_sub_documents(transaction: &mut sqlx::Transaction<'_, sqlx::Postgres>,project_id: &str,) -> anyhow::Result<Vec<BasicDocument>> {+ let status_property_id = SystemPropertyKey::STATUS_UUID;+ let completed_option_id = StatusOption::COMPLETED_UUID.to_string();+let documents: Vec<BasicDocument> = sqlx::query!(r#"SELECT@@ -87,10 +95,23 @@ pub async fn get_sub_documents(d."createdAt"::timestamptz as created_at,d."updatedAt"::timestamptz as updated_at,d."projectId" as "project_id?",- dt.sub_type as "sub_type?: DocumentSubType"+ dt.sub_type as "sub_type?: DocumentSubType",+ CASE+ WHEN dt.sub_type = 'task'+ AND ep_status.values->'value' ? $2+ THEN true+ WHEN dt.sub_type = 'task'+ THEN false+ ELSE NULL+ END as "is_completed"FROM"Document" dLEFT JOIN document_sub_type dt ON dt.document_id = d.id+ LEFT JOIN entity_properties ep_status+ ON dt.sub_type = 'task'+ AND ep_status.entity_id = d.id+ AND ep_status.entity_type = 'TASK'+ AND ep_status.property_definition_id = $3LEFT JOIN LATERAL (SELECTb.id@@ -119,6 +140,8 @@ pub async fn get_sub_documents(WHERE d."projectId" = $1 AND d."deletedAt" IS NULL"#,project_id,+ completed_option_id,+ status_property_id,).try_map(|row| {Ok(BasicDocument {@@ -137,7 +160,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- sub_type: row.sub_type,+ sub_type: BasicDocumentSubType::from_db(row.sub_type, row.is_completed),})}).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 d76ec67785..6477bbf010 100644--- a/rust/cloud-storage/macro_db_client/src/recents/deleted.rs+++ b/rust/cloud-storage/macro_db_client/src/recents/deleted.rs@@ -3,6 +3,7 @@ use model::item::{Item,map_item::{map_chat_item, map_document_item, map_project_item},};+use system_properties::{StatusOption, SystemPropertyKey};/// Gets the users recently deleted items./// Supports pagination.@@ -11,6 +12,9 @@ pub async fn get_recently_deleted(db: &sqlx::Pool<sqlx::Postgres>,user_id: &str,) -> anyhow::Result<Vec<Item>> {+ let status_property_id = SystemPropertyKey::STATUS_UUID;+ let completed_option_id = StatusOption::COMPLETED_UUID.to_string();+// NOTE: we may need to support pagination here at some point.let result: Vec<Item> = sqlx::query!(r#"@@ -26,9 +30,22 @@ pub async fn get_recently_deleted(d."deletedAt"::timestamptz as "deleted_at",d."projectId" as "project_id",NULL as "is_persistent",- dt.sub_type as "sub_type?: DocumentSubType"+ dt.sub_type as "sub_type?: DocumentSubType",+ CASE+ WHEN dt.sub_type = 'task'+ AND ep_status.values->'value' ? $2+ THEN true+ WHEN dt.sub_type = 'task'+ THEN false+ ELSE NULL+ END as "is_completed"FROM "Document" dLEFT JOIN document_sub_type dt ON dt.document_id = d.id+ LEFT JOIN entity_properties ep_status+ ON dt.sub_type = 'task'+ AND ep_status.entity_id = d.id+ AND ep_status.entity_type = 'TASK'+ AND ep_status.property_definition_id = $3LEFT JOIN LATERAL (SELECTb.id@@ -65,7 +82,8 @@ pub async fn get_recently_deleted(c."deletedAt"::timestamptz as "deleted_at",c."projectId" as "project_id",c."isPersistent" as "is_persistent",- NULL as "sub_type"+ NULL as "sub_type",+ NULL as "is_completed"FROM "Chat" cWHERE c."userId" = $1 AND c."deletedAt" IS NOT NULLUNION ALL@@ -81,12 +99,15 @@ pub async fn get_recently_deleted(p."deletedAt"::timestamptz as "deleted_at",p."parentId" as "project_id",NULL as "is_persistent",- NULL as "sub_type"+ NULL as "sub_type",+ NULL as "is_completed"FROM "Project" pWHERE p."userId" = $1 AND p."deletedAt" IS NOT NULLORDER BY deleted_at DESC"#,user_id,+ completed_option_id,+ status_property_id,).try_map(|r| match r.item_type.as_ref() {"document" => {@@ -105,6 +126,7 @@ pub async fn get_recently_deleted(None, // don't care about branched_from_version_idr.project_id,r.sub_type,+ r.is_completed,).map_err(|e| sqlx::Error::TypeNotFound {type_name: e.to_string(),diff --git a/rust/cloud-storage/model/src/activity/map_item.rs b/rust/cloud-storage/model/src/activity/map_item.rsindex bb16ec846c..b3ce5bd99f 100644--- a/rust/cloud-storage/model/src/activity/map_item.rs+++ b/rust/cloud-storage/model/src/activity/map_item.rs@@ -1,7 +1,10 @@use document_sub_type::DocumentSubType;use macro_user_id::{cowlike::CowLike, user_id::MacroUserIdStr};-use crate::{chat::Chat, document::BasicDocument};+use crate::{+ chat::Chat,+ document::{BasicDocument, BasicDocumentSubType},+};#[expect(clippy::too_many_arguments,@@ -21,6 +24,7 @@ pub fn map_document_item(branched_from_version_id: Option<i64>,project_id: Option<String>,sub_type: Option<DocumentSubType>,+ is_completed: Option<bool>,) -> anyhow::Result<BasicDocument> {Ok(BasicDocument {document_id: id,@@ -36,7 +40,7 @@ pub fn map_document_item(branched_from_id,branched_from_version_id,project_id,- sub_type,+ sub_type: BasicDocumentSubType::from_db(sub_type, is_completed),})}diff --git a/rust/cloud-storage/model/src/document/mod.rs b/rust/cloud-storage/model/src/document/mod.rsindex 9db5ffb77a..d330dda9c6 100644--- a/rust/cloud-storage/model/src/document/mod.rs+++ b/rust/cloud-storage/model/src/document/mod.rs@@ -37,6 +37,31 @@ pub struct DocumentPermissionsToken {pub iss: String,}+/// Sub type of a document with associated properties encoded in each variant.+/// This ensures type-safety: task properties only exist when the document is a task.+#[derive(serde::Serialize, serde::Deserialize, Eq, PartialEq, Debug, Clone, ToSchema)]+#[serde(tag = "type", rename_all = "snake_case")]+pub enum BasicDocumentSubType {+ /// A task document with its associated properties+ Task {+ /// Whether the task is completed.+ /// True if the Status property is set to "Completed".+ is_completed: bool,+ },+}++impl BasicDocumentSubType {+ /// Converts from DB representation (separate sub_type and is_completed columns)+ /// to the domain enum.+ pub fn from_db(sub_type: Option<DocumentSubType>, is_completed: Option<bool>) -> Option<Self> {+ match sub_type? {+ DocumentSubType::Task => Some(Self::Task {+ is_completed: is_completed.unwrap_or_default(),+ }),+ }+ }+}+#[derive(sqlx::FromRow, serde::Serialize, serde::Deserialize, Eq, PartialEq, Debug, Clone, ToSchema,)]@@ -92,8 +117,9 @@ pub struct BasicDocument {pub deleted_at: Option<chrono::DateTime<chrono::Utc>>,/// The sub type of the document if present.+ /// Task-related properties are encoded within the variant.#[serde(skip_serializing_if = "Option::is_none")]- pub sub_type: Option<DocumentSubType>,+ pub sub_type: Option<BasicDocumentSubType>,}#[derive(sqlx::FromRow, serde::Serialize, serde::Deserialize, Eq, PartialEq, Debug, Clone)]@@ -315,9 +341,32 @@ pub enum DocumentPreview {DoesNotExist(WithDocumentId),}-#[derive(- sqlx::FromRow, serde::Serialize, serde::Deserialize, Eq, PartialEq, Debug, Clone, ToSchema,-)]+/// The sub type of a document preview with associated properties.+/// Task-related properties are encoded within the variant to ensure valid states.+#[derive(serde::Serialize, serde::Deserialize, Eq, PartialEq, Debug, Clone, ToSchema)]+#[serde(tag = "type", rename_all = "snake_case")]+pub enum DocumentPreviewDataSubType {+ /// A task document with completion status+ Task {+ /// Whether the task is completed.+ /// True if the Status property is set to "Completed".+ is_completed: bool,+ },+}++impl DocumentPreviewDataSubType {+ /// Converts from DB representation (separate sub_type and is_completed columns)+ /// to the domain enum.+ pub fn from_db(sub_type: Option<DocumentSubType>, is_completed: Option<bool>) -> Option<Self> {+ match sub_type? {+ DocumentSubType::Task => Some(Self::Task {+ is_completed: is_completed.unwrap_or_default(),+ }),+ }+ }+}++#[derive(serde::Serialize, serde::Deserialize, Eq, PartialEq, Debug, Clone, ToSchema)]pub struct DocumentPreviewData {/// The document idpub document_id: String,@@ -333,8 +382,9 @@ pub struct DocumentPreviewData {#[schema(value_type = i64, nullable=false)]pub updated_at: Option<chrono::DateTime<chrono::Utc>>,/// The sub type of the document if present.+ /// Task-related properties are encoded within the variant.#[serde(skip_serializing_if = "Option::is_none")]- pub sub_type: Option<DocumentSubType>,+ pub sub_type: Option<DocumentPreviewDataSubType>,}#[derive(diff --git a/rust/cloud-storage/model/src/item/map_item.rs b/rust/cloud-storage/model/src/item/map_item.rsindex 0d8ee50c0f..0feee35c04 100644--- a/rust/cloud-storage/model/src/item/map_item.rs+++ b/rust/cloud-storage/model/src/item/map_item.rs@@ -1,7 +1,11 @@use document_sub_type::DocumentSubType;use macro_user_id::{cowlike::CowLike, user_id::MacroUserIdStr};-use crate::{chat::Chat, document::BasicDocument, project::Project};+use crate::{+ chat::Chat,+ document::{BasicDocument, BasicDocumentSubType},+ project::Project,+};#[expect(clippy::too_many_arguments,@@ -22,6 +26,7 @@ pub fn map_document_item(branched_from_version_id: Option<i64>,project_id: Option<String>,sub_type: Option<DocumentSubType>,+ is_completed: Option<bool>,) -> anyhow::Result<BasicDocument> {Ok(BasicDocument {document_id: id,@@ -37,7 +42,7 @@ pub fn map_document_item(branched_from_id,branched_from_version_id,project_id,- sub_type,+ sub_type: BasicDocumentSubType::from_db(sub_type, is_completed),})}diff --git a/rust/cloud-storage/models_soup/src/comms.rs b/rust/cloud-storage/models_soup/src/comms.rsindex f0f9f260ad..f8893868d7 100644--- a/rust/cloud-storage/models_soup/src/comms.rs+++ b/rust/cloud-storage/models_soup/src/comms.rs@@ -52,15 +52,15 @@ pub struct ChannelMessage {#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]#[dg(backward = comms::domain::models::channel::Channel)]pub struct Channel {- #[schema(value_type = Uuid)]+ #[cfg_attr(feature = "schema", schema(value_type = Uuid))]pub id: ChannelId,pub name: Option<String>,pub channel_type: ChannelType,- #[schema(value_type = Option<u32>)]+ #[cfg_attr(feature = "schema", schema(value_type = Option<u32>))]pub org_id: Option<OrganizationId>,pub created_at: DateTime<Utc>,pub updated_at: DateTime<Utc>,- #[schema(value_type = String)]+ #[cfg_attr(feature = "schema", schema(value_type = String))]pub owner_id: MacroUserIdStr<'static>,}@@ -79,9 +79,9 @@ pub enum ChannelType {#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]#[dg(backward = comms::domain::models::channel::ChannelParticipant)]pub struct ChannelParticipant {- #[schema(value_type = Uuid)]+ #[cfg_attr(feature = "schema", schema(value_type = Uuid))]pub channel_id: ChannelId,- #[schema(value_type = String)]+ #[cfg_attr(feature = "schema", schema(value_type = String))]pub user_id: MacroUserIdStr<'static>,pub role: ParticipantRole,pub joined_at: DateTime<Utc>,diff --git a/rust/cloud-storage/models_soup/src/document.rs b/rust/cloud-storage/models_soup/src/document.rsindex 98f5aad473..eef115942c 100644--- a/rust/cloud-storage/models_soup/src/document.rs+++ b/rust/cloud-storage/models_soup/src/document.rs@@ -3,6 +3,40 @@ use document_sub_type::DocumentSubType;use macro_user_id::user_id::MacroUserIdStr;use uuid::Uuid;+/// Sub type of a document with associated properties encoded in each variant.+/// This ensures type-safety: task properties only exist when the document is a task.+#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]+#[cfg_attr(feature = "mock", derive(PartialEq, Eq))]+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]+#[serde(tag = "type", rename_all = "snake_case")]+pub enum SoupDocumentSubType {+ /// A task document with its associated properties+ Task {+ /// Whether the task is completed.+ /// True if the Status property is set to "Completed".+ is_completed: bool,+ },+}++impl SoupDocumentSubType {+ /// Converts from DB representation (separate sub_type and is_completed columns)+ /// to the domain enum.+ pub fn from_db(sub_type: Option<DocumentSubType>, is_completed: Option<bool>) -> Option<Self> {+ match sub_type? {+ DocumentSubType::Task => Some(Self::Task {+ is_completed: is_completed.unwrap_or_default(),+ }),+ }+ }++ /// Returns whether this is a completed task+ pub fn is_task_completed(&self) -> Option<bool> {+ match self {+ Self::Task { is_completed } => Some(*is_completed),+ }+ }+}+#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]#[cfg_attr(feature = "mock", derive(PartialEq, Eq))]#[serde(rename_all = "camelCase")]@@ -64,6 +98,7 @@ pub struct SoupDocument {pub viewed_at: Option<chrono::DateTime<Utc>>,/// The sub type of the document if present.+ /// Task-related properties are encoded within the variant.#[serde(skip_serializing_if = "Option::is_none")]- pub sub_type: Option<DocumentSubType>,+ pub sub_type: Option<SoupDocumentSubType>,}diff --git a/rust/cloud-storage/soup/.sqlx/query-05426b40fd7dcdd72313998a69a8bc0f91a8b33ca4727a8d6308cc67b7f729a2.json b/rust/cloud-storage/soup/.sqlx/query-05426b40fd7dcdd72313998a69a8bc0f91a8b33ca4727a8d6308cc67b7f729a2.jsonnew file mode 100644index 0000000000..4620b153a3--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-05426b40fd7dcdd72313998a69a8bc0f91a8b33ca4727a8d6308cc67b7f729a2.json@@ -0,0 +1,139 @@+{+ "db_name": "PostgreSQL",+ "query": "\n WITH UserAccessibleItems AS (\n SELECT DISTINCT ON (\"item_id\", \"item_type\")\n \"item_id\",\n \"item_type\"\n FROM \"UserItemAccess\" \n WHERE \"user_id\" = $1\n ORDER BY \"item_id\", \"item_type\", \n CASE \"access_level\"\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\", \n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", d.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN d.\"createdAt\"\n ELSE d.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n CASE \n WHEN dt.sub_type = 'task' \n AND ep_status.values->'value' ? $6\n THEN true \n WHEN dt.sub_type = 'task'\n THEN false\n ELSE NULL \n END as \"is_completed\"\n FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN entity_properties ep_status \n ON dt.sub_type = 'task'\n AND ep_status.entity_id = d.id \n AND ep_status.entity_type = 'TASK'\n AND ep_status.property_definition_id = $7\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = d.id \n AND uai.item_type = 'document'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = d.id \n AND uh.\"itemType\" = 'document' \n AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", c.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN c.\"createdAt\"\n ELSE c.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = c.id \n AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = c.id \n AND uh.\"itemType\" = 'chat' \n AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n \n UNION ALL\n \n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", p.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN p.\"createdAt\"\n ELSE p.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\"\n FROM \"Project\" p\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = p.id \n AND uai.item_type = 'project'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = p.id \n AND uh.\"itemType\" = 'project' \n AND uh.\"userId\" = $1\n WHERE p.\"deletedAt\" IS NULL\n )\n SELECT * \n FROM Combined\n WHERE ($4::timestamptz IS NULL)\n OR (\"sort_ts!\", \"id!\") < ($4, $5)\n ORDER BY \"sort_ts!\" DESC, \"updated_at!\" DESC\n LIMIT $3\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "item_type!",+ "type_info": "Text"+ },+ {+ "ordinal": 1,+ "name": "id!",+ "type_info": "Text"+ },+ {+ "ordinal": 2,+ "name": "document_version_id",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "user_id!",+ "type_info": "Text"+ },+ {+ "ordinal": 4,+ "name": "name!",+ "type_info": "Text"+ },+ {+ "ordinal": 5,+ "name": "branched_from_id",+ "type_info": "Text"+ },+ {+ "ordinal": 6,+ "name": "branched_from_version_id",+ "type_info": "Int8"+ },+ {+ "ordinal": 7,+ "name": "document_family_id",+ "type_info": "Int8"+ },+ {+ "ordinal": 8,+ "name": "file_type",+ "type_info": "Text"+ },+ {+ "ordinal": 9,+ "name": "created_at!",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 10,+ "name": "updated_at!",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 11,+ "name": "project_id",+ "type_info": "Text"+ },+ {+ "ordinal": 12,+ "name": "is_persistent",+ "type_info": "Bool"+ },+ {+ "ordinal": 13,+ "name": "sha",+ "type_info": "Text"+ },+ {+ "ordinal": 14,+ "name": "sub_type?: DocumentSubType",+ "type_info": {+ "Custom": {+ "name": "document_sub_type_value",+ "kind": {+ "Enum": [+ "task"+ ]+ }+ }+ }+ },+ {+ "ordinal": 15,+ "name": "viewed_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 16,+ "name": "sort_ts!",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 17,+ "name": "is_completed",+ "type_info": "Bool"+ }+ ],+ "parameters": {+ "Left": [+ "Text",+ "Text",+ "Int8",+ "Timestamptz",+ "Text",+ "Text",+ "Uuid"+ ]+ },+ "nullable": [+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null+ ]+ },+ "hash": "05426b40fd7dcdd72313998a69a8bc0f91a8b33ca4727a8d6308cc67b7f729a2"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-14085ed173f482f88d7b9c16f85091224dda2a444649cb14fe8b44ad183ed68a.json b/rust/cloud-storage/soup/.sqlx/query-14085ed173f482f88d7b9c16f85091224dda2a444649cb14fe8b44ad183ed68a.jsonnew file mode 100644index 0000000000..dfed5a2d67--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-14085ed173f482f88d7b9c16f85091224dda2a444649cb14fe8b44ad183ed68a.json@@ -0,0 +1,139 @@+{+ "db_name": "PostgreSQL",+ "query": " \n WITH RECURSIVE ProjectHierarchy AS (\n SELECT p.id, uia.access_level \n FROM \"Project\" p\n JOIN \"UserItemAccess\" uia ON p.id = uia.item_id AND uia.item_type = 'project'\n WHERE uia.user_id = $1 AND p.\"deletedAt\" IS NULL\n UNION ALL\n SELECT p.id, ph.access_level\n FROM \"Project\" p \n JOIN ProjectHierarchy ph ON p.\"parentId\" = ph.id\n WHERE p.\"deletedAt\" IS NULL\n ),\n AllAccessGrants AS (\n SELECT item_id, item_type, access_level \n FROM \"UserItemAccess\" \n WHERE user_id = $1\n UNION ALL\n SELECT d.id AS item_id, 'document' AS item_type, ph.access_level\n FROM \"Document\" d \n JOIN ProjectHierarchy ph ON d.\"projectId\" = ph.id\n WHERE d.\"projectId\" IS NOT NULL AND d.\"deletedAt\" IS NULL\n UNION ALL\n SELECT c.id AS item_id, 'chat' AS item_type, ph.access_level\n FROM \"Chat\" c \n JOIN ProjectHierarchy ph ON c.\"projectId\" = ph.id\n WHERE c.\"projectId\" IS NOT NULL AND c.\"deletedAt\" IS NULL\n UNION ALL\n SELECT ph.id AS item_id, 'project' AS item_type, ph.access_level \n FROM ProjectHierarchy ph\n ),\n UserAccessibleItems AS (\n SELECT DISTINCT ON (item_id, item_type) item_id, item_type\n FROM AllAccessGrants\n ORDER BY item_id, item_type, \n CASE access_level\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", d.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN d.\"createdAt\"\n ELSE d.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n CASE \n WHEN dt.sub_type = 'task' \n AND ep_status.values->'value' ? $6\n THEN true \n WHEN dt.sub_type = 'task'\n THEN false\n ELSE NULL \n END as \"is_completed\"\n FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN entity_properties ep_status \n ON dt.sub_type = 'task'\n AND ep_status.entity_id = d.id \n AND ep_status.entity_type = 'TASK'\n AND ep_status.property_definition_id = $7\n INNER JOIN UserAccessibleItems uai ON uai.item_id = d.id AND uai.item_type = 'document'\n -- This MUST be a LEFT JOIN to support all three sort methods\n LEFT JOIN \"UserHistory\" uh ON uh.\"itemId\" = d.id AND uh.\"itemType\" = 'document' AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", c.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN c.\"createdAt\"\n ELSE c.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai ON uai.item_id = c.id AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh ON uh.\"itemId\" = c.id AND uh.\"itemType\" = 'chat' AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n\n UNION ALL\n\n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", p.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN p.\"createdAt\"\n ELSE p.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\"\n FROM \"Project\" p\n INNER JOIN UserAccessibleItems uai\n ON uai.item_id = p.id\n AND uai.item_type = 'project'\n LEFT JOIN \"UserHistory\" uh\n ON uh.\"itemId\" = p.id\n AND uh.\"itemType\" = 'project'\n AND uh.\"userId\" = $1\n WHERE p.\"deletedAt\" IS NULL\n )\n SELECT Combined.* FROM Combined\n LEFT JOIN frecency_aggregates fa\n ON fa.entity_id = Combined.\"id!\"\n AND fa.entity_type = Combined.\"item_type!\"\n AND fa.user_id = $1\n WHERE fa.id IS NULL\n AND (\n ($4::timestamptz IS NULL)\n OR\n (Combined.\"sort_ts!\", Combined.\"id!\"::text) < ($4, $5)\n )\n ORDER BY Combined.\"sort_ts!\" DESC, Combined.\"updated_at!\" DESC\n LIMIT $3\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "item_type!",+ "type_info": "Text"+ },+ {+ "ordinal": 1,+ "name": "id!",+ "type_info": "Text"+ },+ {+ "ordinal": 2,+ "name": "document_version_id",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "user_id!",+ "type_info": "Text"+ },+ {+ "ordinal": 4,+ "name": "name!",+ "type_info": "Text"+ },+ {+ "ordinal": 5,+ "name": "branched_from_id",+ "type_info": "Text"+ },+ {+ "ordinal": 6,+ "name": "branched_from_version_id",+ "type_info": "Int8"+ },+ {+ "ordinal": 7,+ "name": "document_family_id",+ "type_info": "Int8"+ },+ {+ "ordinal": 8,+ "name": "file_type",+ "type_info": "Text"+ },+ {+ "ordinal": 9,+ "name": "created_at!",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 10,+ "name": "updated_at!",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 11,+ "name": "project_id",+ "type_info": "Text"+ },+ {+ "ordinal": 12,+ "name": "is_persistent",+ "type_info": "Bool"+ },+ {+ "ordinal": 13,+ "name": "sha",+ "type_info": "Text"+ },+ {+ "ordinal": 14,+ "name": "sub_type?: DocumentSubType",+ "type_info": {+ "Custom": {+ "name": "document_sub_type_value",+ "kind": {+ "Enum": [+ "task"+ ]+ }+ }+ }+ },+ {+ "ordinal": 15,+ "name": "viewed_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 16,+ "name": "sort_ts!",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 17,+ "name": "is_completed",+ "type_info": "Bool"+ }+ ],+ "parameters": {+ "Left": [+ "Text",+ "Text",+ "Int8",+ "Timestamptz",+ "Text",+ "Text",+ "Uuid"+ ]+ },+ "nullable": [+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null+ ]+ },+ "hash": "14085ed173f482f88d7b9c16f85091224dda2a444649cb14fe8b44ad183ed68a"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-1435acbba365796ddcb6ddbef86f4ebf664cffc44082996f6b60a60373c28f75.json b/rust/cloud-storage/soup/.sqlx/query-1435acbba365796ddcb6ddbef86f4ebf664cffc44082996f6b60a60373c28f75.jsonnew file mode 100644index 0000000000..d2b084cf10--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-1435acbba365796ddcb6ddbef86f4ebf664cffc44082996f6b60a60373c28f75.json@@ -0,0 +1,17 @@+{+ "db_name": "PostgreSQL",+ "query": "\n INSERT INTO entity_properties (id, entity_id, entity_type, property_definition_id, values)\n SELECT \n u.id,\n u.entity_id,\n 'TASK'::property_entity_type,\n u.property_definition_id,\n u.values\n FROM UNNEST(\n $1::UUID[],\n $2::TEXT[],\n $3::UUID[],\n $4::JSONB[]\n ) AS u(id, entity_id, property_definition_id, values)\n ON CONFLICT (entity_id, entity_type, property_definition_id)\n DO UPDATE SET \n values = EXCLUDED.values,\n updated_at = NOW()\n ",+ "describe": {+ "columns": [],+ "parameters": {+ "Left": [+ "UuidArray",+ "TextArray",+ "UuidArray",+ "JsonbArray"+ ]+ },+ "nullable": []+ },+ "hash": "1435acbba365796ddcb6ddbef86f4ebf664cffc44082996f6b60a60373c28f75"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-50f36bd210dc628eafa42eeaba1f2e5ddeb8d28b19270e843dd3b6420c3f4653.json b/rust/cloud-storage/soup/.sqlx/query-50f36bd210dc628eafa42eeaba1f2e5ddeb8d28b19270e843dd3b6420c3f4653.jsondeleted file mode 100644index ad794e1904..0000000000--- a/rust/cloud-storage/soup/.sqlx/query-50f36bd210dc628eafa42eeaba1f2e5ddeb8d28b19270e843dd3b6420c3f4653.json+++ /dev/null@@ -1,131 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n WITH UserAccessibleItems AS (\n SELECT DISTINCT ON (\"item_id\", \"item_type\")\n \"item_id\",\n \"item_type\"\n FROM \"UserItemAccess\" \n WHERE \"user_id\" = $1\n ORDER BY \"item_id\", \"item_type\", \n CASE \"access_level\"\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\", \n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", d.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN d.\"createdAt\"\n ELSE d.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n 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-63492b018803ce26db5891964a0f52f37d2f54bd8243265c6561f4423af8617c.json b/rust/cloud-storage/soup/.sqlx/query-63492b018803ce26db5891964a0f52f37d2f54bd8243265c6561f4423af8617c.jsonnew file mode 100644index 0000000000..6d97183829--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-63492b018803ce26db5891964a0f52f37d2f54bd8243265c6561f4423af8617c.json@@ -0,0 +1,16 @@+{+ "db_name": "PostgreSQL",+ "query": "\n INSERT INTO entity_properties (id, entity_id, entity_type, property_definition_id, values)\n SELECT \n u.id,\n u.entity_id,\n 'TASK'::property_entity_type,\n u.property_definition_id,\n NULL\n FROM UNNEST(\n $1::UUID[],\n $2::TEXT[],\n $3::UUID[]\n ) AS u(id, entity_id, property_definition_id)\n ON CONFLICT (entity_id, entity_type, property_definition_id)\n DO NOTHING\n ",+ "describe": {+ "columns": [],+ "parameters": {+ "Left": [+ "UuidArray",+ "TextArray",+ "UuidArray"+ ]+ },+ "nullable": []+ },+ "hash": "63492b018803ce26db5891964a0f52f37d2f54bd8243265c6561f4423af8617c"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-688f7bb9d9bbf0bc1e5a7e6a4aeb19c80824db2df3df2fc22e15c48af8ef6413.json b/rust/cloud-storage/soup/.sqlx/query-688f7bb9d9bbf0bc1e5a7e6a4aeb19c80824db2df3df2fc22e15c48af8ef6413.jsondeleted file mode 100644index afca3974ff..0000000000--- a/rust/cloud-storage/soup/.sqlx/query-688f7bb9d9bbf0bc1e5a7e6a4aeb19c80824db2df3df2fc22e15c48af8ef6413.json+++ /dev/null@@ -1,131 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n WITH UserAccessibleItems AS (\n SELECT DISTINCT ON (\"item_id\", \"item_type\")\n \"item_id\",\n \"item_type\"\n FROM \"UserItemAccess\" \n WHERE \"user_id\" = $1\n ORDER BY \"item_id\", \"item_type\", \n CASE \"access_level\"\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\", \n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", d.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN d.\"createdAt\"\n ELSE d.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n 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-738f9b58274f884ba0276d6c64baef93ee515506157e3aaccca06f708ee4dc2d.json b/rust/cloud-storage/soup/.sqlx/query-738f9b58274f884ba0276d6c64baef93ee515506157e3aaccca06f708ee4dc2d.jsondeleted file mode 100644index e51903bed0..0000000000--- a/rust/cloud-storage/soup/.sqlx/query-738f9b58274f884ba0276d6c64baef93ee515506157e3aaccca06f708ee4dc2d.json+++ /dev/null@@ -1,131 +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.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-9cd40fbb1ade51e9e0d49792839d1a363cada017252a6f653c2272608189bcc4.json b/rust/cloud-storage/soup/.sqlx/query-9cd40fbb1ade51e9e0d49792839d1a363cada017252a6f653c2272608189bcc4.jsonnew file mode 100644index 0000000000..9d717fa5f9--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-9cd40fbb1ade51e9e0d49792839d1a363cada017252a6f653c2272608189bcc4.json@@ -0,0 +1,28 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT property_definition_id, values\n FROM entity_properties\n WHERE entity_id = $1\n AND entity_type = 'TASK'\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "property_definition_id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 1,+ "name": "values",+ "type_info": "Jsonb"+ }+ ],+ "parameters": {+ "Left": [+ "Text"+ ]+ },+ "nullable": [+ false,+ true+ ]+ },+ "hash": "9cd40fbb1ade51e9e0d49792839d1a363cada017252a6f653c2272608189bcc4"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-b1d22e50a96c22f0e887e594c17b058c7affaddbeb727707eb860ec8ff511235.json b/rust/cloud-storage/soup/.sqlx/query-aa8ade2c95791e695f255437eb1e24960c1ffb8a804b75f533dc6e7e063f5404.jsonsimilarity index 60%rename from rust/cloud-storage/soup/.sqlx/query-b1d22e50a96c22f0e887e594c17b058c7affaddbeb727707eb860ec8ff511235.jsonrename to rust/cloud-storage/soup/.sqlx/query-aa8ade2c95791e695f255437eb1e24960c1ffb8a804b75f533dc6e7e063f5404.jsonindex ab38d5ed61..6bec519dd0 100644--- a/rust/cloud-storage/soup/.sqlx/query-b1d22e50a96c22f0e887e594c17b058c7affaddbeb727707eb860ec8ff511235.json+++ b/rust/cloud-storage/soup/.sqlx/query-aa8ade2c95791e695f255437eb1e24960c1ffb8a804b75f533dc6e7e063f5404.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n WITH RECURSIVE ProjectHierarchy AS (\n SELECT p.id, uia.access_level \n FROM \"Project\" p\n JOIN \"UserItemAccess\" uia ON p.id = uia.item_id AND uia.item_type = 'project'\n WHERE uia.user_id = $1 AND p.\"deletedAt\" IS NULL\n UNION ALL\n SELECT p.id, ph.access_level\n FROM \"Project\" p \n JOIN ProjectHierarchy ph ON p.\"parentId\" = ph.id\n WHERE p.\"deletedAt\" IS NULL\n ),\n AllAccessGrants AS (\n SELECT item_id, item_type, access_level \n FROM \"UserItemAccess\" \n WHERE user_id = $1\n UNION ALL\n SELECT d.id AS item_id, 'document' AS item_type, ph.access_level\n FROM \"Document\" d \n JOIN ProjectHierarchy ph ON d.\"projectId\" = ph.id\n WHERE d.\"projectId\" IS NOT NULL AND d.\"deletedAt\" IS NULL\n UNION ALL\n SELECT c.id AS item_id, 'chat' AS item_type, ph.access_level\n FROM \"Chat\" c \n JOIN ProjectHierarchy ph ON c.\"projectId\" = ph.id\n WHERE c.\"projectId\" IS NOT NULL AND c.\"deletedAt\" IS NULL\n UNION ALL\n SELECT ph.id AS item_id, 'project' AS item_type, ph.access_level \n FROM ProjectHierarchy ph\n ),\n UserAccessibleItems AS (\n SELECT DISTINCT ON (item_id, item_type) item_id, item_type\n FROM AllAccessGrants\n ORDER BY item_id, item_type, \n CASE access_level\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\"\n 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 ",+ "query": "\n WITH RECURSIVE ProjectHierarchy AS (\n SELECT p.id, uia.access_level \n FROM \"Project\" p\n JOIN \"UserItemAccess\" uia ON p.id = uia.item_id AND uia.item_type = 'project'\n WHERE uia.user_id = $1 AND p.\"deletedAt\" IS NULL\n UNION ALL\n SELECT p.id, ph.access_level\n FROM \"Project\" p \n JOIN ProjectHierarchy ph ON p.\"parentId\" = ph.id\n WHERE p.\"deletedAt\" IS NULL\n ),\n AllAccessGrants AS (\n SELECT item_id, item_type, access_level \n FROM \"UserItemAccess\" \n WHERE user_id = $1\n UNION ALL\n SELECT d.id AS item_id, 'document' AS item_type, ph.access_level\n FROM \"Document\" d \n JOIN ProjectHierarchy ph ON d.\"projectId\" = ph.id\n WHERE d.\"projectId\" IS NOT NULL AND d.\"deletedAt\" IS NULL\n UNION ALL\n SELECT c.id AS item_id, 'chat' AS item_type, ph.access_level\n FROM \"Chat\" c \n JOIN ProjectHierarchy ph ON c.\"projectId\" = ph.id\n WHERE c.\"projectId\" IS NOT NULL AND c.\"deletedAt\" IS NULL\n UNION ALL\n SELECT ph.id AS item_id, 'project' AS item_type, ph.access_level \n FROM ProjectHierarchy ph\n ),\n UserAccessibleItems AS (\n SELECT DISTINCT ON (item_id, item_type) item_id, item_type\n FROM AllAccessGrants\n ORDER BY item_id, item_type, \n CASE access_level\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE \n WHEN dt.sub_type = 'task' \n AND ep_status.values->'value' ? $4\n THEN true \n WHEN dt.sub_type = 'task'\n THEN false\n ELSE NULL \n END as \"is_completed\"\n FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN entity_properties ep_status \n ON dt.sub_type = 'task'\n AND ep_status.entity_id = d.id \n AND ep_status.entity_type = 'TASK'\n AND ep_status.property_definition_id = $5\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = d.id \n AND uai.item_type = 'document'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = d.id \n AND uh.\"itemType\" = 'document' \n AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n AND d.id = ANY($2::text[])\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n NULL as \"is_completed\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = c.id \n AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = c.id \n AND uh.\"itemType\" = 'chat' \n AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n AND c.id = ANY($3::text[])\n )\n SELECT * \n FROM Combined\n ","describe": {"columns": [{@@ -91,13 +91,20 @@"ordinal": 15,"name": "viewed_at","type_info": "Timestamptz"+ },+ {+ "ordinal": 16,+ "name": "is_completed",+ "type_info": "Bool"}],"parameters": {"Left": ["Text","TextArray",- "TextArray"+ "TextArray",+ "Text",+ "Uuid"]},"nullable": [@@ -116,8 +123,9 @@null,null,null,+ null,null]},- "hash": "b1d22e50a96c22f0e887e594c17b058c7affaddbeb727707eb860ec8ff511235"+ "hash": "aa8ade2c95791e695f255437eb1e24960c1ffb8a804b75f533dc6e7e063f5404"}diff --git a/rust/cloud-storage/soup/.sqlx/query-e4f5c5a2a3a154e5b4be0cdce5d53199f09d18221d9ffd1e0bfd055b4d3da066.json b/rust/cloud-storage/soup/.sqlx/query-e4f5c5a2a3a154e5b4be0cdce5d53199f09d18221d9ffd1e0bfd055b4d3da066.jsonnew file mode 100644index 0000000000..01e3a90ccf--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-e4f5c5a2a3a154e5b4be0cdce5d53199f09d18221d9ffd1e0bfd055b4d3da066.json@@ -0,0 +1,139 @@+{+ "db_name": "PostgreSQL",+ "query": "\n WITH UserAccessibleItems AS (\n SELECT DISTINCT ON (\"item_id\", \"item_type\")\n \"item_id\",\n \"item_type\"\n FROM \"UserItemAccess\" \n WHERE \"user_id\" = $1\n ORDER BY \"item_id\", \"item_type\", \n CASE \"access_level\"\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\", \n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", d.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN d.\"createdAt\"\n ELSE d.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n CASE \n WHEN dt.sub_type = 'task' \n AND ep_status.values->'value' ? $6\n THEN true \n WHEN dt.sub_type = 'task'\n THEN false\n ELSE NULL \n END as \"is_completed\"\n FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN entity_properties ep_status \n ON dt.sub_type = 'task'\n AND ep_status.entity_id = d.id \n AND ep_status.entity_type = 'TASK'\n AND ep_status.property_definition_id = $7\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = d.id \n AND uai.item_type = 'document'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = d.id \n AND uh.\"itemType\" = 'document' \n AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n Select i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", c.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN c.\"createdAt\"\n ELSE c.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = c.id \n AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = c.id \n AND uh.\"itemType\" = 'chat' \n AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n \n UNION ALL\n \n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", p.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN p.\"createdAt\"\n ELSE p.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\"\n FROM \"Project\" p\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = p.id \n AND uai.item_type = 'project'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = p.id \n AND uh.\"itemType\" = 'project' \n AND uh.\"userId\" = $1\n WHERE p.\"deletedAt\" IS NULL\n )\n SELECT Combined.* FROM Combined\n LEFT JOIN frecency_aggregates fa\n ON fa.entity_id = Combined.\"id!\"\n AND fa.entity_type = Combined.\"item_type!\"\n AND fa.user_id = $1\n WHERE fa.id IS NULL\n AND (\n ($4::timestamptz IS NULL)\n OR\n (Combined.\"sort_ts!\", Combined.\"id!\") < ($4, $5)\n )\n ORDER BY Combined.\"sort_ts!\" DESC, Combined.\"updated_at!\" DESC\n LIMIT $3\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "item_type!",+ "type_info": "Text"+ },+ {+ "ordinal": 1,+ "name": "id!",+ "type_info": "Text"+ },+ {+ "ordinal": 2,+ "name": "document_version_id",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "user_id!",+ "type_info": "Text"+ },+ {+ "ordinal": 4,+ "name": "name!",+ "type_info": "Text"+ },+ {+ "ordinal": 5,+ "name": "branched_from_id",+ "type_info": "Text"+ },+ {+ "ordinal": 6,+ "name": "branched_from_version_id",+ "type_info": "Int8"+ },+ {+ "ordinal": 7,+ "name": "document_family_id",+ "type_info": "Int8"+ },+ {+ "ordinal": 8,+ "name": "file_type",+ "type_info": "Text"+ },+ {+ "ordinal": 9,+ "name": "created_at!",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 10,+ "name": "updated_at!",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 11,+ "name": "project_id",+ "type_info": "Text"+ },+ {+ "ordinal": 12,+ "name": "is_persistent",+ "type_info": "Bool"+ },+ {+ "ordinal": 13,+ "name": "sha",+ "type_info": "Text"+ },+ {+ "ordinal": 14,+ "name": "sub_type?: DocumentSubType",+ "type_info": {+ "Custom": {+ "name": "document_sub_type_value",+ "kind": {+ "Enum": [+ "task"+ ]+ }+ }+ }+ },+ {+ "ordinal": 15,+ "name": "viewed_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 16,+ "name": "sort_ts!",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 17,+ "name": "is_completed",+ "type_info": "Bool"+ }+ ],+ "parameters": {+ "Left": [+ "Text",+ "Text",+ "Int8",+ "Timestamptz",+ "Text",+ "Text",+ "Uuid"+ ]+ },+ "nullable": [+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null+ ]+ },+ "hash": "e4f5c5a2a3a154e5b4be0cdce5d53199f09d18221d9ffd1e0bfd055b4d3da066"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-f2d5d7aea9918978cd69c14f8afe24156c2fa387e001ee8eaf57e4a70a106069.json b/rust/cloud-storage/soup/.sqlx/query-f2d5d7aea9918978cd69c14f8afe24156c2fa387e001ee8eaf57e4a70a106069.jsonnew file mode 100644index 0000000000..182e0858ba--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-f2d5d7aea9918978cd69c14f8afe24156c2fa387e001ee8eaf57e4a70a106069.json@@ -0,0 +1,18 @@+{+ "db_name": "PostgreSQL",+ "query": "\n INSERT INTO entity_properties (id, entity_id, entity_type, property_definition_id, values)\n SELECT \n u.id,\n u.entity_id,\n u.entity_type::property_entity_type,\n u.property_definition_id,\n u.values\n FROM UNNEST(\n $1::UUID[],\n $2::TEXT[],\n $3::TEXT[],\n $4::UUID[],\n $5::JSONB[]\n ) AS u(id, entity_id, entity_type, property_definition_id, values)\n ON CONFLICT (entity_id, entity_type, property_definition_id)\n DO UPDATE SET \n values = EXCLUDED.values,\n updated_at = NOW()\n ",+ "describe": {+ "columns": [],+ "parameters": {+ "Left": [+ "UuidArray",+ "TextArray",+ "TextArray",+ "UuidArray",+ "JsonbArray"+ ]+ },+ "nullable": []+ },+ "hash": "f2d5d7aea9918978cd69c14f8afe24156c2fa387e001ee8eaf57e4a70a106069"+}diff --git a/rust/cloud-storage/soup/.sqlx/query-70e96ea014a65745e18085a6d6ee8efe50102744d45efd6cd01838d69361871d.json b/rust/cloud-storage/soup/.sqlx/query-f5327a81ef04ec4f1059515b983bbda0f8f655657c6395d9ecdb91a8cba91070.jsonsimilarity index 50%rename from rust/cloud-storage/soup/.sqlx/query-70e96ea014a65745e18085a6d6ee8efe50102744d45efd6cd01838d69361871d.jsonrename to rust/cloud-storage/soup/.sqlx/query-f5327a81ef04ec4f1059515b983bbda0f8f655657c6395d9ecdb91a8cba91070.jsonindex 2d5f53971a..5f5171db20 100644--- a/rust/cloud-storage/soup/.sqlx/query-70e96ea014a65745e18085a6d6ee8efe50102744d45efd6cd01838d69361871d.json+++ b/rust/cloud-storage/soup/.sqlx/query-f5327a81ef04ec4f1059515b983bbda0f8f655657c6395d9ecdb91a8cba91070.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": " \n WITH RECURSIVE ProjectHierarchy AS (\n SELECT p.id, uia.access_level \n FROM \"Project\" p\n JOIN \"UserItemAccess\" uia ON p.id = uia.item_id AND uia.item_type = 'project'\n WHERE uia.user_id = $1 AND p.\"deletedAt\" IS NULL\n UNION ALL\n SELECT p.id, ph.access_level\n FROM \"Project\" p \n JOIN ProjectHierarchy ph ON p.\"parentId\" = ph.id\n WHERE p.\"deletedAt\" IS NULL\n ),\n AllAccessGrants AS (\n SELECT item_id, item_type, access_level \n FROM \"UserItemAccess\" \n WHERE user_id = $1\n UNION ALL\n SELECT d.id AS item_id, 'document' AS item_type, ph.access_level\n FROM \"Document\" d \n JOIN ProjectHierarchy ph ON d.\"projectId\" = ph.id\n WHERE d.\"projectId\" IS NOT NULL AND d.\"deletedAt\" IS NULL\n UNION ALL\n SELECT c.id AS item_id, 'chat' AS item_type, ph.access_level\n FROM \"Chat\" c \n JOIN ProjectHierarchy ph ON c.\"projectId\" = ph.id\n WHERE c.\"projectId\" IS NOT NULL AND c.\"deletedAt\" IS NULL\n UNION ALL\n SELECT ph.id AS item_id, 'project' AS item_type, ph.access_level \n FROM ProjectHierarchy ph\n ),\n UserAccessibleItems AS (\n SELECT DISTINCT ON (item_id, item_type) item_id, item_type\n FROM AllAccessGrants\n ORDER BY item_id, item_type, \n CASE access_level\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", d.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN d.\"createdAt\"\n ELSE d.\"updatedAt\"\n END::timestamptz as \"sort_ts!\"\n 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 ",+ "query": " \n WITH RECURSIVE ProjectHierarchy AS (\n SELECT p.id, uia.access_level \n FROM \"Project\" p\n JOIN \"UserItemAccess\" uia ON p.id = uia.item_id AND uia.item_type = 'project'\n WHERE uia.user_id = $1 AND p.\"deletedAt\" IS NULL\n UNION ALL\n SELECT p.id, ph.access_level\n FROM \"Project\" p \n JOIN ProjectHierarchy ph ON p.\"parentId\" = ph.id\n WHERE p.\"deletedAt\" IS NULL\n ),\n AllAccessGrants AS (\n SELECT item_id, item_type, access_level \n FROM \"UserItemAccess\" \n WHERE user_id = $1\n UNION ALL\n SELECT d.id AS item_id, 'document' AS item_type, ph.access_level\n FROM \"Document\" d \n JOIN ProjectHierarchy ph ON d.\"projectId\" = ph.id\n WHERE d.\"projectId\" IS NOT NULL AND d.\"deletedAt\" IS NULL\n UNION ALL\n SELECT c.id AS item_id, 'chat' AS item_type, ph.access_level\n FROM \"Chat\" c \n JOIN ProjectHierarchy ph ON c.\"projectId\" = ph.id\n WHERE c.\"projectId\" IS NOT NULL AND c.\"deletedAt\" IS NULL\n UNION ALL\n SELECT ph.id AS item_id, 'project' AS item_type, ph.access_level \n FROM ProjectHierarchy ph\n ),\n UserAccessibleItems AS (\n SELECT DISTINCT ON (item_id, item_type) item_id, item_type\n FROM AllAccessGrants\n ORDER BY item_id, item_type, \n CASE access_level\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\",\n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", d.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN d.\"createdAt\"\n ELSE d.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n CASE \n WHEN dt.sub_type = 'task' \n AND ep_status.values->'value' ? $6\n THEN true \n WHEN dt.sub_type = 'task'\n THEN false\n ELSE NULL \n END as \"is_completed\"\n FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN entity_properties ep_status \n ON dt.sub_type = 'task'\n AND ep_status.entity_id = d.id \n AND ep_status.entity_type = 'TASK'\n AND ep_status.property_definition_id = $7\n INNER JOIN UserAccessibleItems uai ON uai.item_id = d.id AND uai.item_type = 'document'\n -- This MUST be a LEFT JOIN to support all three sort methods\n LEFT JOIN \"UserHistory\" uh ON uh.\"itemId\" = d.id AND uh.\"itemType\" = 'document' AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", c.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN c.\"createdAt\"\n ELSE c.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai ON uai.item_id = c.id AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh ON uh.\"itemId\" = c.id AND uh.\"itemType\" = 'chat' AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n\n UNION ALL\n\n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n CASE $2\n WHEN 'viewed_updated' THEN COALESCE(uh.\"updatedAt\", p.\"updatedAt\")\n WHEN 'viewed_at' THEN COALESCE(uh.\"updatedAt\", '1970-01-01 00:00:00+00')\n WHEN 'created_at' THEN p.\"createdAt\"\n ELSE p.\"updatedAt\"\n END::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\"\n FROM \"Project\" p\n INNER JOIN UserAccessibleItems uai\n ON uai.item_id = p.id\n AND uai.item_type = 'project'\n LEFT JOIN \"UserHistory\" uh\n ON uh.\"itemId\" = p.id\n AND uh.\"itemType\" = 'project'\n AND uh.\"userId\" = $1\n WHERE p.\"deletedAt\" IS NULL\n )\n SELECT * FROM Combined\n WHERE\n ($4::timestamptz IS NULL)\n OR\n (\"sort_ts!\", \"id!\"::text) < ($4, $5)\n ORDER BY \"sort_ts!\" DESC, \"updated_at!\" DESC\n LIMIT $3\n","describe": {"columns": [{@@ -96,6 +96,11 @@"ordinal": 16,"name": "sort_ts!","type_info": "Timestamptz"+ },+ {+ "ordinal": 17,+ "name": "is_completed",+ "type_info": "Bool"}],"parameters": {@@ -104,7 +109,9 @@"Text","Int8","Timestamptz",- "Text"+ "Text",+ "Text",+ "Uuid"]},"nullable": [@@ -124,8 +131,9 @@null,null,null,+ null,null]},- "hash": "70e96ea014a65745e18085a6d6ee8efe50102744d45efd6cd01838d69361871d"+ "hash": "f5327a81ef04ec4f1059515b983bbda0f8f655657c6395d9ecdb91a8cba91070"}diff --git a/rust/cloud-storage/soup/.sqlx/query-fa139f4c10ab3adb0f4beb6205604f4f1a8b45ecb1a11e6d729375b2426e9e93.json b/rust/cloud-storage/soup/.sqlx/query-fa139f4c10ab3adb0f4beb6205604f4f1a8b45ecb1a11e6d729375b2426e9e93.jsondeleted file mode 100644index 42d8607305..0000000000--- a/rust/cloud-storage/soup/.sqlx/query-fa139f4c10ab3adb0f4beb6205604f4f1a8b45ecb1a11e6d729375b2426e9e93.json+++ /dev/null@@ -1,130 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n WITH UserAccessibleItems AS (\n SELECT DISTINCT ON (\"item_id\", \"item_type\")\n \"item_id\",\n \"item_type\"\n FROM \"UserItemAccess\" \n WHERE \"user_id\" = $1\n ORDER BY \"item_id\", \"item_type\", \n CASE \"access_level\"\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\", \n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n d.\"updatedAt\"::timestamptz as \"sort_ts!\"\n 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/.sqlx/query-ffc5c6bdbf1439c09a27570cf67ce180d79d89950f58e96cc7ea62e5c5156439.json b/rust/cloud-storage/soup/.sqlx/query-ffc5c6bdbf1439c09a27570cf67ce180d79d89950f58e96cc7ea62e5c5156439.jsonnew file mode 100644index 0000000000..48607935f4--- /dev/null+++ b/rust/cloud-storage/soup/.sqlx/query-ffc5c6bdbf1439c09a27570cf67ce180d79d89950f58e96cc7ea62e5c5156439.json@@ -0,0 +1,138 @@+{+ "db_name": "PostgreSQL",+ "query": "\n WITH UserAccessibleItems AS (\n SELECT DISTINCT ON (\"item_id\", \"item_type\")\n \"item_id\",\n \"item_type\"\n FROM \"UserItemAccess\" \n WHERE \"user_id\" = $1\n ORDER BY \"item_id\", \"item_type\", \n CASE \"access_level\"\n WHEN 'owner' THEN 4\n WHEN 'edit' THEN 3 \n WHEN 'comment' THEN 2\n WHEN 'view' THEN 1\n ELSE 0\n END DESC\n ),\n Combined AS (\n SELECT\n 'document' as \"item_type!\",\n d.id as \"id!\",\n CAST(COALESCE(di.id, db.id) as TEXT) as \"document_version_id\",\n d.owner as \"user_id!\",\n d.name as \"name!\",\n d.\"branchedFromId\" as \"branched_from_id\",\n d.\"branchedFromVersionId\" as \"branched_from_version_id\", \n d.\"documentFamilyId\" as \"document_family_id\",\n d.\"fileType\" as \"file_type\",\n d.\"createdAt\"::timestamptz as \"created_at!\",\n d.\"updatedAt\"::timestamptz as \"updated_at!\",\n d.\"projectId\" as \"project_id\",\n NULL as \"is_persistent\",\n di.sha as \"sha\",\n dt.sub_type as \"sub_type?: DocumentSubType\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n d.\"updatedAt\"::timestamptz as \"sort_ts!\",\n CASE \n WHEN dt.sub_type = 'task' \n AND ep_status.values->'value' ? $5\n THEN true \n WHEN dt.sub_type = 'task'\n THEN false\n ELSE NULL \n END as \"is_completed\"\n FROM \"Document\" d\n LEFT JOIN document_sub_type dt ON dt.document_id = d.id\n LEFT JOIN entity_properties ep_status \n ON dt.sub_type = 'task'\n AND ep_status.entity_id = d.id \n AND ep_status.entity_type = 'TASK'\n AND ep_status.property_definition_id = $6\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = d.id \n AND uai.item_type = 'document'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = d.id \n AND uh.\"itemType\" = 'document' \n AND uh.\"userId\" = $1\n LEFT JOIN LATERAL (\n SELECT b.id \n FROM \"DocumentBom\" b \n WHERE b.\"documentId\" = d.id \n ORDER BY b.\"createdAt\" DESC \n LIMIT 1\n ) db ON true\n LEFT JOIN LATERAL (\n SELECT i.id, i.sha \n FROM \"DocumentInstance\" i \n WHERE i.\"documentId\" = d.id \n ORDER BY i.\"updatedAt\" DESC \n LIMIT 1\n ) di ON true\n WHERE d.\"deletedAt\" IS NULL\n AND d.id = ANY($2::text[])\n\n UNION ALL\n \n SELECT\n 'chat' as \"item_type!\",\n c.id as \"id!\",\n NULL as \"document_version_id\",\n c.\"userId\" as \"user_id!\",\n c.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n c.\"createdAt\"::timestamptz as \"created_at!\",\n c.\"updatedAt\"::timestamptz as \"updated_at!\",\n c.\"projectId\" as \"project_id\",\n c.\"isPersistent\" as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n c.\"updatedAt\"::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\"\n FROM \"Chat\" c\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = c.id \n AND uai.item_type = 'chat'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = c.id \n AND uh.\"itemType\" = 'chat' \n AND uh.\"userId\" = $1\n WHERE c.\"deletedAt\" IS NULL\n AND c.id = ANY($3::text[])\n \n UNION ALL\n \n SELECT\n 'project' as \"item_type!\",\n p.id as \"id!\",\n NULL as \"document_version_id\",\n p.\"userId\" as \"user_id!\",\n p.name as \"name!\",\n NULL as \"branched_from_id\",\n NULL as \"branched_from_version_id\",\n NULL as \"document_family_id\",\n NULL as \"file_type\",\n p.\"createdAt\"::timestamptz as \"created_at!\",\n p.\"updatedAt\"::timestamptz as \"updated_at!\",\n p.\"parentId\" as \"project_id\",\n NULL as \"is_persistent\",\n NULL as \"sha\",\n NULL as \"sub_type\",\n uh.\"updatedAt\"::timestamptz as \"viewed_at\",\n p.\"updatedAt\"::timestamptz as \"sort_ts!\",\n NULL as \"is_completed\"\n FROM \"Project\" p\n INNER JOIN UserAccessibleItems uai \n ON uai.item_id = p.id \n AND uai.item_type = 'project'\n LEFT JOIN \"UserHistory\" uh \n ON uh.\"itemId\" = p.id \n AND uh.\"itemType\" = 'project' \n AND uh.\"userId\" = $1\n WHERE p.\"deletedAt\" IS NULL\n AND p.id = ANY($4::text[])\n )\n SELECT * \n FROM Combined\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "item_type!",+ "type_info": "Text"+ },+ {+ "ordinal": 1,+ "name": "id!",+ "type_info": "Text"+ },+ {+ "ordinal": 2,+ "name": "document_version_id",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "user_id!",+ "type_info": "Text"+ },+ {+ "ordinal": 4,+ "name": "name!",+ "type_info": "Text"+ },+ {+ "ordinal": 5,+ "name": "branched_from_id",+ "type_info": "Text"+ },+ {+ "ordinal": 6,+ "name": "branched_from_version_id",+ "type_info": "Int8"+ },+ {+ "ordinal": 7,+ "name": "document_family_id",+ "type_info": "Int8"+ },+ {+ "ordinal": 8,+ "name": "file_type",+ "type_info": "Text"+ },+ {+ "ordinal": 9,+ "name": "created_at!",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 10,+ "name": "updated_at!",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 11,+ "name": "project_id",+ "type_info": "Text"+ },+ {+ "ordinal": 12,+ "name": "is_persistent",+ "type_info": "Bool"+ },+ {+ "ordinal": 13,+ "name": "sha",+ "type_info": "Text"+ },+ {+ "ordinal": 14,+ "name": "sub_type?: DocumentSubType",+ "type_info": {+ "Custom": {+ "name": "document_sub_type_value",+ "kind": {+ "Enum": [+ "task"+ ]+ }+ }+ }+ },+ {+ "ordinal": 15,+ "name": "viewed_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 16,+ "name": "sort_ts!",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 17,+ "name": "is_completed",+ "type_info": "Bool"+ }+ ],+ "parameters": {+ "Left": [+ "Text",+ "TextArray",+ "TextArray",+ "TextArray",+ "Text",+ "Uuid"+ ]+ },+ "nullable": [+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null,+ null+ ]+ },+ "hash": "ffc5c6bdbf1439c09a27570cf67ce180d79d89950f58e96cc7ea62e5c5156439"+}diff --git a/rust/cloud-storage/soup/Cargo.toml b/rust/cloud-storage/soup/Cargo.tomlindex 0bedaf0908..9eae54feb0 100644--- a/rust/cloud-storage/soup/Cargo.toml+++ b/rust/cloud-storage/soup/Cargo.toml@@ -49,6 +49,7 @@ tokio = { workspace = true, features = ["macros"], optional = true }tracing = { workspace = true }utoipa = { workspace = true, optional = true }uuid = { workspace = true }+system_properties = { path = "../system_properties" }[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 dfe118952a..d2d79b3870 100644--- a/rust/cloud-storage/soup/src/domain/service/tests.rs+++ b/rust/cloud-storage/soup/src/domain/service/tests.rs@@ -1,9 +1,9 @@+use crate::domain::models::FrecencySoupItem;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::models::{FrecencyPageRequest, FrecencyPageResponse};use frecency::domain::ports::MockFrecencyQueryService;use frecency::domain::services::FrecencyQueryServiceImpl;use frecency::{domain::models::AggregateFrecency, outbound::mock::MockFrecencyStorage};@@ -11,7 +11,7 @@ use model_entity::EntityType;use models_pagination::{Cursor, CursorVal, FrecencyValue, PaginatedCursor, SimpleSortMethod, TypeEraseCursor,};-use models_soup::document::SoupDocument;+use models_soup::document::{SoupDocument, SoupDocumentSubType};use ordered_float::OrderedFloat;use rootcause::Report;use sqlx::types::chrono::{DateTime, Utc};@@ -100,6 +100,14 @@ fn soup_document_with_updated(id: &str, updated_at: DateTime<Utc>) -> SoupDocume}fn soup_document_uuid_with_updated(id: Uuid, updated_at: DateTime<Utc>) -> SoupDocument {+ soup_document_with_is_completed(id, updated_at, None)+}++fn soup_document_with_is_completed(+ id: Uuid,+ updated_at: DateTime<Utc>,+ is_completed: Option<bool>,+) -> SoupDocument {SoupDocument {id,document_version_id: 1,@@ -114,7 +122,7 @@ fn soup_document_uuid_with_updated(id: Uuid, updated_at: DateTime<Utc>) -> SoupDcreated_at: Default::default(),updated_at,viewed_at: Default::default(),- sub_type: Some(DocumentSubType::Task),+ sub_type: is_completed.map(|is_completed| SoupDocumentSubType::Task { is_completed }),}}@@ -774,3 +782,266 @@ async fn cursor_should_return_frecency() {assert!(filter.is_none());})}++/// Helper to extract is_completed from a FrecencySoupItem+fn get_is_completed(item: &FrecencySoupItem) -> Option<bool> {+ match &item.item {+ SoupItem::Document(doc) => doc.sub_type.as_ref().and_then(|st| st.is_task_completed()),+ _ => None,+ }+}++#[tokio::test]+async fn it_should_return_is_completed_true_for_completed_tasks() {+ let mut soup_mock = MockSoupRepo::new();+ soup_mock+ .expect_unexpanded_generic_cursor_soup()+ .times(1)+ .returning(|_params| {+ Box::pin(async move {+ Ok(vec![SoupItem::Document(soup_document_with_is_completed(+ Uuid::from_u128(1),+ Default::default(),+ Some(true),+ ))])+ })+ });++ let res = SoupImpl::new(+ soup_mock,+ FrecencyQueryServiceImpl::new(MockFrecencyStorage::new()),+ NoopEmailService,+ NoopCommsService,+ )+ .get_user_soup(SoupRequest {+ email_preview_view: PreviewView::StandardLabel(+ email::domain::models::PreviewViewStandardLabel::Inbox,+ ),+ link_id: Some(Uuid::new_v4()),+ soup_type: SoupType::UnExpanded,+ limit: 0,+ cursor: SoupQuery::Simple(Query::Sort(SimpleSortMethod::ViewedUpdated, None)),+ user: MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap(),+ })+ .await+ .unwrap()+ .type_erase();++ assert_eq!(res.items.len(), 1);+ assert_eq!(get_is_completed(res.items.first().unwrap()), Some(true));+}++#[tokio::test]+async fn it_should_return_is_completed_false_for_incomplete_tasks() {+ let mut soup_mock = MockSoupRepo::new();+ soup_mock+ .expect_unexpanded_generic_cursor_soup()+ .times(1)+ .returning(|_params| {+ Box::pin(async move {+ Ok(vec![SoupItem::Document(soup_document_with_is_completed(+ Uuid::from_u128(1),+ Default::default(),+ Some(false),+ ))])+ })+ });++ let res = SoupImpl::new(+ soup_mock,+ FrecencyQueryServiceImpl::new(MockFrecencyStorage::new()),+ NoopEmailService,+ NoopCommsService,+ )+ .get_user_soup(SoupRequest {+ email_preview_view: PreviewView::StandardLabel(+ email::domain::models::PreviewViewStandardLabel::Inbox,+ ),+ link_id: Some(Uuid::new_v4()),+ soup_type: SoupType::UnExpanded,+ limit: 0,+ cursor: SoupQuery::Simple(Query::Sort(SimpleSortMethod::ViewedUpdated, None)),+ user: MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap(),+ })+ .await+ .unwrap()+ .type_erase();++ assert_eq!(res.items.len(), 1);+ assert_eq!(get_is_completed(res.items.first().unwrap()), Some(false));+}++#[tokio::test]+async fn it_should_return_is_completed_none_for_non_tasks() {+ let mut soup_mock = MockSoupRepo::new();+ soup_mock+ .expect_unexpanded_generic_cursor_soup()+ .times(1)+ .returning(|_params| {+ Box::pin(async move {+ Ok(vec![SoupItem::Document(soup_document_with_is_completed(+ Uuid::from_u128(1),+ Default::default(),+ None,+ ))])+ })+ });++ let res = SoupImpl::new(+ soup_mock,+ FrecencyQueryServiceImpl::new(MockFrecencyStorage::new()),+ NoopEmailService,+ NoopCommsService,+ )+ .get_user_soup(SoupRequest {+ email_preview_view: PreviewView::StandardLabel(+ email::domain::models::PreviewViewStandardLabel::Inbox,+ ),+ link_id: Some(Uuid::new_v4()),+ soup_type: SoupType::UnExpanded,+ limit: 0,+ cursor: SoupQuery::Simple(Query::Sort(SimpleSortMethod::ViewedUpdated, None)),+ user: MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap(),+ })+ .await+ .unwrap()+ .type_erase();++ assert_eq!(res.items.len(), 1);+ assert_eq!(get_is_completed(res.items.first().unwrap()), None);+}++#[tokio::test]+async fn it_should_preserve_is_completed_for_mixed_items() {+ let mut soup_mock = MockSoupRepo::new();+ soup_mock+ .expect_unexpanded_generic_cursor_soup()+ .times(1)+ .returning(|_params| {+ Box::pin(async move {+ Ok(vec![+ SoupItem::Document(soup_document_with_is_completed(+ Uuid::from_u128(1),+ Default::default(),+ Some(true),+ )),+ SoupItem::Document(soup_document_with_is_completed(+ Uuid::from_u128(2),+ Default::default(),+ Some(false),+ )),+ SoupItem::Document(soup_document_with_is_completed(+ Uuid::from_u128(3),+ Default::default(),+ None,+ )),+ ])+ })+ });++ let res = SoupImpl::new(+ soup_mock,+ FrecencyQueryServiceImpl::new(MockFrecencyStorage::new()),+ NoopEmailService,+ NoopCommsService,+ )+ .get_user_soup(SoupRequest {+ email_preview_view: PreviewView::StandardLabel(+ email::domain::models::PreviewViewStandardLabel::Inbox,+ ),+ link_id: Some(Uuid::new_v4()),+ soup_type: SoupType::UnExpanded,+ limit: 0,+ cursor: SoupQuery::Simple(Query::Sort(SimpleSortMethod::ViewedUpdated, None)),+ user: MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap(),+ })+ .await+ .unwrap()+ .type_erase();++ assert_eq!(res.items.len(), 3);+ assert_eq!(get_is_completed(&res.items[0]), Some(true));+ assert_eq!(get_is_completed(&res.items[1]), Some(false));+ assert_eq!(get_is_completed(&res.items[2]), None);+}++#[tokio::test]+async fn it_should_preserve_is_completed_in_by_ids_queries() {+ let mut frecency = MockFrecencyQueryService::new();+ frecency+ .expect_get_frecency_page()+ .withf(|params| assert_matches!(params, FrecencyPageRequest { limit: 20, .. } => true))+ .times(1)+ .returning(|params| {+ // Return 20 items to match the limit and avoid fallback+ let iter = (1..=params.limit).map(|v| {+ AggregateFrecency::new_mock(+ EntityType::Document+ .with_entity_string(uuid::Uuid::from_u128(v as u128).to_string()),+ v.into(),+ )+ });+ let res = Ok(FrecencyPageResponse::new_mock(iter));+ Box::pin(async move { res })+ });++ let mut soup_mock = MockSoupRepo::new();+ soup_mock+ .expect_unexpanded_soup_by_ids()+ .times(1)+ .returning(|params| {+ let res = Ok(params+ .entities+ .iter()+ .enumerate()+ .map(|(idx, v)| {+ // Set is_completed on first 3 items to test the field+ let is_completed = match idx {+ 0 => Some(true),+ 1 => Some(false),+ 2 => None,+ _ => None,+ };+ soup_document_with_is_completed(+ Uuid::parse_str(&v.entity_id).unwrap(),+ Default::default(),+ is_completed,+ )+ })+ .map(SoupItem::Document)+ .collect());+ Box::pin(async move { res })+ });++ let res = SoupImpl::new(soup_mock, frecency, NoopEmailService, NoopCommsService)+ .get_user_soup(SoupRequest {+ email_preview_view: PreviewView::StandardLabel(+ email::domain::models::PreviewViewStandardLabel::Inbox,+ ),+ link_id: Some(Uuid::new_v4()),+ soup_type: SoupType::UnExpanded,+ limit: 3,+ cursor: SoupQuery::Frecency(Query::Sort(Frecency, None)),+ user: MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap(),+ })+ .await+ .unwrap()+ .unwrap_right();++ // Should have 20 items, verify is_completed values are preserved+ assert_eq!(res.items.len(), 20);+ let is_completed_values: Vec<Option<bool>> = res.items.iter().map(get_is_completed).collect();+ // Verify that all three is_completed values (true, false, None) are present+ assert!(+ is_completed_values.contains(&Some(true)),+ "Should contain is_completed=true"+ );+ assert!(+ is_completed_values.contains(&Some(false)),+ "Should contain is_completed=false"+ );+ assert!(+ is_completed_values.contains(&None),+ "Should contain is_completed=None"+ );+}diff --git a/rust/cloud-storage/soup/src/outbound/pg_soup_repo.rs b/rust/cloud-storage/soup/src/outbound/pg_soup_repo.rsindex 93ab22b815..31bb8da529 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,10 @@ macro_rules! map_soup_type {created_at: r.created_at,updated_at: r.updated_at,viewed_at: r.viewed_at,- sub_type: r.sub_type,+ sub_type: ::models_soup::document::SoupDocumentSubType::from_db(+ r.sub_type,+ r.is_completed,+ ),},)),"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 4b94b471ca..57631d2c40 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@@ -7,6 +7,7 @@ use models_pagination::{Frecency, Query, SimpleSortMethod};use models_soup::item::SoupItem;use sqlx::PgPool;use std::str::FromStr;+use system_properties::{StatusOption, SystemPropertyKey};use uuid::Uuid;/// Returns objects that a user has EXPLICIT and IMPLICIT access to.@@ -28,6 +29,9 @@ pub async fn expanded_generic_cursor_soup(let (cursor_id, cursor_timestamp) = cursor.vals();let cursor_id = cursor_id.as_ref().map(|u| u.to_string());+ let status_property_id = SystemPropertyKey::STATUS_UUID;+ let completed_option_id = StatusOption::COMPLETED_UUID.to_string();+let items: Vec<SoupItem> = sqlx::query!(r#"WITH RECURSIVE ProjectHierarchy AS (@@ -94,9 +98,22 @@ r#"WHEN 'viewed_at' THEN COALESCE(uh."updatedAt", '1970-01-01 00:00:00+00')WHEN 'created_at' THEN d."createdAt"ELSE d."updatedAt"- END::timestamptz as "sort_ts!"+ END::timestamptz as "sort_ts!",+ CASE+ WHEN dt.sub_type = 'task'+ AND ep_status.values->'value' ? $6+ THEN true+ WHEN dt.sub_type = 'task'+ THEN false+ ELSE NULL+ END as "is_completed"FROM "Document" dLEFT JOIN document_sub_type dt ON dt.document_id = d.id+ LEFT JOIN entity_properties ep_status+ ON dt.sub_type = 'task'+ AND ep_status.entity_id = d.id+ AND ep_status.entity_type = 'TASK'+ AND ep_status.property_definition_id = $7INNER JOIN UserAccessibleItems uai ON uai.item_id = d.id AND uai.item_type = 'document'-- This MUST be a LEFT JOIN to support all three sort methodsLEFT JOIN "UserHistory" uh ON uh."itemId" = d.id AND uh."itemType" = 'document' AND uh."userId" = $1@@ -140,7 +157,8 @@ r#"WHEN 'viewed_at' THEN COALESCE(uh."updatedAt", '1970-01-01 00:00:00+00')WHEN 'created_at' THEN c."createdAt"ELSE c."updatedAt"- END::timestamptz as "sort_ts!"+ END::timestamptz as "sort_ts!",+ NULL as "is_completed"FROM "Chat" cINNER JOIN UserAccessibleItems uai ON uai.item_id = c.id AND uai.item_type = 'chat'LEFT JOIN "UserHistory" uh ON uh."itemId" = c.id AND uh."itemType" = 'chat' AND uh."userId" = $1@@ -170,7 +188,8 @@ r#"WHEN 'viewed_at' THEN COALESCE(uh."updatedAt", '1970-01-01 00:00:00+00')WHEN 'created_at' THEN p."createdAt"ELSE p."updatedAt"- END::timestamptz as "sort_ts!"+ END::timestamptz as "sort_ts!",+ NULL as "is_completed"FROM "Project" pINNER JOIN UserAccessibleItems uaiON uai.item_id = p.id@@ -189,11 +208,13 @@ r#"ORDER BY "sort_ts!" DESC, "updated_at!" DESCLIMIT $3"#,- user_id.as_ref(), // $1- sort_method_str, // $2- query_limit, // $3- cursor_timestamp, // $4- cursor_id, // $5+ user_id.as_ref(), // $1+ sort_method_str, // $2+ query_limit, // $3+ cursor_timestamp, // $4+ cursor_id, // $5+ completed_option_id, // $6+ status_property_id, // $7).try_map(map_soup_type!()).fetch_all(db)@@ -216,6 +237,9 @@ pub async fn no_frecency_expanded_generic_soup(let (cursor_id, cursor_timestamp) = cursor.vals();let cursor_id = cursor_id.as_ref().map(|u| u.to_string());+ let status_property_id = SystemPropertyKey::STATUS_UUID;+ let completed_option_id = StatusOption::COMPLETED_UUID.to_string();+let items: Vec<SoupItem> = sqlx::query!(r#"WITH RECURSIVE ProjectHierarchy AS (@@ -282,9 +306,22 @@ r#"WHEN 'viewed_at' THEN COALESCE(uh."updatedAt", '1970-01-01 00:00:00+00')WHEN 'created_at' THEN d."createdAt"ELSE d."updatedAt"- END::timestamptz as "sort_ts!"+ END::timestamptz as "sort_ts!",+ CASE+ WHEN dt.sub_type = 'task'+ AND ep_status.values->'value' ? $6+ THEN true+ WHEN dt.sub_type = 'task'+ THEN false+ ELSE NULL+ END as "is_completed"FROM "Document" dLEFT JOIN document_sub_type dt ON dt.document_id = d.id+ LEFT JOIN entity_properties ep_status+ ON dt.sub_type = 'task'+ AND ep_status.entity_id = d.id+ AND ep_status.entity_type = 'TASK'+ AND ep_status.property_definition_id = $7INNER JOIN UserAccessibleItems uai ON uai.item_id = d.id AND uai.item_type = 'document'-- This MUST be a LEFT JOIN to support all three sort methodsLEFT JOIN "UserHistory" uh ON uh."itemId" = d.id AND uh."itemType" = 'document' AND uh."userId" = $1@@ -328,7 +365,8 @@ r#"WHEN 'viewed_at' THEN COALESCE(uh."updatedAt", '1970-01-01 00:00:00+00')WHEN 'created_at' THEN c."createdAt"ELSE c."updatedAt"- END::timestamptz as "sort_ts!"+ END::timestamptz as "sort_ts!",+ NULL as "is_completed"FROM "Chat" cINNER JOIN UserAccessibleItems uai ON uai.item_id = c.id AND uai.item_type = 'chat'LEFT JOIN "UserHistory" uh ON uh."itemId" = c.id AND uh."itemType" = 'chat' AND uh."userId" = $1@@ -358,7 +396,8 @@ r#"WHEN 'viewed_at' THEN COALESCE(uh."updatedAt", '1970-01-01 00:00:00+00')WHEN 'created_at' THEN p."createdAt"ELSE p."updatedAt"- END::timestamptz as "sort_ts!"+ END::timestamptz as "sort_ts!",+ NULL as "is_completed"FROM "Project" pINNER JOIN UserAccessibleItems uaiON uai.item_id = p.id@@ -383,11 +422,13 @@ r#"ORDER BY Combined."sort_ts!" DESC, Combined."updated_at!" DESCLIMIT $3"#,- user_id.as_ref(), // $1- sort_method_str, // $2- query_limit, // $3- cursor_timestamp, // $4- cursor_id, // $5+ user_id.as_ref(), // $1+ sort_method_str, // $2+ query_limit, // $3+ cursor_timestamp, // $4+ cursor_id, // $5+ completed_option_id, // $6+ status_property_id, // $7).try_map(map_soup_type!()).fetch_all(db)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 5566d4a53d..cffe691559 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@@ -5,6 +5,7 @@ use model_entity::{Entity, EntityType};use models_soup::item::SoupItem;use sqlx::PgPool;use std::str::FromStr;+use system_properties::{StatusOption, SystemPropertyKey};use uuid::Uuid;/// Returns objects that a user has EXPLICIT and IMPLICIT access to by their IDs, excluding project items.@@ -33,6 +34,9 @@ pub async fn expanded_soup_by_ids<'a>(return Ok(Vec::new());}+ let status_property_id = SystemPropertyKey::STATUS_UUID;+ let completed_option_id = StatusOption::COMPLETED_UUID.to_string();+let items: Vec<SoupItem> = sqlx::query!(r#"WITH RECURSIVE ProjectHierarchy AS (@@ -93,9 +97,22 @@ pub async fn expanded_soup_by_ids<'a>(NULL as "is_persistent",di.sha as "sha",dt.sub_type as "sub_type?: DocumentSubType",- uh."updatedAt"::timestamptz as "viewed_at"+ uh."updatedAt"::timestamptz as "viewed_at",+ CASE+ WHEN dt.sub_type = 'task'+ AND ep_status.values->'value' ? $4+ THEN true+ WHEN dt.sub_type = 'task'+ THEN false+ ELSE NULL+ END as "is_completed"FROM "Document" dLEFT JOIN document_sub_type dt ON dt.document_id = d.id+ LEFT JOIN entity_properties ep_status+ ON dt.sub_type = 'task'+ AND ep_status.entity_id = d.id+ AND ep_status.entity_type = 'TASK'+ AND ep_status.property_definition_id = $5INNER JOIN UserAccessibleItems uaiON uai.item_id = d.idAND uai.item_type = 'document'@@ -138,7 +155,8 @@ pub async fn expanded_soup_by_ids<'a>(c."isPersistent" as "is_persistent",NULL as "sha",NULL as "sub_type",- uh."updatedAt"::timestamptz as "viewed_at"+ uh."updatedAt"::timestamptz as "viewed_at",+ NULL as "is_completed"FROM "Chat" cINNER JOIN UserAccessibleItems uaiON uai.item_id = c.id@@ -156,6 +174,8 @@ pub async fn expanded_soup_by_ids<'a>(user_id.as_ref(), // $1document_ids.as_slice(), // $2chat_ids.as_slice(), // $3+ completed_option_id, // $4+ status_property_id, // $5).try_map(map_soup_type!()).fetch_all(db)diff --git a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/dynamic.rs b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/dynamic.rsindex ca4663e4cf..09c62071fe 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@@ -11,9 +11,15 @@ use item_filters::ast::{};use macro_user_id::{cowlike::CowLike, user_id::MacroUserIdStr};use models_pagination::{Query, SimpleSortMethod};-use models_soup::{chat::SoupChat, document::SoupDocument, item::SoupItem, project::SoupProject};+use models_soup::{+ chat::SoupChat,+ document::{SoupDocument, SoupDocumentSubType},+ item::SoupItem,+ project::SoupProject,+};use recursion::CollapsibleExt;use sqlx::{PgPool, Postgres, QueryBuilder, Row, postgres::PgRow, prelude::FromRow};+use system_properties::{StatusOption, SystemPropertyKey};use uuid::Uuid;use crate::outbound::pg_soup_repo::type_err;@@ -85,9 +91,22 @@ static DOCUMENT_CLAUSE: &str = r#"WHEN 'viewed_at' THEN COALESCE(uh."updatedAt", '1970-01-01 00:00:00+00')WHEN 'created_at' THEN d."createdAt"ELSE d."updatedAt"- END::timestamptz as "sort_ts"+ END::timestamptz as "sort_ts",+ CASE+ WHEN dt.sub_type = 'task'+ AND ep_status.values->'value' ? $6+ THEN true+ WHEN dt.sub_type = 'task'+ THEN false+ ELSE NULL+ END as "is_completed"FROM "Document" dLEFT JOIN document_sub_type dt ON dt.document_id = d.id+ LEFT JOIN entity_properties ep_status+ ON dt.sub_type = 'task'+ AND ep_status.entity_id = d.id+ AND ep_status.entity_type = 'TASK'+ AND ep_status.property_definition_id = $7INNER JOIN UserAccessibleItems uai ON uai.item_id = d.id AND uai.item_type = 'document'-- This MUST be a LEFT JOIN to support all three sort methodsLEFT JOIN "UserHistory" uh ON uh."itemId" = d.id AND uh."itemType" = 'document' AND uh."userId" = $1@@ -131,7 +150,8 @@ static CHAT_CLAUSE: &str = r#"WHEN 'viewed_at' THEN COALESCE(uh."updatedAt", '1970-01-01 00:00:00+00')WHEN 'created_at' THEN c."createdAt"ELSE c."updatedAt"- END::timestamptz as "sort_ts"+ END::timestamptz as "sort_ts",+ NULL as "is_completed"FROM "Chat" cINNER JOIN UserAccessibleItems uai ON uai.item_id = c.id AND uai.item_type = 'chat'LEFT JOIN "UserHistory" uh ON uh."itemId" = c.id AND uh."itemType" = 'chat' AND uh."userId" = $1@@ -161,7 +181,8 @@ static PROJECT_CLAUSE: &str = r#"WHEN 'viewed_at' THEN COALESCE(uh."updatedAt", '1970-01-01 00:00:00+00')WHEN 'created_at' THEN p."createdAt"ELSE p."updatedAt"- END::timestamptz as "sort_ts"+ END::timestamptz as "sort_ts",+ NULL as "is_completed"FROM "Project" pINNER JOIN UserAccessibleItems uaiON uai.item_id = p.id@@ -313,6 +334,7 @@ struct DocumentRow {updated_at: DateTime<Utc>,viewed_at: Option<DateTime<Utc>>,sub_type: Option<DocumentSubType>,+ is_completed: Option<bool>,}#[derive(Debug, FromRow)]@@ -378,6 +400,7 @@ impl SoupRow {updated_at,viewed_at,sub_type,+ is_completed,}) => SoupItem::Document(SoupDocument {id: Uuid::parse_str(&id).map_err(type_err)?,document_version_id: document_version_id@@ -404,7 +427,7 @@ impl SoupRow {created_at,updated_at,viewed_at,- sub_type,+ sub_type: SoupDocumentSubType::from_db(sub_type, is_completed),}),SoupRow::Chat(ChatRow {id,@@ -486,6 +509,8 @@ pub(crate) async fn expanded_dynamic_cursor_soup(let sort_method_str = cursor.sort_method().to_string();let (cursor_id, cursor_timestamp) = cursor.vals();let cursor_id_str = cursor_id.as_ref().map(|u| u.to_string());+ let status_property_id = SystemPropertyKey::STATUS_UUID;+ let completed_option_id = StatusOption::COMPLETED_UUID.to_string();build_query(cursor.filter(), exclude_frecency).build()@@ -494,6 +519,8 @@ pub(crate) async fn expanded_dynamic_cursor_soup(.bind(query_limit).bind(cursor_timestamp).bind(cursor_id_str)+ .bind(completed_option_id)+ .bind(status_property_id).try_map(|row| SoupRow::from_row(&row)?.into_soup_item()).fetch_all(db).awaitdiff --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 93cf37426d..63bcdb3597 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@@ -5,6 +5,7 @@ use models_pagination::{Query, SimpleSortMethod};use models_soup::item::SoupItem;use sqlx::PgPool;use std::str::FromStr;+use system_properties::{StatusOption, SystemPropertyKey};use uuid::Uuid;/// Returns objects that a user has EXPLICIT access to, including project items.@@ -26,6 +27,9 @@ pub async fn unexpanded_generic_cursor_soup(let (cursor_id, cursor_timestamp) = cursor.vals();let cursor_id = cursor_id.map(|u| u.to_string());+ let status_property_id = SystemPropertyKey::STATUS_UUID;+ let completed_option_id = StatusOption::COMPLETED_UUID.to_string();+let items: Vec<SoupItem> = sqlx::query!(r#"WITH UserAccessibleItems AS (@@ -66,9 +70,22 @@ pub async fn unexpanded_generic_cursor_soup(WHEN 'viewed_at' THEN COALESCE(uh."updatedAt", '1970-01-01 00:00:00+00')WHEN 'created_at' THEN d."createdAt"ELSE d."updatedAt"- END::timestamptz as "sort_ts!"+ END::timestamptz as "sort_ts!",+ CASE+ WHEN dt.sub_type = 'task'+ AND ep_status.values->'value' ? $6+ THEN true+ WHEN dt.sub_type = 'task'+ THEN false+ ELSE NULL+ END as "is_completed"FROM "Document" dLEFT JOIN document_sub_type dt ON dt.document_id = d.id+ LEFT JOIN entity_properties ep_status+ ON dt.sub_type = 'task'+ AND ep_status.entity_id = d.id+ AND ep_status.entity_type = 'TASK'+ AND ep_status.property_definition_id = $7INNER JOIN UserAccessibleItems uaiON uai.item_id = d.idAND uai.item_type = 'document'@@ -116,7 +133,8 @@ pub async fn unexpanded_generic_cursor_soup(WHEN 'viewed_at' THEN COALESCE(uh."updatedAt", '1970-01-01 00:00:00+00')WHEN 'created_at' THEN c."createdAt"ELSE c."updatedAt"- END::timestamptz as "sort_ts!"+ END::timestamptz as "sort_ts!",+ NULL as "is_completed"FROM "Chat" cINNER JOIN UserAccessibleItems uaiON uai.item_id = c.id@@ -151,7 +169,8 @@ pub async fn unexpanded_generic_cursor_soup(WHEN 'viewed_at' THEN COALESCE(uh."updatedAt", '1970-01-01 00:00:00+00')WHEN 'created_at' THEN p."createdAt"ELSE p."updatedAt"- END::timestamptz as "sort_ts!"+ END::timestamptz as "sort_ts!",+ NULL as "is_completed"FROM "Project" pINNER JOIN UserAccessibleItems uaiON uai.item_id = p.id@@ -169,11 +188,13 @@ pub async fn unexpanded_generic_cursor_soup(ORDER BY "sort_ts!" DESC, "updated_at!" DESCLIMIT $3"#,- user_id.as_ref(), // $1- sort_method_str, // $2- query_limit, // $3- cursor_timestamp, // $4- cursor_id, // $5+ user_id.as_ref(), // $1+ sort_method_str, // $2+ query_limit, // $3+ cursor_timestamp, // $4+ cursor_id, // $5+ completed_option_id, // $6+ status_property_id, // $7).try_map(map_soup_type!()).fetch_all(db)@@ -200,6 +221,9 @@ pub async fn no_frecency_unexpanded_generic_cursor_soup(let sort_method_str = cursor.sort_method().to_string();let (cursor_id, cursor_timestamp) = cursor.vals();+ let status_property_id = SystemPropertyKey::STATUS_UUID;+ let completed_option_id = StatusOption::COMPLETED_UUID.to_string();+let items: Vec<SoupItem> = sqlx::query!(r#"WITH UserAccessibleItems AS (@@ -240,9 +264,22 @@ pub async fn no_frecency_unexpanded_generic_cursor_soup(WHEN 'viewed_at' THEN COALESCE(uh."updatedAt", '1970-01-01 00:00:00+00')WHEN 'created_at' THEN d."createdAt"ELSE d."updatedAt"- END::timestamptz as "sort_ts!"+ END::timestamptz as "sort_ts!",+ CASE+ WHEN dt.sub_type = 'task'+ AND ep_status.values->'value' ? $6+ THEN true+ WHEN dt.sub_type = 'task'+ THEN false+ ELSE NULL+ END as "is_completed"FROM "Document" dLEFT JOIN document_sub_type dt ON dt.document_id = d.id+ LEFT JOIN entity_properties ep_status+ ON dt.sub_type = 'task'+ AND ep_status.entity_id = d.id+ AND ep_status.entity_type = 'TASK'+ AND ep_status.property_definition_id = $7INNER JOIN UserAccessibleItems uaiON uai.item_id = d.idAND uai.item_type = 'document'@@ -258,7 +295,7 @@ pub async fn no_frecency_unexpanded_generic_cursor_soup(LIMIT 1) db ON trueLEFT JOIN LATERAL (- SELECT i.id, i.sha+ Select i.id, i.shaFROM "DocumentInstance" iWHERE i."documentId" = d.idORDER BY i."updatedAt" DESC@@ -290,7 +327,8 @@ pub async fn no_frecency_unexpanded_generic_cursor_soup(WHEN 'viewed_at' THEN COALESCE(uh."updatedAt", '1970-01-01 00:00:00+00')WHEN 'created_at' THEN c."createdAt"ELSE c."updatedAt"- END::timestamptz as "sort_ts!"+ END::timestamptz as "sort_ts!",+ NULL as "is_completed"FROM "Chat" cINNER JOIN UserAccessibleItems uaiON uai.item_id = c.id@@ -325,7 +363,8 @@ pub async fn no_frecency_unexpanded_generic_cursor_soup(WHEN 'viewed_at' THEN COALESCE(uh."updatedAt", '1970-01-01 00:00:00+00')WHEN 'created_at' THEN p."createdAt"ELSE p."updatedAt"- END::timestamptz as "sort_ts!"+ END::timestamptz as "sort_ts!",+ NULL as "is_completed"FROM "Project" pINNER JOIN UserAccessibleItems uaiON uai.item_id = p.id@@ -350,11 +389,13 @@ pub async fn no_frecency_unexpanded_generic_cursor_soup(ORDER BY Combined."sort_ts!" DESC, Combined."updated_at!" DESCLIMIT $3"#,- user_id.as_ref(), // $1- sort_method_str, // $2- query_limit, // $3- cursor_timestamp, // $4- cursor_id, // $5+ user_id.as_ref(), // $1+ sort_method_str, // $2+ query_limit, // $3+ cursor_timestamp, // $4+ cursor_id, // $5+ completed_option_id, // $6+ status_property_id, // $7).try_map(map_soup_type!()).fetch_all(db)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 b2a1b2154f..7668e2bec1 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@@ -5,6 +5,7 @@ use model_entity::{Entity, EntityType};use models_soup::item::SoupItem;use sqlx::PgPool;use std::str::FromStr;+use system_properties::{StatusOption, SystemPropertyKey};use uuid::Uuid;/// Returns objects that a user has EXPLICIT access to by their IDs, including project items.@@ -34,6 +35,9 @@ pub async fn unexpanded_soup_by_ids<'a>(return Ok(Vec::new());}+ let status_property_id = SystemPropertyKey::STATUS_UUID;+ let completed_option_id = StatusOption::COMPLETED_UUID.to_string();+let items: Vec<SoupItem> = sqlx::query!(r#"WITH UserAccessibleItems AS (@@ -69,9 +73,22 @@ pub async fn unexpanded_soup_by_ids<'a>(di.sha as "sha",dt.sub_type as "sub_type?: DocumentSubType",uh."updatedAt"::timestamptz as "viewed_at",- d."updatedAt"::timestamptz as "sort_ts!"+ d."updatedAt"::timestamptz as "sort_ts!",+ CASE+ WHEN dt.sub_type = 'task'+ AND ep_status.values->'value' ? $5+ THEN true+ WHEN dt.sub_type = 'task'+ THEN false+ ELSE NULL+ END as "is_completed"FROM "Document" dLEFT JOIN document_sub_type dt ON dt.document_id = d.id+ LEFT JOIN entity_properties ep_status+ ON dt.sub_type = 'task'+ AND ep_status.entity_id = d.id+ AND ep_status.entity_type = 'TASK'+ AND ep_status.property_definition_id = $6INNER JOIN UserAccessibleItems uaiON uai.item_id = d.idAND uai.item_type = 'document'@@ -115,7 +132,8 @@ pub async fn unexpanded_soup_by_ids<'a>(NULL as "sha",NULL as "sub_type",uh."updatedAt"::timestamptz as "viewed_at",- c."updatedAt"::timestamptz as "sort_ts!"+ c."updatedAt"::timestamptz as "sort_ts!",+ NULL as "is_completed"FROM "Chat" cINNER JOIN UserAccessibleItems uaiON uai.item_id = c.id@@ -146,7 +164,8 @@ pub async fn unexpanded_soup_by_ids<'a>(NULL as "sha",NULL as "sub_type",uh."updatedAt"::timestamptz as "viewed_at",- p."updatedAt"::timestamptz as "sort_ts!"+ p."updatedAt"::timestamptz as "sort_ts!",+ NULL as "is_completed"FROM "Project" pINNER JOIN UserAccessibleItems uaiON uai.item_id = p.id@@ -165,6 +184,8 @@ pub async fn unexpanded_soup_by_ids<'a>(document_ids.as_slice(), // $2chat_ids.as_slice(), // $3project_ids.as_slice(), // $4+ completed_option_id, // $5+ status_property_id, // $6).try_map(map_soup_type!()).fetch_all(db)diff --git a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/unexpanded/tests.rs b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/unexpanded/tests.rsindex 1b25e8b6ce..e064eb1173 100644--- a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/unexpanded/tests.rs+++ b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/unexpanded/tests.rs@@ -9,7 +9,7 @@ use models_pagination::Identify;use models_pagination::{PaginateOn, Query, SimpleSortMethod};use models_soup::item::SoupItem;use sqlx::{Pool, Postgres};-use std::collections::HashSet;+use std::collections::{HashMap, HashSet};use uuid::Uuid;// testing the sorting methods work as expected@@ -695,3 +695,69 @@ async fn test_no_frecency_unexpanded_cursor_pagination(pool: Pool<Postgres>) ->Ok(())}++// Test that is_completed field is correctly set based on task status+#[sqlx::test(+ migrator = "MACRO_DB_MIGRATIONS",+ fixtures(+ path = "../../../../../macro_db_client/fixtures",+ scripts("tasks_with_is_completed")+ )+)]+async fn test_is_completed_field(pool: Pool<Postgres>) -> anyhow::Result<()> {+ let user_id = MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap();++ let result = unexpanded_generic_cursor_soup(+ &pool,+ user_id,+ 10,+ Query::Sort(SimpleSortMethod::UpdatedAt, ()),+ )+ .await?;++ assert_eq!(result.len(), 4, "Should return 4 documents");++ // Create a map of document IDs to their is_completed values+ let mut is_completed_map: HashMap<Uuid, Option<bool>> = HashMap::new();++ for item in &result {+ if let SoupItem::Document(doc) = item {+ is_completed_map.insert(+ doc.id,+ doc.sub_type.as_ref().and_then(|st| st.is_task_completed()),+ );+ }+ }++ // Verify is_completed values+ let completed_task_id = Uuid::parse_str("11111111-1111-1111-1111-111111111111").unwrap();+ let incomplete_task_id = Uuid::parse_str("22222222-2222-2222-2222-222222222222").unwrap();+ let task_no_status_id = Uuid::parse_str("33333333-3333-3333-3333-333333333333").unwrap();+ let regular_doc_id = Uuid::parse_str("44444444-4444-4444-4444-444444444444").unwrap();++ assert_eq!(+ is_completed_map.get(&completed_task_id),+ Some(&Some(true)),+ "Completed task should have is_completed = true"+ );++ assert_eq!(+ is_completed_map.get(&incomplete_task_id),+ Some(&Some(false)),+ "Incomplete task should have is_completed = false"+ );++ assert_eq!(+ is_completed_map.get(&task_no_status_id),+ Some(&Some(false)),+ "Task without status should have is_completed = false"+ );++ assert_eq!(+ is_completed_map.get(®ular_doc_id),+ Some(&None),+ "Regular document should have is_completed = None"+ );++ Ok(())+}