@twin.org/auditable-item-stream-service 0.0.3-next.9 → 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 +401 -73
  3. package/dist/es/auditableItemStreamRoutes.js.map +1 -1
  4. package/dist/es/auditableItemStreamService.js +304 -113
  5. package/dist/es/auditableItemStreamService.js.map +1 -1
  6. package/dist/es/entities/auditableItemStream.js +17 -3
  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 +10 -1
  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 +371 -92
  21. package/docs/examples.md +211 -1
  22. package/docs/open-api/spec.json +832 -169
  23. package/docs/reference/classes/AuditableItemStream.md +30 -14
  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
  ],
@@ -125,25 +137,28 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
125
137
  proofId: "0101010101010101010101010101010101010101010101010101010101010101",
126
138
  immutableInterval: 10,
127
139
  numberOfItems: 1,
128
- entries: [
129
- {
130
- "@context": [
131
- AuditableItemStreamContexts.Context,
132
- AuditableItemStreamContexts.ContextCommon
133
- ],
134
- type: AuditableItemStreamTypes.StreamEntry,
135
- id: "tst:1234567890",
136
- dateCreated: "2024-08-22T11:55:16.271Z",
137
- proofId: "0101010101010101010101010101010101010101010101010101010101010101",
138
- index: 0,
139
- entryObject: {
140
- "@context": "https://schema.org",
141
- "@type": "Event",
142
- startDate: "2011-04-09T20:00:00Z",
143
- description: "A description of the event"
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
+ }
144
159
  }
145
- }
146
- ]
160
+ ]
161
+ }
147
162
  }
148
163
  }
149
164
  }
@@ -161,6 +176,7 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
161
176
  },
162
177
  body: {
163
178
  "@context": [
179
+ SchemaOrgContexts.Context,
164
180
  AuditableItemStreamContexts.Context,
165
181
  AuditableItemStreamContexts.ContextCommon
166
182
  ],
@@ -177,25 +193,28 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
177
193
  proofId: "0101010101010101010101010101010101010101010101010101010101010101",
178
194
  immutableInterval: 10,
179
195
  numberOfItems: 1,
180
- entries: [
181
- {
182
- "@context": [
183
- AuditableItemStreamContexts.Context,
184
- AuditableItemStreamContexts.ContextCommon
185
- ],
186
- type: AuditableItemStreamTypes.StreamEntry,
187
- id: "tst:1234567890",
188
- dateCreated: "2024-08-22T11:55:16.271Z",
189
- proofId: "0101010101010101010101010101010101010101010101010101010101010101",
190
- index: 0,
191
- entryObject: {
192
- "@context": "https://schema.org",
193
- "@type": "Event",
194
- startDate: "2011-04-09T20:00:00Z",
195
- description: "A description of the event"
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
+ }
196
215
  }
197
- }
198
- ]
216
+ ]
217
+ }
199
218
  }
200
219
  }
201
220
  }
@@ -223,6 +242,12 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
223
242
  id: "ais:1234567890"
224
243
  },
225
244
  body: {
245
+ "@context": [
246
+ SchemaOrgContexts.Context,
247
+ AuditableItemStreamContexts.Context,
248
+ AuditableItemStreamContexts.ContextCommon
249
+ ],
250
+ type: AuditableItemStreamTypes.Stream,
226
251
  annotationObject: {
227
252
  "@context": "https://schema.org",
228
253
  "@type": "Note",
@@ -271,6 +296,35 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
271
296
  }
272
297
  ]
