@kontur.candy/generator 5.2.0-server-side-calculations.0 → 5.2.0-server-side-calculations.2

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 (2) hide show
  1. package/dist/index.js +82 -47
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -60205,6 +60205,33 @@ function assertIs(value) {
60205
60205
 
60206
60206
  /***/ }),
60207
60207
 
60208
+ /***/ "./Common/getRngSchemaFilename.ts":
60209
+ /*!****************************************!*\
60210
+ !*** ./Common/getRngSchemaFilename.ts ***!
60211
+ \****************************************/
60212
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
60213
+
60214
+ "use strict";
60215
+ __webpack_require__.r(__webpack_exports__);
60216
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
60217
+ /* harmony export */ "getRngSchemaFilename": () => (/* binding */ getRngSchemaFilename)
60218
+ /* harmony export */ });
60219
+ /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! fs */ "fs");
60220
+ /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
60221
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! path */ "path");
60222
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
60223
+
60224
+
60225
+ const getRngSchemaFilename = (formSchemasDirPath, gfv) => {
60226
+ const maxSubversion = (0,fs__WEBPACK_IMPORTED_MODULE_0__.readdirSync)(formSchemasDirPath).map(fileName => fileName.includes(".rng.xml") && !fileName.includes("схема.rng.xml")).filter(i => i === true).length - 1;
60227
+ if (maxSubversion === undefined || !(0,fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)(path__WEBPACK_IMPORTED_MODULE_1___default().join(formSchemasDirPath, `${gfv}.${maxSubversion}.rng.xml`))) {
60228
+ return ".rng.xml";
60229
+ }
60230
+ return `.${maxSubversion}.rng.xml`;
60231
+ };
60232
+
60233
+ /***/ }),
60234
+
60208
60235
  /***/ "./Common/hashUtils.ts":
60209
60236
  /*!*****************************!*\
60210
60237
  !*** ./Common/hashUtils.ts ***!
@@ -78899,6 +78926,8 @@ __webpack_require__.r(__webpack_exports__);
78899
78926
  /* harmony import */ var recursive_readdir__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! recursive-readdir */ "./node_modules/recursive-readdir/index.js");
78900
78927
  /* harmony import */ var recursive_readdir__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(recursive_readdir__WEBPACK_IMPORTED_MODULE_7__);
78901
78928
  /* harmony import */ var _common_ExtractSugarReferences__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../common/ExtractSugarReferences */ "./Generator/src/common/ExtractSugarReferences.ts");
78929
+ /* harmony import */ var _Common_getRngSchemaFilename__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Common/getRngSchemaFilename */ "./Common/getRngSchemaFilename.ts");
78930
+
78902
78931
 
78903
78932
 
78904
78933
 
@@ -79137,7 +79166,7 @@ async function connectJSFilesWithNames(formJavaScriptFilesPath) {
79137
79166
  }
79138
79167
  }
79139
79168
  function readSchemaRngFile(formSchemasPath, gfv) {
79140
- return readFileAsync(path__WEBPACK_IMPORTED_MODULE_1___default().join(formSchemasPath, `${gfv}.rng.xml`), "utf-8");
79169
+ return readFileAsync(path__WEBPACK_IMPORTED_MODULE_1___default().join(formSchemasPath, `${gfv}${(0,_Common_getRngSchemaFilename__WEBPACK_IMPORTED_MODULE_9__.getRngSchemaFilename)(formSchemasPath, gfv)}`), "utf-8");
79141
79170
  }
