@kontur.candy/generator 5.21.0-ss-metrics.0 → 5.22.0-descriptionvalidations.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.
Files changed (2) hide show
  1. package/dist/index.js +115 -17
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -60272,11 +60272,17 @@ const getRngSchemaFilename = (formSchemasDirPath, gfv) => {
60272
60272
  if (!Boolean(Number(gfv))) {
60273
60273
  return ".rng.xml";
60274
60274
  }
60275
- 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;
60276
- if (maxSubversion === undefined || !(0,fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)(path__WEBPACK_IMPORTED_MODULE_1___default().join(formSchemasDirPath, `${gfv}.${maxSubversion}.rng.xml`))) {
60275
+ try {
60276
+ 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;
60277
+ if (maxSubversion === undefined || !(0,fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)(path__WEBPACK_IMPORTED_MODULE_1___default().join(formSchemasDirPath, `${gfv}.${maxSubversion}.rng.xml`))) {
60278
+ return ".rng.xml";
60279
+ }
60280
+ return `.${maxSubversion}.rng.xml`;
60281
+ } catch (e) {
60282
+ // eslint-disable-next-line no-console
60283
+ console.log(`Folder not exist. ${formSchemasDirPath}`);
60277
60284
  return ".rng.xml";
60278
60285
  }
60279
- return `.${maxSubversion}.rng.xml`;
60280
60286
  };
60281
60287
 
60282
60288
  /***/ }),
@@ -77217,6 +77223,51 @@ const formulaExpressions = [FormulaSumExpression, FormulaArgumentExpression, For
77217
77223
 
77218
77224
  /***/ }),
77219
77225
 
77226
+ /***/ "./Generator/src/generators/AutoCalculationsGenerator/AutoCalculationsFromFormulas/KCXmlContract/FormulaParsingDescription.ts":
77227
+ /*!************************************************************************************************************************************!*\
77228
+ !*** ./Generator/src/generators/AutoCalculationsGenerator/AutoCalculationsFromFormulas/KCXmlContract/FormulaParsingDescription.ts ***!
77229
+ \************************************************************************************************************************************/
77230
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
77231
+
77232
+ "use strict";
77233
+ __webpack_require__.r(__webpack_exports__);
77234
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
77235
+ /* harmony export */ "splitConditionDescriptionToParts": () => (/* binding */ splitConditionDescriptionToParts)
77236
+ /* harmony export */ });
77237
+ /* harmony import */ var _Formula__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Formula */ "./Generator/src/generators/AutoCalculationsGenerator/AutoCalculationsFromFormulas/KCXmlContract/Formula.ts");
77238
+
77239
+ function splitConditionDescriptionToParts(description) {
77240
+ const reg = new RegExp(/\('|'\)/g);
77241
+ const words = description.split(reg);
77242
+ const splitWords = words.map(item => {
77243
+ if (item.includes("{")) {
77244
+ const word = item.substring(1, item.length - 1);
77245
+ const argument = new _Formula__WEBPACK_IMPORTED_MODULE_0__.FormulaArgumentExpression();
77246
+ argument.select = word;
77247
+ argument.type = "string";
77248
+ return argument;
77249
+ } else {
77250
+ return item;
77251
+ }
77252
+ });
77253
+ const wordsInFormulas = splitWords.map(part => {
77254
+ if (part instanceof _Formula__WEBPACK_IMPORTED_MODULE_0__.FormulaArgumentExpression) {
77255
+ const formulaPart = new _Formula__WEBPACK_IMPORTED_MODULE_0__.FormulaArgumentExpression();
77256
+ formulaPart.select = part.select;
77257
+ formulaPart.type = "string";
77258
+ return formulaPart;
77259
+ } else {
77260
+ const stringPart = new _Formula__WEBPACK_IMPORTED_MODULE_0__.FormulaConstExpression();
77261
+ stringPart.type = "string";
77262
+ stringPart.value = part;
77263
+ return stringPart;
77264
+ }
77265
+ });
77266
+ return wordsInFormulas;
77267
+ }
77268
+
77269
+ /***/ }),
77270
+
77220
77271
  /***/ "./Generator/src/generators/AutoCalculationsGenerator/AutoCalculationsFromFormulas/KCXmlContract/FormulaReader.ts":
