definition-generator-framework 1.13.1 → 2.0.0-rc1

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 +204 -0
  2. package/dist/index.d.ts +204 -17
  3. package/dist/index.js +43 -50
  4. package/dist/index.mjs +43 -0
  5. package/package.json +28 -14
  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,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PathCustomValidator = void 0;
4
- const context_1 = require("../../../framework/context");
5
- const custom_validator_helper_1 = require("../custom-validator-helper/custom-validator.helper");
6
- class PathCustomValidator {
7
- constructor(fs) {
8
- this.fs = fs;
9
- this.regex = /^[\S]+$/;
10
- this.validate = (value, helpers) => {
11
- let validationState = custom_validator_helper_1.CustomValidatorHelper.getValidationState(helpers);
12
- if (validationState === 'valid') {
13
- let { rawDefinition } = custom_validator_helper_1.CustomValidatorHelper.getPathAndRawDefinition(helpers);
14
- let pathPrefix = rawDefinition.location.path.substring(0, rawDefinition.location.path.lastIndexOf('/') + 1);
15
- value = pathPrefix + value;
16
- if (!this.fs.existsSync(value)) {
17
- throw new Error(`No file is found in the path: "${value}"`);
18
- }
19
- else {
20
- return value.replace(context_1.Context.config.projectRoot, '.');
21
- }
22
- }
23
- else {
24
- throw new Error(`Internal Error; joi validation context for path validator: Path: "${helpers.state.path}", RawDefinition: "${JSON.stringify(helpers.prefs.context.rawDefinition)}"`);
25
- }
26
- };
27
- }
28
- }
29
- exports.PathCustomValidator = PathCustomValidator;
30
- //# sourceMappingURL=path.custom-validator.js.map
@@ -1,14 +0,0 @@
1
- import Joi, { ErrorReport } from 'joi';
2
- import { RawSpriteDefinition } from '../../../pre-made-components/assets/1-sprite';
3
- import { CustomObjectValidator } from '../joi-custom-validators';
4
- export interface PositionOnSpriteValidationOptions {
5
- selectSpriteDefinition: (value: any) => RawSpriteDefinition;
6
- positionsJsonPath: string | string[];
7
- includeRotationFromAnchor?: boolean;
8
- checkIfPositionIsOnSprite?: boolean;
9
- }
10
- export declare class PositionOnSpriteCustomValidator implements CustomObjectValidator {
11
- private options;
12
- readonly validate: (value: string, helpers: Joi.CustomHelpers) => any | ErrorReport;
13
- constructor(options: PositionOnSpriteValidationOptions);
14
- }
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PositionOnSpriteCustomValidator = void 0;
4
- const helpers_lib_1 = require("helpers-lib");
5
- const jsonpath_plus_1 = require("jsonpath-plus");
6
- const sprite_validation_helper_1 = require("./helpers/sprite-validation.helper");
7
- class PositionOnSpriteCustomValidator {
8
- constructor(options) {
9
- this.options = options;
10
- this.validate = (value, helpers) => {
11
- let spriteDefinition = this.options.selectSpriteDefinition(value);
12
- if (!spriteDefinition) {
13
- throw new Error(`positionOnSprite - callback function did not return sprite definition.`);
14
- }
15
- let spriteValidationHelper = new sprite_validation_helper_1.SpriteValidationHelper(spriteDefinition.url.size, spriteDefinition.anchor, spriteDefinition.scale, this.options.checkIfPositionIsOnSprite);
16
- let positionsJsonPaths = Array.isArray(this.options.positionsJsonPath)
17
- ? this.options.positionsJsonPath
18
- : [this.options.positionsJsonPath];
19
- positionsJsonPaths.forEach(jsonPath => (0, jsonpath_plus_1.JSONPath)({ json: value, path: jsonPath }).forEach((item) => {
20
- if (!helpers_lib_1.Comparator.isObject(item)) {
21
- throw new Error(`positionOnSprite, positions json path returned a non-object result. Value: "${item}".`);
22
- }
23
- else if (!helpers_lib_1.Comparator.isNumber(item.x) || !helpers_lib_1.Comparator.isNumber(item.y)) {
24
- throw new Error(`positionOnSprite, positions json path returned a non-vec2 result. Value: "${item}".`);
25
- }
26
- let positionFromAnchor = spriteValidationHelper.convertPositionToSpriteAnchor(item);
27
- positionFromAnchor = { x: Math.round(positionFromAnchor.x), y: Math.round(positionFromAnchor.y) };
28
- if (this.options.includeRotationFromAnchor) {
29
- item.rotationFromAnchor = spriteValidationHelper.getRotationFromAnchor(positionFromAnchor);
30
- item.positionFromAnchor = positionFromAnchor;
31
- delete item.x;
32
- delete item.y;
33
- }
34
- else {
35
- item.x = positionFromAnchor.x;
36
- item.y = positionFromAnchor.y;
37
- }
38
- }));
39
- return value;
40
- };
41
- }
42
- }
43
- exports.PositionOnSpriteCustomValidator = PositionOnSpriteCustomValidator;
44
- //# sourceMappingURL=position-on-sprite.js.map
@@ -1,22 +0,0 @@
1
- import Joi, { ErrorReport } from 'joi';
2
- import { DefinitionComponentClassType } from '../../../decorators/definition-component';
3
- import { CustomStringValidator, ReferenceCustomValidatorOptions } from '../joi-custom-validators';
4
- declare abstract class ReferenceCustomValidatorBase implements CustomStringValidator {
5
- protected options?: ReferenceCustomValidatorOptions | undefined;
6
- readonly regex: RegExp;
7
- abstract readonly validate: Joi.CustomValidator<any, any>;
8
- protected constructor(options?: ReferenceCustomValidatorOptions | undefined);
9
- protected validatePropertyExistence(referencedComponent: DefinitionComponentClassType<any>, definitionName: string, options?: ReferenceCustomValidatorOptions): void;
10
- }
11
- export declare class ReferenceCustomValidator extends ReferenceCustomValidatorBase {
12
- readonly validate: (value: string, helpers: Joi.CustomHelpers) => any | ErrorReport;
13
- private includeType;
14
- private referencedComponents;
15
- constructor(definitionComponentClasses: DefinitionComponentClassType<any> | DefinitionComponentClassType<any>[], options?: ReferenceCustomValidatorOptions);
16
- }
17
- export declare class LazyReferenceCustomValidator extends ReferenceCustomValidatorBase {
18
- private componentName;
19
- readonly validate: (value: string, helpers: Joi.CustomHelpers) => any | ErrorReport;
20
- constructor(componentName: string, options?: ReferenceCustomValidatorOptions);
21
- }
22
- export {};
@@ -1,123 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LazyReferenceCustomValidator = exports.ReferenceCustomValidator = void 0;
4
- const helpers_lib_1 = require("helpers-lib");
5
- const context_1 = require("../../../framework/context");
6
- const definition_store_1 = require("../../../framework/definition-store");
7
- const raw_definition_helper_1 = require("../../raw-definition-helper/raw-definition.helper");
8
- const custom_validator_helper_1 = require("../custom-validator-helper/custom-validator.helper");
9
- class ReferenceCustomValidatorBase {
10
- constructor(options) {
11
- this.options = options;
12
- this.regex = /^[a-z]+([a-zA-Z0-9]+)*$/;
13
- }
14
- validatePropertyExistence(referencedComponent, definitionName, options) {
15
- if (options?.additionalValidation) {
16
- let rawDefinition = definition_store_1.DefinitionStore['getRawDefinition'](referencedComponent, definitionName);
17
- let flattenedRawDefinition = rawDefinition ? raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition) : undefined;
18
- let validation = options.additionalValidation.validate(flattenedRawDefinition);
19
- if (validation.error) {
20
- throw new Error(validation.error.message);
21
- }
22
- }
23
- }
24
- }
25
- class ReferenceCustomValidator extends ReferenceCustomValidatorBase {
26
- constructor(definitionComponentClasses, options) {
27
- super(options);
28
- this.validate = (value, helpers) => {
29
- let validationState = custom_validator_helper_1.CustomValidatorHelper.getValidationState(helpers);
30
- if (validationState === 'valid') {
31
- let referencedComponent = this.referencedComponents.find(component => definition_store_1.DefinitionStore.getDefinition(component, value));
32
- if (!referencedComponent) {
33
- let referencedComponentRawDefinitionExists = this.referencedComponents.find(component => definition_store_1.DefinitionStore['isRawDefinitionExists'](component, value));
34
- if (referencedComponentRawDefinitionExists) {
35
- // If referenced definition is failed its own validation, there should be no additional error
36
- helpers.prefs.context.failSilently = true;
37
- }
38
- else {
39
- throw new Error(`There is no "${this.referencedComponents
40
- .map(component => custom_validator_helper_1.CustomValidatorHelper.getDefinitionComponentName(component))
41
- .join(' or ')}" definition found for "${value}"`);
42
- }
43
- }
44
- else {
45
- this.validatePropertyExistence(referencedComponent, value, this.options);
46
- if (this.includeType) {
47
- return {
48
- value,
49
- type: custom_validator_helper_1.CustomValidatorHelper.getDefinitionComponentName(referencedComponent)
50
- };
51
- }
52
- else {
53
- return value;
54
- }
55
- }
56
- }
57
- else {
58
- throw new Error(`Internal Error; joi validation context for reference validator: Path: "${helpers.state.path}", RawDefinition: "${JSON.stringify(helpers.prefs.context)}"`);
59
- }
60
- };
61
- this.referencedComponents = [];
62
- if (helpers_lib_1.Comparator.isArray(definitionComponentClasses)) {
63
- this.includeType = true;
64
- this.referencedComponents = definitionComponentClasses;
65
- }
66
- else {
67
- this.includeType = false;
68
- this.referencedComponents = [definitionComponentClasses];
69
- }
70
- }
71
- }
72
- exports.ReferenceCustomValidator = ReferenceCustomValidator;
73
- class LazyReferenceCustomValidator extends ReferenceCustomValidatorBase {
74
- constructor(componentName, options) {
75
- super(options);
76
- this.componentName = componentName;
77
- this.validate = (value, helpers) => {
78
- if (!context_1.Context.componentInProgressData) {
79
- helpers_lib_1.ConsoleHelper.log('Unexpected error: Lazy reference validation has been called outside of the validation cycle.', 'red');
80
- }
81
- else if (!context_1.Context.componentInProgressData.meta.keyName) {
82
- helpers_lib_1.ConsoleHelper.log('Lazy reference can only be used for definitions with key name defined.', 'red');
83
- }
84
- else if (context_1.Context.componentInProgressData.meta.componentName !== this.componentName) {
85
- helpers_lib_1.ConsoleHelper.log(`Lazy reference can only be used for self referencing. It is used under: "${this.componentName}"`, 'red');
86
- }
87
- else if (context_1.Context.componentInProgressData.meta.singleton) {
88
- helpers_lib_1.ConsoleHelper.log(`Lazy reference cannot be used for singleton components. It is used under: "${this.componentName}"`, 'red');
89
- }
90
- else {
91
- let rootDefinition = helpers.state.ancestors.at(-1);
92
- let definitionId = rootDefinition[context_1.Context.componentInProgressData.meta.keyName];
93
- if (!definitionId) {
94
- helpers_lib_1.ConsoleHelper.log(`Unexpected error: definitionId cannot be retrieved by keyname.`, 'red');
95
- }
96
- else {
97
- if (!context_1.Context.componentInProgressData.idToReferencesMap.has(definitionId)) {
98
- context_1.Context.componentInProgressData.idToReferencesMap.set(definitionId, new Set());
99
- }
100
- let references = context_1.Context.componentInProgressData.idToReferencesMap.get(definitionId);
101
- references.add(value);
102
- }
103
- }
104
- let referencedComponent = definition_store_1.DefinitionStore['getComponentClass'](this.componentName);
105
- let validationState = custom_validator_helper_1.CustomValidatorHelper.getValidationState(helpers);
106
- if (validationState === 'valid') {
107
- let referencedComponentRawDefinitionExists = definition_store_1.DefinitionStore['isRawDefinitionExists'](referencedComponent, value);
108
- if (!referencedComponentRawDefinitionExists) {
109
- throw new Error(`There is no "${this.componentName}" definition found for "${value}"`);
110
- }
111
- else {
112
- this.validatePropertyExistence(referencedComponent, value, this.options);
113
- return value;
114
- }
115
- }
116
- else {
117
- throw new Error(`Internal Error; joi validation context for reference validator: Path: "${helpers.state.path}", RawDefinition: "${JSON.stringify(helpers.prefs.context)}"`);
118
- }
119
- };
120
- }
121
- }
122
- exports.LazyReferenceCustomValidator = LazyReferenceCustomValidator;
123
- //# sourceMappingURL=reference.custom-validator.js.map
@@ -1,14 +0,0 @@
1
- import { Vec2 } from 'helpers-lib';
2
- import Joi, { ErrorReport } from 'joi';
3
- import { FileSystem } from '../../../framework/interfaces';
4
- import { CustomStringValidator } from '../joi-custom-validators';
5
- export interface ValidatedSpriteUrl {
6
- readonly url: string;
7
- readonly size: Vec2;
8
- }
9
- export declare class SpriteCustomValidator implements CustomStringValidator {
10
- private fs;
11
- readonly regex: RegExp;
12
- readonly validate: (value: string, helpers: Joi.CustomHelpers) => any | ErrorReport;
13
- constructor(fs: FileSystem);
14
- }
@@ -1,43 +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
- exports.SpriteCustomValidator = void 0;
7
- const image_size_1 = __importDefault(require("image-size"));
8
- const context_1 = require("../../../framework/context");
9
- const custom_validator_helper_1 = require("../custom-validator-helper/custom-validator.helper");
10
- class SpriteCustomValidator {
11
- constructor(fs) {
12
- this.fs = fs;
13
- this.regex = /^[\S]+$/;
14
- this.validate = (value, helpers) => {
15
- let validationState = custom_validator_helper_1.CustomValidatorHelper.getValidationState(helpers);
16
- if (validationState === 'valid') {
17
- let { rawDefinition } = custom_validator_helper_1.CustomValidatorHelper.getPathAndRawDefinition(helpers);
18
- let pathPrefix = rawDefinition.location.path.substring(0, rawDefinition.location.path.lastIndexOf('/') + 1);
19
- value = pathPrefix + value;
20
- if (!this.fs.existsSync(value)) {
21
- throw new Error(`No file is found in the path: "${value}"`);
22
- }
23
- else {
24
- try {
25
- let size = (0, image_size_1.default)(value);
26
- return {
27
- url: value.replace(context_1.Context.config.projectRoot, '.'),
28
- size: { x: size.width, y: size.height }
29
- };
30
- }
31
- catch {
32
- throw new Error(`The file in the path "${value}" is not an image`);
33
- }
34
- }
35
- }
36
- else {
37
- throw new Error(`Internal Error; joi validation context for image validator: Path: "${helpers.state.path}", RawDefinition: "${JSON.stringify(helpers.prefs.context.rawDefinition)}"`);
38
- }
39
- };
40
- }
41
- }
42
- exports.SpriteCustomValidator = SpriteCustomValidator;
43
- //# sourceMappingURL=sprite.custom-validator.js.map
@@ -1,9 +0,0 @@
1
- import Joi, { ErrorReport } from 'joi';
2
- import { CustomValidator } from '../joi-custom-validators';
3
- import { DefinitionComponentClassType } from '../../../framework/definition-component';
4
- export declare class UniqueNameGroupCustomValidator implements CustomValidator {
5
- private definitionComponentClass;
6
- readonly regex: RegExp;
7
- readonly validate: (value: string, helpers: Joi.CustomHelpers) => any | ErrorReport;
8
- constructor(definitionComponentClass: DefinitionComponentClassType<any>);
9
- }
@@ -1,33 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.UniqueNameGroupCustomValidator = void 0;
4
- const common_functions_1 = require('../../common-functions/common-functions');
5
- const raw_definition_helper_1 = require('../../raw-definition-helper/raw-definition.helper');
6
- const custom_validator_helper_1 = require('../custom-validator-helper/custom-validator.helper');
7
- class UniqueNameGroupCustomValidator {
8
- constructor(definitionComponentClass) {
9
- this.definitionComponentClass = definitionComponentClass;
10
- this.regex = /^[a-z]+([a-zA-Z0-9]+)*$/;
11
- this.validate = (value, helpers) => {
12
- let componentName = this.definitionComponentClass.$meta.componentName;
13
- let validationState = custom_validator_helper_1.CustomValidatorHelper.getValidationState(helpers);
14
- if (validationState === 'valid') {
15
- let { path, rawDefinition } = custom_validator_helper_1.CustomValidatorHelper.getPathAndRawDefinition(helpers);
16
- let duplicateHelper = custom_validator_helper_1.CustomValidatorHelper.getDuplicateHelper(componentName);
17
- duplicateHelper.newEntry(value, {
18
- line: raw_definition_helper_1.RawDefinitionHelper.findLine(rawDefinition, path),
19
- path: rawDefinition.location.path
20
- });
21
- return common_functions_1.CommonFunctions.decorateDefinitionName(value, componentName);
22
- } else if (validationState === 'registerLoop') {
23
- custom_validator_helper_1.CustomValidatorHelper.getDefinitionNames(componentName).add(value);
24
- } else {
25
- throw new Error(
26
- `Internal Error; joi validation context for uniqueNameGroup validator: Path: "${helpers.state.path}", RawDefinition: "${JSON.stringify(helpers.prefs.context)}"`
27
- );
28
- }
29
- };
30
- }
31
- }
32
- exports.UniqueNameGroupCustomValidator = UniqueNameGroupCustomValidator;
33
- //# sourceMappingURL=unique-name-group.custom-validator.js.map
@@ -1,8 +0,0 @@
1
- import Joi, { ErrorReport } from 'joi';
2
- import { CustomStringValidator } from '../joi-custom-validators';
3
- export declare class UniqueCustomValidator implements CustomStringValidator {
4
- private nameSpace;
5
- readonly regex: RegExp;
6
- readonly validate: (value: string, helpers: Joi.CustomHelpers) => any | ErrorReport;
7
- constructor(nameSpace: Set<string>);
8
- }
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UniqueCustomValidator = void 0;
4
- class UniqueCustomValidator {
5
- constructor(nameSpace) {
6
- this.nameSpace = nameSpace;
7
- this.regex = /^[\S]+$/;
8
- this.validate = (value, helpers) => {
9
- if (this.nameSpace.has(value)) {
10
- throw new Error(`Value "${value}" is not unique in the name space: "${Array.from(this.nameSpace).join(', ')}"`);
11
- }
12
- else {
13
- this.nameSpace.add(value);
14
- return value;
15
- }
16
- };
17
- }
18
- }
19
- exports.UniqueCustomValidator = UniqueCustomValidator;
20
- //# sourceMappingURL=unique.custom-validator.js.map
@@ -1,33 +0,0 @@
1
- import Joi from 'joi';
2
- import { DefinitionComponentClassType } from '../../decorators/definition-component';
3
- import { FileSystem } from '../../framework/interfaces';
4
- import { PositionOnSpriteValidationOptions } from './custom-validators/position-on-sprite';
5
- export interface CustomStringValidator {
6
- readonly regex: RegExp;
7
- readonly validate: Joi.CustomValidator<any, any>;
8
- }
9
- export interface CustomObjectValidator {
10
- readonly validate: Joi.CustomValidator<any, any>;
11
- }
12
- export interface ReferenceCustomValidatorOptions {
13
- additionalValidation?: Joi.Schema;
14
- }
15
- declare module 'joi' {
16
- interface StringSchema {
17
- unique(nameSpace: Set<string>): Joi.StringSchema;
18
- path(): Joi.StringSchema;
19
- sprite(): Joi.StringSchema;
20
- reference(definitionComponentClass: DefinitionComponentClassType<any> | DefinitionComponentClassType<any>[], options?: ReferenceCustomValidatorOptions): Joi.StringSchema;
21
- lazyReference(componentName: string, options?: ReferenceCustomValidatorOptions): Joi.StringSchema;
22
- }
23
- interface ObjectSchema {
24
- /**
25
- * Converts the values to relative position from anchor on sprite.
26
- */
27
- positionOnSprite(options: PositionOnSpriteValidationOptions): Joi.ObjectSchema;
28
- }
29
- }
30
- export declare class JoiCustomValidators {
31
- static decorate(joi: object, fs: FileSystem): void;
32
- private static defineCustomStringValidator;
33
- }
@@ -1,54 +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
- exports.JoiCustomValidators = void 0;
7
- const joi_1 = __importDefault(require("joi"));
8
- const path_custom_validator_1 = require("./custom-validators/path.custom-validator");
9
- const position_on_sprite_1 = require("./custom-validators/position-on-sprite");
10
- const reference_custom_validator_1 = require("./custom-validators/reference.custom-validator");
11
- const sprite_custom_validator_1 = require("./custom-validators/sprite.custom-validator");
12
- const unique_custom_validator_1 = require("./custom-validators/unique.custom-validator");
13
- class JoiCustomValidators {
14
- static decorate(joi, fs) {
15
- // @ts-ignore
16
- joi.string().__proto__.unique = function (nameSpace) {
17
- let uniqueCustomValidator = new unique_custom_validator_1.UniqueCustomValidator(nameSpace);
18
- return JoiCustomValidators.defineCustomStringValidator(this, uniqueCustomValidator);
19
- };
20
- // @ts-ignore
21
- joi.string().__proto__.path = function () {
22
- let pathCustomValidator = new path_custom_validator_1.PathCustomValidator(fs);
23
- return JoiCustomValidators.defineCustomStringValidator(this, pathCustomValidator);
24
- };
25
- // @ts-ignore
26
- joi.string().__proto__.sprite = function () {
27
- let spriteCustomValidator = new sprite_custom_validator_1.SpriteCustomValidator(fs);
28
- return JoiCustomValidators.defineCustomStringValidator(this, spriteCustomValidator);
29
- };
30
- // @ts-ignore
31
- joi.string().__proto__.reference = function (definitionComponentClasses, options) {
32
- let referenceCustomValidator = new reference_custom_validator_1.ReferenceCustomValidator(definitionComponentClasses, options);
33
- return JoiCustomValidators.defineCustomStringValidator(this, referenceCustomValidator);
34
- };
35
- // @ts-ignore
36
- joi.string().__proto__.lazyReference = function (componentName, options) {
37
- let lazyReferenceCustomValidator = new reference_custom_validator_1.LazyReferenceCustomValidator(componentName, options);
38
- return JoiCustomValidators.defineCustomStringValidator(this, lazyReferenceCustomValidator);
39
- };
40
- // @ts-ignore
41
- joi.object().__proto__.positionOnSprite = function (options) {
42
- let positionOnSpriteValidator = new position_on_sprite_1.PositionOnSpriteCustomValidator(options);
43
- return this.custom(positionOnSpriteValidator.validate);
44
- };
45
- if (joi !== joi_1.default) {
46
- this.decorate(joi_1.default, fs);
47
- }
48
- }
49
- static defineCustomStringValidator(schema, customValidator) {
50
- return schema.regex(customValidator.regex).custom(customValidator.validate);
51
- }
52
- }
53
- exports.JoiCustomValidators = JoiCustomValidators;
54
- //# sourceMappingURL=joi-custom-validators.js.map