@kontur.candy/generator 5.111.0 → 5.111.1-fetch-fn-in-kclang.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 +16 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -72532,8 +72532,10 @@ function processSugar(formSugarContent, additionalContent, generationOptions) {
72532
72532
  const markupBuilderContext = new _markupGenerator_IMarkupBuildingContext__WEBPACK_IMPORTED_MODULE_52__.MarkupBuildingContext(new _markupGenerator_ElementProcessors_Commons_NodePathsContext__WEBPACK_IMPORTED_MODULE_51__.NodePathsContext(), additionalContent.formSourcesPath, additionalContent.helpersContent, additionalContent.tourSteps, controlCustomizationContext, typeRegistry, formSchemaRng, dataDeclarationHelper, useSchemaValidations);
72533
72533
  const validationGenerator = new _validationGenerator_ValidationGenerator__WEBPACK_IMPORTED_MODULE_18__.ValidationGenerator(sugarRoot, typeRegistry, markupBuilderContext, controlCustomizationContext, formSchemaRng, useSchemaValidations, additionalContent.validationsContent, additionalContent.formJsonSettings);
72534
72534
  if ((_additionalContent$fo5 = additionalContent.formJsonSettings) !== null && _additionalContent$fo5 !== void 0 && _additionalContent$fo5.useServerSideFLangNormalization) {
72535
+ var _additionalContent$fe;
72535
72536
  const kclangValidatios = Iterator.from(getImportedKclangValidations(sugarRoot, additionalContent)).toArray().join("\n");
72536
- const fullKcLangContent = ["// KCLang User Formulas\n\n", additionalContent.kcLangContent, "// KCLang User Validations\n\n", kclangValidatios, "// KCLang Generated Sugar Rules\n\n", kcLangFromSugar].join("\n");
72537
+ const fetchFunctionsKClangContent = (_additionalContent$fe = additionalContent.fetchFunctionKClangSources) === null || _additionalContent$fe === void 0 ? void 0 : _additionalContent$fe.join("\n\n");
72538
+ const fullKcLangContent = ["// KCLang Fetch Functions\n\n", fetchFunctionsKClangContent, "// KCLang User Formulas\n\n", additionalContent.kcLangContent, "// KCLang User Validations\n\n", kclangValidatios, "// KCLang Generated Sugar Rules\n\n", kcLangFromSugar].join("\n");
72537
72539
  builder.addServerSideResource("All.kclang", fullKcLangContent);
72538
72540
  builder.addServerSideResource("extendedSchema.json", JSON.stringify(extendedSchemaInfo, _Common_SerializationUtils__WEBPACK_IMPORTED_MODULE_7__.excludeUndefinedOrEmptyObjectJsonReplacer));
72539
72541
  }
@@ -72606,6 +72608,9 @@ function processSugar(formSugarContent, additionalContent, generationOptions) {
72606
72608
  }) : [];
72607
72609
  const resultRules = combineFlangRules(defaultNormalizationRules.content, ...additionalNormalizationRules, ...customNormalizers);
72608
72610
  builder.addServerSideResource("ServerSide.normalize", resultRules);
72611
+ for (const normalizerInfo of additionalNormalizationRules.filter(x => x.normalizerId != undefined)) {
72612
+ builder.addServerSideResource(`${normalizerInfo.normalizerId}.flang`, normalizerInfo.content);
72613
+ }
72609
72614
  }
72610
72615
  builder.addResource("lazyLoadDeclaration.js", _LazyLoadDeclarationGenerator_LazyLoadDeclarationGenerator__WEBPACK_IMPORTED_MODULE_31__.LazyLoadDeclarationGenerator.convertDeclarationToContent(finalLazyLoadDeclaration));
72611
72616
  const attachmentPathsGenerator = new _AttachmentPaths_AttachmentPathsGenerator__WEBPACK_IMPORTED_MODULE_29__.AttachmentPathsGenerator(markupBuilderContext);
