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,76 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
exports.SelectDefinitionsHelper = void 0;
|
|
4
|
-
const common_functions_1 = require('../helpers/common-functions/common-functions');
|
|
5
|
-
const definition_store_1 = require('../framework/definition-store');
|
|
6
|
-
class SelectDefinitionsHelper {
|
|
7
|
-
constructor() {
|
|
8
|
-
this.definitionsStarted = false;
|
|
9
|
-
this.definitionPlaneTexts = [];
|
|
10
|
-
this.errorLogs = [];
|
|
11
|
-
this.currentFilePath = '';
|
|
12
|
-
}
|
|
13
|
-
process(file) {
|
|
14
|
-
this.definitionsStarted = false;
|
|
15
|
-
this.currentItem = undefined;
|
|
16
|
-
this.definitionPlaneTexts = [];
|
|
17
|
-
this.errorLogs = [];
|
|
18
|
-
this.currentFilePath = file.path;
|
|
19
|
-
file.content.split('\n').forEach((row, index) => {
|
|
20
|
-
let trimmedRow = common_functions_1.CommonFunctions.removeWhiteSpace(row);
|
|
21
|
-
if (this.definitionsStarted) {
|
|
22
|
-
if (trimmedRow.startsWith('###')) {
|
|
23
|
-
this.flushCurrentItem();
|
|
24
|
-
this.onDeclarationEncountered(row, index, trimmedRow.substring(4));
|
|
25
|
-
} else if (this.currentItem && trimmedRow.length > 0) {
|
|
26
|
-
this.currentItem.content.push(common_functions_1.CommonFunctions.removeComments(row));
|
|
27
|
-
}
|
|
28
|
-
} else if (trimmedRow === '# DEFINITIONS') {
|
|
29
|
-
this.definitionsStarted = true;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
this.flushCurrentItem();
|
|
33
|
-
return {
|
|
34
|
-
definitionPlaneTexts: this.definitionPlaneTexts,
|
|
35
|
-
errorLogs: this.errorLogs
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
flushCurrentItem() {
|
|
39
|
-
if (this.currentItem) {
|
|
40
|
-
if (this.currentItem.content.length > 0) {
|
|
41
|
-
this.definitionPlaneTexts.push(this.currentItem);
|
|
42
|
-
} else {
|
|
43
|
-
let errorLog = {
|
|
44
|
-
description: 'Definitions cannot be empty!',
|
|
45
|
-
location: this.currentItem.location
|
|
46
|
-
};
|
|
47
|
-
this.errorLogs.push(errorLog);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
this.currentItem = undefined;
|
|
51
|
-
}
|
|
52
|
-
onDeclarationEncountered(row, index, componentName) {
|
|
53
|
-
if (definition_store_1.DefinitionStore['isValidComponentName'](componentName)) {
|
|
54
|
-
this.currentItem = {
|
|
55
|
-
type: componentName,
|
|
56
|
-
location: {
|
|
57
|
-
line: index + 1,
|
|
58
|
-
path: this.currentFilePath
|
|
59
|
-
},
|
|
60
|
-
content: []
|
|
61
|
-
};
|
|
62
|
-
} else {
|
|
63
|
-
let errorLog = {
|
|
64
|
-
description: `Invalid definition header: "${row.trim()}"`,
|
|
65
|
-
location: {
|
|
66
|
-
line: index + 1,
|
|
67
|
-
path: this.currentFilePath
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
this.errorLogs.push(errorLog);
|
|
71
|
-
this.currentItem = undefined;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
exports.SelectDefinitionsHelper = SelectDefinitionsHelper;
|
|
76
|
-
//# sourceMappingURL=1-select-definitions-helper.js.map
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ErrorLog, FileInfo, LocationInFile } from '../framework/interfaces';
|
|
2
|
-
export interface DefinitionPlaneText {
|
|
3
|
-
readonly type: string;
|
|
4
|
-
readonly content: string[];
|
|
5
|
-
readonly location: LocationInFile;
|
|
6
|
-
}
|
|
7
|
-
export interface SelectDefinitionsResult {
|
|
8
|
-
definitionPlaneTexts: DefinitionPlaneText[];
|
|
9
|
-
errorLogs: ErrorLog[];
|
|
10
|
-
}
|
|
11
|
-
export declare class SelectDefinitionsHelper {
|
|
12
|
-
private definitionsStarted;
|
|
13
|
-
private currentItem;
|
|
14
|
-
private definitionPlaneTexts;
|
|
15
|
-
private errorLogs;
|
|
16
|
-
private currentFilePath;
|
|
17
|
-
process(file: FileInfo): SelectDefinitionsResult;
|
|
18
|
-
private flushCurrentItem;
|
|
19
|
-
private onDeclarationEncountered;
|
|
20
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SelectDefinitionsHelper = void 0;
|
|
4
|
-
const definition_store_1 = require("../framework/definition-store");
|
|
5
|
-
const common_functions_1 = require("../helpers/common-functions/common-functions");
|
|
6
|
-
class SelectDefinitionsHelper {
|
|
7
|
-
constructor() {
|
|
8
|
-
this.definitionsStarted = false;
|
|
9
|
-
this.definitionPlaneTexts = [];
|
|
10
|
-
this.errorLogs = [];
|
|
11
|
-
this.currentFilePath = '';
|
|
12
|
-
}
|
|
13
|
-
process(file) {
|
|
14
|
-
this.definitionsStarted = false;
|
|
15
|
-
this.currentItem = undefined;
|
|
16
|
-
this.definitionPlaneTexts = [];
|
|
17
|
-
this.errorLogs = [];
|
|
18
|
-
this.currentFilePath = file.path;
|
|
19
|
-
file.content.split('\n').forEach((row, index) => {
|
|
20
|
-
let trimmedRow = common_functions_1.CommonFunctions.removeWhiteSpace(row);
|
|
21
|
-
if (this.definitionsStarted) {
|
|
22
|
-
if (trimmedRow.startsWith('###')) {
|
|
23
|
-
this.flushCurrentItem();
|
|
24
|
-
this.onDeclarationEncountered(row, index, trimmedRow.substring(4));
|
|
25
|
-
}
|
|
26
|
-
else if (this.currentItem && trimmedRow.length > 0) {
|
|
27
|
-
this.currentItem.content.push(common_functions_1.CommonFunctions.removeComments(row));
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
else if (trimmedRow === '# DEFINITIONS') {
|
|
31
|
-
this.definitionsStarted = true;
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
this.flushCurrentItem();
|
|
35
|
-
return {
|
|
36
|
-
definitionPlaneTexts: this.definitionPlaneTexts,
|
|
37
|
-
errorLogs: this.errorLogs
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
flushCurrentItem() {
|
|
41
|
-
if (this.currentItem) {
|
|
42
|
-
if (this.currentItem.content.length > 0) {
|
|
43
|
-
this.definitionPlaneTexts.push(this.currentItem);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
let errorLog = {
|
|
47
|
-
description: 'Definitions cannot be empty!',
|
|
48
|
-
location: this.currentItem.location
|
|
49
|
-
};
|
|
50
|
-
this.errorLogs.push(errorLog);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
this.currentItem = undefined;
|
|
54
|
-
}
|
|
55
|
-
onDeclarationEncountered(row, index, componentName) {
|
|
56
|
-
if (definition_store_1.DefinitionStore['isValidComponentName'](componentName)) {
|
|
57
|
-
this.currentItem = {
|
|
58
|
-
type: componentName,
|
|
59
|
-
location: {
|
|
60
|
-
line: index + 1,
|
|
61
|
-
path: this.currentFilePath
|
|
62
|
-
},
|
|
63
|
-
content: []
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
let errorLog = {
|
|
68
|
-
description: `Invalid definition header: "${row.trim()}"`,
|
|
69
|
-
location: {
|
|
70
|
-
line: index + 1,
|
|
71
|
-
path: this.currentFilePath
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
this.errorLogs.push(errorLog);
|
|
75
|
-
this.currentItem = undefined;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
exports.SelectDefinitionsHelper = SelectDefinitionsHelper;
|
|
80
|
-
//# sourceMappingURL=1-select-definitions.helper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,141 +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 definition_store_1 = require("../framework/definition-store");
|
|
6
|
-
const custom_validator_helper_test_1 = require("../helpers/validator/custom-validator-helper/custom-validator.helper.test");
|
|
7
|
-
const _1_select_definitions_helper_1 = require("./1-select-definitions.helper");
|
|
8
|
-
definition_store_1.DefinitionStore['definitionsMap'].set(custom_validator_helper_test_1.AssetComponentName, new Map());
|
|
9
|
-
(0, vitest_1.describe)('SELECT DEFINITIONS HELPER', () => {
|
|
10
|
-
let selectDefinitionsHelper;
|
|
11
|
-
(0, vitest_1.beforeEach)(() => {
|
|
12
|
-
selectDefinitionsHelper = new _1_select_definitions_helper_1.SelectDefinitionsHelper();
|
|
13
|
-
});
|
|
14
|
-
(0, vitest_1.test)('should handle empty files', () => {
|
|
15
|
-
let content = ``;
|
|
16
|
-
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
17
|
-
let result = selectDefinitionsHelper.process(fileInfo);
|
|
18
|
-
(0, vitest_1.expect)(result.definitionPlaneTexts).toStrictEqual([]);
|
|
19
|
-
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
20
|
-
});
|
|
21
|
-
(0, vitest_1.test)('should handle files without definitions', () => {
|
|
22
|
-
let content = `
|
|
23
|
-
Explanation
|
|
24
|
-
|
|
25
|
-
### ASSET
|
|
26
|
-
Name: singular name
|
|
27
|
-
Path: path to file
|
|
28
|
-
`;
|
|
29
|
-
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
30
|
-
let result = selectDefinitionsHelper.process(fileInfo);
|
|
31
|
-
(0, vitest_1.expect)(result.definitionPlaneTexts).toStrictEqual([]);
|
|
32
|
-
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
33
|
-
});
|
|
34
|
-
(0, vitest_1.test)('should select definitions', () => {
|
|
35
|
-
let content = `
|
|
36
|
-
# DEFINITIONS
|
|
37
|
-
### ASSET
|
|
38
|
-
Name: test
|
|
39
|
-
Path: test.png
|
|
40
|
-
`;
|
|
41
|
-
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
42
|
-
let result = selectDefinitionsHelper.process(fileInfo);
|
|
43
|
-
(0, vitest_1.expect)(result.definitionPlaneTexts).toStrictEqual([
|
|
44
|
-
{
|
|
45
|
-
type: 'ASSET',
|
|
46
|
-
content: [' Name: test', ' Path: test.png'],
|
|
47
|
-
location: { line: 3, path: fileInfo.path }
|
|
48
|
-
}
|
|
49
|
-
]);
|
|
50
|
-
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
51
|
-
});
|
|
52
|
-
(0, vitest_1.test)('should ignore comments', () => {
|
|
53
|
-
let content = `
|
|
54
|
-
# DEFINITIONS
|
|
55
|
-
### ASSET
|
|
56
|
-
Name: test // comment
|
|
57
|
-
Path: test.png // comment
|
|
58
|
-
// ----comment----\r
|
|
59
|
-
`;
|
|
60
|
-
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
61
|
-
let result = selectDefinitionsHelper.process(fileInfo);
|
|
62
|
-
(0, vitest_1.expect)(result.definitionPlaneTexts).toStrictEqual([
|
|
63
|
-
{
|
|
64
|
-
type: 'ASSET',
|
|
65
|
-
content: [' Name: test', ' Path: test.png'],
|
|
66
|
-
location: { line: 3, path: fileInfo.path }
|
|
67
|
-
}
|
|
68
|
-
]);
|
|
69
|
-
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
70
|
-
});
|
|
71
|
-
(0, vitest_1.test)('should not allow empty definitions', () => {
|
|
72
|
-
let content = `
|
|
73
|
-
# DEFINITIONS
|
|
74
|
-
### ASSET
|
|
75
|
-
`;
|
|
76
|
-
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
77
|
-
let result = selectDefinitionsHelper.process(fileInfo);
|
|
78
|
-
(0, vitest_1.expect)(result.definitionPlaneTexts).toStrictEqual([]);
|
|
79
|
-
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([
|
|
80
|
-
{
|
|
81
|
-
description: 'Definitions cannot be empty!',
|
|
82
|
-
location: { line: 3, path: fileInfo.path }
|
|
83
|
-
}
|
|
84
|
-
]);
|
|
85
|
-
});
|
|
86
|
-
(0, vitest_1.test)('should not allow unknown definition header after the first valid definition', () => {
|
|
87
|
-
let content = `
|
|
88
|
-
# DEFINITIONS
|
|
89
|
-
### ASSET
|
|
90
|
-
Name: test
|
|
91
|
-
Path: test.png
|
|
92
|
-
|
|
93
|
-
### Some text
|
|
94
|
-
some text
|
|
95
|
-
`;
|
|
96
|
-
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
97
|
-
let result = selectDefinitionsHelper.process(fileInfo);
|
|
98
|
-
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([
|
|
99
|
-
{
|
|
100
|
-
description: 'Invalid definition header: "### Some text"',
|
|
101
|
-
location: { line: 7, path: fileInfo.path }
|
|
102
|
-
}
|
|
103
|
-
]);
|
|
104
|
-
});
|
|
105
|
-
(0, vitest_1.test)('invalid definitions should not corrupt other definitions', () => {
|
|
106
|
-
let content = `
|
|
107
|
-
# DEFINITIONS
|
|
108
|
-
### ASSET
|
|
109
|
-
Name: test
|
|
110
|
-
Path: test.png
|
|
111
|
-
|
|
112
|
-
### Some text
|
|
113
|
-
some text
|
|
114
|
-
|
|
115
|
-
### ASSET
|
|
116
|
-
Name: test2
|
|
117
|
-
Path: test2.png
|
|
118
|
-
`;
|
|
119
|
-
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
120
|
-
let result = selectDefinitionsHelper.process(fileInfo);
|
|
121
|
-
(0, vitest_1.expect)(result.definitionPlaneTexts).toStrictEqual([
|
|
122
|
-
{
|
|
123
|
-
type: 'ASSET',
|
|
124
|
-
content: [' Name: test', ' Path: test.png'],
|
|
125
|
-
location: { line: 3, path: fileInfo.path }
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
type: 'ASSET',
|
|
129
|
-
content: [' Name: test2', ' Path: test2.png'],
|
|
130
|
-
location: { line: 10, path: fileInfo.path }
|
|
131
|
-
}
|
|
132
|
-
]);
|
|
133
|
-
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([
|
|
134
|
-
{
|
|
135
|
-
description: 'Invalid definition header: "### Some text"',
|
|
136
|
-
location: { line: 7, path: fileInfo.path }
|
|
137
|
-
}
|
|
138
|
-
]);
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
//# sourceMappingURL=1-select-definitions.helper.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -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 {};
|