@kontur.candy/generator 5.36.1 → 5.37.0-fix-fs-7820.1

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 +110 -35
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -59828,6 +59828,11 @@ class ModelPathImpl {
59828
59828
  }
59829
59829
  return _PathMatcher__WEBPACK_IMPORTED_MODULE_4__.PathMatcher.match(this.tokens, modelPath.getPathPartsAsArray());
59830
59830
  }
59831
+ startsWith(modelPath) {
59832
+ const thisParts = this.getPathPartsAsArray();
59833
+ const otherParts = modelPath.getPathPartsAsArray();
59834
+ return otherParts.every((value, index) => value === thisParts[index]);
59835
+ }
59831
59836
  *splitByMultiplicity() {
59832
59837
  let lastSimpleParts = new _ModelPathBuilder__WEBPACK_IMPORTED_MODULE_3__.ModelPathBuilder(this.isAbsolute());
59833
59838
  for (const token of this.tokens) {
@@ -78058,12 +78063,12 @@ class DataDeclarationGenerationContext {
78058
78063
  [(0,_markupGenerator_getBindingPath__WEBPACK_IMPORTED_MODULE_7__.getResolvedBindingPath)(node)]: declEntry
78059
78064
  };
78060
78065
  }
78061
- addPathSectionDeclarationEntry(sugarNode, requisite, skipRequisitesSection = false) {
78066
+ addPathSectionDeclarationEntry(sugarNode, requisite, skipRequisitesSection = false, suffix) {
78062
78067
  const declEntry = {};
78063
78068
  const requisitesMode = skipRequisitesSection ? RequisiteSectionMode.ForceSkip : RequisiteSectionMode.AsRequisiteAttribute;
78064
78069
  declEntry.section = this.getSections(sugarNode, requisite, requisitesMode);
78065
78070
  return {
78066
- [(0,_markupGenerator_getBindingPath__WEBPACK_IMPORTED_MODULE_7__.getResolvedBindingPath)(sugarNode)]: declEntry
78071
+ [(0,_markupGenerator_getBindingPath__WEBPACK_IMPORTED_MODULE_7__.getResolvedBindingPath)(sugarNode, suffix)]: declEntry
78067
78072
  };
78068
78073
  }
78069
78074
  addChildPathSectionDeclarationEntry(sugarNode, childPath, requisite) {
@@ -83833,28 +83838,56 @@ class OptionalSectionRulesBuilder extends _BaseRuleBuilder__WEBPACK_IMPORTED_MOD
83833
83838
  buildRulesInternal() {
83834
83839
  const allOptionalSections = this.dataDeclarationHelper.getOptionalSections();
83835
83840
  const section2PathsMap = this.dataDeclarationHelper.getAllPathsBySection();
83841
+ const childrenSectionsByParent = this.getChildrenSectionsByParent();
83836
83842
  const allRules = allOptionalSections.map(x => {
83837
- var _section2PathsMap$get, _section2PathsMap$get2;
83838
- const sectionId = x.id;
83843
+ const allDependentSectionIds = this.getDependentSingleSections(x.id, childrenSectionsByParent).map(sectionInfo => sectionInfo.sectionId);
83839
83844
  const targetPath = (0,_Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_0__.createAbsoluteFromMask)(x.path, _Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_0__.PathTokens.each);
83840
- const pathsBySection = (_section2PathsMap$get = (_section2PathsMap$get2 = section2PathsMap.get(sectionId)) === null || _section2PathsMap$get2 === void 0 ? void 0 : _section2PathsMap$get2.values()) !== null && _section2PathsMap$get !== void 0 ? _section2PathsMap$get : [];
83845
+ const pathsBySection = [x.id, ...allDependentSectionIds].flatMap(sectionId => {
83846
+ var _section2PathsMap$get, _section2PathsMap$get2;
83847
+ return [...((_section2PathsMap$get = (_section2PathsMap$get2 = section2PathsMap.get(sectionId)) === null || _section2PathsMap$get2 === void 0 ? void 0 : _section2PathsMap$get2.values()) !== null && _section2PathsMap$get !== void 0 ? _section2PathsMap$get : [])];
83848
+ });
83841
83849
  return this.buildOptionalSectionIsFilledCheckRule(targetPath, pathsBySection);
83842
83850
  }).filter(_Common_TypingUtils__WEBPACK_IMPORTED_MODULE_4__.isNotNullOrUndefined);
83843
83851
  return allRules;
83844
83852
  }
83853
+ getDependentSingleSections(sourceSection, childrenSectionsByParent) {
83854
+ var _childrenSectionsByPa;
83855
+ const childrenSections = ((_childrenSectionsByPa = childrenSectionsByParent.get(sourceSection)) !== null && _childrenSectionsByPa !== void 0 ? _childrenSectionsByPa : []).filter(x => !x.optional && !x.multiple);
83856
+ const nestedSections = childrenSections.flatMap(x => this.getDependentSingleSections(x.sectionId, childrenSectionsByParent));
83857
+ return childrenSections.concat(...nestedSections);
83858
+ }
83859
+ getChildrenSectionsByParent() {
83860
+ return Iterator.from(this.getAllSections()).reduce((result, current) => {
83861
+ var _result$get;
83862
+ const data = (_result$get = result.get(current.parentSectionId)) !== null && _result$get !== void 0 ? _result$get : [];
83863
+ result.set(current.parentSectionId, data.concat(current));
83864
+ return result;
83865
+ }, new Map());
83866
+ }
83845
83867
  *getAllSections() {
83846
- const pagesToProcess = [...this.sugarRoot.pages];
83868
+ const pagesToProcess = this.sugarRoot.pages.map(x => ({
83869
+ page: x,
83870
+ parentId: undefined
83871
+ }));
83847
83872
  while ((0,_Common_TypingUtils__WEBPACK_IMPORTED_MODULE_4__.arrayIsNotEmpty)(pagesToProcess)) {
83848
- const page = pagesToProcess.pop();
83849
- if (page != null && (0,_Common_TypingUtils__WEBPACK_IMPORTED_MODULE_4__.isNotNullOrUndefined)(page.path)) {
83873
+ const info = pagesToProcess.pop();
83874
+ if (info != null && (0,_Common_TypingUtils__WEBPACK_IMPORTED_MODULE_4__.isNotNullOrUndefined)(info.page.path)) {
83850
83875
  var _page$optional, _page$multiple;
83876
+ const {
83877
+ page,
83878
+ parentId
83879
+ } = info;
83851
83880
  yield {
83852
83881
  sectionId: page.id,
83853
83882
  path: page.getFullPath(),
83854
83883
  optional: (_page$optional = page.optional) !== null && _page$optional !== void 0 ? _page$optional : false,
83855
- multiple: (_page$multiple = page.multiple) !== null && _page$multiple !== void 0 ? _page$multiple : false
83884
+ multiple: (_page$multiple = page.multiple) !== null && _page$multiple !== void 0 ? _page$multiple : false,
83885
+ parentSectionId: parentId
83856
83886
  };
83857
- pagesToProcess.push(...page.pages);
83887
+ pagesToProcess.push(...page.pages.map(x => ({
83888
+ page: x,
83889
+ parentId: page.id
83890
+ })));
83858
83891
  }
83859
83892
  }
83860
83893
  }
@@ -83877,8 +83910,9 @@ class OptionalSectionRulesBuilder extends _BaseRuleBuilder__WEBPACK_IMPORTED_MOD
83877
83910
  }
83878
83911
  buildOptionalSectionIsFilledCheckRule(targetPath, pathsBySection) {
83879
83912
  const createDecimalCondExpr = checkExpt => new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ConditionalExpression(checkExpt, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.DecimalLiteralExpression(1), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.DecimalLiteralExpression(0));
83880
- const targetValueRef = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ValueReferenceExpression(targetPath.joinWith(OptionalSectionRulesBuilder.optionalSectionFilledFieldName), "value");
83881
- const pathInfos = Iterator.from(pathsBySection).map(path => {
83913
+ const targetValueRefBase = targetPath.joinWith(OptionalSectionRulesBuilder.optionalSectionFilledFieldName);
83914
+ const targetValueRef = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ValueReferenceExpression(targetValueRefBase, "value");
83915
+ const pathInfos = Iterator.from(pathsBySection).filter(path => !path.isEquals(targetValueRefBase)).map(path => {
83882
83916
  const splitInfo = (0,_Common_ModelPath_PathSplitHelper__WEBPACK_IMPORTED_MODULE_2__.getMatchedAndDifferentModelPaths)(targetPath, path);
83883
83917
  const iterationEntries = (0,_Common_ModelPath_BuildIterationSequence__WEBPACK_IMPORTED_MODULE_3__.buildIterationSequence)(splitInfo.differentPath);
83884
83918
  return {
@@ -83901,7 +83935,7 @@ class OptionalSectionRulesBuilder extends _BaseRuleBuilder__WEBPACK_IMPORTED_MOD
83901
83935
  return pathCheckWithReduceIfRequiredExpr;
83902
83936
  });
83903
83937
  const allChecksExpressions = pathTestRules.reduce((acc, current) => acc == undefined ? current : new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.OrBinaryExpression(acc, current), undefined);
83904
- return allChecksExpressions != undefined ? new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.SetStatement(targetValueRef, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ConditionalExpression(allChecksExpressions, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.StringLiteralExpression("1"), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.StringLiteralExpression("0"))) : undefined;
83938
+ return allChecksExpressions != undefined ? new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.SetStatement(targetValueRef, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.ConditionalExpression(allChecksExpressions, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.StringLiteralExpression("1"), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_1__.NullLiteralExpression())) : undefined;
83905
83939
  }
83906
83940
  }
83907
83941
  OptionalSectionRulesBuilder.optionalSectionFilledFieldName = "isFilledOptional";
@@ -89155,17 +89189,21 @@ class FormConverter extends _SugarNodeConverter__WEBPACK_IMPORTED_MODULE_7__.Sug
89155
89189
  const rootPath = (0,_getRootPath__WEBPACK_IMPORTED_MODULE_3__.getRootPath)(node);
89156
89190
  const entrySections = ["default"];
89157
89191
  const optionalSections = this.findOptionalSections(node);
89192
+ const allSections = this.findAllSingleSections(node);
89158
89193
  if (node.requisite) {
89159
89194
  entrySections.push(_Common_CommonConstants_SectionNames__WEBPACK_IMPORTED_MODULE_12__.SectionNames.requisitesSection);
89160
89195
  }
89161
- return {
89196
+ const result = {
89162
89197
  [rootPath]: optionalSections.length > 0 ? {
89163
89198
  section: entrySections,
89199
+ allSingleSections: allSections,
89164
89200
  optionalSections: optionalSections
89165
89201
  } : {
89166
- section: entrySections
89202
+ section: entrySections,
89203
+ allSingleSections: allSections
89167
89204
  }
89168
89205
  };
89206
+ return result;
89169
89207
  }
89170
89208
  buildChildrenDataDeclaration(context) {
89171
89209
  const node = this.getCurrentNodeAs(_FormNode__WEBPACK_IMPORTED_MODULE_21__.FormNode);
@@ -89189,18 +89227,41 @@ class FormConverter extends _SugarNodeConverter__WEBPACK_IMPORTED_MODULE_7__.Sug
89189
89227
  }
89190
89228
  }
89191
89229
  findOptionalSections(node) {
89192
- const optionalPages = this.getAllPages(node.pages).filter(page => {
89230
+ const pages = this.findAllSingleSections(node).filter(page => page.optional);
89231
+ return pages;
89232
+ }
89233
+ findNearestOptionalSection(sectionId, allSinglePagesWithParent) {
89234
+ const pageInfo = allSinglePagesWithParent.get(sectionId);
89235
+ if (pageInfo == undefined || pageInfo.page.optional || pageInfo.parentPage == undefined || pageInfo.parentPage.multiple) {
89236
+ return undefined;
89237
+ }
89238
+ if (pageInfo.parentPage.optional) {
89239
+ return pageInfo.parentPage.id;
89240
+ }
89241
+ return this.findNearestOptionalSection(pageInfo.parentPage.id, allSinglePagesWithParent);
89242
+ }
89243
+ findAllSingleSections(node) {
89244
+ const allSinglePagesWithParent = new Map(this.getAllPages(node.pages).filter(x => !x.page.multiple).map(x => [x.page.id, x]));
89245
+ const pages = Iterator.from(allSinglePagesWithParent.values()).map(x => x.page).map(page => {
89193
89246
  var _page$optional;
89194
- return ((_page$optional = page.optional) !== null && _page$optional !== void 0 ? _page$optional : false) && !page.multiple;
89195
- }).map(page => ({
89196
- id: page.id,
89197
- path: page.getFullPath().toLegacyPath()
89198
- })).filter(x => (0,_Common_TypingUtils__WEBPACK_IMPORTED_MODULE_0__.isNotNullOrUndefined)(x.id));
89199
- return optionalPages;
89247
+ return {
89248
+ id: page.id,
89249
+ path: page.getFullPath().toLegacyPath(),
89250
+ optional: (_page$optional = page.optional) !== null && _page$optional !== void 0 ? _page$optional : false,
89251
+ dependsOnSection: this.findNearestOptionalSection(page.id, allSinglePagesWithParent)
89252
+ };
89253
+ }).filter(x => (0,_Common_TypingUtils__WEBPACK_IMPORTED_MODULE_0__.isNotNullOrUndefined)(x.id)).toArray();
89254
+ return pages;
89200
89255
  }
89201
- getAllPages(pages) {
89202
- const allPages = pages.flatMap(page => this.getAllPages(page.pages));
89203
- return pages.concat(allPages);
89256
+ getAllPages(pages, parentPage) {
89257
+ const allPages = pages.flatMap(page => this.getAllPages(page.pages, page)).map(x => ({
89258
+ page: x.page,
89259
+ parentPage: x.parentPage
89260
+ }));
89261
+ return pages.map(page => ({
89262
+ page: page,
89263
+ parentPage: parentPage
89264
+ })).concat(...allPages);
89204
89265
  }
89205
89266
  buildBaseFormWithContent(context, formContent, formNode) {
89206
89267
  const pageNodes = this.getFormPages(formNode);
@@ -90151,7 +90212,9 @@ __webpack_require__.r(__webpack_exports__);
90151
90212
  /* harmony import */ var _Helpers_Normativehelp_NormativeHelpNode__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Helpers/Normativehelp/NormativeHelpNode */ "./Generator/src/generators/markupGenerator/ElementProcessors/Helpers/Normativehelp/NormativeHelpNode.ts");
90152
90213
  /* harmony import */ var _Banner_BannerNode__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Banner/BannerNode */ "./Generator/src/generators/markupGenerator/ElementProcessors/FormParts/Banner/BannerNode.ts");
90153
90214
  /* harmony import */ var _ControlFlow_If_IfNode__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../ControlFlow/If/IfNode */ "./Generator/src/generators/markupGenerator/ElementProcessors/ControlFlow/If/IfNode.ts");
90154
- /* harmony import */ var _PageNode__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./PageNode */ "./Generator/src/generators/markupGenerator/ElementProcessors/FormParts/Page/PageNode.ts");
90215
+ /* harmony import */ var _Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../../../../../../Common/ModelPath/ModelPath */ "./Common/ModelPath/ModelPath.ts");
90216
+ /* harmony import */ var _PageNode__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./PageNode */ "./Generator/src/generators/markupGenerator/ElementProcessors/FormParts/Page/PageNode.ts");
90217
+
90155
90218
 
