gedcom.json 1.0.8 → 1.0.10
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/README.md +246 -256
- package/dist/ToJSON/console.js +15 -12
- package/dist/ToJSON/console.js.map +1 -1
- package/dist/ToJSON/models/DefinitionCache.js.map +1 -1
- package/dist/ToJSON/models/LineParsingResult.js.map +1 -1
- package/dist/ToJSON/models/ParsedLine.js +1 -1
- package/dist/ToJSON/models/ParsedLine.js.map +1 -1
- package/dist/ToJSON/models/Parsing.js +8 -6
- package/dist/ToJSON/models/Parsing.js.map +1 -1
- package/dist/ToJSON/models/ParsingObject.js.map +1 -1
- package/dist/ToJSON/models/ParsingOptions.js.map +1 -1
- package/dist/ToJSON/models/ParsingPath.js.map +1 -1
- package/dist/ToJSON/models/ParsingResult.js.map +1 -1
- package/dist/ToJSON/models/StatisticLine.js.map +1 -1
- package/dist/ToJSON/models/Statistics.js +2 -2
- package/dist/ToJSON/models/Statistics.js.map +1 -1
- package/dist/ToJSON/models/Store.js +11 -11
- package/dist/ToJSON/models/Store.js.map +1 -1
- package/dist/ToJSON/models/TagDefinition.js +11 -11
- package/dist/ToJSON/models/TagDefinition.js.map +1 -1
- package/dist/ToJSON/parsing/lineHelper.js +8 -8
- package/dist/ToJSON/parsing/lineHelper.js.map +1 -1
- package/dist/ToJSON/parsing/lineValidation.js +6 -6
- package/dist/ToJSON/parsing/lineValidation.js.map +1 -1
- package/dist/ToJSON/parsing/parseDate.js +84 -84
- package/dist/ToJSON/parsing/parseDate.js.map +1 -1
- package/dist/ToJSON/parsing/parseLine.js +8 -8
- package/dist/ToJSON/parsing/parseLine.js.map +1 -1
- package/dist/ToJSON/parsing/parsing.js +17 -17
- package/dist/ToJSON/parsing/parsing.js.map +1 -1
- package/dist/ToJSON/parsing/processLine.js +18 -18
- package/dist/ToJSON/parsing/processLine.js.map +1 -1
- package/dist/ToJSON/processing/manipulateValues.js +9 -10
- package/dist/ToJSON/processing/manipulateValues.js.map +1 -1
- package/dist/ToJSON/processing/result.js +87 -80
- package/dist/ToJSON/processing/result.js.map +1 -1
- package/dist/common.js +5 -5
- package/dist/common.js.map +1 -1
- package/dist/console.js +4 -4
- package/dist/console.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/options/version551.yaml +303 -296
- package/package.json +13 -8
- package/src/ToJSON/console.ts +67 -67
- package/src/ToJSON/models/DefinitionCache.ts +7 -7
- package/src/ToJSON/models/LineParsingResult.ts +7 -7
- package/src/ToJSON/models/ParsedLine.ts +35 -35
- package/src/ToJSON/models/Parsing.ts +45 -41
- package/src/ToJSON/models/ParsingObject.ts +16 -16
- package/src/ToJSON/models/ParsingOptions.ts +41 -41
- package/src/ToJSON/models/ParsingPath.ts +7 -7
- package/src/ToJSON/models/ParsingResult.ts +10 -10
- package/src/ToJSON/models/StatisticLine.ts +16 -16
- package/src/ToJSON/models/Statistics.ts +63 -63
- package/src/ToJSON/models/Store.ts +106 -108
- package/src/ToJSON/models/TagDefinition.ts +123 -122
- package/src/ToJSON/parsing/lineHelper.ts +21 -21
- package/src/ToJSON/parsing/lineValidation.ts +39 -40
- package/src/ToJSON/parsing/parseDate.ts +280 -286
- package/src/ToJSON/parsing/parseLine.ts +33 -33
- package/src/ToJSON/parsing/parsing.ts +134 -141
- package/src/ToJSON/parsing/processLine.ts +112 -109
- package/src/ToJSON/processing/manipulateValues.ts +52 -53
- package/src/ToJSON/processing/result.ts +247 -241
- package/src/common.ts +14 -14
- package/src/console.ts +7 -8
- package/src/index.ts +3 -6
- package/test.json +0 -323
|
@@ -5,75 +5,75 @@ import join from 'lodash/join';
|
|
|
5
5
|
* Class with parsing statistics
|
|
6
6
|
*/
|
|
7
7
|
export default class Statistics {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
constructor() {
|
|
9
|
+
this.ParsedLines = [];
|
|
10
|
+
this.IncorrectLines = [];
|
|
11
|
+
this.NotParsedLines = [];
|
|
12
|
+
this.NotParsedLinesWithoutGEDCOMTag = [];
|
|
13
|
+
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
/**
|
|
16
|
+
* @returns list of all correct parsed lines
|
|
17
|
+
*/
|
|
18
|
+
ParsedLines: StatisticLine[];
|
|
19
|
+
/**
|
|
20
|
+
* @returns list of all incorrect parsed lines
|
|
21
|
+
*/
|
|
22
|
+
IncorrectLines: StatisticLine[];
|
|
23
|
+
/**
|
|
24
|
+
* @returns list of all not parsed lines
|
|
25
|
+
*/
|
|
26
|
+
NotParsedLines: StatisticLine[];
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
/**
|
|
29
|
+
* @returns list of all not parsed lines
|
|
30
|
+
*/
|
|
31
|
+
NotParsedLinesWithoutGEDCOMTag: StatisticLine[];
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
/**
|
|
34
|
+
* @returns a count of all correctly parsed lines
|
|
35
|
+
*/
|
|
36
|
+
get ParsedLinesCount(): number {
|
|
37
|
+
return this.ParsedLines.length;
|
|
38
|
+
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
/**
|
|
41
|
+
* @returns a count of all incorrect parsed lines
|
|
42
|
+
*/
|
|
43
|
+
get IncorrectLinesCount(): number {
|
|
44
|
+
return this.IncorrectLines.length;
|
|
45
|
+
}
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
/**
|
|
48
|
+
* @returns a count of all not parsed lines
|
|
49
|
+
*/
|
|
50
|
+
get NotParsedLinesCount(): number {
|
|
51
|
+
return this.NotParsedLines.length;
|
|
52
|
+
}
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
/**
|
|
55
|
+
* @returns a count of all not parsed lines
|
|
56
|
+
*/
|
|
57
|
+
get NotParsedLinesWithoutGEDCOMTagCount(): number {
|
|
58
|
+
return this.NotParsedLinesWithoutGEDCOMTag.length;
|
|
59
|
+
}
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
/**
|
|
62
|
+
* @returns a count of all processed lines
|
|
63
|
+
*/
|
|
64
|
+
get LinesCount(): number {
|
|
65
|
+
return this.ParsedLines.length + this.IncorrectLines.length + this.NotParsedLines.length + this.NotParsedLinesWithoutGEDCOMTag.length;
|
|
66
|
+
}
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
/**
|
|
69
|
+
* @returns a comma separated list of all not parsed line numbers
|
|
70
|
+
*/
|
|
71
|
+
get NotParsedLinesList(): string {
|
|
72
|
+
let lineNumbers: number[] = [];
|
|
73
|
+
this.NotParsedLines.forEach((line) => {
|
|
74
|
+
lineNumbers.push(line.LineNumber);
|
|
75
|
+
});
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
77
|
+
return join(lineNumbers, ', ');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -1,142 +1,140 @@
|
|
|
1
|
-
import dropRight from
|
|
2
|
-
import split from
|
|
3
|
-
import map from
|
|
4
|
-
import flattenDeep from
|
|
1
|
+
import dropRight from 'lodash/dropRight';
|
|
2
|
+
import split from 'lodash/split';
|
|
3
|
+
import map from 'lodash/map';
|
|
4
|
+
import flattenDeep from 'lodash/flattenDeep';
|
|
5
5
|
import remove from 'lodash/remove';
|
|
6
6
|
import find from 'lodash/find';
|
|
7
7
|
import isEqual from 'lodash/isEqual';
|
|
8
8
|
|
|
9
|
-
import objectPath from
|
|
10
|
-
import fclone from
|
|
9
|
+
import objectPath from 'object-path';
|
|
10
|
+
import fclone from 'fclone';
|
|
11
11
|
|
|
12
|
-
import TagDefinition from
|
|
13
|
-
import ParsedLine from
|
|
14
|
-
import ConvertToTime from
|
|
15
|
-
import ParsingObject from
|
|
16
|
-
import ParsingPath from
|
|
12
|
+
import TagDefinition from './TagDefinition';
|
|
13
|
+
import ParsedLine from './ParsedLine';
|
|
14
|
+
import ConvertToTime from './converter/ConvertToTime';
|
|
15
|
+
import ParsingObject from './ParsingObject';
|
|
16
|
+
import ParsingPath from './ParsingPath';
|
|
17
17
|
|
|
18
|
-
import { CreateResult } from
|
|
19
|
-
import { IsEmpty } from
|
|
20
|
-
import { AddStartWith, ManipulateValue } from
|
|
21
|
-
import DefinitionCache from
|
|
18
|
+
import { CreateResult } from '../processing/result';
|
|
19
|
+
import { IsEmpty } from '../../common';
|
|
20
|
+
import { AddStartWith, ManipulateValue } from '../processing/manipulateValues';
|
|
21
|
+
import DefinitionCache from './DefinitionCache';
|
|
22
22
|
|
|
23
23
|
export default class Store {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
constructor() {
|
|
25
|
+
this.objects = [];
|
|
26
|
+
this.path = [];
|
|
27
|
+
this.isParsing = false;
|
|
28
|
+
this.stopParsingTillLevel = undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private objects: ParsingObject[];
|
|
32
|
+
/*
|
|
33
33
|
the actual parsed path
|
|
34
34
|
*/
|
|
35
|
-
|
|
35
|
+
private path: ParsingPath[];
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
/*
|
|
38
38
|
if true the line will be parsed, when false all lines will be ignored until a new defined tag with level 0 is found
|
|
39
39
|
*/
|
|
40
|
-
|
|
40
|
+
private isParsing: Boolean;
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
private stopParsingTillLevel?: Number;
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
private definitionCache: DefinitionCache[] = [];
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
AddDefinitionToCache(path: string[], definition: any) {
|
|
47
|
+
this.definitionCache.push(new DefinitionCache(path, definition));
|
|
48
|
+
}
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
GetDefinitionFromCache(path: string[]) {
|
|
51
|
+
return find(this.definitionCache, (x) => isEqual(path, x.Path));
|
|
52
|
+
}
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
AddTempPath() {
|
|
55
|
+
this.path.push(new ParsingPath('TEMP', ''));
|
|
56
|
+
}
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// concat path and remove empty values
|
|
63
|
-
let path = flattenDeep(map(fclone(this.path), x => split(x.Path, ".")));
|
|
64
|
-
remove(path, x => IsEmpty(x));
|
|
65
|
-
|
|
66
|
-
let obj = new ParsingObject(definition, line, path);
|
|
67
|
-
|
|
68
|
-
// if no value is set, but the value should start with a specific value -> set the value and remove the property
|
|
69
|
-
if (!(line.ReferenceId || line.Value)) {
|
|
70
|
-
line.Value = AddStartWith(definition.StartWith, line.Value);
|
|
71
|
-
definition.StartWith = undefined;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (definition.Property && (line.ReferenceId || line.Value)) {
|
|
75
|
-
if (definition.CollectAs) {
|
|
76
|
-
objectPath.set(obj.Object, definition.Property, ManipulateValue(definition, line));
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
obj.Object = ManipulateValue(definition, line);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
// time has no own property, but must be merged with the last date
|
|
84
|
-
if (definition.ConvertTo instanceof ConvertToTime) {
|
|
85
|
-
ManipulateValue(definition, line);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
this.objects.push(obj);
|
|
90
|
-
}
|
|
58
|
+
StartParsing(definition: TagDefinition, line: ParsedLine) {
|
|
59
|
+
this.isParsing = true;
|
|
60
|
+
this.path.push(new ParsingPath(definition.Tag, definition.Path));
|
|
91
61
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
62
|
+
// concat path and remove empty values
|
|
63
|
+
let path = flattenDeep(map(fclone(this.path), (x) => split(x.Path, '.')));
|
|
64
|
+
remove(path, (x) => IsEmpty(x));
|
|
95
65
|
|
|
96
|
-
|
|
97
|
-
if (!number) {
|
|
98
|
-
this.path = dropRight(this.path, number);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
this.path = dropRight(this.path, this.path.length - number);
|
|
103
|
-
}
|
|
66
|
+
let obj = new ParsingObject(definition, line, path);
|
|
104
67
|
|
|
105
|
-
|
|
106
|
-
|
|
68
|
+
// if no value is set, but the value should start with a specific value -> set the value and remove the property
|
|
69
|
+
if (!(line.ReferenceId || line.Value)) {
|
|
70
|
+
line.Value = AddStartWith(definition.StartWith, line.Value);
|
|
71
|
+
definition.StartWith = undefined;
|
|
107
72
|
}
|
|
108
73
|
|
|
109
|
-
|
|
110
|
-
|
|
74
|
+
if (definition.Property && (line.ReferenceId || line.Value)) {
|
|
75
|
+
if (definition.CollectAs) {
|
|
76
|
+
objectPath.set(obj.Object, definition.Property, ManipulateValue(definition, line));
|
|
77
|
+
} else {
|
|
78
|
+
obj.Object = ManipulateValue(definition, line);
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
// time has no own property, but must be merged with the last date
|
|
82
|
+
if (definition.ConvertTo instanceof ConvertToTime) {
|
|
83
|
+
ManipulateValue(definition, line);
|
|
84
|
+
}
|
|
111
85
|
}
|
|
112
86
|
|
|
113
|
-
|
|
114
|
-
|
|
87
|
+
this.objects.push(obj);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
IsParsing(): Boolean {
|
|
91
|
+
return this.isParsing;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
DropRightPath(number?: number) {
|
|
95
|
+
if (!number) {
|
|
96
|
+
this.path = dropRight(this.path, number);
|
|
97
|
+
return;
|
|
115
98
|
}
|
|
116
99
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
100
|
+
this.path = dropRight(this.path, this.path.length - number);
|
|
101
|
+
}
|
|
121
102
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
103
|
+
GetPath() {
|
|
104
|
+
return this.path;
|
|
105
|
+
}
|
|
126
106
|
|
|
127
|
-
|
|
128
|
-
|
|
107
|
+
CreateResultObject() {
|
|
108
|
+
return CreateResult(this.objects);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
StopParsingUntilLevel(level: Number) {
|
|
112
|
+
this.stopParsingTillLevel = level;
|
|
113
|
+
}
|
|
129
114
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
this.stopParsingTillLevel = undefined;
|
|
134
|
-
this.definitionCache = [];
|
|
115
|
+
ShouldParseLine(level: Number): Boolean {
|
|
116
|
+
if (!this.stopParsingTillLevel) {
|
|
117
|
+
return true;
|
|
135
118
|
}
|
|
136
119
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
this.definitionCache = [];
|
|
120
|
+
if (level <= this.stopParsingTillLevel) {
|
|
121
|
+
this.stopParsingTillLevel = 0;
|
|
122
|
+
return true;
|
|
141
123
|
}
|
|
142
|
-
|
|
124
|
+
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
Reset() {
|
|
129
|
+
this.isParsing = false;
|
|
130
|
+
this.path = [];
|
|
131
|
+
this.stopParsingTillLevel = undefined;
|
|
132
|
+
this.definitionCache = [];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
FullReset() {
|
|
136
|
+
this.Reset();
|
|
137
|
+
this.objects = [];
|
|
138
|
+
this.definitionCache = [];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -1,144 +1,145 @@
|
|
|
1
|
-
import isObject from
|
|
1
|
+
import isObject from 'lodash/isObject';
|
|
2
2
|
|
|
3
|
-
import ConvertTo from
|
|
4
|
-
import ConvertToArray from
|
|
5
|
-
import ConvertToDate from
|
|
6
|
-
import ConvertToString from
|
|
7
|
-
import ConvertToTime from
|
|
3
|
+
import ConvertTo from './converter/ConvertTo';
|
|
4
|
+
import ConvertToArray from './converter/ConvertToArray';
|
|
5
|
+
import ConvertToDate from './converter/ConvertToDate';
|
|
6
|
+
import ConvertToString from './converter/ConvertToString';
|
|
7
|
+
import ConvertToTime from './converter/ConvertToTime';
|
|
8
8
|
|
|
9
9
|
export default class TagDefinition {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
this.Property = plainJsObject.Property;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (plainJsObject.Replace) {
|
|
30
|
-
this.Replace = new ReplaceValue(plainJsObject.Replace.Value, plainJsObject.Replace.With);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (plainJsObject.StripHtml) {
|
|
34
|
-
this.StripHtml = plainJsObject.StripHtml;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
this.ConvertTo = CreateConvertTo(plainJsObject.Type, plainJsObject.ConvertTo);
|
|
10
|
+
constructor(plainJsObject: any) {
|
|
11
|
+
this.CollectAs = plainJsObject.CollectAs;
|
|
12
|
+
this.Tag = plainJsObject.Tag;
|
|
13
|
+
this.MergeWithLast = plainJsObject.MergeWithLast?.toString();
|
|
14
|
+
this.MergeWithNext = plainJsObject.MergeWithNext;
|
|
15
|
+
this.Type = plainJsObject.Type;
|
|
16
|
+
this.IsSingleValue = plainJsObject.IsSingleValue;
|
|
17
|
+
this.CollectAsArray = plainJsObject.CollectAsArray === true;
|
|
18
|
+
this.StartWith = plainJsObject.StartWith;
|
|
19
|
+
|
|
20
|
+
if (isObject(plainJsObject.Property)) {
|
|
21
|
+
let propertyWithOption = new PropertyWithOption(plainJsObject.Property);
|
|
22
|
+
this.Property = propertyWithOption.Name;
|
|
23
|
+
this.PropertyType = propertyWithOption.Type;
|
|
24
|
+
} else {
|
|
25
|
+
this.Property = plainJsObject.Property;
|
|
38
26
|
}
|
|
39
27
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
CollectAsArray?: Boolean;
|
|
43
|
-
Property?: string;
|
|
44
|
-
Tag: string = "";
|
|
45
|
-
MergeWithLast?: string;
|
|
46
|
-
Replace?: ReplaceValue;
|
|
47
|
-
StripHtml?: Boolean;
|
|
48
|
-
ConvertTo?: ConvertTo;
|
|
49
|
-
Type?: string;
|
|
50
|
-
MergeWithNext?: string;
|
|
51
|
-
IsSingleValue?: Boolean;
|
|
52
|
-
PropertyType?: ConvertTo;
|
|
53
|
-
|
|
54
|
-
get Path(): string {
|
|
55
|
-
return this.CollectAs ?? this.Property ?? "";
|
|
28
|
+
if (plainJsObject.Replace) {
|
|
29
|
+
this.Replace = new ReplaceValue(plainJsObject.Replace.Value, plainJsObject.Replace.With);
|
|
56
30
|
}
|
|
57
|
-
}
|
|
58
31
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
this.Value = value;
|
|
62
|
-
this.With = withProperty;
|
|
32
|
+
if (plainJsObject.StripHtml) {
|
|
33
|
+
this.StripHtml = plainJsObject.StripHtml;
|
|
63
34
|
}
|
|
64
35
|
|
|
65
|
-
|
|
66
|
-
|
|
36
|
+
this.ConvertTo = CreateConvertTo(plainJsObject.Type, plainJsObject.ConvertTo);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
CollectAs?: string;
|
|
40
|
+
StartWith?: string;
|
|
41
|
+
CollectAsArray?: Boolean;
|
|
42
|
+
Property?: string;
|
|
43
|
+
Tag: string = '';
|
|
44
|
+
MergeWithLast?: string;
|
|
45
|
+
Replace?: ReplaceValue;
|
|
46
|
+
StripHtml?: Boolean;
|
|
47
|
+
ConvertTo?: ConvertTo;
|
|
48
|
+
Type?: string;
|
|
49
|
+
MergeWithNext?: string;
|
|
50
|
+
IsSingleValue?: Boolean;
|
|
51
|
+
PropertyType?: ConvertTo;
|
|
52
|
+
|
|
53
|
+
get Path(): string {
|
|
54
|
+
return this.CollectAs ?? this.Property ?? '';
|
|
55
|
+
}
|
|
67
56
|
}
|
|
68
57
|
|
|
69
|
-
class
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
this.Type = CreateConvertTo(property.Type);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
this.Type = CreateConvertTo(undefined, property.ConvertTo);
|
|
79
|
-
}
|
|
58
|
+
class ReplaceValue {
|
|
59
|
+
constructor(value: string, withProperty: string) {
|
|
60
|
+
this.Value = value;
|
|
61
|
+
this.With = withProperty;
|
|
62
|
+
}
|
|
80
63
|
|
|
81
|
-
|
|
82
|
-
|
|
64
|
+
Value: string;
|
|
65
|
+
With: string;
|
|
83
66
|
}
|
|
84
67
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
convertTo?.Calculated,
|
|
89
|
-
convertTo?.Estimated,
|
|
90
|
-
convertTo?.Before,
|
|
91
|
-
convertTo?.After,
|
|
92
|
-
convertTo?.Between,
|
|
93
|
-
convertTo?.And,
|
|
94
|
-
convertTo?.Interpreted,
|
|
95
|
-
convertTo?.From,
|
|
96
|
-
convertTo?.To,
|
|
97
|
-
convertTo?.Value,
|
|
98
|
-
convertTo?.HasMonth,
|
|
99
|
-
convertTo?.HasYear,
|
|
100
|
-
convertTo?.HasDay,
|
|
101
|
-
convertTo?.Original,
|
|
102
|
-
convertTo?.Calendar);
|
|
103
|
-
}
|
|
68
|
+
class PropertyWithOption {
|
|
69
|
+
constructor(property: any) {
|
|
70
|
+
this.Name = property.Name;
|
|
104
71
|
|
|
105
|
-
|
|
106
|
-
|
|
72
|
+
if (property.Type) {
|
|
73
|
+
this.Type = CreateConvertTo(property.Type);
|
|
74
|
+
return;
|
|
107
75
|
}
|
|
108
76
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
77
|
+
this.Type = CreateConvertTo(undefined, property.ConvertTo);
|
|
78
|
+
}
|
|
112
79
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
80
|
+
Name?: string;
|
|
81
|
+
Type?: ConvertTo;
|
|
82
|
+
}
|
|
116
83
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
84
|
+
function CreateConvertTo(type?: string, convertTo?: any): ConvertTo | undefined {
|
|
85
|
+
let setConvertToDate = (): ConvertToDate => {
|
|
86
|
+
return new ConvertToDate(
|
|
87
|
+
convertTo?.About,
|
|
88
|
+
convertTo?.Calculated,
|
|
89
|
+
convertTo?.Estimated,
|
|
90
|
+
convertTo?.Before,
|
|
91
|
+
convertTo?.After,
|
|
92
|
+
convertTo?.Between,
|
|
93
|
+
convertTo?.And,
|
|
94
|
+
convertTo?.Interpreted,
|
|
95
|
+
convertTo?.From,
|
|
96
|
+
convertTo?.To,
|
|
97
|
+
convertTo?.Value,
|
|
98
|
+
convertTo?.HasMonth,
|
|
99
|
+
convertTo?.HasYear,
|
|
100
|
+
convertTo?.HasDay,
|
|
101
|
+
convertTo?.Original,
|
|
102
|
+
convertTo?.Calendar
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
let setConvertToString = (): ConvertToString => {
|
|
107
|
+
return new ConvertToString(convertTo?.NewLineCharacter, convertTo?.NewLineIfEmpty);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
let setConvertToArray = (): ConvertToArray => {
|
|
111
|
+
return new ConvertToArray(convertTo?.Delimiter);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
let setConvertToTime = (): ConvertToTime => {
|
|
115
|
+
return new ConvertToTime();
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
if (type) {
|
|
119
|
+
switch (type) {
|
|
120
|
+
case 'Date':
|
|
121
|
+
return setConvertToDate();
|
|
122
|
+
case 'String':
|
|
123
|
+
return setConvertToString();
|
|
124
|
+
case 'Array':
|
|
125
|
+
return setConvertToArray();
|
|
126
|
+
case 'Time':
|
|
127
|
+
return setConvertToTime();
|
|
128
128
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (convertTo) {
|
|
132
|
+
switch (convertTo.Type) {
|
|
133
|
+
case 'String':
|
|
134
|
+
return setConvertToString();
|
|
135
|
+
case 'Date':
|
|
136
|
+
return setConvertToDate();
|
|
137
|
+
case 'Array':
|
|
138
|
+
return setConvertToArray();
|
|
139
|
+
case 'Time':
|
|
140
|
+
return setConvertToTime();
|
|
141
141
|
}
|
|
142
|
+
}
|
|
142
143
|
|
|
143
|
-
|
|
144
|
-
}
|
|
144
|
+
return;
|
|
145
|
+
}
|