@ondc/automation-mock-runner 1.3.7 → 1.3.9

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.
@@ -47,6 +47,7 @@ export declare class MockRunner {
47
47
  action_id: string;
48
48
  payload: any;
49
49
  saved_info: Record<string, any>;
50
+ action?: string | undefined;
50
51
  }[];
51
52
  validationLib: string;
52
53
  helperLib: string;
@@ -75,6 +75,7 @@ export declare function generatePlaygroundConfigFromFlowConfig(payloads: Payload
75
75
  action_id: string;
76
76
  payload: any;
77
77
  saved_info: Record<string, any>;
78
+ action?: string | undefined;
78
79
  }[];
79
80
  validationLib: string;
80
81
  helperLib: string;
@@ -18,9 +18,9 @@ function createInitialMockConfig(domain, version, flowId) {
18
18
  transaction_data: {
19
19
  transaction_id: (0, uuid_1.v4)(),
20
20
  latest_timestamp: new Date(0).toISOString(),
21
- bap_id: "sample-bap-id",
21
+ bap_id: "bap.example.com",
22
22
  bap_uri: "https://bap.example.com",
23
- bpp_id: "sample-bpp-id",
23
+ bpp_id: "bpp.example.com",
24
24
  bpp_uri: "https://bpp.example.com",
25
25
  },
26
26
  steps: [],
@@ -34,6 +34,13 @@ const defaultHelpers = `/*
34
34
  these are appended below the generate function for each step.
35
35
  */
36
36
 
37
+ const createFormURL = (domain,formId, sessionData) => {
38
+ const baseURL = sessionData.mockBaseUrl;
39
+ const transactionId = sessionData.transactionId[0];
40
+ const sessionId = sessionData.sessionId;
41
+ return \`\${baseURL}/forms/\${domain}/\${formId}/?transaction_id=\${transactionId}&session_id=\${sessionId}\`;
42
+ }
43
+
37
44
  // Generates a UUID v4
38
45
  function uuidv4() {
39
46
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
@@ -76,16 +83,40 @@ function convertToFlowConfig(config) {
76
83
  for (const step of config.steps) {
77
84
  const pair = config.steps.find((s) => s.responseFor === step.action_id)?.action_id ||
78
85
  null;
79
- const flowStep = {
80
- key: step.action_id,
81
- type: step.api,
82
- owner: step.owner,
83
- description: step.description || "",
84
- expect: index === 0 ? true : false,
85
- unsolicited: step.unsolicited,
86
- pair: pair,
87
- repeat: step.repeatCount || 1,
88
- };
86
+ let flowStep = {};
87
+ if (step.api === "dynamic_form") {
88
+ flowStep = {
89
+ key: step.action_id,
90
+ type: "DYNAMIC_FORM",
91
+ owner: step.owner,
92
+ description: step.description || "",
93
+ label: step.description || "FORM",
94
+ unsolicited: step.unsolicited,
95
+ pair: pair,
96
+ repeat: step.repeatCount || 1,
97
+ input: [
98
+ {
99
+ name: "form_submission_id",
100
+ label: "Enter form submission ID",
101
+ type: "DYNAMIC_FORM",
102
+ payloadField: "form_submission_id",
103
+ reference: `$.reference_data.${step.action_id}`,
104
+ },
105
+ ],
106
+ };
107
+ }
108
+ else {
109
+ flowStep = {
110
+ key: step.action_id,
111
+ type: step.api,
112
+ owner: step.owner,
113
+ description: step.description || "",
114
+ expect: index === 0 ? true : false,
115
+ unsolicited: step.unsolicited,
116
+ pair: pair,
117
+ repeat: step.repeatCount || 1,
118
+ };
119
+ }
89
120
  if (step.mock.inputs !== undefined &&
90
121
  step.mock.inputs !== null &&
91
122
  Object.keys(step.mock.inputs).length > 0) {
@@ -157,10 +157,11 @@ function getDefaultForm() {
157
157
  <head>
158
158
  <meta charset="UTF-8">
159
159
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
160
- <title>Additional Details</title>
160
+ <title>ENTER FORM TITLE HERE</title>
161
161
  </head>
162
162
 
163
163
  <body>
164
+ <!-- note: update the form id here and don't change the actionUrl template -->
164
165
  <form id="additionalDetailsForm" method="POST" action="<%= actionUrl %>">
165
166
  <label for="name">Name</label>
166
167
  <input type="text" id="name" name="name" />
@@ -194,8 +195,7 @@ function getDefaultForm() {
194
195
 
195
196
  <label for="passportNumber">Passport Number</label>
196
197
  <input type="text" id="passportNumber" name="passportNumber" />
197
- <input type="hidden" id="formId" name="formId" value="FO1">
198
- <input type="hidden" id="transactionId" name="transactionId" value="cf7bb367-c820-4bc9-9be8-f548e0bbf222">
198
+ <!-- note: do not remove the submit button-->
199
199
  <input type="submit" value="Submit">
200
200
  </form>
201
201
  </body>
@@ -54,6 +54,7 @@ export declare const PlaygroundActionStepSchema: z.ZodObject<{
54
54
  }, z.core.$strip>;
55
55
  export declare const TransactionHistoryItemSchema: z.ZodObject<{
56
56
  action_id: z.ZodString;
57
+ action: z.ZodOptional<z.ZodString>;
57
58
  payload: z.ZodAny;
58
59
  saved_info: z.ZodRecord<z.ZodString, z.ZodAny>;
59
60
  }, z.core.$strip>;
@@ -97,6 +98,7 @@ export declare const MockPlaygroundConfigSchema: z.ZodObject<{
97
98
  }, z.core.$strip>>;
98
99
  transaction_history: z.ZodArray<z.ZodObject<{
99
100
  action_id: z.ZodString;
101
+ action: z.ZodOptional<z.ZodString>;
100
102
  payload: z.ZodAny;
101
103
  saved_info: z.ZodRecord<z.ZodString, z.ZodAny>;
102
104
  }, z.core.$strip>>;
@@ -45,6 +45,7 @@ exports.PlaygroundActionStepSchema = zod_1.z.object({
45
45
  });
46
46
  exports.TransactionHistoryItemSchema = zod_1.z.object({
47
47
  action_id: zod_1.z.string().min(1, "Action ID is required"),
48
+ action: zod_1.z.string().optional(),
48
49
  payload: zod_1.z.any(),
49
50
  saved_info: zod_1.z.record(zod_1.z.string(), zod_1.z.any()),
50
51
  });
@@ -449,9 +449,9 @@ describe("configHelper", () => {
449
449
  expect(result.transaction_data).toEqual({
450
450
  transaction_id: "test-uuid-1234",
451
451
  latest_timestamp: "1970-01-01T00:00:00.000Z",
452
- bap_id: "sample-bap-id",
452
+ bap_id: "bap.example.com",
453
453
  bap_uri: "https://bap.example.com",
454
- bpp_id: "sample-bpp-id",
454
+ bpp_id: "bpp.example.com",
455
455
  bpp_uri: "https://bpp.example.com",
456
456
  });
457
457
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ondc/automation-mock-runner",
3
- "version": "1.3.7",
3
+ "version": "1.3.9",
4
4
  "description": "A TypeScript library for ONDC automation mock runner",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",