77221
77272
  /*!************************************************************************************************************************!*\
77222
77273
  !*** ./Generator/src/generators/AutoCalculationsGenerator/AutoCalculationsFromFormulas/KCXmlContract/FormulaReader.ts ***!
@@ -79470,15 +79521,19 @@ __webpack_require__.r(__webpack_exports__);
79470
79521
  /* harmony export */ "KCXmlValidationGenerator": () => (/* binding */ KCXmlValidationGenerator)
79471
79522
  /* harmony export */ });
79472
79523
  /* harmony import */ var _Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../../Common/ModelPath/ModelPath */ "./Common/ModelPath/ModelPath.ts");
79473
- /* harmony import */ var _KCXmlGenerator_KCXmlGeneratorBase__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../KCXmlGenerator/KCXmlGeneratorBase */ "./Generator/src/generators/KCXmlGenerator/KCXmlGeneratorBase.ts");
79474
- /* harmony import */ var _Common_IterableUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../../Common/IterableUtils */ "./Common/IterableUtils.ts");
79524
+ /* harmony import */ var _AutoCalculationsGenerator_AutoCalculationsFromFormulas_KCXmlContract_Formula__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../AutoCalculationsGenerator/AutoCalculationsFromFormulas/KCXmlContract/Formula */ "./Generator/src/generators/AutoCalculationsGenerator/AutoCalculationsFromFormulas/KCXmlContract/Formula.ts");
79525
+ /* harmony import */ var _KCXmlGenerator_KCXmlGeneratorBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../KCXmlGenerator/KCXmlGeneratorBase */ "./Generator/src/generators/KCXmlGenerator/KCXmlGeneratorBase.ts");
79526
+ /* harmony import */ var _Common_IterableUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../../Common/IterableUtils */ "./Common/IterableUtils.ts");
79527
+ /* harmony import */ var _AutoCalculationsGenerator_AutoCalculationsFromFormulas_KCXmlContract_FormulaParsingDescription__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../AutoCalculationsGenerator/AutoCalculationsFromFormulas/KCXmlContract/FormulaParsingDescription */ "./Generator/src/generators/AutoCalculationsGenerator/AutoCalculationsFromFormulas/KCXmlContract/FormulaParsingDescription.ts");
79528
+
79529
+
79475
79530
 
79476
79531
 
79477
79532
 
79478
79533
  const emptyResult = `
79479
79534
  export default function kcXmlValidationConfigurator ({ form, ModelPath, ValidationFunction, KCCondition }) {}
79480
79535
  `;