90156
90219
 
90157
90220
 
@@ -90169,13 +90232,13 @@ __webpack_require__.r(__webpack_exports__);
90169
90232
 
90170
90233
  class PageConverter extends _SugarNodeConverter__WEBPACK_IMPORTED_MODULE_4__.SugarNodeConverterBase {
90171
90234
  static getAcceptNodeClass() {
90172
- return _PageNode__WEBPACK_IMPORTED_MODULE_14__.PageNode;
90235
+ return _PageNode__WEBPACK_IMPORTED_MODULE_15__.PageNode;
90173
90236
  }
90174
90237
  applyVisibilityPathProcessing() {
90175
90238
  return false;
90176
90239
  }
90177
90240
  *doBuildNormalizeRules(builder, formSchemaRng) {
90178
- const node = this.getCurrentNodeAs(_PageNode__WEBPACK_IMPORTED_MODULE_14__.PageNode);
90241
+ const node = this.getCurrentNodeAs(_PageNode__WEBPACK_IMPORTED_MODULE_15__.PageNode);
90179
90242
  const element = formSchemaRng.getElementByPath(node.getFullPath());
90180
90243
  if (node.path == undefined) {
90181
90244
  return;
@@ -90189,7 +90252,8 @@ class PageConverter extends _SugarNodeConverter__WEBPACK_IMPORTED_MODULE_4__.Sug
90189
90252
  }
90190
90253
  }
90191
90254
  doBuildDataDeclaration(context) {
90192
- const node = this.getCurrentNodeAs(_PageNode__WEBPACK_IMPORTED_MODULE_14__.PageNode);
90255
+ var _node$optional, _node$multiple;
90256
+ const node = this.getCurrentNodeAs(_PageNode__WEBPACK_IMPORTED_MODULE_15__.PageNode);
90193
90257
  if (node.path == undefined) {
90194
90258
  return {};
90195
90259
  }
@@ -90202,20 +90266,30 @@ class PageConverter extends _SugarNodeConverter__WEBPACK_IMPORTED_MODULE_4__.Sug
90202
90266
  result.optional = [true];
90203
90267
  }
90204
90268
  }
