@kontur.candy/generator 5.14.0-rsvfunctions.2 → 5.14.0-rsvfunctions.4

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 +43 -31
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -59560,6 +59560,10 @@ class ModelPathImpl {
59560
59560
  const lastItem = _IterableUtils__WEBPACK_IMPORTED_MODULE_0__.IterUtils.last(this.tokens);
59561
59561
  return lastItem == PathTokens.each;
59562
59562
  }
59563
+ isEndsWithCurrentIteration() {
59564
+ const lastItem = _IterableUtils__WEBPACK_IMPORTED_MODULE_0__.IterUtils.last(this.tokens);
59565
+ return lastItem == PathTokens.current;
59566
+ }
59563
59567
  isAbsolute() {
59564
59568
  return this.absolute;
59565
59569
  }
@@ -79278,7 +79282,10 @@ class KCXmlGeneratorBase {
79278
79282
  const compiledItems = expression.items.expressions.map(item => this.compileExpression(prefix, targetFullPath, item, deps)).join(",");
79279
79283
  return gcf(x => x.oneOf, compiledArgument, `[${compiledItems}]`);
79280
79284
  }
79281
-
79285
+ if (expression instanceof _AutoCalculationsGenerator_AutoCalculationsFromFormulas_KCXmlContract_Formula__WEBPACK_IMPORTED_MODULE_1__.FormulaArrayExpression) {
79286
+ const itemsText = expression.items.map(x => this.compileExpression(prefix, targetFullPath, x, deps)).join(", ");
79287
+ return `JSON.stringify([${itemsText}])`;
79288
+ }
79282
79289
  // -- не работает в рантайм калькуляторе
