ondc-code-generator 0.7.8 → 0.8.0
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.
- package/alpha/possible-json-paths.json +2881 -35621
- package/dist/generator/generators/go/go-generator.js +9 -0
- package/dist/generator/generators/go/templates/test-config.mustache +4 -0
- package/dist/generator/generators/go/templates/test-object.mustache +7 -0
- package/dist/generator/generators/python/py-generator.js +5 -0
- package/dist/generator/generators/python/templates/test-config.mustache +2 -0
- package/dist/generator/generators/python/templates/test-object.mustache +4 -0
- package/dist/generator/generators/typescript/templates/test-config.mustache +3 -0
- package/dist/generator/generators/typescript/templates/test-object.mustache +5 -0
- package/dist/generator/generators/typescript/ts-generator.js +6 -1
- package/package.json +1 -1
|
@@ -137,6 +137,13 @@ export class GoGenerator extends CodeGenerator {
|
|
|
137
137
|
externalData validationutils.ExternalData,
|
|
138
138
|
) ([]validationutils.ValidationOutput, error) {
|
|
139
139
|
completeConfig := getCompleteConfig(config)
|
|
140
|
+
if completeConfig.SkipTests == nil {
|
|
141
|
+
completeConfig.SkipTests = []string{}
|
|
142
|
+
}
|
|
143
|
+
completeConfig.SkipTestsDict = make(map[string]bool)
|
|
144
|
+
for _, testName := range completeConfig.SkipTests {
|
|
145
|
+
completeConfig.SkipTestsDict[testName] = true
|
|
146
|
+
}
|
|
140
147
|
|
|
141
148
|
// Validate stateful requirements
|
|
142
149
|
if completeConfig.StateFullValidations {
|
|
@@ -192,6 +199,8 @@ func getCompleteConfig(config *validationutils.ValidationConfig) validationutils
|
|
|
192
199
|
HideParentErrors: true,
|
|
193
200
|
StateFullValidations: false,
|
|
194
201
|
Debug: false,
|
|
202
|
+
SkipTestsDict: make(map[string]bool),
|
|
203
|
+
SkipTests: []string{},
|
|
195
204
|
}
|
|
196
205
|
}
|
|
197
206
|
|
|
@@ -6,6 +6,8 @@ package validationutils
|
|
|
6
6
|
type ValidationConfig struct {
|
|
7
7
|
// StateFullValidations enables stateful validations that may depend on previous data
|
|
8
8
|
StateFullValidations bool
|
|
9
|
+
// SkipTests is a list of test names to be skipped during validation
|
|
10
|
+
SkipTests []string
|
|
9
11
|
// UniqueKey is an optional unique key for the validation instance
|
|
10
12
|
UniqueKey *string
|
|
11
13
|
// Store is an optional implementation of StorageInterface for persisting data across validations
|
|
@@ -16,6 +18,8 @@ type ValidationConfig struct {
|
|
|
16
18
|
HideParentErrors bool
|
|
17
19
|
// Debug enables debug mode for additional diagnostic information
|
|
18
20
|
Debug bool
|
|
21
|
+
// SkipTestsDict is an internal map for quick lookup of tests to skip
|
|
22
|
+
SkipTestsDict map[string]bool
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
// ValidationOutput represents the output of a validation run.
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
var {{name}} = func (input validationutils.ValidationInput) ([]validationutils.ValidationOutput, error) {
|
|
2
|
+
|
|
3
|
+
if input.Config.SkipTestsDict != nil {
|
|
4
|
+
if _, skip := input.Config.SkipTestsDict["{{name}}"]; skip {
|
|
5
|
+
return []validationutils.ValidationOutput{}, nil
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
2
9
|
scope := validationutils.GetJsonPath(input.Payload,"{{{scopePath}}}",true)
|
|
3
10
|
|
|
4
11
|
subResults := make([]validationutils.ValidationOutput, 0)
|
|
@@ -287,6 +287,8 @@ def perform_${functionName.toLowerCase()}(action, payload, config: ValidationCon
|
|
|
287
287
|
"_debug": False,
|
|
288
288
|
"hide_parent_errors": True,
|
|
289
289
|
"state_full_validations": False,
|
|
290
|
+
"skip_tests": [],
|
|
291
|
+
"_skip_tests_dict": {},
|
|
290
292
|
}
|
|
291
293
|
# Merge user config with default config
|
|
292
294
|
if config is None:
|
|
@@ -294,6 +296,9 @@ def perform_${functionName.toLowerCase()}(action, payload, config: ValidationCon
|
|
|
294
296
|
else:
|
|
295
297
|
config = {**default_config, **config}
|
|
296
298
|
|
|
299
|
+
for test_name in config.get("skip_tests", []):
|
|
300
|
+
config["_skip_tests_dict"][test_name] = True
|
|
301
|
+
|
|
297
302
|
if config.get("state_full_validations") and not config.get("store"):
|
|
298
303
|
raise Exception(
|
|
299
304
|
"State Full validations require a storage interface to be provided in the config."
|
|
@@ -18,10 +18,12 @@ class ValidationConfig(TypedDict, total=False):
|
|
|
18
18
|
"""
|
|
19
19
|
only_invalid: Optional[bool]
|
|
20
20
|
hide_parent_errors: Optional[bool]
|
|
21
|
+
skip_tests: Optional[List[str]]
|
|
21
22
|
_debug: Optional[bool]
|
|
22
23
|
state_full_validations: Optional[bool]
|
|
23
24
|
store: Optional[Any]
|
|
24
25
|
unique_key: Optional[str]
|
|
26
|
+
_skip_tests_dict: Optional[Dict[str, bool]]
|
|
25
27
|
|
|
26
28
|
# Input structure for validation functions
|
|
27
29
|
ValidationInput = Dict[str, Any]
|
|
@@ -6,6 +6,7 @@ import StorageInterface from "../interfaces/storage-interface";
|
|
|
6
6
|
*
|
|
7
7
|
* @property onlyInvalid - If true, only invalid results will be returned.
|
|
8
8
|
* @property stateFullValidations - If true, enables stateful validations that may depend on previous data.
|
|
9
|
+
* @property skipTests - Optional. An array of test names to be skipped during validation.
|
|
9
10
|
* @property uniqueKey - Optional. A unique key for the validation instance.
|
|
10
11
|
* @property store - Optional. An implementation of StorageInterface for persisting data across validations.
|
|
11
12
|
* @property hideParentErrors - Optional. Hides nested error details if set to true.
|
|
@@ -13,11 +14,13 @@ import StorageInterface from "../interfaces/storage-interface";
|
|
|
13
14
|
*/
|
|
14
15
|
export interface ValidationConfig {
|
|
15
16
|
stateFullValidations: boolean;
|
|
17
|
+
skipTests?: string[];
|
|
16
18
|
uniqueKey?: string;
|
|
17
19
|
store?: StorageInterface;
|
|
18
20
|
onlyInvalid: boolean;
|
|
19
21
|
hideParentErrors: boolean;
|
|
20
22
|
_debug: boolean;
|
|
23
|
+
_skipTestsDict?: { [key: string]: true };
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
/**
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
function {{name}}(input: validationInput): validationOutput {
|
|
2
|
+
|
|
3
|
+
if(input.config._skipTestsDict && input.config._skipTestsDict["{{testName}}"]){
|
|
4
|
+
return [];
|
|
5
|
+
}
|
|
6
|
+
|
|
2
7
|
const scope = payloadUtils.getJsonPath(input.payload,"{{{scopePath}}}");
|
|
3
8
|
let subResults: validationOutput = [];
|
|
4
9
|
let valid = true;
|
|
@@ -243,9 +243,14 @@ export class TypescriptGenerator extends CodeGenerator {
|
|
|
243
243
|
const masterFunction = `
|
|
244
244
|
export async function perform${functionName}(action: string, payload: any, config?: Partial<ValidationConfig>, externalData: any = {}) {
|
|
245
245
|
const completeConfig: ValidationConfig = {
|
|
246
|
-
...{ onlyInvalid: true, standardLogs: false, hideParentErrors: true, stateFullValidations: false, _debug: false },
|
|
246
|
+
...{ onlyInvalid: true, standardLogs: false, hideParentErrors: true, stateFullValidations: false, _debug: false,skipTests: [] },
|
|
247
247
|
...config,
|
|
248
248
|
};
|
|
249
|
+
completeConfig._skipTestsDict = {};
|
|
250
|
+
for(const testName of completeConfig.skipTests ?? []) {
|
|
251
|
+
completeConfig._skipTestsDict![testName] = true;
|
|
252
|
+
}
|
|
253
|
+
|
|
249
254
|
|
|
250
255
|
if (completeConfig.stateFullValidations && !completeConfig.store) {
|
|
251
256
|
throw new Error(
|