ondc-code-generator 0.0.1

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 (139) hide show
  1. package/.idea/code-generator.iml +12 -0
  2. package/.idea/modules.xml +8 -0
  3. package/.idea/vcs.xml +6 -0
  4. package/LICENSE +21 -0
  5. package/README.md +0 -0
  6. package/custom-loader.js +4 -0
  7. package/dist/Generator/config-compiler.js +53 -0
  8. package/dist/Generator/config-validator.js +21 -0
  9. package/dist/Generator/generators/classes/abstract-generator.js +16 -0
  10. package/dist/Generator/generators/documentation/markdown-message-generator.js +37 -0
  11. package/dist/Generator/generators/documentation/md-generator.js +57 -0
  12. package/dist/Generator/generators/markdown-message-generator.js +25 -0
  13. package/dist/Generator/generators/python/py-generator.js +1 -0
  14. package/dist/Generator/generators/typescript/templates/json-path-utils.js +15 -0
  15. package/dist/Generator/generators/typescript/templates/validation-utils.js +91 -0
  16. package/dist/Generator/generators/typescript/ts-ast.js +50 -0
  17. package/dist/Generator/generators/typescript/ts-generator.js +184 -0
  18. package/dist/Generator/pipline.js +1 -0
  19. package/dist/Generator/validators/abstract-validator.js +6 -0
  20. package/dist/Generator/validators/config-validator.js +32 -0
  21. package/dist/Generator/validators/session-data-config/session-data-validator.js +35 -0
  22. package/dist/Generator/validators/tests-config/sub-validations.js +194 -0
  23. package/dist/Generator/validators/tests-config/test-list-validator.js +36 -0
  24. package/dist/Generator/validators/tests-config/test-validator.js +24 -0
  25. package/dist/Generator/validators/validation-error.js +9 -0
  26. package/dist/constants/operations.js +17 -0
  27. package/dist/constants/syntax.js +75 -0
  28. package/dist/index.js +39 -0
  29. package/dist/services/rename-later/main.js +1 -0
  30. package/dist/services/rename-later/parser.js +22 -0
  31. package/dist/services/rename-later/tokens.js +32 -0
  32. package/dist/services/rename-later/tokens1.js +33 -0
  33. package/dist/services/return-complier/ast-functions/compile-to-markdown.js +66 -0
  34. package/dist/services/return-complier/ast-functions/semantic-validations.js +30 -0
  35. package/dist/services/return-complier/ast.js +92 -0
  36. package/dist/services/return-complier/combined.js +7 -0
  37. package/dist/services/return-complier/parser.js +95 -0
  38. package/dist/services/return-complier/tokens.js +144 -0
  39. package/dist/services/schema-service.js +29 -0
  40. package/dist/types/build.js +1 -0
  41. package/dist/types/compiler-types.js +4 -0
  42. package/dist/types/config-types.js +1 -0
  43. package/dist/types/error-codes.js +1 -0
  44. package/dist/types/general-types.js +1 -0
  45. package/dist/utils/config-utils/json-schema-utils.js +91 -0
  46. package/dist/utils/config-utils/yaml.js +16 -0
  47. package/dist/utils/file-system.js +1 -0
  48. package/dist/utils/fs-utils.js +20 -0
  49. package/dist/utils/general-utils/string-utils.js +56 -0
  50. package/dist/utils/general-utils/test-object-utils.js +12 -0
  51. package/dist/utils/general-utils/validation-utils.js +21 -0
  52. package/dist/utils/json-path-utils/extract-string-paths.js +113 -0
  53. package/dist/utils/json-path-utils/paths.js +46 -0
  54. package/dist/utils/logger.js +41 -0
  55. package/docs/error-gen.md +33 -0
  56. package/docs/return-grammer.md +23 -0
  57. package/docs/sampleConfig.md +39 -0
  58. package/generated/L1-validations/api-tests/cancel.ts +569 -0
  59. package/generated/L1-validations/api-tests/confirm.ts +1162 -0
  60. package/generated/L1-validations/api-tests/init.ts +1063 -0
  61. package/generated/L1-validations/api-tests/on_cancel.ts +2069 -0
  62. package/generated/L1-validations/api-tests/on_confirm.ts +2219 -0
  63. package/generated/L1-validations/api-tests/on_init.ts +1949 -0
  64. package/generated/L1-validations/api-tests/on_search.ts +1574 -0
  65. package/generated/L1-validations/api-tests/on_select.ts +1723 -0
  66. package/generated/L1-validations/api-tests/on_status.ts +2221 -0
  67. package/generated/L1-validations/api-tests/on_update.ts +1969 -0
  68. package/generated/L1-validations/api-tests/search.ts +695 -0
  69. package/generated/L1-validations/api-tests/select.ts +994 -0
  70. package/generated/L1-validations/api-tests/status.ts +443 -0
  71. package/generated/L1-validations/api-tests/update.ts +898 -0
  72. package/generated/L1-validations/error.ts +64 -0
  73. package/generated/L1-validations/index.ts +138 -0
  74. package/generated/L1-validations/page/index.html +2118 -0
  75. package/generated/L1-validations/page/style.css +225 -0
  76. package/generated/L1-validations/readme.md +1779 -0
  77. package/generated/L1-validations/types/test-config.ts +27 -0
  78. package/generated/L1-validations/utils/json-path-utils.ts +17 -0
  79. package/generated/L1-validations/utils/validation-utils.ts +116 -0
  80. package/generated-structure/api-tests/search.ts +24 -0
  81. package/generated-structure/error.ts +0 -0
  82. package/generated-structure/index.ts +0 -0
  83. package/generated-structure/types/test-config.ts +21 -0
  84. package/nodemon.json +5 -0
  85. package/package.json +40 -0
  86. package/samples/build.yaml +24799 -0
  87. package/samples/output.md +91 -0
  88. package/samples/output.ts +27 -0
  89. package/samples/selections.json +216 -0
  90. package/samples/validation-config.json +3422 -0
  91. package/samples/x-validations.yaml +2893 -0
  92. package/src/constants/operations.ts +19 -0
  93. package/src/constants/syntax.ts +81 -0
  94. package/src/example.ts +25 -0
  95. package/src/generator/config-compiler.ts +122 -0
  96. package/src/generator/generators/classes/abstract-generator.ts +29 -0
  97. package/src/generator/generators/documentation/markdown-message-generator.ts +43 -0
  98. package/src/generator/generators/documentation/md-generator.ts +76 -0
  99. package/src/generator/generators/documentation/templates/index.mustache +36 -0
  100. package/src/generator/generators/documentation/templates/style.css +204 -0
  101. package/src/generator/generators/python/py-generator.ts +0 -0
  102. package/src/generator/generators/typescript/templates/api-test.mustache +7 -0
  103. package/src/generator/generators/typescript/templates/json-path-utils.ts +17 -0
  104. package/src/generator/generators/typescript/templates/schema-template.mustache +18 -0
  105. package/src/generator/generators/typescript/templates/test-config.mustache +28 -0
  106. package/src/generator/generators/typescript/templates/test-object.mustache +20 -0
  107. package/src/generator/generators/typescript/templates/validation-code.mustache +39 -0
  108. package/src/generator/generators/typescript/templates/validation-utils.ts +117 -0
  109. package/src/generator/generators/typescript/ts-ast.ts +72 -0
  110. package/src/generator/generators/typescript/ts-generator.ts +275 -0
  111. package/src/generator/validators/abstract-validator.ts +23 -0
  112. package/src/generator/validators/config-validator.ts +55 -0
  113. package/src/generator/validators/session-data-config/session-data-validator.ts +58 -0
  114. package/src/generator/validators/tests-config/sub-validations.ts +302 -0
  115. package/src/generator/validators/tests-config/test-list-validator.ts +59 -0
  116. package/src/generator/validators/tests-config/test-validator.ts +69 -0
  117. package/src/index.ts +2 -0
  118. package/src/services/return-complier/ast-functions/compile-to-markdown.ts +152 -0
  119. package/src/services/return-complier/ast-functions/semantic-validations.ts +44 -0
  120. package/src/services/return-complier/ast.ts +147 -0
  121. package/src/services/return-complier/combined.ts +8 -0
  122. package/src/services/return-complier/parser.ts +128 -0
  123. package/src/services/return-complier/tokens.ts +184 -0
  124. package/src/services/schema-service.ts +42 -0
  125. package/src/types/build.ts +51 -0
  126. package/src/types/compiler-types.ts +3 -0
  127. package/src/types/config-types.ts +27 -0
  128. package/src/types/error-codes.ts +6 -0
  129. package/src/types/general-types.ts +2 -0
  130. package/src/utils/config-utils/json-schema-utils.ts +150 -0
  131. package/src/utils/config-utils/yaml.ts +17 -0
  132. package/src/utils/fs-utils.ts +32 -0
  133. package/src/utils/general-utils/string-utils.ts +76 -0
  134. package/src/utils/general-utils/test-object-utils.ts +14 -0
  135. package/src/utils/general-utils/validation-utils.ts +30 -0
  136. package/src/utils/json-path-utils/extract-string-paths.ts +139 -0
  137. package/src/utils/json-path-utils/paths.ts +44 -0
  138. package/src/utils/logger.ts +53 -0
  139. package/tsconfig.json +17 -0
