xytara 1.8.0 → 1.9.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 +9 -0
- package/index.js +1 -1
- package/lib/catalog_contract.js +68 -0
- package/lib/commerce_client.js +169 -0
- package/package.json +1 -1
- package/server.js +217 -0
package/README.md
CHANGED
|
@@ -121,6 +121,15 @@ 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
|
+
|
|
124
133
|
## Package Surface
|
|
125
134
|
|
|
126
135
|
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,34 @@ 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
|
+
|
|
307
335
|
function buildDefaultTransactionCenter() {
|
|
308
336
|
const settlementProfiles = Array.isArray(catalog.settlement_profiles) ? catalog.settlement_profiles : [];
|
|
309
337
|
const defaultSettlementProfile = settlementProfiles[0] || null;
|
|
@@ -548,6 +576,20 @@ function buildInteractionSpinePathCatalog() {
|
|
|
548
576
|
};
|
|
549
577
|
}
|
|
550
578
|
|
|
579
|
+
function buildInteractionResultPackageCatalog() {
|
|
580
|
+
const center = buildDefaultTransactionCenter();
|
|
581
|
+
const packages = buildInteractionResultPackages();
|
|
582
|
+
return {
|
|
583
|
+
ok: true,
|
|
584
|
+
brand: center.brand,
|
|
585
|
+
product: "interaction result packages",
|
|
586
|
+
default_payment_protocol: center.default_payment && center.default_payment.protocol ? center.default_payment.protocol : null,
|
|
587
|
+
default_settlement_mode: center.default_settlement && center.default_settlement.settlement_mode ? center.default_settlement.settlement_mode : null,
|
|
588
|
+
result_package_count: packages.length,
|
|
589
|
+
result_packages: packages
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
|
|
551
593
|
function summarizeTransactionClassPacks() {
|
|
552
594
|
const catalogResponse = buildTransactionClassPackCatalog();
|
|
553
595
|
const packs = Array.isArray(catalogResponse.class_packs) ? catalogResponse.class_packs : [];
|
|
@@ -596,6 +638,23 @@ function summarizeInteractionSpinePaths() {
|
|
|
596
638
|
};
|
|
597
639
|
}
|
|
598
640
|
|
|
641
|
+
function summarizeInteractionResultPackages() {
|
|
642
|
+
const catalogResponse = buildInteractionResultPackageCatalog();
|
|
643
|
+
const packages = Array.isArray(catalogResponse.result_packages) ? catalogResponse.result_packages : [];
|
|
644
|
+
return {
|
|
645
|
+
ok: true,
|
|
646
|
+
brand: catalogResponse.brand,
|
|
647
|
+
product: catalogResponse.product,
|
|
648
|
+
default_payment_protocol: catalogResponse.default_payment_protocol,
|
|
649
|
+
default_settlement_mode: catalogResponse.default_settlement_mode,
|
|
650
|
+
result_package_count: packages.length,
|
|
651
|
+
result_package_refs: packages.map((entry) => entry && entry.result_package_ref).filter(Boolean),
|
|
652
|
+
source_refs: packages.map((entry) => entry && entry.source_ref).filter(Boolean),
|
|
653
|
+
seam_layers: Array.from(new Set(packages.flatMap((entry) => Array.isArray(entry && entry.seam_layers) ? entry.seam_layers : []))),
|
|
654
|
+
result_packages: packages
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
|
|
599
658
|
function getTransactionClassPack(ref) {
|
|
600
659
|
const normalized = String(ref || "").trim();
|
|
601
660
|
if (!normalized) return null;
|
|
@@ -614,6 +673,12 @@ function getInteractionSpinePath(ref) {
|
|
|
614
673
|
return buildInteractionSpinePaths().find((entry) => entry && entry.spine_path_ref === normalized) || null;
|
|
615
674
|
}
|
|
616
675
|
|
|
676
|
+
function getInteractionResultPackage(ref) {
|
|
677
|
+
const normalized = String(ref || "").trim();
|
|
678
|
+
if (!normalized) return null;
|
|
679
|
+
return buildInteractionResultPackages().find((entry) => entry && entry.result_package_ref === normalized) || null;
|
|
680
|
+
}
|
|
681
|
+
|
|
617
682
|
function buildCatalogResponse() {
|
|
618
683
|
return {
|
|
619
684
|
ok: true,
|
|
@@ -748,6 +813,7 @@ module.exports = {
|
|
|
748
813
|
buildDefaultTransactionEconomics,
|
|
749
814
|
buildDefaultTransactionCenter,
|
|
750
815
|
buildDefaultTransactionGuidedLoopCatalog,
|
|
816
|
+
buildInteractionResultPackageCatalog,
|
|
751
817
|
buildInteractionSpinePathCatalog,
|
|
752
818
|
buildPrecommitInteractionPackCatalog,
|
|
753
819
|
buildDefaultTransactionTaskPackCatalog,
|
|
@@ -755,6 +821,7 @@ module.exports = {
|
|
|
755
821
|
getCatalog,
|
|
756
822
|
getDefaultTransactionGuidedLoop,
|
|
757
823
|
getDefaultTransactionTaskPack,
|
|
824
|
+
getInteractionResultPackage,
|
|
758
825
|
getInteractionSpinePath,
|
|
759
826
|
getPrecommitInteractionPack,
|
|
760
827
|
getTransactionClassPack,
|
|
@@ -766,6 +833,7 @@ module.exports = {
|
|
|
766
833
|
summarizeDefaultTransactionEconomics,
|
|
767
834
|
summarizeDefaultTransactionGuidedLoops,
|
|
768
835
|
summarizeDefaultTransactionTaskPacks,
|
|
836
|
+
summarizeInteractionResultPackages,
|
|
769
837
|
summarizeInteractionSpinePaths,
|
|
770
838
|
summarizePrecommitInteractionPacks,
|
|
771
839
|
summarizeTransactionClassPacks
|
package/lib/commerce_client.js
CHANGED
|
@@ -1089,6 +1089,56 @@ 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
|
+
|
|
1092
1142
|
function buildCatalogSummarySource(client) {
|
|
1093
1143
|
const baseCatalog = client && client.catalogCache && typeof client.catalogCache === "object"
|
|
1094
1144
|
? client.catalogCache
|
|
@@ -2700,6 +2750,37 @@ class CommerceClient {
|
|
|
2700
2750
|
return result && result.data && result.data.spine_path ? result.data.spine_path : null;
|
|
2701
2751
|
}
|
|
2702
2752
|
|
|
2753
|
+
async getInteractionResultPackages(forceRefresh) {
|
|
2754
|
+
if (!forceRefresh && this.catalogSummaryCache && this.catalogSummaryCache.resultPackages) {
|
|
2755
|
+
return this.catalogSummaryCache.resultPackages;
|
|
2756
|
+
}
|
|
2757
|
+
const result = await this.getJson("/v1/transaction-center/result-packages");
|
|
2758
|
+
if (!forceRefresh) {
|
|
2759
|
+
this.catalogSummaryCache = this.catalogSummaryCache || {};
|
|
2760
|
+
this.catalogSummaryCache.resultPackages = result.data;
|
|
2761
|
+
}
|
|
2762
|
+
return result.data;
|
|
2763
|
+
}
|
|
2764
|
+
|
|
2765
|
+
async getInteractionResultPackagesSummary(forceRefresh) {
|
|
2766
|
+
const result = await this.getJson("/v1/transaction-center/result-packages/summary");
|
|
2767
|
+
return result && result.data ? result.data : { ok: true, result_package_count: 0, result_package_refs: [], result_packages: [] };
|
|
2768
|
+
}
|
|
2769
|
+
|
|
2770
|
+
async getInteractionResultPackage(resultPackageRef, forceRefresh) {
|
|
2771
|
+
const normalized = String(resultPackageRef || "").trim();
|
|
2772
|
+
if (!normalized) return null;
|
|
2773
|
+
const result = await this.getJson(`/v1/transaction-center/result-package?ref=${encodeURIComponent(normalized)}`);
|
|
2774
|
+
return result && result.data && result.data.result_package ? result.data.result_package : null;
|
|
2775
|
+
}
|
|
2776
|
+
|
|
2777
|
+
async getInteractionResultPackageExportTemplate(resultPackageRef) {
|
|
2778
|
+
const normalized = String(resultPackageRef || "").trim();
|
|
2779
|
+
if (!normalized) return null;
|
|
2780
|
+
const result = await this.getJson(`/v1/transaction-center/result-package/export-template?ref=${encodeURIComponent(normalized)}`);
|
|
2781
|
+
return result && result.data ? result.data : null;
|
|
2782
|
+
}
|
|
2783
|
+
|
|
2703
2784
|
async listSettlementPayees(forceRefresh) {
|
|
2704
2785
|
const summary = await this.getSettlementPayeeSummaries(forceRefresh);
|
|
2705
2786
|
return extractSummaryValues(summary, "settlement_payees", "payee_agent_id");
|
|
@@ -4012,6 +4093,84 @@ class CommerceClient {
|
|
|
4012
4093
|
};
|
|
4013
4094
|
}
|
|
4014
4095
|
|
|
4096
|
+
async runInteractionResultPackage(resultPackageRef, body, options) {
|
|
4097
|
+
const opts = options || {};
|
|
4098
|
+
return this.runNamedTaskRoute("/v1/transaction-center/result-packages/run", {
|
|
4099
|
+
command: opts.command || String(resultPackageRef || "").trim() || "result.package.run",
|
|
4100
|
+
result_package_ref: String(resultPackageRef || "").trim(),
|
|
4101
|
+
body: body || {},
|
|
4102
|
+
callback_url: opts.callbackUrl || null,
|
|
4103
|
+
settlement_mode: opts.settlementMode || null,
|
|
4104
|
+
payment_protocol: opts.paymentProtocol || null,
|
|
4105
|
+
protocol: opts.protocol || null,
|
|
4106
|
+
integration_id: opts.integrationId || null,
|
|
4107
|
+
integration_ids: Array.isArray(opts.integrationIds) ? opts.integrationIds : [],
|
|
4108
|
+
integration_context: opts.integrationContext || null
|
|
4109
|
+
});
|
|
4110
|
+
}
|
|
4111
|
+
|
|
4112
|
+
async runInteractionResultPackageSummary(resultPackageRef, body, options) {
|
|
4113
|
+
const result = await this.runInteractionResultPackage(resultPackageRef, body, options);
|
|
4114
|
+
return {
|
|
4115
|
+
ok: result && result.ok === true,
|
|
4116
|
+
result_package_ref: result && result.result_package ? result.result_package.result_package_ref || null : null,
|
|
4117
|
+
source_ref: result && result.result_package ? result.result_package.source_ref || null : null,
|
|
4118
|
+
result_package_summary: this.summarizeInteractionResultPackage(
|
|
4119
|
+
result && result.result_package_summary ? result.result_package_summary : null
|
|
4120
|
+
),
|
|
4121
|
+
result_set_summary: result && result.result_set_summary ? result.result_set_summary : null,
|
|
4122
|
+
linked_record_summary: result && result.linked_record_summary ? result.linked_record_summary : null,
|
|
4123
|
+
activity_summary: result && result.activity_summary ? result.activity_summary : null,
|
|
4124
|
+
seam_summary: result && result.seam_summary ? {
|
|
4125
|
+
...result.seam_summary,
|
|
4126
|
+
proof_handoff_summary: this.summarizeProofHandoff(
|
|
4127
|
+
result.seam_summary && result.seam_summary.proof_handoff_summary
|
|
4128
|
+
? result.seam_summary.proof_handoff_summary
|
|
4129
|
+
: null
|
|
4130
|
+
)
|
|
4131
|
+
} : null
|
|
4132
|
+
};
|
|
4133
|
+
}
|
|
4134
|
+
|
|
4135
|
+
async exportInteractionResultPackage(resultPackageRef, body, options) {
|
|
4136
|
+
const opts = options || {};
|
|
4137
|
+
return this.runNamedTaskRoute("/v1/transaction-center/result-packages/export", {
|
|
4138
|
+
command: opts.command || String(resultPackageRef || "").trim() || "result.package.export",
|
|
4139
|
+
result_package_ref: String(resultPackageRef || "").trim(),
|
|
4140
|
+
body: body || {},
|
|
4141
|
+
callback_url: opts.callbackUrl || null,
|
|
4142
|
+
settlement_mode: opts.settlementMode || null,
|
|
4143
|
+
payment_protocol: opts.paymentProtocol || null,
|
|
4144
|
+
protocol: opts.protocol || null,
|
|
4145
|
+
integration_id: opts.integrationId || null,
|
|
4146
|
+
integration_ids: Array.isArray(opts.integrationIds) ? opts.integrationIds : [],
|
|
4147
|
+
integration_context: opts.integrationContext || null
|
|
4148
|
+
});
|
|
4149
|
+
}
|
|
4150
|
+
|
|
4151
|
+
async exportInteractionResultPackageSummary(resultPackageRef, body, options) {
|
|
4152
|
+
const result = await this.exportInteractionResultPackage(resultPackageRef, body, options);
|
|
4153
|
+
return {
|
|
4154
|
+
ok: result && result.ok === true,
|
|
4155
|
+
result_package_ref: result && result.result_package ? result.result_package.result_package_ref || null : null,
|
|
4156
|
+
source_ref: result && result.result_package ? result.result_package.source_ref || null : null,
|
|
4157
|
+
result_package_summary: this.summarizeInteractionResultPackage(
|
|
4158
|
+
result && result.result_package_summary ? result.result_package_summary : null
|
|
4159
|
+
),
|
|
4160
|
+
portable_handoff_summary: this.summarizeInteractionResultPackagePortableHandoff(
|
|
4161
|
+
result && result.portable_handoff_summary ? result.portable_handoff_summary : null
|
|
4162
|
+
),
|
|
4163
|
+
seam_summary: result && result.seam_summary ? {
|
|
4164
|
+
...result.seam_summary,
|
|
4165
|
+
proof_handoff_summary: this.summarizeProofHandoff(
|
|
4166
|
+
result.seam_summary && result.seam_summary.proof_handoff_summary
|
|
4167
|
+
? result.seam_summary.proof_handoff_summary
|
|
4168
|
+
: null
|
|
4169
|
+
)
|
|
4170
|
+
} : null
|
|
4171
|
+
};
|
|
4172
|
+
}
|
|
4173
|
+
|
|
4015
4174
|
async runNamedTaskRoute(path, payload) {
|
|
4016
4175
|
if (!this.apiKey || !this.walletId || !this.walletSecret) {
|
|
4017
4176
|
throw new Error("named task routes require apiKey, walletId, and walletSecret");
|
|
@@ -5511,6 +5670,14 @@ class CommerceClient {
|
|
|
5511
5670
|
return summarizeProofHandoffPayload(payload);
|
|
5512
5671
|
}
|
|
5513
5672
|
|
|
5673
|
+
summarizeInteractionResultPackage(payload) {
|
|
5674
|
+
return summarizeInteractionResultPackagePayload(payload);
|
|
5675
|
+
}
|
|
5676
|
+
|
|
5677
|
+
summarizeInteractionResultPackagePortableHandoff(payload) {
|
|
5678
|
+
return summarizeInteractionResultPackagePortableHandoffPayload(payload);
|
|
5679
|
+
}
|
|
5680
|
+
|
|
5514
5681
|
summarizeTask(task) {
|
|
5515
5682
|
return summarizeCatalogTask(task);
|
|
5516
5683
|
}
|
|
@@ -6264,6 +6431,8 @@ module.exports = {
|
|
|
6264
6431
|
summarizeQuotePreviewPayload,
|
|
6265
6432
|
summarizeDefaultTransactionCenterPayload,
|
|
6266
6433
|
summarizeDefaultTransactionEconomicsPayload,
|
|
6434
|
+
summarizeInteractionResultPackagePayload,
|
|
6435
|
+
summarizeInteractionResultPackagePortableHandoffPayload,
|
|
6267
6436
|
summarizeDefaultTaskPackCatalogPayload,
|
|
6268
6437
|
summarizeDefaultGuidedLoopBundlePayload,
|
|
6269
6438
|
summarizeProofHandoffPayload,
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -7,6 +7,7 @@ const {
|
|
|
7
7
|
buildDefaultTransactionCenter,
|
|
8
8
|
buildDefaultTransactionEconomics,
|
|
9
9
|
buildDefaultTransactionGuidedLoopCatalog,
|
|
10
|
+
buildInteractionResultPackageCatalog,
|
|
10
11
|
buildInteractionSpinePathCatalog,
|
|
11
12
|
buildPrecommitInteractionPackCatalog,
|
|
12
13
|
buildDefaultTransactionTaskPackCatalog,
|
|
@@ -14,6 +15,7 @@ const {
|
|
|
14
15
|
getCatalog,
|
|
15
16
|
getDefaultTransactionGuidedLoop,
|
|
16
17
|
getDefaultTransactionTaskPack,
|
|
18
|
+
getInteractionResultPackage,
|
|
17
19
|
getInteractionSpinePath,
|
|
18
20
|
getPrecommitInteractionPack,
|
|
19
21
|
getTransactionClassPack,
|
|
@@ -24,6 +26,7 @@ const {
|
|
|
24
26
|
summarizeDefaultTransactionCenter,
|
|
25
27
|
summarizeDefaultTransactionEconomics,
|
|
26
28
|
summarizeDefaultTransactionGuidedLoops,
|
|
29
|
+
summarizeInteractionResultPackages,
|
|
27
30
|
summarizeInteractionSpinePaths,
|
|
28
31
|
summarizeDefaultTransactionTaskPacks,
|
|
29
32
|
summarizePrecommitInteractionPacks,
|
|
@@ -977,6 +980,113 @@ function buildInteractionSpineSummary(result, path) {
|
|
|
977
980
|
};
|
|
978
981
|
}
|
|
979
982
|
|
|
983
|
+
function buildInteractionResultSeamSummary(result, resultPackage) {
|
|
984
|
+
const resultSet = buildResultSetFromCommandResult(result);
|
|
985
|
+
const linked = buildLinkedRecordSetFromCommandResult(result);
|
|
986
|
+
const transaction = resultSet.transaction || {};
|
|
987
|
+
const receipt = resultSet.receipt || {};
|
|
988
|
+
const delivery = resultSet.delivery || {};
|
|
989
|
+
const payment = transaction.payment && typeof transaction.payment === "object" ? transaction.payment : {};
|
|
990
|
+
const settlement = transaction.settlement && typeof transaction.settlement === "object" ? transaction.settlement : {};
|
|
991
|
+
const treasury = transaction.treasury && typeof transaction.treasury === "object" ? transaction.treasury : {};
|
|
992
|
+
const taskRefs = transaction.execution && transaction.execution.results_by_task_id
|
|
993
|
+
? Object.values(transaction.execution.results_by_task_id).map((entry) => entry && entry.task_ref).filter(Boolean)
|
|
994
|
+
: [];
|
|
995
|
+
const proofHandoffSummary = buildProofHandoffSummary(result, resultPackage && resultPackage.source_ref ? resultPackage.source_ref : null);
|
|
996
|
+
return {
|
|
997
|
+
ok: true,
|
|
998
|
+
result_package_ref: resultPackage && resultPackage.result_package_ref ? resultPackage.result_package_ref : null,
|
|
999
|
+
source_ref: resultPackage && resultPackage.source_ref ? resultPackage.source_ref : null,
|
|
1000
|
+
execution_consequence_summary: {
|
|
1001
|
+
task_count: taskRefs.length,
|
|
1002
|
+
task_refs: taskRefs,
|
|
1003
|
+
transaction_status: transaction.status || null,
|
|
1004
|
+
receipt_status: receipt.status || null,
|
|
1005
|
+
delivery_status: delivery.status || null,
|
|
1006
|
+
consequence_ready: Boolean(transaction.transaction_id && receipt.receipt_id)
|
|
1007
|
+
},
|
|
1008
|
+
payment_settlement_treasury_summary: {
|
|
1009
|
+
payment_protocol: payment.protocol || null,
|
|
1010
|
+
settlement_mode: settlement.mode || null,
|
|
1011
|
+
treasury_destination_id: treasury.destination_id || null,
|
|
1012
|
+
payee_agent_id: settlement.payee_agent_id || null,
|
|
1013
|
+
payment_ledger_count: Array.isArray(linked.payment_ledger) ? linked.payment_ledger.length : 0
|
|
1014
|
+
},
|
|
1015
|
+
proof_handoff_summary: proofHandoffSummary,
|
|
1016
|
+
recommended_extension_surface: proofHandoffSummary.proof_ready
|
|
1017
|
+
? "/v1/proof-center/interaction-spine-handoff/run"
|
|
1018
|
+
: "/v1/transaction-center/result-packages/run"
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
function buildInteractionResultPackageSummary(result, resultPackage) {
|
|
1023
|
+
const resultSet = buildResultSetFromCommandResult(result);
|
|
1024
|
+
const transaction = resultSet.transaction || {};
|
|
1025
|
+
const receipt = resultSet.receipt || {};
|
|
1026
|
+
const delivery = resultSet.delivery || {};
|
|
1027
|
+
return {
|
|
1028
|
+
ok: true,
|
|
1029
|
+
result_package_ref: resultPackage && resultPackage.result_package_ref ? resultPackage.result_package_ref : null,
|
|
1030
|
+
source_ref: resultPackage && resultPackage.source_ref ? resultPackage.source_ref : null,
|
|
1031
|
+
source_kind: resultPackage && resultPackage.source_kind ? resultPackage.source_kind : null,
|
|
1032
|
+
committed_ref: resultPackage && resultPackage.committed_ref ? resultPackage.committed_ref : null,
|
|
1033
|
+
transaction_id: transaction.transaction_id || null,
|
|
1034
|
+
receipt_id: receipt.receipt_id || null,
|
|
1035
|
+
delivery_id: delivery.delivery_id || null,
|
|
1036
|
+
transaction_status: transaction.status || null,
|
|
1037
|
+
proof_ref: receipt.proof_ref || null,
|
|
1038
|
+
seam_layer_count: Array.isArray(resultPackage && resultPackage.seam_layers) ? resultPackage.seam_layers.length : 0
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
function buildInteractionResultPackagePortableHandoff(result, resultPackage) {
|
|
1043
|
+
const resultSet = buildResultSetFromCommandResult(result);
|
|
1044
|
+
const linked = buildLinkedRecordSetFromCommandResult(result);
|
|
1045
|
+
const transaction = resultSet.transaction || {};
|
|
1046
|
+
const receipt = resultSet.receipt || {};
|
|
1047
|
+
const settlement = transaction.settlement && typeof transaction.settlement === "object" ? transaction.settlement : {};
|
|
1048
|
+
const payment = transaction.payment && typeof transaction.payment === "object" ? transaction.payment : {};
|
|
1049
|
+
const treasury = transaction.treasury && typeof transaction.treasury === "object" ? transaction.treasury : {};
|
|
1050
|
+
const taskRefs = transaction.execution && transaction.execution.results_by_task_id
|
|
1051
|
+
? Object.values(transaction.execution.results_by_task_id).map((entry) => entry && entry.task_ref).filter(Boolean)
|
|
1052
|
+
: [];
|
|
1053
|
+
return {
|
|
1054
|
+
ok: true,
|
|
1055
|
+
handoff_kind: "interaction_result_package",
|
|
1056
|
+
result_package_ref: resultPackage && resultPackage.result_package_ref ? resultPackage.result_package_ref : null,
|
|
1057
|
+
source_ref: resultPackage && resultPackage.source_ref ? resultPackage.source_ref : null,
|
|
1058
|
+
committed_ref: resultPackage && resultPackage.committed_ref ? resultPackage.committed_ref : null,
|
|
1059
|
+
precommit_pack_ref: resultPackage && resultPackage.precommit_pack_ref ? resultPackage.precommit_pack_ref : null,
|
|
1060
|
+
transaction_id: transaction.transaction_id || null,
|
|
1061
|
+
receipt_id: receipt.receipt_id || null,
|
|
1062
|
+
proof_ref: receipt.proof_ref || null,
|
|
1063
|
+
payment_protocol: payment.protocol || null,
|
|
1064
|
+
settlement_mode: settlement.mode || null,
|
|
1065
|
+
treasury_destination_id: treasury.destination_id || null,
|
|
1066
|
+
task_refs: taskRefs,
|
|
1067
|
+
delivery_count: Array.isArray(linked.deliveries) ? linked.deliveries.length : 0,
|
|
1068
|
+
payment_ledger_count: Array.isArray(linked.payment_ledger) ? linked.payment_ledger.length : 0,
|
|
1069
|
+
seam_layers: Array.isArray(resultPackage && resultPackage.seam_layers) ? resultPackage.seam_layers : []
|
|
1070
|
+
};
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
function summarizeInteractionResultPackagePortableHandoff(handoff) {
|
|
1074
|
+
const item = handoff && typeof handoff === "object" ? handoff : {};
|
|
1075
|
+
return {
|
|
1076
|
+
ok: item.ok === true,
|
|
1077
|
+
result_package_ref: item.result_package_ref || null,
|
|
1078
|
+
source_ref: item.source_ref || null,
|
|
1079
|
+
committed_ref: item.committed_ref || null,
|
|
1080
|
+
transaction_id: item.transaction_id || null,
|
|
1081
|
+
receipt_id: item.receipt_id || null,
|
|
1082
|
+
proof_ref: item.proof_ref || null,
|
|
1083
|
+
payment_protocol: item.payment_protocol || null,
|
|
1084
|
+
settlement_mode: item.settlement_mode || null,
|
|
1085
|
+
seam_layer_count: Array.isArray(item.seam_layers) ? item.seam_layers.length : 0,
|
|
1086
|
+
task_ref_count: Array.isArray(item.task_refs) ? item.task_refs.length : 0
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1089
|
+
|
|
980
1090
|
function buildOperationsDashboard(filters) {
|
|
981
1091
|
const disputes = listRecords(state.disputes, filters);
|
|
982
1092
|
const refunds = listRecords(state.refunds, filters);
|
|
@@ -1125,6 +1235,45 @@ async function routeRequest(req, res) {
|
|
|
1125
1235
|
return;
|
|
1126
1236
|
}
|
|
1127
1237
|
|
|
1238
|
+
if (req.method === "GET" && url.pathname === "/v1/transaction-center/result-packages") {
|
|
1239
|
+
sendJson(res, 200, buildInteractionResultPackageCatalog());
|
|
1240
|
+
return;
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
if (req.method === "GET" && url.pathname === "/v1/transaction-center/result-packages/summary") {
|
|
1244
|
+
sendJson(res, 200, summarizeInteractionResultPackages());
|
|
1245
|
+
return;
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
if (req.method === "GET" && url.pathname === "/v1/transaction-center/result-package") {
|
|
1249
|
+
const resultPackage = getInteractionResultPackage(url.searchParams.get("ref"));
|
|
1250
|
+
if (!resultPackage) {
|
|
1251
|
+
sendJson(res, 404, { ok: false, error: "result_package_not_found" });
|
|
1252
|
+
return;
|
|
1253
|
+
}
|
|
1254
|
+
sendJson(res, 200, { ok: true, result_package: resultPackage });
|
|
1255
|
+
return;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
if (req.method === "GET" && url.pathname === "/v1/transaction-center/result-package/export-template") {
|
|
1259
|
+
const resultPackage = getInteractionResultPackage(url.searchParams.get("ref"));
|
|
1260
|
+
if (!resultPackage) {
|
|
1261
|
+
sendJson(res, 404, { ok: false, error: "result_package_not_found" });
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
sendJson(res, 200, {
|
|
1265
|
+
ok: true,
|
|
1266
|
+
result_package: resultPackage,
|
|
1267
|
+
export_template: {
|
|
1268
|
+
handoff_kind: "interaction_result_package",
|
|
1269
|
+
required_fields: ["result_package_ref", "source_ref", "transaction_id", "receipt_id", "proof_ref"],
|
|
1270
|
+
optional_fields: ["committed_ref", "precommit_pack_ref", "payment_protocol", "settlement_mode", "treasury_destination_id", "task_refs", "delivery_count", "payment_ledger_count", "seam_layers"],
|
|
1271
|
+
recommended_proof_surface: "/v1/proof-center/result-package-handoff/run"
|
|
1272
|
+
}
|
|
1273
|
+
});
|
|
1274
|
+
return;
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1128
1277
|
if (req.method === "GET" && url.pathname === "/v1/transaction-center/transaction-class-packs") {
|
|
1129
1278
|
sendJson(res, 200, buildTransactionClassPackCatalog());
|
|
1130
1279
|
return;
|
|
@@ -1712,6 +1861,74 @@ async function routeRequest(req, res) {
|
|
|
1712
1861
|
return;
|
|
1713
1862
|
}
|
|
1714
1863
|
|
|
1864
|
+
if (req.method === "POST" && url.pathname === "/v1/transaction-center/result-packages/run") {
|
|
1865
|
+
const body = await readJsonBody(req);
|
|
1866
|
+
const resultPackageRef = String(body && body.result_package_ref || "").trim();
|
|
1867
|
+
const resultPackage = getInteractionResultPackage(resultPackageRef);
|
|
1868
|
+
if (!resultPackage) {
|
|
1869
|
+
sendJson(res, 404, { ok: false, error: "result_package_not_found" });
|
|
1870
|
+
return;
|
|
1871
|
+
}
|
|
1872
|
+
const payload = buildInteractionSpinePathRunPayload({
|
|
1873
|
+
...(body && typeof body === "object" && !Array.isArray(body) ? body : {}),
|
|
1874
|
+
spine_path_ref: resultPackage.source_ref
|
|
1875
|
+
});
|
|
1876
|
+
if (!payload) {
|
|
1877
|
+
sendJson(res, 404, { ok: false, error: "result_package_not_found" });
|
|
1878
|
+
return;
|
|
1879
|
+
}
|
|
1880
|
+
const result = executeCommandRequest(state, payload, req.headers);
|
|
1881
|
+
if (result.status !== 200) {
|
|
1882
|
+
sendJson(res, result.status, result.payload);
|
|
1883
|
+
return;
|
|
1884
|
+
}
|
|
1885
|
+
sendJson(res, 200, {
|
|
1886
|
+
ok: true,
|
|
1887
|
+
result_package: resultPackage,
|
|
1888
|
+
result: result.payload,
|
|
1889
|
+
result_package_summary: buildInteractionResultPackageSummary(result.payload, resultPackage),
|
|
1890
|
+
result_set_summary: summarizeResultSetPayload(buildResultSetFromCommandResult(result.payload)),
|
|
1891
|
+
linked_record_summary: summarizeLinkedRecordSetPayload(buildLinkedRecordSetFromCommandResult(result.payload)),
|
|
1892
|
+
activity_summary: summarizeActivitySnapshotPayload(buildActivitySnapshotFromCommandResult(result.payload)),
|
|
1893
|
+
seam_summary: buildInteractionResultSeamSummary(result.payload, resultPackage)
|
|
1894
|
+
});
|
|
1895
|
+
return;
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
if (req.method === "POST" && url.pathname === "/v1/transaction-center/result-packages/export") {
|
|
1899
|
+
const body = await readJsonBody(req);
|
|
1900
|
+
const resultPackageRef = String(body && body.result_package_ref || "").trim();
|
|
1901
|
+
const resultPackage = getInteractionResultPackage(resultPackageRef);
|
|
1902
|
+
if (!resultPackage) {
|
|
1903
|
+
sendJson(res, 404, { ok: false, error: "result_package_not_found" });
|
|
1904
|
+
return;
|
|
1905
|
+
}
|
|
1906
|
+
const payload = buildInteractionSpinePathRunPayload({
|
|
1907
|
+
...(body && typeof body === "object" && !Array.isArray(body) ? body : {}),
|
|
1908
|
+
spine_path_ref: resultPackage.source_ref
|
|
1909
|
+
});
|
|
1910
|
+
if (!payload) {
|
|
1911
|
+
sendJson(res, 404, { ok: false, error: "result_package_not_found" });
|
|
1912
|
+
return;
|
|
1913
|
+
}
|
|
1914
|
+
const result = executeCommandRequest(state, payload, req.headers);
|
|
1915
|
+
if (result.status !== 200) {
|
|
1916
|
+
sendJson(res, result.status, result.payload);
|
|
1917
|
+
return;
|
|
1918
|
+
}
|
|
1919
|
+
const portableHandoff = buildInteractionResultPackagePortableHandoff(result.payload, resultPackage);
|
|
1920
|
+
sendJson(res, 200, {
|
|
1921
|
+
ok: true,
|
|
1922
|
+
result_package: resultPackage,
|
|
1923
|
+
result: result.payload,
|
|
1924
|
+
result_package_summary: buildInteractionResultPackageSummary(result.payload, resultPackage),
|
|
1925
|
+
portable_handoff_bundle: portableHandoff,
|
|
1926
|
+
portable_handoff_summary: summarizeInteractionResultPackagePortableHandoff(portableHandoff),
|
|
1927
|
+
seam_summary: buildInteractionResultSeamSummary(result.payload, resultPackage)
|
|
1928
|
+
});
|
|
1929
|
+
return;
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1715
1932
|
if (req.method === "POST" && url.pathname === "/v1/transaction-center/default-loops/run") {
|
|
1716
1933
|
const body = await readJsonBody(req);
|
|
1717
1934
|
const loopRef = String(body && body.loop_ref || "").trim();
|