definition-generator-framework 1.12.5 → 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.
Files changed (49) hide show
  1. package/dist/framework/definition-component.d.ts +11 -9
  2. package/dist/framework/definition-component.js +18 -18
  3. package/dist/framework/definition-generator.d.ts +6 -5
  4. package/dist/framework/definition-generator.js +16 -18
  5. package/dist/framework/file-content-generator/file-content-generator.js +1 -1
  6. package/dist/framework/file-content-generator/file-content-generator.test.js +49 -49
  7. package/dist/framework/framework.d.ts +14 -13
  8. package/dist/framework/framework.data.d.ts +3 -3
  9. package/dist/framework/framework.data.js +13 -7
  10. package/dist/framework/framework.js +36 -33
  11. package/dist/framework/framework.model.d.ts +15 -15
  12. package/dist/framework/framework.model.js +3 -3
  13. package/dist/helpers/common-functions/common-functions.js +1 -1
  14. package/dist/helpers/common-functions/common-functions.spec.js +48 -48
  15. package/dist/helpers/duplicate-helper/duplicate-helper.spec.js +52 -52
  16. package/dist/helpers/output-helper/output-helper.d.ts +26 -26
  17. package/dist/helpers/output-helper/output-helper.js +127 -107
  18. package/dist/helpers/output-helper/output-helper.spec.d.ts +22 -22
  19. package/dist/helpers/output-helper/output-helper.spec.js +223 -211
  20. package/dist/helpers/output-helper/output-helper.test.d.ts +22 -22
  21. package/dist/helpers/output-helper/output-helper.test.js +224 -212
  22. package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.js +133 -125
  23. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.d.ts +1 -1
  24. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.js +174 -156
  25. package/dist/helpers/validator/custom-validators/image.custom-validator.d.ts +6 -6
  26. package/dist/helpers/validator/custom-validators/image.custom-validator.js +40 -39
  27. package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.d.ts +4 -4
  28. package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.js +29 -29
  29. package/dist/helpers/validator/joi-custom-validators.spec.js +284 -240
  30. package/dist/helpers/validator/validator.spec.js +313 -303
  31. package/dist/pipeline/1-select-definitions-helper.d.ts +13 -13
  32. package/dist/pipeline/1-select-definitions-helper.js +68 -72
  33. package/dist/pipeline/1-select-definitions.helper.test.js +40 -40
  34. package/dist/pipeline/1-select-definitions.spec.js +131 -131
  35. package/dist/pipeline/2-structure-parser.helper.spec.js +266 -266
  36. package/dist/pipeline/parsers/array-parser.spec.js +116 -113
  37. package/dist/pipeline/parsers/object-parser.spec.js +159 -153
  38. package/dist/pipeline/parsers/primitive-parser.spec.js +67 -67
  39. package/dist/pre-made-components/assets/3-font.js +4 -4
  40. package/dist/pre-made-components/events/1-event.d.ts +1 -1
  41. package/dist/pre-made-components/events/1-event.js +157 -125
  42. package/dist/pre-made-components/events/2-event-test.d.ts +8 -8
  43. package/dist/pre-made-components/events/2-event-test.js +156 -119
  44. package/dist/pre-made-components/events/2-script-test.js +0 -1
  45. package/dist/pre-made-components/events/event-setup.d.ts +10 -5
  46. package/dist/pre-made-components/events/event-setup.js +15 -15
  47. package/dist/pre-made-components/events/script-setup.d.ts +5 -3
  48. package/dist/pre-made-components/events/script-setup.js +11 -11
  49. package/package.json +5 -10
@@ -1,135 +1,143 @@
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");
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
5
  const ComponentName = 'ASSET';
6
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
- }
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'
29
24
  }
25
+ }
30
26
  }
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(mocks_1.SampleLocation1.line + 2);
34
- expect(raw_definition_helper_1.RawDefinitionHelper.findLine(rawDefinition, ['obj1', 0])).toEqual(mocks_1.SampleLocation1.line + 3);
35
- expect(raw_definition_helper_1.RawDefinitionHelper.findLine(rawDefinition, ['obj1', 0, 'obj2'])).toEqual(mocks_1.SampleLocation1.line + 4);
36
- expect(raw_definition_helper_1.RawDefinitionHelper.findLine(rawDefinition, ['notExists'])).toEqual(mocks_1.SampleLocation1.line + 1);
37
- });
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
+ );
38
45
  });
