xytara 1.8.0 → 1.10.0
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/README.md +18 -0
- package/index.js +1 -1
- package/lib/catalog_contract.js +132 -0
- package/lib/commerce_client.js +303 -0
- package/package.json +1 -1
- package/server.js +356 -0
package/README.md
CHANGED
|
@@ -121,6 +121,24 @@ The same `1.8.0` line also starts exposing grouped interaction spine paths that
|
|
|
121
121
|
|
|
122
122
|
as one clearer cross-layer machine path instead of making callers stitch the layers together manually.
|
|
123
123
|
|
|
124
|
+
The current `1.9.0` line starts hardening the output side of that spine into cleaner extension seams:
|
|
125
|
+
|
|
126
|
+
- interaction result-package catalog, summary, and detail routes
|
|
127
|
+
- direct result-package run surfaces derived from grouped spine paths
|
|
128
|
+
- seam summaries that classify execution/consequence, payment/settlement/treasury, and proof-handoff carry together
|
|
129
|
+
- result-package export surfaces that produce a portable handoff bundle for proof-side follow-through
|
|
130
|
+
|
|
131
|
+
This is intended to make grouped spine outputs easier to treat as stable artifacts and future adapter-ready boundaries instead of one-off route responses.
|
|
132
|
+
|
|
133
|
+
The current `1.10.0` line starts building on that by exposing reusable continuation templates on top of result packages:
|
|
134
|
+
|
|
135
|
+
- result-package continuation catalog, summary, and detail routes
|
|
136
|
+
- direct continuation run surfaces that preserve the default next proof path
|
|
137
|
+
- continuation preparation surfaces that emit proof-ready request templates
|
|
138
|
+
- continuation summaries that make the default transaction-to-proof bridge explicit instead of inferred
|
|
139
|
+
|
|
140
|
+
This is intended to make the public stack easier to compose after grouped execution, not just easier to inspect.
|
|
141
|
+
|
|
124
142
|
## Package Surface
|
|
125
143
|
|
|
126
144
|
The SDK is broad, but it stays organized into a few repeatable families instead of one-off surfaces.
|
package/index.js
CHANGED
package/lib/catalog_contract.js
CHANGED
|
@@ -304,6 +304,59 @@ function buildInteractionSpinePaths() {
|
|
|
304
304
|
];
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
+
function buildInteractionResultPackages() {
|
|
308
|
+
return buildInteractionSpinePaths().map((path) => ({
|
|
309
|
+
result_package_ref: path && path.spine_path_ref ? `result.${path.spine_path_ref}` : null,
|
|
310
|
+
source_kind: "interaction_spine_path",
|
|
311
|
+
source_ref: path && path.spine_path_ref ? path.spine_path_ref : null,
|
|
312
|
+
title: path && path.title ? `${path.title} Result Package` : "Interaction Result Package",
|
|
313
|
+
description: path && path.description
|
|
314
|
+
? `${path.description} Preserve the composed output as a stable result-side package and proof-handoff seam.`
|
|
315
|
+
: "Preserve the composed output as a stable result-side package and proof-handoff seam.",
|
|
316
|
+
category: path && path.category ? path.category : null,
|
|
317
|
+
protocol: path && path.protocol ? path.protocol : null,
|
|
318
|
+
precommit_pack_ref: path && path.precommit_pack_ref ? path.precommit_pack_ref : null,
|
|
319
|
+
committed_ref: path && path.committed_ref ? path.committed_ref : null,
|
|
320
|
+
proof_followthrough: path && path.proof_followthrough ? path.proof_followthrough : null,
|
|
321
|
+
portable_handoff_surface: "/v1/transaction-center/result-packages/export",
|
|
322
|
+
portable_proof_surface: "/v1/proof-center/result-package-handoff/run",
|
|
323
|
+
default_payment_protocol: path && path.default_payment_protocol ? path.default_payment_protocol : null,
|
|
324
|
+
default_settlement_mode: path && path.default_settlement_mode ? path.default_settlement_mode : null,
|
|
325
|
+
seam_layers: [
|
|
326
|
+
"execution_consequence",
|
|
327
|
+
"payment_settlement_treasury",
|
|
328
|
+
"proof_handoff"
|
|
329
|
+
],
|
|
330
|
+
required_inputs: Array.isArray(path && path.required_inputs) ? path.required_inputs : [],
|
|
331
|
+
optional_inputs: Array.isArray(path && path.optional_inputs) ? path.optional_inputs : []
|
|
332
|
+
}));
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function buildInteractionResultPackageContinuationTemplates() {
|
|
336
|
+
return buildInteractionResultPackages().map((resultPackage) => ({
|
|
337
|
+
continuation_ref: resultPackage && resultPackage.result_package_ref
|
|
338
|
+
? `continue.${resultPackage.result_package_ref}`
|
|
339
|
+
: null,
|
|
340
|
+
result_package_ref: resultPackage && resultPackage.result_package_ref ? resultPackage.result_package_ref : null,
|
|
341
|
+
source_ref: resultPackage && resultPackage.source_ref ? resultPackage.source_ref : null,
|
|
342
|
+
title: resultPackage && resultPackage.title
|
|
343
|
+
? `${resultPackage.title} Continuation`
|
|
344
|
+
: "Interaction Result Package Continuation",
|
|
345
|
+
description: resultPackage && resultPackage.description
|
|
346
|
+
? `${resultPackage.description} Continue through the reusable default path into proof-native follow-through.`
|
|
347
|
+
: "Continue through the reusable default path into proof-native follow-through.",
|
|
348
|
+
continuation_kind: "proof_native_default",
|
|
349
|
+
default_next_surface: "/v1/transaction-center/result-package-continuations/run",
|
|
350
|
+
default_export_surface: "/v1/transaction-center/result-packages/export",
|
|
351
|
+
default_proof_surface: "/v1/proof-center/result-package-handoff/run",
|
|
352
|
+
committed_ref: resultPackage && resultPackage.committed_ref ? resultPackage.committed_ref : null,
|
|
353
|
+
precommit_pack_ref: resultPackage && resultPackage.precommit_pack_ref ? resultPackage.precommit_pack_ref : null,
|
|
354
|
+
seam_layers: Array.isArray(resultPackage && resultPackage.seam_layers) ? resultPackage.seam_layers : [],
|
|
355
|
+
required_inputs: Array.isArray(resultPackage && resultPackage.required_inputs) ? resultPackage.required_inputs : [],
|
|
356
|
+
optional_inputs: Array.isArray(resultPackage && resultPackage.optional_inputs) ? resultPackage.optional_inputs : []
|
|
357
|
+
}));
|
|
358
|
+
}
|
|
359
|
+
|
|
307
360
|
function buildDefaultTransactionCenter() {
|
|
308
361
|
const settlementProfiles = Array.isArray(catalog.settlement_profiles) ? catalog.settlement_profiles : [];
|
|
309
362
|
const defaultSettlementProfile = settlementProfiles[0] || null;
|
|
@@ -548,6 +601,34 @@ function buildInteractionSpinePathCatalog() {
|
|
|
548
601
|
};
|
|
549
602
|
}
|
|
550
603
|
|
|
604
|
+
function buildInteractionResultPackageCatalog() {
|
|
605
|
+
const center = buildDefaultTransactionCenter();
|
|
606
|
+
const packages = buildInteractionResultPackages();
|
|
607
|
+
return {
|
|
608
|
+
ok: true,
|
|
609
|
+
brand: center.brand,
|
|
610
|
+
product: "interaction result packages",
|
|
611
|
+
default_payment_protocol: center.default_payment && center.default_payment.protocol ? center.default_payment.protocol : null,
|
|
612
|
+
default_settlement_mode: center.default_settlement && center.default_settlement.settlement_mode ? center.default_settlement.settlement_mode : null,
|
|
613
|
+
result_package_count: packages.length,
|
|
614
|
+
result_packages: packages
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
function buildInteractionResultPackageContinuationCatalog() {
|
|
619
|
+
const center = buildDefaultTransactionCenter();
|
|
620
|
+
const templates = buildInteractionResultPackageContinuationTemplates();
|
|
621
|
+
return {
|
|
622
|
+
ok: true,
|
|
623
|
+
brand: center.brand,
|
|
624
|
+
product: "interaction result package continuations",
|
|
625
|
+
default_payment_protocol: center.default_payment && center.default_payment.protocol ? center.default_payment.protocol : null,
|
|
626
|
+
default_settlement_mode: center.default_settlement && center.default_settlement.settlement_mode ? center.default_settlement.settlement_mode : null,
|
|
627
|
+
continuation_count: templates.length,
|
|
628
|
+
continuations: templates
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
|
|
551
632
|
function summarizeTransactionClassPacks() {
|
|
552
633
|
const catalogResponse = buildTransactionClassPackCatalog();
|
|
553
634
|
const packs = Array.isArray(catalogResponse.class_packs) ? catalogResponse.class_packs : [];
|
|
@@ -596,6 +677,39 @@ function summarizeInteractionSpinePaths() {
|
|
|
596
677
|
};
|
|
597
678
|
}
|
|
598
679
|
|
|
680
|
+
function summarizeInteractionResultPackages() {
|
|
681
|
+
const catalogResponse = buildInteractionResultPackageCatalog();
|
|
682
|
+
const packages = Array.isArray(catalogResponse.result_packages) ? catalogResponse.result_packages : [];
|
|
683
|
+
return {
|
|
684
|
+
ok: true,
|
|
685
|
+
brand: catalogResponse.brand,
|
|
686
|
+
product: catalogResponse.product,
|
|
687
|
+
default_payment_protocol: catalogResponse.default_payment_protocol,
|
|
688
|
+
default_settlement_mode: catalogResponse.default_settlement_mode,
|
|
689
|
+
result_package_count: packages.length,
|
|
690
|
+
result_package_refs: packages.map((entry) => entry && entry.result_package_ref).filter(Boolean),
|
|
691
|
+
source_refs: packages.map((entry) => entry && entry.source_ref).filter(Boolean),
|
|
692
|
+
seam_layers: Array.from(new Set(packages.flatMap((entry) => Array.isArray(entry && entry.seam_layers) ? entry.seam_layers : []))),
|
|
693
|
+
result_packages: packages
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
function summarizeInteractionResultPackageContinuations() {
|
|
698
|
+
const catalogResponse = buildInteractionResultPackageContinuationCatalog();
|
|
699
|
+
const templates = Array.isArray(catalogResponse.continuations) ? catalogResponse.continuations : [];
|
|
700
|
+
return {
|
|
701
|
+
ok: true,
|
|
702
|
+
brand: catalogResponse.brand,
|
|
703
|
+
product: catalogResponse.product,
|
|
704
|
+
default_payment_protocol: catalogResponse.default_payment_protocol,
|
|
705
|
+
default_settlement_mode: catalogResponse.default_settlement_mode,
|
|
706
|
+
continuation_count: templates.length,
|
|
707
|
+
continuation_refs: templates.map((entry) => entry && entry.continuation_ref).filter(Boolean),
|
|
708
|
+
result_package_refs: templates.map((entry) => entry && entry.result_package_ref).filter(Boolean),
|
|
709
|
+
continuations: templates
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
|
|
599
713
|
function getTransactionClassPack(ref) {
|
|
600
714
|
const normalized = String(ref || "").trim();
|
|
601
715
|
if (!normalized) return null;
|
|
@@ -614,6 +728,18 @@ function getInteractionSpinePath(ref) {
|
|
|
614
728
|
return buildInteractionSpinePaths().find((entry) => entry && entry.spine_path_ref === normalized) || null;
|
|
615
729
|
}
|
|
616
730
|
|
|
731
|
+
function getInteractionResultPackage(ref) {
|
|
732
|
+
const normalized = String(ref || "").trim();
|
|
733
|
+
if (!normalized) return null;
|
|
734
|
+
return buildInteractionResultPackages().find((entry) => entry && entry.result_package_ref === normalized) || null;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
function getInteractionResultPackageContinuation(ref) {
|
|
738
|
+
const normalized = String(ref || "").trim();
|
|
739
|
+
if (!normalized) return null;
|
|
740
|
+
return buildInteractionResultPackageContinuationTemplates().find((entry) => entry && entry.continuation_ref === normalized) || null;
|
|
741
|
+
}
|
|
742
|
+
|
|
617
743
|
function buildCatalogResponse() {
|
|
618
744
|
return {
|
|
619
745
|
ok: true,
|
|
@@ -748,6 +874,8 @@ module.exports = {
|
|
|
748
874
|
buildDefaultTransactionEconomics,
|
|
749
875
|
buildDefaultTransactionCenter,
|
|
750
876
|
buildDefaultTransactionGuidedLoopCatalog,
|
|
877
|
+
buildInteractionResultPackageCatalog,
|
|
878
|
+
buildInteractionResultPackageContinuationCatalog,
|
|
751
879
|
buildInteractionSpinePathCatalog,
|
|
752
880
|
buildPrecommitInteractionPackCatalog,
|
|
753
881
|
buildDefaultTransactionTaskPackCatalog,
|
|
@@ -755,6 +883,8 @@ module.exports = {
|
|
|
755
883
|
getCatalog,
|
|
756
884
|
getDefaultTransactionGuidedLoop,
|
|
757
885
|
getDefaultTransactionTaskPack,
|
|
886
|
+
getInteractionResultPackage,
|
|
887
|
+
getInteractionResultPackageContinuation,
|
|
758
888
|
getInteractionSpinePath,
|
|
759
889
|
getPrecommitInteractionPack,
|
|
760
890
|
getTransactionClassPack,
|
|
@@ -766,6 +896,8 @@ module.exports = {
|
|
|
766
896
|
summarizeDefaultTransactionEconomics,
|
|
767
897
|
summarizeDefaultTransactionGuidedLoops,
|
|
768
898
|
summarizeDefaultTransactionTaskPacks,
|
|
899
|
+
summarizeInteractionResultPackageContinuations,
|
|
900
|
+
summarizeInteractionResultPackages,
|
|
769
901
|
summarizeInteractionSpinePaths,
|
|
770
902
|
summarizePrecommitInteractionPacks,
|
|
771
903
|
summarizeTransactionClassPacks
|
package/lib/commerce_client.js
CHANGED
|
@@ -1089,6 +1089,96 @@ function summarizeProofHandoffPayload(payload) {
|
|
|
1089
1089
|
};
|
|
1090
1090
|
}
|
|
1091
1091
|
|
|
1092
|
+
function summarizeInteractionResultPackagePayload(payload) {
|
|
1093
|
+
const item = payload && typeof payload === "object" ? payload : {};
|
|
1094
|
+
const seam = item.seam_summary && typeof item.seam_summary === "object" ? item.seam_summary : {};
|
|
1095
|
+
const execution = seam.execution_consequence_summary && typeof seam.execution_consequence_summary === "object"
|
|
1096
|
+
? seam.execution_consequence_summary
|
|
1097
|
+
: {};
|
|
1098
|
+
const economics = seam.payment_settlement_treasury_summary && typeof seam.payment_settlement_treasury_summary === "object"
|
|
1099
|
+
? seam.payment_settlement_treasury_summary
|
|
1100
|
+
: {};
|
|
1101
|
+
const proof = seam.proof_handoff_summary && typeof seam.proof_handoff_summary === "object"
|
|
1102
|
+
? summarizeProofHandoffPayload(seam.proof_handoff_summary)
|
|
1103
|
+
: null;
|
|
1104
|
+
return {
|
|
1105
|
+
ok: item.ok === true,
|
|
1106
|
+
result_package_ref: item.result_package_ref || null,
|
|
1107
|
+
source_ref: item.source_ref || null,
|
|
1108
|
+
committed_ref: item.committed_ref || null,
|
|
1109
|
+
transaction_id: item.transaction_id || null,
|
|
1110
|
+
receipt_id: item.receipt_id || null,
|
|
1111
|
+
delivery_id: item.delivery_id || null,
|
|
1112
|
+
transaction_status: item.transaction_status || execution.transaction_status || null,
|
|
1113
|
+
seam_layer_count: Number(item.seam_layer_count || 0),
|
|
1114
|
+
payment_protocol: economics.payment_protocol || null,
|
|
1115
|
+
settlement_mode: economics.settlement_mode || null,
|
|
1116
|
+
payment_ledger_count: Number(economics.payment_ledger_count || 0),
|
|
1117
|
+
proof_handoff_summary: proof
|
|
1118
|
+
};
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
function summarizeInteractionResultPackagePortableHandoffPayload(payload) {
|
|
1122
|
+
const item = payload && typeof payload === "object" ? payload : {};
|
|
1123
|
+
return {
|
|
1124
|
+
ok: item.ok === true,
|
|
1125
|
+
result_package_ref: item.result_package_ref || null,
|
|
1126
|
+
source_ref: item.source_ref || null,
|
|
1127
|
+
committed_ref: item.committed_ref || null,
|
|
1128
|
+
transaction_id: item.transaction_id || null,
|
|
1129
|
+
receipt_id: item.receipt_id || null,
|
|
1130
|
+
proof_ref: item.proof_ref || null,
|
|
1131
|
+
payment_protocol: item.payment_protocol || null,
|
|
1132
|
+
settlement_mode: item.settlement_mode || null,
|
|
1133
|
+
seam_layer_count: Array.isArray(item.seam_layers)
|
|
1134
|
+
? item.seam_layers.length
|
|
1135
|
+
: Number(item.seam_layer_count || 0),
|
|
1136
|
+
task_ref_count: Array.isArray(item.task_refs)
|
|
1137
|
+
? item.task_refs.length
|
|
1138
|
+
: Number(item.task_ref_count || 0)
|
|
1139
|
+
};
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
function summarizeInteractionResultPackageContinuationPayload(payload) {
|
|
1143
|
+
const item = payload && typeof payload === "object" ? payload : {};
|
|
1144
|
+
return {
|
|
1145
|
+
ok: item.ok === true,
|
|
1146
|
+
continuation_ref: item.continuation_ref || null,
|
|
1147
|
+
result_package_ref: item.result_package_ref || null,
|
|
1148
|
+
source_ref: item.source_ref || null,
|
|
1149
|
+
continuation_kind: item.continuation_kind || null,
|
|
1150
|
+
default_next_surface: item.default_next_surface || null,
|
|
1151
|
+
default_export_surface: item.default_export_surface || null,
|
|
1152
|
+
default_proof_surface: item.default_proof_surface || null,
|
|
1153
|
+
transaction_id: item.transaction_id || null,
|
|
1154
|
+
receipt_id: item.receipt_id || null,
|
|
1155
|
+
proof_ref: item.proof_ref || null,
|
|
1156
|
+
continuation_ready: item.continuation_ready === true,
|
|
1157
|
+
seam_layer_count: Number(item.seam_layer_count || 0)
|
|
1158
|
+
};
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
function summarizeInteractionResultPackageContinuationPreparationPayload(payload) {
|
|
1162
|
+
const item = payload && typeof payload === "object" ? payload : {};
|
|
1163
|
+
const continuation = item.continuation_summary && typeof item.continuation_summary === "object"
|
|
1164
|
+
? summarizeInteractionResultPackageContinuationPayload(item.continuation_summary)
|
|
1165
|
+
: null;
|
|
1166
|
+
const template = item.proof_request_template && typeof item.proof_request_template === "object"
|
|
1167
|
+
? item.proof_request_template
|
|
1168
|
+
: {};
|
|
1169
|
+
return {
|
|
1170
|
+
ok: item.ok === true,
|
|
1171
|
+
continuation_ref: continuation ? continuation.continuation_ref : null,
|
|
1172
|
+
result_package_ref: continuation ? continuation.result_package_ref : null,
|
|
1173
|
+
target_surface: template.target_surface || null,
|
|
1174
|
+
review_surface: template.review_surface || null,
|
|
1175
|
+
continuation_ready: continuation ? continuation.continuation_ready === true : false,
|
|
1176
|
+
evidence_ref_count: Array.isArray(template.request_template && template.request_template.evidence_refs)
|
|
1177
|
+
? template.request_template.evidence_refs.length
|
|
1178
|
+
: 0
|
|
1179
|
+
};
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1092
1182
|
function buildCatalogSummarySource(client) {
|
|
1093
1183
|
const baseCatalog = client && client.catalogCache && typeof client.catalogCache === "object"
|
|
1094
1184
|
? client.catalogCache
|
|
@@ -2700,6 +2790,61 @@ class CommerceClient {
|
|
|
2700
2790
|
return result && result.data && result.data.spine_path ? result.data.spine_path : null;
|
|
2701
2791
|
}
|
|
2702
2792
|
|
|
2793
|
+
async getInteractionResultPackages(forceRefresh) {
|
|
2794
|
+
if (!forceRefresh && this.catalogSummaryCache && this.catalogSummaryCache.resultPackages) {
|
|
2795
|
+
return this.catalogSummaryCache.resultPackages;
|
|
2796
|
+
}
|
|
2797
|
+
const result = await this.getJson("/v1/transaction-center/result-packages");
|
|
2798
|
+
if (!forceRefresh) {
|
|
2799
|
+
this.catalogSummaryCache = this.catalogSummaryCache || {};
|
|
2800
|
+
this.catalogSummaryCache.resultPackages = result.data;
|
|
2801
|
+
}
|
|
2802
|
+
return result.data;
|
|
2803
|
+
}
|
|
2804
|
+
|
|
2805
|
+
async getInteractionResultPackagesSummary(forceRefresh) {
|
|
2806
|
+
const result = await this.getJson("/v1/transaction-center/result-packages/summary");
|
|
2807
|
+
return result && result.data ? result.data : { ok: true, result_package_count: 0, result_package_refs: [], result_packages: [] };
|
|
2808
|
+
}
|
|
2809
|
+
|
|
2810
|
+
async getInteractionResultPackage(resultPackageRef, forceRefresh) {
|
|
2811
|
+
const normalized = String(resultPackageRef || "").trim();
|
|
2812
|
+
if (!normalized) return null;
|
|
2813
|
+
const result = await this.getJson(`/v1/transaction-center/result-package?ref=${encodeURIComponent(normalized)}`);
|
|
2814
|
+
return result && result.data && result.data.result_package ? result.data.result_package : null;
|
|
2815
|
+
}
|
|
2816
|
+
|
|
2817
|
+
async getInteractionResultPackageExportTemplate(resultPackageRef) {
|
|
2818
|
+
const normalized = String(resultPackageRef || "").trim();
|
|
2819
|
+
if (!normalized) return null;
|
|
2820
|
+
const result = await this.getJson(`/v1/transaction-center/result-package/export-template?ref=${encodeURIComponent(normalized)}`);
|
|
2821
|
+
return result && result.data ? result.data : null;
|
|
2822
|
+
}
|
|
2823
|
+
|
|
2824
|
+
async getInteractionResultPackageContinuations(forceRefresh) {
|
|
2825
|
+
if (!forceRefresh && this.catalogSummaryCache && this.catalogSummaryCache.resultPackageContinuations) {
|
|
2826
|
+
return this.catalogSummaryCache.resultPackageContinuations;
|
|
2827
|
+
}
|
|
2828
|
+
const result = await this.getJson("/v1/transaction-center/result-package-continuations");
|
|
2829
|
+
if (!forceRefresh) {
|
|
2830
|
+
this.catalogSummaryCache = this.catalogSummaryCache || {};
|
|
2831
|
+
this.catalogSummaryCache.resultPackageContinuations = result.data;
|
|
2832
|
+
}
|
|
2833
|
+
return result.data;
|
|
2834
|
+
}
|
|
2835
|
+
|
|
2836
|
+
async getInteractionResultPackageContinuationsSummary(forceRefresh) {
|
|
2837
|
+
const result = await this.getJson("/v1/transaction-center/result-package-continuations/summary");
|
|
2838
|
+
return result && result.data ? result.data : { ok: true, continuation_count: 0, continuation_refs: [], continuations: [] };
|
|
2839
|
+
}
|
|
2840
|
+
|
|
2841
|
+
async getInteractionResultPackageContinuation(continuationRef, forceRefresh) {
|
|
2842
|
+
const normalized = String(continuationRef || "").trim();
|
|
2843
|
+
if (!normalized) return null;
|
|
2844
|
+
const result = await this.getJson(`/v1/transaction-center/result-package-continuation?ref=${encodeURIComponent(normalized)}`);
|
|
2845
|
+
return result && result.data && result.data.continuation ? result.data.continuation : null;
|
|
2846
|
+
}
|
|
2847
|
+
|
|
2703
2848
|
async listSettlementPayees(forceRefresh) {
|
|
2704
2849
|
const summary = await this.getSettlementPayeeSummaries(forceRefresh);
|
|
2705
2850
|
return extractSummaryValues(summary, "settlement_payees", "payee_agent_id");
|
|
@@ -4012,6 +4157,144 @@ class CommerceClient {
|
|
|
4012
4157
|
};
|
|
4013
4158
|
}
|
|
4014
4159
|
|
|
4160
|
+
async runInteractionResultPackage(resultPackageRef, body, options) {
|
|
4161
|
+
const opts = options || {};
|
|
4162
|
+
return this.runNamedTaskRoute("/v1/transaction-center/result-packages/run", {
|
|
4163
|
+
command: opts.command || String(resultPackageRef || "").trim() || "result.package.run",
|
|
4164
|
+
result_package_ref: String(resultPackageRef || "").trim(),
|
|
4165
|
+
body: body || {},
|
|
4166
|
+
callback_url: opts.callbackUrl || null,
|
|
4167
|
+
settlement_mode: opts.settlementMode || null,
|
|
4168
|
+
payment_protocol: opts.paymentProtocol || null,
|
|
4169
|
+
protocol: opts.protocol || null,
|
|
4170
|
+
integration_id: opts.integrationId || null,
|
|
4171
|
+
integration_ids: Array.isArray(opts.integrationIds) ? opts.integrationIds : [],
|
|
4172
|
+
integration_context: opts.integrationContext || null
|
|
4173
|
+
});
|
|
4174
|
+
}
|
|
4175
|
+
|
|
4176
|
+
async runInteractionResultPackageSummary(resultPackageRef, body, options) {
|
|
4177
|
+
const result = await this.runInteractionResultPackage(resultPackageRef, body, options);
|
|
4178
|
+
return {
|
|
4179
|
+
ok: result && result.ok === true,
|
|
4180
|
+
result_package_ref: result && result.result_package ? result.result_package.result_package_ref || null : null,
|
|
4181
|
+
source_ref: result && result.result_package ? result.result_package.source_ref || null : null,
|
|
4182
|
+
result_package_summary: this.summarizeInteractionResultPackage(
|
|
4183
|
+
result && result.result_package_summary ? result.result_package_summary : null
|
|
4184
|
+
),
|
|
4185
|
+
result_set_summary: result && result.result_set_summary ? result.result_set_summary : null,
|
|
4186
|
+
linked_record_summary: result && result.linked_record_summary ? result.linked_record_summary : null,
|
|
4187
|
+
activity_summary: result && result.activity_summary ? result.activity_summary : null,
|
|
4188
|
+
seam_summary: result && result.seam_summary ? {
|
|
4189
|
+
...result.seam_summary,
|
|
4190
|
+
proof_handoff_summary: this.summarizeProofHandoff(
|
|
4191
|
+
result.seam_summary && result.seam_summary.proof_handoff_summary
|
|
4192
|
+
? result.seam_summary.proof_handoff_summary
|
|
4193
|
+
: null
|
|
4194
|
+
)
|
|
4195
|
+
} : null
|
|
4196
|
+
};
|
|
4197
|
+
}
|
|
4198
|
+
|
|
4199
|
+
async exportInteractionResultPackage(resultPackageRef, body, options) {
|
|
4200
|
+
const opts = options || {};
|
|
4201
|
+
return this.runNamedTaskRoute("/v1/transaction-center/result-packages/export", {
|
|
4202
|
+
command: opts.command || String(resultPackageRef || "").trim() || "result.package.export",
|
|
4203
|
+
result_package_ref: String(resultPackageRef || "").trim(),
|
|
4204
|
+
body: body || {},
|
|
4205
|
+
callback_url: opts.callbackUrl || null,
|
|
4206
|
+
settlement_mode: opts.settlementMode || null,
|
|
4207
|
+
payment_protocol: opts.paymentProtocol || null,
|
|
4208
|
+
protocol: opts.protocol || null,
|
|
4209
|
+
integration_id: opts.integrationId || null,
|
|
4210
|
+
integration_ids: Array.isArray(opts.integrationIds) ? opts.integrationIds : [],
|
|
4211
|
+
integration_context: opts.integrationContext || null
|
|
4212
|
+
});
|
|
4213
|
+
}
|
|
4214
|
+
|
|
4215
|
+
async exportInteractionResultPackageSummary(resultPackageRef, body, options) {
|
|
4216
|
+
const result = await this.exportInteractionResultPackage(resultPackageRef, body, options);
|
|
4217
|
+
return {
|
|
4218
|
+
ok: result && result.ok === true,
|
|
4219
|
+
result_package_ref: result && result.result_package ? result.result_package.result_package_ref || null : null,
|
|
4220
|
+
source_ref: result && result.result_package ? result.result_package.source_ref || null : null,
|
|
4221
|
+
result_package_summary: this.summarizeInteractionResultPackage(
|
|
4222
|
+
result && result.result_package_summary ? result.result_package_summary : null
|
|
4223
|
+
),
|
|
4224
|
+
portable_handoff_summary: this.summarizeInteractionResultPackagePortableHandoff(
|
|
4225
|
+
result && result.portable_handoff_summary ? result.portable_handoff_summary : null
|
|
4226
|
+
),
|
|
4227
|
+
seam_summary: result && result.seam_summary ? {
|
|
4228
|
+
...result.seam_summary,
|
|
4229
|
+
proof_handoff_summary: this.summarizeProofHandoff(
|
|
4230
|
+
result.seam_summary && result.seam_summary.proof_handoff_summary
|
|
4231
|
+
? result.seam_summary.proof_handoff_summary
|
|
4232
|
+
: null
|
|
4233
|
+
)
|
|
4234
|
+
} : null
|
|
4235
|
+
};
|
|
4236
|
+
}
|
|
4237
|
+
|
|
4238
|
+
async runInteractionResultPackageContinuation(continuationRef, body, options) {
|
|
4239
|
+
const opts = options || {};
|
|
4240
|
+
return this.runNamedTaskRoute("/v1/transaction-center/result-package-continuations/run", {
|
|
4241
|
+
command: opts.command || String(continuationRef || "").trim() || "result.package.continuation.run",
|
|
4242
|
+
continuation_ref: String(continuationRef || "").trim(),
|
|
4243
|
+
body: body || {},
|
|
4244
|
+
callback_url: opts.callbackUrl || null,
|
|
4245
|
+
settlement_mode: opts.settlementMode || null,
|
|
4246
|
+
payment_protocol: opts.paymentProtocol || null,
|
|
4247
|
+
protocol: opts.protocol || null,
|
|
4248
|
+
integration_id: opts.integrationId || null,
|
|
4249
|
+
integration_ids: Array.isArray(opts.integrationIds) ? opts.integrationIds : [],
|
|
4250
|
+
integration_context: opts.integrationContext || null
|
|
4251
|
+
});
|
|
4252
|
+
}
|
|
4253
|
+
|
|
4254
|
+
async runInteractionResultPackageContinuationSummary(continuationRef, body, options) {
|
|
4255
|
+
const result = await this.runInteractionResultPackageContinuation(continuationRef, body, options);
|
|
4256
|
+
return {
|
|
4257
|
+
ok: result && result.ok === true,
|
|
4258
|
+
continuation_ref: result && result.continuation ? result.continuation.continuation_ref || null : null,
|
|
4259
|
+
result_package_ref: result && result.result_package ? result.result_package.result_package_ref || null : null,
|
|
4260
|
+
continuation_summary: this.summarizeInteractionResultPackageContinuation(
|
|
4261
|
+
result && result.continuation_summary ? result.continuation_summary : null
|
|
4262
|
+
),
|
|
4263
|
+
portable_handoff_summary: this.summarizeInteractionResultPackagePortableHandoff(
|
|
4264
|
+
result && result.portable_handoff_summary ? result.portable_handoff_summary : null
|
|
4265
|
+
),
|
|
4266
|
+
seam_summary: result && result.seam_summary ? {
|
|
4267
|
+
...result.seam_summary,
|
|
4268
|
+
proof_handoff_summary: this.summarizeProofHandoff(
|
|
4269
|
+
result.seam_summary && result.seam_summary.proof_handoff_summary
|
|
4270
|
+
? result.seam_summary.proof_handoff_summary
|
|
4271
|
+
: null
|
|
4272
|
+
)
|
|
4273
|
+
} : null
|
|
4274
|
+
};
|
|
4275
|
+
}
|
|
4276
|
+
|
|
4277
|
+
async prepareInteractionResultPackageContinuation(continuationRef, body, options) {
|
|
4278
|
+
const opts = options || {};
|
|
4279
|
+
return this.runNamedTaskRoute("/v1/transaction-center/result-package-continuations/prepare", {
|
|
4280
|
+
command: opts.command || String(continuationRef || "").trim() || "result.package.continuation.prepare",
|
|
4281
|
+
continuation_ref: String(continuationRef || "").trim(),
|
|
4282
|
+
body: body || {},
|
|
4283
|
+
callback_url: opts.callbackUrl || null,
|
|
4284
|
+
settlement_mode: opts.settlementMode || null,
|
|
4285
|
+
payment_protocol: opts.paymentProtocol || null,
|
|
4286
|
+
protocol: opts.protocol || null,
|
|
4287
|
+
integration_id: opts.integrationId || null,
|
|
4288
|
+
integration_ids: Array.isArray(opts.integrationIds) ? opts.integrationIds : [],
|
|
4289
|
+
integration_context: opts.integrationContext || null
|
|
4290
|
+
});
|
|
4291
|
+
}
|
|
4292
|
+
|
|
4293
|
+
async prepareInteractionResultPackageContinuationSummary(continuationRef, body, options) {
|
|
4294
|
+
const result = await this.prepareInteractionResultPackageContinuation(continuationRef, body, options);
|
|
4295
|
+
return summarizeInteractionResultPackageContinuationPreparationPayload(result);
|
|
4296
|
+
}
|
|
4297
|
+
|
|
4015
4298
|
async runNamedTaskRoute(path, payload) {
|
|
4016
4299
|
if (!this.apiKey || !this.walletId || !this.walletSecret) {
|
|
4017
4300
|
throw new Error("named task routes require apiKey, walletId, and walletSecret");
|
|
@@ -5511,6 +5794,22 @@ class CommerceClient {
|
|
|
5511
5794
|
return summarizeProofHandoffPayload(payload);
|
|
5512
5795
|
}
|
|
5513
5796
|
|
|
5797
|
+
summarizeInteractionResultPackage(payload) {
|
|
5798
|
+
return summarizeInteractionResultPackagePayload(payload);
|
|
5799
|
+
}
|
|
5800
|
+
|
|
5801
|
+
summarizeInteractionResultPackagePortableHandoff(payload) {
|
|
5802
|
+
return summarizeInteractionResultPackagePortableHandoffPayload(payload);
|
|
5803
|
+
}
|
|
5804
|
+
|
|
5805
|
+
summarizeInteractionResultPackageContinuation(payload) {
|
|
5806
|
+
return summarizeInteractionResultPackageContinuationPayload(payload);
|
|
5807
|
+
}
|
|
5808
|
+
|
|
5809
|
+
summarizeInteractionResultPackageContinuationPreparation(payload) {
|
|
5810
|
+
return summarizeInteractionResultPackageContinuationPreparationPayload(payload);
|
|
5811
|
+
}
|
|
5812
|
+
|
|
5514
5813
|
summarizeTask(task) {
|
|
5515
5814
|
return summarizeCatalogTask(task);
|
|
5516
5815
|
}
|
|
@@ -6264,6 +6563,10 @@ module.exports = {
|
|
|
6264
6563
|
summarizeQuotePreviewPayload,
|
|
6265
6564
|
summarizeDefaultTransactionCenterPayload,
|
|
6266
6565
|
summarizeDefaultTransactionEconomicsPayload,
|
|
6566
|
+
summarizeInteractionResultPackageContinuationPayload,
|
|
6567
|
+
summarizeInteractionResultPackageContinuationPreparationPayload,
|
|
6568
|
+
summarizeInteractionResultPackagePayload,
|
|
6569
|
+
summarizeInteractionResultPackagePortableHandoffPayload,
|
|
6267
6570
|
summarizeDefaultTaskPackCatalogPayload,
|
|
6268
6571
|
summarizeDefaultGuidedLoopBundlePayload,
|
|
6269
6572
|
summarizeProofHandoffPayload,
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -7,6 +7,8 @@ const {
|
|
|
7
7
|
buildDefaultTransactionCenter,
|
|
8
8
|
buildDefaultTransactionEconomics,
|
|
9
9
|
buildDefaultTransactionGuidedLoopCatalog,
|
|
10
|
+
buildInteractionResultPackageCatalog,
|
|
11
|
+
buildInteractionResultPackageContinuationCatalog,
|
|
10
12
|
buildInteractionSpinePathCatalog,
|
|
11
13
|
buildPrecommitInteractionPackCatalog,
|
|
12
14
|
buildDefaultTransactionTaskPackCatalog,
|
|
@@ -14,6 +16,8 @@ const {
|
|
|
14
16
|
getCatalog,
|
|
15
17
|
getDefaultTransactionGuidedLoop,
|
|
16
18
|
getDefaultTransactionTaskPack,
|
|
19
|
+
getInteractionResultPackage,
|
|
20
|
+
getInteractionResultPackageContinuation,
|
|
17
21
|
getInteractionSpinePath,
|
|
18
22
|
getPrecommitInteractionPack,
|
|
19
23
|
getTransactionClassPack,
|
|
@@ -24,6 +28,8 @@ const {
|
|
|
24
28
|
summarizeDefaultTransactionCenter,
|
|
25
29
|
summarizeDefaultTransactionEconomics,
|
|
26
30
|
summarizeDefaultTransactionGuidedLoops,
|
|
31
|
+
summarizeInteractionResultPackageContinuations,
|
|
32
|
+
summarizeInteractionResultPackages,
|
|
27
33
|
summarizeInteractionSpinePaths,
|
|
28
34
|
summarizeDefaultTransactionTaskPacks,
|
|
29
35
|
summarizePrecommitInteractionPacks,
|
|
@@ -977,6 +983,149 @@ function buildInteractionSpineSummary(result, path) {
|
|
|
977
983
|
};
|
|
978
984
|
}
|
|
979
985
|
|
|
986
|
+
function buildInteractionResultSeamSummary(result, resultPackage) {
|
|
987
|
+
const resultSet = buildResultSetFromCommandResult(result);
|
|
988
|
+
const linked = buildLinkedRecordSetFromCommandResult(result);
|
|
989
|
+
const transaction = resultSet.transaction || {};
|
|
990
|
+
const receipt = resultSet.receipt || {};
|
|
991
|
+
const delivery = resultSet.delivery || {};
|
|
992
|
+
const payment = transaction.payment && typeof transaction.payment === "object" ? transaction.payment : {};
|
|
993
|
+
const settlement = transaction.settlement && typeof transaction.settlement === "object" ? transaction.settlement : {};
|
|
994
|
+
const treasury = transaction.treasury && typeof transaction.treasury === "object" ? transaction.treasury : {};
|
|
995
|
+
const taskRefs = transaction.execution && transaction.execution.results_by_task_id
|
|
996
|
+
? Object.values(transaction.execution.results_by_task_id).map((entry) => entry && entry.task_ref).filter(Boolean)
|
|
997
|
+
: [];
|
|
998
|
+
const proofHandoffSummary = buildProofHandoffSummary(result, resultPackage && resultPackage.source_ref ? resultPackage.source_ref : null);
|
|
999
|
+
return {
|
|
1000
|
+
ok: true,
|
|
1001
|
+
result_package_ref: resultPackage && resultPackage.result_package_ref ? resultPackage.result_package_ref : null,
|
|
1002
|
+
source_ref: resultPackage && resultPackage.source_ref ? resultPackage.source_ref : null,
|
|
1003
|
+
execution_consequence_summary: {
|
|
1004
|
+
task_count: taskRefs.length,
|
|
1005
|
+
task_refs: taskRefs,
|
|
1006
|
+
transaction_status: transaction.status || null,
|
|
1007
|
+
receipt_status: receipt.status || null,
|
|
1008
|
+
delivery_status: delivery.status || null,
|
|
1009
|
+
consequence_ready: Boolean(transaction.transaction_id && receipt.receipt_id)
|
|
1010
|
+
},
|
|
1011
|
+
payment_settlement_treasury_summary: {
|
|
1012
|
+
payment_protocol: payment.protocol || null,
|
|
1013
|
+
settlement_mode: settlement.mode || null,
|
|
1014
|
+
treasury_destination_id: treasury.destination_id || null,
|
|
1015
|
+
payee_agent_id: settlement.payee_agent_id || null,
|
|
1016
|
+
payment_ledger_count: Array.isArray(linked.payment_ledger) ? linked.payment_ledger.length : 0
|
|
1017
|
+
},
|
|
1018
|
+
proof_handoff_summary: proofHandoffSummary,
|
|
1019
|
+
recommended_extension_surface: proofHandoffSummary.proof_ready
|
|
1020
|
+
? "/v1/proof-center/interaction-spine-handoff/run"
|
|
1021
|
+
: "/v1/transaction-center/result-packages/run"
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
function buildInteractionResultPackageSummary(result, resultPackage) {
|
|
1026
|
+
const resultSet = buildResultSetFromCommandResult(result);
|
|
1027
|
+
const transaction = resultSet.transaction || {};
|
|
1028
|
+
const receipt = resultSet.receipt || {};
|
|
1029
|
+
const delivery = resultSet.delivery || {};
|
|
1030
|
+
return {
|
|
1031
|
+
ok: true,
|
|
1032
|
+
result_package_ref: resultPackage && resultPackage.result_package_ref ? resultPackage.result_package_ref : null,
|
|
1033
|
+
source_ref: resultPackage && resultPackage.source_ref ? resultPackage.source_ref : null,
|
|
1034
|
+
source_kind: resultPackage && resultPackage.source_kind ? resultPackage.source_kind : null,
|
|
1035
|
+
committed_ref: resultPackage && resultPackage.committed_ref ? resultPackage.committed_ref : null,
|
|
1036
|
+
transaction_id: transaction.transaction_id || null,
|
|
1037
|
+
receipt_id: receipt.receipt_id || null,
|
|
1038
|
+
delivery_id: delivery.delivery_id || null,
|
|
1039
|
+
transaction_status: transaction.status || null,
|
|
1040
|
+
proof_ref: receipt.proof_ref || null,
|
|
1041
|
+
seam_layer_count: Array.isArray(resultPackage && resultPackage.seam_layers) ? resultPackage.seam_layers.length : 0
|
|
1042
|
+
};
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
function buildInteractionResultPackagePortableHandoff(result, resultPackage) {
|
|
1046
|
+
const resultSet = buildResultSetFromCommandResult(result);
|
|
1047
|
+
const linked = buildLinkedRecordSetFromCommandResult(result);
|
|
1048
|
+
const transaction = resultSet.transaction || {};
|
|
1049
|
+
const receipt = resultSet.receipt || {};
|
|
1050
|
+
const settlement = transaction.settlement && typeof transaction.settlement === "object" ? transaction.settlement : {};
|
|
1051
|
+
const payment = transaction.payment && typeof transaction.payment === "object" ? transaction.payment : {};
|
|
1052
|
+
const treasury = transaction.treasury && typeof transaction.treasury === "object" ? transaction.treasury : {};
|
|
1053
|
+
const taskRefs = transaction.execution && transaction.execution.results_by_task_id
|
|
1054
|
+
? Object.values(transaction.execution.results_by_task_id).map((entry) => entry && entry.task_ref).filter(Boolean)
|
|
1055
|
+
: [];
|
|
1056
|
+
return {
|
|
1057
|
+
ok: true,
|
|
1058
|
+
handoff_kind: "interaction_result_package",
|
|
1059
|
+
result_package_ref: resultPackage && resultPackage.result_package_ref ? resultPackage.result_package_ref : null,
|
|
1060
|
+
source_ref: resultPackage && resultPackage.source_ref ? resultPackage.source_ref : null,
|
|
1061
|
+
committed_ref: resultPackage && resultPackage.committed_ref ? resultPackage.committed_ref : null,
|
|
1062
|
+
precommit_pack_ref: resultPackage && resultPackage.precommit_pack_ref ? resultPackage.precommit_pack_ref : null,
|
|
1063
|
+
transaction_id: transaction.transaction_id || null,
|
|
1064
|
+
receipt_id: receipt.receipt_id || null,
|
|
1065
|
+
proof_ref: receipt.proof_ref || null,
|
|
1066
|
+
payment_protocol: payment.protocol || null,
|
|
1067
|
+
settlement_mode: settlement.mode || null,
|
|
1068
|
+
treasury_destination_id: treasury.destination_id || null,
|
|
1069
|
+
task_refs: taskRefs,
|
|
1070
|
+
delivery_count: Array.isArray(linked.deliveries) ? linked.deliveries.length : 0,
|
|
1071
|
+
payment_ledger_count: Array.isArray(linked.payment_ledger) ? linked.payment_ledger.length : 0,
|
|
1072
|
+
seam_layers: Array.isArray(resultPackage && resultPackage.seam_layers) ? resultPackage.seam_layers : []
|
|
1073
|
+
};
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
function summarizeInteractionResultPackagePortableHandoff(handoff) {
|
|
1077
|
+
const item = handoff && typeof handoff === "object" ? handoff : {};
|
|
1078
|
+
return {
|
|
1079
|
+
ok: item.ok === true,
|
|
1080
|
+
result_package_ref: item.result_package_ref || null,
|
|
1081
|
+
source_ref: item.source_ref || null,
|
|
1082
|
+
committed_ref: item.committed_ref || null,
|
|
1083
|
+
transaction_id: item.transaction_id || null,
|
|
1084
|
+
receipt_id: item.receipt_id || null,
|
|
1085
|
+
proof_ref: item.proof_ref || null,
|
|
1086
|
+
payment_protocol: item.payment_protocol || null,
|
|
1087
|
+
settlement_mode: item.settlement_mode || null,
|
|
1088
|
+
seam_layer_count: Array.isArray(item.seam_layers) ? item.seam_layers.length : 0,
|
|
1089
|
+
task_ref_count: Array.isArray(item.task_refs) ? item.task_refs.length : 0
|
|
1090
|
+
};
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
function buildInteractionResultPackageContinuationSummary(portableHandoff, continuation) {
|
|
1094
|
+
const handoff = portableHandoff && typeof portableHandoff === "object" ? portableHandoff : {};
|
|
1095
|
+
return {
|
|
1096
|
+
ok: true,
|
|
1097
|
+
continuation_ref: continuation && continuation.continuation_ref ? continuation.continuation_ref : null,
|
|
1098
|
+
result_package_ref: continuation && continuation.result_package_ref ? continuation.result_package_ref : null,
|
|
1099
|
+
source_ref: continuation && continuation.source_ref ? continuation.source_ref : null,
|
|
1100
|
+
continuation_kind: continuation && continuation.continuation_kind ? continuation.continuation_kind : null,
|
|
1101
|
+
default_next_surface: continuation && continuation.default_next_surface ? continuation.default_next_surface : null,
|
|
1102
|
+
default_export_surface: continuation && continuation.default_export_surface ? continuation.default_export_surface : null,
|
|
1103
|
+
default_proof_surface: continuation && continuation.default_proof_surface ? continuation.default_proof_surface : null,
|
|
1104
|
+
transaction_id: handoff.transaction_id || null,
|
|
1105
|
+
receipt_id: handoff.receipt_id || null,
|
|
1106
|
+
proof_ref: handoff.proof_ref || null,
|
|
1107
|
+
continuation_ready: Boolean(handoff.result_package_ref && handoff.proof_ref),
|
|
1108
|
+
seam_layer_count: Array.isArray(handoff.seam_layers) ? handoff.seam_layers.length : 0
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
function buildInteractionResultPackageContinuationRequestTemplate(portableHandoff, continuation) {
|
|
1113
|
+
const handoff = portableHandoff && typeof portableHandoff === "object" ? portableHandoff : {};
|
|
1114
|
+
return {
|
|
1115
|
+
ok: true,
|
|
1116
|
+
continuation_ref: continuation && continuation.continuation_ref ? continuation.continuation_ref : null,
|
|
1117
|
+
target_surface: "/v1/proof-center/result-package-handoff/run",
|
|
1118
|
+
review_surface: "/v1/proof-center/result-package-handoff/review",
|
|
1119
|
+
request_template: {
|
|
1120
|
+
handoff_bundle: handoff,
|
|
1121
|
+
evidence_refs: handoff.proof_ref ? [handoff.proof_ref] : [],
|
|
1122
|
+
options: {
|
|
1123
|
+
legacy_identity_material_hex: "<required_for_local_demo_signing>"
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
};
|
|
1127
|
+
}
|
|
1128
|
+
|
|
980
1129
|
function buildOperationsDashboard(filters) {
|
|
981
1130
|
const disputes = listRecords(state.disputes, filters);
|
|
982
1131
|
const refunds = listRecords(state.refunds, filters);
|
|
@@ -1125,6 +1274,65 @@ async function routeRequest(req, res) {
|
|
|
1125
1274
|
return;
|
|
1126
1275
|
}
|
|
1127
1276
|
|
|
1277
|
+
if (req.method === "GET" && url.pathname === "/v1/transaction-center/result-packages") {
|
|
1278
|
+
sendJson(res, 200, buildInteractionResultPackageCatalog());
|
|
1279
|
+
return;
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
if (req.method === "GET" && url.pathname === "/v1/transaction-center/result-packages/summary") {
|
|
1283
|
+
sendJson(res, 200, summarizeInteractionResultPackages());
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
if (req.method === "GET" && url.pathname === "/v1/transaction-center/result-package") {
|
|
1288
|
+
const resultPackage = getInteractionResultPackage(url.searchParams.get("ref"));
|
|
1289
|
+
if (!resultPackage) {
|
|
1290
|
+
sendJson(res, 404, { ok: false, error: "result_package_not_found" });
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
sendJson(res, 200, { ok: true, result_package: resultPackage });
|
|
1294
|
+
return;
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
if (req.method === "GET" && url.pathname === "/v1/transaction-center/result-package/export-template") {
|
|
1298
|
+
const resultPackage = getInteractionResultPackage(url.searchParams.get("ref"));
|
|
1299
|
+
if (!resultPackage) {
|
|
1300
|
+
sendJson(res, 404, { ok: false, error: "result_package_not_found" });
|
|
1301
|
+
return;
|
|
1302
|
+
}
|
|
1303
|
+
sendJson(res, 200, {
|
|
1304
|
+
ok: true,
|
|
1305
|
+
result_package: resultPackage,
|
|
1306
|
+
export_template: {
|
|
1307
|
+
handoff_kind: "interaction_result_package",
|
|
1308
|
+
required_fields: ["result_package_ref", "source_ref", "transaction_id", "receipt_id", "proof_ref"],
|
|
1309
|
+
optional_fields: ["committed_ref", "precommit_pack_ref", "payment_protocol", "settlement_mode", "treasury_destination_id", "task_refs", "delivery_count", "payment_ledger_count", "seam_layers"],
|
|
1310
|
+
recommended_proof_surface: "/v1/proof-center/result-package-handoff/run"
|
|
1311
|
+
}
|
|
1312
|
+
});
|
|
1313
|
+
return;
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
if (req.method === "GET" && url.pathname === "/v1/transaction-center/result-package-continuations") {
|
|
1317
|
+
sendJson(res, 200, buildInteractionResultPackageContinuationCatalog());
|
|
1318
|
+
return;
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
if (req.method === "GET" && url.pathname === "/v1/transaction-center/result-package-continuations/summary") {
|
|
1322
|
+
sendJson(res, 200, summarizeInteractionResultPackageContinuations());
|
|
1323
|
+
return;
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
if (req.method === "GET" && url.pathname === "/v1/transaction-center/result-package-continuation") {
|
|
1327
|
+
const continuation = getInteractionResultPackageContinuation(url.searchParams.get("ref"));
|
|
1328
|
+
if (!continuation) {
|
|
1329
|
+
sendJson(res, 404, { ok: false, error: "result_package_continuation_not_found" });
|
|
1330
|
+
return;
|
|
1331
|
+
}
|
|
1332
|
+
sendJson(res, 200, { ok: true, continuation });
|
|
1333
|
+
return;
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1128
1336
|
if (req.method === "GET" && url.pathname === "/v1/transaction-center/transaction-class-packs") {
|
|
1129
1337
|
sendJson(res, 200, buildTransactionClassPackCatalog());
|
|
1130
1338
|
return;
|
|
@@ -1712,6 +1920,154 @@ async function routeRequest(req, res) {
|
|
|
1712
1920
|
return;
|
|
1713
1921
|
}
|
|
1714
1922
|
|
|
1923
|
+
if (req.method === "POST" && url.pathname === "/v1/transaction-center/result-packages/run") {
|
|
1924
|
+
const body = await readJsonBody(req);
|
|
1925
|
+
const resultPackageRef = String(body && body.result_package_ref || "").trim();
|
|
1926
|
+
const resultPackage = getInteractionResultPackage(resultPackageRef);
|
|
1927
|
+
if (!resultPackage) {
|
|
1928
|
+
sendJson(res, 404, { ok: false, error: "result_package_not_found" });
|
|
1929
|
+
return;
|
|
1930
|
+
}
|
|
1931
|
+
const payload = buildInteractionSpinePathRunPayload({
|
|
1932
|
+
...(body && typeof body === "object" && !Array.isArray(body) ? body : {}),
|
|
1933
|
+
spine_path_ref: resultPackage.source_ref
|
|
1934
|
+
});
|
|
1935
|
+
if (!payload) {
|
|
1936
|
+
sendJson(res, 404, { ok: false, error: "result_package_not_found" });
|
|
1937
|
+
return;
|
|
1938
|
+
}
|
|
1939
|
+
const result = executeCommandRequest(state, payload, req.headers);
|
|
1940
|
+
if (result.status !== 200) {
|
|
1941
|
+
sendJson(res, result.status, result.payload);
|
|
1942
|
+
return;
|
|
1943
|
+
}
|
|
1944
|
+
sendJson(res, 200, {
|
|
1945
|
+
ok: true,
|
|
1946
|
+
result_package: resultPackage,
|
|
1947
|
+
result: result.payload,
|
|
1948
|
+
result_package_summary: buildInteractionResultPackageSummary(result.payload, resultPackage),
|
|
1949
|
+
result_set_summary: summarizeResultSetPayload(buildResultSetFromCommandResult(result.payload)),
|
|
1950
|
+
linked_record_summary: summarizeLinkedRecordSetPayload(buildLinkedRecordSetFromCommandResult(result.payload)),
|
|
1951
|
+
activity_summary: summarizeActivitySnapshotPayload(buildActivitySnapshotFromCommandResult(result.payload)),
|
|
1952
|
+
seam_summary: buildInteractionResultSeamSummary(result.payload, resultPackage)
|
|
1953
|
+
});
|
|
1954
|
+
return;
|
|
1955
|
+
}
|
|
1956
|
+
|
|
1957
|
+
if (req.method === "POST" && url.pathname === "/v1/transaction-center/result-packages/export") {
|
|
1958
|
+
const body = await readJsonBody(req);
|
|
1959
|
+
const resultPackageRef = String(body && body.result_package_ref || "").trim();
|
|
1960
|
+
const resultPackage = getInteractionResultPackage(resultPackageRef);
|
|
1961
|
+
if (!resultPackage) {
|
|
1962
|
+
sendJson(res, 404, { ok: false, error: "result_package_not_found" });
|
|
1963
|
+
return;
|
|
1964
|
+
}
|
|
1965
|
+
const payload = buildInteractionSpinePathRunPayload({
|
|
1966
|
+
...(body && typeof body === "object" && !Array.isArray(body) ? body : {}),
|
|
1967
|
+
spine_path_ref: resultPackage.source_ref
|
|
1968
|
+
});
|
|
1969
|
+
if (!payload) {
|
|
1970
|
+
sendJson(res, 404, { ok: false, error: "result_package_not_found" });
|
|
1971
|
+
return;
|
|
1972
|
+
}
|
|
1973
|
+
const result = executeCommandRequest(state, payload, req.headers);
|
|
1974
|
+
if (result.status !== 200) {
|
|
1975
|
+
sendJson(res, result.status, result.payload);
|
|
1976
|
+
return;
|
|
1977
|
+
}
|
|
1978
|
+
const portableHandoff = buildInteractionResultPackagePortableHandoff(result.payload, resultPackage);
|
|
1979
|
+
sendJson(res, 200, {
|
|
1980
|
+
ok: true,
|
|
1981
|
+
result_package: resultPackage,
|
|
1982
|
+
result: result.payload,
|
|
1983
|
+
result_package_summary: buildInteractionResultPackageSummary(result.payload, resultPackage),
|
|
1984
|
+
portable_handoff_bundle: portableHandoff,
|
|
1985
|
+
portable_handoff_summary: summarizeInteractionResultPackagePortableHandoff(portableHandoff),
|
|
1986
|
+
seam_summary: buildInteractionResultSeamSummary(result.payload, resultPackage)
|
|
1987
|
+
});
|
|
1988
|
+
return;
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
if (req.method === "POST" && url.pathname === "/v1/transaction-center/result-package-continuations/run") {
|
|
1992
|
+
const body = await readJsonBody(req);
|
|
1993
|
+
const continuationRef = String(body && body.continuation_ref || "").trim();
|
|
1994
|
+
const continuation = getInteractionResultPackageContinuation(continuationRef);
|
|
1995
|
+
if (!continuation) {
|
|
1996
|
+
sendJson(res, 404, { ok: false, error: "result_package_continuation_not_found" });
|
|
1997
|
+
return;
|
|
1998
|
+
}
|
|
1999
|
+
const resultPackage = getInteractionResultPackage(continuation.result_package_ref);
|
|
2000
|
+
if (!resultPackage) {
|
|
2001
|
+
sendJson(res, 404, { ok: false, error: "result_package_not_found" });
|
|
2002
|
+
return;
|
|
2003
|
+
}
|
|
2004
|
+
const payload = buildInteractionSpinePathRunPayload({
|
|
2005
|
+
...(body && typeof body === "object" && !Array.isArray(body) ? body : {}),
|
|
2006
|
+
spine_path_ref: resultPackage.source_ref
|
|
2007
|
+
});
|
|
2008
|
+
if (!payload) {
|
|
2009
|
+
sendJson(res, 404, { ok: false, error: "result_package_continuation_not_found" });
|
|
2010
|
+
return;
|
|
2011
|
+
}
|
|
2012
|
+
const result = executeCommandRequest(state, payload, req.headers);
|
|
2013
|
+
if (result.status !== 200) {
|
|
2014
|
+
sendJson(res, result.status, result.payload);
|
|
2015
|
+
return;
|
|
2016
|
+
}
|
|
2017
|
+
const portableHandoff = buildInteractionResultPackagePortableHandoff(result.payload, resultPackage);
|
|
2018
|
+
sendJson(res, 200, {
|
|
2019
|
+
ok: true,
|
|
2020
|
+
continuation,
|
|
2021
|
+
result_package: resultPackage,
|
|
2022
|
+
result: result.payload,
|
|
2023
|
+
result_package_summary: buildInteractionResultPackageSummary(result.payload, resultPackage),
|
|
2024
|
+
portable_handoff_bundle: portableHandoff,
|
|
2025
|
+
portable_handoff_summary: summarizeInteractionResultPackagePortableHandoff(portableHandoff),
|
|
2026
|
+
continuation_summary: buildInteractionResultPackageContinuationSummary(portableHandoff, continuation),
|
|
2027
|
+
seam_summary: buildInteractionResultSeamSummary(result.payload, resultPackage)
|
|
2028
|
+
});
|
|
2029
|
+
return;
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
if (req.method === "POST" && url.pathname === "/v1/transaction-center/result-package-continuations/prepare") {
|
|
2033
|
+
const body = await readJsonBody(req);
|
|
2034
|
+
const continuationRef = String(body && body.continuation_ref || "").trim();
|
|
2035
|
+
const continuation = getInteractionResultPackageContinuation(continuationRef);
|
|
2036
|
+
if (!continuation) {
|
|
2037
|
+
sendJson(res, 404, { ok: false, error: "result_package_continuation_not_found" });
|
|
2038
|
+
return;
|
|
2039
|
+
}
|
|
2040
|
+
const resultPackage = getInteractionResultPackage(continuation.result_package_ref);
|
|
2041
|
+
if (!resultPackage) {
|
|
2042
|
+
sendJson(res, 404, { ok: false, error: "result_package_not_found" });
|
|
2043
|
+
return;
|
|
2044
|
+
}
|
|
2045
|
+
const payload = buildInteractionSpinePathRunPayload({
|
|
2046
|
+
...(body && typeof body === "object" && !Array.isArray(body) ? body : {}),
|
|
2047
|
+
spine_path_ref: resultPackage.source_ref
|
|
2048
|
+
});
|
|
2049
|
+
if (!payload) {
|
|
2050
|
+
sendJson(res, 404, { ok: false, error: "result_package_continuation_not_found" });
|
|
2051
|
+
return;
|
|
2052
|
+
}
|
|
2053
|
+
const result = executeCommandRequest(state, payload, req.headers);
|
|
2054
|
+
if (result.status !== 200) {
|
|
2055
|
+
sendJson(res, result.status, result.payload);
|
|
2056
|
+
return;
|
|
2057
|
+
}
|
|
2058
|
+
const portableHandoff = buildInteractionResultPackagePortableHandoff(result.payload, resultPackage);
|
|
2059
|
+
sendJson(res, 200, {
|
|
2060
|
+
ok: true,
|
|
2061
|
+
continuation,
|
|
2062
|
+
result_package: resultPackage,
|
|
2063
|
+
result_package_summary: buildInteractionResultPackageSummary(result.payload, resultPackage),
|
|
2064
|
+
portable_handoff_summary: summarizeInteractionResultPackagePortableHandoff(portableHandoff),
|
|
2065
|
+
continuation_summary: buildInteractionResultPackageContinuationSummary(portableHandoff, continuation),
|
|
2066
|
+
proof_request_template: buildInteractionResultPackageContinuationRequestTemplate(portableHandoff, continuation)
|
|
2067
|
+
});
|
|
2068
|
+
return;
|
|
2069
|
+
}
|
|
2070
|
+
|
|
1715
2071
|
if (req.method === "POST" && url.pathname === "/v1/transaction-center/default-loops/run") {
|
|
1716
2072
|
const body = await readJsonBody(req);
|
|
1717
2073
|
const loopRef = String(body && body.loop_ref || "").trim();
|