@kontur.candy/generator 5.43.0 → 5.44.0-fix-holkin-validations.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/dist/index.js +40 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -58179,6 +58179,21 @@ class FormSchemaRng {
|
|
|
58179
58179
|
}
|
|
58180
58180
|
return children;
|
|
58181
58181
|
}
|
|
58182
|
+
getAllChildValueNodes(element) {
|
|
58183
|
+
const children = [];
|
|
58184
|
+
const queue = [element];
|
|
58185
|
+
while (queue.length > 0) {
|
|
58186
|
+
const current = queue.shift();
|
|
58187
|
+
if (current instanceof FormSchemaRngElement) {
|
|
58188
|
+
const childrenOfCurrent = Array.from(current.children.values());
|
|
58189
|
+
const attributesOfCurrent = Array.from(current.attributes.values());
|
|
58190
|
+
children.push(...childrenOfCurrent.filter(x => x.innerTextType != undefined));
|
|
58191
|
+
queue.push(...childrenOfCurrent);
|
|
58192
|
+
children.push(...attributesOfCurrent);
|
|
58193
|
+
}
|
|
58194
|
+
}
|
|
58195
|
+
return children;
|
|
58196
|
+
}
|
|
58182
58197
|
getPath(element, multiplicityToken = _Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_1__.PathTokens.current) {
|
|
58183
58198
|
const result = [];
|
|
58184
58199
|
let currentElement = element;
|
|
@@ -68074,7 +68089,7 @@ class FLangValidationBuildContext {
|
|
|
68074
68089
|
this.pathsWithValidations.add(targetPath);
|
|
68075
68090
|
const schemaNode = this.schemaRng.getElementByPath(targetPath);
|
|
68076
68091
|
const parentNode = schemaNode != undefined ? this.getFirstAcceptedParent(schemaNode) : undefined;
|
|
68077
|
-
const allChildrenPaths = parentNode instanceof _common_SchemaRng_FormSchemaRng__WEBPACK_IMPORTED_MODULE_2__.FormSchemaRngElement ? this.schemaRng.
|
|
68092
|
+
const allChildrenPaths = parentNode instanceof _common_SchemaRng_FormSchemaRng__WEBPACK_IMPORTED_MODULE_2__.FormSchemaRngElement ? this.schemaRng.getAllChildValueNodes(parentNode).map(x => this.schemaRng.getPath(x, _Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_1__.PathTokens.each)).filter(x => !(0,_Common_ModelPath_PathSplitHelper__WEBPACK_IMPORTED_MODULE_4__.getMatchedAndDifferentModelPaths)(targetPath, x).differentPath.isContainIteration()) : undefined;
|
|
68078
68093
|
const restChecks = allChildrenPaths === null || allChildrenPaths === void 0 ? void 0 : allChildrenPaths.map(childPath => new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_14__.EqExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_14__.ValueReferenceExpression(childPath.toCurrentIteration(), "value"), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_14__.StringLiteralExpression(""))).reduce(_FLang_FlangUtils__WEBPACK_IMPORTED_MODULE_13__.combineByAndFlangExpr, undefined);
|
|
68079
68094
|
const errorValidations = validations.filter(x => !x.checkType || x.checkType === "error");
|
|
68080
68095
|
const errorExpression = this.createFlangExpression((0,_Common_IterableUtils__WEBPACK_IMPORTED_MODULE_5__.reverseArray)(errorValidations), targetPath, valueReference, "error", highOrderDescription !== null && highOrderDescription !== void 0 ? highOrderDescription : typeNode === null || typeNode === void 0 ? void 0 : typeNode.requiredDescription, optional, parentNode, restChecks);
|
|
@@ -99580,7 +99595,6 @@ class ValidationGenerator {
|
|
|
99580
99595
|
this.controlCustomizationContext = void 0;
|
|
99581
99596
|
this.useSchemaValidations = void 0;
|
|
99582
99597
|
this.criterionOfExistenceFromSchemaRng = [];
|
|
99583
|
-
this.depsRngSchemaValidationCounter = 0;
|
|
99584
99598
|
this.settings = void 0;
|
|
99585
99599
|
this.visibilityConditionsStack = [];
|
|
99586
99600
|
this.sugarRoot = sugarRoot;
|
|
@@ -99672,7 +99686,7 @@ class ValidationGenerator {
|
|
|
99672
99686
|
// NOTE Просто, чтоб не падали аппрувал тесты
|
|
99673
99687
|
return emptyResult;
|
|
99674
99688
|
}
|
|
99675
|
-
const result = `export default function rngSchemaValidationConfigurator ({ form, ValidationHelper, Validators, ap, ValidationFunction, DependenciesRequiredAreEmpty, PathTokens }) {
|
|
99689
|
+
const result = `export default function rngSchemaValidationConfigurator ({ form, ValidationHelper, Validators, ap, ValidationFunction, DependenciesRequiredAreEmpty, PathTokens, kcLangUtils }) {
|
|
99676
99690
|
const t = str => x => x.translate(str);
|
|
99677
99691
|
${compiledConditions.join("\n")}
|
|
99678
99692
|
}
|
|
@@ -99680,18 +99694,35 @@ class ValidationGenerator {
|
|
|
99680
99694
|
return result;
|
|
99681
99695
|
}
|
|
99682
99696
|
generateRequiredValidationByDeps(bindingPath, dependencies, localizedString) {
|
|
99697
|
+
var _this$validations$bin, _this$validations$bin2, _this$validations$bin3;
|
|
99683
99698
|
const targetAsString = this.modelPathInstance(bindingPath);
|
|
99684
|
-
const dependenciesAsString = dependencies.map(x => this.modelPathInstance(x.toCurrentIteration())).join(", \n");
|
|
99685
99699
|
const message = typeof localizedString === "string" ? `"${localizedString}"` : localizedString.expression;
|
|
99686
|
-
const
|
|
99700
|
+
const hasAlwaysVisibleCondition = (_this$validations$bin = this.validations[bindingPath.toLegacyPath()]) === null || _this$validations$bin === void 0 ? void 0 : _this$validations$bin.map(x => x.conditions).some(x => x.length == 0);
|
|
99701
|
+
const conditions = (_this$validations$bin2 = (_this$validations$bin3 = this.validations[bindingPath.toLegacyPath()]) === null || _this$validations$bin3 === void 0 ? void 0 : _this$validations$bin3.map(x => x.conditions).flat()) !== null && _this$validations$bin2 !== void 0 ? _this$validations$bin2 : [];
|
|
99702
|
+
if (conditions.length == 0 || hasAlwaysVisibleCondition) {
|
|
99703
|
+
const dependenciesToCheck = dependencies.map(x => this.modelPathInstance(x.toCurrentIteration()));
|
|
99704
|
+
return `
|
|
99705
|
+
form.calculator2.addCalculationFunction(
|
|
99706
|
+
new ValidationFunction(
|
|
99707
|
+
${targetAsString},
|
|
99708
|
+
[${dependenciesToCheck}],
|
|
99709
|
+
context => DependenciesRequiredAreEmpty.execute(context, ${targetAsString}, [${dependenciesToCheck}], ${message}, "Error", form.localization)
|
|
99710
|
+
)
|
|
99711
|
+
);`;
|
|
99712
|
+
}
|
|
99713
|
+
const depsFromConditions = conditions.map(x => x[2].map(depPath => x[1].joinWith(depPath))).flat();
|
|
99714
|
+
const generatedCondition = conditions.map(([condition, context]) => `[(path, count) => ${condition}, ${this.modelPathInstance(context)}]`).join(",");
|
|
99715
|
+
const dependenciesAsString = [...dependencies.map(x => this.modelPathInstance(x.toCurrentIteration())), ...depsFromConditions.map(x => this.modelPathInstance(x.normalize().toCurrentIteration()))].join(", \n");
|
|
99716
|
+
const dependenciesToCheck = dependencies.map(x => this.modelPathInstance(x.toCurrentIteration()));
|
|
99687
99717
|
return `
|
|
99688
|
-
const ${depsVariableName} = [${dependenciesAsString}]
|
|
99689
99718
|
form.calculator2.addCalculationFunction(
|
|
99690
99719
|
new ValidationFunction(
|
|
99691
99720
|
${targetAsString},
|
|
99692
|
-
${
|
|
99693
|
-
|
|
99694
|
-
|
|
99721
|
+
[${dependenciesAsString}],
|
|
99722
|
+
ValidationFunction.conditionalValidatorEvaluator(
|
|
99723
|
+
ValidationFunction.javascriptSugarExpressionToEvaluator(form, [${generatedCondition}]),
|
|
99724
|
+
context => DependenciesRequiredAreEmpty.execute(context, ${targetAsString}, [${dependenciesToCheck}], ${message}, "Error", form.localization)
|
|
99725
|
+
)
|
|
99695
99726
|
)
|
|
99696
99727
|
);`;
|
|
99697
99728
|
}
|