@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.
@@ -68,4 +68,5 @@ export declare class MockRunner {
68
68
  static runGetSave(payload: any, expression: string): Promise<ExecutionResult>;
69
69
  static encodeBase64(input: string): string;
70
70
  static decodeBase64(encoded: string): string;
71
+ private static getIdFromSession;
71
72
  }
@@ -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: this.config.transaction_data?.bap_id || "",
432
- bap_uri: this.config.transaction_data?.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 = this.config.transaction_data?.bpp_id || "";
438
- baseContext.bpp_uri = this.config.transaction_data?.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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ondc/automation-mock-runner",
3
- "version": "1.3.12",
3
+ "version": "1.3.13",
4
4
  "description": "A TypeScript library for ONDC automation mock runner",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",