90269
+ const optionalFieldPath = node.getFullPath().joinWith(PageConverter.optionalSectionFilledFieldName).toLegacyPath();
90270
+ const optionalFieldRequired = ((_node$optional = node.optional) !== null && _node$optional !== void 0 ? _node$optional : false) && !((_node$multiple = node.multiple) !== null && _node$multiple !== void 0 ? _node$multiple : false);
90205
90271
  return context.mergeDataDeclaration({
90206
90272
  [this.getResolvedBindingPath(node)]: result
90207
- }, context.addPathSectionDeclarationEntry(node));
90273
+ }, context.addPathSectionDeclarationEntry(node), optionalFieldRequired ? {
90274
+ [optionalFieldPath]: {
90275
+ value: context.initSequenceFactory.dataValue({
90276
+ defaultValue: "1",
90277
+ fetchfn: undefined,
90278
+ settings: undefined
90279
+ }, false, "1")
90280
+ }
90281
+ } : undefined, optionalFieldRequired ? context.addPathSectionDeclarationEntry(node, false, false, (0,_Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_14__.createRelativeFromTokens)([PageConverter.optionalSectionFilledFieldName])) : undefined);
90208
90282
  }
90209
90283
  buildChildrenDataDeclaration(context) {
90210
- const node = this.getCurrentNodeAs(_PageNode__WEBPACK_IMPORTED_MODULE_14__.PageNode);
90284
+ const node = this.getCurrentNodeAs(_PageNode__WEBPACK_IMPORTED_MODULE_15__.PageNode);
90211
90285
  return context.processChildrenDataDeclaration(node.children);
90212
90286
  }
