@ondc/automation-mock-runner 1.3.11 → 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
  }
@@ -76,7 +76,9 @@ class MockRunner {
76
76
  inputSchema: step.mock.inputs.jsonSchema,
77
77
  });
78
78
  }
79
- sessionData.user_inputs = inputs;
79
+ if (Object.keys(inputs).length > 0) {
80
+ sessionData.user_inputs = inputs;
81
+ }
80
82
  const context = this.generateContext(step.action_id, step.api);
81
83
  defaultPayload.context = context;
82
84
  const schema = (0, function_registry_1.getFunctionSchema)("generate");
@@ -419,6 +421,18 @@ class MockRunner {
419
421
  // Priority 4: Generate new UUID as last resort
420
422
  return (0, uuid_1.v4)();
421
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
+ "";
422
436
  // Build base context
423
437
  const baseContext = {
424
438
  domain: this.config.meta?.domain || "",
@@ -426,14 +440,14 @@ class MockRunner {
426
440
  timestamp: new Date().toISOString(),
427
441
  transaction_id: transactionId,
428
442
  message_id: messageId,
429
- bap_id: this.config.transaction_data?.bap_id || "",
430
- bap_uri: this.config.transaction_data?.bap_uri || "",
443
+ bap_id: bapId,
444
+ bap_uri: bapUri,
431
445
  ttl: "PT30S",
432
446
  };
433
447
  // Add BPP details for non-search actions
434
448
  if (action !== "search") {
435
- baseContext.bpp_id = this.config.transaction_data?.bpp_id || "";
436
- baseContext.bpp_uri = this.config.transaction_data?.bpp_uri || "";
449
+ baseContext.bpp_id = bppId;
450
+ baseContext.bpp_uri = bppUri;
437
451
  }
438
452
  // Version-specific context structure
439
453
  const version = this.config.meta?.version || "2.0.0";
@@ -560,5 +574,18 @@ class MockRunner {
560
574
  const bytes = new Uint8Array([...binaryString].map((char) => char.charCodeAt(0)));
561
575
  return new TextDecoder().decode(bytes);
562
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
+ }
563
590
  }
564
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.11",
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",