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.
Files changed (185) hide show
  1. package/dist/framework/definition-component.d.ts +11 -9
  2. package/dist/framework/definition-component.js +18 -18
  3. package/dist/framework/definition-generator.d.ts +6 -5
  4. package/dist/framework/definition-generator.js +16 -18
  5. package/dist/framework/file-content-generator/file-content-generator.js +1 -1
  6. package/dist/framework/file-content-generator/file-content-generator.test.js +49 -49
  7. package/dist/framework/framework.d.ts +14 -13
  8. package/dist/framework/framework.data.d.ts +3 -3
  9. package/dist/framework/framework.data.js +13 -7
  10. package/dist/framework/framework.js +36 -33
  11. package/dist/framework/framework.model.d.ts +15 -15
  12. package/dist/framework/framework.model.js +3 -3
  13. package/dist/helpers/common-functions/common-functions.js +1 -1
  14. package/dist/helpers/common-functions/common-functions.spec.d.ts +1 -0
  15. package/dist/helpers/common-functions/common-functions.spec.js +50 -0
  16. package/dist/helpers/duplicate-helper/duplicate-helper.spec.d.ts +1 -0
  17. package/dist/helpers/duplicate-helper/duplicate-helper.spec.js +54 -0
  18. package/dist/helpers/output-helper/output-helper.d.ts +26 -26
  19. package/dist/helpers/output-helper/output-helper.js +127 -107
  20. package/dist/helpers/output-helper/output-helper.spec.d.ts +24 -0
  21. package/dist/helpers/output-helper/output-helper.spec.js +261 -0
  22. package/dist/helpers/output-helper/output-helper.test.d.ts +22 -22
  23. package/dist/helpers/output-helper/output-helper.test.js +224 -212
  24. package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.d.ts +1 -0
  25. package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.js +143 -0
  26. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.d.ts +1 -0
  27. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.js +191 -0
  28. package/dist/helpers/validator/custom-validators/image.custom-validator.d.ts +6 -6
  29. package/dist/helpers/validator/custom-validators/image.custom-validator.js +40 -39
  30. package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.d.ts +4 -4
  31. package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.js +29 -29
  32. package/dist/helpers/validator/joi-custom-validators.spec.d.ts +1 -0
  33. package/dist/helpers/validator/joi-custom-validators.spec.js +304 -0
  34. package/dist/helpers/validator/validator.spec.d.ts +1 -0
  35. package/dist/helpers/validator/validator.spec.js +332 -0
  36. package/dist/pipeline/1-select-definitions-helper.d.ts +13 -13
  37. package/dist/pipeline/1-select-definitions-helper.js +68 -72
  38. package/dist/pipeline/1-select-definitions.helper.test.js +40 -40
  39. package/dist/pipeline/1-select-definitions.spec.d.ts +1 -0
  40. package/dist/pipeline/1-select-definitions.spec.js +140 -0
  41. package/dist/pipeline/2-structure-parser.helper.spec.d.ts +1 -0
  42. package/dist/pipeline/2-structure-parser.helper.spec.js +280 -0
  43. package/dist/pipeline/parsers/array-parser.spec.d.ts +1 -0
  44. package/dist/pipeline/parsers/array-parser.spec.js +128 -0
  45. package/dist/pipeline/parsers/object-parser.spec.d.ts +1 -0
  46. package/dist/pipeline/parsers/object-parser.spec.js +179 -0
  47. package/dist/pipeline/parsers/primitive-parser.spec.d.ts +1 -0
  48. package/dist/pipeline/parsers/primitive-parser.spec.js +79 -0
  49. package/dist/pre-made-components/assets/3-font.js +4 -4
  50. package/dist/pre-made-components/events/1-event.d.ts +1 -1
  51. package/dist/pre-made-components/events/1-event.js +157 -125
  52. package/dist/pre-made-components/events/2-event-test.d.ts +8 -8
  53. package/dist/pre-made-components/events/2-event-test.js +156 -119
  54. package/dist/pre-made-components/events/2-script-test.js +0 -1
  55. package/dist/pre-made-components/events/event-setup.d.ts +10 -5
  56. package/dist/pre-made-components/events/event-setup.js +15 -15
  57. package/dist/pre-made-components/events/script-setup.d.ts +5 -3
  58. package/dist/pre-made-components/events/script-setup.js +11 -11
  59. package/package.json +11 -11
  60. package/.eslintrc.js +0 -212
  61. package/.vscode/launch.json +0 -15
  62. package/.vscode/settings.json +0 -25
  63. package/coverage/clover.xml +0 -503
  64. package/coverage/coverage-final.json +0 -16
  65. package/coverage/lcov-report/_mocks/index.html +0 -116
  66. package/coverage/lcov-report/_mocks/mocks.ts.html +0 -223
  67. package/coverage/lcov-report/base.css +0 -224
  68. package/coverage/lcov-report/block-navigation.js +0 -87
  69. package/coverage/lcov-report/favicon.png +0 -0
  70. package/coverage/lcov-report/framework/framework.data.ts.html +0 -109
  71. package/coverage/lcov-report/framework/index.html +0 -116
  72. package/coverage/lcov-report/helpers/common-functions/common-functions.ts.html +0 -178
  73. package/coverage/lcov-report/helpers/common-functions/index.html +0 -116
  74. package/coverage/lcov-report/helpers/duplicate-helper/duplicate-helper.ts.html +0 -196
  75. package/coverage/lcov-report/helpers/duplicate-helper/index.html +0 -116
  76. package/coverage/lcov-report/helpers/output-helper/index.html +0 -116
  77. package/coverage/lcov-report/helpers/output-helper/output-helper.ts.html +0 -277
  78. package/coverage/lcov-report/helpers/raw-definition-helper/index.html +0 -116
  79. package/coverage/lcov-report/helpers/raw-definition-helper/raw-definition.helper.ts.html +0 -256
  80. package/coverage/lcov-report/helpers/validator/index.html +0 -131
  81. package/coverage/lcov-report/helpers/validator/joi-custom-validators.ts.html +0 -643
  82. package/coverage/lcov-report/helpers/validator/validator.ts.html +0 -310
  83. package/coverage/lcov-report/index.html +0 -251
  84. package/coverage/lcov-report/pipeline/1-select-definitions-helper.ts.html +0 -358
  85. package/coverage/lcov-report/pipeline/2-structure-parser.helper.ts.html +0 -301
  86. package/coverage/lcov-report/pipeline/3-config.ts.html +0 -178
  87. package/coverage/lcov-report/pipeline/_mocks/index.html +0 -116
  88. package/coverage/lcov-report/pipeline/_mocks/index.ts.html +0 -229
  89. package/coverage/lcov-report/pipeline/index.html +0 -146
  90. package/coverage/lcov-report/pipeline/parsers/array-parser.ts.html +0 -271
  91. package/coverage/lcov-report/pipeline/parsers/index.html +0 -146
  92. package/coverage/lcov-report/pipeline/parsers/object-parser.ts.html +0 -439
  93. package/coverage/lcov-report/pipeline/parsers/primitive-parser.ts.html +0 -370
  94. package/coverage/lcov-report/prettify.css +0 -1
  95. package/coverage/lcov-report/prettify.js +0 -2
  96. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  97. package/coverage/lcov-report/sorter.js +0 -196
  98. package/coverage/lcov.info +0 -911
  99. package/dist/_mocks/mocks.js.map +0 -1
  100. package/dist/decorators/definition-component.js.map +0 -1
  101. package/dist/decorators/definition-generator.js.map +0 -1
  102. package/dist/framework/context.js.map +0 -1
  103. package/dist/framework/definition-component.js.map +0 -1
  104. package/dist/framework/definition-generator.js.map +0 -1
  105. package/dist/framework/definition-store.js.map +0 -1
  106. package/dist/framework/file-content-generator/file-content-generator.js.map +0 -1
  107. package/dist/framework/file-content-generator/file-content-generator.test.js.map +0 -1
  108. package/dist/framework/framework.data.js.map +0 -1
  109. package/dist/framework/framework.js.map +0 -1
  110. package/dist/framework/framework.model.js.map +0 -1
  111. package/dist/framework/index-file-generator/index-file-generator.js.map +0 -1
  112. package/dist/framework/interfaces.js.map +0 -1
  113. package/dist/framework/kernel.js.map +0 -1
  114. package/dist/helpers/common-functions/common-functions.js.map +0 -1
  115. package/dist/helpers/common-functions/common-functions.spec.js.map +0 -1
  116. package/dist/helpers/common-functions/common-functions.test.js.map +0 -1
  117. package/dist/helpers/duplicate-helper/duplicate-helper.js.map +0 -1
  118. package/dist/helpers/duplicate-helper/duplicate-helper.spec.js.map +0 -1
  119. package/dist/helpers/duplicate-helper/duplicate-helper.test.js.map +0 -1
  120. package/dist/helpers/output-helper/output-helper.js.map +0 -1
  121. package/dist/helpers/output-helper/output-helper.spec.js.map +0 -1
  122. package/dist/helpers/output-helper/output-helper.test.js.map +0 -1
  123. package/dist/helpers/raw-definition-helper/raw-definition.helper.js.map +0 -1
  124. package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.js.map +0 -1
  125. package/dist/helpers/raw-definition-helper/raw-definition.helper.test.js.map +0 -1
  126. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.js.map +0 -1
  127. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.js.map +0 -1
  128. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.test.js.map +0 -1
  129. package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.js.map +0 -1
  130. package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.test.js.map +0 -1
  131. package/dist/helpers/validator/custom-validators/image.custom-validator.js.map +0 -1
  132. package/dist/helpers/validator/custom-validators/path.custom-validator.js.map +0 -1
  133. package/dist/helpers/validator/custom-validators/position-on-sprite.js.map +0 -1
  134. package/dist/helpers/validator/custom-validators/reference.custom-validator.js.map +0 -1
  135. package/dist/helpers/validator/custom-validators/sprite.custom-validator.js.map +0 -1
  136. package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.js.map +0 -1
  137. package/dist/helpers/validator/custom-validators/unique.custom-validator.js.map +0 -1
  138. package/dist/helpers/validator/joi-custom-validators.js.map +0 -1
  139. package/dist/helpers/validator/joi-custom-validators.spec.js.map +0 -1
  140. package/dist/helpers/validator/validator.js.map +0 -1
  141. package/dist/helpers/validator/validator.spec.js.map +0 -1
  142. package/dist/helpers/validator/validator.test.js.map +0 -1
  143. package/dist/index.js.map +0 -1
  144. package/dist/pipeline/1-select-definitions-helper.js.map +0 -1
  145. package/dist/pipeline/1-select-definitions.helper.js.map +0 -1
  146. package/dist/pipeline/1-select-definitions.helper.test.js.map +0 -1
  147. package/dist/pipeline/1-select-definitions.spec.js.map +0 -1
  148. package/dist/pipeline/2-structure-parser.helper.js.map +0 -1
  149. package/dist/pipeline/2-structure-parser.helper.spec.js.map +0 -1
  150. package/dist/pipeline/2-structure-parser.helper.test.js.map +0 -1
  151. package/dist/pipeline/3-config.js.map +0 -1
  152. package/dist/pipeline/_mocks/index.js.map +0 -1
  153. package/dist/pipeline/parsers/array-parser.js.map +0 -1
  154. package/dist/pipeline/parsers/array-parser.spec.js.map +0 -1
  155. package/dist/pipeline/parsers/array-parser.test.js.map +0 -1
  156. package/dist/pipeline/parsers/object-parser.js.map +0 -1
  157. package/dist/pipeline/parsers/object-parser.spec.js.map +0 -1
  158. package/dist/pipeline/parsers/object-parser.test.js.map +0 -1
  159. package/dist/pipeline/parsers/primitive-parser.js.map +0 -1
  160. package/dist/pipeline/parsers/primitive-parser.spec.js.map +0 -1
  161. package/dist/pipeline/parsers/primitive-parser.test.js.map +0 -1
  162. package/dist/pipeline/raw-data-parser.js.map +0 -1
  163. package/dist/pre-made-components/_validators/shape-validators.js.map +0 -1
  164. package/dist/pre-made-components/_validators/sprite-validators.js.map +0 -1
  165. package/dist/pre-made-components/assets/1-sprite.js.map +0 -1
  166. package/dist/pre-made-components/assets/2-sprite-group.js.map +0 -1
  167. package/dist/pre-made-components/assets/3-font.js.map +0 -1
  168. package/dist/pre-made-components/events/1-event.js.map +0 -1
  169. package/dist/pre-made-components/events/1-script.js.map +0 -1
  170. package/dist/pre-made-components/events/2-event-test.js.map +0 -1
  171. package/dist/pre-made-components/events/2-script-test.js.map +0 -1
  172. package/dist/pre-made-components/events/3-event.js.map +0 -1
  173. package/dist/pre-made-components/events/4-event-test.js.map +0 -1
  174. package/dist/pre-made-components/events/event-setup.js.map +0 -1
  175. package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.js.map +0 -1
  176. package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.test.js.map +0 -1
  177. package/dist/pre-made-components/events/helpers/script-testing.helper.js.map +0 -1
  178. package/dist/pre-made-components/events/script-setup.js.map +0 -1
  179. package/dist/pre-made-components/events/scripting-setup.js.map +0 -1
  180. package/dist/pre-made-components/events/validators.js.map +0 -1
  181. package/dist/setup.js.map +0 -1
  182. package/package.json.bak +0 -60
  183. package/scripts/prepare-package-json.ts +0 -23
  184. package/tsconfig.json +0 -24
  185. package/vitest.config.ts +0 -1
