definition-generator-framework 1.13.1 → 2.0.0-rc0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/dist/index.d.mts +198 -0
  2. package/dist/index.d.ts +198 -17
  3. package/dist/index.js +43 -50
  4. package/dist/index.mjs +43 -0
  5. package/package.json +27 -13
  6. package/dist/_mocks/mocks.d.ts +0 -7
  7. package/dist/_mocks/mocks.js +0 -44
  8. package/dist/decorators/definition-component.d.ts +0 -18
  9. package/dist/decorators/definition-component.js +0 -52
  10. package/dist/decorators/definition-generator.d.ts +0 -11
  11. package/dist/decorators/definition-generator.js +0 -30
  12. package/dist/framework/context.d.ts +0 -24
  13. package/dist/framework/context.js +0 -64
  14. package/dist/framework/definition-component.d.ts +0 -20
  15. package/dist/framework/definition-component.js +0 -29
  16. package/dist/framework/definition-generator.d.ts +0 -11
  17. package/dist/framework/definition-generator.js +0 -22
  18. package/dist/framework/definition-store.d.ts +0 -25
  19. package/dist/framework/definition-store.js +0 -121
  20. package/dist/framework/file-content-generator/file-content-generator.d.ts +0 -19
  21. package/dist/framework/file-content-generator/file-content-generator.js +0 -117
  22. package/dist/framework/file-content-generator/file-content-generator.test.d.ts +0 -24
  23. package/dist/framework/file-content-generator/file-content-generator.test.js +0 -161
  24. package/dist/framework/file-generators/index-file-generator.d.ts +0 -13
  25. package/dist/framework/file-generators/index-file-generator.js +0 -139
  26. package/dist/framework/file-generators/types-file-generator.d.ts +0 -6
  27. package/dist/framework/file-generators/types-file-generator.js +0 -35
  28. package/dist/framework/framework.d.ts +0 -28
  29. package/dist/framework/framework.data.d.ts +0 -6
  30. package/dist/framework/framework.data.js +0 -17
  31. package/dist/framework/framework.js +0 -51
  32. package/dist/framework/framework.model.d.ts +0 -32
  33. package/dist/framework/framework.model.js +0 -3
  34. package/dist/framework/index-file-generator/index-file-generator.d.ts +0 -10
  35. package/dist/framework/index-file-generator/index-file-generator.js +0 -118
  36. package/dist/framework/interfaces.d.ts +0 -46
  37. package/dist/framework/interfaces.js +0 -3
  38. package/dist/framework/kernel.d.ts +0 -12
  39. package/dist/framework/kernel.js +0 -308
  40. package/dist/helpers/common-functions/common-functions.d.ts +0 -10
  41. package/dist/helpers/common-functions/common-functions.js +0 -29
  42. package/dist/helpers/common-functions/common-functions.spec.d.ts +0 -1
  43. package/dist/helpers/common-functions/common-functions.spec.js +0 -50
  44. package/dist/helpers/common-functions/common-functions.test.d.ts +0 -1
  45. package/dist/helpers/common-functions/common-functions.test.js +0 -51
  46. package/dist/helpers/duplicate-helper/duplicate-helper.d.ts +0 -11
  47. package/dist/helpers/duplicate-helper/duplicate-helper.js +0 -40
  48. package/dist/helpers/duplicate-helper/duplicate-helper.spec.d.ts +0 -1
  49. package/dist/helpers/duplicate-helper/duplicate-helper.spec.js +0 -54
  50. package/dist/helpers/duplicate-helper/duplicate-helper.test.d.ts +0 -1
  51. package/dist/helpers/duplicate-helper/duplicate-helper.test.js +0 -55
  52. package/dist/helpers/output-helper/output-helper.d.ts +0 -30
  53. package/dist/helpers/output-helper/output-helper.js +0 -143
  54. package/dist/helpers/output-helper/output-helper.spec.d.ts +0 -24
  55. package/dist/helpers/output-helper/output-helper.spec.js +0 -261
  56. package/dist/helpers/output-helper/output-helper.test.d.ts +0 -24
  57. package/dist/helpers/output-helper/output-helper.test.js +0 -262
  58. package/dist/helpers/raw-definition-helper/raw-definition.helper.d.ts +0 -7
  59. package/dist/helpers/raw-definition-helper/raw-definition.helper.js +0 -66
  60. package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.d.ts +0 -1
  61. package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.js +0 -143
  62. package/dist/helpers/raw-definition-helper/raw-definition.helper.test.d.ts +0 -1
  63. package/dist/helpers/raw-definition-helper/raw-definition.helper.test.js +0 -136
  64. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.d.ts +0 -16
  65. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.js +0 -48
  66. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.d.ts +0 -1
  67. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.js +0 -191
  68. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.test.d.ts +0 -1
  69. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.test.js +0 -213
  70. package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.d.ts +0 -13
  71. package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.js +0 -53
  72. package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.test.d.ts +0 -1
  73. package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.test.js +0 -96
  74. package/dist/helpers/validator/custom-validators/image.custom-validator.d.ts +0 -14
  75. package/dist/helpers/validator/custom-validators/image.custom-validator.js +0 -44
  76. package/dist/helpers/validator/custom-validators/path.custom-validator.d.ts +0 -9
  77. package/dist/helpers/validator/custom-validators/path.custom-validator.js +0 -30
  78. package/dist/helpers/validator/custom-validators/position-on-sprite.d.ts +0 -14
  79. package/dist/helpers/validator/custom-validators/position-on-sprite.js +0 -44
  80. package/dist/helpers/validator/custom-validators/reference.custom-validator.d.ts +0 -22
  81. package/dist/helpers/validator/custom-validators/reference.custom-validator.js +0 -123
  82. package/dist/helpers/validator/custom-validators/sprite.custom-validator.d.ts +0 -14
  83. package/dist/helpers/validator/custom-validators/sprite.custom-validator.js +0 -43
  84. package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.d.ts +0 -9
  85. package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.js +0 -33
  86. package/dist/helpers/validator/custom-validators/unique.custom-validator.d.ts +0 -8
  87. package/dist/helpers/validator/custom-validators/unique.custom-validator.js +0 -20
  88. package/dist/helpers/validator/joi-custom-validators.d.ts +0 -33
  89. package/dist/helpers/validator/joi-custom-validators.js +0 -54
  90. package/dist/helpers/validator/joi-custom-validators.spec.d.ts +0 -1
  91. package/dist/helpers/validator/joi-custom-validators.spec.js +0 -304
  92. package/dist/helpers/validator/validator.d.ts +0 -21
  93. package/dist/helpers/validator/validator.js +0 -74
  94. package/dist/helpers/validator/validator.spec.d.ts +0 -1
  95. package/dist/helpers/validator/validator.spec.js +0 -332
  96. package/dist/helpers/validator/validator.test.d.ts +0 -1
  97. package/dist/helpers/validator/validator.test.js +0 -329
  98. package/dist/pipeline/1-select-definitions-helper.d.ts +0 -20
  99. package/dist/pipeline/1-select-definitions-helper.js +0 -76
  100. package/dist/pipeline/1-select-definitions.helper.d.ts +0 -20
  101. package/dist/pipeline/1-select-definitions.helper.js +0 -80
  102. package/dist/pipeline/1-select-definitions.helper.test.d.ts +0 -1
  103. package/dist/pipeline/1-select-definitions.helper.test.js +0 -141
  104. package/dist/pipeline/1-select-definitions.spec.d.ts +0 -1
  105. package/dist/pipeline/1-select-definitions.spec.js +0 -140
  106. package/dist/pipeline/2-structure-parser.helper.d.ts +0 -11
  107. package/dist/pipeline/2-structure-parser.helper.js +0 -70
  108. package/dist/pipeline/2-structure-parser.helper.spec.d.ts +0 -1
  109. package/dist/pipeline/2-structure-parser.helper.spec.js +0 -280
  110. package/dist/pipeline/2-structure-parser.helper.test.d.ts +0 -1
  111. package/dist/pipeline/2-structure-parser.helper.test.js +0 -281
  112. package/dist/pipeline/3-config.d.ts +0 -9
  113. package/dist/pipeline/3-config.js +0 -36
  114. package/dist/pipeline/_mocks/index.d.ts +0 -13
  115. package/dist/pipeline/_mocks/index.js +0 -52
  116. package/dist/pipeline/parsers/array-parser.d.ts +0 -4
  117. package/dist/pipeline/parsers/array-parser.js +0 -69
  118. package/dist/pipeline/parsers/array-parser.spec.d.ts +0 -1
  119. package/dist/pipeline/parsers/array-parser.spec.js +0 -128
  120. package/dist/pipeline/parsers/array-parser.test.d.ts +0 -1
  121. package/dist/pipeline/parsers/array-parser.test.js +0 -126
  122. package/dist/pipeline/parsers/object-parser.d.ts +0 -4
  123. package/dist/pipeline/parsers/object-parser.js +0 -135
  124. package/dist/pipeline/parsers/object-parser.spec.d.ts +0 -1
  125. package/dist/pipeline/parsers/object-parser.spec.js +0 -179
  126. package/dist/pipeline/parsers/object-parser.test.d.ts +0 -1
  127. package/dist/pipeline/parsers/object-parser.test.js +0 -186
  128. package/dist/pipeline/parsers/primitive-parser.d.ts +0 -7
  129. package/dist/pipeline/parsers/primitive-parser.js +0 -111
  130. package/dist/pipeline/parsers/primitive-parser.spec.d.ts +0 -1
  131. package/dist/pipeline/parsers/primitive-parser.spec.js +0 -79
  132. package/dist/pipeline/parsers/primitive-parser.test.d.ts +0 -1
  133. package/dist/pipeline/parsers/primitive-parser.test.js +0 -85
  134. package/dist/pipeline/raw-data-parser.d.ts +0 -5
  135. package/dist/pipeline/raw-data-parser.js +0 -25
  136. package/dist/pre-made-components/_validators/shape-validators.d.ts +0 -7
  137. package/dist/pre-made-components/_validators/shape-validators.js +0 -37
  138. package/dist/pre-made-components/_validators/sprite-validators.d.ts +0 -7
  139. package/dist/pre-made-components/_validators/sprite-validators.js +0 -43
  140. package/dist/pre-made-components/assets/1-sprite.d.ts +0 -15
  141. package/dist/pre-made-components/assets/1-sprite.js +0 -74
  142. package/dist/pre-made-components/assets/2-sprite-group.d.ts +0 -11
  143. package/dist/pre-made-components/assets/2-sprite-group.js +0 -41
  144. package/dist/pre-made-components/assets/3-font.d.ts +0 -17
  145. package/dist/pre-made-components/assets/3-font.js +0 -71
  146. package/dist/pre-made-components/events/1-event.d.ts +0 -6
  147. package/dist/pre-made-components/events/1-event.js +0 -206
  148. package/dist/pre-made-components/events/1-script.d.ts +0 -8
  149. package/dist/pre-made-components/events/1-script.js +0 -102
  150. package/dist/pre-made-components/events/2-event-test.d.ts +0 -18
  151. package/dist/pre-made-components/events/2-event-test.js +0 -172
  152. package/dist/pre-made-components/events/2-script-test.d.ts +0 -7
  153. package/dist/pre-made-components/events/2-script-test.js +0 -102
  154. package/dist/pre-made-components/events/3-event.d.ts +0 -7
  155. package/dist/pre-made-components/events/3-event.js +0 -100
  156. package/dist/pre-made-components/events/4-event-test.d.ts +0 -7
  157. package/dist/pre-made-components/events/4-event-test.js +0 -89
  158. package/dist/pre-made-components/events/event-setup.d.ts +0 -13
  159. package/dist/pre-made-components/events/event-setup.js +0 -20
  160. package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.d.ts +0 -3
  161. package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.js +0 -24
  162. package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.test.d.ts +0 -1
  163. package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.test.js +0 -39
  164. package/dist/pre-made-components/events/helpers/script-testing.helper.d.ts +0 -33
  165. package/dist/pre-made-components/events/helpers/script-testing.helper.js +0 -79
  166. package/dist/pre-made-components/events/script-setup.d.ts +0 -8
  167. package/dist/pre-made-components/events/script-setup.js +0 -16
  168. package/dist/pre-made-components/events/scripting-setup.d.ts +0 -33
  169. package/dist/pre-made-components/events/scripting-setup.js +0 -97
  170. package/dist/pre-made-components/events/validators.d.ts +0 -6
  171. package/dist/pre-made-components/events/validators.js +0 -96
  172. package/dist/setup.d.ts +0 -1
  173. package/dist/setup.js +0 -10
