@ondc/automation-mock-runner 1.3.14 → 1.3.16

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.
@@ -13,6 +13,7 @@ export declare class MockRunner {
13
13
  domain: string;
14
14
  version: string;
15
15
  flowId: string;
16
+ config_version?: string | undefined;
16
17
  };
17
18
  transaction_data: {
18
19
  transaction_id: string;
@@ -41,6 +41,7 @@ export declare function generatePlaygroundConfigFromFlowConfig(payloads: Payload
41
41
  domain: string;
42
42
  version: string;
43
43
  flowId: string;
44
+ config_version?: string | undefined;
44
45
  };
45
46
  transaction_data: {
46
47
  transaction_id: string;
@@ -77,13 +77,13 @@ const isoDurToSec = (duration) => {
77
77
 
78
78
  const setCityFromInputs = (payload, inputs) => {
79
79
  if (!inputs) return "*";
80
- if (payload.context.version.startsWith("1")) {
80
+ let version = payload.context.version || payload.context.core_version || "2.0.0";
81
+ if (version.startsWith("1")) {
81
82
  payload.context.city = inputs.city_code ?? "*";
82
83
  } else {
83
84
  payload.context.location.city.code = inputs.city_code ?? "*";
84
85
  }
85
86
  }
86
-
87
87
  `;
88
88
  function convertToFlowConfig(config) {
89
89
  const flowConfig = {};
@@ -218,7 +218,7 @@ async function generatePlaygroundConfigFromFlowConfig(payloads, flowConfig) {
218
218
  }
219
219
  const stepConfig = mockRunner.getDefaultStep(step.type, step.key);
220
220
  if (index === 0) {
221
- stepConfig.mock.defaultPayload = MockRunner_1.MockRunner.encodeBase64(`async function generate(defaultPayload, sessionData) {
221
+ stepConfig.mock.generate = MockRunner_1.MockRunner.encodeBase64(`async function generate(defaultPayload, sessionData) {
222
222
  setCityFromInputs(defaultPayload, sessionData.user_inputs);
223
223
  return defaultPayload;
224
224
  }`);
@@ -232,6 +232,7 @@ async function generatePlaygroundConfigFromFlowConfig(payloads, flowConfig) {
232
232
  stepConfig.responseFor = findResponseFor ? findResponseFor.key : null;
233
233
  stepConfig.unsolicited = step.unsolicited;
234
234
  config.steps.push(stepConfig);
235
+ index++;
235
236
  }
236
237
  return config;
237
238
  }
@@ -7,6 +7,7 @@ export declare const MetaSchema: z.ZodObject<{
7
7
  domain: z.ZodString;
8
8
  version: z.ZodString;
9
9
  flowId: z.ZodString;
10
+ config_version: z.ZodOptional<z.ZodString>;
10
11
  }, z.core.$strip>;
11
12
  export declare const TransactionDataSchema: z.ZodObject<{
12
13
  transaction_id: z.ZodString;
@@ -63,6 +64,7 @@ export declare const MockPlaygroundConfigSchema: z.ZodObject<{
63
64
  domain: z.ZodString;
64
65
  version: z.ZodString;
65
66
  flowId: z.ZodString;
67
+ config_version: z.ZodOptional<z.ZodString>;
66
68
  }, z.core.$strip>;
67
69
  transaction_data: z.ZodObject<{
68
70
  transaction_id: z.ZodString;
@@ -8,6 +8,7 @@ exports.MetaSchema = zod_1.z.object({
8
8
  domain: zod_1.z.string().min(1, "Domain is required"),
9
9
  version: zod_1.z.string().min(1, "Version is required"),
10
10
  flowId: zod_1.z.string().min(1, "Flow ID is required"),
11
+ config_version: zod_1.z.string().optional(),
11
12
  });
12
13
  exports.TransactionDataSchema = zod_1.z.object({
13
14
  transaction_id: zod_1.z.string().min(1, "Transaction ID is required"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ondc/automation-mock-runner",
3
- "version": "1.3.14",
3
+ "version": "1.3.16",
4
4
  "description": "A TypeScript library for ONDC automation mock runner",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",