79283
79290
  if (expression instanceof _AutoCalculationsGenerator_AutoCalculationsFromFormulas_KCXmlContract_Formula__WEBPACK_IMPORTED_MODULE_1__.FormulaGetPicklistValuesExpression) {
79284
79291
  return "null";
@@ -79289,10 +79296,6 @@ class KCXmlGeneratorBase {
79289
79296
  if (expression instanceof _AutoCalculationsGenerator_AutoCalculationsFromFormulas_KCXmlContract_Formula__WEBPACK_IMPORTED_MODULE_1__.FormulaHashSetExpression) {
79290
79297
  return "null";
79291
79298
  }
79292
- if (expression instanceof _AutoCalculationsGenerator_AutoCalculationsFromFormulas_KCXmlContract_Formula__WEBPACK_IMPORTED_MODULE_1__.FormulaArrayExpression) {
79293
- const itemsText = expression.items.map(x => this.compileExpression(prefix, targetFullPath, x, deps)).join(", ");
79294
- return `JSON.stringify([${itemsText}])`;
79295
- }
79296
79299
  if (expression instanceof _AutoCalculationsGenerator_AutoCalculationsFromFormulas_KCXmlContract_Formula__WEBPACK_IMPORTED_MODULE_1__.FormulaNoDepsNode) {
79297
79300
  return "null";
79298
79301
  }
@@ -81838,22 +81841,25 @@ class SerializeEnumerationExpression extends FLangExpression {
81838
81841
  }
81839
81842
  }
81840
81843
  class DeserializeEnumerationExpression extends FLangExpression {
81841
- constructor(expression, convertToStringFlag) {
81844
+ constructor(items, convertToStringFlag) {
81842
81845
  super();
81843
- this.expression = void 0;
81846
+ this.items = void 0;
81844
81847
  this.autoConvertToArray = void 0;
81845
- this.expression = expression;
81848
+ this.items = items;
81846
81849
  this.autoConvertToArray = convertToStringFlag;
81847
81850
  }
81848
81851
  getType() {
81849
81852
  return BuildInTypeExpression.string;
81850
81853
  }
81851
81854
  *getChildNodes() {
81852
- yield this.expression;
81855
+ for (const item of this.items) {
81856
+ yield item;
81857
+ }
81853
81858
  yield this.autoConvertToArray;
81854
81859
  }
81855
81860
  convertToString() {
81856
- return `deserializeEnumeration(${this.expression.convertToString()}, ${this.autoConvertToArray.convertToString()})`;
81861
+ const items = this.items.map(x => x.convertToString()).join(", ");
81862
+ return `deserializeEnumeration(${items}, ${this.autoConvertToArray.convertToString()})`;
81857
81863
  }
81858
81864
  }
81859
81865
  class ArrayExpression extends FLangExpression {
@@ -82534,12 +82540,7 @@ class FormulaExpressionToFlangExpressionConverter {
82534
82540
  return new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.IsValidMirCardNumberExpression((0,_FLang_FlangUtils__WEBPACK_IMPORTED_MODULE_7__.castOperandToStringIfNeed)(arg));
82535
82541
  }
82536
82542
  if (expression instanceof _AutoCalculationsGenerator_AutoCalculationsFromFormulas_KCXmlContract_Formula__WEBPACK_IMPORTED_MODULE_0__.FormulaArrayExpression) {
82537
- const items = expression.items.map(arg => {
82538
- if (arg instanceof _AutoCalculationsGenerator_AutoCalculationsFromFormulas_KCXmlContract_Formula__WEBPACK_IMPORTED_MODULE_0__.FormulaArgumentExpression) {
82539
- return this.compiledArgumentExpression(prefix, target, arg.select, "string", addPrecalculationRule);
82540
- }
82541
- return this.compileExpressionToFlangExpressionInternal(arg, prefix, target, addPrecalculationRule);
82542
- });
82543
+ const items = expression.items.map(arg => this.compileEnumerationItem(arg, prefix, target, addPrecalculationRule));
82543
82544
  return new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ArrayExpression(items);
82544
82545
  }
82545
82546
  if (expression instanceof _AutoCalculationsGenerator_AutoCalculationsFromFormulas_KCXmlContract_Formula__WEBPACK_IMPORTED_MODULE_0__.FormulaFirstOrDefaultExpression) {
@@ -82610,35 +82611,46 @@ class FormulaExpressionToFlangExpressionConverter {
82610
82611
  const matchPaths = (0,_Common_ModelPath_PathSplitHelper__WEBPACK_IMPORTED_MODULE_5__.getMatchedAndDifferentModelPaths)(target.path, sourceKeyPath);
82611
82612
  const sourceKeyParts = sourceKeyPath.getPathPartsAsArray();
82612
82613
  const firstPart = matchPaths.matchedPath.toCurrentIteration();
82613
- const firstPartLength = _Common_IterableUtils__WEBPACK_IMPORTED_MODULE_3__.IterUtils.count(firstPart.getPathParts());
82614
- const secondPartParts = (0,_Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_1__.createRelativeFromTokens)(sourceKeyParts.slice(firstPartLength)).getPathPartsAsArray();
82615
- const lastStarIndexSecondPart = secondPartParts.lastIndexOf(_Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_1__.PathTokens.each);
82616
- const secondPartFinalParts = secondPartParts.slice(0, lastStarIndexSecondPart);
82617
- const finalIterPath = (0,_Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_1__.createAbsoluteFromTokens)([...firstPart.getPathParts(), ...secondPartFinalParts]).trimLastStarIfLastToken();
82618
- const keys = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DeserializeEnumerationExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ValueReferenceExpression(sourceKeyPath.toCurrentIteration(), "value"), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.BoolLiteralExpression(true));
82614
+ let finalIterPath;
82615
+ if (firstPart.isEndsWithCurrentIteration()) {
82616
+ //Когда путь до итерируемых ключей начинается не с множественности
82617
+ const firstPartLength = _Common_IterableUtils__WEBPACK_IMPORTED_MODULE_3__.IterUtils.count(firstPart.getPathParts()) - 1;
82618
+ finalIterPath = (0,_Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_1__.createAbsoluteFromTokens)(sourceKeyParts.slice(0, firstPartLength));
82619
+ } else {
82620
+ const firstPartLength = _Common_IterableUtils__WEBPACK_IMPORTED_MODULE_3__.IterUtils.count(firstPart.getPathParts());
82621
+ const secondPartParts = (0,_Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_1__.createRelativeFromTokens)(sourceKeyParts.slice(firstPartLength)).getPathPartsAsArray();
82622
+ const lastStarIndexSecondPart = secondPartParts.lastIndexOf(_Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_1__.PathTokens.each);
82623
+ const secondPartFinalParts = secondPartParts.slice(0, lastStarIndexSecondPart);
82624
+ finalIterPath = (0,_Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_1__.createAbsoluteFromTokens)([...firstPart.getPathParts(), ...secondPartFinalParts]).trimLastStarIfLastToken();
82625
+ }
82626
+ if (!finalIterPath) {
82627
+ throw new Error("Error occurred while trying parse path for reduce: " + firstPart.toLegacyPath());
82628
+ }
82629
+ const keys = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DeserializeEnumerationExpression([new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ValueReferenceExpression(sourceKeyPath.toCurrentIteration(), "value")], new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.BoolLiteralExpression(true));
82619
82630
  const reduceExpression = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ReduceCallExpression(finalIterPath, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.AnonymousFunctionDeclarationExpression(_FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.BuildInTypeExpression.dict, [new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ArgumentDeclarationExpression("result", _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.BuildInTypeExpression.dict)], new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.AddSumExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ArgumentReferenceExpression("result"), keys, (0,_FLang_FlangUtils__WEBPACK_IMPORTED_MODULE_7__.castOperandToDecimalIfNeed)(sourceValueExpression))), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DictLiteralExpression());
82620
82631
  if (reduceExpression == undefined) {
82621
82632
  throw new _Common_Errors__WEBPACK_IMPORTED_MODULE_2__.NotSupportedError("Target and source must be in different collections! " + "\n" + `Target: ${target}` + "\n" + `SourceKey: ${sourceKeyPath}`);
82622
82633
  }
82623
- if (targetKeys instanceof _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ArrayExpression) {
82624
- const finalValueExpression = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.GetExpression(reduceExpression, targetKeys !== null && targetKeys !== void 0 ? targetKeys : (0,_Common_TypingUtils__WEBPACK_IMPORTED_MODULE_6__.reject)());
82625
- return finalValueExpression;
82626
- } else {
82627
- throw new _Common_Errors__WEBPACK_IMPORTED_MODULE_2__.NotSupportedError("Server normalization does not support non array first argument in groupSum operator");
82634
+ const deserializedKeys = targetKeys.items[0] instanceof _AutoCalculationsGenerator_AutoCalculationsFromFormulas_KCXmlContract_Formula__WEBPACK_IMPORTED_MODULE_0__.FormulaGetPicklistValuesExpression ? this.compileExpressionToFlangExpressionInternal(targetKeys.items[0], prefix, target, addPrecalculationRule) : new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DeserializeEnumerationExpression(targetKeys.items.map(i => this.compileEnumerationItem(i, prefix, target, addPrecalculationRule)), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.BoolLiteralExpression(true));
82635
+ const finalValueExpression = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.GetExpression(reduceExpression, deserializedKeys !== null && deserializedKeys !== void 0 ? deserializedKeys : (0,_Common_TypingUtils__WEBPACK_IMPORTED_MODULE_6__.reject)());
82636
+ return finalValueExpression;
82637
+ }
82638
+ compileEnumerationItem(expression, prefix, target, addPrecalculationRule) {
82639
+ if (expression instanceof _AutoCalculationsGenerator_AutoCalculationsFromFormulas_KCXmlContract_Formula__WEBPACK_IMPORTED_MODULE_0__.FormulaArgumentExpression) {
82640
+ return this.compiledArgumentExpression(prefix, target, expression.select, "string", addPrecalculationRule);
82628
82641
  }
82642
+ return this.compileExpressionToFlangExpressionInternal(expression, prefix, target, addPrecalculationRule);
82629
82643
  }
82630
82644
  compileGroupSumExpression(prefix, target, expression, addPrecalculationRule) {
82631
- const targetKeys = this.compileExpressionToFlangExpressionInternal(expression.targetKeys, prefix, target, addPrecalculationRule);
82632
82645
  const sourceKeyPath = this.preparePathAndAdjustMultiplicity(prefix, expression.sourceKeyPath);
82633
82646
  const sourceValuePath = this.preparePathAndAdjustMultiplicity(prefix, expression.sourceValuePath);
82634
82647
  const sourceValueExpression = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.ValueReferenceExpression(sourceValuePath.toCurrentIteration(), "value");
82635
- return this.compileGroupSumExpressionWithCustomValueExpression(prefix, target, targetKeys, sourceKeyPath, sourceValueExpression, addPrecalculationRule);
82648
+ return this.compileGroupSumExpressionWithCustomValueExpression(prefix, target, expression.targetKeys, sourceKeyPath, sourceValueExpression, addPrecalculationRule);
82636
82649
  }
82637
82650
  compileGroupCountExpression(prefix, target, expression, addPrecalculationRule) {
82638
- const targetKeys = this.compileExpressionToFlangExpressionInternal(expression.targetKeys, prefix, target, addPrecalculationRule);
82639
82651
  const sourceKeyPath = this.preparePathAndAdjustMultiplicity(prefix, expression.sourceKeyPath);
82640
82652
  const sourceValueExpression = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_8__.DecimalLiteralExpression(1);
82641
- return this.compileGroupSumExpressionWithCustomValueExpression(prefix, target, targetKeys, sourceKeyPath, sourceValueExpression, addPrecalculationRule);
82653
+ return this.compileGroupSumExpressionWithCustomValueExpression(prefix, target, expression.targetKeys, sourceKeyPath, sourceValueExpression, addPrecalculationRule);
82642
82654
  }
82643
82655
  compiledArgumentExpression(prefix, target, selectPath, selectType, addPrecalculationRule, aggregationFunction = "Sum") {
82644
82656
  const adjustedSelectPath = this.preparePathAndAdjustMultiplicity(prefix, selectPath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kontur.candy/generator",
3
- "version": "5.14.0-rsvfunctions.2",
3
+ "version": "5.14.0-rsvfunctions.4",
4
4
  "description": "Candy forms generator",
5
5
  "author": "SKBKontur Candy Team",
6
6
  "private": false,