@twin.org/auditable-item-graph-rest-client 0.0.3-next.2 → 0.0.3-next.21

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/docs/examples.md CHANGED
@@ -1 +1,119 @@
1
- # @twin.org/auditable-item-graph-rest-client - Examples
1
+ # Auditable Item Graph REST Client Examples
2
+
3
+ These snippets show practical request flows for creating, reading, updating, and querying graph items through HTTP endpoints.
4
+
5
+ ## AuditableItemGraphRestClient
6
+
7
+ ```typescript
8
+ import { AuditableItemGraphRestClient } from '@twin.org/auditable-item-graph-rest-client';
9
+
10
+ const client = new AuditableItemGraphRestClient({ endpoint: 'http://localhost:8080' });
11
+
12
+ console.log(client.className()); // AuditableItemGraphRestClient
13
+ ```
14
+
15
+ ```typescript
16
+ import { VerifyDepth } from '@twin.org/auditable-item-graph-models';
17
+ import { AuditableItemGraphRestClient } from '@twin.org/auditable-item-graph-rest-client';
18
+
19
+ const client = new AuditableItemGraphRestClient({ endpoint: 'http://localhost:8080' });
20
+
21
+ const id = await client.create({
22
+ annotationObject: {
23
+ '@context': 'https://www.w3.org/ns/activitystreams',
24
+ type: 'Create',
25
+ actor: {
26
+ type: 'Person',
27
+ id: 'acct:alex@example.org',
28
+ name: 'Alex'
29
+ },
30
+ object: {
31
+ type: 'Note',
32
+ content: 'Created through the REST client'
33
+ }
34
+ },
35
+ aliases: [{ id: 'ticket-2026-0007', aliasFormat: 'externalRef', unique: true }],
36
+ resources: [
37
+ { resourceObject: { '@context': 'https://schema.org', type: 'Thing', name: 'Asset A' } }
38
+ ]
39
+ });
40
+
41
+ const vertex = await client.get(id, {
42
+ includeDeleted: false,
43
+ verifySignatureDepth: VerifyDepth.Current
44
+ });
45
+
46
+ console.log(id); // aig:018f5a6cfd9444d58c7c2d4df1fd0a23
47
+ console.log(vertex.id); // aig:018f5a6cfd9444d58c7c2d4df1fd0a23
48
+ ```
49
+
50
+ ```typescript
51
+ import { VerifyDepth } from '@twin.org/auditable-item-graph-models';
52
+ import { AuditableItemGraphRestClient } from '@twin.org/auditable-item-graph-rest-client';
53
+
54
+ const client = new AuditableItemGraphRestClient({ endpoint: 'http://localhost:8080' });
55
+
56
+ const id = 'aig:018f5a6cfd9444d58c7c2d4df1fd0a23';
57
+
58
+ await client.update({
59
+ id,
60
+ aliases: [{ id: 'ticket-2026-0007', aliasFormat: 'externalRef' }],
61
+ resources: [
62
+ {
63
+ id: 'resource-1',
64
+ resourceObject: { '@context': 'https://schema.org', type: 'Thing', name: 'Asset A v2' }
65
+ }
66
+ ],
67
+ edges: [{ targetId: 'aig:018f5a6cfd9444d58c7c2d4df1fd0999', edgeRelationships: ['dependsOn'] }]
68
+ });
69
+
70
+ const changesetChunk = await client.getChangesets(id, undefined, 20, {
71
+ verifySignatureDepth: VerifyDepth.Current
72
+ });
73
+
74
+ const firstChangeset = changesetChunk.changesets.itemListElement?.[0];
75
+
76
+ if (firstChangeset?.id) {
77
+ const changeset = await client.getChangeset(firstChangeset.id, {
78
+ verifySignatureDepth: VerifyDepth.Current
79
+ });
80
+
81
+ console.log(changeset.id); // aig:018f5a6cfd9444d58c7c2d4df1fd0a23:changeset:018f5a6cfd9444d58c7c2d4df1fd0b10
82
+ }
83
+ ```
84
+
85
+ ```typescript
86
+ import { AuditableItemGraphRestClient } from '@twin.org/auditable-item-graph-rest-client';
87
+ import { ComparisonOperator, SortDirection } from '@twin.org/entity';
88
+
89
+ const client = new AuditableItemGraphRestClient({ endpoint: 'http://localhost:8080' });
90
+
91
+ const result = await client.query(
92
+ {
93
+ id: 'ticket-2026',
94
+ idMode: 'alias',
95
+ idExact: false,
96
+ resourceTypes: ['Thing']
97
+ },
98
+ [
99
+ {
100
+ field: 'dateCreated',
101
+ comparison: ComparisonOperator.GreaterThan,
102
+ value: '2026-01-01T00:00:00.000Z'
103
+ }
104
+ ],
105
+ 'dateCreated',
106
+ SortDirection.Descending,
107
+ ['id', 'dateCreated', 'aliases'],
108
+ undefined,
109
+ 10
110
+ );
111
+
112
+ console.log(result.entries.itemListElement?.length ?? 0); // 2
113
+
114
+ try {
115
+ await client.removeVerifiable('aig:018f5a6cfd9444d58c7c2d4df1fd0a23');
116
+ } catch (error) {
117
+ console.log(error instanceof Error ? error.message : 'Unknown error'); // Not supported on client
118
+ }
119
+ ```
@@ -8,7 +8,7 @@ Client for performing auditable item graph through to REST endpoints.
8
8
 
