@twin.org/document-management-service 0.0.2-next.4 → 0.0.3-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/documentManagementRoutes.js +584 -0
- package/dist/es/documentManagementRoutes.js.map +1 -0
- package/dist/es/documentManagementService.js +622 -0
- package/dist/es/documentManagementService.js.map +1 -0
- package/dist/es/index.js +8 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/IDocumentManagementServiceConfig.js +4 -0
- package/dist/es/models/IDocumentManagementServiceConfig.js.map +1 -0
- package/dist/es/models/IDocumentManagementStorageServiceConstructorOptions.js +2 -0
- package/dist/es/models/IDocumentManagementStorageServiceConstructorOptions.js.map +1 -0
- package/dist/es/restEntryPoints.js +10 -0
- package/dist/es/restEntryPoints.js.map +1 -0
- package/dist/types/documentManagementService.d.ts +12 -21
- package/dist/types/index.d.ts +5 -5
- package/dist/types/models/IDocumentManagementStorageServiceConstructorOptions.d.ts +1 -1
- package/docs/changelog.md +48 -0
- package/docs/open-api/spec.json +64 -90
- package/docs/reference/classes/DocumentManagementService.md +25 -79
- package/package.json +7 -8
- package/dist/cjs/index.cjs +0 -1233
- package/dist/esm/index.mjs +0 -1222
|
@@ -0,0 +1,584 @@
|
|
|
1
|
+
import { AuditableItemGraphContexts, AuditableItemGraphTypes } from "@twin.org/auditable-item-graph-models";
|
|
2
|
+
import { Coerce, ComponentFactory, Converter, Guards, Is } from "@twin.org/core";
|
|
3
|
+
import { DocumentContexts, DocumentTypes } from "@twin.org/document-management-models";
|
|
4
|
+
import { SchemaOrgContexts, SchemaOrgTypes } from "@twin.org/standards-schema-org";
|
|
5
|
+
import { UneceDocumentCodes } from "@twin.org/standards-unece";
|
|
6
|
+
import { HeaderTypes, HttpStatusCode, MimeTypes } from "@twin.org/web";
|
|
7
|
+
/**
|
|
8
|
+
* The source used when communicating about these routes.
|
|
9
|
+
*/
|
|
10
|
+
const ROUTES_SOURCE = "documentManagementStorageRoutes";
|
|
11
|
+
/**
|
|
12
|
+
* The tag to associate with the routes.
|
|
13
|
+
*/
|
|
14
|
+
export const tagsDocumentManagement = [
|
|
15
|
+
{
|
|
16
|
+
name: "Document Management",
|
|
17
|
+
description: "Endpoints which are modelled to access a document management contract."
|
|
18
|
+
}
|
|
19
|
+
];
|
|
20
|
+
/**
|
|
21
|
+
* The REST routes for document management.
|
|
22
|
+
* @param baseRouteName Prefix to prepend to the paths.
|
|
23
|
+
* @param componentName The name of the component to use in the routes stored in the ComponentFactory.
|
|
24
|
+
* @returns The generated routes.
|
|
25
|
+
*/
|
|
26
|
+
export function generateRestRoutesDocumentManagement(baseRouteName, componentName) {
|
|
27
|
+
const documentManagementCreateRoute = {
|
|
28
|
+
operationId: "DocumentManagementSet",
|
|
29
|
+
summary: "Store a document in an auditable item graph vertex and add its content to blob storage.",
|
|
30
|
+
tag: tagsDocumentManagement[0].name,
|
|
31
|
+
method: "POST",
|
|
32
|
+
path: `${baseRouteName}/`,
|
|
33
|
+
handler: async (httpRequestContext, request) => documentManagementCreate(httpRequestContext, componentName, request),
|
|
34
|
+
requestType: {
|
|
35
|
+
type: "IDocumentManagementCreateRequest",
|
|
36
|
+
examples: [
|
|
37
|
+
{
|
|
38
|
+
id: "DocumentManagementCreateRequestExample",
|
|
39
|
+
request: {
|
|
40
|
+
body: {
|
|
41
|
+
documentId: "2721000",
|
|
42
|
+
documentIdFormat: "bol",
|
|
43
|
+
documentCode: UneceDocumentCodes.BillOfLading,
|
|
44
|
+
blob: "SGVsbG8gV29ybGQ=",
|
|
45
|
+
annotationObject: {
|
|
46
|
+
"@context": "https://schema.org",
|
|
47
|
+
"@type": "DigitalDocument",
|
|
48
|
+
name: "myfile.pdf"
|
|
49
|
+
},
|
|
50
|
+
createAttestation: true
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
responseType: [
|
|
57
|
+
{
|
|
58
|
+
type: "ICreatedResponse",
|
|
59
|
+
examples: [
|
|
60
|
+
{
|
|
61
|
+
id: "DocumentManagementCreateResponseExample",
|
|
62
|
+
response: {
|
|
63
|
+
statusCode: HttpStatusCode.created,
|
|
64
|
+
headers: {
|
|
65
|
+
[HeaderTypes.Location]: "aig:123456"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
};
|
|
73
|
+
const documentManagementUpdateRoute = {
|
|
74
|
+
operationId: "DocumentManagementUpdate",
|
|
75
|
+
summary: "Update a document in an auditable item graph vertex and add its content to blob storage.",
|
|
76
|
+
tag: tagsDocumentManagement[0].name,
|
|
77
|
+
method: "PUT",
|
|
78
|
+
path: `${baseRouteName}/:auditableItemGraphDocumentId`,
|
|
79
|
+
handler: async (httpRequestContext, request) => documentManagementUpdate(httpRequestContext, componentName, request),
|
|
80
|
+
requestType: {
|
|
81
|
+
type: "IDocumentManagementUpdateRequest",
|
|
82
|
+
examples: [
|
|
83
|
+
{
|
|
84
|
+
id: "DocumentManagementUpdateRequestExample",
|
|
85
|
+
request: {
|
|
86
|
+
pathParams: {
|
|
87
|
+
auditableItemGraphDocumentId: "aig:123456"
|
|
88
|
+
},
|
|
89
|
+
body: {
|
|
90
|
+
blob: "SGVsbG8gV29ybGQ=",
|
|
91
|
+
annotationObject: {
|
|
92
|
+
"@context": "https://schema.org",
|
|
93
|
+
"@type": "DigitalDocument",
|
|
94
|
+
name: "myfile.pdf"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
responseType: [
|
|
102
|
+
{
|
|
103
|
+
type: "INoContentResponse",
|
|
104
|
+
examples: [
|
|
105
|
+
{
|
|
106
|
+
id: "DocumentManagementCreateResponseExample",
|
|
107
|
+
response: {
|
|
108
|
+
statusCode: HttpStatusCode.noContent
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
};
|
|
115
|
+
const documentManagementGetRoute = {
|
|
116
|
+
operationId: "DocumentManagementGet",
|
|
117
|
+
summary: "Get the data for a document from document management",
|
|
118
|
+
tag: tagsDocumentManagement[0].name,
|
|
119
|
+
method: "GET",
|
|
120
|
+
path: `${baseRouteName}/:auditableItemGraphDocumentId`,
|
|
121
|
+
handler: async (httpRequestContext, request) => documentManagementGet(httpRequestContext, componentName, request),
|
|
122
|
+
requestType: {
|
|
123
|
+
type: "IDocumentManagementGetRequest",
|
|
124
|
+
examples: [
|
|
125
|
+
{
|
|
126
|
+
id: "DocumentManagementGetRequestExample",
|
|
127
|
+
request: {
|
|
128
|
+
pathParams: {
|
|
129
|
+
auditableItemGraphDocumentId: "aig:123456"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
},
|
|
135
|
+
responseType: [
|
|
136
|
+
{
|
|
137
|
+
type: "IDocumentManagementGetResponse",
|
|
138
|
+
examples: [
|
|
139
|
+
{
|
|
140
|
+
id: "DocumentManagementGetResponseExample",
|
|
141
|
+
response: {
|
|
142
|
+
body: {
|
|
143
|
+
"@context": [
|
|
144
|
+
SchemaOrgContexts.ContextRoot,
|
|
145
|
+
DocumentContexts.ContextRoot,
|
|
146
|
+
DocumentContexts.ContextRootCommon
|
|
147
|
+
],
|
|
148
|
+
type: SchemaOrgTypes.ItemList,
|
|
149
|
+
[SchemaOrgTypes.ItemListElement]: [
|
|
150
|
+
{
|
|
151
|
+
"@context": [
|
|
152
|
+
DocumentContexts.ContextRoot,
|
|
153
|
+
DocumentContexts.ContextRootCommon,
|
|
154
|
+
SchemaOrgContexts.ContextRoot
|
|
155
|
+
],
|
|
156
|
+
type: DocumentTypes.Document,
|
|
157
|
+
id: "2721000:0",
|
|
158
|
+
documentId: "2721000",
|
|
159
|
+
documentIdFormat: "bol",
|
|
160
|
+
documentCode: UneceDocumentCodes.BillOfLading,
|
|
161
|
+
documentRevision: 0,
|
|
162
|
+
blobStorageId: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
|
|
163
|
+
blobHash: "sha256:123456",
|
|
164
|
+
dateCreated: "2024-01-01T00:00:00Z",
|
|
165
|
+
annotationObject: {
|
|
166
|
+
"@context": "https://schema.org",
|
|
167
|
+
"@type": "DigitalDocument",
|
|
168
|
+
name: "myfile.pdf"
|
|
169
|
+
},
|
|
170
|
+
organizationIdentity: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363",
|
|
171
|
+
userIdentity: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363"
|
|
172
|
+
}
|
|
173
|
+
]
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
]
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
type: "IDocumentManagementGetResponse",
|
|
181
|
+
mimeType: MimeTypes.JsonLd,
|
|
182
|
+
examples: [
|
|
183
|
+
{
|
|
184
|
+
id: "DocumentManagementGetResponseExample",
|
|
185
|
+
response: {
|
|
186
|
+
body: {
|
|
187
|
+
"@context": [
|
|
188
|
+
SchemaOrgContexts.ContextRoot,
|
|
189
|
+
DocumentContexts.ContextRoot,
|
|
190
|
+
DocumentContexts.ContextRootCommon
|
|
191
|
+
],
|
|
192
|
+
type: SchemaOrgTypes.ItemList,
|
|
193
|
+
[SchemaOrgTypes.ItemListElement]: [
|
|
194
|
+
{
|
|
195
|
+
"@context": [
|
|
196
|
+
DocumentContexts.ContextRoot,
|
|
197
|
+
DocumentContexts.ContextRootCommon,
|
|
198
|
+
SchemaOrgContexts.ContextRoot
|
|
199
|
+
],
|
|
200
|
+
type: DocumentTypes.Document,
|
|
201
|
+
id: "2721000:0",
|
|
202
|
+
documentId: "2721000",
|
|
203
|
+
documentIdFormat: "bol",
|
|
204
|
+
documentCode: UneceDocumentCodes.BillOfLading,
|
|
205
|
+
documentRevision: 0,
|
|
206
|
+
blobStorageId: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
|
|
207
|
+
blobHash: "sha256:123456",
|
|
208
|
+
dateCreated: "2024-01-01T00:00:00Z",
|
|
209
|
+
annotationObject: {
|
|
210
|
+
"@context": "https://schema.org",
|
|
211
|
+
"@type": "DigitalDocument",
|
|
212
|
+
name: "myfile.pdf"
|
|
213
|
+
},
|
|
214
|
+
organizationIdentity: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363",
|
|
215
|
+
userIdentity: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363"
|
|
216
|
+
}
|
|
217
|
+
]
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
]
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
type: "INotFoundResponse"
|
|
225
|
+
}
|
|
226
|
+
]
|
|
227
|
+
};
|
|
228
|
+
const documentManagementGetRevisionRoute = {
|
|
229
|
+
operationId: "DocumentManagementGetRevision",
|
|
230
|
+
summary: "Get the data for a document revision from document management",
|
|
231
|
+
tag: tagsDocumentManagement[0].name,
|
|
232
|
+
method: "GET",
|
|
233
|
+
path: `${baseRouteName}/:auditableItemGraphDocumentId/:revision`,
|
|
234
|
+
handler: async (httpRequestContext, request) => documentManagementGetRevision(httpRequestContext, componentName, request),
|
|
235
|
+
requestType: {
|
|
236
|
+
type: "IDocumentManagementGetRequest",
|
|
237
|
+
examples: [
|
|
238
|
+
{
|
|
239
|
+
id: "DocumentManagementGetRevisionRequestExample",
|
|
240
|
+
request: {
|
|
241
|
+
pathParams: {
|
|
242
|
+
auditableItemGraphDocumentId: "aig:123456",
|
|
243
|
+
revision: "1"
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
]
|
|
248
|
+
},
|
|
249
|
+
responseType: [
|
|
250
|
+
{
|
|
251
|
+
type: "IDocumentManagementGetRevisionResponse",
|
|
252
|
+
examples: [
|
|
253
|
+
{
|
|
254
|
+
id: "DocumentManagementGetRevisionResponseExample",
|
|
255
|
+
response: {
|
|
256
|
+
body: {
|
|
257
|
+
"@context": [
|
|
258
|
+
DocumentContexts.ContextRoot,
|
|
259
|
+
DocumentContexts.ContextRootCommon,
|
|
260
|
+
SchemaOrgContexts.ContextRoot
|
|
261
|
+
],
|
|
262
|
+
type: DocumentTypes.Document,
|
|
263
|
+
id: "2721000:0",
|
|
264
|
+
documentId: "2721000",
|
|
265
|
+
documentIdFormat: "bol",
|
|
266
|
+
documentCode: UneceDocumentCodes.BillOfLading,
|
|
267
|
+
documentRevision: 1,
|
|
268
|
+
blobStorageId: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
|
|
269
|
+
blobHash: "sha256:123456",
|
|
270
|
+
dateCreated: "2024-01-01T00:00:00Z",
|
|
271
|
+
annotationObject: {
|
|
272
|
+
"@context": "https://schema.org",
|
|
273
|
+
"@type": "DigitalDocument",
|
|
274
|
+
name: "myfile.pdf"
|
|
275
|
+
},
|
|
276
|
+
organizationIdentity: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363",
|
|
277
|
+
userIdentity: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363"
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
]
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
type: "IDocumentManagementGetRevisionResponse",
|
|
285
|
+
mimeType: MimeTypes.JsonLd,
|
|
286
|
+
examples: [
|
|
287
|
+
{
|
|
288
|
+
id: "DocumentManagementGetRevisionResponseExample",
|
|
289
|
+
response: {
|
|
290
|
+
body: {
|
|
291
|
+
"@context": [
|
|
292
|
+
DocumentContexts.ContextRoot,
|
|
293
|
+
DocumentContexts.ContextRootCommon,
|
|
294
|
+
SchemaOrgContexts.ContextRoot
|
|
295
|
+
],
|
|
296
|
+
type: DocumentTypes.Document,
|
|
297
|
+
id: "2721000:0",
|
|
298
|
+
documentId: "2721000",
|
|
299
|
+
documentIdFormat: "bol",
|
|
300
|
+
documentCode: UneceDocumentCodes.BillOfLading,
|
|
301
|
+
documentRevision: 1,
|
|
302
|
+
blobStorageId: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
|
|
303
|
+
blobHash: "sha256:123456",
|
|
304
|
+
dateCreated: "2024-01-01T00:00:00Z",
|
|
305
|
+
annotationObject: {
|
|
306
|
+
"@context": "https://schema.org",
|
|
307
|
+
"@type": "DigitalDocument",
|
|
308
|
+
name: "myfile.pdf"
|
|
309
|
+
},
|
|
310
|
+
organizationIdentity: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363",
|
|
311
|
+
userIdentity: "did:entity-storage:0x6363636363636363636363636363636363636363636363636363636363636363"
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
]
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
type: "INotFoundResponse"
|
|
319
|
+
}
|
|
320
|
+
]
|
|
321
|
+
};
|
|
322
|
+
const documentManagementRemoveRevisionRoute = {
|
|
323
|
+
operationId: "DocumentManagementRemove",
|
|
324
|
+
summary: "Remove an document from an auditable item graph vertex",
|
|
325
|
+
tag: tagsDocumentManagement[0].name,
|
|
326
|
+
method: "DELETE",
|
|
327
|
+
path: `${baseRouteName}/:auditableItemGraphDocumentId/:revision`,
|
|
328
|
+
handler: async (httpRequestContext, request) => documentManagementRemove(httpRequestContext, componentName, request),
|
|
329
|
+
requestType: {
|
|
330
|
+
type: "IDocumentManagementRemoveRequest",
|
|
331
|
+
examples: [
|
|
332
|
+
{
|
|
333
|
+
id: "DocumentManagementRemoveRequestExample",
|
|
334
|
+
request: {
|
|
335
|
+
pathParams: {
|
|
336
|
+
auditableItemGraphDocumentId: "aig:1234",
|
|
337
|
+
revision: "1"
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
]
|
|
342
|
+
},
|
|
343
|
+
responseType: [
|
|
344
|
+
{
|
|
345
|
+
type: "INoContentResponse"
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
type: "INotFoundResponse"
|
|
349
|
+
}
|
|
350
|
+
]
|
|
351
|
+
};
|
|
352
|
+
const documentManagementQueryRoute = {
|
|
353
|
+
operationId: "DocumentManagementQuery",
|
|
354
|
+
summary: "Query the items from an auditable item graph vertex",
|
|
355
|
+
tag: tagsDocumentManagement[0].name,
|
|
356
|
+
method: "GET",
|
|
357
|
+
path: `${baseRouteName}/`,
|
|
358
|
+
handler: async (httpRequestContext, request) => documentManagementQuery(httpRequestContext, componentName, request),
|
|
359
|
+
requestType: {
|
|
360
|
+
type: "IDocumentManagementQueryRequest",
|
|
361
|
+
examples: [
|
|
362
|
+
{
|
|
363
|
+
id: "DocumentManagementQueryRequestExample",
|
|
364
|
+
request: {
|
|
365
|
+
query: {
|
|
366
|
+
documentId: "2721000"
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
]
|
|
371
|
+
},
|
|
372
|
+
responseType: [
|
|
373
|
+
{
|
|
374
|
+
type: "IDocumentManagementQueryResponse",
|
|
375
|
+
examples: [
|
|
376
|
+
{
|
|
377
|
+
id: "DocumentManagementQueryResponseExample",
|
|
378
|
+
response: {
|
|
379
|
+
body: {
|
|
380
|
+
"@context": [SchemaOrgContexts.ContextRoot, AuditableItemGraphContexts.ContextRoot],
|
|
381
|
+
type: [SchemaOrgTypes.ItemList, AuditableItemGraphTypes.VertexList],
|
|
382
|
+
[SchemaOrgTypes.ItemListElement]: [
|
|
383
|
+
{
|
|
384
|
+
"@context": [
|
|
385
|
+
AuditableItemGraphContexts.ContextRoot,
|
|
386
|
+
AuditableItemGraphContexts.ContextRootCommon
|
|
387
|
+
],
|
|
388
|
+
id: "aig:c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7",
|
|
389
|
+
type: AuditableItemGraphTypes.Vertex,
|
|
390
|
+
dateCreated: "2024-08-22T04:13:20.000Z",
|
|
391
|
+
aliases: [
|
|
392
|
+
{
|
|
393
|
+
"@context": [AuditableItemGraphContexts.ContextRoot],
|
|
394
|
+
id: "test-id-0",
|
|
395
|
+
type: AuditableItemGraphTypes.Alias,
|
|
396
|
+
dateCreated: "2024-08-22T04:13:20.000Z"
|
|
397
|
+
}
|
|
398
|
+
],
|
|
399
|
+
resources: [
|
|
400
|
+
{
|
|
401
|
+
"@context": AuditableItemGraphContexts.ContextRoot,
|
|
402
|
+
type: AuditableItemGraphTypes.Resource,
|
|
403
|
+
dateCreated: "2024-08-22T04:13:20.000Z",
|
|
404
|
+
resourceObject: {
|
|
405
|
+
"@context": [
|
|
406
|
+
"https://schema.twindev.org/documents/",
|
|
407
|
+
"https://schema.twindev.org/common/",
|
|
408
|
+
"https://schema.org"
|
|
409
|
+
],
|
|
410
|
+
type: "Document",
|
|
411
|
+
id: "test-id-0:0",
|
|
412
|
+
documentId: "test-id-0",
|
|
413
|
+
documentCode: "unece:DocumentCodeList#705",
|
|
414
|
+
documentRevision: 0,
|
|
415
|
+
annotationObject: {
|
|
416
|
+
"@context": "https://schema.org",
|
|
417
|
+
type: "DigitalDocument",
|
|
418
|
+
name: "bill-of-lading"
|
|
419
|
+
},
|
|
420
|
+
blobHash: "sha256:E3Duqrp6bHojSx+CzDttAToAiP1eFkCDAPBbKLABVGM=",
|
|
421
|
+
blobStorageId: "blob:memory:1370eeaaba7a6c7a234b1f82cc3b6d013a0088fd5e16408300f05b28b0015463",
|
|
422
|
+
dateCreated: "2024-08-22T04:13:20.000Z",
|
|
423
|
+
organizationIdentity: "did:entity-storage:0x0101010101010101010101010101010101010101010101010101010101010101",
|
|
424
|
+
userIdentity: "did:entity-storage:0x0404040404040404040404040404040404040404040404040404040404040404"
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
]
|
|
428
|
+
}
|
|
429
|
+
]
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
]
|
|
434
|
+
}
|
|
435
|
+
]
|
|
436
|
+
};
|
|
437
|
+
return [
|
|
438
|
+
documentManagementCreateRoute,
|
|
439
|
+
documentManagementUpdateRoute,
|
|
440
|
+
documentManagementGetRoute,
|
|
441
|
+
documentManagementGetRevisionRoute,
|
|
442
|
+
documentManagementRemoveRevisionRoute,
|
|
443
|
+
documentManagementQueryRoute
|
|
444
|
+
];
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Create a document as an auditable item graph vertex.
|
|
448
|
+
* @param httpRequestContext The request context for the API.
|
|
449
|
+
* @param componentName The name of the component to use in the routes.
|
|
450
|
+
* @param request The request.
|
|
451
|
+
* @returns The response object with additional http response properties.
|
|
452
|
+
*/
|
|
453
|
+
export async function documentManagementCreate(httpRequestContext, componentName, request) {
|
|
454
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
455
|
+
Guards.object(ROUTES_SOURCE, "request.body", request.body);
|
|
456
|
+
Guards.stringBase64(ROUTES_SOURCE, "request.body.blob", request.body.blob);
|
|
457
|
+
const component = ComponentFactory.get(componentName);
|
|
458
|
+
const id = await component.create(request.body.documentId, request.body.documentIdFormat, request.body.documentCode, Converter.base64ToBytes(request.body.blob), request.body.annotationObject, request.body.auditableItemGraphEdges, {
|
|
459
|
+
createAttestation: request.body.createAttestation,
|
|
460
|
+
addAlias: request.body.addAlias,
|
|
461
|
+
aliasAnnotationObject: request.body.aliasAnnotationObject
|
|
462
|
+
});
|
|
463
|
+
return {
|
|
464
|
+
statusCode: HttpStatusCode.created,
|
|
465
|
+
headers: {
|
|
466
|
+
location: id
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Get the document from the auditable item graph vertex.
|
|
472
|
+
* @param httpRequestContext The request context for the API.
|
|
473
|
+
* @param componentName The name of the component to use in the routes.
|
|
474
|
+
* @param request The request.
|
|
475
|
+
* @returns The response object with additional http response properties.
|
|
476
|
+
*/
|
|
477
|
+
export async function documentManagementGet(httpRequestContext, componentName, request) {
|
|
478
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
479
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
480
|
+
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.auditableItemGraphDocumentId", request.pathParams.auditableItemGraphDocumentId);
|
|
481
|
+
const mimeType = request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? "jsonld" : "json";
|
|
482
|
+
const component = ComponentFactory.get(componentName);
|
|
483
|
+
const result = await component.get(request.pathParams.auditableItemGraphDocumentId, {
|
|
484
|
+
includeBlobStorageMetadata: Coerce.boolean(request.query?.includeBlobStorageMetadata),
|
|
485
|
+
includeBlobStorageData: Coerce.boolean(request.query?.includeBlobStorageData),
|
|
486
|
+
includeAttestation: Coerce.boolean(request.query?.includeAttestation),
|
|
487
|
+
includeRemoved: Coerce.boolean(request.query?.includeRemoved),
|
|
488
|
+
extractRuleGroupId: request.query?.extractRuleGroupId,
|
|
489
|
+
extractMimeType: request.query?.extractMimeType
|
|
490
|
+
}, request.query?.cursor, Coerce.integer(request.query?.limit));
|
|
491
|
+
return {
|
|
492
|
+
headers: {
|
|
493
|
+
[HeaderTypes.ContentType]: mimeType === "json" ? MimeTypes.Json : MimeTypes.JsonLd
|
|
494
|
+
},
|
|
495
|
+
body: result
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Get the document revision from the auditable item graph vertex.
|
|
500
|
+
* @param httpRequestContext The request context for the API.
|
|
501
|
+
* @param componentName The name of the component to use in the routes.
|
|
502
|
+
* @param request The request.
|
|
503
|
+
* @returns The response object with additional http response properties.
|
|
504
|
+
*/
|
|
505
|
+
export async function documentManagementGetRevision(httpRequestContext, componentName, request) {
|
|
506
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
507
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
508
|
+
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.auditableItemGraphDocumentId", request.pathParams.auditableItemGraphDocumentId);
|
|
509
|
+
const revision = Coerce.integer(request.pathParams.revision);
|
|
510
|
+
Guards.integer(ROUTES_SOURCE, "revision", revision);
|
|
511
|
+
const mimeType = request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? "jsonld" : "json";
|
|
512
|
+
const component = ComponentFactory.get(componentName);
|
|
513
|
+
const result = await component.getRevision(request.pathParams.auditableItemGraphDocumentId, revision, {
|
|
514
|
+
includeBlobStorageMetadata: Coerce.boolean(request.query?.includeBlobStorageMetadata),
|
|
515
|
+
includeBlobStorageData: Coerce.boolean(request.query?.includeBlobStorageData),
|
|
516
|
+
includeAttestation: Coerce.boolean(request.query?.includeAttestation),
|
|
517
|
+
extractRuleGroupId: request.query?.extractRuleGroupId,
|
|
518
|
+
extractMimeType: request.query?.extractMimeType
|
|
519
|
+
});
|
|
520
|
+
return {
|
|
521
|
+
headers: {
|
|
522
|
+
[HeaderTypes.ContentType]: mimeType === "json" ? MimeTypes.Json : MimeTypes.JsonLd
|
|
523
|
+
},
|
|
524
|
+
body: result
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Update the document from the auditable item graph vertex.
|
|
529
|
+
* @param httpRequestContext The request context for the API.
|
|
530
|
+
* @param componentName The name of the component to use in the routes.
|
|
531
|
+
* @param request The request.
|
|
532
|
+
* @returns The response object with additional http response properties.
|
|
533
|
+
*/
|
|
534
|
+
export async function documentManagementUpdate(httpRequestContext, componentName, request) {
|
|
535
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
536
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
537
|
+
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.auditableItemGraphDocumentId", request.pathParams.auditableItemGraphDocumentId);
|
|
538
|
+
const component = ComponentFactory.get(componentName);
|
|
539
|
+
await component.update(request.pathParams.auditableItemGraphDocumentId, Is.stringValue(request.body.blob) ? Converter.base64ToBytes(request.body.blob) : undefined, request.body.annotationObject, request.body.auditableItemGraphEdges);
|
|
540
|
+
return {
|
|
541
|
+
statusCode: HttpStatusCode.noContent
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Remove the document from the auditable item graph vertex.
|
|
546
|
+
* @param httpRequestContext The request context for the API.
|
|
547
|
+
* @param componentName The name of the component to use in the routes.
|
|
548
|
+
* @param request The request.
|
|
549
|
+
* @returns The response object with additional http response properties.
|
|
550
|
+
*/
|
|
551
|
+
export async function documentManagementRemove(httpRequestContext, componentName, request) {
|
|
552
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
553
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
554
|
+
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.auditableItemGraphDocumentId", request.pathParams.auditableItemGraphDocumentId);
|
|
555
|
+
const revision = Coerce.number(request.pathParams.revision);
|
|
556
|
+
Guards.integer(ROUTES_SOURCE, "request.pathParams.revision", revision);
|
|
557
|
+
const component = ComponentFactory.get(componentName);
|
|
558
|
+
await component.removeRevision(request.pathParams.auditableItemGraphDocumentId, revision);
|
|
559
|
+
return {
|
|
560
|
+
statusCode: HttpStatusCode.noContent
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Query the documents from an auditable item graph vertex.
|
|
565
|
+
* @param httpRequestContext The request context for the API.
|
|
566
|
+
* @param componentName The name of the component to use in the routes.
|
|
567
|
+
* @param request The request.
|
|
568
|
+
* @returns The response object with additional http response properties.
|
|
569
|
+
*/
|
|
570
|
+
export async function documentManagementQuery(httpRequestContext, componentName, request) {
|
|
571
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
572
|
+
Guards.object(ROUTES_SOURCE, "request.query", request.query);
|
|
573
|
+
Guards.stringValue(ROUTES_SOURCE, "request.query.documentId", request.query.documentId);
|
|
574
|
+
const mimeType = request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? "jsonld" : "json";
|
|
575
|
+
const component = ComponentFactory.get(componentName);
|
|
576
|
+
const result = await component.query(request.query.documentId, request.query?.cursor, Coerce.integer(request.query?.limit));
|
|
577
|
+
return {
|
|
578
|
+
headers: {
|
|
579
|
+
[HeaderTypes.ContentType]: mimeType === "json" ? MimeTypes.Json : MimeTypes.JsonLd
|
|
580
|
+
},
|
|
581
|
+
body: result
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
//# sourceMappingURL=documentManagementRoutes.js.map
|