@twin.org/auditable-item-stream-service 0.0.1-next.8 → 0.0.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.
- package/dist/cjs/index.cjs +510 -305
- package/dist/esm/index.mjs +512 -308
- package/dist/types/auditableItemStreamRoutes.d.ts +9 -1
- package/dist/types/auditableItemStreamService.d.ts +45 -38
- package/dist/types/entities/auditableItemStream.d.ts +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/models/IAuditableItemStreamServiceConstructorOptions.d.ts +29 -0
- package/docs/changelog.md +199 -1
- package/docs/open-api/spec.json +2272 -2123
- package/docs/reference/classes/AuditableItemStream.md +5 -5
- package/docs/reference/classes/AuditableItemStreamEntry.md +3 -3
- package/docs/reference/classes/AuditableItemStreamService.md +233 -95
- package/docs/reference/functions/auditableItemStreamCreate.md +9 -3
- package/docs/reference/functions/auditableItemStreamCreateEntry.md +9 -3
- package/docs/reference/functions/auditableItemStreamDelete.md +31 -0
- package/docs/reference/functions/auditableItemStreamDeleteEntry.md +9 -3
- package/docs/reference/functions/auditableItemStreamGet.md +9 -3
- package/docs/reference/functions/auditableItemStreamGetEntry.md +9 -3
- package/docs/reference/functions/auditableItemStreamGetEntryObject.md +9 -3
- package/docs/reference/functions/auditableItemStreamList.md +9 -3
- package/docs/reference/functions/auditableItemStreamListEntries.md +9 -3
- package/docs/reference/functions/auditableItemStreamListEntryObjects.md +9 -3
- package/docs/reference/functions/auditableItemStreamUpdate.md +9 -3
- package/docs/reference/functions/auditableItemStreamUpdateEntry.md +9 -3
- package/docs/reference/functions/generateRestRoutesAuditableItemStream.md +8 -4
- package/docs/reference/index.md +2 -0
- package/docs/reference/interfaces/IAuditableItemStreamServiceConstructorOptions.md +61 -0
- package/locales/en.json +3 -1
- package/package.json +59 -18
package/dist/esm/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { HttpParameterHelper } from '@twin.org/api-models';
|
|
2
|
-
import { AuditableItemStreamTypes } from '@twin.org/auditable-item-stream-models';
|
|
3
|
-
import { Guards, ComponentFactory, StringHelper, Is, Validation, Converter, RandomHelper,
|
|
2
|
+
import { AuditableItemStreamTypes, AuditableItemStreamContexts, AuditableItemStreamTopics } from '@twin.org/auditable-item-stream-models';
|
|
3
|
+
import { Guards, ComponentFactory, Coerce, StringHelper, Is, Validation, Converter, RandomHelper, ObjectHelper, GeneralError, Urn, NotFoundError } from '@twin.org/core';
|
|
4
|
+
import { SchemaOrgTypes, SchemaOrgContexts, SchemaOrgDataTypes } from '@twin.org/standards-schema-org';
|
|
4
5
|
import { HttpStatusCode, HeaderTypes, MimeTypes } from '@twin.org/web';
|
|
5
6
|
import { JsonLdHelper, JsonLdProcessor, JsonLdTypes } from '@twin.org/data-json-ld';
|
|
6
|
-
import { SchemaOrgDataTypes, SchemaOrgTypes } from '@twin.org/data-schema-org';
|
|
7
7
|
import { SortDirection, LogicalOperator, ComparisonOperator, property, entity, EntitySchemaFactory, EntitySchemaHelper } from '@twin.org/entity';
|
|
8
8
|
import { EntityStorageConnectorFactory } from '@twin.org/entity-storage-models';
|
|
9
|
-
import {
|
|
9
|
+
import { ImmutableProofContexts } from '@twin.org/immutable-proof-models';
|
|
10
10
|
|
|
11
11
|
// Copyright 2024 IOTA Stiftung.
|
|
12
12
|
// SPDX-License-Identifier: Apache-2.0.
|
|
@@ -44,15 +44,15 @@ function generateRestRoutesAuditableItemStream(baseRouteName, componentName) {
|
|
|
44
44
|
id: "auditableItemStreamCreateRequestExample",
|
|
45
45
|
request: {
|
|
46
46
|
body: {
|
|
47
|
-
|
|
48
|
-
"@context": "
|
|
47
|
+
annotationObject: {
|
|
48
|
+
"@context": "https://schema.org",
|
|
49
49
|
"@type": "Note",
|
|
50
50
|
content: "This is a simple note"
|
|
51
51
|
},
|
|
52
52
|
entries: [
|
|
53
53
|
{
|
|
54
54
|
entryObject: {
|
|
55
|
-
"@context": "
|
|
55
|
+
"@context": "https://schema.org",
|
|
56
56
|
"@type": "Event",
|
|
57
57
|
startDate: "2011-04-09T20:00:00Z",
|
|
58
58
|
description: "A description of the event"
|
|
@@ -113,13 +113,16 @@ function generateRestRoutesAuditableItemStream(baseRouteName, componentName) {
|
|
|
113
113
|
id: "auditableItemStreamGetResponseExample",
|
|
114
114
|
response: {
|
|
115
115
|
body: {
|
|
116
|
-
"@context":
|
|
116
|
+
"@context": [
|
|
117
|
+
AuditableItemStreamContexts.ContextRoot,
|
|
118
|
+
AuditableItemStreamContexts.ContextRootCommon
|
|
119
|
+
],
|
|
117
120
|
type: AuditableItemStreamTypes.Stream,
|
|
118
121
|
id: "ais:1234567890",
|
|
119
122
|
dateCreated: "2024-08-22T11:55:16.271Z",
|
|
120
123
|
dateModified: "2024-08-22T11:55:16.271Z",
|
|
121
|
-
|
|
122
|
-
"@context": "
|
|
124
|
+
annotationObject: {
|
|
125
|
+
"@context": "https://schema.org",
|
|
123
126
|
"@type": "Note",
|
|
124
127
|
content: "This is a simple note"
|
|
125
128
|
},
|
|
@@ -129,14 +132,17 @@ function generateRestRoutesAuditableItemStream(baseRouteName, componentName) {
|
|
|
129
132
|
immutableInterval: 10,
|
|
130
133
|
entries: [
|
|
131
134
|
{
|
|
132
|
-
"@context":
|
|
135
|
+
"@context": [
|
|
136
|
+
AuditableItemStreamContexts.ContextRoot,
|
|
137
|
+
AuditableItemStreamContexts.ContextRootCommon
|
|
138
|
+
],
|
|
133
139
|
type: AuditableItemStreamTypes.StreamEntry,
|
|
134
140
|
id: "tst:1234567890",
|
|
135
141
|
dateCreated: "2024-08-22T11:55:16.271Z",
|
|
136
142
|
proofId: "0101010101010101010101010101010101010101010101010101010101010101",
|
|
137
143
|
index: 0,
|
|
138
144
|
entryObject: {
|
|
139
|
-
"@context": "
|
|
145
|
+
"@context": "https://schema.org",
|
|
140
146
|
"@type": "Event",
|
|
141
147
|
startDate: "2011-04-09T20:00:00Z",
|
|
142
148
|
description: "A description of the event"
|
|
@@ -159,13 +165,16 @@ function generateRestRoutesAuditableItemStream(baseRouteName, componentName) {
|
|
|
159
165
|
[HeaderTypes.ContentType]: MimeTypes.JsonLd
|
|
160
166
|
},
|
|
161
167
|
body: {
|
|
162
|
-
"@context":
|
|
168
|
+
"@context": [
|
|
169
|
+
AuditableItemStreamContexts.ContextRoot,
|
|
170
|
+
AuditableItemStreamContexts.ContextRootCommon
|
|
171
|
+
],
|
|
163
172
|
type: AuditableItemStreamTypes.Stream,
|
|
164
173
|
id: "ais:1234567890",
|
|
165
174
|
dateCreated: "2024-08-22T11:55:16.271Z",
|
|
166
175
|
dateModified: "2024-08-22T11:55:16.271Z",
|
|
167
|
-
|
|
168
|
-
"@context": "
|
|
176
|
+
annotationObject: {
|
|
177
|
+
"@context": "https://schema.org",
|
|
169
178
|
"@type": "Note",
|
|
170
179
|
content: "This is a simple note"
|
|
171
180
|
},
|
|
@@ -175,14 +184,17 @@ function generateRestRoutesAuditableItemStream(baseRouteName, componentName) {
|
|
|
175
184
|
immutableInterval: 10,
|
|
176
185
|
entries: [
|
|
177
186
|
{
|
|
178
|
-
"@context":
|
|
187
|
+
"@context": [
|
|
188
|
+
AuditableItemStreamContexts.ContextRoot,
|
|
189
|
+
AuditableItemStreamContexts.ContextRootCommon
|
|
190
|
+
],
|
|
179
191
|
type: AuditableItemStreamTypes.StreamEntry,
|
|
180
192
|
id: "tst:1234567890",
|
|
181
193
|
dateCreated: "2024-08-22T11:55:16.271Z",
|
|
182
194
|
proofId: "0101010101010101010101010101010101010101010101010101010101010101",
|
|
183
195
|
index: 0,
|
|
184
196
|
entryObject: {
|
|
185
|
-
"@context": "
|
|
197
|
+
"@context": "https://schema.org",
|
|
186
198
|
"@type": "Event",
|
|
187
199
|
startDate: "2011-04-09T20:00:00Z",
|
|
188
200
|
description: "A description of the event"
|
|
@@ -216,8 +228,8 @@ function generateRestRoutesAuditableItemStream(baseRouteName, componentName) {
|
|
|
216
228
|
id: "ais:1234567890"
|
|
217
229
|
},
|
|
218
230
|
body: {
|
|
219
|
-
|
|
220
|
-
"@context": "
|
|
231
|
+
annotationObject: {
|
|
232
|
+
"@context": "https://schema.org",
|
|
221
233
|
"@type": "Note",
|
|
222
234
|
content: "This is a simple note"
|
|
223
235
|
}
|
|
@@ -235,6 +247,35 @@ function generateRestRoutesAuditableItemStream(baseRouteName, componentName) {
|
|
|
235
247
|
}
|
|
236
248
|
]
|
|
237
249
|
};
|
|
250
|
+
const deleteRoute = {
|
|
251
|
+
operationId: "auditableItemStreamDelete",
|
|
252
|
+
summary: "Delete a stream",
|
|
253
|
+
tag: tagsAuditableItemStream[0].name,
|
|
254
|
+
method: "DELETE",
|
|
255
|
+
path: `${baseRouteName}/:id`,
|
|
256
|
+
handler: async (httpRequestContext, request) => auditableItemStreamDelete(httpRequestContext, componentName, request),
|
|
257
|
+
requestType: {
|
|
258
|
+
type: "IAuditableItemStreamDeleteRequest",
|
|
259
|
+
examples: [
|
|
260
|
+
{
|
|
261
|
+
id: "auditableItemStreamDeleteRequestExample",
|
|
262
|
+
request: {
|
|
263
|
+
pathParams: {
|
|
264
|
+
id: "ais:1234567890"
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
]
|
|
269
|
+
},
|
|
270
|
+
responseType: [
|
|
271
|
+
{
|
|
272
|
+
type: "INoContentResponse"
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
type: "INotFoundResponse"
|
|
276
|
+
}
|
|
277
|
+
]
|
|
278
|
+
};
|
|
238
279
|
const listRoute = {
|
|
239
280
|
operationId: "auditableItemStreamList",
|
|
240
281
|
summary: "Query streams",
|
|
@@ -259,17 +300,24 @@ function generateRestRoutesAuditableItemStream(baseRouteName, componentName) {
|
|
|
259
300
|
id: "auditableItemStreamListResponseExample",
|
|
260
301
|
response: {
|
|
261
302
|
body: {
|
|
262
|
-
"@context":
|
|
263
|
-
|
|
264
|
-
|
|
303
|
+
"@context": [
|
|
304
|
+
SchemaOrgContexts.ContextRoot,
|
|
305
|
+
AuditableItemStreamContexts.ContextRoot,
|
|
306
|
+
AuditableItemStreamContexts.ContextRootCommon
|
|
307
|
+
],
|
|
308
|
+
type: [SchemaOrgTypes.ItemList, AuditableItemStreamTypes.StreamList],
|
|
309
|
+
[SchemaOrgTypes.ItemListElement]: [
|
|
265
310
|
{
|
|
266
|
-
"@context":
|
|
311
|
+
"@context": [
|
|
312
|
+
AuditableItemStreamContexts.ContextRoot,
|
|
313
|
+
AuditableItemStreamContexts.ContextRootCommon
|
|
314
|
+
],
|
|
267
315
|
type: AuditableItemStreamTypes.Stream,
|
|
268
316
|
id: "ais:1234567890",
|
|
269
317
|
dateCreated: "2024-08-22T11:55:16.271Z",
|
|
270
318
|
dateModified: "2024-08-22T11:55:16.271Z",
|
|
271
|
-
|
|
272
|
-
"@context": "
|
|
319
|
+
annotationObject: {
|
|
320
|
+
"@context": "https://schema.org",
|
|
273
321
|
"@type": "Note",
|
|
274
322
|
content: "This is a simple note"
|
|
275
323
|
},
|
|
@@ -279,7 +327,7 @@ function generateRestRoutesAuditableItemStream(baseRouteName, componentName) {
|
|
|
279
327
|
immutableInterval: 10
|
|
280
328
|
}
|
|
281
329
|
],
|
|
282
|
-
|
|
330
|
+
[SchemaOrgTypes.NextItem]: "1"
|
|
283
331
|
}
|
|
284
332
|
}
|
|
285
333
|
}
|
|
@@ -296,17 +344,24 @@ function generateRestRoutesAuditableItemStream(baseRouteName, componentName) {
|
|
|
296
344
|
[HeaderTypes.ContentType]: MimeTypes.JsonLd
|
|
297
345
|
},
|
|
298
346
|
body: {
|
|
299
|
-
"@context":
|
|
300
|
-
|
|
301
|
-
|
|
347
|
+
"@context": [
|
|
348
|
+
SchemaOrgContexts.ContextRoot,
|
|
349
|
+
AuditableItemStreamContexts.ContextRoot,
|
|
350
|
+
AuditableItemStreamContexts.ContextRootCommon
|
|
351
|
+
],
|
|
352
|
+
type: [SchemaOrgTypes.ItemList, AuditableItemStreamTypes.StreamList],
|
|
353
|
+
[SchemaOrgTypes.ItemListElement]: [
|
|
302
354
|
{
|
|
303
|
-
"@context":
|
|
355
|
+
"@context": [
|
|
356
|
+
AuditableItemStreamContexts.ContextRoot,
|
|
357
|
+
AuditableItemStreamContexts.ContextRootCommon
|
|
358
|
+
],
|
|
304
359
|
type: AuditableItemStreamTypes.Stream,
|
|
305
360
|
id: "ais:1234567890",
|
|
306
361
|
dateCreated: "2024-08-22T11:55:16.271Z",
|
|
307
362
|
dateModified: "2024-08-22T11:55:16.271Z",
|
|
308
|
-
|
|
309
|
-
"@context": "
|
|
363
|
+
annotationObject: {
|
|
364
|
+
"@context": "https://schema.org",
|
|
310
365
|
"@type": "Note",
|
|
311
366
|
content: "This is a simple note"
|
|
312
367
|
},
|
|
@@ -316,7 +371,7 @@ function generateRestRoutesAuditableItemStream(baseRouteName, componentName) {
|
|
|
316
371
|
immutableInterval: 10
|
|
317
372
|
}
|
|
318
373
|
],
|
|
319
|
-
|
|
374
|
+
[SchemaOrgTypes.NextItem]: "1"
|
|
320
375
|
}
|
|
321
376
|
}
|
|
322
377
|
}
|
|
@@ -345,7 +400,7 @@ function generateRestRoutesAuditableItemStream(baseRouteName, componentName) {
|
|
|
345
400
|
},
|
|
346
401
|
body: {
|
|
347
402
|
entryObject: {
|
|
348
|
-
"@context": "
|
|
403
|
+
"@context": "https://schema.org",
|
|
349
404
|
"@type": "Event",
|
|
350
405
|
startDate: "2011-04-09T20:00:00Z",
|
|
351
406
|
description: "A description of the event"
|
|
@@ -381,7 +436,7 @@ function generateRestRoutesAuditableItemStream(baseRouteName, componentName) {
|
|
|
381
436
|
path: `${baseRouteName}/:id/:entryId`,
|
|
382
437
|
handler: async (httpRequestContext, request) => auditableItemStreamDeleteEntry(httpRequestContext, componentName, request),
|
|
383
438
|
requestType: {
|
|
384
|
-
type: "
|
|
439
|
+
type: "IAuditableItemStreamDeleteRequest",
|
|
385
440
|
examples: [
|
|
386
441
|
{
|
|
387
442
|
id: "auditableItemStreamDeleteEntryRequestExample",
|
|
@@ -422,7 +477,7 @@ function generateRestRoutesAuditableItemStream(baseRouteName, componentName) {
|
|
|
422
477
|
},
|
|
423
478
|
body: {
|
|
424
479
|
entryObject: {
|
|
425
|
-
"@context": "
|
|
480
|
+
"@context": "https://schema.org",
|
|
426
481
|
"@type": "Note",
|
|
427
482
|
content: "This is a simple note"
|
|
428
483
|
}
|
|
@@ -469,14 +524,17 @@ function generateRestRoutesAuditableItemStream(baseRouteName, componentName) {
|
|
|
469
524
|
id: "auditableItemStreamGetEntryResponseExample",
|
|
470
525
|
response: {
|
|
471
526
|
body: {
|
|
472
|
-
"@context":
|
|
527
|
+
"@context": [
|
|
528
|
+
AuditableItemStreamContexts.ContextRoot,
|
|
529
|
+
AuditableItemStreamContexts.ContextRootCommon
|
|
530
|
+
],
|
|
473
531
|
type: AuditableItemStreamTypes.StreamEntry,
|
|
474
532
|
id: "tst:1234567890",
|
|
475
533
|
dateCreated: "2024-08-22T11:55:16.271Z",
|
|
476
534
|
proofId: "0101010101010101010101010101010101010101010101010101010101010101",
|
|
477
535
|
index: 0,
|
|
478
536
|
entryObject: {
|
|
479
|
-
"@context": "
|
|
537
|
+
"@context": "https://schema.org",
|
|
480
538
|
"@type": "Event",
|
|
481
539
|
startDate: "2011-04-09T20:00:00Z",
|
|
482
540
|
description: "A description of the event"
|
|
@@ -497,14 +555,17 @@ function generateRestRoutesAuditableItemStream(baseRouteName, componentName) {
|
|
|
497
555
|
[HeaderTypes.ContentType]: MimeTypes.JsonLd
|
|
498
556
|
},
|
|
499
557
|
body: {
|
|
500
|
-
"@context":
|
|
558
|
+
"@context": [
|
|
559
|
+
AuditableItemStreamContexts.ContextRoot,
|
|
560
|
+
AuditableItemStreamContexts.ContextRootCommon
|
|
561
|
+
],
|
|
501
562
|
type: AuditableItemStreamTypes.StreamEntry,
|
|
502
563
|
id: "tst:1234567890",
|
|
503
564
|
dateCreated: "2024-08-22T11:55:16.271Z",
|
|
504
565
|
proofId: "0101010101010101010101010101010101010101010101010101010101010101",
|
|
505
566
|
index: 0,
|
|
506
567
|
entryObject: {
|
|
507
|
-
"@context": "
|
|
568
|
+
"@context": "https://schema.org",
|
|
508
569
|
"@type": "Event",
|
|
509
570
|
startDate: "2011-04-09T20:00:00Z",
|
|
510
571
|
description: "A description of the event"
|
|
@@ -548,7 +609,7 @@ function generateRestRoutesAuditableItemStream(baseRouteName, componentName) {
|
|
|
548
609
|
id: "auditableItemStreamGetEntryObjectResponseExample",
|
|
549
610
|
response: {
|
|
550
611
|
body: {
|
|
551
|
-
"@context": "
|
|
612
|
+
"@context": "https://schema.org",
|
|
552
613
|
"@type": "Event",
|
|
553
614
|
startDate: "2011-04-09T20:00:00Z",
|
|
554
615
|
description: "A description of the event"
|
|
@@ -590,25 +651,32 @@ function generateRestRoutesAuditableItemStream(baseRouteName, componentName) {
|
|
|
590
651
|
id: "auditableItemStreamListEntriesResponseExample",
|
|
591
652
|
response: {
|
|
592
653
|
body: {
|
|
593
|
-
"@context":
|
|
594
|
-
|
|
595
|
-
|
|
654
|
+
"@context": [
|
|
655
|
+
SchemaOrgContexts.ContextRoot,
|
|
656
|
+
AuditableItemStreamContexts.ContextRoot,
|
|
657
|
+
AuditableItemStreamContexts.ContextRootCommon
|
|
658
|
+
],
|
|
659
|
+
type: [SchemaOrgTypes.ItemList, AuditableItemStreamTypes.StreamEntryList],
|
|
660
|
+
[SchemaOrgTypes.ItemListElement]: [
|
|
596
661
|
{
|
|
597
|
-
"@context":
|
|
662
|
+
"@context": [
|
|
663
|
+
AuditableItemStreamContexts.ContextRoot,
|
|
664
|
+
AuditableItemStreamContexts.ContextRootCommon
|
|
665
|
+
],
|
|
598
666
|
type: AuditableItemStreamTypes.StreamEntry,
|
|
599
667
|
id: "tst:1234567890",
|
|
600
668
|
dateCreated: "2024-08-22T11:55:16.271Z",
|
|
601
669
|
proofId: "0101010101010101010101010101010101010101010101010101010101010101",
|
|
602
670
|
index: 0,
|
|
603
671
|
entryObject: {
|
|
604
|
-
"@context": "
|
|
672
|
+
"@context": "https://schema.org",
|
|
605
673
|
"@type": "Event",
|
|
606
674
|
startDate: "2011-04-09T20:00:00Z",
|
|
607
675
|
description: "A description of the event"
|
|
608
676
|
}
|
|
609
677
|
}
|
|
610
678
|
],
|
|
611
|
-
|
|
679
|
+
[SchemaOrgTypes.NextItem]: "1"
|
|
612
680
|
}
|
|
613
681
|
}
|
|
614
682
|
}
|
|
@@ -625,25 +693,32 @@ function generateRestRoutesAuditableItemStream(baseRouteName, componentName) {
|
|
|
625
693
|
[HeaderTypes.ContentType]: MimeTypes.JsonLd
|
|
626
694
|
},
|
|
627
695
|
body: {
|
|
628
|
-
"@context":
|
|
629
|
-
|
|
630
|
-
|
|
696
|
+
"@context": [
|
|
697
|
+
SchemaOrgContexts.ContextRoot,
|
|
698
|
+
AuditableItemStreamContexts.ContextRoot,
|
|
699
|
+
AuditableItemStreamContexts.ContextRootCommon
|
|
700
|
+
],
|
|
701
|
+
type: [SchemaOrgTypes.ItemList, AuditableItemStreamTypes.StreamEntryList],
|
|
702
|
+
[SchemaOrgTypes.ItemListElement]: [
|
|
631
703
|
{
|
|
632
|
-
"@context":
|
|
704
|
+
"@context": [
|
|
705
|
+
AuditableItemStreamContexts.ContextRoot,
|
|
706
|
+
AuditableItemStreamContexts.ContextRootCommon
|
|
707
|
+
],
|
|
633
708
|
type: AuditableItemStreamTypes.StreamEntry,
|
|
634
709
|
id: "tst:1234567890",
|
|
635
710
|
dateCreated: "2024-08-22T11:55:16.271Z",
|
|
636
711
|
proofId: "0101010101010101010101010101010101010101010101010101010101010101",
|
|
637
712
|
index: 0,
|
|
638
713
|
entryObject: {
|
|
639
|
-
"@context": "
|
|
714
|
+
"@context": "https://schema.org",
|
|
640
715
|
"@type": "Event",
|
|
641
716
|
startDate: "2011-04-09T20:00:00Z",
|
|
642
717
|
description: "A description of the event"
|
|
643
718
|
}
|
|
644
719
|
}
|
|
645
720
|
],
|
|
646
|
-
|
|
721
|
+
[SchemaOrgTypes.NextItem]: "1"
|
|
647
722
|
}
|
|
648
723
|
}
|
|
649
724
|
}
|
|
@@ -682,17 +757,21 @@ function generateRestRoutesAuditableItemStream(baseRouteName, componentName) {
|
|
|
682
757
|
id: "auditableItemStreamListEntryObjectsResponseExample",
|
|
683
758
|
response: {
|
|
684
759
|
body: {
|
|
685
|
-
"@context":
|
|
686
|
-
|
|
687
|
-
|
|
760
|
+
"@context": [
|
|
761
|
+
SchemaOrgContexts.ContextRoot,
|
|
762
|
+
AuditableItemStreamContexts.ContextRoot,
|
|
763
|
+
AuditableItemStreamContexts.ContextRootCommon
|
|
764
|
+
],
|
|
765
|
+
type: [SchemaOrgTypes.ItemList, AuditableItemStreamTypes.StreamEntryObjectList],
|
|
766
|
+
[SchemaOrgTypes.ItemListElement]: [
|
|
688
767
|
{
|
|
689
|
-
"@context": "
|
|
768
|
+
"@context": "https://schema.org",
|
|
690
769
|
"@type": "Event",
|
|
691
770
|
startDate: "2011-04-09T20:00:00Z",
|
|
692
771
|
description: "A description of the event"
|
|
693
772
|
}
|
|
694
773
|
],
|
|
695
|
-
|
|
774
|
+
[SchemaOrgTypes.NextItem]: "1"
|
|
696
775
|
}
|
|
697
776
|
}
|
|
698
777
|
}
|
|
@@ -707,6 +786,7 @@ function generateRestRoutesAuditableItemStream(baseRouteName, componentName) {
|
|
|
707
786
|
createRoute,
|
|
708
787
|
getRoute,
|
|
709
788
|
updateRoute,
|
|
789
|
+
deleteRoute,
|
|
710
790
|
listRoute,
|
|
711
791
|
createEntryRoute,
|
|
712
792
|
getEntryRoute,
|
|
@@ -726,8 +806,12 @@ function generateRestRoutesAuditableItemStream(baseRouteName, componentName) {
|
|
|
726
806
|
*/
|
|
727
807
|
async function auditableItemStreamCreate(httpRequestContext, componentName, request) {
|
|
728
808
|
Guards.object(ROUTES_SOURCE, "request", request);
|
|
809
|
+
Guards.object(ROUTES_SOURCE, "request.body", request.body);
|
|
729
810
|
const component = ComponentFactory.get(componentName);
|
|
730
|
-
const id = await component.create(
|
|
811
|
+
const id = await component.create({
|
|
812
|
+
annotationObject: request.body.annotationObject,
|
|
813
|
+
entries: request.body.entries
|
|
814
|
+
}, {
|
|
731
815
|
immutableInterval: request.body?.immutableInterval
|
|
732
816
|
}, httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
|
|
733
817
|
return {
|
|
@@ -751,10 +835,10 @@ async function auditableItemStreamGet(httpRequestContext, componentName, request
|
|
|
751
835
|
const mimeType = request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? "jsonld" : "json";
|
|
752
836
|
const component = ComponentFactory.get(componentName);
|
|
753
837
|
const result = await component.get(request.pathParams.id, {
|
|
754
|
-
includeEntries: request.query?.includeEntries,
|
|
755
|
-
includeDeleted: request.query?.includeDeleted,
|
|
756
|
-
verifyStream: request.query?.verifyStream,
|
|
757
|
-
verifyEntries: request.query?.verifyEntries
|
|
838
|
+
includeEntries: Coerce.boolean(request.query?.includeEntries),
|
|
839
|
+
includeDeleted: Coerce.boolean(request.query?.includeDeleted),
|
|
840
|
+
verifyStream: Coerce.boolean(request.query?.verifyStream),
|
|
841
|
+
verifyEntries: Coerce.boolean(request.query?.verifyEntries)
|
|
758
842
|
});
|
|
759
843
|
return {
|
|
760
844
|
headers: {
|
|
@@ -771,11 +855,32 @@ async function auditableItemStreamGet(httpRequestContext, componentName, request
|
|
|
771
855
|
* @returns The response object with additional http response properties.
|
|
772
856
|
*/
|
|
773
857
|
async function auditableItemStreamUpdate(httpRequestContext, componentName, request) {
|
|
858
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
859
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
860
|
+
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
861
|
+
Guards.object(ROUTES_SOURCE, "request.body", request.body);
|
|
862
|
+
const component = ComponentFactory.get(componentName);
|
|
863
|
+
await component.update({
|
|
864
|
+
id: request.pathParams.id,
|
|
865
|
+
annotationObject: request.body.annotationObject
|
|
866
|
+
}, httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
|
|
867
|
+
return {
|
|
868
|
+
statusCode: HttpStatusCode.noContent
|
|
869
|
+
};
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* Delete the stream.
|
|
873
|
+
* @param httpRequestContext The request context for the API.
|
|
874
|
+
* @param componentName The name of the component to use in the routes.
|
|
875
|
+
* @param request The request.
|
|
876
|
+
* @returns The response object with additional http response properties.
|
|
877
|
+
*/
|
|
878
|
+
async function auditableItemStreamDelete(httpRequestContext, componentName, request) {
|
|
774
879
|
Guards.object(ROUTES_SOURCE, "request", request);
|
|
775
880
|
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
776
881
|
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
777
882
|
const component = ComponentFactory.get(componentName);
|
|
778
|
-
await component.
|
|
883
|
+
await component.remove(request.pathParams.id, httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
|
|
779
884
|
return {
|
|
780
885
|
statusCode: HttpStatusCode.noContent
|
|
781
886
|
};
|
|
@@ -792,7 +897,7 @@ async function auditableItemStreamList(httpRequestContext, componentName, reques
|
|
|
792
897
|
Guards.object(ROUTES_SOURCE, "request.query", request.query);
|
|
793
898
|
const component = ComponentFactory.get(componentName);
|
|
794
899
|
const mimeType = request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? "jsonld" : "json";
|
|
795
|
-
const result = await component.query(HttpParameterHelper.
|
|
900
|
+
const result = await component.query(HttpParameterHelper.objectFromString(request.query?.conditions), request.query?.orderBy, request.query?.orderByDirection, HttpParameterHelper.arrayFromString(request.query?.properties), request.query?.cursor, Coerce.integer(request.query?.pageSize));
|
|
796
901
|
return {
|
|
797
902
|
headers: {
|
|
798
903
|
[HeaderTypes.ContentType]: mimeType === "json" ? MimeTypes.Json : MimeTypes.JsonLd
|
|
@@ -875,7 +980,7 @@ async function auditableItemStreamGetEntry(httpRequestContext, componentName, re
|
|
|
875
980
|
const mimeType = request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? "jsonld" : "json";
|
|
876
981
|
const component = ComponentFactory.get(componentName);
|
|
877
982
|
const result = await component.getEntry(request.pathParams.id, request.pathParams.entryId, {
|
|
878
|
-
verifyEntry: request.query?.verifyEntry
|
|
983
|
+
verifyEntry: Coerce.boolean(request.query?.verifyEntry)
|
|
879
984
|
});
|
|
880
985
|
return {
|
|
881
986
|
headers: {
|
|
@@ -920,11 +1025,11 @@ async function auditableItemStreamListEntries(httpRequestContext, componentName,
|
|
|
920
1025
|
const component = ComponentFactory.get(componentName);
|
|
921
1026
|
const mimeType = request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? "jsonld" : "json";
|
|
922
1027
|
const result = await component.getEntries(request.pathParams.id, {
|
|
923
|
-
conditions: HttpParameterHelper.
|
|
924
|
-
includeDeleted: request.query?.includeDeleted,
|
|
925
|
-
verifyEntries: request.query?.verifyEntries,
|
|
1028
|
+
conditions: HttpParameterHelper.objectFromString(request.query?.conditions),
|
|
1029
|
+
includeDeleted: Coerce.boolean(request.query?.includeDeleted),
|
|
1030
|
+
verifyEntries: Coerce.boolean(request.query?.verifyEntries),
|
|
926
1031
|
order: request.query?.order,
|
|
927
|
-
pageSize: request.query?.pageSize,
|
|
1032
|
+
pageSize: Coerce.integer(request.query?.pageSize),
|
|
928
1033
|
cursor: request.query?.cursor
|
|
929
1034
|
});
|
|
930
1035
|
return {
|
|
@@ -948,10 +1053,10 @@ async function auditableItemStreamListEntryObjects(httpRequestContext, component
|
|
|
948
1053
|
const component = ComponentFactory.get(componentName);
|
|
949
1054
|
const mimeType = request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? "jsonld" : "json";
|
|
950
1055
|
const result = await component.getEntryObjects(request.pathParams.id, {
|
|
951
|
-
conditions: HttpParameterHelper.
|
|
952
|
-
includeDeleted: request.query?.includeDeleted,
|
|
1056
|
+
conditions: HttpParameterHelper.objectFromString(request.query?.conditions),
|
|
1057
|
+
includeDeleted: Coerce.boolean(request.query?.includeDeleted),
|
|
953
1058
|
order: request.query?.order,
|
|
954
|
-
pageSize: request.query?.pageSize,
|
|
1059
|
+
pageSize: Coerce.integer(request.query?.pageSize),
|
|
955
1060
|
cursor: request.query?.cursor
|
|
956
1061
|
});
|
|
957
1062
|
return {
|
|
@@ -1016,6 +1121,11 @@ class AuditableItemStreamService {
|
|
|
1016
1121
|
* @internal
|
|
1017
1122
|
*/
|
|
1018
1123
|
_streamEntryStorage;
|
|
1124
|
+
/**
|
|
1125
|
+
* The event bus component.
|
|
1126
|
+
* @internal
|
|
1127
|
+
*/
|
|
1128
|
+
_eventBusComponent;
|
|
1019
1129
|
/**
|
|
1020
1130
|
* The default interval for the integrity checks.
|
|
1021
1131
|
* @internal
|
|
@@ -1024,24 +1134,24 @@ class AuditableItemStreamService {
|
|
|
1024
1134
|
/**
|
|
1025
1135
|
* Create a new instance of AuditableItemStreamService.
|
|
1026
1136
|
* @param options The dependencies for the auditable item stream connector.
|
|
1027
|
-
* @param options.config The configuration for the connector.
|
|
1028
|
-
* @param options.immutableProofComponentType The immutable proof component type, defaults to "immutable-proof".
|
|
1029
|
-
* @param options.streamEntityStorageType The entity storage for stream, defaults to "auditable-item-stream".
|
|
1030
|
-
* @param options.streamEntryEntityStorageType The entity storage for stream entries, defaults to "auditable-item-stream-entry".
|
|
1031
1137
|
*/
|
|
1032
1138
|
constructor(options) {
|
|
1033
1139
|
this._immutableProofComponent = ComponentFactory.get(options?.immutableProofComponentType ?? "immutable-proof");
|
|
1034
1140
|
this._streamStorage = EntityStorageConnectorFactory.get(options?.streamEntityStorageType ?? StringHelper.kebabCase("AuditableItemStream"));
|
|
1035
1141
|
this._streamEntryStorage = EntityStorageConnectorFactory.get(options?.streamEntryEntityStorageType ??
|
|
1036
1142
|
StringHelper.kebabCase("AuditableItemStreamEntry"));
|
|
1143
|
+
if (Is.stringValue(options?.eventBusComponentType)) {
|
|
1144
|
+
this._eventBusComponent = ComponentFactory.get(options.eventBusComponentType);
|
|
1145
|
+
}
|
|
1037
1146
|
this._config = options?.config ?? {};
|
|
1038
1147
|
this._defaultImmutableInterval = this._config.defaultImmutableInterval ?? 10;
|
|
1039
1148
|
SchemaOrgDataTypes.registerRedirects();
|
|
1040
1149
|
}
|
|
1041
1150
|
/**
|
|
1042
1151
|
* Create a new stream.
|
|
1043
|
-
* @param
|
|
1044
|
-
* @param
|
|
1152
|
+
* @param stream The stream to create.
|
|
1153
|
+
* @param stream.annotationObject The object for the stream as JSON-LD.
|
|
1154
|
+
* @param stream.entries Entries to store in the stream.
|
|
1045
1155
|
* @param options Options for creating the stream.
|
|
1046
1156
|
* @param options.immutableInterval After how many entries do we add immutable checks, defaults to service configured value.
|
|
1047
1157
|
* A value of 0 will disable integrity checks, 1 will be every item, or any other integer for an interval.
|
|
@@ -1049,14 +1159,15 @@ class AuditableItemStreamService {
|
|
|
1049
1159
|
* @param nodeIdentity The node identity to use for vault operations.
|
|
1050
1160
|
* @returns The id of the new stream item.
|
|
1051
1161
|
*/
|
|
1052
|
-
async create(
|
|
1162
|
+
async create(stream, options, userIdentity, nodeIdentity) {
|
|
1163
|
+
Guards.object(this.CLASS_NAME, "stream", stream);
|
|
1053
1164
|
Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
|
|
1054
1165
|
Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
1055
1166
|
try {
|
|
1056
|
-
if (Is.object(
|
|
1167
|
+
if (Is.object(stream.annotationObject)) {
|
|
1057
1168
|
const validationFailures = [];
|
|
1058
|
-
await JsonLdHelper.validate(
|
|
1059
|
-
Validation.asValidationError(this.CLASS_NAME, "
|
|
1169
|
+
await JsonLdHelper.validate(stream.annotationObject, validationFailures);
|
|
1170
|
+
Validation.asValidationError(this.CLASS_NAME, "stream.annotationObject", validationFailures);
|
|
1060
1171
|
}
|
|
1061
1172
|
const id = Converter.bytesToHex(RandomHelper.generate(32), false);
|
|
1062
1173
|
const context = {
|
|
@@ -1075,25 +1186,23 @@ class AuditableItemStreamService {
|
|
|
1075
1186
|
indexCounter: 0,
|
|
1076
1187
|
proofId: ""
|
|
1077
1188
|
};
|
|
1078
|
-
const fullId = new Urn(AuditableItemStreamService.NAMESPACE, id).toString();
|
|
1079
1189
|
// Create the JSON-LD object we want to use for the proof
|
|
1080
1190
|
// this is a subset of fixed properties from the stream object.
|
|
1081
1191
|
const streamModel = await this.streamEntityToJsonLd(ObjectHelper.pick(streamEntity, AuditableItemStreamService._PROOF_KEYS_STREAM));
|
|
1082
|
-
// Use the full id which will appear in the proof
|
|
1083
|
-
streamModel.id = fullId;
|
|
1084
1192
|
// Create the proof for the stream object
|
|
1085
1193
|
streamEntity.proofId = await this._immutableProofComponent.create(streamModel, userIdentity, nodeIdentity);
|
|
1086
|
-
if (Is.arrayValue(entries)) {
|
|
1087
|
-
for (const entry of entries) {
|
|
1194
|
+
if (Is.arrayValue(stream.entries)) {
|
|
1195
|
+
for (const entry of stream.entries) {
|
|
1088
1196
|
await this.setEntry(context, id, entry);
|
|
1089
1197
|
}
|
|
1090
1198
|
}
|
|
1091
1199
|
// Add these dynamic properties to the stream object after the proof has been created.
|
|
1092
1200
|
streamEntity.dateModified = context.now;
|
|
1093
|
-
streamEntity.
|
|
1201
|
+
streamEntity.annotationObject = stream.annotationObject;
|
|
1094
1202
|
streamEntity.indexCounter = context.indexCounter;
|
|
1095
1203
|
await this._streamStorage.set(streamEntity);
|
|
1096
|
-
|
|
1204
|
+
await this._eventBusComponent?.publish(AuditableItemStreamTopics.StreamCreated, { id: streamModel.id });
|
|
1205
|
+
return streamModel.id;
|
|
1097
1206
|
}
|
|
1098
1207
|
catch (error) {
|
|
1099
1208
|
throw new GeneralError(this.CLASS_NAME, "createFailed", undefined, error);
|
|
@@ -1125,20 +1234,21 @@ class AuditableItemStreamService {
|
|
|
1125
1234
|
if (Is.empty(streamEntity)) {
|
|
1126
1235
|
throw new NotFoundError(this.CLASS_NAME, "streamNotFound", id);
|
|
1127
1236
|
}
|
|
1237
|
+
const verifyStream = options?.verifyStream ?? false;
|
|
1238
|
+
const verifyEntries = options?.verifyEntries ?? false;
|
|
1128
1239
|
const streamModel = await this.streamEntityToJsonLd(streamEntity);
|
|
1129
1240
|
if (options?.includeEntries) {
|
|
1130
|
-
const result = await this.findEntries(
|
|
1241
|
+
const result = await this.findEntries(streamId, options?.includeDeleted, verifyEntries);
|
|
1131
1242
|
streamModel.entries = result.entries;
|
|
1132
1243
|
streamModel.cursor = result.cursor;
|
|
1133
1244
|
}
|
|
1134
|
-
if (
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1245
|
+
if (verifyStream && Is.stringValue(streamEntity.proofId)) {
|
|
1246
|
+
streamModel.verification = await this._immutableProofComponent.verify(streamEntity.proofId);
|
|
1247
|
+
}
|
|
1248
|
+
if (verifyStream || verifyEntries) {
|
|
1249
|
+
streamModel["@context"].push(ImmutableProofContexts.ContextRoot);
|
|
1139
1250
|
}
|
|
1140
|
-
|
|
1141
|
-
return compacted;
|
|
1251
|
+
return JsonLdProcessor.compact(streamModel, streamModel["@context"]);
|
|
1142
1252
|
}
|
|
1143
1253
|
catch (error) {
|
|
1144
1254
|
throw new GeneralError(this.CLASS_NAME, "getFailed", undefined, error);
|
|
@@ -1146,44 +1256,79 @@ class AuditableItemStreamService {
|
|
|
1146
1256
|
}
|
|
1147
1257
|
/**
|
|
1148
1258
|
* Update a stream.
|
|
1149
|
-
* @param
|
|
1150
|
-
* @param
|
|
1259
|
+
* @param stream The stream to update.
|
|
1260
|
+
* @param stream.id The id of the stream to update.
|
|
1261
|
+
* @param stream.annotationObject The object for the stream as JSON-LD.
|
|
1151
1262
|
* @param userIdentity The identity to create the auditable item stream operation with.
|
|
1152
1263
|
* @param nodeIdentity The node identity to use for vault operations.
|
|
1153
1264
|
* @returns Nothing.
|
|
1154
1265
|
*/
|
|
1155
|
-
async update(
|
|
1156
|
-
Guards.
|
|
1266
|
+
async update(stream, userIdentity, nodeIdentity) {
|
|
1267
|
+
Guards.object(this.CLASS_NAME, "stream", stream);
|
|
1268
|
+
Guards.stringValue(this.CLASS_NAME, "stream.id", stream.id);
|
|
1157
1269
|
Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
|
|
1158
1270
|
Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
1159
|
-
const urnParsed = Urn.fromValidString(id);
|
|
1271
|
+
const urnParsed = Urn.fromValidString(stream.id);
|
|
1160
1272
|
if (urnParsed.namespaceIdentifier() !== AuditableItemStreamService.NAMESPACE) {
|
|
1161
1273
|
throw new GeneralError(this.CLASS_NAME, "namespaceMismatch", {
|
|
1162
1274
|
namespace: AuditableItemStreamService.NAMESPACE,
|
|
1163
|
-
id
|
|
1275
|
+
id: stream.id
|
|
1164
1276
|
});
|
|
1165
1277
|
}
|
|
1166
1278
|
try {
|
|
1167
1279
|
const streamId = urnParsed.namespaceSpecific(0);
|
|
1168
1280
|
const streamEntity = await this._streamStorage.get(streamId);
|
|
1169
1281
|
if (Is.empty(streamEntity)) {
|
|
1170
|
-
throw new NotFoundError(this.CLASS_NAME, "streamNotFound", id);
|
|
1282
|
+
throw new NotFoundError(this.CLASS_NAME, "streamNotFound", stream.id);
|
|
1171
1283
|
}
|
|
1172
|
-
if (Is.object(
|
|
1284
|
+
if (Is.object(stream.annotationObject)) {
|
|
1173
1285
|
const validationFailures = [];
|
|
1174
|
-
await JsonLdHelper.validate(
|
|
1175
|
-
Validation.asValidationError(this.CLASS_NAME, "
|
|
1286
|
+
await JsonLdHelper.validate(stream.annotationObject, validationFailures);
|
|
1287
|
+
Validation.asValidationError(this.CLASS_NAME, "stream.annotationObject", validationFailures);
|
|
1176
1288
|
}
|
|
1177
|
-
if (!ObjectHelper.equal(streamEntity.
|
|
1178
|
-
streamEntity.
|
|
1289
|
+
if (!ObjectHelper.equal(streamEntity.annotationObject, stream.annotationObject, false)) {
|
|
1290
|
+
streamEntity.annotationObject = stream.annotationObject;
|
|
1179
1291
|
streamEntity.dateModified = new Date(Date.now()).toISOString();
|
|
1180
1292
|
await this._streamStorage.set(streamEntity);
|
|
1293
|
+
await this._eventBusComponent?.publish(AuditableItemStreamTopics.StreamUpdated, { id: stream.id });
|
|
1181
1294
|
}
|
|
1182
1295
|
}
|
|
1183
1296
|
catch (error) {
|
|
1184
1297
|
throw new GeneralError(this.CLASS_NAME, "updateFailed", undefined, error);
|
|
1185
1298
|
}
|
|
1186
1299
|
}
|
|
1300
|
+
/**
|
|
1301
|
+
* Delete the stream.
|
|
1302
|
+
* @param id The id of the stream to remove.
|
|
1303
|
+
* @param userIdentity The identity to create the auditable item stream operation with.
|
|
1304
|
+
* @param nodeIdentity The node identity to use for vault operations.
|
|
1305
|
+
* @returns Nothing.
|
|
1306
|
+
*/
|
|
1307
|
+
async remove(id, userIdentity, nodeIdentity) {
|
|
1308
|
+
Guards.stringValue(this.CLASS_NAME, "id", id);
|
|
1309
|
+
Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
|
|
1310
|
+
Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
1311
|
+
const urnParsed = Urn.fromValidString(id);
|
|
1312
|
+
if (urnParsed.namespaceIdentifier() !== AuditableItemStreamService.NAMESPACE) {
|
|
1313
|
+
throw new GeneralError(this.CLASS_NAME, "namespaceMismatch", {
|
|
1314
|
+
namespace: AuditableItemStreamService.NAMESPACE,
|
|
1315
|
+
id
|
|
1316
|
+
});
|
|
1317
|
+
}
|
|
1318
|
+
try {
|
|
1319
|
+
const streamId = urnParsed.namespaceSpecific(0);
|
|
1320
|
+
const streamEntity = await this._streamStorage.get(streamId);
|
|
1321
|
+
if (Is.empty(streamEntity)) {
|
|
1322
|
+
throw new NotFoundError(this.CLASS_NAME, "streamNotFound", id);
|
|
1323
|
+
}
|
|
1324
|
+
await this.internalRemoveEntries(streamEntity, false, nodeIdentity);
|
|
1325
|
+
await this._streamStorage.remove(streamEntity.id);
|
|
1326
|
+
await this._eventBusComponent?.publish(AuditableItemStreamTopics.StreamDeleted, { id });
|
|
1327
|
+
}
|
|
1328
|
+
catch (error) {
|
|
1329
|
+
throw new GeneralError(this.CLASS_NAME, "removingFailed", undefined, error);
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1187
1332
|
/**
|
|
1188
1333
|
* Query all the streams, will not return entries.
|
|
1189
1334
|
* @param conditions Conditions to use in the query.
|
|
@@ -1200,7 +1345,7 @@ class AuditableItemStreamService {
|
|
|
1200
1345
|
"id",
|
|
1201
1346
|
"dateCreated",
|
|
1202
1347
|
"dateModified",
|
|
1203
|
-
"
|
|
1348
|
+
"annotationObject"
|
|
1204
1349
|
];
|
|
1205
1350
|
const orderProperty = orderBy ?? "dateCreated";
|
|
1206
1351
|
const orderDirection = orderByDirection ?? SortDirection.Descending;
|
|
@@ -1222,13 +1367,16 @@ class AuditableItemStreamService {
|
|
|
1222
1367
|
}
|
|
1223
1368
|
], propertiesToReturn, cursor, pageSize);
|
|
1224
1369
|
const list = {
|
|
1225
|
-
"@context":
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1370
|
+
"@context": [
|
|
1371
|
+
SchemaOrgContexts.ContextRoot,
|
|
1372
|
+
AuditableItemStreamContexts.ContextRoot,
|
|
1373
|
+
AuditableItemStreamContexts.ContextRootCommon
|
|
1374
|
+
],
|
|
1375
|
+
type: [SchemaOrgTypes.ItemList, AuditableItemStreamTypes.StreamList],
|
|
1376
|
+
[SchemaOrgTypes.ItemListElement]: results.entities.map(e => this.streamEntityToJsonLd(e)),
|
|
1377
|
+
[SchemaOrgTypes.NextItem]: results.cursor
|
|
1229
1378
|
};
|
|
1230
|
-
|
|
1231
|
-
return compacted;
|
|
1379
|
+
return JsonLdProcessor.compact(list, list["@context"]);
|
|
1232
1380
|
}
|
|
1233
1381
|
catch (error) {
|
|
1234
1382
|
throw new GeneralError(this.CLASS_NAME, "queryingFailed", undefined, error);
|
|
@@ -1236,28 +1384,28 @@ class AuditableItemStreamService {
|
|
|
1236
1384
|
}
|
|
1237
1385
|
/**
|
|
1238
1386
|
* Create an entry in the stream.
|
|
1239
|
-
* @param
|
|
1387
|
+
* @param streamId The id of the stream to update.
|
|
1240
1388
|
* @param entryObject The object for the stream as JSON-LD.
|
|
1241
1389
|
* @param userIdentity The identity to create the auditable item stream operation with.
|
|
1242
1390
|
* @param nodeIdentity The node identity to use for vault operations.
|
|
1243
1391
|
* @returns The id of the created entry, if not provided.
|
|
1244
1392
|
*/
|
|
1245
|
-
async createEntry(
|
|
1246
|
-
Guards.stringValue(this.CLASS_NAME, "
|
|
1393
|
+
async createEntry(streamId, entryObject, userIdentity, nodeIdentity) {
|
|
1394
|
+
Guards.stringValue(this.CLASS_NAME, "streamId", streamId);
|
|
1247
1395
|
Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
|
|
1248
1396
|
Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
1249
|
-
const urnParsed = Urn.fromValidString(
|
|
1397
|
+
const urnParsed = Urn.fromValidString(streamId);
|
|
1250
1398
|
if (urnParsed.namespaceIdentifier() !== AuditableItemStreamService.NAMESPACE) {
|
|
1251
1399
|
throw new GeneralError(this.CLASS_NAME, "namespaceMismatch", {
|
|
1252
1400
|
namespace: AuditableItemStreamService.NAMESPACE,
|
|
1253
|
-
id
|
|
1401
|
+
id: streamId
|
|
1254
1402
|
});
|
|
1255
1403
|
}
|
|
1256
1404
|
try {
|
|
1257
|
-
const
|
|
1258
|
-
const streamEntity = await this._streamStorage.get(
|
|
1405
|
+
const streamIdParts = urnParsed.namespaceSpecific(0);
|
|
1406
|
+
const streamEntity = await this._streamStorage.get(streamIdParts);
|
|
1259
1407
|
if (Is.empty(streamEntity)) {
|
|
1260
|
-
throw new NotFoundError(this.CLASS_NAME, "streamNotFound",
|
|
1408
|
+
throw new NotFoundError(this.CLASS_NAME, "streamNotFound", streamIdParts);
|
|
1261
1409
|
}
|
|
1262
1410
|
const context = {
|
|
1263
1411
|
now: new Date(Date.now()).toISOString(),
|
|
@@ -1272,7 +1420,12 @@ class AuditableItemStreamService {
|
|
|
1272
1420
|
streamEntity.dateModified = context.now;
|
|
1273
1421
|
streamEntity.indexCounter = context.indexCounter;
|
|
1274
1422
|
await this._streamStorage.set(streamEntity);
|
|
1275
|
-
|
|
1423
|
+
const fullId = new Urn(AuditableItemStreamService.NAMESPACE, [
|
|
1424
|
+
streamEntity.id,
|
|
1425
|
+
createdId
|
|
1426
|
+
]).toString();
|
|
1427
|
+
await this._eventBusComponent?.publish(AuditableItemStreamTopics.StreamEntryCreated, { id: streamId, entryId: fullId });
|
|
1428
|
+
return fullId;
|
|
1276
1429
|
}
|
|
1277
1430
|
catch (error) {
|
|
1278
1431
|
throw new GeneralError(this.CLASS_NAME, "creatingEntryFailed", undefined, error);
|
|
@@ -1280,21 +1433,21 @@ class AuditableItemStreamService {
|
|
|
1280
1433
|
}
|
|
1281
1434
|
/**
|
|
1282
1435
|
* Get the entry from the stream.
|
|
1283
|
-
* @param
|
|
1436
|
+
* @param streamId The id of the stream to get.
|
|
1284
1437
|
* @param entryId The id of the stream entry to get.
|
|
1285
1438
|
* @param options Additional options for the get operation.
|
|
1286
1439
|
* @param options.verifyEntry Should the entry be verified, defaults to false.
|
|
1287
1440
|
* @returns The stream and entries if found.
|
|
1288
1441
|
* @throws NotFoundError if the stream is not found.
|
|
1289
1442
|
*/
|
|
1290
|
-
async getEntry(
|
|
1291
|
-
Guards.stringValue(this.CLASS_NAME, "
|
|
1443
|
+
async getEntry(streamId, entryId, options) {
|
|
1444
|
+
Guards.stringValue(this.CLASS_NAME, "streamId", streamId);
|
|
1292
1445
|
Guards.stringValue(this.CLASS_NAME, "entryId", entryId);
|
|
1293
|
-
const urnParsed = Urn.fromValidString(
|
|
1446
|
+
const urnParsed = Urn.fromValidString(streamId);
|
|
1294
1447
|
if (urnParsed.namespaceIdentifier() !== AuditableItemStreamService.NAMESPACE) {
|
|
1295
1448
|
throw new GeneralError(this.CLASS_NAME, "namespaceMismatch", {
|
|
1296
1449
|
namespace: AuditableItemStreamService.NAMESPACE,
|
|
1297
|
-
id
|
|
1450
|
+
id: streamId
|
|
1298
1451
|
});
|
|
1299
1452
|
}
|
|
1300
1453
|
const urnParsedEntry = Urn.fromValidString(entryId);
|
|
@@ -1308,16 +1461,20 @@ class AuditableItemStreamService {
|
|
|
1308
1461
|
const streamNamespaceId = urnParsed.namespaceSpecific(0);
|
|
1309
1462
|
const streamEntity = await this._streamStorage.get(streamNamespaceId);
|
|
1310
1463
|
if (Is.empty(streamEntity)) {
|
|
1311
|
-
throw new NotFoundError(this.CLASS_NAME, "streamNotFound",
|
|
1464
|
+
throw new NotFoundError(this.CLASS_NAME, "streamNotFound", streamId);
|
|
1312
1465
|
}
|
|
1466
|
+
const verifyEntry = options?.verifyEntry ?? false;
|
|
1313
1467
|
const entryNamespaceId = urnParsedEntry.namespaceSpecific(1);
|
|
1314
|
-
const result = await this.findEntry(streamEntity.nodeIdentity, streamEntity.id, entryNamespaceId,
|
|
1468
|
+
const result = await this.findEntry(streamEntity.nodeIdentity, streamEntity.id, entryNamespaceId, verifyEntry);
|
|
1315
1469
|
if (Is.empty(result)) {
|
|
1316
1470
|
throw new NotFoundError(this.CLASS_NAME, "streamEntryNotFound", entryId);
|
|
1317
1471
|
}
|
|
1318
1472
|
const entry = this.streamEntryEntityToJsonLd(result.entity);
|
|
1319
|
-
|
|
1320
|
-
|
|
1473
|
+
if (verifyEntry) {
|
|
1474
|
+
entry["@context"].push(ImmutableProofContexts.ContextRoot);
|
|
1475
|
+
entry.verification = result.verification;
|
|
1476
|
+
}
|
|
1477
|
+
return JsonLdProcessor.compact(entry, entry["@context"]);
|
|
1321
1478
|
}
|
|
1322
1479
|
catch (error) {
|
|
1323
1480
|
throw new GeneralError(this.CLASS_NAME, "gettingEntryFailed", undefined, error);
|
|
@@ -1325,19 +1482,19 @@ class AuditableItemStreamService {
|
|
|
1325
1482
|
}
|
|
1326
1483
|
/**
|
|
1327
1484
|
* Get the entry object from the stream.
|
|
1328
|
-
* @param
|
|
1485
|
+
* @param streamId The id of the stream to get.
|
|
1329
1486
|
* @param entryId The id of the stream entry to get.
|
|
1330
1487
|
* @returns The stream and entries if found.
|
|
1331
1488
|
* @throws NotFoundError if the stream is not found.
|
|
1332
1489
|
*/
|
|
1333
|
-
async getEntryObject(
|
|
1334
|
-
Guards.stringValue(this.CLASS_NAME, "
|
|
1490
|
+
async getEntryObject(streamId, entryId) {
|
|
1491
|
+
Guards.stringValue(this.CLASS_NAME, "streamId", streamId);
|
|
1335
1492
|
Guards.stringValue(this.CLASS_NAME, "entryId", entryId);
|
|
1336
|
-
const urnParsed = Urn.fromValidString(
|
|
1493
|
+
const urnParsed = Urn.fromValidString(streamId);
|
|
1337
1494
|
if (urnParsed.namespaceIdentifier() !== AuditableItemStreamService.NAMESPACE) {
|
|
1338
1495
|
throw new GeneralError(this.CLASS_NAME, "namespaceMismatch", {
|
|
1339
1496
|
namespace: AuditableItemStreamService.NAMESPACE,
|
|
1340
|
-
id
|
|
1497
|
+
id: streamId
|
|
1341
1498
|
});
|
|
1342
1499
|
}
|
|
1343
1500
|
const urnParsedEntry = Urn.fromValidString(entryId);
|
|
@@ -1351,7 +1508,7 @@ class AuditableItemStreamService {
|
|
|
1351
1508
|
const streamNamespaceId = urnParsed.namespaceSpecific(0);
|
|
1352
1509
|
const streamEntity = await this._streamStorage.get(streamNamespaceId);
|
|
1353
1510
|
if (Is.empty(streamEntity)) {
|
|
1354
|
-
throw new NotFoundError(this.CLASS_NAME, "streamNotFound",
|
|
1511
|
+
throw new NotFoundError(this.CLASS_NAME, "streamNotFound", streamId);
|
|
1355
1512
|
}
|
|
1356
1513
|
const entryNamespaceId = urnParsedEntry.namespaceSpecific(1);
|
|
1357
1514
|
const result = await this.findEntry(streamEntity.nodeIdentity, streamEntity.id, entryNamespaceId);
|
|
@@ -1366,23 +1523,23 @@ class AuditableItemStreamService {
|
|
|
1366
1523
|
}
|
|
1367
1524
|
/**
|
|
1368
1525
|
* Update an entry in the stream.
|
|
1369
|
-
* @param
|
|
1526
|
+
* @param streamId The id of the stream to update.
|
|
1370
1527
|
* @param entryId The id of the entry to update.
|
|
1371
1528
|
* @param entryObject The object for the entry as JSON-LD.
|
|
1372
1529
|
* @param userIdentity The identity to create the auditable item stream operation with.
|
|
1373
1530
|
* @param nodeIdentity The node identity to use for vault operations.
|
|
1374
1531
|
* @returns Nothing.
|
|
1375
1532
|
*/
|
|
1376
|
-
async updateEntry(
|
|
1377
|
-
Guards.stringValue(this.CLASS_NAME, "
|
|
1533
|
+
async updateEntry(streamId, entryId, entryObject, userIdentity, nodeIdentity) {
|
|
1534
|
+
Guards.stringValue(this.CLASS_NAME, "streamId", streamId);
|
|
1378
1535
|
Guards.stringValue(this.CLASS_NAME, "entryId", entryId);
|
|
1379
1536
|
Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
|
|
1380
1537
|
Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
1381
|
-
const urnParsed = Urn.fromValidString(
|
|
1538
|
+
const urnParsed = Urn.fromValidString(streamId);
|
|
1382
1539
|
if (urnParsed.namespaceIdentifier() !== AuditableItemStreamService.NAMESPACE) {
|
|
1383
1540
|
throw new GeneralError(this.CLASS_NAME, "namespaceMismatch", {
|
|
1384
1541
|
namespace: AuditableItemStreamService.NAMESPACE,
|
|
1385
|
-
id
|
|
1542
|
+
id: streamId
|
|
1386
1543
|
});
|
|
1387
1544
|
}
|
|
1388
1545
|
const urnParsedEntry = Urn.fromValidString(entryId);
|
|
@@ -1393,10 +1550,17 @@ class AuditableItemStreamService {
|
|
|
1393
1550
|
});
|
|
1394
1551
|
}
|
|
1395
1552
|
try {
|
|
1396
|
-
const streamNamespaceId = urnParsed.
|
|
1553
|
+
const streamNamespaceId = urnParsed.namespaceMethod();
|
|
1554
|
+
const streamEntryNamespaceId = urnParsedEntry.namespaceMethod();
|
|
1555
|
+
if (streamNamespaceId !== streamEntryNamespaceId) {
|
|
1556
|
+
throw new GeneralError(this.CLASS_NAME, "namespaceMismatch", {
|
|
1557
|
+
streamNamespaceId,
|
|
1558
|
+
streamEntryNamespaceId
|
|
1559
|
+
});
|
|
1560
|
+
}
|
|
1397
1561
|
const streamEntity = await this._streamStorage.get(streamNamespaceId);
|
|
1398
1562
|
if (Is.empty(streamEntity)) {
|
|
1399
|
-
throw new NotFoundError(this.CLASS_NAME, "streamNotFound",
|
|
1563
|
+
throw new NotFoundError(this.CLASS_NAME, "streamNotFound", streamId);
|
|
1400
1564
|
}
|
|
1401
1565
|
const entryNamespaceId = urnParsedEntry.namespaceSpecific(1);
|
|
1402
1566
|
const existing = await this.findEntry(nodeIdentity, streamEntity.id, entryNamespaceId);
|
|
@@ -1411,12 +1575,13 @@ class AuditableItemStreamService {
|
|
|
1411
1575
|
immutableInterval: streamEntity.immutableInterval
|
|
1412
1576
|
};
|
|
1413
1577
|
await this.setEntry(context, streamEntity.id, {
|
|
1414
|
-
...existing,
|
|
1578
|
+
...existing.entity,
|
|
1415
1579
|
entryObject
|
|
1416
1580
|
});
|
|
1417
1581
|
streamEntity.dateModified = context.now;
|
|
1418
1582
|
streamEntity.indexCounter = context.indexCounter;
|
|
1419
1583
|
await this._streamStorage.set(streamEntity);
|
|
1584
|
+
await this._eventBusComponent?.publish(AuditableItemStreamTopics.StreamEntryUpdated, { id: streamId, entryId });
|
|
1420
1585
|
}
|
|
1421
1586
|
catch (error) {
|
|
1422
1587
|
throw new GeneralError(this.CLASS_NAME, "updatingEntryFailed", undefined, error);
|
|
@@ -1424,22 +1589,22 @@ class AuditableItemStreamService {
|
|
|
1424
1589
|
}
|
|
1425
1590
|
/**
|
|
1426
1591
|
* Delete from the stream.
|
|
1427
|
-
* @param
|
|
1428
|
-
* @param entryId The id of the entry to
|
|
1592
|
+
* @param streamId The id of the stream to remove from.
|
|
1593
|
+
* @param entryId The id of the entry to remove.
|
|
1429
1594
|
* @param userIdentity The identity to create the auditable item stream operation with.
|
|
1430
1595
|
* @param nodeIdentity The node identity to use for vault operations.
|
|
1431
1596
|
* @returns Nothing.
|
|
1432
1597
|
*/
|
|
1433
|
-
async removeEntry(
|
|
1434
|
-
Guards.stringValue(this.CLASS_NAME, "
|
|
1598
|
+
async removeEntry(streamId, entryId, userIdentity, nodeIdentity) {
|
|
1599
|
+
Guards.stringValue(this.CLASS_NAME, "streamId", streamId);
|
|
1435
1600
|
Guards.stringValue(this.CLASS_NAME, "entryId", entryId);
|
|
1436
1601
|
Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
|
|
1437
1602
|
Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
1438
|
-
const urnParsed = Urn.fromValidString(
|
|
1603
|
+
const urnParsed = Urn.fromValidString(streamId);
|
|
1439
1604
|
if (urnParsed.namespaceIdentifier() !== AuditableItemStreamService.NAMESPACE) {
|
|
1440
1605
|
throw new GeneralError(this.CLASS_NAME, "namespaceMismatch", {
|
|
1441
1606
|
namespace: AuditableItemStreamService.NAMESPACE,
|
|
1442
|
-
id
|
|
1607
|
+
id: streamId
|
|
1443
1608
|
});
|
|
1444
1609
|
}
|
|
1445
1610
|
const urnParsedEntry = Urn.fromValidString(entryId);
|
|
@@ -1450,10 +1615,17 @@ class AuditableItemStreamService {
|
|
|
1450
1615
|
});
|
|
1451
1616
|
}
|
|
1452
1617
|
try {
|
|
1453
|
-
const streamNamespaceId = urnParsed.
|
|
1618
|
+
const streamNamespaceId = urnParsed.namespaceMethod();
|
|
1619
|
+
const streamEntryNamespaceId = urnParsedEntry.namespaceMethod();
|
|
1620
|
+
if (streamNamespaceId !== streamEntryNamespaceId) {
|
|
1621
|
+
throw new GeneralError(this.CLASS_NAME, "namespaceMismatch", {
|
|
1622
|
+
streamNamespaceId,
|
|
1623
|
+
streamEntryNamespaceId
|
|
1624
|
+
});
|
|
1625
|
+
}
|
|
1454
1626
|
const streamEntity = await this._streamStorage.get(streamNamespaceId);
|
|
1455
1627
|
if (Is.empty(streamEntity)) {
|
|
1456
|
-
throw new NotFoundError(this.CLASS_NAME, "streamNotFound",
|
|
1628
|
+
throw new NotFoundError(this.CLASS_NAME, "streamNotFound", streamId);
|
|
1457
1629
|
}
|
|
1458
1630
|
const entryNamespaceId = urnParsedEntry.namespaceSpecific(1);
|
|
1459
1631
|
const result = await this.findEntry(streamEntity.nodeIdentity, streamNamespaceId, entryNamespaceId);
|
|
@@ -1475,6 +1647,7 @@ class AuditableItemStreamService {
|
|
|
1475
1647
|
streamEntity.dateModified = context.now;
|
|
1476
1648
|
streamEntity.indexCounter = context.indexCounter;
|
|
1477
1649
|
await this._streamStorage.set(streamEntity);
|
|
1650
|
+
await this._eventBusComponent?.publish(AuditableItemStreamTopics.StreamEntryDeleted, { id: streamId, entryId });
|
|
1478
1651
|
}
|
|
1479
1652
|
}
|
|
1480
1653
|
catch (error) {
|
|
@@ -1483,7 +1656,7 @@ class AuditableItemStreamService {
|
|
|
1483
1656
|
}
|
|
1484
1657
|
/**
|
|
1485
1658
|
* Get the entries for the stream.
|
|
1486
|
-
* @param
|
|
1659
|
+
* @param streamId The id of the stream to get.
|
|
1487
1660
|
* @param options Additional options for the get operation.
|
|
1488
1661
|
* @param options.conditions The conditions to filter the stream.
|
|
1489
1662
|
* @param options.includeDeleted Whether to include deleted entries, defaults to false.
|
|
@@ -1494,34 +1667,37 @@ class AuditableItemStreamService {
|
|
|
1494
1667
|
* @returns The stream and entries if found.
|
|
1495
1668
|
* @throws NotFoundError if the stream is not found.
|
|
1496
1669
|
*/
|
|
1497
|
-
async getEntries(
|
|
1498
|
-
Guards.stringValue(this.CLASS_NAME, "
|
|
1499
|
-
const urnParsed = Urn.fromValidString(
|
|
1670
|
+
async getEntries(streamId, options) {
|
|
1671
|
+
Guards.stringValue(this.CLASS_NAME, "streamId", streamId);
|
|
1672
|
+
const urnParsed = Urn.fromValidString(streamId);
|
|
1500
1673
|
if (urnParsed.namespaceIdentifier() !== AuditableItemStreamService.NAMESPACE) {
|
|
1501
1674
|
throw new GeneralError(this.CLASS_NAME, "namespaceMismatch", {
|
|
1502
1675
|
namespace: AuditableItemStreamService.NAMESPACE,
|
|
1503
|
-
id
|
|
1676
|
+
id: streamId
|
|
1504
1677
|
});
|
|
1505
1678
|
}
|
|
1506
1679
|
try {
|
|
1507
1680
|
const streamNamespaceId = urnParsed.namespaceSpecific(0);
|
|
1508
1681
|
const streamEntity = await this._streamStorage.get(streamNamespaceId);
|
|
1509
1682
|
if (Is.empty(streamEntity)) {
|
|
1510
|
-
throw new NotFoundError(this.CLASS_NAME, "streamNotFound",
|
|
1683
|
+
throw new NotFoundError(this.CLASS_NAME, "streamNotFound", streamId);
|
|
1511
1684
|
}
|
|
1512
|
-
const
|
|
1685
|
+
const verifyEntries = options?.verifyEntries ?? false;
|
|
1686
|
+
const result = await this.findEntries(streamNamespaceId, options?.includeDeleted, verifyEntries, options?.conditions, options?.order, undefined, options?.pageSize, options?.cursor);
|
|
1513
1687
|
const list = {
|
|
1514
1688
|
"@context": [
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1689
|
+
SchemaOrgContexts.ContextRoot,
|
|
1690
|
+
AuditableItemStreamContexts.ContextRoot,
|
|
1691
|
+
AuditableItemStreamContexts.ContextRootCommon
|
|
1518
1692
|
],
|
|
1519
|
-
type: AuditableItemStreamTypes.StreamEntryList,
|
|
1520
|
-
|
|
1521
|
-
|
|
1693
|
+
type: [SchemaOrgTypes.ItemList, AuditableItemStreamTypes.StreamEntryList],
|
|
1694
|
+
[SchemaOrgTypes.ItemListElement]: result.entries,
|
|
1695
|
+
[SchemaOrgTypes.NextItem]: result.cursor
|
|
1522
1696
|
};
|
|
1523
|
-
|
|
1524
|
-
|
|
1697
|
+
if (verifyEntries) {
|
|
1698
|
+
list["@context"].push(ImmutableProofContexts.ContextRoot);
|
|
1699
|
+
}
|
|
1700
|
+
return JsonLdProcessor.compact(list, list["@context"]);
|
|
1525
1701
|
}
|
|
1526
1702
|
catch (error) {
|
|
1527
1703
|
throw new GeneralError(this.CLASS_NAME, "gettingEntriesFailed", undefined, error);
|
|
@@ -1529,7 +1705,7 @@ class AuditableItemStreamService {
|
|
|
1529
1705
|
}
|
|
1530
1706
|
/**
|
|
1531
1707
|
* Get the entry objects for the stream.
|
|
1532
|
-
* @param
|
|
1708
|
+
* @param streamId The id of the stream to get.
|
|
1533
1709
|
* @param options Additional options for the get operation.
|
|
1534
1710
|
* @param options.conditions The conditions to filter the stream.
|
|
1535
1711
|
* @param options.includeDeleted Whether to include deleted entries, defaults to false.
|
|
@@ -1539,86 +1715,65 @@ class AuditableItemStreamService {
|
|
|
1539
1715
|
* @returns The stream and entries if found.
|
|
1540
1716
|
* @throws NotFoundError if the stream is not found.
|
|
1541
1717
|
*/
|
|
1542
|
-
async getEntryObjects(
|
|
1543
|
-
Guards.stringValue(this.CLASS_NAME, "
|
|
1544
|
-
const urnParsed = Urn.fromValidString(
|
|
1718
|
+
async getEntryObjects(streamId, options) {
|
|
1719
|
+
Guards.stringValue(this.CLASS_NAME, "streamId", streamId);
|
|
1720
|
+
const urnParsed = Urn.fromValidString(streamId);
|
|
1545
1721
|
if (urnParsed.namespaceIdentifier() !== AuditableItemStreamService.NAMESPACE) {
|
|
1546
1722
|
throw new GeneralError(this.CLASS_NAME, "namespaceMismatch", {
|
|
1547
1723
|
namespace: AuditableItemStreamService.NAMESPACE,
|
|
1548
|
-
id
|
|
1724
|
+
id: streamId
|
|
1549
1725
|
});
|
|
1550
1726
|
}
|
|
1551
1727
|
try {
|
|
1552
1728
|
const streamNamespaceId = urnParsed.namespaceSpecific(0);
|
|
1553
1729
|
const streamEntity = await this._streamStorage.get(streamNamespaceId);
|
|
1554
1730
|
if (Is.empty(streamEntity)) {
|
|
1555
|
-
throw new NotFoundError(this.CLASS_NAME, "streamNotFound",
|
|
1731
|
+
throw new NotFoundError(this.CLASS_NAME, "streamNotFound", streamId);
|
|
1556
1732
|
}
|
|
1557
|
-
const result = await this.findEntries(
|
|
1733
|
+
const result = await this.findEntries(streamNamespaceId, options?.includeDeleted, false, options?.conditions, options?.order, undefined, options?.pageSize, options?.cursor);
|
|
1558
1734
|
const list = {
|
|
1559
|
-
"@context":
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1735
|
+
"@context": [
|
|
1736
|
+
SchemaOrgContexts.ContextRoot,
|
|
1737
|
+
AuditableItemStreamContexts.ContextRoot,
|
|
1738
|
+
AuditableItemStreamContexts.ContextRootCommon
|
|
1739
|
+
],
|
|
1740
|
+
type: [SchemaOrgTypes.ItemList, AuditableItemStreamTypes.StreamEntryObjectList],
|
|
1741
|
+
[SchemaOrgTypes.ItemListElement]: result.entries.map(m => m.entryObject),
|
|
1742
|
+
[SchemaOrgTypes.NextItem]: result.cursor
|
|
1563
1743
|
};
|
|
1564
|
-
|
|
1565
|
-
return compacted;
|
|
1744
|
+
return JsonLdProcessor.compact(list, list["@context"]);
|
|
1566
1745
|
}
|
|
1567
1746
|
catch (error) {
|
|
1568
1747
|
throw new GeneralError(this.CLASS_NAME, "gettingEntryObjectsFailed", undefined, error);
|
|
1569
1748
|
}
|
|
1570
1749
|
}
|
|
1571
1750
|
/**
|
|
1572
|
-
* Remove the
|
|
1573
|
-
* @param
|
|
1751
|
+
* Remove the verifiable storage for the stream and entries.
|
|
1752
|
+
* @param streamId The id of the stream to remove the storage from.
|
|
1574
1753
|
* @param nodeIdentity The node identity to use for vault operations.
|
|
1575
1754
|
* @returns Nothing.
|
|
1576
1755
|
* @throws NotFoundError if the vertex is not found.
|
|
1577
1756
|
*/
|
|
1578
|
-
async
|
|
1579
|
-
Guards.stringValue(this.CLASS_NAME, "
|
|
1757
|
+
async removeVerifiable(streamId, nodeIdentity) {
|
|
1758
|
+
Guards.stringValue(this.CLASS_NAME, "streamId", streamId);
|
|
1580
1759
|
Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
1581
|
-
const urnParsed = Urn.fromValidString(
|
|
1760
|
+
const urnParsed = Urn.fromValidString(streamId);
|
|
1582
1761
|
if (urnParsed.namespaceIdentifier() !== AuditableItemStreamService.NAMESPACE) {
|
|
1583
1762
|
throw new GeneralError(this.CLASS_NAME, "namespaceMismatch", {
|
|
1584
1763
|
namespace: AuditableItemStreamService.NAMESPACE,
|
|
1585
|
-
id
|
|
1764
|
+
id: streamId
|
|
1586
1765
|
});
|
|
1587
1766
|
}
|
|
1588
1767
|
try {
|
|
1589
|
-
const
|
|
1590
|
-
const streamEntity = await this._streamStorage.get(
|
|
1768
|
+
const streamIdParts = urnParsed.namespaceSpecific(0);
|
|
1769
|
+
const streamEntity = await this._streamStorage.get(streamIdParts);
|
|
1591
1770
|
if (Is.empty(streamEntity)) {
|
|
1592
|
-
throw new NotFoundError(this.CLASS_NAME, "streamNotFound",
|
|
1593
|
-
}
|
|
1594
|
-
if (Is.stringValue(streamEntity.proofId)) {
|
|
1595
|
-
await this._immutableProofComponent.removeImmutable(streamEntity.proofId, nodeIdentity);
|
|
1596
|
-
delete streamEntity.proofId;
|
|
1597
|
-
await this._streamStorage.set(streamEntity);
|
|
1771
|
+
throw new NotFoundError(this.CLASS_NAME, "streamNotFound", streamIdParts);
|
|
1598
1772
|
}
|
|
1599
|
-
|
|
1600
|
-
do {
|
|
1601
|
-
entriesResult = await this._streamEntryStorage.query({
|
|
1602
|
-
property: "streamId",
|
|
1603
|
-
value: streamId,
|
|
1604
|
-
comparison: ComparisonOperator.Equals
|
|
1605
|
-
}, [
|
|
1606
|
-
{
|
|
1607
|
-
property: "dateCreated",
|
|
1608
|
-
sortDirection: SortDirection.Ascending
|
|
1609
|
-
}
|
|
1610
|
-
], undefined, entriesResult?.cursor);
|
|
1611
|
-
for (const streamEntry of entriesResult.entities) {
|
|
1612
|
-
if (Is.stringValue(streamEntry.proofId)) {
|
|
1613
|
-
await this._immutableProofComponent.removeImmutable(nodeIdentity, streamEntry.proofId);
|
|
1614
|
-
delete streamEntry.proofId;
|
|
1615
|
-
await this._streamEntryStorage.set(streamEntry);
|
|
1616
|
-
}
|
|
1617
|
-
}
|
|
1618
|
-
} while (Is.stringValue(entriesResult.cursor));
|
|
1773
|
+
await this.internalRemoveEntries(streamEntity, true, nodeIdentity);
|
|
1619
1774
|
}
|
|
1620
1775
|
catch (error) {
|
|
1621
|
-
throw new GeneralError(this.CLASS_NAME, "
|
|
1776
|
+
throw new GeneralError(this.CLASS_NAME, "removeVerifiableFailed", undefined, error);
|
|
1622
1777
|
}
|
|
1623
1778
|
}
|
|
1624
1779
|
/**
|
|
@@ -1630,17 +1785,17 @@ class AuditableItemStreamService {
|
|
|
1630
1785
|
streamEntityToJsonLd(streamEntity) {
|
|
1631
1786
|
const model = {
|
|
1632
1787
|
"@context": [
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1788
|
+
AuditableItemStreamContexts.ContextRoot,
|
|
1789
|
+
AuditableItemStreamContexts.ContextRootCommon,
|
|
1790
|
+
SchemaOrgContexts.ContextRoot
|
|
1636
1791
|
],
|
|
1637
1792
|
type: AuditableItemStreamTypes.Stream,
|
|
1638
|
-
id: streamEntity.id
|
|
1793
|
+
id: `${AuditableItemStreamService.NAMESPACE}:${streamEntity.id}`,
|
|
1639
1794
|
dateCreated: streamEntity.dateCreated,
|
|
1640
1795
|
dateModified: streamEntity.dateModified,
|
|
1641
1796
|
nodeIdentity: streamEntity.nodeIdentity,
|
|
1642
1797
|
userIdentity: streamEntity.userIdentity,
|
|
1643
|
-
|
|
1798
|
+
annotationObject: streamEntity.annotationObject,
|
|
1644
1799
|
immutableInterval: streamEntity.immutableInterval,
|
|
1645
1800
|
proofId: streamEntity.proofId
|
|
1646
1801
|
};
|
|
@@ -1655,9 +1810,9 @@ class AuditableItemStreamService {
|
|
|
1655
1810
|
streamEntryEntityToJsonLd(streamEntryEntity) {
|
|
1656
1811
|
const streamEntryModel = {
|
|
1657
1812
|
"@context": [
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1813
|
+
AuditableItemStreamContexts.ContextRoot,
|
|
1814
|
+
AuditableItemStreamContexts.ContextRootCommon,
|
|
1815
|
+
SchemaOrgContexts.ContextRoot
|
|
1661
1816
|
],
|
|
1662
1817
|
type: AuditableItemStreamTypes.StreamEntry,
|
|
1663
1818
|
id: `${AuditableItemStreamService.NAMESPACE}:${streamEntryEntity.streamId}:${streamEntryEntity.id}`,
|
|
@@ -1743,10 +1898,7 @@ class AuditableItemStreamService {
|
|
|
1743
1898
|
const entity = result.entities[0];
|
|
1744
1899
|
let verification;
|
|
1745
1900
|
if ((verifyEntry ?? false) && Is.stringValue(entity.proofId)) {
|
|
1746
|
-
|
|
1747
|
-
// this is a subset of fixed properties from the stream entry object.
|
|
1748
|
-
const streamEntryModel = await this.streamEntryEntityToJsonLd(ObjectHelper.pick(entity, AuditableItemStreamService._PROOF_KEYS_STREAM_ENTRY));
|
|
1749
|
-
verification = await this._immutableProofComponent.verify(entity.proofId, streamEntryModel);
|
|
1901
|
+
verification = await this._immutableProofComponent.verify(entity.proofId);
|
|
1750
1902
|
}
|
|
1751
1903
|
return {
|
|
1752
1904
|
entity,
|
|
@@ -1756,7 +1908,6 @@ class AuditableItemStreamService {
|
|
|
1756
1908
|
}
|
|
1757
1909
|
/**
|
|
1758
1910
|
* Find stream entries.
|
|
1759
|
-
* @param nodeIdentity The node identity.
|
|
1760
1911
|
* @param streamId The stream id.
|
|
1761
1912
|
* @param includeDeleted Should deleted entries be included.
|
|
1762
1913
|
* @param verifyEntries Should the entries be verified.
|
|
@@ -1767,7 +1918,7 @@ class AuditableItemStreamService {
|
|
|
1767
1918
|
* @param cursor The cursor.
|
|
1768
1919
|
* @internal
|
|
1769
1920
|
*/
|
|
1770
|
-
async findEntries(
|
|
1921
|
+
async findEntries(streamId, includeDeleted, verifyEntries, conditions, sortDirection, propertiesToReturn, pageSize, cursor) {
|
|
1771
1922
|
const needToVerify = verifyEntries ?? false;
|
|
1772
1923
|
const combinedConditions = [
|
|
1773
1924
|
{
|
|
@@ -1823,10 +1974,7 @@ class AuditableItemStreamService {
|
|
|
1823
1974
|
for (const entry of result.entities) {
|
|
1824
1975
|
const entryModel = this.streamEntryEntityToJsonLd(entry);
|
|
1825
1976
|
if (needToVerify && Is.stringValue(entry.proofId)) {
|
|
1826
|
-
|
|
1827
|
-
// this is a subset of fixed properties from the stream entry object.
|
|
1828
|
-
const streamEntryModel = await this.streamEntryEntityToJsonLd(ObjectHelper.pick(entry, AuditableItemStreamService._PROOF_KEYS_STREAM_ENTRY));
|
|
1829
|
-
entryModel.verification = await this._immutableProofComponent.verify(entry.proofId, streamEntryModel);
|
|
1977
|
+
entryModel.verification = await this._immutableProofComponent.verify(entry.proofId);
|
|
1830
1978
|
}
|
|
1831
1979
|
entryModels.push(entryModel);
|
|
1832
1980
|
}
|
|
@@ -1835,46 +1983,92 @@ class AuditableItemStreamService {
|
|
|
1835
1983
|
cursor: returnCursor
|
|
1836
1984
|
};
|
|
1837
1985
|
}
|
|
1986
|
+
/**
|
|
1987
|
+
* Remove the verifiable storage for the stream and entries.
|
|
1988
|
+
* @param streamEntity The stream entity.
|
|
1989
|
+
* @param removeOnlyProof Should only the proof be removed.
|
|
1990
|
+
* @param nodeIdentity The node identity to use for vault operations.
|
|
1991
|
+
* @returns Nothing.
|
|
1992
|
+
* @internal
|
|
1993
|
+
*/
|
|
1994
|
+
async internalRemoveEntries(streamEntity, removeOnlyProof, nodeIdentity) {
|
|
1995
|
+
if (Is.stringValue(streamEntity.proofId)) {
|
|
1996
|
+
await this._immutableProofComponent.removeVerifiable(streamEntity.proofId, nodeIdentity);
|
|
1997
|
+
delete streamEntity.proofId;
|
|
1998
|
+
await this._streamStorage.set(streamEntity);
|
|
1999
|
+
}
|
|
2000
|
+
const entryIds = [];
|
|
2001
|
+
let entriesResult;
|
|
2002
|
+
do {
|
|
2003
|
+
entriesResult = await this._streamEntryStorage.query({
|
|
2004
|
+
property: "streamId",
|
|
2005
|
+
value: streamEntity.id,
|
|
2006
|
+
comparison: ComparisonOperator.Equals
|
|
2007
|
+
}, [
|
|
2008
|
+
{
|
|
2009
|
+
property: "dateCreated",
|
|
2010
|
+
sortDirection: SortDirection.Ascending
|
|
2011
|
+
}
|
|
2012
|
+
], undefined, entriesResult?.cursor);
|
|
2013
|
+
for (const streamEntry of entriesResult.entities) {
|
|
2014
|
+
entryIds.push(streamEntry.id);
|
|
2015
|
+
if (Is.stringValue(streamEntry.proofId)) {
|
|
2016
|
+
await this._immutableProofComponent.removeVerifiable(streamEntry.proofId, nodeIdentity);
|
|
2017
|
+
delete streamEntry.proofId;
|
|
2018
|
+
// If we are only removing the proof, we need to set the entry
|
|
2019
|
+
// otherwise the entry is going to be removed later anyway.
|
|
2020
|
+
if (removeOnlyProof) {
|
|
2021
|
+
await this._streamEntryStorage.set(streamEntry);
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
} while (Is.stringValue(entriesResult.cursor));
|
|
2026
|
+
if (!removeOnlyProof) {
|
|
2027
|
+
for (const entryId of entryIds) {
|
|
2028
|
+
await this._streamEntryStorage.remove(entryId);
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
1838
2032
|
}
|
|
1839
2033
|
|
|
1840
2034
|
// Copyright 2024 IOTA Stiftung.
|
|
1841
2035
|
// SPDX-License-Identifier: Apache-2.0.
|
|
1842
2036
|
/**
|
|
1843
|
-
* Class describing the auditable item stream
|
|
2037
|
+
* Class describing the auditable item stream.
|
|
1844
2038
|
*/
|
|
1845
|
-
let
|
|
2039
|
+
let AuditableItemStream = class AuditableItemStream {
|
|
1846
2040
|
/**
|
|
1847
|
-
* The id of the
|
|
2041
|
+
* The id of the stream.
|
|
1848
2042
|
*/
|
|
1849
2043
|
id;
|
|
1850
2044
|
/**
|
|
1851
|
-
* The
|
|
1852
|
-
*/
|
|
1853
|
-
streamId;
|
|
1854
|
-
/**
|
|
1855
|
-
* The date/time of when the entry was created.
|
|
2045
|
+
* The date/time of when the stream was created.
|
|
1856
2046
|
*/
|
|
1857
2047
|
dateCreated;
|
|
1858
2048
|
/**
|
|
1859
|
-
* The date/time of when the
|
|
2049
|
+
* The date/time of when the stream was modified.
|
|
1860
2050
|
*/
|
|
1861
2051
|
dateModified;
|
|
1862
2052
|
/**
|
|
1863
|
-
* The
|
|
2053
|
+
* The identity of the node which controls the stream.
|
|
1864
2054
|
*/
|
|
1865
|
-
|
|
2055
|
+
nodeIdentity;
|
|
1866
2056
|
/**
|
|
1867
|
-
* The identity of the user
|
|
2057
|
+
* The identity of the user which created the stream.
|
|
1868
2058
|
*/
|
|
1869
2059
|
userIdentity;
|
|
1870
2060
|
/**
|
|
1871
|
-
* Object to associate with the
|
|
2061
|
+
* Object to associate with the stream as JSON-LD.
|
|
1872
2062
|
*/
|
|
1873
|
-
|
|
2063
|
+
annotationObject;
|
|
1874
2064
|
/**
|
|
1875
|
-
* The
|
|
2065
|
+
* The counter for the entry index.
|
|
1876
2066
|
*/
|
|
1877
|
-
|
|
2067
|
+
indexCounter;
|
|
2068
|
+
/**
|
|
2069
|
+
* After how many entries do we add immutable checks.
|
|
2070
|
+
*/
|
|
2071
|
+
immutableInterval;
|
|
1878
2072
|
/**
|
|
1879
2073
|
* The immutable proof id.
|
|
1880
2074
|
*/
|
|
@@ -1883,81 +2077,86 @@ let AuditableItemStreamEntry = class AuditableItemStreamEntry {
|
|
|
1883
2077
|
__decorate([
|
|
1884
2078
|
property({ type: "string", isPrimary: true }),
|
|
1885
2079
|
__metadata("design:type", String)
|
|
1886
|
-
],
|
|
1887
|
-
__decorate([
|
|
1888
|
-
property({ type: "string" }),
|
|
1889
|
-
__metadata("design:type", String)
|
|
1890
|
-
], AuditableItemStreamEntry.prototype, "streamId", void 0);
|
|
2080
|
+
], AuditableItemStream.prototype, "id", void 0);
|
|
1891
2081
|
__decorate([
|
|
1892
|
-
property({ type: "string", format: "date-time", sortDirection: SortDirection.
|
|
2082
|
+
property({ type: "string", format: "date-time", sortDirection: SortDirection.Descending }),
|
|
1893
2083
|
__metadata("design:type", String)
|
|
1894
|
-
],
|
|
2084
|
+
], AuditableItemStream.prototype, "dateCreated", void 0);
|
|
1895
2085
|
__decorate([
|
|
1896
|
-
property({
|
|
2086
|
+
property({
|
|
2087
|
+
type: "string",
|
|
2088
|
+
format: "date-time",
|
|
2089
|
+
sortDirection: SortDirection.Descending,
|
|
2090
|
+
optional: true
|
|
2091
|
+
}),
|
|
1897
2092
|
__metadata("design:type", String)
|
|
1898
|
-
],
|
|
2093
|
+
], AuditableItemStream.prototype, "dateModified", void 0);
|
|
1899
2094
|
__decorate([
|
|
1900
|
-
property({ type: "string"
|
|
2095
|
+
property({ type: "string" }),
|
|
1901
2096
|
__metadata("design:type", String)
|
|
1902
|
-
],
|
|
2097
|
+
], AuditableItemStream.prototype, "nodeIdentity", void 0);
|
|
1903
2098
|
__decorate([
|
|
1904
2099
|
property({ type: "string" }),
|
|
1905
2100
|
__metadata("design:type", String)
|
|
1906
|
-
],
|
|
2101
|
+
], AuditableItemStream.prototype, "userIdentity", void 0);
|
|
1907
2102
|
__decorate([
|
|
1908
|
-
property({ type: "object", itemTypeRef: JsonLdTypes.Object }),
|
|
2103
|
+
property({ type: "object", itemTypeRef: JsonLdTypes.Object, optional: true }),
|
|
1909
2104
|
__metadata("design:type", Object)
|
|
1910
|
-
],
|
|
2105
|
+
], AuditableItemStream.prototype, "annotationObject", void 0);
|
|
1911
2106
|
__decorate([
|
|
1912
2107
|
property({ type: "integer" }),
|
|
1913
2108
|
__metadata("design:type", Number)
|
|
1914
|
-
],
|
|
2109
|
+
], AuditableItemStream.prototype, "indexCounter", void 0);
|
|
1915
2110
|
__decorate([
|
|
1916
|
-
property({ type: "
|
|
2111
|
+
property({ type: "integer" }),
|
|
2112
|
+
__metadata("design:type", Number)
|
|
2113
|
+
], AuditableItemStream.prototype, "immutableInterval", void 0);
|
|
2114
|
+
__decorate([
|
|
2115
|
+
property({ type: "string", optional: true }),
|
|
1917
2116
|
__metadata("design:type", String)
|
|
1918
|
-
],
|
|
1919
|
-
|
|
2117
|
+
], AuditableItemStream.prototype, "proofId", void 0);
|
|
2118
|
+
AuditableItemStream = __decorate([
|
|
1920
2119
|
entity()
|
|
1921
|
-
],
|
|
2120
|
+
], AuditableItemStream);
|
|
1922
2121
|
|
|
1923
2122
|
// Copyright 2024 IOTA Stiftung.
|
|
1924
2123
|
// SPDX-License-Identifier: Apache-2.0.
|
|
1925
2124
|
/**
|
|
1926
|
-
* Class describing the auditable item stream.
|
|
2125
|
+
* Class describing the auditable item stream entry.
|
|
1927
2126
|
*/
|
|
1928
|
-
let
|
|
2127
|
+
let AuditableItemStreamEntry = class AuditableItemStreamEntry {
|
|
1929
2128
|
/**
|
|
1930
|
-
* The id of the
|
|
2129
|
+
* The id of the entry.
|
|
1931
2130
|
*/
|
|
1932
2131
|
id;
|
|
1933
2132
|
/**
|
|
1934
|
-
* The
|
|
2133
|
+
* The stream that the entry belongs to.
|
|
2134
|
+
*/
|
|
2135
|
+
streamId;
|
|
2136
|
+
/**
|
|
2137
|
+
* The date/time of when the entry was created.
|
|
1935
2138
|
*/
|
|
1936
2139
|
dateCreated;
|
|
1937
2140
|
/**
|
|
1938
|
-
* The date/time of when the
|
|
2141
|
+
* The date/time of when the entry was modified.
|
|
1939
2142
|
*/
|
|
1940
2143
|
dateModified;
|
|
1941
2144
|
/**
|
|
1942
|
-
* The
|
|
2145
|
+
* The date/time of when the entry was deleted, as we never actually remove items.
|
|
1943
2146
|
*/
|
|
1944
|
-
|
|
2147
|
+
dateDeleted;
|
|
1945
2148
|
/**
|
|
1946
|
-
* The identity of the user
|
|
2149
|
+
* The identity of the user that added the entry.
|
|
1947
2150
|
*/
|
|
1948
2151
|
userIdentity;
|
|
1949
2152
|
/**
|
|
1950
|
-
* Object to associate with the
|
|
1951
|
-
*/
|
|
1952
|
-
streamObject;
|
|
1953
|
-
/**
|
|
1954
|
-
* The counter for the entry index.
|
|
2153
|
+
* Object to associate with the entry as JSON-LD.
|
|
1955
2154
|
*/
|
|
1956
|
-
|
|
2155
|
+
entryObject;
|
|
1957
2156
|
/**
|
|
1958
|
-
*
|
|
2157
|
+
* The index of the entry in the stream.
|
|
1959
2158
|
*/
|
|
1960
|
-
|
|
2159
|
+
index;
|
|
1961
2160
|
/**
|
|
1962
2161
|
* The immutable proof id.
|
|
1963
2162
|
*/
|
|
@@ -1966,42 +2165,47 @@ let AuditableItemStream = class AuditableItemStream {
|
|
|
1966
2165
|
__decorate([
|
|
1967
2166
|
property({ type: "string", isPrimary: true }),
|
|
1968
2167
|
__metadata("design:type", String)
|
|
1969
|
-
],
|
|
2168
|
+
], AuditableItemStreamEntry.prototype, "id", void 0);
|
|
1970
2169
|
__decorate([
|
|
1971
|
-
property({ type: "string"
|
|
2170
|
+
property({ type: "string" }),
|
|
1972
2171
|
__metadata("design:type", String)
|
|
1973
|
-
],
|
|
2172
|
+
], AuditableItemStreamEntry.prototype, "streamId", void 0);
|
|
1974
2173
|
__decorate([
|
|
1975
|
-
property({ type: "string", format: "date-time" }),
|
|
2174
|
+
property({ type: "string", format: "date-time", sortDirection: SortDirection.Ascending }),
|
|
1976
2175
|
__metadata("design:type", String)
|
|
1977
|
-
],
|
|
2176
|
+
], AuditableItemStreamEntry.prototype, "dateCreated", void 0);
|
|
1978
2177
|
__decorate([
|
|
1979
|
-
property({
|
|
2178
|
+
property({
|
|
2179
|
+
type: "string",
|
|
2180
|
+
format: "date-time",
|
|
2181
|
+
sortDirection: SortDirection.Descending,
|
|
2182
|
+
optional: true
|
|
2183
|
+
}),
|
|
1980
2184
|
__metadata("design:type", String)
|
|
1981
|
-
],
|
|
2185
|
+
], AuditableItemStreamEntry.prototype, "dateModified", void 0);
|
|
2186
|
+
__decorate([
|
|
2187
|
+
property({ type: "string", format: "date-time", optional: true }),
|
|
2188
|
+
__metadata("design:type", String)
|
|
2189
|
+
], AuditableItemStreamEntry.prototype, "dateDeleted", void 0);
|
|
1982
2190
|
__decorate([
|
|
1983
2191
|
property({ type: "string" }),
|
|
1984
2192
|
__metadata("design:type", String)
|
|
1985
|
-
],
|
|
2193
|
+
], AuditableItemStreamEntry.prototype, "userIdentity", void 0);
|
|
1986
2194
|
__decorate([
|
|
1987
2195
|
property({ type: "object", itemTypeRef: JsonLdTypes.Object }),
|
|
1988
2196
|
__metadata("design:type", Object)
|
|
1989
|
-
],
|
|
1990
|
-
__decorate([
|
|
1991
|
-
property({ type: "integer" }),
|
|
1992
|
-
__metadata("design:type", Number)
|
|
1993
|
-
], AuditableItemStream.prototype, "indexCounter", void 0);
|
|
2197
|
+
], AuditableItemStreamEntry.prototype, "entryObject", void 0);
|
|
1994
2198
|
__decorate([
|
|
1995
2199
|
property({ type: "integer" }),
|
|
1996
2200
|
__metadata("design:type", Number)
|
|
1997
|
-
],
|
|
2201
|
+
], AuditableItemStreamEntry.prototype, "index", void 0);
|
|
1998
2202
|
__decorate([
|
|
1999
|
-
property({ type: "string" }),
|
|
2203
|
+
property({ type: "string", optional: true }),
|
|
2000
2204
|
__metadata("design:type", String)
|
|
2001
|
-
],
|
|
2002
|
-
|
|
2205
|
+
], AuditableItemStreamEntry.prototype, "proofId", void 0);
|
|
2206
|
+
AuditableItemStreamEntry = __decorate([
|
|
2003
2207
|
entity()
|
|
2004
|
-
],
|
|
2208
|
+
], AuditableItemStreamEntry);
|
|
2005
2209
|
|
|
2006
2210
|
const restEntryPoints = [
|
|
2007
2211
|
{
|
|
@@ -2022,4 +2226,4 @@ function initSchema() {
|
|
|
2022
2226
|
EntitySchemaFactory.register("AuditableItemStreamEntry", () => EntitySchemaHelper.getSchema(AuditableItemStreamEntry));
|
|
2023
2227
|
}
|
|
2024
2228
|
|
|
2025
|
-
export { AuditableItemStream, AuditableItemStreamEntry, AuditableItemStreamService, auditableItemStreamCreate, auditableItemStreamCreateEntry, auditableItemStreamDeleteEntry, auditableItemStreamGet, auditableItemStreamGetEntry, auditableItemStreamGetEntryObject, auditableItemStreamList, auditableItemStreamListEntries, auditableItemStreamListEntryObjects, auditableItemStreamUpdate, auditableItemStreamUpdateEntry, generateRestRoutesAuditableItemStream, initSchema, restEntryPoints, tagsAuditableItemStream };
|
|
2229
|
+
export { AuditableItemStream, AuditableItemStreamEntry, AuditableItemStreamService, auditableItemStreamCreate, auditableItemStreamCreateEntry, auditableItemStreamDelete, auditableItemStreamDeleteEntry, auditableItemStreamGet, auditableItemStreamGetEntry, auditableItemStreamGetEntryObject, auditableItemStreamList, auditableItemStreamListEntries, auditableItemStreamListEntryObjects, auditableItemStreamUpdate, auditableItemStreamUpdateEntry, generateRestRoutesAuditableItemStream, initSchema, restEntryPoints, tagsAuditableItemStream };
|