90213
90287
  *doTraverseChildren() {
90214
- const node = this.getCurrentNodeAs(_PageNode__WEBPACK_IMPORTED_MODULE_14__.PageNode);
90288
+ const node = this.getCurrentNodeAs(_PageNode__WEBPACK_IMPORTED_MODULE_15__.PageNode);
90215
90289
  yield* node.children;
90216
90290
  }
90217
90291
  doConvert(context) {
90218
- const node = this.getCurrentNodeAs(_PageNode__WEBPACK_IMPORTED_MODULE_14__.PageNode);
90292
+ const node = this.getCurrentNodeAs(_PageNode__WEBPACK_IMPORTED_MODULE_15__.PageNode);
90219
90293
  if (node.multiple) {
90220
90294
  this.ensurePathExists(node, node.path);
90221
90295
  }
@@ -90279,6 +90353,7 @@ class PageConverter extends _SugarNodeConverter__WEBPACK_IMPORTED_MODULE_4__.Sug
90279
90353
  return pageBuilder.buildConverterResult();
90280
90354
  }
90281
90355
  }
90356
+ PageConverter.optionalSectionFilledFieldName = "isFilledOptional";
90282
90357
 
90283
90358
  /***/ }),
90284
90359
 
@@ -111094,8 +111169,8 @@ function getBindingPathExpression(node, customPath) {
111094
111169
  }
111095
111170
  return node.getFullPath().toLegacyPath();
111096
111171
  }
111097
- function getResolvedBindingPath(node) {
111098
- return node.getFullPath().toLegacyPath();
111172
+ function getResolvedBindingPath(node, suffix) {
111173
+ return node.getFullPath().joinWith(suffix != undefined ? suffix : (0,_Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_1__.emptyModelPath)()).toLegacyPath();
111099
111174
  }
111100
111175
  function getBindingPathWithSuffix(node, customPath) {
111101
111176
  return node.getFullPath().joinWith((0,_Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_1__.createFromMask)(customPath, "auto", _Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_1__.PathTokens.each)).normalize().toLegacyPath();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kontur.candy/generator",
3
- "version": "5.36.1",
3
+ "version": "5.37.0-fix-fs-7820.1",
4
4
  "description": "Candy forms generator",
5
5
  "author": "SKBKontur Candy Team",
6
6
  "private": false,