@twin.org/document-management-models 0.0.1-next.1

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.
Files changed (31) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +21 -0
  3. package/dist/cjs/index.cjs +28 -0
  4. package/dist/esm/index.mjs +26 -0
  5. package/dist/types/index.d.ts +10 -0
  6. package/dist/types/models/IDocument.d.ts +88 -0
  7. package/dist/types/models/IDocumentList.d.ts +28 -0
  8. package/dist/types/models/IDocumentManagementComponent.d.ts +78 -0
  9. package/dist/types/models/api/IDocumentManagementGetRequest.d.ts +59 -0
  10. package/dist/types/models/api/IDocumentManagementGetResponse.d.ts +17 -0
  11. package/dist/types/models/api/IDocumentManagementQueryRequest.d.ts +44 -0
  12. package/dist/types/models/api/IDocumentManagementQueryResponse.d.ts +17 -0
  13. package/dist/types/models/api/IDocumentManagementRemoveRequest.d.ts +28 -0
  14. package/dist/types/models/api/IDocumentManagementSetRequest.d.ts +45 -0
  15. package/dist/types/models/documentDataTypes.d.ts +25 -0
  16. package/docs/changelog.md +5 -0
  17. package/docs/examples.md +1 -0
  18. package/docs/reference/index.md +21 -0
  19. package/docs/reference/interfaces/IDocument.md +147 -0
  20. package/docs/reference/interfaces/IDocumentList.md +35 -0
  21. package/docs/reference/interfaces/IDocumentManagementComponent.md +272 -0
  22. package/docs/reference/interfaces/IDocumentManagementGetRequest.md +109 -0
  23. package/docs/reference/interfaces/IDocumentManagementGetResponse.md +23 -0
  24. package/docs/reference/interfaces/IDocumentManagementQueryRequest.md +73 -0
  25. package/docs/reference/interfaces/IDocumentManagementQueryResponse.md +23 -0
  26. package/docs/reference/interfaces/IDocumentManagementRemoveRequest.md +43 -0
  27. package/docs/reference/interfaces/IDocumentManagementSetRequest.md +61 -0
  28. package/docs/reference/type-aliases/DocumentTypes.md +5 -0
  29. package/docs/reference/variables/DocumentTypes.md +31 -0
  30. package/locales/en.json +3 -0
  31. package/package.json +43 -0
