definition-generator-framework 1.12.4 → 1.12.6
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/framework/definition-component.d.ts +11 -9
- package/dist/framework/definition-component.js +18 -18
- package/dist/framework/definition-generator.d.ts +6 -5
- package/dist/framework/definition-generator.js +16 -18
- package/dist/framework/file-content-generator/file-content-generator.js +1 -1
- package/dist/framework/file-content-generator/file-content-generator.test.js +49 -49
- package/dist/framework/framework.d.ts +14 -13
- package/dist/framework/framework.data.d.ts +3 -3
- package/dist/framework/framework.data.js +13 -7
- package/dist/framework/framework.js +36 -33
- package/dist/framework/framework.model.d.ts +15 -15
- package/dist/framework/framework.model.js +3 -3
- package/dist/helpers/common-functions/common-functions.js +1 -1
- package/dist/helpers/common-functions/common-functions.spec.d.ts +1 -0
- package/dist/helpers/common-functions/common-functions.spec.js +50 -0
- package/dist/helpers/duplicate-helper/duplicate-helper.spec.d.ts +1 -0
- package/dist/helpers/duplicate-helper/duplicate-helper.spec.js +54 -0
- package/dist/helpers/output-helper/output-helper.d.ts +26 -26
- package/dist/helpers/output-helper/output-helper.js +127 -107
- package/dist/helpers/output-helper/output-helper.spec.d.ts +24 -0
- package/dist/helpers/output-helper/output-helper.spec.js +261 -0
- package/dist/helpers/output-helper/output-helper.test.d.ts +22 -22
- package/dist/helpers/output-helper/output-helper.test.js +224 -212
- package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.d.ts +1 -0
- package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.js +143 -0
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.d.ts +1 -0
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.js +191 -0
- package/dist/helpers/validator/custom-validators/image.custom-validator.d.ts +6 -6
- package/dist/helpers/validator/custom-validators/image.custom-validator.js +40 -39
- package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.d.ts +4 -4
- package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.js +29 -29
- package/dist/helpers/validator/joi-custom-validators.spec.d.ts +1 -0
- package/dist/helpers/validator/joi-custom-validators.spec.js +304 -0
- package/dist/helpers/validator/validator.spec.d.ts +1 -0
- package/dist/helpers/validator/validator.spec.js +332 -0
- package/dist/pipeline/1-select-definitions-helper.d.ts +13 -13
- package/dist/pipeline/1-select-definitions-helper.js +68 -72
- package/dist/pipeline/1-select-definitions.helper.test.js +40 -40
- package/dist/pipeline/1-select-definitions.spec.d.ts +1 -0
- package/dist/pipeline/1-select-definitions.spec.js +140 -0
- package/dist/pipeline/2-structure-parser.helper.spec.d.ts +1 -0
- package/dist/pipeline/2-structure-parser.helper.spec.js +280 -0
- package/dist/pipeline/parsers/array-parser.spec.d.ts +1 -0
- package/dist/pipeline/parsers/array-parser.spec.js +128 -0
- package/dist/pipeline/parsers/object-parser.spec.d.ts +1 -0
- package/dist/pipeline/parsers/object-parser.spec.js +179 -0
- package/dist/pipeline/parsers/primitive-parser.spec.d.ts +1 -0
- package/dist/pipeline/parsers/primitive-parser.spec.js +79 -0
- package/dist/pre-made-components/assets/3-font.js +4 -4
- package/dist/pre-made-components/events/1-event.d.ts +1 -1
- package/dist/pre-made-components/events/1-event.js +157 -125
- package/dist/pre-made-components/events/2-event-test.d.ts +8 -8
- package/dist/pre-made-components/events/2-event-test.js +156 -119
- package/dist/pre-made-components/events/2-script-test.js +0 -1
- package/dist/pre-made-components/events/event-setup.d.ts +10 -5
- package/dist/pre-made-components/events/event-setup.js +15 -15
- package/dist/pre-made-components/events/script-setup.d.ts +5 -3
- package/dist/pre-made-components/events/script-setup.js +11 -11
- package/package.json +11 -11
- package/.eslintrc.js +0 -212
- package/.vscode/launch.json +0 -15
- package/.vscode/settings.json +0 -25
- package/coverage/clover.xml +0 -503
- package/coverage/coverage-final.json +0 -16
- package/coverage/lcov-report/_mocks/index.html +0 -116
- package/coverage/lcov-report/_mocks/mocks.ts.html +0 -223
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/framework/framework.data.ts.html +0 -109
- package/coverage/lcov-report/framework/index.html +0 -116
- package/coverage/lcov-report/helpers/common-functions/common-functions.ts.html +0 -178
- package/coverage/lcov-report/helpers/common-functions/index.html +0 -116
- package/coverage/lcov-report/helpers/duplicate-helper/duplicate-helper.ts.html +0 -196
- package/coverage/lcov-report/helpers/duplicate-helper/index.html +0 -116
- package/coverage/lcov-report/helpers/output-helper/index.html +0 -116
- package/coverage/lcov-report/helpers/output-helper/output-helper.ts.html +0 -277
- package/coverage/lcov-report/helpers/raw-definition-helper/index.html +0 -116
- package/coverage/lcov-report/helpers/raw-definition-helper/raw-definition.helper.ts.html +0 -256
- package/coverage/lcov-report/helpers/validator/index.html +0 -131
- package/coverage/lcov-report/helpers/validator/joi-custom-validators.ts.html +0 -643
- package/coverage/lcov-report/helpers/validator/validator.ts.html +0 -310
- package/coverage/lcov-report/index.html +0 -251
- package/coverage/lcov-report/pipeline/1-select-definitions-helper.ts.html +0 -358
- package/coverage/lcov-report/pipeline/2-structure-parser.helper.ts.html +0 -301
- package/coverage/lcov-report/pipeline/3-config.ts.html +0 -178
- package/coverage/lcov-report/pipeline/_mocks/index.html +0 -116
- package/coverage/lcov-report/pipeline/_mocks/index.ts.html +0 -229
- package/coverage/lcov-report/pipeline/index.html +0 -146
- package/coverage/lcov-report/pipeline/parsers/array-parser.ts.html +0 -271
- package/coverage/lcov-report/pipeline/parsers/index.html +0 -146
- package/coverage/lcov-report/pipeline/parsers/object-parser.ts.html +0 -439
- package/coverage/lcov-report/pipeline/parsers/primitive-parser.ts.html +0 -370
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov.info +0 -911
- package/dist/_mocks/mocks.js.map +0 -1
- package/dist/decorators/definition-component.js.map +0 -1
- package/dist/decorators/definition-generator.js.map +0 -1
- package/dist/framework/context.js.map +0 -1
- package/dist/framework/definition-component.js.map +0 -1
- package/dist/framework/definition-generator.js.map +0 -1
- package/dist/framework/definition-store.js.map +0 -1
- package/dist/framework/file-content-generator/file-content-generator.js.map +0 -1
- package/dist/framework/file-content-generator/file-content-generator.test.js.map +0 -1
- package/dist/framework/framework.data.js.map +0 -1
- package/dist/framework/framework.js.map +0 -1
- package/dist/framework/framework.model.js.map +0 -1
- package/dist/framework/index-file-generator/index-file-generator.js.map +0 -1
- package/dist/framework/interfaces.js.map +0 -1
- package/dist/framework/kernel.js.map +0 -1
- package/dist/helpers/common-functions/common-functions.js.map +0 -1
- package/dist/helpers/common-functions/common-functions.spec.js.map +0 -1
- package/dist/helpers/common-functions/common-functions.test.js.map +0 -1
- package/dist/helpers/duplicate-helper/duplicate-helper.js.map +0 -1
- package/dist/helpers/duplicate-helper/duplicate-helper.spec.js.map +0 -1
- package/dist/helpers/duplicate-helper/duplicate-helper.test.js.map +0 -1
- package/dist/helpers/output-helper/output-helper.js.map +0 -1
- package/dist/helpers/output-helper/output-helper.spec.js.map +0 -1
- package/dist/helpers/output-helper/output-helper.test.js.map +0 -1
- package/dist/helpers/raw-definition-helper/raw-definition.helper.js.map +0 -1
- package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.js.map +0 -1
- package/dist/helpers/raw-definition-helper/raw-definition.helper.test.js.map +0 -1
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.js.map +0 -1
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.js.map +0 -1
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.test.js.map +0 -1
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.js.map +0 -1
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.test.js.map +0 -1
- package/dist/helpers/validator/custom-validators/image.custom-validator.js.map +0 -1
- package/dist/helpers/validator/custom-validators/path.custom-validator.js.map +0 -1
- package/dist/helpers/validator/custom-validators/position-on-sprite.js.map +0 -1
- package/dist/helpers/validator/custom-validators/reference.custom-validator.js.map +0 -1
- package/dist/helpers/validator/custom-validators/sprite.custom-validator.js.map +0 -1
- package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.js.map +0 -1
- package/dist/helpers/validator/custom-validators/unique.custom-validator.js.map +0 -1
- package/dist/helpers/validator/joi-custom-validators.js.map +0 -1
- package/dist/helpers/validator/joi-custom-validators.spec.js.map +0 -1
- package/dist/helpers/validator/validator.js.map +0 -1
- package/dist/helpers/validator/validator.spec.js.map +0 -1
- package/dist/helpers/validator/validator.test.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/pipeline/1-select-definitions-helper.js.map +0 -1
- package/dist/pipeline/1-select-definitions.helper.js.map +0 -1
- package/dist/pipeline/1-select-definitions.helper.test.js.map +0 -1
- package/dist/pipeline/1-select-definitions.spec.js.map +0 -1
- package/dist/pipeline/2-structure-parser.helper.js.map +0 -1
- package/dist/pipeline/2-structure-parser.helper.spec.js.map +0 -1
- package/dist/pipeline/2-structure-parser.helper.test.js.map +0 -1
- package/dist/pipeline/3-config.js.map +0 -1
- package/dist/pipeline/_mocks/index.js.map +0 -1
- package/dist/pipeline/parsers/array-parser.js.map +0 -1
- package/dist/pipeline/parsers/array-parser.spec.js.map +0 -1
- package/dist/pipeline/parsers/array-parser.test.js.map +0 -1
- package/dist/pipeline/parsers/object-parser.js.map +0 -1
- package/dist/pipeline/parsers/object-parser.spec.js.map +0 -1
- package/dist/pipeline/parsers/object-parser.test.js.map +0 -1
- package/dist/pipeline/parsers/primitive-parser.js.map +0 -1
- package/dist/pipeline/parsers/primitive-parser.spec.js.map +0 -1
- package/dist/pipeline/parsers/primitive-parser.test.js.map +0 -1
- package/dist/pipeline/raw-data-parser.js.map +0 -1
- package/dist/pre-made-components/_validators/shape-validators.js.map +0 -1
- package/dist/pre-made-components/_validators/sprite-validators.js.map +0 -1
- package/dist/pre-made-components/assets/1-sprite.js.map +0 -1
- package/dist/pre-made-components/assets/2-sprite-group.js.map +0 -1
- package/dist/pre-made-components/assets/3-font.js.map +0 -1
- package/dist/pre-made-components/events/1-event.js.map +0 -1
- package/dist/pre-made-components/events/1-script.js.map +0 -1
- package/dist/pre-made-components/events/2-event-test.js.map +0 -1
- package/dist/pre-made-components/events/2-script-test.js.map +0 -1
- package/dist/pre-made-components/events/3-event.js.map +0 -1
- package/dist/pre-made-components/events/4-event-test.js.map +0 -1
- package/dist/pre-made-components/events/event-setup.js.map +0 -1
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.js.map +0 -1
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.test.js.map +0 -1
- package/dist/pre-made-components/events/helpers/script-testing.helper.js.map +0 -1
- package/dist/pre-made-components/events/script-setup.js.map +0 -1
- package/dist/pre-made-components/events/scripting-setup.js.map +0 -1
- package/dist/pre-made-components/events/validators.js.map +0 -1
- package/dist/setup.js.map +0 -1
- package/package.json.bak +0 -60
- package/scripts/prepare-package-json.ts +0 -23
- package/tsconfig.json +0 -24
- package/vitest.config.ts +0 -1
|
@@ -0,0 +1,191 @@
|
|
|
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
|
|
@@ -3,12 +3,12 @@ import { Vec2 } from 'pixi-framework';
|
|
|
3
3
|
import { CustomValidator } from '../joi-custom-validators';
|
|
4
4
|
import { FileSystem } from '../../../framework/framework.model';
|
|
5
5
|
export interface ValidatedImageUrl {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
readonly url: string;
|
|
7
|
+
readonly size: Vec2;
|
|
8
8
|
}
|
|
9
9
|
export declare class ImageCustomValidator implements CustomValidator {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
private fs;
|
|
11
|
+
readonly regex: RegExp;
|
|
12
|
+
readonly validate: (value: string, helpers: Joi.CustomHelpers) => any | ErrorReport;
|
|
13
|
+
constructor(fs: FileSystem);
|
|
14
14
|
}
|
|
@@ -1,43 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 });
|
|
6
8
|
exports.ImageCustomValidator = void 0;
|
|
7
|
-
const image_size_1 = __importDefault(require(
|
|
8
|
-
const custom_validator_helper_1 = require(
|
|
9
|
-
const context_1 = require(
|
|
9
|
+
const image_size_1 = __importDefault(require('image-size'));
|
|
10
|
+
const custom_validator_helper_1 = require('../custom-validator-helper/custom-validator.helper');
|
|
11
|
+
const context_1 = require('../../../framework/context');
|
|
10
12
|
class ImageCustomValidator {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
13
|
+
constructor(fs) {
|
|
14
|
+
this.fs = fs;
|
|
15
|
+
this.regex = /^[\S]+$/;
|
|
16
|
+
this.validate = (value, helpers) => {
|
|
17
|
+
let validationState = custom_validator_helper_1.CustomValidatorHelper.getValidationState(helpers);
|
|
18
|
+
if (validationState === 'valid') {
|
|
19
|
+
let { rawDefinition } = custom_validator_helper_1.CustomValidatorHelper.getPathAndRawDefinition(helpers);
|
|
20
|
+
let pathPrefix = rawDefinition.location.path.substring(0, rawDefinition.location.path.lastIndexOf('/') + 1);
|
|
21
|
+
value = pathPrefix + value;
|
|
22
|
+
if (!this.fs.existsSync(value)) {
|
|
23
|
+
throw new Error(`No file is found in the path: "${value}"`);
|
|
24
|
+
} else {
|
|
25
|
+
try {
|
|
26
|
+
let size = (0, image_size_1.default)(value);
|
|
27
|
+
return {
|
|
28
|
+
url: value.replace(context_1.Context.config.projectRoot, '.'),
|
|
29
|
+
size: { x: size.width, y: size.height }
|
|
30
|
+
};
|
|
31
|
+
} catch (error) {
|
|
32
|
+
throw new Error(`The file in the path "${value}" is not an image`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
throw new Error(
|
|
37
|
+
`Internal Error; joi validation context for image validator: Path: "${helpers.state.path}", RawDefinition: "${JSON.stringify(helpers.prefs.context)}"`
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
41
42
|
}
|
|
42
43
|
exports.ImageCustomValidator = ImageCustomValidator;
|
|
43
|
-
//# sourceMappingURL=image.custom-validator.js.map
|
|
44
|
+
//# sourceMappingURL=image.custom-validator.js.map
|
|
@@ -2,8 +2,8 @@ import Joi, { ErrorReport } from 'joi';
|
|
|
2
2
|
import { CustomValidator } from '../joi-custom-validators';
|
|
3
3
|
import { DefinitionComponentClassType } from '../../../framework/definition-component';
|
|
4
4
|
export declare class UniqueNameGroupCustomValidator implements CustomValidator {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
private definitionComponentClass;
|
|
6
|
+
readonly regex: RegExp;
|
|
7
|
+
readonly validate: (value: string, helpers: Joi.CustomHelpers) => any | ErrorReport;
|
|
8
|
+
constructor(definitionComponentClass: DefinitionComponentClassType<any>);
|
|
9
9
|
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
3
|
exports.UniqueNameGroupCustomValidator = void 0;
|
|
4
|
-
const common_functions_1 = require(
|
|
5
|
-
const raw_definition_helper_1 = require(
|
|
6
|
-
const custom_validator_helper_1 = require(
|
|
4
|
+
const common_functions_1 = require('../../common-functions/common-functions');
|
|
5
|
+
const raw_definition_helper_1 = require('../../raw-definition-helper/raw-definition.helper');
|
|
6
|
+
const custom_validator_helper_1 = require('../custom-validator-helper/custom-validator.helper');
|
|
7
7
|
class UniqueNameGroupCustomValidator {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
8
|
+
constructor(definitionComponentClass) {
|
|
9
|
+
this.definitionComponentClass = definitionComponentClass;
|
|
10
|
+
this.regex = /^[a-z]+([a-zA-Z0-9]+)*$/;
|
|
11
|
+
this.validate = (value, helpers) => {
|
|
12
|
+
let componentName = this.definitionComponentClass.$meta.componentName;
|
|
13
|
+
let validationState = custom_validator_helper_1.CustomValidatorHelper.getValidationState(helpers);
|
|
14
|
+
if (validationState === 'valid') {
|
|
15
|
+
let { path, rawDefinition } = custom_validator_helper_1.CustomValidatorHelper.getPathAndRawDefinition(helpers);
|
|
16
|
+
let duplicateHelper = custom_validator_helper_1.CustomValidatorHelper.getDuplicateHelper(componentName);
|
|
17
|
+
duplicateHelper.newEntry(value, {
|
|
18
|
+
line: raw_definition_helper_1.RawDefinitionHelper.findLine(rawDefinition, path),
|
|
19
|
+
path: rawDefinition.location.path
|
|
20
|
+
});
|
|
21
|
+
return common_functions_1.CommonFunctions.decorateDefinitionName(value, componentName);
|
|
22
|
+
} else if (validationState === 'registerLoop') {
|
|
23
|
+
custom_validator_helper_1.CustomValidatorHelper.getDefinitionNames(componentName).add(value);
|
|
24
|
+
} else {
|
|
25
|
+
throw new Error(
|
|
26
|
+
`Internal Error; joi validation context for uniqueNameGroup validator: Path: "${helpers.state.path}", RawDefinition: "${JSON.stringify(helpers.prefs.context)}"`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
31
|
}
|
|
32
32
|
exports.UniqueNameGroupCustomValidator = UniqueNameGroupCustomValidator;
|
|
33
|
-
//# sourceMappingURL=unique-name-group.custom-validator.js.map
|
|
33
|
+
//# sourceMappingURL=unique-name-group.custom-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|