@twin.org/document-management-service 0.0.1-next.10

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.
@@ -0,0 +1,370 @@
1
+ # Class: DocumentManagementService
2
+
3
+ Service for performing document management operations.
4
+
5
+ ## Implements
6
+
7
+ - `IDocumentManagementComponent`
8
+
9
+ ## Constructors
10
+
11
+ ### Constructor
12
+
13
+ > **new DocumentManagementService**(`options?`): `DocumentManagementService`
14
+
15
+ Create a new instance of DocumentManagementService.
16
+
17
+ #### Parameters
18
+
19
+ ##### options?
20
+
21
+ [`IDocumentManagementServiceConstructorOptions`](../interfaces/IDocumentManagementServiceConstructorOptions.md)
22
+
23
+ The options for the service.
24
+
25
+ #### Returns
26
+
27
+ `DocumentManagementService`
28
+
29
+ ## Properties
30
+
31
+ ### NAMESPACE
32
+
33
+ > `readonly` `static` **NAMESPACE**: `string` = `"documents"`
34
+
35
+ The namespace supported by the document management service.
36
+
37
+ ***
38
+
39
+ ### CLASS\_NAME
40
+
41
+ > `readonly` **CLASS\_NAME**: `string`
42
+
43
+ Runtime name for the class.
44
+
45
+ #### Implementation of
46
+
47
+ `IDocumentManagementComponent.CLASS_NAME`
48
+
49
+ ## Methods
50
+
51
+ ### create()
52
+
53
+ > **create**(`documentId`, `documentIdFormat`, `documentCode`, `blob`, `annotationObject?`, `auditableItemGraphEdges?`, `options?`, `userIdentity?`, `nodeIdentity?`): `Promise`\<`string`\>
54
+
55
+ Store a document as an auditable item graph vertex and add its content to blob storage.
56
+ If the document id already exists and the blob data is different a new revision will be created.
57
+ For any other changes the current revision will be updated.
58
+
59
+ #### Parameters
60
+
61
+ ##### documentId
62
+
63
+ `string`
64
+
65
+ The document id to create.
66
+
67
+ ##### documentIdFormat
68
+
69
+ The format of the document identifier.
70
+
71
+ `undefined` | `string`
72
+
73
+ ##### documentCode
74
+
75
+ `string`
76
+
77
+ The code for the document type.
78
+
79
+ ##### blob
80
+
81
+ `Uint8Array`
82
+
83
+ The data to create the document with.
84
+
85
+ ##### annotationObject?
86
+
87
+ `IJsonLdNodeObject`
88
+
89
+ Additional information to associate with the document.
90
+
91
+ ##### auditableItemGraphEdges?
92
+
93
+ `object`[]
94
+
95
+ The auditable item graph vertices to connect the document to.
96
+
97
+ ##### options?
98
+
99
+ Additional options for the set operation.
100
+
101
+ ###### createAttestation?
102
+
103
+ `boolean`
104
+
105
+ Flag to create an attestation for the document, defaults to false.
106
+
107
+ ###### addAlias?
108
+
109
+ `boolean`
110
+
111
+ Flag to add the document id as an alias to the aig vertex, defaults to true.
112
+
113
+ ###### aliasAnnotationObject?
114
+
115
+ `IJsonLdNodeObject`
116
+
117
+ Annotation object for the alias.
118
+
119
+ ##### userIdentity?
120
+
121
+ `string`
122
+
123
+ The identity to perform the auditable item graph operation with.
124
+
125
+ ##### nodeIdentity?
126
+
127
+ `string`
128
+
129
+ The node identity to use for vault operations.
130
+
131
+ #### Returns
132
+
133
+ `Promise`\<`string`\>
134
+
135
+ The auditable item graph vertex created for the document including its revision.
136
+
137
+ #### Implementation of
138
+
139
+ `IDocumentManagementComponent.create`
140
+
141
+ ***
142
+
143
+ ### update()
144
+
145
+ > **update**(`auditableItemGraphDocumentId`, `blob?`, `annotationObject?`, `auditableItemGraphEdges?`, `userIdentity?`, `nodeIdentity?`): `Promise`\<`void`\>
146
+
147
+ Update a document as an auditable item graph vertex and add its content to blob storage.
148
+ If the blob data is different a new revision will be created.
149
+ For any other changes the current revision will be updated.
150
+
151
+ #### Parameters
152
+
153
+ ##### auditableItemGraphDocumentId
154
+
155
+ `string`
156
+
157
+ The auditable item graph vertex id which contains the document.
158
+
159
+ ##### blob?
160
+
161
+ `Uint8Array`\<`ArrayBufferLike`\>
162
+
163
+ The data to update the document with.
164
+
165
+ ##### annotationObject?
166
+
167
+ `IJsonLdNodeObject`
168
+
169
+ Additional information to associate with the document.
170
+
171
+ ##### auditableItemGraphEdges?
172
+
173
+ `object`[]
174
+
175
+ The auditable item graph vertices to connect the document to, if undefined retains current connections.
176
+
177
+ ##### userIdentity?
178
+
179
+ `string`
180
+
181
+ The identity to perform the auditable item graph operation with.
182
+
183
+ ##### nodeIdentity?
184
+
185
+ `string`
186
+
187
+ The node identity to use for vault operations.
188
+
189
+ #### Returns
190
+
191
+ `Promise`\<`void`\>
192
+
193
+ Nothing.
194
+
195
+ #### Implementation of
196
+
197
+ `IDocumentManagementComponent.update`
198
+
199
+ ***
200
+
201
+ ### get()
202
+
203
+ > **get**(`auditableItemGraphDocumentId`, `options?`, `cursor?`, `pageSize?`, `userIdentity?`, `nodeIdentity?`): `Promise`\<`IDocumentList`\>
204
+
205
+ Get a document using it's auditable item graph vertex id and optional revision.
206
+
207
+ #### Parameters
208
+
209
+ ##### auditableItemGraphDocumentId
210
+
211
+ `string`
212
+
213
+ The auditable item graph vertex id which contains the document.
214
+
215
+ ##### options?
216
+
217
+ Additional options for the get operation.
218
+
219
+ ###### includeBlobStorageMetadata?
220
+
221
+ `boolean`
222
+
223
+ Flag to include the blob storage metadata for the document, defaults to false.
224
+
225
+ ###### includeBlobStorageData?
226
+
227
+ `boolean`
228
+
229
+ Flag to include the blob storage data for the document, defaults to false.
230
+
231
+ ###### includeAttestation?
232
+
233
+ `boolean`
234
+
235
+ Flag to include the attestation information for the document, defaults to false.
236
+
237
+ ###### includeRemoved?
238
+
239
+ `boolean`
240
+
241
+ Flag to include deleted documents, defaults to false.
242
+
243
+ ##### cursor?
244
+
245
+ `string`
246
+
247
+ The cursor to get the next chunk of revisions.
248
+
249
+ ##### pageSize?
250
+
251
+ `number`
252
+
253
+ Page size of items to return, defaults to 1 so only most recent is returned.
254
+
255
+ ##### userIdentity?
256
+
257
+ `string`
258
+
259
+ The identity to perform the auditable item graph operation with.
260
+
261
+ ##### nodeIdentity?
262
+
263
+ `string`
264
+
265
+ The node identity to use for vault operations.
266
+
267
+ #### Returns
268
+
269
+ `Promise`\<`IDocumentList`\>
270
+
271
+ The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
272
+
273
+ #### Implementation of
274
+
275
+ `IDocumentManagementComponent.get`
276
+
277
+ ***
278
+
279
+ ### removeRevision()
280
+
281
+ > **removeRevision**(`auditableItemGraphDocumentId`, `revision`, `userIdentity?`, `nodeIdentity?`): `Promise`\<`void`\>
282
+
283
+ Remove an auditable item graph vertex using it's id.
284
+ The document dateDeleted will be set, but can still be queried with the includeRemoved flag.
285
+
286
+ #### Parameters
287
+
288
+ ##### auditableItemGraphDocumentId
289
+
290
+ `string`
291
+
292
+ The auditable item graph vertex id which contains the document.
293
+
294
+ ##### revision
295
+
296
+ `number`
297
+
298
+ The revision of the document to remove.
299
+
300
+ ##### userIdentity?
301
+
302
+ `string`
303
+
304
+ The identity to perform the auditable item graph operation with.
305
+
306
+ ##### nodeIdentity?
307
+
308
+ `string`
309
+
310
+ The node identity to use for vault operations.
311
+
312
+ #### Returns
313
+
314
+ `Promise`\<`void`\>
315
+
316
+ Nothing.
317
+
318
+ #### Implementation of
319
+
320
+ `IDocumentManagementComponent.removeRevision`
321
+
322
+ ***
323
+
324
+ ### query()
325
+
326
+ > **query**(`documentId`, `cursor?`, `pageSize?`, `userIdentity?`, `nodeIdentity?`): `Promise`\<`IAuditableItemGraphVertexList`\>
327
+
328
+ Find all the document with a specific id.
329
+
330
+ #### Parameters
331
+
332
+ ##### documentId
333
+
334
+ `string`
335
+
336
+ The document id to find in the graph.
337
+
338
+ ##### cursor?
339
+
340
+ `string`
341
+
342
+ The cursor to get the next chunk of documents.
343
+
344
+ ##### pageSize?
345
+
346
+ `number`
347
+
348
+ The page size to get the next chunk of documents.
349
+
350
+ ##### userIdentity?
351
+
352
+ `string`
353
+
354
+ The identity to perform the auditable item graph operation with.
355
+
356
+ ##### nodeIdentity?
357
+
358
+ `string`
359
+
360
+ The node identity to use for vault operations.
361
+
362
+ #### Returns
363
+
364
+ `Promise`\<`IAuditableItemGraphVertexList`\>
365
+
366
+ The graph vertices that contain documents referencing the specified document id.
367
+
368
+ #### Implementation of
369
+
370
+ `IDocumentManagementComponent.query`
@@ -0,0 +1,31 @@
1
+ # Function: documentManagementCreate()
2
+
3
+ > **documentManagementCreate**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`ICreatedResponse`\>
4
+
5
+ Create a document as an auditable item graph vertex.
6
+
7
+ ## Parameters
8
+
9
+ ### httpRequestContext
10
+
11
+ `IHttpRequestContext`
12
+
13
+ The request context for the API.
14
+
15
+ ### componentName
16
+
17
+ `string`
18
+
19
+ The name of the component to use in the routes.
20
+
21
+ ### request
22
+
23
+ `IDocumentManagementCreateRequest`
24
+
25
+ The request.
26
+
27
+ ## Returns
28
+
29
+ `Promise`\<`ICreatedResponse`\>
30
+
31
+ The response object with additional http response properties.
@@ -0,0 +1,31 @@
1
+ # Function: documentManagementGet()
2
+
3
+ > **documentManagementGet**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`IDocumentManagementGetResponse`\>
4
+
5
+ Get the document from the auditable item graph vertex.
6
+
7
+ ## Parameters
8
+
9
+ ### httpRequestContext
10
+
11
+ `IHttpRequestContext`
12
+
13
+ The request context for the API.
14
+
15
+ ### componentName
16
+
17
+ `string`
18
+
19
+ The name of the component to use in the routes.
20
+
21
+ ### request
22
+
23
+ `IDocumentManagementGetRequest`
24
+
25
+ The request.
26
+
27
+ ## Returns
28
+
29
+ `Promise`\<`IDocumentManagementGetResponse`\>
30
+
31
+ The response object with additional http response properties.
@@ -0,0 +1,31 @@
1
+ # Function: documentManagementQuery()
2
+
3
+ > **documentManagementQuery**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`IDocumentManagementQueryResponse`\>
4
+
5
+ Query the documents from an auditable item graph vertex.
6
+
7
+ ## Parameters
8
+
9
+ ### httpRequestContext
10
+
11
+ `IHttpRequestContext`
12
+
13
+ The request context for the API.
14
+
15
+ ### componentName
16
+
17
+ `string`
18
+
19
+ The name of the component to use in the routes.
20
+
21
+ ### request
22
+
23
+ `IDocumentManagementQueryRequest`
24
+
25
+ The request.
26
+
27
+ ## Returns
28
+
29
+ `Promise`\<`IDocumentManagementQueryResponse`\>
30
+
31
+ The response object with additional http response properties.
@@ -0,0 +1,31 @@
1
+ # Function: documentManagementRemove()
2
+
3
+ > **documentManagementRemove**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`INoContentResponse`\>
4
+
5
+ Remove the document from the auditable item graph vertex.
6
+
7
+ ## Parameters
8
+
9
+ ### httpRequestContext
10
+
11
+ `IHttpRequestContext`
12
+
13
+ The request context for the API.
14
+
15
+ ### componentName
16
+
17
+ `string`
18
+
19
+ The name of the component to use in the routes.
20
+
21
+ ### request
22
+
23
+ `IDocumentManagementRemoveRequest`
24
+
25
+ The request.
26
+
27
+ ## Returns
28
+
29
+ `Promise`\<`INoContentResponse`\>
30
+
31
+ The response object with additional http response properties.
@@ -0,0 +1,31 @@
1
+ # Function: documentManagementUpdate()
2
+
3
+ > **documentManagementUpdate**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`INoContentResponse`\>
4
+
5
+ UPdate the document from the auditable item graph vertex.
6
+
7
+ ## Parameters
8
+
9
+ ### httpRequestContext
10
+
11
+ `IHttpRequestContext`
12
+
13
+ The request context for the API.
14
+
15
+ ### componentName
16
+
17
+ `string`
18
+
19
+ The name of the component to use in the routes.
20
+
21
+ ### request
22
+
23
+ `IDocumentManagementUpdateRequest`
24
+
25
+ The request.
26
+
27
+ ## Returns
28
+
29
+ `Promise`\<`INoContentResponse`\>
30
+
31
+ The response object with additional http response properties.
@@ -0,0 +1,25 @@
1
+ # Function: generateRestRoutesDocumentManagement()
2
+
3
+ > **generateRestRoutesDocumentManagement**(`baseRouteName`, `componentName`): `IRestRoute`\<`any`, `any`\>[]
4
+
5
+ The REST routes for document management.
6
+
7
+ ## Parameters
8
+
9
+ ### baseRouteName
10
+
11
+ `string`
12
+
13
+ Prefix to prepend to the paths.
14
+
15
+ ### componentName
16
+
17
+ `string`
18
+
19
+ The name of the component to use in the routes stored in the ComponentFactory.
20
+
21
+ ## Returns
22
+
23
+ `IRestRoute`\<`any`, `any`\>[]
24
+
25
+ The generated routes.
@@ -0,0 +1,24 @@
1
+ # @twin.org/document-management-service
2
+
3
+ ## Classes
4
+
5
+ - [DocumentManagementService](classes/DocumentManagementService.md)
6
+
7
+ ## Interfaces
8
+
9
+ - [IDocumentManagementServiceConfig](interfaces/IDocumentManagementServiceConfig.md)
10
+ - [IDocumentManagementServiceConstructorOptions](interfaces/IDocumentManagementServiceConstructorOptions.md)
11
+
12
+ ## Variables
13
+
14
+ - [tagsDocumentManagement](variables/tagsDocumentManagement.md)
15
+ - [restEntryPoints](variables/restEntryPoints.md)
16
+
17
+ ## Functions
18
+
19
+ - [generateRestRoutesDocumentManagement](functions/generateRestRoutesDocumentManagement.md)
20
+ - [documentManagementCreate](functions/documentManagementCreate.md)
21
+ - [documentManagementGet](functions/documentManagementGet.md)
22
+ - [documentManagementUpdate](functions/documentManagementUpdate.md)
23
+ - [documentManagementRemove](functions/documentManagementRemove.md)
24
+ - [documentManagementQuery](functions/documentManagementQuery.md)
@@ -0,0 +1,3 @@
1
+ # Interface: IDocumentManagementServiceConfig
2
+
3
+ Configuration for the document management service.
@@ -0,0 +1,53 @@
1
+ # Interface: IDocumentManagementServiceConstructorOptions
2
+
3
+ Options for the document management Service constructor.
4
+
5
+ ## Properties
6
+
7
+ ### auditableItemGraphComponentType?
8
+
9
+ > `optional` **auditableItemGraphComponentType**: `string`
10
+
11
+ The type of the auditable item graph component.
12
+
13
+ #### Default
14
+
15
+ ```ts
16
+ auditable-item-graph
17
+ ```
18
+
19
+ ***
20
+
21
+ ### blobStorageComponentType?
22
+
23
+ > `optional` **blobStorageComponentType**: `string`
24
+
25
+ The type of the blob storage component.
26
+
27
+ #### Default
28
+
29
+ ```ts
30
+ blob-storage
31
+ ```
32
+
33
+ ***
34
+
35
+ ### attestationComponentType?
36
+
37
+ > `optional` **attestationComponentType**: `string`
38
+
39
+ The type of the attestation component.
40
+
41
+ #### Default
42
+
43
+ ```ts
44
+ attestation
45
+ ```
46
+
47
+ ***
48
+
49
+ ### config?
50
+
51
+ > `optional` **config**: [`IDocumentManagementServiceConfig`](IDocumentManagementServiceConfig.md)
52
+
53
+ The configuration for the service.
@@ -0,0 +1,3 @@
1
+ # Variable: restEntryPoints
2
+
3
+ > `const` **restEntryPoints**: `IRestRouteEntryPoint`[]
@@ -0,0 +1,5 @@
1
+ # Variable: tagsDocumentManagement
2
+
3
+ > `const` **tagsDocumentManagement**: `ITag`[]
4
+
5
+ The tag to associate with the routes.
@@ -0,0 +1,14 @@
1
+ {
2
+ "error": {
3
+ "documentManagementService": {
4
+ "createFailed": "Failed to create document",
5
+ "updateFailed": "Failed to update document",
6
+ "getFailed": "Failed to get document",
7
+ "removeRevision": "Failed to remove document revision",
8
+ "queryFailed": "Failed to query document",
9
+ "documentRevisionNone": "There are no revisions in the document",
10
+ "documentRevisionNotFound": "There is no revision number \"{revision}\" in the document",
11
+ "namespaceMismatch": "The namespace in the urn \"{id}\" does not match the namespace of the Document Management component \"{namespace}\""
12
+ }
13
+ }
14
+ }
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@twin.org/document-management-service",
3
+ "version": "0.0.1-next.10",
4
+ "description": "Document management contract implementation and REST endpoint definitions",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/twinfoundation/document-management.git",
8
+ "directory": "packages/document-management-service"
9
+ },
10
+ "author": "martyn.janes@iota.org",
11
+ "license": "Apache-2.0",
12
+ "type": "module",
13
+ "engines": {
14
+ "node": ">=20.0.0"
15
+ },
16
+ "dependencies": {
17
+ "@twin.org/api-models": "next",
18
+ "@twin.org/attestation-models": "next",
19
+ "@twin.org/auditable-item-graph-models": "next",
20
+ "@twin.org/blob-storage-models": "next",
21
+ "@twin.org/core": "next",
22
+ "@twin.org/crypto": "next",
23
+ "@twin.org/data-json-ld": "next",
24
+ "@twin.org/document-management-models": "0.0.1-next.10",
25
+ "@twin.org/entity": "next",
26
+ "@twin.org/entity-storage-models": "next",
27
+ "@twin.org/nameof": "next",
28
+ "@twin.org/standards-schema-org": "next",
29
+ "@twin.org/standards-unece": "next",
30
+ "@twin.org/web": "next"
31
+ },
32
+ "main": "./dist/cjs/index.cjs",
33
+ "module": "./dist/esm/index.mjs",
34
+ "types": "./dist/types/index.d.ts",
35
+ "exports": {
36
+ ".": {
37
+ "types": "./dist/types/index.d.ts",
38
+ "require": "./dist/cjs/index.cjs",
39
+ "import": "./dist/esm/index.mjs"
40
+ },
41
+ "./locales/*.json": "./locales/*.json"
42
+ },
43
+ "files": [
44
+ "dist/cjs",
45
+ "dist/esm",
46
+ "dist/types",
47
+ "locales",
48
+ "docs"
49
+ ]
50
+ }