@ondc/automation-mock-runner 1.3.12 → 1.3.13
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/lib/MockRunner.d.ts +1 -0
- package/dist/lib/MockRunner.js +29 -4
- package/package.json +1 -1
package/dist/lib/MockRunner.d.ts
CHANGED
package/dist/lib/MockRunner.js
CHANGED
|
@@ -421,6 +421,18 @@ class MockRunner {
|
|
|
421
421
|
// Priority 4: Generate new UUID as last resort
|
|
422
422
|
return (0, uuid_1.v4)();
|
|
423
423
|
})();
|
|
424
|
+
const bapId = MockRunner.getIdFromSession(sessionData, "bapId") ||
|
|
425
|
+
this.config.transaction_data?.bap_id ||
|
|
426
|
+
"";
|
|
427
|
+
const bppId = MockRunner.getIdFromSession(sessionData, "bppId") ||
|
|
428
|
+
this.config.transaction_data?.bpp_id ||
|
|
429
|
+
"";
|
|
430
|
+
const bapUri = MockRunner.getIdFromSession(sessionData, "bapUri") ||
|
|
431
|
+
this.config.transaction_data?.bap_uri ||
|
|
432
|
+
"";
|
|
433
|
+
const bppUri = MockRunner.getIdFromSession(sessionData, "bppUri") ||
|
|
434
|
+
this.config.transaction_data?.bpp_uri ||
|
|
435
|
+
"";
|
|
424
436
|
// Build base context
|
|
425
437
|
const baseContext = {
|
|
426
438
|
domain: this.config.meta?.domain || "",
|
|
@@ -428,14 +440,14 @@ class MockRunner {
|
|
|
428
440
|
timestamp: new Date().toISOString(),
|
|
429
441
|
transaction_id: transactionId,
|
|
430
442
|
message_id: messageId,
|
|
431
|
-
bap_id:
|
|
432
|
-
bap_uri:
|
|
443
|
+
bap_id: bapId,
|
|
444
|
+
bap_uri: bapUri,
|
|
433
445
|
ttl: "PT30S",
|
|
434
446
|
};
|
|
435
447
|
// Add BPP details for non-search actions
|
|
436
448
|
if (action !== "search") {
|
|
437
|
-
baseContext.bpp_id =
|
|
438
|
-
baseContext.bpp_uri =
|
|
449
|
+
baseContext.bpp_id = bppId;
|
|
450
|
+
baseContext.bpp_uri = bppUri;
|
|
439
451
|
}
|
|
440
452
|
// Version-specific context structure
|
|
441
453
|
const version = this.config.meta?.version || "2.0.0";
|
|
@@ -562,5 +574,18 @@ class MockRunner {
|
|
|
562
574
|
const bytes = new Uint8Array([...binaryString].map((char) => char.charCodeAt(0)));
|
|
563
575
|
return new TextDecoder().decode(bytes);
|
|
564
576
|
}
|
|
577
|
+
static getIdFromSession(sessionData, key) {
|
|
578
|
+
if (sessionData === undefined) {
|
|
579
|
+
return undefined;
|
|
580
|
+
}
|
|
581
|
+
const data = sessionData[key];
|
|
582
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
583
|
+
return data[0];
|
|
584
|
+
}
|
|
585
|
+
if (typeof data === "string") {
|
|
586
|
+
return data;
|
|
587
|
+
}
|
|
588
|
+
return undefined;
|
|
589
|
+
}
|
|
565
590
|
}
|
|
566
591
|
exports.MockRunner = MockRunner;
|