@twin.org/auditable-item-graph-rest-client 0.0.3-next.8 → 0.9.0-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.
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
+ ```
@@ -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**(`vertex`): `Promise`\<`string`\>
68
68
 
@@ -72,31 +72,9 @@ Create a new graph vertex.
72
72
 
73
73
  ##### vertex
74
74
 
75
- The vertex to create.
76
-
77
- ###### annotationObject?
78
-
79
- `IJsonLdNodeObject`
80
-
81
- The annotation object for the vertex as JSON-LD.
82
-
83
- ###### aliases?
84
-
85
- `object`[]
86
-
87
- Alternative aliases that can be used to identify the vertex.
88
-
89
- ###### resources?
90
-
91
- `object`[]
92
-
93
- The resources attached to the vertex.
94
-
95
- ###### edges?
96
-
97
- `object`[]
75
+ `Omit`\<`IAuditableItemGraphVertex`, `"id"`\>
98
76
 
99
- The edges connected to the vertex.
77
+ The vertex to create.
100
78
 
101
79
  #### Returns
102
80
 
@@ -110,7 +88,7 @@ The id of the new graph item.
110
88
 
111
89
  ***
112
90
 
113
- ### get()
91
+ ### get() {#get}
114
92
 
115
93
  > **get**(`id`, `options?`): `Promise`\<`IAuditableItemGraphVertex`\>
116
94
 
@@ -156,7 +134,7 @@ NotFoundError if the vertex is not found.
156
134
 
157
135
  ***
158
136
 
159
- ### getChangesets()
137
+ ### getChangesets() {#getchangesets}
160
138
 
161
139
  > **getChangesets**(`id`, `cursor?`, `limit?`, `options?`): `Promise`\<\{ `changesets`: `IAuditableItemGraphChangesetList`; `cursor?`: `string`; \}\>
162
140
 
@@ -204,7 +182,7 @@ The changesets if found.
204
182
 
205
183
  ***
206
184
 
207
- ### getChangeset()
185
+ ### getChangeset() {#getchangeset}
208
186
 
209
187
  > **getChangeset**(`id`, `options?`): `Promise`\<`IAuditableItemGraphChangeset`\>
210
188
 
@@ -244,53 +222,109 @@ NotFoundError if the vertex or changeset is not found.
244
222
 
245
223
  ***
246
224
 
247
- ### update()
225
+ ### getVersion() {#getversion}
248
226
 
249
- > **update**(`vertex`): `Promise`\<`void`\>
227
+ > **getVersion**(`id`, `version`): `Promise`\<`IAuditableItemGraphVertex`\>
250
228
 
251
- Update a graph vertex.
229
+ Get a graph vertex at a specific version.
252
230
 
253
231
  #### Parameters
254
232
 
255
- ##### vertex
233
+ ##### id
256
234
 
257
- The vertex to update.
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
+
247
+ `Promise`\<`IAuditableItemGraphVertex`\>
248
+
249
+ The vertex reconstructed at that version.
250
+
251
+ #### Throws
252
+
253
+ NotFoundError if the vertex or version is not found.
254
+
255
+ #### Implementation of
256
+
257
+ `IAuditableItemGraphComponent.getVersion`
258
+
259
+ ***
260
+
261
+ ### getVersions() {#getversions}
262
+
263
+ > **getVersions**(`id`, `options?`): `Promise`\<`IAuditableItemGraphVertexVersionList`\>
264
+
265
+ Get all versions of a graph vertex.
266
+
267
+ #### Parameters
268
+
269
+ ##### id
270
+
271
+ `string`
258
272
 
259
- ###### id
273
+ The id of the vertex.
274
+
275
+ ##### options?
276
+
277
+ Additional options for the operation.
278
+
279
+ ###### after?
260
280
 
261
281
  `string`
262
282
 
263
- The id of the vertex to update.
283
+ Only return versions created after this ISO 8601 timestamp (exclusive).
284
+
285
+ ###### before?
264
286
 
265
- ###### annotationObject?
287
+ `string`
266
288
 
267
- `IJsonLdNodeObject`
289
+ Only return versions created before this ISO 8601 timestamp (exclusive).
268
290
 
269
- The annotation object for the vertex as JSON-LD.
291
+ #### Returns
270
292
 
271
- ###### aliases?
293
+ `Promise`\<`IAuditableItemGraphVertexVersionList`\>
272
294
 
273
- `object`[]
295
+ The list of vertex versions.
274
296
 
275
- Alternative aliases that can be used to identify the vertex.
297
+ #### Throws
276
298
 
277
- ###### resources?
299
+ NotFoundError if the vertex is not found.
278
300
 
279
- `object`[]
301
+ #### Implementation of
280
302
 
281
- The resources attached to the vertex.
303
+ `IAuditableItemGraphComponent.getVersions`
282
304
 
283
- ###### edges?
305
+ ***
284
306
 
285
- `object`[]
307
+ ### update() {#update}
286
308
 
287
- 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.
288
322
 
289
323
  #### Returns
290
324
 
291
325
  `Promise`\<`void`\>
292
326
 
293
- Nothing.
327
+ A promise that resolves when the vertex has been updated.
294
328
 
295
329
  #### Implementation of
296
330
 
@@ -298,37 +332,59 @@ Nothing.
298
332
 
299
333
  ***
300
334
 
301
- ### removeVerifiable()
335
+ ### updatePartial() {#updatepartial}
302
336
 
303
- > **removeVerifiable**(`id`): `Promise`\<`void`\>
337
+ > **updatePartial**(`partial`): `Promise`\<`void`\>
304
338
 
305
- 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 }`).
306
340
 
