@kontur.candy/generator 5.2.0-server-side-calculations.1 → 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 +52 -16
  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
  }
@@ -81777,22 +81806,29 @@ class ValidationRulesBuilder {
81777
81806
  getReadErrorCountValueExpression(path, countFieldName, readOldValues) {
81778
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));
81779
81808
  }
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
+ }
81780
81826
  buildErrorWarningCountRules(allPathsWithValidations, fieldName) {
81781
81827
  const countFieldName = `${fieldName}sCount`;
81782
- const errorCountByTarget = new _Common_ModelPath_Map_AbsoluteModelPathMap__WEBPACK_IMPORTED_MODULE_5__.AbsoluteModelPathMap(_Common_ModelPath_EachCurrentCollision__WEBPACK_IMPORTED_MODULE_6__.EachCurrentCollision.AreDifferent);
81783
- for (const path of allPathsWithValidations) {
81784
- const iterationSequence = [...(0,_Common_IterableUtils__WEBPACK_IMPORTED_MODULE_4__.reverseArray)([...this.splitModelPathIfErrorCountRequired(path)])];
81785
- let resultCountExpression = oldValues => this.getErrorWarningCountExpression(path.toCurrentIteration(), fieldName, oldValues);
81786
- for (const iterationPath of iterationSequence) {
81787
- if (this.dataDeclarationHelper.isNodeHasChildrenEntry(iterationPath)) {
81788
- const multipleTarget = iterationPath.joinWith(_Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_0__.PathTokens.each);
81789
- errorCountByTarget.getOrSet(multipleTarget, () => []).push(resultCountExpression);
81790
- resultCountExpression = oldValues => this.getReadErrorCountValueExpression(multipleTarget, countFieldName, oldValues);
81791
- }
81792
- errorCountByTarget.getOrSet(iterationPath, () => []).push(resultCountExpression);
81793
- resultCountExpression = oldValues => this.getReadErrorCountValueExpression(iterationPath, countFieldName, oldValues);
81794
- }
81795
- }
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));
81796
81832
  const rules = Iterator.from(errorCountByTarget.entries()).map(([iterable, getExpressionFunctions]) => {
81797
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());
81798
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kontur.candy/generator",
3
- "version": "5.2.0-server-side-calculations.1",
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,