@twin.org/auditable-item-stream-service 0.0.3-next.20 → 0.0.3-next.22

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 (28) hide show
  1. package/dist/es/auditableItemStreamRoutes.js +69 -21
  2. package/dist/es/auditableItemStreamRoutes.js.map +1 -1
  3. package/dist/es/auditableItemStreamService.js +25 -24
  4. package/dist/es/auditableItemStreamService.js.map +1 -1
  5. package/dist/es/entities/auditableItemStream.js +1 -1
  6. package/dist/es/entities/auditableItemStream.js.map +1 -1
  7. package/dist/es/models/IAuditableItemStreamServiceContext.js.map +1 -1
  8. package/dist/es/restEntryPoints.js +3 -0
  9. package/dist/es/restEntryPoints.js.map +1 -1
  10. package/dist/types/auditableItemStreamRoutes.d.ts +15 -7
  11. package/dist/types/auditableItemStreamService.d.ts +7 -6
  12. package/dist/types/entities/auditableItemStream.d.ts +1 -1
  13. package/dist/types/models/IAuditableItemStreamServiceContext.d.ts +1 -1
  14. package/dist/types/restEntryPoints.d.ts +3 -0
  15. package/docs/changelog.md +41 -0
  16. package/docs/open-api/spec.json +112 -2
  17. package/docs/reference/classes/AuditableItemStream.md +2 -2
  18. package/docs/reference/classes/AuditableItemStreamService.md +8 -6
  19. package/docs/reference/functions/auditableItemStreamDeleteEntry.md +1 -1
  20. package/docs/reference/functions/auditableItemStreamList.md +1 -1
  21. package/docs/reference/functions/auditableItemStreamListEntries.md +1 -1
  22. package/docs/reference/functions/auditableItemStreamListEntriesNoStream.md +1 -1
  23. package/docs/reference/functions/auditableItemStreamListEntryObjects.md +1 -1
  24. package/docs/reference/functions/auditableItemStreamListEntryObjectsNoStream.md +1 -1
  25. package/docs/reference/functions/auditableItemStreamRemoveProof.md +31 -0
  26. package/docs/reference/index.md +1 -0
  27. package/docs/reference/variables/restEntryPoints.md +2 -0
  28. package/package.json +2 -2
