definition-generator-framework 1.12.5 → 1.12.7

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 (50) 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/framework/index-file-generator/index-file-generator.js +2 -4
  14. package/dist/helpers/common-functions/common-functions.js +1 -1
  15. package/dist/helpers/common-functions/common-functions.spec.js +48 -48
  16. package/dist/helpers/duplicate-helper/duplicate-helper.spec.js +52 -52
  17. package/dist/helpers/output-helper/output-helper.d.ts +26 -26
  18. package/dist/helpers/output-helper/output-helper.js +127 -107
  19. package/dist/helpers/output-helper/output-helper.spec.d.ts +22 -22
  20. package/dist/helpers/output-helper/output-helper.spec.js +223 -211
  21. package/dist/helpers/output-helper/output-helper.test.d.ts +22 -22
  22. package/dist/helpers/output-helper/output-helper.test.js +224 -212
  23. package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.js +133 -125
  24. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.d.ts +1 -1
  25. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.js +174 -156
  26. package/dist/helpers/validator/custom-validators/image.custom-validator.d.ts +6 -6
  27. package/dist/helpers/validator/custom-validators/image.custom-validator.js +40 -39
  28. package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.d.ts +4 -4
  29. package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.js +29 -29
  30. package/dist/helpers/validator/joi-custom-validators.spec.js +284 -240
  31. package/dist/helpers/validator/validator.spec.js +313 -303
  32. package/dist/pipeline/1-select-definitions-helper.d.ts +13 -13
  33. package/dist/pipeline/1-select-definitions-helper.js +68 -72
  34. package/dist/pipeline/1-select-definitions.helper.test.js +40 -40
  35. package/dist/pipeline/1-select-definitions.spec.js +131 -131
  36. package/dist/pipeline/2-structure-parser.helper.spec.js +266 -266
  37. package/dist/pipeline/parsers/array-parser.spec.js +116 -113
  38. package/dist/pipeline/parsers/object-parser.spec.js +159 -153
  39. package/dist/pipeline/parsers/primitive-parser.spec.js +67 -67
  40. package/dist/pre-made-components/assets/3-font.js +4 -4
  41. package/dist/pre-made-components/events/1-event.d.ts +1 -1
  42. package/dist/pre-made-components/events/1-event.js +157 -125
  43. package/dist/pre-made-components/events/2-event-test.d.ts +8 -8
  44. package/dist/pre-made-components/events/2-event-test.js +156 -119
  45. package/dist/pre-made-components/events/2-script-test.js +0 -1
  46. package/dist/pre-made-components/events/event-setup.d.ts +10 -5
  47. package/dist/pre-made-components/events/event-setup.js +15 -15
  48. package/dist/pre-made-components/events/script-setup.d.ts +5 -3
  49. package/dist/pre-made-components/events/script-setup.js +11 -11
  50. package/package.json +5 -10
