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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
use Deserialize;
use ;
/// Query parameters for filtering, pagination, and sorting resources.
///
/// # Filtering
/// The `filter` parameter accepts a JSON-encoded string with various options:
/// - **Free text search:** Use the key `"q"` with a string value, for example:
/// ```json
/// {"q": "search text"}
/// ```
/// - **Filter by a single ID:** Use the key `"id"` with a UUID string, for example:
/// ```json
/// {"id": "550e8400-e29b-41d4-a716-446655440000"}
/// ```
/// - **Filter by multiple IDs:** Use the key `"id"` with an array of UUID strings, for example:
/// ```json
/// {"id": ["550e8400-e29b-41d4-a716-446655440000", "550e8400-e29b-41d4-a716-446655440001"]}
/// ```
/// - **Filter by other columns:** Include any additional key-value pairs, for example:
/// ```json
/// {"name": "example"}
/// ```
///
/// # Pagination
/// Two pagination formats are supported:
/// - **React Admin format:** Use the `range` parameter with JSON array format, for example: `[0,9]`
/// - **Standard REST format:** Use `page` and `per_page` parameters, for example: `page=1&per_page=10`
///
/// # Sorting
/// The `sort` parameter should be a JSON array with the column name and sort order, for example:
/// ```json
/// ["id", "ASC"]
/// ```
/// Query parameters for batch operations.
///
/// # Partial Success Mode
///
/// By default, batch operations use all-or-nothing semantics - if any item fails,
/// the entire batch is rolled back. When `partial=true` is specified, the operation
/// processes each item independently:
///
/// - Items that succeed are committed
/// - Items that fail are collected with their error messages
/// - Response includes both `succeeded` and `failed` arrays
/// - HTTP status is 207 Multi-Status for partial success
///
/// ## Important: Hook Behavior
///
/// Partial mode processes items via single-item methods (`create`, `update`, `delete`),
/// **not** the batch methods (`create_many`, `update_many`, `delete_many`). This means:
/// - `create::many::*`, `update::many::*`, and `delete::many::*` hooks are **not called**
/// - Single-item hooks (`create::one::*`, etc.) are called for each item
/// - There is no shared transaction — each item commits independently
///
/// ## Response Shape
///
/// When `partial=true`, the response is always a `BatchResult<T>` (with `succeeded`
/// and `failed` arrays), even when all items succeed. Without `partial=true`, the
/// response is a plain `Vec<T>`.
///
/// # Example
///
/// ```bash
/// # All-or-nothing (default)
/// POST /resources/batch
///
/// # Partial success mode
/// POST /resources/batch?partial=true
/// ```
///
/// ## Partial Success Response
///
/// ```json
/// {
/// "succeeded": [
/// { "id": "uuid-1", "name": "Item 1", ... }
/// ],
/// "failed": [
/// { "index": 1, "error": "Validation failed" }
/// ]
/// }
/// ```