273
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
+ };
274
328
  const listRoute = {
275
329
  operationId: "auditableItemStreamList",
276
330
  summary: "Query streams",
@@ -304,6 +358,7 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
304
358
  [SchemaOrgTypes.ItemListElement]: [
305
359
  {
306
360
  "@context": [
361
+ SchemaOrgContexts.Context,
307
362
  AuditableItemStreamContexts.Context,
308
363
  AuditableItemStreamContexts.ContextCommon
309
364
  ],
@@ -347,6 +402,7 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
347
402
  [SchemaOrgTypes.ItemListElement]: [
348
403
  {
349
404
  "@context": [
405
+ SchemaOrgContexts.Context,
350
406
  AuditableItemStreamContexts.Context,
351
407
  AuditableItemStreamContexts.ContextCommon
352
408
  ],
@@ -720,6 +776,106 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
720
776
  }
721
777
  ]
722
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
+ };
723
879
  const listEntryObjectsRoute = {
724
880
  operationId: "auditableItemStreamListEntryObjects",
725
881
  summary: "Get the entry objects in a stream",
@@ -772,11 +928,89 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
772
928
  }
773
929
  ]
774
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
+ };
775
1008
  return [
776
1009
  createRoute,
777
1010
  getRoute,
778
1011
  updateRoute,
779
1012
  deleteRoute,
1013
+ closeRoute,
780
1014
  listRoute,
781
1015
  createEntryRoute,
782
1016
  getEntryRoute,
@@ -784,7 +1018,10 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
784
1018
  deleteEntryRoute,
785
1019
  updateEntryRoute,
786
1020
  listEntriesRoute,
787
- listEntryObjectsRoute
1021
+ listEntriesNoStreamRoute,
1022
+ listEntryObjectsRoute,
1023
+ listEntryObjectsNoStreamRoute,
1024
+ removeProofRoute
788
1025
  ];
789
1026
  }
