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,304 @@
|
|
|
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) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null)
|
|
37
|
+
for (var k in mod) if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
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' });
|
|
47
|
+
const DefinitionType = 'ASSET';
|
|
48
|
+
class Asset {
|
|
49
|
+
static {
|
|
50
|
+
this.$meta = {
|
|
51
|
+
definitionName: DefinitionType
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
async process() {}
|
|
55
|
+
}
|
|
56
|
+
class AssetGroup {
|
|
57
|
+
static {
|
|
58
|
+
this.$meta = {
|
|
59
|
+
definitionName: 'ASSET-GROUP'
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
async process() {}
|
|
63
|
+
}
|
|
64
|
+
function getSimpleRawDefinition(value, offset = 1) {
|
|
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
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function getFlatRawDefinition(value, offset = 1) {
|
|
80
|
+
return {
|
|
81
|
+
type: DefinitionType,
|
|
82
|
+
location: mocks_1.SampleLocation1,
|
|
83
|
+
parsedStructure: {
|
|
84
|
+
line: mocks_1.SampleLocation1.line + offset,
|
|
85
|
+
rawData: value
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
describe('JOI CUSTOM VALIDATORS', () => {
|
|
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
|
+
]);
|
|
129
|
+
});
|
|
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()
|
|
179
|
+
});
|
|
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
|
+
]);
|
|
232
|
+
});
|
|
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
|
+
]);
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
//# sourceMappingURL=joi-custom-validators.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,332 @@
|
|
|
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
|
+
const joi_1 = __importDefault(require('joi'));
|
|
9
|
+
const validator_1 = require('./validator');
|
|
10
|
+
const joi_custom_validators_1 = require('./joi-custom-validators');
|
|
11
|
+
const mocks_1 = require('../../_mocks/mocks');
|
|
12
|
+
const custom_validator_helper_1 = require('./custom-validator-helper/custom-validator.helper');
|
|
13
|
+
const context_1 = require('../../framework/context');
|
|
14
|
+
const definition_store_1 = require('../../framework/definition-store');
|
|
15
|
+
joi_custom_validators_1.JoiCustomValidators.decorate(joi_1.default, { existsSync: path => path !== 'D:/test/false/path.png' });
|
|
16
|
+
const ComponentType = 'ASSET';
|
|
17
|
+
class Asset {
|
|
18
|
+
static {
|
|
19
|
+
this.$meta = {
|
|
20
|
+
componentName: ComponentType
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
async process() {}
|
|
24
|
+
}
|
|
25
|
+
const TestSchema = joi_1.default.object().keys({
|
|
26
|
+
str1: joi_1.default.string().required(),
|
|
27
|
+
str2: joi_1.default.string().path().optional()
|
|
28
|
+
});
|
|
29
|
+
function getSampleRawDefinition(str, pathString) {
|
|
30
|
+
let rawDefinition = {
|
|
31
|
+
componentName: ComponentType,
|
|
32
|
+
location: mocks_1.SampleLocation1,
|
|
33
|
+
parsedStructure: {
|
|
34
|
+
line: mocks_1.SampleLocation1.line + 1,
|
|
35
|
+
rawData: {
|
|
36
|
+
str1: {
|
|
37
|
+
rawData: str,
|
|
38
|
+
line: mocks_1.SampleLocation1.line + 1
|
|
39
|
+
},
|
|
40
|
+
str2: {
|
|
41
|
+
rawData: pathString,
|
|
42
|
+
line: mocks_1.SampleLocation1.line + 2
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
return rawDefinition;
|
|
48
|
+
}
|
|
49
|
+
const SampleNestedRawDefinition = {
|
|
50
|
+
componentName: ComponentType,
|
|
51
|
+
location: mocks_1.SampleLocation1,
|
|
52
|
+
parsedStructure: {
|
|
53
|
+
line: mocks_1.SampleLocation1.line + 1,
|
|
54
|
+
rawData: {
|
|
55
|
+
obj1: {
|
|
56
|
+
line: mocks_1.SampleLocation1.line + 1,
|
|
57
|
+
rawData: [
|
|
58
|
+
{
|
|
59
|
+
line: mocks_1.SampleLocation1.line + 2,
|
|
60
|
+
rawData: {
|
|
61
|
+
obj2: {
|
|
62
|
+
line: mocks_1.SampleLocation1.line + 2,
|
|
63
|
+
rawData: 'test data'
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
describe('VALIDATOR', () => {
|
|
73
|
+
beforeEach(() => {
|
|
74
|
+
(0, mocks_1.resetContext)();
|
|
75
|
+
custom_validator_helper_1.CustomValidatorHelper['duplicateHelpers'] = new Map();
|
|
76
|
+
});
|
|
77
|
+
describe('Convert', () => {
|
|
78
|
+
test('valid definition', () => {
|
|
79
|
+
context_1.Context.rawDefinitions.push(getSampleRawDefinition('str1', 'images/test.png'));
|
|
80
|
+
let definitions = validator_1.Validator.validateAndConvert(ComponentType, TestSchema);
|
|
81
|
+
custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
|
|
82
|
+
expect(context_1.Context.errorLogs).toStrictEqual([]);
|
|
83
|
+
expect(definitions).toStrictEqual([{ str1: 'str1', str2: '.test/images/test.png' }]);
|
|
84
|
+
});
|
|
85
|
+
test('singular definition', () => {
|
|
86
|
+
context_1.Context.rawDefinitions.push(getSampleRawDefinition('str1', 'images/test.png'));
|
|
87
|
+
let definitions = validator_1.Validator.validateAndConvert(ComponentType, TestSchema);
|
|
88
|
+
custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
|
|
89
|
+
expect(context_1.Context.errorLogs).toStrictEqual([]);
|
|
90
|
+
expect(definitions).toStrictEqual([{ str1: 'str1', str2: '.test/images/test.png' }]);
|
|
91
|
+
});
|
|
92
|
+
test('should allow references in the same namespace', () => {
|
|
93
|
+
let rawDefinition1 = {
|
|
94
|
+
componentName: ComponentType,
|
|
95
|
+
location: mocks_1.SampleLocation1,
|
|
96
|
+
parsedStructure: {
|
|
97
|
+
line: mocks_1.SampleLocation1.line + 1,
|
|
98
|
+
rawData: {
|
|
99
|
+
name: {
|
|
100
|
+
rawData: 'asset2',
|
|
101
|
+
line: mocks_1.SampleLocation1.line + 1
|
|
102
|
+
},
|
|
103
|
+
ref: {
|
|
104
|
+
rawData: 'asset1',
|
|
105
|
+
line: mocks_1.SampleLocation1.line + 2
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
let rawDefinition2 = {
|
|
111
|
+
componentName: ComponentType,
|
|
112
|
+
location: mocks_1.SampleLocation1,
|
|
113
|
+
parsedStructure: {
|
|
114
|
+
line: mocks_1.SampleLocation1.line + 1,
|
|
115
|
+
rawData: {
|
|
116
|
+
name: {
|
|
117
|
+
rawData: 'asset1',
|
|
118
|
+
line: mocks_1.SampleLocation1.line + 1
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
context_1.Context.rawDefinitions.push(rawDefinition1);
|
|
124
|
+
context_1.Context.rawDefinitions.push(rawDefinition2);
|
|
125
|
+
let schema = joi_1.default.object().keys({
|
|
126
|
+
name: joi_1.default.string().required(),
|
|
127
|
+
ref: joi_1.default.string().reference(Asset).optional()
|
|
128
|
+
});
|
|
129
|
+
definition_store_1.DefinitionStore['setRawDefinition'](Asset, 'asset1', rawDefinition2);
|
|
130
|
+
let definitions = validator_1.Validator.validateAndConvert(ComponentType, schema);
|
|
131
|
+
custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
|
|
132
|
+
expect(context_1.Context.errorLogs).toStrictEqual([]);
|
|
133
|
+
expect(definitions).toStrictEqual([
|
|
134
|
+
{
|
|
135
|
+
name: 'asset2',
|
|
136
|
+
ref: 'asset1'
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: 'asset1'
|
|
140
|
+
}
|
|
141
|
+
]);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
describe('Convert Singular', () => {
|
|
145
|
+
test('valid definition', () => {
|
|
146
|
+
context_1.Context.rawDefinitions.push(getSampleRawDefinition('str1', 'images/test.png'));
|
|
147
|
+
let definition = validator_1.Validator.validateAndConvertSingular(ComponentType, TestSchema);
|
|
148
|
+
custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
|
|
149
|
+
expect(context_1.Context.errorLogs).toStrictEqual([]);
|
|
150
|
+
expect(definition).toStrictEqual({ str1: 'str1', str2: '.test/images/test.png' });
|
|
151
|
+
});
|
|
152
|
+
test('should log error for no definition', () => {
|
|
153
|
+
let definition = validator_1.Validator.validateAndConvertSingular(ComponentType, TestSchema);
|
|
154
|
+
custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
|
|
155
|
+
expect(definition).toStrictEqual(undefined);
|
|
156
|
+
expect(context_1.Context.errorLogs).toStrictEqual([
|
|
157
|
+
{
|
|
158
|
+
description: 'Singleton definition has no declared entry "ASSET"',
|
|
159
|
+
location: {
|
|
160
|
+
line: 0,
|
|
161
|
+
path: '*'
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
]);
|
|
165
|
+
});
|
|
166
|
+
test('should log error for multiple definitions', () => {
|
|
167
|
+
context_1.Context.rawDefinitions.push(getSampleRawDefinition('str1', 'images/test.png'));
|
|
168
|
+
context_1.Context.rawDefinitions.push(getSampleRawDefinition('str2', 'images/test.png'));
|
|
169
|
+
let definition = validator_1.Validator.validateAndConvertSingular(ComponentType, TestSchema);
|
|
170
|
+
custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
|
|
171
|
+
expect(definition).toStrictEqual(undefined);
|
|
172
|
+
expect(context_1.Context.errorLogs).toStrictEqual([
|
|
173
|
+
{
|
|
174
|
+
description: 'Only one definition can be defined for "ASSET"',
|
|
175
|
+
location: {
|
|
176
|
+
line: 2,
|
|
177
|
+
path: 'D:/test/file-1.md'
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
description: 'Only one definition can be defined for "ASSET"',
|
|
182
|
+
location: {
|
|
183
|
+
line: 2,
|
|
184
|
+
path: 'D:/test/file-1.md'
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
]);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
describe('Validate', () => {
|
|
191
|
+
test('should handle valid raw definition', () => {
|
|
192
|
+
let rawDefinition = getSampleRawDefinition('a', 'images/test.png');
|
|
193
|
+
let value = validator_1.Validator['validate'](rawDefinition, TestSchema);
|
|
194
|
+
custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
|
|
195
|
+
expect(value).toStrictEqual({ str1: 'a', str2: '.test/images/test.png' });
|
|
196
|
+
expect(context_1.Context.errorLogs).toStrictEqual([]);
|
|
197
|
+
});
|
|
198
|
+
test('should log error for required fields', () => {
|
|
199
|
+
let rawDefinition = getSampleRawDefinition(undefined, 'images/test.png');
|
|
200
|
+
let value = validator_1.Validator['validate'](rawDefinition, TestSchema);
|
|
201
|
+
custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
|
|
202
|
+
expect(value).toStrictEqual(undefined);
|
|
203
|
+
expect(context_1.Context.errorLogs).toStrictEqual([
|
|
204
|
+
{
|
|
205
|
+
description: '"str1" is required',
|
|
206
|
+
location: {
|
|
207
|
+
line: mocks_1.SampleLocation1.line + 1,
|
|
208
|
+
path: mocks_1.SampleLocation1.path
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
]);
|
|
212
|
+
});
|
|
213
|
+
test('should log error for invalid flag attribute value', () => {
|
|
214
|
+
let rawDefinition = getSampleRawDefinition('a', 'wrong text');
|
|
215
|
+
let value = validator_1.Validator['validate'](rawDefinition, TestSchema);
|
|
216
|
+
custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
|
|
217
|
+
expect(value).toStrictEqual(undefined);
|
|
218
|
+
expect(context_1.Context.errorLogs).toStrictEqual([
|
|
219
|
+
{
|
|
220
|
+
description: `"str2" with value "wrong text" fails to match the required pattern: /^[\\S]+$/`,
|
|
221
|
+
location: {
|
|
222
|
+
line: mocks_1.SampleLocation1.line + 2,
|
|
223
|
+
path: mocks_1.SampleLocation1.path
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
]);
|
|
227
|
+
});
|
|
228
|
+
test('should log error for non matching pattern', () => {
|
|
229
|
+
let schema = joi_1.default.object().keys({
|
|
230
|
+
str1: joi_1.default
|
|
231
|
+
.string()
|
|
232
|
+
.regex(/^[a-z]+([a-zA-Z0-9]+)*$/)
|
|
233
|
+
.required(),
|
|
234
|
+
str2: joi_1.default
|
|
235
|
+
.string()
|
|
236
|
+
.regex(/^[a-z]+([a-zA-Z0-9]+)*$/)
|
|
237
|
+
.required()
|
|
238
|
+
});
|
|
239
|
+
let rawDefinition = getSampleRawDefinition('1a', 'wrong string');
|
|
240
|
+
let value = validator_1.Validator['validate'](rawDefinition, schema);
|
|
241
|
+
custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
|
|
242
|
+
expect(value).toStrictEqual(undefined);
|
|
243
|
+
expect(context_1.Context.errorLogs).toStrictEqual([
|
|
244
|
+
{
|
|
245
|
+
description: `"str1" with value "1a" fails to match the required pattern: /^[a-z]+([a-zA-Z0-9]+)*$/`,
|
|
246
|
+
location: {
|
|
247
|
+
line: mocks_1.SampleLocation1.line + 1,
|
|
248
|
+
path: mocks_1.SampleLocation1.path
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
description: `"str2" with value "wrong string" fails to match the required pattern: /^[a-z]+([a-zA-Z0-9]+)*$/`,
|
|
253
|
+
location: {
|
|
254
|
+
line: mocks_1.SampleLocation1.line + 2,
|
|
255
|
+
path: mocks_1.SampleLocation1.path
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
]);
|
|
259
|
+
});
|
|
260
|
+
test('should validate primitive definition', () => {
|
|
261
|
+
let rawDefinition = {
|
|
262
|
+
componentName: ComponentType,
|
|
263
|
+
location: mocks_1.SampleLocation1,
|
|
264
|
+
parsedStructure: {
|
|
265
|
+
line: mocks_1.SampleLocation1.line + 1,
|
|
266
|
+
rawData: 'test'
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
let value = validator_1.Validator['validate'](rawDefinition, joi_1.default.string());
|
|
270
|
+
custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
|
|
271
|
+
expect(value).toStrictEqual('test');
|
|
272
|
+
expect(context_1.Context.errorLogs).toStrictEqual([]);
|
|
273
|
+
});
|
|
274
|
+
test('should log error for primitive definition', () => {
|
|
275
|
+
let rawDefinition = {
|
|
276
|
+
componentName: ComponentType,
|
|
277
|
+
location: mocks_1.SampleLocation1,
|
|
278
|
+
parsedStructure: {
|
|
279
|
+
line: mocks_1.SampleLocation1.line + 1,
|
|
280
|
+
rawData: 'test'
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
let value = validator_1.Validator['validate'](rawDefinition, joi_1.default.string().valid('only'));
|
|
284
|
+
custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
|
|
285
|
+
expect(value).toStrictEqual(undefined);
|
|
286
|
+
expect(context_1.Context.errorLogs).toStrictEqual([
|
|
287
|
+
{
|
|
288
|
+
description: '"value" must be [only]',
|
|
289
|
+
location: {
|
|
290
|
+
line: mocks_1.SampleLocation1.line + 1,
|
|
291
|
+
path: mocks_1.SampleLocation1.path
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
]);
|
|
295
|
+
});
|
|
296
|
+
test('should validate nested object', () => {
|
|
297
|
+
let schema = joi_1.default.object().keys({
|
|
298
|
+
obj1: joi_1.default.array().items(
|
|
299
|
+
joi_1.default.object().keys({
|
|
300
|
+
obj2: joi_1.default.string()
|
|
301
|
+
})
|
|
302
|
+
)
|
|
303
|
+
});
|
|
304
|
+
let value = validator_1.Validator['validate'](SampleNestedRawDefinition, schema);
|
|
305
|
+
custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
|
|
306
|
+
expect(value).toStrictEqual({ obj1: [{ obj2: 'test data' }] });
|
|
307
|
+
expect(context_1.Context.errorLogs).toStrictEqual([]);
|
|
308
|
+
});
|
|
309
|
+
test('should log error for nested object', () => {
|
|
310
|
+
let schema = joi_1.default.object().keys({
|
|
311
|
+
obj1: joi_1.default.array().items(
|
|
312
|
+
joi_1.default.object().keys({
|
|
313
|
+
obj2: joi_1.default.string().valid('only')
|
|
314
|
+
})
|
|
315
|
+
)
|
|
316
|
+
});
|
|
317
|
+
let value = validator_1.Validator['validate'](SampleNestedRawDefinition, schema);
|
|
318
|
+
custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
|
|
319
|
+
expect(value).toStrictEqual(undefined);
|
|
320
|
+
expect(context_1.Context.errorLogs).toStrictEqual([
|
|
321
|
+
{
|
|
322
|
+
description: '"obj1[0].obj2" must be [only]',
|
|
323
|
+
location: {
|
|
324
|
+
line: mocks_1.SampleLocation1.line + 2,
|
|
325
|
+
path: 'D:/test/file-1.md'
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
]);
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
//# sourceMappingURL=validator.spec.js.map
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { FileInfo, LocationInFile, ErrorLog } from '../framework/interfaces';
|
|
2
2
|
export interface DefinitionPlaneText {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
readonly type: string;
|
|
4
|
+
readonly content: string[];
|
|
5
|
+
readonly location: LocationInFile;
|
|
6
6
|
}
|
|
7
7
|
export interface SelectDefinitionsResult {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
definitionPlaneTexts: DefinitionPlaneText[];
|
|
9
|
+
errorLogs: ErrorLog[];
|
|
10
10
|
}
|
|
11
11
|
export declare class SelectDefinitionsHelper {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
private definitionsStarted;
|
|
13
|
+
private currentItem;
|
|
14
|
+
private definitionPlaneTexts;
|
|
15
|
+
private errorLogs;
|
|
16
|
+
private currentFilePath;
|
|
17
|
+
process(file: FileInfo): SelectDefinitionsResult;
|
|
18
|
+
private flushCurrentItem;
|
|
19
|
+
private onDeclarationEncountered;
|
|
20
20
|
}
|