9
9
  ## Implements
10
10
 
11
- - `IAuditableItemGraphComponent`
11
+ - `Omit`\<`IAuditableItemGraphComponent`, `"removeProof"`\>
12
12
 
13
13
  ## Constructors
14
14
 
@@ -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
 
@@ -58,11 +58,11 @@ The class name of the component.
58
58
 
59
59
  #### Implementation of
60
60
 
61
- `IAuditableItemGraphComponent.className`
61
+ `Omit.className`
62
62
 
63
63
  ***
64
64
 
65
- ### create()
65
+ ### create() {#create}
66
66
 
67
67
  > **create**(`vertex`): `Promise`\<`string`\>
68
68
 
@@ -72,49 +72,73 @@ Create a new graph vertex.
72
72
 
73
73
  ##### vertex
74
74
 
75
+ `Omit`\<`IAuditableItemGraphVertex`, `"id"`\>
76
+
75
77
  The vertex to create.
76
78
 
77
- ###### annotationObject?
79
+ #### Returns
78
80
 
79
- `IJsonLdNodeObject`
81
+ `Promise`\<`string`\>
82
+
83
+ The id of the new graph item.
80
84
 
81
- The annotation object for the vertex as JSON-LD.
85
+ #### Implementation of
86
+
87
+ `Omit.create`
88
+
89
+ ***
82
90
 
83
- ###### aliases?
91
+ ### get() {#get}
84
92
 
85
- `object`[]
93
+ > **get**(`id`, `options?`): `Promise`\<`IAuditableItemGraphVertex`\>
86
94
 
87
- Alternative aliases that can be used to identify the vertex.
95
+ Get a graph vertex.
88
96
 
89
- ###### resources?
97
+ #### Parameters
90
98
 
91
- `object`[]
99
+ ##### id
92
100
 
93
- The resources attached to the vertex.
101
+ `string`
94
102
 
95
- ###### edges?
103
+ The id of the vertex to get.
96
104
 
97
- `object`[]
105
+ ##### options?
98
106
 
99
- The edges connected to the vertex.
107
+ Additional options for the get operation.
108
+
109
+ ###### includeDeleted?
110
+
111
+ `boolean`
112
+
113
+ Whether to include deleted/updated aliases, resource, edges, defaults to false.
114
+
115
+ ###### verifySignatureDepth?
116
+
117
+ `VerifyDepth`
118
+
119
+ How many signatures to verify, defaults to "none".
100
120
 