79481
- class KCXmlValidationGenerator extends _KCXmlGenerator_KCXmlGeneratorBase__WEBPACK_IMPORTED_MODULE_1__.KCXmlGeneratorBase {
79536
+ class KCXmlValidationGenerator extends _KCXmlGenerator_KCXmlGeneratorBase__WEBPACK_IMPORTED_MODULE_2__.KCXmlGeneratorBase {
79482
79537
  generate(kcXmlConditions) {
79483
79538
  const compiledConditions = Iterator.from(kcXmlConditions).map(condition => this.compileCondition(condition)).toArray();
79484
79539
  if (compiledConditions.length === 0) {
@@ -79497,15 +79552,23 @@ class KCXmlValidationGenerator extends _KCXmlGenerator_KCXmlGeneratorBase__WEBPA
79497
79552
  const target = this.schema.adjustPathMultiplicity(prefix.joinWith((0,_Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_0__.createFromMask)(this.removeMultiplicity(this.removeAttributePrefix(condition.target)), false, _Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_0__.PathTokens.each)).normalize());
79498
79553
  const deps = [];
79499
79554
  const compiledExpression = this.compileExpression(prefix, target, condition.expression, deps);
79555
+ const compiledDescriptionParts = (0,_AutoCalculationsGenerator_AutoCalculationsFromFormulas_KCXmlContract_FormulaParsingDescription__WEBPACK_IMPORTED_MODULE_4__.splitConditionDescriptionToParts)((_condition$descriptio = condition.description) !== null && _condition$descriptio !== void 0 ? _condition$descriptio : "Error Message");
79556
+ let concatDescription;
79557
+ if (compiledDescriptionParts.length > 1) {
79558
+ concatDescription = new _AutoCalculationsGenerator_AutoCalculationsFromFormulas_KCXmlContract_Formula__WEBPACK_IMPORTED_MODULE_1__.FormulaConcatExpression();
79559
+ concatDescription.arguments = compiledDescriptionParts;
79560
+ } else {
79561
+ concatDescription = compiledDescriptionParts[0];
79562
+ }
79563
+ const compiledDescription = this.compileExpression(prefix, target, concatDescription, deps);
79500
79564
  const compiledTarget = this.modelPathInstance(target);
79501
- const dependencyModelPaths = Array.from(_Common_IterableUtils__WEBPACK_IMPORTED_MODULE_2__.IterUtils.distinctBy(deps.map(x => ({
79565
+ const dependencyModelPaths = Array.from(_Common_IterableUtils__WEBPACK_IMPORTED_MODULE_3__.IterUtils.distinctBy(deps.map(x => ({
79502
79566
  path: x.asDependencyModelPath(),
79503
- isIgnoreForChecks: (0,_KCXmlGenerator_KCXmlGeneratorBase__WEBPACK_IMPORTED_MODULE_1__.isDependencyWithoutChecks)(x),
79567
+ isIgnoreForChecks: (0,_KCXmlGenerator_KCXmlGeneratorBase__WEBPACK_IMPORTED_MODULE_2__.isDependencyWithoutChecks)(x),
79504
79568
  pathString: (0,_Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_0__.createAbsoluteFromTokens)(x.asDependencyModelPath().getPathPartsAsArray().map(token => token === _Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_0__.PathTokens.current ? "!" : token)).toLegacyPath()
79505
79569
  })).filter(x => !x.path.isEquals(target)), x => x.pathString));
79506
79570
  const compiledDeps = dependencyModelPaths.map(x => x.path).map(x => this.modelPathInstance(x)).join(", ");
79507
- const compiledDescription = (_condition$descriptio = condition.description) !== null && _condition$descriptio !== void 0 ? _condition$descriptio : "Error Message";
79508
- const compiledDelegate = `context => KCCondition.execute(context, expression => ${compiledExpression}, ` + `() => "${compiledDescription}", "${(_condition$errorLevel = condition.errorLevel) !== null && _condition$errorLevel !== void 0 ? _condition$errorLevel : "Error"}")`;
79571
+ const compiledDelegate = `context => KCCondition.execute(context, expression => ${compiledExpression}, ` + `(expression) => ${compiledDescription}, "${(_condition$errorLevel = condition.errorLevel) !== null && _condition$errorLevel !== void 0 ? _condition$errorLevel : "Error"}")`;
79509
79572
  return `new ValidationFunction(${compiledTarget}, [${compiledDeps}], ${compiledDelegate})`;
79510
79573
  }
79511
79574
  }
@@ -80891,6 +80954,7 @@ __webpack_require__.r(__webpack_exports__);
80891
80954
  /* harmony export */ "ReduceCallExpression": () => (/* binding */ ReduceCallExpression),
80892
80955
  /* harmony export */ "ReduceMultipleCallExpression": () => (/* binding */ ReduceMultipleCallExpression),
80893
80956
  /* harmony export */ "CastExpression": () => (/* binding */ CastExpression),
80957
+ /* harmony export */ "JoinExpression": () => (/* binding */ JoinExpression),
80894
80958
  /* harmony export */ "ConstExpression": () => (/* binding */ ConstExpression),
80895
80959
  /* harmony export */ "StringLiteralExpression": () => (/* binding */ StringLiteralExpression),
80896
80960
  /* harmony export */ "DecimalLiteralExpression": () => (/* binding */ DecimalLiteralExpression),
@@ -81435,6 +81499,25 @@ class CastExpression extends FLangExpression {
81435
81499
  return this.targetType;
81436
81500
  }
81437
81501
  }
81502
+ class JoinExpression extends FLangExpression {
81503
+ constructor(expression, separator) {
81504
+ super();
81505
+ this.expression = void 0;
81506
+ this.separator = void 0;
81507
+ this.expression = expression;
81508
+ this.separator = separator;
81509
+ }
81510
+ getType() {
81511
+ return BuildInTypeExpression.string;
81512
+ }
81513
+ *getChildNodes() {
81514
+ yield this.expression;
81515
+ yield this.separator;
81516
+ }
81517
+ convertToString() {
81518
+ return `join(${this.expression.convertToString()}, ${this.separator.convertToString()})`;
81519
+ }
81520
+ }
81438
81521
  class ConstExpression extends FLangExpression {
81439
81522
  getChildNodes() {
81440
81523
  return [];
@@ -83395,8 +83478,10 @@ __webpack_require__.r(__webpack_exports__);
83395
83478
  /* harmony import */ var _Common_ModelPath_EachCurrentCollision__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../../../Common/ModelPath/EachCurrentCollision */ "./Common/ModelPath/EachCurrentCollision.ts");
83396
83479
  /* harmony import */ var _DataSchema_DataSchemaUtils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../DataSchema/DataSchemaUtils */ "./Generator/src/generators/DataSchema/DataSchemaUtils.ts");
83397
83480
  /* harmony import */ var _FLang_FlangUtils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../FLang/FlangUtils */ "./Generator/src/generators/ServerSideFLangNormalization/FLang/FlangUtils.ts");
83398
- /* harmony import */ var _NodeTypeInfoHelper__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../NodeTypeInfoHelper */ "./Generator/src/generators/ServerSideFLangNormalization/NodeTypeInfoHelper.ts");
83399
- /* harmony import */ var _Common_ModelPath_AbsoluteModelFieldPath__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../../../Common/ModelPath/AbsoluteModelFieldPath */ "./Common/ModelPath/AbsoluteModelFieldPath.ts");
83481
+ /* harmony import */ var _AutoCalculationsGenerator_AutoCalculationsFromFormulas_KCXmlContract_FormulaParsingDescription__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../AutoCalculationsGenerator/AutoCalculationsFromFormulas/KCXmlContract/FormulaParsingDescription */ "./Generator/src/generators/AutoCalculationsGenerator/AutoCalculationsFromFormulas/KCXmlContract/FormulaParsingDescription.ts");
83482
+ /* harmony import */ var _NodeTypeInfoHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../NodeTypeInfoHelper */ "./Generator/src/generators/ServerSideFLangNormalization/NodeTypeInfoHelper.ts");
83483
+ /* harmony import */ var _Common_ModelPath_AbsoluteModelFieldPath__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../../../Common/ModelPath/AbsoluteModelFieldPath */ "./Common/ModelPath/AbsoluteModelFieldPath.ts");
83484
+
83400
83485
 