@@ -0,0 +1,280 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ const _2_structure_parser_helper_1 = require('./2-structure-parser.helper');
4
+ const mocks_1 = require('../_mocks/mocks');
5
+ function getMockDefinitionPlaneText(content) {
6
+ return {
7
+ type: 'ASSET',
8
+ content,
9
+ location: mocks_1.SampleLocation1
10
+ };
11
+ }
12
+ function getBaseRawDefinition(definitionPlaneText, parsedStructure) {
13
+ return {
14
+ componentName: definitionPlaneText.type,
15
+ location: definitionPlaneText.location,
16
+ parsedStructure: parsedStructure
17
+ };
18
+ }
19
+ function getExpectedRawDefinition(expected, offset, definitionPlaneText) {
20
+ let rawDefinition = getBaseRawDefinition(definitionPlaneText, {
21
+ rawData: expected,
22
+ line: definitionPlaneText.location.line + offset
23
+ });
24
+ return rawDefinition;
25
+ }
26
+ describe('STRUCTURE PARSER HELPER', () => {
27
+ let structureParserHelper;
28
+ beforeEach(() => {
29
+ structureParserHelper = new _2_structure_parser_helper_1.StructureParserHelper();
30
+ });
31
+ describe('Primitive', () => {
32
+ test('empty content', () => {
33
+ let definitionPlaneText = getMockDefinitionPlaneText([]);
34
+ let result = structureParserHelper.process([definitionPlaneText]);
35
+ expect(result.rawDefinitions).toStrictEqual([]);
36
+ expect(result.errorLogs).toStrictEqual([]);
37
+ });
38
+ test('primitive string', () => {
39
+ let definitionPlaneText = getMockDefinitionPlaneText(['text']);
40
+ let result = structureParserHelper.process([definitionPlaneText]);
41
+ expect(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('text', 1, definitionPlaneText)]);
42
+ expect(result.errorLogs).toStrictEqual([]);
43
+ });
44
+ test('primitive quoted string', () => {
45
+ let definitionPlaneText = getMockDefinitionPlaneText(['"text with spaces"']);
46
+ let result = structureParserHelper.process([definitionPlaneText]);
47
+ expect(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('text with spaces', 1, definitionPlaneText)]);
48
+ expect(result.errorLogs).toStrictEqual([]);
49
+ });
50
+ it('primitive multiline string', () => {
51
+ let definitionPlaneText = getMockDefinitionPlaneText(['`', 'text text', 'text', '`']);
52
+ let result = structureParserHelper.process([definitionPlaneText]);
53
+ expect(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('text text\ntext', 1, definitionPlaneText)]);
54
+ expect(result.errorLogs).toStrictEqual([]);
55
+ });
56
+ test('primitive number', () => {
57
+ let definitionPlaneText = getMockDefinitionPlaneText(['123.123']);
58
+ let result = structureParserHelper.process([definitionPlaneText]);
59
+ expect(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('123.123', 1, definitionPlaneText)]);
60
+ expect(result.errorLogs).toStrictEqual([]);
61
+ });
62
+ test('primitive negative number', () => {
63
+ let definitionPlaneText = getMockDefinitionPlaneText(['-123.123']);
64
+ let result = structureParserHelper.process([definitionPlaneText]);
65
+ expect(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition('-123.123', 1, definitionPlaneText)]);
66
+ expect(result.errorLogs).toStrictEqual([]);
67
+ });
68
+ test('primitive undefined', () => {
69
+ let definitionPlaneText = getMockDefinitionPlaneText(['undefined']);
70
+ let result = structureParserHelper.process([definitionPlaneText]);
71
+ expect(result.rawDefinitions).toStrictEqual([getExpectedRawDefinition(undefined, 1, definitionPlaneText)]);
72
+ expect(result.errorLogs).toStrictEqual([]);
73
+ });
74
+ });
75
+ describe('Array', () => {
76
+ it('basic', () => {
77
+ let definitionPlaneText = getMockDefinitionPlaneText(['- orange', '- banana']);
78
+ let result = structureParserHelper.process([definitionPlaneText]);
79
+ let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
80
+ line: definitionPlaneText.location.line + 1,
81
+ rawData: [
82
+ {
83
+ line: definitionPlaneText.location.line + 1,
84
+ rawData: 'orange'
85
+ },
86
+ {
87
+ line: definitionPlaneText.location.line + 2,
88
+ rawData: 'banana'
89
+ }
90
+ ]
91
+ });
92
+ expect(result.rawDefinitions).toStrictEqual([expectedStructure]);
93
+ expect(result.errorLogs).toStrictEqual([]);
94
+ });
95
+ it('array contains array', () => {
96
+ let definitionPlaneText = getMockDefinitionPlaneText(['- - orange', ' - banana', '- - 1', ' - 2']);
97
+ let result = structureParserHelper.process([definitionPlaneText]);
98
+ let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
99
+ line: definitionPlaneText.location.line + 1,
100
+ rawData: [
101
+ {
102
+ line: definitionPlaneText.location.line + 1,
103
+ rawData: [
104
+ {
105
+ line: definitionPlaneText.location.line + 1,
106
+ rawData: 'orange'
107
+ },
108
+ {
109
+ line: definitionPlaneText.location.line + 2,
110
+ rawData: 'banana'
111
+ }
112
+ ]
113
+ },
114
+ {
115
+ line: definitionPlaneText.location.line + 3,
116
+ rawData: [
117
+ {
118
+ line: definitionPlaneText.location.line + 3,
119
+ rawData: '1'
120
+ },
121
+ {
122
+ line: definitionPlaneText.location.line + 4,
123
+ rawData: '2'
124
+ }
125
+ ]
126
+ }
127
+ ]
128
+ });
129
+ expect(result.rawDefinitions).toStrictEqual([expectedStructure]);
130
+ expect(result.errorLogs).toStrictEqual([]);
131
+ });
132
+ it('array contains object', () => {
133
+ let definitionPlaneText = getMockDefinitionPlaneText(['- Name: arrow', ' Quantity: 4', '- Name: axe', ' Quantity: 1']);
134
+ let result = structureParserHelper.process([definitionPlaneText]);
135
+ let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
136
+ line: definitionPlaneText.location.line + 1,
137
+ rawData: [
138
+ {
139
+ line: definitionPlaneText.location.line + 1,
140
+ rawData: {
141
+ name: {
142
+ line: definitionPlaneText.location.line + 1,
143
+ rawData: 'arrow'
144
+ },
145
+ quantity: {
146
+ line: definitionPlaneText.location.line + 2,
147
+ rawData: '4'
148
+ }
149
+ }
150
+ },
151
+ {
152
+ line: definitionPlaneText.location.line + 3,
153
+ rawData: {
154
+ name: {
155
+ line: definitionPlaneText.location.line + 3,
156
+ rawData: 'axe'
157
+ },
158
+ quantity: {
159
+ line: definitionPlaneText.location.line + 4,
160
+ rawData: '1'
161
+ }
162
+ }
163
+ }
164
+ ]
165
+ });
166
+ expect(result.rawDefinitions).toStrictEqual([expectedStructure]);
167
+ expect(result.errorLogs).toStrictEqual([]);
168
+ });
169
+ });
170
+ describe('Object', () => {
171
+ it('basic', () => {
172
+ let definitionPlaneText = getMockDefinitionPlaneText(['Name: axe', 'Quantity: 1']);
173
+ let result = structureParserHelper.process([definitionPlaneText]);
174
+ let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
175
+ line: definitionPlaneText.location.line + 1,
176
+ rawData: {
177
+ name: {
178
+ line: definitionPlaneText.location.line + 1,
179
+ rawData: 'axe'
180
+ },
181
+ quantity: {
182
+ line: definitionPlaneText.location.line + 2,
183
+ rawData: '1'
184
+ }
185
+ }
186
+ });
187
+ expect(result.rawDefinitions).toStrictEqual([expectedStructure]);
188
+ expect(result.errorLogs).toStrictEqual([]);
189
+ });
190
+ it('object contains object', () => {
191
+ let definitionPlaneText = getMockDefinitionPlaneText([
192
+ 'Attacker:',
193
+ ' Name: firstObjectName',
194
+ ' Age: 25',
195
+ 'Defender:',
196
+ ' Name: secondObjectName',
197
+ ' Age: 35'
198
+ ]);
199
+ let result = structureParserHelper.process([definitionPlaneText]);
200
+ let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
201
+ line: definitionPlaneText.location.line + 1,
202
+ rawData: {
203
+ attacker: {
204
+ line: definitionPlaneText.location.line + 1,
205
+ rawData: {
206
+ name: {
207
+ line: definitionPlaneText.location.line + 2,
208
+ rawData: 'firstObjectName'
209
+ },
210
+ age: {
211
+ line: definitionPlaneText.location.line + 3,
212
+ rawData: '25'
213
+ }
214
+ }
215
+ },
216
+ defender: {
217
+ line: definitionPlaneText.location.line + 4,
218
+ rawData: {
219
+ name: {
220
+ line: definitionPlaneText.location.line + 5,
221
+ rawData: 'secondObjectName'
222
+ },
223
+ age: {
224
+ line: definitionPlaneText.location.line + 6,
225
+ rawData: '35'
226
+ }
227
+ }
228
+ }
229
+ }
230
+ });
231
+ expect(result.rawDefinitions).toStrictEqual([expectedStructure]);
232
+ expect(result.errorLogs).toStrictEqual([]);
233
+ });
234
+ it('object contains array', () => {
235
+ let definitionPlaneText = getMockDefinitionPlaneText([
236
+ 'Array1:',
237
+ '- apple',
238
+ '- orange',
239
+ 'Array2:',
240
+ '- xWing',
241
+ '- tieFighter'
242
+ ]);
243
+ let result = structureParserHelper.process([definitionPlaneText]);
244
+ let expectedStructure = getBaseRawDefinition(definitionPlaneText, {
245
+ line: definitionPlaneText.location.line + 1,
246
+ rawData: {
247
+ array1: {
248
+ line: definitionPlaneText.location.line + 1,
249
+ rawData: [
250
+ {
251
+ line: definitionPlaneText.location.line + 2,
252
+ rawData: 'apple'
253
+ },
254
+ {
255
+ line: definitionPlaneText.location.line + 3,
256
+ rawData: 'orange'
257
+ }
258
+ ]
259
+ },
260
+ array2: {
261
+ line: definitionPlaneText.location.line + 4,
262
+ rawData: [
263
+ {
264
+ line: definitionPlaneText.location.line + 5,
265
+ rawData: 'xWing'
266
+ },
267
+ {
268
+ line: definitionPlaneText.location.line + 6,
269
+ rawData: 'tieFighter'
270
+ }
271
+ ]
272
+ }
273
+ }
274
+ });
275
+ expect(result.rawDefinitions).toStrictEqual([expectedStructure]);
276
+ expect(result.errorLogs).toStrictEqual([]);
277
+ });
278
+ });
279
+ });
280
+ //# sourceMappingURL=2-structure-parser.helper.spec.js.map
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,128 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ const _mocks_1 = require('../_mocks');
4
+ const array_parser_1 = require('./array-parser');
5
+ const mocks_1 = require('../../_mocks/mocks');
6
+ describe('ARRAY PARSER', () => {
7
+ test('basic', () => {
8
+ let result = array_parser_1.ArrayParser.parse(['- orange', '- banana'], mocks_1.SampleLocation1);
9
+ expect(result).toStrictEqual({
10
+ line: mocks_1.SampleLocation1.line,
11
+ rawData: [
12
+ {
13
+ line: mocks_1.SampleLocation1.line,
14
+ rawData: 'orange'
15
+ },
16
+ {
17
+ line: mocks_1.SampleLocation1.line + 1,
18
+ rawData: 'banana'
19
+ }
20
+ ]
21
+ });
22
+ });
23
+ test('array contains array', () => {
24
+ let result = array_parser_1.ArrayParser.parse(['- - orange', ' - banana', '- - 1', ' - 2'], mocks_1.SampleLocation1);
25
+ expect(result).toStrictEqual({
26
+ line: mocks_1.SampleLocation1.line,
27
+ rawData: [
28
+ {
29
+ line: mocks_1.SampleLocation1.line,
30
+ rawData: [
31
+ {
32
+ line: mocks_1.SampleLocation1.line,
33
+ rawData: 'orange'
34
+ },
35
+ {
36
+ line: mocks_1.SampleLocation1.line + 1,
37
+ rawData: 'banana'
38
+ }
39
+ ]
40
+ },
41
+ {
42
+ line: mocks_1.SampleLocation1.line + 2,
43
+ rawData: [
44
+ {
45
+ line: mocks_1.SampleLocation1.line + 2,
46
+ rawData: '1'
47
+ },
48
+ {
49
+ line: mocks_1.SampleLocation1.line + 3,
50
+ rawData: '2'
51
+ }
52
+ ]
53
+ }
54
+ ]
55
+ });
56
+ });
57
+ test('array contains object', () => {
58
+ let result = array_parser_1.ArrayParser.parse(
59
+ ['- Name: arrow', ' Quantity: 4', '- Name: axe', ' Quantity: 1'],
60
+ mocks_1.SampleLocation1
61
+ );
62
+ expect(result).toStrictEqual({
63
+ line: mocks_1.SampleLocation1.line,
64
+ rawData: [
65
+ {
66
+ line: mocks_1.SampleLocation1.line,
67
+ rawData: {
68
+ name: {
69
+ line: mocks_1.SampleLocation1.line,
70
+ rawData: 'arrow'
71
+ },
72
+ quantity: {
73
+ line: mocks_1.SampleLocation1.line + 1,
74
+ rawData: '4'
75
+ }
76
+ }
77
+ },
78
+ {
79
+ line: mocks_1.SampleLocation1.line + 2,
80
+ rawData: {
81
+ name: {
82
+ line: mocks_1.SampleLocation1.line + 2,
83
+ rawData: 'axe'
84
+ },
85
+ quantity: {
86
+ line: mocks_1.SampleLocation1.line + 3,
87
+ rawData: '1'
88
+ }
89
+ }
90
+ }
91
+ ]
92
+ });
93
+ });
94
+ });
95
+ describe('ARRAY PARSER - Error Detection', () => {
96
+ let expectErrorHelper = new _mocks_1.ExpectErrorHelper(array_parser_1.ArrayParser);
97
+ test.each(['-text', '- text'])('one space after dash, first line "%s"', item => {
98
+ expectErrorHelper.expect([item], {
99
+ description: `There should be one space after dash operator! "${item}"`,
100
+ location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
101
+ });
102
+ });
103
+ test.each(['-text', '- text'])('one space after dash, second line "%s"', item => {
104
+ expectErrorHelper.expect(['- item', item], {
105
+ description: `There should be one space after dash operator! "${item}"`,
106
+ location: { line: mocks_1.SampleLocation1.line + 1, path: mocks_1.SampleLocation1.path }
107
+ });
108
+ });
109
+ test('unexpected array element', () => {
110
+ expectErrorHelper.expect(['- item', 'Name: axe'], {
111
+ description: `Unexpected array element! "Name: axe"`,
112
+ location: { line: mocks_1.SampleLocation1.line + 1, path: mocks_1.SampleLocation1.path }
113
+ });
114
+ });
115
+ test('invalid coding indent', () => {
116
+ expectErrorHelper.expect([' - item'], {
117
+ description: `Invalid coding indent!`,
118
+ location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
119
+ });
120
+ });
121
+ test('invalid coding indent', () => {
122
+ expectErrorHelper.expect([' - item'], {
123
+ description: `Invalid coding indent!`,
124
+ location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
125
+ });
126
+ });
127
+ });
128
+ //# sourceMappingURL=array-parser.spec.js.map
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,179 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ const object_parser_1 = require('./object-parser');
4
+ const mocks_1 = require('../../_mocks/mocks');
5
+ const _mocks_1 = require('../_mocks');
6
+ describe('OBJECT PARSER', () => {
7
+ test('basic', () => {
8
+ let result = object_parser_1.ObjectParser.parse(['Name: axe', 'Quantity: 1'], mocks_1.SampleLocation1);
9
+ expect(result).toStrictEqual({
10
+ line: mocks_1.SampleLocation1.line,
11
+ rawData: {
12
+ name: {
13
+ line: mocks_1.SampleLocation1.line,
14
+ rawData: 'axe'
15
+ },
16
+ quantity: {
17
+ line: mocks_1.SampleLocation1.line + 1,
18
+ rawData: '1'
19
+ }
20
+ }
21
+ });
22
+ });
23
+ test('quote string value', () => {
24
+ let result = object_parser_1.ObjectParser.parse(['Path: "D:/test"'], mocks_1.SampleLocation1);
25
+ expect(result).toStrictEqual({
26
+ line: mocks_1.SampleLocation1.line,
27
+ rawData: {
28
+ path: {
29
+ line: mocks_1.SampleLocation1.line,
30
+ rawData: 'D:/test'
31
+ }
32
+ }
33
+ });
34
+ });
35
+ test('quote string value', () => {
36
+ let result = object_parser_1.ObjectParser.parse(['Str: `', 'text with space', 'text', '`'], mocks_1.SampleLocation1);
37
+ expect(result).toStrictEqual({
38
+ line: mocks_1.SampleLocation1.line,
39
+ rawData: {
40
+ str: {
41
+ line: mocks_1.SampleLocation1.line,
42
+ rawData: 'text with space\ntext'
43
+ }
44
+ }
45
+ });
46
+ });
47
+ test('object contains object', () => {
48
+ let result = object_parser_1.ObjectParser.parse(
49
+ ['Attacker:', ' Name: firstObjectName', ' Age: 25', 'Defender:', ' Name: secondObjectName', ' Age: 35'],
50
+ mocks_1.SampleLocation1
51
+ );
52
+ expect(result).toStrictEqual({
53
+ line: mocks_1.SampleLocation1.line,
54
+ rawData: {
55
+ attacker: {
56
+ line: mocks_1.SampleLocation1.line,
57
+ rawData: {
58
+ name: {
59
+ line: mocks_1.SampleLocation1.line + 1,
60
+ rawData: 'firstObjectName'
61
+ },
62
+ age: {
63
+ line: mocks_1.SampleLocation1.line + 2,
64
+ rawData: '25'
65
+ }
66
+ }
67
+ },
68
+ defender: {
69
+ line: mocks_1.SampleLocation1.line + 3,
70
+ rawData: {
71
+ name: {
72
+ line: mocks_1.SampleLocation1.line + 4,
73
+ rawData: 'secondObjectName'
74
+ },
75
+ age: {
76
+ line: mocks_1.SampleLocation1.line + 5,
77
+ rawData: '35'
78
+ }
79
+ }
80
+ }
81
+ }
82
+ });
83
+ });
84
+ test('object contains array', () => {
85
+ let result = object_parser_1.ObjectParser.parse(
86
+ ['Array1:', '- apple', '- orange', 'Array2:', '- xWing', '- tieFighter'],
87
+ mocks_1.SampleLocation1
88
+ );
89
+ expect(result).toStrictEqual({
90
+ line: mocks_1.SampleLocation1.line,
91
+ rawData: {
92
+ array1: {
93
+ line: mocks_1.SampleLocation1.line,
94
+ rawData: [
95
+ {
96
+ line: mocks_1.SampleLocation1.line + 1,
97
+ rawData: 'apple'
98
+ },
99
+ {
100
+ line: mocks_1.SampleLocation1.line + 2,
101
+ rawData: 'orange'
102
+ }
103
+ ]
104
+ },
105
+ array2: {
106
+ line: mocks_1.SampleLocation1.line + 3,
107
+ rawData: [
108
+ {
109
+ line: mocks_1.SampleLocation1.line + 4,
110
+ rawData: 'xWing'
111
+ },
112
+ {
113
+ line: mocks_1.SampleLocation1.line + 5,
114
+ rawData: 'tieFighter'
115
+ }
116
+ ]
117
+ }
118
+ }
119
+ });
120
+ });
121
+ });
122
+ describe('OBJECT PARSER - Error Detection', () => {
123
+ let expectErrorHelper = new _mocks_1.ExpectErrorHelper(object_parser_1.ObjectParser);
124
+ test.each(['Name:axe', 'Name: axe'])('one space after column, first line "%s"', item => {
125
+ expectErrorHelper.expect([item], {
126
+ description: `There should be one space after column operator! "${item}"`,
127
+ location: mocks_1.SampleLocation1
128
+ });
129
+ });
130
+ test('object cannot start with backtick', () => {
131
+ expectErrorHelper.expect(['`'], {
132
+ description: `Unexpected object element! "\`"`,
133
+ location: mocks_1.SampleLocation1
134
+ });
135
+ });
136
+ test('unexpected backtick', () => {
137
+ expectErrorHelper.expect(['Group:', '- item', '`'], {
138
+ description: `Unexpected object element! "\`"`,
139
+ location: { line: mocks_1.SampleLocation1.line + 2, path: mocks_1.SampleLocation1.path }
140
+ });
141
+ });
142
+ test.each(['Quantity:5', 'Quantity: 5'])('one space after column, second line "%s"', item => {
143
+ expectErrorHelper.expect(['Name: axe', item], {
144
+ description: `There should be one space after column operator! "${item}"`,
145
+ location: { line: mocks_1.SampleLocation1.line + 1, path: mocks_1.SampleLocation1.path }
146
+ });
147
+ });
148
+ test.each(['- apple', 'text'])('unexpected object element, "%s"', item => {
149
+ expectErrorHelper.expect([item], {
150
+ description: `Unexpected object element! "${item}"`,
151
+ location: mocks_1.SampleLocation1
152
+ });
153
+ });
154
+ test('multiple columns', () => {
155
+ expectErrorHelper.expect(['Name:something: axe'], {
156
+ description: `Invalid row, multiple columns! "Name:something: axe"`,
157
+ location: mocks_1.SampleLocation1
158
+ });
159
+ });
160
+ test('starting with column', () => {
161
+ expectErrorHelper.expect([':something: axe'], {
162
+ description: `Invalid row, row cannot start with columns! ":something: axe"`,
163
+ location: mocks_1.SampleLocation1
164
+ });
165
+ });
166
+ test.each([' Name: axe', ' Name: axe'])('invalid coding indent, "%s"', item => {
167
+ expectErrorHelper.expect([item], {
168
+ description: `Invalid coding indent! "${item}"`,
169
+ location: mocks_1.SampleLocation1
170
+ });
171
+ });
172
+ test('no value', () => {
173
+ expectErrorHelper.expect(['Name:'], {
174
+ description: `No value found after column! "Name:"`,
175
+ location: mocks_1.SampleLocation1
176
+ });
177
+ });
178
+ });
179
+ //# sourceMappingURL=object-parser.spec.js.map
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,79 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ const primitive_parser_1 = require('./primitive-parser');
4
+ const _mocks_1 = require('../_mocks');
5
+ const mocks_1 = require('../../_mocks/mocks');
6
+ describe('PRIMITIVE PARSER', () => {
7
+ test('primitive string', () => {
8
+ let result = primitive_parser_1.PrimitiveParser.parse(['text'], mocks_1.SampleLocation1);
9
+ expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('text', mocks_1.SampleLocation1));
10
+ });
11
+ test('primitive quoted string', () => {
12
+ let result = primitive_parser_1.PrimitiveParser.parse(['"text with spaces"'], mocks_1.SampleLocation1);
13
+ expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('text with spaces', mocks_1.SampleLocation1));
14
+ });
15
+ test('primitive multiline string', () => {
16
+ let result = primitive_parser_1.PrimitiveParser.parse(['`', 'text text', 'text', '`'], mocks_1.SampleLocation1);
17
+ expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('text text\ntext', mocks_1.SampleLocation1));
18
+ });
19
+ test('primitive number', () => {
20
+ let result = primitive_parser_1.PrimitiveParser.parse(['123.123'], mocks_1.SampleLocation1);
21
+ expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('123.123', mocks_1.SampleLocation1));
22
+ });
23
+ test('primitive undefined', () => {
24
+ let result = primitive_parser_1.PrimitiveParser.parse(['undefined'], mocks_1.SampleLocation1);
25
+ expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)(undefined, mocks_1.SampleLocation1));
26
+ });
27
+ });
28
+ describe('PRIMITIVE PARSER - Error Detection', () => {
29
+ let expectErrorHelper = new _mocks_1.ExpectErrorHelper(primitive_parser_1.PrimitiveParser);
30
+ test.each([' text', 'some text'])('primitive with space "%s"', item => {
31
+ expectErrorHelper.expect([item], {
32
+ description: `Unexpected space! "${item}"`,
33
+ location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
34
+ });
35
+ });
36
+ test('not closed quote string', () => {
37
+ expectErrorHelper.expect(['"some text'], {
38
+ description: 'Quote is not get closed!',
39
+ location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
40
+ });
41
+ });
42
+ test('invalid quote text', () => {
43
+ expectErrorHelper.expect(['"some "text"'], {
44
+ description: 'There should be only one opening and one closeing quote!',
45
+ location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
46
+ });
47
+ });
48
+ test('multiline primitive', () => {
49
+ expectErrorHelper.expect(['text', 'secondRow'], {
50
+ description: 'Invalid row! "secondRow"',
51
+ location: { line: mocks_1.SampleLocation1.line + 2, path: mocks_1.SampleLocation1.path }
52
+ });
53
+ });
54
+ test('multiline string no character after backtick - openning', () => {
55
+ expectErrorHelper.expect(['`test', 'something'], {
56
+ description: 'There should be new line after backtick "`test"!',
57
+ location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
58
+ });
59
+ });
60
+ test('multiline string no character after backtick - closing', () => {
61
+ expectErrorHelper.expect(['`', 'test', '`,'], {
62
+ description: 'There should be new line after backtick "`,"!',
63
+ location: { line: mocks_1.SampleLocation1.line + 3, path: mocks_1.SampleLocation1.path }
64
+ });
65
+ });
66
+ test('multiline string should end with backtick', () => {
67
+ expectErrorHelper.expect(['`', 'test`'], {
68
+ description: 'Multiline string should end with backtick in new line "test`"!',
69
+ location: { line: mocks_1.SampleLocation1.line + 2, path: mocks_1.SampleLocation1.path }
70
+ });
71
+ });
72
+ test('multiline string should end with backtick in the same coding indent', () => {
73
+ expectErrorHelper.expect(['`', 'test', ' `'], {
74
+ description: 'Invalid coding indent!',
75
+ location: { line: mocks_1.SampleLocation1.line + 3, path: mocks_1.SampleLocation1.path }
76
+ });
77
+ });
78
+ });
79
+ //# sourceMappingURL=primitive-parser.spec.js.map
@@ -17,10 +17,10 @@ const helpers_lib_1 = require("helpers-lib");
17
17
  const joi_1 = __importDefault(require("joi"));
18
18
  const definition_component_1 = require("../../decorators/definition-component");
19
19
  const index_file_generator_1 = require("../../framework/index-file-generator/index-file-generator");
20
- const INDEX_ENTRY = `
21
- export interface FontDefinition {
22
- readonly id: string;
23
- readonly fontFamily: string;
20
+ const INDEX_ENTRY = `
21
+ export interface FontDefinition {
22
+ readonly id: string;
23
+ readonly fontFamily: string;
24
24
  }`;
25
25
  let FontComponent = class FontComponent extends definition_component_1.DefinitionComponent {
26
26
  constructor() {