definition-generator-framework 1.13.1 → 2.0.0-rc1
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.d.mts +204 -0
- package/dist/index.d.ts +204 -17
- package/dist/index.js +43 -50
- package/dist/index.mjs +43 -0
- package/package.json +28 -14
- package/dist/_mocks/mocks.d.ts +0 -7
- package/dist/_mocks/mocks.js +0 -44
- package/dist/decorators/definition-component.d.ts +0 -18
- package/dist/decorators/definition-component.js +0 -52
- package/dist/decorators/definition-generator.d.ts +0 -11
- package/dist/decorators/definition-generator.js +0 -30
- package/dist/framework/context.d.ts +0 -24
- package/dist/framework/context.js +0 -64
- package/dist/framework/definition-component.d.ts +0 -20
- package/dist/framework/definition-component.js +0 -29
- package/dist/framework/definition-generator.d.ts +0 -11
- package/dist/framework/definition-generator.js +0 -22
- package/dist/framework/definition-store.d.ts +0 -25
- package/dist/framework/definition-store.js +0 -121
- package/dist/framework/file-content-generator/file-content-generator.d.ts +0 -19
- package/dist/framework/file-content-generator/file-content-generator.js +0 -117
- package/dist/framework/file-content-generator/file-content-generator.test.d.ts +0 -24
- package/dist/framework/file-content-generator/file-content-generator.test.js +0 -161
- package/dist/framework/file-generators/index-file-generator.d.ts +0 -13
- package/dist/framework/file-generators/index-file-generator.js +0 -139
- package/dist/framework/file-generators/types-file-generator.d.ts +0 -6
- package/dist/framework/file-generators/types-file-generator.js +0 -35
- package/dist/framework/framework.d.ts +0 -28
- package/dist/framework/framework.data.d.ts +0 -6
- package/dist/framework/framework.data.js +0 -17
- package/dist/framework/framework.js +0 -51
- package/dist/framework/framework.model.d.ts +0 -32
- package/dist/framework/framework.model.js +0 -3
- package/dist/framework/index-file-generator/index-file-generator.d.ts +0 -10
- package/dist/framework/index-file-generator/index-file-generator.js +0 -118
- package/dist/framework/interfaces.d.ts +0 -46
- package/dist/framework/interfaces.js +0 -3
- package/dist/framework/kernel.d.ts +0 -12
- package/dist/framework/kernel.js +0 -308
- package/dist/helpers/common-functions/common-functions.d.ts +0 -10
- package/dist/helpers/common-functions/common-functions.js +0 -29
- package/dist/helpers/common-functions/common-functions.spec.d.ts +0 -1
- package/dist/helpers/common-functions/common-functions.spec.js +0 -50
- package/dist/helpers/common-functions/common-functions.test.d.ts +0 -1
- package/dist/helpers/common-functions/common-functions.test.js +0 -51
- package/dist/helpers/duplicate-helper/duplicate-helper.d.ts +0 -11
- package/dist/helpers/duplicate-helper/duplicate-helper.js +0 -40
- package/dist/helpers/duplicate-helper/duplicate-helper.spec.d.ts +0 -1
- package/dist/helpers/duplicate-helper/duplicate-helper.spec.js +0 -54
- package/dist/helpers/duplicate-helper/duplicate-helper.test.d.ts +0 -1
- package/dist/helpers/duplicate-helper/duplicate-helper.test.js +0 -55
- package/dist/helpers/output-helper/output-helper.d.ts +0 -30
- package/dist/helpers/output-helper/output-helper.js +0 -143
- package/dist/helpers/output-helper/output-helper.spec.d.ts +0 -24
- package/dist/helpers/output-helper/output-helper.spec.js +0 -261
- package/dist/helpers/output-helper/output-helper.test.d.ts +0 -24
- package/dist/helpers/output-helper/output-helper.test.js +0 -262
- package/dist/helpers/raw-definition-helper/raw-definition.helper.d.ts +0 -7
- package/dist/helpers/raw-definition-helper/raw-definition.helper.js +0 -66
- package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.d.ts +0 -1
- package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.js +0 -143
- package/dist/helpers/raw-definition-helper/raw-definition.helper.test.d.ts +0 -1
- package/dist/helpers/raw-definition-helper/raw-definition.helper.test.js +0 -136
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.d.ts +0 -16
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.js +0 -48
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.d.ts +0 -1
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.js +0 -191
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.test.d.ts +0 -1
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.test.js +0 -213
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.d.ts +0 -13
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.js +0 -53
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.test.d.ts +0 -1
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.test.js +0 -96
- package/dist/helpers/validator/custom-validators/image.custom-validator.d.ts +0 -14
- package/dist/helpers/validator/custom-validators/image.custom-validator.js +0 -44
- package/dist/helpers/validator/custom-validators/path.custom-validator.d.ts +0 -9
- package/dist/helpers/validator/custom-validators/path.custom-validator.js +0 -30
- package/dist/helpers/validator/custom-validators/position-on-sprite.d.ts +0 -14
- package/dist/helpers/validator/custom-validators/position-on-sprite.js +0 -44
- package/dist/helpers/validator/custom-validators/reference.custom-validator.d.ts +0 -22
- package/dist/helpers/validator/custom-validators/reference.custom-validator.js +0 -123
- package/dist/helpers/validator/custom-validators/sprite.custom-validator.d.ts +0 -14
- package/dist/helpers/validator/custom-validators/sprite.custom-validator.js +0 -43
- package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.d.ts +0 -9
- package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.js +0 -33
- package/dist/helpers/validator/custom-validators/unique.custom-validator.d.ts +0 -8
- package/dist/helpers/validator/custom-validators/unique.custom-validator.js +0 -20
- package/dist/helpers/validator/joi-custom-validators.d.ts +0 -33
- package/dist/helpers/validator/joi-custom-validators.js +0 -54
- package/dist/helpers/validator/joi-custom-validators.spec.d.ts +0 -1
- package/dist/helpers/validator/joi-custom-validators.spec.js +0 -304
- package/dist/helpers/validator/validator.d.ts +0 -21
- package/dist/helpers/validator/validator.js +0 -74
- package/dist/helpers/validator/validator.spec.d.ts +0 -1
- package/dist/helpers/validator/validator.spec.js +0 -332
- package/dist/helpers/validator/validator.test.d.ts +0 -1
- package/dist/helpers/validator/validator.test.js +0 -329
- package/dist/pipeline/1-select-definitions-helper.d.ts +0 -20
- package/dist/pipeline/1-select-definitions-helper.js +0 -76
- package/dist/pipeline/1-select-definitions.helper.d.ts +0 -20
- package/dist/pipeline/1-select-definitions.helper.js +0 -80
- package/dist/pipeline/1-select-definitions.helper.test.d.ts +0 -1
- package/dist/pipeline/1-select-definitions.helper.test.js +0 -141
- package/dist/pipeline/1-select-definitions.spec.d.ts +0 -1
- package/dist/pipeline/1-select-definitions.spec.js +0 -140
- package/dist/pipeline/2-structure-parser.helper.d.ts +0 -11
- package/dist/pipeline/2-structure-parser.helper.js +0 -70
- package/dist/pipeline/2-structure-parser.helper.spec.d.ts +0 -1
- package/dist/pipeline/2-structure-parser.helper.spec.js +0 -280
- package/dist/pipeline/2-structure-parser.helper.test.d.ts +0 -1
- package/dist/pipeline/2-structure-parser.helper.test.js +0 -281
- package/dist/pipeline/3-config.d.ts +0 -9
- package/dist/pipeline/3-config.js +0 -36
- package/dist/pipeline/_mocks/index.d.ts +0 -13
- package/dist/pipeline/_mocks/index.js +0 -52
- package/dist/pipeline/parsers/array-parser.d.ts +0 -4
- package/dist/pipeline/parsers/array-parser.js +0 -69
- package/dist/pipeline/parsers/array-parser.spec.d.ts +0 -1
- package/dist/pipeline/parsers/array-parser.spec.js +0 -128
- package/dist/pipeline/parsers/array-parser.test.d.ts +0 -1
- package/dist/pipeline/parsers/array-parser.test.js +0 -126
- package/dist/pipeline/parsers/object-parser.d.ts +0 -4
- package/dist/pipeline/parsers/object-parser.js +0 -135
- package/dist/pipeline/parsers/object-parser.spec.d.ts +0 -1
- package/dist/pipeline/parsers/object-parser.spec.js +0 -179
- package/dist/pipeline/parsers/object-parser.test.d.ts +0 -1
- package/dist/pipeline/parsers/object-parser.test.js +0 -186
- package/dist/pipeline/parsers/primitive-parser.d.ts +0 -7
- package/dist/pipeline/parsers/primitive-parser.js +0 -111
- package/dist/pipeline/parsers/primitive-parser.spec.d.ts +0 -1
- package/dist/pipeline/parsers/primitive-parser.spec.js +0 -79
- package/dist/pipeline/parsers/primitive-parser.test.d.ts +0 -1
- package/dist/pipeline/parsers/primitive-parser.test.js +0 -85
- package/dist/pipeline/raw-data-parser.d.ts +0 -5
- package/dist/pipeline/raw-data-parser.js +0 -25
- package/dist/pre-made-components/_validators/shape-validators.d.ts +0 -7
- package/dist/pre-made-components/_validators/shape-validators.js +0 -37
- package/dist/pre-made-components/_validators/sprite-validators.d.ts +0 -7
- package/dist/pre-made-components/_validators/sprite-validators.js +0 -43
- package/dist/pre-made-components/assets/1-sprite.d.ts +0 -15
- package/dist/pre-made-components/assets/1-sprite.js +0 -74
- package/dist/pre-made-components/assets/2-sprite-group.d.ts +0 -11
- package/dist/pre-made-components/assets/2-sprite-group.js +0 -41
- package/dist/pre-made-components/assets/3-font.d.ts +0 -17
- package/dist/pre-made-components/assets/3-font.js +0 -71
- package/dist/pre-made-components/events/1-event.d.ts +0 -6
- package/dist/pre-made-components/events/1-event.js +0 -206
- package/dist/pre-made-components/events/1-script.d.ts +0 -8
- package/dist/pre-made-components/events/1-script.js +0 -102
- package/dist/pre-made-components/events/2-event-test.d.ts +0 -18
- package/dist/pre-made-components/events/2-event-test.js +0 -172
- package/dist/pre-made-components/events/2-script-test.d.ts +0 -7
- package/dist/pre-made-components/events/2-script-test.js +0 -102
- package/dist/pre-made-components/events/3-event.d.ts +0 -7
- package/dist/pre-made-components/events/3-event.js +0 -100
- package/dist/pre-made-components/events/4-event-test.d.ts +0 -7
- package/dist/pre-made-components/events/4-event-test.js +0 -89
- package/dist/pre-made-components/events/event-setup.d.ts +0 -13
- package/dist/pre-made-components/events/event-setup.js +0 -20
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.d.ts +0 -3
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.js +0 -24
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.test.d.ts +0 -1
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.test.js +0 -39
- package/dist/pre-made-components/events/helpers/script-testing.helper.d.ts +0 -33
- package/dist/pre-made-components/events/helpers/script-testing.helper.js +0 -79
- package/dist/pre-made-components/events/script-setup.d.ts +0 -8
- package/dist/pre-made-components/events/script-setup.js +0 -16
- package/dist/pre-made-components/events/scripting-setup.d.ts +0 -33
- package/dist/pre-made-components/events/scripting-setup.js +0 -97
- package/dist/pre-made-components/events/validators.d.ts +0 -6
- package/dist/pre-made-components/events/validators.js +0 -96
- package/dist/setup.d.ts +0 -1
- package/dist/setup.js +0 -10
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ArrayParser = void 0;
|
|
4
|
-
const _2_structure_parser_helper_1 = require("../2-structure-parser.helper");
|
|
5
|
-
class ArrayParser {
|
|
6
|
-
static parse(content, location) {
|
|
7
|
-
let unparsedContent = [];
|
|
8
|
-
let unparsedContentStart = location.line;
|
|
9
|
-
let children = [];
|
|
10
|
-
content.forEach((row, index) => {
|
|
11
|
-
if (!row.startsWith(' ')) {
|
|
12
|
-
if (row.match(/^- {2}/g) || row.match(/^-[\S]/g)) {
|
|
13
|
-
let errorLog = {
|
|
14
|
-
description: `There should be one space after dash operator! "${row}"`,
|
|
15
|
-
location: { line: location.line + index, path: location.path }
|
|
16
|
-
};
|
|
17
|
-
throw errorLog;
|
|
18
|
-
}
|
|
19
|
-
else if (!row.startsWith('-')) {
|
|
20
|
-
if (row.startsWith(' ')) {
|
|
21
|
-
let errorLog = {
|
|
22
|
-
description: `Invalid coding indent!`,
|
|
23
|
-
location: { line: location.line + index, path: location.path }
|
|
24
|
-
};
|
|
25
|
-
throw errorLog;
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
let errorLog = {
|
|
29
|
-
description: `Unexpected array element! "${row}"`,
|
|
30
|
-
location: { line: location.line + index, path: location.path }
|
|
31
|
-
};
|
|
32
|
-
throw errorLog;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
if (unparsedContent.length) {
|
|
37
|
-
let child = _2_structure_parser_helper_1.StructureParserHelper.getParsedStructure(unparsedContent, {
|
|
38
|
-
line: unparsedContentStart,
|
|
39
|
-
path: location.path
|
|
40
|
-
});
|
|
41
|
-
children.push(child);
|
|
42
|
-
}
|
|
43
|
-
unparsedContent = [row.substring(2)];
|
|
44
|
-
unparsedContentStart = location.line + index;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
else if (index === 0) {
|
|
48
|
-
let errorLog = {
|
|
49
|
-
description: `Invalid coding indent!`,
|
|
50
|
-
location: { line: location.line + index, path: location.path }
|
|
51
|
-
};
|
|
52
|
-
throw errorLog;
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
unparsedContent.push(row.substring(2));
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
if (unparsedContent.length) {
|
|
59
|
-
let child = _2_structure_parser_helper_1.StructureParserHelper.getParsedStructure(unparsedContent, { line: unparsedContentStart, path: location.path });
|
|
60
|
-
children.push(child);
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
line: location.line,
|
|
64
|
-
rawData: children
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
exports.ArrayParser = ArrayParser;
|
|
69
|
-
//# sourceMappingURL=array-parser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
const _mocks_1 = require('../_mocks');
|
|
4
|
-
const array_parser_1 = require('./array-parser');
|
|
5
|
-
const mocks_1 = require('../../_mocks/mocks');
|
|
6
|
-
describe('ARRAY PARSER', () => {
|
|
7
|
-
test('basic', () => {
|
|
8
|
-
let result = array_parser_1.ArrayParser.parse(['- orange', '- banana'], mocks_1.SampleLocation1);
|
|
9
|
-
expect(result).toStrictEqual({
|
|
10
|
-
line: mocks_1.SampleLocation1.line,
|
|
11
|
-
rawData: [
|
|
12
|
-
{
|
|
13
|
-
line: mocks_1.SampleLocation1.line,
|
|
14
|
-
rawData: 'orange'
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
line: mocks_1.SampleLocation1.line + 1,
|
|
18
|
-
rawData: 'banana'
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
test('array contains array', () => {
|
|
24
|
-
let result = array_parser_1.ArrayParser.parse(['- - orange', ' - banana', '- - 1', ' - 2'], mocks_1.SampleLocation1);
|
|
25
|
-
expect(result).toStrictEqual({
|
|
26
|
-
line: mocks_1.SampleLocation1.line,
|
|
27
|
-
rawData: [
|
|
28
|
-
{
|
|
29
|
-
line: mocks_1.SampleLocation1.line,
|
|
30
|
-
rawData: [
|
|
31
|
-
{
|
|
32
|
-
line: mocks_1.SampleLocation1.line,
|
|
33
|
-
rawData: 'orange'
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
line: mocks_1.SampleLocation1.line + 1,
|
|
37
|
-
rawData: 'banana'
|
|
38
|
-
}
|
|
39
|
-
]
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
line: mocks_1.SampleLocation1.line + 2,
|
|
43
|
-
rawData: [
|
|
44
|
-
{
|
|
45
|
-
line: mocks_1.SampleLocation1.line + 2,
|
|
46
|
-
rawData: '1'
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
line: mocks_1.SampleLocation1.line + 3,
|
|
50
|
-
rawData: '2'
|
|
51
|
-
}
|
|
52
|
-
]
|
|
53
|
-
}
|
|
54
|
-
]
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
test('array contains object', () => {
|
|
58
|
-
let result = array_parser_1.ArrayParser.parse(
|
|
59
|
-
['- Name: arrow', ' Quantity: 4', '- Name: axe', ' Quantity: 1'],
|
|
60
|
-
mocks_1.SampleLocation1
|
|
61
|
-
);
|
|
62
|
-
expect(result).toStrictEqual({
|
|
63
|
-
line: mocks_1.SampleLocation1.line,
|
|
64
|
-
rawData: [
|
|
65
|
-
{
|
|
66
|
-
line: mocks_1.SampleLocation1.line,
|
|
67
|
-
rawData: {
|
|
68
|
-
name: {
|
|
69
|
-
line: mocks_1.SampleLocation1.line,
|
|
70
|
-
rawData: 'arrow'
|
|
71
|
-
},
|
|
72
|
-
quantity: {
|
|
73
|
-
line: mocks_1.SampleLocation1.line + 1,
|
|
74
|
-
rawData: '4'
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
line: mocks_1.SampleLocation1.line + 2,
|
|
80
|
-
rawData: {
|
|
81
|
-
name: {
|
|
82
|
-
line: mocks_1.SampleLocation1.line + 2,
|
|
83
|
-
rawData: 'axe'
|
|
84
|
-
},
|
|
85
|
-
quantity: {
|
|
86
|
-
line: mocks_1.SampleLocation1.line + 3,
|
|
87
|
-
rawData: '1'
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
]
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
describe('ARRAY PARSER - Error Detection', () => {
|
|
96
|
-
let expectErrorHelper = new _mocks_1.ExpectErrorHelper(array_parser_1.ArrayParser);
|
|
97
|
-
test.each(['-text', '- text'])('one space after dash, first line "%s"', item => {
|
|
98
|
-
expectErrorHelper.expect([item], {
|
|
99
|
-
description: `There should be one space after dash operator! "${item}"`,
|
|
100
|
-
location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
test.each(['-text', '- text'])('one space after dash, second line "%s"', item => {
|
|
104
|
-
expectErrorHelper.expect(['- item', item], {
|
|
105
|
-
description: `There should be one space after dash operator! "${item}"`,
|
|
106
|
-
location: { line: mocks_1.SampleLocation1.line + 1, path: mocks_1.SampleLocation1.path }
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
test('unexpected array element', () => {
|
|
110
|
-
expectErrorHelper.expect(['- item', 'Name: axe'], {
|
|
111
|
-
description: `Unexpected array element! "Name: axe"`,
|
|
112
|
-
location: { line: mocks_1.SampleLocation1.line + 1, path: mocks_1.SampleLocation1.path }
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
test('invalid coding indent', () => {
|
|
116
|
-
expectErrorHelper.expect([' - item'], {
|
|
117
|
-
description: `Invalid coding indent!`,
|
|
118
|
-
location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
test('invalid coding indent', () => {
|
|
122
|
-
expectErrorHelper.expect([' - item'], {
|
|
123
|
-
description: `Invalid coding indent!`,
|
|
124
|
-
location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
//# sourceMappingURL=array-parser.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const vitest_1 = require("vitest");
|
|
4
|
-
const mocks_1 = require("../../_mocks/mocks");
|
|
5
|
-
const _mocks_1 = require("../_mocks");
|
|
6
|
-
const array_parser_1 = require("./array-parser");
|
|
7
|
-
(0, vitest_1.describe)('ARRAY PARSER', () => {
|
|
8
|
-
(0, vitest_1.test)('basic', () => {
|
|
9
|
-
let result = array_parser_1.ArrayParser.parse(['- orange', '- banana'], mocks_1.SampleLocation1);
|
|
10
|
-
(0, vitest_1.expect)(result).toStrictEqual({
|
|
11
|
-
line: mocks_1.SampleLocation1.line,
|
|
12
|
-
rawData: [
|
|
13
|
-
{
|
|
14
|
-
line: mocks_1.SampleLocation1.line,
|
|
15
|
-
rawData: 'orange'
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
line: mocks_1.SampleLocation1.line + 1,
|
|
19
|
-
rawData: 'banana'
|
|
20
|
-
}
|
|
21
|
-
]
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
(0, vitest_1.test)('array contains array', () => {
|
|
25
|
-
let result = array_parser_1.ArrayParser.parse(['- - orange', ' - banana', '- - 1', ' - 2'], mocks_1.SampleLocation1);
|
|
26
|
-
(0, vitest_1.expect)(result).toStrictEqual({
|
|
27
|
-
line: mocks_1.SampleLocation1.line,
|
|
28
|
-
rawData: [
|
|
29
|
-
{
|
|
30
|
-
line: mocks_1.SampleLocation1.line,
|
|
31
|
-
rawData: [
|
|
32
|
-
{
|
|
33
|
-
line: mocks_1.SampleLocation1.line,
|
|
34
|
-
rawData: 'orange'
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
line: mocks_1.SampleLocation1.line + 1,
|
|
38
|
-
rawData: 'banana'
|
|
39
|
-
}
|
|
40
|
-
]
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
line: mocks_1.SampleLocation1.line + 2,
|
|
44
|
-
rawData: [
|
|
45
|
-
{
|
|
46
|
-
line: mocks_1.SampleLocation1.line + 2,
|
|
47
|
-
rawData: '1'
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
line: mocks_1.SampleLocation1.line + 3,
|
|
51
|
-
rawData: '2'
|
|
52
|
-
}
|
|
53
|
-
]
|
|
54
|
-
}
|
|
55
|
-
]
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
(0, vitest_1.test)('array contains object', () => {
|
|
59
|
-
let result = array_parser_1.ArrayParser.parse(['- Name: arrow', ' Quantity: 4', '- Name: axe', ' Quantity: 1'], mocks_1.SampleLocation1);
|
|
60
|
-
(0, vitest_1.expect)(result).toStrictEqual({
|
|
61
|
-
line: mocks_1.SampleLocation1.line,
|
|
62
|
-
rawData: [
|
|
63
|
-
{
|
|
64
|
-
line: mocks_1.SampleLocation1.line,
|
|
65
|
-
rawData: {
|
|
66
|
-
name: {
|
|
67
|
-
line: mocks_1.SampleLocation1.line,
|
|
68
|
-
rawData: 'arrow'
|
|
69
|
-
},
|
|
70
|
-
quantity: {
|
|
71
|
-
line: mocks_1.SampleLocation1.line + 1,
|
|
72
|
-
rawData: '4'
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
line: mocks_1.SampleLocation1.line + 2,
|
|
78
|
-
rawData: {
|
|
79
|
-
name: {
|
|
80
|
-
line: mocks_1.SampleLocation1.line + 2,
|
|
81
|
-
rawData: 'axe'
|
|
82
|
-
},
|
|
83
|
-
quantity: {
|
|
84
|
-
line: mocks_1.SampleLocation1.line + 3,
|
|
85
|
-
rawData: '1'
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
]
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
(0, vitest_1.describe)('ARRAY PARSER - Error Detection', () => {
|
|
94
|
-
let expectErrorHelper = new _mocks_1.ExpectErrorHelper(array_parser_1.ArrayParser);
|
|
95
|
-
vitest_1.test.each(['-text', '- text'])('one space after dash, first line "%s"', (item) => {
|
|
96
|
-
expectErrorHelper.expect([item], {
|
|
97
|
-
description: `There should be one space after dash operator! "${item}"`,
|
|
98
|
-
location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
vitest_1.test.each(['-text', '- text'])('one space after dash, second line "%s"', (item) => {
|
|
102
|
-
expectErrorHelper.expect(['- item', item], {
|
|
103
|
-
description: `There should be one space after dash operator! "${item}"`,
|
|
104
|
-
location: { line: mocks_1.SampleLocation1.line + 1, path: mocks_1.SampleLocation1.path }
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
(0, vitest_1.test)('unexpected array element', () => {
|
|
108
|
-
expectErrorHelper.expect(['- item', 'Name: axe'], {
|
|
109
|
-
description: `Unexpected array element! "Name: axe"`,
|
|
110
|
-
location: { line: mocks_1.SampleLocation1.line + 1, path: mocks_1.SampleLocation1.path }
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
(0, vitest_1.test)('invalid coding indent', () => {
|
|
114
|
-
expectErrorHelper.expect([' - item'], {
|
|
115
|
-
description: `Invalid coding indent!`,
|
|
116
|
-
location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
(0, vitest_1.test)('invalid coding indent', () => {
|
|
120
|
-
expectErrorHelper.expect([' - item'], {
|
|
121
|
-
description: `Invalid coding indent!`,
|
|
122
|
-
location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
//# sourceMappingURL=array-parser.test.js.map
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ObjectParser = void 0;
|
|
4
|
-
const common_functions_1 = require("../../helpers/common-functions/common-functions");
|
|
5
|
-
const _2_structure_parser_helper_1 = require("../2-structure-parser.helper");
|
|
6
|
-
class ObjectParser {
|
|
7
|
-
static parse(content, location) {
|
|
8
|
-
let unparsedContent = [];
|
|
9
|
-
let unparsedContentKey = '';
|
|
10
|
-
let unparsedContentStart = 0;
|
|
11
|
-
let unparsedContentType;
|
|
12
|
-
let children = {};
|
|
13
|
-
content.forEach((row, index) => {
|
|
14
|
-
if (!row.startsWith(' ') && !row.startsWith('- ') && unparsedContentType !== 'multiLineString') {
|
|
15
|
-
if (row.startsWith(':')) {
|
|
16
|
-
let errorLog = {
|
|
17
|
-
description: `Invalid row, row cannot start with columns! "${row}"`,
|
|
18
|
-
location: { line: location.line + index, path: location.path }
|
|
19
|
-
};
|
|
20
|
-
throw errorLog;
|
|
21
|
-
}
|
|
22
|
-
else if (row.match(/[\w]*:[\w]*:/g)) {
|
|
23
|
-
let errorLog = {
|
|
24
|
-
description: `Invalid row, multiple columns! "${row}"`,
|
|
25
|
-
location: { line: location.line + index, path: location.path }
|
|
26
|
-
};
|
|
27
|
-
throw errorLog;
|
|
28
|
-
}
|
|
29
|
-
else if (row.match(/: {2}/g) || row.match(/^[\w]+:[\S]/g)) {
|
|
30
|
-
let errorLog = {
|
|
31
|
-
description: `There should be one space after column operator! "${row}"`,
|
|
32
|
-
location: { line: location.line + index, path: location.path }
|
|
33
|
-
};
|
|
34
|
-
throw errorLog;
|
|
35
|
-
}
|
|
36
|
-
else if (row.startsWith(' ')) {
|
|
37
|
-
let errorLog = {
|
|
38
|
-
description: `Invalid coding indent! "${row}"`,
|
|
39
|
-
location: { line: location.line + index, path: location.path }
|
|
40
|
-
};
|
|
41
|
-
throw errorLog;
|
|
42
|
-
}
|
|
43
|
-
else if (row.indexOf(':') === -1) {
|
|
44
|
-
let errorLog = {
|
|
45
|
-
description: `Unexpected object element! "${row}"`,
|
|
46
|
-
location: { line: location.line + index, path: location.path }
|
|
47
|
-
};
|
|
48
|
-
throw errorLog;
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
if (unparsedContent.length) {
|
|
52
|
-
let child = _2_structure_parser_helper_1.StructureParserHelper.getParsedStructure(unparsedContent, {
|
|
53
|
-
line: unparsedContentStart,
|
|
54
|
-
path: location.path
|
|
55
|
-
});
|
|
56
|
-
child.line -= 1;
|
|
57
|
-
children[unparsedContentKey] = child;
|
|
58
|
-
unparsedContent = [];
|
|
59
|
-
unparsedContentKey = '';
|
|
60
|
-
unparsedContentStart = 0;
|
|
61
|
-
}
|
|
62
|
-
let key = common_functions_1.CommonFunctions.lowerCaseFirstLetter(row.substring(0, row.indexOf(':')));
|
|
63
|
-
if (row.trimEnd().endsWith(':')) {
|
|
64
|
-
unparsedContentKey = key;
|
|
65
|
-
unparsedContentStart = location.line + index + 1;
|
|
66
|
-
if (!content[index + 1]) {
|
|
67
|
-
let errorLog = {
|
|
68
|
-
description: `No value found after column! "${row}"`,
|
|
69
|
-
location: { line: location.line + index, path: location.path }
|
|
70
|
-
};
|
|
71
|
-
throw errorLog;
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
let nextRow = content[index + 1];
|
|
75
|
-
unparsedContentType = nextRow.startsWith('-') ? 'array' : 'object';
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
else if (row.trimEnd().endsWith('`') && row.indexOf('`') === row.lastIndexOf('`')) {
|
|
79
|
-
unparsedContent.push('`');
|
|
80
|
-
unparsedContentKey = key;
|
|
81
|
-
unparsedContentStart = location.line + index + 1;
|
|
82
|
-
unparsedContentType = 'multiLineString';
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
let value = row.substring(row.indexOf(':') + 2);
|
|
86
|
-
let child = _2_structure_parser_helper_1.StructureParserHelper.getParsedStructure([value], { line: location.line + index, path: location.path });
|
|
87
|
-
children[key] = child;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
else if (index === 0) {
|
|
92
|
-
if (row.startsWith('-')) {
|
|
93
|
-
let errorLog = {
|
|
94
|
-
description: `Unexpected object element! "${row}"`,
|
|
95
|
-
location: { line: location.line + index, path: location.path }
|
|
96
|
-
};
|
|
97
|
-
throw errorLog;
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
let errorLog = {
|
|
101
|
-
description: `Invalid coding indent! "${row}"`,
|
|
102
|
-
location: { line: location.line + index, path: location.path }
|
|
103
|
-
};
|
|
104
|
-
throw errorLog;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
else if (row.startsWith('`')) {
|
|
108
|
-
unparsedContent.push(row);
|
|
109
|
-
let child = _2_structure_parser_helper_1.StructureParserHelper.getParsedStructure(unparsedContent, {
|
|
110
|
-
line: unparsedContentStart,
|
|
111
|
-
path: location.path
|
|
112
|
-
});
|
|
113
|
-
child.line -= 1;
|
|
114
|
-
children[unparsedContentKey] = child;
|
|
115
|
-
unparsedContent = [];
|
|
116
|
-
unparsedContentKey = '';
|
|
117
|
-
unparsedContentStart = 0;
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
unparsedContent.push(row.substring(unparsedContentType === 'object' ? 2 : 0));
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
if (unparsedContent.length) {
|
|
124
|
-
let child = _2_structure_parser_helper_1.StructureParserHelper.getParsedStructure(unparsedContent, { line: unparsedContentStart, path: location.path });
|
|
125
|
-
child.line -= 1;
|
|
126
|
-
children[unparsedContentKey] = child;
|
|
127
|
-
}
|
|
128
|
-
return {
|
|
129
|
-
line: location.line,
|
|
130
|
-
rawData: children
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
exports.ObjectParser = ObjectParser;
|
|
135
|
-
//# sourceMappingURL=object-parser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
const object_parser_1 = require('./object-parser');
|
|
4
|
-
const mocks_1 = require('../../_mocks/mocks');
|
|
5
|
-
const _mocks_1 = require('../_mocks');
|
|
6
|
-
describe('OBJECT PARSER', () => {
|
|
7
|
-
test('basic', () => {
|
|
8
|
-
let result = object_parser_1.ObjectParser.parse(['Name: axe', 'Quantity: 1'], mocks_1.SampleLocation1);
|
|
9
|
-
expect(result).toStrictEqual({
|
|
10
|
-
line: mocks_1.SampleLocation1.line,
|
|
11
|
-
rawData: {
|
|
12
|
-
name: {
|
|
13
|
-
line: mocks_1.SampleLocation1.line,
|
|
14
|
-
rawData: 'axe'
|
|
15
|
-
},
|
|
16
|
-
quantity: {
|
|
17
|
-
line: mocks_1.SampleLocation1.line + 1,
|
|
18
|
-
rawData: '1'
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
test('quote string value', () => {
|
|
24
|
-
let result = object_parser_1.ObjectParser.parse(['Path: "D:/test"'], mocks_1.SampleLocation1);
|
|
25
|
-
expect(result).toStrictEqual({
|
|
26
|
-
line: mocks_1.SampleLocation1.line,
|
|
27
|
-
rawData: {
|
|
28
|
-
path: {
|
|
29
|
-
line: mocks_1.SampleLocation1.line,
|
|
30
|
-
rawData: 'D:/test'
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
test('quote string value', () => {
|
|
36
|
-
let result = object_parser_1.ObjectParser.parse(['Str: `', 'text with space', 'text', '`'], mocks_1.SampleLocation1);
|
|
37
|
-
expect(result).toStrictEqual({
|
|
38
|
-
line: mocks_1.SampleLocation1.line,
|
|
39
|
-
rawData: {
|
|
40
|
-
str: {
|
|
41
|
-
line: mocks_1.SampleLocation1.line,
|
|
42
|
-
rawData: 'text with space\ntext'
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
test('object contains object', () => {
|
|
48
|
-
let result = object_parser_1.ObjectParser.parse(
|
|
49
|
-
['Attacker:', ' Name: firstObjectName', ' Age: 25', 'Defender:', ' Name: secondObjectName', ' Age: 35'],
|
|
50
|
-
mocks_1.SampleLocation1
|
|
51
|
-
);
|
|
52
|
-
expect(result).toStrictEqual({
|
|
53
|
-
line: mocks_1.SampleLocation1.line,
|
|
54
|
-
rawData: {
|
|
55
|
-
attacker: {
|
|
56
|
-
line: mocks_1.SampleLocation1.line,
|
|
57
|
-
rawData: {
|
|
58
|
-
name: {
|
|
59
|
-
line: mocks_1.SampleLocation1.line + 1,
|
|
60
|
-
rawData: 'firstObjectName'
|
|
61
|
-
},
|
|
62
|
-
age: {
|
|
63
|
-
line: mocks_1.SampleLocation1.line + 2,
|
|
64
|
-
rawData: '25'
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
defender: {
|
|
69
|
-
line: mocks_1.SampleLocation1.line + 3,
|
|
70
|
-
rawData: {
|
|
71
|
-
name: {
|
|
72
|
-
line: mocks_1.SampleLocation1.line + 4,
|
|
73
|
-
rawData: 'secondObjectName'
|
|
74
|
-
},
|
|
75
|
-
age: {
|
|
76
|
-
line: mocks_1.SampleLocation1.line + 5,
|
|
77
|
-
rawData: '35'
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
test('object contains array', () => {
|
|
85
|
-
let result = object_parser_1.ObjectParser.parse(
|
|
86
|
-
['Array1:', '- apple', '- orange', 'Array2:', '- xWing', '- tieFighter'],
|
|
87
|
-
mocks_1.SampleLocation1
|
|
88
|
-
);
|
|
89
|
-
expect(result).toStrictEqual({
|
|
90
|
-
line: mocks_1.SampleLocation1.line,
|
|
91
|
-
rawData: {
|
|
92
|
-
array1: {
|
|
93
|
-
line: mocks_1.SampleLocation1.line,
|
|
94
|
-
rawData: [
|
|
95
|
-
{
|
|
96
|
-
line: mocks_1.SampleLocation1.line + 1,
|
|
97
|
-
rawData: 'apple'
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
line: mocks_1.SampleLocation1.line + 2,
|
|
101
|
-
rawData: 'orange'
|
|
102
|
-
}
|
|
103
|
-
]
|
|
104
|
-
},
|
|
105
|
-
array2: {
|
|
106
|
-
line: mocks_1.SampleLocation1.line + 3,
|
|
107
|
-
rawData: [
|
|
108
|
-
{
|
|
109
|
-
line: mocks_1.SampleLocation1.line + 4,
|
|
110
|
-
rawData: 'xWing'
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
line: mocks_1.SampleLocation1.line + 5,
|
|
114
|
-
rawData: 'tieFighter'
|
|
115
|
-
}
|
|
116
|
-
]
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
describe('OBJECT PARSER - Error Detection', () => {
|
|
123
|
-
let expectErrorHelper = new _mocks_1.ExpectErrorHelper(object_parser_1.ObjectParser);
|
|
124
|
-
test.each(['Name:axe', 'Name: axe'])('one space after column, first line "%s"', item => {
|
|
125
|
-
expectErrorHelper.expect([item], {
|
|
126
|
-
description: `There should be one space after column operator! "${item}"`,
|
|
127
|
-
location: mocks_1.SampleLocation1
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
test('object cannot start with backtick', () => {
|
|
131
|
-
expectErrorHelper.expect(['`'], {
|
|
132
|
-
description: `Unexpected object element! "\`"`,
|
|
133
|
-
location: mocks_1.SampleLocation1
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
test('unexpected backtick', () => {
|
|
137
|
-
expectErrorHelper.expect(['Group:', '- item', '`'], {
|
|
138
|
-
description: `Unexpected object element! "\`"`,
|
|
139
|
-
location: { line: mocks_1.SampleLocation1.line + 2, path: mocks_1.SampleLocation1.path }
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
test.each(['Quantity:5', 'Quantity: 5'])('one space after column, second line "%s"', item => {
|
|
143
|
-
expectErrorHelper.expect(['Name: axe', item], {
|
|
144
|
-
description: `There should be one space after column operator! "${item}"`,
|
|
145
|
-
location: { line: mocks_1.SampleLocation1.line + 1, path: mocks_1.SampleLocation1.path }
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
test.each(['- apple', 'text'])('unexpected object element, "%s"', item => {
|
|
149
|
-
expectErrorHelper.expect([item], {
|
|
150
|
-
description: `Unexpected object element! "${item}"`,
|
|
151
|
-
location: mocks_1.SampleLocation1
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
test('multiple columns', () => {
|
|
155
|
-
expectErrorHelper.expect(['Name:something: axe'], {
|
|
156
|
-
description: `Invalid row, multiple columns! "Name:something: axe"`,
|
|
157
|
-
location: mocks_1.SampleLocation1
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
test('starting with column', () => {
|
|
161
|
-
expectErrorHelper.expect([':something: axe'], {
|
|
162
|
-
description: `Invalid row, row cannot start with columns! ":something: axe"`,
|
|
163
|
-
location: mocks_1.SampleLocation1
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
test.each([' Name: axe', ' Name: axe'])('invalid coding indent, "%s"', item => {
|
|
167
|
-
expectErrorHelper.expect([item], {
|
|
168
|
-
description: `Invalid coding indent! "${item}"`,
|
|
169
|
-
location: mocks_1.SampleLocation1
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
test('no value', () => {
|
|
173
|
-
expectErrorHelper.expect(['Name:'], {
|
|
174
|
-
description: `No value found after column! "Name:"`,
|
|
175
|
-
location: mocks_1.SampleLocation1
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
//# sourceMappingURL=object-parser.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|