ondc-code-generator 0.0.3 → 0.0.4

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.
Files changed (71) hide show
  1. package/dist/constants/operations.d.ts +6 -0
  2. package/dist/constants/syntax.d.ts +15 -0
  3. package/dist/generator/config-compiler.d.ts +23 -0
  4. package/dist/generator/generators/classes/abstract-generator.d.ts +11 -0
  5. package/dist/generator/generators/documentation/markdown-message-generator.d.ts +2 -0
  6. package/dist/generator/generators/documentation/md-generator.d.ts +9 -0
  7. package/dist/generator/generators/typescript/templates/json-path-utils.d.ts +5 -0
  8. package/dist/generator/generators/typescript/templates/validation-utils.d.ts +21 -0
  9. package/dist/generator/generators/typescript/ts-ast.d.ts +1 -0
  10. package/dist/generator/generators/typescript/ts-generator.d.ts +17 -0
  11. package/dist/generator/validators/abstract-validator.d.ts +17 -0
  12. package/dist/generator/validators/config-validator.d.ts +11 -0
  13. package/dist/generator/validators/session-data-config/session-data-validator.d.ts +9 -0
  14. package/dist/generator/validators/tests-config/sub-validations.d.ts +38 -0
  15. package/dist/generator/validators/tests-config/test-list-validator.d.ts +10 -0
  16. package/dist/generator/validators/tests-config/test-validator.d.ts +7 -0
  17. package/dist/index.d.ts +2 -0
  18. package/dist/services/return-complier/ast-functions/compile-to-markdown.d.ts +2 -0
  19. package/dist/services/return-complier/ast-functions/semantic-validations.d.ts +2 -0
  20. package/dist/services/return-complier/ast.d.ts +42 -0
  21. package/dist/services/return-complier/combined.d.ts +2 -0
  22. package/dist/services/return-complier/parser.d.ts +14 -0
  23. package/dist/services/return-complier/tokens.d.ts +22 -0
  24. package/dist/services/schema-service.d.ts +6 -0
  25. package/dist/types/build.d.ts +48 -0
  26. package/dist/types/compiler-types.d.ts +3 -0
  27. package/dist/types/config-types.d.ts +21 -0
  28. package/dist/types/error-codes.d.ts +6 -0
  29. package/dist/types/general-types.d.ts +2 -0
  30. package/dist/utils/config-utils/json-schema-utils.d.ts +7 -0
  31. package/dist/utils/config-utils/yaml.d.ts +1 -0
  32. package/dist/utils/fs-utils.d.ts +3 -0
  33. package/dist/utils/general-utils/string-utils.d.ts +27 -0
  34. package/dist/utils/general-utils/test-object-utils.d.ts +2 -0
  35. package/dist/utils/general-utils/validation-utils.d.ts +5 -0
  36. package/dist/utils/json-path-utils/extract-string-paths.d.ts +8 -0
  37. package/dist/utils/json-path-utils/paths.d.ts +9 -0
  38. package/dist/utils/logger.d.ts +3 -0
  39. package/package.json +1 -2
  40. package/generated/L1-validations/api-tests/cancel.ts +0 -569
  41. package/generated/L1-validations/api-tests/confirm.ts +0 -1162
  42. package/generated/L1-validations/api-tests/init.ts +0 -1063
  43. package/generated/L1-validations/api-tests/on_cancel.ts +0 -2069
  44. package/generated/L1-validations/api-tests/on_confirm.ts +0 -2219
  45. package/generated/L1-validations/api-tests/on_init.ts +0 -1949
  46. package/generated/L1-validations/api-tests/on_search.ts +0 -1574
  47. package/generated/L1-validations/api-tests/on_select.ts +0 -1723
  48. package/generated/L1-validations/api-tests/on_status.ts +0 -2221
  49. package/generated/L1-validations/api-tests/on_update.ts +0 -1969
  50. package/generated/L1-validations/api-tests/search.ts +0 -695
  51. package/generated/L1-validations/api-tests/select.ts +0 -994
  52. package/generated/L1-validations/api-tests/status.ts +0 -443
  53. package/generated/L1-validations/api-tests/update.ts +0 -898
  54. package/generated/L1-validations/error.ts +0 -64
  55. package/generated/L1-validations/index.ts +0 -138
  56. package/generated/L1-validations/page/index.html +0 -2118
  57. package/generated/L1-validations/page/style.css +0 -225
  58. package/generated/L1-validations/readme.md +0 -1779
  59. package/generated/L1-validations/types/test-config.ts +0 -27
  60. package/generated/L1-validations/utils/json-path-utils.ts +0 -17
  61. package/generated/L1-validations/utils/validation-utils.ts +0 -116
  62. package/generated-structure/api-tests/search.ts +0 -24
  63. package/generated-structure/types/test-config.ts +0 -21
  64. package/samples/build.yaml +0 -24799
  65. package/samples/output.md +0 -91
  66. package/samples/output.ts +0 -27
  67. package/samples/selections.json +0 -216
  68. package/samples/validation-config.json +0 -3422
  69. package/samples/x-validations.yaml +0 -2893
  70. /package/{generated-structure/error.ts → dist/example.d.ts} +0 -0
  71. /package/{generated-structure/index.ts → dist/generator/generators/python/py-generator.d.ts} +0 -0