79142
79171
  function readHooksFile(formDirectoryPath) {
79143
79172
  return readFileAsync(path__WEBPACK_IMPORTED_MODULE_1___default().join(formDirectoryPath, "hooks.js"), "utf-8").catch(() => "");
@@ -79145,7 +79174,7 @@ function readHooksFile(formDirectoryPath) {
79145
79174
  async function readFileSource(filePath, filename, defaultValue) {
79146
79175
  try {
79147
79176
  return await readFileAsync(path__WEBPACK_IMPORTED_MODULE_1___default().join(filePath, filename), "utf-8");
79148
- } catch (ingoreError) {
79177
+ } catch (ignoreError) {
79149
79178
  return defaultValue;
79150
79179
  }
79151
79180
  }
@@ -81148,7 +81177,7 @@ class FormulaExpressionToFlangExpressionConverter {
81148
81177
  const currenCountExpression = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ValueReferenceExpression(iterablePath.joinWith((0,_Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_1__.createRelativeFromTokens)(suffixWithoutMultiple)).joinWith("Count").toCurrentIteration().normalize(), "value");
81149
81178
  const sumReduceExpr = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ReduceCallExpression(iterablePath.toCurrentIteration(), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.AnonymousFunctionDeclarationExpression(_FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.BuildInTypeExpression.decimal, [new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ArgumentDeclarationExpression("result", _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.BuildInTypeExpression.decimal)], new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ConditionalExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.OrBinaryExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.NotEqExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ArgumentReferenceExpression("result"), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.NullLiteralExpression()), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.NotEqExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.CastExpression(resultValueExpression, _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.BuildInTypeExpression.decimal), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.NullLiteralExpression())), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.MinusBinaryExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.SumBinaryExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.NullCoalesceExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ArgumentReferenceExpression("result"), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DecimalLiteralExpression(0)), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.CastExpression(resultValueExpression, _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.BuildInTypeExpression.decimal, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DecimalLiteralExpression(0))), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ConditionalExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.IncrementalFlagExpression(), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.CastExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.GetOldExpression(resultValueExpression), _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.BuildInTypeExpression.decimal, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DecimalLiteralExpression(0)), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DecimalLiteralExpression(0))), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.NullLiteralExpression())), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ConditionalExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.IncrementalFlagExpression(), (0,_FLang_FlangUtils__WEBPACK_IMPORTED_MODULE_7__.castOperandToDecimalIfNeed)(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.NoDepsExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ValueReferenceExpression(nextResultValueExpression.modePath.toCurrentIteration(), nextResultValueExpression.valueName))), (0,_FLang_FlangUtils__WEBPACK_IMPORTED_MODULE_7__.castOperandToDecimalIfNeed)(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.NullLiteralExpression())));
81150
81179
  addPrecalculationRule(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.SetStatement(nextResultValueExpression, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.NullCoalesceExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.CastExpression(sumReduceExpr, _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.BuildInTypeExpression.string, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.StringLiteralExpression("G29")), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.StringLiteralExpression(""))));
81151
- const countReduceExpr = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ReduceCallExpression(iterablePath.toCurrentIteration(), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.AnonymousFunctionDeclarationExpression(_FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.BuildInTypeExpression.decimal, [new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ArgumentDeclarationExpression("result", _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.BuildInTypeExpression.decimal)], new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.MinusBinaryExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.SumBinaryExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ArgumentReferenceExpression("result"), countValueExpression == undefined ? new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ConditionalExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.NotEqExpression(resultValueExpression, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.StringLiteralExpression("")), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DecimalLiteralExpression(1), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DecimalLiteralExpression(0)) : new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.CastExpression(countValueExpression, _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.BuildInTypeExpression.decimal, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DecimalLiteralExpression(0))), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ConditionalExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.IncrementalFlagExpression(), countValueExpression == undefined ? new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ConditionalExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.NotEqExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.GetOldExpression(resultValueExpression), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.StringLiteralExpression("")), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DecimalLiteralExpression(1), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DecimalLiteralExpression(0)) : new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.CastExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.GetOldExpression(countValueExpression), _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.BuildInTypeExpression.decimal, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DecimalLiteralExpression(0)), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DecimalLiteralExpression(0)))), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ConditionalExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.IncrementalFlagExpression(), (0,_FLang_FlangUtils__WEBPACK_IMPORTED_MODULE_7__.castOperandToDecimalIfNeed)(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.NoDepsExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ValueReferenceExpression(countResultValueExpression.modePath.toCurrentIteration(), countResultValueExpression.valueName))), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DecimalLiteralExpression(0)));
81180
+ const countReduceExpr = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ReduceCallExpression(iterablePath.toCurrentIteration(), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.AnonymousFunctionDeclarationExpression(_FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.BuildInTypeExpression.decimal, [new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ArgumentDeclarationExpression("result", _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.BuildInTypeExpression.decimal)], new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.MinusBinaryExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.SumBinaryExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.NullCoalesceExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ArgumentReferenceExpression("result"), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DecimalLiteralExpression(0)), countValueExpression == undefined ? new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ConditionalExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.AndBinaryExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.NotEqExpression(resultValueExpression, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.StringLiteralExpression("")), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.NotEqExpression(resultValueExpression, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.NullLiteralExpression())), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DecimalLiteralExpression(1), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DecimalLiteralExpression(0)) : new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.CastExpression(countValueExpression, _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.BuildInTypeExpression.decimal, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DecimalLiteralExpression(0))), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ConditionalExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.IncrementalFlagExpression(), countValueExpression == undefined ? new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ConditionalExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.AndBinaryExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.NotEqExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.GetOldExpression(resultValueExpression), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.StringLiteralExpression("")), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.NotEqExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.GetOldExpression(resultValueExpression), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.NullLiteralExpression())), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DecimalLiteralExpression(1), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DecimalLiteralExpression(0)) : new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.CastExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.GetOldExpression(countValueExpression), _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.BuildInTypeExpression.decimal, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DecimalLiteralExpression(0)), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DecimalLiteralExpression(0)))), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ConditionalExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.IncrementalFlagExpression(), (0,_FLang_FlangUtils__WEBPACK_IMPORTED_MODULE_7__.castOperandToDecimalIfNeed)(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.NoDepsExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ValueReferenceExpression(countResultValueExpression.modePath.toCurrentIteration(), countResultValueExpression.valueName))), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DecimalLiteralExpression(0)));
81152
81181
  addPrecalculationRule(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.SetStatement(countResultValueExpression, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.CastExpression(countReduceExpr, _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.BuildInTypeExpression.string, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.StringLiteralExpression("G29"))));
