Skip to content

armgit / macro

Public Imported from GitHub
0

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

feat(documents): move edit document to documents hex (#1857)

Will Hutchinsonc2e8f07cc43f
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/editDocumentRequestV2.ts b/js/app/packages/service-clients/service-storage/generated/schemas/editDocumentRequestV2.ts
deleted file mode 100644
index ffc7bc0961..0000000000
--- a/js/app/packages/service-clients/service-storage/generated/schemas/editDocumentRequestV2.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-/**
- * Generated by orval v7.13.0 🍺
- * Do not edit manually.
- * document_storage_service
- * OpenAPI spec version: 0.1.0
- */
-import type { EditDocumentRequestV2DocumentName } from './editDocumentRequestV2DocumentName';
-import type { EditDocumentRequestV2ProjectId } from './editDocumentRequestV2ProjectId';
-import type { EditDocumentRequestV2SharePermission } from './editDocumentRequestV2SharePermission';
-
-export interface EditDocumentRequestV2 {
- /** The name of the document */
- documentName?: EditDocumentRequestV2DocumentName;
- /** The new project id of the document.
-This will also update the documents permissions to match the project it is going into */
- projectId?: EditDocumentRequestV2ProjectId;
- sharePermission?: EditDocumentRequestV2SharePermission;
-}
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/editDocumentResponse.ts b/js/app/packages/service-clients/service-storage/generated/schemas/editDocumentResponse.ts
new file mode 100644
index 0000000000..687fd50f80
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/editDocumentResponse.ts
@@ -0,0 +1,17 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { GenericSuccessResponse } from './genericSuccessResponse';
+
+/**
+ * Edit document response.
+ */
+export interface EditDocumentResponse {
+ /** The response data. */
+ data: GenericSuccessResponse;
+ /** Whether an error occurred. */
+ error: boolean;
+}
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/editDocumentServiceArgs.ts b/js/app/packages/service-clients/service-storage/generated/schemas/editDocumentServiceArgs.ts
new file mode 100644
index 0000000000..975f98f5ee
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/editDocumentServiceArgs.ts
@@ -0,0 +1,20 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { EditDocumentServiceArgsDocumentName } from './editDocumentServiceArgsDocumentName';
+import type { EditDocumentServiceArgsProjectId } from './editDocumentServiceArgsProjectId';
+import type { EditDocumentServiceArgsSharePermission } from './editDocumentServiceArgsSharePermission';
+
+/**
+ * Arguments for the edit_document service call.
+ */
+export interface EditDocumentServiceArgs {
+ /** The name of the document. */
+ documentName?: EditDocumentServiceArgsDocumentName;
+ /** The new project id of the document. */
+ projectId?: EditDocumentServiceArgsProjectId;
+ sharePermission?: EditDocumentServiceArgsSharePermission;
+}
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/editDocumentRequestV2DocumentName.ts b/js/app/packages/service-clients/service-storage/generated/schemas/editDocumentServiceArgsDocumentName.ts
similarity index 59%
rename from js/app/packages/service-clients/service-storage/generated/schemas/editDocumentRequestV2DocumentName.ts
rename to js/app/packages/service-clients/service-storage/generated/schemas/editDocumentServiceArgsDocumentName.ts
index b99f500724..5cc1f551b6 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/editDocumentRequestV2DocumentName.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/editDocumentServiceArgsDocumentName.ts
@@ -6,6 +6,6 @@
*/
/**
- * The name of the document
+ * The name of the document.
*/
-export type EditDocumentRequestV2DocumentName = string | null;
+export type EditDocumentServiceArgsDocumentName = string | null;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/editDocumentRequestV2ProjectId.ts b/js/app/packages/service-clients/service-storage/generated/schemas/editDocumentServiceArgsProjectId.ts
similarity index 54%
rename from js/app/packages/service-clients/service-storage/generated/schemas/editDocumentRequestV2ProjectId.ts
rename to js/app/packages/service-clients/service-storage/generated/schemas/editDocumentServiceArgsProjectId.ts
index 27ae82380c..187f9684be 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/editDocumentRequestV2ProjectId.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/editDocumentServiceArgsProjectId.ts
@@ -7,6 +7,5 @@
/**
* The new project id of the document.
-This will also update the documents permissions to match the project it is going into
*/
-export type EditDocumentRequestV2ProjectId = string | null;
+export type EditDocumentServiceArgsProjectId = string | null;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/editDocumentRequestV2SharePermission.ts b/js/app/packages/service-clients/service-storage/generated/schemas/editDocumentServiceArgsSharePermission.ts
similarity index 82%
rename from js/app/packages/service-clients/service-storage/generated/schemas/editDocumentRequestV2SharePermission.ts
rename to js/app/packages/service-clients/service-storage/generated/schemas/editDocumentServiceArgsSharePermission.ts
index 4f0643fc3c..15cf41fff0 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/editDocumentRequestV2SharePermission.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/editDocumentServiceArgsSharePermission.ts
@@ -6,5 +6,5 @@
*/
import type { UpdateSharePermissionRequestV2 } from './updateSharePermissionRequestV2';
-export type EditDocumentRequestV2SharePermission =
+export type EditDocumentServiceArgsSharePermission =
null | UpdateSharePermissionRequestV2;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/index.ts b/js/app/packages/service-clients/service-storage/generated/schemas/index.ts
index c64737ec34..6816a8a380 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/index.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/index.ts
@@ -242,10 +242,11 @@ export * from './editCommentRequestText';
export * from './editCommentResponse';
export * from './editCommentResponseAllOf';
export * from './editCommentResponseAllOfFileType';
-export * from './editDocumentRequestV2';
-export * from './editDocumentRequestV2DocumentName';
-export * from './editDocumentRequestV2ProjectId';
-export * from './editDocumentRequestV2SharePermission';
+export * from './editDocumentResponse';
+export * from './editDocumentServiceArgs';
+export * from './editDocumentServiceArgsDocumentName';
+export * from './editDocumentServiceArgsProjectId';
+export * from './editDocumentServiceArgsSharePermission';
export * from './editPdfAnchorRequest';
export * from './editPdfAnchorRequestOneOf';
export * from './editPdfAnchorRequestOneOfAllOf';
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/shortIdResponse.ts b/js/app/packages/service-clients/service-storage/generated/schemas/shortIdResponse.ts
index 49058b1bff..42842163f9 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/shortIdResponse.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/shortIdResponse.ts
@@ -6,9 +6,9 @@
*/
/**
- * Short ID response
+ * Short ID response.
*/
export interface ShortIdResponse {
- /** The short id of the document */
+ /** The short id of the document. */
shortId: string;
}
diff --git a/js/app/packages/service-clients/service-storage/generated/zod.ts b/js/app/packages/service-clients/service-storage/generated/zod.ts
index 6573e8bd6b..5611fe951b 100644
--- a/js/app/packages/service-clients/service-storage/generated/zod.ts
+++ b/js/app/packages/service-clients/service-storage/generated/zod.ts
@@ -2024,6 +2024,77 @@ export const deleteDocumentResponse = zod.object({
success: zod.boolean().describe('Indicates if the request was successful'),
});
+/**
+ * Edits document metadata such as name or project, and modifies
+the document's share permissions. Requires edit access to the document,
+and edit access to the target project if moving the document.
+ * @summary Handler for `PATCH /documents/:document_id`.
+ */
+export const editDocumentParams = zod.object({
+ document_id: zod.string().describe('Document ID'),
+});
+
+export const editDocumentBody = zod
+ .object({
+ documentName: zod.string().nullish().describe('The name of the document.'),
+ projectId: zod
+ .string()
+ .nullish()
+ .describe('The new project id of the document.'),
+ sharePermission: zod
+ .union([
+ zod.null(),
+ zod.object({
+ channelSharePermissions: zod
+ .array(
+ zod.object({
+ accessLevel: zod
+ .union([
+ zod.null(),
+ zod
+ .enum(['view', 'comment', 'edit', 'owner'])
+ .describe(
+ 'Ordered from least to most access top -> bottom'
+ ),
+ ])
+ .optional(),
+ channelId: zod.string().describe('The channel id'),
+ operation: zod.enum(['add', 'remove', 'replace']),
+ })
+ )
+ .nullish()
+ .describe(
+ 'Any channel share permissions to be created/updated/removed'
+ ),
+ isPublic: zod
+ .boolean()
+ .nullish()
+ .describe('If the item is publicly accessible'),
+ publicAccessLevel: zod
+ .union([
+ zod.null(),
+ zod
+ .enum(['view', 'comment', 'edit', 'owner'])
+ .describe('Ordered from least to most access top -> bottom'),
+ ])
+ .optional(),
+ }),
+ ])
+ .optional(),
+ })
+ .describe('Arguments for the edit_document service call.');
+
+export const editDocumentResponse = zod
+ .object({
+ data: zod.object({
+ success: zod
+ .boolean()
+ .describe('Indicates if the request was successful'),
+ }),
+ error: zod.boolean().describe('Whether an error occurred.'),
+ })
+ .describe('Edit document response.');
+
/**
* @summary Handles copying a given document. This is the similar to
create_document_handler where you provide the branched_from_id,
@@ -7545,72 +7616,6 @@ export const deleteUserDocumentViewLocationResponse = zod
'Empty response is required due to custom fetch forcing `response.json()`'
);
-/**
- * @summary Edit document v2
-Edits traits of a document such as owner, or name as well as modify the documents share
-permissions.
- */
-export const editDocumentV2Params = zod.object({
- document_id: zod.string().describe('Document ID'),
-});
-
-export const editDocumentV2Body = zod.object({
- documentName: zod.string().nullish().describe('The name of the document'),
- projectId: zod
- .string()
- .nullish()
- .describe(
- 'The new project id of the document.\nThis will also update the documents permissions to match the project it is going into'
- ),
- sharePermission: zod
- .union([
- zod.null(),
- zod.object({
- channelSharePermissions: zod
- .array(
- zod.object({
- accessLevel: zod
- .union([
- zod.null(),
- zod
- .enum(['view', 'comment', 'edit', 'owner'])
- .describe(
- 'Ordered from least to most access top -> bottom'
- ),
- ])
- .optional(),
- channelId: zod.string().describe('The channel id'),
- operation: zod.enum(['add', 'remove', 'replace']),
- })
- )
- .nullish()
- .describe(
- 'Any channel share permissions to be created/updated/removed'
- ),
- isPublic: zod
- .boolean()
- .nullish()
- .describe('If the item is publicly accessible'),
- publicAccessLevel: zod
- .union([
- zod.null(),
- zod
- .enum(['view', 'comment', 'edit', 'owner'])
- .describe('Ordered from least to most access top -> bottom'),
- ])
- .optional(),
- }),
- ])
- .optional(),
-});
-
-export const editDocumentV2Response = zod.object({
- data: zod.object({
- success: zod.boolean().describe('Indicates if the request was successful'),
- }),
- error: zod.boolean().describe('Indicates if an error occurred'),
-});
-
/**
* @summary Gets the current documents share permissions
*/
diff --git a/js/app/packages/service-clients/service-storage/openapi.json b/js/app/packages/service-clients/service-storage/openapi.json
index 99f4eb2297..90f4cdee8b 100644
--- a/js/app/packages/service-clients/service-storage/openapi.json
+++ b/js/app/packages/service-clients/service-storage/openapi.json
@@ -1727,6 +1727,85 @@
}
}
}
+ },
+ "patch": {
+ "tags": ["document"],
+ "summary": "Handler for `PATCH /documents/:document_id`.",
+ "description": "Edits document metadata such as name or project, and modifies\nthe document's share permissions. Requires edit access to the document,\nand edit access to the target project if moving the document.",
+ "operationId": "edit_document",
+ "parameters": [
+ {
+ "name": "document_id",
+ "in": "path",
+ "description": "Document ID",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
+ ],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/EditDocumentServiceArgs"
+ }
+ }
+ },
+ "required": true
+ },
+ "responses": {
+ "200": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/EditDocumentResponse"
+ }
+ }
+ }
+ },
+ "400": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "500": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ }
+ }
}
},
"/documents/{document_id}/copy": {
@@ -4507,76 +4586,6 @@
}
}
},
- "/v2/documents/{document_id}": {
- "patch": {
- "tags": ["document"],
- "summary": "Edit document v2\nEdits traits of a document such as owner, or name as well as modify the documents share\npermissions.",
- "operationId": "edit_document_v2",
- "parameters": [
- {
- "name": "document_id",
- "in": "path",
- "description": "Document ID",
- "required": true,
- "schema": {
- "type": "string"
- }
- }
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/EditDocumentRequestV2"
- }
- }
- },
- "required": true
- },
- "responses": {
- "200": {
- "description": "",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/SuccessResponse"
- }
- }
- }
- },
- "401": {
- "description": "",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/GenericErrorResponse"
- }
- }
- }
- },
- "404": {
- "description": "",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/GenericErrorResponse"
- }
- }
- }
- },
- "500": {
- "description": "",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/GenericErrorResponse"
- }
- }
- }
- }
- }
- }
- },
"/v2/documents/{document_id}/permissions": {
"get": {
"tags": ["document"],
@@ -6776,16 +6785,32 @@
}
]
},
- "EditDocumentRequestV2": {
+ "EditDocumentResponse": {
"type": "object",
+ "description": "Edit document response.",
+ "required": ["error", "data"],
+ "properties": {
+ "data": {
+ "$ref": "#/components/schemas/GenericSuccessResponse",
+ "description": "The response data."
+ },
+ "error": {
+ "type": "boolean",
+ "description": "Whether an error occurred."
+ }
+ }
+ },
+ "EditDocumentServiceArgs": {
+ "type": "object",
+ "description": "Arguments for the edit_document service call.",
"properties": {
"documentName": {
"type": ["string", "null"],
- "description": "The name of the document"
+ "description": "The name of the document."
},
"projectId": {
"type": ["string", "null"],
- "description": "The new project id of the document.\nThis will also update the documents permissions to match the project it is going into"
+ "description": "The new project id of the document."
},
"sharePermission": {
"oneOf": [
@@ -9576,12 +9601,12 @@
},
"ShortIdResponse": {
"type": "object",
- "description": "Short ID response",
+ "description": "Short ID response.",
"required": ["shortId"],
"properties": {
"shortId": {
"type": "string",
- "description": "The short id of the document"
+ "description": "The short id of the document."
}
}
},
diff --git a/js/app/packages/service-clients/service-storage/service.ts b/js/app/packages/service-clients/service-storage/service.ts
index 33ca019ae7..66a8c5f2d6 100644
--- a/js/app/packages/service-clients/service-storage/service.ts
+++ b/js/app/packages/service-clients/service-storage/service.ts
@@ -323,12 +323,12 @@ export const StorageService = new Svc('Document++ Storage Service API')
throws: withFetchErrors(),
})
.fn('editDocument', {
- description: schemas.editDocumentV2Params.description!,
+ description: schemas.editDocumentParams.description!,
args: {
- documentId: schemas.editDocumentV2Params.shape.document_id,
- ...schemas.editDocumentV2Body.shape,
+ documentId: schemas.editDocumentParams.shape.document_id,
+ ...schemas.editDocumentBody.shape,
},
- result: schemas.editDocumentV2Response.shape.data.shape,
+ result: schemas.editDocumentResponse.shape.data.shape,
modifies: true,
throws: withFetchErrors(),
})
diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lock
index 9b2fa84ce8..5b700a890d 100644
--- a/rust/cloud-storage/Cargo.lock
+++ b/rust/cloud-storage/Cargo.lock
@@ -3047,7 +3047,6 @@ dependencies = [
"lexical_client",
"macro_aws_config",
"macro_db_migrator",
- "macro_project_utils",
"macro_user_id",
"macro_uuid",
"mockall",
diff --git a/rust/cloud-storage/document_cognition_service/src/api/context/test.rs b/rust/cloud-storage/document_cognition_service/src/api/context/test.rs
index bc77f8263d..64d262e4b5 100644
--- a/rust/cloud-storage/document_cognition_service/src/api/context/test.rs
+++ b/rust/cloud-storage/document_cognition_service/src/api/context/test.rs
@@ -272,7 +272,6 @@ pub async fn test_api_context(pool: sqlx::Pool<sqlx::Postgres>) -> std::sync::Ar
sync_service_client.as_ref().clone(),
s3_upload_adapter,
ai_tools::NoOpTaskProperties,
- pool.clone(),
ai_tools::NoOpConnectionService,
);
let entity_access_service = entity_access::domain::service::EntityAccessServiceImpl::new(
diff --git a/rust/cloud-storage/document_cognition_service/src/main.rs b/rust/cloud-storage/document_cognition_service/src/main.rs
index d21aa89cd6..4aa7228125 100644
--- a/rust/cloud-storage/document_cognition_service/src/main.rs
+++ b/rust/cloud-storage/document_cognition_service/src/main.rs
@@ -270,7 +270,6 @@ async fn main() -> anyhow::Result<()> {
sync_service_client.clone(),
s3_upload_adapter,
NoOpTaskProperties,
- db.clone(),
NoOpConnectionService,
);
let entity_access_service = EntityAccessServiceImpl::new(PgAccessRepository::new(db.clone()));
diff --git a/rust/cloud-storage/document_storage_service/src/api/documents/edit_document/edit_document_v2.rs b/rust/cloud-storage/document_storage_service/src/api/documents/edit_document/edit_document_v2.rs
deleted file mode 100644
index e7e235195a..0000000000
--- a/rust/cloud-storage/document_storage_service/src/api/documents/edit_document/edit_document_v2.rs
+++ /dev/null
@@ -1,136 +0,0 @@
-use crate::{api::context::ApiContext, model::request::documents::edit::EditDocumentRequestV2};
-use anyhow::Context;
-use axum::{
- http::StatusCode,
- response::{IntoResponse, Json, Response},
-};
-use macro_share_permissions::user_item_access::update_user_item_access;
-use model::{
- document::{DocumentBasic, FileType, FileTypeExt},
- response::{ErrorResponse, GenericSuccessResponse, SuccessResponse},
- user::UserContext,
-};
-use models_permissions::share_permission::UpdateSharePermissionRequestV2;
-use models_permissions::share_permission::access_level::AccessLevel;
-
-pub async fn edit_document(
- ctx: &ApiContext,
- document_context: DocumentBasic,
- users_access_level: AccessLevel,
- req: EditDocumentRequestV2,
- user_context: &UserContext,
-) -> Result<Response, Response> {
- let share_permission: Option<UpdateSharePermissionRequestV2> = req.share_permission.clone();
- // Overrides the document name cleaned document name (removing file extension)
- // if it was accidentally included
- let document_name = req
- .document_name
- .map(|s| FileType::clean_document_name(&s).unwrap_or(s));
-
- if req.project_id.is_some() && users_access_level != AccessLevel::Owner {
- return Err((
- StatusCode::UNAUTHORIZED,
- Json(ErrorResponse {
- message: "you do not have valid permissions to move this item",
- }),
- )
- .into_response());
- }
-
- if req.share_permission.is_some() && users_access_level != AccessLevel::Owner {
- return Err((
- StatusCode::UNAUTHORIZED,
- Json(ErrorResponse {
- message: "you do not have valid permission to modify share permissions",
- }),
- )
- .into_response());
- }
-
- if let Err(err) = edit_document_transaction(
- ctx,
- user_context,
- &document_context,
- document_name.clone(),
- req.project_id.clone(),
- share_permission.as_ref(),
- )
- .await
- {
- tracing::error!(error=?err, "Failed to edit document");
- return Err((
- StatusCode::INTERNAL_SERVER_ERROR,
- Json(ErrorResponse {
- message: "unable to edit document",
- }),
- )
- .into_response());
- }
-
- // update project modified if necessary
- macro_project_utils::update_project_modified(
- &ctx.db,
- macro_project_utils::ProjectModifiedArgs {
- project_id: req.project_id,
- old_project_id: document_context.project_id,
- user_id: user_context.user_id.clone(),
- },
- )
- .await;
-
- Ok((
- StatusCode::OK,
- Json(SuccessResponse {
- error: false,
- data: GenericSuccessResponse::default(),
- }),
- )
- .into_response())
-}
-
-#[tracing::instrument(skip(ctx, user_context, document_context))]
-async fn edit_document_transaction(
- ctx: &ApiContext,
- user_context: &UserContext,
- document_context: &DocumentBasic,
- document_name: Option<String>,
- project_id: Option<String>,
- share_permission: Option<&UpdateSharePermissionRequestV2>,
-) -> anyhow::Result<()> {
- let mut transaction = ctx
- .db
- .begin()
- .await
- .context("failed to begin transaction")?;
-
- // Update document metadata
- macro_db_client::document::v2::edit::edit_document(
- &mut transaction,
- &document_context.document_id,
- document_name.as_deref(),
- project_id.as_deref(),
- share_permission,
- )
- .await
- .context("failed to edit document")?;
-
- // Update user item access if share permissions are changing
- if let Some(share_permission) = share_permission {
- update_user_item_access(
- &mut transaction,
- &user_context.user_id,
- &document_context.document_id,
- "document",
- share_permission,
- )
- .await
- .context("failed to update user item access")?;
- }
-
- transaction
- .commit()
- .await
- .context("failed to commit transaction")?;
-
- Ok(())
-}
diff --git a/rust/cloud-storage/document_storage_service/src/api/documents/edit_document/mod.rs b/rust/cloud-storage/document_storage_service/src/api/documents/edit_document/mod.rs
deleted file mode 100644
index 0534030b9e..0000000000
--- a/rust/cloud-storage/document_storage_service/src/api/documents/edit_document/mod.rs
+++ /dev/null
@@ -1,75 +0,0 @@
-mod edit_document_v2;
-
-use crate::{api::context::ApiContext, model::request::documents::edit::EditDocumentRequestV2};
-use axum::{
- Extension, Json,
- extract::{self, State},
- http::StatusCode,
- response::{IntoResponse, Response},
-};
-use macro_middleware::cloud_storage::ensure_access::{
- document::DocumentAccessExtractor, project::ProjectBodyAccessLevelExtractor,
-};
-use model::{
- document::DocumentBasic,
- response::{ErrorResponse, GenericErrorResponse, SuccessResponse},
- user::UserContext,
-};
-use models_permissions::share_permission::access_level::EditAccessLevel;
-
-#[derive(serde::Deserialize)]
-pub struct Params {
- pub document_id: String,
-}
-
-/// Edit document v2
-/// Edits traits of a document such as owner, or name as well as modify the documents share
-/// permissions.
-#[utoipa::path(
- tag = "document",
- patch,
- operation_id="edit_document_v2",
- path = "/v2/documents/{document_id}",
- params(
- ("document_id" = String, Path, description = "Document ID")
- ),
- responses(
- (status = 200, body=SuccessResponse),
- (status = 401, body=GenericErrorResponse),
- (status = 404, body=GenericErrorResponse),
- (status = 500, body=GenericErrorResponse),
- )
- )]
-#[allow(unused, reason = "used to generate OpenAPI documentation")]
-pub(in crate::api) async fn edit_document_handler_v2(
- extract::Path(Params { document_id }): extract::Path<Params>,
- extract::Json(_req): extract::Json<EditDocumentRequestV2>,
-) -> impl IntoResponse {
- StatusCode::OK
-}
-
-/// Edits traits of a document such as owner, or name.
-#[tracing::instrument(skip(state, user_context, project), fields(user_id=?user_context.user_id))]
-pub async fn edit_document_handler(
- DocumentAccessExtractor { access_level, .. }: DocumentAccessExtractor<EditAccessLevel>,
- State(state): State<ApiContext>,
- user_context: Extension<UserContext>,
- document_context: Extension<DocumentBasic>,
- extract::Path(Params { document_id }): extract::Path<Params>,
- project: ProjectBodyAccessLevelExtractor<EditAccessLevel, EditDocumentRequestV2>,
-) -> Result<Response, Response> {
- let req = project.into_inner();
-
- if document_context.deleted_at.is_some() {
- return Err((
- StatusCode::BAD_REQUEST,
- Json(ErrorResponse {
- message: "cannot modify deleted document",
- }),
- )
- .into_response());
- }
-
- edit_document_v2::edit_document(&state, document_context.0, access_level, req, &user_context)
- .await
-}
diff --git a/rust/cloud-storage/document_storage_service/src/api/documents/mod.rs b/rust/cloud-storage/document_storage_service/src/api/documents/mod.rs
index 054e17f50c..8988252563 100644
--- a/rust/cloud-storage/document_storage_service/src/api/documents/mod.rs
+++ b/rust/cloud-storage/document_storage_service/src/api/documents/mod.rs
@@ -1,7 +1,7 @@
use super::{context::ApiContext, middleware};
use axum::{
Router,
- routing::{delete, get, patch, post, put},
+ routing::{delete, get, post, put},
};
use tower::ServiceBuilder;
@@ -9,7 +9,6 @@ use tower::ServiceBuilder;
pub(in crate::api) mod copy_document;
pub(in crate::api) mod create_task;
pub(in crate::api) mod delete_document;
-pub(in crate::api) mod edit_document;
pub(in crate::api) mod export_document;
pub(in crate::api) mod get_batch_preview;
pub(in crate::api) mod get_document;
@@ -142,11 +141,7 @@ pub fn router(state: ApiContext) -> Router<ApiContext> {
"/:document_id/:document_version_id",
get(get_document_version::handler).layer(ensure_document_exists_middleware.clone()),
)
- .route(
- "/:document_id",
- patch(edit_document::edit_document_handler)
- .layer(ensure_document_exists_middleware.clone()),
- )
+ // NOTE: PATCH /:document_id (edit_document) is now served by the documents hex crate router
.route(
"/:document_id",
put(save_document::save_document_handler)
diff --git a/rust/cloud-storage/document_storage_service/src/api/swagger.rs b/rust/cloud-storage/document_storage_service/src/api/swagger.rs
index 5bb5c556b9..a59324fd87 100644
--- a/rust/cloud-storage/document_storage_service/src/api/swagger.rs
+++ b/rust/cloud-storage/document_storage_service/src/api/swagger.rs
@@ -33,7 +33,6 @@ use crate::{
request::{
documents::{
copy::{CopyDocumentQueryParams, CopyDocumentRequest},
- edit::EditDocumentRequestV2,
preview::GetBatchPreviewRequest,
save::{PreSaveDocumentRequest, SaveDocumentRequest},
user_document_view_location::UpsertUserDocumentViewLocationRequest,
@@ -146,7 +145,7 @@ use utoipa::OpenApi;
documents::copy_document::copy_document_handler,
documents::save_document::save_document_handler,
documents::pre_save::presave_document_handler,
- documents::edit_document::edit_document_handler_v2,
+ documents_hex::inbound::axum_router::edit_document_handler,
documents_hex::inbound::axum_router::delete_document_handler,
documents::delete_document::permanently_delete_document_handler,
documents::get_document_list::get_document_list_handler,
@@ -263,7 +262,8 @@ use utoipa::OpenApi;
GetDocumentSearchResponse, // Search document
CopyDocumentRequest,
CopyDocumentQueryParams, // Copy document
- EditDocumentRequestV2, // Edit document
+ documents_hex::domain::models::EditDocumentServiceArgs,
+ documents_hex::inbound::axum_router::EditDocumentResponse, // Edit document
UserDocumentsResponse,
GetDocumentsResponse, // Get user documents
GetDocumentProcessingResult,
diff --git a/rust/cloud-storage/document_storage_service/src/main.rs b/rust/cloud-storage/document_storage_service/src/main.rs
index 73deb63c32..07fabe612c 100644
--- a/rust/cloud-storage/document_storage_service/src/main.rs
+++ b/rust/cloud-storage/document_storage_service/src/main.rs
@@ -328,7 +328,6 @@ async fn main() -> anyhow::Result<()> {
sync_service_client.clone(),
s3_upload_adapter,
TaskPropertiesAdapter(system_properties_service.clone()),
- db.clone(),
connection_service,
));
diff --git a/rust/cloud-storage/document_storage_service/src/model/request/documents/edit.rs b/rust/cloud-storage/document_storage_service/src/model/request/documents/edit.rs
deleted file mode 100644
index cc6b11176a..0000000000
--- a/rust/cloud-storage/document_storage_service/src/model/request/documents/edit.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-use utoipa::ToSchema;
-
-#[derive(serde::Serialize, serde::Deserialize, Eq, PartialEq, Debug, ToSchema)]
-#[serde(rename_all = "camelCase")]
-pub struct EditDocumentRequestV2 {
- /// The name of the document
- pub document_name: Option<String>,
- /// The new project id of the document.
- /// This will also update the documents permissions to match the project it is going into
- pub project_id: Option<String>,
- /// Updated share permissions for the document.
- pub share_permission:
- Option<models_permissions::share_permission::UpdateSharePermissionRequestV2>,
-}
diff --git a/rust/cloud-storage/document_storage_service/src/model/request/documents/mod.rs b/rust/cloud-storage/document_storage_service/src/model/request/documents/mod.rs
index 2996d8fd72..68450bcc65 100644
--- a/rust/cloud-storage/document_storage_service/src/model/request/documents/mod.rs
+++ b/rust/cloud-storage/document_storage_service/src/model/request/documents/mod.rs
@@ -1,5 +1,4 @@
pub mod copy;
-pub mod edit;
pub mod get_user_documents;
pub mod location;
pub mod preview;
diff --git a/rust/cloud-storage/documents/.sqlx/query-28c518d844cd4d843c097af1551f6f384a4763514d278b5444341390f58a8281.json b/rust/cloud-storage/documents/.sqlx/query-28c518d844cd4d843c097af1551f6f384a4763514d278b5444341390f58a8281.json
new file mode 100644
index 0000000000..98ceb2aeec
--- /dev/null
+++ b/rust/cloud-storage/documents/.sqlx/query-28c518d844cd4d843c097af1551f6f384a4763514d278b5444341390f58a8281.json
@@ -0,0 +1,14 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "UPDATE \"Project\" SET \"updatedAt\" = NOW() WHERE id = $1",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "Text"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "28c518d844cd4d843c097af1551f6f384a4763514d278b5444341390f58a8281"
+}
diff --git a/rust/cloud-storage/documents/.sqlx/query-b08f21bc79644b7ae980ef17ea38f60be7749e48143ad40a164b236e977157f3.json b/rust/cloud-storage/documents/.sqlx/query-b08f21bc79644b7ae980ef17ea38f60be7749e48143ad40a164b236e977157f3.json
new file mode 100644
index 0000000000..4327d95754
--- /dev/null
+++ b/rust/cloud-storage/documents/.sqlx/query-b08f21bc79644b7ae980ef17ea38f60be7749e48143ad40a164b236e977157f3.json
@@ -0,0 +1,16 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n INSERT INTO \"ChannelSharePermission\" (\"share_permission_id\", \"channel_id\", \"access_level\")\n SELECT $1, channel_id, access_level::\"AccessLevel\"\n FROM UNNEST($2::text[], $3::text[]) AS t(channel_id, access_level)\n ON CONFLICT (\"share_permission_id\", \"channel_id\")\n DO UPDATE SET \"access_level\" = EXCLUDED.\"access_level\"\n ",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "Text",
+ "TextArray",
+ "TextArray"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "b08f21bc79644b7ae980ef17ea38f60be7749e48143ad40a164b236e977157f3"
+}
diff --git a/rust/cloud-storage/documents/.sqlx/query-b46b2b51f07ec4fc65cd158b210ce262e9ab44f10825969072c01a8fe3022a23.json b/rust/cloud-storage/documents/.sqlx/query-b46b2b51f07ec4fc65cd158b210ce262e9ab44f10825969072c01a8fe3022a23.json
new file mode 100644
index 0000000000..93348ea121
--- /dev/null
+++ b/rust/cloud-storage/documents/.sqlx/query-b46b2b51f07ec4fc65cd158b210ce262e9ab44f10825969072c01a8fe3022a23.json
@@ -0,0 +1,15 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n DELETE FROM \"ChannelSharePermission\"\n WHERE \"share_permission_id\" = $1\n AND \"channel_id\" = ANY($2)\n ",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "Text",
+ "TextArray"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "b46b2b51f07ec4fc65cd158b210ce262e9ab44f10825969072c01a8fe3022a23"
+}
diff --git a/rust/cloud-storage/documents/.sqlx/query-ff3cfaae68201d92e5a587defc0b23eddb2d7a5a8a1572ef33f3040f8e0d671b.json b/rust/cloud-storage/documents/.sqlx/query-ff3cfaae68201d92e5a587defc0b23eddb2d7a5a8a1572ef33f3040f8e0d671b.json
new file mode 100644
index 0000000000..b0ce9f3ac1
--- /dev/null
+++ b/rust/cloud-storage/documents/.sqlx/query-ff3cfaae68201d92e5a587defc0b23eddb2d7a5a8a1572ef33f3040f8e0d671b.json
@@ -0,0 +1,22 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT dp.\"sharePermissionId\" as \"share_permission_id!\"\n FROM \"DocumentPermission\" dp\n WHERE dp.\"documentId\" = $1\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "share_permission_id!",
+ "type_info": "Text"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Text"
+ ]
+ },
+ "nullable": [
+ false
+ ]
+ },
+ "hash": "ff3cfaae68201d92e5a587defc0b23eddb2d7a5a8a1572ef33f3040f8e0d671b"
+}
diff --git a/rust/cloud-storage/documents/Cargo.toml b/rust/cloud-storage/documents/Cargo.toml
index 93fc79caa3..e9d607d954 100644
--- a/rust/cloud-storage/documents/Cargo.toml
+++ b/rust/cloud-storage/documents/Cargo.toml
@@ -26,7 +26,7 @@ axum = [
]
default = ["ai_tools", "axum", "inbound", "outbound", "ports"]
inbound = ["axum", "ports"]
-outbound = ["dep:aws-sdk-s3", "dep:base64", "dep:hex", "ports"]
+outbound = ["dep:aws-sdk-s3", "dep:base64", "dep:hex", "dep:sqlx", "ports"]
ports = ["dep:tokio"]
[dependencies]
@@ -67,8 +67,7 @@ base64 = { workspace = true, optional = true }
cloudfront_sign = { workspace = true }
futures = { workspace = true }
hex = { workspace = true, optional = true }
-macro_project_utils = { path = "../macro_project_utils" }
-sqlx = { workspace = true }
+sqlx = { workspace = true, optional = true }
sync_service_client = { path = "../sync_service_client" }
urlencoding = { workspace = true }
diff --git a/rust/cloud-storage/documents/examples/documents_toolset.rs b/rust/cloud-storage/documents/examples/documents_toolset.rs
index 6aa1317dea..78802f449b 100644
--- a/rust/cloud-storage/documents/examples/documents_toolset.rs
+++ b/rust/cloud-storage/documents/examples/documents_toolset.rs
@@ -125,7 +125,6 @@ async fn main() {
SyncServiceClient::new(sync_service_auth_key.clone(), sync_service_url),
s3_upload_adapter,
NoOpTaskProperties,
- pool,
NoOpConnectionService,
);
diff --git a/rust/cloud-storage/documents/fixtures/documents_test_data.sql b/rust/cloud-storage/documents/fixtures/documents_test_data.sql
index 51dfc40b7f..376e4636f6 100644
--- a/rust/cloud-storage/documents/fixtures/documents_test_data.sql
+++ b/rust/cloud-storage/documents/fixtures/documents_test_data.sql
@@ -66,3 +66,17 @@ INSERT INTO
'test_project_name',
);
+
+-- Share permissions for document-one
+INSERT INTO public."SharePermission" ("id", "isPublic", "publicAccessLevel", "createdAt", "updatedAt")
+ (SELECT 'sp-doc-one', true, 'read', NOW(), NOW());
+
+INSERT INTO public."DocumentPermission" ("documentId", "sharePermissionId")
+ (SELECT 'document-one', 'sp-doc-one');
+
+-- Share permissions for document-two
+INSERT INTO public."SharePermission" ("id", "isPublic", "createdAt", "updatedAt")
+ (SELECT 'sp-doc-two', false, NOW(), NOW());
+
+INSERT INTO public."DocumentPermission" ("documentId", "sharePermissionId")
+ (SELECT 'document-two', 'sp-doc-two');
diff --git a/rust/cloud-storage/documents/src/domain/models.rs b/rust/cloud-storage/documents/src/domain/models.rs
index 22ef9d1137..9c7c9be7c7 100644
--- a/rust/cloud-storage/documents/src/domain/models.rs
+++ b/rust/cloud-storage/documents/src/domain/models.rs
@@ -64,6 +64,33 @@ pub struct CloudFrontConfig {
pub browser_cache_expiry_seconds: u64,
}
+/// Arguments for editing a document in the repository.
+pub struct EditDocumentRepoArgs {
+ /// The document ID to edit.
+ pub document_id: String,
+ /// New document name (None = no change).
+ pub document_name: Option<String>,
+ /// New project ID (None = no change, Some("") = remove from project).
+ pub project_id: Option<String>,
+ /// Updated share permissions.
+ pub share_permission:
+ Option<models_permissions::share_permission::UpdateSharePermissionRequestV2>,
+}
+
+/// Arguments for the edit_document service call.
+#[derive(serde::Serialize, serde::Deserialize, Eq, PartialEq, Debug)]
+#[cfg_attr(feature = "axum", derive(utoipa::ToSchema))]
+#[serde(rename_all = "camelCase")]
+pub struct EditDocumentServiceArgs {
+ /// The name of the document.
+ pub document_name: Option<String>,
+ /// The new project id of the document.
+ pub project_id: Option<String>,
+ /// Updated share permissions for the document.
+ pub share_permission:
+ Option<models_permissions::share_permission::UpdateSharePermissionRequestV2>,
+}
+
/// Query parameters for the location_v3 endpoint.
#[derive(serde::Serialize, serde::Deserialize, Eq, PartialEq, Debug)]
pub struct LocationQueryParams {
diff --git a/rust/cloud-storage/documents/src/domain/ports.rs b/rust/cloud-storage/documents/src/domain/ports.rs
index efdff7d0e5..d4ab8aca67 100644
--- a/rust/cloud-storage/documents/src/domain/ports.rs
+++ b/rust/cloud-storage/documents/src/domain/ports.rs
@@ -13,7 +13,10 @@ use model::document::response::{
};
use model::document::{ContentType, DocumentBasic, DocumentMetadata};
-use super::models::{CreateDocumentRepoArgs, DocumentError, LocationQueryParams};
+use super::models::{
+ CreateDocumentRepoArgs, DocumentError, EditDocumentRepoArgs, EditDocumentServiceArgs,
+ LocationQueryParams,
+};
/// Repository for accessing document data from the database.
///
@@ -98,6 +101,20 @@ pub trait DocumentRepo: Send + Sync + 'static {
job_id: &str,
) -> impl Future<Output = Result<(), Self::Err>> + Send;
+ /// Edit a document's metadata and share permissions in a single transaction.
+ ///
+ /// Updates: Document name, project ID, share permissions, and user item access.
+ fn edit_document(
+ &self,
+ args: EditDocumentRepoArgs,
+ ) -> impl Future<Output = Result<(), Self::Err>> + Send;
+
+ /// Update a project's `updatedAt` timestamp.
+ fn update_project_modified(
+ &self,
+ project_id: &str,
+ ) -> impl Future<Output = Result<(), Self::Err>> + Send;
+
/// Delete a document by ID (used for error cleanup).
fn delete_document_by_id(
&self,
@@ -192,6 +209,17 @@ pub trait DocumentService: Send + Sync + 'static {
entity_access_receipt: EntityAccessReceipt<ViewAccessLevel>,
) -> impl Future<Output = Result<String, DocumentError>> + Send;
+ /// Edit a document's metadata and share permissions.
+ ///
+ /// Validates permissions, updates the document, sends invalidation event,
+ /// and updates project modified timestamp.
+ fn edit_document(
+ &self,
+ entity_access_receipt: EntityAccessReceipt<EditAccessLevel>,
+ document_context: DocumentBasic,
+ args: EditDocumentServiceArgs,
+ ) -> impl Future<Output = Result<(), DocumentError>> + Send;
+
/// Updates the tasks status to what is provided
fn update_task_status(
&self,
diff --git a/rust/cloud-storage/documents/src/domain/service.rs b/rust/cloud-storage/documents/src/domain/service.rs
index d4c95a8fb1..bce33b7235 100644
--- a/rust/cloud-storage/documents/src/domain/service.rs
+++ b/rust/cloud-storage/documents/src/domain/service.rs
@@ -13,7 +13,7 @@ use connection::domain::models::{InvalidationEvent, InvalidationReason};
use connection::domain::ports::ConnectionService;
use document_sub_type::DocumentSubType;
use entity_access::domain::models::{
- EntityAccessAuth, EntityAccessReceipt, OwnerAccessLevel, ViewAccessLevel,
+ EditAccessLevel, EntityAccessAuth, EntityAccessReceipt, OwnerAccessLevel, ViewAccessLevel,
};
use macro_user_id::user_id::MacroUserIdStr;
use model::document::response::{
@@ -25,10 +25,12 @@ use model::document::{
build_cloud_storage_bucket_document_key,
};
use model::response::PresignedUrl;
-use sqlx::PgPool;
use tracing;
-use super::models::{CloudFrontConfig, CreateDocumentRepoArgs, DocumentError, LocationQueryParams};
+use super::models::{
+ CloudFrontConfig, CreateDocumentRepoArgs, DocumentError, EditDocumentRepoArgs,
+ EditDocumentServiceArgs, LocationQueryParams,
+};
use super::ports::{DocumentRepo, DocumentService, PresignedUploadUrlPort, TaskPropertiesPort};
/// The concrete document service implementation.
@@ -44,7 +46,6 @@ pub struct DocumentServiceImpl<
upload_url_service: U,
task_properties_service: T,
connection_service: C,
- db: PgPool,
}
impl<R: DocumentRepo, U: PresignedUploadUrlPort, T: TaskPropertiesPort, C: ConnectionService>
@@ -57,7 +58,6 @@ impl<R: DocumentRepo, U: PresignedUploadUrlPort, T: TaskPropertiesPort, C: Conne
sync_service_client: sync_service_client::SyncServiceClient,
upload_url_service: U,
task_properties_service: T,
- db: PgPool,
connection_service: C,
) -> Self {
Self {
@@ -66,7 +66,6 @@ impl<R: DocumentRepo, U: PresignedUploadUrlPort, T: TaskPropertiesPort, C: Conne
sync_service_client,
upload_url_service,
task_properties_service,
- db,
connection_service,
}
}
@@ -405,19 +404,12 @@ impl<R: DocumentRepo, U: PresignedUploadUrlPort, T: TaskPropertiesPort, C: Conne
.await
.map_err(|e| DocumentError::Internal(e.into()))?;
- match entity_access_receipt.auth() {
- EntityAccessAuth::Authenticated(macro_user_id) => {
- macro_project_utils::update_project_modified(
- &self.db,
- macro_project_utils::ProjectModifiedArgs {
- project_id,
- old_project_id: None::<String>,
- user_id: macro_user_id.as_ref().to_string(),
- },
- )
- .await;
- }
- EntityAccessAuth::Unauthenticated | EntityAccessAuth::Internal => (),
+ if let Some(project_id) = &project_id
+ && !project_id.is_empty()
+ {
+ let _ = self.repo.update_project_modified(project_id).await.inspect_err(
+ |e| tracing::error!(error=?e, project_id=?project_id, "unable to update project modified date"),
+ );
}
let _ = self
@@ -549,16 +541,13 @@ impl<R: DocumentRepo, U: PresignedUploadUrlPort, T: TaskPropertiesPort, C: Conne
DocumentError::Internal(anyhow!("unable to convert document metadata"))
})?;
- // Update project modified timestamp (fire-and-forget)
- macro_project_utils::update_project_modified(
- &self.db,
- macro_project_utils::ProjectModifiedArgs {
- project_id,
- old_project_id: None,
- user_id: user_id.as_ref().to_string(),
- },
- )
- .await;
+ // Update project modified timestamp
+ if let Some(project_id) = &project_id {
+ let project_id_str = project_id.to_string();
+ let _ = self.repo.update_project_modified(&project_id_str).await.inspect_err(
+ |e| tracing::error!(error=?e, project_id=?project_id, "unable to update project modified date"),
+ );
+ }
// Attach task properties if creating a task
if document_response_metadata.sub_type == Some(DocumentSubType::Task) {
@@ -581,6 +570,81 @@ impl<R: DocumentRepo, U: PresignedUploadUrlPort, T: TaskPropertiesPort, C: Conne
})
}
+ #[tracing::instrument(err, skip(self, document_context, args))]
+ async fn edit_document(
+ &self,
+ entity_access_receipt: EntityAccessReceipt<EditAccessLevel>,
+ document_context: DocumentBasic,
+ args: EditDocumentServiceArgs,
+ ) -> Result<(), DocumentError> {
+ // Check owner-only restrictions for authenticated users
+ if let entity_access::domain::models::EntityPermission::AccessLevel { access_level } =
+ entity_access_receipt.entity_permission()
+ {
+ if args.project_id.is_some()
+ && *access_level
+ != models_permissions::share_permission::access_level::AccessLevel::Owner
+ {
+ return Err(DocumentError::Unauthorized);
+ }
+
+ if args.share_permission.is_some()
+ && *access_level
+ != models_permissions::share_permission::access_level::AccessLevel::Owner
+ {
+ return Err(DocumentError::Unauthorized);
+ }
+ }
+
+ // Clean the document name (remove file extension if present)
+ let document_name = args
+ .document_name
+ .map(|s| FileType::clean_document_name(&s).unwrap_or(s));
+
+ self.repo
+ .edit_document(EditDocumentRepoArgs {
+ document_id: entity_access_receipt.entity().entity_id.clone(),
+ document_name,
+ project_id: args.project_id.clone(),
+ share_permission: args.share_permission,
+ })
+ .await
+ .map_err(|e| DocumentError::Internal(e.into()))?;
+
+ // Update project modified timestamps
+ if let Some(old_project_id) = &document_context.project_id
+ && !old_project_id.is_empty()
+ {
+ let _ = self.repo.update_project_modified(old_project_id).await.inspect_err(
+ |e| tracing::error!(error=?e, project_id=?old_project_id, "unable to update project modified date"),
+ );
+ }
+ if let Some(project_id) = &args.project_id
+ && !project_id.is_empty()
+ {
+ let _ = self.repo.update_project_modified(project_id).await.inspect_err(
+ |e| tracing::error!(error=?e, project_id=?project_id, "unable to update project modified date"),
+ );
+ }
+
+ // Send invalidation event
+ let _ = self
+ .connection_service
+ .send_invalidation_event(InvalidationEvent::<()> {
+ invalidation_reason: InvalidationReason::Content,
+ entity_id: Cow::Borrowed(&entity_access_receipt.entity().entity_id),
+ entity_type: entity_access_receipt.entity().entity_type,
+ invalidated_by: entity_access_receipt.auth().clone(),
+ metadata: None,
+ })
+ .await
+ .inspect_err(|e| {
+ tracing::error!(error=?e, "failed to send invalidation event");
+ });
+
+ Ok(())
+ }
+
#[tracing::instrument(skip(self))]
async fn update_task_status(
&self,
diff --git a/rust/cloud-storage/documents/src/inbound/axum_router.rs b/rust/cloud-storage/documents/src/inbound/axum_router.rs
index 0ab3edc42c..8525896dfa 100644
--- a/rust/cloud-storage/documents/src/inbound/axum_router.rs
+++ b/rust/cloud-storage/documents/src/inbound/axum_router.rs
@@ -1,46 +1,48 @@
//! Axum router for document endpoints.
//!
-//! Provides four routes:
+//! Provides routes:
//! - `POST /` — create a new document
//! - `GET /:document_id` — get document metadata
//! - `GET /:document_id/location_v3` — get document content location (presigned URL)
+//! - `GET /:document_id/short_id` — get document short ID
//! - `DELETE /:document_id` — soft-delete a document
#[cfg(test)]
mod tests;
-use std::str::FromStr;
+mod create_document;
+mod delete_document;
+mod edit_document;
+mod get_document;
+mod get_location;
+mod get_short_id;
+
use std::sync::Arc;
use axum::{
- Extension, Json, Router,
+ Json, Router,
body::Body,
- extract::{FromRef, Path, Query, State},
- http::{HeaderMap, Request, StatusCode},
+ extract::{FromRef, Path, State},
+ http::{Request, StatusCode},
middleware::{self, Next},
response::IntoResponse,
};
use entity_access::domain::ports::EntityAccessService;
-use entity_access::inbound::axum_extractors::{
- DocumentAccessExtractor, InternalUser, ProjectBodyAccessLevelExtractor,
-};
-use model::document::response::{
- CreateDocumentRequest, CreateDocumentResponse, GetDocumentResponse,
-};
-use model::document::{DocumentBasic, FileType, FileTypeExt, response::LocationResponseV3};
-use model::response::GenericSuccessResponse;
-use model::user::UserContext;
use model_error_response::ErrorResponse;
-use model_user::axum_extractor::MacroUserExtractor;
-use models_permissions::share_permission::access_level::{
- EditAccessLevel, OwnerAccessLevel, ViewAccessLevel,
-};
use serde::Deserialize;
use sqlx::PgPool;
-use crate::domain::models::{CreateDocumentRepoArgs, DocumentError, LocationQueryParams};
+use crate::domain::models::DocumentError;
use crate::domain::ports::DocumentService;
+// Re-export handlers and utoipa path types for external use (swagger, internal routes)
+pub use create_document::*;
+pub use delete_document::*;
+pub use edit_document::*;
+pub use get_document::*;
+pub use get_location::*;
+pub use get_short_id::*;
+
impl IntoResponse for DocumentError {
fn into_response(self) -> axum::response::Response {
let status_code = match &self {
@@ -94,7 +96,7 @@ pub struct Params {
document_id: String,
}
-/// Build the documents router with all four endpoints.
+/// Build the documents router with all endpoints.
pub fn documents_router<T, Svc, S>(state: DocumentRouterState<T, Svc>) -> Router<S>
where
T: DocumentService,
@@ -106,6 +108,7 @@ where
.route(
"/:document_id",
axum::routing::get(get_document_handler::<T, Svc>)
+ .patch(edit_document_handler::<T, Svc>)
.delete(delete_document_handler::<T, Svc>),
)
.route(
@@ -133,7 +136,7 @@ pub struct DocumentIdPathParams {
pub document_id: String,
}
-/// Middleware that loads [`DocumentBasic`] into request extensions.
+/// Middleware that loads [`DocumentBasic`](model::document::DocumentBasic) into request extensions.
///
/// Extracts `document_id` from the path and queries the database.
/// Returns 404 if the document does not exist.
@@ -180,246 +183,3 @@ async fn ensure_document_exists<T: DocumentService, Svc: EntityAccessService>(
request.extensions_mut().insert(document_basic);
next.run(request).await.into_response()
}
-
-/// Handler for `GET /documents/:document_id`.
-///
-/// Returns document metadata, user access level, and view location.
-#[utoipa::path(
- tag = "document",
- get,
- path = "/documents/{document_id}",
- operation_id = "get_document",
- params(
- ("document_id" = String, Path, description = "Document ID")
- ),
- responses(
- (status = 200, body = GetDocumentResponse),
- (status = 401, body = ErrorResponse),
- (status = 404, body = ErrorResponse),
- (status = 500, body = ErrorResponse),
- )
-)]
-#[tracing::instrument(skip(state, access), err)]
-pub async fn get_document_handler<T: DocumentService, Svc: EntityAccessService>(
- State(state): State<DocumentRouterState<T, Svc>>,
- access: DocumentAccessExtractor<ViewAccessLevel, Svc>,
- user_context: Extension<UserContext>,
- Path(Params { document_id }): Path<Params>,
-) -> Result<Json<GetDocumentResponse>, DocumentError> {
- let response_data = state
- .service
- .get_document(access.entity_access_receipt)
- .await?;
-
- Ok(Json(GetDocumentResponse {
- error: false,
- data: response_data,
- }))
-}
-
-// entity access
-// do work
-
-/// Handler for `GET /documents/:document_id/location_v3`.
-///
-/// Returns a presigned URL or sync service content for accessing the document.
-#[utoipa::path(
- tag = "document",
- get,
- path = "/documents/{document_id}/location_v3",
- operation_id = "get_document_location_v3",
- params(
- ("document_id" = String, Path, description = "Document ID"),
- ("document_version_id" = Option<i64>, Query, description = "A specific document version id to get the location for."),
- ("get_converted_docx_url" = Option<bool>, Query, description = "If true, this will return the converted docx url.")
- ),
- responses(
- (status = 200),
- (status = 401, body = ErrorResponse),
- (status = 404, body = ErrorResponse),
- (status = 410, body = ErrorResponse),
- (status = 500, body = ErrorResponse),
- )
-)]
-#[tracing::instrument(skip(state, access, document_context), err)]
-pub async fn get_location_v3_handler<T: DocumentService, Svc: EntityAccessService>(
- access: DocumentAccessExtractor<ViewAccessLevel, Svc>,
- State(state): State<DocumentRouterState<T, Svc>>,
- Extension(document_context): Extension<DocumentBasic>,
- Path(Params { document_id }): Path<Params>,
- Query(params): Query<LocationQueryParams>,
-) -> Result<(HeaderMap, Json<LocationResponseV3>), DocumentError> {
- let response_data = state
- .service
- .get_document_location(&document_context, access.entity_access_receipt, params)
- .await?;
-
- let mut header_map = HeaderMap::new();
- header_map.append("content-type", "application/json".parse().unwrap());
- header_map.append("Cache-Control", "max-age-300".parse().unwrap());
-
- Ok((header_map, Json(response_data)))
-}
-
-/// Short ID response
-#[derive(serde::Serialize, utoipa::ToSchema)]
-#[serde(rename_all = "camelCase")]
-pub struct ShortIdResponse {
- /// The short id of the document
- short_id: String,
-}
-
-/// Handler for `GET /documents/:document_id/short_id`.
-///
-/// Returns the short UUID for a document.
-#[utoipa::path(
- tag = "document",
- get,
- path = "/documents/{document_id}/short_id",
- operation_id = "get_document_short_id",
- params(
- ("document_id" = String, Path, description = "Document ID")
- ),
- responses(
- (status = 200, body = String),
- (status = 401, body = ErrorResponse),
- (status = 404, body = ErrorResponse),
- (status = 500, body = ErrorResponse),
- )
-)]
-#[tracing::instrument(skip(state, access), err)]
-pub async fn get_short_id_handler<T: DocumentService, Svc: EntityAccessService>(
- State(state): State<DocumentRouterState<T, Svc>>,
- access: DocumentAccessExtractor<ViewAccessLevel, Svc>,
- Path(Params { document_id }): Path<Params>,
-) -> Result<Json<ShortIdResponse>, DocumentError> {
- let short_id = state
- .service
- .get_short_id(access.entity_access_receipt)
- .await?;
-
- Ok(Json(ShortIdResponse { short_id }))
-}
-
-/// Handler for `DELETE /documents/:document_id`.
-///
-/// Soft-deletes a document (only owners can delete).
-#[utoipa::path(
- tag = "document",
- delete,
- path = "/documents/{document_id}",
- operation_id = "delete_document",
- params(
- ("document_id" = String, Path, description = "Document ID")
- ),
- responses(
- (status = 200, body = GenericSuccessResponse),
- (status = 401, body = ErrorResponse),
- (status = 404, body = ErrorResponse),
- (status = 500, body = ErrorResponse),
- )
-)]
-#[tracing::instrument(skip(state, access, doc), err)]
-pub async fn delete_document_handler<T: DocumentService, Svc: EntityAccessService>(
- access: DocumentAccessExtractor<OwnerAccessLevel, Svc>,
- State(state): State<DocumentRouterState<T, Svc>>,
- user_context: Extension<UserContext>,
- doc: Extension<DocumentBasic>,
- Path(Params { document_id }): Path<Params>,
-) -> Result<Json<GenericSuccessResponse>, DocumentError> {
- tracing::info!("delete document");
-
- state
- .service
- .delete_document(access.entity_access_receipt, doc.project_id.clone())
- .await?;
-
- Ok(Json(GenericSuccessResponse { success: true }))
-}
-
-/// Handler for `POST /documents`.
-///
-/// Creates a new document, generates an S3 presigned upload URL, and returns
-/// the document metadata with the URL for the client to upload to.
-#[utoipa::path(
- tag = "document",
- post,
- path = "/documents",
- operation_id = "create_document",
- request_body = CreateDocumentRequest,
- responses(
- (status = 200, body = inline(CreateDocumentResponse)),
- (status = 400, body = ErrorResponse),
- (status = 401, body = ErrorResponse),
- (status = 409, body = ErrorResponse),
- (status = 500, body = ErrorResponse),
- )
-)]
-#[tracing::instrument(skip(state, user_context, project), fields(user_id=?user_context.macro_user_id))]
-pub async fn create_document_handler<T: DocumentService, Svc: EntityAccessService>(
- State(state): State<DocumentRouterState<T, Svc>>,
- internal_user: Option<Extension<InternalUser>>,
- user_context: MacroUserExtractor,
- project: ProjectBodyAccessLevelExtractor<EditAccessLevel, CreateDocumentRequest, Svc>,
-) -> Result<Json<CreateDocumentResponse>, DocumentError> {
- let req = project.into_inner();
-
- // Email linking is internal only
- if req.email_attachment_id.is_some() && internal_user.is_none() {
- return Err(DocumentError::Unauthorized);
- }
-
- // Parse file type from the request
- let user_provided_file_type: Option<FileType> = req
- .file_type
- .as_deref()
- .and_then(|f| FileType::from_str(f).ok());
-
- let (document_name, file_type) = match user_provided_file_type {
- Some(file_type) => {
- let document_name = FileType::clean_document_name(&req.document_name);
- (document_name.unwrap_or(req.document_name), Some(file_type))
- }
- None => match FileType::split_suffix_match(req.document_name.as_str()) {
- Some((file_name, extension)) => {
- let file_type: Option<FileType> = FileType::from_str(extension).ok();
- (file_name.to_string(), file_type)
- }
- None => (req.document_name, None),
- },
- };
-
- // Log if the user-provided mime type does not match the file type
- if let (Some(ft), Some(user_mime_type)) = (file_type, &req.mime_type)
- && *user_mime_type != ft.mime_type()
- {
- tracing::warn!(
- file_type=?ft,
- mime_type=?user_mime_type,
- "provided mime type does not match file type"
- );
- }
-
- let args = CreateDocumentRepoArgs {
- id: req.id,
- sha: req.sha,
- document_name,
- user_id: user_context.macro_user_id.clone(),
- file_type,
- project_id: req.project_id,
- email_attachment_id: req.email_attachment_id,
- created_at: req.created_at,
- is_task: req.is_task,
- skip_history: req.skip_history,
- };
-
- let response_data = state
- .service
- .create_document(user_context.macro_user_id, args, req.job_id)
- .await?;
-
- Ok(Json(CreateDocumentResponse {
- error: false,
- data: response_data,
- }))
-}
diff --git a/rust/cloud-storage/documents/src/inbound/axum_router/create_document.rs b/rust/cloud-storage/documents/src/inbound/axum_router/create_document.rs
new file mode 100644
index 0000000000..4499a34602
--- /dev/null
+++ b/rust/cloud-storage/documents/src/inbound/axum_router/create_document.rs
@@ -0,0 +1,102 @@
+//! Handler for `POST /documents`.
+
+use std::str::FromStr;
+
+use axum::{Extension, Json, extract::State};
+use entity_access::domain::ports::EntityAccessService;
+use entity_access::inbound::axum_extractors::{InternalUser, ProjectBodyAccessLevelExtractor};
+use model::document::response::{CreateDocumentRequest, CreateDocumentResponse};
+use model::document::{FileType, FileTypeExt};
+use model_user::axum_extractor::MacroUserExtractor;
+use models_permissions::share_permission::access_level::EditAccessLevel;
+
+use super::DocumentRouterState;
+use crate::domain::models::{CreateDocumentRepoArgs, DocumentError};
+use crate::domain::ports::DocumentService;
+
+/// Handler for `POST /documents`.
+///
+/// Creates a new document, generates an S3 presigned upload URL, and returns
+/// the document metadata with the URL for the client to upload to.
+#[utoipa::path(
+ tag = "document",
+ post,
+ path = "/documents",
+ operation_id = "create_document",
+ request_body = CreateDocumentRequest,
+ responses(
+ (status = 200, body = inline(CreateDocumentResponse)),
+ (status = 400, body = model_error_response::ErrorResponse),
+ (status = 401, body = model_error_response::ErrorResponse),
+ (status = 409, body = model_error_response::ErrorResponse),
+ (status = 500, body = model_error_response::ErrorResponse),
+ )
+)]
+#[tracing::instrument(skip(state, user_context, project), fields(user_id=?user_context.macro_user_id))]
+pub async fn create_document_handler<T: DocumentService, Svc: EntityAccessService>(
+ State(state): State<DocumentRouterState<T, Svc>>,
+ internal_user: Option<Extension<InternalUser>>,
+ user_context: MacroUserExtractor,
+ project: ProjectBodyAccessLevelExtractor<EditAccessLevel, CreateDocumentRequest, Svc>,
+) -> Result<Json<CreateDocumentResponse>, DocumentError> {
+ let req = project.into_inner();
+
+ // Email linking is internal only
+ if req.email_attachment_id.is_some() && internal_user.is_none() {
+ return Err(DocumentError::Unauthorized);
+ }
+
+ // Parse file type from the request
+ let user_provided_file_type: Option<FileType> = req
+ .file_type
+ .as_deref()
+ .and_then(|f| FileType::from_str(f).ok());
+
+ let (document_name, file_type) = match user_provided_file_type {
+ Some(file_type) => {
+ let document_name = FileType::clean_document_name(&req.document_name);
+ (document_name.unwrap_or(req.document_name), Some(file_type))
+ }
+ None => match FileType::split_suffix_match(req.document_name.as_str()) {
+ Some((file_name, extension)) => {
+ let file_type: Option<FileType> = FileType::from_str(extension).ok();
+ (file_name.to_string(), file_type)
+ }
+ None => (req.document_name, None),
+ },
+ };
+
+ // Log if the user-provided mime type does not match the file type
+ if let (Some(ft), Some(user_mime_type)) = (file_type, &req.mime_type)
+ && *user_mime_type != ft.mime_type()
+ {
+ tracing::warn!(
+ file_type=?ft,
+ mime_type=?user_mime_type,
+ "provided mime type does not match file type"
+ );
+ }
+
+ let args = CreateDocumentRepoArgs {
+ id: req.id,
+ sha: req.sha,
+ document_name,
+ user_id: user_context.macro_user_id.clone(),
+ file_type,
+ project_id: req.project_id,
+ email_attachment_id: req.email_attachment_id,
+ created_at: req.created_at,
+ is_task: req.is_task,
+ skip_history: req.skip_history,
+ };
+
+ let response_data = state
+ .service
+ .create_document(user_context.macro_user_id, args, req.job_id)
+ .await?;
+
+ Ok(Json(CreateDocumentResponse {
+ error: false,
+ data: response_data,
+ }))
+}
diff --git a/rust/cloud-storage/documents/src/inbound/axum_router/delete_document.rs b/rust/cloud-storage/documents/src/inbound/axum_router/delete_document.rs
new file mode 100644
index 0000000000..48648b960e
--- /dev/null
+++ b/rust/cloud-storage/documents/src/inbound/axum_router/delete_document.rs
@@ -0,0 +1,52 @@
+//! Handler for `DELETE /documents/:document_id`.
+
+use axum::{
+ Extension, Json,
+ extract::{Path, State},
+};
+use entity_access::domain::ports::EntityAccessService;
+use entity_access::inbound::axum_extractors::DocumentAccessExtractor;
+use model::document::DocumentBasic;
+use model::response::GenericSuccessResponse;
+use model::user::UserContext;
+use models_permissions::share_permission::access_level::OwnerAccessLevel;
+
+use super::{DocumentRouterState, Params};
+use crate::domain::models::DocumentError;
+use crate::domain::ports::DocumentService;
+
+/// Handler for `DELETE /documents/:document_id`.
+///
+/// Soft-deletes a document (only owners can delete).
+#[utoipa::path(
+ tag = "document",
+ delete,
+ path = "/documents/{document_id}",
+ operation_id = "delete_document",
+ params(
+ ("document_id" = String, Path, description = "Document ID")
+ ),
+ responses(
+ (status = 200, body = GenericSuccessResponse),
+ (status = 401, body = model_error_response::ErrorResponse),
+ (status = 404, body = model_error_response::ErrorResponse),
+ (status = 500, body = model_error_response::ErrorResponse),
+ )
+)]
+#[tracing::instrument(skip(state, access, doc), err)]
+pub async fn delete_document_handler<T: DocumentService, Svc: EntityAccessService>(
+ access: DocumentAccessExtractor<OwnerAccessLevel, Svc>,
+ State(state): State<DocumentRouterState<T, Svc>>,
+ user_context: Extension<UserContext>,
+ doc: Extension<DocumentBasic>,
+ Path(Params { document_id }): Path<Params>,
+) -> Result<Json<GenericSuccessResponse>, DocumentError> {
+ tracing::info!("delete document");
+
+ state
+ .service
+ .delete_document(access.entity_access_receipt, doc.project_id.clone())
+ .await?;
+
+ Ok(Json(GenericSuccessResponse { success: true }))
+}
diff --git a/rust/cloud-storage/documents/src/inbound/axum_router/edit_document.rs b/rust/cloud-storage/documents/src/inbound/axum_router/edit_document.rs
new file mode 100644
index 0000000000..4b4b848b88
--- /dev/null
+++ b/rust/cloud-storage/documents/src/inbound/axum_router/edit_document.rs
@@ -0,0 +1,75 @@
+//! Handler for `PATCH /documents/:document_id`.
+
+use axum::{
+ Extension, Json,
+ extract::{Path, State},
+};
+use entity_access::domain::ports::EntityAccessService;
+use entity_access::inbound::axum_extractors::{
+ DocumentAccessExtractor, ProjectBodyAccessLevelExtractor,
+};
+use model::document::DocumentBasic;
+use model::response::GenericSuccessResponse;
+use models_permissions::share_permission::access_level::EditAccessLevel;
+
+use super::{DocumentRouterState, Params};
+use crate::domain::models::{DocumentError, EditDocumentServiceArgs};
+use crate::domain::ports::DocumentService;
+
+/// Edit document response.
+#[derive(serde::Serialize, utoipa::ToSchema)]
+pub struct EditDocumentResponse {
+ /// Whether an error occurred.
+ pub error: bool,
+ /// The response data.
+ pub data: GenericSuccessResponse,
+}
+
+/// Handler for `PATCH /documents/:document_id`.
+///
+/// Edits document metadata such as name or project, and modifies
+/// the document's share permissions. Requires edit access to the document,
+/// and edit access to the target project if moving the document.
+#[utoipa::path(
+ tag = "document",
+ patch,
+ path = "/documents/{document_id}",
+ operation_id = "edit_document",
+ params(
+ ("document_id" = String, Path, description = "Document ID")
+ ),
+ request_body = EditDocumentServiceArgs,
+ responses(
+ (status = 200, body = EditDocumentResponse),
+ (status = 400, body = model_error_response::ErrorResponse),
+ (status = 401, body = model_error_response::ErrorResponse),
+ (status = 404, body = model_error_response::ErrorResponse),
+ (status = 500, body = model_error_response::ErrorResponse),
+ )
+)]
+#[tracing::instrument(skip(state, access, doc, project), err)]
+pub async fn edit_document_handler<T: DocumentService, Svc: EntityAccessService>(
+ access: DocumentAccessExtractor<EditAccessLevel, Svc>,
+ State(state): State<DocumentRouterState<T, Svc>>,
+ doc: Extension<DocumentBasic>,
+ Path(Params { document_id }): Path<Params>,
+ project: ProjectBodyAccessLevelExtractor<EditAccessLevel, EditDocumentServiceArgs, Svc>,
+) -> Result<Json<EditDocumentResponse>, DocumentError> {
+ if doc.deleted_at.is_some() {
+ return Err(DocumentError::BadRequest(
+ "cannot modify deleted document".to_string(),
+ ));
+ }
+
+ let args = project.into_inner();
+
+ state
+ .service
+ .edit_document(access.entity_access_receipt, doc.0, args)
+ .await?;
+
+ Ok(Json(EditDocumentResponse {
+ error: false,
+ data: GenericSuccessResponse::default(),
+ }))
+}
diff --git a/rust/cloud-storage/documents/src/inbound/axum_router/get_document.rs b/rust/cloud-storage/documents/src/inbound/axum_router/get_document.rs
new file mode 100644
index 0000000000..f1575e36ca
--- /dev/null
+++ b/rust/cloud-storage/documents/src/inbound/axum_router/get_document.rs
@@ -0,0 +1,51 @@
+//! Handler for `GET /documents/:document_id`.
+
+use axum::{
+ Extension, Json,
+ extract::{Path, State},
+};
+use entity_access::domain::ports::EntityAccessService;
+use entity_access::inbound::axum_extractors::DocumentAccessExtractor;
+use model::document::response::GetDocumentResponse;
+use model::user::UserContext;
+use models_permissions::share_permission::access_level::ViewAccessLevel;
+
+use super::{DocumentRouterState, Params};
+use crate::domain::models::DocumentError;
+use crate::domain::ports::DocumentService;
+
+/// Handler for `GET /documents/:document_id`.
+///
+/// Returns document metadata, user access level, and view location.
+#[utoipa::path(
+ tag = "document",
+ get,
+ path = "/documents/{document_id}",
+ operation_id = "get_document",
+ params(
+ ("document_id" = String, Path, description = "Document ID")
+ ),
+ responses(
+ (status = 200, body = GetDocumentResponse),
+ (status = 401, body = model_error_response::ErrorResponse),
+ (status = 404, body = model_error_response::ErrorResponse),
+ (status = 500, body = model_error_response::ErrorResponse),
+ )
+)]
+#[tracing::instrument(skip(state, access), err)]
+pub async fn get_document_handler<T: DocumentService, Svc: EntityAccessService>(
+ State(state): State<DocumentRouterState<T, Svc>>,
+ access: DocumentAccessExtractor<ViewAccessLevel, Svc>,
+ user_context: Extension<UserContext>,
+ Path(Params { document_id }): Path<Params>,
+) -> Result<Json<GetDocumentResponse>, DocumentError> {
+ let response_data = state
+ .service
+ .get_document(access.entity_access_receipt)
+ .await?;
+
+ Ok(Json(GetDocumentResponse {
+ error: false,
+ data: response_data,
+ }))
+}
diff --git a/rust/cloud-storage/documents/src/inbound/axum_router/get_location.rs b/rust/cloud-storage/documents/src/inbound/axum_router/get_location.rs
new file mode 100644
index 0000000000..ad8f1c14e3
--- /dev/null
+++ b/rust/cloud-storage/documents/src/inbound/axum_router/get_location.rs
@@ -0,0 +1,57 @@
+//! Handler for `GET /documents/:document_id/location_v3`.
+
+use axum::{
+ Extension, Json,
+ extract::{Path, Query, State},
+ http::HeaderMap,
+};
+use entity_access::domain::ports::EntityAccessService;
+use entity_access::inbound::axum_extractors::DocumentAccessExtractor;
+use model::document::DocumentBasic;
+use model::document::response::LocationResponseV3;
+use models_permissions::share_permission::access_level::ViewAccessLevel;
+
+use super::{DocumentRouterState, Params};
+use crate::domain::models::{DocumentError, LocationQueryParams};
+use crate::domain::ports::DocumentService;
+
+/// Handler for `GET /documents/:document_id/location_v3`.
+///
+/// Returns a presigned URL or sync service content for accessing the document.
+#[utoipa::path(
+ tag = "document",
+ get,
+ path = "/documents/{document_id}/location_v3",
+ operation_id = "get_document_location_v3",
+ params(
+ ("document_id" = String, Path, description = "Document ID"),
+ ("document_version_id" = Option<i64>, Query, description = "A specific document version id to get the location for."),
+ ("get_converted_docx_url" = Option<bool>, Query, description = "If true, this will return the converted docx url.")
+ ),
+ responses(
+ (status = 200),
+ (status = 401, body = model_error_response::ErrorResponse),
+ (status = 404, body = model_error_response::ErrorResponse),
+ (status = 410, body = model_error_response::ErrorResponse),
+ (status = 500, body = model_error_response::ErrorResponse),
+ )
+)]
+#[tracing::instrument(skip(state, access, document_context), err)]
+pub async fn get_location_v3_handler<T: DocumentService, Svc: EntityAccessService>(
+ access: DocumentAccessExtractor<ViewAccessLevel, Svc>,
+ State(state): State<DocumentRouterState<T, Svc>>,
+ Extension(document_context): Extension<DocumentBasic>,
+ Path(Params { document_id }): Path<Params>,
+ Query(params): Query<LocationQueryParams>,
+) -> Result<(HeaderMap, Json<LocationResponseV3>), DocumentError> {
+ let response_data = state
+ .service
+ .get_document_location(&document_context, access.entity_access_receipt, params)
+ .await?;
+
+ let mut header_map = HeaderMap::new();
+ header_map.append("content-type", "application/json".parse().unwrap());
+ header_map.append("Cache-Control", "max-age-300".parse().unwrap());
+
+ Ok((header_map, Json(response_data)))
+}
diff --git a/rust/cloud-storage/documents/src/inbound/axum_router/get_short_id.rs b/rust/cloud-storage/documents/src/inbound/axum_router/get_short_id.rs
new file mode 100644
index 0000000000..8a7546652d
--- /dev/null
+++ b/rust/cloud-storage/documents/src/inbound/axum_router/get_short_id.rs
@@ -0,0 +1,53 @@
+//! Handler for `GET /documents/:document_id/short_id`.
+
+use axum::{
+ Json,
+ extract::{Path, State},
+};
+use entity_access::domain::ports::EntityAccessService;
+use entity_access::inbound::axum_extractors::DocumentAccessExtractor;
+use models_permissions::share_permission::access_level::ViewAccessLevel;
+
+use super::{DocumentRouterState, Params};
+use crate::domain::models::DocumentError;
+use crate::domain::ports::DocumentService;
+
+/// Short ID response.
+#[derive(serde::Serialize, utoipa::ToSchema)]
+#[serde(rename_all = "camelCase")]
+pub struct ShortIdResponse {
+ /// The short id of the document.
+ short_id: String,
+}
+
+/// Handler for `GET /documents/:document_id/short_id`.
+///
+/// Returns the short UUID for a document.
+#[utoipa::path(
+ tag = "document",
+ get,
+ path = "/documents/{document_id}/short_id",
+ operation_id = "get_document_short_id",
+ params(
+ ("document_id" = String, Path, description = "Document ID")
+ ),
+ responses(
+ (status = 200, body = String),
+ (status = 401, body = model_error_response::ErrorResponse),
+ (status = 404, body = model_error_response::ErrorResponse),
+ (status = 500, body = model_error_response::ErrorResponse),
+ )
+)]
+#[tracing::instrument(skip(state, access), err)]
+pub async fn get_short_id_handler<T: DocumentService, Svc: EntityAccessService>(
+ State(state): State<DocumentRouterState<T, Svc>>,
+ access: DocumentAccessExtractor<ViewAccessLevel, Svc>,
+ Path(Params { document_id }): Path<Params>,
+) -> Result<Json<ShortIdResponse>, DocumentError> {
+ let short_id = state
+ .service
+ .get_short_id(access.entity_access_receipt)
+ .await?;
+
+ Ok(Json(ShortIdResponse { short_id }))
+}
diff --git a/rust/cloud-storage/documents/src/outbound/pg_document_repo.rs b/rust/cloud-storage/documents/src/outbound/pg_document_repo.rs
index 3cccfbbb3f..040b62ad49 100644
--- a/rust/cloud-storage/documents/src/outbound/pg_document_repo.rs
+++ b/rust/cloud-storage/documents/src/outbound/pg_document_repo.rs
@@ -6,13 +6,14 @@
mod tests;
mod create;
+mod edit;
use document_sub_type::DocumentSubType;
use macro_user_id::{cowlike::CowLike, user_id::MacroUserIdStr};
use model::document::{DocumentBasic, DocumentMetadata};
use sqlx::PgPool;
-use crate::domain::models::CreateDocumentRepoArgs;
+use crate::domain::models::{CreateDocumentRepoArgs, EditDocumentRepoArgs};
use crate::domain::ports::DocumentRepo;
/// PostgreSQL-backed document repository.
@@ -479,6 +480,27 @@ impl DocumentRepo for PgDocumentRepo {
))
}
+ #[tracing::instrument(err, skip(self, args))]
+ async fn edit_document(&self, args: EditDocumentRepoArgs) -> Result<(), Self::Err> {
+ let mut transaction = self.pool.begin().await?;
+
+ edit::update_document_metadata(
+ &mut transaction,
+ &args.document_id,
+ args.document_name.as_deref(),
+ args.project_id.as_deref(),
+ )
+ .await?;
+
+ if let Some(ref share_permission) = args.share_permission {
+ edit::update_share_permission(&mut transaction, &args.document_id, share_permission)
+ .await?;
+ }
+
+ transaction.commit().await?;
+ Ok(())
+ }
+
#[tracing::instrument(err, skip(self))]
async fn update_upload_job(&self, document_id: &str, job_id: &str) -> Result<(), Self::Err> {
let result = sqlx::query!(
@@ -498,6 +520,18 @@ impl DocumentRepo for PgDocumentRepo {
Ok(())
}
+ #[tracing::instrument(err, skip(self))]
+ async fn update_project_modified(&self, project_id: &str) -> Result<(), Self::Err> {
+ sqlx::query!(
+ r#"UPDATE "Project" SET "updatedAt" = NOW() WHERE id = $1"#,
+ project_id,
+ )
+ .execute(&self.pool)
+ .await?;
+
+ Ok(())
+ }
+
#[tracing::instrument(err, skip(self))]
async fn delete_document_by_id(&self, document_id: &str) -> Result<(), Self::Err> {
sqlx::query!(r#"DELETE FROM "Document" WHERE id = $1"#, document_id,)
diff --git a/rust/cloud-storage/documents/src/outbound/pg_document_repo/edit.rs b/rust/cloud-storage/documents/src/outbound/pg_document_repo/edit.rs
new file mode 100644
index 0000000000..1d5d80e78f
--- /dev/null
+++ b/rust/cloud-storage/documents/src/outbound/pg_document_repo/edit.rs
@@ -0,0 +1,226 @@
+//! SQL operations for editing document metadata and share permissions.
+
+use models_permissions::share_permission::UpdateSharePermissionRequestV2;
+use models_permissions::share_permission::channel_share_permission::UpdateOperation;
+use sqlx::{Postgres, Transaction};
+
+/// Update document metadata (name, projectId, updatedAt).
+pub(super) async fn update_document_metadata(
+ transaction: &mut Transaction<'_, Postgres>,
+ document_id: &str,
+ document_name: Option<&str>,
+ project_id: Option<&str>,
+) -> Result<(), sqlx::Error> {
+ let mut query = "UPDATE \"Document\" SET ".to_string();
+ let mut parameters: Vec<Option<&str>> = Vec::new();
+ let mut set_parts = Vec::new();
+
+ if let Some(name) = document_name {
+ set_parts.push(format!("\"name\" = ${}", parameters.len() + 2));
+ parameters.push(Some(name));
+ }
+
+ if let Some(project_id) = project_id {
+ set_parts.push(format!("\"projectId\" = ${}", parameters.len() + 2));
+ if project_id.is_empty() {
+ parameters.push(None);
+ } else {
+ parameters.push(Some(project_id));
+ }
+ }
+
+ query += &set_parts.join(", ");
+
+ if !set_parts.is_empty() {
+ query += ", ";
+ }
+
+ query += "\"updatedAt\" = NOW() WHERE id = $1";
+
+ let mut query = sqlx::query(&query);
+ query = query.bind(document_id);
+
+ for param in parameters {
+ query = query.bind(param);
+ }
+
+ query.execute(transaction.as_mut()).await?;
+ Ok(())
+}
+
+/// Update share permissions for a document.
+///
+/// Looks up the document's share permission ID, then updates the SharePermission
+/// and ChannelSharePermission tables.
+pub(super) async fn update_share_permission(
+ transaction: &mut Transaction<'_, Postgres>,
+ document_id: &str,
+ share_permission: &UpdateSharePermissionRequestV2,
+) -> Result<(), sqlx::Error> {
+ // Look up the share permission ID for this document
+ let share_permission_id = sqlx::query_scalar!(
+ r#"
+ SELECT dp."sharePermissionId" as "share_permission_id!"
+ FROM "DocumentPermission" dp
+ WHERE dp."documentId" = $1
+ "#,
+ document_id
+ )
+ .fetch_one(transaction.as_mut())
+ .await?;
+
+ // Build dynamic update for SharePermission
+ update_share_permission_row(transaction, &share_permission_id, share_permission).await?;
+
+ // Handle channel share permission changes
+ if let Some(channel_perms) = &share_permission.channel_share_permissions {
+ update_channel_share_permissions(transaction, &share_permission_id, channel_perms).await?;
+ }
+
+ Ok(())
+}
+
+/// Update the SharePermission row (isPublic, publicAccessLevel).
+async fn update_share_permission_row(
+ transaction: &mut Transaction<'_, Postgres>,
+ share_permission_id: &str,
+ share_permission: &UpdateSharePermissionRequestV2,
+) -> Result<(), sqlx::Error> {
+ let mut set_parts = Vec::new();
+ let mut str_params: Vec<Option<String>> = Vec::new();
+ let mut bool_params: Vec<bool> = Vec::new();
+
+ // Track parameter indices (starting at 2 since $1 is the share_permission_id)
+ let mut param_idx = 2u32;
+ // We'll track which params are bool vs string to bind in order
+ enum ParamType {
+ Bool(usize),
+ Str(usize),
+ }
+ let mut param_order: Vec<ParamType> = Vec::new();
+
+ let mut ignore_public_access_level = false;
+ if let Some(is_public) = share_permission.is_public {
+ set_parts.push(format!("\"isPublic\" = ${param_idx}"));
+ param_idx += 1;
+ bool_params.push(is_public);
+ param_order.push(ParamType::Bool(bool_params.len() - 1));
+
+ if is_public && share_permission.public_access_level.is_none() {
+ set_parts.push(format!("\"publicAccessLevel\" = ${param_idx}"));
+ param_idx += 1;
+ str_params.push(Some("view".to_string()));
+ param_order.push(ParamType::Str(str_params.len() - 1));
+ }
+
+ if !is_public {
+ ignore_public_access_level = true;
+ set_parts.push("\"publicAccessLevel\" = NULL".to_string());
+ }
+ }
+
+ if let Some(public_access_level) = share_permission.public_access_level
+ && !ignore_public_access_level
+ {
+ set_parts.push(format!("\"publicAccessLevel\" = ${param_idx}"));
+ // param_idx += 1; (not needed, last usage)
+ str_params.push(Some(public_access_level.to_string()));
+ param_order.push(ParamType::Str(str_params.len() - 1));
+ }
+
+ if set_parts.is_empty() {
+ // Nothing to update on the SharePermission row, but still update timestamp
+ sqlx::query(r#"UPDATE "SharePermission" SET "updatedAt" = NOW() WHERE id = $1"#)
+ .bind(share_permission_id)
+ .execute(transaction.as_mut())
+ .await?;
+ return Ok(());
+ }
+
+ let query_str = format!(
+ r#"UPDATE "SharePermission" SET {}, "updatedAt" = NOW() WHERE id = $1"#,
+ set_parts.join(", ")
+ );
+
+ let mut query = sqlx::query(&query_str);
+ query = query.bind(share_permission_id.to_string());
+
+ for param_type in &param_order {
+ match param_type {
+ ParamType::Bool(idx) => {
+ query = query.bind(bool_params[*idx]);
+ }
+ ParamType::Str(idx) => {
+ query = query.bind(str_params[*idx].clone());
+ }
+ }
+ }
+
+ query.execute(transaction.as_mut()).await?;
+ Ok(())
+}
+
+/// Update channel share permissions (add/replace/remove).
+async fn update_channel_share_permissions(
+ transaction: &mut Transaction<'_, Postgres>,
+ share_permission_id: &str,
+ channel_perms: &[models_permissions::share_permission::channel_share_permission::UpdateChannelSharePermission],
+) -> Result<(), sqlx::Error> {
+ // Collect upserts (Add/Replace) and removals
+ let mut upsert_channel_ids = Vec::new();
+ let mut upsert_access_levels = Vec::new();
+ let mut remove_channel_ids = Vec::new();
+
+ for perm in channel_perms {
+ match perm.operation {
+ UpdateOperation::Add | UpdateOperation::Replace => {
+ upsert_channel_ids.push(perm.channel_id.clone());
+ upsert_access_levels.push(
+ perm.access_level
+ .unwrap_or(
+ models_permissions::share_permission::access_level::AccessLevel::View,
+ )
+ .to_string(),
+ );
+ }
+ UpdateOperation::Remove => {
+ remove_channel_ids.push(perm.channel_id.clone());
+ }
+ }
+ }
+
+ // Remove channel share permissions
+ if !remove_channel_ids.is_empty() {
+ sqlx::query!(
+ r#"
+ DELETE FROM "ChannelSharePermission"
+ WHERE "share_permission_id" = $1
+ AND "channel_id" = ANY($2)
+ "#,
+ share_permission_id,
+ &remove_channel_ids,
+ )
+ .execute(transaction.as_mut())
+ .await?;
+ }
+
+ // Upsert channel share permissions
+ if !upsert_channel_ids.is_empty() {
+ sqlx::query!(
+ r#"
+ INSERT INTO "ChannelSharePermission" ("share_permission_id", "channel_id", "access_level")
+ SELECT $1, channel_id, access_level::"AccessLevel"
+ FROM UNNEST($2::text[], $3::text[]) AS t(channel_id, access_level)
+ ON CONFLICT ("share_permission_id", "channel_id")
+ DO UPDATE SET "access_level" = EXCLUDED."access_level"
+ "#,
+ share_permission_id,
+ &upsert_channel_ids,
+ &upsert_access_levels,
+ )
+ .execute(transaction.as_mut())
+ .await?;
+ }
+
+ Ok(())
+}
diff --git a/rust/cloud-storage/documents/src/outbound/pg_document_repo/tests.rs b/rust/cloud-storage/documents/src/outbound/pg_document_repo/tests.rs
index d3cb81f403..70a7c01a3d 100644
--- a/rust/cloud-storage/documents/src/outbound/pg_document_repo/tests.rs
+++ b/rust/cloud-storage/documents/src/outbound/pg_document_repo/tests.rs
@@ -1,6 +1,9 @@
use macro_db_migrator::MACRO_DB_MIGRATIONS;
+use models_permissions::share_permission::UpdateSharePermissionRequestV2;
+use models_permissions::share_permission::access_level::AccessLevel;
use sqlx::{Pool, Postgres};
+use crate::domain::models::EditDocumentRepoArgs;
use crate::domain::ports::DocumentRepo;
use crate::outbound::pg_document_repo::PgDocumentRepo;
@@ -101,3 +104,192 @@ async fn test_get_user_view_location(pool: Pool<Postgres>) {
.unwrap();
assert!(location.is_none());
}
+
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("documents_test_data"))
+)]
+async fn test_edit_document_name(pool: Pool<Postgres>) {
+ let repo = PgDocumentRepo::new(pool.clone());
+
+ repo.edit_document(EditDocumentRepoArgs {
+ document_id: "document-one".to_string(),
+ document_name: Some("new-name".to_string()),
+ project_id: None,
+ share_permission: None,
+ })
+ .await
+ .unwrap();
+
+ let doc = repo.get_basic_document("document-one").await.unwrap();
+ assert_eq!(doc.document_name, "new-name");
+}
+
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("documents_test_data"))
+)]
+async fn test_edit_document_project(pool: Pool<Postgres>) {
+ let repo = PgDocumentRepo::new(pool.clone());
+
+ repo.edit_document(EditDocumentRepoArgs {
+ document_id: "document-one".to_string(),
+ document_name: None,
+ project_id: Some("new-project".to_string()),
+ share_permission: None,
+ })
+ .await
+ .unwrap();
+
+ let doc = repo.get_basic_document("document-one").await.unwrap();
+ assert_eq!(doc.project_id, Some("new-project".to_string()));
+}
+
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("documents_test_data"))
+)]
+async fn test_edit_document_remove_project(pool: Pool<Postgres>) {
+ let repo = PgDocumentRepo::new(pool.clone());
+
+ // First set a project
+ repo.edit_document(EditDocumentRepoArgs {
+ document_id: "document-one".to_string(),
+ document_name: None,
+ project_id: Some("new-project".to_string()),
+ share_permission: None,
+ })
+ .await
+ .unwrap();
+
+ let doc = repo.get_basic_document("document-one").await.unwrap();
+ assert_eq!(doc.project_id, Some("new-project".to_string()));
+
+ // Then remove it by passing empty string
+ repo.edit_document(EditDocumentRepoArgs {
+ document_id: "document-one".to_string(),
+ document_name: None,
+ project_id: Some("".to_string()),
+ share_permission: None,
+ })
+ .await
+ .unwrap();
+
+ let doc = repo.get_basic_document("document-one").await.unwrap();
+ assert_eq!(doc.project_id, None);
+}
+
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("documents_test_data"))
+)]
+async fn test_edit_document_share_permission(pool: Pool<Postgres>) {
+ let repo = PgDocumentRepo::new(pool.clone());
+
+ repo.edit_document(EditDocumentRepoArgs {
+ document_id: "document-one".to_string(),
+ document_name: None,
+ project_id: None,
+ share_permission: Some(UpdateSharePermissionRequestV2 {
+ is_public: Some(false),
+ public_access_level: None,
+ channel_share_permissions: None,
+ }),
+ })
+ .await
+ .unwrap();
+
+ // Verify the share permission was updated
+ let result = sqlx::query!(
+ r#"
+ SELECT sp."isPublic" as is_public, sp."publicAccessLevel" as "public_access_level?"
+ FROM "SharePermission" sp
+ JOIN "DocumentPermission" dp ON dp."sharePermissionId" = sp.id
+ WHERE dp."documentId" = $1
+ "#,
+ "document-one"
+ )
+ .fetch_one(&pool)
+ .await
+ .unwrap();
+
+ assert!(!result.is_public);
+ assert!(result.public_access_level.is_none());
+}
+
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("documents_test_data"))
+)]
+async fn test_edit_document_set_public_access_level(pool: Pool<Postgres>) {
+ let repo = PgDocumentRepo::new(pool.clone());
+
+ repo.edit_document(EditDocumentRepoArgs {
+ document_id: "document-one".to_string(),
+ document_name: None,
+ project_id: None,
+ share_permission: Some(UpdateSharePermissionRequestV2 {
+ is_public: None,
+ public_access_level: Some(AccessLevel::Edit),
+ channel_share_permissions: None,
+ }),
+ })
+ .await
+ .unwrap();
+
+ let result = sqlx::query!(
+ r#"
+ SELECT sp."publicAccessLevel" as "public_access_level?"
+ FROM "SharePermission" sp
+ JOIN "DocumentPermission" dp ON dp."sharePermissionId" = sp.id
+ WHERE dp."documentId" = $1
+ "#,
+ "document-one"
+ )
+ .fetch_one(&pool)
+ .await
+ .unwrap();
+
+ assert_eq!(result.public_access_level, Some("edit".to_string()));
+}
+
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("documents_test_data"))
+)]
+async fn test_edit_document_name_and_project(pool: Pool<Postgres>) {
+ let repo = PgDocumentRepo::new(pool.clone());
+
+ repo.edit_document(EditDocumentRepoArgs {
+ document_id: "document-one".to_string(),
+ document_name: Some("renamed".to_string()),
+ project_id: Some("new-project".to_string()),
+ share_permission: Some(UpdateSharePermissionRequestV2 {
+ is_public: Some(true),
+ public_access_level: Some(AccessLevel::Edit),
+ channel_share_permissions: None,
+ }),
+ })
+ .await
+ .unwrap();
+
+ let doc = repo.get_basic_document("document-one").await.unwrap();
+ assert_eq!(doc.document_name, "renamed");
+ assert_eq!(doc.project_id, Some("new-project".to_string()));
+
+ let result = sqlx::query!(
+ r#"
+ SELECT sp."isPublic" as is_public, sp."publicAccessLevel" as "public_access_level?"
+ FROM "SharePermission" sp
+ JOIN "DocumentPermission" dp ON dp."sharePermissionId" = sp.id
+ WHERE dp."documentId" = $1
+ "#,
+ "document-one"
+ )
+ .fetch_one(&pool)
+ .await
+ .unwrap();
+
+ assert!(result.is_public);
+ assert_eq!(result.public_access_level, Some("edit".to_string()));
+}
diff --git a/rust/cloud-storage/github/src/domain/service/sync/test.rs b/rust/cloud-storage/github/src/domain/service/sync/test.rs
index c938d437f3..0a2bad9d5c 100644
--- a/rust/cloud-storage/github/src/domain/service/sync/test.rs
+++ b/rust/cloud-storage/github/src/domain/service/sync/test.rs
@@ -9,6 +9,7 @@ use crate::domain::{
ports::{GithubSyncClient, GithubSyncRepo, GithubSyncService},
};
use document_sub_type::DocumentSubType;
+use documents::domain::models::EditDocumentServiceArgs;
use documents::domain::{
models::{CreateDocumentRepoArgs, DocumentError, LocationQueryParams},
ports::DocumentService,
@@ -171,6 +172,15 @@ impl DocumentService for StubDocumentService {
});
Ok(())
}
+
+ async fn edit_document(
+ &self,
+ _entity_access_receipt: EntityAccessReceipt<EditAccessLevel>,
+ _document_basic: DocumentBasic,
+ _request: EditDocumentServiceArgs,
+ ) -> Result<(), DocumentError> {
+ Ok(())
+ }
}
/// Stateful stub repo that tracks task IDs per github key.