@@ -72813,7 +72818,8 @@ async function readFormSources(formSourcesPath, farmDirectory) {
72813
72818
  tourSteps: await readFileSource(path__WEBPACK_IMPORTED_MODULE_1___default().join(rootPath, "tour"), "tour.js", "{}"),
72814
72819
  hooksContent: await readHooksFile(formSourcesPath),
72815
72820
  customControlsContent: await readCustomControlsFiles(path__WEBPACK_IMPORTED_MODULE_1___default().join(formSourcesPath, "controls")),
72816
- fetchFunctionSources: await readFiles(sugarReferences.fetchFunctionFiles.map(x => path__WEBPACK_IMPORTED_MODULE_1___default().resolve(formSugarDirectoryPath, x))),
72821
+ fetchFunctionSources: await readFiles(sugarReferences.fetchFunctionFiles.filter(x => path__WEBPACK_IMPORTED_MODULE_1___default().extname(x) == ".js").map(x => path__WEBPACK_IMPORTED_MODULE_1___default().resolve(formSugarDirectoryPath, x))),
72822
+ fetchFunctionKClangSources: await readFiles(sugarReferences.fetchFunctionFiles.filter(x => path__WEBPACK_IMPORTED_MODULE_1___default().extname(x) == ".kclang").map(x => path__WEBPACK_IMPORTED_MODULE_1___default().resolve(formSugarDirectoryPath, x))),
72817
72823
  localization: await connectJSFilesWithNames(path__WEBPACK_IMPORTED_MODULE_1___default().join(formSourcesPath, "localization")),
72818
72824
  importedFiles: await readImportedFiles(formSourcesPath),
72819
72825
  additionalNormalizers: additionalNormalizers
@@ -73508,7 +73514,7 @@ class MinusBinaryExpression extends BinaryExpression {
73508
73514
  }
73509
73515
  class MultiplicativeBinaryExpression extends BinaryExpression {
73510
73516
  needAddBraces(child) {
73511
- return !(child instanceof NegateUnaryExpression || child instanceof ValueReferenceExpression || child instanceof ArgumentReferenceExpression || child instanceof SumBinaryExpression || child instanceof MinusBinaryExpression || child instanceof CastExpression || child instanceof ConstExpression);
73517
+ return !(child instanceof NegateUnaryExpression || child instanceof ValueReferenceExpression || child instanceof ArgumentReferenceExpression || child instanceof CastExpression || child instanceof ConstExpression);
73512
73518
  }
73513
73519
  getType() {
73514
73520
  return BuildInTypeExpression.decimal;
@@ -75771,7 +75777,7 @@ class FormulaExpressionToFlangExpressionConverter {
75771
75777
  if (result == undefined) {
75772
75778
  throw new _Common_Errors__WEBPACK_IMPORTED_MODULE_2__.InvalidProgramStateError();
75773
75779
  }
75774
- return (0,_FLang_FlangUtils__WEBPACK_IMPORTED_MODULE_8__.wrapWithArgumentsCondition)(result);
75780
+ return result;
75775
75781
  }
75776
75782
  compileConcatExpression(expression, prefix, target, addPrecalculationRule) {
75777
75783
  const result = expression.arguments.reduce((acc, curr) => {
@@ -75811,7 +75817,7 @@ class FormulaExpressionToFlangExpressionConverter {
75811
75817
  if (result == undefined) {
75812
75818
  throw new _Common_Errors__WEBPACK_IMPORTED_MODULE_2__.InvalidProgramStateError();
75813
75819
  }
75814
- return (0,_FLang_FlangUtils__WEBPACK_IMPORTED_MODULE_8__.wrapWithArgumentsCondition)(result);
75820
+ return result;
75815
75821
  }
75816
75822
  compileDivisionExpression(expression, prefix, target, addPrecalculationRule) {
75817
75823
  const makeDivision = (numerator, denominator) => new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_9__.ConditionalExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_9__.NotEqExpression(denominator, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_9__.DecimalLiteralExpression(0)), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_9__.DivisionBinaryExpression(numerator, denominator), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_9__.NullLiteralExpression());
@@ -75822,7 +75828,7 @@ class FormulaExpressionToFlangExpressionConverter {
75822
75828
  if (result == undefined) {
75823
75829
  throw new _Common_Errors__WEBPACK_IMPORTED_MODULE_2__.InvalidProgramStateError();
75824
75830
  }
75825
- return (0,_FLang_FlangUtils__WEBPACK_IMPORTED_MODULE_8__.wrapWithArgumentsCondition)(result);
75831
+ return result;
75826
75832
  }
75827
75833
  preparePathAndAdjustMultiplicity(prefix, path) {
75828
75834
  const resultPath = this.adjustPathMultiplicity(prefix.joinWith((0,_Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_1__.createModelPath)(path.replace(/\@/g, ""), "auto")).normalize());
@@ -76574,8 +76580,8 @@ class OptionalElementsRulesBuilder extends _BaseRuleBuilder__WEBPACK_IMPORTED_MO
76574
76580
  return this.rules;
76575
76581
  }
76576
76582
  selectPrimaryElements() {
76577
- const optionalBlocksPaths = this.dataDeclarationHelper.getOptionalBlocksPaths();
76578
- const primaryElements = optionalBlocksPaths.map(path => this.formSchemaRng.getElementByPath(path)).filter(_Common_TypingUtils__WEBPACK_IMPORTED_MODULE_2__.isNotNullOrUndefined).filter(_common_SchemaRng_FormSchemaRng__WEBPACK_IMPORTED_MODULE_3__.isFormSchemaRngElement);
76583
+ const optionalBlocksPaths = Iterator.from(this.dataDeclarationHelper.getAllPaths());
76584
+ const primaryElements = optionalBlocksPaths.map(path => this.formSchemaRng.getElementByPath(path)).filter(_Common_TypingUtils__WEBPACK_IMPORTED_MODULE_2__.isNotNullOrUndefined).filter(_common_SchemaRng_FormSchemaRng__WEBPACK_IMPORTED_MODULE_3__.isFormSchemaRngElement).toArray();
76579
76585
  return primaryElements;
76580
76586
  }
76581
76587
  buildRulesForElement(element) {
@@ -76737,8 +76743,8 @@ class OptionalElementsRulesBuilder extends _BaseRuleBuilder__WEBPACK_IMPORTED_MO
76737
76743
  }
76738
76744
  createIsMultipleChildExistsExpression(element) {
76739
76745
  const childrenPath = this.formSchemaRng.getPath(element).trimLastStarIfLastToken();
76740
- const childrenFieldRef = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_4__.CastExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_4__.ValueReferenceExpression(childrenPath, "children"), _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_4__.BuildInTypeExpression.array);
76741
- return new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_4__.GtExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_4__.ArrayLengthExpression(childrenFieldRef), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_4__.DecimalLiteralExpression(0));
76746
+ const childrenFieldRef = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_4__.CastExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_4__.ValueReferenceExpression(childrenPath, "children"), _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_4__.BuildInTypeExpression.string);
76747
+ return new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_4__.AndBinaryExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_4__.NotEqExpression(childrenFieldRef, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_4__.StringLiteralExpression("[]")), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_4__.NotEqExpression(childrenFieldRef, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_4__.NullLiteralExpression()));
76742
76748
  }
76743
76749
  createElementExistenceValueRefForLeftPart(element) {
76744
76750
  const elementPath = this.formSchemaRng.getPath(element).toEachIteration();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kontur.candy/generator",
3
- "version": "5.111.0",
3
+ "version": "5.111.1-fetch-fn-in-kclang.0",
4
4
  "description": "Candy forms generator",
5
5
  "author": "SKBKontur Candy Team",
6
6
  "private": false,