@peac/audit 0.12.12 → 0.12.14
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/commerce-bundle-types.d.ts +47 -0
- package/dist/commerce-bundle-types.d.ts.map +1 -1
- package/dist/commerce-bundle.d.ts +24 -1
- package/dist/commerce-bundle.d.ts.map +1 -1
- package/dist/index.cjs +57 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +56 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -58,7 +58,7 @@ export { BUNDLE_VERSION, createCaseBundle, generateBundleSummary, filterByDisput
|
|
|
58
58
|
export { BUNDLE_VERSION as DISPUTE_BUNDLE_VERSION_v2, DISPUTE_BUNDLE_VERSION, VERIFICATION_REPORT_VERSION, type BundleKind, type BundleRef, type ManifestFileEntry, type ManifestReceiptEntry, type ManifestKeyEntry, type BundleTimeRange, type DisputeBundleManifest, type CreateDisputeBundleOptions, type JsonWebKeySet, type JsonWebKey, type DisputeBundleContents, type ReceiptVerificationResult, type KeyUsageEntry, type AuditorSummary, type VerificationReport, type VerifyBundleOptions, type BundleError, type BundleResult, } from './dispute-bundle-types.js';
|
|
59
59
|
export { createDisputeBundle, readDisputeBundle, verifyBundleIntegrity, getBundleContentHash, } from './dispute-bundle.js';
|
|
60
60
|
export { verifyBundle, serializeReport, formatReportText } from './verification-report.js';
|
|
61
|
-
export type { CommerceEvidenceBundle, CommerceSummary, CreateCommerceBundleOptions, ProtocolEvidence, TimelineEntry, ObservedAmount, } from './commerce-bundle-types.js';
|
|
62
|
-
export { COMMERCE_BUNDLE_VERSION } from './commerce-bundle-types.js';
|
|
63
|
-
export { createCommerceEvidenceBundle, addProtocolEvidence, addTimelineEntry, addReceiptRef, computeCommerceSummary, serializeCommerceBundle, } from './commerce-bundle.js';
|
|
61
|
+
export type { CommerceEvidenceBundle, CommerceSummary, CreateCommerceBundleOptions, LifecycleBundle, LifecycleInputRecord, ProtocolEvidence, TimelineEntry, ObservedAmount, } from './commerce-bundle-types.js';
|
|
62
|
+
export { COMMERCE_BUNDLE_VERSION, UNCLASSIFIED_LIFECYCLE_BUCKET } from './commerce-bundle-types.js';
|
|
63
|
+
export { createCommerceEvidenceBundle, addProtocolEvidence, addTimelineEntry, addReceiptRef, computeCommerceSummary, serializeCommerceBundle, groupByLifecycle, } from './commerce-bundle.js';
|
|
64
64
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAG9C,YAAY,EACV,cAAc,EACd,aAAa,EACb,YAAY,EACZ,UAAU,EACV,aAAa,EACb,YAAY,EACZ,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,gBAAgB,GACtB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,eAAe,EACf,WAAW,EACX,cAAc,EACd,UAAU,EACV,mBAAmB,EACnB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,GACtB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe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A4B,CAAC;AAEpC,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAEpG,OAAO,EACL,4BAA4B,EAC5B,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,sBAAsB,EACtB,uBAAuB,EACvB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -1527,6 +1527,7 @@ function formatReportText(report) {
|
|
|
1527
1527
|
|
|
1528
1528
|
// src/commerce-bundle-types.ts
|
|
1529
1529
|
var COMMERCE_BUNDLE_VERSION = "peac.commerce-bundle/0.1-experimental";
|
|
1530
|
+
var UNCLASSIFIED_LIFECYCLE_BUCKET = "unclassified";
|
|
1530
1531
|
|
|
1531
1532
|
// src/commerce-bundle.ts
|
|
1532
1533
|
function createCommerceEvidenceBundle(options) {
|
|
@@ -1621,10 +1622,64 @@ function sortTimeline(entries) {
|
|
|
1621
1622
|
(a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime()
|
|
1622
1623
|
);
|
|
1623
1624
|
}
|
|
1625
|
+
function groupByLifecycle(records) {
|
|
1626
|
+
const bySession = /* @__PURE__ */ new Map();
|
|
1627
|
+
for (const rec of records) {
|
|
1628
|
+
const list = bySession.get(rec.session_ref);
|
|
1629
|
+
if (list) list.push(rec);
|
|
1630
|
+
else bySession.set(rec.session_ref, [rec]);
|
|
1631
|
+
}
|
|
1632
|
+
const bundles = [];
|
|
1633
|
+
for (const [session_ref, rs] of bySession) {
|
|
1634
|
+
const buckets = {};
|
|
1635
|
+
for (const rec of rs) {
|
|
1636
|
+
const key = resolveBucketKey(rec.commerce_event);
|
|
1637
|
+
const list = buckets[key];
|
|
1638
|
+
if (list) list.push(rec);
|
|
1639
|
+
else buckets[key] = [rec];
|
|
1640
|
+
}
|
|
1641
|
+
for (const key of Object.keys(buckets)) {
|
|
1642
|
+
buckets[key] = [...buckets[key]].sort(compareLifecycleRecords);
|
|
1643
|
+
}
|
|
1644
|
+
bundles.push({
|
|
1645
|
+
session_ref,
|
|
1646
|
+
buckets,
|
|
1647
|
+
record_count: rs.length,
|
|
1648
|
+
version: COMMERCE_BUNDLE_VERSION
|
|
1649
|
+
});
|
|
1650
|
+
}
|
|
1651
|
+
bundles.sort(
|
|
1652
|
+
(a, b) => a.session_ref < b.session_ref ? -1 : a.session_ref > b.session_ref ? 1 : 0
|
|
1653
|
+
);
|
|
1654
|
+
return bundles;
|
|
1655
|
+
}
|
|
1656
|
+
function resolveBucketKey(event) {
|
|
1657
|
+
if (typeof event !== "string") return UNCLASSIFIED_LIFECYCLE_BUCKET;
|
|
1658
|
+
const trimmed = event.trim();
|
|
1659
|
+
if (trimmed === "") return UNCLASSIFIED_LIFECYCLE_BUCKET;
|
|
1660
|
+
return trimmed;
|
|
1661
|
+
}
|
|
1662
|
+
function compareLifecycleRecords(a, b) {
|
|
1663
|
+
const aTs = normalizeIat(a.iat);
|
|
1664
|
+
const bTs = normalizeIat(b.iat);
|
|
1665
|
+
if (aTs < bTs) return -1;
|
|
1666
|
+
if (aTs > bTs) return 1;
|
|
1667
|
+
if (a.receipt_ref < b.receipt_ref) return -1;
|
|
1668
|
+
if (a.receipt_ref > b.receipt_ref) return 1;
|
|
1669
|
+
return 0;
|
|
1670
|
+
}
|
|
1671
|
+
function normalizeIat(iat) {
|
|
1672
|
+
if (typeof iat === "number") return iat;
|
|
1673
|
+
const asNumber = Number(iat);
|
|
1674
|
+
if (!Number.isNaN(asNumber)) return asNumber;
|
|
1675
|
+
const parsed = Date.parse(iat);
|
|
1676
|
+
if (!Number.isNaN(parsed)) return parsed;
|
|
1677
|
+
return 0;
|
|
1678
|
+
}
|
|
1624
1679
|
|
|
1625
1680
|
// src/index.ts
|
|
1626
1681
|
var AUDIT_PACKAGE_VERSION = "0.9.27";
|
|
1627
1682
|
|
|
1628
|
-
export { AUDIT_EVENT_TYPES, AUDIT_PACKAGE_VERSION, AUDIT_SEVERITIES, AUDIT_VERSION, BUNDLE_VERSION, COMMERCE_BUNDLE_VERSION, DISPUTE_BUNDLE_VERSION, BUNDLE_VERSION2 as DISPUTE_BUNDLE_VERSION_v2, VERIFICATION_REPORT_VERSION, addProtocolEvidence, addReceiptRef, addTimelineEntry, computeCommerceSummary, correlateByTrace, createAuditEntry, createCaseBundle, createCommerceEvidenceBundle, createDisputeBundle, createJsonlAppender, filterByDispute, filterByResource, filterByTimeRange, filterByTraceId, formatJsonl, formatJsonlLine, formatReportText, generateAuditId, generateBundleSummary, getBundleContentHash, isValidAuditEntry, isValidTraceContext, isValidUlid, parseJsonl, parseJsonlLine, readDisputeBundle, serializeBundle, serializeCommerceBundle, serializeReport, validateAuditEntry, verifyBundle, verifyBundleIntegrity };
|
|
1683
|
+
export { AUDIT_EVENT_TYPES, AUDIT_PACKAGE_VERSION, AUDIT_SEVERITIES, AUDIT_VERSION, BUNDLE_VERSION, COMMERCE_BUNDLE_VERSION, DISPUTE_BUNDLE_VERSION, BUNDLE_VERSION2 as DISPUTE_BUNDLE_VERSION_v2, UNCLASSIFIED_LIFECYCLE_BUCKET, VERIFICATION_REPORT_VERSION, addProtocolEvidence, addReceiptRef, addTimelineEntry, computeCommerceSummary, correlateByTrace, createAuditEntry, createCaseBundle, createCommerceEvidenceBundle, createDisputeBundle, createJsonlAppender, filterByDispute, filterByResource, filterByTimeRange, filterByTraceId, formatJsonl, formatJsonlLine, formatReportText, generateAuditId, generateBundleSummary, getBundleContentHash, groupByLifecycle, isValidAuditEntry, isValidTraceContext, isValidUlid, parseJsonl, parseJsonlLine, readDisputeBundle, serializeBundle, serializeCommerceBundle, serializeReport, validateAuditEntry, verifyBundle, verifyBundleIntegrity };
|
|
1629
1684
|
//# sourceMappingURL=index.mjs.map
|
|
1630
1685
|
//# sourceMappingURL=index.mjs.map
|