@twin.org/auditable-item-stream-service 0.0.3-next.8 → 0.9.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +2 -2
  2. package/dist/es/auditableItemStreamRoutes.js +413 -81
  3. package/dist/es/auditableItemStreamRoutes.js.map +1 -1
  4. package/dist/es/auditableItemStreamService.js +313 -121
  5. package/dist/es/auditableItemStreamService.js.map +1 -1
  6. package/dist/es/entities/auditableItemStream.js +20 -6
  7. package/dist/es/entities/auditableItemStream.js.map +1 -1
  8. package/dist/es/models/IAuditableItemStreamServiceConfig.js.map +1 -1
  9. package/dist/es/models/IAuditableItemStreamServiceConstructorOptions.js.map +1 -1
  10. package/dist/es/models/IAuditableItemStreamServiceContext.js.map +1 -1
  11. package/dist/es/restEntryPoints.js +3 -0
  12. package/dist/es/restEntryPoints.js.map +1 -1
  13. package/dist/types/auditableItemStreamRoutes.d.ts +37 -5
  14. package/dist/types/auditableItemStreamService.d.ts +37 -38
  15. package/dist/types/entities/auditableItemStream.d.ts +12 -3
  16. package/dist/types/models/IAuditableItemStreamServiceConfig.d.ts +4 -0
  17. package/dist/types/models/IAuditableItemStreamServiceConstructorOptions.d.ts +4 -0
  18. package/dist/types/models/IAuditableItemStreamServiceContext.d.ts +4 -0
  19. package/dist/types/restEntryPoints.d.ts +3 -0
  20. package/docs/changelog.md +383 -90
  21. package/docs/examples.md +211 -1
  22. package/docs/open-api/spec.json +839 -172
  23. package/docs/reference/classes/AuditableItemStream.md +32 -16
  24. package/docs/reference/classes/AuditableItemStreamEntry.md +13 -13
  25. package/docs/reference/classes/AuditableItemStreamService.md +109 -84
  26. package/docs/reference/functions/auditableItemStreamClose.md +31 -0
  27. package/docs/reference/functions/auditableItemStreamDeleteEntry.md +1 -1
  28. package/docs/reference/functions/auditableItemStreamList.md +1 -1
  29. package/docs/reference/functions/auditableItemStreamListEntries.md +1 -1
  30. package/docs/reference/functions/auditableItemStreamListEntriesNoStream.md +31 -0
  31. package/docs/reference/functions/auditableItemStreamListEntryObjects.md +1 -1
  32. package/docs/reference/functions/auditableItemStreamListEntryObjectsNoStream.md +31 -0
  33. package/docs/reference/functions/auditableItemStreamRemoveProof.md +31 -0
  34. package/docs/reference/index.md +4 -0
  35. package/docs/reference/interfaces/IAuditableItemStreamServiceConfig.md +10 -2
  36. package/docs/reference/interfaces/IAuditableItemStreamServiceConstructorOptions.md +18 -10
  37. package/docs/reference/variables/restEntryPoints.md +2 -0
  38. package/locales/en.json +6 -1
  39. package/package.json +19 -18
@@ -1,12 +1,13 @@
1
1
  // Copyright 2024 IOTA Stiftung.
2
2
  // SPDX-License-Identifier: Apache-2.0.
3
- import { HttpParameterHelper } from "@twin.org/api-models";
3
+ import { HttpContextIdKeys, HttpParameterHelper, HttpUrlHelper } from "@twin.org/api-models";
4
4
  import { AuditableItemStreamContexts, AuditableItemStreamTypes } from "@twin.org/auditable-item-stream-models";
5
+ import { ContextIdStore } from "@twin.org/context";
5
6
  import { Coerce, ComponentFactory, Guards, Is } from "@twin.org/core";
6
7
  import { SchemaOrgContexts, SchemaOrgTypes } from "@twin.org/standards-schema-org";
7
8
  import { HeaderHelper, HeaderTypes, HttpStatusCode, MimeTypes } from "@twin.org/web";
8
9
  /**
9
- * The source used when communicating about these routes.
10
+ * The source identifier used when communicating errors from these routes.
10
11
  */
11
12
  const ROUTES_SOURCE = "auditableItemStreamRoutes";
