@twin.org/document-management-rest-client 0.0.3-next.10 → 0.0.3-next.12
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/README.md +1 -1
- package/docs/changelog.md +29 -1
- package/docs/examples.md +118 -1
- package/docs/reference/classes/DocumentManagementRestClient.md +10 -10
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# TWIN Document Management REST Client
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This package provides a client for invoking document lifecycle endpoints over HTTP with a stable, contract-led API. It is intended for consumers that need to create, update, fetch revisions, remove revisions, and query document records from remote services.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
package/docs/changelog.md
CHANGED
|
@@ -1,4 +1,32 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.0.3-next.12](https://github.com/twinfoundation/document-management/compare/document-management-rest-client-v0.0.3-next.11...document-management-rest-client-v0.0.3-next.12) (2026-03-26)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* update to latest aig method shapes ([497e895](https://github.com/twinfoundation/document-management/commit/497e8954f24774db628e057ebb9d158a1fd9d92a))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/document-management-models bumped from 0.0.3-next.11 to 0.0.3-next.12
|
|
16
|
+
|
|
17
|
+
## [0.0.3-next.11](https://github.com/twinfoundation/document-management/compare/document-management-rest-client-v0.0.3-next.10...document-management-rest-client-v0.0.3-next.11) (2026-02-25)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Miscellaneous Chores
|
|
21
|
+
|
|
22
|
+
* **document-management-rest-client:** Synchronize repo versions
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Dependencies
|
|
26
|
+
|
|
27
|
+
* The following workspace dependencies were updated
|
|
28
|
+
* dependencies
|
|
29
|
+
* @twin.org/document-management-models bumped from 0.0.3-next.10 to 0.0.3-next.11
|
|
2
30
|
|
|
3
31
|
## [0.0.3-next.10](https://github.com/twinfoundation/document-management/compare/document-management-rest-client-v0.0.3-next.9...document-management-rest-client-v0.0.3-next.10) (2026-02-11)
|
|
4
32
|
|
package/docs/examples.md
CHANGED
|
@@ -1 +1,118 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Document Management REST Client Examples
|
|
2
|
+
|
|
3
|
+
These examples walk through common client calls for creating, updating, reading, and finding documents from a remote service.
|
|
4
|
+
|
|
5
|
+
## DocumentManagementRestClient
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { DocumentManagementRestClient } from '@twin.org/document-management-rest-client';
|
|
9
|
+
import { Converter } from '@twin.org/core';
|
|
10
|
+
import { UneceDocumentCodeList } from '@twin.org/standards-unece';
|
|
11
|
+
|
|
12
|
+
const client = new DocumentManagementRestClient({
|
|
13
|
+
endpoint: 'http://localhost:3000'
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const blobBytes = Converter.utf8ToBytes('Updated bill of lading payload');
|
|
17
|
+
const edgeTargetId = 'aig:shipment-vertex';
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
const componentName = client.className();
|
|
22
|
+
console.log(componentName); // DocumentManagementRestClient
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
const createdVertexId = await client.create(
|
|
27
|
+
'BOL-2026-0001',
|
|
28
|
+
'bol',
|
|
29
|
+
UneceDocumentCodeList.BillOfLading,
|
|
30
|
+
blobBytes,
|
|
31
|
+
{
|
|
32
|
+
'@context': 'https://schema.org',
|
|
33
|
+
'@type': 'DigitalDocument',
|
|
34
|
+
name: 'bol-2026-0001.pdf'
|
|
35
|
+
},
|
|
36
|
+
[
|
|
37
|
+
{
|
|
38
|
+
targetId: edgeTargetId,
|
|
39
|
+
addAlias: true,
|
|
40
|
+
aliasAnnotationObject: {
|
|
41
|
+
'@context': 'https://schema.org',
|
|
42
|
+
'@type': 'Thing',
|
|
43
|
+
name: 'Shipment link'
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
{
|
|
48
|
+
createAttestation: true,
|
|
49
|
+
addAlias: true,
|
|
50
|
+
aliasAnnotationObject: {
|
|
51
|
+
'@context': 'https://schema.org',
|
|
52
|
+
'@type': 'Thing',
|
|
53
|
+
name: 'Primary alias'
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
console.log(createdVertexId); // aig:document-vertex-1
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
await client.update(
|
|
63
|
+
'aig:document-vertex-1',
|
|
64
|
+
Converter.utf8ToBytes('Second revision payload'),
|
|
65
|
+
{
|
|
66
|
+
'@context': 'https://schema.org',
|
|
67
|
+
'@type': 'CreativeWork',
|
|
68
|
+
name: 'bol-2026-0001-rev1.pdf'
|
|
69
|
+
},
|
|
70
|
+
[
|
|
71
|
+
{
|
|
72
|
+
targetId: edgeTargetId,
|
|
73
|
+
addAlias: true,
|
|
74
|
+
aliasAnnotationObject: {
|
|
75
|
+
'@context': 'https://schema.org',
|
|
76
|
+
'@type': 'Thing',
|
|
77
|
+
name: 'Shipment alias'
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
);
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
const latest = await client.get(
|
|
86
|
+
'aig:document-vertex-1',
|
|
87
|
+
{
|
|
88
|
+
includeBlobStorageMetadata: true,
|
|
89
|
+
includeAttestation: true
|
|
90
|
+
},
|
|
91
|
+
'0',
|
|
92
|
+
2
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
console.log(latest.entries.itemListElement.length); // 2
|
|
96
|
+
console.log(latest.cursor); // 2
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
const revisionOne = await client.getRevision('aig:document-vertex-1', 1, {
|
|
101
|
+
includeBlobStorageData: true,
|
|
102
|
+
includeAttestation: true
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
console.log(revisionOne.documentRevision); // 1
|
|
106
|
+
console.log(revisionOne.documentId); // BOL-2026-0001
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
await client.removeRevision('aig:document-vertex-1', 1);
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
const matches = await client.query('BOL-2026-0001', '0', 10);
|
|
115
|
+
|
|
116
|
+
console.log(matches.entries.vertices.length); // 1
|
|
117
|
+
console.log(matches.cursor); // undefined
|
|
118
|
+
```
|
|
@@ -36,7 +36,7 @@ The configuration for the client.
|
|
|
36
36
|
|
|
37
37
|
## Properties
|
|
38
38
|
|
|
39
|
-
### CLASS\_NAME
|
|
39
|
+
### CLASS\_NAME {#class_name}
|
|
40
40
|
|
|
41
41
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
42
42
|
|
|
@@ -44,7 +44,7 @@ Runtime name for the class.
|
|
|
44
44
|
|
|
45
45
|
## Methods
|
|
46
46
|
|
|
47
|
-
### className()
|
|
47
|
+
### className() {#classname}
|
|
48
48
|
|
|
49
49
|
> **className**(): `string`
|
|
50
50
|
|
|
@@ -62,7 +62,7 @@ The class name of the component.
|
|
|
62
62
|
|
|
63
63
|
***
|
|
64
64
|
|
|
65
|
-
### create()
|
|
65
|
+
### create() {#create}
|
|
66
66
|
|
|
67
67
|
> **create**(`documentId`, `documentIdFormat`, `documentCode`, `blob`, `annotationObject?`, `auditableItemGraphEdges?`, `options?`): `Promise`\<`string`\>
|
|
68
68
|
|
|
@@ -80,9 +80,9 @@ The document id to create.
|
|
|
80
80
|
|
|
81
81
|
##### documentIdFormat
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
`string` \| `undefined`
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
The format of the document identifier.
|
|
86
86
|
|
|
87
87
|
##### documentCode
|
|
88
88
|
|
|
@@ -142,7 +142,7 @@ The auditable item graph vertex created for the document including its revision.
|
|
|
142
142
|
|
|
143
143
|
***
|
|
144
144
|
|
|
145
|
-
### update()
|
|
145
|
+
### update() {#update}
|
|
146
146
|
|
|
147
147
|
> **update**(`auditableItemGraphDocumentId`, `blob?`, `annotationObject?`, `auditableItemGraphEdges?`): `Promise`\<`void`\>
|
|
148
148
|
|
|
@@ -188,7 +188,7 @@ Nothing.
|
|
|
188
188
|
|
|
189
189
|
***
|
|
190
190
|
|
|
191
|
-
### get()
|
|
191
|
+
### get() {#get}
|
|
192
192
|
|
|
193
193
|
> **get**(`auditableItemGraphDocumentId`, `options?`, `cursor?`, `limit?`): `Promise`\<\{ `entries`: `IDocumentList`; `cursor?`: `string`; \}\>
|
|
194
194
|
|
|
@@ -266,7 +266,7 @@ The documents and revisions if requested, ordered by revision descending, cursor
|
|
|
266
266
|
|
|
267
267
|
***
|
|
268
268
|
|
|
269
|
-
### getRevision()
|
|
269
|
+
### getRevision() {#getrevision}
|
|
270
270
|
|
|
271
271
|
> **getRevision**(`auditableItemGraphDocumentId`, `revision`, `options?`): `Promise`\<`IDocument`\>
|
|
272
272
|
|
|
@@ -332,7 +332,7 @@ The documents and revisions if requested, ordered by revision descending, cursor
|
|
|
332
332
|
|
|
333
333
|
***
|
|
334
334
|
|
|
335
|
-
### removeRevision()
|
|
335
|
+
### removeRevision() {#removerevision}
|
|
336
336
|
|
|
337
337
|
> **removeRevision**(`auditableItemGraphDocumentId`, `revision`): `Promise`\<`void`\>
|
|
338
338
|
|
|
@@ -365,7 +365,7 @@ Nothing.
|
|
|
365
365
|
|
|
366
366
|
***
|
|
367
367
|
|
|
368
|
-
### query()
|
|
368
|
+
### query() {#query}
|
|
369
369
|
|
|
370
370
|
> **query**(`documentId`, `cursor?`, `limit?`): `Promise`\<\{ `entries`: `IAuditableItemGraphVertexList`; `cursor?`: `string`; \}\>
|
|
371
371
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/document-management-rest-client",
|
|
3
|
-
"version": "0.0.3-next.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.3-next.12",
|
|
4
|
+
"description": "REST client operations for creating, updating, retrieving, and querying managed documents.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/twinfoundation/document-management.git",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@twin.org/auditable-item-graph-models": "next",
|
|
20
20
|
"@twin.org/core": "next",
|
|
21
21
|
"@twin.org/data-json-ld": "next",
|
|
22
|
-
"@twin.org/document-management-models": "0.0.3-next.
|
|
22
|
+
"@twin.org/document-management-models": "0.0.3-next.12",
|
|
23
23
|
"@twin.org/entity": "next",
|
|
24
24
|
"@twin.org/nameof": "next",
|
|
25
25
|
"@twin.org/standards-unece": "next",
|