101
121
  #### Returns
102
122
 
103
- `Promise`\<`string`\>
123
+ `Promise`\<`IAuditableItemGraphVertex`\>
104
124
 
105
- The id of the new graph item.
125
+ The vertex if found.
126
+
127
+ #### Throws
128
+
129
+ NotFoundError if the vertex is not found.
106
130
 
107
131
  #### Implementation of
108
132
 
109
- `IAuditableItemGraphComponent.create`
133
+ `Omit.get`
110
134
 
111
135
  ***
112
136
 
113
- ### get()
137
+ ### getChangesets() {#getchangesets}
114
138
 
115
- > **get**(`id`, `options?`): `Promise`\<`IAuditableItemGraphVertex`\>
139
+ > **getChangesets**(`id`, `cursor?`, `limit?`, `options?`): `Promise`\<\{ `changesets`: `IAuditableItemGraphChangesetList`; `cursor?`: `string`; \}\>
116
140
 
117
- Get a graph vertex.
141
+ Get a graph vertex changeset list.
118
142
 
119
143
  #### Parameters
120
144
 
@@ -124,21 +148,57 @@ Get a graph vertex.
124
148
 
125
149
  The id of the vertex to get.
126
150
 
151
+ ##### cursor?
152
+
153
+ `string`
154
+
155
+ The optional cursor to get next chunk.
156
+
157
+ ##### limit?
158
+
159
+ `number`
160
+
161
+ Limit the number of entities to return.
162
+
127
163
  ##### options?
128
164
 
129
165
  Additional options for the get operation.
130
166
 
131
- ###### includeDeleted?
167
+ ###### verifySignatureDepth?
132
168
 
133
- `boolean`
169
+ `VerifyDepth`
134
170
 
135
- Whether to include deleted/updated aliases, resource, edges, defaults to false.
171
+ How many signatures to verify, defaults to "none".
136
172
 
137
- ###### includeChangesets?
173
+ #### Returns
138
174
 
139
- `boolean`
175
+ `Promise`\<\{ `changesets`: `IAuditableItemGraphChangesetList`; `cursor?`: `string`; \}\>
176
+
177
+ The changesets if found.
178
+
179
+ #### Implementation of
180
+
181
+ `Omit.getChangesets`
182
+
183
+ ***
184
+
185
+ ### getChangeset() {#getchangeset}
186
+
187
+ > **getChangeset**(`id`, `options?`): `Promise`\<`IAuditableItemGraphChangeset`\>
188
+
189
+ Get a graph vertex changeset.
190
+
191
+ #### Parameters
192
+
193
+ ##### id
140
194
 
141
- Whether to include the changesets of the vertex, defaults to false.
195
+ `string`
196
+
197
+ The id of the vertex to get.
198
+
199
+ ##### options?
200
+
201
+ Additional options for the get operation.
142
202
 
143
203
  ###### verifySignatureDepth?
144
204
 
@@ -148,61 +208,117 @@ How many signatures to verify, defaults to "none".
148
208
 
149
209
  #### Returns
150
210
 
211
+ `Promise`\<`IAuditableItemGraphChangeset`\>
212
+
213
+ The changeset if found.
214
+
215
+ #### Throws
216
+
217
+ NotFoundError if the vertex or changeset is not found.
218
+
219
+ #### Implementation of
220
+
221
+ `Omit.getChangeset`
222
+
223
+ ***
224
+
225
+ ### getVersion() {#getversion}
226
+
227
+ > **getVersion**(`id`, `version`): `Promise`\<`IAuditableItemGraphVertex`\>
228
+
229
+ Get a graph vertex at a specific version.
230
+
231
+ #### Parameters
232
+
233
+ ##### id
234
+
235
+ `string`
236
+
237
+ The id of the vertex.
238
+
239
+ ##### version
240
+
241
+ `number`
242
+
243
+ The version number to retrieve.
244
+
245
+ #### Returns
246
+
151
247
  `Promise`\<`IAuditableItemGraphVertex`\>
