definition-generator-framework 1.13.1 → 2.0.0-rc0
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 +198 -0
- package/dist/index.d.ts +198 -17
- package/dist/index.js +43 -50
- package/dist/index.mjs +43 -0
- package/package.json +27 -13
- 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,281 +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 _2_structure_parser_helper_1 = require("./2-structure-parser.helper");
|
|
6
|
-
function getMockDefinitionPlaneText(content) {
|
|
7
|
-
return {
|
|
8
|
-
type: 'ASSET',
|
|
9
|
-
content,
|
|
10
|
-
location: mocks_1.SampleLocation1
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
function getBaseRawDefinition(definitionPlaneText, parsedStructure) {
|
|
14
|
-
return {
|
|
15
|
-
componentName: definitionPlaneText.type,
|
|
16
|
-
location: definitionPlaneText.location,
|
|
17
|
-
parsedStructure: parsedStructure
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function getExpectedRawDefinition(expected, offset, definitionPlaneText) {
|
|
21
|
-
let rawDefinition = getBaseRawDefinition(definitionPlaneText, {
|
|
22
|
-
rawData: expected,
|
|
23
|
-
line: definitionPlaneText.location.line + offset
|
|
24
|
-
});
|
|
25
|
-
return rawDefinition;
|
|
26
|
-
}
|
|
27
|
-
(0, vitest_1.describe)('STRUCTURE PARSER HELPER', () => {
|
|
28
|
-
let structureParserHelper;
|
|
29
|
-
(0, vitest_1.beforeEach)(() => {
|
|
30
|
-
structureParserHelper = new _2_structure_parser_helper_1.StructureParserHelper();
|
|
31
|
-
});
|
|
32
|
-
(0, vitest_1.describe)('Primitive', () => {
|
|
33
|
-
(0, vitest_1.test)('empty content', () => {
|
|
34
|
-
let definitionPlaneText = getMockDefinitionPlaneText([]);
|
|
35
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
36
|
-
(0, vitest_1.expect)(result.rawDefinitions).toStrictEqual([]);
|
|
37
|
-
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
38
|
-
});
|
|
39
|
-
(0, vitest_1.test)('primitive string', () => {
|
|
40
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['text']);
|
|
41
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
42
|
-
(0, vitest_1.expect)(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('text', 1, definitionPlaneText)]);
|
|
43
|
-
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
44
|
-
});
|
|
45
|
-
(0, vitest_1.test)('primitive quoted string', () => {
|
|
46
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['"text with spaces"']);
|
|
47
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
48
|
-
(0, vitest_1.expect)(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('text with spaces', 1, definitionPlaneText)]);
|
|
49
|
-
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
50
|
-
});
|
|
51
|
-
(0, vitest_1.test)('primitive multiline string', () => {
|
|
52
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['`', 'text text', 'text', '`']);
|
|
53
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
54
|
-
(0, vitest_1.expect)(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('text text\ntext', 1, definitionPlaneText)]);
|
|
55
|
-
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
56
|
-
});
|
|
57
|
-
(0, vitest_1.test)('primitive number', () => {
|
|
58
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['123.123']);
|
|
59
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
60
|
-
(0, vitest_1.expect)(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('123.123', 1, definitionPlaneText)]);
|
|
61
|
-
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
62
|
-
});
|
|
63
|
-
(0, vitest_1.test)('primitive negative number', () => {
|
|
64
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['-123.123']);
|
|
65
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
66
|
-
(0, vitest_1.expect)(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('-123.123', 1, definitionPlaneText)]);
|
|
67
|
-
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
68
|
-
});
|
|
69
|
-
(0, vitest_1.test)('primitive undefined', () => {
|
|
70
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['undefined']);
|
|
71
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
72
|
-
(0, vitest_1.expect)(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition(undefined, 1, definitionPlaneText)]);
|
|
73
|
-
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
(0, vitest_1.describe)('Array', () => {
|
|
77
|
-
(0, vitest_1.test)('basic', () => {
|
|
78
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['- orange', '- banana']);
|
|
79
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
80
|
-
let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
|
|
81
|
-
line: definitionPlaneText.location.line + 1,
|
|
82
|
-
rawData: [
|
|
83
|
-
{
|
|
84
|
-
line: definitionPlaneText.location.line + 1,
|
|
85
|
-
rawData: 'orange'
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
line: definitionPlaneText.location.line + 2,
|
|
89
|
-
rawData: 'banana'
|
|
90
|
-
}
|
|
91
|
-
]
|
|
92
|
-
});
|
|
93
|
-
(0, vitest_1.expect)(result.rawDefinitions).toStrictEqual([expectedStructure]);
|
|
94
|
-
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
95
|
-
});
|
|
96
|
-
(0, vitest_1.test)('array contains array', () => {
|
|
97
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['- - orange', ' - banana', '- - 1', ' - 2']);
|
|
98
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
99
|
-
let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
|
|
100
|
-
line: definitionPlaneText.location.line + 1,
|
|
101
|
-
rawData: [
|
|
102
|
-
{
|
|
103
|
-
line: definitionPlaneText.location.line + 1,
|
|
104
|
-
rawData: [
|
|
105
|
-
{
|
|
106
|
-
line: definitionPlaneText.location.line + 1,
|
|
107
|
-
rawData: 'orange'
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
line: definitionPlaneText.location.line + 2,
|
|
111
|
-
rawData: 'banana'
|
|
112
|
-
}
|
|
113
|
-
]
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
line: definitionPlaneText.location.line + 3,
|
|
117
|
-
rawData: [
|
|
118
|
-
{
|
|
119
|
-
line: definitionPlaneText.location.line + 3,
|
|
120
|
-
rawData: '1'
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
line: definitionPlaneText.location.line + 4,
|
|
124
|
-
rawData: '2'
|
|
125
|
-
}
|
|
126
|
-
]
|
|
127
|
-
}
|
|
128
|
-
]
|
|
129
|
-
});
|
|
130
|
-
(0, vitest_1.expect)(result.rawDefinitions).toStrictEqual([expectedStructure]);
|
|
131
|
-
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
132
|
-
});
|
|
133
|
-
(0, vitest_1.test)('array contains object', () => {
|
|
134
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['- Name: arrow', ' Quantity: 4', '- Name: axe', ' Quantity: 1']);
|
|
135
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
136
|
-
let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
|
|
137
|
-
line: definitionPlaneText.location.line + 1,
|
|
138
|
-
rawData: [
|
|
139
|
-
{
|
|
140
|
-
line: definitionPlaneText.location.line + 1,
|
|
141
|
-
rawData: {
|
|
142
|
-
name: {
|
|
143
|
-
line: definitionPlaneText.location.line + 1,
|
|
144
|
-
rawData: 'arrow'
|
|
145
|
-
},
|
|
146
|
-
quantity: {
|
|
147
|
-
line: definitionPlaneText.location.line + 2,
|
|
148
|
-
rawData: '4'
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
line: definitionPlaneText.location.line + 3,
|
|
154
|
-
rawData: {
|
|
155
|
-
name: {
|
|
156
|
-
line: definitionPlaneText.location.line + 3,
|
|
157
|
-
rawData: 'axe'
|
|
158
|
-
},
|
|
159
|
-
quantity: {
|
|
160
|
-
line: definitionPlaneText.location.line + 4,
|
|
161
|
-
rawData: '1'
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
]
|
|
166
|
-
});
|
|
167
|
-
(0, vitest_1.expect)(result.rawDefinitions).toStrictEqual([expectedStructure]);
|
|
168
|
-
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
(0, vitest_1.describe)('Object', () => {
|
|
172
|
-
(0, vitest_1.test)('basic', () => {
|
|
173
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['Name: axe', 'Quantity: 1']);
|
|
174
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
175
|
-
let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
|
|
176
|
-
line: definitionPlaneText.location.line + 1,
|
|
177
|
-
rawData: {
|
|
178
|
-
name: {
|
|
179
|
-
line: definitionPlaneText.location.line + 1,
|
|
180
|
-
rawData: 'axe'
|
|
181
|
-
},
|
|
182
|
-
quantity: {
|
|
183
|
-
line: definitionPlaneText.location.line + 2,
|
|
184
|
-
rawData: '1'
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
(0, vitest_1.expect)(result.rawDefinitions).toStrictEqual([expectedStructure]);
|
|
189
|
-
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
190
|
-
});
|
|
191
|
-
(0, vitest_1.test)('object contains object', () => {
|
|
192
|
-
let definitionPlaneText = getMockDefinitionPlaneText([
|
|
193
|
-
'Attacker:',
|
|
194
|
-
' Name: firstObjectName',
|
|
195
|
-
' Age: 25',
|
|
196
|
-
'Defender:',
|
|
197
|
-
' Name: secondObjectName',
|
|
198
|
-
' Age: 35'
|
|
199
|
-
]);
|
|
200
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
201
|
-
let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
|
|
202
|
-
line: definitionPlaneText.location.line + 1,
|
|
203
|
-
rawData: {
|
|
204
|
-
attacker: {
|
|
205
|
-
line: definitionPlaneText.location.line + 1,
|
|
206
|
-
rawData: {
|
|
207
|
-
name: {
|
|
208
|
-
line: definitionPlaneText.location.line + 2,
|
|
209
|
-
rawData: 'firstObjectName'
|
|
210
|
-
},
|
|
211
|
-
age: {
|
|
212
|
-
line: definitionPlaneText.location.line + 3,
|
|
213
|
-
rawData: '25'
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
},
|
|
217
|
-
defender: {
|
|
218
|
-
line: definitionPlaneText.location.line + 4,
|
|
219
|
-
rawData: {
|
|
220
|
-
name: {
|
|
221
|
-
line: definitionPlaneText.location.line + 5,
|
|
222
|
-
rawData: 'secondObjectName'
|
|
223
|
-
},
|
|
224
|
-
age: {
|
|
225
|
-
line: definitionPlaneText.location.line + 6,
|
|
226
|
-
rawData: '35'
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
(0, vitest_1.expect)(result.rawDefinitions).toStrictEqual([expectedStructure]);
|
|
233
|
-
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
234
|
-
});
|
|
235
|
-
(0, vitest_1.test)('object contains array', () => {
|
|
236
|
-
let definitionPlaneText = getMockDefinitionPlaneText([
|
|
237
|
-
'Array1:',
|
|
238
|
-
'- apple',
|
|
239
|
-
'- orange',
|
|
240
|
-
'Array2:',
|
|
241
|
-
'- xWing',
|
|
242
|
-
'- tieFighter'
|
|
243
|
-
]);
|
|
244
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
245
|
-
let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
|
|
246
|
-
line: definitionPlaneText.location.line + 1,
|
|
247
|
-
rawData: {
|
|
248
|
-
array1: {
|
|
249
|
-
line: definitionPlaneText.location.line + 1,
|
|
250
|
-
rawData: [
|
|
251
|
-
{
|
|
252
|
-
line: definitionPlaneText.location.line + 2,
|
|
253
|
-
rawData: 'apple'
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
line: definitionPlaneText.location.line + 3,
|
|
257
|
-
rawData: 'orange'
|
|
258
|
-
}
|
|
259
|
-
]
|
|
260
|
-
},
|
|
261
|
-
array2: {
|
|
262
|
-
line: definitionPlaneText.location.line + 4,
|
|
263
|
-
rawData: [
|
|
264
|
-
{
|
|
265
|
-
line: definitionPlaneText.location.line + 5,
|
|
266
|
-
rawData: 'xWing'
|
|
267
|
-
},
|
|
268
|
-
{
|
|
269
|
-
line: definitionPlaneText.location.line + 6,
|
|
270
|
-
rawData: 'tieFighter'
|
|
271
|
-
}
|
|
272
|
-
]
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
(0, vitest_1.expect)(result.rawDefinitions).toStrictEqual([expectedStructure]);
|
|
277
|
-
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
});
|
|
281
|
-
//# sourceMappingURL=2-structure-parser.helper.test.js.map
|
|
@@ -1,36 +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
|
-
exports.Config = exports.ConfigDefinitionComponentName = void 0;
|
|
7
|
-
const joi_1 = __importDefault(require("joi"));
|
|
8
|
-
const context_1 = require("../framework/context");
|
|
9
|
-
const validator_1 = require("../helpers/validator/validator");
|
|
10
|
-
exports.ConfigDefinitionComponentName = 'CONFIG';
|
|
11
|
-
const ConfigSchema = joi_1.default.object().keys({
|
|
12
|
-
projectRoot: joi_1.default.string()
|
|
13
|
-
.regex(/^[\S]+$/)
|
|
14
|
-
.required(),
|
|
15
|
-
compilerModulesPath: joi_1.default.string()
|
|
16
|
-
.regex(/^[\S]+$/)
|
|
17
|
-
.optional()
|
|
18
|
-
});
|
|
19
|
-
class Config {
|
|
20
|
-
static { this.$meta = {
|
|
21
|
-
componentName: exports.ConfigDefinitionComponentName,
|
|
22
|
-
validationSchema: ConfigSchema
|
|
23
|
-
}; }
|
|
24
|
-
static process() {
|
|
25
|
-
let validatedItem = validator_1.Validator.validateAndConvertSingular(exports.ConfigDefinitionComponentName, ConfigSchema);
|
|
26
|
-
if (validatedItem) {
|
|
27
|
-
let definition = validatedItem.definition;
|
|
28
|
-
context_1.Context.config.projectRoot = definition.projectRoot;
|
|
29
|
-
if (definition.compilerModulesPath) {
|
|
30
|
-
context_1.Context.config.compilerModulesPath = `${definition.projectRoot}${definition.compilerModulesPath.replace('./', '')}`;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.Config = Config;
|
|
36
|
-
//# sourceMappingURL=3-config.js.map
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ErrorLog, LocationInFile, ParsedStructure, RawData, RawDefinition } from '../../framework/interfaces';
|
|
2
|
-
import { DefinitionPlaneText } from '../1-select-definitions.helper';
|
|
3
|
-
export declare function getBaseStructure(location: LocationInFile, parsedStructure: ParsedStructure): RawDefinition;
|
|
4
|
-
export declare function getMockDefinitionPlaneText(content: string[]): DefinitionPlaneText;
|
|
5
|
-
export declare function getExpectedStructure(expected: RawData, offset: number, location: LocationInFile): RawDefinition;
|
|
6
|
-
export declare function getExpectedParsedStructure(content: string | undefined, location: LocationInFile): ParsedStructure;
|
|
7
|
-
export declare class ExpectErrorHelper {
|
|
8
|
-
private parser;
|
|
9
|
-
constructor(parser: {
|
|
10
|
-
parse: (content: string[], location: LocationInFile) => ParsedStructure;
|
|
11
|
-
});
|
|
12
|
-
expect(content: string[], expectedError: ErrorLog): void;
|
|
13
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExpectErrorHelper = exports.getExpectedParsedStructure = exports.getExpectedStructure = exports.getMockDefinitionPlaneText = exports.getBaseStructure = void 0;
|
|
4
|
-
const vitest_1 = require("vitest");
|
|
5
|
-
const mocks_1 = require("../../_mocks/mocks");
|
|
6
|
-
function getBaseStructure(location, parsedStructure) {
|
|
7
|
-
return {
|
|
8
|
-
componentName: 'ASSET',
|
|
9
|
-
location,
|
|
10
|
-
parsedStructure: parsedStructure
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
exports.getBaseStructure = getBaseStructure;
|
|
14
|
-
function getMockDefinitionPlaneText(content) {
|
|
15
|
-
return {
|
|
16
|
-
type: 'ASSET',
|
|
17
|
-
location: mocks_1.SampleLocation1,
|
|
18
|
-
content
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
exports.getMockDefinitionPlaneText = getMockDefinitionPlaneText;
|
|
22
|
-
function getExpectedStructure(expected, offset, location) {
|
|
23
|
-
return getBaseStructure(location, {
|
|
24
|
-
line: location.line + offset,
|
|
25
|
-
rawData: expected
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
exports.getExpectedStructure = getExpectedStructure;
|
|
29
|
-
function getExpectedParsedStructure(content, location) {
|
|
30
|
-
return {
|
|
31
|
-
line: location.line,
|
|
32
|
-
rawData: content
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
exports.getExpectedParsedStructure = getExpectedParsedStructure;
|
|
36
|
-
class ExpectErrorHelper {
|
|
37
|
-
constructor(parser) {
|
|
38
|
-
this.parser = parser;
|
|
39
|
-
}
|
|
40
|
-
expect(content, expectedError) {
|
|
41
|
-
let thrownError;
|
|
42
|
-
try {
|
|
43
|
-
this.parser.parse(content, mocks_1.SampleLocation1);
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
thrownError = error;
|
|
47
|
-
}
|
|
48
|
-
(0, vitest_1.expect)(thrownError).toStrictEqual(expectedError);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.ExpectErrorHelper = ExpectErrorHelper;
|
|
52
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -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 {};
|