83401
83486
 
83402
83487
 
@@ -83435,8 +83520,8 @@ class ValidationRulesBuilder {
83435
83520
  const precalculationRules = [];
83436
83521
  return {
83437
83522
  target: fullTarget,
83438
- checkExpression: this.formulaExprConverter.compileExpressionToFlangExpression(condition.expression, prefix, new _Common_ModelPath_AbsoluteModelFieldPath__WEBPACK_IMPORTED_MODULE_10__.AbsoluteModelFieldPath(fullTarget, condition.errorLevel === "Error" ? "error" : "warning"), x => precalculationRules.push(x)),
83439
- message: condition.description,
83523
+ checkExpression: this.formulaExprConverter.compileExpressionToFlangExpression(condition.expression, prefix, new _Common_ModelPath_AbsoluteModelFieldPath__WEBPACK_IMPORTED_MODULE_11__.AbsoluteModelFieldPath(fullTarget, condition.errorLevel === "Error" ? "error" : "warning"), x => precalculationRules.push(x)),
83524
+ message: (0,_AutoCalculationsGenerator_AutoCalculationsFromFormulas_KCXmlContract_FormulaParsingDescription__WEBPACK_IMPORTED_MODULE_9__.splitConditionDescriptionToParts)(condition.description).map(item => this.formulaExprConverter.compileExpressionToFlangExpression(item, prefix, new _Common_ModelPath_AbsoluteModelFieldPath__WEBPACK_IMPORTED_MODULE_11__.AbsoluteModelFieldPath(fullTarget, condition.errorLevel === "Error" ? "error" : "warning"), x => precalculationRules.push(x))),
83440
83525
  errorLevel: condition.errorLevel,
83441
83526
  precalculationRules: precalculationRules
83442
83527
  };
@@ -83447,8 +83532,8 @@ class ValidationRulesBuilder {
83447
83532
  const path = current.target.toLegacyPath();
83448
83533
  const targetCtx = current.errorLevel === "Warning" ? ctx.warnings : ctx.errors;
83449
83534
  const currentExpression = (_targetCtx$path = targetCtx[path]) !== null && _targetCtx$path !== void 0 ? _targetCtx$path : new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.NullLiteralExpression();
83450
- const condition = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ConditionalExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.NegateUnaryExpression(current.checkExpression), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.StringLiteralExpression("[" + JSON.stringify(current.message) + "]"), currentExpression);
83451
- targetCtx[path] = condition;
83535
+ const validationRule = this.generateValidationText(currentExpression, current);
83536
+ targetCtx[path] = validationRule;
83452
83537
  return ctx;
83453
83538
  }, {
83454
83539
  errors: {},
@@ -83456,9 +83541,22 @@ class ValidationRulesBuilder {
83456
83541
  });