152
248
 
153
- The vertex if found.
249
+ The vertex reconstructed at that version.
154
250
 
155
251
  #### Throws
156
252
 
157
- NotFoundError if the vertex is not found.
253
+ NotFoundError if the vertex or version is not found.
158
254
 
159
255
  #### Implementation of
160
256
 
161
- `IAuditableItemGraphComponent.get`
257
+ `Omit.getVersion`
162
258
 
163
259
  ***
164
260
 
165
- ### update()
261
+ ### getVersions() {#getversions}
166
262
 
167
- > **update**(`vertex`): `Promise`\<`void`\>
263
+ > **getVersions**(`id`, `options?`): `Promise`\<`IAuditableItemGraphVertexVersionList`\>
168
264
 
169
- Update a graph vertex.
265
+ Get all versions of a graph vertex.
170
266
 
171
267
  #### Parameters
172
268
 
173
- ##### vertex
269
+ ##### id
174
270
 
175
- The vertex to update.
271
+ `string`
272
+
273
+ The id of the vertex.
274
+
275
+ ##### options?
176
276
 
177
- ###### id
277
+ Additional options for the operation.
278
+
279
+ ###### after?
178
280
 
179
281
  `string`
180
282
 
181
- The id of the vertex to update.
283
+ Only return versions created after this ISO 8601 timestamp (exclusive).
182
284
 
183
- ###### annotationObject?
285
+ ###### before?
184
286
 
185
- `IJsonLdNodeObject`
287
+ `string`
186
288
 
187
- The annotation object for the vertex as JSON-LD.
289
+ Only return versions created before this ISO 8601 timestamp (exclusive).
188
290
 
189
- ###### aliases?
291
+ #### Returns
190
292
 
191
- `object`[]
293
+ `Promise`\<`IAuditableItemGraphVertexVersionList`\>
192
294
 
193
- Alternative aliases that can be used to identify the vertex.
295
+ The list of vertex versions.
194
296
 
195
- ###### resources?
297
+ #### Throws
196
298
 
197
- `object`[]
299
+ NotFoundError if the vertex is not found.
198
300
 
199
- The resources attached to the vertex.
301
+ #### Implementation of
302
+
303
+ `Omit.getVersions`
200
304
 
201
- ###### edges?
305
+ ***
202
306
 
203
- `object`[]
307
+ ### update() {#update}
204
308
 
205
- The edges connected to the vertex.
309
+ > **update**(`vertex`): `Promise`\<`void`\>
310
+
311
+ Update a graph vertex (PUT — full replacement of vertex state).
312
+ The server serializes concurrent updates for the same vertex via `Mutex` on the vertex id;
313
+ requests load-balanced across replicas can still race.
314
+
315
+ #### Parameters
316
+
317
+ ##### vertex
318
+
319
+ `IAuditableItemGraphVertex`
320
+
321
+ The vertex to update.
206
322
 
207
323
  #### Returns
208
324
 
@@ -212,23 +328,23 @@ Nothing.
212
328
 
213
329
  #### Implementation of
214
330
 
215
- `IAuditableItemGraphComponent.update`
331
+ `Omit.update`
216
332
 
217
333
  ***
218
334
 
219
- ### removeVerifiable()
335
+ ### updatePartial() {#updatepartial}
220
336
 
221
- > **removeVerifiable**(`id`): `Promise`\<`void`\>
337
+ > **updatePartial**(`partial`): `Promise`\<`void`\>
222
338
 
223
- Remove the verifiable storage for an item, not supported on client.
339
+ Partially update a graph vertex (PATCH optional scalars; list fields use `{ add, remove }`).
224
340
 
225
341
  #### Parameters
226
342
 
227
- ##### id
343
+ ##### partial
228
344
 
229
- `string`
345
+ `IAuditableItemGraphPartialVertex`
230
346
 
231
- The id of the vertex to get.
347
+ The partial vertex update (must include `id`).
232
348
 
