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,140 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
const _1_select_definitions_helper_1 = require('./1-select-definitions-helper');
|
|
4
|
-
const mocks_1 = require('../_mocks/mocks');
|
|
5
|
-
const custom_validator_helper_spec_1 = require('../helpers/validator/custom-validator-helper/custom-validator.helper.spec');
|
|
6
|
-
const definition_store_1 = require('../framework/definition-store');
|
|
7
|
-
definition_store_1.DefinitionStore['definitionsMap'].set(custom_validator_helper_spec_1.AssetComponentName, new Map());
|
|
8
|
-
describe('SELECT DEFINITIONS HELPER', () => {
|
|
9
|
-
let selectDefinitionsHelper;
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
selectDefinitionsHelper = new _1_select_definitions_helper_1.SelectDefinitionsHelper();
|
|
12
|
-
});
|
|
13
|
-
test('should handle empty files', () => {
|
|
14
|
-
let content = ``;
|
|
15
|
-
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
16
|
-
let result = selectDefinitionsHelper.process(fileInfo);
|
|
17
|
-
expect(result.definitionPlaneTexts).toStrictEqual([]);
|
|
18
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
19
|
-
});
|
|
20
|
-
test('should handle files without definitions', () => {
|
|
21
|
-
let content = `
|
|
22
|
-
Explanation
|
|
23
|
-
|
|
24
|
-
### ASSET
|
|
25
|
-
Name: singular name
|
|
26
|
-
Path: path to file
|
|
27
|
-
`;
|
|
28
|
-
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
29
|
-
let result = selectDefinitionsHelper.process(fileInfo);
|
|
30
|
-
expect(result.definitionPlaneTexts).toStrictEqual([]);
|
|
31
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
32
|
-
});
|
|
33
|
-
test('should select definitions', () => {
|
|
34
|
-
let content = `
|
|
35
|
-
# DEFINITIONS
|
|
36
|
-
### ASSET
|
|
37
|
-
Name: test
|
|
38
|
-
Path: test.png
|
|
39
|
-
`;
|
|
40
|
-
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
41
|
-
let result = selectDefinitionsHelper.process(fileInfo);
|
|
42
|
-
expect(result.definitionPlaneTexts).toStrictEqual([
|
|
43
|
-
{
|
|
44
|
-
type: 'ASSET',
|
|
45
|
-
content: [' Name: test', ' Path: test.png'],
|
|
46
|
-
location: { line: 3, path: fileInfo.path }
|
|
47
|
-
}
|
|
48
|
-
]);
|
|
49
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
50
|
-
});
|
|
51
|
-
test('should ignore comments', () => {
|
|
52
|
-
let content = `
|
|
53
|
-
# DEFINITIONS
|
|
54
|
-
### ASSET
|
|
55
|
-
Name: test // comment
|
|
56
|
-
Path: test.png // comment
|
|
57
|
-
// ----comment----\r
|
|
58
|
-
`;
|
|
59
|
-
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
60
|
-
let result = selectDefinitionsHelper.process(fileInfo);
|
|
61
|
-
expect(result.definitionPlaneTexts).toStrictEqual([
|
|
62
|
-
{
|
|
63
|
-
type: 'ASSET',
|
|
64
|
-
content: [' Name: test', ' Path: test.png'],
|
|
65
|
-
location: { line: 3, path: fileInfo.path }
|
|
66
|
-
}
|
|
67
|
-
]);
|
|
68
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
69
|
-
});
|
|
70
|
-
test('should not allow empty definitions', () => {
|
|
71
|
-
let content = `
|
|
72
|
-
# DEFINITIONS
|
|
73
|
-
### ASSET
|
|
74
|
-
`;
|
|
75
|
-
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
76
|
-
let result = selectDefinitionsHelper.process(fileInfo);
|
|
77
|
-
expect(result.definitionPlaneTexts).toStrictEqual([]);
|
|
78
|
-
expect(result.errorLogs).toStrictEqual([
|
|
79
|
-
{
|
|
80
|
-
description: 'Definitions cannot be empty!',
|
|
81
|
-
location: { line: 3, path: fileInfo.path }
|
|
82
|
-
}
|
|
83
|
-
]);
|
|
84
|
-
});
|
|
85
|
-
test('should not allow unknown definition header after the first valid definition', () => {
|
|
86
|
-
let content = `
|
|
87
|
-
# DEFINITIONS
|
|
88
|
-
### ASSET
|
|
89
|
-
Name: test
|
|
90
|
-
Path: test.png
|
|
91
|
-
|
|
92
|
-
### Some text
|
|
93
|
-
some text
|
|
94
|
-
`;
|
|
95
|
-
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
96
|
-
let result = selectDefinitionsHelper.process(fileInfo);
|
|
97
|
-
expect(result.errorLogs).toStrictEqual([
|
|
98
|
-
{
|
|
99
|
-
description: 'Invalid definition header: "### Some text"',
|
|
100
|
-
location: { line: 7, path: fileInfo.path }
|
|
101
|
-
}
|
|
102
|
-
]);
|
|
103
|
-
});
|
|
104
|
-
test('invalid definitions should not corrupt other definitions', () => {
|
|
105
|
-
let content = `
|
|
106
|
-
# DEFINITIONS
|
|
107
|
-
### ASSET
|
|
108
|
-
Name: test
|
|
109
|
-
Path: test.png
|
|
110
|
-
|
|
111
|
-
### Some text
|
|
112
|
-
some text
|
|
113
|
-
|
|
114
|
-
### ASSET
|
|
115
|
-
Name: test2
|
|
116
|
-
Path: test2.png
|
|
117
|
-
`;
|
|
118
|
-
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
119
|
-
let result = selectDefinitionsHelper.process(fileInfo);
|
|
120
|
-
expect(result.definitionPlaneTexts).toStrictEqual([
|
|
121
|
-
{
|
|
122
|
-
type: 'ASSET',
|
|
123
|
-
content: [' Name: test', ' Path: test.png'],
|
|
124
|
-
location: { line: 3, path: fileInfo.path }
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
type: 'ASSET',
|
|
128
|
-
content: [' Name: test2', ' Path: test2.png'],
|
|
129
|
-
location: { line: 10, path: fileInfo.path }
|
|
130
|
-
}
|
|
131
|
-
]);
|
|
132
|
-
expect(result.errorLogs).toStrictEqual([
|
|
133
|
-
{
|
|
134
|
-
description: 'Invalid definition header: "### Some text"',
|
|
135
|
-
location: { line: 7, path: fileInfo.path }
|
|
136
|
-
}
|
|
137
|
-
]);
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
//# sourceMappingURL=1-select-definitions.spec.js.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ErrorLog, LocationInFile, ParsedStructure, RawDefinition } from '../framework/interfaces';
|
|
2
|
-
import { DefinitionPlaneText } from './1-select-definitions.helper';
|
|
3
|
-
export interface StructureParserResult {
|
|
4
|
-
readonly rawDefinitions: RawDefinition[];
|
|
5
|
-
readonly errorLogs: ErrorLog[];
|
|
6
|
-
}
|
|
7
|
-
export declare class StructureParserHelper {
|
|
8
|
-
static getParsedStructure(content: string[], location: LocationInFile): ParsedStructure;
|
|
9
|
-
private static getStructureType;
|
|
10
|
-
process(definitionPlaneTexts: DefinitionPlaneText[]): StructureParserResult;
|
|
11
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StructureParserHelper = void 0;
|
|
4
|
-
const array_parser_1 = require("./parsers/array-parser");
|
|
5
|
-
const object_parser_1 = require("./parsers/object-parser");
|
|
6
|
-
const primitive_parser_1 = require("./parsers/primitive-parser");
|
|
7
|
-
var ParsedStructureType;
|
|
8
|
-
(function (ParsedStructureType) {
|
|
9
|
-
ParsedStructureType["primitive"] = "primitive";
|
|
10
|
-
ParsedStructureType["array"] = "array";
|
|
11
|
-
ParsedStructureType["object"] = "object";
|
|
12
|
-
})(ParsedStructureType || (ParsedStructureType = {}));
|
|
13
|
-
class StructureParserHelper {
|
|
14
|
-
static getParsedStructure(content, location) {
|
|
15
|
-
let structureType = this.getStructureType(content[0]);
|
|
16
|
-
switch (structureType) {
|
|
17
|
-
case ParsedStructureType.object:
|
|
18
|
-
return object_parser_1.ObjectParser.parse(content, location);
|
|
19
|
-
case ParsedStructureType.array:
|
|
20
|
-
return array_parser_1.ArrayParser.parse(content, location);
|
|
21
|
-
case ParsedStructureType.primitive:
|
|
22
|
-
return primitive_parser_1.PrimitiveParser.parse(content, location);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
static getStructureType(firstLine) {
|
|
26
|
-
if (firstLine.startsWith('-') && !firstLine.match(/^-?\d+(\.\d+)?$/)) {
|
|
27
|
-
return ParsedStructureType.array;
|
|
28
|
-
}
|
|
29
|
-
else if (firstLine.match(/^[\w]+:/)) {
|
|
30
|
-
return ParsedStructureType.object;
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
return ParsedStructureType.primitive;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
process(definitionPlaneTexts) {
|
|
37
|
-
let errorLogs = [];
|
|
38
|
-
let structuredDefinitions = definitionPlaneTexts
|
|
39
|
-
.map(definitionPlaneText => {
|
|
40
|
-
try {
|
|
41
|
-
if (definitionPlaneText.content.length) {
|
|
42
|
-
let structuredDefinition = {
|
|
43
|
-
componentName: definitionPlaneText.type,
|
|
44
|
-
location: definitionPlaneText.location,
|
|
45
|
-
parsedStructure: StructureParserHelper.getParsedStructure(definitionPlaneText.content, {
|
|
46
|
-
line: definitionPlaneText.location.line + 1,
|
|
47
|
-
path: definitionPlaneText.location.path
|
|
48
|
-
})
|
|
49
|
-
};
|
|
50
|
-
return structuredDefinition;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
if (error?.description && error?.location) {
|
|
55
|
-
errorLogs.push(error);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
errorLogs.push({
|
|
59
|
-
description: `Unexpected Error! Error: "${error}"`,
|
|
60
|
-
location: definitionPlaneText.location
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
})
|
|
65
|
-
.filter(item => item);
|
|
66
|
-
return { rawDefinitions: structuredDefinitions, errorLogs };
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
exports.StructureParserHelper = StructureParserHelper;
|
|
70
|
-
//# sourceMappingURL=2-structure-parser.helper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
const _2_structure_parser_helper_1 = require('./2-structure-parser.helper');
|
|
4
|
-
const mocks_1 = require('../_mocks/mocks');
|
|
5
|
-
function getMockDefinitionPlaneText(content) {
|
|
6
|
-
return {
|
|
7
|
-
type: 'ASSET',
|
|
8
|
-
content,
|
|
9
|
-
location: mocks_1.SampleLocation1
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
function getBaseRawDefinition(definitionPlaneText, parsedStructure) {
|
|
13
|
-
return {
|
|
14
|
-
componentName: definitionPlaneText.type,
|
|
15
|
-
location: definitionPlaneText.location,
|
|
16
|
-
parsedStructure: parsedStructure
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
function getExpectedRawDefinition(expected, offset, definitionPlaneText) {
|
|
20
|
-
let rawDefinition = getBaseRawDefinition(definitionPlaneText, {
|
|
21
|
-
rawData: expected,
|
|
22
|
-
line: definitionPlaneText.location.line + offset
|
|
23
|
-
});
|
|
24
|
-
return rawDefinition;
|
|
25
|
-
}
|
|
26
|
-
describe('STRUCTURE PARSER HELPER', () => {
|
|
27
|
-
let structureParserHelper;
|
|
28
|
-
beforeEach(() => {
|
|
29
|
-
structureParserHelper = new _2_structure_parser_helper_1.StructureParserHelper();
|
|
30
|
-
});
|
|
31
|
-
describe('Primitive', () => {
|
|
32
|
-
test('empty content', () => {
|
|
33
|
-
let definitionPlaneText = getMockDefinitionPlaneText([]);
|
|
34
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
35
|
-
expect(result.rawDefinitions).toStrictEqual([]);
|
|
36
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
37
|
-
});
|
|
38
|
-
test('primitive string', () => {
|
|
39
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['text']);
|
|
40
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
41
|
-
expect(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('text', 1, definitionPlaneText)]);
|
|
42
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
43
|
-
});
|
|
44
|
-
test('primitive quoted string', () => {
|
|
45
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['"text with spaces"']);
|
|
46
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
47
|
-
expect(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('text with spaces', 1, definitionPlaneText)]);
|
|
48
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
49
|
-
});
|
|
50
|
-
it('primitive multiline string', () => {
|
|
51
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['`', 'text text', 'text', '`']);
|
|
52
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
53
|
-
expect(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('text text\ntext', 1, definitionPlaneText)]);
|
|
54
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
55
|
-
});
|
|
56
|
-
test('primitive number', () => {
|
|
57
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['123.123']);
|
|
58
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
59
|
-
expect(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('123.123', 1, definitionPlaneText)]);
|
|
60
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
61
|
-
});
|
|
62
|
-
test('primitive negative number', () => {
|
|
63
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['-123.123']);
|
|
64
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
65
|
-
expect(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('-123.123', 1, definitionPlaneText)]);
|
|
66
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
67
|
-
});
|
|
68
|
-
test('primitive undefined', () => {
|
|
69
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['undefined']);
|
|
70
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
71
|
-
expect(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition(undefined, 1, definitionPlaneText)]);
|
|
72
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
describe('Array', () => {
|
|
76
|
-
it('basic', () => {
|
|
77
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['- orange', '- banana']);
|
|
78
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
79
|
-
let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
|
|
80
|
-
line: definitionPlaneText.location.line + 1,
|
|
81
|
-
rawData: [
|
|
82
|
-
{
|
|
83
|
-
line: definitionPlaneText.location.line + 1,
|
|
84
|
-
rawData: 'orange'
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
line: definitionPlaneText.location.line + 2,
|
|
88
|
-
rawData: 'banana'
|
|
89
|
-
}
|
|
90
|
-
]
|
|
91
|
-
});
|
|
92
|
-
expect(result.rawDefinitions).toStrictEqual([expectedStructure]);
|
|
93
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
94
|
-
});
|
|
95
|
-
it('array contains array', () => {
|
|
96
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['- - orange', ' - banana', '- - 1', ' - 2']);
|
|
97
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
98
|
-
let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
|
|
99
|
-
line: definitionPlaneText.location.line + 1,
|
|
100
|
-
rawData: [
|
|
101
|
-
{
|
|
102
|
-
line: definitionPlaneText.location.line + 1,
|
|
103
|
-
rawData: [
|
|
104
|
-
{
|
|
105
|
-
line: definitionPlaneText.location.line + 1,
|
|
106
|
-
rawData: 'orange'
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
line: definitionPlaneText.location.line + 2,
|
|
110
|
-
rawData: 'banana'
|
|
111
|
-
}
|
|
112
|
-
]
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
line: definitionPlaneText.location.line + 3,
|
|
116
|
-
rawData: [
|
|
117
|
-
{
|
|
118
|
-
line: definitionPlaneText.location.line + 3,
|
|
119
|
-
rawData: '1'
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
line: definitionPlaneText.location.line + 4,
|
|
123
|
-
rawData: '2'
|
|
124
|
-
}
|
|
125
|
-
]
|
|
126
|
-
}
|
|
127
|
-
]
|
|
128
|
-
});
|
|
129
|
-
expect(result.rawDefinitions).toStrictEqual([expectedStructure]);
|
|
130
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
131
|
-
});
|
|
132
|
-
it('array contains object', () => {
|
|
133
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['- Name: arrow', ' Quantity: 4', '- Name: axe', ' Quantity: 1']);
|
|
134
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
135
|
-
let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
|
|
136
|
-
line: definitionPlaneText.location.line + 1,
|
|
137
|
-
rawData: [
|
|
138
|
-
{
|
|
139
|
-
line: definitionPlaneText.location.line + 1,
|
|
140
|
-
rawData: {
|
|
141
|
-
name: {
|
|
142
|
-
line: definitionPlaneText.location.line + 1,
|
|
143
|
-
rawData: 'arrow'
|
|
144
|
-
},
|
|
145
|
-
quantity: {
|
|
146
|
-
line: definitionPlaneText.location.line + 2,
|
|
147
|
-
rawData: '4'
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
line: definitionPlaneText.location.line + 3,
|
|
153
|
-
rawData: {
|
|
154
|
-
name: {
|
|
155
|
-
line: definitionPlaneText.location.line + 3,
|
|
156
|
-
rawData: 'axe'
|
|
157
|
-
},
|
|
158
|
-
quantity: {
|
|
159
|
-
line: definitionPlaneText.location.line + 4,
|
|
160
|
-
rawData: '1'
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
]
|
|
165
|
-
});
|
|
166
|
-
expect(result.rawDefinitions).toStrictEqual([expectedStructure]);
|
|
167
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
describe('Object', () => {
|
|
171
|
-
it('basic', () => {
|
|
172
|
-
let definitionPlaneText = getMockDefinitionPlaneText(['Name: axe', 'Quantity: 1']);
|
|
173
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
174
|
-
let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
|
|
175
|
-
line: definitionPlaneText.location.line + 1,
|
|
176
|
-
rawData: {
|
|
177
|
-
name: {
|
|
178
|
-
line: definitionPlaneText.location.line + 1,
|
|
179
|
-
rawData: 'axe'
|
|
180
|
-
},
|
|
181
|
-
quantity: {
|
|
182
|
-
line: definitionPlaneText.location.line + 2,
|
|
183
|
-
rawData: '1'
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
expect(result.rawDefinitions).toStrictEqual([expectedStructure]);
|
|
188
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
189
|
-
});
|
|
190
|
-
it('object contains object', () => {
|
|
191
|
-
let definitionPlaneText = getMockDefinitionPlaneText([
|
|
192
|
-
'Attacker:',
|
|
193
|
-
' Name: firstObjectName',
|
|
194
|
-
' Age: 25',
|
|
195
|
-
'Defender:',
|
|
196
|
-
' Name: secondObjectName',
|
|
197
|
-
' Age: 35'
|
|
198
|
-
]);
|
|
199
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
200
|
-
let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
|
|
201
|
-
line: definitionPlaneText.location.line + 1,
|
|
202
|
-
rawData: {
|
|
203
|
-
attacker: {
|
|
204
|
-
line: definitionPlaneText.location.line + 1,
|
|
205
|
-
rawData: {
|
|
206
|
-
name: {
|
|
207
|
-
line: definitionPlaneText.location.line + 2,
|
|
208
|
-
rawData: 'firstObjectName'
|
|
209
|
-
},
|
|
210
|
-
age: {
|
|
211
|
-
line: definitionPlaneText.location.line + 3,
|
|
212
|
-
rawData: '25'
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
},
|
|
216
|
-
defender: {
|
|
217
|
-
line: definitionPlaneText.location.line + 4,
|
|
218
|
-
rawData: {
|
|
219
|
-
name: {
|
|
220
|
-
line: definitionPlaneText.location.line + 5,
|
|
221
|
-
rawData: 'secondObjectName'
|
|
222
|
-
},
|
|
223
|
-
age: {
|
|
224
|
-
line: definitionPlaneText.location.line + 6,
|
|
225
|
-
rawData: '35'
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
expect(result.rawDefinitions).toStrictEqual([expectedStructure]);
|
|
232
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
233
|
-
});
|
|
234
|
-
it('object contains array', () => {
|
|
235
|
-
let definitionPlaneText = getMockDefinitionPlaneText([
|
|
236
|
-
'Array1:',
|
|
237
|
-
'- apple',
|
|
238
|
-
'- orange',
|
|
239
|
-
'Array2:',
|
|
240
|
-
'- xWing',
|
|
241
|
-
'- tieFighter'
|
|
242
|
-
]);
|
|
243
|
-
let result = structureParserHelper.process([definitionPlaneText]);
|
|
244
|
-
let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
|
|
245
|
-
line: definitionPlaneText.location.line + 1,
|
|
246
|
-
rawData: {
|
|
247
|
-
array1: {
|
|
248
|
-
line: definitionPlaneText.location.line + 1,
|
|
249
|
-
rawData: [
|
|
250
|
-
{
|
|
251
|
-
line: definitionPlaneText.location.line + 2,
|
|
252
|
-
rawData: 'apple'
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
line: definitionPlaneText.location.line + 3,
|
|
256
|
-
rawData: 'orange'
|
|
257
|
-
}
|
|
258
|
-
]
|
|
259
|
-
},
|
|
260
|
-
array2: {
|
|
261
|
-
line: definitionPlaneText.location.line + 4,
|
|
262
|
-
rawData: [
|
|
263
|
-
{
|
|
264
|
-
line: definitionPlaneText.location.line + 5,
|
|
265
|
-
rawData: 'xWing'
|
|
266
|
-
},
|
|
267
|
-
{
|
|
268
|
-
line: definitionPlaneText.location.line + 6,
|
|
269
|
-
rawData: 'tieFighter'
|
|
270
|
-
}
|
|
271
|
-
]
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
expect(result.rawDefinitions).toStrictEqual([expectedStructure]);
|
|
276
|
-
expect(result.errorLogs).toStrictEqual([]);
|
|
277
|
-
});
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
//# sourceMappingURL=2-structure-parser.helper.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|