81153
81182
  resultValueExpression = currentSumExpression;
81154
81183
  countValueExpression = currenCountExpression;
@@ -81655,8 +81684,8 @@ __webpack_require__.r(__webpack_exports__);
81655
81684
  /* harmony import */ var _Common_IterableUtils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../../../Common/IterableUtils */ "./Common/IterableUtils.ts");
81656
81685
  /* harmony import */ var _Common_ModelPath_Map_AbsoluteModelPathMap__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../../../Common/ModelPath/Map/AbsoluteModelPathMap */ "./Common/ModelPath/Map/AbsoluteModelPathMap.ts");
81657
81686
  /* harmony import */ var _Common_ModelPath_EachCurrentCollision__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../../../Common/ModelPath/EachCurrentCollision */ "./Common/ModelPath/EachCurrentCollision.ts");
81658
- /* harmony import */ var _markupGenerator_getRootPath__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../markupGenerator/getRootPath */ "./Generator/src/generators/markupGenerator/getRootPath.ts");
81659
- /* harmony import */ var _DataSchema_DataSchemaUtils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../DataSchema/DataSchemaUtils */ "./Generator/src/generators/DataSchema/DataSchemaUtils.ts");
81687
+ /* harmony import */ var _DataSchema_DataSchemaUtils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../DataSchema/DataSchemaUtils */ "./Generator/src/generators/DataSchema/DataSchemaUtils.ts");
81688
+ /* harmony import */ var _FLang_FlangUtils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../FLang/FlangUtils */ "./Generator/src/generators/ServerSideFLangNormalization/FLang/FlangUtils.ts");
81660
81689
 
81661
81690
 
81662
81691
 
@@ -81749,60 +81778,66 @@ class ValidationRulesBuilder {
81749
81778
  yield rule;
81750
81779
  }
81751
81780
  const targetPaths = [..._Common_IterableUtils__WEBPACK_IMPORTED_MODULE_4__.IterUtils.distinctBy(_Common_IterableUtils__WEBPACK_IMPORTED_MODULE_4__.IterUtils.concat(context.getAllPathsWithValidations(), Object.keys(kcRules.errors).concat(Object.keys(kcRules.warnings)).map(x => (0,_Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_0__.createAbsoluteFromMask)(x, _Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_0__.PathTokens.each))), x => x.toLegacyPath())];
81752
-
81753
- // yield* this.buildErrorWarningCountRules(targetPaths, "error");
81754
- // yield* this.buildErrorWarningCountRules(targetPaths, "warning");
81781
+ yield* this.buildErrorWarningCountRules(targetPaths, "error");
81782
+ yield* this.buildErrorWarningCountRules(targetPaths, "warning");
81755
81783
  }