@@ -1,329 +0,0 @@
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 });
6
- const joi_1 = __importDefault(require("joi"));
7
- const vitest_1 = require("vitest");
8
- const mocks_1 = require("../../_mocks/mocks");
9
- const context_1 = require("../../framework/context");
10
- const definition_store_1 = require("../../framework/definition-store");
11
- const custom_validator_helper_1 = require("./custom-validator-helper/custom-validator.helper");
12
- const joi_custom_validators_1 = require("./joi-custom-validators");
13
- const validator_1 = require("./validator");
14
- joi_custom_validators_1.JoiCustomValidators.decorate(joi_1.default, { existsSync: (path) => path !== 'D:/test/false/path.png' });
15
- const ComponentType = 'ASSET';
16
- class Asset {
17
- static { this.$meta = {
18
- componentName: ComponentType,
19
- keyName: 'name'
20
- }; }
21
- async process() { }
22
- }
23
- definition_store_1.DefinitionStore['setComponents'](new Map([[ComponentType, Asset]]));
24
- const TestSchema = joi_1.default.object().keys({
25
- str1: joi_1.default.string().required(),
26
- str2: joi_1.default.string().path().optional()
27
- });
28
- function getSampleRawDefinition(str, pathString) {
29
- let rawDefinition = {
30
- componentName: ComponentType,
31
- location: mocks_1.SampleLocation1,
32
- parsedStructure: {
33
- line: mocks_1.SampleLocation1.line + 1,
34
- rawData: {
35
- str1: {
36
- rawData: str,
37
- line: mocks_1.SampleLocation1.line + 1
38
- },
39
- str2: {
40
- rawData: pathString,
41
- line: mocks_1.SampleLocation1.line + 2
42
- }
43
- }
44
- }
45
- };
46
- return rawDefinition;
47
- }
48
- const SampleNestedRawDefinition = {
49
- componentName: ComponentType,
50
- location: mocks_1.SampleLocation1,
51
- parsedStructure: {
52
- line: mocks_1.SampleLocation1.line + 1,
53
- rawData: {
54
- obj1: {
55
- line: mocks_1.SampleLocation1.line + 1,
56
- rawData: [
57
- {
58
- line: mocks_1.SampleLocation1.line + 2,
59
- rawData: {
60
- obj2: {
61
- line: mocks_1.SampleLocation1.line + 2,
62
- rawData: 'test data'
63
- }
64
- }
65
- }
66
- ]
67
- }
68
- }
69
- }
70
- };
71
- (0, vitest_1.describe)('VALIDATOR', () => {
72
- (0, vitest_1.beforeEach)(() => {
73
- (0, mocks_1.resetContext)();
74
- custom_validator_helper_1.CustomValidatorHelper['duplicateHelpers'] = new Map();
75
- });
76
- (0, vitest_1.describe)('Convert', () => {
77
- (0, vitest_1.test)('valid definition', () => {
78
- context_1.Context.rawDefinitions.push(getSampleRawDefinition('str1', 'images/test.png'));
79
- let definitions = validator_1.Validator.validateAndConvert(ComponentType, TestSchema).map(item => item.definition);
80
- custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
81
- (0, vitest_1.expect)(context_1.Context['errorLogBuffer']).toStrictEqual([]);
82
- (0, vitest_1.expect)(definitions).toStrictEqual([{ str1: 'str1', str2: '.test/images/test.png' }]);
83
- });
84
- (0, vitest_1.test)('singular definition', () => {
85
- context_1.Context.rawDefinitions.push(getSampleRawDefinition('str1', 'images/test.png'));
86
- let definitions = validator_1.Validator.validateAndConvert(ComponentType, TestSchema).map(item => item.definition);
87
- custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
88
- (0, vitest_1.expect)(context_1.Context['errorLogBuffer']).toStrictEqual([]);
89
- (0, vitest_1.expect)(definitions).toStrictEqual([{ str1: 'str1', str2: '.test/images/test.png' }]);
90
- });
91
- (0, vitest_1.test)('should allow references in the same namespace', () => {
92
- let rawDefinition1 = {
93
- componentName: ComponentType,
94
- location: mocks_1.SampleLocation1,
95
- parsedStructure: {
96
- line: mocks_1.SampleLocation1.line + 1,
97
- rawData: {
98
- name: {
99
- rawData: 'asset2',
100
- line: mocks_1.SampleLocation1.line + 1
101
- },
102
- ref: {
103
- rawData: 'asset1',
104
- line: mocks_1.SampleLocation1.line + 2
105
- }
106
- }
107
- }
108
- };
109
- let rawDefinition2 = {
110
- componentName: ComponentType,
111
- location: mocks_1.SampleLocation1,
112
- parsedStructure: {
113
- line: mocks_1.SampleLocation1.line + 1,
114
- rawData: {
115
- name: {
116
- rawData: 'asset1',
117
- line: mocks_1.SampleLocation1.line + 1
118
- }
119
- }
120
- }
121
- };
122
- context_1.Context.rawDefinitions.push(rawDefinition1);
123
- context_1.Context.rawDefinitions.push(rawDefinition2);
124
- let schema = joi_1.default.object().keys({
125
- name: joi_1.default.string().required(),
126
- ref: joi_1.default.string().lazyReference('ASSET').optional()
127
- });
128
- definition_store_1.DefinitionStore['setRawDefinitionByKey'](Asset, 'asset1', rawDefinition2);
129
- context_1.Context.componentInProgressData = {
130
- meta: { keyName: 'name', componentName: ComponentType },
131
- idToReferencesMap: new Map()
132
- };
133
- let definitions = validator_1.Validator.validateAndConvert(ComponentType, schema).map(item => item.definition);
134
- custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
135
- (0, vitest_1.expect)(context_1.Context['errorLogBuffer']).toStrictEqual([]);
136
- (0, vitest_1.expect)(definitions).toStrictEqual([
137
- {
138
- name: 'asset2',
139
- ref: 'asset1'
140
- },
141
- {
142
- name: 'asset1'
143
- }
144
- ]);
145
- });
146
- });
147
- (0, vitest_1.describe)('Convert Singular', () => {
148
- (0, vitest_1.test)('valid definition', () => {
149
- context_1.Context.rawDefinitions.push(getSampleRawDefinition('str1', 'images/test.png'));
150
- let result = validator_1.Validator.validateAndConvertSingular(ComponentType, TestSchema);
151
- custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
152
- (0, vitest_1.expect)(context_1.Context['errorLogBuffer']).toStrictEqual([]);
153
- (0, vitest_1.expect)(result?.definition).toStrictEqual({ str1: 'str1', str2: '.test/images/test.png' });
154
- });
155
- (0, vitest_1.test)('should log error for no definition', () => {
156
- let definition = validator_1.Validator.validateAndConvertSingular(ComponentType, TestSchema);
157
- custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
158
- (0, vitest_1.expect)(definition).toStrictEqual(undefined);
159
- (0, vitest_1.expect)(context_1.Context['errorLogBuffer']).toStrictEqual([
160
- {
161
- description: 'Singleton definition has no declared entry "ASSET"',
162
- location: {
163
- line: 0,
164
- path: '*'
165
- }
166
- }
167
- ]);
168
- });
169
- (0, vitest_1.test)('should log error for multiple definitions', () => {
170
- context_1.Context.rawDefinitions.push(getSampleRawDefinition('str1', 'images/test.png'));
171
- context_1.Context.rawDefinitions.push(getSampleRawDefinition('str2', 'images/test.png'));
172
- let definition = validator_1.Validator.validateAndConvertSingular(ComponentType, TestSchema);
173
- custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
174
- (0, vitest_1.expect)(definition).toStrictEqual(undefined);
175
- (0, vitest_1.expect)(context_1.Context['errorLogBuffer']).toStrictEqual([
176
- {
177
- description: 'Only one definition can be defined for "ASSET"',
178
- location: {
179
- line: 2,
180
- path: 'D:/test/file-1.md'
181
- }
182
- },
183
- {
184
- description: 'Only one definition can be defined for "ASSET"',
185
- location: {
186
- line: 2,
187
- path: 'D:/test/file-1.md'
188
- }
189
- }
190
- ]);
191
- });
192
- });
193
- (0, vitest_1.describe)('Validate', () => {
194
- (0, vitest_1.test)('should handle valid raw definition', () => {
195
- let rawDefinition = getSampleRawDefinition('a', 'images/test.png');
196
- let value = validator_1.Validator['validate'](rawDefinition, TestSchema);
197
- custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
198
- (0, vitest_1.expect)(value).toStrictEqual({ str1: 'a', str2: '.test/images/test.png' });
199
- (0, vitest_1.expect)(context_1.Context['errorLogBuffer']).toStrictEqual([]);
200
- });
201
- (0, vitest_1.test)('should log error for required fields', () => {
202
- let rawDefinition = getSampleRawDefinition(undefined, 'images/test.png');
203
- let value = validator_1.Validator['validate'](rawDefinition, TestSchema);
204
- custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
205
- (0, vitest_1.expect)(value).toStrictEqual(undefined);
206
- (0, vitest_1.expect)(context_1.Context['errorLogBuffer']).toStrictEqual([
207
- {
208
- description: '"str1" is required',
209
- location: {
210
- line: mocks_1.SampleLocation1.line + 1,
211
- path: mocks_1.SampleLocation1.path
212
- }
213
- }
214
- ]);
215
- });
216
- (0, vitest_1.test)('should log error for invalid flag attribute value', () => {
217
- let rawDefinition = getSampleRawDefinition('a', 'wrong text');
218
- let value = validator_1.Validator['validate'](rawDefinition, TestSchema);
219
- custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
220
- (0, vitest_1.expect)(value).toStrictEqual(undefined);
221
- (0, vitest_1.expect)(context_1.Context['errorLogBuffer']).toStrictEqual([
222
- {
223
- description: `"str2" with value "wrong text" fails to match the required pattern: /^[\\S]+$/`,
224
- location: {
225
- line: mocks_1.SampleLocation1.line + 2,
226
- path: mocks_1.SampleLocation1.path
227
- }
228
- }
229
- ]);
230
- });
231
- (0, vitest_1.test)('should log error for non matching pattern', () => {
232
- let schema = joi_1.default.object().keys({
233
- str1: joi_1.default.string()
234
- .regex(/^[a-z]+([a-zA-Z0-9]+)*$/)
235
- .required(),
236
- str2: joi_1.default.string()
237
- .regex(/^[a-z]+([a-zA-Z0-9]+)*$/)
238
- .required()
239
- });
240
- let rawDefinition = getSampleRawDefinition('1a', 'wrong string');
241
- let value = validator_1.Validator['validate'](rawDefinition, schema);
242
- custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
243
- (0, vitest_1.expect)(value).toStrictEqual(undefined);
244
- (0, vitest_1.expect)(context_1.Context['errorLogBuffer']).toStrictEqual([
245
- {
246
- description: `"str1" with value "1a" fails to match the required pattern: /^[a-z]+([a-zA-Z0-9]+)*$/`,
247
- location: {
248
- line: mocks_1.SampleLocation1.line + 1,
249
- path: mocks_1.SampleLocation1.path
250
- }
251
- },
252
- {
253
- description: `"str2" with value "wrong string" fails to match the required pattern: /^[a-z]+([a-zA-Z0-9]+)*$/`,
254
- location: {
255
- line: mocks_1.SampleLocation1.line + 2,
256
- path: mocks_1.SampleLocation1.path
257
- }
258
- }
259
- ]);
260
- });
261
- (0, vitest_1.test)('should validate primitive definition', () => {
262
- let rawDefinition = {
263
- componentName: ComponentType,
264
- location: mocks_1.SampleLocation1,
265
- parsedStructure: {
266
- line: mocks_1.SampleLocation1.line + 1,
267
- rawData: 'test'
268
- }
269
- };
270
- let value = validator_1.Validator['validate'](rawDefinition, joi_1.default.string());
271
- custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
272
- (0, vitest_1.expect)(value).toStrictEqual('test');
273
- (0, vitest_1.expect)(context_1.Context['errorLogBuffer']).toStrictEqual([]);
274
- });
275
- (0, vitest_1.test)('should log error for primitive definition', () => {
276
- let rawDefinition = {
277
- componentName: ComponentType,
278
- location: mocks_1.SampleLocation1,
279
- parsedStructure: {
280
- line: mocks_1.SampleLocation1.line + 1,
281
- rawData: 'test'
282
- }
283
- };
284
- let value = validator_1.Validator['validate'](rawDefinition, joi_1.default.string().valid('only'));
285
- custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
286
- (0, vitest_1.expect)(value).toStrictEqual(undefined);
287
- (0, vitest_1.expect)(context_1.Context['errorLogBuffer']).toStrictEqual([
288
- {
289
- description: '"value" must be [only]',
290
- location: {
291
- line: mocks_1.SampleLocation1.line + 1,
292
- path: mocks_1.SampleLocation1.path
293
- }
294
- }
295
- ]);
296
- });
297
- (0, vitest_1.test)('should validate nested object', () => {
298
- let schema = joi_1.default.object().keys({
299
- obj1: joi_1.default.array().items(joi_1.default.object().keys({
300
- obj2: joi_1.default.string()
301
- }))
302
- });
303
- let value = validator_1.Validator['validate'](SampleNestedRawDefinition, schema);
304
- custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
305
- (0, vitest_1.expect)(value).toStrictEqual({ obj1: [{ obj2: 'test data' }] });
306
- (0, vitest_1.expect)(context_1.Context['errorLogBuffer']).toStrictEqual([]);
307
- });
308
- (0, vitest_1.test)('should log error for nested object', () => {
309
- let schema = joi_1.default.object().keys({
310
- obj1: joi_1.default.array().items(joi_1.default.object().keys({
311
- obj2: joi_1.default.string().valid('only')
312
- }))
313
- });
314
- let value = validator_1.Validator['validate'](SampleNestedRawDefinition, schema);
315
- custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
316
- (0, vitest_1.expect)(value).toStrictEqual(undefined);
317
- (0, vitest_1.expect)(context_1.Context['errorLogBuffer']).toStrictEqual([
318
- {
319
- description: '"obj1[0].obj2" must be [only]',
320
- location: {
321
- line: mocks_1.SampleLocation1.line + 2,
322
- path: 'D:/test/file-1.md'
323
- }
324
- }
325
- ]);
326
- });
327
- });
328
- });
329
- //# sourceMappingURL=validator.test.js.map
@@ -1,20 +0,0 @@
1
- import { FileInfo, LocationInFile, ErrorLog } from '../framework/interfaces';
2
- export interface DefinitionPlaneText {
3
- readonly type: string;
4
- readonly content: string[];
5
- readonly location: LocationInFile;
6
- }
7
- export interface SelectDefinitionsResult {
8
- definitionPlaneTexts: DefinitionPlaneText[];
9
- errorLogs: ErrorLog[];
10
- }
11
- export declare class SelectDefinitionsHelper {
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
- }
@@ -1,76 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.SelectDefinitionsHelper = void 0;
4
- const common_functions_1 = require('../helpers/common-functions/common-functions');
5
- const definition_store_1 = require('../framework/definition-store');
6
- class SelectDefinitionsHelper {
7
- constructor() {
8
- this.definitionsStarted = false;
9
- this.definitionPlaneTexts = [];
10
- this.errorLogs = [];
11
- this.currentFilePath = '';
12
- }
13
- process(file) {
14
- this.definitionsStarted = false;
15
- this.currentItem = undefined;
16
- this.definitionPlaneTexts = [];
17
- this.errorLogs = [];
18
- this.currentFilePath = file.path;
19
- file.content.split('\n').forEach((row, index) => {
20
- let trimmedRow = common_functions_1.CommonFunctions.removeWhiteSpace(row);
21
- if (this.definitionsStarted) {
22
- if (trimmedRow.startsWith('###')) {
23
- this.flushCurrentItem();
24
- this.onDeclarationEncountered(row, index, trimmedRow.substring(4));
25
- } else if (this.currentItem && trimmedRow.length > 0) {
26
- this.currentItem.content.push(common_functions_1.CommonFunctions.removeComments(row));
27
- }
28
- } else if (trimmedRow === '# DEFINITIONS') {
29
- this.definitionsStarted = true;
30
- }
31
- });
32
- this.flushCurrentItem();
33
- return {
34
- definitionPlaneTexts: this.definitionPlaneTexts,
35
- errorLogs: this.errorLogs
36
- };
37
- }
38
- flushCurrentItem() {
39
- if (this.currentItem) {
40
- if (this.currentItem.content.length > 0) {
41
- this.definitionPlaneTexts.push(this.currentItem);
42
- } else {
43
- let errorLog = {
44
- description: 'Definitions cannot be empty!',
45
- location: this.currentItem.location
46
- };
47
- this.errorLogs.push(errorLog);
48
- }
49
- }
50
- this.currentItem = undefined;
51
- }
52
- onDeclarationEncountered(row, index, componentName) {
53
- if (definition_store_1.DefinitionStore['isValidComponentName'](componentName)) {
54
- this.currentItem = {
55
- type: componentName,
56
- location: {
57
- line: index + 1,
58
- path: this.currentFilePath
59
- },
60
- content: []
61
- };
62
- } else {
63
- let errorLog = {
64
- description: `Invalid definition header: "${row.trim()}"`,
65
- location: {
66
- line: index + 1,
67
- path: this.currentFilePath
68
- }
69
- };
70
- this.errorLogs.push(errorLog);
71
- this.currentItem = undefined;
72
- }
73
- }
74
- }
75
- exports.SelectDefinitionsHelper = SelectDefinitionsHelper;
76
- //# sourceMappingURL=1-select-definitions-helper.js.map
@@ -1,20 +0,0 @@
1
- import { ErrorLog, FileInfo, LocationInFile } from '../framework/interfaces';
2
- export interface DefinitionPlaneText {
3
- readonly type: string;
4
- readonly content: string[];
5
- readonly location: LocationInFile;
6
- }
7
- export interface SelectDefinitionsResult {
8
- definitionPlaneTexts: DefinitionPlaneText[];
9
- errorLogs: ErrorLog[];
10
- }
11
- export declare class SelectDefinitionsHelper {
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
- }
@@ -1,80 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SelectDefinitionsHelper = void 0;
4
- const definition_store_1 = require("../framework/definition-store");
5
- const common_functions_1 = require("../helpers/common-functions/common-functions");
6
- class SelectDefinitionsHelper {
7
- constructor() {
8
- this.definitionsStarted = false;
9
- this.definitionPlaneTexts = [];
10
- this.errorLogs = [];
11
- this.currentFilePath = '';
12
- }
13
- process(file) {
14
- this.definitionsStarted = false;
15
- this.currentItem = undefined;
16
- this.definitionPlaneTexts = [];
17
- this.errorLogs = [];
18
- this.currentFilePath = file.path;
19
- file.content.split('\n').forEach((row, index) => {
20
- let trimmedRow = common_functions_1.CommonFunctions.removeWhiteSpace(row);
21
- if (this.definitionsStarted) {
22
- if (trimmedRow.startsWith('###')) {
23
- this.flushCurrentItem();
24
- this.onDeclarationEncountered(row, index, trimmedRow.substring(4));
25
- }
26
- else if (this.currentItem && trimmedRow.length > 0) {
27
- this.currentItem.content.push(common_functions_1.CommonFunctions.removeComments(row));
28
- }
29
- }
30
- else if (trimmedRow === '# DEFINITIONS') {
31
- this.definitionsStarted = true;
32
- }
33
- });
34
- this.flushCurrentItem();
35
- return {
36
- definitionPlaneTexts: this.definitionPlaneTexts,
37
- errorLogs: this.errorLogs
38
- };
39
- }
40
- flushCurrentItem() {
41
- if (this.currentItem) {
42
- if (this.currentItem.content.length > 0) {
43
- this.definitionPlaneTexts.push(this.currentItem);
44
- }
45
- else {
46
- let errorLog = {
47
- description: 'Definitions cannot be empty!',
48
- location: this.currentItem.location
49
- };
50
- this.errorLogs.push(errorLog);
51
- }
52
- }
53
- this.currentItem = undefined;
54
- }
55
- onDeclarationEncountered(row, index, componentName) {
56
- if (definition_store_1.DefinitionStore['isValidComponentName'](componentName)) {
57
- this.currentItem = {
58
- type: componentName,
59
- location: {
60
- line: index + 1,
61
- path: this.currentFilePath
62
- },
63
- content: []
64
- };
65
- }
66
- else {
67
- let errorLog = {
68
- description: `Invalid definition header: "${row.trim()}"`,
69
- location: {
70
- line: index + 1,
71
- path: this.currentFilePath
72
- }
73
- };
74
- this.errorLogs.push(errorLog);
75
- this.currentItem = undefined;
76
- }
77
- }
78
- }
79
- exports.SelectDefinitionsHelper = SelectDefinitionsHelper;
80
- //# sourceMappingURL=1-select-definitions.helper.js.map
@@ -1 +0,0 @@
1
- export {};
@@ -1,141 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
- const mocks_1 = require("../_mocks/mocks");
5
- const definition_store_1 = require("../framework/definition-store");
6
- const custom_validator_helper_test_1 = require("../helpers/validator/custom-validator-helper/custom-validator.helper.test");
7
- const _1_select_definitions_helper_1 = require("./1-select-definitions.helper");
8
- definition_store_1.DefinitionStore['definitionsMap'].set(custom_validator_helper_test_1.AssetComponentName, new Map());
9
- (0, vitest_1.describe)('SELECT DEFINITIONS HELPER', () => {
10
- let selectDefinitionsHelper;
11
- (0, vitest_1.beforeEach)(() => {
12
- selectDefinitionsHelper = new _1_select_definitions_helper_1.SelectDefinitionsHelper();
13
- });
14
- (0, vitest_1.test)('should handle empty files', () => {
15
- let content = ``;
16
- let fileInfo = (0, mocks_1.getMockFileInfo)(content);
17
- let result = selectDefinitionsHelper.process(fileInfo);
18
- (0, vitest_1.expect)(result.definitionPlaneTexts).toStrictEqual([]);
19
- (0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
20
- });
21
- (0, vitest_1.test)('should handle files without definitions', () => {
22
- let content = `
23
- Explanation
24
-
25
- ### ASSET
26
- Name: singular name
27
- Path: path to file
28
- `;
29
- let fileInfo = (0, mocks_1.getMockFileInfo)(content);
30
- let result = selectDefinitionsHelper.process(fileInfo);
31
- (0, vitest_1.expect)(result.definitionPlaneTexts).toStrictEqual([]);
32
- (0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
33
- });
34
- (0, vitest_1.test)('should select definitions', () => {
35
- let content = `
36
- # DEFINITIONS
37
- ### ASSET
38
- Name: test
39
- Path: test.png
40
- `;
41
- let fileInfo = (0, mocks_1.getMockFileInfo)(content);
42
- let result = selectDefinitionsHelper.process(fileInfo);
43
- (0, vitest_1.expect)(result.definitionPlaneTexts).toStrictEqual([
44
- {
45
- type: 'ASSET',
46
- content: [' Name: test', ' Path: test.png'],
47
- location: { line: 3, path: fileInfo.path }
48
- }
49
- ]);
50
- (0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
51
- });
52
- (0, vitest_1.test)('should ignore comments', () => {
53
- let content = `
54
- # DEFINITIONS
55
- ### ASSET
56
- Name: test // comment
57
- Path: test.png // comment
58
- // ----comment----\r
59
- `;
60
- let fileInfo = (0, mocks_1.getMockFileInfo)(content);
61
- let result = selectDefinitionsHelper.process(fileInfo);
62
- (0, vitest_1.expect)(result.definitionPlaneTexts).toStrictEqual([
63
- {
64
- type: 'ASSET',
65
- content: [' Name: test', ' Path: test.png'],
66
- location: { line: 3, path: fileInfo.path }
67
- }
68
- ]);
69
- (0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
70
- });
71
- (0, vitest_1.test)('should not allow empty definitions', () => {
72
- let content = `
73
- # DEFINITIONS
74
- ### ASSET
75
- `;
76
- let fileInfo = (0, mocks_1.getMockFileInfo)(content);
77
- let result = selectDefinitionsHelper.process(fileInfo);
78
- (0, vitest_1.expect)(result.definitionPlaneTexts).toStrictEqual([]);
79
- (0, vitest_1.expect)(result.errorLogs).toStrictEqual([
80
- {
81
- description: 'Definitions cannot be empty!',
82
- location: { line: 3, path: fileInfo.path }
83
- }
84
- ]);
85
- });
86
- (0, vitest_1.test)('should not allow unknown definition header after the first valid definition', () => {
87
- let content = `
88
- # DEFINITIONS
89
- ### ASSET
90
- Name: test
91
- Path: test.png
92
-
93
- ### Some text
94
- some text
95
- `;
96
- let fileInfo = (0, mocks_1.getMockFileInfo)(content);
97
- let result = selectDefinitionsHelper.process(fileInfo);
98
- (0, vitest_1.expect)(result.errorLogs).toStrictEqual([
99
- {
100
- description: 'Invalid definition header: "### Some text"',
101
- location: { line: 7, path: fileInfo.path }
102
- }
103
- ]);
104
- });
105
- (0, vitest_1.test)('invalid definitions should not corrupt other definitions', () => {
106
- let content = `
107
- # DEFINITIONS
108
- ### ASSET
109
- Name: test
110
- Path: test.png
111
-
112
- ### Some text
113
- some text
114
-
115
- ### ASSET
116
- Name: test2
117
- Path: test2.png
118
- `;
119
- let fileInfo = (0, mocks_1.getMockFileInfo)(content);
120
- let result = selectDefinitionsHelper.process(fileInfo);
121
- (0, vitest_1.expect)(result.definitionPlaneTexts).toStrictEqual([
122
- {
123
- type: 'ASSET',
124
- content: [' Name: test', ' Path: test.png'],
125
- location: { line: 3, path: fileInfo.path }
126
- },
127
- {
128
- type: 'ASSET',
129
- content: [' Name: test2', ' Path: test2.png'],
130
- location: { line: 10, path: fileInfo.path }
131
- }
132
- ]);
133
- (0, vitest_1.expect)(result.errorLogs).toStrictEqual([
134
- {
135
- description: 'Invalid definition header: "### Some text"',
136
- location: { line: 7, path: fileInfo.path }
137
- }
138
- ]);
139
- });
140
- });
141
- //# sourceMappingURL=1-select-definitions.helper.test.js.map
@@ -1 +0,0 @@
1
- export {};