790
1027
  /**
@@ -798,12 +1035,7 @@ export async function auditableItemStreamCreate(httpRequestContext, componentNam
798
1035
  Guards.object(ROUTES_SOURCE, "request", request);
799
1036
  Guards.object(ROUTES_SOURCE, "request.body", request.body);
800
1037
  const component = ComponentFactory.get(componentName);
801
- const id = await component.create({
802
- annotationObject: request.body.annotationObject,
803
- entries: request.body.entries
804
- }, {
805
- immutableInterval: request.body?.immutableInterval
806
- });
1038
+ const id = await component.create(request.body);
807
1039
  return {
808
1040
  statusCode: HttpStatusCode.created,
809
1041
  headers: {
@@ -823,19 +1055,22 @@ export async function auditableItemStreamGet(httpRequestContext, componentName,
823
1055
  Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
824
1056
  Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
825
1057
  const component = ComponentFactory.get(componentName);
826
- 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), {
827
1059
  includeEntries: Coerce.boolean(request.query?.includeEntries),
828
1060
  includeDeleted: Coerce.boolean(request.query?.includeDeleted),
829
1061
  verifyStream: Coerce.boolean(request.query?.verifyStream),
830
1062
  verifyEntries: Coerce.boolean(request.query?.verifyEntries)
831
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
+ }
832
1071
  return {
833
- headers: {
834
- [HeaderTypes.ContentType]: request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd
835
- ? MimeTypes.JsonLd
836
- : MimeTypes.Json
837
- },
838
- body: result
1072
+ headers,
1073
+ body: result.stream
839
1074
  };
840
1075
  }
841
1076
  /**
@@ -852,8 +1087,8 @@ export async function auditableItemStreamUpdate(httpRequestContext, componentNam
852
1087
  Guards.object(ROUTES_SOURCE, "request.body", request.body);
853
1088
  const component = ComponentFactory.get(componentName);
854
1089
  await component.update({
855
- id: request.pathParams.id,
856
- annotationObject: request.body.annotationObject
1090
+ ...request.body,
1091
+ id: request.pathParams.id
857
1092
  });
858
1093
  return {
859
1094
  statusCode: HttpStatusCode.noContent
@@ -877,7 +1112,24 @@ export async function auditableItemStreamDelete(httpRequestContext, componentNam
877
1112
  };
878
1113
  }
879
1114
  /**
880
- * 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.
881
1133
  * @param httpRequestContext The request context for the API.
882
1134
  * @param componentName The name of the component to use in the routes.
883
1135
  * @param request The request.
@@ -886,14 +1138,14 @@ export async function auditableItemStreamDelete(httpRequestContext, componentNam
886
1138
  export async function auditableItemStreamList(httpRequestContext, componentName, request) {
887
1139
  Guards.object(ROUTES_SOURCE, "request", request);
888
1140
  Guards.object(ROUTES_SOURCE, "request.query", request.query);
889
- const hostingComponent = ComponentFactory.get(httpRequestContext.hostingComponentType ?? "hosting");
890
1141
  const component = ComponentFactory.get(componentName);
891
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));
892
1143
  const headers = {
893
1144
  [HeaderTypes.ContentType]: request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? MimeTypes.JsonLd : MimeTypes.Json
894
1145
  };
895
1146
  if (Is.stringValue(result.cursor)) {
896
- 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");
897
1149
  }
898
1150
  return {
899
1151
  headers,
@@ -923,7 +1175,7 @@ export async function auditableItemStreamCreateEntry(httpRequestContext, compone
923
1175
  };
924
1176
  }
925
1177
  /**
926
- * Get the stream.
1178
+ * Delete an entry from the stream.
927
1179
  * @param httpRequestContext The request context for the API.
928
1180
  * @param componentName The name of the component to use in the routes.
929
1181
  * @param request The request.
@@ -1009,7 +1261,7 @@ export async function auditableItemStreamGetEntryObject(httpRequestContext, comp
1009
1261
  };
1010
1262
  }
1011
1263
  /**
1012
- * Query the stream.
1264
+ * List the entries for a stream.
1013
1265
  * @param httpRequestContext The request context for the API.
1014
1266
  * @param componentName The name of the component to use in the routes.
1015
1267
  * @param request The request.
@@ -1019,7 +1271,6 @@ export async function auditableItemStreamListEntries(httpRequestContext, compone
1019
1271
  Guards.object(ROUTES_SOURCE, "request", request);
1020
1272
  Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
1021
1273
  Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
1022
- const hostingComponent = ComponentFactory.get(httpRequestContext.hostingComponentType ?? "hosting");
1023
1274
  const component = ComponentFactory.get(componentName);
1024
1275
  const result = await component.getEntries(request.pathParams.id, {
1025
1276
  conditions: HttpParameterHelper.objectFromString(request.query?.conditions),
@@ -1033,7 +1284,38 @@ export async function auditableItemStreamListEntries(httpRequestContext, compone
1033
1284
  [HeaderTypes.ContentType]: request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? MimeTypes.JsonLd : MimeTypes.Json
1034
1285
  };
1035
1286
  if (Is.stringValue(result.cursor)) {
1036
- 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");
1037
1319
  }
1038
1320
  return {
1039
1321
  headers,
@@ -1041,7 +1323,7 @@ export async function auditableItemStreamListEntries(httpRequestContext, compone
1041
1323
  };
1042
1324
  }
1043
1325
  /**
1044
- * Query the stream objects.
1326
+ * List the entry objects for a stream.
1045
1327
  * @param httpRequestContext The request context for the API.
1046
1328
  * @param componentName The name of the component to use in the routes.
1047
1329
  * @param request The request.
@@ -1051,7 +1333,6 @@ export async function auditableItemStreamListEntryObjects(httpRequestContext, co
1051
1333
  Guards.object(ROUTES_SOURCE, "request", request);
1052
1334
  Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
1053
1335
  Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
1054
- const hostingComponent = ComponentFactory.get(httpRequestContext.hostingComponentType ?? "hosting");
1055
1336
  const component = ComponentFactory.get(componentName);
1056
1337
  const result = await component.getEntryObjects(request.pathParams.id, {
1057
1338
  conditions: HttpParameterHelper.objectFromString(request.query?.conditions),
@@ -1064,11 +1345,58 @@ export async function auditableItemStreamListEntryObjects(httpRequestContext, co
1064
1345
  [HeaderTypes.ContentType]: request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? MimeTypes.JsonLd : MimeTypes.Json
1065
1346
  };
1066
1347
  if (Is.stringValue(result.cursor)) {
1067
- 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");
1068
1379
  }
1069
1380
  return {
1070
1381
  headers,
1071
1382
  body: result.entries
1072
1383
  };
1073
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
+ }
1074
1402
  //# sourceMappingURL=auditableItemStreamRoutes.js.map