81756
-
81757
81784
  *splitModelPathIfErrorCountRequired(modelPath) {
81758
81785
  const tokens = modelPath.getPathPartsAsArray();
81759
81786
  for (let i = 0; i < tokens.length; i++) {
81760
81787
  const currentModelPath = (0,_Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_0__.createAbsoluteFromTokens)(tokens.slice(0, i));
81761
- if (tokens[i] === _Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_0__.PathTokens.each || this.dataDeclarationHelper.isErrorsAndWarningsCountRequired(currentModelPath)) {
81788
+ if (tokens[i] === _Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_0__.PathTokens.each || this.dataDeclarationHelper.isErrorsAndWarningsCountRequired(currentModelPath) || i == 1) {
81762
81789
  yield currentModelPath;
81763
81790
  }
81764
81791
  }
81765
81792
  }
81766
- *buildErrorWarningCountRules(allPathsWithValidations, fieldName) {
81767
- const countFieldName = `${fieldName}sCount`;
81768
- const zeroExpression = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.DecimalLiteralExpression(0);
81769
- const totalErrorCountExpressions = new _Common_ModelPath_Map_AbsoluteModelPathMap__WEBPACK_IMPORTED_MODULE_5__.AbsoluteModelPathMap(_Common_ModelPath_EachCurrentCollision__WEBPACK_IMPORTED_MODULE_6__.EachCurrentCollision.AreDifferent);
81770
- const errorCountByTarget = new _Common_ModelPath_Map_AbsoluteModelPathMap__WEBPACK_IMPORTED_MODULE_5__.AbsoluteModelPathMap(_Common_ModelPath_EachCurrentCollision__WEBPACK_IMPORTED_MODULE_6__.EachCurrentCollision.AreDifferent);
81771
- for (const path of allPathsWithValidations) {
81772
- var _IterUtils$last;
81773
- const iterationSequence = [...(0,_Common_IterableUtils__WEBPACK_IMPORTED_MODULE_4__.reverseArray)([...this.splitModelPathIfErrorCountRequired(path)])];
81774
- let resultCountExpression = this.getErrorWarningCountExpression(path.toCurrentIteration(), fieldName);
81775
- for (const iterationPath of iterationSequence) {
81776
- if (this.dataDeclarationHelper.isErrorsAndWarningsCountRequired(iterationPath) && this.dataDeclarationHelper.isNodeHasChildrenEntry(iterationPath)) {
81777
- const multipleTarget = iterationPath.joinWith(_Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_0__.PathTokens.each);
81778
- errorCountByTarget.getOrSet(multipleTarget, () => []).push(resultCountExpression);
81779
- resultCountExpression = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.CastExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ValueReferenceExpression(multipleTarget.toCurrentIteration(), countFieldName), _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.BuildInTypeExpression.decimal, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.DecimalLiteralExpression(0));
81780
- }
81781
- errorCountByTarget.getOrSet(iterationPath, () => []).push(resultCountExpression);
81782
- resultCountExpression = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.CastExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ValueReferenceExpression(iterationPath.toCurrentIteration(), countFieldName), _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.BuildInTypeExpression.decimal, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.DecimalLiteralExpression(0));
81783
- }
81784
- totalErrorCountExpressions.set((_IterUtils$last = _Common_IterableUtils__WEBPACK_IMPORTED_MODULE_4__.IterUtils.last(iterationSequence)) !== null && _IterUtils$last !== void 0 ? _IterUtils$last : path, resultCountExpression);
81785
- }
81786
- for (const entry of errorCountByTarget.entries()) {
81787
- const iterable = entry[0];
81788
- const items = [..._Common_IterableUtils__WEBPACK_IMPORTED_MODULE_4__.IterUtils.distinctBy(entry[1], x => x.convertToString())];
81789
- const firstEmptyExpression = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.NullLiteralExpression();
81790
- const allItemsSumExpression = items.reduce((x, y) => x == firstEmptyExpression ? y : new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.SumBinaryExpression(x, y), firstEmptyExpression);
81791
- const nextErrorCountPrecalculation = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ValueReferenceExpression(iterable, countFieldName);
81792
- if (_Common_IterableUtils__WEBPACK_IMPORTED_MODULE_4__.IterUtils.last(iterable.getPathParts()) === _Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_0__.PathTokens.each || !this.dataDeclarationHelper.isNodeHasChildrenEntry(iterable)) {
81793
- yield new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.SetStatement(nextErrorCountPrecalculation, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.CastExpression(allItemsSumExpression, _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.BuildInTypeExpression.string, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.StringLiteralExpression("G29")));
81794
- } else {
81795
- yield new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.SetStatement(nextErrorCountPrecalculation, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.CastExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ReduceCallExpression(iterable.toCurrentIteration(), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.AnonymousFunctionDeclarationExpression(_FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.BuildInTypeExpression.decimal, [new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ArgumentDeclarationExpression("result", _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.BuildInTypeExpression.decimal)], new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.SumBinaryExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ArgumentReferenceExpression("result"), allItemsSumExpression)), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ConditionalExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.IncrementalFlagExpression(), nextErrorCountPrecalculation, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.DecimalLiteralExpression(0))), _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.BuildInTypeExpression.string, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.StringLiteralExpression("G29")));
81796
- }
81797
- }
81798
- const allRules = Iterator.from(totalErrorCountExpressions.values()).reduce((result, expression) => result === zeroExpression ? expression : new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.SumBinaryExpression(result, expression), zeroExpression);
81799
- yield new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.SetStatement(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ValueReferenceExpression((0,_Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_0__.createAbsolute)((0,_markupGenerator_getRootPath__WEBPACK_IMPORTED_MODULE_7__.getRootPath)(this.sugarRoot)), countFieldName), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.CastExpression(allRules, _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.BuildInTypeExpression.string, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.StringLiteralExpression("G29")));
81793
+ buildErrorWarningCountReduceRule(iterable, countFieldName, getAllItemsSumExpression) {
81794
+ const nextErrorCountTarget = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ValueReferenceExpression(iterable, countFieldName);
81795
+ const aggregationReduce = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ReduceCallExpression(iterable.toCurrentIteration(), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.AnonymousFunctionDeclarationExpression(_FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.BuildInTypeExpression.decimal, [new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ArgumentDeclarationExpression("result", _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.BuildInTypeExpression.decimal)], new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.SumBinaryExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ArgumentReferenceExpression("result"), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.MinusBinaryExpression(getAllItemsSumExpression(false), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ConditionalExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.IncrementalFlagExpression(), getAllItemsSumExpression(true), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.DecimalLiteralExpression(0))))), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ConditionalExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.IncrementalFlagExpression(), (0,_FLang_FlangUtils__WEBPACK_IMPORTED_MODULE_8__.castOperandToDecimalIfNeed)(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.GetOldExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ValueReferenceExpression(iterable.toCurrentIteration(), countFieldName))), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.DecimalLiteralExpression(0)));
81796
+ return new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.SetStatement(nextErrorCountTarget, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.CastExpression(aggregationReduce, _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.BuildInTypeExpression.string, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.StringLiteralExpression("G29")));
81797
+ }
81798
+ buildErrorWarningCountSimpleSumRule(iterable, countFieldName, getAllItemsSumExpression) {
81799
+ const nextErrorCountTarget = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ValueReferenceExpression(iterable, countFieldName);
81800
+ return new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.SetStatement(nextErrorCountTarget, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.CastExpression(getAllItemsSumExpression(false), _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.BuildInTypeExpression.string, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.StringLiteralExpression("G29")));
81801
+ }
81802
+ getErrorWarningCountExpression(path, fieldName, readOldValues) {
81803
+ const valueGetExpression = readOldValues ? new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.GetOldExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ValueReferenceExpression(path, fieldName)) : new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ValueReferenceExpression(path, fieldName);
81804
+ return new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ConditionalExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.OrBinaryExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.IsEqualsBinaryExpression(valueGetExpression, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.StringLiteralExpression(`[]`)), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.IsEqualsBinaryExpression(valueGetExpression, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.NullLiteralExpression())), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.DecimalLiteralExpression(0), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.DecimalLiteralExpression(1));
81805
+ }
81806
+ getReadErrorCountValueExpression(path, countFieldName, readOldValues) {
81807
+ return new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.CastExpression(readOldValues ? new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.GetOldExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ValueReferenceExpression(path.toCurrentIteration(), countFieldName)) : new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ValueReferenceExpression(path.toCurrentIteration(), countFieldName), _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.BuildInTypeExpression.decimal, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.DecimalLiteralExpression(0));
81800
81808
  }
