-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathschemas.js
More file actions
463 lines (461 loc) · 14.4 KB
/
Copy pathschemas.js
File metadata and controls
463 lines (461 loc) · 14.4 KB
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
/**
* @swagger
* components:
* securitySchemes:
* BearerAuth:
* type: http
* scheme: bearer
* bearerFormat: JWT
* description: |
* JWT-based authentication for web app users. The token is obtained by authenticating via the login endpoint.
*
* ### How to authenticate:
* 1. Send a POST request to `/login` with your username and password
* 2. The server will respond with a JWT token (also set as a cookie in browsers)
* 3. Include this token in the `Authorization` header as `Bearer {token}`
*
* Example:
* ```
* Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
* ```
*
* JWT tokens are valid for 24 hours after issuance.
*
* ApiKeyAuth:
* type: apiKey
* in: header
* name: x-api-key
* description: |
* API key authentication for programmatic access. The API key can be generated or regenerated using the /api/key-regenerate endpoint.
*
* ### How to authenticate:
* 1. Access the API key from your application settings
* 2. Include the API key in the `x-api-key` HTTP header for all requests
*
* Example:
* ```
* x-api-key: 7c1f3f5e2b0a9d8c6e4b2a1d3f5e8c9b2a1d3f5e
* ```
*
* API keys do not expire unless regenerated.
*/
/**
* @swagger
* components:
* schemas:
* Error:
* type: object
* properties:
* error:
* type: string
* description: Error message
* example: Error resetting documents
*
* User:
* type: object
* required:
* - username
* - password
* properties:
* username:
* type: string
* description: User's username
* example: admin
* password:
* type: string
* format: password
* description: User's password (will be hashed)
* example: securePassword123
* id:
* type: integer
* description: User ID (auto-generated)
* example: 1
* readOnly: true
*
* LoginRequest:
* type: object
* required:
* - username
* - password
* properties:
* username:
* type: string
* description: User's username
* example: admin
* password:
* type: string
* format: password
* description: User's password
* example: securePassword123
*
* LoginResponse:
* type: object
* properties:
* token:
* type: string
* description: JWT token for authentication
* example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
* expiresIn:
* type: string
* description: Token expiration time
* example: 24h
*
* Document:
* type: object
* properties:
* id:
* type: integer
* description: Document ID
* example: 123
* title:
* type: string
* description: Document title
* example: Invoice #12345
* tags:
* type: array
* items:
* type: integer
* description: Array of tag IDs
* example: [1, 4, 7]
* correspondent:
* type: integer
* description: Correspondent ID
* example: 5
* created:
* type: string
* format: date-time
* description: Document creation date
* example: 2023-12-15T10:30:00Z
* document_type:
* type: integer
* description: Document type ID
* example: 2
* content:
* type: string
* description: Document text content
* example: "This is an invoice from Company XYZ..."
* language:
* type: string
* description: Document language code
* example: en
* custom_fields:
* type: array
* items:
* $ref: '#/components/schemas/CustomField'
* description: Custom field values for the document
*
* DocumentUpdateRequest:
* type: object
* properties:
* title:
* type: string
* description: New document title
* example: Updated Invoice #12345
* tags:
* type: array
* items:
* type: integer
* description: Array of tag IDs
* example: [1, 4, 7]
* correspondent:
* type: integer
* description: Correspondent ID
* example: 5
* document_type:
* type: integer
* description: Document type ID
* example: 2
* language:
* type: string
* description: Document language code
* example: en
* custom_fields:
* type: array
* items:
* $ref: '#/components/schemas/CustomField'
* description: Custom field values for the document
*
* CustomField:
* type: object
* required:
* - field
* - value
* properties:
* field:
* type: integer
* description: Custom field ID
* example: 3
* value:
* type: string
* description: Custom field value
* example: "123.45"
*
* AnalysisResult:
* type: object
* properties:
* document:
* type: object
* properties:
* title:
* type: string
* description: Suggested document title
* example: Invoice from ABC Corporation
* tags:
* type: array
* items:
* type: string
* description: Suggested tags
* example: ["invoice", "utilities", "2023"]
* correspondent:
* type: string
* description: Suggested correspondent name
* example: ABC Corporation
* document_type:
* type: string
* description: Suggested document type
* example: Invoice
* document_date:
* type: string
* format: date-time
* description: Extracted document date
* example: 2023-12-15T00:00:00Z
* language:
* type: string
* description: Detected document language
* example: en
* custom_fields:
* type: object
* additionalProperties:
* type: object
* properties:
* field_name:
* type: string
* description: Custom field name
* example: invoice_amount
* value:
* type: string
* description: Custom field value
* example: "123.45"
* metrics:
* type: object
* properties:
* promptTokens:
* type: integer
* description: Number of tokens in the prompt
* example: 450
* completionTokens:
* type: integer
* description: Number of tokens in the completion
* example: 120
* totalTokens:
* type: integer
* description: Total tokens used
* example: 570
* error:
* type: string
* description: Error message if analysis failed
* example: null
*
* Tag:
* type: object
* properties:
* id:
* type: integer
* description: Tag ID
* example: 5
* name:
* type: string
* description: Tag name
* example: Invoice
* color:
* type: string
* description: Tag color (hex code)
* example: "#FF5733"
* match:
* type: string
* enum: [ANY, ALL, LITERAL, REGEX]
* description: Tag matching algorithm
* example: ANY
*
* HistoryItem:
* type: object
* properties:
* document_id:
* type: integer
* description: Document ID
* example: 123
* title:
* type: string
* description: Document title
* example: Invoice #12345
* created_at:
* type: string
* format: date-time
* description: Date and time when the processing occurred
* example: 2023-12-15T10:30:00Z
* tags:
* type: array
* items:
* $ref: '#/components/schemas/Tag'
* correspondent:
* type: string
* description: Document correspondent name
* example: Acme Corp
* link:
* type: string
* description: Link to the document in Paperless-ngx
* example: http://paperless.example.com/documents/123/
*
* HistoryResponse:
* type: object
* properties:
* draw:
* type: integer
* description: DataTables draw counter echo
* example: 1
* recordsTotal:
* type: integer
* description: Total number of records in database
* example: 100
* recordsFiltered:
* type: integer
* description: Number of records after filtering
* example: 25
* data:
* type: array
* items:
* $ref: '#/components/schemas/HistoryItem'
*
* APIKeyResponse:
* type: object
* properties:
* success:
* type: string
* description: The newly generated API key
* example: 7c1f3f5e2b0a9d8c6e4b2a1d3f5e8c9b2a1d3f5e
*
* HealthResponse:
* type: object
* properties:
* status:
* type: string
* enum: [healthy, degraded, database_error, error]
* description: |
* Overall system health. `degraded` means the database is fine but
* the document scanner cannot work (scheduler not armed, or repeated
* failed runs, e.g. an unreachable Paperless-ngx).
* example: healthy
* database:
* type: string
* description: Result of the local database check
* example: ok
* message:
* type: string
* description: Additional status information (for non-healthy states)
* example: "Document scan failed 3 time(s) in a row: connect ECONNREFUSED 172.18.0.2:8000"
* scanner:
* $ref: '#/components/schemas/ScannerHealth'
* paperless:
* $ref: '#/components/schemas/PaperlessHealth'
*
* ScannerHealth:
* type: object
* description: State of the periodic document scan loop
* properties:
* automaticProcessingEnabled:
* type: boolean
* description: False when DISABLE_AUTOMATIC_PROCESSING=yes
* example: true
* armed:
* type: boolean
* description: Whether the scan cron job is scheduled
* example: true
* running:
* type: boolean
* description: Whether a scan is currently in progress
* example: false
* scanInterval:
* type: string
* nullable: true
* description: Cron expression the scheduler was armed with
* example: "0 * * * *"
* lastRunStartedAt:
* type: string
* format: date-time
* nullable: true
* lastRunFinishedAt:
* type: string
* format: date-time
* nullable: true
* lastRunSource:
* type: string
* nullable: true
* description: Trigger of the last run (initial, scheduler, api-manual, ...)
* example: scheduler
* lastRunStatus:
* type: string
* nullable: true
* enum: [ok, paperless_unreachable, error]
* example: ok
* lastSuccessfulRunAt:
* type: string
* format: date-time
* nullable: true
* consecutiveFailures:
* type: integer
* description: Number of consecutive failed scan runs
* example: 0
* failureThreshold:
* type: integer
* description: Failures required before the scanner counts as degraded
* example: 3
* degraded:
* type: boolean
* example: false
* lastError:
* type: string
* nullable: true
* description: Error message of the last failed run
*
* PaperlessHealth:
* type: object
* description: |
* Result of the most recent Paperless-ngx connectivity probe. The probe
* runs on every scan and additionally every
* `PAPERLESS_PROBE_INTERVAL_SECONDS` (default 60s), so the result stays
* current even while no scan is running.
* properties:
* reachable:
* type: boolean
* nullable: true
* description: |
* Whether the host answered at all. Null until the first probe has
* run. A rejected API token still counts as reachable — check
* `usable` to decide whether Paperless-ngx can actually be used.
* example: true
* authorized:
* type: boolean
* nullable: true
* description: Whether the API token was accepted (not 401/403)
* example: true
* usable:
* type: boolean
* nullable: true
* description: Reachable *and* authorized — what the scan loop needs
* example: true
* status:
* type: integer
* nullable: true
* description: HTTP status of the probe, null when no response arrived
* example: 200
* lastCheckedAt:
* type: string
* format: date-time
* nullable: true
* error:
* type: string
* nullable: true
* example: "connect ECONNREFUSED 172.18.0.2:8000"
*/
// This file only contains JSDoc comments for Swagger schema definitions
// No actual code is needed