1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//! This module provides the API handlers for Document entity operations.
//!
//! It includes functions for creating new documents and retrieving existing ones,
//! serving as the entry point for interactions with the document service layer.
use crate::;
use ;
use Document;
use Deserialize;
use Value;
use HashMap;
/// Request payload for creating a new document.
///
/// A document is created against a specific form and workflow. The `data`
/// field contains the user-provided values for the form and is validated
/// against the referenced form definition during creation.
/// Create a new document definition.
///
/// Accepts a [`CreateDocumentRequest`] and validates it.
/// If validation succeeds, the document is
/// persisted and the stored document is returned.
///
/// # Route
/// `POST /documents`
///
/// # Errors
/// - Returns an error if the document definition fails validation.
/// - Returns an error if persistence fails.
///
/// # Notes
/// This endpoint is intended only for creating new documents.
/// Updates to existing documents should be handled via a separate endpoint
/// to allow different validation and lifecycle rules.
pub async
/// Retrieve a document definition by id.
///
/// # Route
/// `GET /documents/{id}`
///
/// # Errors
/// - Returns an error if the document does not exist.
/// - Returns an error if the underlying storage operation fails.
pub async
// TODO: POST /documents/{id} for Updates