@kontur.candy/generator 5.38.0 → 5.40.0-fix-rsv-normalizer.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.
- package/dist/index.js +50 -24
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -72415,7 +72415,6 @@ class TextFromSugarExtractor {
|
|
|
72415
72415
|
this.resultJson = {};
|
|
72416
72416
|
this.schemaRng = null;
|
|
72417
72417
|
this.formSource = void 0;
|
|
72418
|
-
this.fromTable = false;
|
|
72419
72418
|
this.formSource = sources;
|
|
72420
72419
|
}
|
|
72421
72420
|
getResult() {
|
|
@@ -72474,7 +72473,6 @@ class TextFromSugarExtractor {
|
|
|
72474
72473
|
let parent = node.parent;
|
|
72475
72474
|
for (let hoisting = 0; hoisting < deep; hoisting++) {
|
|
72476
72475
|
if (!parent) {
|
|
72477
|
-
this.fromTable = false;
|
|
72478
72476
|
return result;
|
|
72479
72477
|
}
|
|
72480
72478
|
const extractorManager = new _utils_ExtractorManager_ExtractorManager__WEBPACK_IMPORTED_MODULE_9__.ExtractorManager(new _utils_Extractors_EmptyExtractor__WEBPACK_IMPORTED_MODULE_8__.EmptyExtractor(node));
|
|
@@ -72483,7 +72481,6 @@ class TextFromSugarExtractor {
|
|
|
72483
72481
|
} else if (node.name === "stack") {
|
|
72484
72482
|
extractorManager.setExtractor(new _utils_Extractors_StackSubheaderExtractor__WEBPACK_IMPORTED_MODULE_7__.StackSubheaderExtractor(node));
|
|
72485
72483
|
} else if (parent.name === "table") {
|
|
72486
|
-
this.fromTable = true;
|
|
72487
72484
|
extractorManager.setExtractor(new _utils_Extractors_TableExtractor__WEBPACK_IMPORTED_MODULE_5__.TableExtractor(node));
|
|
72488
72485
|
}
|
|
72489
72486
|
const extractorTexts = extractorManager.executeExtractor();
|
|
@@ -72497,7 +72494,6 @@ class TextFromSugarExtractor {
|
|
|
72497
72494
|
}
|
|
72498
72495
|
parent = parent.parent;
|
|
72499
72496
|
}
|
|
72500
|
-
this.fromTable = false;
|
|
72501
72497
|
return result;
|
|
72502
72498
|
}
|
|
72503
72499
|
normalizeTexts(texts) {
|
|
@@ -72508,23 +72504,15 @@ class TextFromSugarExtractor {
|
|
|
72508
72504
|
const cut2 = uniqueTexts.slice(0, 2);
|
|
72509
72505
|
const first = cut2[0];
|
|
72510
72506
|
const second = cut2[1];
|
|
72511
|
-
if (this.fromTable) {
|
|
72512
|
-
this.fromTable = false;
|
|
72513
|
-
return [`графа ${first}`];
|
|
72514
|
-
}
|
|
72515
72507
|
if (first && second) {
|
|
72516
72508
|
if (!/[^0-9]/.test(first)) {
|
|
72517
72509
|
return [`строка ${first}`];
|
|
72518
72510
|
} else if (!/[^0-9]/.test(second)) {
|
|
72519
72511
|
return [`строка ${second}`];
|
|
72520
|
-
} else if (first === second) {
|
|
72521
|
-
return [`${first}`];
|
|
72522
72512
|
}
|
|
72523
72513
|
return [first];
|
|
72524
72514
|
} else if (first && second === undefined) {
|
|
72525
72515
|
return [first];
|
|
72526
|
-
} else {
|
|
72527
|
-
return [];
|
|
72528
72516
|
}
|
|
72529
72517
|
return [];
|
|
72530
72518
|
}
|
|
@@ -72735,6 +72723,18 @@ class TableExtractor extends _BaseExtractor_BaseExtractor__WEBPACK_IMPORTED_MODU
|
|
|
72735
72723
|
return this.getInnerTextsFromTableRow(this.node);
|
|
72736
72724
|
}
|
|
72737
72725
|
getInnerTextsFromTableRow(controlNode) {
|
|
72726
|
+
var _this$getColumnText, _this$getRowText;
|
|
72727
|
+
const columnText = (_this$getColumnText = this.getColumnText(controlNode)) === null || _this$getColumnText === void 0 ? void 0 : _this$getColumnText.shift();
|
|
72728
|
+
if (columnText === undefined) {
|
|
72729
|
+
return [];
|
|
72730
|
+
}
|
|
72731
|
+
const rowText = (_this$getRowText = this.getRowText(controlNode)) === null || _this$getRowText === void 0 ? void 0 : _this$getRowText.shift();
|
|
72732
|
+
const result = [];
|
|
72733
|
+
columnText && result.push(`графа ${columnText}`);
|
|
72734
|
+
rowText && result.push(`строка ${rowText}`);
|
|
72735
|
+
return [result.join(" ")];
|
|
72736
|
+
}
|
|
72737
|
+
getColumnText(controlNode) {
|
|
72738
72738
|
var _TextExtractorUtils$g;
|
|
72739
72739
|
const tableNode = (_TextExtractorUtils$g = _TextExtractorUtils__WEBPACK_IMPORTED_MODULE_1__.TextExtractorUtils.getParentControlByName(controlNode, "table")) !== null && _TextExtractorUtils$g !== void 0 ? _TextExtractorUtils$g : (0,_Common_TypingUtils__WEBPACK_IMPORTED_MODULE_0__.reject)();
|
|
72740
72740
|
const columnControlNode = _TextExtractorUtils__WEBPACK_IMPORTED_MODULE_1__.TextExtractorUtils.getParentControlByName(controlNode, "column");
|
|
@@ -72758,6 +72758,14 @@ class TableExtractor extends _BaseExtractor_BaseExtractor__WEBPACK_IMPORTED_MODU
|
|
|
72758
72758
|
}
|
|
72759
72759
|
return _TextExtractorUtils__WEBPACK_IMPORTED_MODULE_1__.TextExtractorUtils.getAllInnerTexts(textColumn, []);
|
|
72760
72760
|
}
|
|
72761
|
+
getRowText(controlNode) {
|
|
72762
|
+
const rowNode = _TextExtractorUtils__WEBPACK_IMPORTED_MODULE_1__.TextExtractorUtils.getParentControlByName(controlNode, "row");
|
|
72763
|
+
if (rowNode === undefined) {
|
|
72764
|
+
return [];
|
|
72765
|
+
}
|
|
72766
|
+
const texts = _TextExtractorUtils__WEBPACK_IMPORTED_MODULE_1__.TextExtractorUtils.getAllInnerTexts(rowNode, []).filter(el => !isNaN(Number(el)));
|
|
72767
|
+
return texts;
|
|
72768
|
+
}
|
|
72761
72769
|
|
|
72762
72770
|
/**
|
|
72763
72771
|
Интервал у табличных колонок.
|
|
@@ -72839,6 +72847,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
72839
72847
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
72840
72848
|
/* harmony export */ TextExtractorUtils: () => (/* binding */ TextExtractorUtils)
|
|
72841
72849
|
/* harmony export */ });
|
|
72850
|
+
/* harmony import */ var _Common_TypingUtils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../../../Common/TypingUtils */ "./Common/TypingUtils.ts");
|
|
72851
|
+
|
|
72842
72852
|
class TextExtractorUtils {
|
|
72843
72853
|
static getChildControlByName(node, nodeName) {
|
|
72844
72854
|
if (node.name === nodeName) {
|
|
@@ -72869,30 +72879,48 @@ class TextExtractorUtils {
|
|
|
72869
72879
|
if (deep < 0) {
|
|
72870
72880
|
return result;
|
|
72871
72881
|
}
|
|
72882
|
+
if (this.isSkipNode(node)) {
|
|
72883
|
+
return result;
|
|
72884
|
+
}
|
|
72872
72885
|
if (node.name === "#innertext") {
|
|
72873
72886
|
const text = this.extractInnerTextFromNode(node);
|
|
72874
72887
|
if (text) {
|
|
72875
|
-
!this.
|
|
72888
|
+
!this.ignoreStrings.includes(text) && result.push(text);
|
|
72876
72889
|
}
|
|
72877
72890
|
}
|
|
72878
72891
|
for (const childNode of node.children) {
|
|
72879
|
-
const text = this.extractInnerTextFromNode(childNode);
|
|
72880
|
-
if (text) {
|
|
72881
|
-
!this.ignoreSymbols.includes(text) && result.push(text);
|
|
72882
|
-
}
|
|
72883
72892
|
this.getAllInnerTexts(childNode, result, deep - 1);
|
|
72884
72893
|
}
|
|
72885
72894
|
return result;
|
|
72886
72895
|
}
|
|
72887
72896
|
static extractInnerTextFromNode(node) {
|
|
72888
|
-
|
|
72889
|
-
|
|
72897
|
+
var _node$parent;
|
|
72898
|
+
const text = (_node$parent = node.parent) === null || _node$parent === void 0 ? void 0 : _node$parent.children.reduce((acc, curr) => {
|
|
72899
|
+
if ("#innertext" in curr.attributes && typeof curr.attributes["#innertext"] === "string") {
|
|
72900
|
+
return this.formatText(acc + " " + curr.attributes["#innertext"]);
|
|
72901
|
+
}
|
|
72902
|
+
return acc;
|
|
72903
|
+
}, "");
|
|
72904
|
+
if ((0,_Common_TypingUtils__WEBPACK_IMPORTED_MODULE_0__.isNotNullOrEmpty)(text)) {
|
|
72905
|
+
return text;
|
|
72890
72906
|
}
|
|
72891
72907
|
return undefined;
|
|
72892
72908
|
}
|
|
72893
72909
|
static formatText(text) {
|
|
72894
72910
|
return text.replace(/(\s|\\n)+/g, " ").replace(/ +/g, " ").replace(/(( $)|(^ ))/g, "");
|
|
72895
72911
|
}
|
|
72912
|
+
static isSkipNode(node) {
|
|
72913
|
+
if (node.name.endsWith(".formula")) {
|
|
72914
|
+
return true;
|
|
72915
|
+
}
|
|
72916
|
+
if (node.name === "radiogroup") {
|
|
72917
|
+
return true;
|
|
72918
|
+
}
|
|
72919
|
+
if (node.name === "case") {
|
|
72920
|
+
return true;
|
|
72921
|
+
}
|
|
72922
|
+
return false;
|
|
72923
|
+
}
|
|
72896
72924
|
}
|
|
72897
72925
|
TextExtractorUtils.titleTexts = {
|
|
72898
72926
|
Год: "Год",
|
|
@@ -72901,13 +72929,11 @@ TextExtractorUtils.titleTexts = {
|
|
|
72901
72929
|
Фамилия: "Фамилия",
|
|
72902
72930
|
Имя: "Имя",
|
|
72903
72931
|
Отчество: "Отчество",
|
|
72904
|
-
ИНН: "ИНН",
|
|
72905
|
-
КПП: "КПП",
|
|
72906
72932
|
Период: "Отчетный период",
|
|
72907
72933
|
НомерКорректировки: "Номер корректировки",
|
|
72908
72934
|
НомКорр: "Номер корректировки"
|
|
72909
72935
|
};
|
|
72910
|
-
TextExtractorUtils.
|
|
72936
|
+
TextExtractorUtils.ignoreStrings = ["—", "₽", "–", "%", "Заполнить суммы", "Удалить суммы", "Рекомендации по заполнению", "Код строки", "Заполнить", "№", "от А до Я", "от Я до А", "По возрастанию", "По убыванию", "Сначала старые", "Сначала новые", "Добавить мероприятие", "Пример заполнения", "Удалить", "Удалить сведения", "Загрузить из Xml файла", "Загрузить из Excel файла", "Загрузить из файла", "в том числе:", "в том числе за:"];
|
|
72911
72937
|
TextExtractorUtils.hoistLevel = 7;
|
|
72912
72938
|
TextExtractorUtils.maxFoundTexts = 1000;
|
|
72913
72939
|
|
|
@@ -84055,7 +84081,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
84055
84081
|
|
|
84056
84082
|
|
|
84057
84083
|
/**
|
|
84058
|
-
* Нормализатор, соответсвующий дефолтному за исключением метода нормализации
|
|
84084
|
+
* Нормализатор, соответсвующий дефолтному за исключением метода нормализации значений,
|
|
84059
84085
|
* отсутсвующих в исходном иннере:
|
|
84060
84086
|
* "если value == null и autoFlag == null, то выполнить инициализировать value значением авторасчёта,
|
|
84061
84087
|
* а при его отсутсвии дефолтным значением"
|
|
@@ -84094,7 +84120,7 @@ class AutoValueForValueByDefaultNormalizationRuleGenerator {
|
|
|
84094
84120
|
const autoFlagRefCurrentIteration = new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_2__.ValueReferenceExpression(autoValueRule.left.modePath.toCurrentIteration(), "autoFlag");
|
|
84095
84121
|
return new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_2__.SetStatement(valueRef, new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_2__.ConditionalExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_2__.AndBinaryExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_2__.EqExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_2__.NoDepsExpression(valueRefCurrentIteration), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_2__.NullLiteralExpression()), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_2__.EqExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_2__.NoDepsExpression(autoFlagRefCurrentIteration), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_2__.NullLiteralExpression())), autoValueRule.right, formulaRulesMap.has(valueRef) ? (_formulaRulesMap$get$ = (_formulaRulesMap$get = formulaRulesMap.get(valueRef)) === null || _formulaRulesMap$get === void 0 ? void 0 : _formulaRulesMap$get.right) !== null && _formulaRulesMap$get$ !== void 0 ? _formulaRulesMap$get$ : (0,_Common_TypingUtils__WEBPACK_IMPORTED_MODULE_4__.reject)("Unexpected error") : new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_2__.NullCoalesceExpression(new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_2__.ValueReferenceExpression(autoValueRule.left.modePath.toCurrentIteration(), "value"), new _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_2__.StringLiteralExpression(this.dataDeclarationHelper.getDefaultValue(autoValueRule.left.modePath)))));
|
|
84096
84122
|
};
|
|
84097
|
-
const updatedFormulaRules = Iterator.from(formulaFLangRules).flatMap(x => x instanceof _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_2__.SetStatement && x.left.valueName === "autoValue"
|
|
84123
|
+
const updatedFormulaRules = Iterator.from(formulaFLangRules).flatMap(x => x instanceof _FLang_FLangCodeDom__WEBPACK_IMPORTED_MODULE_2__.SetStatement && x.left.valueName === "autoValue" ? [x, createValueRuleFromAutoValueRule(x)] : [x]);
|
|
84098
84124
|
|
|
84099
84125
|
// Порядок важен, т.к. потом делаем distinctBy.
|
|
84100
84126
|
const allRules = _Common_IterableUtils__WEBPACK_IMPORTED_MODULE_0__.IterUtils.concat(initializeRules, lazyLoadingRules, updatedFormulaRules, optionalSectionRules, dataDeclarationRules, sugarValidationRules).flatMap(rule => (0,_FLang_FlangUtils__WEBPACK_IMPORTED_MODULE_1__.wrapWithDisableValueAutoInitFlagCheckIfRequired)(this.formSchemaRng, rule));
|