@twin.org/document-management-service 0.0.1-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.
@@ -0,0 +1,328 @@
1
+ # Class: DocumentManagementService
2
+
3
+ Service for performing document management operations.
4
+
5
+ ## Implements
6
+
7
+ - `IDocumentManagementComponent`
8
+
9
+ ## Constructors
10
+
11
+ ### new DocumentManagementService()
12
+
13
+ > **new DocumentManagementService**(`options`?): [`DocumentManagementService`](DocumentManagementService.md)
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`](DocumentManagementService.md)
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
+ ### set()
52
+
53
+ > **set**(`auditableItemGraphId`, `documentId`, `documentIdFormat`, `documentCode`, `blob`, `annotationObject`?, `createAttestation`?, `userIdentity`?, `nodeIdentity`?): `Promise`\<`string`\>
54
+
55
+ Store a document in 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
+ ##### auditableItemGraphId
62
+
63
+ `string`
64
+
65
+ The auditable item graph vertex id to create the document on.
66
+
67
+ ##### documentId
68
+
69
+ `string`
70
+
71
+ The document id to create.
72
+
73
+ ##### documentIdFormat
74
+
75
+ The format of the document identifier.
76
+
77
+ `undefined` | `string`
78
+
79
+ ##### documentCode
80
+
81
+ `string`
82
+
83
+ The code for the document type.
84
+
85
+ ##### blob
86
+
87
+ `Uint8Array`
88
+
89
+ The data to create the document.
90
+
91
+ ##### annotationObject?
92
+
93
+ `IJsonLdNodeObject`
94
+
95
+ Additional information to associate with the document.
96
+
97
+ ##### createAttestation?
98
+
99
+ `boolean`
100
+
101
+ Flag to create an attestation for the document, defaults to false.
102
+
103
+ ##### userIdentity?
104
+
105
+ `string`
106
+
107
+ The identity to perform the auditable item graph operation with.
108
+
109
+ ##### nodeIdentity?
110
+
111
+ `string`
112
+
113
+ The node identity to use for vault operations.
114
+
115
+ #### Returns
116
+
117
+ `Promise`\<`string`\>
118
+
119
+ The identifier for the document which includes the auditable item graph identifier.
120
+
121
+ #### Implementation of
122
+
123
+ `IDocumentManagementComponent.set`
124
+
125
+ ***
126
+
127
+ ### get()
128
+
129
+ > **get**(`auditableItemGraphId`, `identifier`, `options`?, `revisionCursor`?, `userIdentity`?, `nodeIdentity`?): `Promise`\<`IDocument`\>
130
+
131
+ Get a specific document from an auditable item graph vertex.
132
+
133
+ #### Parameters
134
+
135
+ ##### auditableItemGraphId
136
+
137
+ `string`
138
+
139
+ The auditable item graph vertex id to get the document from.
140
+
141
+ ##### identifier
142
+
143
+ `string`
144
+
145
+ The identifier of the document to get.
146
+
147
+ ##### options?
148
+
149
+ Additional options for the get operation.
150
+
151
+ ###### includeBlobStorageMetadata?
152
+
153
+ `boolean`
154
+
155
+ Flag to include the blob storage metadata for the document, defaults to false.
156
+
157
+ ###### includeBlobStorageData?
158
+
159
+ `boolean`
160
+
161
+ Flag to include the blob storage data for the document, defaults to false.
162
+
163
+ ###### includeAttestation?
164
+
165
+ `boolean`
166
+
167
+ Flag to include the attestation information for the document, defaults to false.
168
+
169
+ ###### includeRemoved?
170
+
171
+ `boolean`
172
+
173
+ Flag to include deleted documents, defaults to false.
174
+
175
+ ###### maxRevisionCount?
176
+
177
+ `number`
178
+
179
+ Max number of revisions to return, defaults to 0.
180
+
181
+ ##### revisionCursor?
182
+
183
+ `string`
184
+
185
+ The cursor to get the next chunk of revisions.
186
+
187
+ ##### userIdentity?
188
+
189
+ `string`
190
+
191
+ The identity to perform the auditable item graph operation with.
192
+
193
+ ##### nodeIdentity?
194
+
195
+ `string`
196
+
197
+ The node identity to use for vault operations.
198
+
199
+ #### Returns
200
+
201
+ `Promise`\<`IDocument`\>
202
+
203
+ The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
204
+
205
+ #### Implementation of
206
+
207
+ `IDocumentManagementComponent.get`
208
+
209
+ ***
210
+
211
+ ### remove()
212
+
213
+ > **remove**(`auditableItemGraphId`, `identifier`, `options`?, `userIdentity`?, `nodeIdentity`?): `Promise`\<`void`\>
214
+
215
+ Remove a specific document from an auditable item graph vertex.
216
+ The documents dateDeleted will be set, but can still be queried with the includeRemoved flag.
217
+
218
+ #### Parameters
219
+
220
+ ##### auditableItemGraphId
221
+
222
+ `string`
223
+
224
+ The auditable item graph vertex id to remove the document from.
225
+
226
+ ##### identifier
227
+
228
+ `string`
229
+
230
+ The identifier of the document to remove.
231
+
232
+ ##### options?
233
+
234
+ Additional options for the remove operation.
235
+
236
+ ###### removeAllRevisions?
237
+
238
+ `boolean`
239
+
240
+ Flag to remove all revisions of the document, defaults to false.
241
+
242
+ ##### userIdentity?
243
+
244
+ `string`
245
+
246
+ The identity to perform the auditable item graph operation with.
247
+
248
+ ##### nodeIdentity?
249
+
250
+ `string`
251
+
252
+ The node identity to use for vault operations.
253
+
254
+ #### Returns
255
+
256
+ `Promise`\<`void`\>
257
+
258
+ Nothing.
259
+
260
+ #### Implementation of
261
+
262
+ `IDocumentManagementComponent.remove`
263
+
264
+ ***
265
+
266
+ ### query()
267
+
268
+ > **query**(`auditableItemGraphId`, `documentCodes`?, `options`?, `cursor`?, `userIdentity`?, `nodeIdentity`?): `Promise`\<`IDocumentList`\>
269
+
270
+ Query an auditable item graph vertex for documents.
271
+
272
+ #### Parameters
273
+
274
+ ##### auditableItemGraphId
275
+
276
+ `string`
277
+
278
+ The auditable item graph vertex to get the documents from.
279
+
280
+ ##### documentCodes?
281
+
282
+ `string`[]
283
+
284
+ The document codes to query for, if undefined gets all document codes.
285
+
286
+ ##### options?
287
+
288
+ Additional options for the query operation.
289
+
290
+ ###### includeMostRecentRevisions?
291
+
292
+ `boolean`
293
+
294
+ Include the most recent 5 revisions, use the individual get to retrieve more.
295
+
296
+ ###### includeRemoved?
297
+
298
+ `boolean`
299
+
300
+ Flag to include deleted documents, defaults to false.
301
+
302
+ ##### cursor?
303
+
304
+ `string`
305
+
306
+ The cursor to get the next chunk of documents.
307
+
308
+ ##### userIdentity?
309
+
310
+ `string`
311
+
312
+ The identity to perform the auditable item graph operation with.
313
+
314
+ ##### nodeIdentity?
315
+
316
+ `string`
317
+
318
+ The node identity to use for vault operations.
319
+
320
+ #### Returns
321
+
322
+ `Promise`\<`IDocumentList`\>
323
+
324
+ The most recent revisions of each document, cursor is set if there are more documents.
325
+
326
+ #### Implementation of
327
+
328
+ `IDocumentManagementComponent.query`
@@ -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: documentManagementSet()
2
+
3
+ > **documentManagementSet**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`ICreatedResponse`\>
4
+
5
+ Set a document in to 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
+ `IDocumentManagementSetRequest`
24
+
25
+ The request.
26
+
27
+ ## Returns
28
+
29
+ `Promise`\<`ICreatedResponse`\>
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,23 @@
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
+ - [documentManagementSet](functions/documentManagementSet.md)
21
+ - [documentManagementGet](functions/documentManagementGet.md)
22
+ - [documentManagementRemove](functions/documentManagementRemove.md)
23
+ - [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
+ "setFailed": "Failed to set document",
5
+ "getFailed": "Failed to get document",
6
+ "removeFailed": "Failed to remove document",
7
+ "queryFailed": "Failed to query document",
8
+ "invalidDocumentId": "The document id not in the correct format, it is \"{identifier}\"",
9
+ "invalidDocumentCode": "The document code does not follow the format unece:DocumentCodeList#1, it is \"{documentCode}\"",
10
+ "documentRevisionNotFound": "The document revision was not found \"{identifier}\"",
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.2",
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.2",
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
+ }