@3sixty/document-management-service 0.0.0-stage → 0.20.0-next.0
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/LICENSE +201 -0
- package/README.md +24 -2
- package/dist/es/documentManagementRoutes.js +609 -0
- package/dist/es/documentManagementRoutes.js.map +1 -0
- package/dist/es/documentManagementService.js +967 -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 +13 -0
- package/dist/es/restEntryPoints.js.map +1 -0
- package/dist/types/documentManagementRoutes.d.ts +62 -0
- package/dist/types/documentManagementService.d.ts +147 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/models/IDocumentManagementServiceConfig.d.ts +9 -0
- package/dist/types/models/IDocumentManagementStorageServiceConstructorOptions.d.ts +34 -0
- package/dist/types/restEntryPoints.d.ts +5 -0
- package/docs/changelog.md +0 -0
- package/docs/examples.md +121 -0
- package/docs/open-api/spec.json +1387 -0
- package/docs/reference/classes/DocumentManagementService.md +464 -0
- package/docs/reference/functions/documentManagementCreate.md +37 -0
- package/docs/reference/functions/documentManagementGet.md +31 -0
- package/docs/reference/functions/documentManagementGetRevision.md +31 -0
- package/docs/reference/functions/documentManagementQuery.md +31 -0
- package/docs/reference/functions/documentManagementRemove.md +31 -0
- package/docs/reference/functions/documentManagementUpdatePartial.md +31 -0
- package/docs/reference/functions/generateRestRoutesDocumentManagement.md +25 -0
- package/docs/reference/index.md +25 -0
- package/docs/reference/interfaces/IDocumentManagementServiceConfig.md +11 -0
- package/docs/reference/interfaces/IDocumentManagementServiceConstructorOptions.md +75 -0
- package/docs/reference/variables/restEntryPoints.md +5 -0
- package/docs/reference/variables/tagsDocumentManagement.md +5 -0
- package/locales/en.json +22 -0
- package/package.json +68 -5
package/docs/examples.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Document Management Service Examples
|
|
2
|
+
|
|
3
|
+
Use these snippets to wire the service into existing components and handle a full document lifecycle from creation through querying.
|
|
4
|
+
|
|
5
|
+
## DocumentManagementService
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { ComponentFactory, Converter } from '@3sixty/core';
|
|
9
|
+
import { DocumentManagementService } from '@3sixty/document-management-service';
|
|
10
|
+
import { UneceDocumentCodeList } from '@3sixty/standards-unece';
|
|
11
|
+
|
|
12
|
+
// Register concrete components before constructing the service.
|
|
13
|
+
ComponentFactory.register('auditable-item-graph', () => auditableItemGraphComponent);
|
|
14
|
+
ComponentFactory.register('blob-storage', () => blobStorageComponent);
|
|
15
|
+
ComponentFactory.register('attestation', () => attestationComponent);
|
|
16
|
+
ComponentFactory.register('data-processing', () => dataProcessingComponent);
|
|
17
|
+
|
|
18
|
+
const service = new DocumentManagementService();
|
|
19
|
+
const newBlob = Converter.utf8ToBytes('Initial customs document payload');
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
const className = service.className();
|
|
24
|
+
console.log(className); // DocumentManagementService
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
const vertexId = await service.create(
|
|
29
|
+
'CUS-2026-0100',
|
|
30
|
+
'customs',
|
|
31
|
+
UneceDocumentCodeList.CustomsDeclaration,
|
|
32
|
+
newBlob,
|
|
33
|
+
{
|
|
34
|
+
'@context': 'https://schema.org',
|
|
35
|
+
'@type': 'DigitalDocument',
|
|
36
|
+
name: 'customs-2026-0100.xml'
|
|
37
|
+
},
|
|
38
|
+
[
|
|
39
|
+
{
|
|
40
|
+
targetId: 'aig:shipment-123',
|
|
41
|
+
addAlias: true,
|
|
42
|
+
aliasAnnotationObject: {
|
|
43
|
+
'@context': 'https://schema.org',
|
|
44
|
+
'@type': 'Thing',
|
|
45
|
+
name: 'Shipment reference'
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
{
|
|
50
|
+
createAttestation: true,
|
|
51
|
+
addAlias: true,
|
|
52
|
+
aliasAnnotationObject: {
|
|
53
|
+
'@context': 'https://schema.org',
|
|
54
|
+
'@type': 'Thing',
|
|
55
|
+
name: 'Primary document alias'
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
console.log(vertexId); // aig:document-vertex-2
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
await service.update(
|
|
65
|
+
'aig:document-vertex-2',
|
|
66
|
+
Converter.utf8ToBytes('Customs document payload revision 1'),
|
|
67
|
+
{
|
|
68
|
+
'@context': 'https://schema.org',
|
|
69
|
+
'@type': 'CreativeWork',
|
|
70
|
+
name: 'customs-2026-0100-rev1.xml'
|
|
71
|
+
},
|
|
72
|
+
[
|
|
73
|
+
{
|
|
74
|
+
targetId: 'aig:shipment-123',
|
|
75
|
+
addAlias: true,
|
|
76
|
+
aliasAnnotationObject: {
|
|
77
|
+
'@context': 'https://schema.org',
|
|
78
|
+
'@type': 'Thing',
|
|
79
|
+
name: 'Updated shipment alias'
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
const latestDocuments = await service.get(
|
|
88
|
+
'aig:document-vertex-2',
|
|
89
|
+
{
|
|
90
|
+
includeBlobStorageMetadata: true,
|
|
91
|
+
includeAttestation: true,
|
|
92
|
+
includeRemoved: false
|
|
93
|
+
},
|
|
94
|
+
'0',
|
|
95
|
+
2
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
console.log(latestDocuments.entries.itemListElement.length); // 2
|
|
99
|
+
console.log(latestDocuments.cursor); // 2
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
const revision = await service.getRevision('aig:document-vertex-2', 1, {
|
|
104
|
+
includeBlobStorageData: true,
|
|
105
|
+
includeAttestation: true
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
console.log(revision.documentRevision); // 1
|
|
109
|
+
console.log(revision.documentCode); // Cusdec
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
await service.removeRevision('aig:document-vertex-2', 1);
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
const queryResult = await service.query('CUS-2026-0100', '0', 10);
|
|
118
|
+
|
|
119
|
+
console.log(queryResult.entries.vertices.length); // 1
|
|
120
|
+
console.log(queryResult.cursor); // undefined
|
|
121
|
+
```
|