233
349
  #### Returns
234
350
 
@@ -236,19 +352,15 @@ The id of the vertex to get.
236
352
 
237
353
  Nothing.
238
354
 
239
- #### Throws
240
-
241
- NotFoundError if the vertex is not found.
242
-
243
355
  #### Implementation of
244
356
 
245
- `IAuditableItemGraphComponent.removeVerifiable`
357
+ `Omit.updatePartial`
246
358
 
247
359
  ***
248
360
 
249
- ### query()
361
+ ### query() {#query}
250
362
 
251
- > **query**(`options?`, `conditions?`, `orderBy?`, `orderByDirection?`, `properties?`, `cursor?`, `limit?`): `Promise`\<`IAuditableItemGraphVertexList`\>
363
+ > **query**(`options?`, `conditions?`, `orderBy?`, `orderByDirection?`, `properties?`, `cursor?`, `limit?`): `Promise`\<\{ `entries`: `IAuditableItemGraphVertexList`; `cursor?`: `string`; \}\>
252
364
 
253
365
  Query the graph for vertices.
254
366
 
@@ -290,9 +402,9 @@ Conditions to use in the query.
290
402
 
291
403
  ##### orderBy?
292
404
 
293
- The order for the results, defaults to created.
405
+ `"dateCreated"` \| `"dateModified"`
294
406
 
295
- `"dateCreated"` | `"dateModified"`
407
+ The order for the results, defaults to created.
296
408
 
297
409
  ##### orderByDirection?
298
410
 
@@ -320,10 +432,10 @@ Limit the number of entities to return.
320
432
 
321
433
  #### Returns
322
434
 
323
- `Promise`\<`IAuditableItemGraphVertexList`\>
435
+ `Promise`\<\{ `entries`: `IAuditableItemGraphVertexList`; `cursor?`: `string`; \}\>
324
436
 
325
437
  The entities, which can be partial if a limited keys list was provided.
326
438
 
327
439
  #### Implementation of
328
440
 
329
- `IAuditableItemGraphComponent.query`
441
+ `Omit.query`
package/locales/en.json CHANGED
@@ -1,7 +1 @@
1
- {
2
- "error": {
3
- "auditableItemGraphRestClient": {
4
- "notSupportedOnClient": "The method \"{methodName}\" is not supported on the REST client, it can only be used on a server side component"
5
- }
6
- }
7
- }
1
+ {}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@twin.org/auditable-item-graph-rest-client",
3
- "version": "0.0.3-next.2",
4
- "description": "Auditable Item Graph contract implementation which can connect to REST endpoints",
3
+ "version": "0.0.3-next.21",
4
+ "description": "Provides a client for interacting with auditable graph endpoints over HTTP.",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "git+https://github.com/twinfoundation/auditable-item-graph.git",
7
+ "url": "git+https://github.com/iotaledger/twin-auditable-item-graph.git",
8
8
  "directory": "packages/auditable-item-graph-rest-client"
9
9
  },
10
10
  "author": "martyn.janes@iota.org",
@@ -16,7 +16,7 @@
16
16
  "dependencies": {
17
17
  "@twin.org/api-core": "next",
18
18
  "@twin.org/api-models": "next",
19
- "@twin.org/auditable-item-graph-models": "0.0.3-next.2",
19
+ "@twin.org/auditable-item-graph-models": "0.0.3-next.21",
20
20
  "@twin.org/core": "next",
21
21
  "@twin.org/data-json-ld": "next",
22
22
  "@twin.org/entity": "next",
@@ -49,7 +49,7 @@
49
49
  "auditable-item-graph"
50
50
  ],
51
51
  "bugs": {
52
- "url": "git+https://github.com/twinfoundation/auditable-item-graph/issues"
52
+ "url": "git+https://github.com/iotaledger/twin-auditable-item-graph/issues"
53
53
  },
54
54
  "homepage": "https://twindev.org"
55
55
  }