Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(documents): ai cant see comments on tasks (#2796)

Will Hutchinsond9f6c3f1915c
diff --git a/js/app/packages/service-clients/service-cognition/generated/tools/schemas.ts b/js/app/packages/service-clients/service-cognition/generated/tools/schemas.ts
index 71b80fa42c..badebba6c0 100644
--- a/js/app/packages/service-clients/service-cognition/generated/tools/schemas.ts
+++ b/js/app/packages/service-clients/service-cognition/generated/tools/schemas.ts
@@ -497,37 +497,79 @@ export const NameSearch = z
export const ReadContent = z.object({ documentId: z.string().uuid() }).strict();
-export const ReadContentResponse = z.any().superRefine((x, ctx) => {
- const schemas = [
- z.object({ text: z.string() }).strict(),
- z
- .object({
- markdown: z.array(
- z.object({
- content: z.string(),
- nodeId: z.string(),
- rawContent: z.string(),
- type: z.string(),
- })
- ),
- })
- .strict(),
- ];
- const errors = schemas.reduce<z.ZodError[]>(
- (errors, schema) =>
- ((result) => (result.error ? [...errors, result.error] : errors))(
- schema.safeParse(x)
+export const ReadContentResponse = z.object({
+ comments: z.array(
+ z.object({
+ comments: z.array(
+ z.object({
+ commentId: z.number().int(),
+ createdAt: z
+ .union([z.string().datetime({ offset: true }), z.null()])
+ .optional(),
+ deletedAt: z
+ .union([z.string().datetime({ offset: true }), z.null()])
+ .optional(),
+ metadata: z.any().optional(),
+ order: z.union([z.number().int(), z.null()]).optional(),
+ owner: z.string(),
+ sender: z.union([z.string(), z.null()]).optional(),
+ text: z.string(),
+ threadId: z.number().int(),
+ updatedAt: z
+ .union([z.string().datetime({ offset: true }), z.null()])
+ .optional(),
+ })
),
- []
- );
- if (schemas.length - errors.length !== 1) {
- ctx.addIssue({
- path: ctx.path,
- code: 'invalid_union',
- unionErrors: errors,
- message: 'Invalid input: Should pass single schema',
- });
- }
+ thread: z.object({
+ createdAt: z
+ .union([z.string().datetime({ offset: true }), z.null()])
+ .optional(),
+ deletedAt: z
+ .union([z.string().datetime({ offset: true }), z.null()])
+ .optional(),
+ documentId: z.string(),
+ metadata: z.any().optional(),
+ owner: z.string(),
+ resolved: z.boolean(),
+ threadId: z.number().int(),
+ updatedAt: z
+ .union([z.string().datetime({ offset: true }), z.null()])
+ .optional(),
+ }),
+ })
+ ),
+ content: z.any().superRefine((x, ctx) => {
+ const schemas = [
+ z.object({ text: z.string() }).strict(),
+ z
+ .object({
+ markdown: z.array(
+ z.object({
+ content: z.string(),
+ nodeId: z.string(),
+ rawContent: z.string(),
+ type: z.string(),
+ })
+ ),
+ })
+ .strict(),
+ ];
+ const errors = schemas.reduce<z.ZodError[]>(
+ (errors, schema) =>
+ ((result) => (result.error ? [...errors, result.error] : errors))(
+ schema.safeParse(x)
+ ),
+ []
+ );
+ if (schemas.length - errors.length !== 1) {
+ ctx.addIssue({
+ path: ctx.path,
+ code: 'invalid_union',
+ unionErrors: errors,
+ message: 'Invalid input: Should pass single schema',
+ });
+ }
+ }),
});
export const ReadMetadata = z
diff --git a/js/app/packages/service-clients/service-cognition/generated/tools/types.ts b/js/app/packages/service-clients/service-cognition/generated/tools/types.ts
index 841649be44..632bc91164 100644
--- a/js/app/packages/service-clients/service-cognition/generated/tools/types.ts
+++ b/js/app/packages/service-clients/service-cognition/generated/tools/types.ts
@@ -939,33 +939,126 @@ export interface ReadContent {
* and run json-schema-to-typescript to regenerate this file.
*/
-/**
- * The read content response
- */
-export type ReadContentResponse =
- | {
+export interface ReadContentResponse {
+ /**
+ * Any comments on the document
+ */
+ comments: {
+ /**
+ * The comments in the thread, ordered by `createdAt` ASC.
+ */
+ comments: {
+ /**
+ * The unique id of the comment.
+ */
+ commentId: number;
+ /**
+ * When the comment was created.
+ */
+ createdAt?: string | null;
+ /**
+ * When the comment was deleted, if ever.
+ */
+ deletedAt?: string | null;
+ /**
+ * Arbitrary comment metadata.
+ */
+ metadata?: {
+ [k: string]: unknown;
+ };
+ /**
+ * Ordering position within the thread.
+ */
+ order?: number | null;
+ /**
+ * The user id of the comment owner.
+ */
+ owner: string;
+ /**
+ * Sender display string.
+ */
+ sender?: string | null;
+ /**
+ * Comment body.
+ */
text: string;
- }
- | {
- markdown: {
- /**
- * Human readable content
- */
- content: string;
- /**
- * The node id
- */
- nodeId: string;
- /**
- * Json respresentation
- */
- rawContent: string;
- /**
- * The style on the node, H1, em, code, etc.
- */
- type: string;
- }[];
+ /**
+ * The thread this comment belongs to.
+ */
+ threadId: number;
+ /**
+ * When the comment was last updated.
+ */
+ updatedAt?: string | null;
+ }[];
+ /**
+ * The thread metadata.
+ */
+ thread: {
+ /**
+ * When the thread was created.
+ */
+ createdAt?: string | null;
+ /**
+ * When the thread was deleted, if ever.
+ */
+ deletedAt?: string | null;
+ /**
+ * The document the thread is attached to.
+ */
+ documentId: string;
+ /**
+ * Arbitrary thread metadata.
+ */
+ metadata?: {
+ [k: string]: unknown;
+ };
+ /**
+ * The user id of the thread owner.
+ */
+ owner: string;
+ /**
+ * Whether the thread has been resolved.
+ */
+ resolved: boolean;
+ /**
+ * The unique id of the thread.
+ */
+ threadId: number;
+ /**
+ * When the thread was last updated.
+ */
+ updatedAt?: string | null;
};
+ }[];
+ /**
+ * The content of the document
+ */
+ content:
+ | {
+ text: string;
+ }
+ | {
+ markdown: {
+ /**
+ * Human readable content
+ */
+ content: string;
+ /**
+ * The node id
+ */
+ nodeId: string;
+ /**
+ * Json respresentation
+ */
+ rawContent: string;
+ /**
+ * The style on the node, H1, em, code, etc.
+ */
+ type: string;
+ }[];
+ };
+}
/* eslint-disable */
/**
diff --git a/rust/cloud-storage/documents/.sqlx/query-06a72bfcfbcc5f5bbed6cd093436309607f9375d2ba7b151e9dc1a8493f88e44.json b/rust/cloud-storage/documents/.sqlx/query-06a72bfcfbcc5f5bbed6cd093436309607f9375d2ba7b151e9dc1a8493f88e44.json
deleted file mode 100644
index 4c5afc274a..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-06a72bfcfbcc5f5bbed6cd093436309607f9375d2ba7b151e9dc1a8493f88e44.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n DELETE FROM notification_user_device_registration\n WHERE device_endpoint = $1\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Text"
- ]
- },
- "nullable": []
- },
- "hash": "06a72bfcfbcc5f5bbed6cd093436309607f9375d2ba7b151e9dc1a8493f88e44"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-0c0d2d2d944ff26d1b60d890ffb5becd7ce6250a3becf484a65ecfa99a0c0d2d.json b/rust/cloud-storage/documents/.sqlx/query-0c0d2d2d944ff26d1b60d890ffb5becd7ce6250a3becf484a65ecfa99a0c0d2d.json
deleted file mode 100644
index 99a3b6f452..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-0c0d2d2d944ff26d1b60d890ffb5becd7ce6250a3becf484a65ecfa99a0c0d2d.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT user_id FROM (\n -- Direct user grants\n SELECT source_id as user_id FROM entity_access\n WHERE entity_id = $1 AND entity_type = $2 AND source_type = 'user'\n\n UNION ALL\n\n -- Channel Members\n SELECT cp.user_id FROM comms_channel_participants cp\n WHERE cp.left_at IS NULL AND cp.channel_id IN (\n SELECT source_id::uuid FROM entity_access\n WHERE entity_id = $1 AND entity_type = $2 AND source_type = 'channel'\n )\n\n UNION ALL\n\n -- Team Members\n SELECT tu.user_id FROM team_user tu\n WHERE tu.team_id IN (\n SELECT source_id::uuid FROM entity_access\n WHERE entity_id = $1 AND entity_type = $2 AND source_type = 'team'\n )\n )\n \n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "user_id",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid",
- "Text"
- ]
- },
- "nullable": [
- null
- ]
- },
- "hash": "0c0d2d2d944ff26d1b60d890ffb5becd7ce6250a3becf484a65ecfa99a0c0d2d"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-1b7983a9a8a54322fd63d2bf169f27b45f853652a757123e3508017861b5c7c6.json b/rust/cloud-storage/documents/.sqlx/query-1b7983a9a8a54322fd63d2bf169f27b45f853652a757123e3508017861b5c7c6.json
deleted file mode 100644
index f97907a55c..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-1b7983a9a8a54322fd63d2bf169f27b45f853652a757123e3508017861b5c7c6.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT\n \"publicAccessLevel\" as \"access_level!\"\n FROM \"SharePermission\"\n WHERE \"isPublic\" = true\n AND \"publicAccessLevel\" IS NOT NULL\n AND id IN (\n SELECT \"sharePermissionId\" FROM \"ProjectPermission\" WHERE \"projectId\" = $1\n )\n\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "access_level!",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Text"
- ]
- },
- "nullable": [
- true
- ]
- },
- "hash": "1b7983a9a8a54322fd63d2bf169f27b45f853652a757123e3508017861b5c7c6"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-270cd8ae6b47508cb7e4e920bd76cb0f6177d685bddedb06f1892d0014af6f01.json b/rust/cloud-storage/documents/.sqlx/query-270cd8ae6b47508cb7e4e920bd76cb0f6177d685bddedb06f1892d0014af6f01.json
deleted file mode 100644
index 01cece9642..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-270cd8ae6b47508cb7e4e920bd76cb0f6177d685bddedb06f1892d0014af6f01.json
+++ /dev/null
@@ -1,33 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n DELETE FROM notification_user_device_registration\n WHERE device_token = $1 AND device_type = $2\n RETURNING device_endpoint\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "device_endpoint",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Text",
- {
- "Custom": {
- "name": "notification_device_type_option",
- "kind": {
- "Enum": [
- "ios",
- "android"
- ]
- }
- }
- }
- ]
- },
- "nullable": [
- false
- ]
- },
- "hash": "270cd8ae6b47508cb7e4e920bd76cb0f6177d685bddedb06f1892d0014af6f01"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-279926d74db34fd618a6b507e2ec60160ef8399af5cfa11393a2e1e8d9762d65.json b/rust/cloud-storage/documents/.sqlx/query-279926d74db34fd618a6b507e2ec60160ef8399af5cfa11393a2e1e8d9762d65.json
deleted file mode 100644
index 0216da5e97..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-279926d74db34fd618a6b507e2ec60160ef8399af5cfa11393a2e1e8d9762d65.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n DELETE FROM entity_access\n WHERE entity_id = ANY($1)\n AND granted_from_project_id = ANY($2)\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "UuidArray",
- "TextArray"
- ]
- },
- "nullable": []
- },
- "hash": "279926d74db34fd618a6b507e2ec60160ef8399af5cfa11393a2e1e8d9762d65"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-317f05707fdc73269f3017a3bb96d55b7327338bf5e52dfaad106b4b492cbb8e.json b/rust/cloud-storage/documents/.sqlx/query-317f05707fdc73269f3017a3bb96d55b7327338bf5e52dfaad106b4b492cbb8e.json
deleted file mode 100644
index b17b203167..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-317f05707fdc73269f3017a3bb96d55b7327338bf5e52dfaad106b4b492cbb8e.json
+++ /dev/null
@@ -1,98 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT\n un.user_id as owner_id,\n un.notification_id,\n n.event_item_id,\n n.event_item_type,\n un.sent,\n un.done,\n un.created_at::timestamptz as \"created_at!\",\n un.seen_at::timestamptz as viewed_at,\n un.created_at::timestamptz as \"updated_at!\",\n un.deleted_at::timestamptz,\n n.metadata as \"notification_metadata: serde_json::Value\",\n n.notification_event_type as notification_event_type,\n n.sender_id as sender_id\n FROM user_notification un\n JOIN notification n ON n.id = un.notification_id\n WHERE un.user_id = $1\n AND n.event_item_id = ANY($2)\n AND un.deleted_at IS NULL\n AND un.done = false\n AND (($4::timestamptz IS NULL)\n OR (un.created_at, un.notification_id) < ($4, $5))\n ORDER BY un.created_at DESC, un.notification_id DESC\n LIMIT $3\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "owner_id",
- "type_info": "Text"
- },
- {
- "ordinal": 1,
- "name": "notification_id",
- "type_info": "Uuid"
- },
- {
- "ordinal": 2,
- "name": "event_item_id",
- "type_info": "Text"
- },
- {
- "ordinal": 3,
- "name": "event_item_type",
- "type_info": "Text"
- },
- {
- "ordinal": 4,
- "name": "sent",
- "type_info": "Bool"
- },
- {
- "ordinal": 5,
- "name": "done",
- "type_info": "Bool"
- },
- {
- "ordinal": 6,
- "name": "created_at!",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 7,
- "name": "viewed_at",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 8,
- "name": "updated_at!",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 9,
- "name": "deleted_at",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 10,
- "name": "notification_metadata: serde_json::Value",
- "type_info": "Jsonb"
- },
- {
- "ordinal": 11,
- "name": "notification_event_type",
- "type_info": "Varchar"
- },
- {
- "ordinal": 12,
- "name": "sender_id",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Text",
- "TextArray",
- "Int8",
- "Timestamptz",
- "Uuid"
- ]
- },
- "nullable": [
- false,
- false,
- false,
- false,
- false,
- false,
- null,
- null,
- null,
- null,
- false,
- false,
- true
- ]
- },
- "hash": "317f05707fdc73269f3017a3bb96d55b7327338bf5e52dfaad106b4b492cbb8e"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-3293eab63193f1b3822a59e9a6a9621520f26e6ec8248abed103985281ef7ff1.json b/rust/cloud-storage/documents/.sqlx/query-3293eab63193f1b3822a59e9a6a9621520f26e6ec8248abed103985281ef7ff1.json
deleted file mode 100644
index e4a18ac5f0..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-3293eab63193f1b3822a59e9a6a9621520f26e6ec8248abed103985281ef7ff1.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n UPDATE user_notification\n SET done = $3\n WHERE user_id = $1 AND notification_id = ANY($2)\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Text",
- "UuidArray",
- "Bool"
- ]
- },
- "nullable": []
- },
- "hash": "3293eab63193f1b3822a59e9a6a9621520f26e6ec8248abed103985281ef7ff1"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-3357165799ff1f7bf1de3891174668e0ab16c64bd9dfc905213681e6021474fa.json b/rust/cloud-storage/documents/.sqlx/query-3357165799ff1f7bf1de3891174668e0ab16c64bd9dfc905213681e6021474fa.json
deleted file mode 100644
index 6696253445..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-3357165799ff1f7bf1de3891174668e0ab16c64bd9dfc905213681e6021474fa.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT EXISTS(\n SELECT 1 FROM notification_message_receipt\n WHERE user_id = $1\n AND notification_id = $2\n AND failed = false\n ) as \"exists!\"\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "exists!",
- "type_info": "Bool"
- }
- ],
- "parameters": {
- "Left": [
- "Text",
- "Uuid"
- ]
- },
- "nullable": [
- null
- ]
- },
- "hash": "3357165799ff1f7bf1de3891174668e0ab16c64bd9dfc905213681e6021474fa"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-36dfcf982834f117d97d1ba332be6784c946f05120c7c228ff258389ceba97a1.json b/rust/cloud-storage/documents/.sqlx/query-36dfcf982834f117d97d1ba332be6784c946f05120c7c228ff258389ceba97a1.json
deleted file mode 100644
index c07ec0acbe..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-36dfcf982834f117d97d1ba332be6784c946f05120c7c228ff258389ceba97a1.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n INSERT INTO user_notification_type_preference (user_id, notification_event_type)\n VALUES ($1, $2)\n ON CONFLICT (user_id, notification_event_type) DO NOTHING\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Text",
- "Varchar"
- ]
- },
- "nullable": []
- },
- "hash": "36dfcf982834f117d97d1ba332be6784c946f05120c7c228ff258389ceba97a1"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-377f7c130cc3d834870fa692f5ba36d070bce17512b9ab348d0cb40ebe4d1b08.json b/rust/cloud-storage/documents/.sqlx/query-377f7c130cc3d834870fa692f5ba36d070bce17512b9ab348d0cb40ebe4d1b08.json
deleted file mode 100644
index 9348d25315..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-377f7c130cc3d834870fa692f5ba36d070bce17512b9ab348d0cb40ebe4d1b08.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT\n \"publicAccessLevel\" as \"access_level!\"\n FROM \"SharePermission\"\n WHERE \"isPublic\" = true\n AND \"publicAccessLevel\" IS NOT NULL\n AND id IN (\n SELECT \"sharePermissionId\" FROM \"DocumentPermission\" WHERE \"documentId\" = $1\n )\n \n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "access_level!",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Text"
- ]
- },
- "nullable": [
- true
- ]
- },
- "hash": "377f7c130cc3d834870fa692f5ba36d070bce17512b9ab348d0cb40ebe4d1b08"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-37b5168f739c490a3373c65eab35f247a34af0a8e659cbad61cb99e3094e5a60.json b/rust/cloud-storage/documents/.sqlx/query-37b5168f739c490a3373c65eab35f247a34af0a8e659cbad61cb99e3094e5a60.json
deleted file mode 100644
index 44d3a67e72..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-37b5168f739c490a3373c65eab35f247a34af0a8e659cbad61cb99e3094e5a60.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT EXISTS (\n SELECT 1\n FROM public.email_threads t\n JOIN public.email_links l ON l.id = t.link_id\n WHERE t.id = $1::uuid\n AND l.macro_id = $2\n ) AS \"exists!\"\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "exists!",
- "type_info": "Bool"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid",
- "Text"
- ]
- },
- "nullable": [
- null
- ]
- },
- "hash": "37b5168f739c490a3373c65eab35f247a34af0a8e659cbad61cb99e3094e5a60"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-41de07226ced9b95c7419c9e6d5d9bd9c5890cf1c144f0f8905664cd72c7f132.json b/rust/cloud-storage/documents/.sqlx/query-41de07226ced9b95c7419c9e6d5d9bd9c5890cf1c144f0f8905664cd72c7f132.json
deleted file mode 100644
index b75a3a2ff5..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-41de07226ced9b95c7419c9e6d5d9bd9c5890cf1c144f0f8905664cd72c7f132.json
+++ /dev/null
@@ -1,41 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n INSERT INTO entity_access (entity_id, entity_type, source_id, source_type, access_level)\n VALUES ($1, $2, $3, $4, $5)\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Uuid",
- "Text",
- "Text",
- {
- "Custom": {
- "name": "entity_access_source_type",
- "kind": {
- "Enum": [
- "channel",
- "team",
- "user"
- ]
- }
- }
- },
- {
- "Custom": {
- "name": "\"AccessLevel\"",
- "kind": {
- "Enum": [
- "view",
- "comment",
- "edit",
- "owner"
- ]
- }
- }
- }
- ]
- },
- "nullable": []
- },
- "hash": "41de07226ced9b95c7419c9e6d5d9bd9c5890cf1c144f0f8905664cd72c7f132"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-46ffaa1a906d49a47c765c9c03d89e50037adc4b72c364bdb4282ab0c8cf1237.json b/rust/cloud-storage/documents/.sqlx/query-46ffaa1a906d49a47c765c9c03d89e50037adc4b72c364bdb4282ab0c8cf1237.json
deleted file mode 100644
index c91a76ff52..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-46ffaa1a906d49a47c765c9c03d89e50037adc4b72c364bdb4282ab0c8cf1237.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n DELETE FROM entity_access\n WHERE entity_id = $1 AND entity_type = $2\n AND source_id = ANY($3) AND source_type = 'channel'\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Uuid",
- "Text",
- "TextArray"
- ]
- },
- "nullable": []
- },
- "hash": "46ffaa1a906d49a47c765c9c03d89e50037adc4b72c364bdb4282ab0c8cf1237"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-48697f17a7121986cc770d6698fbca7bf107ae20dbadbf64a7799ab162b2feb4.json b/rust/cloud-storage/documents/.sqlx/query-48697f17a7121986cc770d6698fbca7bf107ae20dbadbf64a7799ab162b2feb4.json
deleted file mode 100644
index 3fdea7e232..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-48697f17a7121986cc770d6698fbca7bf107ae20dbadbf64a7799ab162b2feb4.json
+++ /dev/null
@@ -1,95 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT\n un.user_id as owner_id,\n un.notification_id,\n n.event_item_id,\n n.event_item_type,\n un.sent,\n un.done,\n un.created_at::timestamptz as \"created_at!\",\n un.seen_at::timestamptz as viewed_at,\n un.created_at::timestamptz as \"updated_at!\",\n un.deleted_at::timestamptz,\n n.metadata as \"notification_metadata: serde_json::Value\",\n n.notification_event_type as notification_event_type,\n n.sender_id as sender_id\n FROM user_notification un\n JOIN notification n ON n.id = un.notification_id\n WHERE un.user_id = $1\n AND un.notification_id = $2\n AND un.deleted_at IS NULL\n LIMIT 1\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "owner_id",
- "type_info": "Text"
- },
- {
- "ordinal": 1,
- "name": "notification_id",
- "type_info": "Uuid"
- },
- {
- "ordinal": 2,
- "name": "event_item_id",
- "type_info": "Text"
- },
- {
- "ordinal": 3,
- "name": "event_item_type",
- "type_info": "Text"
- },
- {
- "ordinal": 4,
- "name": "sent",
- "type_info": "Bool"
- },
- {
- "ordinal": 5,
- "name": "done",
- "type_info": "Bool"
- },
- {
- "ordinal": 6,
- "name": "created_at!",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 7,
- "name": "viewed_at",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 8,
- "name": "updated_at!",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 9,
- "name": "deleted_at",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 10,
- "name": "notification_metadata: serde_json::Value",
- "type_info": "Jsonb"
- },
- {
- "ordinal": 11,
- "name": "notification_event_type",
- "type_info": "Varchar"
- },
- {
- "ordinal": 12,
- "name": "sender_id",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Text",
- "Uuid"
- ]
- },
- "nullable": [
- false,
- false,
- false,
- false,
- false,
- false,
- null,
- null,
- null,
- null,
- false,
- false,
- true
- ]
- },
- "hash": "48697f17a7121986cc770d6698fbca7bf107ae20dbadbf64a7799ab162b2feb4"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-4e096eb7d3c507e3647685073fba7b3f36ef0e70c887db31f5cc5a8eb8ee1844.json b/rust/cloud-storage/documents/.sqlx/query-4e096eb7d3c507e3647685073fba7b3f36ef0e70c887db31f5cc5a8eb8ee1844.json
deleted file mode 100644
index 55fcda1121..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-4e096eb7d3c507e3647685073fba7b3f36ef0e70c887db31f5cc5a8eb8ee1844.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n DELETE FROM user_notification\n WHERE user_id = $1\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Text"
- ]
- },
- "nullable": []
- },
- "hash": "4e096eb7d3c507e3647685073fba7b3f36ef0e70c887db31f5cc5a8eb8ee1844"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-5915728325fe5163ae5f18a99350e0cb5153d368eceb75d03b4cf1adfd1f58bf.json b/rust/cloud-storage/documents/.sqlx/query-5915728325fe5163ae5f18a99350e0cb5153d368eceb75d03b4cf1adfd1f58bf.json
deleted file mode 100644
index 514e8d9770..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-5915728325fe5163ae5f18a99350e0cb5153d368eceb75d03b4cf1adfd1f58bf.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT\n \"publicAccessLevel\" as \"access_level!\"\n FROM \"SharePermission\"\n WHERE \"isPublic\" = true\n AND \"publicAccessLevel\" IS NOT NULL\n AND id IN (\n SELECT \"sharePermissionId\" FROM \"ChatPermission\" WHERE \"chatId\" = $1\n )\n\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "access_level!",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Text"
- ]
- },
- "nullable": [
- true
- ]
- },
- "hash": "5915728325fe5163ae5f18a99350e0cb5153d368eceb75d03b4cf1adfd1f58bf"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-5b17a30f841372cce9989af409baf993e24bfe90d3a3553f6851b3e92c8540eb.json b/rust/cloud-storage/documents/.sqlx/query-5b17a30f841372cce9989af409baf993e24bfe90d3a3553f6851b3e92c8540eb.json
deleted file mode 100644
index 113b9e269a..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-5b17a30f841372cce9989af409baf993e24bfe90d3a3553f6851b3e92c8540eb.json
+++ /dev/null
@@ -1,63 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT\n entity_id,\n source_id,\n source_type as \"source_type:EntityAccessSourceType\",\n access_level as \"access_level:AccessLevel\"\n FROM entity_access\n WHERE entity_id = ANY($1) AND entity_type = 'project' AND granted_from_project_id IS NULL\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "entity_id",
- "type_info": "Uuid"
- },
- {
- "ordinal": 1,
- "name": "source_id",
- "type_info": "Text"
- },
- {
- "ordinal": 2,
- "name": "source_type:EntityAccessSourceType",
- "type_info": {
- "Custom": {
- "name": "entity_access_source_type",
- "kind": {
- "Enum": [
- "channel",
- "team",
- "user"
- ]
- }
- }
- }
- },
- {
- "ordinal": 3,
- "name": "access_level:AccessLevel",
- "type_info": {
- "Custom": {
- "name": "\"AccessLevel\"",
- "kind": {
- "Enum": [
- "view",
- "comment",
- "edit",
- "owner"
- ]
- }
- }
- }
- }
- ],
- "parameters": {
- "Left": [
- "UuidArray"
- ]
- },
- "nullable": [
- false,
- false,
- false,
- false
- ]
- },
- "hash": "5b17a30f841372cce9989af409baf993e24bfe90d3a3553f6851b3e92c8540eb"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-5ffee439386fd24fee2bfa20caa76b882f5be1d44a2a06a71783418fc5ef381b.json b/rust/cloud-storage/documents/.sqlx/query-5ffee439386fd24fee2bfa20caa76b882f5be1d44a2a06a71783418fc5ef381b.json
deleted file mode 100644
index ac050656e7..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-5ffee439386fd24fee2bfa20caa76b882f5be1d44a2a06a71783418fc5ef381b.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n INSERT INTO entity_access (entity_id, entity_type, source_id, source_type, access_level)\n SELECT $1, $2, u.user_id, 'user', $3\n FROM UNNEST($4::text[]) as u(user_id)\n ON CONFLICT (entity_id, entity_type, source_id, source_type)\n WHERE granted_from_project_id IS NULL\n AND access_level != 'owner' -- this prevents us from overriding the owner user\n DO UPDATE SET access_level = EXCLUDED.access_level, updated_at = NOW()\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Uuid",
- "Text",
- {
- "Custom": {
- "name": "\"AccessLevel\"",
- "kind": {
- "Enum": [
- "view",
- "comment",
- "edit",
- "owner"
- ]
- }
- }
- },
- "TextArray"
- ]
- },
- "nullable": []
- },
- "hash": "5ffee439386fd24fee2bfa20caa76b882f5be1d44a2a06a71783418fc5ef381b"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-621186dcec072b603a5f3d7b9e987a1638589d539c60d9dc5c2ab0865ff062d6.json b/rust/cloud-storage/documents/.sqlx/query-621186dcec072b603a5f3d7b9e987a1638589d539c60d9dc5c2ab0865ff062d6.json
deleted file mode 100644
index d0a749ebd2..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-621186dcec072b603a5f3d7b9e987a1638589d539c60d9dc5c2ab0865ff062d6.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT user_id FROM user_mute_notification\n WHERE user_id = ANY($1)\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "user_id",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "TextArray"
- ]
- },
- "nullable": [
- false
- ]
- },
- "hash": "621186dcec072b603a5f3d7b9e987a1638589d539c60d9dc5c2ab0865ff062d6"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-625ee33d48768e369ee1fe3abe27811ad04313b1aa31f4b51abe5fd3bf569674.json b/rust/cloud-storage/documents/.sqlx/query-625ee33d48768e369ee1fe3abe27811ad04313b1aa31f4b51abe5fd3bf569674.json
deleted file mode 100644
index d374c2f79f..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-625ee33d48768e369ee1fe3abe27811ad04313b1aa31f4b51abe5fd3bf569674.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n DELETE FROM user_notification_type_preference\n WHERE user_id = $1 AND notification_event_type = $2\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Text",
- "Text"
- ]
- },
- "nullable": []
- },
- "hash": "625ee33d48768e369ee1fe3abe27811ad04313b1aa31f4b51abe5fd3bf569674"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-63ca13cc79c27b5267ebbf53491b657ca7671e1ab9d1a4691372693a9f9a4ff8.json b/rust/cloud-storage/documents/.sqlx/query-63ca13cc79c27b5267ebbf53491b657ca7671e1ab9d1a4691372693a9f9a4ff8.json
deleted file mode 100644
index a110bb67c6..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-63ca13cc79c27b5267ebbf53491b657ca7671e1ab9d1a4691372693a9f9a4ff8.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT DISTINCT cp.user_id\n FROM comms_channel_participants cp\n WHERE cp.channel_id = $1 AND cp.left_at IS NULL\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "user_id",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid"
- ]
- },
- "nullable": [
- false
- ]
- },
- "hash": "63ca13cc79c27b5267ebbf53491b657ca7671e1ab9d1a4691372693a9f9a4ff8"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-6ff2b4ae4df25f6fe125338e274f4149fe8829da208e8689ccd7e2154e8d7136.json b/rust/cloud-storage/documents/.sqlx/query-6ff2b4ae4df25f6fe125338e274f4149fe8829da208e8689ccd7e2154e8d7136.json
new file mode 100644
index 0000000000..8d0fb607f9
--- /dev/null
+++ b/rust/cloud-storage/documents/.sqlx/query-6ff2b4ae4df25f6fe125338e274f4149fe8829da208e8689ccd7e2154e8d7136.json
@@ -0,0 +1,76 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT\n c.id as \"comment_id!\",\n c.\"threadId\" as \"thread_id!\",\n c.owner as \"owner!\",\n c.sender,\n c.text as \"text!\",\n c.metadata,\n c.\"createdAt\"::timestamptz as \"created_at\",\n c.\"updatedAt\"::timestamptz as \"updated_at\",\n c.\"deletedAt\"::timestamptz as \"deleted_at\",\n c.order\n FROM \"Comment\" c\n JOIN \"Thread\" t ON c.\"threadId\" = t.id\n WHERE t.\"documentId\" = $1\n AND t.\"deletedAt\" IS NULL\n AND c.\"deletedAt\" IS NULL\n ORDER BY c.\"createdAt\" ASC\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "comment_id!",
+ "type_info": "Int8"
+ },
+ {
+ "ordinal": 1,
+ "name": "thread_id!",
+ "type_info": "Int8"
+ },
+ {
+ "ordinal": 2,
+ "name": "owner!",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 3,
+ "name": "sender",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 4,
+ "name": "text!",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 5,
+ "name": "metadata",
+ "type_info": "Jsonb"
+ },
+ {
+ "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": "order",
+ "type_info": "Int4"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Text"
+ ]
+ },
+ "nullable": [
+ false,
+ false,
+ false,
+ true,
+ false,
+ true,
+ null,
+ null,
+ null,
+ true
+ ]
+ },
+ "hash": "6ff2b4ae4df25f6fe125338e274f4149fe8829da208e8689ccd7e2154e8d7136"
+}
diff --git a/rust/cloud-storage/documents/.sqlx/query-7078d46dbcbe1c4201bcb4f63d98400d28bde0e2c3af5211a83a01165f751029.json b/rust/cloud-storage/documents/.sqlx/query-7078d46dbcbe1c4201bcb4f63d98400d28bde0e2c3af5211a83a01165f751029.json
deleted file mode 100644
index b7e5230b4c..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-7078d46dbcbe1c4201bcb4f63d98400d28bde0e2c3af5211a83a01165f751029.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n DELETE FROM entity_access\n WHERE (source_id = ANY($1) AND source_type = 'channel')\n AND (entity_id = ANY($2) OR granted_from_project_id = ANY($3))\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "TextArray",
- "UuidArray",
- "TextArray"
- ]
- },
- "nullable": []
- },
- "hash": "7078d46dbcbe1c4201bcb4f63d98400d28bde0e2c3af5211a83a01165f751029"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-73c67fbf678e1479d528adcc5bea7da3261d0a04e24cc16f96ec9f2dea3b2e98.json b/rust/cloud-storage/documents/.sqlx/query-73c67fbf678e1479d528adcc5bea7da3261d0a04e24cc16f96ec9f2dea3b2e98.json
deleted file mode 100644
index 65459bcefd..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-73c67fbf678e1479d528adcc5bea7da3261d0a04e24cc16f96ec9f2dea3b2e98.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT id\n FROM \"User\"\n WHERE email = $1\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "id",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Text"
- ]
- },
- "nullable": [
- false
- ]
- },
- "hash": "73c67fbf678e1479d528adcc5bea7da3261d0a04e24cc16f96ec9f2dea3b2e98"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-74d33764e454fb9ab4f2775974462d6fdb092bffc720d929de5e7b50ecef5139.json b/rust/cloud-storage/documents/.sqlx/query-74d33764e454fb9ab4f2775974462d6fdb092bffc720d929de5e7b50ecef5139.json
deleted file mode 100644
index 34382e8725..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-74d33764e454fb9ab4f2775974462d6fdb092bffc720d929de5e7b50ecef5139.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT id, apns_collapse_key as \"apns_collapse_key!: String\"\n FROM notification\n WHERE id = ANY($1) AND apns_collapse_key IS NOT NULL\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "id",
- "type_info": "Uuid"
- },
- {
- "ordinal": 1,
- "name": "apns_collapse_key!: String",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "UuidArray"
- ]
- },
- "nullable": [
- false,
- true
- ]
- },
- "hash": "74d33764e454fb9ab4f2775974462d6fdb092bffc720d929de5e7b50ecef5139"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-7617f808df94ffe77c8195a911ee6b230a21fe9935e099d1310d244248ca253a.json b/rust/cloud-storage/documents/.sqlx/query-7617f808df94ffe77c8195a911ee6b230a21fe9935e099d1310d244248ca253a.json
deleted file mode 100644
index 655495fb29..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-7617f808df94ffe77c8195a911ee6b230a21fe9935e099d1310d244248ca253a.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT c.id\n FROM comms_channels c\n INNER JOIN comms_channel_participants cp ON cp.channel_id = c.id\n WHERE cp.user_id = $1 AND cp.left_at IS NULL\n AND c.id = ANY($2::uuid[])\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "id",
- "type_info": "Uuid"
- }
- ],
- "parameters": {
- "Left": [
- "Text",
- "UuidArray"
- ]
- },
- "nullable": [
- false
- ]
- },
- "hash": "7617f808df94ffe77c8195a911ee6b230a21fe9935e099d1310d244248ca253a"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-765650cab2b1a1d1abe6ca406438bf48968cebebc7316b87b192d649e096cd67.json b/rust/cloud-storage/documents/.sqlx/query-765650cab2b1a1d1abe6ca406438bf48968cebebc7316b87b192d649e096cd67.json
deleted file mode 100644
index a8e7326c35..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-765650cab2b1a1d1abe6ca406438bf48968cebebc7316b87b192d649e096cd67.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT user_id FROM user_notification_item_unsubscribe\n WHERE item_id = $1 AND user_id = ANY($2)\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "user_id",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Text",
- "TextArray"
- ]
- },
- "nullable": [
- false
- ]
- },
- "hash": "765650cab2b1a1d1abe6ca406438bf48968cebebc7316b87b192d649e096cd67"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-78f1cf9da464937604c1a2d5115c014cab9de72bd88605ff47a316baa2c7acc2.json b/rust/cloud-storage/documents/.sqlx/query-78f1cf9da464937604c1a2d5115c014cab9de72bd88605ff47a316baa2c7acc2.json
deleted file mode 100644
index 9e6f7f8877..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-78f1cf9da464937604c1a2d5115c014cab9de72bd88605ff47a316baa2c7acc2.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT d.device_endpoint\n FROM notification_user_device_registration d\n WHERE d.device_token = $1\n LIMIT 1\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "device_endpoint",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Text"
- ]
- },
- "nullable": [
- false
- ]
- },
- "hash": "78f1cf9da464937604c1a2d5115c014cab9de72bd88605ff47a316baa2c7acc2"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-7c0b9d645a85e30577377e4d8c8a8f976e86c6251e12517a2b1e14d525e09198.json b/rust/cloud-storage/documents/.sqlx/query-7c0b9d645a85e30577377e4d8c8a8f976e86c6251e12517a2b1e14d525e09198.json
deleted file mode 100644
index 721b0038f2..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-7c0b9d645a85e30577377e4d8c8a8f976e86c6251e12517a2b1e14d525e09198.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT user_id, notification_event_type\n FROM user_notification_type_preference\n WHERE user_id = $1\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "user_id",
- "type_info": "Text"
- },
- {
- "ordinal": 1,
- "name": "notification_event_type",
- "type_info": "Varchar"
- }
- ],
- "parameters": {
- "Left": [
- "Text"
- ]
- },
- "nullable": [
- false,
- false
- ]
- },
- "hash": "7c0b9d645a85e30577377e4d8c8a8f976e86c6251e12517a2b1e14d525e09198"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-7ccdaab5873129437c98581ac37eb4148255b83e18fad15349d06c54040fd6cc.json b/rust/cloud-storage/documents/.sqlx/query-7ccdaab5873129437c98581ac37eb4148255b83e18fad15349d06c54040fd6cc.json
deleted file mode 100644
index a166680895..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-7ccdaab5873129437c98581ac37eb4148255b83e18fad15349d06c54040fd6cc.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n INSERT INTO notification (id, notification_event_type, event_item_id, event_item_type, service_sender, metadata, sender_id, apns_collapse_key)\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8)\n ON CONFLICT (id) DO NOTHING\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Uuid",
- "Varchar",
- "Text",
- "Text",
- "Text",
- "Jsonb",
- "Text",
- "Text"
- ]
- },
- "nullable": []
- },
- "hash": "7ccdaab5873129437c98581ac37eb4148255b83e18fad15349d06c54040fd6cc"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-86eee52e30e4168f4a7f319d1dcaa59144a5b3269120df892f161c74b5fe7436.json b/rust/cloud-storage/documents/.sqlx/query-86eee52e30e4168f4a7f319d1dcaa59144a5b3269120df892f161c74b5fe7436.json
deleted file mode 100644
index eab49b91f7..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-86eee52e30e4168f4a7f319d1dcaa59144a5b3269120df892f161c74b5fe7436.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n UPDATE user_notification\n SET sent = true\n WHERE notification_id = $1 AND user_id = ANY($2)\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Uuid",
- "TextArray"
- ]
- },
- "nullable": []
- },
- "hash": "86eee52e30e4168f4a7f319d1dcaa59144a5b3269120df892f161c74b5fe7436"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-92edc80110af7b96f7f908989461a4abb11652671a95454969369a0484ed9239.json b/rust/cloud-storage/documents/.sqlx/query-92edc80110af7b96f7f908989461a4abb11652671a95454969369a0484ed9239.json
deleted file mode 100644
index a8520fdfd0..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-92edc80110af7b96f7f908989461a4abb11652671a95454969369a0484ed9239.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n INSERT INTO notification_message_receipt (message_id, user_id, notification_id)\n VALUES ($1, $2, $3)\n ON CONFLICT (message_id) DO NOTHING\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Text",
- "Text",
- "Uuid"
- ]
- },
- "nullable": []
- },
- "hash": "92edc80110af7b96f7f908989461a4abb11652671a95454969369a0484ed9239"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-94c019227741f6c4fe8411454cb7c0a3a97e5594c29f11fa893238656e161ff1.json b/rust/cloud-storage/documents/.sqlx/query-94c019227741f6c4fe8411454cb7c0a3a97e5594c29f11fa893238656e161ff1.json
deleted file mode 100644
index 4035617965..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-94c019227741f6c4fe8411454cb7c0a3a97e5594c29f11fa893238656e161ff1.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n UPDATE user_notification\n SET deleted_at = NOW()\n WHERE user_id = $1 AND notification_id = $2\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Text",
- "Uuid"
- ]
- },
- "nullable": []
- },
- "hash": "94c019227741f6c4fe8411454cb7c0a3a97e5594c29f11fa893238656e161ff1"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-a0046a263c572915a8e14a8ac70479f1ba89549f1930f571bf278fcfe259cfd1.json b/rust/cloud-storage/documents/.sqlx/query-a0046a263c572915a8e14a8ac70479f1ba89549f1930f571bf278fcfe259cfd1.json
deleted file mode 100644
index ad14cfedba..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-a0046a263c572915a8e14a8ac70479f1ba89549f1930f571bf278fcfe259cfd1.json
+++ /dev/null
@@ -1,44 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT user_id, device_endpoint, device_type as \"device_type: DbDeviceType\"\n FROM notification_user_device_registration\n WHERE user_id = ANY($1)\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "user_id",
- "type_info": "Text"
- },
- {
- "ordinal": 1,
- "name": "device_endpoint",
- "type_info": "Text"
- },
- {
- "ordinal": 2,
- "name": "device_type: DbDeviceType",
- "type_info": {
- "Custom": {
- "name": "notification_device_type_option",
- "kind": {
- "Enum": [
- "ios",
- "android"
- ]
- }
- }
- }
- }
- ],
- "parameters": {
- "Left": [
- "TextArray"
- ]
- },
- "nullable": [
- false,
- false,
- false
- ]
- },
- "hash": "a0046a263c572915a8e14a8ac70479f1ba89549f1930f571bf278fcfe259cfd1"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-a5d9f358b5382c0eaed918f903bc6aa328f527e6e47d649c37dfcf1c9f3a7139.json b/rust/cloud-storage/documents/.sqlx/query-a5d9f358b5382c0eaed918f903bc6aa328f527e6e47d649c37dfcf1c9f3a7139.json
deleted file mode 100644
index 7626c0a06b..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-a5d9f358b5382c0eaed918f903bc6aa328f527e6e47d649c37dfcf1c9f3a7139.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n UPDATE user_notification\n SET seen_at = NOW()\n WHERE user_id = $1 AND notification_id = ANY($2)\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Text",
- "UuidArray"
- ]
- },
- "nullable": []
- },
- "hash": "a5d9f358b5382c0eaed918f903bc6aa328f527e6e47d649c37dfcf1c9f3a7139"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-a94e5ac730ba6bdb11e9b27b11babb1552e787c0920e1102882acc4381245f24.json b/rust/cloud-storage/documents/.sqlx/query-a94e5ac730ba6bdb11e9b27b11babb1552e787c0920e1102882acc4381245f24.json
deleted file mode 100644
index f214362a1f..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-a94e5ac730ba6bdb11e9b27b11babb1552e787c0920e1102882acc4381245f24.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT access_level FROM (\n -- Source 1: entity_access source_id match\n SELECT\n access_level::text FROM entity_access\n WHERE entity_id = $1\n AND entity_type = 'call'\n AND source_id = ANY($2)\n\n UNION ALL\n -- Source 2: items share permission\n SELECT\n \"publicAccessLevel\" as \"access_level!\"\n FROM \"SharePermission\"\n WHERE id in (\n SELECT share_permission_id\n FROM calls\n WHERE id = $1\n UNION ALL\n SELECT share_permission_id\n FROM call_records\n WHERE id = $1\n LIMIT 1\n )\n AND \"isPublic\" = true\n AND \"publicAccessLevel\" IS NOT NULL\n )\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "access_level",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid",
- "TextArray"
- ]
- },
- "nullable": [
- null
- ]
- },
- "hash": "a94e5ac730ba6bdb11e9b27b11babb1552e787c0920e1102882acc4381245f24"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-ac30668bed9f5d19db9e0a0cacda6ee156a13fae34c5ccb129794c9d16e95e10.json b/rust/cloud-storage/documents/.sqlx/query-ac30668bed9f5d19db9e0a0cacda6ee156a13fae34c5ccb129794c9d16e95e10.json
deleted file mode 100644
index b0fb258d2d..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-ac30668bed9f5d19db9e0a0cacda6ee156a13fae34c5ccb129794c9d16e95e10.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT l.macro_id\n FROM email_threads et\n JOIN email_links l ON et.link_id = l.id\n WHERE et.id = $1\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "macro_id",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid"
- ]
- },
- "nullable": [
- false
- ]
- },
- "hash": "ac30668bed9f5d19db9e0a0cacda6ee156a13fae34c5ccb129794c9d16e95e10"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-b1ca353c3b2a80e3dadf3415cc79d4a08684a7a76ecaf47edfc5bedf5a0e1815.json b/rust/cloud-storage/documents/.sqlx/query-b1ca353c3b2a80e3dadf3415cc79d4a08684a7a76ecaf47edfc5bedf5a0e1815.json
deleted file mode 100644
index aa74e2b98b..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-b1ca353c3b2a80e3dadf3415cc79d4a08684a7a76ecaf47edfc5bedf5a0e1815.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT access_level FROM (\n -- Source 1: entity_access source_id match\n SELECT\n access_level::text FROM entity_access\n WHERE entity_id = $1\n AND entity_type = 'email_thread'\n AND source_id = ANY($2)\n\n UNION ALL\n -- Source 2: items share permission\n SELECT\n \"publicAccessLevel\" as \"access_level!\"\n FROM \"SharePermission\"\n WHERE \"isPublic\" = true\n AND \"publicAccessLevel\" IS NOT NULL\n AND id IN (\n SELECT \"sharePermissionId\" FROM \"EmailThreadPermission\" WHERE \"threadId\" = $3\n )\n )\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "access_level",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid",
- "TextArray",
- "Text"
- ]
- },
- "nullable": [
- null
- ]
- },
- "hash": "b1ca353c3b2a80e3dadf3415cc79d4a08684a7a76ecaf47edfc5bedf5a0e1815"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-b3f9f3696438bd2ad8754650d87d7bbf32e70d3d173a748a07eacdb4e42841eb.json b/rust/cloud-storage/documents/.sqlx/query-b3f9f3696438bd2ad8754650d87d7bbf32e70d3d173a748a07eacdb4e42841eb.json
deleted file mode 100644
index e5d913399d..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-b3f9f3696438bd2ad8754650d87d7bbf32e70d3d173a748a07eacdb4e42841eb.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n INSERT INTO notification_user_device_registration (id, user_id, device_token, device_endpoint, device_type)\n VALUES ($1, $2, $3, $4, $5)\n ON CONFLICT (device_endpoint) DO UPDATE SET user_id = $2, device_token = $3, device_type = $5, updated_at = NOW()\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Uuid",
- "Text",
- "Text",
- "Text",
- {
- "Custom": {
- "name": "notification_device_type_option",
- "kind": {
- "Enum": [
- "ios",
- "android"
- ]
- }
- }
- }
- ]
- },
- "nullable": []
- },
- "hash": "b3f9f3696438bd2ad8754650d87d7bbf32e70d3d173a748a07eacdb4e42841eb"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-b56786cafd46e138a172ca008f6586c551794b50c95616b56b7c94ac7c2d4524.json b/rust/cloud-storage/documents/.sqlx/query-b56786cafd46e138a172ca008f6586c551794b50c95616b56b7c94ac7c2d4524.json
deleted file mode 100644
index be13d76b25..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-b56786cafd46e138a172ca008f6586c551794b50c95616b56b7c94ac7c2d4524.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT access_level FROM (\n -- Source 1: entity_access source_id match\n SELECT\n access_level::text FROM entity_access\n WHERE entity_id = $1\n AND entity_type = 'document'\n AND source_id = ANY($2)\n\n UNION ALL\n -- Source 2: items share permission\n SELECT\n \"publicAccessLevel\" as \"access_level!\"\n FROM \"SharePermission\"\n WHERE \"isPublic\" = true\n AND \"publicAccessLevel\" IS NOT NULL\n AND id IN (\n SELECT \"sharePermissionId\" FROM \"DocumentPermission\" WHERE \"documentId\" = $3\n ) \n )\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "access_level",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid",
- "TextArray",
- "Text"
- ]
- },
- "nullable": [
- null
- ]
- },
- "hash": "b56786cafd46e138a172ca008f6586c551794b50c95616b56b7c94ac7c2d4524"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-b6705d3675950d0bbbd4a0ba10f7716a24694cfd98741fc0508d607684b1c8a9.json b/rust/cloud-storage/documents/.sqlx/query-b6705d3675950d0bbbd4a0ba10f7716a24694cfd98741fc0508d607684b1c8a9.json
deleted file mode 100644
index 1168d26a34..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-b6705d3675950d0bbbd4a0ba10f7716a24694cfd98741fc0508d607684b1c8a9.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n UPDATE notification_message_receipt\n SET failed = true, failed_at = NOW()\n WHERE message_id = $1\n RETURNING user_id, notification_id\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "user_id",
- "type_info": "Text"
- },
- {
- "ordinal": 1,
- "name": "notification_id",
- "type_info": "Uuid"
- }
- ],
- "parameters": {
- "Left": [
- "Text"
- ]
- },
- "nullable": [
- false,
- false
- ]
- },
- "hash": "b6705d3675950d0bbbd4a0ba10f7716a24694cfd98741fc0508d607684b1c8a9"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-b9fc3c761760c8e3d0013e064f23a9ad1f17396c8f5f91e9cc27e2ba9ba02157.json b/rust/cloud-storage/documents/.sqlx/query-b9fc3c761760c8e3d0013e064f23a9ad1f17396c8f5f91e9cc27e2ba9ba02157.json
deleted file mode 100644
index d560cb7eb3..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-b9fc3c761760c8e3d0013e064f23a9ad1f17396c8f5f91e9cc27e2ba9ba02157.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT access_level FROM (\n -- Source 1: entity_access source_id match\n SELECT\n access_level::text FROM entity_access\n WHERE entity_id = $1\n AND entity_type = 'chat'\n AND source_id = ANY($2)\n\n UNION ALL\n -- Source 2: items share permission\n SELECT\n \"publicAccessLevel\" as \"access_level!\"\n FROM \"SharePermission\"\n WHERE \"isPublic\" = true\n AND \"publicAccessLevel\" IS NOT NULL\n AND id IN (\n SELECT \"sharePermissionId\" FROM \"ChatPermission\" WHERE \"chatId\" = $3\n )\n )\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "access_level",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid",
- "TextArray",
- "Text"
- ]
- },
- "nullable": [
- null
- ]
- },
- "hash": "b9fc3c761760c8e3d0013e064f23a9ad1f17396c8f5f91e9cc27e2ba9ba02157"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-bdb882d426cf81329dd6d824a5d945cfd0ea2fffa26b5324ef641dfe3e304682.json b/rust/cloud-storage/documents/.sqlx/query-bdb882d426cf81329dd6d824a5d945cfd0ea2fffa26b5324ef641dfe3e304682.json
deleted file mode 100644
index 3ed3f3db5e..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-bdb882d426cf81329dd6d824a5d945cfd0ea2fffa26b5324ef641dfe3e304682.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT\n \"publicAccessLevel\" as \"access_level!\"\n FROM \"SharePermission\"\n WHERE id in (SELECT share_permission_id\n FROM calls\n WHERE id = $1\n UNION ALL\n SELECT share_permission_id\n FROM call_records\n WHERE id = $1\n LIMIT 1)\n AND \"isPublic\" = true\n AND \"publicAccessLevel\" IS NOT NULL\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "access_level!",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid"
- ]
- },
- "nullable": [
- true
- ]
- },
- "hash": "bdb882d426cf81329dd6d824a5d945cfd0ea2fffa26b5324ef641dfe3e304682"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-c8f152fcf66d2a28cb74bd5e5bd00494b195ba6fa890f7ed840a04dc49088476.json b/rust/cloud-storage/documents/.sqlx/query-c8f152fcf66d2a28cb74bd5e5bd00494b195ba6fa890f7ed840a04dc49088476.json
deleted file mode 100644
index 1216b39a3c..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-c8f152fcf66d2a28cb74bd5e5bd00494b195ba6fa890f7ed840a04dc49088476.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT access_level FROM (\n -- Source 1: entity_access source_id match\n SELECT\n access_level::text FROM entity_access\n WHERE entity_id = $1\n AND entity_type = 'project'\n AND source_id = ANY($2)\n\n UNION ALL\n -- Source 2: items share permission\n SELECT\n \"publicAccessLevel\" as \"access_level!\"\n FROM \"SharePermission\"\n WHERE \"isPublic\" = true\n AND \"publicAccessLevel\" IS NOT NULL\n AND id IN (\n SELECT \"sharePermissionId\" FROM \"ProjectPermission\" WHERE \"projectId\" = $3\n )\n )\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "access_level",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid",
- "TextArray",
- "Text"
- ]
- },
- "nullable": [
- null
- ]
- },
- "hash": "c8f152fcf66d2a28cb74bd5e5bd00494b195ba6fa890f7ed840a04dc49088476"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-cac5e246875c3539f7a03cee8271708be47a56582c2f0323716f206ab905a580.json b/rust/cloud-storage/documents/.sqlx/query-cac5e246875c3539f7a03cee8271708be47a56582c2f0323716f206ab905a580.json
deleted file mode 100644
index ddcaf87146..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-cac5e246875c3539f7a03cee8271708be47a56582c2f0323716f206ab905a580.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT cp.channel_id::text FROM comms_channel_participants cp\n WHERE cp.user_id = $1 AND cp.left_at IS NULL\n UNION ALL\n SELECT t.team_id::text FROM team_user t\n WHERE t.user_id = $1\n UNION ALL\n SELECT $1\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "channel_id",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Text"
- ]
- },
- "nullable": [
- null
- ]
- },
- "hash": "cac5e246875c3539f7a03cee8271708be47a56582c2f0323716f206ab905a580"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-cd2ae30f38c8fd4467fafbf57d515e303d2c5bed1c53a5c1cf255a172defa46c.json b/rust/cloud-storage/documents/.sqlx/query-cd2ae30f38c8fd4467fafbf57d515e303d2c5bed1c53a5c1cf255a172defa46c.json
deleted file mode 100644
index a42c11b623..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-cd2ae30f38c8fd4467fafbf57d515e303d2c5bed1c53a5c1cf255a172defa46c.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n DELETE FROM entity_access\n WHERE entity_id = $1\n AND entity_type = $2\n AND granted_from_project_id = ANY($3)\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Uuid",
- "Text",
- "TextArray"
- ]
- },
- "nullable": []
- },
- "hash": "cd2ae30f38c8fd4467fafbf57d515e303d2c5bed1c53a5c1cf255a172defa46c"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-d0a3d7eadc0e7d5d469f5ae755561b859efa9b55a2b085a1f564b42024be3e92.json b/rust/cloud-storage/documents/.sqlx/query-d0a3d7eadc0e7d5d469f5ae755561b859efa9b55a2b085a1f564b42024be3e92.json
new file mode 100644
index 0000000000..909828efa5
--- /dev/null
+++ b/rust/cloud-storage/documents/.sqlx/query-d0a3d7eadc0e7d5d469f5ae755561b859efa9b55a2b085a1f564b42024be3e92.json
@@ -0,0 +1,64 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT\n t.id as \"thread_id!\",\n t.resolved as \"resolved!\",\n t.\"documentId\" as \"document_id!\",\n t.\"createdAt\"::timestamptz as \"created_at\",\n t.\"updatedAt\"::timestamptz as \"updated_at\",\n t.\"deletedAt\"::timestamptz as \"deleted_at\",\n t.metadata as \"metadata\",\n t.owner as \"owner!\"\n FROM \"Thread\" t\n WHERE t.\"documentId\" = $1 AND t.\"deletedAt\" IS NULL\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "thread_id!",
+ "type_info": "Int8"
+ },
+ {
+ "ordinal": 1,
+ "name": "resolved!",
+ "type_info": "Bool"
+ },
+ {
+ "ordinal": 2,
+ "name": "document_id!",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 3,
+ "name": "created_at",
+ "type_info": "Timestamptz"
+ },
+ {
+ "ordinal": 4,
+ "name": "updated_at",
+ "type_info": "Timestamptz"
+ },
+ {
+ "ordinal": 5,
+ "name": "deleted_at",
+ "type_info": "Timestamptz"
+ },
+ {
+ "ordinal": 6,
+ "name": "metadata",
+ "type_info": "Jsonb"
+ },
+ {
+ "ordinal": 7,
+ "name": "owner!",
+ "type_info": "Text"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Text"
+ ]
+ },
+ "nullable": [
+ false,
+ false,
+ false,
+ null,
+ null,
+ null,
+ true,
+ false
+ ]
+ },
+ "hash": "d0a3d7eadc0e7d5d469f5ae755561b859efa9b55a2b085a1f564b42024be3e92"
+}
diff --git a/rust/cloud-storage/documents/.sqlx/query-d20bc5b5dfecf0a2ef4b7d77b9090ad28584cd0a1fd24460096b6a5097a870ac.json b/rust/cloud-storage/documents/.sqlx/query-d20bc5b5dfecf0a2ef4b7d77b9090ad28584cd0a1fd24460096b6a5097a870ac.json
deleted file mode 100644
index f3780614e0..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-d20bc5b5dfecf0a2ef4b7d77b9090ad28584cd0a1fd24460096b6a5097a870ac.json
+++ /dev/null
@@ -1,97 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT\n un.user_id as owner_id,\n un.notification_id,\n n.event_item_id,\n n.event_item_type,\n un.sent,\n un.done,\n un.created_at::timestamptz as \"created_at!\",\n un.seen_at::timestamptz as viewed_at,\n un.created_at::timestamptz as \"updated_at!\",\n un.deleted_at::timestamptz,\n n.metadata as \"notification_metadata: serde_json::Value\",\n n.notification_event_type as notification_event_type,\n n.sender_id as sender_id\n FROM user_notification un\n JOIN notification n ON n.id = un.notification_id\n WHERE un.user_id = $1\n AND un.deleted_at IS NULL\n AND un.done = false\n AND (($3::timestamptz IS NULL)\n OR (un.created_at, un.notification_id) < ($3, $4))\n ORDER BY un.created_at DESC, un.notification_id DESC\n LIMIT $2\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "owner_id",
- "type_info": "Text"
- },
- {
- "ordinal": 1,
- "name": "notification_id",
- "type_info": "Uuid"
- },
- {
- "ordinal": 2,
- "name": "event_item_id",
- "type_info": "Text"
- },
- {
- "ordinal": 3,
- "name": "event_item_type",
- "type_info": "Text"
- },
- {
- "ordinal": 4,
- "name": "sent",
- "type_info": "Bool"
- },
- {
- "ordinal": 5,
- "name": "done",
- "type_info": "Bool"
- },
- {
- "ordinal": 6,
- "name": "created_at!",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 7,
- "name": "viewed_at",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 8,
- "name": "updated_at!",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 9,
- "name": "deleted_at",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 10,
- "name": "notification_metadata: serde_json::Value",
- "type_info": "Jsonb"
- },
- {
- "ordinal": 11,
- "name": "notification_event_type",
- "type_info": "Varchar"
- },
- {
- "ordinal": 12,
- "name": "sender_id",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Text",
- "Int8",
- "Timestamptz",
- "Uuid"
- ]
- },
- "nullable": [
- false,
- false,
- false,
- false,
- false,
- false,
- null,
- null,
- null,
- null,
- false,
- false,
- true
- ]
- },
- "hash": "d20bc5b5dfecf0a2ef4b7d77b9090ad28584cd0a1fd24460096b6a5097a870ac"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-db297e24e3ed1e94c27121977d81813bbe4cde5e5b7bec42e424c72db0e27e73.json b/rust/cloud-storage/documents/.sqlx/query-db297e24e3ed1e94c27121977d81813bbe4cde5e5b7bec42e424c72db0e27e73.json
deleted file mode 100644
index d197caf563..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-db297e24e3ed1e94c27121977d81813bbe4cde5e5b7bec42e424c72db0e27e73.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT user_id FROM user_notification_type_preference\n WHERE notification_event_type = $1 AND user_id = ANY($2)\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "user_id",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Text",
- "TextArray"
- ]
- },
- "nullable": [
- false
- ]
- },
- "hash": "db297e24e3ed1e94c27121977d81813bbe4cde5e5b7bec42e424c72db0e27e73"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-e08bcee71072e0e693b1b3f2df39a2b9574f45847919251446878f32b9febbc2.json b/rust/cloud-storage/documents/.sqlx/query-e08bcee71072e0e693b1b3f2df39a2b9574f45847919251446878f32b9febbc2.json
deleted file mode 100644
index f47413e3dc..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-e08bcee71072e0e693b1b3f2df39a2b9574f45847919251446878f32b9febbc2.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n WITH RECURSIVE parent_projects AS (\n -- Base case: the project itself\n SELECT id, name, \"parentId\"\n FROM \"Project\"\n WHERE id = $1\n\n UNION ALL\n\n -- Recursive case: walk up to the parent\n SELECT p.id, p.name, p.\"parentId\"\n FROM \"Project\" p\n INNER JOIN parent_projects pp ON p.id = pp.\"parentId\"\n )\n SELECT id as \"id!\"\n FROM parent_projects\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "id!",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Text"
- ]
- },
- "nullable": [
- null
- ]
- },
- "hash": "e08bcee71072e0e693b1b3f2df39a2b9574f45847919251446878f32b9febbc2"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-e35594f0b886c9eaba037a0b13ccb3baf21cd37b638190889fb5383180a8e437.json b/rust/cloud-storage/documents/.sqlx/query-e35594f0b886c9eaba037a0b13ccb3baf21cd37b638190889fb5383180a8e437.json
deleted file mode 100644
index 3ac1b029f6..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-e35594f0b886c9eaba037a0b13ccb3baf21cd37b638190889fb5383180a8e437.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT\n \"publicAccessLevel\" as \"access_level!\"\n FROM \"SharePermission\"\n WHERE \"isPublic\" = true\n AND \"publicAccessLevel\" IS NOT NULL\n AND id IN (\n SELECT \"sharePermissionId\" FROM \"EmailThreadPermission\" WHERE \"threadId\" = $1\n )\n\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "access_level!",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Text"
- ]
- },
- "nullable": [
- true
- ]
- },
- "hash": "e35594f0b886c9eaba037a0b13ccb3baf21cd37b638190889fb5383180a8e437"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-efc740cd935fb67ef5c2a75b3c37cf16bf09d6e52e5f6e5c5b107ef8244a141d.json b/rust/cloud-storage/documents/.sqlx/query-efc740cd935fb67ef5c2a75b3c37cf16bf09d6e52e5f6e5c5b107ef8244a141d.json
deleted file mode 100644
index 1cbb49a96b..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-efc740cd935fb67ef5c2a75b3c37cf16bf09d6e52e5f6e5c5b107ef8244a141d.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n INSERT INTO user_notification (notification_id, user_id)\n SELECT $1, user_id\n FROM UNNEST($2::text[]) as user_id\n RETURNING created_at::timestamptz as \"created_at!\"\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "created_at!",
- "type_info": "Timestamptz"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid",
- "TextArray"
- ]
- },
- "nullable": [
- null
- ]
- },
- "hash": "efc740cd935fb67ef5c2a75b3c37cf16bf09d6e52e5f6e5c5b107ef8244a141d"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-f3e53dd531be738b881df199783a2beded3bd378038cbd6f012080ac77c5291b.json b/rust/cloud-storage/documents/.sqlx/query-f3e53dd531be738b881df199783a2beded3bd378038cbd6f012080ac77c5291b.json
deleted file mode 100644
index 39180b3b0f..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-f3e53dd531be738b881df199783a2beded3bd378038cbd6f012080ac77c5291b.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n UPDATE user_notification\n SET deleted_at = NOW()\n WHERE user_id = $1 AND notification_id = ANY($2)\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Text",
- "UuidArray"
- ]
- },
- "nullable": []
- },
- "hash": "f3e53dd531be738b881df199783a2beded3bd378038cbd6f012080ac77c5291b"
-}
diff --git a/rust/cloud-storage/documents/.sqlx/query-f6a7499d3079d346afe5d866734ffc5d4ac3f9f1a8c2a5714ef130e53d11145f.json b/rust/cloud-storage/documents/.sqlx/query-f6a7499d3079d346afe5d866734ffc5d4ac3f9f1a8c2a5714ef130e53d11145f.json
deleted file mode 100644
index c718076a09..0000000000
--- a/rust/cloud-storage/documents/.sqlx/query-f6a7499d3079d346afe5d866734ffc5d4ac3f9f1a8c2a5714ef130e53d11145f.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n WITH RECURSIVE child_projects AS (\n SELECT id FROM \"Project\" WHERE id = $1\n\n UNION ALL\n\n SELECT p.id FROM \"Project\" p\n INNER JOIN child_projects cp ON p.\"parentId\" = cp.id\n )\n SELECT id as \"entity_id!\", 'project' as \"entity_type!\" FROM child_projects\n\n UNION ALL\n\n SELECT d.id as \"entity_id!\", 'document' as \"entity_type!\" FROM \"Document\" d\n WHERE d.\"projectId\" IN (SELECT id FROM child_projects)\n\n UNION ALL\n\n SELECT c.id as \"entity_id!\", 'chat' as \"entity_type!\" FROM \"Chat\" c\n WHERE c.\"projectId\" IN (SELECT id FROM child_projects)\n\n UNION ALL\n\n SELECT et.id::text as \"entity_id!\", 'email_thread' as \"entity_type!\" FROM email_threads et\n WHERE et.project_id IN (SELECT id FROM child_projects)\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "entity_id!",
- "type_info": "Text"
- },
- {
- "ordinal": 1,
- "name": "entity_type!",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Text"
- ]
- },
- "nullable": [
- null,
- null
- ]
- },
- "hash": "f6a7499d3079d346afe5d866734ffc5d4ac3f9f1a8c2a5714ef130e53d11145f"
-}
diff --git a/rust/cloud-storage/documents/fixtures/document_pdf_comments_and_highlights.sql b/rust/cloud-storage/documents/fixtures/document_pdf_comments_and_highlights.sql
new file mode 100644
index 0000000000..84a383bebd
--- /dev/null
+++ b/rust/cloud-storage/documents/fixtures/document_pdf_comments_and_highlights.sql
@@ -0,0 +1,1007 @@
+-- Setup organizations and users
+INSERT INTO
+ public."Organization" ("id", "name")
+VALUES
+ (1, 'organization-one');
+
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES
+ ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id'),
+ ('a2222222-2222-2222-2222-222222222222', 'user2', '[email protected]', 'stripe_id2');
+
+INSERT INTO
+ public."User" (
+ "id",
+ "email",
+ "stripeCustomerId",
+ "organizationId",
+ "macro_user_id"
+ )
+VALUES
+ (
+ 'stripe_id',
+ 1,
+ 'a1111111-1111-1111-1111-111111111111'
+ );
+
+INSERT INTO
+ public."User" ("id", "email", "stripeCustomerId", "macro_user_id")
+VALUES
+ (
+ 'stripe_id2',
+ 'a2222222-2222-2222-2222-222222222222'
+ );
+
+--------------------------------------------------
+-- Document with comments
+--------------------------------------------------
+-- Create a PDF document that will have comments
+INSERT INTO
+ public."Document" (
+ "id",
+ "name",
+ "fileType",
+ "owner",
+ "createdAt",
+ "updatedAt"
+ )
+VALUES
+ (
+ 'document-with-comments',
+ 'Document With Comments',
+ 'pdf',
+ '2022-01-01 00:00:00',
+ '2022-01-01 00:00:00'
+ );
+
+-- Create document instance for the PDF
+INSERT INTO
+ public."DocumentInstance" (
+ "id",
+ "documentId",
+ "sha",
+ "createdAt",
+ "updatedAt"
+ )
+VALUES
+ (
+ 100,
+ 'document-with-comments',
+ 'sha-pdf-comments',
+ '2022-01-01 00:00:00',
+ '2022-01-01 00:00:00'
+ );
+
+-- Add share permissions
+INSERT INTO
+ public."SharePermission" (
+ "id",
+ "isPublic",
+ "publicAccessLevel",
+ "createdAt",
+ "updatedAt"
+ )
+VALUES
+ (
+ 'sp-comments',
+ false,
+ NULL,
+ '2022-01-01 00:00:00',
+ '2022-01-01 00:00:00'
+ );
+
+INSERT INTO
+ public."DocumentPermission" ("documentId", "sharePermissionId")
+VALUES
+ ('document-with-comments', 'sp-comments');
+
+-- Create threads for the document
+INSERT INTO
+ public."Thread" (
+ "id",
+ "owner",
+ "documentId",
+ "createdAt",
+ "updatedAt",
+ "deletedAt",
+ "resolved"
+ )
+VALUES
+ (
+ 1001,
+ 'document-with-comments',
+ '2022-01-10 10:00:00',
+ '2022-01-10 10:00:00',
+ NULL,
+ false
+ ),
+ (
+ 1002,
+ 'document-with-comments',
+ '2022-01-10 11:30:00',
+ '2022-01-10 11:30:00',
+ NULL,
+ TRUE
+ ),
+ (
+ 1003,
+ 'document-with-comments',
+ '2022-01-10 14:45:00',
+ '2022-01-10 14:45:00',
+ NULL,
+ false
+ ),
+ (
+ 1004,
+ 'document-with-comments',
+ '2022-01-10 14:45:00',
+ '2022-01-10 14:45:00',
+ '2022-01-10 14:45:00',
+ false
+ ),
+ (
+ 1005,
+ 'document-with-comments',
+ '2022-01-10 14:45:00',
+ '2022-01-10 14:45:00',
+ NULL,
+ false
+ );
+
+-- Create PDF anchors for each thread
+INSERT INTO
+ public."PdfPlaceableCommentAnchor" (
+ "documentId",
+ "uuid",
+ "owner",
+ "page",
+ "originalPage",
+ "originalIndex",
+ "shouldLockOnSave",
+ "xPct",
+ "yPct",
+ "widthPct",
+ "heightPct",
+ "rotation",
+ "threadId",
+ "wasEdited",
+ "wasDeleted",
+ "allowableEdits"
+ )
+VALUES
+ (
+ 'document-with-comments',
+ '91111111-1111-1111-1111-111111111111',
+ 1,
+ 1,
+ 0,
+ TRUE,
+ 0.2,
+ 0.3,
+ 0.1,
+ 0.05,
+ 0.0,
+ 1001,
+ false,
+ false,
+ '{"allowResize": true, "allowTranslate": true, "allowRotate": true, "allowDelete": true, "lockAspectRatio": false}'
+ ),
+ (
+ 'document-with-comments',
+ '81111111-1111-1111-1111-111111111111',
+ 2,
+ 2,
+ 1,
+ false,
+ 0.5,
+ 0.6,
+ 0.15,
+ 0.07,
+ 0.0,
+ 1002,
+ false,
+ false,
+ '{"allowResize": true, "allowTranslate": true, "allowRotate": true, "allowDelete": true, "lockAspectRatio": false}'
+ ),
+ (
+ 'document-with-comments',
+ '71111111-1111-1111-1111-111111111111',
+ 3,
+ 3,
+ 2,
+ TRUE,
+ 0.7,
+ 0.4,
+ 0.12,
+ 0.06,
+ 0.0,
+ 1003,
+ TRUE,
+ false,
+ '{"allowResize": true, "allowTranslate": true, "allowRotate": true, "allowDelete": true, "lockAspectRatio": false}'
+ );
+
+-- Create comments for each thread
+INSERT INTO
+ public."Comment" (
+ "id",
+ "threadId",
+ "owner",
+ "sender",
+ "text",
+ "createdAt",
+ "updatedAt"
+ )
+VALUES
+ -- Comments for thread 1
+ (
+ 10001,
+ 1001,
+ 'Initial question on page 1',
+ '2022-01-10 10:00:00',
+ '2022-01-10 10:00:00'
+ ),
+ (
+ 10002,
+ 1001,
+ 'Response to question on page 1',
+ '2022-01-10 10:15:00',
+ '2022-01-10 10:15:00'
+ ),
+ (
+ 10003,
+ 1001,
+ 'Follow up question',
+ '2022-01-10 10:30:00',
+ '2022-01-10 10:30:00'
+ ), -- Comments for thread 2 (resolved)
+ (
+ 10004,
+ 1002,
+ 'Question about diagram on page 2',
+ '2022-01-10 11:30:00',
+ '2022-01-10 11:30:00'
+ ),
+ (
+ 10005,
+ 1002,
+ 'Answer about the diagram',
+ '2022-01-10 11:45:00',
+ '2022-01-10 11:45:00'
+ ),
+ (
+ 10006,
+ 1002,
+ 'Thanks, marking as resolved',
+ '2022-01-10 12:00:00',
+ '2022-01-10 12:00:00'
+ ), -- Comments for thread 3
+ (
+ 10007,
+ 1003,
+ 'Feedback on page 3',
+ '2022-01-10 14:45:00',
+ '2022-01-10 14:45:00'
+ ),
+ (
+ 10008,
+ 1005,
+ 'Comment on page 3',
+ '2022-01-10 14:45:00',
+ '2022-01-10 14:45:00'
+ );
+
+-- Create modification data JSON that matches the thread/comment structure with camelCase
+INSERT INTO
+ public."DocumentInstanceModificationData" ("documentInstanceId", "modificationData")
+VALUES
+ (
+ 100,
+ '{
+ "placeables": [
+ {
+ "allowableEdits": {
+ "allowResize": true,
+ "allowTranslate": true,
+ "allowRotate": true,
+ "allowDelete": true,
+ "lockAspectRatio": false
+ },
+ "wasEdited": false,
+ "wasDeleted": false,
+ "pageRange": [1],
+ "position": {
+ "xPct": 0.2,
+ "yPct": 0.3,
+ "widthPct": 0.1,
+ "heightPct": 0.05,
+ "rotation": 0.0
+ },
+ "shouldLockOnSave": true,
+ "originalPage": 1,
+ "originalIndex": 0,
+ "payloadType": "thread",
+ "payload": {
+ "headID": "thread1",
+ "page": 1,
+ "comments": [
+ {
+ "id": "comment1",
+ "sender": "[email protected]",
+ "content": "Initial question on page 1",
+ "editDate": "2022-01-10T10:00:00Z"
+ },
+ {
+ "id": "comment2",
+ "sender": "[email protected]",
+ "content": "Response to question on page 1",
+ "editDate": "2022-01-10T10:15:00Z"
+ },
+ {
+ "id": "comment3",
+ "sender": "[email protected]",
+ "content": "Follow up question",
+ "editDate": "2022-01-10T10:30:00Z"
+ }
+ ],
+ "isResolved": false
+ }
+ },
+ {
+ "allowableEdits": {
+ "allowResize": true,
+ "allowTranslate": true,
+ "allowRotate": true,
+ "allowDelete": true,
+ "lockAspectRatio": false
+ },
+ "wasEdited": false,
+ "wasDeleted": false,
+ "pageRange": [2],
+ "position": {
+ "xPct": 0.5,
+ "yPct": 0.6,
+ "widthPct": 0.15,
+ "heightPct": 0.07,
+ "rotation": 0.0
+ },
+ "shouldLockOnSave": false,
+ "originalPage": 2,
+ "originalIndex": 1,
+ "payloadType": "thread",
+ "payload": {
+ "headID": "thread2",
+ "page": 2,
+ "comments": [
+ {
+ "id": "comment4",
+ "sender": "[email protected]",
+ "content": "Question about diagram on page 2",
+ "editDate": "2022-01-10T11:30:00Z"
+ },
+ {
+ "id": "comment5",
+ "sender": "[email protected]",
+ "content": "Answer about the diagram",
+ "editDate": "2022-01-10T11:45:00Z"
+ },
+ {
+ "id": "comment6",
+ "sender": "[email protected]",
+ "content": "Thanks, marking as resolved",
+ "editDate": "2022-01-10T12:00:00Z"
+ }
+ ],
+ "isResolved": true
+ }
+ },
+ {
+ "allowableEdits": {
+ "allowResize": true,
+ "allowTranslate": true,
+ "allowRotate": true,
+ "allowDelete": true,
+ "lockAspectRatio": false
+ },
+ "wasEdited": true,
+ "wasDeleted": false,
+ "pageRange": [3],
+ "position": {
+ "xPct": 0.7,
+ "yPct": 0.4,
+ "widthPct": 0.12,
+ "heightPct": 0.06,
+ "rotation": 0.0
+ },
+ "shouldLockOnSave": true,
+ "originalPage": 3,
+ "originalIndex": 2,
+ "payloadType": "thread",
+ "payload": {
+ "headID": "thread3",
+ "page": 3,
+ "comments": [
+ {
+ "id": "comment7",
+ "sender": "[email protected]",
+ "content": "Feedback on page 3",
+ "editDate": "2022-01-10T14:45:00Z"
+ }
+ ],
+ "isResolved": false
+ }
+ }
+ ]
+}'
+ );
+
+--------------------------------------------------
+-- Document for updates
+--------------------------------------------------
+-- Create another document to test the updates
+INSERT INTO
+ public."Document" (
+ "id",
+ "name",
+ "fileType",
+ "owner",
+ "createdAt",
+ "updatedAt"
+ )
+VALUES
+ (
+ 'document-for-updates',
+ 'Document For Updates',
+ 'pdf',
+ '2022-01-02 00:00:00',
+ '2022-01-02 00:00:00'
+ );
+
+-- Create document instance for the PDF that will be updated
+INSERT INTO
+ public."DocumentInstance" (
+ "id",
+ "documentId",
+ "sha",
+ "createdAt",
+ "updatedAt"
+ )
+VALUES
+ (
+ 200,
+ 'document-for-updates',
+ 'sha-updates',
+ '2022-01-02 00:00:00',
+ '2022-01-02 00:00:00'
+ );
+
+-- Add an initial thread to document-for-updates
+INSERT INTO
+ public."Thread" (
+ "id",
+ "owner",
+ "documentId",
+ "createdAt",
+ "updatedAt",
+ "resolved"
+ )
+VALUES
+ (
+ 2001,
+ 'document-for-updates',
+ '2022-01-15 09:00:00',
+ '2022-01-15 09:00:00',
+ false
+ );
+
+-- Create PDF anchor for the thread
+INSERT INTO
+ public."PdfPlaceableCommentAnchor" (
+ "documentId",
+ "uuid",
+ "owner",
+ "page",
+ "originalPage",
+ "originalIndex",
+ "shouldLockOnSave",
+ "xPct",
+ "yPct",
+ "widthPct",
+ "heightPct",
+ "rotation",
+ "threadId",
+ "wasEdited",
+ "wasDeleted",
+ "allowableEdits"
+ )
+VALUES
+ (
+ 'document-for-updates',
+ '61111111-1111-1111-1111-111111111111',
+ 1,
+ 1,
+ 0,
+ TRUE,
+ 0.3,
+ 0.4,
+ 0.1,
+ 0.05,
+ 0.0,
+ 2001,
+ false,
+ false,
+ '{"allowResize": true, "allowTranslate": true, "allowRotate": true, "allowDelete": true, "lockAspectRatio": false}'
+ );
+
+-- Add comments to thread
+INSERT INTO
+ public."Comment" (
+ "id",
+ "threadId",
+ "owner",
+ "sender",
+ "text",
+ "createdAt",
+ "updatedAt"
+ )
+VALUES
+ (
+ 20001,
+ 2001,
+ 'Initial comment for thread',
+ '2022-01-15 09:00:00',
+ '2022-01-15 09:00:00'
+ );
+
+-- Add consistent modification data with camelCase
+INSERT INTO
+ public."DocumentInstanceModificationData" ("documentInstanceId", "modificationData")
+VALUES
+ (
+ 200,
+ '{
+ "placeables": [
+ {
+ "allowableEdits": {
+ "allowResize": true,
+ "allowTranslate": true,
+ "allowRotate": true,
+ "allowDelete": true,
+ "lockAspectRatio": false
+ },
+ "wasEdited": false,
+ "wasDeleted": false,
+ "pageRange": [1],
+ "position": {
+ "xPct": 0.3,
+ "yPct": 0.4,
+ "widthPct": 0.1,
+ "heightPct": 0.05,
+ "rotation": 0.0
+ },
+ "shouldLockOnSave": true,
+ "originalPage": 1,
+ "originalIndex": 0,
+ "payloadType": "thread",
+ "payload": {
+ "headID": "update-thread1",
+ "page": 1,
+ "comments": [
+ {
+ "id": "update-comment1",
+ "sender": "[email protected]",
+ "content": "Initial comment for thread",
+ "editDate": "2022-01-15T09:00:00Z"
+ }
+ ],
+ "isResolved": false
+ }
+ }
+ ]
+}'
+ );
+
+--------------------------------------------------
+-- Document for deletion tests
+--------------------------------------------------
+-- Create document that will be used for testing thread deletion
+INSERT INTO
+ public."Document" (
+ "id",
+ "name",
+ "fileType",
+ "owner",
+ "createdAt",
+ "updatedAt"
+ )
+VALUES
+ (
+ 'document-delete-test',
+ 'Document Delete Test',
+ 'pdf',
+ '2022-01-03 00:00:00',
+ '2022-01-03 00:00:00'
+ );
+
+-- Create document instance for the PDF
+INSERT INTO
+ public."DocumentInstance" (
+ "id",
+ "documentId",
+ "sha",
+ "createdAt",
+ "updatedAt"
+ )
+VALUES
+ (
+ 300,
+ 'document-delete-test',
+ 'sha-delete',
+ '2022-01-03 00:00:00',
+ '2022-01-03 00:00:00'
+ );
+
+-- Add threads to document-delete-test
+INSERT INTO
+ public."Thread" (
+ "id",
+ "owner",
+ "documentId",
+ "createdAt",
+ "updatedAt",
+ "resolved"
+ )
+VALUES
+ (
+ 3001,
+ 'document-delete-test',
+ '2022-01-20 10:00:00',
+ '2022-01-20 10:00:00',
+ false
+ ),
+ (
+ 3002,
+ 'document-delete-test',
+ '2022-01-20 11:00:00',
+ '2022-01-20 11:00:00',
+ false
+ );
+
+-- Create PDF anchors for the threads
+INSERT INTO
+ public."PdfPlaceableCommentAnchor" (
+ "documentId",
+ "uuid",
+ "owner",
+ "page",
+ "originalPage",
+ "originalIndex",
+ "shouldLockOnSave",
+ "xPct",
+ "yPct",
+ "widthPct",
+ "heightPct",
+ "rotation",
+ "threadId",
+ "wasEdited",
+ "wasDeleted",
+ "allowableEdits"
+ )
+VALUES
+ (
+ 'document-delete-test',
+ '51111111-1111-1111-1111-111111111111',
+ 1,
+ 1,
+ 0,
+ TRUE,
+ 0.2,
+ 0.3,
+ 0.1,
+ 0.05,
+ 0.0,
+ 3001,
+ false,
+ false,
+ '{"allowResize": true, "allowTranslate": true, "allowRotate": true, "allowDelete": true, "lockAspectRatio": false}'
+ ),
+ (
+ 'document-delete-test',
+ '41111111-1111-1111-1111-111111111111',
+ 2,
+ 2,
+ 1,
+ TRUE,
+ 0.5,
+ 0.6,
+ 0.15,
+ 0.07,
+ 0.0,
+ 3002,
+ false,
+ false,
+ '{"allowResize": true, "allowTranslate": true, "allowRotate": true, "allowDelete": true, "lockAspectRatio": false}'
+ );
+
+-- Add comments to threads
+INSERT INTO
+ public."Comment" (
+ "id",
+ "threadId",
+ "owner",
+ "sender",
+ "text",
+ "createdAt",
+ "updatedAt"
+ )
+VALUES
+ (
+ 30001,
+ 3001,
+ 'Comment in thread 1',
+ '2022-01-20 10:00:00',
+ '2022-01-20 10:00:00'
+ ),
+ (
+ 30002,
+ 3002,
+ 'Comment in thread 2',
+ '2022-01-20 11:00:00',
+ '2022-01-20 11:00:00'
+ );
+
+-- Add modification data with only the first thread (to test deletion) with camelCase
+INSERT INTO
+ public."DocumentInstanceModificationData" ("documentInstanceId", "modificationData")
+VALUES
+ (
+ 300,
+ '{
+ "placeables": [
+ {
+ "allowableEdits": {
+ "allowResize": true,
+ "allowTranslate": true,
+ "allowRotate": true,
+ "allowDelete": true,
+ "lockAspectRatio": false
+ },
+ "wasEdited": false,
+ "wasDeleted": false,
+ "pageRange": [1],
+ "position": {
+ "xPct": 0.2,
+ "yPct": 0.3,
+ "widthPct": 0.1,
+ "heightPct": 0.05,
+ "rotation": 0.0
+ },
+ "shouldLockOnSave": true,
+ "originalPage": 1,
+ "originalIndex": 0,
+ "payloadType": "thread",
+ "payload": {
+ "headID": "delete-thread1",
+ "page": 1,
+ "comments": [
+ {
+ "id": "delete-comment1",
+ "sender": "[email protected]",
+ "content": "Comment in thread 1",
+ "editDate": "2022-01-20T10:00:00Z"
+ }
+ ],
+ "isResolved": false
+ }
+ }
+ ]
+}'
+ );
+
+-- Add highlight anchors (each associated with a thread)
+INSERT INTO
+ public."PdfHighlightAnchor" (
+ "uuid",
+ "documentId",
+ "owner",
+ "threadId",
+ "page",
+ "red",
+ "green",
+ "blue",
+ "alpha",
+ "type",
+ "text",
+ "pageViewportWidth",
+ "pageViewportHeight",
+ "createdAt",
+ "updatedAt",
+ "deletedAt"
+ )
+VALUES
+ -- Highlight 1 (red highlight on page 1, linked to thread 1001)
+ (
+ '11111111-1111-1111-1111-111111111111',
+ 'document-with-comments',
+ 1001,
+ 1,
+ 255,
+ 0,
+ 0,
+ 0.8,
+ 1,
+ 'Highlighted text on page 1',
+ 800,
+ 1000,
+ '2022-01-10 10:00:00',
+ '2022-01-10 10:00:00',
+ NULL
+ ), -- Highlight 2 (green highlight on page 2, linked to thread 1002)
+ (
+ '22222222-2222-2222-2222-222222222222',
+ 'document-with-comments',
+ 1002,
+ 2,
+ 0,
+ 255,
+ 0,
+ 0.7,
+ 1,
+ 'Another highlight on page 2',
+ 800,
+ 1000,
+ '2022-01-10 11:30:00',
+ '2022-01-10 11:30:00',
+ NULL
+ ), -- Highlight 3 (blue highlight on page 3, linked to no thread)
+ (
+ '33333333-3333-3333-3333-333333333333',
+ 'document-with-comments',
+ NULL,
+ 3,
+ 0,
+ 0,
+ 255,
+ 0.6,
+ 1,
+ 'Last highlight on page 3',
+ 800,
+ 1000,
+ '2022-01-10 14:45:00',
+ '2022-01-10 14:45:00',
+ NULL
+ );
+
+-- Add highlight rectangles (each linked to its respective highlight anchor)
+INSERT INTO
+ public."PdfHighlightRect" (
+ "pdfHighlightAnchorId",
+ "top",
+ "left",
+ "width",
+ "height"
+ )
+VALUES
+ -- Rectangles for highlight 1 (on page 1)
+ (
+ '11111111-1111-1111-1111-111111111111',
+ 100,
+ 50,
+ 200,
+ 50
+ ),
+ (
+ '11111111-1111-1111-1111-111111111111',
+ 160,
+ 50,
+ 200,
+ 50
+ ), -- Rectangle for highlight 2 (on page 2)
+ (
+ '22222222-2222-2222-2222-222222222222',
+ 220,
+ 80,
+ 250,
+ 55
+ ), -- Rectangles for highlight 3 (on page 3)
+ (
+ '33333333-3333-3333-3333-333333333333',
+ 300,
+ 100,
+ 150,
+ 40
+ ),
+ (
+ '33333333-3333-3333-3333-333333333333',
+ 350,
+ 100,
+ 150,
+ 40
+ ),
+ (
+ '33333333-3333-3333-3333-333333333333',
+ 400,
+ 100,
+ 150,
+ 40
+ );
+
+INSERT INTO
+ "ThreadAnchor" ("threadId", "anchorId", "anchorTableName")
+VALUES
+ (
+ 1001,
+ '91111111-1111-1111-1111-111111111111',
+ 'PdfPlaceableCommentAnchor'
+ ),
+ (
+ 1002,
+ '81111111-1111-1111-1111-111111111111',
+ 'PdfPlaceableCommentAnchor'
+ ),
+ (
+ 1003,
+ '71111111-1111-1111-1111-111111111111',
+ 'PdfPlaceableCommentAnchor'
+ ),
+ (
+ 2001,
+ '61111111-1111-1111-1111-111111111111',
+ 'PdfPlaceableCommentAnchor'
+ ),
+ (
+ 3001,
+ '51111111-1111-1111-1111-111111111111',
+ 'PdfPlaceableCommentAnchor'
+ ),
+ (
+ 3002,
+ '41111111-1111-1111-1111-111111111111',
+ 'PdfPlaceableCommentAnchor'
+ );
\ No newline at end of file
diff --git a/rust/cloud-storage/documents/src/domain/models.rs b/rust/cloud-storage/documents/src/domain/models.rs
index 551a82afc7..a6dd2e00cf 100644
--- a/rust/cloud-storage/documents/src/domain/models.rs
+++ b/rust/cloud-storage/documents/src/domain/models.rs
@@ -1,9 +1,11 @@
//! Domain models for the documents crate.
+use chrono::{DateTime, Utc};
use macro_user_id::user_id::MacroUserIdStr;
use model::document::{DocumentMetadata, FileType};
use model::sync_service::SyncServiceVersionID;
use models_properties::api::requests::SetPropertyValue;
+use serde_json::Value;
/// SHA256 hash of an empty string — used for empty markdown documents (tasks).
pub const EMPTY_SHA256: &str = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
@@ -203,3 +205,67 @@ pub struct CreateTaskResponse {
/// The document ID of the created task.
pub document_id: String,
}
+
+/// A comment thread attached to a document.
+#[derive(serde::Serialize, serde::Deserialize, Eq, PartialEq, Debug, Clone)]
+#[cfg_attr(feature = "ai_tools", derive(schemars::JsonSchema))]
+#[cfg_attr(feature = "axum", derive(utoipa::ToSchema))]
+#[serde(rename_all = "camelCase")]
+pub struct Thread {
+ /// The unique id of the thread.
+ pub thread_id: i64,
+ /// The user id of the thread owner.
+ pub owner: String,
+ /// Whether the thread has been resolved.
+ pub resolved: bool,
+ /// The document the thread is attached to.
+ pub document_id: String,
+ /// When the thread was created.
+ pub created_at: Option<DateTime<Utc>>,
+ /// When the thread was last updated.
+ pub updated_at: Option<DateTime<Utc>>,
+ /// When the thread was deleted, if ever.
+ pub deleted_at: Option<DateTime<Utc>>,
+ /// Arbitrary thread metadata.
+ pub metadata: Option<Value>,
+}
+
+/// A single comment in a thread.
+#[derive(serde::Serialize, serde::Deserialize, Eq, PartialEq, Debug, Clone)]
+#[cfg_attr(feature = "ai_tools", derive(schemars::JsonSchema))]
+#[cfg_attr(feature = "axum", derive(utoipa::ToSchema))]
+#[serde(rename_all = "camelCase")]
+pub struct Comment {
+ /// The unique id of the comment.
+ pub comment_id: i64,
+ /// The thread this comment belongs to.
+ pub thread_id: i64,
+ /// Ordering position within the thread.
+ pub order: Option<i32>,
+ /// The user id of the comment owner.
+ pub owner: String,
+ /// Sender display string.
+ pub sender: Option<String>,
+ /// Comment body.
+ pub text: String,
+ /// Arbitrary comment metadata.
+ pub metadata: Option<Value>,
+ /// When the comment was created.
+ pub created_at: Option<DateTime<Utc>>,
+ /// When the comment was last updated.
+ pub updated_at: Option<DateTime<Utc>>,
+ /// When the comment was deleted, if ever.
+ pub deleted_at: Option<DateTime<Utc>>,
+}
+
+/// A thread bundled together with its ordered comments.
+#[derive(serde::Serialize, serde::Deserialize, Eq, PartialEq, Debug, Clone)]
+#[cfg_attr(feature = "ai_tools", derive(schemars::JsonSchema))]
+#[cfg_attr(feature = "axum", derive(utoipa::ToSchema))]
+#[serde(rename_all = "camelCase")]
+pub struct CommentThread {
+ /// The thread metadata.
+ pub thread: Thread,
+ /// The comments in the thread, ordered by `createdAt` ASC.
+ pub comments: Vec<Comment>,
+}
diff --git a/rust/cloud-storage/documents/src/domain/ports.rs b/rust/cloud-storage/documents/src/domain/ports.rs
index fea1060033..a3ac8e3737 100644
--- a/rust/cloud-storage/documents/src/domain/ports.rs
+++ b/rust/cloud-storage/documents/src/domain/ports.rs
@@ -16,8 +16,9 @@ use model::document::{ContentType, DocumentBasic, DocumentMetadata};
use model::sync_service::SyncServiceVersionID;
use super::models::{
- CopyDocumentRepoArgs, CreateDocumentRepoArgs, CreateTaskRequest, CreateTaskResponse,
- DocumentError, EditDocumentRepoArgs, EditDocumentServiceArgs, LocationQueryParams,
+ CommentThread, CopyDocumentRepoArgs, CreateDocumentRepoArgs, CreateTaskRequest,
+ CreateTaskResponse, DocumentError, EditDocumentRepoArgs, EditDocumentServiceArgs,
+ LocationQueryParams,
};
/// Repository for accessing document data from the database.
@@ -86,6 +87,12 @@ pub trait DocumentRepo: Send + Sync + 'static {
document_id: &str,
) -> impl Future<Output = Result<String, Self::Err>> + Send;
+ /// Get all comment threads (with their comments) attached to a document.
+ fn get_document_comments(
+ &self,
+ document_id: &str,
+ ) -> impl Future<Output = Result<Vec<CommentThread>, Self::Err>> + Send;
+
/// Create a new document with all associated records in a single transaction.
///
/// Handles: Document row, version (DocumentInstance or DocumentBom),
@@ -255,6 +262,12 @@ pub trait DocumentService: Send + Sync + 'static {
entity_access_receipt: EntityAccessReceipt<ViewAccessLevel>,
) -> impl Future<Output = Result<String, DocumentError>> + Send;
+ /// Get all comment threads (with their comments) for a document.
+ fn get_document_comments(
+ &self,
+ entity_access_receipt: EntityAccessReceipt<ViewAccessLevel>,
+ ) -> impl Future<Output = Result<Vec<CommentThread>, DocumentError>> + Send;
+
/// Create a new document, generate an S3 presigned upload URL, and
/// optionally attach task properties and update project modified.
fn create_document(
diff --git a/rust/cloud-storage/documents/src/domain/service.rs b/rust/cloud-storage/documents/src/domain/service.rs
index 97cf541bb4..bdd34bf65e 100644
--- a/rust/cloud-storage/documents/src/domain/service.rs
+++ b/rust/cloud-storage/documents/src/domain/service.rs
@@ -32,9 +32,9 @@ use s3_key::{
use tracing;
use super::models::{
- CloudFrontConfig, CopyDocumentRepoArgs, CreateDocumentRepoArgs, CreateTaskRequest,
- CreateTaskResponse, DocumentError, EMPTY_SHA256, EditDocumentRepoArgs, EditDocumentServiceArgs,
- FileTypeUpdate, LocationQueryParams,
+ CloudFrontConfig, CommentThread, CopyDocumentRepoArgs, CreateDocumentRepoArgs,
+ CreateTaskRequest, CreateTaskResponse, DocumentError, EMPTY_SHA256, EditDocumentRepoArgs,
+ EditDocumentServiceArgs, FileTypeUpdate, LocationQueryParams,
};
use super::ports::{DocumentRepo, DocumentService, PresignedUploadUrlPort, TaskPropertiesPort};
@@ -473,6 +473,16 @@ impl<
.map_err(|e| DocumentError::Internal(e.into()))
}
+ async fn get_document_comments(
+ &self,
+ entity_access_receipt: EntityAccessReceipt<ViewAccessLevel>,
+ ) -> Result<Vec<CommentThread>, DocumentError> {
+ self.repo
+ .get_document_comments(&entity_access_receipt.entity().entity_id)
+ .await
+ .map_err(|e| DocumentError::Internal(e.into()))
+ }
+
async fn get_short_id(
&self,
entity_access_receipt: EntityAccessReceipt<ViewAccessLevel>,
diff --git a/rust/cloud-storage/documents/src/inbound/toolset/read_content.rs b/rust/cloud-storage/documents/src/inbound/toolset/read_content.rs
index 392aecec37..cd6d7814ab 100644
--- a/rust/cloud-storage/documents/src/inbound/toolset/read_content.rs
+++ b/rust/cloud-storage/documents/src/inbound/toolset/read_content.rs
@@ -2,7 +2,10 @@
use std::str::FromStr;
-use crate::domain::{models::LocationQueryParams, ports::DocumentService};
+use crate::domain::{
+ models::{CommentThread, LocationQueryParams},
+ ports::DocumentService,
+};
use ai::tool::{AsyncTool, RequestContext, ServiceContext, ToolCallError, ToolResult};
use async_trait::async_trait;
use entity_access::domain::{
@@ -42,16 +45,25 @@ impl From<lexical_client::types::MarkdownNode> for MarkdownNode {
}
}
-/// The read content response
+/// The content of the document
#[derive(Debug, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
-pub enum ReadContentResponse {
+pub enum Content {
/// Simple text content
Text(String),
/// All nodes of the markdown file
Markdown(Vec<MarkdownNode>),
}
+#[derive(Debug, Serialize, JsonSchema)]
+#[serde(rename_all = "camelCase")]
+pub struct ReadContentResponse {
+ /// The content of the document
+ pub content: Content,
+ /// Any comments on the document
+ pub comments: Vec<CommentThread>,
+}
+
#[derive(Debug, Deserialize, JsonSchema, Clone, Default)]
#[serde(rename_all = "camelCase")]
#[schemars(title = "ReadContent", description = "Retrieve a documents content")]
@@ -115,18 +127,18 @@ where
});
};
- let response: ReadContentResponse = match file_type.macro_app_path() {
- FileAssociation::Pdf(_) | FileAssociation::Write(_) => ReadContentResponse::Text(
+ let content: Content = match file_type.macro_app_path() {
+ FileAssociation::Pdf(_) | FileAssociation::Write(_) => Content::Text(
service_context
.service
- .get_document_text(entity_access_receipt)
+ .get_document_text(entity_access_receipt.clone())
.await
.map_err(|e| ToolCallError {
description: "unable to get document text".to_string(),
internal_error: e.into(),
})?,
),
- FileAssociation::Md(_) => ReadContentResponse::Markdown(
+ FileAssociation::Md(_) => Content::Markdown(
service_context
.lexical_client
.parse_markdown_for_ai(&self.document_id.to_string())
@@ -140,11 +152,11 @@ where
.map(|i| i.into())
.collect(),
),
- FileAssociation::Code(_) | FileAssociation::Document(_) => ReadContentResponse::Text(
+ FileAssociation::Code(_) | FileAssociation::Document(_) => Content::Text(
get_document_content_from_location(
service_context.clone(),
&document_context,
- entity_access_receipt,
+ entity_access_receipt.clone(),
)
.await
.map_err(|e| ToolCallError {
@@ -160,7 +172,16 @@ where
}
};
- Ok(response)
+ let comments = service_context
+ .service
+ .get_document_comments(entity_access_receipt)
+ .await
+ .map_err(|e| ToolCallError {
+ description: "unable to get document comments".to_string(),
+ internal_error: e.into(),
+ })?;
+
+ Ok(ReadContentResponse { content, comments })
}
}
diff --git a/rust/cloud-storage/documents/src/outbound/pg_document_repo.rs b/rust/cloud-storage/documents/src/outbound/pg_document_repo.rs
index 07311bed60..235ec2e532 100644
--- a/rust/cloud-storage/documents/src/outbound/pg_document_repo.rs
+++ b/rust/cloud-storage/documents/src/outbound/pg_document_repo.rs
@@ -15,7 +15,10 @@ use macro_user_id::{cowlike::CowLike, user_id::MacroUserIdStr};
use model::document::{DocumentBasic, DocumentMetadata};
use sqlx::PgPool;
-use crate::domain::models::{CopyDocumentRepoArgs, CreateDocumentRepoArgs, EditDocumentRepoArgs};
+use crate::domain::models::{
+ Comment, CommentThread, CopyDocumentRepoArgs, CreateDocumentRepoArgs, EditDocumentRepoArgs,
+ Thread,
+};
use crate::domain::ports::DocumentRepo;
/// PostgreSQL-backed document repository.
@@ -768,4 +771,100 @@ impl DocumentRepo for PgDocumentRepo {
transaction.commit().await?;
Ok(())
}
+
+ #[tracing::instrument(err, skip(self))]
+ async fn get_document_comments(
+ &self,
+ document_id: &str,
+ ) -> Result<Vec<CommentThread>, Self::Err> {
+ let threads = sqlx::query!(
+ r#"
+ SELECT
+ t.id as "thread_id!",
+ t.resolved as "resolved!",
+ t."documentId" as "document_id!",
+ t."createdAt"::timestamptz as "created_at",
+ t."updatedAt"::timestamptz as "updated_at",
+ t."deletedAt"::timestamptz as "deleted_at",
+ t.metadata as "metadata",
+ t.owner as "owner!"
+ FROM "Thread" t
+ WHERE t."documentId" = $1 AND t."deletedAt" IS NULL
+ "#,
+ document_id,
+ )
+ .map(|row| Thread {
+ thread_id: row.thread_id,
+ resolved: row.resolved,
+ document_id: row.document_id,
+ created_at: row.created_at,
+ updated_at: row.updated_at,
+ deleted_at: row.deleted_at,
+ metadata: row.metadata,
+ owner: row.owner,
+ })
+ .fetch_all(&self.pool)
+ .await?;
+
+ let comments = sqlx::query!(
+ r#"
+ SELECT
+ c.id as "comment_id!",
+ c."threadId" as "thread_id!",
+ c.owner as "owner!",
+ c.sender,
+ c.text as "text!",
+ c.metadata,
+ c."createdAt"::timestamptz as "created_at",
+ c."updatedAt"::timestamptz as "updated_at",
+ c."deletedAt"::timestamptz as "deleted_at",
+ c.order
+ FROM "Comment" c
+ JOIN "Thread" t ON c."threadId" = t.id
+ WHERE t."documentId" = $1
+ AND t."deletedAt" IS NULL
+ AND c."deletedAt" IS NULL
+ ORDER BY c."createdAt" ASC
+ "#,
+ document_id,
+ )
+ .map(|row| Comment {
+ comment_id: row.comment_id,
+ thread_id: row.thread_id,
+ owner: row.owner,
+ sender: row.sender,
+ text: row.text,
+ metadata: row.metadata,
+ created_at: row.created_at,
+ updated_at: row.updated_at,
+ deleted_at: row.deleted_at,
+ order: row.order,
+ })
+ .fetch_all(&self.pool)
+ .await?;
+
+ let mut comments_by_thread: std::collections::HashMap<i64, Vec<Comment>> =
+ std::collections::HashMap::new();
+ for comment in comments {
+ comments_by_thread
+ .entry(comment.thread_id)
+ .or_default()
+ .push(comment);
+ }
+
+ let comment_threads = threads
+ .into_iter()
+ .map(|thread| {
+ let thread_comments = comments_by_thread
+ .remove(&thread.thread_id)
+ .unwrap_or_default();
+ CommentThread {
+ thread,
+ comments: thread_comments,
+ }
+ })
+ .collect();
+
+ Ok(comment_threads)
+ }
}
diff --git a/rust/cloud-storage/documents/src/outbound/pg_document_repo/tests.rs b/rust/cloud-storage/documents/src/outbound/pg_document_repo/tests.rs
index dc9910a055..ebbeb225a3 100644
--- a/rust/cloud-storage/documents/src/outbound/pg_document_repo/tests.rs
+++ b/rust/cloud-storage/documents/src/outbound/pg_document_repo/tests.rs
@@ -721,3 +721,155 @@ async fn test_edit_document_channel_share_idempotent(pool: Pool<Postgres>) {
"Should still have exactly 1 channel row after idempotent upsert"
);
}
+
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(
+ path = "../../../fixtures",
+ scripts("document_pdf_comments_and_highlights")
+ )
+)]
+async fn test_fetch_document_comments(pool: Pool<Postgres>) -> anyhow::Result<()> {
+ let repo = PgDocumentRepo::new(pool);
+
+ // Test fetching comments for document-with-comments (which has 3 threads and 7 comments)
+ let comment_threads = repo.get_document_comments("document-with-comments").await?;
+
+ // Verify we got all threads
+ assert_eq!(comment_threads.len(), 4);
+
+ // Map threads by ID for easier testing
+ let thread_map: std::collections::HashMap<i64, &crate::domain::models::CommentThread> =
+ comment_threads
+ .iter()
+ .map(|t| (t.thread.thread_id, t))
+ .collect();
+
+ // Check thread 1001 (unresolved with 3 comments)
+ let thread_1001 = thread_map.get(&1001).expect("Thread 1001 should exist");
+ assert_eq!(thread_1001.comments.len(), 3);
+ assert!(!thread_1001.thread.resolved);
+
+ // Check thread 1002 (resolved with 3 comments)
+ let thread_1002 = thread_map.get(&1002).expect("Thread 1002 should exist");
+ assert_eq!(thread_1002.comments.len(), 3);
+ assert!(thread_1002.thread.resolved);
+
+ // Check thread 1003 (unresolved with 1 comment)
+ let thread_1003 = thread_map.get(&1003).expect("Thread 1003 should exist");
+ assert_eq!(thread_1003.comments.len(), 1);
+ assert!(!thread_1003.thread.resolved);
+
+ // Check specific comment content for thread 1001
+ let first_comment = &thread_1001.comments[0];
+ assert_eq!(first_comment.text, "Initial question on page 1");
+ assert_eq!(first_comment.sender, Some("[email protected]".to_string()));
+
+ Ok(())
+}
+
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(
+ path = "../../../fixtures",
+ scripts("document_pdf_comments_and_highlights")
+ )
+)]
+async fn test_fetch_document_comments_empty(pool: Pool<Postgres>) -> anyhow::Result<()> {
+ let repo = PgDocumentRepo::new(pool);
+
+ // This document ID doesn't exist in our fixture, so should return empty results
+ let comment_threads = repo.get_document_comments("non-existent-document").await?;
+
+ // Verify we got an empty list
+ assert_eq!(comment_threads.len(), 0);
+
+ Ok(())
+}
+
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(
+ path = "../../../fixtures",
+ scripts("document_pdf_comments_and_highlights")
+ )
+)]
+async fn test_thread_deletion(pool: Pool<Postgres>) -> anyhow::Result<()> {
+ let repo = PgDocumentRepo::new(pool.clone());
+
+ // First verify we have 2 threads in document-delete-test
+ let threads_before = repo.get_document_comments("document-delete-test").await?;
+ assert_eq!(threads_before.len(), 2);
+
+ // Now mark one thread as deleted
+ sqlx::query!(
+ r#"
+ UPDATE "Thread"
+ SET "deletedAt" = NOW()
+ WHERE "id" = 3001
+ "#
+ )
+ .execute(&pool)
+ .await?;
+
+ // Fetch comments again - deleted threads should be filtered out
+ let threads_after = repo.get_document_comments("document-delete-test").await?;
+
+ // Verify only one thread remains and it's the correct one
+ assert_eq!(threads_after.len(), 1);
+ assert_eq!(threads_after[0].thread.thread_id, 3002);
+
+ Ok(())
+}
+
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(
+ path = "../../../fixtures",
+ scripts("document_pdf_comments_and_highlights")
+ )
+)]
+async fn test_comment_deletion(pool: Pool<Postgres>) -> anyhow::Result<()> {
+ let repo = PgDocumentRepo::new(pool.clone());
+
+ // First verify thread 1001 has 3 comments
+ let threads_before = repo.get_document_comments("document-with-comments").await?;
+ let thread_1001_before = threads_before
+ .iter()
+ .find(|t| t.thread.thread_id == 1001)
+ .expect("Thread 1001 should exist");
+ assert_eq!(thread_1001_before.comments.len(), 3);
+
+ // Now mark one comment as deleted
+ sqlx::query!(
+ r#"
+ UPDATE "Comment"
+ SET "deletedAt" = NOW()
+ WHERE "id" = 10001
+ "#
+ )
+ .execute(&pool)
+ .await?;
+
+ // Fetch comments again - deleted comments should be filtered out
+ let threads_after = repo.get_document_comments("document-with-comments").await?;
+ let thread_1001_after = threads_after
+ .iter()
+ .find(|t| t.thread.thread_id == 1001)
+ .expect("Thread 1001 should exist");
+
+ // Verify one comment was filtered out
+ assert_eq!(thread_1001_after.comments.len(), 2);
+
+ // Verify the remaining comments are the ones we expect
+ let comment_ids: Vec<i64> = thread_1001_after
+ .comments
+ .iter()
+ .map(|c| c.comment_id)
+ .collect();
+ assert!(comment_ids.contains(&10002));
+ assert!(comment_ids.contains(&10003));
+ assert!(!comment_ids.contains(&10001));
+
+ Ok(())
+}
diff --git a/rust/cloud-storage/github/src/domain/service/sync/test.rs b/rust/cloud-storage/github/src/domain/service/sync/test.rs
index 4f06edd890..0a923c00a8 100644
--- a/rust/cloud-storage/github/src/domain/service/sync/test.rs
+++ b/rust/cloud-storage/github/src/domain/service/sync/test.rs
@@ -202,6 +202,13 @@ impl DocumentService for StubDocumentService {
) -> Result<documents::domain::models::CreateTaskResponse, DocumentError> {
unimplemented!()
}
+
+ async fn get_document_comments(
+ &self,
+ _entity_access_receipt: EntityAccessReceipt<ViewAccessLevel>,
+ ) -> Result<Vec<documents::domain::models::CommentThread>, DocumentError> {
+ unimplemented!()
+ }
}
/// Stateful stub repo that tracks task IDs per github key.