@@ -0,0 +1,91 @@
1
+ ## a are unique && b are unique
2
+
3
+ - **condition A**: all of the following sub conditions must be met:
4
+
5
+ - **condition A.1**: {{a}} must be unique
6
+ - **condition A.2**: {{b}} must be unique
7
+
8
+ ## a are unique
9
+
10
+ - **condition A**: {{a}} must be unique
11
+
12
+ ## (a are unique && b are unique) || c are unique
13
+
14
+ - **condition A**: any one of the following sub conditions must be met:
15
+
16
+ - **condition A.1**: all of the following sub conditions must be met:
17
+
18
+ - **condition A.1.1**: {{a}} must be unique
19
+ - **condition A.1.2**: {{b}} must be unique
20
+
21
+ - **condition A.2**: {{c}} must be unique
22
+
23
+ ## a are unique && b are unique || c are unique
24
+
25
+ - **condition A**: any one of the following sub conditions must be met:
26
+
27
+ - **condition A.1**: all of the following sub conditions must be met:
28
+
29
+ - **condition A.1.1**: {{a}} must be unique
30
+ - **condition A.1.2**: {{b}} must be unique
31
+
32
+ - **condition A.2**: {{c}} must be unique
33
+
34
+ ## a are unique && (b are unique || c are unique)
35
+
36
+ - **condition A**: all of the following sub conditions must be met:
37
+
38
+ - **condition A.1**: {{a}} must be unique
39
+ - **condition A.2**: any one of the following sub conditions must be met:
40
+
41
+ - **condition A.2.1**: {{b}} must be unique
42
+ - **condition A.2.2**: {{c}} must be unique
43
+
44
+ ## a are unique && b are unique && c are unique && d are unique
45
+
46
+ - **condition A**: all of the following sub conditions must be met:
47
+
48
+ - **condition A.1**: all of the following sub conditions must be met:
49
+
50
+ - **condition A.1.1**: all of the following sub conditions must be met:
51
+
52
+ - **condition A.1.1.1**: {{a}} must be unique
53
+ - **condition A.1.1.2**: {{b}} must be unique
54
+
55
+ - **condition A.1.2**: {{c}} must be unique
56
+
57
+ - **condition A.2**: {{d}} must be unique
58
+
59
+ ## a are unique && !(b are unique || !(c are unique))
60
+
61
+ - **condition A**: all of the following sub conditions must be met:
62
+
63
+ - **condition A.1**: {{a}} must be unique
64
+ - **condition A.2**: any one of the following sub conditions must **not** be met:
65
+
66
+ - **condition A.2.1**: {{b}} must **not** be unique
67
+ - **condition A.2.2**: {{c}} must be unique
68
+
69
+ ## a are unique && (b are unique || !(!(c are unique))) && !(d are unique)
70
+
71
+ - **condition A**: all of the following sub conditions must be met:
72
+
73
+ - **condition A.1**: all of the following sub conditions must be met:
74
+
75
+ - **condition A.1.1**: {{a}} must be unique
76
+ - **condition A.1.2**: any one of the following sub conditions must be met:
77
+
78
+ - **condition A.1.2.1**: {{b}} must be unique
79
+ - **condition A.1.2.2**: {{c}} must be unique
80
+
81
+ - **condition A.2**: {{d}} must **not** be unique
82
+
83
+ ## hello
84
+
85
+ - **condition A**: no element of $.context.location.country.code must be in ["null"]
86
+
87
+ ###
88
+
89
+ > Note: **Condition A** can be skipped if the following conditions are met:
90
+ >
91
+ > - **condition B**: $.context.location.country.code must be unique
@@ -0,0 +1,27 @@
1
+ function finder_fees_percetage_check(input: validationInput): validationOutput {
2
+ const scope = payloadUtils.getJsonPath(input.payload,"$.message.order.payments[*].tags[?(@.descriptor.code=='BUYER_FINDER_FEES')].list[?(@.descriptor.code=='BUYER_FINDER_FEES_PERCENTAGE')]");
3
+ for(const testObj of scope){
4
+ testObj._EXTERNAL = input.externalData;
5
+ const value = payloadUtils.getJsonPath(testObj, '$.value')
6
+ const reg = ["^[0-9]{1,2}$"]
7
+ const nulls = ["null"]
8
+
9
+
10
+
11
+
12
+ const validate = (validations.noneIn(value, nulls)) && (validations.followRegex(value, reg))
13
+
14
+
15
+ if(!validate){
16
+ return [{
17
+ valid: false,
18
+ errorCode: "30000",
19
+ description: `- **condition A**: all of the following sub conditions must be met:
20
+
21
+ - **condition A.1**: no element of $.value must be in ["null"]
22
+ - **condition A.2**: all elements of $.value must follow every regex in ["^[0-9]{1,2}$"]`
23
+ }]
24
+ }
25
+ }
26
+ return [{valid: true}];
27
+ }
@@ -0,0 +1,216 @@
1
+ {
2
+ "_TESTS_": {
3
+ "search": [
4
+ {
5
+ "_NAME_": "first_search_request",
6
+ "mockType": "$._EXTERNAL.mock_type",
7
+ "forType": ["BAP"],
8
+ "_RETURN_": "(mockType equal to forType)",
9
+ "_SUCCESS_CODE_": 100
10
+ },
11
+ {
12
+ "_NAME_": "second_search_request",
13
+ "mockType": "$._EXTERNAL.mock_type",
14
+ "forType": ["BAP"],
15
+ "_RETURN_": "(mockType equal to forType)",
16
+ "_SUCCESS_CODE_": 101
17
+ },
18
+ {
19
+ "_NAME_": "first_onsearch_request",
20
+ "mockType": "$._EXTERNAL.mock_type",
21
+ "city_code": "$._EXTERNAL.city_code",
22
+ "bap_uri": "$._EXTERNAL.bap_uri",
23
+ "forType": ["BPP"],
24
+ "_RETURN_": "(mockType equal to forType) && (bap_uri are present) && (city_code are present)",
25
+ "_SUCCESS_CODE_": 102
26
+ },
27
+ {
28
+ "_NAME_": "second_onsearch_request",
29
+ "mockType": "$._EXTERNAL.mock_type",
30
+ "start_code": "$._EXTERNAL.start_code",
31
+ "forType": ["BPP"],
32
+ "_RETURN_": "(mockType equal to forType) && (start_code are present)",
33
+ "_SUCCESS_CODE_": 103
34
+ },
35
+ {
36
+ "_NAME_": "select_request",
37
+ "lastAction": "$._EXTERNAL.last_action",
38
+ "mockType": "$._EXTERNAL.mock_type",
39
+ "forType": ["BAP"],
40
+ "_RETURN_": "(mockType equal to forType)",
41
+ "_SUCCESS_CODE_": 104
42
+ },
43
+ {
44
+ "_NAME_": "onselect_request",
45
+ "mockType": "$._EXTERNAL.mock_type",
46
+ "selected_item_ids": "$._EXTERNAL.selected_item_ids[*]",
47
+ "forType": ["BPP"],
48
+ "_RETURN_": "(mockType equal to forType) && (selected_item_ids are present)",
49
+ "_SUCCESS_CODE_": 105
50
+ },
51
+ {
52
+ "_NAME_": "init_request",
53
+ "mockType": "$._EXTERNAL.mock_type",
54
+ "forType": ["BAP"],
55
+ "_RETURN_": "(mockType equal to forType)",
56
+ "_SUCCESS_CODE_": 106
57
+ },
58
+ {
59
+ "_NAME_": "oninit_request",
60
+ "mockType": "$._EXTERNAL.mock_type",
61
+ "payments": "$._EXTERNAL.payments[*].collected_by",
62
+ "forType": ["BPP"],
63
+ "_RETURN_": "(mockType equal to forType) && (payments are present)",
64
+ "_SUCCESS_CODE_": 107
65
+ },
66
+ {
67
+ "_NAME_": "confirm_request",
68
+ "mockType": "$._EXTERNAL.mock_type",
69
+ "forType": ["BAP"],
70
+ "_RETURN_": "(mockType equal to forType)",
71
+ "_SUCCESS_CODE_": 108
72
+ },
73
+ {
74
+ "_NAME_": "onconfirm_request",
75
+ "mockType": "$._EXTERNAL.mock_type",
76
+ "updated_payments": "$._EXTERNAL.updated_payments[*].id",
77
+ "forType": ["BPP"],
78
+ "_RETURN_": "(mockType equal to forType) && (updated_payments are present)",
79
+ "_SUCCESS_CODE_": 109
80
+ },
81
+ {
82
+ "_NAME_": "onconfirm_delayed_request",
83
+ "mockType": "$._EXTERNAL.mock_type",
84
+ "updated_payments": "$._EXTERNAL.updated_payments[*].id",
85
+ "forType": ["BPP"],
86
+ "_RETURN_": "(mockType equal to forType) && (updated_payments are present)",
87
+ "_SUCCESS_CODE_": 110
88
+ },
89
+ {
90
+ "_NAME_": "status_request",
91
+ "mockType": "$._EXTERNAL.mock_type",
92
+ "forType": ["BAP"],
93
+ "_RETURN_": "(mockType equal to forType)",
94
+ "_SUCCESS_CODE_": 111
95
+ },
96
+ {
97
+ "_NAME_": "onstatus_active_request",
98
+ "mockType": "$._EXTERNAL.mock_type",
99
+ "forType": ["BPP"],
100
+ "order_id": "$._EXTERNAL.order_id",
101
+ "_RETURN_": "(mockType equal to forType) && (order_id are present)",
102
+ "_SUCCESS_CODE_": 112
103
+ },
104
+ {
105
+ "_NAME_": "onstatus_complete_request",
106
+ "mockType": "$._EXTERNAL.mock_type",
107
+ "forType": ["BPP"],
108
+ "order_id": "$._EXTERNAL.order_id",
109
+ "_RETURN_": "(mockType equal to forType) && (order_id are present)",
110
+ "_SUCCESS_CODE_": 113
111
+ },
112
+ {
113
+ "_NAME_": "onstatus_complete_unsolicited_request",
114
+ "mockType": "$._EXTERNAL.mock_type",
115
+ "forType": ["BPP"],
116
+ "order_id": "$._EXTERNAL.order_id",
117
+ "_RETURN_": "(mockType equal to forType) && (order_id are present)",
118
+ "_SUCCESS_CODE_": 114
119
+ },
120
+ {
121
+ "_NAME_": "cancel_request",
122
+ "mockType": "$._EXTERNAL.mock_type",
123
+ "forType": ["BAP"],
124
+ "_RETURN_": "(mockType equal to forType) ",
125
+ "_SUCCESS_CODE_": 115
126
+ },
127
+ {
128
+ "_NAME_": "cancel_soft_request",
129
+ "mockType": "$._EXTERNAL.mock_type",
130
+ "forType": ["BAP"],
131
+ "_RETURN_": "(mockType equal to forType)",
132
+ "_SUCCESS_CODE_": 116
133
+ },
134
+ {
135
+ "_NAME_": "cancel_hard_request",
136
+ "mockType": "$._EXTERNAL.mock_type",
137
+ "forType": ["BAP"],
138
+ "_RETURN_": "(mockType equal to forType)",
139
+ "_SUCCESS_CODE_": 117
140
+ },
141
+ {
142
+ "_NAME_": "oncancel_request",
143
+ "mockType": "$._EXTERNAL.mock_type",
144
+ "forType": ["BPP"],
145
+ "order_id": "$._EXTERNAL.order_id",
146
+ "_RETURN_": "(mockType equal to forType) && (order_id are present)",
147
+ "_SUCCESS_CODE_": 118
148
+ },
149
+ {
150
+ "_NAME_": "oncancel_soft_request",
151
+ "mockType": "$._EXTERNAL.mock_type",
152
+ "forType": ["BPP"],
153
+ "order_id": "$._EXTERNAL.order_id",
154
+ "_RETURN_": "(mockType equal to forType) && (order_id are present)",
155
+ "_SUCCESS_CODE_": 119
156
+ },
157
+ {
158
+ "_NAME_": "oncancel_hard_request",
159
+ "mockType": "$._EXTERNAL.mock_type",
160
+ "forType": ["BPP"],
161
+ "order_id": "$._EXTERNAL.order_id",
162
+ "_RETURN_": "(mockType equal to forType) && (order_id are present)",
163
+ "_SUCCESS_CODE_": 120
164
+ },
165
+ {
166
+ "_NAME_": "oncancel_init_request",
167
+ "mockType": "$._EXTERNAL.mock_type",
168
+ "forType": ["BPP"],
169
+ "order_id": "$._EXTERNAL.order_id",
170
+ "_RETURN_": "(mockType equal to forType) && (order_id are present)",
171
+ "_SUCCESS_CODE_": 121
172
+ },
173
+ {
174
+ "_NAME_": "onupdate_request",
175
+ "mockType": "$._EXTERNAL.mock_type",
176
+ "forType": ["BPP"],
177
+ "order_id": "$._EXTERNAL.order_id",
178
+ "_RETURN_": "(mockType equal to forType) && (order_id are present)",
179
+ "_SUCCESS_CODE_": 122
180
+ }
181
+ ]
182
+ },
183
+ "_SESSION_DATA_": {
184
+ "search": {
185
+ "transaction_id": null,
186
+ "message_id": null,
187
+ "last_action": null,
188
+ "mock_type": null,
189
+ "city_code": null,
190
+ "bap_id": null,
191
+ "bap_uri": null,
192
+ "bpp_id": null,
193
+ "bpp_uri": null,
194
+ "start_code": null,
195
+ "end_code": null,
196
+ "buyer_app_fee": null,
197
+ "vehicle_type": null,
198
+ "fulfillments": null,
199
+ "category_ids": null,
200
+ "provider_id": null,
201
+ "fulfillment_ids": null,
202
+ "item_ids": null,
203
+ "items": null,
204
+ "selected_items": null,
205
+ "selected_item_ids": null,
206
+ "billing": null,
207
+ "payments": null,
208
+ "updated_payments": null,
209
+ "order_id": null,
210
+ "status": null,
211
+ "error_code": null,
212
+ "error_message": null,
213
+ "quote": null
214
+ }
215
+ }
216
+ }