81801
- getErrorWarningCountExpression(path, fieldName) {
81802
- return new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ConditionalExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.OrBinaryExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.IsEqualsBinaryExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ValueReferenceExpression(path, fieldName), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.StringLiteralExpression(`[]`)), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.IsEqualsBinaryExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ValueReferenceExpression(path, fieldName), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.NullLiteralExpression())), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.DecimalLiteralExpression(0), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.DecimalLiteralExpression(1));
81809
+ buildChainOfErrorCountRules(path, countFieldName, fieldName) {
81810
+ const reduceResult = Iterator.from((0,_Common_IterableUtils__WEBPACK_IMPORTED_MODULE_4__.reverseArray)([...this.splitModelPathIfErrorCountRequired(path)])).flatMap(iterationPath => this.dataDeclarationHelper.isNodeHasChildrenEntry(iterationPath) ? [iterationPath.joinWith(_Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_0__.PathTokens.each), iterationPath] : [iterationPath]).reduce((result, iterationPath) => {
81811
+ const nextResultCountExpression = oldValues => this.getReadErrorCountValueExpression(iterationPath, countFieldName, oldValues);
81812
+ const info = {
81813
+ target: iterationPath,
81814
+ getExpressionFunc: result.resultCountExpression
81815
+ };
81816
+ return {
81817
+ resultCountExpression: nextResultCountExpression,
81818
+ items: result.items.concat(info)
81819
+ };
81820
+ }, {
81821
+ resultCountExpression: oldValues => this.getErrorWarningCountExpression(path.toCurrentIteration(), fieldName, oldValues),
81822
+ items: []
81823
+ });
81824
+ return reduceResult.items;
81825
+ }
81826
+ buildErrorWarningCountRules(allPathsWithValidations, fieldName) {
81827
+ const countFieldName = `${fieldName}sCount`;
81828
+ const errorCountByTarget = Iterator.from(allPathsWithValidations).flatMap(path => this.buildChainOfErrorCountRules(path, countFieldName, fieldName)).reduce((result, current) => {
81829
+ result.getOrSet(current.target, () => []).push(current.getExpressionFunc);
81830
+ return result;
81831
+ }, new _Common_ModelPath_Map_AbsoluteModelPathMap__WEBPACK_IMPORTED_MODULE_5__.AbsoluteModelPathMap(_Common_ModelPath_EachCurrentCollision__WEBPACK_IMPORTED_MODULE_6__.EachCurrentCollision.AreDifferent));
81832
+ const rules = Iterator.from(errorCountByTarget.entries()).map(([iterable, getExpressionFunctions]) => {
81833
+ const getAllItemsSumExpression = readOldValues => Iterator.from(_Common_IterableUtils__WEBPACK_IMPORTED_MODULE_4__.IterUtils.distinctBy(getExpressionFunctions.map(x => x(readOldValues)), x => x.convertToString())).reduce((result, currentExpr) => result instanceof _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.NullLiteralExpression ? currentExpr : new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.SumBinaryExpression(result, currentExpr), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.NullLiteralExpression());
81834
+ const isTargetRequiredReduce = _Common_IterableUtils__WEBPACK_IMPORTED_MODULE_4__.IterUtils.last(iterable.getPathParts()) !== _Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_0__.PathTokens.each && this.dataDeclarationHelper.isNodeHasChildrenEntry(iterable);
81835
+ return isTargetRequiredReduce ? this.buildErrorWarningCountReduceRule(iterable, countFieldName, getAllItemsSumExpression) : this.buildErrorWarningCountSimpleSumRule(iterable, countFieldName, getAllItemsSumExpression);
81836
+ });
81837
+ return rules;
81803
81838
  }
81804
81839
  adjustPathMultiplicity(path) {
81805
- return (0,_DataSchema_DataSchemaUtils__WEBPACK_IMPORTED_MODULE_8__.adjustPathMultiplicityComplex)(path, this.formSchemaRng, this.dataDeclarationHelper);
81840
+ return (0,_DataSchema_DataSchemaUtils__WEBPACK_IMPORTED_MODULE_7__.adjustPathMultiplicityComplex)(path, this.formSchemaRng, this.dataDeclarationHelper);
81806
81841
  }
81807
81842
  }
81808
81843
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kontur.candy/generator",
3
- "version": "5.2.0-server-side-calculations.0",
3
+ "version": "5.2.0-server-side-calculations.2",
4
4
  "description": "Candy forms generator",
5
5
  "author": "SKBKontur Candy Team",
6
6
  "private": false,