12
13
  /**
@@ -39,21 +40,31 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
39
40
  id: "auditableItemStreamCreateRequestExample",
40
41
  request: {
41
42
  body: {
43
+ "@context": [
44
+ SchemaOrgContexts.Context,
45
+ AuditableItemStreamContexts.Context,
46
+ AuditableItemStreamContexts.ContextCommon
47
+ ],
48
+ type: AuditableItemStreamTypes.Stream,
42
49
  annotationObject: {
43
50
  "@context": "https://schema.org",
44
51
  "@type": "Note",
45
52
  content: "This is a simple note"
46
53
  },
47
- entries: [
48
- {
49
- entryObject: {
50
- "@context": "https://schema.org",
51
- "@type": "Event",
52
- startDate: "2011-04-09T20:00:00Z",
53
- description: "A description of the event"
54
+ entries: {
55
+ type: SchemaOrgTypes.ItemList,
56
+ [SchemaOrgTypes.ItemListElement]: [
57
+ {
58
+ type: AuditableItemStreamTypes.StreamEntry,
59
+ entryObject: {
60
+ "@context": "https://schema.org",
61
+ "@type": "Event",
62
+ startDate: "2011-04-09T20:00:00Z",
63
+ description: "A description of the event"
64
+ }
54
65
  }
55
- }
56
- ]
66
+ ]
67
+ }
57
68
  }
58
69
  }
59
70
  }
@@ -109,6 +120,7 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
109
120
  response: {
110
121
  body: {
111
122
  "@context": [
123
+ SchemaOrgContexts.Context,
112
124
  AuditableItemStreamContexts.Context,
113
125
  AuditableItemStreamContexts.ContextCommon
114
126
  ],
@@ -124,25 +136,29 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
124
136
  organizationIdentity: "did:iota:1234567890",
125
137
  proofId: "0101010101010101010101010101010101010101010101010101010101010101",
126
138
  immutableInterval: 10,
127
- entries: [
128
- {
129
- "@context": [
130
- AuditableItemStreamContexts.Context,
131
- AuditableItemStreamContexts.ContextCommon
132
- ],
133
- type: AuditableItemStreamTypes.StreamEntry,
134
- id: "tst:1234567890",
135
- dateCreated: "2024-08-22T11:55:16.271Z",
136
- proofId: "0101010101010101010101010101010101010101010101010101010101010101",
137
- index: 0,
138
- entryObject: {
139
- "@context": "https://schema.org",
140
- "@type": "Event",
141
- startDate: "2011-04-09T20:00:00Z",
142
- description: "A description of the event"
139
+ numberOfItems: 1,
140
+ entries: {
141
+ type: SchemaOrgTypes.ItemList,
142
+ [SchemaOrgTypes.ItemListElement]: [
143
+ {
144
+ "@context": [
145
+ AuditableItemStreamContexts.Context,
146
+ AuditableItemStreamContexts.ContextCommon
147
+ ],
148
+ type: AuditableItemStreamTypes.StreamEntry,
149
+ id: "tst:1234567890",
150
+ dateCreated: "2024-08-22T11:55:16.271Z",
151
+ proofId: "0101010101010101010101010101010101010101010101010101010101010101",
152
+ index: 0,
153
+ entryObject: {
154
+ "@context": "https://schema.org",
155
+ "@type": "Event",
156
+ startDate: "2011-04-09T20:00:00Z",
157
+ description: "A description of the event"
158
+ }
143
159
  }
144
- }
145
- ]
160
+ ]
161
+ }
146
162
  }
147
163
  }
148
164
  }
@@ -160,6 +176,7 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
160
176
  },
161
177
  body: {
162
178
  "@context": [
179
+ SchemaOrgContexts.Context,
163
180
  AuditableItemStreamContexts.Context,
164
181
  AuditableItemStreamContexts.ContextCommon
165
182
  ],
@@ -175,25 +192,29 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
175
192
  organizationIdentity: "did:iota:1234567890",
176
193
  proofId: "0101010101010101010101010101010101010101010101010101010101010101",
177
194
  immutableInterval: 10,
178
- entries: [
179
- {
180
- "@context": [
181
- AuditableItemStreamContexts.Context,
182
- AuditableItemStreamContexts.ContextCommon
183
- ],
184
- type: AuditableItemStreamTypes.StreamEntry,
185
- id: "tst:1234567890",
186
- dateCreated: "2024-08-22T11:55:16.271Z",
187
- proofId: "0101010101010101010101010101010101010101010101010101010101010101",
188
- index: 0,
189
- entryObject: {
190
- "@context": "https://schema.org",
191
- "@type": "Event",
192
- startDate: "2011-04-09T20:00:00Z",
193
- description: "A description of the event"
195
+ numberOfItems: 1,
196
+ entries: {
197
+ type: SchemaOrgTypes.ItemList,
198
+ [SchemaOrgTypes.ItemListElement]: [
199
+ {
200
+ "@context": [
201
+ AuditableItemStreamContexts.Context,
202
+ AuditableItemStreamContexts.ContextCommon
203
+ ],
204
+ type: AuditableItemStreamTypes.StreamEntry,
205
+ id: "tst:1234567890",
206
+ dateCreated: "2024-08-22T11:55:16.271Z",
207
+ proofId: "0101010101010101010101010101010101010101010101010101010101010101",
208
+ index: 0,
209
+ entryObject: {
210
+ "@context": "https://schema.org",
211
+ "@type": "Event",
212
+ startDate: "2011-04-09T20:00:00Z",
213
+ description: "A description of the event"
214
+ }
194
215
  }
195
- }
196
- ]
216
+ ]
217
+ }
197
218
  }
198
219
  }
199
220
  }
@@ -221,6 +242,12 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
221
242
  id: "ais:1234567890"
222
243
  },
223
244
  body: {
245
+ "@context": [
246
+ SchemaOrgContexts.Context,
247
+ AuditableItemStreamContexts.Context,
248
+ AuditableItemStreamContexts.ContextCommon
249
+ ],
250
+ type: AuditableItemStreamTypes.Stream,
224
251
  annotationObject: {
225
252
  "@context": "https://schema.org",
226
253
  "@type": "Note",
@@ -269,6 +296,35 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
269
296
  }
270
297
  ]
271
298
  };
299
+ const closeRoute = {
300
+ operationId: "auditableItemStreamClose",
301
+ summary: "Close a stream",
302
+ tag: tagsAuditableItemStream[0].name,
303
+ method: "PUT",
304
+ path: `${baseRouteName}/:id/close`,
305
+ handler: async (httpRequestContext, request) => auditableItemStreamClose(httpRequestContext, componentName, request),
306
+ requestType: {
307
+ type: "IAuditableItemStreamCloseRequest",
308
+ examples: [
309
+ {
310
+ id: "auditableItemStreamCloseRequestExample",
311
+ request: {
312
+ pathParams: {
313
+ id: "ais:1234567890"
314
+ }
315
+ }
316
+ }
317
+ ]
318
+ },
319
+ responseType: [
320
+ {
321
+ type: "INoContentResponse"
322
+ },
323
+ {
324
+ type: "INotFoundResponse"
325
+ }
326
+ ]
327
+ };
272
328
  const listRoute = {
273
329
  operationId: "auditableItemStreamList",
274
330
  summary: "Query streams",
@@ -302,6 +358,7 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
302
358
  [SchemaOrgTypes.ItemListElement]: [
303
359
  {
304
360
  "@context": [
361
+ SchemaOrgContexts.Context,
305
362
  AuditableItemStreamContexts.Context,
306
363
  AuditableItemStreamContexts.ContextCommon
307
364
  ],
@@ -316,7 +373,8 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
316
373
  },
317
374
  organizationIdentity: "did:iota:1234567890",
318
375
  proofId: "0101010101010101010101010101010101010101010101010101010101010101",
319
- immutableInterval: 10
376
+ immutableInterval: 10,
377
+ numberOfItems: 0
320
378
  }
321
379
  ]
322
380
  }
@@ -344,6 +402,7 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
344
402
  [SchemaOrgTypes.ItemListElement]: [
345
403
  {
346
404
  "@context": [
405
+ SchemaOrgContexts.Context,
347
406
  AuditableItemStreamContexts.Context,
348
407
  AuditableItemStreamContexts.ContextCommon
349
408
  ],
@@ -358,7 +417,8 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
358
417
  },
359
418
  organizationIdentity: "did:iota:1234567890",
360
419
  proofId: "0101010101010101010101010101010101010101010101010101010101010101",
361
- immutableInterval: 10
420
+ immutableInterval: 10,
421
+ numberOfItems: 0
362
422
  }
363
423
  ]
364
424
  }
@@ -376,7 +436,7 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
376
436
  summary: "Create a new stream entry",
377
437
  tag: tagsAuditableItemStream[0].name,
378
438
  method: "POST",
379
- path: `${baseRouteName}/:id`,
439
+ path: `${baseRouteName}/:id/entries`,
380
440
  handler: async (httpRequestContext, request) => auditableItemStreamCreateEntry(httpRequestContext, componentName, request),
381
441
  requestType: {
382
442
  type: "IAuditableItemStreamCreateEntryRequest",
@@ -422,7 +482,7 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
422
482
  summary: "Delete an entry from the stream",
423
483
  tag: tagsAuditableItemStream[0].name,
424
484
  method: "DELETE",
425
- path: `${baseRouteName}/:id/:entryId`,
485
+ path: `${baseRouteName}/:id/entries/:entryId`,
426
486
  handler: async (httpRequestContext, request) => auditableItemStreamDeleteEntry(httpRequestContext, componentName, request),
427
487
  requestType: {
428
488
  type: "IAuditableItemStreamDeleteRequest",
@@ -452,7 +512,7 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
452
512
  summary: "Update a stream entry",
453
513
  tag: tagsAuditableItemStream[0].name,
454
514
  method: "PUT",
455
- path: `${baseRouteName}/:id/:entryId`,
515
+ path: `${baseRouteName}/:id/entries/:entryId`,
456
516
  handler: async (httpRequestContext, request) => auditableItemStreamUpdateEntry(httpRequestContext, componentName, request),
457
517
  requestType: {
458
518
  type: "IAuditableItemStreamUpdateEntryRequest",
@@ -489,7 +549,7 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
489
549
  summary: "Get a stream entry",
490
550
  tag: tagsAuditableItemStream[0].name,
491
551
  method: "GET",
492
- path: `${baseRouteName}/:id/:entryId`,
552
+ path: `${baseRouteName}/:id/entries/:entryId`,
493
553
  handler: async (httpRequestContext, request) => auditableItemStreamGetEntry(httpRequestContext, componentName, request),
494
554
  requestType: {
495
555
  type: "IAuditableItemStreamGetEntryRequest",
@@ -571,10 +631,10 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
571
631
  };
572
632
  const getEntryObjectRoute = {
573
633
  operationId: "auditableItemStreamGetEntryObject",
574
- summary: "Get a stream entry",
634
+ summary: "Get a stream entry object",
575
635
  tag: tagsAuditableItemStream[0].name,
576
636
  method: "GET",
577
- path: `${baseRouteName}/:id/:entryId/object`,
637
+ path: `${baseRouteName}/:id/entries/:entryId/object`,
578
638
  handler: async (httpRequestContext, request) => auditableItemStreamGetEntryObject(httpRequestContext, componentName, request),
579
639
  requestType: {
580
640
  type: "IAuditableItemStreamGetEntryRequest",
@@ -716,6 +776,106 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
716
776
  }
717
777
  ]
718
778
  };
779
+ const listEntriesNoStreamRoute = {
780
+ operationId: "auditableItemStreamListEntriesNoStream",
781
+ summary: "Get the entry objects for all streams",
782
+ tag: tagsAuditableItemStream[0].name,
783
+ method: "GET",
784
+ path: `${baseRouteName}/entries`,
785
+ handler: async (httpRequestContext, request) => auditableItemStreamListEntriesNoStream(httpRequestContext, componentName, request),
786
+ requestType: {
787
+ type: "IAuditableItemStreamListEntriesNoStreamRequest",
788
+ examples: [
789
+ {
790
+ id: "auditableItemStreamListEntriesNoStreamRequestExample",
791
+ request: {}
792
+ }
793
+ ]
794
+ },
795
+ responseType: [
796
+ {
797
+ type: "IAuditableItemStreamListEntriesResponse",
798
+ examples: [
799
+ {
800
+ id: "auditableItemStreamListEntriesNoStreamResponseExample",
801
+ response: {
802
+ body: {
803
+ "@context": [
804
+ SchemaOrgContexts.Context,
805
+ AuditableItemStreamContexts.Context,
806
+ AuditableItemStreamContexts.ContextCommon
807
+ ],
808
+ type: [SchemaOrgTypes.ItemList, AuditableItemStreamTypes.StreamEntryList],
809
+ [SchemaOrgTypes.ItemListElement]: [
810
+ {
811
+ "@context": [
812
+ AuditableItemStreamContexts.Context,
813
+ AuditableItemStreamContexts.ContextCommon
814
+ ],
815
+ type: AuditableItemStreamTypes.StreamEntry,
816
+ id: "tst:1234567890",
817
+ dateCreated: "2024-08-22T11:55:16.271Z",
818
+ proofId: "0101010101010101010101010101010101010101010101010101010101010101",
819
+ index: 0,
820
+ entryObject: {
821
+ "@context": "https://schema.org",
822
+ "@type": "Event",
823
+ startDate: "2011-04-09T20:00:00Z",
824
+ description: "A description of the event"
825
+ }
826
+ }
827
+ ]
828
+ }
829
+ }
830
+ }
831
+ ]
832
+ },
833
+ {
834
+ type: "IAuditableItemStreamListEntriesResponse",
835
+ mimeType: MimeTypes.JsonLd,
836
+ examples: [
837
+ {
838
+ id: "auditableItemStreamJsonLdListEntriesNoStreamResponseExample",
839
+ response: {
840
+ headers: {
841
+ [HeaderTypes.ContentType]: MimeTypes.JsonLd
842
+ },
843
+ body: {
844
+ "@context": [
845
+ SchemaOrgContexts.Context,
846
+ AuditableItemStreamContexts.Context,
847
+ AuditableItemStreamContexts.ContextCommon
848
+ ],
849
+ type: [SchemaOrgTypes.ItemList, AuditableItemStreamTypes.StreamEntryList],
850
+ [SchemaOrgTypes.ItemListElement]: [
851
+ {
852
+ "@context": [
853
+ AuditableItemStreamContexts.Context,
854
+ AuditableItemStreamContexts.ContextCommon
855
+ ],
856
+ type: AuditableItemStreamTypes.StreamEntry,
857
+ id: "tst:1234567890",
858
+ dateCreated: "2024-08-22T11:55:16.271Z",
859
+ proofId: "0101010101010101010101010101010101010101010101010101010101010101",
860
+ index: 0,
861
+ entryObject: {
862
+ "@context": "https://schema.org",
863
+ "@type": "Event",
864
+ startDate: "2011-04-09T20:00:00Z",
865
+ description: "A description of the event"
866
+ }
867
+ }
868
+ ]
869
+ }
870
+ }
871
+ }
872
+ ]
873
+ },
874
+ {
875
+ type: "INotFoundResponse"
876
+ }
877
+ ]
878
+ };
719
879
  const listEntryObjectsRoute = {
720
880
  operationId: "auditableItemStreamListEntryObjects",
721
881
  summary: "Get the entry objects in a stream",
@@ -768,11 +928,89 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
768
928
  }
769
929
  ]
770
930
  };
931
+ const listEntryObjectsNoStreamRoute = {
932
+ operationId: "auditableItemStreamListEntryObjectsNoStream",
933
+ summary: "Get the entry objects for all streams",
934
+ tag: tagsAuditableItemStream[0].name,
935
+ method: "GET",
936
+ path: `${baseRouteName}/entries/objects`,
937
+ handler: async (httpRequestContext, request) => auditableItemStreamListEntryObjectsNoStream(httpRequestContext, componentName, request),
938
+ requestType: {
939
+ type: "IAuditableItemStreamListEntryObjectsNoStreamRequest",
940
+ examples: [
941
+ {
942
+ id: "auditableItemStreamListEntryObjectsNoStreamRequestExample",
943
+ request: {}
944
+ }
945
+ ]
946
+ },
947
+ responseType: [
948
+ {
949
+ type: "IAuditableItemStreamListEntryObjectsResponse",
950
+ examples: [
951
+ {
952
+ id: "auditableItemStreamListEntryObjectsNoStreamResponseExample",
953
+ response: {
954
+ body: {
955
+ "@context": [
956
+ SchemaOrgContexts.Context,
957
+ AuditableItemStreamContexts.Context,
958
+ AuditableItemStreamContexts.ContextCommon
959
+ ],
960
+ type: [SchemaOrgTypes.ItemList, AuditableItemStreamTypes.StreamEntryObjectList],
961
+ [SchemaOrgTypes.ItemListElement]: [
962
+ {
963
+ "@context": "https://schema.org",
964
+ "@type": "Event",
965
+ startDate: "2011-04-09T20:00:00Z",
966
+ description: "A description of the event"
967
+ }
968
+ ]
969
+ }
970
+ }
971
+ }
972
+ ]
973
+ },
974
+ {
975
+ type: "INotFoundResponse"
976
+ }
977
+ ]
978
+ };
979
+ const removeProofRoute = {
980
+ operationId: "auditableItemStreamRemoveProof",
981
+ summary: "Remove the proof from a stream",
982
+ tag: tagsAuditableItemStream[0].name,
983
+ method: "DELETE",
984
+ path: `${baseRouteName}/:id/proof`,
985
+ handler: async (httpRequestContext, request) => auditableItemStreamRemoveProof(httpRequestContext, componentName, request),
986
+ requestType: {
987
+ type: "IAuditableItemStreamRemoveProofRequest",
988
+ examples: [
989
+ {
990
+ id: "auditableItemStreamRemoveProofRequestExample",
991
+ request: {
992
+ pathParams: {
993
+ id: "ais:1234567890"
994
+ }
995
+ }
996
+ }
997
+ ]
998
+ },
999
+ responseType: [
1000
+ {
1001
+ type: "INoContentResponse"
1002
+ },
1003
+ {
1004
+ type: "INotFoundResponse"
1005
+ }
1006
+ ]
1007
+ };
771
1008
  return [
772
1009
  createRoute,
773
1010
  getRoute,
774
1011
  updateRoute,
775
1012
  deleteRoute,
1013
+ closeRoute,
776
1014
  listRoute,
777
1015
  createEntryRoute,
778
1016
  getEntryRoute,
@@ -780,7 +1018,10 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
780
1018
  deleteEntryRoute,
781
1019
  updateEntryRoute,
782
1020
  listEntriesRoute,
783
- listEntryObjectsRoute
1021
+ listEntriesNoStreamRoute,
1022
+ listEntryObjectsRoute,
1023
+ listEntryObjectsNoStreamRoute,
1024
+ removeProofRoute
784
1025
  ];
785
1026
  }
786
1027
  /**
@@ -794,12 +1035,7 @@ export async function auditableItemStreamCreate(httpRequestContext, componentNam
794
1035
  Guards.object(ROUTES_SOURCE, "request", request);
795
1036
  Guards.object(ROUTES_SOURCE, "request.body", request.body);
796
1037
  const component = ComponentFactory.get(componentName);
797
- const id = await component.create({
798
- annotationObject: request.body.annotationObject,
799
- entries: request.body.entries
800
- }, {
801
- immutableInterval: request.body?.immutableInterval
802
- });
1038
+ const id = await component.create(request.body);
803
1039
  return {
804
1040
  statusCode: HttpStatusCode.created,
805
1041
  headers: {
@@ -819,19 +1055,22 @@ export async function auditableItemStreamGet(httpRequestContext, componentName,
819
1055
  Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
820
1056
  Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
821
1057
  const component = ComponentFactory.get(componentName);
822
- const result = await component.get(request.pathParams.id, {
1058
+ const result = await component.get(request.pathParams.id, request.query?.cursor, Coerce.integer(request.query?.limit), {
823
1059
  includeEntries: Coerce.boolean(request.query?.includeEntries),
824
1060
  includeDeleted: Coerce.boolean(request.query?.includeDeleted),
825
1061
  verifyStream: Coerce.boolean(request.query?.verifyStream),
826
1062
  verifyEntries: Coerce.boolean(request.query?.verifyEntries)
827
1063
  });
1064
+ const headers = {
1065
+ [HeaderTypes.ContentType]: request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? MimeTypes.JsonLd : MimeTypes.Json
1066
+ };
1067
+ if (Is.stringValue(result.cursor)) {
1068
+ const contextIds = await ContextIdStore.getContextIds();
1069
+ headers[HeaderTypes.Link] = HeaderHelper.createLinkHeader(HttpUrlHelper.replaceOrigin(httpRequestContext.serverRequest.url, contextIds?.[HttpContextIdKeys.PublicOrigin]), { cursor: result.cursor }, "next");
1070
+ }
828
1071
  return {
829
- headers: {
830
- [HeaderTypes.ContentType]: request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd
831
- ? MimeTypes.JsonLd
832
- : MimeTypes.Json
833
- },
834
- body: result
1072
+ headers,
1073
+ body: result.stream
835
1074
  };
836
1075
  }
837
1076
  /**
@@ -848,8 +1087,8 @@ export async function auditableItemStreamUpdate(httpRequestContext, componentNam
848
1087
  Guards.object(ROUTES_SOURCE, "request.body", request.body);
849
1088
  const component = ComponentFactory.get(componentName);
850
1089
  await component.update({
851
- id: request.pathParams.id,
852
- annotationObject: request.body.annotationObject
1090
+ ...request.body,
1091
+ id: request.pathParams.id
853
1092
  });
854
1093
  return {
855
1094
  statusCode: HttpStatusCode.noContent
@@ -873,7 +1112,24 @@ export async function auditableItemStreamDelete(httpRequestContext, componentNam
873
1112
  };
874
1113
  }
875
1114
  /**
876
- * Query the stream.
1115
+ * Close the stream.
1116
+ * @param httpRequestContext The request context for the API.
1117
+ * @param componentName The name of the component to use in the routes.
1118
+ * @param request The request.
1119
+ * @returns The response object with additional http response properties.
1120
+ */
1121
+ export async function auditableItemStreamClose(httpRequestContext, componentName, request) {
1122
+ Guards.object(ROUTES_SOURCE, "request", request);
1123
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
1124
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
1125
+ const component = ComponentFactory.get(componentName);
1126
+ await component.close(request.pathParams.id);
1127
+ return {
1128
+ statusCode: HttpStatusCode.noContent
1129
+ };
1130
+ }
1131
+ /**
1132
+ * List all streams.
877
1133
  * @param httpRequestContext The request context for the API.
878
1134
  * @param componentName The name of the component to use in the routes.
879
1135
  * @param request The request.
@@ -882,14 +1138,14 @@ export async function auditableItemStreamDelete(httpRequestContext, componentNam
882
1138
  export async function auditableItemStreamList(httpRequestContext, componentName, request) {
883
1139
  Guards.object(ROUTES_SOURCE, "request", request);
884
1140
  Guards.object(ROUTES_SOURCE, "request.query", request.query);
885
- const hostingComponent = ComponentFactory.get(httpRequestContext.hostingComponentType ?? "hosting");
886
1141
  const component = ComponentFactory.get(componentName);
887
1142
  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?.limit));
888
1143
  const headers = {
889
1144
  [HeaderTypes.ContentType]: request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? MimeTypes.JsonLd : MimeTypes.Json
890
1145
  };
891
1146
  if (Is.stringValue(result.cursor)) {
892
- headers[HeaderTypes.Link] = HeaderHelper.createLinkHeader(await hostingComponent.buildPublicUrl(httpRequestContext.serverRequest.url), { cursor: result.cursor }, "next");
1147
+ const contextIds = await ContextIdStore.getContextIds();
1148
+ headers[HeaderTypes.Link] = HeaderHelper.createLinkHeader(HttpUrlHelper.replaceOrigin(httpRequestContext.serverRequest.url, contextIds?.[HttpContextIdKeys.PublicOrigin]), { cursor: result.cursor }, "next");
893
1149
  }
894
1150
  return {
895
1151
  headers,
@@ -919,7 +1175,7 @@ export async function auditableItemStreamCreateEntry(httpRequestContext, compone
919
1175
  };
920
1176
  }
921
1177
  /**
922
- * Get the stream.
1178
+ * Delete an entry from the stream.
923
1179
  * @param httpRequestContext The request context for the API.
924
1180
  * @param componentName The name of the component to use in the routes.
925
1181
  * @param request The request.
@@ -1005,7 +1261,7 @@ export async function auditableItemStreamGetEntryObject(httpRequestContext, comp
1005
1261
  };
1006
1262
  }
1007
1263
  /**
1008
- * Query the stream.
1264
+ * List the entries for a stream.
1009
1265
  * @param httpRequestContext The request context for the API.
1010
1266
  * @param componentName The name of the component to use in the routes.
1011
1267
  * @param request The request.
@@ -1015,7 +1271,6 @@ export async function auditableItemStreamListEntries(httpRequestContext, compone
1015
1271
  Guards.object(ROUTES_SOURCE, "request", request);
1016
1272
  Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
1017
1273
  Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
1018
- const hostingComponent = ComponentFactory.get(httpRequestContext.hostingComponentType ?? "hosting");
1019
1274
  const component = ComponentFactory.get(componentName);
1020
1275
  const result = await component.getEntries(request.pathParams.id, {
1021
1276
  conditions: HttpParameterHelper.objectFromString(request.query?.conditions),
@@ -1029,7 +1284,38 @@ export async function auditableItemStreamListEntries(httpRequestContext, compone
1029
1284
  [HeaderTypes.ContentType]: request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? MimeTypes.JsonLd : MimeTypes.Json
1030
1285
  };
1031
1286
  if (Is.stringValue(result.cursor)) {
1032
- headers[HeaderTypes.Link] = HeaderHelper.createLinkHeader(await hostingComponent.buildPublicUrl(httpRequestContext.serverRequest.url), { cursor: result.cursor }, "next");
1287
+ const contextIds = await ContextIdStore.getContextIds();
1288
+ headers[HeaderTypes.Link] = HeaderHelper.createLinkHeader(HttpUrlHelper.replaceOrigin(httpRequestContext.serverRequest.url, contextIds?.[HttpContextIdKeys.PublicOrigin]), { cursor: result.cursor }, "next");
1289
+ }
1290
+ return {
1291
+ headers,
1292
+ body: result.entries
1293
+ };
1294
+ }
1295
+ /**
1296
+ * List entries across all streams.
1297
+ * @param httpRequestContext The request context for the API.
1298
+ * @param componentName The name of the component to use in the routes.
1299
+ * @param request The request.
1300
+ * @returns The response object with additional http response properties.
1301
+ */
1302
+ export async function auditableItemStreamListEntriesNoStream(httpRequestContext, componentName, request) {
1303
+ Guards.object(ROUTES_SOURCE, "request", request);
1304
+ const component = ComponentFactory.get(componentName);
1305
+ const result = await component.getEntries(undefined, {
1306
+ conditions: HttpParameterHelper.objectFromString(request.query?.conditions),
1307
+ includeDeleted: Coerce.boolean(request.query?.includeDeleted),
1308
+ verifyEntries: Coerce.boolean(request.query?.verifyEntries),
1309
+ order: request.query?.order,
1310
+ limit: Coerce.integer(request.query?.limit),
1311
+ cursor: request.query?.cursor
1312
+ });
1313
+ const headers = {
1314
+ [HeaderTypes.ContentType]: request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? MimeTypes.JsonLd : MimeTypes.Json
1315
+ };
1316
+ if (Is.stringValue(result.cursor)) {
1317
+ const contextIds = await ContextIdStore.getContextIds();
1318
+ headers[HeaderTypes.Link] = HeaderHelper.createLinkHeader(HttpUrlHelper.replaceOrigin(httpRequestContext.serverRequest.url, contextIds?.[HttpContextIdKeys.PublicOrigin]), { cursor: result.cursor }, "next");
1033
1319
  }
1034
1320
  return {
1035
1321
  headers,
@@ -1037,7 +1323,7 @@ export async function auditableItemStreamListEntries(httpRequestContext, compone
1037
1323
  };
1038
1324
  }
1039
1325
  /**
1040
- * Query the stream objects.
1326
+ * List the entry objects for a stream.
1041
1327
  * @param httpRequestContext The request context for the API.
1042
1328
  * @param componentName The name of the component to use in the routes.
1043
1329
  * @param request The request.
@@ -1047,7 +1333,6 @@ export async function auditableItemStreamListEntryObjects(httpRequestContext, co
1047
1333
  Guards.object(ROUTES_SOURCE, "request", request);
1048
1334
  Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
1049
1335
  Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
1050
- const hostingComponent = ComponentFactory.get(httpRequestContext.hostingComponentType ?? "hosting");
1051
1336
  const component = ComponentFactory.get(componentName);
1052
1337
  const result = await component.getEntryObjects(request.pathParams.id, {
1053
1338
  conditions: HttpParameterHelper.objectFromString(request.query?.conditions),
@@ -1060,11 +1345,58 @@ export async function auditableItemStreamListEntryObjects(httpRequestContext, co
1060
1345
  [HeaderTypes.ContentType]: request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? MimeTypes.JsonLd : MimeTypes.Json
1061
1346
  };
1062
1347
  if (Is.stringValue(result.cursor)) {
1063
- headers[HeaderTypes.Link] = HeaderHelper.createLinkHeader(await hostingComponent.buildPublicUrl(httpRequestContext.serverRequest.url), { cursor: result.cursor }, "next");
1348
+ const contextIds = await ContextIdStore.getContextIds();
1349
+ headers[HeaderTypes.Link] = HeaderHelper.createLinkHeader(HttpUrlHelper.replaceOrigin(httpRequestContext.serverRequest.url, contextIds?.[HttpContextIdKeys.PublicOrigin]), { cursor: result.cursor }, "next");
1350
+ }
1351
+ return {
1352
+ headers,
1353
+ body: result.entries
1354
+ };
1355
+ }
1356
+ /**
1357
+ * List entry objects across all streams.
1358
+ * @param httpRequestContext The request context for the API.
1359
+ * @param componentName The name of the component to use in the routes.
1360
+ * @param request The request.
1361
+ * @returns The response object with additional http response properties.
1362
+ */
1363
+ export async function auditableItemStreamListEntryObjectsNoStream(httpRequestContext, componentName, request) {
1364
+ Guards.object(ROUTES_SOURCE, "request", request);
1365
+ const component = ComponentFactory.get(componentName);
1366
+ const result = await component.getEntryObjects(undefined, {
1367
+ conditions: HttpParameterHelper.objectFromString(request.query?.conditions),
1368
+ includeDeleted: Coerce.boolean(request.query?.includeDeleted),
1369
+ order: request.query?.order,
1370
+ limit: Coerce.integer(request.query?.limit),
1371
+ cursor: request.query?.cursor
1372
+ });
1373
+ const headers = {
1374
+ [HeaderTypes.ContentType]: request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? MimeTypes.JsonLd : MimeTypes.Json
1375
+ };
1376
+ if (Is.stringValue(result.cursor)) {
1377
+ const contextIds = await ContextIdStore.getContextIds();
1378
+ headers[HeaderTypes.Link] = HeaderHelper.createLinkHeader(HttpUrlHelper.replaceOrigin(httpRequestContext.serverRequest.url, contextIds?.[HttpContextIdKeys.PublicOrigin]), { cursor: result.cursor }, "next");
1064
1379
  }
1065
1380
  return {
1066
1381
  headers,
1067
1382
  body: result.entries
1068
1383
  };
1069
1384
  }
1385
+ /**
1386
+ * Remove the proof from a stream.
1387
+ * @param httpRequestContext The request context for the API.
1388
+ * @param componentName The name of the component to use in the routes.
1389
+ * @param request The request.
1390
+ * @returns The response object with additional http response properties.
1391
+ */
1392
+ export async function auditableItemStreamRemoveProof(httpRequestContext, componentName, request) {
1393
+ Guards.object(ROUTES_SOURCE, "request", request);
1394
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
1395
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
1396
+ const component = ComponentFactory.get(componentName);
1397
+ await component.removeProof(request.pathParams.id);
1398
+ return {
1399
+ statusCode: HttpStatusCode.noContent
1400
+ };
1401
+ }
1070
1402
  //# sourceMappingURL=auditableItemStreamRoutes.js.map