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(teams): add in team slug support (#3405)
Will Hutchinsone6f4517fab8e
diff --git a/js/app/packages/queries/team/teams.ts b/js/app/packages/queries/team/teams.tsindex a3e4c170ad..590825f13d 100644--- a/js/app/packages/queries/team/teams.ts+++ b/js/app/packages/queries/team/teams.ts@@ -200,6 +200,7 @@ export function useCreateTeamWithInvitesMutation(const optimisticTeam: Team = {id: `optimistic-${Date.now()}`,name,+ slug: 'MACRO', // optimisitc slugowner_id: userInfo.userId,};diff --git a/js/app/packages/service-clients/service-auth/generated/schemas/index.ts b/js/app/packages/service-clients/service-auth/generated/schemas/index.tsindex 065db87880..9ac98b1df1 100644--- a/js/app/packages/service-clients/service-auth/generated/schemas/index.ts+++ b/js/app/packages/service-clients/service-auth/generated/schemas/index.ts@@ -44,6 +44,7 @@ export * from './patchSubscriptionTierRequest';export * from './patchTeamPlanRequest';export * from './patchTeamRequest';export * from './patchTeamRequestName';+export * from './patchTeamRequestSlug';export * from './patchTeamRequestUserRoleUpdates';export * from './patchTeamUserRole';export * from './patchUserGroupRequest';diff --git a/js/app/packages/service-clients/service-auth/generated/schemas/patchTeamRequest.ts b/js/app/packages/service-clients/service-auth/generated/schemas/patchTeamRequest.tsindex 3e95479fc8..ba6e5fe59b 100644--- a/js/app/packages/service-clients/service-auth/generated/schemas/patchTeamRequest.ts+++ b/js/app/packages/service-clients/service-auth/generated/schemas/patchTeamRequest.ts@@ -5,6 +5,7 @@* OpenAPI spec version: 0.1.0*/import type { PatchTeamRequestName } from './patchTeamRequestName';+import type { PatchTeamRequestSlug } from './patchTeamRequestSlug';import type { PatchTeamRequestUserRoleUpdates } from './patchTeamRequestUserRoleUpdates';/**@@ -13,6 +14,8 @@ import type { PatchTeamRequestUserRoleUpdates } from './patchTeamRequestUserRoleexport interface PatchTeamRequest {/** The new name for the team */name?: PatchTeamRequestName;+ /** The new slug for the team. This is normalized to SCREAMING_SNAKE_CASE. */+ slug?: PatchTeamRequestSlug;/** Role updates to apply to team users */user_role_updates?: PatchTeamRequestUserRoleUpdates;}diff --git a/js/app/packages/service-clients/service-auth/generated/schemas/patchTeamRequestSlug.ts b/js/app/packages/service-clients/service-auth/generated/schemas/patchTeamRequestSlug.tsnew file mode 100644index 0000000000..2c96a31826--- /dev/null+++ b/js/app/packages/service-clients/service-auth/generated/schemas/patchTeamRequestSlug.ts@@ -0,0 +1,11 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * authentication_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * The new slug for the team. This is normalized to SCREAMING_SNAKE_CASE.+ */+export type PatchTeamRequestSlug = string | null;diff --git a/js/app/packages/service-clients/service-auth/generated/schemas/team.ts b/js/app/packages/service-clients/service-auth/generated/schemas/team.tsindex a45b5fe332..1eed38acde 100644--- a/js/app/packages/service-clients/service-auth/generated/schemas/team.ts+++ b/js/app/packages/service-clients/service-auth/generated/schemas/team.ts@@ -12,4 +12,5 @@ export interface Team {id: string;name: string;owner_id: string;+ slug: string;}diff --git a/js/app/packages/service-clients/service-auth/openapi.json b/js/app/packages/service-clients/service-auth/openapi.jsonindex 8de4509c25..abf5cac5da 100644--- a/js/app/packages/service-clients/service-auth/openapi.json+++ b/js/app/packages/service-clients/service-auth/openapi.json@@ -3523,6 +3523,10 @@"type": ["string", "null"],"description": "The new name for the team"},+ "slug": {+ "type": ["string", "null"],+ "description": "The new slug for the team. This is normalized to SCREAMING_SNAKE_CASE."+ },"user_role_updates": {"type": ["array", "null"],"items": {@@ -3718,7 +3722,7 @@"Team": {"type": "object","description": "The Team struct",- "required": ["id", "name", "owner_id"],+ "required": ["id", "name", "slug", "owner_id"],"properties": {"id": {"type": "string",@@ -3729,6 +3733,9 @@},"owner_id": {"type": "string"+ },+ "slug": {+ "type": "string"}}},diff --git a/js/bun.lock b/js/bun.lockindex e2ec2551a9..abb76fa624 100644--- a/js/bun.lock+++ b/js/bun.lock@@ -839,7 +839,7 @@"@img/sharp-win32-x64": ["@img/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-+29YMsqY2/9eFEiW93eqWnuLcWcufowXewwSNIT6UwZdUUCrM3oFjMWH/Z6/TMmb4hlFenmfAVbpWeup2jryCw=="],- "@inkibra/tauri-plugins": ["@inkibra/tauri-plugins@github:macro-inc/tauri-plugins#6152009", { "dependencies": { "react": "^18.3.1", "react-dom": "^18.3.1" } }, "macro-inc-tauri-plugins-6152009"],+ "@inkibra/tauri-plugins": ["@inkibra/tauri-plugins@github:macro-inc/tauri-plugins#6152009", { "dependencies": { "react": "^18.3.1", "react-dom": "^18.3.1" } }, "macro-inc-tauri-plugins-6152009", "sha512-XLN+niDA9BkzrxiZqBjYf+DL4TLoMIcI80ypCowacVfrfAjWt0qLwLkzWVUXjD7k3v0DB/G+BP4OLJNkGygHIw=="],"@inquirer/external-editor": ["@inquirer/[email protected]", "", { "dependencies": { "chardet": "^2.1.1", "iconv-lite": "^0.7.0" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-RWbSrDiYmO4LbejWY7ttpxczuwQyZLBUyygsA9Nsv95hpzUWwnNTVQmAq3xuh7vNwCp07UTmE5i11XAEExx4RA=="],@@ -2565,7 +2565,7 @@"pathval": ["[email protected]", "", {}, "sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ=="],- "pdfjs-dist": ["pdfjs-dist@github:macro-inc/pdf.js#f9b2ce6", { "dependencies": { "dommatrix": "^1.0.3", "web-streams-polyfill": "^3.2.1" }, "peerDependencies": { "worker-loader": "^3.0.8" }, "optionalPeers": ["worker-loader"] }, "macro-inc-pdf.js-f9b2ce6"],+ "pdfjs-dist": ["pdfjs-dist@github:macro-inc/pdf.js#f9b2ce6", { "dependencies": { "dommatrix": "^1.0.3", "web-streams-polyfill": "^3.2.1" }, "peerDependencies": { "worker-loader": "^3.0.8" }, "optionalPeers": ["worker-loader"] }, "macro-inc-pdf.js-f9b2ce6", "sha512-HDFaPbCxLG2GHpf1smUG97nku5aPGBGaCcIbK05dGdp07TBLUlDcXsM4WcE82mO5W4RBPIBVYobX5N/6M6NFrA=="],"performance-now": ["[email protected]", "", {}, "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow=="],diff --git a/rust/cloud-storage/.sqlx/query-00f5c74ee659c3676ea06b0fd5e3ad33905202426458176b9ba7ea8ac99fc3ee.json b/rust/cloud-storage/.sqlx/query-00f5c74ee659c3676ea06b0fd5e3ad33905202426458176b9ba7ea8ac99fc3ee.jsondeleted file mode 100644index f6e849768f..0000000000--- a/rust/cloud-storage/.sqlx/query-00f5c74ee659c3676ea06b0fd5e3ad33905202426458176b9ba7ea8ac99fc3ee.json+++ /dev/null@@ -1,20 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT COUNT(*)\n FROM \"DocumentInstanceModificationData\" dimd\n WHERE \n dimd.\"modificationData\" -> 'highlights' IS NOT NULL\n AND jsonb_typeof(dimd.\"modificationData\" -> 'highlights') = 'object'\n AND dimd.\"modificationData\" -> 'highlights' != '{}';\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "count",- "type_info": "Int8"- }- ],- "parameters": {- "Left": []- },- "nullable": [- null- ]- },- "hash": "00f5c74ee659c3676ea06b0fd5e3ad33905202426458176b9ba7ea8ac99fc3ee"-}diff --git a/rust/cloud-storage/.sqlx/query-050acec4f32b8d9f7e8489a67d626819f39a33f91b635c369e219213afe37668.json b/rust/cloud-storage/.sqlx/query-050acec4f32b8d9f7e8489a67d626819f39a33f91b635c369e219213afe37668.jsondeleted file mode 100644index 4417c165f6..0000000000--- a/rust/cloud-storage/.sqlx/query-050acec4f32b8d9f7e8489a67d626819f39a33f91b635c369e219213afe37668.json+++ /dev/null@@ -1,45 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT team_id, email, team_role as \"team_role!: models_team::TeamRole\"\n FROM team_invite \n WHERE id = $1\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "team_id",- "type_info": "Uuid"- },- {- "ordinal": 1,- "name": "email",- "type_info": "Text"- },- {- "ordinal": 2,- "name": "team_role!: models_team::TeamRole",- "type_info": {- "Custom": {- "name": "team_role",- "kind": {- "Enum": [- "member",- "admin",- "owner"- ]- }- }- }- }- ],- "parameters": {- "Left": [- "Uuid"- ]- },- "nullable": [- false,- false,- false- ]- },- "hash": "050acec4f32b8d9f7e8489a67d626819f39a33f91b635c369e219213afe37668"-}diff --git a/rust/cloud-storage/.sqlx/query-6a4e10be5bba1043622c0cac69f3f74891866fb4828bf00db7ce0f763ff55da4.json b/rust/cloud-storage/.sqlx/query-15f433450a25ed0fb63fa44a1e4d13fb82179f90fbdd99b632a244c24f1ff5d2.jsonsimilarity index 73%rename from rust/cloud-storage/.sqlx/query-6a4e10be5bba1043622c0cac69f3f74891866fb4828bf00db7ce0f763ff55da4.jsonrename to rust/cloud-storage/.sqlx/query-15f433450a25ed0fb63fa44a1e4d13fb82179f90fbdd99b632a244c24f1ff5d2.jsonindex 0469ed3ec7..7c02d0b9f0 100644--- a/rust/cloud-storage/.sqlx/query-6a4e10be5bba1043622c0cac69f3f74891866fb4828bf00db7ce0f763ff55da4.json+++ b/rust/cloud-storage/.sqlx/query-15f433450a25ed0fb63fa44a1e4d13fb82179f90fbdd99b632a244c24f1ff5d2.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n INSERT INTO team (id, name, owner_id, seat_count)\n VALUES ($1, $2, $3, 1)\n RETURNING id, name, owner_id\n ",+ "query": "\n INSERT INTO team (id, name, owner_id, seat_count)\n VALUES ($1, $2, $3, 1)\n RETURNING id, name, slug, owner_id\n ","describe": {"columns": [{@@ -15,6 +15,11 @@},{"ordinal": 2,+ "name": "slug",+ "type_info": "Varchar"+ },+ {+ "ordinal": 3,"name": "owner_id","type_info": "Text"}@@ -27,10 +32,11 @@]},"nullable": [+ false,false,false,false]},- "hash": "6a4e10be5bba1043622c0cac69f3f74891866fb4828bf00db7ce0f763ff55da4"+ "hash": "15f433450a25ed0fb63fa44a1e4d13fb82179f90fbdd99b632a244c24f1ff5d2"}diff --git a/rust/cloud-storage/.sqlx/query-20968294bc4a969511f02809aaa0267da032ee0de31f13d0ed1929550bd8adda.json b/rust/cloud-storage/.sqlx/query-20968294bc4a969511f02809aaa0267da032ee0de31f13d0ed1929550bd8adda.jsondeleted file mode 100644index 7e6ffff347..0000000000--- a/rust/cloud-storage/.sqlx/query-20968294bc4a969511f02809aaa0267da032ee0de31f13d0ed1929550bd8adda.json+++ /dev/null@@ -1,15 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n UPDATE team\n SET name = $1\n WHERE id = $2\n ",- "describe": {- "columns": [],- "parameters": {- "Left": [- "Text",- "Uuid"- ]- },- "nullable": []- },- "hash": "20968294bc4a969511f02809aaa0267da032ee0de31f13d0ed1929550bd8adda"-}diff --git a/rust/cloud-storage/.sqlx/query-2683ed5de04d186f9d997d088e4d371be0b22106450171fbc1cef5ce96fb00b6.json b/rust/cloud-storage/.sqlx/query-2683ed5de04d186f9d997d088e4d371be0b22106450171fbc1cef5ce96fb00b6.jsondeleted file mode 100644index 99c433ede6..0000000000--- a/rust/cloud-storage/.sqlx/query-2683ed5de04d186f9d997d088e4d371be0b22106450171fbc1cef5ce96fb00b6.json+++ /dev/null@@ -1,22 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT name\n FROM team\n WHERE id = $1\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "name",- "type_info": "Text"- }- ],- "parameters": {- "Left": [- "Uuid"- ]- },- "nullable": [- false- ]- },- "hash": "2683ed5de04d186f9d997d088e4d371be0b22106450171fbc1cef5ce96fb00b6"-}diff --git a/rust/cloud-storage/.sqlx/query-31e8eb8fb8d4562d654245be9afd54beff087b85e84ebd5b93c12eb9d7ebc877.json b/rust/cloud-storage/.sqlx/query-31e8eb8fb8d4562d654245be9afd54beff087b85e84ebd5b93c12eb9d7ebc877.jsondeleted file mode 100644index e4f32c45b5..0000000000--- a/rust/cloud-storage/.sqlx/query-31e8eb8fb8d4562d654245be9afd54beff087b85e84ebd5b93c12eb9d7ebc877.json+++ /dev/null@@ -1,14 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n UPDATE team_invite\n SET last_sent_at = NOW()\n WHERE id = $1\n ",- "describe": {- "columns": [],- "parameters": {- "Left": [- "Uuid"- ]- },- "nullable": []- },- "hash": "31e8eb8fb8d4562d654245be9afd54beff087b85e84ebd5b93c12eb9d7ebc877"-}diff --git a/rust/cloud-storage/.sqlx/query-a5aedcffb360128c84269103ae40fa87aa2f14601611e60570808bd0946f5baa.json b/rust/cloud-storage/.sqlx/query-322b3420ee6b76c4b85d1953e2bfb47c8b8ba0618e2833475801815dff29d42b.jsonsimilarity index 60%rename from rust/cloud-storage/.sqlx/query-a5aedcffb360128c84269103ae40fa87aa2f14601611e60570808bd0946f5baa.jsonrename to rust/cloud-storage/.sqlx/query-322b3420ee6b76c4b85d1953e2bfb47c8b8ba0618e2833475801815dff29d42b.jsonindex db46df8eb6..baf375e8ba 100644--- a/rust/cloud-storage/.sqlx/query-a5aedcffb360128c84269103ae40fa87aa2f14601611e60570808bd0946f5baa.json+++ b/rust/cloud-storage/.sqlx/query-322b3420ee6b76c4b85d1953e2bfb47c8b8ba0618e2833475801815dff29d42b.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n SELECT id, name, owner_id\n FROM team\n WHERE id = $1\n ",+ "query": "\n SELECT id, name, slug, owner_id\n FROM team\n WHERE id = $1\n ","describe": {"columns": [{@@ -15,6 +15,11 @@},{"ordinal": 2,+ "name": "slug",+ "type_info": "Varchar"+ },+ {+ "ordinal": 3,"name": "owner_id","type_info": "Text"}@@ -25,10 +30,11 @@]},"nullable": [+ false,false,false,false]},- "hash": "a5aedcffb360128c84269103ae40fa87aa2f14601611e60570808bd0946f5baa"+ "hash": "322b3420ee6b76c4b85d1953e2bfb47c8b8ba0618e2833475801815dff29d42b"}diff --git a/rust/cloud-storage/.sqlx/query-35dd883b5e9798f3946761308fccae6247ea21ab4446b1cd699aafb7290c30e6.json b/rust/cloud-storage/.sqlx/query-35dd883b5e9798f3946761308fccae6247ea21ab4446b1cd699aafb7290c30e6.jsondeleted file mode 100644index 4160d3b1f5..0000000000--- a/rust/cloud-storage/.sqlx/query-35dd883b5e9798f3946761308fccae6247ea21ab4446b1cd699aafb7290c30e6.json+++ /dev/null@@ -1,84 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n INSERT INTO team_invite (id, team_id, email, team_role, invited_by, created_at, last_sent_at)\n VALUES ($1, $2, $3, $4, $5, NOW(), NOW())\n RETURNING id, email, team_id, team_role as \"team_role!: models_team::TeamRole\", invited_by, created_at as \"created_at!: chrono::DateTime<chrono::Utc>\", last_sent_at as \"last_sent_at!: chrono::DateTime<chrono::Utc>\"\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "id",- "type_info": "Uuid"- },- {- "ordinal": 1,- "name": "email",- "type_info": "Text"- },- {- "ordinal": 2,- "name": "team_id",- "type_info": "Uuid"- },- {- "ordinal": 3,- "name": "team_role!: models_team::TeamRole",- "type_info": {- "Custom": {- "name": "team_role",- "kind": {- "Enum": [- "member",- "admin",- "owner"- ]- }- }- }- },- {- "ordinal": 4,- "name": "invited_by",- "type_info": "Text"- },- {- "ordinal": 5,- "name": "created_at!: chrono::DateTime<chrono::Utc>",- "type_info": "Timestamp"- },- {- "ordinal": 6,- "name": "last_sent_at!: chrono::DateTime<chrono::Utc>",- "type_info": "Timestamp"- }- ],- "parameters": {- "Left": [- "Uuid",- "Uuid",- "Text",- {- "Custom": {- "name": "team_role",- "kind": {- "Enum": [- "member",- "admin",- "owner"- ]- }- }- },- "Text"- ]- },- "nullable": [- false,- false,- false,- false,- false,- false,- false- ]- },- "hash": "35dd883b5e9798f3946761308fccae6247ea21ab4446b1cd699aafb7290c30e6"-}diff --git a/rust/cloud-storage/.sqlx/query-6e0240fcbc3f8f086e2529a680a1eee5f2495c0db613c33984e5755936513654.json b/rust/cloud-storage/.sqlx/query-6e0240fcbc3f8f086e2529a680a1eee5f2495c0db613c33984e5755936513654.jsondeleted file mode 100644index c6c06891e2..0000000000--- a/rust/cloud-storage/.sqlx/query-6e0240fcbc3f8f086e2529a680a1eee5f2495c0db613c33984e5755936513654.json+++ /dev/null@@ -1,45 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT\n user_id,\n team_id,\n team_role as \"team_role!: TeamRole\"\n FROM team_user\n WHERE team_id = $1\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "user_id",- "type_info": "Text"- },- {- "ordinal": 1,- "name": "team_id",- "type_info": "Uuid"- },- {- "ordinal": 2,- "name": "team_role!: TeamRole",- "type_info": {- "Custom": {- "name": "team_role",- "kind": {- "Enum": [- "member",- "admin",- "owner"- ]- }- }- }- }- ],- "parameters": {- "Left": [- "Uuid"- ]- },- "nullable": [- false,- false,- false- ]- },- "hash": "6e0240fcbc3f8f086e2529a680a1eee5f2495c0db613c33984e5755936513654"-}diff --git a/rust/cloud-storage/.sqlx/query-7843258fc5ef444237a72be82c1be7ebbd77c6e056cde81c14b5526eef9045c2.json b/rust/cloud-storage/.sqlx/query-7843258fc5ef444237a72be82c1be7ebbd77c6e056cde81c14b5526eef9045c2.jsondeleted file mode 100644index 0f10c737ca..0000000000--- a/rust/cloud-storage/.sqlx/query-7843258fc5ef444237a72be82c1be7ebbd77c6e056cde81c14b5526eef9045c2.json+++ /dev/null@@ -1,69 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT\n id,\n email,\n team_id,\n team_role as \"team_role!: TeamRole\",\n invited_by,\n created_at as \"created_at!: chrono::DateTime<chrono::Utc>\",\n last_sent_at as \"last_sent_at!: chrono::DateTime<chrono::Utc>\"\n FROM team_invite\n WHERE team_id = $1\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "id",- "type_info": "Uuid"- },- {- "ordinal": 1,- "name": "email",- "type_info": "Text"- },- {- "ordinal": 2,- "name": "team_id",- "type_info": "Uuid"- },- {- "ordinal": 3,- "name": "team_role!: TeamRole",- "type_info": {- "Custom": {- "name": "team_role",- "kind": {- "Enum": [- "member",- "admin",- "owner"- ]- }- }- }- },- {- "ordinal": 4,- "name": "invited_by",- "type_info": "Text"- },- {- "ordinal": 5,- "name": "created_at!: chrono::DateTime<chrono::Utc>",- "type_info": "Timestamp"- },- {- "ordinal": 6,- "name": "last_sent_at!: chrono::DateTime<chrono::Utc>",- "type_info": "Timestamp"- }- ],- "parameters": {- "Left": [- "Uuid"- ]- },- "nullable": [- false,- false,- false,- false,- false,- false,- false- ]- },- "hash": "7843258fc5ef444237a72be82c1be7ebbd77c6e056cde81c14b5526eef9045c2"-}diff --git a/rust/cloud-storage/.sqlx/query-7ab64e5cba66fcea21b94760cf7c840a90db5fa8c9cba8247d07b0ef6fa3b004.json b/rust/cloud-storage/.sqlx/query-7ab64e5cba66fcea21b94760cf7c840a90db5fa8c9cba8247d07b0ef6fa3b004.jsondeleted file mode 100644index db6ad1869a..0000000000--- a/rust/cloud-storage/.sqlx/query-7ab64e5cba66fcea21b94760cf7c840a90db5fa8c9cba8247d07b0ef6fa3b004.json+++ /dev/null@@ -1,36 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n INSERT INTO team (id, name, owner_id)\n VALUES ($1, $2, $3)\n RETURNING id, name, owner_id\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "id",- "type_info": "Uuid"- },- {- "ordinal": 1,- "name": "name",- "type_info": "Text"- },- {- "ordinal": 2,- "name": "owner_id",- "type_info": "Text"- }- ],- "parameters": {- "Left": [- "Uuid",- "Text",- "Text"- ]- },- "nullable": [- false,- false,- false- ]- },- "hash": "7ab64e5cba66fcea21b94760cf7c840a90db5fa8c9cba8247d07b0ef6fa3b004"-}diff --git a/rust/cloud-storage/.sqlx/query-8650979421df05be29af8d8b21c16cd01dbdbdbad7cce1333ee8b45d1f55cdfb.json b/rust/cloud-storage/.sqlx/query-8650979421df05be29af8d8b21c16cd01dbdbdbad7cce1333ee8b45d1f55cdfb.jsondeleted file mode 100644index 3bf9054a8a..0000000000--- a/rust/cloud-storage/.sqlx/query-8650979421df05be29af8d8b21c16cd01dbdbdbad7cce1333ee8b45d1f55cdfb.json+++ /dev/null@@ -1,20 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT COUNT(*)\n FROM \"DocumentInstanceModificationData\",\n jsonb_array_elements(\"modificationData\"->'placeables') AS placeable\n WHERE placeable->>'payloadType' = 'thread';\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "count",- "type_info": "Int8"- }- ],- "parameters": {- "Left": []- },- "nullable": [- null- ]- },- "hash": "8650979421df05be29af8d8b21c16cd01dbdbdbad7cce1333ee8b45d1f55cdfb"-}diff --git a/rust/cloud-storage/.sqlx/query-86d18e7e4b32bfa5e0ca2c8048f2e544756b6c60a5745705c726b3269f743c3c.json b/rust/cloud-storage/.sqlx/query-86d18e7e4b32bfa5e0ca2c8048f2e544756b6c60a5745705c726b3269f743c3c.jsondeleted file mode 100644index 41e01db088..0000000000--- a/rust/cloud-storage/.sqlx/query-86d18e7e4b32bfa5e0ca2c8048f2e544756b6c60a5745705c726b3269f743c3c.json+++ /dev/null@@ -1,15 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n INSERT INTO team_user (team_id, user_id, team_role)\n VALUES ($1, $2, 'owner')\n ",- "describe": {- "columns": [],- "parameters": {- "Left": [- "Uuid",- "Text"- ]- },- "nullable": []- },- "hash": "86d18e7e4b32bfa5e0ca2c8048f2e544756b6c60a5745705c726b3269f743c3c"-}diff --git a/rust/cloud-storage/.sqlx/query-88ef62575a41128850e0943150af07a886168487ebe62c651b4cd33e26cf5ea7.json b/rust/cloud-storage/.sqlx/query-88ef62575a41128850e0943150af07a886168487ebe62c651b4cd33e26cf5ea7.jsondeleted file mode 100644index 92d4d68f99..0000000000--- a/rust/cloud-storage/.sqlx/query-88ef62575a41128850e0943150af07a886168487ebe62c651b4cd33e26cf5ea7.json+++ /dev/null@@ -1,15 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n UPDATE team\n SET name = $1\n WHERE id = $2\n ",- "describe": {- "columns": [],- "parameters": {- "Left": [- "Text",- "Uuid"- ]- },- "nullable": []- },- "hash": "88ef62575a41128850e0943150af07a886168487ebe62c651b4cd33e26cf5ea7"-}diff --git a/rust/cloud-storage/.sqlx/query-95de69ef467e5821f5d4f5b632a04a344fa87a00986709ff1b6e04a222ce0795.json b/rust/cloud-storage/.sqlx/query-95de69ef467e5821f5d4f5b632a04a344fa87a00986709ff1b6e04a222ce0795.jsondeleted file mode 100644index 061871fdc7..0000000000--- a/rust/cloud-storage/.sqlx/query-95de69ef467e5821f5d4f5b632a04a344fa87a00986709ff1b6e04a222ce0795.json+++ /dev/null@@ -1,69 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT\n id,\n email,\n team_id,\n team_role as \"team_role!: TeamRole\",\n invited_by,\n created_at as \"created_at!: chrono::DateTime<chrono::Utc>\",\n last_sent_at as \"last_sent_at!: chrono::DateTime<chrono::Utc>\"\n FROM team_invite\n WHERE email = $1\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "id",- "type_info": "Uuid"- },- {- "ordinal": 1,- "name": "email",- "type_info": "Text"- },- {- "ordinal": 2,- "name": "team_id",- "type_info": "Uuid"- },- {- "ordinal": 3,- "name": "team_role!: TeamRole",- "type_info": {- "Custom": {- "name": "team_role",- "kind": {- "Enum": [- "member",- "admin",- "owner"- ]- }- }- }- },- {- "ordinal": 4,- "name": "invited_by",- "type_info": "Text"- },- {- "ordinal": 5,- "name": "created_at!: chrono::DateTime<chrono::Utc>",- "type_info": "Timestamp"- },- {- "ordinal": 6,- "name": "last_sent_at!: chrono::DateTime<chrono::Utc>",- "type_info": "Timestamp"- }- ],- "parameters": {- "Left": [- "Text"- ]- },- "nullable": [- false,- false,- false,- false,- false,- false,- false- ]- },- "hash": "95de69ef467e5821f5d4f5b632a04a344fa87a00986709ff1b6e04a222ce0795"-}diff --git a/rust/cloud-storage/.sqlx/query-eb60dffb5b5eee74b267402d11b05e3c7edb39484f34fb204523df6cd46fa3fe.json b/rust/cloud-storage/.sqlx/query-cba64686023001741b1fa46b747fffa9af9eabd558af03fd0e2a250d29a4a64d.jsonsimilarity index 55%rename from rust/cloud-storage/.sqlx/query-eb60dffb5b5eee74b267402d11b05e3c7edb39484f34fb204523df6cd46fa3fe.jsonrename to rust/cloud-storage/.sqlx/query-cba64686023001741b1fa46b747fffa9af9eabd558af03fd0e2a250d29a4a64d.jsonindex 9ebaeb29e0..fc4e6700ae 100644--- a/rust/cloud-storage/.sqlx/query-eb60dffb5b5eee74b267402d11b05e3c7edb39484f34fb204523df6cd46fa3fe.json+++ b/rust/cloud-storage/.sqlx/query-cba64686023001741b1fa46b747fffa9af9eabd558af03fd0e2a250d29a4a64d.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n SELECT t.id, t.name, t.owner_id\n FROM team t\n JOIN team_user tu ON t.id = tu.team_id\n WHERE tu.user_id = $1\n ",+ "query": "\n SELECT t.id, t.name, t.slug, t.owner_id\n FROM team t\n JOIN team_user tu ON t.id = tu.team_id\n WHERE tu.user_id = $1\n ","describe": {"columns": [{@@ -15,6 +15,11 @@},{"ordinal": 2,+ "name": "slug",+ "type_info": "Varchar"+ },+ {+ "ordinal": 3,"name": "owner_id","type_info": "Text"}@@ -25,10 +30,11 @@]},"nullable": [+ false,false,false,false]},- "hash": "eb60dffb5b5eee74b267402d11b05e3c7edb39484f34fb204523df6cd46fa3fe"+ "hash": "cba64686023001741b1fa46b747fffa9af9eabd558af03fd0e2a250d29a4a64d"}diff --git a/rust/cloud-storage/.sqlx/query-d6b6e32ff0004295738c15f2cf449cf2edec9087e56452c7078c497fcbb90422.json b/rust/cloud-storage/.sqlx/query-d6b6e32ff0004295738c15f2cf449cf2edec9087e56452c7078c497fcbb90422.jsondeleted file mode 100644index de1b867bcf..0000000000--- a/rust/cloud-storage/.sqlx/query-d6b6e32ff0004295738c15f2cf449cf2edec9087e56452c7078c497fcbb90422.json+++ /dev/null@@ -1,69 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT\n id,\n email,\n team_id,\n team_role as \"team_role!: TeamRole\",\n invited_by,\n created_at as \"created_at!: chrono::DateTime<chrono::Utc>\",\n last_sent_at as \"last_sent_at!: chrono::DateTime<chrono::Utc>\"\n FROM team_invite\n WHERE id = $1\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "id",- "type_info": "Uuid"- },- {- "ordinal": 1,- "name": "email",- "type_info": "Text"- },- {- "ordinal": 2,- "name": "team_id",- "type_info": "Uuid"- },- {- "ordinal": 3,- "name": "team_role!: TeamRole",- "type_info": {- "Custom": {- "name": "team_role",- "kind": {- "Enum": [- "member",- "admin",- "owner"- ]- }- }- }- },- {- "ordinal": 4,- "name": "invited_by",- "type_info": "Text"- },- {- "ordinal": 5,- "name": "created_at!: chrono::DateTime<chrono::Utc>",- "type_info": "Timestamp"- },- {- "ordinal": 6,- "name": "last_sent_at!: chrono::DateTime<chrono::Utc>",- "type_info": "Timestamp"- }- ],- "parameters": {- "Left": [- "Uuid"- ]- },- "nullable": [- false,- false,- false,- false,- false,- false,- false- ]- },- "hash": "d6b6e32ff0004295738c15f2cf449cf2edec9087e56452c7078c497fcbb90422"-}diff --git a/rust/cloud-storage/.sqlx/query-d85a61dc12daaeb6515164755b6b3b48822a19d72f4126e5be12bfa34aa22d0f.json b/rust/cloud-storage/.sqlx/query-d85a61dc12daaeb6515164755b6b3b48822a19d72f4126e5be12bfa34aa22d0f.jsondeleted file mode 100644index 1e2772ce54..0000000000--- a/rust/cloud-storage/.sqlx/query-d85a61dc12daaeb6515164755b6b3b48822a19d72f4126e5be12bfa34aa22d0f.json+++ /dev/null@@ -1,34 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT\n id,\n name,\n owner_id\n FROM team\n WHERE id = $1\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "id",- "type_info": "Uuid"- },- {- "ordinal": 1,- "name": "name",- "type_info": "Text"- },- {- "ordinal": 2,- "name": "owner_id",- "type_info": "Text"- }- ],- "parameters": {- "Left": [- "Uuid"- ]- },- "nullable": [- false,- false,- false- ]- },- "hash": "d85a61dc12daaeb6515164755b6b3b48822a19d72f4126e5be12bfa34aa22d0f"-}diff --git a/rust/cloud-storage/.sqlx/query-d9b1cf736916e61816697e8fec5f803458408bf5d03a4bfe18351b0191a2f9e7.json b/rust/cloud-storage/.sqlx/query-d9b1cf736916e61816697e8fec5f803458408bf5d03a4bfe18351b0191a2f9e7.jsondeleted file mode 100644index 4b1f76efda..0000000000--- a/rust/cloud-storage/.sqlx/query-d9b1cf736916e61816697e8fec5f803458408bf5d03a4bfe18351b0191a2f9e7.json+++ /dev/null@@ -1,27 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n INSERT INTO team_user (team_id, user_id, team_role)\n VALUES ($1, $2, $3)\n ",- "describe": {- "columns": [],- "parameters": {- "Left": [- "Uuid",- "Text",- {- "Custom": {- "name": "team_role",- "kind": {- "Enum": [- "member",- "admin",- "owner"- ]- }- }- }- ]- },- "nullable": []- },- "hash": "d9b1cf736916e61816697e8fec5f803458408bf5d03a4bfe18351b0191a2f9e7"-}diff --git a/rust/cloud-storage/.sqlx/query-e74177df51e1bd70b1e0cc19543d3533e96935ca54673f809c0720ea530faeac.json b/rust/cloud-storage/.sqlx/query-e74177df51e1bd70b1e0cc19543d3533e96935ca54673f809c0720ea530faeac.jsondeleted file mode 100644index f7464854d5..0000000000--- a/rust/cloud-storage/.sqlx/query-e74177df51e1bd70b1e0cc19543d3533e96935ca54673f809c0720ea530faeac.json+++ /dev/null@@ -1,14 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n DELETE FROM team_invite\n WHERE id = $1\n ",- "describe": {- "columns": [],- "parameters": {- "Left": [- "Uuid"- ]- },- "nullable": []- },- "hash": "e74177df51e1bd70b1e0cc19543d3533e96935ca54673f809c0720ea530faeac"-}diff --git a/rust/cloud-storage/.sqlx/query-effa102b8b4009d40fb90ed8471199aae934ce6e23a5b8c5dc7d2cd0c4c8577a.json b/rust/cloud-storage/.sqlx/query-effa102b8b4009d40fb90ed8471199aae934ce6e23a5b8c5dc7d2cd0c4c8577a.jsondeleted file mode 100644index b699ae57f9..0000000000--- a/rust/cloud-storage/.sqlx/query-effa102b8b4009d40fb90ed8471199aae934ce6e23a5b8c5dc7d2cd0c4c8577a.json+++ /dev/null@@ -1,20 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT \"modificationData\" as \"modification_data\"\n FROM \"DocumentInstanceModificationData\"\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "modification_data",- "type_info": "Jsonb"- }- ],- "parameters": {- "Left": []- },- "nullable": [- false- ]- },- "hash": "effa102b8b4009d40fb90ed8471199aae934ce6e23a5b8c5dc7d2cd0c4c8577a"-}diff --git a/rust/cloud-storage/.sqlx/query-f563f31f8ae4a8aa31c1753bcdb3e57e37cf0accc398cde5340483b03f749893.json b/rust/cloud-storage/.sqlx/query-f563f31f8ae4a8aa31c1753bcdb3e57e37cf0accc398cde5340483b03f749893.jsondeleted file mode 100644index 317349cb37..0000000000--- a/rust/cloud-storage/.sqlx/query-f563f31f8ae4a8aa31c1753bcdb3e57e37cf0accc398cde5340483b03f749893.json+++ /dev/null@@ -1,34 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT team_role as \"team_role!: TeamRole\"\n FROM team_user\n WHERE team_id = $1 AND user_id = $2\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "team_role!: TeamRole",- "type_info": {- "Custom": {- "name": "team_role",- "kind": {- "Enum": [- "member",- "admin",- "owner"- ]- }- }- }- }- ],- "parameters": {- "Left": [- "Uuid",- "Text"- ]- },- "nullable": [- false- ]- },- "hash": "f563f31f8ae4a8aa31c1753bcdb3e57e37cf0accc398cde5340483b03f749893"-}diff --git a/rust/cloud-storage/CLAUDE.md b/rust/cloud-storage/CLAUDE.mdindex 466fff9933..bdd60be6e5 100644--- a/rust/cloud-storage/CLAUDE.md+++ b/rust/cloud-storage/CLAUDE.md@@ -240,6 +240,8 @@ The migration included comprehensive indexes:### Database Query Management+- Prefer SQLx compile-time checked macros (`query!`, `query_as!`, `query_scalar!`) for database queries whenever possible instead of dynamic `sqlx::query` calls.+- Never manually create or edit `.sqlx/query-*.json` files. To update SQLx query metadata, run `just prepare_db` from `rust/cloud-storage`.- Always run tests between changes that involve changes to db queries- Never run `cargo test` with `SQLX_OFFLINE=true`. Tests are designed to validate against the live local Postgres; offline mode forces sqlx macros to consult the cached `.sqlx` data and can either surface confusing "type annotations needed" errors when a query was not in the cache or hide regressions where a query no longer matches the schema. If tests fail with sqlx "no cached data" errors, run `just prepare_db` (with `--tests` when the failure is in test code) — do not flip offline mode on. `SQLX_OFFLINE=true` is fine for `cargo check` / `cargo build` / `cargo clippy` only.diff --git a/rust/cloud-storage/macro_db_client/migrations/20260520120000_add_team_slug.sql b/rust/cloud-storage/macro_db_client/migrations/20260520120000_add_team_slug.sqlnew file mode 100644index 0000000000..d8fd34544a--- /dev/null+++ b/rust/cloud-storage/macro_db_client/migrations/20260520120000_add_team_slug.sql@@ -0,0 +1,3 @@+ALTER TABLE team+ ADD COLUMN slug VARCHAR(20) NOT NULL DEFAULT 'MACRO',+ ADD CONSTRAINT team_slug_format_check CHECK (slug ~ '^[A-Z]+(_[A-Z]+)*$');diff --git a/rust/cloud-storage/macro_db_client/src/team/create.rs b/rust/cloud-storage/macro_db_client/src/team/create.rsdeleted file mode 100644index 8353ea0413..0000000000--- a/rust/cloud-storage/macro_db_client/src/team/create.rs+++ /dev/null@@ -1,121 +0,0 @@-/// Creates a new team-pub async fn create_team(- db: &sqlx::Pool<sqlx::Postgres>,- user_id: &str,- name: &str,-) -> anyhow::Result<models_team::Team> {- let mut transaction = db.begin().await?;-- let id = macro_uuid::generate_uuid_v7();-- let team = sqlx::query_as!(- models_team::Team,- r#"- INSERT INTO team (id, name, owner_id)- VALUES ($1, $2, $3)- RETURNING id, name, owner_id- "#,- &id,- name,- user_id,- )- .fetch_one(&mut *transaction)- .await?;-- sqlx::query!(- r#"- INSERT INTO team_user (team_id, user_id, team_role)- VALUES ($1, $2, 'owner')- "#,- &team.id,- user_id,- )- .execute(&mut *transaction)- .await?;-- transaction.commit().await?;-- Ok(team)-}--pub async fn join_team(- db: &sqlx::Pool<sqlx::Postgres>,- team_invite_id: &uuid::Uuid,-) -> anyhow::Result<()> {- let mut transaction = db.begin().await?;-- // lookup if invite exists- let (team_id, email, team_role) = sqlx::query!(- r#"- SELECT team_id, email, team_role as "team_role!: models_team::TeamRole"- FROM team_invite- WHERE id = $1- "#,- &team_invite_id,- )- .map(|r| (r.team_id, r.email, r.team_role))- .fetch_one(&mut *transaction)- .await?;-- let macro_user_profile_id = format!("macro|{email}");-- // Create team user- sqlx::query!(- r#"- INSERT INTO team_user (team_id, user_id, team_role)- VALUES ($1, $2, $3)- "#,- &team_id,- ¯o_user_profile_id,- &team_role as _,- )- .execute(&mut *transaction)- .await?;-- // Delete invite- sqlx::query!(- r#"- DELETE FROM team_invite- WHERE id = $1- "#,- &team_invite_id,- )- .execute(&mut *transaction)- .await?;-- transaction.commit().await?;-- Ok(())-}--/// Creates a new team invite-#[tracing::instrument(skip(db))]-pub async fn create_team_invite(- db: &sqlx::Pool<sqlx::Postgres>,- team_id: &str,- email: &str,- team_role: &models_team::TeamRole,- user_id: &str,-) -> anyhow::Result<models_team::TeamInvite> {- let id = macro_uuid::generate_uuid_v7();-- let team_id = macro_uuid::string_to_uuid(team_id)?;-- let team_invite = sqlx::query_as!(- models_team::TeamInvite,- r#"- INSERT INTO team_invite (id, team_id, email, team_role, invited_by, created_at, last_sent_at)- VALUES ($1, $2, $3, $4, $5, NOW(), NOW())- RETURNING id, email, team_id, team_role as "team_role!: models_team::TeamRole", invited_by, created_at as "created_at!: chrono::DateTime<chrono::Utc>", last_sent_at as "last_sent_at!: chrono::DateTime<chrono::Utc>"- "#,- &id,- &team_id,- email,- team_role as _,- user_id,- )- .fetch_one(db)- .await?;-- Ok(team_invite)-}diff --git a/rust/cloud-storage/macro_db_client/src/team/get.rs b/rust/cloud-storage/macro_db_client/src/team/get.rsindex 84fd046c50..6f75a4efb7 100644--- a/rust/cloud-storage/macro_db_client/src/team/get.rs+++ b/rust/cloud-storage/macro_db_client/src/team/get.rs@@ -1,53 +1,4 @@-use models_team::{Team, TeamInvite, TeamRole, TeamUser, TeamWithUsers};--/// Gets the name of a team by ID-#[tracing::instrument(skip(db))]-pub async fn get_team_name(- db: &sqlx::Pool<sqlx::Postgres>,- team_id: &uuid::Uuid,-) -> anyhow::Result<String> {- let team_name = sqlx::query!(- r#"- SELECT name- FROM team- WHERE id = $1- "#,- team_id,- )- .map(|row| row.name)- .fetch_one(db)- .await?;-- Ok(team_name)-}--pub async fn get_user_team_invites(- db: &sqlx::Pool<sqlx::Postgres>,- user_id: &str,-) -> anyhow::Result<Vec<TeamInvite>> {- let email = user_id.replace("macro|", "");-- let invites = sqlx::query_as!(- TeamInvite,- r#"- SELECT- id,- email,- team_id,- team_role as "team_role!: TeamRole",- invited_by,- created_at as "created_at!: chrono::DateTime<chrono::Utc>",- last_sent_at as "last_sent_at!: chrono::DateTime<chrono::Utc>"- FROM team_invite- WHERE email = $1- "#,- &email,- )- .fetch_all(db)- .await?;-- Ok(invites)-}+use models_team::Team;pub async fn get_user_teams(db: &sqlx::Pool<sqlx::Postgres>,@@ -71,122 +22,3 @@ pub async fn get_user_teams(Ok(teams)}--/// Gets a team and it's users by ID-#[tracing::instrument(skip(db))]-pub async fn get_team_by_id(- db: &sqlx::Pool<sqlx::Postgres>,- team_id: &uuid::Uuid,-) -> anyhow::Result<TeamWithUsers> {- let team = sqlx::query_as!(- Team,- r#"- SELECT- id,- name,- owner_id- FROM team- WHERE id = $1- "#,- &team_id,- )- .fetch_one(db)- .await?;-- let users = sqlx::query_as!(- TeamUser,- r#"- SELECT- user_id,- team_id,- team_role as "team_role!: TeamRole"- FROM team_user- WHERE team_id = $1- "#,- &team_id,- )- .fetch_all(db)- .await?;-- let team_with_users = TeamWithUsers { team, users };-- Ok(team_with_users)-}--/// Gets the team role of a user-#[tracing::instrument(skip(db))]-pub async fn get_team_role(- db: &sqlx::Pool<sqlx::Postgres>,- team_id: &uuid::Uuid,- user_id: &str,-) -> anyhow::Result<Option<TeamRole>> {- let team_role = sqlx::query!(- r#"- SELECT team_role as "team_role!: TeamRole"- FROM team_user- WHERE team_id = $1 AND user_id = $2- "#,- &team_id,- user_id,- )- .map(|r| r.team_role)- .fetch_optional(db)- .await?;-- Ok(team_role)-}--/// Gets all invites for a team.-#[tracing::instrument(skip(db))]-pub async fn get_team_invites(- db: &sqlx::Pool<sqlx::Postgres>,- team_id: &uuid::Uuid,-) -> anyhow::Result<Vec<TeamInvite>> {- let invites = sqlx::query_as!(- TeamInvite,- r#"- SELECT- id,- email,- team_id,- team_role as "team_role!: TeamRole",- invited_by,- created_at as "created_at!: chrono::DateTime<chrono::Utc>",- last_sent_at as "last_sent_at!: chrono::DateTime<chrono::Utc>"- FROM team_invite- WHERE team_id = $1- "#,- &team_id,- )- .fetch_all(db)- .await?;-- Ok(invites)-}--#[tracing::instrument(skip(db))]-pub async fn get_team_invite_by_id(- db: &sqlx::Pool<sqlx::Postgres>,- team_invite_id: &uuid::Uuid,-) -> anyhow::Result<TeamInvite> {- let team_invite = sqlx::query_as!(- TeamInvite,- r#"- SELECT- id,- email,- team_id,- team_role as "team_role!: TeamRole",- invited_by,- created_at as "created_at!: chrono::DateTime<chrono::Utc>",- last_sent_at as "last_sent_at!: chrono::DateTime<chrono::Utc>"- FROM team_invite- WHERE id = $1- "#,- &team_invite_id,- )- .fetch_one(db)- .await?;-- Ok(team_invite)-}diff --git a/rust/cloud-storage/macro_db_client/src/team/mod.rs b/rust/cloud-storage/macro_db_client/src/team/mod.rsindex 2e39f0cc79..125ca70d5d 100644--- a/rust/cloud-storage/macro_db_client/src/team/mod.rs+++ b/rust/cloud-storage/macro_db_client/src/team/mod.rs@@ -1,3 +1 @@-pub mod create;pub mod get;-pub mod patch;diff --git a/rust/cloud-storage/macro_db_client/src/team/patch.rs b/rust/cloud-storage/macro_db_client/src/team/patch.rsdeleted file mode 100644index 0d69cf8598..0000000000--- a/rust/cloud-storage/macro_db_client/src/team/patch.rs+++ /dev/null@@ -1,78 +0,0 @@-/// Updates a team.-#[tracing::instrument(skip(db))]-pub async fn patch_team(- db: &sqlx::Pool<sqlx::Postgres>,- team_id: &uuid::Uuid,- req: &models_team::PatchTeamRequest,-) -> anyhow::Result<()> {- let mut transaction = db.begin().await?;-- if let Some(name) = req.name.as_ref() {- sqlx::query!(- r#"- UPDATE team- SET name = $1- WHERE id = $2- "#,- name,- &team_id,- )- .execute(&mut *transaction)- .await?;- }-- transaction.commit().await?;-- Ok(())-}--pub async fn update_team_invite_last_sent_at(- db: &sqlx::Pool<sqlx::Postgres>,- team_invite_id: &uuid::Uuid,-) -> anyhow::Result<()> {- sqlx::query!(- r#"- UPDATE team_invite- SET last_sent_at = NOW()- WHERE id = $1- "#,- team_invite_id,- )- .execute(db)- .await?;-- Ok(())-}--#[cfg(test)]-mod tests {- use super::*;- use sqlx::{Pool, Postgres};-- #[sqlx::test(fixtures(path = "../../fixtures", scripts("team")))]- async fn test_patch_team(pool: Pool<Postgres>) -> anyhow::Result<()> {- let team_id = macro_uuid::string_to_uuid("11111111-1111-1111-1111-111111111111")?;- let req = models_team::PatchTeamRequest {- name: Some("new name".to_string()),- };-- patch_team(&pool, &team_id, &req).await?;-- let name = sqlx::query!(- r#"- SELECT- name- FROM team- WHERE id = $1- "#,- &team_id,- )- .map(|row| row.name)- .fetch_one(&pool)- .await?;-- assert_eq!(name, "new name");-- Ok(())- }-}diff --git a/rust/cloud-storage/teams/src/domain/model.rs b/rust/cloud-storage/teams/src/domain/model.rsindex 038b7bfb08..56b7629a30 100644--- a/rust/cloud-storage/teams/src/domain/model.rs+++ b/rust/cloud-storage/teams/src/domain/model.rs@@ -147,6 +147,8 @@ pub struct TeamInviteDetails {pub struct PatchTeamRequest {/// The new name for the teampub name: Option<String>,+ /// The new slug for the team. This is normalized to SCREAMING_SNAKE_CASE.+ pub slug: Option<String>,/// Role updates to apply to team userspub user_role_updates: Option<Vec<PatchTeamUserRole>>,}@@ -205,14 +207,25 @@ pub struct TeamCheckoutSessionRequest {pub struct Team {pub(crate) id: uuid::Uuid,pub(crate) name: String,+ pub(crate) slug: String,#[cfg_attr(feature = "axum", schema(value_type = String))]pub(crate) owner_id: MacroUserIdStr<'static>,}impl Team {/// Creates a new Team- pub fn new(id: uuid::Uuid, name: String, owner_id: MacroUserIdStr<'static>) -> Self {- Self { id, name, owner_id }+ pub fn new(+ id: uuid::Uuid,+ name: String,+ slug: String,+ owner_id: MacroUserIdStr<'static>,+ ) -> Self {+ Self {+ id,+ name,+ slug,+ owner_id,+ }}}@@ -227,6 +240,11 @@ impl Team {&self.name}+ /// The slug of the team+ pub fn slug(&self) -> &str {+ &self.slug+ }+/// The owner id of the teampub fn owner_id(&self) -> &str {self.owner_id.as_ref()diff --git a/rust/cloud-storage/teams/src/domain/team_service/test.rs b/rust/cloud-storage/teams/src/domain/team_service/test.rsindex 518c5234f0..ef5cd89b3b 100644--- a/rust/cloud-storage/teams/src/domain/team_service/test.rs+++ b/rust/cloud-storage/teams/src/domain/team_service/test.rs@@ -59,7 +59,7 @@ struct MockTeamRepository {fail_rollback_accept: bool,fail_rollback_remove: bool,patch_team_user_role_calls: Arc<Mutex<Vec<(uuid::Uuid, String, TeamRole)>>>,- patch_team_name_calls: Arc<Mutex<Vec<(uuid::Uuid, Option<String>)>>>,+ patch_team_name_calls: Arc<Mutex<Vec<(uuid::Uuid, Option<String>, Option<String>)>>>,}impl MockTeamRepository {@@ -319,10 +319,11 @@ impl TeamRepository for MockTeamRepository {team_id: &uuid::Uuid,req: &PatchTeamRequest,) -> impl Future<Output = Result<(), TeamError>> + Send {- self.patch_team_name_calls- .lock()- .unwrap()- .push((*team_id, req.name.clone()));+ self.patch_team_name_calls.lock().unwrap().push((+ *team_id,+ req.name.clone(),+ req.slug.clone(),+ ));async { Ok(()) }}@@ -721,7 +722,7 @@ fn build_service_with_team() -> (impl TeamService,Arc<Mutex<Vec<(uuid::Uuid, String, TeamRole)>>>,- Arc<Mutex<Vec<(uuid::Uuid, Option<String>)>>>,+ Arc<Mutex<Vec<(uuid::Uuid, Option<String>, Option<String>)>>>,) {let mark_sent_calls: Arc<Mutex<Vec<Vec<uuid::Uuid>>>> = Arc::new(Mutex::new(Vec::new()));let team_repo =@@ -746,12 +747,18 @@ async fn test_patch_team_rejects_owner_role_assignment() {let owner_id = MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap().into_owned();- let team = Team::new(team_id, "Test Team".to_string(), owner_id);+ let team = Team::new(+ team_id,+ "Test Team".to_string(),+ "TEST_TEAM".to_string(),+ owner_id,+ );let (service, role_calls, name_calls) = build_service_with_team(team);let req = PatchTeamRequest {name: Some("New Name".to_string()),+ slug: Some("new-team".to_string()),user_role_updates: Some(vec![PatchTeamUserRole {team_user_id: MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap()@@ -777,12 +784,18 @@ async fn test_patch_team_rejects_owner_downgrade() {let owner_id = MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap().into_owned();- let team = Team::new(team_id, "Test Team".to_string(), owner_id.clone());+ let team = Team::new(+ team_id,+ "Test Team".to_string(),+ "TEST_TEAM".to_string(),+ owner_id.clone(),+ );let (service, role_calls, name_calls) = build_service_with_team(team);let req = PatchTeamRequest {name: None,+ slug: None,user_role_updates: Some(vec![PatchTeamUserRole {team_user_id: owner_id.clone(),role: TeamRole::Member,@@ -809,12 +822,18 @@ async fn test_patch_team_applies_role_updates_and_name() {let admin_id = MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap().into_owned();- let team = Team::new(team_id, "Old Name".to_string(), owner_id.clone());+ let team = Team::new(+ team_id,+ "Old Name".to_string(),+ "OLD_NAME".to_string(),+ owner_id.clone(),+ );let (service, role_calls, name_calls) = build_service_with_team(team);let req = PatchTeamRequest {name: Some("New Name".to_string()),+ slug: Some("new-team slug".to_string()),user_role_updates: Some(vec![PatchTeamUserRole {team_user_id: member_id.clone(),@@ -843,7 +862,14 @@ async fn test_patch_team_applies_role_updates_and_name() {let name_calls = name_calls.lock().unwrap();assert_eq!(name_calls.len(), 1);- assert_eq!(name_calls[0], (team_id, Some("New Name".to_string())));+ assert_eq!(+ name_calls[0],+ (+ team_id,+ Some("New Name".to_string()),+ Some("new-team slug".to_string())+ )+ );}/// Empty user_role_updates vec is a no-op for roles but still applies name.@@ -853,12 +879,18 @@ async fn test_patch_team_empty_role_updates() {let owner_id = MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap().into_owned();- let team = Team::new(team_id, "Old Name".to_string(), owner_id.clone());+ let team = Team::new(+ team_id,+ "Old Name".to_string(),+ "OLD_NAME".to_string(),+ owner_id.clone(),+ );let (service, role_calls, name_calls) = build_service_with_team(team);let req = PatchTeamRequest {name: Some("New Name".to_string()),+ slug: None,user_role_updates: Some(Vec::new()),};@@ -868,5 +900,5 @@ async fn test_patch_team_empty_role_updates() {assert!(role_calls.lock().unwrap().is_empty());let name_calls = name_calls.lock().unwrap();assert_eq!(name_calls.len(), 1);- assert_eq!(name_calls[0], (team_id, Some("New Name".to_string())));+ assert_eq!(name_calls[0], (team_id, Some("New Name".to_string()), None));}diff --git a/rust/cloud-storage/teams/src/outbound/team_repo.rs b/rust/cloud-storage/teams/src/outbound/team_repo.rsindex 7bf0826583..a2f2826530 100644--- a/rust/cloud-storage/teams/src/outbound/team_repo.rs+++ b/rust/cloud-storage/teams/src/outbound/team_repo.rs@@ -21,6 +21,54 @@ fn type_err<E: std::fmt::Display>(e: E) -> sqlx::Error {}}+const MAX_TEAM_SLUG_LEN: usize = 20;++fn normalize_team_slug(slug: &str) -> Result<String, TeamError> {+ let mut normalized = String::new();+ let mut last_was_separator = false;++ for ch in slug.chars() {+ let normalized_char = if ch.is_ascii_alphabetic() {+ ch.to_ascii_uppercase()+ } else if ch == '_' || ch == '-' || ch.is_ascii_whitespace() {+ '_'+ } else {+ return Err(TeamError::BadRequest(+ "team slug may only contain ASCII letters, spaces, hyphens, and underscores"+ .to_string(),+ ));+ };++ if normalized_char == '_' {+ if !normalized.is_empty() && !last_was_separator {+ normalized.push('_');+ }+ last_was_separator = true;+ } else {+ normalized.push(normalized_char);+ last_was_separator = false;+ }+ }++ while normalized.ends_with('_') {+ normalized.pop();+ }++ if normalized.is_empty() {+ return Err(TeamError::BadRequest(+ "team slug cannot be empty".to_string(),+ ));+ }++ if normalized.len() > MAX_TEAM_SLUG_LEN {+ return Err(TeamError::BadRequest(format!(+ "team slug cannot be longer than {MAX_TEAM_SLUG_LEN} characters"+ )));+ }++ Ok(normalized)+}+#[cfg(test)]mod test;@@ -96,9 +144,9 @@ impl TeamRepositoryImpl {r#"INSERT INTO team (id, name, owner_id, seat_count)VALUES ($1, $2, $3, 1)- RETURNING id, name, owner_id+ RETURNING id, name, slug, owner_id"#,- &id,+ id,team_name,user_id.as_ref(),)@@ -106,6 +154,7 @@ impl TeamRepositoryImpl {Ok(Team {id: row.id,name: row.name,+ slug: row.slug,owner_id: MacroUserIdStr::parse_from_str(&row.owner_id).map_err(type_err)?.into_owned(),@@ -899,7 +948,7 @@ impl TeamRepository for TeamRepositoryImpl {async fn get_team_by_id(&self, team_id: &uuid::Uuid) -> Result<TeamWithMembers, TeamError> {let team = sqlx::query!(r#"- SELECT id, name, owner_id+ SELECT id, name, slug, owner_idFROM teamWHERE id = $1"#,@@ -909,6 +958,7 @@ impl TeamRepository for TeamRepositoryImpl {Ok(Team {id: row.id,name: row.name,+ slug: row.slug,owner_id: MacroUserIdStr::parse_from_str(&row.owner_id).map_err(type_err)?.into_owned(),@@ -949,7 +999,7 @@ impl TeamRepository for TeamRepositoryImpl {async fn get_user_teams(&self, user_id: &MacroUserIdStr<'_>) -> Result<Vec<Team>, TeamError> {let teams = sqlx::query!(r#"- SELECT t.id, t.name, t.owner_id+ SELECT t.id, t.name, t.slug, t.owner_idFROM team tJOIN team_user tu ON t.id = tu.team_idWHERE tu.user_id = $1@@ -960,6 +1010,7 @@ impl TeamRepository for TeamRepositoryImpl {Ok(Team {id: row.id,name: row.name,+ slug: row.slug,owner_id: MacroUserIdStr::parse_from_str(&row.owner_id).map_err(type_err)?.into_owned(),@@ -1066,18 +1117,27 @@ impl TeamRepository for TeamRepositoryImpl {team_id: &uuid::Uuid,req: &PatchTeamRequest,) -> Result<(), TeamError> {- if let Some(name) = req.name.as_ref() {- sqlx::query!(+ let normalized_slug = req.slug.as_deref().map(normalize_team_slug).transpose()?;++ if req.name.is_some() || normalized_slug.is_some() {+ let result = sqlx::query(r#"UPDATE team- SET name = $1- WHERE id = $2+ SET+ name = COALESCE($2, name),+ slug = COALESCE($3, slug)+ WHERE id = $1"#,- name,- team_id,)+ .bind(team_id)+ .bind(req.name.as_deref())+ .bind(normalized_slug.as_deref()).execute(&self.pool).await?;++ if result.rows_affected() == 0 {+ return Err(TeamError::TeamDoesNotExist);+ }}Ok(())diff --git a/rust/cloud-storage/teams/src/outbound/team_repo/test.rs b/rust/cloud-storage/teams/src/outbound/team_repo/test.rsindex e90b28758d..0f731fd742 100644--- a/rust/cloud-storage/teams/src/outbound/team_repo/test.rs+++ b/rust/cloud-storage/teams/src/outbound/team_repo/test.rs@@ -106,6 +106,7 @@ async fn test_create_team(pool: Pool<Postgres>) -> anyhow::Result<()> {assert!(!result.id.to_string().is_empty());assert_eq!(result.name, "team1");+ assert_eq!(result.slug, "MACRO");assert_eq!(result.owner_id.0.as_ref(), "macro|[email protected]");// Create team with too large a name@@ -950,6 +951,99 @@ async fn test_patch_team_plan(pool: Pool<Postgres>) -> anyhow::Result<()> {Ok(())}+#[sqlx::test(+ migrator = "MACRO_DB_MIGRATIONS",+ fixtures(path = "../../../fixtures", scripts("teams"))+)]+async fn test_get_team_by_id_includes_slug(pool: Pool<Postgres>) -> anyhow::Result<()> {+ let team_repo = TeamRepositoryImpl::new(pool);+ let team_id = macro_uuid::string_to_uuid("11111111-1111-1111-1111-111111111111")?;++ let team = team_repo.get_team_by_id(&team_id).await?.team;++ assert_eq!(team.name(), "team1");+ assert_eq!(team.slug(), "MACRO");++ Ok(())+}++#[sqlx::test(+ migrator = "MACRO_DB_MIGRATIONS",+ fixtures(path = "../../../fixtures", scripts("teams"))+)]+async fn test_patch_team_normalizes_slug_to_screaming_snake_case(+ pool: Pool<Postgres>,+) -> anyhow::Result<()> {+ let team_repo = TeamRepositoryImpl::new(pool.clone());+ let team_id = macro_uuid::string_to_uuid("11111111-1111-1111-1111-111111111111")?;+ let req = PatchTeamRequest {+ name: Some("New Name".to_string()),+ slug: Some("my-team slug".to_string()),+ user_role_updates: None,+ };++ team_repo.patch_team(&team_id, &req).await?;++ let row = sqlx::query(r#"SELECT name, slug FROM team WHERE id = $1"#)+ .bind(team_id)+ .fetch_one(&pool)+ .await?;++ assert_eq!(row.try_get::<String, _>("name")?, "New Name");+ assert_eq!(row.try_get::<String, _>("slug")?, "MY_TEAM_SLUG");++ Ok(())+}++#[sqlx::test(+ migrator = "MACRO_DB_MIGRATIONS",+ fixtures(path = "../../../fixtures", scripts("teams"))+)]+async fn test_patch_team_rejects_invalid_slug_without_updating_name(+ pool: Pool<Postgres>,+) -> anyhow::Result<()> {+ let team_repo = TeamRepositoryImpl::new(pool.clone());+ let team_id = macro_uuid::string_to_uuid("11111111-1111-1111-1111-111111111111")?;+ let req = PatchTeamRequest {+ name: Some("Should Not Apply".to_string()),+ slug: Some("bad.slug".to_string()),+ user_role_updates: None,+ };++ let err = team_repo.patch_team(&team_id, &req).await.err().unwrap();+ assert!(matches!(err, TeamError::BadRequest(_)));++ let row = sqlx::query(r#"SELECT name, slug FROM team WHERE id = $1"#)+ .bind(team_id)+ .fetch_one(&pool)+ .await?;++ assert_eq!(row.try_get::<String, _>("name")?, "team1");+ assert_eq!(row.try_get::<String, _>("slug")?, "MACRO");++ Ok(())+}++#[sqlx::test(+ migrator = "MACRO_DB_MIGRATIONS",+ fixtures(path = "../../../fixtures", scripts("teams"))+)]+async fn test_patch_team_rejects_too_long_slug(pool: Pool<Postgres>) -> anyhow::Result<()> {+ let team_repo = TeamRepositoryImpl::new(pool);+ let team_id = macro_uuid::string_to_uuid("11111111-1111-1111-1111-111111111111")?;+ let req = PatchTeamRequest {+ name: None,+ slug: Some("THIS_SLUG_IS_WAY_TOO_LONG".to_string()),+ user_role_updates: None,+ };++ let err = team_repo.patch_team(&team_id, &req).await.err().unwrap();++ assert!(matches!(err, TeamError::BadRequest(_)));++ Ok(())+}+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS",fixtures(path = "../../../fixtures", scripts("teams"))