39
- describe('Flattening', () => {
40
- test('primitive', () => {
41
- let rawDefinition = {
42
- componentName: ComponentName,
43
- location: mocks_1.SampleLocation1,
44
- parsedStructure: {
45
- line: 0,
46
- rawData: 'test'
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'
47
77
  }
48
- };
49
- let expected = 'test';
50
- expect(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition)).toStrictEqual(expected);
51
- });
52
- test('array', () => {
53
- let rawDefinition = {
54
- componentName: ComponentName,
55
- location: mocks_1.SampleLocation1,
56
- parsedStructure: {
57
- line: 0,
58
- rawData: [
59
- {
60
- line: 0,
61
- rawData: [
62
- {
63
- line: 0,
64
- rawData: 'orange'
65
- },
66
- {
67
- line: 0,
68
- rawData: 'banana'
69
- }
70
- ]
71
- },
72
- {
73
- line: 0,
74
- rawData: [
75
- {
76
- line: 0,
77
- rawData: '1'
78
- },
79
- {
80
- line: 0,
81
- rawData: '2'
82
- }
83
- ]
84
- }
85
- ]
78
+ ]
79
+ },
80
+ {
81
+ line: 0,
82
+ rawData: [
83
+ {
84
+ line: 0,
85
+ rawData: '1'
86
+ },
87
+ {
88
+ line: 0,
89
+ rawData: '2'
86
90
  }
87
- };
88
- let expected = [
89
- ['orange', 'banana'],
90
- ['1', '2']
91
- ];
92
- expect(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition)).toStrictEqual(expected);
93
- });
94
- test('object', () => {
95
- let rawDefinition = {
96
- componentName: ComponentName,
97
- location: mocks_1.SampleLocation1,
98
- parsedStructure: {
99
- line: 0,
100
- rawData: {
101
- array1: {
102
- line: 0,
103
- rawData: [
104
- {
105
- line: 0,
106
- rawData: 'apple'
107
- },
108
- {
109
- line: 0,
110
- rawData: 'orange'
111
- }
112
- ]
113
- },
114
- array2: {
115
- line: 0,
116
- rawData: [
117
- {
118
- line: 0,
119
- rawData: 'xWing'
120
- },
121
- {
122
- line: 0,
123
- rawData: 'tieFighter'
124
- }
125
- ]
126
- }
127
- }
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'
128
132
  }
129
- };
130
- let expected = { array1: ['apple', 'orange'], array2: ['xWing', 'tieFighter'] };
131
- expect(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition)).toStrictEqual(expected);
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);
133
140
  });
141
+ });
134
142
  });
135
- //# sourceMappingURL=raw-definition.helper.spec.js.map
143
+ //# sourceMappingURL=raw-definition.helper.spec.js.map
@@ -1 +1 @@
1
- export declare const AssetComponentName = "ASSET";
1
+ export declare const AssetComponentName = 'ASSET';
@@ -1,173 +1,191 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
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.AssetComponentName = void 0;
7
- const joi_1 = __importDefault(require("joi"));
8
- const joi_custom_validators_1 = require("../joi-custom-validators");
9
- const mocks_1 = require("../../../_mocks/mocks");
10
- const raw_definition_helper_1 = require("../../raw-definition-helper/raw-definition.helper");
11
- const custom_validator_helper_1 = require("./custom-validator.helper");
12
- const context_1 = require("../../../framework/context");
13
- const definition_store_1 = require("../../../framework/definition-store");
14
- joi_custom_validators_1.JoiCustomValidators.decorate(joi_1.default, { existsSync: (path) => path !== 'D:/test/false/path.png' });
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' });
15
17
  exports.AssetComponentName = 'ASSET';
16
18
  class Asset {
17
- static { this.$meta = {
18
- componentName: exports.AssetComponentName
19
- }; }
20
- async process() { }
19
+ static {
20
+ this.$meta = {
21
+ componentName: exports.AssetComponentName
22
+ };
23
+ }
24
+ async process() {}
21
25
  }
22
26
  class AssetGroup {
23
- static { this.$meta = {
24
- componentName: 'ASSET-GROUP'
25
- }; }
26
- async process() { }
27
+ static {
28
+ this.$meta = {
29
+ componentName: 'ASSET-GROUP'
30
+ };
31
+ }
32
+ async process() {}
27
33
  }
28
34
  function getSimpleRawDefinition(value, offset = 1) {
29
- return {
30
- componentName: exports.AssetComponentName,
31
- location: mocks_1.SampleLocation1,
32
- parsedStructure: {
33
- line: mocks_1.SampleLocation1.line + offset,
34
- rawData: {
35
- value: {
36
- rawData: value,
37
- line: mocks_1.SampleLocation1.line + offset
38
- }
39
- }
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
40
44
  }
41
- };
45
+ }
46
+ }
47
+ };
42
48
  }
43
49
  function getFlatRawDefinition(value, offset = 1) {
44
- return {
45
- componentName: exports.AssetComponentName,
46
- location: mocks_1.SampleLocation1,
47
- parsedStructure: {
48
- line: mocks_1.SampleLocation1.line + offset,
49
- rawData: value
50
- }
51
- };
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
+ };
52
58
  }