@@ -1,260 +1,304 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
1
+ 'use strict';
2
+ var __createBinding =
3
+ (this && this.__createBinding) ||
4
+ (Object.create
5
+ ? function (o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = {
10
+ enumerable: true,
11
+ get: function () {
12
+ return m[k];
13
+ }
14
+ };
15
+ }
16
+ Object.defineProperty(o, k2, desc);
17
+ }
18
+ : function (o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ o[k2] = m[k];
21
+ });
22
+ var __setModuleDefault =
23
+ (this && this.__setModuleDefault) ||
24
+ (Object.create
25
+ ? function (o, v) {
26
+ Object.defineProperty(o, 'default', { enumerable: true, value: v });
27
+ }
28
+ : function (o, v) {
29
+ o['default'] = v;
30
+ });
31
+ var __importStar =
32
+ (this && this.__importStar) ||
33
+ function (mod) {
19
34
  if (mod && mod.__esModule) return mod;
20
35
  var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
36
+ if (mod != null)
37
+ for (var k in mod) if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
38
  __setModuleDefault(result, mod);
23
39
  return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const Joi = __importStar(require("joi"));
27
- const joi_custom_validators_1 = require("./joi-custom-validators");
28
- const mocks_1 = require("../../_mocks/mocks");
29
- const raw_definition_helper_1 = require("../raw-definition-helper/raw-definition.helper");
30
- joi_custom_validators_1.JoiCustomValidators.decorate({ existsSync: (path) => path !== 'D:/test/false/path.png' });
40
+ };
41
+ Object.defineProperty(exports, '__esModule', { value: true });
42
+ const Joi = __importStar(require('joi'));
43
+ const joi_custom_validators_1 = require('./joi-custom-validators');
44
+ const mocks_1 = require('../../_mocks/mocks');
45
+ const raw_definition_helper_1 = require('../raw-definition-helper/raw-definition.helper');
46
+ joi_custom_validators_1.JoiCustomValidators.decorate({ existsSync: path => path !== 'D:/test/false/path.png' });
31
47
  const DefinitionType = 'ASSET';
32
48
  class Asset {
33
- static { this.$meta = {
34
- definitionName: DefinitionType
35
- }; }
36
- async process() { }
49
+ static {
50
+ this.$meta = {
51
+ definitionName: DefinitionType
52
+ };
53
+ }
54
+ async process() {}
37
55
  }
38
56
  class AssetGroup {
39
- static { this.$meta = {
40
- definitionName: 'ASSET-GROUP'
41
- }; }
42
- async process() { }
57
+ static {
58
+ this.$meta = {
59
+ definitionName: 'ASSET-GROUP'
60
+ };
61
+ }
62
+ async process() {}
43
63
  }