307
341
  #### Parameters
308
342
 
309
- ##### id
343
+ ##### partial
310
344
 
311
- `string`
345
+ `IAuditableItemGraphPartialVertex`
312
346
 
313
- The id of the vertex to get.
347
+ The partial vertex update (must include `id`).
314
348
 
315
349
  #### Returns
316
350
 
317
351
  `Promise`\<`void`\>
318
352
 
319
- Nothing.
353
+ A promise that resolves when the partial update has been applied.
320
354
 
321
- #### Throws
355
+ #### Implementation of
322
356
 
323
- NotFoundError if the vertex is not found.
357
+ `IAuditableItemGraphComponent.updatePartial`
358
+
359
+ ***
360
+
361
+ ### removeProof() {#removeproof}
362
+
363
+ > **removeProof**(`id`): `Promise`\<`void`\>
364
+
365
+ Remove the notarization proof from all changesets of a graph vertex.
366
+
367
+ #### Parameters
368
+
369
+ ##### id
370
+
371
+ `string`
372
+
373
+ The id of the vertex.
374
+
375
+ #### Returns
376
+
377
+ `Promise`\<`void`\>
378
+
379
+ A promise that resolves when the proof has been removed.
324
380
 
325
381
  #### Implementation of
326
382
 
327
- `IAuditableItemGraphComponent.removeVerifiable`
383
+ `IAuditableItemGraphComponent.removeProof`
328
384
 
329
385
  ***
330
386
 
331
- ### query()
387
+ ### query() {#query}
332
388
 
333
389
  > **query**(`options?`, `conditions?`, `orderBy?`, `orderByDirection?`, `properties?`, `cursor?`, `limit?`): `Promise`\<\{ `entries`: `IAuditableItemGraphVertexList`; `cursor?`: `string`; \}\>
334
390
 
@@ -366,15 +422,15 @@ Include vertices with specific resource types.
366
422
 
367
423
  ##### conditions?
368
424
 
369
- `IComparator`[]
425
+ `EntityCondition`\<`IAuditableItemGraphVertex`\>
370
426
 
371
427
  Conditions to use in the query.
372
428
 
373
429
  ##### orderBy?
374
430
 
375
- The order for the results, defaults to created.
431
+ `"dateCreated"` \| `"dateModified"`
376
432
 
377
- `"dateCreated"` | `"dateModified"`
433
+ The order for the results, defaults to created.
378
434
 
379
435
  ##### orderByDirection?
380
436
 
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.8",
4
- "description": "Auditable Item Graph contract implementation which can connect to REST endpoints",
3
+ "version": "0.9.0-next.2",
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.8",
19
+ "@twin.org/auditable-item-graph-models": "0.9.0-next.2",
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
  }