@@ -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
  /**
@@ -975,6 +976,35 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
975
976
  }
976
977
  ]
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
+ };
978
1008
  return [
979
1009
  createRoute,
980
1010
  getRoute,
@@ -990,7 +1020,8 @@ export function generateRestRoutesAuditableItemStream(baseRouteName, componentNa
990
1020
  listEntriesRoute,
991
1021
  listEntriesNoStreamRoute,
992
1022
  listEntryObjectsRoute,
993
- listEntryObjectsNoStreamRoute
1023
+ listEntryObjectsNoStreamRoute,
1024
+ removeProofRoute
994
1025
  ];
995
1026
  }
996
1027
  /**
@@ -1023,7 +1054,6 @@ export async function auditableItemStreamGet(httpRequestContext, componentName,
1023
1054
  Guards.object(ROUTES_SOURCE, "request", request);
1024
1055
  Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
1025
1056
  Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
1026
- const hostingComponent = ComponentFactory.get(httpRequestContext.hostingComponentType ?? "hosting");
1027
1057
  const component = ComponentFactory.get(componentName);
1028
1058
  const result = await component.get(request.pathParams.id, request.query?.cursor, Coerce.integer(request.query?.limit), {
1029
1059
  includeEntries: Coerce.boolean(request.query?.includeEntries),
@@ -1035,7 +1065,8 @@ export async function auditableItemStreamGet(httpRequestContext, componentName,
1035
1065
  [HeaderTypes.ContentType]: request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? MimeTypes.JsonLd : MimeTypes.Json
1036
1066
  };
1037
1067
  if (Is.stringValue(result.cursor)) {
1038
- headers[HeaderTypes.Link] = HeaderHelper.createLinkHeader(await hostingComponent.buildPublicUrl(httpRequestContext.serverRequest.url), { cursor: result.cursor }, "next");
1068
+ const contextIds = await ContextIdStore.getContextIds();
1069
+ headers[HeaderTypes.Link] = HeaderHelper.createLinkHeader(HttpUrlHelper.replaceOrigin(httpRequestContext.serverRequest.url, contextIds?.[HttpContextIdKeys.PublicOrigin]), { cursor: result.cursor }, "next");
1039
1070
  }
1040
1071
  return {
1041
1072
  headers,
@@ -1098,7 +1129,7 @@ export async function auditableItemStreamClose(httpRequestContext, componentName
1098
1129
  };
1099
1130
  }
1100
1131
  /**
1101
- * Query the stream.
1132
+ * List all streams.
1102
1133
  * @param httpRequestContext The request context for the API.
1103
1134
  * @param componentName The name of the component to use in the routes.
1104
1135
  * @param request The request.
@@ -1107,14 +1138,14 @@ export async function auditableItemStreamClose(httpRequestContext, componentName
1107
1138
  export async function auditableItemStreamList(httpRequestContext, componentName, request) {
1108
1139
  Guards.object(ROUTES_SOURCE, "request", request);
1109
1140
  Guards.object(ROUTES_SOURCE, "request.query", request.query);
1110
- const hostingComponent = ComponentFactory.get(httpRequestContext.hostingComponentType ?? "hosting");
1111
1141
  const component = ComponentFactory.get(componentName);
1112
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));
1113
1143
  const headers = {
1114
1144
  [HeaderTypes.ContentType]: request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? MimeTypes.JsonLd : MimeTypes.Json
1115
1145
  };
1116
1146
  if (Is.stringValue(result.cursor)) {
1117
- 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");
1118
1149
  }
1119
1150
  return {
1120
1151
  headers,
@@ -1144,7 +1175,7 @@ export async function auditableItemStreamCreateEntry(httpRequestContext, compone
1144
1175
  };
1145
1176
  }
1146
1177
  /**
1147
- * Get the stream.
1178
+ * Delete an entry from the stream.
1148
1179
  * @param httpRequestContext The request context for the API.
1149
1180
  * @param componentName The name of the component to use in the routes.
1150
1181
  * @param request The request.
@@ -1230,7 +1261,7 @@ export async function auditableItemStreamGetEntryObject(httpRequestContext, comp
1230
1261
  };
1231
1262
  }
1232
1263
  /**
1233
- * Query the stream.
1264
+ * List the entries for a stream.
1234
1265
  * @param httpRequestContext The request context for the API.
1235
1266
  * @param componentName The name of the component to use in the routes.
1236
1267
  * @param request The request.
@@ -1240,7 +1271,6 @@ export async function auditableItemStreamListEntries(httpRequestContext, compone
1240
1271
  Guards.object(ROUTES_SOURCE, "request", request);
1241
1272
  Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
1242
1273
  Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
1243
- const hostingComponent = ComponentFactory.get(httpRequestContext.hostingComponentType ?? "hosting");
1244
1274
  const component = ComponentFactory.get(componentName);
1245
1275
  const result = await component.getEntries(request.pathParams.id, {
1246
1276
  conditions: HttpParameterHelper.objectFromString(request.query?.conditions),
@@ -1254,7 +1284,8 @@ export async function auditableItemStreamListEntries(httpRequestContext, compone
1254
1284
  [HeaderTypes.ContentType]: request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? MimeTypes.JsonLd : MimeTypes.Json
1255
1285
  };
1256
1286
  if (Is.stringValue(result.cursor)) {
1257
- 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");
1258
1289
  }
1259
1290
  return {
1260
1291
  headers,
@@ -1262,7 +1293,7 @@ export async function auditableItemStreamListEntries(httpRequestContext, compone
1262
1293
  };
1263
1294
  }
1264
1295
  /**
1265
- * Query the stream.
1296
+ * List entries across all streams.
1266
1297
  * @param httpRequestContext The request context for the API.
1267
1298
  * @param componentName The name of the component to use in the routes.
1268
1299
  * @param request The request.
@@ -1270,7 +1301,6 @@ export async function auditableItemStreamListEntries(httpRequestContext, compone
1270
1301
  */
