@legalplace/prerenderx 3.0.0 → 3.1.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.
- package/CHANGELOG.md +17 -0
- package/dist/libs/DocumentRender.d.ts +4 -4
- package/dist/libs/OptionRender.d.ts +4 -4
- package/dist/libs/OutputParser.d.ts +3 -3
- package/dist/libs/Prerender.d.ts +3 -3
- package/dist/libs/Prerender.js +5 -5
- package/dist/libs/SectionRender.d.ts +4 -4
- package/dist/libs/misc/FillPdfFormBase.d.ts +4 -4
- package/package.json +4 -1
- package/src/libs/DocumentRender.ts +4 -4
- package/src/libs/OptionRender.ts +4 -4
- package/src/libs/OutputParser.ts +4 -3
- package/src/libs/Prerender.ts +6 -5
- package/src/libs/SectionRender.ts +4 -4
- package/src/libs/misc/FillPdfFormBase.ts +4 -4
- package/dist/libs/ConditionsRunner.d.ts +0 -24
- package/dist/libs/ConditionsRunner.js +0 -69
- package/dist/libs/DataPopulator.d.ts +0 -53
- package/dist/libs/DataPopulator.js +0 -175
- package/dist/libs/OvcConverter.d.ts +0 -21
- package/dist/libs/OvcConverter.js +0 -132
- package/dist/libs/ovc.type.d.ts +0 -9
- package/dist/libs/ovc.type.js +0 -2
- package/src/libs/ConditionsRunner.ts +0 -118
- package/src/libs/DataPopulator.ts +0 -304
- package/src/libs/OvcConverter.ts +0 -187
- package/src/libs/ovc.type.ts +0 -10
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [3.1.0](https://git.legalplace.eu/legalplace/prerenderx/compare/v2.5.5-alpha...v3.1.0) (2021-12-16)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* add .gitlab-automator to .gitignore file ([56c8502](https://git.legalplace.eu/legalplace/prerenderx/commit/56c8502787a6f4b0019c8e3c91f4aec9f4d2e94c))
|
|
11
|
+
* add conditions-runner, types and ovc-converter as packages ([772bfdc](https://git.legalplace.eu/legalplace/prerenderx/commit/772bfdce518ac90306da996c54159fc7919427f4))
|
|
12
|
+
* add InputsType from Types package for OVC_TYPE ([24eb6b0](https://git.legalplace.eu/legalplace/prerenderx/commit/24eb6b01f8c0904d4a2612748b1cfe0175c0e2d8))
|
|
13
|
+
* move package types from dependencies to devDependencies ([8abc056](https://git.legalplace.eu/legalplace/prerenderx/commit/8abc05623d6d69f473139e613bbfe1c438f732f8))
|
|
14
|
+
* remove cache key ([e89e5d5](https://git.legalplace.eu/legalplace/prerenderx/commit/e89e5d5dd0353d44927151cc19c23a6192263c60))
|
|
15
|
+
* use package in FillPdfFormBase ([c96b782](https://git.legalplace.eu/legalplace/prerenderx/commit/c96b7829a378483e9f3f02b50a1ff1da6829bf2d))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* use types package instead of ovc.type file ([d0af6ee](https://git.legalplace.eu/legalplace/prerenderx/commit/d0af6ee936a054dd6292e054e035f92e5954caad))
|
|
21
|
+
|
|
5
22
|
### [2.5.5](https://git.legalplace.eu/legalplace/prerenderx/compare/v2.6.3...v2.5.5) (2021-10-27)
|
|
6
23
|
|
|
7
24
|
### [2.6.3](https://git.legalplace.eu/legalplace/prerenderx/compare/v2.6.2...v2.6.3) (2021-10-04)
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Types } from '@legalplace/referencesparser';
|
|
2
|
-
import ConditionsRunner from '
|
|
3
|
-
import
|
|
2
|
+
import ConditionsRunner from '@legalplace/conditions-runner';
|
|
3
|
+
import InputsType from '@legalplace/types/dist/inputs';
|
|
4
4
|
import NumAuto from './NumAuto';
|
|
5
5
|
declare class DocumentRender {
|
|
6
6
|
references: Types.ReferencesType;
|
|
7
7
|
conditions: ConditionsRunner;
|
|
8
|
-
ovc:
|
|
8
|
+
ovc: InputsType;
|
|
9
9
|
private NumAuto;
|
|
10
|
-
constructor(references: Types.ReferencesType, conditions: ConditionsRunner, ovc:
|
|
10
|
+
constructor(references: Types.ReferencesType, conditions: ConditionsRunner, ovc: InputsType, numauto: NumAuto);
|
|
11
11
|
renderDocument(documentName: string): string;
|
|
12
12
|
}
|
|
13
13
|
export default DocumentRender;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Types } from '@legalplace/referencesparser';
|
|
2
|
-
import ConditionsRunner from '
|
|
3
|
-
import
|
|
2
|
+
import ConditionsRunner from '@legalplace/conditions-runner';
|
|
3
|
+
import InputsType from '@legalplace/types/dist/inputs';
|
|
4
4
|
import NumAuto from './NumAuto';
|
|
5
5
|
declare class OptionRender {
|
|
6
6
|
outputs: string[];
|
|
@@ -8,12 +8,12 @@ declare class OptionRender {
|
|
|
8
8
|
index: number;
|
|
9
9
|
id: number;
|
|
10
10
|
conditions: ConditionsRunner;
|
|
11
|
-
ovc:
|
|
11
|
+
ovc: InputsType;
|
|
12
12
|
private NumAuto;
|
|
13
13
|
constructor(options: {
|
|
14
14
|
references: Types.ReferencesType;
|
|
15
15
|
conditions: ConditionsRunner;
|
|
16
|
-
ovc:
|
|
16
|
+
ovc: InputsType;
|
|
17
17
|
index: number;
|
|
18
18
|
id: number;
|
|
19
19
|
numauto: NumAuto;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Types } from '@legalplace/referencesparser';
|
|
2
|
-
import
|
|
2
|
+
import InputsType from '@legalplace/types/dist/inputs';
|
|
3
3
|
declare type relVarsValsT = Record<string, string | number>;
|
|
4
|
-
declare type getRelatedVarsT = (optionId: number, index: number, variables: number[], ovc:
|
|
4
|
+
declare type getRelatedVarsT = (optionId: number, index: number, variables: number[], ovc: InputsType, references: Types.ReferencesType) => relVarsValsT;
|
|
5
5
|
export declare const getRelatedVariablesValues: getRelatedVarsT;
|
|
6
6
|
declare type autonumsType = [string, string, number, string | null][];
|
|
7
7
|
declare type parseOutputT = (output: string, index: number, variables: relVarsValsT, autonums: autonumsType) => string;
|
|
8
8
|
export declare const parseOutputWithVariables: parseOutputT;
|
|
9
|
-
declare type TParseDocumentNameWithVariables = (text: string, ovc:
|
|
9
|
+
declare type TParseDocumentNameWithVariables = (text: string, ovc: InputsType, references: Types.ReferencesType, fallback?: string) => string;
|
|
10
10
|
export declare const parseDocumentNameWithVariables: TParseDocumentNameWithVariables;
|
|
11
11
|
export {};
|
package/dist/libs/Prerender.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ModelV3 } from '@legalplace/models-v3-types';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import OvcType from '@legalplace/types/dist/ovc';
|
|
3
|
+
import InputsType from '@legalplace/types/dist/inputs';
|
|
4
4
|
declare type DocumentOutputIndex = {
|
|
5
5
|
name: string;
|
|
6
6
|
slug: string;
|
|
@@ -30,7 +30,7 @@ declare class Prerender {
|
|
|
30
30
|
private NumAuto;
|
|
31
31
|
private documentsIndex;
|
|
32
32
|
private renderedDocuments;
|
|
33
|
-
constructor(model: ModelV3, ovc:
|
|
33
|
+
constructor(model: ModelV3, ovc: InputsType | OvcType);
|
|
34
34
|
getDocumentsIndex(): Record<string, DocumentOutputIndex | DocumentPdfFormIndex>;
|
|
35
35
|
getDocument(documentNameHash: string): string | FDFType;
|
|
36
36
|
private generateDocumentNamesHash;
|
package/dist/libs/Prerender.js
CHANGED
|
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var referencesparser_1 = require("@legalplace/referencesparser");
|
|
7
|
+
var conditions_runner_1 = __importDefault(require("@legalplace/conditions-runner"));
|
|
8
|
+
var ovc_converter_1 = __importDefault(require("@legalplace/ovc-converter"));
|
|
7
9
|
var crypto_1 = __importDefault(require("crypto"));
|
|
8
10
|
var DocumentRender_1 = __importDefault(require("./DocumentRender"));
|
|
9
|
-
var ConditionsRunner_1 = __importDefault(require("./ConditionsRunner"));
|
|
10
|
-
var OvcConverter_1 = __importDefault(require("./OvcConverter"));
|
|
11
11
|
var NumAuto_1 = __importDefault(require("./NumAuto"));
|
|
12
12
|
var InputsInitiator_1 = __importDefault(require("./InputsInitiator"));
|
|
13
13
|
var FillPdfForm_1 = __importDefault(require("./FillPdfForm"));
|
|
@@ -19,11 +19,11 @@ var Prerender = (function () {
|
|
|
19
19
|
this.model = model;
|
|
20
20
|
this.NumAuto = new NumAuto_1.default();
|
|
21
21
|
this.references = new referencesparser_1.ReferencesParser(model).getReferences();
|
|
22
|
-
this.ovc =
|
|
23
|
-
?
|
|
22
|
+
this.ovc = ovc_converter_1.default.isOvc(ovc)
|
|
23
|
+
? ovc_converter_1.default.convertToOptionsVariables(ovc, this.references)
|
|
24
24
|
: ovc;
|
|
25
25
|
var inputs = new InputsInitiator_1.default(this.references, this.ovc).getInputs();
|
|
26
|
-
this.conditions = new
|
|
26
|
+
this.conditions = new conditions_runner_1.default(this.references, inputs);
|
|
27
27
|
this.documentRender = new DocumentRender_1.default(this.references, this.conditions, inputs, this.NumAuto);
|
|
28
28
|
this.pdfFiller = new FillPdfForm_1.default(this.references, this.conditions, inputs);
|
|
29
29
|
this.generateDocumentNamesHash();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Types } from '@legalplace/referencesparser';
|
|
2
|
-
import ConditionsRunner from '
|
|
3
|
-
import
|
|
2
|
+
import ConditionsRunner from '@legalplace/conditions-runner';
|
|
3
|
+
import InputsType from '@legalplace/types/dist/inputs';
|
|
4
4
|
import NumAuto from './NumAuto';
|
|
5
5
|
declare class SectionRender {
|
|
6
6
|
outputs: string[];
|
|
@@ -8,12 +8,12 @@ declare class SectionRender {
|
|
|
8
8
|
currentSection: number;
|
|
9
9
|
documentName: string;
|
|
10
10
|
conditions: ConditionsRunner;
|
|
11
|
-
ovc:
|
|
11
|
+
ovc: InputsType;
|
|
12
12
|
private NumAuto;
|
|
13
13
|
constructor(options: {
|
|
14
14
|
references: Types.ReferencesType;
|
|
15
15
|
conditions: ConditionsRunner;
|
|
16
|
-
ovc:
|
|
16
|
+
ovc: InputsType;
|
|
17
17
|
documentName: string;
|
|
18
18
|
currentSection: number;
|
|
19
19
|
numauto: NumAuto;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Types } from '@legalplace/referencesparser';
|
|
2
|
-
import ConditionsRunner from '
|
|
3
|
-
import
|
|
2
|
+
import ConditionsRunner from '@legalplace/conditions-runner';
|
|
3
|
+
import InputsType from '@legalplace/types/dist/inputs';
|
|
4
4
|
declare class FillPdfFormBase {
|
|
5
5
|
references: Types.ReferencesType;
|
|
6
6
|
conditions: ConditionsRunner;
|
|
7
|
-
ovc:
|
|
8
|
-
constructor(references: Types.ReferencesType, conditions: ConditionsRunner, ovc:
|
|
7
|
+
ovc: InputsType;
|
|
8
|
+
constructor(references: Types.ReferencesType, conditions: ConditionsRunner, ovc: InputsType);
|
|
9
9
|
isVariableDisplayed(id: number, index: number): boolean;
|
|
10
10
|
isOptionDisplayed(id: number, index: number): boolean;
|
|
11
11
|
private getVariableCondition;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legalplace/prerenderx",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "PrerenderX",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": "https://git.legalplace.eu/legalplace/prerenderx",
|
|
@@ -15,8 +15,10 @@
|
|
|
15
15
|
"release": "standard-version -a --no-verify"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
+
"@legalplace/conditions-runner": "1.1.0",
|
|
18
19
|
"@legalplace/lplogic": "2.1.6",
|
|
19
20
|
"@legalplace/models-v3-types": "3.5.1",
|
|
21
|
+
"@legalplace/ovc-converter": "1.1.0",
|
|
20
22
|
"@legalplace/referencesparser": "1.6.3",
|
|
21
23
|
"crypto": "^1.0.1",
|
|
22
24
|
"standard-version": "^9.3.1",
|
|
@@ -25,6 +27,7 @@
|
|
|
25
27
|
"devDependencies": {
|
|
26
28
|
"@babel/core": "^7.7.2",
|
|
27
29
|
"@babel/preset-typescript": "^7.7.2",
|
|
30
|
+
"@legalplace/types": "1.1.0",
|
|
28
31
|
"@types/jest": "^24.0.15",
|
|
29
32
|
"@types/node": "^12.12.6",
|
|
30
33
|
"@typescript-eslint/eslint-plugin": "^2.6.1",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Types } from '@legalplace/referencesparser'
|
|
2
|
-
import ConditionsRunner from '
|
|
2
|
+
import ConditionsRunner from '@legalplace/conditions-runner'
|
|
3
|
+
import InputsType from '@legalplace/types/dist/inputs'
|
|
3
4
|
import SectionRender from './SectionRender'
|
|
4
|
-
import OVC_TYPE from './ovc.type'
|
|
5
5
|
import NumAuto from './NumAuto'
|
|
6
6
|
|
|
7
7
|
class DocumentRender {
|
|
@@ -9,11 +9,11 @@ class DocumentRender {
|
|
|
9
9
|
|
|
10
10
|
conditions: ConditionsRunner
|
|
11
11
|
|
|
12
|
-
ovc:
|
|
12
|
+
ovc: InputsType
|
|
13
13
|
|
|
14
14
|
private NumAuto: NumAuto
|
|
15
15
|
|
|
16
|
-
constructor(references: Types.ReferencesType, conditions: ConditionsRunner, ovc:
|
|
16
|
+
constructor(references: Types.ReferencesType, conditions: ConditionsRunner, ovc: InputsType, numauto: NumAuto) {
|
|
17
17
|
this.references = references
|
|
18
18
|
this.conditions = conditions
|
|
19
19
|
this.ovc = ovc
|
package/src/libs/OptionRender.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Types } from '@legalplace/referencesparser'
|
|
2
|
-
import ConditionsRunner from '
|
|
3
|
-
import
|
|
2
|
+
import ConditionsRunner from '@legalplace/conditions-runner'
|
|
3
|
+
import InputsType from '@legalplace/types/dist/inputs'
|
|
4
4
|
import { parseOutputWithVariables, getRelatedVariablesValues } from './OutputParser'
|
|
5
5
|
import NumAuto from './NumAuto'
|
|
6
6
|
|
|
@@ -15,11 +15,11 @@ class OptionRender {
|
|
|
15
15
|
|
|
16
16
|
conditions: ConditionsRunner
|
|
17
17
|
|
|
18
|
-
ovc:
|
|
18
|
+
ovc: InputsType
|
|
19
19
|
|
|
20
20
|
private NumAuto: NumAuto
|
|
21
21
|
|
|
22
|
-
constructor(options: { references: Types.ReferencesType; conditions: ConditionsRunner; ovc:
|
|
22
|
+
constructor(options: { references: Types.ReferencesType; conditions: ConditionsRunner; ovc: InputsType; index: number; id: number; numauto: NumAuto }) {
|
|
23
23
|
this.references = options.references
|
|
24
24
|
this.conditions = options.conditions
|
|
25
25
|
this.index = options.index
|
package/src/libs/OutputParser.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Types } from '@legalplace/referencesparser'
|
|
2
|
-
import
|
|
2
|
+
import InputsType from '@legalplace/types/dist/inputs'
|
|
3
|
+
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Parses number to correct french number format ("," instead of ".")
|
|
@@ -18,7 +19,7 @@ const frenchNumber = (value: string | number) => {
|
|
|
18
19
|
* @param variables Variables ids list
|
|
19
20
|
*/
|
|
20
21
|
type relVarsValsT = Record<string, string | number>
|
|
21
|
-
type getRelatedVarsT = (optionId: number, index: number, variables: number[], ovc:
|
|
22
|
+
type getRelatedVarsT = (optionId: number, index: number, variables: number[], ovc: InputsType, references: Types.ReferencesType) => relVarsValsT
|
|
22
23
|
export const getRelatedVariablesValues: getRelatedVarsT = (optionId, index, variables, ovc, references) => {
|
|
23
24
|
// Getting variables values
|
|
24
25
|
const variablesValues: Record<string, string> = {}
|
|
@@ -105,7 +106,7 @@ export const parseOutputWithVariables: parseOutputT = (output, index, variables,
|
|
|
105
106
|
*/
|
|
106
107
|
type TParseDocumentNameWithVariables = (
|
|
107
108
|
text: string,
|
|
108
|
-
ovc:
|
|
109
|
+
ovc: InputsType,
|
|
109
110
|
references: Types.ReferencesType,
|
|
110
111
|
fallback?: string
|
|
111
112
|
) => string;
|
package/src/libs/Prerender.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ModelV3 } from '@legalplace/models-v3-types'
|
|
2
2
|
import { Types, ReferencesParser } from '@legalplace/referencesparser'
|
|
3
|
+
import ConditionsRunner from '@legalplace/conditions-runner'
|
|
4
|
+
import OvcConverter from '@legalplace/ovc-converter'
|
|
5
|
+
import OvcType from '@legalplace/types/dist/ovc'
|
|
6
|
+
import InputsType from '@legalplace/types/dist/inputs'
|
|
3
7
|
import crypto from 'crypto'
|
|
4
8
|
import DocumentRender from './DocumentRender'
|
|
5
|
-
import ConditionsRunner from './ConditionsRunner'
|
|
6
|
-
import OVC_TYPE from './ovc.type'
|
|
7
|
-
import OvcConverter, { OldOVC } from './OvcConverter'
|
|
8
9
|
import NumAuto from './NumAuto'
|
|
9
10
|
import IntputsInitiator from './InputsInitiator'
|
|
10
11
|
import FillPdfForm from './FillPdfForm'
|
|
@@ -38,7 +39,7 @@ class Prerender {
|
|
|
38
39
|
|
|
39
40
|
private references: Types.ReferencesType
|
|
40
41
|
|
|
41
|
-
private ovc:
|
|
42
|
+
private ovc: InputsType
|
|
42
43
|
|
|
43
44
|
private conditions: ConditionsRunner
|
|
44
45
|
|
|
@@ -52,7 +53,7 @@ class Prerender {
|
|
|
52
53
|
|
|
53
54
|
private renderedDocuments: Record<string, string | FDFType> = {}
|
|
54
55
|
|
|
55
|
-
constructor(model: ModelV3, ovc:
|
|
56
|
+
constructor(model: ModelV3, ovc: InputsType | OvcType) {
|
|
56
57
|
this.model = model
|
|
57
58
|
|
|
58
59
|
// Initiating num auto
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Types } from '@legalplace/referencesparser'
|
|
2
|
-
import ConditionsRunner from '
|
|
2
|
+
import ConditionsRunner from '@legalplace/conditions-runner'
|
|
3
|
+
import InputsType from '@legalplace/types/dist/inputs'
|
|
3
4
|
import OptionRender from './OptionRender'
|
|
4
|
-
import OVC_TYPE from './ovc.type'
|
|
5
5
|
import NumAuto from './NumAuto'
|
|
6
6
|
|
|
7
7
|
class SectionRender {
|
|
@@ -15,11 +15,11 @@ class SectionRender {
|
|
|
15
15
|
|
|
16
16
|
conditions: ConditionsRunner
|
|
17
17
|
|
|
18
|
-
ovc:
|
|
18
|
+
ovc: InputsType
|
|
19
19
|
|
|
20
20
|
private NumAuto: NumAuto
|
|
21
21
|
|
|
22
|
-
constructor(options: { references: Types.ReferencesType; conditions: ConditionsRunner; ovc:
|
|
22
|
+
constructor(options: { references: Types.ReferencesType; conditions: ConditionsRunner; ovc: InputsType; documentName: string; currentSection: number; numauto: NumAuto }) {
|
|
23
23
|
this.references = options.references
|
|
24
24
|
this.conditions = options.conditions
|
|
25
25
|
this.documentName = options.documentName
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Types } from '@legalplace/referencesparser'
|
|
2
|
-
import ConditionsRunner from '
|
|
3
|
-
import
|
|
2
|
+
import ConditionsRunner from '@legalplace/conditions-runner'
|
|
3
|
+
import InputsType from '@legalplace/types/dist/inputs'
|
|
4
4
|
|
|
5
5
|
class FillPdfFormBase {
|
|
6
6
|
references: Types.ReferencesType
|
|
7
7
|
|
|
8
8
|
conditions: ConditionsRunner
|
|
9
9
|
|
|
10
|
-
ovc:
|
|
10
|
+
ovc: InputsType
|
|
11
11
|
|
|
12
|
-
constructor(references: Types.ReferencesType, conditions: ConditionsRunner, ovc:
|
|
12
|
+
constructor(references: Types.ReferencesType, conditions: ConditionsRunner, ovc: InputsType) {
|
|
13
13
|
this.references = references
|
|
14
14
|
this.conditions = conditions
|
|
15
15
|
this.ovc = ovc
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Types } from '@legalplace/referencesparser';
|
|
2
|
-
import { ConditionV3 } from '@legalplace/models-v3-types';
|
|
3
|
-
import { ConditionDataMap } from './DataPopulator';
|
|
4
|
-
declare type OVC_TYPE = {
|
|
5
|
-
options: {
|
|
6
|
-
[key: string]: boolean[];
|
|
7
|
-
};
|
|
8
|
-
variables: {
|
|
9
|
-
[key: string]: (number | string)[];
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
declare class ConditionsRunner {
|
|
13
|
-
private references;
|
|
14
|
-
private ovc;
|
|
15
|
-
constructor(references: Types.ReferencesType, ovc: OVC_TYPE);
|
|
16
|
-
isOptionRelatedToOption(optionA: number, optionB: number): boolean;
|
|
17
|
-
isVariableRelatedToOption(variableId: number, optionId: number): boolean;
|
|
18
|
-
isVariableRelatedToVariable(variableA: number, variableB: number): boolean;
|
|
19
|
-
executeCondition(condition: {
|
|
20
|
-
dataMap: ConditionDataMap;
|
|
21
|
-
conditions: ConditionV3;
|
|
22
|
-
}, id: number, index: number, conditionType: 'options' | 'optionValidator' | 'variables' | 'prefillers' | 'variableValidator' | 'sections' | 'documents'): any;
|
|
23
|
-
}
|
|
24
|
-
export default ConditionsRunner;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var lplogic_1 = __importDefault(require("@legalplace/lplogic"));
|
|
7
|
-
var DataPopulator_1 = __importDefault(require("./DataPopulator"));
|
|
8
|
-
var conditionsCache = {};
|
|
9
|
-
var ConditionsRunner = (function () {
|
|
10
|
-
function ConditionsRunner(references, ovc) {
|
|
11
|
-
this.references = references;
|
|
12
|
-
this.ovc = ovc;
|
|
13
|
-
}
|
|
14
|
-
ConditionsRunner.prototype.isOptionRelatedToOption = function (optionA, optionB) {
|
|
15
|
-
var OptionBParents = this.references.relations.options[optionB].parents;
|
|
16
|
-
var OptionBRoot = OptionBParents[OptionBParents.length - 1];
|
|
17
|
-
var OptionBRootRelations = OptionBRoot ? this.references.relations.options[OptionBRoot] : undefined;
|
|
18
|
-
if (OptionBRootRelations) {
|
|
19
|
-
if (optionA === optionB || OptionBRootRelations.children.options.includes(optionA) || OptionBRootRelations.dependants.includes(optionA)) {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return false;
|
|
24
|
-
};
|
|
25
|
-
ConditionsRunner.prototype.isVariableRelatedToOption = function (variableId, optionId) {
|
|
26
|
-
var variableParentId = this.references.relations.variables[variableId].parents[0];
|
|
27
|
-
var optionParents = this.references.relations.options[variableParentId].parents;
|
|
28
|
-
var optionRoot = optionParents[optionParents.length - 1];
|
|
29
|
-
var optionRootRelations = optionRoot ? this.references.relations.options[optionRoot] : undefined;
|
|
30
|
-
if (optionRootRelations) {
|
|
31
|
-
if (optionRootRelations.children.options.includes(optionId) || optionRootRelations.dependants.includes(optionId)) {
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return false;
|
|
36
|
-
};
|
|
37
|
-
ConditionsRunner.prototype.isVariableRelatedToVariable = function (variableA, variableB) {
|
|
38
|
-
var optionA = this.references.relations.variables[variableA].parents[0];
|
|
39
|
-
var optionB = this.references.relations.variables[variableB].parents[0];
|
|
40
|
-
var OptionBParents = this.references.relations.options[optionB].parents;
|
|
41
|
-
var OptionBRoot = OptionBParents[OptionBParents.length - 1];
|
|
42
|
-
var OptionBRootRelations = OptionBRoot ? this.references.relations.options[OptionBRoot] : undefined;
|
|
43
|
-
if (OptionBRootRelations) {
|
|
44
|
-
if (optionA === optionB || OptionBRootRelations.children.options.includes(optionA) || OptionBRootRelations.dependants.includes(optionA)) {
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return false;
|
|
49
|
-
};
|
|
50
|
-
ConditionsRunner.prototype.executeCondition = function (condition, id, index, conditionType) {
|
|
51
|
-
var _this = this;
|
|
52
|
-
if (Array.isArray(condition))
|
|
53
|
-
return condition.map(function (_condition) { return _this.executeCondition(_condition, id, index, conditionType); });
|
|
54
|
-
var currentData;
|
|
55
|
-
if (conditionType === 'options' || conditionType === 'optionValidator') {
|
|
56
|
-
currentData = new DataPopulator_1.default(this, this.references, this.ovc, condition.dataMap, id, index).getData();
|
|
57
|
-
}
|
|
58
|
-
else if (conditionType === 'variables' || conditionType === 'prefillers' || conditionType === 'variableValidator') {
|
|
59
|
-
var dataId = this.references.relations.variables[id].parents[0];
|
|
60
|
-
currentData = new DataPopulator_1.default(this, this.references, this.ovc, condition.dataMap, dataId, index).getData();
|
|
61
|
-
}
|
|
62
|
-
else if (conditionType === 'sections' || conditionType === 'documents') {
|
|
63
|
-
currentData = new DataPopulator_1.default(this, this.references, this.ovc, condition.dataMap, id, index).getData();
|
|
64
|
-
}
|
|
65
|
-
return lplogic_1.default(condition.conditions, currentData);
|
|
66
|
-
};
|
|
67
|
-
return ConditionsRunner;
|
|
68
|
-
}());
|
|
69
|
-
exports.default = ConditionsRunner;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { Types } from '@legalplace/referencesparser';
|
|
2
|
-
import ConditionsRunner from './ConditionsRunner';
|
|
3
|
-
declare type OVC_TYPE = {
|
|
4
|
-
options: {
|
|
5
|
-
[key: string]: boolean[];
|
|
6
|
-
};
|
|
7
|
-
variables: {
|
|
8
|
-
[key: string]: (number | string)[];
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
declare class DataPopulator {
|
|
12
|
-
private references;
|
|
13
|
-
private ovc;
|
|
14
|
-
private conditionsRunner;
|
|
15
|
-
private id?;
|
|
16
|
-
private index?;
|
|
17
|
-
private dataMap;
|
|
18
|
-
private data;
|
|
19
|
-
constructor(conditionsRunner: ConditionsRunner, references: Types.ReferencesType, ovc: OVC_TYPE, dataMap: ConditionDataMap, id?: number, index?: number);
|
|
20
|
-
getData(): Readonly<ConditionData>;
|
|
21
|
-
private populateConditions;
|
|
22
|
-
private getOptionConditions;
|
|
23
|
-
private getVariablesConditions;
|
|
24
|
-
private populateVariables;
|
|
25
|
-
private getVariableValues;
|
|
26
|
-
private getVariableRootParent;
|
|
27
|
-
private cleanArrayFromNullValues;
|
|
28
|
-
populateOptions(): void;
|
|
29
|
-
private getOptionInputs;
|
|
30
|
-
private getOptionRootParent;
|
|
31
|
-
private optionConditionValue;
|
|
32
|
-
private variableConditionValue;
|
|
33
|
-
private sectionConditionValue;
|
|
34
|
-
}
|
|
35
|
-
export interface ConditionDataMap {
|
|
36
|
-
o: number[];
|
|
37
|
-
v: number[];
|
|
38
|
-
c: {
|
|
39
|
-
o: number[];
|
|
40
|
-
s: number[];
|
|
41
|
-
v: number[];
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
export interface ConditionData {
|
|
45
|
-
o: Record<string, boolean[]>;
|
|
46
|
-
v: Record<string, (string | number)[]>;
|
|
47
|
-
c: {
|
|
48
|
-
o: Record<string, boolean[]>;
|
|
49
|
-
s: Record<string, boolean[]>;
|
|
50
|
-
v: Record<string, boolean[]>;
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
export default DataPopulator;
|