@twin.org/auditable-item-stream-service 0.0.1-next.21 → 0.0.1-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.
- package/dist/cjs/index.cjs +22 -11
- package/dist/esm/index.mjs +22 -11
- package/docs/changelog.md +1 -1
- package/package.json +2 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -1231,16 +1231,21 @@ class AuditableItemStreamService {
|
|
|
1231
1231
|
if (core.Is.empty(streamEntity)) {
|
|
1232
1232
|
throw new core.NotFoundError(this.CLASS_NAME, "streamNotFound", id);
|
|
1233
1233
|
}
|
|
1234
|
+
const verifyStream = options?.verifyStream ?? false;
|
|
1235
|
+
const verifyEntries = options?.verifyEntries ?? false;
|
|
1234
1236
|
const streamModel = await this.streamEntityToJsonLd(streamEntity);
|
|
1235
1237
|
if (options?.includeEntries) {
|
|
1236
|
-
const result = await this.findEntries(streamId, options?.includeDeleted,
|
|
1238
|
+
const result = await this.findEntries(streamId, options?.includeDeleted, verifyEntries);
|
|
1237
1239
|
streamModel.entries = result.entries;
|
|
1238
1240
|
streamModel.cursor = result.cursor;
|
|
1239
1241
|
}
|
|
1240
|
-
if (
|
|
1242
|
+
if (verifyStream && core.Is.stringValue(streamEntity.proofId)) {
|
|
1241
1243
|
streamModel.verification = await this._immutableProofComponent.verify(streamEntity.proofId);
|
|
1242
1244
|
}
|
|
1243
|
-
|
|
1245
|
+
if (verifyStream || verifyEntries) {
|
|
1246
|
+
streamModel["@context"].push(immutableProofModels.ImmutableProofTypes.ContextRoot);
|
|
1247
|
+
}
|
|
1248
|
+
return dataJsonLd.JsonLdProcessor.compact(streamModel, streamModel["@context"]);
|
|
1244
1249
|
}
|
|
1245
1250
|
catch (error) {
|
|
1246
1251
|
throw new core.GeneralError(this.CLASS_NAME, "getFailed", undefined, error);
|
|
@@ -1368,7 +1373,7 @@ class AuditableItemStreamService {
|
|
|
1368
1373
|
itemStreams: results.entities.map(e => this.streamEntityToJsonLd(e)),
|
|
1369
1374
|
cursor: results.cursor
|
|
1370
1375
|
};
|
|
1371
|
-
return dataJsonLd.JsonLdProcessor.compact(list);
|
|
1376
|
+
return dataJsonLd.JsonLdProcessor.compact(list, list["@context"]);
|
|
1372
1377
|
}
|
|
1373
1378
|
catch (error) {
|
|
1374
1379
|
throw new core.GeneralError(this.CLASS_NAME, "queryingFailed", undefined, error);
|
|
@@ -1455,13 +1460,17 @@ class AuditableItemStreamService {
|
|
|
1455
1460
|
if (core.Is.empty(streamEntity)) {
|
|
1456
1461
|
throw new core.NotFoundError(this.CLASS_NAME, "streamNotFound", streamId);
|
|
1457
1462
|
}
|
|
1463
|
+
const verifyEntry = options?.verifyEntry ?? false;
|
|
1458
1464
|
const entryNamespaceId = urnParsedEntry.namespaceSpecific(1);
|
|
1459
|
-
const result = await this.findEntry(streamEntity.nodeIdentity, streamEntity.id, entryNamespaceId,
|
|
1465
|
+
const result = await this.findEntry(streamEntity.nodeIdentity, streamEntity.id, entryNamespaceId, verifyEntry);
|
|
1460
1466
|
if (core.Is.empty(result)) {
|
|
1461
1467
|
throw new core.NotFoundError(this.CLASS_NAME, "streamEntryNotFound", entryId);
|
|
1462
1468
|
}
|
|
1463
1469
|
const entry = this.streamEntryEntityToJsonLd(result.entity);
|
|
1464
|
-
|
|
1470
|
+
if (verifyEntry) {
|
|
1471
|
+
entry.verification = result.verification;
|
|
1472
|
+
}
|
|
1473
|
+
return dataJsonLd.JsonLdProcessor.compact(entry, entry["@context"]);
|
|
1465
1474
|
}
|
|
1466
1475
|
catch (error) {
|
|
1467
1476
|
throw new core.GeneralError(this.CLASS_NAME, "gettingEntryFailed", undefined, error);
|
|
@@ -1655,7 +1664,8 @@ class AuditableItemStreamService {
|
|
|
1655
1664
|
if (core.Is.empty(streamEntity)) {
|
|
1656
1665
|
throw new core.NotFoundError(this.CLASS_NAME, "streamNotFound", streamId);
|
|
1657
1666
|
}
|
|
1658
|
-
const
|
|
1667
|
+
const verifyEntries = options?.verifyEntries ?? false;
|
|
1668
|
+
const result = await this.findEntries(streamNamespaceId, options?.includeDeleted, verifyEntries, options?.conditions, options?.order, undefined, options?.pageSize, options?.cursor);
|
|
1659
1669
|
const list = {
|
|
1660
1670
|
"@context": [
|
|
1661
1671
|
auditableItemStreamModels.AuditableItemStreamTypes.ContextRoot,
|
|
@@ -1666,7 +1676,10 @@ class AuditableItemStreamService {
|
|
|
1666
1676
|
entries: result.entries,
|
|
1667
1677
|
cursor: result.cursor
|
|
1668
1678
|
};
|
|
1669
|
-
|
|
1679
|
+
if (verifyEntries) {
|
|
1680
|
+
list["@context"].push(immutableProofModels.ImmutableProofTypes.ContextRoot);
|
|
1681
|
+
}
|
|
1682
|
+
return dataJsonLd.JsonLdProcessor.compact(list, list["@context"]);
|
|
1670
1683
|
}
|
|
1671
1684
|
catch (error) {
|
|
1672
1685
|
throw new core.GeneralError(this.CLASS_NAME, "gettingEntriesFailed", undefined, error);
|
|
@@ -1709,7 +1722,7 @@ class AuditableItemStreamService {
|
|
|
1709
1722
|
entryObjects: result.entries.map(m => m.entryObject),
|
|
1710
1723
|
cursor: result.cursor
|
|
1711
1724
|
};
|
|
1712
|
-
return dataJsonLd.JsonLdProcessor.compact(list);
|
|
1725
|
+
return dataJsonLd.JsonLdProcessor.compact(list, list["@context"]);
|
|
1713
1726
|
}
|
|
1714
1727
|
catch (error) {
|
|
1715
1728
|
throw new core.GeneralError(this.CLASS_NAME, "gettingEntryObjectsFailed", undefined, error);
|
|
@@ -1755,7 +1768,6 @@ class AuditableItemStreamService {
|
|
|
1755
1768
|
"@context": [
|
|
1756
1769
|
auditableItemStreamModels.AuditableItemStreamTypes.ContextRoot,
|
|
1757
1770
|
auditableItemStreamModels.AuditableItemStreamTypes.ContextRootCommon,
|
|
1758
|
-
immutableProofModels.ImmutableProofTypes.ContextRoot,
|
|
1759
1771
|
standardsSchemaOrg.SchemaOrgTypes.ContextRoot
|
|
1760
1772
|
],
|
|
1761
1773
|
type: auditableItemStreamModels.AuditableItemStreamTypes.Stream,
|
|
@@ -1781,7 +1793,6 @@ class AuditableItemStreamService {
|
|
|
1781
1793
|
"@context": [
|
|
1782
1794
|
auditableItemStreamModels.AuditableItemStreamTypes.ContextRoot,
|
|
1783
1795
|
auditableItemStreamModels.AuditableItemStreamTypes.ContextRootCommon,
|
|
1784
|
-
immutableProofModels.ImmutableProofTypes.ContextRoot,
|
|
1785
1796
|
standardsSchemaOrg.SchemaOrgTypes.ContextRoot
|
|
1786
1797
|
],
|
|
1787
1798
|
type: auditableItemStreamModels.AuditableItemStreamTypes.StreamEntry,
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1229,16 +1229,21 @@ class AuditableItemStreamService {
|
|
|
1229
1229
|
if (Is.empty(streamEntity)) {
|
|
1230
1230
|
throw new NotFoundError(this.CLASS_NAME, "streamNotFound", id);
|
|
1231
1231
|
}
|
|
1232
|
+
const verifyStream = options?.verifyStream ?? false;
|
|
1233
|
+
const verifyEntries = options?.verifyEntries ?? false;
|
|
1232
1234
|
const streamModel = await this.streamEntityToJsonLd(streamEntity);
|
|
1233
1235
|
if (options?.includeEntries) {
|
|
1234
|
-
const result = await this.findEntries(streamId, options?.includeDeleted,
|
|
1236
|
+
const result = await this.findEntries(streamId, options?.includeDeleted, verifyEntries);
|
|
1235
1237
|
streamModel.entries = result.entries;
|
|
1236
1238
|
streamModel.cursor = result.cursor;
|
|
1237
1239
|
}
|
|
1238
|
-
if (
|
|
1240
|
+
if (verifyStream && Is.stringValue(streamEntity.proofId)) {
|
|
1239
1241
|
streamModel.verification = await this._immutableProofComponent.verify(streamEntity.proofId);
|
|
1240
1242
|
}
|
|
1241
|
-
|
|
1243
|
+
if (verifyStream || verifyEntries) {
|
|
1244
|
+
streamModel["@context"].push(ImmutableProofTypes.ContextRoot);
|
|
1245
|
+
}
|
|
1246
|
+
return JsonLdProcessor.compact(streamModel, streamModel["@context"]);
|
|
1242
1247
|
}
|
|
1243
1248
|
catch (error) {
|
|
1244
1249
|
throw new GeneralError(this.CLASS_NAME, "getFailed", undefined, error);
|
|
@@ -1366,7 +1371,7 @@ class AuditableItemStreamService {
|
|
|
1366
1371
|
itemStreams: results.entities.map(e => this.streamEntityToJsonLd(e)),
|
|
1367
1372
|
cursor: results.cursor
|
|
1368
1373
|
};
|
|
1369
|
-
return JsonLdProcessor.compact(list);
|
|
1374
|
+
return JsonLdProcessor.compact(list, list["@context"]);
|
|
1370
1375
|
}
|
|
1371
1376
|
catch (error) {
|
|
1372
1377
|
throw new GeneralError(this.CLASS_NAME, "queryingFailed", undefined, error);
|
|
@@ -1453,13 +1458,17 @@ class AuditableItemStreamService {
|
|
|
1453
1458
|
if (Is.empty(streamEntity)) {
|
|
1454
1459
|
throw new NotFoundError(this.CLASS_NAME, "streamNotFound", streamId);
|
|
1455
1460
|
}
|
|
1461
|
+
const verifyEntry = options?.verifyEntry ?? false;
|
|
1456
1462
|
const entryNamespaceId = urnParsedEntry.namespaceSpecific(1);
|
|
1457
|
-
const result = await this.findEntry(streamEntity.nodeIdentity, streamEntity.id, entryNamespaceId,
|
|
1463
|
+
const result = await this.findEntry(streamEntity.nodeIdentity, streamEntity.id, entryNamespaceId, verifyEntry);
|
|
1458
1464
|
if (Is.empty(result)) {
|
|
1459
1465
|
throw new NotFoundError(this.CLASS_NAME, "streamEntryNotFound", entryId);
|
|
1460
1466
|
}
|
|
1461
1467
|
const entry = this.streamEntryEntityToJsonLd(result.entity);
|
|
1462
|
-
|
|
1468
|
+
if (verifyEntry) {
|
|
1469
|
+
entry.verification = result.verification;
|
|
1470
|
+
}
|
|
1471
|
+
return JsonLdProcessor.compact(entry, entry["@context"]);
|
|
1463
1472
|
}
|
|
1464
1473
|
catch (error) {
|
|
1465
1474
|
throw new GeneralError(this.CLASS_NAME, "gettingEntryFailed", undefined, error);
|
|
@@ -1653,7 +1662,8 @@ class AuditableItemStreamService {
|
|
|
1653
1662
|
if (Is.empty(streamEntity)) {
|
|
1654
1663
|
throw new NotFoundError(this.CLASS_NAME, "streamNotFound", streamId);
|
|
1655
1664
|
}
|
|
1656
|
-
const
|
|
1665
|
+
const verifyEntries = options?.verifyEntries ?? false;
|
|
1666
|
+
const result = await this.findEntries(streamNamespaceId, options?.includeDeleted, verifyEntries, options?.conditions, options?.order, undefined, options?.pageSize, options?.cursor);
|
|
1657
1667
|
const list = {
|
|
1658
1668
|
"@context": [
|
|
1659
1669
|
AuditableItemStreamTypes.ContextRoot,
|
|
@@ -1664,7 +1674,10 @@ class AuditableItemStreamService {
|
|
|
1664
1674
|
entries: result.entries,
|
|
1665
1675
|
cursor: result.cursor
|
|
1666
1676
|
};
|
|
1667
|
-
|
|
1677
|
+
if (verifyEntries) {
|
|
1678
|
+
list["@context"].push(ImmutableProofTypes.ContextRoot);
|
|
1679
|
+
}
|
|
1680
|
+
return JsonLdProcessor.compact(list, list["@context"]);
|
|
1668
1681
|
}
|
|
1669
1682
|
catch (error) {
|
|
1670
1683
|
throw new GeneralError(this.CLASS_NAME, "gettingEntriesFailed", undefined, error);
|
|
@@ -1707,7 +1720,7 @@ class AuditableItemStreamService {
|
|
|
1707
1720
|
entryObjects: result.entries.map(m => m.entryObject),
|
|
1708
1721
|
cursor: result.cursor
|
|
1709
1722
|
};
|
|
1710
|
-
return JsonLdProcessor.compact(list);
|
|
1723
|
+
return JsonLdProcessor.compact(list, list["@context"]);
|
|
1711
1724
|
}
|
|
1712
1725
|
catch (error) {
|
|
1713
1726
|
throw new GeneralError(this.CLASS_NAME, "gettingEntryObjectsFailed", undefined, error);
|
|
@@ -1753,7 +1766,6 @@ class AuditableItemStreamService {
|
|
|
1753
1766
|
"@context": [
|
|
1754
1767
|
AuditableItemStreamTypes.ContextRoot,
|
|
1755
1768
|
AuditableItemStreamTypes.ContextRootCommon,
|
|
1756
|
-
ImmutableProofTypes.ContextRoot,
|
|
1757
1769
|
SchemaOrgTypes.ContextRoot
|
|
1758
1770
|
],
|
|
1759
1771
|
type: AuditableItemStreamTypes.Stream,
|
|
@@ -1779,7 +1791,6 @@ class AuditableItemStreamService {
|
|
|
1779
1791
|
"@context": [
|
|
1780
1792
|
AuditableItemStreamTypes.ContextRoot,
|
|
1781
1793
|
AuditableItemStreamTypes.ContextRootCommon,
|
|
1782
|
-
ImmutableProofTypes.ContextRoot,
|
|
1783
1794
|
SchemaOrgTypes.ContextRoot
|
|
1784
1795
|
],
|
|
1785
1796
|
type: AuditableItemStreamTypes.StreamEntry,
|
package/docs/changelog.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/auditable-item-stream-service",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.22",
|
|
4
4
|
"description": "Auditable Item Stream contract implementation and REST endpoint definitions",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@twin.org/api-models": "next",
|
|
18
|
-
"@twin.org/auditable-item-stream-models": "0.0.1-next.
|
|
18
|
+
"@twin.org/auditable-item-stream-models": "0.0.1-next.22",
|
|
19
19
|
"@twin.org/core": "next",
|
|
20
20
|
"@twin.org/crypto": "next",
|
|
21
21
|
"@twin.org/data-json-ld": "next",
|