1271
1302
  export async function auditableItemStreamListEntriesNoStream(httpRequestContext, componentName, request) {
1272
1303
  Guards.object(ROUTES_SOURCE, "request", request);
1273
- const hostingComponent = ComponentFactory.get(httpRequestContext.hostingComponentType ?? "hosting");
1274
1304
  const component = ComponentFactory.get(componentName);
1275
1305
  const result = await component.getEntries(undefined, {
1276
1306
  conditions: HttpParameterHelper.objectFromString(request.query?.conditions),
@@ -1284,7 +1314,8 @@ export async function auditableItemStreamListEntriesNoStream(httpRequestContext,
1284
1314
  [HeaderTypes.ContentType]: request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? MimeTypes.JsonLd : MimeTypes.Json
1285
1315
  };
1286
1316
  if (Is.stringValue(result.cursor)) {
1287
- headers[HeaderTypes.Link] = HeaderHelper.createLinkHeader(await hostingComponent.buildPublicUrl(httpRequestContext.serverRequest.url), { cursor: result.cursor }, "next");
1317
+ const contextIds = await ContextIdStore.getContextIds();
1318
+ headers[HeaderTypes.Link] = HeaderHelper.createLinkHeader(HttpUrlHelper.replaceOrigin(httpRequestContext.serverRequest.url, contextIds?.[HttpContextIdKeys.PublicOrigin]), { cursor: result.cursor }, "next");
1288
1319
  }
1289
1320
  return {
1290
1321
  headers,
@@ -1292,7 +1323,7 @@ export async function auditableItemStreamListEntriesNoStream(httpRequestContext,
1292
1323
  };
1293
1324
  }
1294
1325
  /**
1295
- * Query the stream objects.
1326
+ * List the entry objects for a stream.
1296
1327
  * @param httpRequestContext The request context for the API.
1297
1328
  * @param componentName The name of the component to use in the routes.
1298
1329
  * @param request The request.
@@ -1302,7 +1333,6 @@ export async function auditableItemStreamListEntryObjects(httpRequestContext, co
1302
1333
  Guards.object(ROUTES_SOURCE, "request", request);
1303
1334
  Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
1304
1335
  Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
1305
- const hostingComponent = ComponentFactory.get(httpRequestContext.hostingComponentType ?? "hosting");
1306
1336
  const component = ComponentFactory.get(componentName);
1307
1337
  const result = await component.getEntryObjects(request.pathParams.id, {
1308
1338
  conditions: HttpParameterHelper.objectFromString(request.query?.conditions),
@@ -1315,7 +1345,8 @@ export async function auditableItemStreamListEntryObjects(httpRequestContext, co
1315
1345
  [HeaderTypes.ContentType]: request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? MimeTypes.JsonLd : MimeTypes.Json
1316
1346
  };
1317
1347
  if (Is.stringValue(result.cursor)) {
1318
- 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");
1319
1350
  }
1320
1351
  return {
1321
1352
  headers,
@@ -1323,7 +1354,7 @@ export async function auditableItemStreamListEntryObjects(httpRequestContext, co
1323
1354
  };
1324
1355
  }
1325
1356
  /**
1326
- * Query the stream objects.
1357
+ * List entry objects across all streams.
1327
1358
  * @param httpRequestContext The request context for the API.
1328
1359
  * @param componentName The name of the component to use in the routes.
1329
1360
  * @param request The request.
@@ -1331,7 +1362,6 @@ export async function auditableItemStreamListEntryObjects(httpRequestContext, co
1331
1362
  */
1332
1363
  export async function auditableItemStreamListEntryObjectsNoStream(httpRequestContext, componentName, request) {
1333
1364
  Guards.object(ROUTES_SOURCE, "request", request);
1334
- const hostingComponent = ComponentFactory.get(httpRequestContext.hostingComponentType ?? "hosting");
1335
1365
  const component = ComponentFactory.get(componentName);
1336
1366
  const result = await component.getEntryObjects(undefined, {
1337
1367
  conditions: HttpParameterHelper.objectFromString(request.query?.conditions),
@@ -1344,11 +1374,29 @@ export async function auditableItemStreamListEntryObjectsNoStream(httpRequestCon
1344
1374
  [HeaderTypes.ContentType]: request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? MimeTypes.JsonLd : MimeTypes.Json
1345
1375
  };
1346
1376
  if (Is.stringValue(result.cursor)) {
1347
- headers[HeaderTypes.Link] = HeaderHelper.createLinkHeader(await hostingComponent.buildPublicUrl(httpRequestContext.serverRequest.url), { cursor: result.cursor }, "next");
1377
+ const contextIds = await ContextIdStore.getContextIds();
1378
+ headers[HeaderTypes.Link] = HeaderHelper.createLinkHeader(HttpUrlHelper.replaceOrigin(httpRequestContext.serverRequest.url, contextIds?.[HttpContextIdKeys.PublicOrigin]), { cursor: result.cursor }, "next");
1348
1379
  }
1349
1380
  return {
1350
1381
  headers,
1351
1382
  body: result.entries
1352
1383
  };
1353
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
+ }
1354
1402
  //# sourceMappingURL=auditableItemStreamRoutes.js.map