44
64
  function getSimpleRawDefinition(value, offset = 1) {
45
- return {
46
- type: DefinitionType,
47
- location: mocks_1.SampleLocation1,
48
- parsedStructure: {
49
- line: mocks_1.SampleLocation1.line + offset,
50
- rawData: {
51
- value: {
52
- rawData: value,
53
- line: mocks_1.SampleLocation1.line + offset
54
- }
55
- }
65
+ return {
66
+ type: DefinitionType,
67
+ location: mocks_1.SampleLocation1,
68
+ parsedStructure: {
69
+ line: mocks_1.SampleLocation1.line + offset,
70
+ rawData: {
71
+ value: {
72
+ rawData: value,
73
+ line: mocks_1.SampleLocation1.line + offset
56
74
  }
57
- };
75
+ }
76
+ }
77
+ };
58
78
  }
59
79
  function getFlatRawDefinition(value, offset = 1) {
60
- return {
61
- type: DefinitionType,
62
- location: mocks_1.SampleLocation1,
63
- parsedStructure: {
64
- line: mocks_1.SampleLocation1.line + offset,
65
- rawData: value
66
- }
67
- };
80
+ return {
81
+ type: DefinitionType,
82
+ location: mocks_1.SampleLocation1,
83
+ parsedStructure: {
84
+ line: mocks_1.SampleLocation1.line + offset,
85
+ rawData: value
86
+ }
87
+ };
68
88
  }
69
89
  describe('JOI CUSTOM VALIDATORS', () => {
70
- beforeEach(() => {
71
- let validators = joi_custom_validators_1.JoiCustomValidators;
72
- validators.rootDirectory = 'D:/';
73
- validators.definitionNames = new Map();
74
- validators.duplicateHelpers = new Map();
90
+ beforeEach(() => {
91
+ let validators = joi_custom_validators_1.JoiCustomValidators;
92
+ validators.rootDirectory = 'D:/';
93
+ validators.definitionNames = new Map();
94
+ validators.duplicateHelpers = new Map();
95
+ });
96
+ describe('Variable Name', () => {
97
+ let schema = Joi.object().keys({
98
+ value: Joi.string().uniqueNameGroup(Asset).required()
99
+ });
100
+ test('valid data', () => {
101
+ let rawDefinition = getSimpleRawDefinition('test');
102
+ let { value, error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
103
+ abortEarly: false,
104
+ context: rawDefinition
105
+ });
106
+ expect(value).toEqual({ value: 'assetTest' });
107
+ expect(error).toEqual(undefined);
108
+ });
109
+ test('invalid data', () => {
110
+ let rawDefinition = getSimpleRawDefinition('invalid data');
111
+ let { error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
112
+ abortEarly: false,
113
+ context: rawDefinition
114
+ });
115
+ expect(error?.details).toStrictEqual([
116
+ {
117
+ message: '"value" with value "invalid data" fails to match the required pattern: /^[a-z]+([a-zA-Z0-9]+)*$/',
118
+ path: [],
119
+ type: 'string.pattern.base',
120
+ context: {
121
+ name: undefined,
122
+ regex: /^[a-z]+([a-zA-Z0-9]+)*$/,
123
+ value: 'invalid data',
124
+ label: 'value',
125
+ key: 'value'
126
+ }
127
+ }
128
+ ]);
75
129
  });
76
- describe('Variable Name', () => {
77
- let schema = Joi.object().keys({
78
- value: Joi.string().uniqueNameGroup(Asset).required()
79
- });
80
- test('valid data', () => {
81
- let rawDefinition = getSimpleRawDefinition('test');
82
- let { value, error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
83
- abortEarly: false,
84
- context: rawDefinition
85
- });
86
- expect(value).toEqual({ value: 'assetTest' });
87
- expect(error).toEqual(undefined);
88
- });
89
- test('invalid data', () => {
90
- let rawDefinition = getSimpleRawDefinition('invalid data');
91
- let { error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), { abortEarly: false, context: rawDefinition });
92
- expect(error?.details).toStrictEqual([
93
- {
94
- message: '"value" with value "invalid data" fails to match the required pattern: /^[a-z]+([a-zA-Z0-9]+)*$/',
95
- path: [],
96
- type: 'string.pattern.base',
97
- context: {
98
- name: undefined,
99
- regex: /^[a-z]+([a-zA-Z0-9]+)*$/,
100
- value: 'invalid data',
101
- label: 'value',
102
- key: 'value'
103
- }
104
- }
105
- ]);
106
- });
107
- test('should detect duplicate variable names', () => {
108
- let rawDefinition1 = getSimpleRawDefinition('test', 1);
109
- let rawDefinition2 = getSimpleRawDefinition('test', 2);
110
- schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition1), { abortEarly: false, context: rawDefinition1 });
111
- schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition2), { abortEarly: false, context: rawDefinition2 });
112
- let context = (0, mocks_1.getMockContext)();
113
- joi_custom_validators_1.JoiCustomValidators.logDuplicates(context);
114
- expect(context.errorLogs).toStrictEqual([
115
- {
116
- description: 'Value should be singular! Group: "ASSET", Value: "test"',
117
- location: { line: mocks_1.SampleLocation1.line + 1, path: 'D:/test/file-1.md' }
118
- },
119
- {
120
- description: 'Value should be singular! Group: "ASSET", Value: "test"',
121
- location: { line: mocks_1.SampleLocation1.line + 2, path: 'D:/test/file-1.md' }
122
- }
123
- ]);
124
- });
125
- test('different groups should not create duplicates', () => {
126
- let schema2 = Joi.object().keys({
127
- value: Joi.string().uniqueNameGroup(AssetGroup).required()
128
- });
129
- let rawDefinition1 = getSimpleRawDefinition('test', 1);
130
- let rawDefinition2 = getSimpleRawDefinition('test', 2);
131
- schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition1), { abortEarly: false, context: rawDefinition1 });
132
- schema2.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition2), { abortEarly: false, context: rawDefinition2 });
133
- let context = (0, mocks_1.getMockContext)();
134
- joi_custom_validators_1.JoiCustomValidators.logDuplicates(context);
135
- expect(context.errorLogs).toStrictEqual([]);
136
- });
130
+ test('should detect duplicate variable names', () => {
131
+ let rawDefinition1 = getSimpleRawDefinition('test', 1);
132
+ let rawDefinition2 = getSimpleRawDefinition('test', 2);
133
+ schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition1), {
134
+ abortEarly: false,
135
+ context: rawDefinition1
136
+ });
137
+ schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition2), {
138
+ abortEarly: false,
139
+ context: rawDefinition2
140
+ });
141
+ let context = (0, mocks_1.getMockContext)();
142
+ joi_custom_validators_1.JoiCustomValidators.logDuplicates(context);
143
+ expect(context.errorLogs).toStrictEqual([
144
+ {
145
+ description: 'Value should be singular! Group: "ASSET", Value: "test"',
146
+ location: { line: mocks_1.SampleLocation1.line + 1, path: 'D:/test/file-1.md' }
147
+ },
148
+ {
149
+ description: 'Value should be singular! Group: "ASSET", Value: "test"',
150
+ location: { line: mocks_1.SampleLocation1.line + 2, path: 'D:/test/file-1.md' }
151
+ }
152
+ ]);
153
+ });
154
+ test('different groups should not create duplicates', () => {
155
+ let schema2 = Joi.object().keys({
156
+ value: Joi.string().uniqueNameGroup(AssetGroup).required()
157
+ });
158
+ let rawDefinition1 = getSimpleRawDefinition('test', 1);
159
+ let rawDefinition2 = getSimpleRawDefinition('test', 2);
160
+ schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition1), {
161
+ abortEarly: false,
162
+ context: rawDefinition1
163
+ });
164
+ schema2.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition2), {
165
+ abortEarly: false,
166
+ context: rawDefinition2
167
+ });
168
+ let context = (0, mocks_1.getMockContext)();
169
+ joi_custom_validators_1.JoiCustomValidators.logDuplicates(context);
170
+ expect(context.errorLogs).toStrictEqual([]);
171
+ });
172
+ });
173
+ describe('Reference', () => {
174
+ let schema = Joi.object().keys({
175
+ value: Joi.string().reference(Asset).required()
176
+ });
177
+ let multipleSchema = Joi.object().keys({
178
+ value: Joi.string().reference([AssetGroup, Asset]).required()
137
179
  });
138
- describe('Reference', () => {
139
- let schema = Joi.object().keys({
140
- value: Joi.string().reference(Asset).required()
141
- });
142
- let multipleSchema = Joi.object().keys({
143
- value: Joi.string().reference([AssetGroup, Asset]).required()
144
- });
145
- test('valid data', () => {
146
- let rawDefinition = getSimpleRawDefinition('test');
147
- let validators = joi_custom_validators_1.JoiCustomValidators;
148
- validators.getDefinitionNames(DefinitionType).add('test');
149
- let { value, error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
150
- abortEarly: false,
151
- context: rawDefinition
152
- });
153
- expect(value).toEqual({ value: 'assetTest' });
154
- expect(error).toEqual(undefined);
155
- });
156
- test('multiple reference', () => {
157
- let rawDefinition = getSimpleRawDefinition('test');
158
- let validators = joi_custom_validators_1.JoiCustomValidators;
159
- validators.getDefinitionNames(DefinitionType).add('test');
160
- let { value, error } = multipleSchema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
161
- abortEarly: false,
162
- context: rawDefinition
163
- });
164
- expect(value).toEqual({ value: 'assetTest' });
165
- expect(error).toEqual(undefined);
166
- });
167
- test('primitive valid data', () => {
168
- let rawDefinition = getFlatRawDefinition('test');
169
- let primitiveSchema = Joi.string().reference(Asset).required();
170
- let validators = joi_custom_validators_1.JoiCustomValidators;
171
- validators.getDefinitionNames(DefinitionType).add('test');
172
- let { value, error } = primitiveSchema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
173
- abortEarly: false,
174
- context: rawDefinition
175
- });
176
- expect(value).toEqual('assetTest');
177
- expect(error).toEqual(undefined);
178
- });
179
- test('should detect non existing references', () => {
180
- let rawDefinition = getSimpleRawDefinition('test');
181
- let { error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), { abortEarly: false, context: rawDefinition });
182
- expect(error?.details).toEqual([
183
- {
184
- context: {
185
- key: 'value',
186
- label: 'value',
187
- value: 'test'
188
- },
189
- message: 'There is no definition found for "test" in name field: "ASSET"',
190
- path: ['value'],
191
- type: 'any.custom'
192
- }
193
- ]);
194
- });
195
- test('should detect non existing multiple references', () => {
196
- let rawDefinition = getSimpleRawDefinition('test');
197
- let { error } = multipleSchema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
198
- abortEarly: false,
199
- context: rawDefinition
200
- });
201
- expect(error?.details).toEqual([
202
- {
203
- context: {
204
- key: 'value',
205
- label: 'value',
206
- value: 'test'
207
- },
208
- message: 'There is no definition found for "test" in name field: "ASSET-GROUP, ASSET"',
209
- path: ['value'],
210
- type: 'any.custom'
211
- }
212
- ]);
213
- });
180
+ test('valid data', () => {
181
+ let rawDefinition = getSimpleRawDefinition('test');
182
+ let validators = joi_custom_validators_1.JoiCustomValidators;
183
+ validators.getDefinitionNames(DefinitionType).add('test');
184
+ let { value, error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
185
+ abortEarly: false,
186
+ context: rawDefinition
187
+ });
188
+ expect(value).toEqual({ value: 'assetTest' });
189
+ expect(error).toEqual(undefined);
190
+ });
191
+ test('multiple reference', () => {
192
+ let rawDefinition = getSimpleRawDefinition('test');
193
+ let validators = joi_custom_validators_1.JoiCustomValidators;
194
+ validators.getDefinitionNames(DefinitionType).add('test');
195
+ let { value, error } = multipleSchema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
196
+ abortEarly: false,
197
+ context: rawDefinition
198
+ });
199
+ expect(value).toEqual({ value: 'assetTest' });
200
+ expect(error).toEqual(undefined);
201
+ });
202
+ test('primitive valid data', () => {
203
+ let rawDefinition = getFlatRawDefinition('test');
204
+ let primitiveSchema = Joi.string().reference(Asset).required();
205
+ let validators = joi_custom_validators_1.JoiCustomValidators;
206
+ validators.getDefinitionNames(DefinitionType).add('test');
207
+ let { value, error } = primitiveSchema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
208
+ abortEarly: false,
209
+ context: rawDefinition
210
+ });
211
+ expect(value).toEqual('assetTest');
212
+ expect(error).toEqual(undefined);
213
+ });
214
+ test('should detect non existing references', () => {
215
+ let rawDefinition = getSimpleRawDefinition('test');
216
+ let { error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
217
+ abortEarly: false,
218
+ context: rawDefinition
219
+ });
220
+ expect(error?.details).toEqual([
221
+ {
222
+ context: {
223
+ key: 'value',
224
+ label: 'value',
225
+ value: 'test'
226
+ },
227
+ message: 'There is no definition found for "test" in name field: "ASSET"',
228
+ path: ['value'],
229
+ type: 'any.custom'
230
+ }
231
+ ]);
214
232
  });