@@ -1,898 +0,0 @@
1
- import payloadUtils from "../utils/json-path-utils";
2
- import validations from "../utils/validation-utils";
3
- import {
4
- testFunctionArray,
5
- validationInput,
6
- validationOutput,
7
- } from "../types/test-config";
8
-
9
- export default function update(input: validationInput): validationOutput {
10
- const scope = payloadUtils.getJsonPath(input.payload, "$");
11
- let subResults: validationOutput = [];
12
- let valid = true;
13
- for (const testObj of scope) {
14
- testObj._EXTERNAL = input.externalData;
15
-
16
- function Attri_Required_1_CONTEXT_TIMESTAMP(
17
- input: validationInput,
18
- ): validationOutput {
19
- const scope = payloadUtils.getJsonPath(input.payload, "$");
20
- let subResults: validationOutput = [];
21
- let valid = true;
22
- for (const testObj of scope) {
23
- testObj._EXTERNAL = input.externalData;
24
- const attr = payloadUtils.getJsonPath(
25
- testObj,
26
- "$.context.timestamp",
27
- );
28
-
29
- const validate = validations.arePresent(attr);
30
-
31
- if (!validate) {
32
- return [
33
- {
34
- valid: false,
35
- code: 30000,
36
- description: `- **condition Attri_Required_1_CONTEXT_TIMESTAMP**: $.context.timestamp must be present in the payload`,
37
- },
38
- ];
39
- }
40
-
41
- delete testObj._EXTERNAL;
42
- }
43
- return [{ valid: valid, code: 200 }, ...subResults];
44
- }
45
- function Attri_Required_2_CONTEXT_BAP_ID(
46
- input: validationInput,
47
- ): validationOutput {
48
- const scope = payloadUtils.getJsonPath(input.payload, "$");
49
- let subResults: validationOutput = [];
50
- let valid = true;
51
- for (const testObj of scope) {
52
- testObj._EXTERNAL = input.externalData;
53
- const attr = payloadUtils.getJsonPath(
54
- testObj,
55
- "$.context.bap_id",
56
- );
57
-
58
- const validate = validations.arePresent(attr);
59
-
60
- if (!validate) {
61
- return [
62
- {
63
- valid: false,
64
- code: 30000,
65
- description: `- **condition Attri_Required_2_CONTEXT_BAP_ID**: $.context.bap_id must be present in the payload`,
66
- },
67
- ];
68
- }
69
-
70
- delete testObj._EXTERNAL;
71
- }
72
- return [{ valid: valid, code: 200 }, ...subResults];
73
- }
74
- function Attri_Required_3_CONTEXT_TRANSACTION_ID(
75
- input: validationInput,
76
- ): validationOutput {
77
- const scope = payloadUtils.getJsonPath(input.payload, "$");
78
- let subResults: validationOutput = [];
79
- let valid = true;
80
- for (const testObj of scope) {
81
- testObj._EXTERNAL = input.externalData;
82
- const attr = payloadUtils.getJsonPath(
83
- testObj,
84
- "$.context.transaction_id",
85
- );
86
-
87
- const validate = validations.arePresent(attr);
88
-
89
- if (!validate) {
90
- return [
91
- {
92
- valid: false,
93
- code: 30000,
94
- description: `- **condition Attri_Required_3_CONTEXT_TRANSACTION_ID**: $.context.transaction_id must be present in the payload`,
95
- },
96
- ];
97
- }
98
-
99
- delete testObj._EXTERNAL;
100
- }
101
- return [{ valid: valid, code: 200 }, ...subResults];
102
- }
103
- function Attri_Required_4_CONTEXT_MESSAGE_ID(
104
- input: validationInput,
105
- ): validationOutput {
106
- const scope = payloadUtils.getJsonPath(input.payload, "$");
107
- let subResults: validationOutput = [];
108
- let valid = true;
109
- for (const testObj of scope) {
110
- testObj._EXTERNAL = input.externalData;
111
- const attr = payloadUtils.getJsonPath(
112
- testObj,
113
- "$.context.message_id",
114
- );
115
-
116
- const validate = validations.arePresent(attr);
117
-
118
- if (!validate) {
119
- return [
120
- {
121
- valid: false,
122
- code: 30000,
123
- description: `- **condition Attri_Required_4_CONTEXT_MESSAGE_ID**: $.context.message_id must be present in the payload`,
124
- },
125
- ];
126
- }
127
-
128
- delete testObj._EXTERNAL;
129
- }
130
- return [{ valid: valid, code: 200 }, ...subResults];
131
- }
132
- function Attri_Required_5_CONTEXT_VERSION(
133
- input: validationInput,
134
- ): validationOutput {
135
- const scope = payloadUtils.getJsonPath(input.payload, "$");
136
- let subResults: validationOutput = [];
137
- let valid = true;
138
- for (const testObj of scope) {
139
- testObj._EXTERNAL = input.externalData;
140
- const attr = payloadUtils.getJsonPath(
141
- testObj,
142
- "$.context.version",
143
- );
144
-
145
- const validate = validations.arePresent(attr);
146
-
147
- if (!validate) {
148
- return [
149
- {
150
- valid: false,
151
- code: 30000,
152
- description: `- **condition Attri_Required_5_CONTEXT_VERSION**: $.context.version must be present in the payload`,
153
- },
154
- ];
155
- }
156
-
157
- delete testObj._EXTERNAL;
158
- }
159
- return [{ valid: valid, code: 200 }, ...subResults];
160
- }
161
- function Attri_Required_6_CONTEXT_BAP_URI(
162
- input: validationInput,
163
- ): validationOutput {
164
- const scope = payloadUtils.getJsonPath(input.payload, "$");
165
- let subResults: validationOutput = [];
166
- let valid = true;
167
- for (const testObj of scope) {
168
- testObj._EXTERNAL = input.externalData;
169
- const attr = payloadUtils.getJsonPath(
170
- testObj,
171
- "$.context.bap_uri",
172
- );
173
-
174
- const validate = validations.arePresent(attr);
175
-
176
- if (!validate) {
177
- return [
178
- {
179
- valid: false,
180
- code: 30000,
181
- description: `- **condition Attri_Required_6_CONTEXT_BAP_URI**: $.context.bap_uri must be present in the payload`,
182
- },
183
- ];
184
- }
185
-
186
- delete testObj._EXTERNAL;
187
- }
188
- return [{ valid: valid, code: 200 }, ...subResults];
189
- }
190
- function Attri_Required_7_CONTEXT_TTL(
191
- input: validationInput,
192
- ): validationOutput {
193
- const scope = payloadUtils.getJsonPath(input.payload, "$");
194
- let subResults: validationOutput = [];
195
- let valid = true;
196
- for (const testObj of scope) {
197
- testObj._EXTERNAL = input.externalData;
198
- const attr = payloadUtils.getJsonPath(testObj, "$.context.ttl");
199
-
200
- const validate = validations.arePresent(attr);
201
-
202
- if (!validate) {
203
- return [
204
- {
205
- valid: false,
206
- code: 30000,
207
- description: `- **condition Attri_Required_7_CONTEXT_TTL**: $.context.ttl must be present in the payload`,
208
- },
209
- ];
210
- }
211
-
212
- delete testObj._EXTERNAL;
213
- }
214
- return [{ valid: valid, code: 200 }, ...subResults];
215
- }
216
- function Attri_Required_8_CONTEXT_BPP_ID(
217
- input: validationInput,
218
- ): validationOutput {
219
- const scope = payloadUtils.getJsonPath(input.payload, "$");
220
- let subResults: validationOutput = [];
221
- let valid = true;
222
- for (const testObj of scope) {
223
- testObj._EXTERNAL = input.externalData;
224
- const attr = payloadUtils.getJsonPath(
225
- testObj,
226
- "$.context.bpp_id",
227
- );
228
-
229
- const validate = validations.arePresent(attr);
230
-
231
- if (!validate) {
232
- return [
233
- {
234
- valid: false,
235
- code: 30000,
236
- description: `- **condition Attri_Required_8_CONTEXT_BPP_ID**: $.context.bpp_id must be present in the payload`,
237
- },
238
- ];
239
- }
240
-
241
- delete testObj._EXTERNAL;
242
- }
243
- return [{ valid: valid, code: 200 }, ...subResults];
244
- }
245
- function Attri_Required_9_CONTEXT_BPP_URI(
246
- input: validationInput,
247
- ): validationOutput {
248
- const scope = payloadUtils.getJsonPath(input.payload, "$");
249
- let subResults: validationOutput = [];
250
- let valid = true;
251
- for (const testObj of scope) {
252
- testObj._EXTERNAL = input.externalData;
253
- const attr = payloadUtils.getJsonPath(
254
- testObj,
255
- "$.context.bpp_uri",
256
- );
257
-
258
- const validate = validations.arePresent(attr);
259
-
260
- if (!validate) {
261
- return [
262
- {
263
- valid: false,
264
- code: 30000,
265
- description: `- **condition Attri_Required_9_CONTEXT_BPP_URI**: $.context.bpp_uri must be present in the payload`,
266
- },
267
- ];
268
- }
269
-
270
- delete testObj._EXTERNAL;
271
- }
272
- return [{ valid: valid, code: 200 }, ...subResults];
273
- }
274
- function Attri_Required_10_MESSAGE_UPDATE_TARGET(
275
- input: validationInput,
276
- ): validationOutput {
277
- const scope = payloadUtils.getJsonPath(input.payload, "$");
278
- let subResults: validationOutput = [];
279
- let valid = true;
280
- for (const testObj of scope) {
281
- testObj._EXTERNAL = input.externalData;
282
- const attr = payloadUtils.getJsonPath(
283
- testObj,
284
- "$.message.update_target",
285
- );
286
-
287
- const validate = validations.arePresent(attr);
288
-
289
- if (!validate) {
290
- return [
291
- {
292
- valid: false,
293
- code: 30000,
294
- description: `- **condition Attri_Required_10_MESSAGE_UPDATE_TARGET**: $.message.update_target must be present in the payload`,
295
- },
296
- ];
297
- }
298
-
299
- delete testObj._EXTERNAL;
300
- }
301
- return [{ valid: valid, code: 200 }, ...subResults];
302
- }
303
- function Attri_Required_11_ORDER_ID(
304
- input: validationInput,
305
- ): validationOutput {
306
- const scope = payloadUtils.getJsonPath(input.payload, "$");
307
- let subResults: validationOutput = [];
308
- let valid = true;
309
- for (const testObj of scope) {
310
- testObj._EXTERNAL = input.externalData;
311
- const attr = payloadUtils.getJsonPath(
312
- testObj,
313
- "$.message.order.id",
314
- );
315
-
316
- const validate = validations.arePresent(attr);
317
-
318
- if (!validate) {
319
- return [
320
- {
321
- valid: false,
322
- code: 30000,
323
- description: `- **condition Attri_Required_11_ORDER_ID**: $.message.order.id must be present in the payload`,
324
- },
325
- ];
326
- }
327
-
328
- delete testObj._EXTERNAL;
329
- }
330
- return [{ valid: valid, code: 200 }, ...subResults];
331
- }
332
- function Enum_Required_12_CONTEXT_ACTION(
333
- input: validationInput,
334
- ): validationOutput {
335
- const scope = payloadUtils.getJsonPath(input.payload, "$");
336
- let subResults: validationOutput = [];
337
- let valid = true;
338
- for (const testObj of scope) {
339
- testObj._EXTERNAL = input.externalData;
340
- const enumList = ["update"];
341
- const enumPath = payloadUtils.getJsonPath(
342
- testObj,
343
- "$.context.action",
344
- );
345
-
346
- const validate =
347
- validations.allIn(enumPath, enumList) &&
348
- validations.arePresent(enumPath);
349
-
350
- if (!validate) {
351
- return [
352
- {
353
- valid: false,
354
- code: 30000,
355
- description: `- **condition Enum_Required_12_CONTEXT_ACTION**: all of the following sub conditions must be met:
356
-
357
- - **condition Enum_Required_12_CONTEXT_ACTION.1**: every element of $.context.action must be in ["update"]
358
- - **condition Enum_Required_12_CONTEXT_ACTION.2**: $.context.action must be present in the payload`,
359
- },
360
- ];
361
- }
362
-
363
- delete testObj._EXTERNAL;
364
- }
365
- return [{ valid: valid, code: 200 }, ...subResults];
366
- }
367
- function Enum_Required_13_COUNTRY_CODE(
368
- input: validationInput,
369
- ): validationOutput {
370
- const scope = payloadUtils.getJsonPath(input.payload, "$");
371
- let subResults: validationOutput = [];
372
- let valid = true;
373
- for (const testObj of scope) {
374
- testObj._EXTERNAL = input.externalData;
375
- const enumList = ["IND"];
376
- const enumPath = payloadUtils.getJsonPath(
377
- testObj,
378
- "$.context.location.country.code",
379
- );
380
-
381
- const validate =
382
- validations.allIn(enumPath, enumList) &&
383
- validations.arePresent(enumPath);
384
-
385
- if (!validate) {
386
- return [
387
- {
388
- valid: false,
389
- code: 30000,
390
- description: `- **condition Enum_Required_13_COUNTRY_CODE**: all of the following sub conditions must be met:
391
-
392
- - **condition Enum_Required_13_COUNTRY_CODE.1**: every element of $.context.location.country.code must be in ["IND"]
393
- - **condition Enum_Required_13_COUNTRY_CODE.2**: $.context.location.country.code must be present in the payload`,
394
- },
395
- ];
396
- }
397
-
398
- delete testObj._EXTERNAL;
399
- }
400
- return [{ valid: valid, code: 200 }, ...subResults];
401
- }
402
- function Enum_Required_14_CITY_CODE(
403
- input: validationInput,
404
- ): validationOutput {
405
- const scope = payloadUtils.getJsonPath(input.payload, "$");
406
- let subResults: validationOutput = [];
407
- let valid = true;
408
- for (const testObj of scope) {
409
- testObj._EXTERNAL = input.externalData;
410
- const enumPath = payloadUtils.getJsonPath(
411
- testObj,
412
- "$.context.location.city.code",
413
- );
414
-
415
- const validate = validations.arePresent(enumPath);
416
-
417
- if (!validate) {
418
- return [
419
- {
420
- valid: false,
421
- code: 30000,
422
- description: `- **condition Enum_Required_14_CITY_CODE**: $.context.location.city.code must be present in the payload`,
423
- },
424
- ];
425
- }
426
-
427
- delete testObj._EXTERNAL;
428
- }
429
- return [{ valid: valid, code: 200 }, ...subResults];
430
- }
431
- function Enum_Required_15_CONTEXT_DOMAIN(
432
- input: validationInput,
433
- ): validationOutput {
434
- const scope = payloadUtils.getJsonPath(input.payload, "$");
435
- let subResults: validationOutput = [];
436
- let valid = true;
437
- for (const testObj of scope) {
438
- testObj._EXTERNAL = input.externalData;
439
- const enumList = ["ONDC:TRV11"];
440
- const enumPath = payloadUtils.getJsonPath(
441
- testObj,
442
- "$.context.domain",
443
- );
444
-
445
- const validate =
446
- validations.allIn(enumPath, enumList) &&
447
- validations.arePresent(enumPath);
448
-
449
- if (!validate) {
450
- return [
451
- {
452
- valid: false,
453
- code: 30000,
454
- description: `- **condition Enum_Required_15_CONTEXT_DOMAIN**: all of the following sub conditions must be met:
455
-
456
- - **condition Enum_Required_15_CONTEXT_DOMAIN.1**: every element of $.context.domain must be in ["ONDC:TRV11"]
457
- - **condition Enum_Required_15_CONTEXT_DOMAIN.2**: $.context.domain must be present in the payload`,
458
- },
459
- ];
460
- }
461
-
462
- delete testObj._EXTERNAL;
463
- }
464
- return [{ valid: valid, code: 200 }, ...subResults];
465
- }
466
- function Enum_Required_16_DESCRIPTOR_CODE(
467
- input: validationInput,
468
- ): validationOutput {
469
- const scope = payloadUtils.getJsonPath(input.payload, "$");
470
- let subResults: validationOutput = [];
471
- let valid = true;
472
- for (const testObj of scope) {
473
- testObj._EXTERNAL = input.externalData;
474
- const enumList = ["SJT", "SFSJT", "RJT", "PASS"];
475
- const enumPath = payloadUtils.getJsonPath(
476
- testObj,
477
- "$.message.order.items[*].descriptor.code",
478
- );
479
-
480
- const skipCheck = !validations.arePresent(enumPath);
481
- if (skipCheck) continue;
482
-
483
- const validate = validations.allIn(enumPath, enumList);
484
-
485
- if (!validate) {
486
- return [
487
- {
488
- valid: false,
489
- code: 30000,
490
- description: `- **condition Enum_Required_16_DESCRIPTOR_CODE**: every element of $.message.order.items[*].descriptor.code must be in ["SJT", "SFSJT", "RJT", "PASS"]
491
-
492
- > Note: **Condition Enum_Required_16_DESCRIPTOR_CODE** can be skipped if the following conditions are met:
493
- >
494
- > - **condition B**: $.message.order.items[*].descriptor.code must **not** be present in the payload`,
495
- },
496
- ];
497
- }
498
-
499
- delete testObj._EXTERNAL;
500
- }
501
- return [{ valid: valid, code: 200 }, ...subResults];
502
- }
503
- function Enum_Required_17_VEHICLE_CATEGORY(
504
- input: validationInput,
505
- ): validationOutput {
506
- const scope = payloadUtils.getJsonPath(input.payload, "$");
507
- let subResults: validationOutput = [];
508
- let valid = true;
509
- for (const testObj of scope) {
510
- testObj._EXTERNAL = input.externalData;
511
- const enumList = ["BUS", "METRO"];
512
- const enumPath = payloadUtils.getJsonPath(
513
- testObj,
514
- "$.message.order.fulfillments[*].vehicle.category",
515
- );
516
-
517
- const skipCheck = !validations.arePresent(enumPath);
518
- if (skipCheck) continue;
519
-
520
- const validate = validations.allIn(enumPath, enumList);
521
-
522
- if (!validate) {
523
- return [
524
- {
525
- valid: false,
526
- code: 30000,
527
- description: `- **condition Enum_Required_17_VEHICLE_CATEGORY**: every element of $.message.order.fulfillments[*].vehicle.category must be in ["BUS", "METRO"]
528
-
529
- > Note: **Condition Enum_Required_17_VEHICLE_CATEGORY** can be skipped if the following conditions are met:
530
- >
531
- > - **condition B**: $.message.order.fulfillments[*].vehicle.category must **not** be present in the payload`,
532
- },
533
- ];
534
- }
535
-
536
- delete testObj._EXTERNAL;
537
- }
538
- return [{ valid: valid, code: 200 }, ...subResults];
539
- }
540
- function Enum_Required_18_FULFILLMENTS_TYPE(
541
- input: validationInput,
542
- ): validationOutput {
543
- const scope = payloadUtils.getJsonPath(input.payload, "$");
544
- let subResults: validationOutput = [];
545
- let valid = true;
546
- for (const testObj of scope) {
547
- testObj._EXTERNAL = input.externalData;
548
- const enumList = ["ROUTE", "TRIP"];
549
- const enumPath = payloadUtils.getJsonPath(
550
- testObj,
551
- "$.message.order.fulfillments[*].type",
552
- );
553
-
554
- const skipCheck = !validations.arePresent(enumPath);
555
- if (skipCheck) continue;
556
-
557
- const validate = validations.allIn(enumPath, enumList);
558
-
559
- if (!validate) {
560
- return [
561
- {
562
- valid: false,
563
- code: 30000,
564
- description: `- **condition Enum_Required_18_FULFILLMENTS_TYPE**: every element of $.message.order.fulfillments[*].type must be in ["ROUTE", "TRIP"]
565
-
566
- > Note: **Condition Enum_Required_18_FULFILLMENTS_TYPE** can be skipped if the following conditions are met:
567
- >
568
- > - **condition B**: $.message.order.fulfillments[*].type must **not** be present in the payload`,
569
- },
570
- ];
571
- }
572
-
573
- delete testObj._EXTERNAL;
574
- }
575
- return [{ valid: valid, code: 200 }, ...subResults];
576
- }
577
- function Enum_Required_19_FULFILLMENTS_TYPE(
578
- input: validationInput,
579
- ): validationOutput {
580
- const scope = payloadUtils.getJsonPath(input.payload, "$");
581
- let subResults: validationOutput = [];
582
- let valid = true;
583
- for (const testObj of scope) {
584
- testObj._EXTERNAL = input.externalData;
585
- const enumList = [
586
- "START",
587
- "END",
588
- "INTERMEDIATE_STOP",
589
- "TRANSIT_STOP",
590
- ];
591
- const enumPath = payloadUtils.getJsonPath(
592
- testObj,
593
- "$.message.order.fulfillments[*].type",
594
- );
595
-
596
- const skipCheck = !validations.arePresent(enumPath);
597
- if (skipCheck) continue;
598
-
599
- const validate = validations.allIn(enumPath, enumList);
600
-
601
- if (!validate) {
602
- return [
603
- {
604
- valid: false,
605
- code: 30000,
606
- description: `- **condition Enum_Required_19_FULFILLMENTS_TYPE**: every element of $.message.order.fulfillments[*].type must be in ["START", "END", "INTERMEDIATE_STOP", "TRANSIT_STOP"]
607
-
608
- > Note: **Condition Enum_Required_19_FULFILLMENTS_TYPE** can be skipped if the following conditions are met:
609
- >
610
- > - **condition B**: $.message.order.fulfillments[*].type must **not** be present in the payload`,
611
- },
612
- ];
613
- }
614
-
615
- delete testObj._EXTERNAL;
616
- }
617
- return [{ valid: valid, code: 200 }, ...subResults];
618
- }
619
- function Enum_Required_20_AUTHORIZATION_TYPE(
620
- input: validationInput,
621
- ): validationOutput {
622
- const scope = payloadUtils.getJsonPath(input.payload, "$");
623
- let subResults: validationOutput = [];
624
- let valid = true;
625
- for (const testObj of scope) {
626
- testObj._EXTERNAL = input.externalData;
627
- const enumList = ["QR"];
628
- const enumPath = payloadUtils.getJsonPath(
629
- testObj,
630
- "$.message.order.fulfillments[*].stops[*].authorization.type",
631
- );
632
-
633
- const skipCheck = !validations.arePresent(enumPath);
634
- if (skipCheck) continue;
635
-
636
- const validate = validations.allIn(enumPath, enumList);
637
-
638
- if (!validate) {
639
- return [
640
- {
641
- valid: false,
642
- code: 30000,
643
- description: `- **condition Enum_Required_20_AUTHORIZATION_TYPE**: every element of $.message.order.fulfillments[*].stops[*].authorization.type must be in ["QR"]
644
-
645
- > Note: **Condition Enum_Required_20_AUTHORIZATION_TYPE** can be skipped if the following conditions are met:
646
- >
647
- > - **condition B**: $.message.order.fulfillments[*].stops[*].authorization.type must **not** be present in the payload`,
648
- },
649
- ];
650
- }
651
-
652
- delete testObj._EXTERNAL;
653
- }
654
- return [{ valid: valid, code: 200 }, ...subResults];
655
- }
656
- function Enum_Required_21_AUTHORIZATION_STATUS(
657
- input: validationInput,
658
- ): validationOutput {
659
- const scope = payloadUtils.getJsonPath(input.payload, "$");
660
- let subResults: validationOutput = [];
661
- let valid = true;
662
- for (const testObj of scope) {
663
- testObj._EXTERNAL = input.externalData;
664
- const enumList = ["UNCLAIMED", "CLAIMED"];
665
- const enumPath = payloadUtils.getJsonPath(
666
- testObj,
667
- "$.message.order.fulfillments[*].stops[*].authorization.status",
668
- );
669
-
670
- const skipCheck = !validations.arePresent(enumPath);
671
- if (skipCheck) continue;
672
-
673
- const validate = validations.allIn(enumPath, enumList);
674
-
675
- if (!validate) {
676
- return [
677
- {
678
- valid: false,
679
- code: 30000,
680
- description: `- **condition Enum_Required_21_AUTHORIZATION_STATUS**: every element of $.message.order.fulfillments[*].stops[*].authorization.status must be in ["UNCLAIMED", "CLAIMED"]
681
-
682
- > Note: **Condition Enum_Required_21_AUTHORIZATION_STATUS** can be skipped if the following conditions are met:
683
- >
684
- > - **condition B**: $.message.order.fulfillments[*].stops[*].authorization.status must **not** be present in the payload`,
685
- },
686
- ];
687
- }
688
-
689
- delete testObj._EXTERNAL;
690
- }
691
- return [{ valid: valid, code: 200 }, ...subResults];
692
- }
693
- function Enum_Required_22_PAYMENTS_STATUS(
694
- input: validationInput,
695
- ): validationOutput {
696
- const scope = payloadUtils.getJsonPath(input.payload, "$");
697
- let subResults: validationOutput = [];
698
- let valid = true;
699
- for (const testObj of scope) {
700
- testObj._EXTERNAL = input.externalData;
701
- const enumList = ["NOT-PAID", "PAID"];
702
- const enumPath = payloadUtils.getJsonPath(
703
- testObj,
704
- "$.message.order.payments[*].status",
705
- );
706
-
707
- const skipCheck = !validations.arePresent(enumPath);
708
- if (skipCheck) continue;
709
-
710
- const validate = validations.allIn(enumPath, enumList);
711
-
712
- if (!validate) {
713
- return [
714
- {
715
- valid: false,
716
- code: 30000,
717
- description: `- **condition Enum_Required_22_PAYMENTS_STATUS**: every element of $.message.order.payments[*].status must be in ["NOT-PAID", "PAID"]
718
-
719
- > Note: **Condition Enum_Required_22_PAYMENTS_STATUS** can be skipped if the following conditions are met:
720
- >
721
- > - **condition B**: $.message.order.payments[*].status must **not** be present in the payload`,
722
- },
723
- ];
724
- }
725
-
726
- delete testObj._EXTERNAL;
727
- }
728
- return [{ valid: valid, code: 200 }, ...subResults];
729
- }
730
- function Enum_Required_23_PAYMENTS_COLLECTED_BY(
731
- input: validationInput,
732
- ): validationOutput {
733
- const scope = payloadUtils.getJsonPath(input.payload, "$");
734
- let subResults: validationOutput = [];
735
- let valid = true;
736
- for (const testObj of scope) {
737
- testObj._EXTERNAL = input.externalData;
738
- const enumList = ["BPP", "BAP"];
739
- const enumPath = payloadUtils.getJsonPath(
740
- testObj,
741
- "$.message.order.payments[*].collected_by",
742
- );
743
-
744
- const skipCheck = !validations.arePresent(enumPath);
745
- if (skipCheck) continue;
746
-
747
- const validate = validations.allIn(enumPath, enumList);
748
-
749
- if (!validate) {
750
- return [
751
- {
752
- valid: false,
753
- code: 30000,
754
- description: `- **condition Enum_Required_23_PAYMENTS_COLLECTED_BY**: every element of $.message.order.payments[*].collected_by must be in ["BPP", "BAP"]
755
-
756
- > Note: **Condition Enum_Required_23_PAYMENTS_COLLECTED_BY** can be skipped if the following conditions are met:
757
- >
758
- > - **condition B**: $.message.order.payments[*].collected_by must **not** be present in the payload`,
759
- },
760
- ];
761
- }
762
-
763
- delete testObj._EXTERNAL;
764
- }
765
- return [{ valid: valid, code: 200 }, ...subResults];
766
- }
767
- function Enum_Required_24_PAYMENTS_TYPE(
768
- input: validationInput,
769
- ): validationOutput {
770
- const scope = payloadUtils.getJsonPath(input.payload, "$");
771
- let subResults: validationOutput = [];
772
- let valid = true;
773
- for (const testObj of scope) {
774
- testObj._EXTERNAL = input.externalData;
775
- const enumList = [
776
- "PRE-ORDER",
777
- "ON-FULFILLMENT",
778
- "POST-FULFILLMENT",
779
- ];
780
- const enumPath = payloadUtils.getJsonPath(
781
- testObj,
782
- "$.message.order.payments[*].type",
783
- );
784
-
785
- const skipCheck = !validations.arePresent(enumPath);
786
- if (skipCheck) continue;
787
-
788
- const validate = validations.allIn(enumPath, enumList);
789
-
790
- if (!validate) {
791
- return [
792
- {
793
- valid: false,
794
- code: 30000,
795
- description: `- **condition Enum_Required_24_PAYMENTS_TYPE**: every element of $.message.order.payments[*].type must be in ["PRE-ORDER", "ON-FULFILLMENT", "POST-FULFILLMENT"]
796
-
797
- > Note: **Condition Enum_Required_24_PAYMENTS_TYPE** can be skipped if the following conditions are met:
798
- >
799
- > - **condition B**: $.message.order.payments[*].type must **not** be present in the payload`,
800
- },
801
- ];
802
- }
803
-
804
- delete testObj._EXTERNAL;
805
- }
806
- return [{ valid: valid, code: 200 }, ...subResults];
807
- }
808
- function Enum_Required_25_BREAKUP_TITLE(
809
- input: validationInput,
810
- ): validationOutput {
811
- const scope = payloadUtils.getJsonPath(input.payload, "$");
812
- let subResults: validationOutput = [];
813
- let valid = true;
814
- for (const testObj of scope) {
815
- testObj._EXTERNAL = input.externalData;
816
- const enumList = [
817
- "BASE_PRICE",
818
- "REFUND",
819
- "CANCELLATION_CHARGES",
820
- "OFFER",
821
- "TOLL",
822
- ];
823
- const enumPath = payloadUtils.getJsonPath(
824
- testObj,
825
- "$.message.order.quote.breakup[*].title",
826
- );
827
-
828
- const skipCheck = !validations.arePresent(enumPath);
829
- if (skipCheck) continue;
830
-
831
- const validate = validations.allIn(enumPath, enumList);
832
-
833
- if (!validate) {
834
- return [
835
- {
836
- valid: false,
837
- code: 30000,
838
- description: `- **condition Enum_Required_25_BREAKUP_TITLE**: every element of $.message.order.quote.breakup[*].title must be in ["BASE_PRICE", "REFUND", "CANCELLATION_CHARGES", "OFFER", "TOLL"]
839
-
840
- > Note: **Condition Enum_Required_25_BREAKUP_TITLE** can be skipped if the following conditions are met:
841
- >
842
- > - **condition B**: $.message.order.quote.breakup[*].title must **not** be present in the payload`,
843
- },
844
- ];
845
- }
846
-
847
- delete testObj._EXTERNAL;
848
- }
849
- return [{ valid: valid, code: 200 }, ...subResults];
850
- }
851
-
852
- const testFunctions: testFunctionArray = [
853
- Attri_Required_1_CONTEXT_TIMESTAMP,
854
- Attri_Required_2_CONTEXT_BAP_ID,
855
- Attri_Required_3_CONTEXT_TRANSACTION_ID,
856
- Attri_Required_4_CONTEXT_MESSAGE_ID,
857
- Attri_Required_5_CONTEXT_VERSION,
858
- Attri_Required_6_CONTEXT_BAP_URI,
859
- Attri_Required_7_CONTEXT_TTL,
860
- Attri_Required_8_CONTEXT_BPP_ID,
861
- Attri_Required_9_CONTEXT_BPP_URI,
862
- Attri_Required_10_MESSAGE_UPDATE_TARGET,
863
- Attri_Required_11_ORDER_ID,
864
- Enum_Required_12_CONTEXT_ACTION,
865
- Enum_Required_13_COUNTRY_CODE,
866
- Enum_Required_14_CITY_CODE,
867
- Enum_Required_15_CONTEXT_DOMAIN,
868
- Enum_Required_16_DESCRIPTOR_CODE,
869
- Enum_Required_17_VEHICLE_CATEGORY,
870
- Enum_Required_18_FULFILLMENTS_TYPE,
871
- Enum_Required_19_FULFILLMENTS_TYPE,
872
- Enum_Required_20_AUTHORIZATION_TYPE,
873
- Enum_Required_21_AUTHORIZATION_STATUS,
874
- Enum_Required_22_PAYMENTS_STATUS,
875
- Enum_Required_23_PAYMENTS_COLLECTED_BY,
876
- Enum_Required_24_PAYMENTS_TYPE,
877
- Enum_Required_25_BREAKUP_TITLE,
878
- ];
879
-
880
- let invalidResults: validationOutput = [];
881
- for (const fn of testFunctions) {
882
- const subResult = fn(input);
883
- // .filter(r => !r.valid);
884
- invalidResults = [...invalidResults, ...subResult];
885
- if (!input.config.runAllValidations && invalidResults.length > 0) {
886
- return invalidResults;
887
- }
888
- }
889
- if (invalidResults.length > 0) {
890
- // return invalidResults;
891
- subResults = invalidResults;
892
- valid = subResults.every((r) => r.valid);
893
- }
894
-
895
- delete testObj._EXTERNAL;
896
- }
897
- return [{ valid: valid, code: 200 }, ...subResults];
898
- }