@@ -0,0 +1,45 @@
1
+ import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
2
+ import type { UneceDocumentCodes } from "@twin.org/standards-unece";
3
+ /**
4
+ * Request to set a document in an auditable item graph vertex.
5
+ */
6
+ export interface IDocumentManagementSetRequest {
7
+ /**
8
+ * The path parameters.
9
+ */
10
+ pathParams: {
11
+ /**
12
+ * The id of the auditable item graph vertex to store the document on.
13
+ */
14
+ auditableItemGraphId: string;
15
+ };
16
+ /**
17
+ * The body parameters.
18
+ */
19
+ body: {
20
+ /**
21
+ * The document id to create.
22
+ */
23
+ documentId: string;
24
+ /**
25
+ * The format of the document identifier.
26
+ */
27
+ documentIdFormat: string | undefined;
28
+ /**
29
+ * The code for the document type.
30
+ */
31
+ documentCode: UneceDocumentCodes;
32
+ /**
33
+ * The data to create the document with, in base64.
34
+ */
35
+ blob: string;
36
+ /**
37
+ * Additional information to associate with the document.
38
+ */
39
+ annotationObject?: IJsonLdNodeObject;
40
+ /**
41
+ * Flag to create an attestation for the document, defaults to false
42
+ */
43
+ createAttestation?: boolean;
44
+ };
45
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The types of document management objects.
3
+ */
4
+ export declare const DocumentTypes: {
5
+ /**
6
+ * The context root for the document types.
7
+ */
8
+ readonly ContextRoot: "https://schema.twindev.org/documents/";
9
+ /**
10
+ * The context root for the common types.
11
+ */
12
+ readonly ContextRootCommon: "https://schema.twindev.org/common/";
13
+ /**
14
+ * Represents a document.
15
+ */
16
+ readonly Document: "Document";
17
+ /**
18
+ * Represents a document list.
19
+ */
20
+ readonly DocumentList: "DocumentList";
21
+ };
22
+ /**
23
+ * The types of document management objects.
24
+ */
25
+ export type DocumentTypes = (typeof DocumentTypes)[keyof typeof DocumentTypes];
@@ -0,0 +1,5 @@
1
+ # @twin.org/document-management-models - Changelog
2
+
3
+ ## v0.0.1-next.1
4
+
5
+ - Initial Release
@@ -0,0 +1 @@
1
+ # @twin.org/document-management-models - Examples
@@ -0,0 +1,21 @@
1
+ # @twin.org/document-management-models
2
+
3
+ ## Interfaces
4
+
5
+ - [IDocument](interfaces/IDocument.md)
6
+ - [IDocumentList](interfaces/IDocumentList.md)
7
+ - [IDocumentManagementComponent](interfaces/IDocumentManagementComponent.md)
8
+ - [IDocumentManagementGetRequest](interfaces/IDocumentManagementGetRequest.md)
9
+ - [IDocumentManagementGetResponse](interfaces/IDocumentManagementGetResponse.md)
10
+ - [IDocumentManagementQueryRequest](interfaces/IDocumentManagementQueryRequest.md)
11
+ - [IDocumentManagementQueryResponse](interfaces/IDocumentManagementQueryResponse.md)
12
+ - [IDocumentManagementRemoveRequest](interfaces/IDocumentManagementRemoveRequest.md)
13
+ - [IDocumentManagementSetRequest](interfaces/IDocumentManagementSetRequest.md)
14
+
15
+ ## Type Aliases
16
+
17
+ - [DocumentTypes](type-aliases/DocumentTypes.md)
18
+
19
+ ## Variables
20
+
21
+ - [DocumentTypes](variables/DocumentTypes.md)
@@ -0,0 +1,147 @@
1
+ # Interface: IDocument
2
+
3
+ Interface describing a document.
4
+
5
+ ## Properties
6
+
7
+ ### @context
8
+
9
+ > **@context**: \[`"https://schema.twindev.org/documents/"`, `"https://schema.twindev.org/common/"`, `"https://schema.org"`, `...IJsonLdContextDefinitionElement[]`\]
10
+
11
+ JSON-LD Context.
12
+
13
+ ***
14
+
15
+ ### type
16
+
17
+ > **type**: `"Document"`
18
+
19
+ JSON-LD Type.
20
+
21
+ ***
22
+
23
+ ### id
24
+
25
+ > **id**: `string`
26
+
27
+ The full id of the document.
28
+
29
+ ***
30
+
31
+ ### documentId
32
+
33
+ > **documentId**: `string`
34
+
35
+ The id of the document.
36
+
37
+ ***
38
+
39
+ ### documentIdFormat?
40
+
41
+ > `optional` **documentIdFormat**: `string`
42
+
43
+ The format of the document id.
44
+
45
+ ***
46
+
47
+ ### documentCode
48
+
49
+ > **documentCode**: `string`
50
+
51
+ The code for the document type.
52
+
53
+ ***
54
+
55
+ ### documentRevision
56
+
57
+ > **documentRevision**: `number`
58
+
59
+ The revision of the document as a 0 based index.
60
+
61
+ ***
62
+
63
+ ### annotationObject?
64
+
65
+ > `optional` **annotationObject**: `IJsonLdNodeObject`
66
+
67
+ Additional annotation information for the document.
68
+
69
+ ***
70
+
71
+ ### blobStorageId
72
+
73
+ > **blobStorageId**: `string`
74
+
75
+ The blob storage id for the document.
76
+
77
+ ***
78
+
79
+ ### blobHash
80
+
81
+ > **blobHash**: `string`
82
+
83
+ The hash of the blob data.
84
+
85
+ ***
86
+
87
+ ### blobStorageEntry?
88
+
89
+ > `optional` **blobStorageEntry**: `IBlobStorageEntry`
90
+
91
+ The additional JSON-LD for blob storage if it was requested.
92
+
93
+ ***
94
+
95
+ ### attestationId?
96
+
97
+ > `optional` **attestationId**: `string`
98
+
99
+ The attestation for the document if one was created.
100
+
101
+ ***
102
+
103
+ ### attestationInformation?
104
+
105
+ > `optional` **attestationInformation**: `IAttestationInformation`
106
+
107
+ The additional JSON-LD for attestation storage if it was requested.
108
+
109
+ ***
110
+
111
+ ### dateCreated
112
+
113
+ > **dateCreated**: `string`
114
+
115
+ The date/time of when the document was created.
116
+
117
+ ***
118
+
119
+ ### dateModified?
120
+
121
+ > `optional` **dateModified**: `string`
122
+
123
+ The date/time of when the document was modified.
124
+
125
+ ***
126
+
127
+ ### dateDeleted?
128
+
129
+ > `optional` **dateDeleted**: `string`
130
+
131
+ The date/time of when the document was deleted, as we never actually remove items.
132
+
133
+ ***
134
+
135
+ ### revisions?
136
+
137
+ > `optional` **revisions**: [`IDocument`](IDocument.md)[]
138
+
139
+ The previous revisions of the document.
140
+
141
+ ***
142
+
143
+ ### revisionCursor?
144
+
145
+ > `optional` **revisionCursor**: `string`
146
+
147
+ The cursor to get the next chunk of revisions.
@@ -0,0 +1,35 @@
1
+ # Interface: IDocumentList
2
+
3
+ Interface describing a document entry list.
4
+
5
+ ## Properties
6
+
7
+ ### @context
8
+
9
+ > **@context**: \[`"https://schema.twindev.org/documents/"`, `"https://schema.twindev.org/common/"`, `...IJsonLdContextDefinitionElement[]`\]
10
+
11
+ JSON-LD Context.
12
+
13
+ ***
14
+
15
+ ### type
16
+
17
+ > **type**: `"DocumentList"`
18
+
19
+ JSON-LD Type.
20
+
21
+ ***
22
+
23
+ ### documents
24
+
25
+ > **documents**: [`IDocument`](IDocument.md)[]
26
+
27
+ The list of documents.
28
+
29
+ ***
30
+
31
+ ### cursor?
32
+
33
+ > `optional` **cursor**: `string`
34
+
35
+ The cursor to get the next chunk of documents.
@@ -0,0 +1,272 @@
1
+ # Interface: IDocumentManagementComponent
2
+
3
+ Interface describing an document management contract.
4
+
5
+ ## Extends
6
+
7
+ - `IComponent`
8
+
9
+ ## Methods
10
+
11
+ ### set()
12
+
13
+ > **set**(`auditableItemGraphId`, `documentId`, `documentIdFormat`, `documentCode`, `blob`, `annotationObject`?, `createAttestation`?, `userIdentity`?, `nodeIdentity`?): `Promise`\<`string`\>
14
+
15
+ Store a document in an auditable item graph vertex and add its content to blob storage.
16
+ If the document id already exists and the blob data is different a new revision will be created.
17
+ For any other changes the current revision will be updated.
18
+
19
+ #### Parameters
20
+
21
+ ##### auditableItemGraphId
22
+
23
+ `string`
24
+
25
+ The auditable item graph vertex id to create the document on.
26
+
27
+ ##### documentId
28
+
29
+ `string`
30
+
31
+ The document id to create.
32
+
33
+ ##### documentIdFormat
34
+
35
+ The format of the document identifier.
36
+
37
+ `undefined` | `string`
38
+
39
+ ##### documentCode
40
+
41
+ `string`
42
+
43
+ The code for the document type.
44
+
45
+ ##### blob
46
+
47
+ `Uint8Array`
48
+
49
+ The data to create the document with.
50
+
51
+ ##### annotationObject?
52
+
53
+ `IJsonLdNodeObject`
54
+
55
+ Additional information to associate with the document.
56
+
57
+ ##### createAttestation?
58
+
59
+ `boolean`
60
+
61
+ Flag to create an attestation for the document, defaults to false.
62
+
63
+ ##### userIdentity?
64
+
65
+ `string`
66
+
67
+ The identity to perform the auditable item graph operation with.
68
+
69
+ ##### nodeIdentity?
70
+
71
+ `string`
72
+
73
+ The node identity to use for vault operations.
74
+
75
+ #### Returns
76
+
77
+ `Promise`\<`string`\>
78
+
79
+ The identifier for the document which includes the auditable item graph identifier.
80
+
81
+ ***
82
+
83
+ ### get()
84
+
85
+ > **get**(`auditableItemGraphId`, `identifier`, `options`?, `revisionCursor`?, `userIdentity`?, `nodeIdentity`?): `Promise`\<[`IDocument`](IDocument.md)\>
86
+
87
+ Get a specific document from an auditable item graph vertex.
88
+
89
+ #### Parameters
90
+
91
+ ##### auditableItemGraphId
92
+
93
+ `string`
94
+
95
+ The auditable item graph vertex id to get the document from.
96
+
97
+ ##### identifier
98
+
99
+ `string`
100
+
101
+ The identifier of the document to get.
102
+
103
+ ##### options?
104
+
105
+ Additional options for the get operation.
106
+
107
+ ###### includeBlobStorageMetadata?
108
+
109
+ `boolean`
110
+
111
+ Flag to include the blob storage metadata for the document, defaults to false.
112
+
113
+ ###### includeBlobStorageData?
114
+
115
+ `boolean`
116
+
117
+ Flag to include the blob storage data for the document, defaults to false.
118
+
119
+ ###### includeAttestation?
120
+
121
+ `boolean`
122
+
123
+ Flag to include the attestation information for the document, defaults to false.
124
+
125
+ ###### includeRemoved?
126
+
127
+ `boolean`
128
+
129
+ Flag to include deleted documents, defaults to false.
130
+
131
+ ###### maxRevisionCount?
132
+
133
+ `number`
134
+
135
+ Max number of revisions to return, defaults to 0.
136
+
137
+ ##### revisionCursor?
138
+
139
+ `string`
140
+
141
+ The cursor to get the next chunk of revisions.
142
+
143
+ ##### userIdentity?
144
+
145
+ `string`
146
+
147
+ The identity to perform the auditable item graph operation with.
148
+
149
+ ##### nodeIdentity?
150
+
151
+ `string`
152
+
153
+ The node identity to use for vault operations.
154
+
155
+ #### Returns
156
+
157
+ `Promise`\<[`IDocument`](IDocument.md)\>
158
+
159
+ The documents and revisions if requested, ordered by revision descending, cursor is set if there are more document revisions.
160
+
161
+ ***
162
+
163
+ ### remove()
164
+
165
+ > **remove**(`auditableItemGraphId`, `identifier`, `options`?, `userIdentity`?, `nodeIdentity`?): `Promise`\<`void`\>
166
+
167
+ Remove a specific document from an auditable item graph vertex.
168
+ The documents dateDeleted will be set, but can still be queried with the includeRemoved flag.
169
+
170
+ #### Parameters
171
+
172
+ ##### auditableItemGraphId
173
+
174
+ `string`
175
+
176
+ The auditable item graph vertex id to remove the document from.
177
+
178
+ ##### identifier
179
+
180
+ `string`
181
+
182
+ The identifier of the document to remove.
183
+
184
+ ##### options?
185
+
186
+ Additional options for the remove operation.
187
+
188
+ ###### removeAllRevisions?
189
+
190
+ `boolean`
191
+
192
+ Flag to remove all revisions of the document, defaults to false.
193
+
194
+ ##### userIdentity?
195
+
196
+ `string`
197
+
198
+ The identity to perform the auditable item graph operation with.
199
+
200
+ ##### nodeIdentity?
201
+
202
+ `string`
203
+
204
+ The node identity to use for vault operations.
205
+
206
+ #### Returns
207
+
208
+ `Promise`\<`void`\>
209
+
210
+ Nothing.
211
+
212
+ ***
213
+
214
+ ### query()
215
+
216
+ > **query**(`auditableItemGraphId`, `documentCodes`?, `options`?, `cursor`?, `userIdentity`?, `nodeIdentity`?): `Promise`\<[`IDocumentList`](IDocumentList.md)\>
217
+
218
+ Query an auditable item graph vertex for documents.
219
+
220
+ #### Parameters
221
+
222
+ ##### auditableItemGraphId
223
+
224
+ `string`
225
+
226
+ The auditable item graph vertex to get the documents from.
227
+
228
+ ##### documentCodes?
229
+
230
+ `string`[]
231
+
232
+ The document codes to query for, if undefined gets all document codes.
233
+
234
+ ##### options?
235
+
236
+ Additional options for the query operation.
237
+
238
+ ###### includeMostRecentRevisions?
239
+
240
+ `boolean`
241
+
242
+ Include the most recent 5 revisions, use the individual get to retrieve more.
243
+
244
+ ###### includeRemoved?
245
+
246
+ `boolean`
247
+
248
+ Flag to include deleted documents, defaults to false.
249
+
250
+ ##### cursor?
251
+
252
+ `string`
253
+
254
+ The cursor to get the next chunk of documents.
255
+
256
+ ##### userIdentity?
257
+
258
+ `string`
259
+
260
+ The identity to perform the auditable item graph operation with.
261
+
262
+ ##### nodeIdentity?
263
+
264
+ `string`
265
+
266
+ The node identity to use for vault operations.
267
+
268
+ #### Returns
269
+
270
+ `Promise`\<[`IDocumentList`](IDocumentList.md)\>
271
+
272
+ The most recent revisions of each document, cursor is set if there are more documents.
@@ -0,0 +1,109 @@
1
+ # Interface: IDocumentManagementGetRequest
2
+
3
+ Request to get a document from an auditable item graph vertex.
4
+
5
+ ## Properties
6
+
7
+ ### headers?
8
+
9
+ > `optional` **headers**: `object`
10
+
11
+ The headers which can be used to determine the response data type.
12
+
13
+ #### accept
14
+
15
+ > **accept**: `"application/json"` \| `"application/ld+json"`
16
+
17
+ ***
18
+
19
+ ### pathParams
20
+
21
+ > **pathParams**: `object`
22
+
23
+ The path parameters.
24
+
25
+ #### auditableItemGraphId
26
+
27
+ > **auditableItemGraphId**: `string`
28
+
29
+ The id of the auditable item graph vertex to store the document on.
30
+
31
+ #### documentId
32
+
33
+ > **documentId**: `string`
34
+
35
+ The full id of the document to get.
36
+
37
+ ***
38
+
39
+ ### query?
40
+
41
+ > `optional` **query**: `object`
42
+
43
+ The query parameters.
44
+
45
+ #### includeBlobStorageMetadata?
46
+
47
+ > `optional` **includeBlobStorageMetadata**: `boolean`
48
+
49
+ Include the blob storage metadata in the response.
50
+
51
+ ##### Default
52
+
53
+ ```ts
54
+ false
55
+ ```
56
+
57
+ #### includeBlobStorageData?
58
+
59
+ > `optional` **includeBlobStorageData**: `boolean`
60
+
61
+ Include the blob storage data in the response.
62
+
63
+ ##### Default
64
+
65
+ ```ts
66
+ false
67
+ ```
68
+
69
+ #### includeAttestation?
70
+
71
+ > `optional` **includeAttestation**: `boolean`
72
+
73
+ Include the attestation information in the response.
74
+
75
+ ##### Default
76
+
77
+ ```ts
78
+ false
79
+ ```
80
+
81
+ #### includeRemoved?
82
+
83
+ > `optional` **includeRemoved**: `boolean`
84
+
85
+ Include deleted documents in the response.
86
+
87
+ ##### Default
88
+
89
+ ```ts
90
+ false
91
+ ```
92
+
93
+ #### maxRevisionCount?
94
+
95
+ > `optional` **maxRevisionCount**: `number`
96
+
97
+ Max number of revisions to return.
98
+
99
+ ##### Default
100
+
101
+ ```ts
102
+ 0
103
+ ```
104
+
105
+ #### revisionCursor?
106
+
107
+ > `optional` **revisionCursor**: `string`
108
+
109
+ The cursor to get the next chunk of revisions.
@@ -0,0 +1,23 @@
1
+ # Interface: IDocumentManagementGetResponse
2
+
3
+ Response to get a document and optionally revisions from an auditable item graph vertex.
4
+
5
+ ## Properties
6
+
7
+ ### headers?
8
+
9
+ > `optional` **headers**: `object`
10
+
11
+ The headers which can be used to determine the response data type.
12
+
13
+ #### content-type
14
+
15
+ > **content-type**: `"application/json"` \| `"application/ld+json"`
16
+
17
+ ***
18
+
19
+ ### body
20
+
21
+ > **body**: [`IDocument`](IDocument.md)
22
+
23
+ The body parameters.