Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(seed): channel message mentions (#1662)
Will Hutchinsond64bbb33a92b
diff --git a/rust/cloud-storage/.dockerignore b/rust/cloud-storage/.dockerignoreindex 46c4765b4f..4327bb1f44 100644--- a/rust/cloud-storage/.dockerignore+++ b/rust/cloud-storage/.dockerignore@@ -4,6 +4,7 @@# Docker.dockerignoreDockerfile*+.env*# Rusttarget/diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lockindex e6bf28e7a0..83030798ef 100644--- a/rust/cloud-storage/Cargo.lock+++ b/rust/cloud-storage/Cargo.lock@@ -2389,27 +2389,6 @@ dependencies = ["syn 2.0.98",]-[[package]]-name = "csv"-version = "1.4.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "52cd9d68cf7efc6ddfaaee42e7288d3a99d613d4b50f76ce9827ae0c6e14f938"-dependencies = [- "csv-core",- "itoa",- "ryu",- "serde_core",-]--[[package]]-name = "csv-core"-version = "0.1.13"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "704a3c26996a80471189265814dbc2c257598b96b8a7feae2d31ace646bb9782"-dependencies = [- "memchr",-]-[[package]]name = "curve25519-dalek"version = "4.1.3"@@ -8284,7 +8263,6 @@ dependencies = ["chrono","clap","comms_db_client",- "csv","email_db_client","fusionauth","futures",diff --git a/rust/cloud-storage/Dockerfile.dev b/rust/cloud-storage/Dockerfile.devindex 8b3f0ffcfc..c50e3540e8 100644--- a/rust/cloud-storage/Dockerfile.dev+++ b/rust/cloud-storage/Dockerfile.dev@@ -10,7 +10,7 @@ COPY . .RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=shared \--mount=type=cache,target=/usr/local/cargo/git/db,sharing=shared \--mount=type=cache,target=/app/target,id=rust-target-dev-debug,sharing=locked \- cargo build \+ cargo build -j 2 \--bin authentication_service \--bin connection_gateway_service \--bin contacts_service \diff --git a/rust/cloud-storage/Dockerfile.search_processing_service.dev b/rust/cloud-storage/Dockerfile.search_processing_service.devindex dc2f5473aa..1c7fe6bd16 100644--- a/rust/cloud-storage/Dockerfile.search_processing_service.dev+++ b/rust/cloud-storage/Dockerfile.search_processing_service.dev@@ -10,9 +10,8 @@ COPY . .RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=shared \--mount=type=cache,target=/usr/local/cargo/git/db,sharing=shared \--mount=type=cache,target=/app/target,id=rust-target-dev-release,sharing=locked \- cargo build --release --bin search_processing_service \- && cargo strip \- && cp /app/target/release/search_processing_service /app/svc+ cargo build --bin search_processing_service \+ && cp /app/target/debug/search_processing_service /app/svc# Runtime imageFROM debian:trixie-slim AS search_processing_servicediff --git a/rust/cloud-storage/seed_cli/Cargo.toml b/rust/cloud-storage/seed_cli/Cargo.tomlindex e2ec5204f3..5f5036388e 100644--- a/rust/cloud-storage/seed_cli/Cargo.toml+++ b/rust/cloud-storage/seed_cli/Cargo.toml@@ -21,7 +21,6 @@ fusionauth = { path = "../fusionauth" }mockall = { workspace = true }comms_db_client = { path = "../comms_db_client" }model = { path = "../model" }-csv = { workspace = true }uuid = { workspace = true }email_db_client = { path = "../email_db_client" }models_email = { path = "../models_email" }diff --git a/rust/cloud-storage/seed_cli/seed/channel_messages.csv b/rust/cloud-storage/seed_cli/seed/channel_messages.csvdeleted file mode 100644index f4cc25addc..0000000000--- a/rust/cloud-storage/seed_cli/seed/channel_messages.csv+++ /dev/null@@ -1,22 +0,0 @@-message_id,channel_id,sender_id,content,thread_id-00000000-0000-0000-0001-000000000001,00000000-0000-0000-0000-000000000001,macro|[email protected],Welcome to the general channel everyone!,-00000000-0000-0000-0001-000000000002,00000000-0000-0000-0000-000000000001,macro|[email protected],Thanks Bob! Glad to be here.,-00000000-0000-0000-0001-000000000003,00000000-0000-0000-0000-000000000001,macro|[email protected],Hey all - quick question about the onboarding doc?,-00000000-0000-0000-0001-000000000004,00000000-0000-0000-0000-000000000001,macro|[email protected],Sure thing - I can walk you through it.,00000000-0000-0000-0001-000000000003-00000000-0000-0000-0001-000000000005,00000000-0000-0000-0000-000000000002,macro|[email protected],Reminder: all-hands meeting tomorrow at 10am.,-00000000-0000-0000-0001-000000000006,00000000-0000-0000-0000-000000000002,macro|[email protected],Will there be a recording for those who can't attend?,00000000-0000-0000-0001-000000000005-00000000-0000-0000-0001-000000000007,00000000-0000-0000-0000-000000000003,macro|[email protected],Anyone tried that new coffee place on 5th?,-00000000-0000-0000-0001-000000000008,00000000-0000-0000-0000-000000000003,macro|[email protected],Yes! The cold brew is amazing.,00000000-0000-0000-0001-000000000007-00000000-0000-0000-0001-000000000009,00000000-0000-0000-0000-000000000003,macro|[email protected],Adding it to my list for this week.,00000000-0000-0000-0001-000000000007-00000000-0000-0000-0001-00000000000a,00000000-0000-0000-0000-000000000004,macro|[email protected],Q3 roadmap draft is ready for review.,-00000000-0000-0000-0001-00000000000b,00000000-0000-0000-0000-000000000004,macro|[email protected],Looks good - left a few comments on the doc.,00000000-0000-0000-0001-00000000000a-00000000-0000-0000-0001-00000000000c,00000000-0000-0000-0000-000000000005,macro|[email protected],Sprint retro notes have been uploaded.,-00000000-0000-0000-0001-00000000000d,00000000-0000-0000-0000-000000000005,macro|[email protected],Can we discuss the velocity drop next standup?,00000000-0000-0000-0001-00000000000c-00000000-0000-0000-0001-00000000000e,00000000-0000-0000-0000-000000000005,macro|[email protected],Agreed - I think the new estimation process might be a factor.,00000000-0000-0000-0001-00000000000c-00000000-0000-0000-0001-00000000000f,00000000-0000-0000-0000-000000000006,macro|[email protected],Should we move this conversation to a named channel?,-00000000-0000-0000-0001-000000000010,00000000-0000-0000-0000-000000000006,macro|[email protected],Good idea - let me set one up.,00000000-0000-0000-0001-00000000000f-00000000-0000-0000-0001-000000000011,00000000-0000-0000-0000-000000000007,macro|[email protected],Can you review my PR when you get a chance?,-00000000-0000-0000-0001-000000000012,00000000-0000-0000-0000-000000000007,macro|[email protected],On it - will have feedback by EOD.,00000000-0000-0000-0001-000000000011-00000000-0000-0000-0001-000000000013,00000000-0000-0000-0000-000000000008,macro|[email protected],Hey - are you free for a quick sync?,-00000000-0000-0000-0001-000000000014,00000000-0000-0000-0000-000000000009,macro|[email protected],Sent you the updated design files.,-00000000-0000-0000-0001-000000000015,00000000-0000-0000-0000-00000000000a,macro|[email protected],Thanks for the help earlier!,diff --git a/rust/cloud-storage/seed_cli/seed/channel_messages.json b/rust/cloud-storage/seed_cli/seed/channel_messages.jsonnew file mode 100644index 0000000000..b39b796874--- /dev/null+++ b/rust/cloud-storage/seed_cli/seed/channel_messages.json@@ -0,0 +1,176 @@+[+ {+ "message_id": "00000000-0000-0000-0001-000000000001",+ "channel_id": "00000000-0000-0000-0000-000000000001",+ "sender_id": "macro|[email protected]",+ "content": "Welcome to the general channel everyone!"+ },+ {+ "message_id": "00000000-0000-0000-0001-000000000002",+ "channel_id": "00000000-0000-0000-0000-000000000001",+ "sender_id": "macro|[email protected]",+ "content": "Thanks Bob! Glad to be here."+ },+ {+ "message_id": "00000000-0000-0000-0001-000000000003",+ "channel_id": "00000000-0000-0000-0000-000000000001",+ "sender_id": "macro|[email protected]",+ "content": "Hey all - quick question about <m-document-mention>{\"documentId\":\"00000000-0000-0000-0002-00000000000e\",\"blockName\":\"md\",\"documentName\":\"Onboarding Guide\",\"blockParams\":{},\"collapsed\":false}</m-document-mention> - is it up to date?",+ "entity_mentions": [+ { "entity_type": "document", "entity_id": "00000000-0000-0000-0002-00000000000e" }+ ]+ },+ {+ "message_id": "00000000-0000-0000-0001-000000000004",+ "channel_id": "00000000-0000-0000-0000-000000000001",+ "sender_id": "macro|[email protected]",+ "content": "Sure thing <m-user-mention>{\"userId\":\"macro|[email protected]\",\"email\":\"[email protected]\"}</m-user-mention> - I can walk you through it.",+ "thread_id": "00000000-0000-0000-0001-000000000003",+ "entity_mentions": [+ { "entity_type": "user", "entity_id": "macro|[email protected]" }+ ]+ },+ {+ "message_id": "00000000-0000-0000-0001-000000000005",+ "channel_id": "00000000-0000-0000-0000-000000000002",+ "sender_id": "macro|[email protected]",+ "content": "Reminder: all-hands meeting tomorrow at 10am. <m-user-mention>{\"userId\":\"macro|[email protected]\",\"email\":\"[email protected]\"}</m-user-mention> can you send out the agenda?",+ "entity_mentions": [+ { "entity_type": "user", "entity_id": "macro|[email protected]" }+ ]+ },+ {+ "message_id": "00000000-0000-0000-0001-000000000006",+ "channel_id": "00000000-0000-0000-0000-000000000002",+ "sender_id": "macro|[email protected]",+ "content": "Will there be a recording for those who can't attend?",+ "thread_id": "00000000-0000-0000-0001-000000000005"+ },+ {+ "message_id": "00000000-0000-0000-0001-000000000007",+ "channel_id": "00000000-0000-0000-0000-000000000003",+ "sender_id": "macro|[email protected]",+ "content": "Anyone tried that new coffee place on 5th?"+ },+ {+ "message_id": "00000000-0000-0000-0001-000000000008",+ "channel_id": "00000000-0000-0000-0000-000000000003",+ "sender_id": "macro|[email protected]",+ "content": "Yes! The cold brew is amazing.",+ "thread_id": "00000000-0000-0000-0001-000000000007"+ },+ {+ "message_id": "00000000-0000-0000-0001-000000000009",+ "channel_id": "00000000-0000-0000-0000-000000000003",+ "sender_id": "macro|[email protected]",+ "content": "Adding it to my list for this week.",+ "thread_id": "00000000-0000-0000-0001-000000000007"+ },+ {+ "message_id": "00000000-0000-0000-0001-00000000000a",+ "channel_id": "00000000-0000-0000-0000-000000000004",+ "sender_id": "macro|[email protected]",+ "content": "<m-document-mention>{\"documentId\":\"00000000-0000-0000-0002-000000000001\",\"blockName\":\"pdf\",\"documentName\":\"Project Roadmap\",\"blockParams\":{},\"collapsed\":false}</m-document-mention> draft is ready for review. <m-user-mention>{\"userId\":\"macro|[email protected]\",\"email\":\"[email protected]\"}</m-user-mention> take a look when you get a chance.",+ "entity_mentions": [+ { "entity_type": "document", "entity_id": "00000000-0000-0000-0002-000000000001" },+ { "entity_type": "user", "entity_id": "macro|[email protected]" }+ ]+ },+ {+ "message_id": "00000000-0000-0000-0001-00000000000b",+ "channel_id": "00000000-0000-0000-0000-000000000004",+ "sender_id": "macro|[email protected]",+ "content": "Looks good - left a few comments on <m-document-mention>{\"documentId\":\"00000000-0000-0000-0002-000000000010\",\"blockName\":\"pdf\",\"documentName\":\"Product Requirements\",\"blockParams\":{},\"collapsed\":false}</m-document-mention>.",+ "thread_id": "00000000-0000-0000-0001-00000000000a",+ "entity_mentions": [+ { "entity_type": "document", "entity_id": "00000000-0000-0000-0002-000000000010" }+ ]+ },+ {+ "message_id": "00000000-0000-0000-0001-00000000000c",+ "channel_id": "00000000-0000-0000-0000-000000000005",+ "sender_id": "macro|[email protected]",+ "content": "<m-document-mention>{\"documentId\":\"00000000-0000-0000-0002-000000000005\",\"blockName\":\"md\",\"documentName\":\"Sprint Retro Notes\",\"blockParams\":{},\"collapsed\":false}</m-document-mention> have been uploaded.",+ "entity_mentions": [+ { "entity_type": "document", "entity_id": "00000000-0000-0000-0002-000000000005" }+ ]+ },+ {+ "message_id": "00000000-0000-0000-0001-00000000000d",+ "channel_id": "00000000-0000-0000-0000-000000000005",+ "sender_id": "macro|[email protected]",+ "content": "<m-user-mention>{\"userId\":\"macro|[email protected]\",\"email\":\"[email protected]\"}</m-user-mention> can we discuss the velocity drop next standup?",+ "thread_id": "00000000-0000-0000-0001-00000000000c",+ "entity_mentions": [+ { "entity_type": "user", "entity_id": "macro|[email protected]" }+ ]+ },+ {+ "message_id": "00000000-0000-0000-0001-00000000000e",+ "channel_id": "00000000-0000-0000-0000-000000000005",+ "sender_id": "macro|[email protected]",+ "content": "Agreed - I think the new estimation process might be a factor. I documented it in <m-document-mention>{\"documentId\":\"00000000-0000-0000-0002-000000000014\",\"blockName\":\"md\",\"documentName\":\"Incident Postmortem\",\"blockParams\":{},\"collapsed\":false}</m-document-mention>.",+ "thread_id": "00000000-0000-0000-0001-00000000000c",+ "entity_mentions": [+ { "entity_type": "document", "entity_id": "00000000-0000-0000-0002-000000000014" }+ ]+ },+ {+ "message_id": "00000000-0000-0000-0001-00000000000f",+ "channel_id": "00000000-0000-0000-0000-000000000006",+ "sender_id": "macro|[email protected]",+ "content": "Should we move this conversation to a named channel? <m-user-mention>{\"userId\":\"macro|[email protected]\",\"email\":\"[email protected]\"}</m-user-mention> <m-user-mention>{\"userId\":\"macro|[email protected]\",\"email\":\"[email protected]\"}</m-user-mention> thoughts?",+ "entity_mentions": [+ { "entity_type": "user", "entity_id": "macro|[email protected]" },+ { "entity_type": "user", "entity_id": "macro|[email protected]" }+ ]+ },+ {+ "message_id": "00000000-0000-0000-0001-000000000010",+ "channel_id": "00000000-0000-0000-0000-000000000006",+ "sender_id": "macro|[email protected]",+ "content": "Good idea - let me set one up.",+ "thread_id": "00000000-0000-0000-0001-00000000000f"+ },+ {+ "message_id": "00000000-0000-0000-0001-000000000011",+ "channel_id": "00000000-0000-0000-0000-000000000007",+ "sender_id": "macro|[email protected]",+ "content": "<m-user-mention>{\"userId\":\"macro|[email protected]\",\"email\":\"[email protected]\"}</m-user-mention> can you review my PR when you get a chance? It touches <m-document-mention>{\"documentId\":\"00000000-0000-0000-0002-000000000008\",\"blockName\":\"md\",\"documentName\":\"API Documentation\",\"blockParams\":{},\"collapsed\":false}</m-document-mention>.",+ "entity_mentions": [+ { "entity_type": "user", "entity_id": "macro|[email protected]" },+ { "entity_type": "document", "entity_id": "00000000-0000-0000-0002-000000000008" }+ ]+ },+ {+ "message_id": "00000000-0000-0000-0001-000000000012",+ "channel_id": "00000000-0000-0000-0000-000000000007",+ "sender_id": "macro|[email protected]",+ "content": "On it <m-user-mention>{\"userId\":\"macro|[email protected]\",\"email\":\"[email protected]\"}</m-user-mention> - will have feedback by EOD.",+ "thread_id": "00000000-0000-0000-0001-000000000011",+ "entity_mentions": [+ { "entity_type": "user", "entity_id": "macro|[email protected]" }+ ]+ },+ {+ "message_id": "00000000-0000-0000-0001-000000000013",+ "channel_id": "00000000-0000-0000-0000-000000000008",+ "sender_id": "macro|[email protected]",+ "content": "Hey - are you free for a quick sync?"+ },+ {+ "message_id": "00000000-0000-0000-0001-000000000014",+ "channel_id": "00000000-0000-0000-0000-000000000009",+ "sender_id": "macro|[email protected]",+ "content": "Sent you the updated <m-document-mention>{\"documentId\":\"00000000-0000-0000-0002-000000000009\",\"blockName\":\"canvas\",\"documentName\":\"Wireframe Draft\",\"blockParams\":{},\"collapsed\":false}</m-document-mention>.",+ "entity_mentions": [+ { "entity_type": "document", "entity_id": "00000000-0000-0000-0002-000000000009" }+ ]+ },+ {+ "message_id": "00000000-0000-0000-0001-000000000015",+ "channel_id": "00000000-0000-0000-0000-00000000000a",+ "sender_id": "macro|[email protected]",+ "content": "Thanks for the help earlier!"+ }+]diff --git a/rust/cloud-storage/seed_cli/seed/channels.csv b/rust/cloud-storage/seed_cli/seed/channels.csvdeleted file mode 100644index 709708b7ce..0000000000--- a/rust/cloud-storage/seed_cli/seed/channels.csv+++ /dev/null@@ -1,11 +0,0 @@-channel_id,channel_name,channel_type,participants-00000000-0000-0000-0000-000000000001,general,public,macro|[email protected];macro|[email protected];macro|[email protected]-00000000-0000-0000-0000-000000000002,announcements,public,macro|[email protected];macro|[email protected]-00000000-0000-0000-0000-000000000003,random,public,macro|[email protected];macro|[email protected];macro|[email protected]-00000000-0000-0000-0000-000000000004,leadership,private,macro|[email protected];macro|[email protected]-00000000-0000-0000-0000-000000000005,project-alpha,private,macro|[email protected];macro|[email protected];macro|[email protected]-00000000-0000-0000-0000-000000000006,,private,macro|[email protected];macro|[email protected];macro|[email protected]-00000000-0000-0000-0000-000000000007,,private,macro|[email protected];macro|[email protected]-00000000-0000-0000-0000-000000000008,,direct_message,macro|[email protected]-00000000-0000-0000-0000-000000000009,,direct_message,macro|[email protected]-00000000-0000-0000-0000-00000000000a,,direct_message,macro|[email protected]diff --git a/rust/cloud-storage/seed_cli/seed/channels.json b/rust/cloud-storage/seed_cli/seed/channels.jsonnew file mode 100644index 0000000000..5095e4fad5--- /dev/null+++ b/rust/cloud-storage/seed_cli/seed/channels.json@@ -0,0 +1,88 @@+[+ {+ "channel_id": "00000000-0000-0000-0000-000000000001",+ "channel_name": "general",+ "channel_type": "public",+ "participants": [+ "macro|[email protected]",+ "macro|[email protected]",+ "macro|[email protected]"+ ]+ },+ {+ "channel_id": "00000000-0000-0000-0000-000000000002",+ "channel_name": "announcements",+ "channel_type": "public",+ "participants": [+ "macro|[email protected]",+ "macro|[email protected]"+ ]+ },+ {+ "channel_id": "00000000-0000-0000-0000-000000000003",+ "channel_name": "random",+ "channel_type": "public",+ "participants": [+ "macro|[email protected]",+ "macro|[email protected]",+ "macro|[email protected]"+ ]+ },+ {+ "channel_id": "00000000-0000-0000-0000-000000000004",+ "channel_name": "leadership",+ "channel_type": "private",+ "participants": [+ "macro|[email protected]",+ "macro|[email protected]"+ ]+ },+ {+ "channel_id": "00000000-0000-0000-0000-000000000005",+ "channel_name": "project-alpha",+ "channel_type": "private",+ "participants": [+ "macro|[email protected]",+ "macro|[email protected]",+ "macro|[email protected]"+ ]+ },+ {+ "channel_id": "00000000-0000-0000-0000-000000000006",+ "channel_type": "private",+ "participants": [+ "macro|[email protected]",+ "macro|[email protected]",+ "macro|[email protected]"+ ]+ },+ {+ "channel_id": "00000000-0000-0000-0000-000000000007",+ "channel_type": "private",+ "participants": [+ "macro|[email protected]",+ "macro|[email protected]"+ ]+ },+ {+ "channel_id": "00000000-0000-0000-0000-000000000008",+ "channel_type": "direct_message",+ "participants": [+ "macro|[email protected]"+ ]+ },+ {+ "channel_id": "00000000-0000-0000-0000-000000000009",+ "channel_type": "direct_message",+ "participants": [+ "macro|[email protected]"+ ]+ },+ {+ "channel_id": "00000000-0000-0000-0000-00000000000a",+ "channel_type": "direct_message",+ "participants": [+ "macro|[email protected]"+ ]+ }+]diff --git a/rust/cloud-storage/seed_cli/seed/documents/documents.csv b/rust/cloud-storage/seed_cli/seed/documents/documents.csvdeleted file mode 100644index 8772770a18..0000000000--- a/rust/cloud-storage/seed_cli/seed/documents/documents.csv+++ /dev/null@@ -1,101 +0,0 @@-document_id,document_name,file_name,is_public-00000000-0000-0000-0002-000000000001,Project Roadmap,pdf.pdf,false-00000000-0000-0000-0002-000000000002,Meeting Notes,md.md,false-00000000-0000-0000-0002-000000000003,Architecture Diagram,canvas.canvas,false-00000000-0000-0000-0002-000000000004,Q3 Budget Report,pdf.pdf,true-00000000-0000-0000-0002-000000000005,Sprint Retro Notes,md.md,false-00000000-0000-0000-0002-000000000006,System Design,canvas.canvas,false-00000000-0000-0000-0002-000000000007,Employee Handbook,pdf.pdf,true-00000000-0000-0000-0002-000000000008,API Documentation,md.md,false-00000000-0000-0000-0002-000000000009,Wireframe Draft,canvas.canvas,false-00000000-0000-0000-0002-00000000000a,Sales Pitch Deck,pdf.pdf,false-00000000-0000-0000-0002-00000000000b,Release Checklist,md.md,false-00000000-0000-0000-0002-00000000000c,User Flow Diagram,canvas.canvas,false-00000000-0000-0000-0002-00000000000d,Annual Report,pdf.pdf,true-00000000-0000-0000-0002-00000000000e,Onboarding Guide,md.md,true-00000000-0000-0000-0002-00000000000f,Network Topology,canvas.canvas,false-00000000-0000-0000-0002-000000000010,Product Requirements,pdf.pdf,false-00000000-0000-0000-0002-000000000011,Dev Setup Guide,md.md,false-00000000-0000-0000-0002-000000000012,ER Diagram,canvas.canvas,false-00000000-0000-0000-0002-000000000013,Marketing Plan,pdf.pdf,false-00000000-0000-0000-0002-000000000014,Incident Postmortem,md.md,false-00000000-0000-0000-0002-000000000015,Component Layout,canvas.canvas,false-00000000-0000-0000-0002-000000000016,Security Audit,pdf.pdf,false-00000000-0000-0000-0002-000000000017,Changelog,md.md,true-00000000-0000-0000-0002-000000000018,Data Flow Sketch,canvas.canvas,false-00000000-0000-0000-0002-000000000019,Contract Template,pdf.pdf,false-00000000-0000-0000-0002-00000000001a,Team Standup Notes,md.md,false-00000000-0000-0000-0002-00000000001b,Infrastructure Map,canvas.canvas,false-00000000-0000-0000-0002-00000000001c,Compliance Report,pdf.pdf,true-00000000-0000-0000-0002-00000000001d,Migration Plan,md.md,false-00000000-0000-0000-0002-00000000001e,Sequence Diagram,canvas.canvas,false-00000000-0000-0000-0002-00000000001f,Vendor Proposal,pdf.pdf,false-00000000-0000-0000-0002-000000000020,Troubleshooting Guide,md.md,false-00000000-0000-0000-0002-000000000021,Deployment Pipeline,canvas.canvas,false-00000000-0000-0000-0002-000000000022,Board Presentation,pdf.pdf,false-00000000-0000-0000-0002-000000000023,Feature Spec,md.md,false-00000000-0000-0000-0002-000000000024,Brainstorm Session,canvas.canvas,false-00000000-0000-0000-0002-000000000025,Investor Update,pdf.pdf,false-00000000-0000-0000-0002-000000000026,Code Review Checklist,md.md,false-00000000-0000-0000-0002-000000000027,Service Architecture,canvas.canvas,false-00000000-0000-0000-0002-000000000028,Performance Report,pdf.pdf,false-00000000-0000-0000-0002-000000000029,Testing Strategy,md.md,false-00000000-0000-0000-0002-00000000002a,Page Layout,canvas.canvas,false-00000000-0000-0000-0002-00000000002b,NDA Template,pdf.pdf,false-00000000-0000-0000-0002-00000000002c,Decision Log,md.md,false-00000000-0000-0000-0002-00000000002d,Mind Map,canvas.canvas,false-00000000-0000-0000-0002-00000000002e,Tax Filing,pdf.pdf,false-00000000-0000-0000-0002-00000000002f,Knowledge Base Entry,md.md,true-00000000-0000-0000-0002-000000000030,Org Chart,canvas.canvas,false-00000000-0000-0000-0002-000000000031,Training Material,pdf.pdf,true-00000000-0000-0000-0002-000000000032,Bug Report Template,md.md,false-00000000-0000-0000-0002-000000000033,Concept Sketch,canvas.canvas,false-00000000-0000-0000-0002-000000000034,Legal Review,pdf.pdf,false-00000000-0000-0000-0002-000000000035,Architecture Decision Record,md.md,false-00000000-0000-0000-0002-000000000036,Dashboard Mockup,canvas.canvas,false-00000000-0000-0000-0002-000000000037,SLA Agreement,pdf.pdf,false-00000000-0000-0000-0002-000000000038,Runbook,md.md,false-00000000-0000-0000-0002-000000000039,Workflow Diagram,canvas.canvas,false-00000000-0000-0000-0002-00000000003a,Research Paper,pdf.pdf,false-00000000-0000-0000-0002-00000000003b,RFC Draft,md.md,false-00000000-0000-0000-0002-00000000003c,Sitemap,canvas.canvas,false-00000000-0000-0000-0002-00000000003d,Expense Report,pdf.pdf,false-00000000-0000-0000-0002-00000000003e,Project Retrospective,md.md,false-00000000-0000-0000-0002-00000000003f,State Machine,canvas.canvas,false-00000000-0000-0000-0002-000000000040,Insurance Policy,pdf.pdf,false-00000000-0000-0000-0002-000000000041,Style Guide,md.md,true-00000000-0000-0000-0002-000000000042,UI Prototype,canvas.canvas,false-00000000-0000-0000-0002-000000000043,Partnership Agreement,pdf.pdf,false-00000000-0000-0000-0002-000000000044,API Changelog,md.md,false-00000000-0000-0000-0002-000000000045,Database Schema,canvas.canvas,false-00000000-0000-0000-0002-000000000046,Quarterly Review,pdf.pdf,false-00000000-0000-0000-0002-000000000047,Configuration Guide,md.md,false-00000000-0000-0000-0002-000000000048,Gantt Chart,canvas.canvas,false-00000000-0000-0000-0002-000000000049,Warranty Document,pdf.pdf,false-00000000-0000-0000-0002-00000000004a,Deployment Notes,md.md,false-00000000-0000-0000-0002-00000000004b,Class Diagram,canvas.canvas,false-00000000-0000-0000-0002-00000000004c,Customer Feedback Summary,pdf.pdf,false-00000000-0000-0000-0002-00000000004d,Contributing Guidelines,md.md,true-00000000-0000-0000-0002-00000000004e,Login Flow,canvas.canvas,false-00000000-0000-0000-0002-00000000004f,Brand Guidelines,pdf.pdf,false-00000000-0000-0000-0002-000000000050,Monitoring Setup,md.md,false-00000000-0000-0000-0002-000000000051,Payment Flow,canvas.canvas,false-00000000-0000-0000-0002-000000000052,Privacy Policy,pdf.pdf,true-00000000-0000-0000-0002-000000000053,Environment Variables,md.md,false-00000000-0000-0000-0002-000000000054,Notification Flow,canvas.canvas,false-00000000-0000-0000-0002-000000000055,Terms of Service,pdf.pdf,true-00000000-0000-0000-0002-000000000056,Dependency Audit,md.md,false-00000000-0000-0000-0002-000000000057,Search Architecture,canvas.canvas,false-00000000-0000-0000-0002-000000000058,Invoice Template,pdf.pdf,false-00000000-0000-0000-0002-000000000059,Capacity Planning,md.md,false-00000000-0000-0000-0002-00000000005a,Auth Flow,canvas.canvas,false-00000000-0000-0000-0002-00000000005b,Compliance Checklist,pdf.pdf,false-00000000-0000-0000-0002-00000000005c,Load Test Results,md.md,false-00000000-0000-0000-0002-00000000005d,Microservices Map,canvas.canvas,false-00000000-0000-0000-0002-00000000005e,Risk Assessment,pdf.pdf,false-00000000-0000-0000-0002-00000000005f,Disaster Recovery Plan,md.md,false-00000000-0000-0000-0002-000000000060,CI Pipeline,canvas.canvas,false-00000000-0000-0000-0002-000000000061,Shipping Label,pdf.pdf,false-00000000-0000-0000-0002-000000000062,Benchmarks,md.md,false-00000000-0000-0000-0002-000000000063,Feature Flag Matrix,canvas.canvas,false-00000000-0000-0000-0002-000000000064,Certificate,pdf.pdf,falsediff --git a/rust/cloud-storage/seed_cli/seed/documents/documents.json b/rust/cloud-storage/seed_cli/seed/documents/documents.jsonnew file mode 100644index 0000000000..856e07b25e--- /dev/null+++ b/rust/cloud-storage/seed_cli/seed/documents/documents.json@@ -0,0 +1,102 @@+[+ { "document_id": "00000000-0000-0000-0002-000000000001", "document_name": "Project Roadmap", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000002", "document_name": "Meeting Notes", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000003", "document_name": "Architecture Diagram", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000004", "document_name": "Q3 Budget Report", "file_name": "pdf.pdf", "is_public": true },+ { "document_id": "00000000-0000-0000-0002-000000000005", "document_name": "Sprint Retro Notes", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000006", "document_name": "System Design", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000007", "document_name": "Employee Handbook", "file_name": "pdf.pdf", "is_public": true },+ { "document_id": "00000000-0000-0000-0002-000000000008", "document_name": "API Documentation", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000009", "document_name": "Wireframe Draft", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000000a", "document_name": "Sales Pitch Deck", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000000b", "document_name": "Release Checklist", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000000c", "document_name": "User Flow Diagram", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000000d", "document_name": "Annual Report", "file_name": "pdf.pdf", "is_public": true },+ { "document_id": "00000000-0000-0000-0002-00000000000e", "document_name": "Onboarding Guide", "file_name": "md.md", "is_public": true },+ { "document_id": "00000000-0000-0000-0002-00000000000f", "document_name": "Network Topology", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000010", "document_name": "Product Requirements", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000011", "document_name": "Dev Setup Guide", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000012", "document_name": "ER Diagram", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000013", "document_name": "Marketing Plan", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000014", "document_name": "Incident Postmortem", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000015", "document_name": "Component Layout", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000016", "document_name": "Security Audit", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000017", "document_name": "Changelog", "file_name": "md.md", "is_public": true },+ { "document_id": "00000000-0000-0000-0002-000000000018", "document_name": "Data Flow Sketch", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000019", "document_name": "Contract Template", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000001a", "document_name": "Team Standup Notes", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000001b", "document_name": "Infrastructure Map", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000001c", "document_name": "Compliance Report", "file_name": "pdf.pdf", "is_public": true },+ { "document_id": "00000000-0000-0000-0002-00000000001d", "document_name": "Migration Plan", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000001e", "document_name": "Sequence Diagram", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000001f", "document_name": "Vendor Proposal", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000020", "document_name": "Troubleshooting Guide", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000021", "document_name": "Deployment Pipeline", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000022", "document_name": "Board Presentation", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000023", "document_name": "Feature Spec", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000024", "document_name": "Brainstorm Session", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000025", "document_name": "Investor Update", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000026", "document_name": "Code Review Checklist", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000027", "document_name": "Service Architecture", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000028", "document_name": "Performance Report", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000029", "document_name": "Testing Strategy", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000002a", "document_name": "Page Layout", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000002b", "document_name": "NDA Template", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000002c", "document_name": "Decision Log", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000002d", "document_name": "Mind Map", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000002e", "document_name": "Tax Filing", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000002f", "document_name": "Knowledge Base Entry", "file_name": "md.md", "is_public": true },+ { "document_id": "00000000-0000-0000-0002-000000000030", "document_name": "Org Chart", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000031", "document_name": "Training Material", "file_name": "pdf.pdf", "is_public": true },+ { "document_id": "00000000-0000-0000-0002-000000000032", "document_name": "Bug Report Template", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000033", "document_name": "Concept Sketch", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000034", "document_name": "Legal Review", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000035", "document_name": "Architecture Decision Record", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000036", "document_name": "Dashboard Mockup", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000037", "document_name": "SLA Agreement", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000038", "document_name": "Runbook", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000039", "document_name": "Workflow Diagram", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000003a", "document_name": "Research Paper", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000003b", "document_name": "RFC Draft", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000003c", "document_name": "Sitemap", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000003d", "document_name": "Expense Report", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000003e", "document_name": "Project Retrospective", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000003f", "document_name": "State Machine", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000040", "document_name": "Insurance Policy", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000041", "document_name": "Style Guide", "file_name": "md.md", "is_public": true },+ { "document_id": "00000000-0000-0000-0002-000000000042", "document_name": "UI Prototype", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000043", "document_name": "Partnership Agreement", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000044", "document_name": "API Changelog", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000045", "document_name": "Database Schema", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000046", "document_name": "Quarterly Review", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000047", "document_name": "Configuration Guide", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000048", "document_name": "Gantt Chart", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000049", "document_name": "Warranty Document", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000004a", "document_name": "Deployment Notes", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000004b", "document_name": "Class Diagram", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000004c", "document_name": "Customer Feedback Summary", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000004d", "document_name": "Contributing Guidelines", "file_name": "md.md", "is_public": true },+ { "document_id": "00000000-0000-0000-0002-00000000004e", "document_name": "Login Flow", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000004f", "document_name": "Brand Guidelines", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000050", "document_name": "Monitoring Setup", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000051", "document_name": "Payment Flow", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000052", "document_name": "Privacy Policy", "file_name": "pdf.pdf", "is_public": true },+ { "document_id": "00000000-0000-0000-0002-000000000053", "document_name": "Environment Variables", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000054", "document_name": "Notification Flow", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000055", "document_name": "Terms of Service", "file_name": "pdf.pdf", "is_public": true },+ { "document_id": "00000000-0000-0000-0002-000000000056", "document_name": "Dependency Audit", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000057", "document_name": "Search Architecture", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000058", "document_name": "Invoice Template", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000059", "document_name": "Capacity Planning", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000005a", "document_name": "Auth Flow", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000005b", "document_name": "Compliance Checklist", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000005c", "document_name": "Load Test Results", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000005d", "document_name": "Microservices Map", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000005e", "document_name": "Risk Assessment", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-00000000005f", "document_name": "Disaster Recovery Plan", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000060", "document_name": "CI Pipeline", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000061", "document_name": "Shipping Label", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000062", "document_name": "Benchmarks", "file_name": "md.md", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000063", "document_name": "Feature Flag Matrix", "file_name": "canvas.canvas", "is_public": false },+ { "document_id": "00000000-0000-0000-0002-000000000064", "document_name": "Certificate", "file_name": "pdf.pdf", "is_public": false }+]diff --git a/rust/cloud-storage/seed_cli/src/entity/channel/mod.rs b/rust/cloud-storage/seed_cli/src/entity/channel/mod.rsindex 1f475a16e4..7b5bcbd008 100644--- a/rust/cloud-storage/seed_cli/src/entity/channel/mod.rs+++ b/rust/cloud-storage/seed_cli/src/entity/channel/mod.rs@@ -28,31 +28,32 @@ pub struct ChannelArgs {pub enum ChannelCommand {/// Create a single channelCreate(CreateArgs),- /// Bulk create multiple channels- BulkCreate(BulkCreateArgs),- /// Seed channels from a fixed CSV file with pre-defined UUIDs+ /// Seed channels from a fixed JSON file with pre-defined UUIDsSeed(SeedArgs),}-/// Arguments for seeding channels from a fixed CSV file.+/// Arguments for seeding channels from a JSON file.#[derive(Debug, Args)]pub struct SeedArgs {/// The user ID to set as channel owner and append to participants#[arg(long)]pub user_id: String,+ /// Path to the JSON file containing channels to seed (defaults to seed/channels.json)+ #[arg(long)]+ pub file_path: Option<String>,}-/// A row in the seed CSV file.+/// A row in the seed JSON file.#[derive(Debug, Deserialize)]-struct CsvSeedChannelRow {+struct SeedChannelRow {/// Pre-defined channel UUID.channel_id: Uuid,/// Channel name (optional).channel_name: Option<String>,/// Channel type.channel_type: ChannelType,- /// Semicolon-separated list of participant user IDs.- #[serde(default, deserialize_with = "deserialize_semicolon_list")]+ /// List of participant user IDs.+ #[serde(default)]participants: Vec<String>,}@@ -100,47 +101,11 @@ pub struct CreateArgs {pub org_id: Option<i64>,}-/// Arguments for bulk creating channels.-#[derive(Debug, Args)]-pub struct BulkCreateArgs {- /// Path to the CSV file containing channels to create- #[arg(long)]- pub file_path: String,-}--/// A row in the bulk-create CSV file.-#[derive(Debug, Deserialize)]-struct CsvChannelRow {- /// Channel name (optional)- name: Option<String>,- /// User ID of the channel owner- owner_id: String,- /// Channel type- channel_type: ChannelType,- /// Organization ID (optional)- org_id: Option<i64>,- /// Semicolon-separated list of participant user IDs- #[serde(default, deserialize_with = "deserialize_semicolon_list")]- participants: Vec<String>,-}--fn deserialize_semicolon_list<'de, D>(deserializer: D) -> Result<Vec<String>, D::Error>-where- D: serde::Deserializer<'de>,-{- let s = String::deserialize(deserializer)?;- if s.is_empty() {- return Ok(Vec::new());- }- Ok(s.split(';').map(|s| s.trim().to_string()).collect())-}-impl ChannelArgs {/// Execute the channel command.pub async fn execute(self, ctx: SeedCliContext) -> anyhow::Result<()> {match self.command {ChannelCommand::Create(args) => create(args, ctx).await,- ChannelCommand::BulkCreate(args) => bulk_create(args, ctx).await,ChannelCommand::Seed(args) => seed(args, ctx).await,}}@@ -164,79 +129,28 @@ async fn create(args: CreateArgs, ctx: SeedCliContext) -> anyhow::Result<()> {Ok(())}-#[tracing::instrument(skip(ctx), err)]-async fn bulk_create(args: BulkCreateArgs, ctx: SeedCliContext) -> anyhow::Result<()> {- tracing::info!("bulk creating channels");-- let content = std::fs::read_to_string(Path::new(&args.file_path))- .with_context(|| format!("failed to read csv file: {}", args.file_path))?;-- let mut reader = csv::Reader::from_reader(content.as_bytes());- let rows: Vec<CsvChannelRow> = reader- .deserialize()- .collect::<Result<Vec<_>, _>>()- .context("failed to parse csv")?;-- if rows.is_empty() {- anyhow::bail!("no channels found in csv file");- }-- println!("Found {} channels to create", rows.len());-- let mut created = 0;- let mut failed = 0;-- for row in rows {- let channel_label = row- .name- .as_deref()- .map_or_else(|| format!("{:?}", row.channel_type), str::to_string);-- let options = CreateChannelOptions {- name: row.name,- owner_id: row.owner_id,- channel_type: row.channel_type,- org_id: row.org_id,- participants: row.participants,- };-- match ctx.db.create_channel(options).await {- Ok(channel_id) => {- println!("Created channel {channel_label} with id {channel_id}");- created += 1;- }- Err(e) => {- tracing::error!(error=?e, channel = channel_label, "failed to create channel");- println!("Failed to create channel {channel_label}: {e}");- failed += 1;- }- }- }-- println!("\nBulk create complete: {created} created, {failed} failed");-- Ok(())-}-#[tracing::instrument(skip(ctx), err)]async fn seed(args: SeedArgs, ctx: SeedCliContext) -> anyhow::Result<()> {- seed_from_file(args, ctx, Path::new("seed/channels.csv")).await+ let default_path = Path::new("seed/channels.json").to_path_buf();+ let path = args+ .file_path+ .as_deref()+ .map(std::path::PathBuf::from)+ .unwrap_or(default_path);+ seed_from_file(args, ctx, &path).await}async fn seed_from_file(args: SeedArgs, ctx: SeedCliContext, path: &Path) -> anyhow::Result<()> {tracing::info!("seeding channels");let content = std::fs::read_to_string(path)- .with_context(|| format!("failed to read csv file: {}", path.display()))?;+ .with_context(|| format!("failed to read json file: {}", path.display()))?;- let mut reader = csv::Reader::from_reader(content.as_bytes());- let rows: Vec<CsvSeedChannelRow> = reader- .deserialize()- .collect::<Result<Vec<_>, _>>()- .context("failed to parse csv")?;+ let rows: Vec<SeedChannelRow> =+ serde_json::from_str(&content).context("failed to parse json")?;if rows.is_empty() {- anyhow::bail!("no channels found in csv file");+ anyhow::bail!("no channels found in json file");}println!("Found {} channels to seed", rows.len());diff --git a/rust/cloud-storage/seed_cli/src/entity/channel/test.rs b/rust/cloud-storage/seed_cli/src/entity/channel/test.rsindex 74b87147bf..fe13a26858 100644--- a/rust/cloud-storage/seed_cli/src/entity/channel/test.rs+++ b/rust/cloud-storage/seed_cli/src/entity/channel/test.rs@@ -134,28 +134,6 @@ fn parse_channel_create_invalid_type_fails() {assert!(result.is_err());}-#[test]-fn parse_channel_bulk_create() {- let cli = Cli::try_parse_from([- "seed_cli",- "channel",- "bulk-create",- "--file-path",- "test.csv",- ])- .unwrap();-- match cli.command {- crate::entity::EntityCommand::Channel(args) => match args.command {- ChannelCommand::BulkCreate(bulk) => {- assert_eq!(bulk.file_path, "test.csv");- }- other => panic!("expected BulkCreate, got {other:?}"),- },- other => panic!("expected Channel, got {other:?}"),- }-}-#[test]fn parse_channel_seed() {let cli = Cli::try_parse_from([@@ -194,7 +172,7 @@ fn mock_ctx(db: Db) -> SeedCliContext {}}-fn write_temp_csv(content: &str) -> NamedTempFile {+fn write_temp_json(content: &str) -> NamedTempFile {let mut file = NamedTempFile::new().unwrap();file.write_all(content.as_bytes()).unwrap();file.flush().unwrap();@@ -276,154 +254,27 @@ async fn create_channel_db_failure_propagates_error() {assert!(err.to_string().contains("db connection failed"));}-// ── Bulk CSV tests ────────────────────────────────────────--#[tokio::test]-async fn bulk_create_creates_all_channels() {- let csv = "\-name,owner_id,channel_type,org_id,participants-,macro|[email protected],direct_message,,macro|[email protected]-";- let file = write_temp_csv(csv);-- let mut mock_db = Db::default();- mock_db- .expect_create_channel()- .times(2)- .returning(|_| Ok(uuid::Uuid::nil()));-- let args = ChannelArgs {- command: ChannelCommand::BulkCreate(BulkCreateArgs {- file_path: file.path().to_str().unwrap().to_string(),- }),- };-- let result = args.execute(mock_ctx(mock_db)).await;- assert!(result.is_ok());-}--#[tokio::test]-async fn bulk_create_with_optional_fields() {- let csv = "\-name,owner_id,channel_type,org_id,participants-team-chat,macro|[email protected],organization,42,macro|[email protected]-";- let file = write_temp_csv(csv);-- let mut mock_db = Db::default();- mock_db- .expect_create_channel()- .times(1)- .withf(|opts| {- opts.name.as_deref() == Some("team-chat")- && opts.channel_type == ChannelType::Organization- && opts.org_id == Some(42)- && opts.participants == vec!["macro|[email protected]"]- })- .returning(|_| Ok(uuid::Uuid::nil()));-- let args = ChannelArgs {- command: ChannelCommand::BulkCreate(BulkCreateArgs {- file_path: file.path().to_str().unwrap().to_string(),- }),- };-- let result = args.execute(mock_ctx(mock_db)).await;- assert!(result.is_ok());-}--#[tokio::test]-async fn bulk_create_empty_file_fails() {- let csv = "name,owner_id,channel_type,org_id,participants\n";- let file = write_temp_csv(csv);-- let mock_db = Db::default();-- let args = ChannelArgs {- command: ChannelCommand::BulkCreate(BulkCreateArgs {- file_path: file.path().to_str().unwrap().to_string(),- }),- };-- let result = args.execute(mock_ctx(mock_db)).await;- let err = result.unwrap_err();- assert!(err.to_string().contains("no channels found"));-}--#[tokio::test]-async fn bulk_create_missing_file_fails() {- let mock_db = Db::default();-- let args = ChannelArgs {- command: ChannelCommand::BulkCreate(BulkCreateArgs {- file_path: "/nonexistent/path.csv".to_string(),- }),- };-- let result = args.execute(mock_ctx(mock_db)).await;- let err = result.unwrap_err();- assert!(err.to_string().contains("failed to read csv file"));-}--#[tokio::test]-async fn bulk_create_continues_on_failure() {- let csv = "\-name,owner_id,channel_type,org_id,participants-good-1,macro|[email protected],public,,-bad,macro|[email protected],public,,-good-2,macro|[email protected],private,,-";- let file = write_temp_csv(csv);-- let mut mock_db = Db::default();- mock_db.expect_create_channel().times(3).returning(|opts| {- if opts.owner_id == "macro|[email protected]" {- Err(anyhow::anyhow!("db error"))- } else {- Ok(uuid::Uuid::nil())- }- });-- let args = ChannelArgs {- command: ChannelCommand::BulkCreate(BulkCreateArgs {- file_path: file.path().to_str().unwrap().to_string(),- }),- };-- let result = args.execute(mock_ctx(mock_db)).await;- assert!(result.is_ok());-}--#[tokio::test]-async fn bulk_create_invalid_csv_fails() {- let csv = "not,a,valid,header,set\nfoo,bar,baz,qux,quux\n";- let file = write_temp_csv(csv);-- let mock_db = Db::default();-- let args = ChannelArgs {- command: ChannelCommand::BulkCreate(BulkCreateArgs {- file_path: file.path().to_str().unwrap().to_string(),- }),- };-- let result = args.execute(mock_ctx(mock_db)).await;- assert!(result.is_err());-}--// ── Seed CSV tests ────────────────────────────────────────+// ── Seed JSON tests ────────────────────────────────────────#[tokio::test]async fn seed_creates_all_channels() {let id1 = uuid::Uuid::new_v4();let id2 = uuid::Uuid::new_v4();- let csv = format!(- "channel_id,channel_name,channel_type,participants\n\- {id1},general,public,macro|[email protected];macro|[email protected]\n\- {id2},,direct_message,macro|[email protected]\n"- );- let file = write_temp_csv(&csv);+ let json = serde_json::json!([+ {+ "channel_id": id1,+ "channel_name": "general",+ "channel_type": "public",+ "participants": ["macro|[email protected]", "macro|[email protected]"]+ },+ {+ "channel_id": id2,+ "channel_type": "direct_message",+ "participants": ["macro|[email protected]"]+ }+ ])+ .to_string();+ let file = write_temp_json(&json);let mut mock_db = Db::default();mock_db@@ -433,6 +284,7 @@ async fn seed_creates_all_channels() {let args = SeedArgs {user_id: "macro|[email protected]".to_string(),+ file_path: None,};let result = seed_from_file(args, mock_ctx(mock_db), file.path()).await;@@ -442,11 +294,16 @@ async fn seed_creates_all_channels() {#[tokio::test]async fn seed_sets_user_id_as_owner_and_appends_to_participants() {let id = uuid::Uuid::new_v4();- let csv = format!(- "channel_id,channel_name,channel_type,participants\n\- {id},general,public,macro|[email protected]\n"- );- let file = write_temp_csv(&csv);+ let json = serde_json::json!([+ {+ "channel_id": id,+ "channel_name": "general",+ "channel_type": "public",+ "participants": ["macro|[email protected]"]+ }+ ])+ .to_string();+ let file = write_temp_json(&json);let mut mock_db = Db::default();mock_db@@ -465,6 +322,7 @@ async fn seed_sets_user_id_as_owner_and_appends_to_participants() {let args = SeedArgs {user_id: "macro|[email protected]".to_string(),+ file_path: None,};let result = seed_from_file(args, mock_ctx(mock_db), file.path()).await;@@ -474,11 +332,16 @@ async fn seed_sets_user_id_as_owner_and_appends_to_participants() {#[tokio::test]async fn seed_does_not_duplicate_user_in_participants() {let id = uuid::Uuid::new_v4();- let csv = format!(- "channel_id,channel_name,channel_type,participants\n\- {id},general,public,macro|[email protected];macro|[email protected]\n"- );- let file = write_temp_csv(&csv);+ let json = serde_json::json!([+ {+ "channel_id": id,+ "channel_name": "general",+ "channel_type": "public",+ "participants": ["macro|[email protected]", "macro|[email protected]"]+ }+ ])+ .to_string();+ let file = write_temp_json(&json);let mut mock_db = Db::default();mock_db@@ -495,6 +358,7 @@ async fn seed_does_not_duplicate_user_in_participants() {let args = SeedArgs {user_id: "macro|[email protected]".to_string(),+ file_path: None,};let result = seed_from_file(args, mock_ctx(mock_db), file.path()).await;@@ -502,14 +366,15 @@ async fn seed_does_not_duplicate_user_in_participants() {}#[tokio::test]-async fn seed_empty_csv_fails() {- let csv = "channel_id,channel_name,channel_type,participants\n";- let file = write_temp_csv(csv);+async fn seed_empty_json_fails() {+ let json = "[]";+ let file = write_temp_json(json);let mock_db = Db::default();let args = SeedArgs {user_id: "macro|[email protected]".to_string(),+ file_path: None,};let result = seed_from_file(args, mock_ctx(mock_db), file.path()).await;@@ -522,13 +387,25 @@ async fn seed_continues_on_failure() {let id1 = uuid::Uuid::new_v4();let id2 = uuid::Uuid::new_v4();let id3 = uuid::Uuid::new_v4();- let csv = format!(- "channel_id,channel_name,channel_type,participants\n\- {id1},good-1,public,\n\- {id2},bad,public,\n\- {id3},good-2,private,\n"- );- let file = write_temp_csv(&csv);+ let json = serde_json::json!([+ {+ "channel_id": id1,+ "channel_name": "good-1",+ "channel_type": "public"+ },+ {+ "channel_id": id2,+ "channel_name": "bad",+ "channel_type": "public"+ },+ {+ "channel_id": id3,+ "channel_name": "good-2",+ "channel_type": "private"+ }+ ])+ .to_string();+ let file = write_temp_json(&json);let mut mock_db = Db::default();mock_db.expect_seed_channel().times(3).returning(|opts| {@@ -541,6 +418,7 @@ async fn seed_continues_on_failure() {let args = SeedArgs {user_id: "macro|[email protected]".to_string(),+ file_path: None,};let result = seed_from_file(args, mock_ctx(mock_db), file.path()).await;diff --git a/rust/cloud-storage/seed_cli/src/entity/channel_message/mod.rs b/rust/cloud-storage/seed_cli/src/entity/channel_message/mod.rsindex 5c25009e1c..fc8b682119 100644--- a/rust/cloud-storage/seed_cli/src/entity/channel_message/mod.rs+++ b/rust/cloud-storage/seed_cli/src/entity/channel_message/mod.rs@@ -4,11 +4,14 @@mod test;use std::path::Path;+use std::str::FromStr;use anyhow::Context;use clap::{Args, Subcommand};use comms_db_client::messages::create_message::CreateMessageOptions;use comms_db_client::messages::seed_message::SeedMessageOptions;+use comms_db_client::model::SimpleMention;+use model::item::ShareableItemType;use serde::Deserialize;use uuid::Uuid;@@ -27,15 +30,21 @@ pub struct ChannelMessageArgs {pub enum ChannelMessageCommand {/// Create a single channel messageCreate(CreateArgs),- /// Bulk create multiple channel messages- BulkCreate(BulkCreateArgs),- /// Seed channel messages from a fixed CSV file with pre-defined UUIDs- Seed,+ /// Seed channel messages from a JSON file with pre-defined UUIDs+ Seed(SeedArgs),}-/// A row in the seed CSV file.+/// Arguments for seeding channel messages from a JSON file.+#[derive(Debug, Args)]+pub struct SeedArgs {+ /// Path to the JSON file containing messages to seed (defaults to seed/channel_messages.json)+ #[arg(long)]+ pub file_path: Option<String>,+}++/// A row in the seed JSON file.#[derive(Debug, Deserialize)]-struct CsvSeedMessageRow {+struct SeedMessageRow {/// Pre-defined message UUID.message_id: Uuid,/// The channel ID to post the message to.@@ -46,6 +55,9 @@ struct CsvSeedMessageRow {content: String,/// Optional thread ID if this is a reply.thread_id: Option<Uuid>,+ /// Entity mentions in the message.+ #[serde(default)]+ entity_mentions: Vec<SimpleMention>,}/// Arguments for creating a single channel message.@@ -65,34 +77,12 @@ pub struct CreateArgs {pub thread_id: Option<Uuid>,}-/// Arguments for bulk creating channel messages.-#[derive(Debug, Args)]-pub struct BulkCreateArgs {- /// Path to the CSV file containing messages to create- #[arg(long)]- pub file_path: String,-}--/// A row in the bulk-create CSV file.-#[derive(Debug, Deserialize)]-struct CsvMessageRow {- /// The channel ID to post the message to- channel_id: Uuid,- /// The user ID of the message sender- sender_id: String,- /// The message content- content: String,- /// Optional thread ID if this is a reply- thread_id: Option<Uuid>,-}-impl ChannelMessageArgs {/// Execute the channel message command.pub async fn execute(self, ctx: SeedCliContext) -> anyhow::Result<()> {match self.command {ChannelMessageCommand::Create(args) => create(args, ctx).await,- ChannelMessageCommand::BulkCreate(args) => bulk_create(args, ctx).await,- ChannelMessageCommand::Seed => seed(ctx).await,+ ChannelMessageCommand::Seed(args) => seed(args, ctx).await,}}}@@ -115,74 +105,26 @@ async fn create(args: CreateArgs, ctx: SeedCliContext) -> anyhow::Result<()> {}#[tracing::instrument(skip(ctx), err)]-async fn bulk_create(args: BulkCreateArgs, ctx: SeedCliContext) -> anyhow::Result<()> {- tracing::info!("bulk creating channel messages");-- let content = std::fs::read_to_string(Path::new(&args.file_path))- .with_context(|| format!("failed to read csv file: {}", args.file_path))?;-- let mut reader = csv::Reader::from_reader(content.as_bytes());- let rows: Vec<CsvMessageRow> = reader- .deserialize()- .collect::<Result<Vec<_>, _>>()- .context("failed to parse csv")?;-- if rows.is_empty() {- anyhow::bail!("no messages found in csv file");- }-- println!("Found {} messages to create", rows.len());-- let mut created = 0;- let mut failed = 0;-- for row in rows {- let message_label = format!("channel={} sender={}", row.channel_id, row.sender_id);-- let options = CreateMessageOptions {- channel_id: row.channel_id,- sender_id: row.sender_id,- content: row.content,- thread_id: row.thread_id,- };-- match ctx.db.create_message(options).await {- Ok(message_id) => {- println!("Created message {message_label} with id {message_id}");- created += 1;- }- Err(e) => {- tracing::error!(error=?e, message = message_label, "failed to create message");- println!("Failed to create message {message_label}: {e}");- failed += 1;- }- }- }-- println!("\nBulk create complete: {created} created, {failed} failed");-- Ok(())-}--#[tracing::instrument(skip(ctx), err)]-async fn seed(ctx: SeedCliContext) -> anyhow::Result<()> {- seed_from_file(ctx, Path::new("seed/channel_messages.csv")).await+async fn seed(args: SeedArgs, ctx: SeedCliContext) -> anyhow::Result<()> {+ let default_path = Path::new("seed/channel_messages.json").to_path_buf();+ let path = args+ .file_path+ .map(std::path::PathBuf::from)+ .unwrap_or(default_path);+ seed_from_file(ctx, &path).await}async fn seed_from_file(ctx: SeedCliContext, path: &Path) -> anyhow::Result<()> {tracing::info!("seeding channel messages");let content = std::fs::read_to_string(path)- .with_context(|| format!("failed to read csv file: {}", path.display()))?;+ .with_context(|| format!("failed to read json file: {}", path.display()))?;- let mut reader = csv::Reader::from_reader(content.as_bytes());- let rows: Vec<CsvSeedMessageRow> = reader- .deserialize()- .collect::<Result<Vec<_>, _>>()- .context("failed to parse csv")?;+ let rows: Vec<SeedMessageRow> =+ serde_json::from_str(&content).context("failed to parse json")?;if rows.is_empty() {- anyhow::bail!("no messages found in csv file");+ anyhow::bail!("no messages found in json file");}println!("Found {} messages to seed", rows.len());@@ -192,24 +134,71 @@ async fn seed_from_file(ctx: SeedCliContext, path: &Path) -> anyhow::Result<()>for row in rows {let message_label = format!("channel={} sender={}", row.channel_id, row.sender_id);+ let entity_mentions = row.entity_mentions;+ let channel_id = row.channel_id;let options = SeedMessageOptions {message_id: row.message_id,- channel_id: row.channel_id,+ channel_id,sender_id: row.sender_id,content: row.content,thread_id: row.thread_id,};- match ctx.db.seed_message(options).await {- Ok(message_id) => {- println!("Seeded message {message_label} with id {message_id}");+ let message_id = match ctx.db.seed_message(options).await {+ Ok(id) => {+ println!("Seeded message {message_label} with id {id}");created += 1;+ id}Err(e) => {tracing::error!(error=?e, message = message_label, "failed to seed message");println!("Failed to seed message {message_label}: {e}");failed += 1;+ continue;+ }+ };++ if entity_mentions.is_empty() {+ continue;+ }++ if let Err(e) = ctx+ .db+ .create_message_mentions(message_id, entity_mentions.clone())+ .await+ {+ tracing::error!(error=?e, message = message_label, "failed to create message mentions");+ println!("Warning: failed to create mentions for {message_label}: {e}");+ }++ for mention in &entity_mentions {+ if mention.entity_type == "user" {+ continue;+ }+ if ShareableItemType::from_str(&mention.entity_type).is_err() {+ continue;+ }+ if let Err(e) = ctx+ .db+ .update_share_permissions_for_mention(+ channel_id,+ &mention.entity_id,+ &mention.entity_type,+ )+ .await+ {+ tracing::error!(+ error=?e,+ message = message_label,+ entity_type = mention.entity_type,+ entity_id = mention.entity_id,+ "failed to update share permissions for mention"+ );+ println!(+ "Warning: failed to update share permissions for {}|{} in {message_label}: {e}",+ mention.entity_type, mention.entity_id,+ );}}}diff --git a/rust/cloud-storage/seed_cli/src/entity/channel_message/test.rs b/rust/cloud-storage/seed_cli/src/entity/channel_message/test.rsindex cbb99b9b91..a705c9c5ac 100644--- a/rust/cloud-storage/seed_cli/src/entity/channel_message/test.rs+++ b/rust/cloud-storage/seed_cli/src/entity/channel_message/test.rs@@ -1,6 +1,7 @@use std::io::Write;use clap::Parser;+use comms_db_client::model::SimpleMention;use tempfile::NamedTempFile;use uuid::Uuid;@@ -20,7 +21,9 @@ fn parse_channel_message_seed() {match cli.command {crate::entity::EntityCommand::ChannelMessage(args) => match args.command {- ChannelMessageCommand::Seed => {}+ ChannelMessageCommand::Seed(seed) => {+ assert!(seed.file_path.is_none());+ }other => panic!("expected Seed, got {other:?}"),},other => panic!("expected ChannelMessage, got {other:?}"),@@ -152,28 +155,6 @@ fn parse_channel_message_create_invalid_channel_id_fails() {assert!(result.is_err());}-#[test]-fn parse_channel_message_bulk_create() {- let cli = Cli::try_parse_from([- "seed_cli",- "channel-message",- "bulk-create",- "--file-path",- "messages.csv",- ])- .unwrap();-- match cli.command {- crate::entity::EntityCommand::ChannelMessage(args) => match args.command {- ChannelMessageCommand::BulkCreate(bulk) => {- assert_eq!(bulk.file_path, "messages.csv");- }- other => panic!("expected BulkCreate, got {other:?}"),- },- other => panic!("expected ChannelMessage, got {other:?}"),- }-}-// ── Helpers ────────────────────────────────────────────────fn mock_ctx(db: Db) -> SeedCliContext {@@ -184,7 +165,7 @@ fn mock_ctx(db: Db) -> SeedCliContext {}}-fn write_temp_csv(content: &str) -> NamedTempFile {+fn write_temp_json(content: &str) -> NamedTempFile {let mut file = NamedTempFile::new().unwrap();file.write_all(content.as_bytes()).unwrap();file.flush().unwrap();@@ -274,242 +255,275 @@ async fn create_message_db_failure_propagates_error() {assert!(err.to_string().contains("db connection failed"));}-// ── Bulk CSV tests ────────────────────────────────────────+// ── Seed JSON tests ────────────────────────────────────────#[tokio::test]-async fn bulk_create_creates_all_messages() {- let channel_id = Uuid::nil();- let csv = format!(- "channel_id,sender_id,content,thread_id\n\- {channel_id},macro|[email protected],Hello world,\n\- {channel_id},macro|[email protected],Hi there,\n"- );- let file = write_temp_csv(&csv);+async fn seed_creates_all_messages() {+ let msg1 = Uuid::new_v4();+ let msg2 = Uuid::new_v4();+ let channel_id = Uuid::new_v4();+ let json = serde_json::json!([+ {+ "message_id": msg1,+ "channel_id": channel_id,+ "sender_id": "macro|[email protected]",+ "content": "Hello world"+ },+ {+ "message_id": msg2,+ "channel_id": channel_id,+ "sender_id": "macro|[email protected]",+ "content": "Hi there"+ }+ ])+ .to_string();+ let file = write_temp_json(&json);let mut mock_db = Db::default();mock_db- .expect_create_message()+ .expect_seed_message().times(2)- .returning(|_| Ok(Uuid::nil()));-- let args = ChannelMessageArgs {- command: ChannelMessageCommand::BulkCreate(BulkCreateArgs {- file_path: file.path().to_str().unwrap().to_string(),- }),- };+ .returning(|opts| Ok(opts.message_id));- let result = args.execute(mock_ctx(mock_db)).await;+ let result = seed_from_file(mock_ctx(mock_db), file.path()).await;assert!(result.is_ok());}#[tokio::test]-async fn bulk_create_with_thread_id() {- let channel_id = Uuid::nil();- let thread_id = Uuid::from_u128(1);- let csv = format!(- "channel_id,sender_id,content,thread_id\n\- {channel_id},macro|[email protected],Thread reply,{thread_id}\n"- );- let file = write_temp_csv(&csv);+async fn seed_uses_provided_message_id() {+ let msg_id = Uuid::new_v4();+ let channel_id = Uuid::new_v4();+ let json = serde_json::json!([+ {+ "message_id": msg_id,+ "channel_id": channel_id,+ "sender_id": "macro|[email protected]",+ "content": "Test message"+ }+ ])+ .to_string();+ let file = write_temp_json(&json);let mut mock_db = Db::default();mock_db- .expect_create_message()+ .expect_seed_message().times(1)- .withf(move |opts| opts.thread_id == Some(thread_id) && opts.content == "Thread reply")- .returning(|_| Ok(Uuid::nil()));-- let args = ChannelMessageArgs {- command: ChannelMessageCommand::BulkCreate(BulkCreateArgs {- file_path: file.path().to_str().unwrap().to_string(),- }),- };+ .withf(move |opts| opts.message_id == msg_id && opts.channel_id == channel_id)+ .returning(|opts| Ok(opts.message_id));- let result = args.execute(mock_ctx(mock_db)).await;+ let result = seed_from_file(mock_ctx(mock_db), file.path()).await;assert!(result.is_ok());}#[tokio::test]-async fn bulk_create_empty_file_fails() {- let csv = "channel_id,sender_id,content,thread_id\n";- let file = write_temp_csv(csv);-- let mock_db = Db::default();-- let args = ChannelMessageArgs {- command: ChannelMessageCommand::BulkCreate(BulkCreateArgs {- file_path: file.path().to_str().unwrap().to_string(),- }),- };-- let result = args.execute(mock_ctx(mock_db)).await;- let err = result.unwrap_err();- assert!(err.to_string().contains("no messages found"));-}--#[tokio::test]-async fn bulk_create_missing_file_fails() {- let mock_db = Db::default();-- let args = ChannelMessageArgs {- command: ChannelMessageCommand::BulkCreate(BulkCreateArgs {- file_path: "/nonexistent/path.csv".to_string(),- }),- };-- let result = args.execute(mock_ctx(mock_db)).await;- let err = result.unwrap_err();- assert!(err.to_string().contains("failed to read csv file"));-}--#[tokio::test]-async fn bulk_create_continues_on_failure() {- let channel_id = Uuid::nil();- let csv = format!(- "channel_id,sender_id,content,thread_id\n\- {channel_id},macro|[email protected],Good message 1,\n\- {channel_id},macro|[email protected],Bad message,\n\- {channel_id},macro|[email protected],Good message 2,\n"- );- let file = write_temp_csv(&csv);-- let mut mock_db = Db::default();- mock_db.expect_create_message().times(3).returning(|opts| {- if opts.sender_id == "macro|[email protected]" {- Err(anyhow::anyhow!("db error"))- } else {- Ok(Uuid::nil())+async fn seed_with_thread_id() {+ let msg_id = Uuid::new_v4();+ let channel_id = Uuid::new_v4();+ let thread_id = Uuid::new_v4();+ let json = serde_json::json!([+ {+ "message_id": msg_id,+ "channel_id": channel_id,+ "sender_id": "macro|[email protected]",+ "content": "Thread reply",+ "thread_id": thread_id}- });+ ])+ .to_string();+ let file = write_temp_json(&json);- let args = ChannelMessageArgs {- command: ChannelMessageCommand::BulkCreate(BulkCreateArgs {- file_path: file.path().to_str().unwrap().to_string(),- }),- };+ let mut mock_db = Db::default();+ mock_db+ .expect_seed_message()+ .times(1)+ .withf(move |opts| opts.thread_id == Some(thread_id))+ .returning(|opts| Ok(opts.message_id));- let result = args.execute(mock_ctx(mock_db)).await;+ let result = seed_from_file(mock_ctx(mock_db), file.path()).await;assert!(result.is_ok());}#[tokio::test]-async fn bulk_create_invalid_csv_fails() {- let csv = "not,a,valid,header\nfoo,bar,baz,qux\n";- let file = write_temp_csv(csv);+async fn seed_empty_json_fails() {+ let json = "[]";+ let file = write_temp_json(json);let mock_db = Db::default();- let args = ChannelMessageArgs {- command: ChannelMessageCommand::BulkCreate(BulkCreateArgs {- file_path: file.path().to_str().unwrap().to_string(),- }),- };-- let result = args.execute(mock_ctx(mock_db)).await;- assert!(result.is_err());+ let result = seed_from_file(mock_ctx(mock_db), file.path()).await;+ let err = result.unwrap_err();+ assert!(err.to_string().contains("no messages found"));}-// ── Seed CSV tests ────────────────────────────────────────-#[tokio::test]-async fn seed_creates_all_messages() {+async fn seed_continues_on_failure() {let msg1 = Uuid::new_v4();let msg2 = Uuid::new_v4();+ let msg3 = Uuid::new_v4();let channel_id = Uuid::new_v4();- let csv = format!(- "message_id,channel_id,sender_id,content,thread_id\n\- {msg1},{channel_id},macro|[email protected],Hello world,\n\- {msg2},{channel_id},macro|[email protected],Hi there,\n"- );- let file = write_temp_csv(&csv);+ let json = serde_json::json!([+ {+ "message_id": msg1,+ "channel_id": channel_id,+ "sender_id": "macro|[email protected]",+ "content": "Good 1"+ },+ {+ "message_id": msg2,+ "channel_id": channel_id,+ "sender_id": "macro|[email protected]",+ "content": "Bad"+ },+ {+ "message_id": msg3,+ "channel_id": channel_id,+ "sender_id": "macro|[email protected]",+ "content": "Good 2"+ }+ ])+ .to_string();+ let file = write_temp_json(&json);let mut mock_db = Db::default();- mock_db- .expect_seed_message()- .times(2)- .returning(|opts| Ok(opts.message_id));+ mock_db.expect_seed_message().times(3).returning(|opts| {+ if opts.sender_id == "macro|[email protected]" {+ Err(anyhow::anyhow!("db error"))+ } else {+ Ok(opts.message_id)+ }+ });let result = seed_from_file(mock_ctx(mock_db), file.path()).await;assert!(result.is_ok());}+// ── Mention flow tests ────────────────────────────────────+#[tokio::test]-async fn seed_uses_provided_message_id() {+async fn seed_with_mentions_calls_create_message_mentions() {let msg_id = Uuid::new_v4();let channel_id = Uuid::new_v4();- let csv = format!(- "message_id,channel_id,sender_id,content,thread_id\n\- {msg_id},{channel_id},macro|[email protected],Test message,\n"- );- let file = write_temp_csv(&csv);+ let json = serde_json::json!([+ {+ "message_id": msg_id,+ "channel_id": channel_id,+ "sender_id": "macro|[email protected]",+ "content": "Check this doc",+ "entity_mentions": [+ { "entity_type": "document", "entity_id": "doc-123" },+ { "entity_type": "user", "entity_id": "macro|[email protected]" }+ ]+ }+ ])+ .to_string();+ let file = write_temp_json(&json);let mut mock_db = Db::default();mock_db.expect_seed_message().times(1)- .withf(move |opts| opts.message_id == msg_id && opts.channel_id == channel_id).returning(|opts| Ok(opts.message_id));+ mock_db+ .expect_create_message_mentions()+ .times(1)+ .withf(move |mid, mentions| {+ *mid == msg_id+ && mentions.len() == 2+ && mentions[0]+ == (SimpleMention {+ entity_type: "document".to_string(),+ entity_id: "doc-123".to_string(),+ })+ && mentions[1]+ == (SimpleMention {+ entity_type: "user".to_string(),+ entity_id: "macro|[email protected]".to_string(),+ })+ })+ .returning(|_, _| Ok(vec![]));+ mock_db+ .expect_update_share_permissions_for_mention()+ .times(1)+ .withf(move |cid, item_id, item_type| {+ *cid == channel_id && item_id == "doc-123" && item_type == "document"+ })+ .returning(|_, _, _| Ok(()));let result = seed_from_file(mock_ctx(mock_db), file.path()).await;assert!(result.is_ok());}#[tokio::test]-async fn seed_with_thread_id() {+async fn seed_without_mentions_does_not_call_mention_methods() {let msg_id = Uuid::new_v4();let channel_id = Uuid::new_v4();- let thread_id = Uuid::new_v4();- let csv = format!(- "message_id,channel_id,sender_id,content,thread_id\n\- {msg_id},{channel_id},macro|[email protected],Thread reply,{thread_id}\n"- );- let file = write_temp_csv(&csv);+ let json = serde_json::json!([+ {+ "message_id": msg_id,+ "channel_id": channel_id,+ "sender_id": "macro|[email protected]",+ "content": "No mentions here"+ }+ ])+ .to_string();+ let file = write_temp_json(&json);let mut mock_db = Db::default();mock_db.expect_seed_message().times(1)- .withf(move |opts| opts.thread_id == Some(thread_id)).returning(|opts| Ok(opts.message_id));+ mock_db+ .expect_create_message_mentions()+ .never()+ .returning(|_, _| Ok(vec![]));+ mock_db+ .expect_update_share_permissions_for_mention()+ .never()+ .returning(|_, _, _| Ok(()));let result = seed_from_file(mock_ctx(mock_db), file.path()).await;assert!(result.is_ok());}#[tokio::test]-async fn seed_empty_csv_fails() {- let csv = "message_id,channel_id,sender_id,content,thread_id\n";- let file = write_temp_csv(csv);-- let mock_db = Db::default();-- let result = seed_from_file(mock_ctx(mock_db), file.path()).await;- let err = result.unwrap_err();- assert!(err.to_string().contains("no messages found"));-}--#[tokio::test]-async fn seed_continues_on_failure() {+async fn seed_mention_failure_does_not_prevent_message_creation() {let msg1 = Uuid::new_v4();let msg2 = Uuid::new_v4();- let msg3 = Uuid::new_v4();let channel_id = Uuid::new_v4();- let csv = format!(- "message_id,channel_id,sender_id,content,thread_id\n\- {msg1},{channel_id},macro|[email protected],Good 1,\n\- {msg2},{channel_id},macro|[email protected],Bad,\n\- {msg3},{channel_id},macro|[email protected],Good 2,\n"- );- let file = write_temp_csv(&csv);+ let json = serde_json::json!([+ {+ "message_id": msg1,+ "channel_id": channel_id,+ "sender_id": "macro|[email protected]",+ "content": "With mentions",+ "entity_mentions": [+ { "entity_type": "document", "entity_id": "doc-123" }+ ]+ },+ {+ "message_id": msg2,+ "channel_id": channel_id,+ "sender_id": "macro|[email protected]",+ "content": "After mention fail"+ }+ ])+ .to_string();+ let file = write_temp_json(&json);let mut mock_db = Db::default();- mock_db.expect_seed_message().times(3).returning(|opts| {- if opts.sender_id == "macro|[email protected]" {- Err(anyhow::anyhow!("db error"))- } else {- Ok(opts.message_id)- }- });+ mock_db+ .expect_seed_message()+ .times(2)+ .returning(|opts| Ok(opts.message_id));+ mock_db+ .expect_create_message_mentions()+ .times(1)+ .returning(|_, _| Err(anyhow::anyhow!("mention insert failed")));+ mock_db+ .expect_update_share_permissions_for_mention()+ .times(1)+ .returning(|_, _, _| Ok(()));let result = seed_from_file(mock_ctx(mock_db), file.path()).await;assert!(result.is_ok());diff --git a/rust/cloud-storage/seed_cli/src/entity/document/mod.rs b/rust/cloud-storage/seed_cli/src/entity/document/mod.rsindex 5c977c3225..404a5fcb51 100644--- a/rust/cloud-storage/seed_cli/src/entity/document/mod.rs+++ b/rust/cloud-storage/seed_cli/src/entity/document/mod.rs@@ -30,7 +30,7 @@ pub struct DocumentArgs {pub enum DocumentCommand {/// Create a single documentCreate(CreateArgs),- /// Seed documents from a fixed CSV file with pre-defined UUIDs+ /// Seed documents from a fixed JSON file with pre-defined UUIDsSeed(SeedArgs),}@@ -62,17 +62,20 @@ pub struct CreateArgs {pub skip_history: bool,}-/// Arguments for seeding documents from a fixed CSV file.+/// Arguments for seeding documents from a JSON file.#[derive(Debug, Args)]pub struct SeedArgs {/// The user ID to set as document owner#[arg(long)]pub user_id: String,+ /// Path to the JSON file containing documents to seed (defaults to seed/documents/documents.json)+ #[arg(long)]+ pub file_path: Option<String>,}-/// A row in the seed CSV file.+/// A row in the seed JSON file.#[derive(Debug, Deserialize)]-struct CsvSeedDocumentRow {+struct SeedDocumentRow {/// Pre-defined document UUID.document_id: Uuid,/// Document name.@@ -158,23 +161,26 @@ async fn create(args: CreateArgs, ctx: SeedCliContext) -> anyhow::Result<()> {#[tracing::instrument(skip(ctx), err)]async fn seed(args: SeedArgs, ctx: SeedCliContext) -> anyhow::Result<()> {- seed_from_file(args, ctx, Path::new("seed/documents/documents.csv")).await+ let default_path = Path::new("seed/documents/documents.json").to_path_buf();+ let path = args+ .file_path+ .as_deref()+ .map(std::path::PathBuf::from)+ .unwrap_or(default_path);+ seed_from_file(args, ctx, &path).await}async fn seed_from_file(args: SeedArgs, ctx: SeedCliContext, path: &Path) -> anyhow::Result<()> {tracing::info!("seeding documents");let content = std::fs::read_to_string(path)- .with_context(|| format!("failed to read csv file: {}", path.display()))?;+ .with_context(|| format!("failed to read json file: {}", path.display()))?;- let mut reader = csv::Reader::from_reader(content.as_bytes());- let rows: Vec<CsvSeedDocumentRow> = reader- .deserialize()- .collect::<Result<Vec<_>, _>>()- .context("failed to parse csv")?;+ let rows: Vec<SeedDocumentRow> =+ serde_json::from_str(&content).context("failed to parse json")?;if rows.is_empty() {- anyhow::bail!("no documents found in csv file");+ anyhow::bail!("no documents found in json file");}println!("Found {} documents to seed", rows.len());diff --git a/rust/cloud-storage/seed_cli/src/entity/document/test.rs b/rust/cloud-storage/seed_cli/src/entity/document/test.rsindex 5511ed107c..ad90d5cb7f 100644--- a/rust/cloud-storage/seed_cli/src/entity/document/test.rs+++ b/rust/cloud-storage/seed_cli/src/entity/document/test.rs@@ -167,14 +167,7 @@ fn mock_ctx(db: Db, s3: S3) -> SeedCliContext {}}-fn write_temp_file(content: &[u8], suffix: &str) -> NamedTempFile {- let mut file = tempfile::Builder::new().suffix(suffix).tempfile().unwrap();- file.write_all(content).unwrap();- file.flush().unwrap();- file-}--fn write_temp_csv(content: &str) -> NamedTempFile {+fn write_temp_json(content: &str) -> NamedTempFile {let mut file = NamedTempFile::new().unwrap();file.write_all(content.as_bytes()).unwrap();file.flush().unwrap();@@ -221,6 +214,13 @@ fn test_document_metadata_with_type(file_type: FileType) -> DocumentMetadata {)}+fn write_temp_file(content: &[u8], suffix: &str) -> NamedTempFile {+ let mut file = tempfile::Builder::new().suffix(suffix).tempfile().unwrap();+ file.write_all(content).unwrap();+ file.flush().unwrap();+ file+}+// ── Execution tests ───────────────────────────────────────#[tokio::test]@@ -317,18 +317,18 @@ async fn create_document_s3_failure_propagates() {assert!(err.to_string().contains("s3 upload failed"));}-// ── Seed CSV tests ────────────────────────────────────────+// ── Seed JSON tests ────────────────────────────────────────#[tokio::test]async fn seed_creates_all_documents() {let doc1 = Uuid::new_v4();let doc2 = Uuid::new_v4();- let csv = format!(- "document_id,document_name,file_name,is_public\n\- {doc1},Test PDF,pdf.pdf,false\n\- {doc2},Test Markdown,md.md,true\n"- );- let file = write_temp_csv(&csv);+ let json = serde_json::json!([+ { "document_id": doc1, "document_name": "Test PDF", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": doc2, "document_name": "Test Markdown", "file_name": "md.md", "is_public": true }+ ])+ .to_string();+ let file = write_temp_json(&json);let mut mock_db = Db::default();mock_db@@ -344,6 +344,7 @@ async fn seed_creates_all_documents() {let args = SeedArgs {user_id: "macro|[email protected]".to_string(),+ file_path: None,};let result = seed_from_file(args, mock_ctx(mock_db, mock_s3), file.path()).await;@@ -351,15 +352,16 @@ async fn seed_creates_all_documents() {}#[tokio::test]-async fn seed_empty_csv_fails() {- let csv = "document_id,document_name,file_name,is_public\n";- let file = write_temp_csv(csv);+async fn seed_empty_json_fails() {+ let json = "[]";+ let file = write_temp_json(json);let mock_db = Db::default();let mock_s3 = S3::default();let args = SeedArgs {user_id: "macro|[email protected]".to_string(),+ file_path: None,};let result = seed_from_file(args, mock_ctx(mock_db, mock_s3), file.path()).await;@@ -372,13 +374,13 @@ async fn seed_continues_on_db_failure() {let doc1 = Uuid::new_v4();let doc2 = Uuid::new_v4();let doc3 = Uuid::new_v4();- let csv = format!(- "document_id,document_name,file_name,is_public\n\- {doc1},Good Doc 1,pdf.pdf,false\n\- {doc2},Bad Doc,md.md,false\n\- {doc3},Good Doc 2,canvas.canvas,false\n"- );- let file = write_temp_csv(&csv);+ let json = serde_json::json!([+ { "document_id": doc1, "document_name": "Good Doc 1", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": doc2, "document_name": "Bad Doc", "file_name": "md.md", "is_public": false },+ { "document_id": doc3, "document_name": "Good Doc 2", "file_name": "canvas.canvas", "is_public": false }+ ])+ .to_string();+ let file = write_temp_json(&json);let mut call_count = 0;let mut mock_db = Db::default();@@ -402,6 +404,7 @@ async fn seed_continues_on_db_failure() {let args = SeedArgs {user_id: "macro|[email protected]".to_string(),+ file_path: None,};let result = seed_from_file(args, mock_ctx(mock_db, mock_s3), file.path()).await;@@ -412,12 +415,12 @@ async fn seed_continues_on_db_failure() {async fn seed_continues_on_s3_failure() {let doc1 = Uuid::new_v4();let doc2 = Uuid::new_v4();- let csv = format!(- "document_id,document_name,file_name,is_public\n\- {doc1},Good Doc,pdf.pdf,false\n\- {doc2},S3 Fail Doc,md.md,false\n"- );- let file = write_temp_csv(&csv);+ let json = serde_json::json!([+ { "document_id": doc1, "document_name": "Good Doc", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": doc2, "document_name": "S3 Fail Doc", "file_name": "md.md", "is_public": false }+ ])+ .to_string();+ let file = write_temp_json(&json);let mut mock_db = Db::default();mock_db@@ -441,6 +444,7 @@ async fn seed_continues_on_s3_failure() {let args = SeedArgs {user_id: "macro|[email protected]".to_string(),+ file_path: None,};let result = seed_from_file(args, mock_ctx(mock_db, mock_s3), file.path()).await;@@ -452,13 +456,13 @@ async fn seed_handles_all_file_types() {let doc1 = Uuid::new_v4();let doc2 = Uuid::new_v4();let doc3 = Uuid::new_v4();- let csv = format!(- "document_id,document_name,file_name,is_public\n\- {doc1},PDF Doc,pdf.pdf,false\n\- {doc2},Markdown Doc,md.md,false\n\- {doc3},Canvas Doc,canvas.canvas,false\n"- );- let file = write_temp_csv(&csv);+ let json = serde_json::json!([+ { "document_id": doc1, "document_name": "PDF Doc", "file_name": "pdf.pdf", "is_public": false },+ { "document_id": doc2, "document_name": "Markdown Doc", "file_name": "md.md", "is_public": false },+ { "document_id": doc3, "document_name": "Canvas Doc", "file_name": "canvas.canvas", "is_public": false }+ ])+ .to_string();+ let file = write_temp_json(&json);let mut mock_db = Db::default();mock_db.expect_create_document().times(3).returning(|args| {@@ -474,6 +478,7 @@ async fn seed_handles_all_file_types() {let args = SeedArgs {user_id: "macro|[email protected]".to_string(),+ file_path: None,};let result = seed_from_file(args, mock_ctx(mock_db, mock_s3), file.path()).await;diff --git a/rust/cloud-storage/seed_cli/src/service/db/mod.rs b/rust/cloud-storage/seed_cli/src/service/db/mod.rsindex 4a6787404c..f1248a9916 100644--- a/rust/cloud-storage/seed_cli/src/service/db/mod.rs+++ b/rust/cloud-storage/seed_cli/src/service/db/mod.rs@@ -11,9 +11,12 @@ use mockall::automock;use comms_db_client::channels::create_channel::CreateChannelOptions;use comms_db_client::channels::seed_channel::SeedChannelOptions;use comms_db_client::messages::create_message::CreateMessageOptions;+use comms_db_client::messages::create_message_mentions::CreateMessageMentionOptions;use comms_db_client::messages::seed_message::SeedMessageOptions;+use comms_db_client::model::SimpleMention;use model::document::DocumentMetadata;use models_email::email::service;+use models_permissions::share_permission::access_level::AccessLevel;/// Wrapper around the database connection pool.pub struct SeedDb {@@ -75,6 +78,77 @@ impl SeedDb {Ok(message.id)}+ /// Create entity mentions for a message.+ #[tracing::instrument(skip(self), err)]+ pub async fn create_message_mentions(+ &self,+ message_id: uuid::Uuid,+ mentions: Vec<SimpleMention>,+ ) -> anyhow::Result<Vec<String>> {+ let options = CreateMessageMentionOptions {+ message_id,+ mentions,+ };+ comms_db_client::messages::create_message_mentions::create_message_mentions(+ &self.inner,+ options,+ )+ .await+ }++ /// Update channel share permissions for a mentioned entity (seed-data only, no access check).+ #[tracing::instrument(skip(self), err)]+ pub async fn update_share_permissions_for_mention(+ &self,+ channel_id: uuid::Uuid,+ item_id: &str,+ item_type: &str,+ ) -> anyhow::Result<()> {+ let share_permission_id = macro_db_client::share_permission::get::get_share_permission_id(+ &self.inner,+ item_id,+ item_type,+ )+ .await?;++ let channel_id_str = channel_id.to_string();+ if let Err(e) =+ macro_db_client::share_permission::channel_permission::create::insert_channel_share_permission(+ &self.inner,+ &share_permission_id,+ &channel_id_str,+ &AccessLevel::View,+ )+ .await+ {+ tracing::warn!(error=?e, "channel share permission may already exist, continuing");+ }++ let participants = comms_db_client::participants::get_participants::get_participants(+ &self.inner,+ &channel_id,+ )+ .await?;++ let active_user_ids: Vec<_> = participants+ .into_iter()+ .filter(|p| p.left_at.is_none())+ .map(|p| p.user_id)+ .collect();++ macro_db_client::item_access::insert::upsert_user_item_access_bulk(+ &self.inner,+ &active_user_ids,+ item_id,+ item_type,+ AccessLevel::View,+ Some(channel_id),+ )+ .await?;++ Ok(())+ }+/// Fetch an email link by its ID.#[tracing::instrument(skip(self), err)]pub async fn get_email_link(