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,126 +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 _mocks_1 = require("../_mocks");
6
- const array_parser_1 = require("./array-parser");
7
- (0, vitest_1.describe)('ARRAY PARSER', () => {
8
- (0, vitest_1.test)('basic', () => {
9
- let result = array_parser_1.ArrayParser.parse(['- orange', '- banana'], mocks_1.SampleLocation1);
10
- (0, vitest_1.expect)(result).toStrictEqual({
11
- line: mocks_1.SampleLocation1.line,
12
- rawData: [
13
- {
14
- line: mocks_1.SampleLocation1.line,
15
- rawData: 'orange'
16
- },
17
- {
18
- line: mocks_1.SampleLocation1.line + 1,
19
- rawData: 'banana'
20
- }
21
- ]
22
- });
23
- });
24
- (0, vitest_1.test)('array contains array', () => {
25
- let result = array_parser_1.ArrayParser.parse(['- - orange', ' - banana', '- - 1', ' - 2'], mocks_1.SampleLocation1);
26
- (0, vitest_1.expect)(result).toStrictEqual({
27
- line: mocks_1.SampleLocation1.line,
28
- rawData: [
29
- {
30
- line: mocks_1.SampleLocation1.line,
31
- rawData: [
32
- {
33
- line: mocks_1.SampleLocation1.line,
34
- rawData: 'orange'
35
- },
36
- {
37
- line: mocks_1.SampleLocation1.line + 1,
38
- rawData: 'banana'
39
- }
40
- ]
41
- },
42
- {
43
- line: mocks_1.SampleLocation1.line + 2,
44
- rawData: [
45
- {
46
- line: mocks_1.SampleLocation1.line + 2,
47
- rawData: '1'
48
- },
49
- {
50
- line: mocks_1.SampleLocation1.line + 3,
51
- rawData: '2'
52
- }
53
- ]
54
- }
55
- ]
56
- });
57
- });
58
- (0, vitest_1.test)('array contains object', () => {
59
- let result = array_parser_1.ArrayParser.parse(['- Name: arrow', ' Quantity: 4', '- Name: axe', ' Quantity: 1'], mocks_1.SampleLocation1);
60
- (0, vitest_1.expect)(result).toStrictEqual({
61
- line: mocks_1.SampleLocation1.line,
62
- rawData: [
63
- {
64
- line: mocks_1.SampleLocation1.line,
65
- rawData: {
66
- name: {
67
- line: mocks_1.SampleLocation1.line,
68
- rawData: 'arrow'
69
- },
70
- quantity: {
71
- line: mocks_1.SampleLocation1.line + 1,
72
- rawData: '4'
73
- }
74
- }
75
- },
76
- {
77
- line: mocks_1.SampleLocation1.line + 2,
78
- rawData: {
79
- name: {
80
- line: mocks_1.SampleLocation1.line + 2,
81
- rawData: 'axe'
82
- },
83
- quantity: {
84
- line: mocks_1.SampleLocation1.line + 3,
85
- rawData: '1'
86
- }
87
- }
88
- }
89
- ]
90
- });
91
- });
92
- });
93
- (0, vitest_1.describe)('ARRAY PARSER - Error Detection', () => {
94
- let expectErrorHelper = new _mocks_1.ExpectErrorHelper(array_parser_1.ArrayParser);
95
- vitest_1.test.each(['-text', '- text'])('one space after dash, first line "%s"', (item) => {
96
- expectErrorHelper.expect([item], {
97
- description: `There should be one space after dash operator! "${item}"`,
98
- location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
99
- });
100
- });
101
- vitest_1.test.each(['-text', '- text'])('one space after dash, second line "%s"', (item) => {
102
- expectErrorHelper.expect(['- item', item], {
103
- description: `There should be one space after dash operator! "${item}"`,
104
- location: { line: mocks_1.SampleLocation1.line + 1, path: mocks_1.SampleLocation1.path }
105
- });
106
- });
107
- (0, vitest_1.test)('unexpected array element', () => {
108
- expectErrorHelper.expect(['- item', 'Name: axe'], {
109
- description: `Unexpected array element! "Name: axe"`,
110
- location: { line: mocks_1.SampleLocation1.line + 1, path: mocks_1.SampleLocation1.path }
111
- });
112
- });
113
- (0, vitest_1.test)('invalid coding indent', () => {
114
- expectErrorHelper.expect([' - item'], {
115
- description: `Invalid coding indent!`,
116
- location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
117
- });
118
- });
119
- (0, vitest_1.test)('invalid coding indent', () => {
120
- expectErrorHelper.expect([' - item'], {
121
- description: `Invalid coding indent!`,
122
- location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
123
- });
124
- });
125
- });
126
- //# sourceMappingURL=array-parser.test.js.map
@@ -1,4 +0,0 @@
1
- import { LocationInFile, ParsedStructure } from '../../framework/interfaces';
2
- export declare class ObjectParser {
3
- static parse(content: string[], location: LocationInFile): ParsedStructure;
4
- }
@@ -1,135 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ObjectParser = void 0;
4
- const common_functions_1 = require("../../helpers/common-functions/common-functions");
5
- const _2_structure_parser_helper_1 = require("../2-structure-parser.helper");
6
- class ObjectParser {
7
- static parse(content, location) {
8
- let unparsedContent = [];
9
- let unparsedContentKey = '';
10
- let unparsedContentStart = 0;
11
- let unparsedContentType;
12
- let children = {};
13
- content.forEach((row, index) => {
14
- if (!row.startsWith(' ') && !row.startsWith('- ') && unparsedContentType !== 'multiLineString') {
15
- if (row.startsWith(':')) {
16
- let errorLog = {
17
- description: `Invalid row, row cannot start with columns! "${row}"`,
18
- location: { line: location.line + index, path: location.path }
19
- };
20
- throw errorLog;
21
- }
22
- else if (row.match(/[\w]*:[\w]*:/g)) {
23
- let errorLog = {
24
- description: `Invalid row, multiple columns! "${row}"`,
25
- location: { line: location.line + index, path: location.path }
26
- };
27
- throw errorLog;
28
- }
29
- else if (row.match(/: {2}/g) || row.match(/^[\w]+:[\S]/g)) {
30
- let errorLog = {
31
- description: `There should be one space after column operator! "${row}"`,
32
- location: { line: location.line + index, path: location.path }
33
- };
34
- throw errorLog;
35
- }
36
- else if (row.startsWith(' ')) {
37
- let errorLog = {
38
- description: `Invalid coding indent! "${row}"`,
39
- location: { line: location.line + index, path: location.path }
40
- };
41
- throw errorLog;
42
- }
43
- else if (row.indexOf(':') === -1) {
44
- let errorLog = {
45
- description: `Unexpected object element! "${row}"`,
46
- location: { line: location.line + index, path: location.path }
47
- };
48
- throw errorLog;
49
- }
50
- else {
51
- if (unparsedContent.length) {
52
- let child = _2_structure_parser_helper_1.StructureParserHelper.getParsedStructure(unparsedContent, {
53
- line: unparsedContentStart,
54
- path: location.path
55
- });
56
- child.line -= 1;
57
- children[unparsedContentKey] = child;
58
- unparsedContent = [];
59
- unparsedContentKey = '';
60
- unparsedContentStart = 0;
61
- }
62
- let key = common_functions_1.CommonFunctions.lowerCaseFirstLetter(row.substring(0, row.indexOf(':')));
63
- if (row.trimEnd().endsWith(':')) {
64
- unparsedContentKey = key;
65
- unparsedContentStart = location.line + index + 1;
66
- if (!content[index + 1]) {
67
- let errorLog = {
68
- description: `No value found after column! "${row}"`,
69
- location: { line: location.line + index, path: location.path }
70
- };
71
- throw errorLog;
72
- }
73
- else {
74
- let nextRow = content[index + 1];
75
- unparsedContentType = nextRow.startsWith('-') ? 'array' : 'object';
76
- }
77
- }
78
- else if (row.trimEnd().endsWith('`') && row.indexOf('`') === row.lastIndexOf('`')) {
79
- unparsedContent.push('`');
80
- unparsedContentKey = key;
81
- unparsedContentStart = location.line + index + 1;
82
- unparsedContentType = 'multiLineString';
83
- }
84
- else {
85
- let value = row.substring(row.indexOf(':') + 2);
86
- let child = _2_structure_parser_helper_1.StructureParserHelper.getParsedStructure([value], { line: location.line + index, path: location.path });
87
- children[key] = child;
88
- }
89
- }
90
- }
91
- else if (index === 0) {
92
- if (row.startsWith('-')) {
93
- let errorLog = {
94
- description: `Unexpected object element! "${row}"`,
95
- location: { line: location.line + index, path: location.path }
96
- };
97
- throw errorLog;
98
- }
99
- else {
100
- let errorLog = {
101
- description: `Invalid coding indent! "${row}"`,
102
- location: { line: location.line + index, path: location.path }
103
- };
104
- throw errorLog;
105
- }
106
- }
107
- else if (row.startsWith('`')) {
108
- unparsedContent.push(row);
109
- let child = _2_structure_parser_helper_1.StructureParserHelper.getParsedStructure(unparsedContent, {
110
- line: unparsedContentStart,
111
- path: location.path
112
- });
113
- child.line -= 1;
114
- children[unparsedContentKey] = child;
115
- unparsedContent = [];
116
- unparsedContentKey = '';
117
- unparsedContentStart = 0;
118
- }
119
- else {
120
- unparsedContent.push(row.substring(unparsedContentType === 'object' ? 2 : 0));
121
- }
122
- });
123
- if (unparsedContent.length) {
124
- let child = _2_structure_parser_helper_1.StructureParserHelper.getParsedStructure(unparsedContent, { line: unparsedContentStart, path: location.path });
125
- child.line -= 1;
126
- children[unparsedContentKey] = child;
127
- }
128
- return {
129
- line: location.line,
130
- rawData: children
131
- };
132
- }
133
- }
134
- exports.ObjectParser = ObjectParser;
135
- //# sourceMappingURL=object-parser.js.map
@@ -1 +0,0 @@
1
- export {};
@@ -1,179 +0,0 @@
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
@@ -1 +0,0 @@
1
- export {};
@@ -1,186 +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 _mocks_1 = require("../_mocks");
6
- const object_parser_1 = require("./object-parser");
7
- (0, vitest_1.describe)('OBJECT PARSER', () => {
8
- (0, vitest_1.test)('basic', () => {
9
- let result = object_parser_1.ObjectParser.parse(['Name: axe', 'Quantity: 1'], mocks_1.SampleLocation1);
10
- (0, vitest_1.expect)(result).toStrictEqual({
11
- line: mocks_1.SampleLocation1.line,
12
- rawData: {
13
- name: {
14
- line: mocks_1.SampleLocation1.line,
15
- rawData: 'axe'
16
- },
17
- quantity: {
18
- line: mocks_1.SampleLocation1.line + 1,
19
- rawData: '1'
20
- }
21
- }
22
- });
23
- });
24
- (0, vitest_1.test)('quote string value', () => {
25
- let result = object_parser_1.ObjectParser.parse(['Path: "D:/test"'], mocks_1.SampleLocation1);
26
- (0, vitest_1.expect)(result).toStrictEqual({
27
- line: mocks_1.SampleLocation1.line,
28
- rawData: {
29
- path: {
30
- line: mocks_1.SampleLocation1.line,
31
- rawData: 'D:/test'
32
- }
33
- }
34
- });
35
- });
36
- (0, vitest_1.test)('back-tick string value', () => {
37
- let result = object_parser_1.ObjectParser.parse(['Path: `D:/test`'], mocks_1.SampleLocation1);
38
- (0, vitest_1.expect)(result).toStrictEqual({
39
- line: mocks_1.SampleLocation1.line,
40
- rawData: {
41
- path: {
42
- line: mocks_1.SampleLocation1.line,
43
- rawData: 'D:/test'
44
- }
45
- }
46
- });
47
- });
48
- (0, vitest_1.test)('multiline string value', () => {
49
- let result = object_parser_1.ObjectParser.parse(['Str: `', 'text with space', 'text', '`'], mocks_1.SampleLocation1);
50
- (0, vitest_1.expect)(result).toStrictEqual({
51
- line: mocks_1.SampleLocation1.line,
52
- rawData: {
53
- str: {
54
- line: mocks_1.SampleLocation1.line,
55
- rawData: 'text with space\ntext'
56
- }
57
- }
58
- });
59
- });
60
- (0, vitest_1.test)('object contains object', () => {
61
- let result = object_parser_1.ObjectParser.parse(['Attacker:', ' Name: firstObjectName', ' Age: 25', 'Defender:', ' Name: secondObjectName', ' Age: 35'], mocks_1.SampleLocation1);
62
- (0, vitest_1.expect)(result).toStrictEqual({
63
- line: mocks_1.SampleLocation1.line,
64
- rawData: {
65
- attacker: {
66
- line: mocks_1.SampleLocation1.line,
67
- rawData: {
68
- name: {
69
- line: mocks_1.SampleLocation1.line + 1,
70
- rawData: 'firstObjectName'
71
- },
72
- age: {
73
- line: mocks_1.SampleLocation1.line + 2,
74
- rawData: '25'
75
- }
76
- }
77
- },
78
- defender: {
79
- line: mocks_1.SampleLocation1.line + 3,
80
- rawData: {
81
- name: {
82
- line: mocks_1.SampleLocation1.line + 4,
83
- rawData: 'secondObjectName'
84
- },
85
- age: {
86
- line: mocks_1.SampleLocation1.line + 5,
87
- rawData: '35'
88
- }
89
- }
90
- }
91
- }
92
- });
93
- });
94
- (0, vitest_1.test)('object contains array', () => {
95
- let result = object_parser_1.ObjectParser.parse(['Array1:', '- apple', '- orange', 'Array2:', '- xWing', '- tieFighter'], mocks_1.SampleLocation1);
96
- (0, vitest_1.expect)(result).toStrictEqual({
97
- line: mocks_1.SampleLocation1.line,
98
- rawData: {
99
- array1: {
100
- line: mocks_1.SampleLocation1.line,
101
- rawData: [
102
- {
103
- line: mocks_1.SampleLocation1.line + 1,
104
- rawData: 'apple'
105
- },
106
- {
107
- line: mocks_1.SampleLocation1.line + 2,
108
- rawData: 'orange'
109
- }
110
- ]
111
- },
112
- array2: {
113
- line: mocks_1.SampleLocation1.line + 3,
114
- rawData: [
115
- {
116
- line: mocks_1.SampleLocation1.line + 4,
117
- rawData: 'xWing'
118
- },
119
- {
120
- line: mocks_1.SampleLocation1.line + 5,
121
- rawData: 'tieFighter'
122
- }
123
- ]
124
- }
125
- }
126
- });
127
- });
128
- });
129
- (0, vitest_1.describe)('OBJECT PARSER - Error Detection', () => {
130
- let expectErrorHelper = new _mocks_1.ExpectErrorHelper(object_parser_1.ObjectParser);
131
- vitest_1.test.each(['Name:axe', 'Name: axe'])('one space after column, first line "%s"', (item) => {
132
- expectErrorHelper.expect([item], {
133
- description: `There should be one space after column operator! "${item}"`,
134
- location: mocks_1.SampleLocation1
135
- });
136
- });
137
- (0, vitest_1.test)('object cannot start with backtick', () => {
138
- expectErrorHelper.expect(['`'], {
139
- description: `Unexpected object element! "\`"`,
140
- location: mocks_1.SampleLocation1
141
- });
142
- });
143
- (0, vitest_1.test)('unexpected backtick', () => {
144
- expectErrorHelper.expect(['Group:', '- item', '`'], {
145
- description: `Unexpected object element! "\`"`,
146
- location: { line: mocks_1.SampleLocation1.line + 2, path: mocks_1.SampleLocation1.path }
147
- });
148
- });
149
- vitest_1.test.each(['Quantity:5', 'Quantity: 5'])('one space after column, second line "%s"', (item) => {
150
- expectErrorHelper.expect(['Name: axe', item], {
151
- description: `There should be one space after column operator! "${item}"`,
152
- location: { line: mocks_1.SampleLocation1.line + 1, path: mocks_1.SampleLocation1.path }
153
- });
154
- });
155
- vitest_1.test.each(['- apple', 'text'])('unexpected object element, "%s"', (item) => {
156
- expectErrorHelper.expect([item], {
157
- description: `Unexpected object element! "${item}"`,
158
- location: mocks_1.SampleLocation1
159
- });
160
- });
161
- (0, vitest_1.test)('multiple columns', () => {
162
- expectErrorHelper.expect(['Name:something: axe'], {
163
- description: `Invalid row, multiple columns! "Name:something: axe"`,
164
- location: mocks_1.SampleLocation1
165
- });
166
- });
167
- (0, vitest_1.test)('starting with column', () => {
168
- expectErrorHelper.expect([':something: axe'], {
169
- description: `Invalid row, row cannot start with columns! ":something: axe"`,
170
- location: mocks_1.SampleLocation1
171
- });
172
- });
173
- vitest_1.test.each([' Name: axe', ' Name: axe'])('invalid coding indent, "%s"', (item) => {
174
- expectErrorHelper.expect([item], {
175
- description: `Invalid coding indent! "${item}"`,
176
- location: mocks_1.SampleLocation1
177
- });
178
- });
179
- (0, vitest_1.test)('no value', () => {
180
- expectErrorHelper.expect(['Name:'], {
181
- description: `No value found after column! "Name:"`,
182
- location: mocks_1.SampleLocation1
183
- });
184
- });
185
- });
186
- //# sourceMappingURL=object-parser.test.js.map
@@ -1,7 +0,0 @@
1
- import { LocationInFile, ParsedStructure } from '../../framework/interfaces';
2
- export declare class PrimitiveParser {
3
- static parse(content: string[], location: LocationInFile): ParsedStructure;
4
- private static parsePlaneString;
5
- private static parseSingleLineString;
6
- private static parseMultilineString;
7
- }