53
59
  describe('JOI CUSTOM VALIDATORS', () => {
54
- beforeEach(() => {
55
- context_1.Context.config.projectRoot = 'D:/';
56
- custom_validator_helper_1.CustomValidatorHelper['duplicateHelpers'] = new Map();
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()
57
99
  });
58
- describe('Variable Name', () => {
59
- let schema = joi_1.default.object().keys({
60
- value: joi_1.default.string().required()
61
- });
62
- test('valid data', () => {
63
- let rawDefinition = getSimpleRawDefinition('test');
64
- let { value, error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
65
- abortEarly: false,
66
- context: rawDefinition
67
- });
68
- expect(value).toEqual({ value: 'test' });
69
- expect(error).toEqual(undefined);
70
- });
71
- test('different groups should not create duplicates', () => {
72
- let schema2 = joi_1.default.object().keys({
73
- value: joi_1.default.string().required()
74
- });
75
- let rawDefinition1 = getSimpleRawDefinition('test', 1);
76
- let rawDefinition2 = getSimpleRawDefinition('test', 2);
77
- schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition1), { abortEarly: false, context: rawDefinition1 });
78
- schema2.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition2), { abortEarly: false, context: rawDefinition2 });
79
- (0, mocks_1.resetContext)();
80
- custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
81
- expect(context_1.Context.errorLogs).toStrictEqual([]);
82
- });
100
+ let multipleSchema = joi_1.default.object().keys({
101
+ value: joi_1.default.string().reference([AssetGroup, Asset]).required()
83
102
  });
84
- describe('Reference', () => {
85
- let schema = joi_1.default.object().keys({
86
- value: joi_1.default.string().reference(Asset).required()
87
- });
88
- let multipleSchema = joi_1.default.object().keys({
89
- value: joi_1.default.string().reference([AssetGroup, Asset]).required()
90
- });
91
- test('valid data', () => {
92
- let rawDefinition = getSimpleRawDefinition('test');
93
- definition_store_1.DefinitionStore['setRawDefinition'](Asset, 'test', rawDefinition);
94
- let { value, error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
95
- abortEarly: false,
96
- context: rawDefinition
97
- });
98
- expect(value).toEqual({ value: 'test' });
99
- expect(error).toEqual(undefined);
100
- });
101
- test('multiple reference', () => {
102
- let rawDefinition = getSimpleRawDefinition('test');
103
- definition_store_1.DefinitionStore['setRawDefinition'](Asset, 'test', rawDefinition);
104
- let { value, error } = multipleSchema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
105
- abortEarly: false,
106
- context: rawDefinition
107
- });
108
- expect(value).toEqual({ value: 'test' });
109
- expect(error).toEqual(undefined);
110
- });
111
- test('primitive valid data', () => {
112
- let rawDefinition = getFlatRawDefinition('test');
113
- let primitiveSchema = joi_1.default.string().reference(Asset).required();
114
- definition_store_1.DefinitionStore['setRawDefinition'](Asset, 'test', rawDefinition);
115
- let { value, error } = primitiveSchema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
116
- abortEarly: false,
117
- context: rawDefinition
118
- });
119
- expect(value).toEqual('test');
120
- expect(error).toEqual(undefined);
121
- });
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);
122
112
  });
123
- describe('Path', () => {
124
- let schema = joi_1.default.object().keys({
125
- value: joi_1.default.string().path().required()
126
- });
127
- test('valid data', () => {
128
- let rawDefinition = getSimpleRawDefinition('images/test.png');
129
- let { value, error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
130
- abortEarly: false,
131
- context: rawDefinition
132
- });
133
- expect(value).toEqual({ value: '.test/images/test.png' });
134
- expect(error).toEqual(undefined);
135
- });
136
- test('should detect files not existing, invalid url', () => {
137
- let rawDefinition = getSimpleRawDefinition('invalid data');
138
- let { error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), { abortEarly: false, context: rawDefinition });
139
- expect(error?.details).toStrictEqual([
140
- {
141
- message: '"value" with value "invalid data" fails to match the required pattern: /^[\\S]+$/',
142
- path: ['value'],
143
- type: 'string.pattern.base',
144
- context: {
145
- name: undefined,
146
- regex: /^[\S]+$/,
147
- value: 'invalid data',
148
- label: 'value',
149
- key: 'value'
150
- }
151
- }
152
- ]);
153
- });
154
- test('should detect files not existing, missing file', () => {
155
- let rawDefinition = getSimpleRawDefinition('false/path.png');
156
- let { error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), { abortEarly: false, context: rawDefinition });
157
- expect(error?.details).toStrictEqual([
158
- {
159
- message: '"value" failed custom validation because No file is found in the path: "D:/test/false/path.png"',
160
- path: ['value'],
161
- type: 'any.custom',
162
- context: {
163
- error: new Error('No file is found in the path: "D:/test/false/path.png"'),
164
- label: 'value',
165
- value: 'false/path.png',
166
- key: 'value'
167
- }
168
- }
169
- ]);
170
- });
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
+ ]);
171
188
  });
189
+ });
172
190
  });
173
- //# sourceMappingURL=custom-validator.helper.spec.js.map
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
- readonly url: string;
7
- readonly size: Vec2;
6
+ readonly url: string;
7
+ readonly size: Vec2;
8
8
  }
9
9
  export declare class ImageCustomValidator implements CustomValidator {
10
- private fs;
11
- readonly regex: RegExp;
12
- readonly validate: (value: string, helpers: Joi.CustomHelpers) => any | ErrorReport;
13
- constructor(fs: FileSystem);
10
+ private fs;
11
+ readonly regex: RegExp;
12
+ readonly validate: (value: string, helpers: Joi.CustomHelpers) => any | ErrorReport;
13
+ constructor(fs: FileSystem);
14
14
  }