83457
83542
  return allRulesCheck;
83458
83543
  }
83544
+ generateValidationText(current, next) {
83545
+ const validationText = next.message.reduce((acc, item) => {
83546
+ if (item instanceof _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.StringLiteralExpression) {
83547
+ return new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ConcatStringsExpression(acc, (0,_FLang_FlangUtils__WEBPACK_IMPORTED_MODULE_8__.castOperandToStringIfNeed)(item));
83548
+ } else if (item instanceof _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ValueReferenceExpression) {
83549
+ return new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ConcatStringsExpression(acc, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.JoinExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.DeserializeEnumerationExpression([item], new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.BoolLiteralExpression(true)), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.StringLiteralExpression(", ")));
83550
+ } else {
83551
+ throw new Error(`Invalid WithDescription ${item.toString()}`);
83552
+ }
83553
+ }, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.StringLiteralExpression(""));
83554
+ const condition = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ConditionalExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.NegateUnaryExpression(next.checkExpression), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ConcatStringsExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ConcatStringsExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.StringLiteralExpression(`["`), validationText), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.StringLiteralExpression(`"]`)), current);
83555
+ return condition;
83556
+ }
83459
83557
  *buildSugarValidationRules() {
83460
83558
  const converter = new _markupGenerator_ElementProcessors_FormParts_Form_FormConverter__WEBPACK_IMPORTED_MODULE_2__.FormConverter(this.sugarRoot);
83461
- const context = new _FLangValidationBuildContext__WEBPACK_IMPORTED_MODULE_3__.FLangValidationBuildContext(this.formSchemaRng, this.formulaExprConverter, new _NodeTypeInfoHelper__WEBPACK_IMPORTED_MODULE_9__.NodeTypeInfoHelper(this.formSchemaRng, this.typesRegistry, this.useSchemaValidations));
83559
+ const context = new _FLangValidationBuildContext__WEBPACK_IMPORTED_MODULE_3__.FLangValidationBuildContext(this.formSchemaRng, this.formulaExprConverter, new _NodeTypeInfoHelper__WEBPACK_IMPORTED_MODULE_10__.NodeTypeInfoHelper(this.formSchemaRng, this.typesRegistry, this.useSchemaValidations));
83462
83560
  const sugarRules = Iterator.from(converter.buildFLangValidations(context, this.formSchemaRng)).reduce((ctx, current) => {
83463
83561
  const statement = current.statement;
83464
83562
  if (!(statement instanceof _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.SetStatement)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kontur.candy/generator",
3
- "version": "5.21.0-ss-metrics.0",
3
+ "version": "5.22.0-descriptionvalidations.0",
4
4
  "description": "Candy forms generator",
5
5
  "author": "SKBKontur Candy Team",
6
6
  "private": false,