215
- describe('Path', () => {
216
- let schema = Joi.object().keys({
217
- value: Joi.string().path().required()
218
- });
219
- test('valid data', () => {
220
- let rawDefinition = getSimpleRawDefinition('images/test.png');
221
- let { value, error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
222
- abortEarly: false,
223
- context: rawDefinition
224
- });
225
- expect(value).toEqual({ value: '.test/images/test.png' });
226
- expect(error).toEqual(undefined);
227
- });
228
- test('should detect files not existing', () => {
229
- let rawDefinition = getSimpleRawDefinition('invalid data');
230
- let { error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), { abortEarly: false, context: rawDefinition });
231
- expect(error?.details).toStrictEqual([
232
- {
233
- message: '"value" with value "invalid data" fails to match the required pattern: /^[\\S]+$/',
234
- path: ['value'],
235
- type: 'string.pattern.base',
236
- context: {
237
- name: undefined,
238
- regex: /^[\S]+$/,
239
- value: 'invalid data',
240
- label: 'value',
241
- key: 'value'
242
- }
243
- }
244
- ]);
245
- });
246
- test('should detect files not existing', () => {
247
- let rawDefinition = getSimpleRawDefinition('false/path.png');
248
- let { error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), { abortEarly: false, context: rawDefinition });
249
- expect(error?.details).toStrictEqual([
250
- {
251
- message: 'No file is found in the path: "false/path.png"',
252
- path: ['value'],
253
- type: 'any.custom',
254
- context: { label: 'value', value: 'false/path.png', key: 'value' }
255
- }
256
- ]);
257
- });
233
+ test('should detect non existing multiple references', () => {
234
+ let rawDefinition = getSimpleRawDefinition('test');
235
+ let { error } = multipleSchema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
236
+ abortEarly: false,
237
+ context: rawDefinition
238
+ });
239
+ expect(error?.details).toEqual([
240
+ {
241
+ context: {
242
+ key: 'value',
243
+ label: 'value',
244
+ value: 'test'
245
+ },
246
+ message: 'There is no definition found for "test" in name field: "ASSET-GROUP, ASSET"',
247
+ path: ['value'],
248
+ type: 'any.custom'
249
+ }
250
+ ]);
251
+ });
252
+ });
253
+ describe('Path', () => {
254
+ let schema = Joi.object().keys({
255
+ value: Joi.string().path().required()
256
+ });
257
+ test('valid data', () => {
258
+ let rawDefinition = getSimpleRawDefinition('images/test.png');
259
+ let { value, error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
260
+ abortEarly: false,
261
+ context: rawDefinition
262
+ });
263
+ expect(value).toEqual({ value: '.test/images/test.png' });
264
+ expect(error).toEqual(undefined);
265
+ });
266
+ test('should detect files not existing', () => {
267
+ let rawDefinition = getSimpleRawDefinition('invalid data');
268
+ let { error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
269
+ abortEarly: false,
270
+ context: rawDefinition
271
+ });
272
+ expect(error?.details).toStrictEqual([
273
+ {
274
+ message: '"value" with value "invalid data" fails to match the required pattern: /^[\\S]+$/',
275
+ path: ['value'],
276
+ type: 'string.pattern.base',
277
+ context: {
278
+ name: undefined,
279
+ regex: /^[\S]+$/,
280
+ value: 'invalid data',
281
+ label: 'value',
282
+ key: 'value'
283
+ }
284
+ }
285
+ ]);
286
+ });
287
+ test('should detect files not existing', () => {
288
+ let rawDefinition = getSimpleRawDefinition('false/path.png');
289
+ let { error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
290
+ abortEarly: false,
291
+ context: rawDefinition
292
+ });
293
+ expect(error?.details).toStrictEqual([
294
+ {
295
+ message: 'No file is found in the path: "false/path.png"',
296
+ path: ['value'],
297
+ type: 'any.custom',
298
+ context: { label: 'value', value: 'false/path.png', key: 'value' }
299
+ }
300
+ ]);
258
301
  });
302
+ });
259
303
  });
260
- //# sourceMappingURL=joi-custom-validators.spec.js.map
304
+ //# sourceMappingURL=joi-custom-validators.spec.js.map