definition-generator-framework 1.13.0 → 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 +33 -22
- 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,143 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
const mocks_1 = require('../../_mocks/mocks');
|
|
4
|
-
const raw_definition_helper_1 = require('./raw-definition.helper');
|
|
5
|
-
const ComponentName = 'ASSET';
|
|
6
|
-
describe('RAW DEFINITION HELPER', () => {
|
|
7
|
-
describe('Find Parsed Structure', () => {
|
|
8
|
-
test('nested definition', () => {
|
|
9
|
-
let rawDefinition = {
|
|
10
|
-
componentName: ComponentName,
|
|
11
|
-
location: mocks_1.SampleLocation1,
|
|
12
|
-
parsedStructure: {
|
|
13
|
-
line: mocks_1.SampleLocation1.line + 1,
|
|
14
|
-
rawData: {
|
|
15
|
-
obj1: {
|
|
16
|
-
line: mocks_1.SampleLocation1.line + 2,
|
|
17
|
-
rawData: [
|
|
18
|
-
{
|
|
19
|
-
line: mocks_1.SampleLocation1.line + 3,
|
|
20
|
-
rawData: {
|
|
21
|
-
obj2: {
|
|
22
|
-
line: mocks_1.SampleLocation1.line + 4,
|
|
23
|
-
rawData: 'test data'
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
]
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
expect(raw_definition_helper_1.RawDefinitionHelper.findLine(rawDefinition, [])).toEqual(mocks_1.SampleLocation1.line + 1);
|
|
33
|
-
expect(raw_definition_helper_1.RawDefinitionHelper.findLine(rawDefinition, ['obj1'])).toEqual(
|
|
34
|
-
mocks_1.SampleLocation1.line + 2
|
|
35
|
-
);
|
|
36
|
-
expect(raw_definition_helper_1.RawDefinitionHelper.findLine(rawDefinition, ['obj1', 0])).toEqual(
|
|
37
|
-
mocks_1.SampleLocation1.line + 3
|
|
38
|
-
);
|
|
39
|
-
expect(raw_definition_helper_1.RawDefinitionHelper.findLine(rawDefinition, ['obj1', 0, 'obj2'])).toEqual(
|
|
40
|
-
mocks_1.SampleLocation1.line + 4
|
|
41
|
-
);
|
|
42
|
-
expect(raw_definition_helper_1.RawDefinitionHelper.findLine(rawDefinition, ['notExists'])).toEqual(
|
|
43
|
-
mocks_1.SampleLocation1.line + 1
|
|
44
|
-
);
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
describe('Flattening', () => {
|
|
48
|
-
test('primitive', () => {
|
|
49
|
-
let rawDefinition = {
|
|
50
|
-
componentName: ComponentName,
|
|
51
|
-
location: mocks_1.SampleLocation1,
|
|
52
|
-
parsedStructure: {
|
|
53
|
-
line: 0,
|
|
54
|
-
rawData: 'test'
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
let expected = 'test';
|
|
58
|
-
expect(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition)).toStrictEqual(expected);
|
|
59
|
-
});
|
|
60
|
-
test('array', () => {
|
|
61
|
-
let rawDefinition = {
|
|
62
|
-
componentName: ComponentName,
|
|
63
|
-
location: mocks_1.SampleLocation1,
|
|
64
|
-
parsedStructure: {
|
|
65
|
-
line: 0,
|
|
66
|
-
rawData: [
|
|
67
|
-
{
|
|
68
|
-
line: 0,
|
|
69
|
-
rawData: [
|
|
70
|
-
{
|
|
71
|
-
line: 0,
|
|
72
|
-
rawData: 'orange'
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
line: 0,
|
|
76
|
-
rawData: 'banana'
|
|
77
|
-
}
|
|
78
|
-
]
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
line: 0,
|
|
82
|
-
rawData: [
|
|
83
|
-
{
|
|
84
|
-
line: 0,
|
|
85
|
-
rawData: '1'
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
line: 0,
|
|
89
|
-
rawData: '2'
|
|
90
|
-
}
|
|
91
|
-
]
|
|
92
|
-
}
|
|
93
|
-
]
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
let expected = [
|
|
97
|
-
['orange', 'banana'],
|
|
98
|
-
['1', '2']
|
|
99
|
-
];
|
|
100
|
-
expect(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition)).toStrictEqual(expected);
|
|
101
|
-
});
|
|
102
|
-
test('object', () => {
|
|
103
|
-
let rawDefinition = {
|
|
104
|
-
componentName: ComponentName,
|
|
105
|
-
location: mocks_1.SampleLocation1,
|
|
106
|
-
parsedStructure: {
|
|
107
|
-
line: 0,
|
|
108
|
-
rawData: {
|
|
109
|
-
array1: {
|
|
110
|
-
line: 0,
|
|
111
|
-
rawData: [
|
|
112
|
-
{
|
|
113
|
-
line: 0,
|
|
114
|
-
rawData: 'apple'
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
line: 0,
|
|
118
|
-
rawData: 'orange'
|
|
119
|
-
}
|
|
120
|
-
]
|
|
121
|
-
},
|
|
122
|
-
array2: {
|
|
123
|
-
line: 0,
|
|
124
|
-
rawData: [
|
|
125
|
-
{
|
|
126
|
-
line: 0,
|
|
127
|
-
rawData: 'xWing'
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
line: 0,
|
|
131
|
-
rawData: 'tieFighter'
|
|
132
|
-
}
|
|
133
|
-
]
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
let expected = { array1: ['apple', 'orange'], array2: ['xWing', 'tieFighter'] };
|
|
139
|
-
expect(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition)).toStrictEqual(expected);
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
//# sourceMappingURL=raw-definition.helper.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,136 +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 raw_definition_helper_1 = require("./raw-definition.helper");
|
|
6
|
-
const ComponentName = 'ASSET';
|
|
7
|
-
(0, vitest_1.describe)('RAW DEFINITION HELPER', () => {
|
|
8
|
-
(0, vitest_1.describe)('Find Parsed Structure', () => {
|
|
9
|
-
(0, vitest_1.test)('nested definition', () => {
|
|
10
|
-
let rawDefinition = {
|
|
11
|
-
componentName: ComponentName,
|
|
12
|
-
location: mocks_1.SampleLocation1,
|
|
13
|
-
parsedStructure: {
|
|
14
|
-
line: mocks_1.SampleLocation1.line + 1,
|
|
15
|
-
rawData: {
|
|
16
|
-
obj1: {
|
|
17
|
-
line: mocks_1.SampleLocation1.line + 2,
|
|
18
|
-
rawData: [
|
|
19
|
-
{
|
|
20
|
-
line: mocks_1.SampleLocation1.line + 3,
|
|
21
|
-
rawData: {
|
|
22
|
-
obj2: {
|
|
23
|
-
line: mocks_1.SampleLocation1.line + 4,
|
|
24
|
-
rawData: 'test data'
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
]
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
(0, vitest_1.expect)(raw_definition_helper_1.RawDefinitionHelper.findLine(rawDefinition, [])).toEqual(mocks_1.SampleLocation1.line + 1);
|
|
34
|
-
(0, vitest_1.expect)(raw_definition_helper_1.RawDefinitionHelper.findLine(rawDefinition, ['obj1'])).toEqual(mocks_1.SampleLocation1.line + 2);
|
|
35
|
-
(0, vitest_1.expect)(raw_definition_helper_1.RawDefinitionHelper.findLine(rawDefinition, ['obj1', 0])).toEqual(mocks_1.SampleLocation1.line + 3);
|
|
36
|
-
(0, vitest_1.expect)(raw_definition_helper_1.RawDefinitionHelper.findLine(rawDefinition, ['obj1', 0, 'obj2'])).toEqual(mocks_1.SampleLocation1.line + 4);
|
|
37
|
-
(0, vitest_1.expect)(raw_definition_helper_1.RawDefinitionHelper.findLine(rawDefinition, ['notExists'])).toEqual(mocks_1.SampleLocation1.line + 1);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
(0, vitest_1.describe)('Flattening', () => {
|
|
41
|
-
(0, vitest_1.test)('primitive', () => {
|
|
42
|
-
let rawDefinition = {
|
|
43
|
-
componentName: ComponentName,
|
|
44
|
-
location: mocks_1.SampleLocation1,
|
|
45
|
-
parsedStructure: {
|
|
46
|
-
line: 0,
|
|
47
|
-
rawData: 'test'
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
let expected = 'test';
|
|
51
|
-
(0, vitest_1.expect)(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition)).toStrictEqual(expected);
|
|
52
|
-
});
|
|
53
|
-
(0, vitest_1.test)('array', () => {
|
|
54
|
-
let rawDefinition = {
|
|
55
|
-
componentName: ComponentName,
|
|
56
|
-
location: mocks_1.SampleLocation1,
|
|
57
|
-
parsedStructure: {
|
|
58
|
-
line: 0,
|
|
59
|
-
rawData: [
|
|
60
|
-
{
|
|
61
|
-
line: 0,
|
|
62
|
-
rawData: [
|
|
63
|
-
{
|
|
64
|
-
line: 0,
|
|
65
|
-
rawData: 'orange'
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
line: 0,
|
|
69
|
-
rawData: 'banana'
|
|
70
|
-
}
|
|
71
|
-
]
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
line: 0,
|
|
75
|
-
rawData: [
|
|
76
|
-
{
|
|
77
|
-
line: 0,
|
|
78
|
-
rawData: '1'
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
line: 0,
|
|
82
|
-
rawData: '2'
|
|
83
|
-
}
|
|
84
|
-
]
|
|
85
|
-
}
|
|
86
|
-
]
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
let expected = [
|
|
90
|
-
['orange', 'banana'],
|
|
91
|
-
['1', '2']
|
|
92
|
-
];
|
|
93
|
-
(0, vitest_1.expect)(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition)).toStrictEqual(expected);
|
|
94
|
-
});
|
|
95
|
-
(0, vitest_1.test)('object', () => {
|
|
96
|
-
let rawDefinition = {
|
|
97
|
-
componentName: ComponentName,
|
|
98
|
-
location: mocks_1.SampleLocation1,
|
|
99
|
-
parsedStructure: {
|
|
100
|
-
line: 0,
|
|
101
|
-
rawData: {
|
|
102
|
-
array1: {
|
|
103
|
-
line: 0,
|
|
104
|
-
rawData: [
|
|
105
|
-
{
|
|
106
|
-
line: 0,
|
|
107
|
-
rawData: 'apple'
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
line: 0,
|
|
111
|
-
rawData: 'orange'
|
|
112
|
-
}
|
|
113
|
-
]
|
|
114
|
-
},
|
|
115
|
-
array2: {
|
|
116
|
-
line: 0,
|
|
117
|
-
rawData: [
|
|
118
|
-
{
|
|
119
|
-
line: 0,
|
|
120
|
-
rawData: 'xWing'
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
line: 0,
|
|
124
|
-
rawData: 'tieFighter'
|
|
125
|
-
}
|
|
126
|
-
]
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
let expected = { array1: ['apple', 'orange'], array2: ['xWing', 'tieFighter'] };
|
|
132
|
-
(0, vitest_1.expect)(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition)).toStrictEqual(expected);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
//# sourceMappingURL=raw-definition.helper.test.js.map
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import Joi from 'joi';
|
|
2
|
-
import { DefinitionComponentClassType } from '../../../decorators/definition-component';
|
|
3
|
-
import { RawDefinition } from '../../../framework/interfaces';
|
|
4
|
-
import { DuplicateHelper } from '../../duplicate-helper/duplicate-helper';
|
|
5
|
-
export declare class CustomValidatorHelper {
|
|
6
|
-
private static duplicateHelpers;
|
|
7
|
-
static logDuplicates(): void;
|
|
8
|
-
static getDefinitionComponentName(definitionComponentClass: DefinitionComponentClassType<any>): string;
|
|
9
|
-
static getDefinitionComponentNamesFromArray(definitionComponentClasses: DefinitionComponentClassType<any> | DefinitionComponentClassType<any>[]): string[];
|
|
10
|
-
static getValidationState(helpers: Joi.CustomHelpers): 'notValid' | 'valid';
|
|
11
|
-
static getPathAndRawDefinition(helpers: Joi.CustomHelpers): {
|
|
12
|
-
path: string[];
|
|
13
|
-
rawDefinition: RawDefinition;
|
|
14
|
-
};
|
|
15
|
-
static getDuplicateHelper(componentName: string): DuplicateHelper;
|
|
16
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CustomValidatorHelper = void 0;
|
|
4
|
-
const helpers_lib_1 = require("helpers-lib");
|
|
5
|
-
const duplicate_helper_1 = require("../../duplicate-helper/duplicate-helper");
|
|
6
|
-
class CustomValidatorHelper {
|
|
7
|
-
static { this.duplicateHelpers = new Map(); }
|
|
8
|
-
static logDuplicates() {
|
|
9
|
-
this.duplicateHelpers.forEach(duplicateHelper => duplicateHelper.logDuplicateErrors());
|
|
10
|
-
}
|
|
11
|
-
static getDefinitionComponentName(definitionComponentClass) {
|
|
12
|
-
return definitionComponentClass.$meta.componentName;
|
|
13
|
-
}
|
|
14
|
-
static getDefinitionComponentNamesFromArray(definitionComponentClasses) {
|
|
15
|
-
return helpers_lib_1.Comparator.isArray(definitionComponentClasses)
|
|
16
|
-
? definitionComponentClasses.map(definitionComponentClass => this.getDefinitionComponentName(definitionComponentClass))
|
|
17
|
-
: [this.getDefinitionComponentName(definitionComponentClasses)];
|
|
18
|
-
}
|
|
19
|
-
static getValidationState(helpers) {
|
|
20
|
-
if (!helpers.state.path) {
|
|
21
|
-
return 'notValid';
|
|
22
|
-
}
|
|
23
|
-
else if (helpers.state.path.length === 0) {
|
|
24
|
-
return 'valid';
|
|
25
|
-
}
|
|
26
|
-
else if (helpers.state.path[0] !== undefined && helpers.prefs.context.rawDefinition) {
|
|
27
|
-
return 'valid';
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
return 'notValid';
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
static getPathAndRawDefinition(helpers) {
|
|
34
|
-
let path = helpers.state.path;
|
|
35
|
-
let rawDefinition = helpers.prefs.context.rawDefinition;
|
|
36
|
-
return { path, rawDefinition };
|
|
37
|
-
}
|
|
38
|
-
static getDuplicateHelper(componentName) {
|
|
39
|
-
let duplicateHelper = this.duplicateHelpers.get(componentName);
|
|
40
|
-
if (!duplicateHelper) {
|
|
41
|
-
duplicateHelper = new duplicate_helper_1.DuplicateHelper(componentName);
|
|
42
|
-
this.duplicateHelpers.set(componentName, duplicateHelper);
|
|
43
|
-
}
|
|
44
|
-
return duplicateHelper;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.CustomValidatorHelper = CustomValidatorHelper;
|
|
48
|
-
//# sourceMappingURL=custom-validator.helper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const AssetComponentName = 'ASSET';
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var __importDefault =
|
|
3
|
-
(this && this.__importDefault) ||
|
|
4
|
-
function (mod) {
|
|
5
|
-
return mod && mod.__esModule ? mod : { default: mod };
|
|
6
|
-
};
|
|
7
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
8
|
-
exports.AssetComponentName = void 0;
|
|
9
|
-
const joi_1 = __importDefault(require('joi'));
|
|
10
|
-
const joi_custom_validators_1 = require('../joi-custom-validators');
|
|
11
|
-
const mocks_1 = require('../../../_mocks/mocks');
|
|
12
|
-
const raw_definition_helper_1 = require('../../raw-definition-helper/raw-definition.helper');
|
|
13
|
-
const custom_validator_helper_1 = require('./custom-validator.helper');
|
|
14
|
-
const context_1 = require('../../../framework/context');
|
|
15
|
-
const definition_store_1 = require('../../../framework/definition-store');
|
|
16
|
-
joi_custom_validators_1.JoiCustomValidators.decorate(joi_1.default, { existsSync: path => path !== 'D:/test/false/path.png' });
|
|
17
|
-
exports.AssetComponentName = 'ASSET';
|
|
18
|
-
class Asset {
|
|
19
|
-
static {
|
|
20
|
-
this.$meta = {
|
|
21
|
-
componentName: exports.AssetComponentName
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
async process() {}
|
|
25
|
-
}
|
|
26
|
-
class AssetGroup {
|
|
27
|
-
static {
|
|
28
|
-
this.$meta = {
|
|
29
|
-
componentName: 'ASSET-GROUP'
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
async process() {}
|
|
33
|
-
}
|
|
34
|
-
function getSimpleRawDefinition(value, offset = 1) {
|
|
35
|
-
return {
|
|
36
|
-
componentName: exports.AssetComponentName,
|
|
37
|
-
location: mocks_1.SampleLocation1,
|
|
38
|
-
parsedStructure: {
|
|
39
|
-
line: mocks_1.SampleLocation1.line + offset,
|
|
40
|
-
rawData: {
|
|
41
|
-
value: {
|
|
42
|
-
rawData: value,
|
|
43
|
-
line: mocks_1.SampleLocation1.line + offset
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
function getFlatRawDefinition(value, offset = 1) {
|
|
50
|
-
return {
|
|
51
|
-
componentName: exports.AssetComponentName,
|
|
52
|
-
location: mocks_1.SampleLocation1,
|
|
53
|
-
parsedStructure: {
|
|
54
|
-
line: mocks_1.SampleLocation1.line + offset,
|
|
55
|
-
rawData: value
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
describe('JOI CUSTOM VALIDATORS', () => {
|
|
60
|
-
beforeEach(() => {
|
|
61
|
-
context_1.Context.config.projectRoot = 'D:/';
|
|
62
|
-
custom_validator_helper_1.CustomValidatorHelper['duplicateHelpers'] = new Map();
|
|
63
|
-
});
|
|
64
|
-
describe('Variable Name', () => {
|
|
65
|
-
let schema = joi_1.default.object().keys({
|
|
66
|
-
value: joi_1.default.string().required()
|
|
67
|
-
});
|
|
68
|
-
test('valid data', () => {
|
|
69
|
-
let rawDefinition = getSimpleRawDefinition('test');
|
|
70
|
-
let { value, error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
|
|
71
|
-
abortEarly: false,
|
|
72
|
-
context: rawDefinition
|
|
73
|
-
});
|
|
74
|
-
expect(value).toEqual({ value: 'test' });
|
|
75
|
-
expect(error).toEqual(undefined);
|
|
76
|
-
});
|
|
77
|
-
test('different groups should not create duplicates', () => {
|
|
78
|
-
let schema2 = joi_1.default.object().keys({
|
|
79
|
-
value: joi_1.default.string().required()
|
|
80
|
-
});
|
|
81
|
-
let rawDefinition1 = getSimpleRawDefinition('test', 1);
|
|
82
|
-
let rawDefinition2 = getSimpleRawDefinition('test', 2);
|
|
83
|
-
schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition1), {
|
|
84
|
-
abortEarly: false,
|
|
85
|
-
context: rawDefinition1
|
|
86
|
-
});
|
|
87
|
-
schema2.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition2), {
|
|
88
|
-
abortEarly: false,
|
|
89
|
-
context: rawDefinition2
|
|
90
|
-
});
|
|
91
|
-
(0, mocks_1.resetContext)();
|
|
92
|
-
custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
|
|
93
|
-
expect(context_1.Context.errorLogs).toStrictEqual([]);
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
describe('Reference', () => {
|
|
97
|
-
let schema = joi_1.default.object().keys({
|
|
98
|
-
value: joi_1.default.string().reference(Asset).required()
|
|
99
|
-
});
|
|
100
|
-
let multipleSchema = joi_1.default.object().keys({
|
|
101
|
-
value: joi_1.default.string().reference([AssetGroup, Asset]).required()
|
|
102
|
-
});
|
|
103
|
-
test('valid data', () => {
|
|
104
|
-
let rawDefinition = getSimpleRawDefinition('test');
|
|
105
|
-
definition_store_1.DefinitionStore['setRawDefinition'](Asset, 'test', rawDefinition);
|
|
106
|
-
let { value, error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
|
|
107
|
-
abortEarly: false,
|
|
108
|
-
context: rawDefinition
|
|
109
|
-
});
|
|
110
|
-
expect(value).toEqual({ value: 'test' });
|
|
111
|
-
expect(error).toEqual(undefined);
|
|
112
|
-
});
|
|
113
|
-
test('multiple reference', () => {
|
|
114
|
-
let rawDefinition = getSimpleRawDefinition('test');
|
|
115
|
-
definition_store_1.DefinitionStore['setRawDefinition'](Asset, 'test', rawDefinition);
|
|
116
|
-
let { value, error } = multipleSchema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
|
|
117
|
-
abortEarly: false,
|
|
118
|
-
context: rawDefinition
|
|
119
|
-
});
|
|
120
|
-
expect(value).toEqual({ value: 'test' });
|
|
121
|
-
expect(error).toEqual(undefined);
|
|
122
|
-
});
|
|
123
|
-
test('primitive valid data', () => {
|
|
124
|
-
let rawDefinition = getFlatRawDefinition('test');
|
|
125
|
-
let primitiveSchema = joi_1.default.string().reference(Asset).required();
|
|
126
|
-
definition_store_1.DefinitionStore['setRawDefinition'](Asset, 'test', rawDefinition);
|
|
127
|
-
let { value, error } = primitiveSchema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
|
|
128
|
-
abortEarly: false,
|
|
129
|
-
context: rawDefinition
|
|
130
|
-
});
|
|
131
|
-
expect(value).toEqual('test');
|
|
132
|
-
expect(error).toEqual(undefined);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
describe('Path', () => {
|
|
136
|
-
let schema = joi_1.default.object().keys({
|
|
137
|
-
value: joi_1.default.string().path().required()
|
|
138
|
-
});
|
|
139
|
-
test('valid data', () => {
|
|
140
|
-
let rawDefinition = getSimpleRawDefinition('images/test.png');
|
|
141
|
-
let { value, error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
|
|
142
|
-
abortEarly: false,
|
|
143
|
-
context: rawDefinition
|
|
144
|
-
});
|
|
145
|
-
expect(value).toEqual({ value: '.test/images/test.png' });
|
|
146
|
-
expect(error).toEqual(undefined);
|
|
147
|
-
});
|
|
148
|
-
test('should detect files not existing, invalid url', () => {
|
|
149
|
-
let rawDefinition = getSimpleRawDefinition('invalid data');
|
|
150
|
-
let { error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
|
|
151
|
-
abortEarly: false,
|
|
152
|
-
context: rawDefinition
|
|
153
|
-
});
|
|
154
|
-
expect(error?.details).toStrictEqual([
|
|
155
|
-
{
|
|
156
|
-
message: '"value" with value "invalid data" fails to match the required pattern: /^[\\S]+$/',
|
|
157
|
-
path: ['value'],
|
|
158
|
-
type: 'string.pattern.base',
|
|
159
|
-
context: {
|
|
160
|
-
name: undefined,
|
|
161
|
-
regex: /^[\S]+$/,
|
|
162
|
-
value: 'invalid data',
|
|
163
|
-
label: 'value',
|
|
164
|
-
key: 'value'
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
]);
|
|
168
|
-
});
|
|
169
|
-
test('should detect files not existing, missing file', () => {
|
|
170
|
-
let rawDefinition = getSimpleRawDefinition('false/path.png');
|
|
171
|
-
let { error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
|
|
172
|
-
abortEarly: false,
|
|
173
|
-
context: rawDefinition
|
|
174
|
-
});
|
|
175
|
-
expect(error?.details).toStrictEqual([
|
|
176
|
-
{
|
|
177
|
-
message: '"value" failed custom validation because No file is found in the path: "D:/test/false/path.png"',
|
|
178
|
-
path: ['value'],
|
|
179
|
-
type: 'any.custom',
|
|
180
|
-
context: {
|
|
181
|
-
error: new Error('No file is found in the path: "D:/test/false/path.png"'),
|
|
182
|
-
label: 'value',
|
|
183
|
-
value: 'false/path.png',
|
|
184
|
-
key: 'value'
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
]);
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
//# sourceMappingURL=custom-validator.helper.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const AssetComponentName = "ASSET";
|