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,100 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __importDefault = (this && this.__importDefault) || function (mod) {
9
- return (mod && mod.__esModule) ? mod : { "default": mod };
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.EventComponent = void 0;
13
- const helpers_lib_1 = require("helpers-lib");
14
- const joi_1 = __importDefault(require("joi"));
15
- const definition_component_1 = require("../../decorators/definition-component");
16
- const _1_script_1 = require("./1-script");
17
- const validators_1 = require("./validators");
18
- const JumpToEventSchema = joi_1.default.object()
19
- .keys({
20
- jumpTo: joi_1.default.string().lazyReference('EVENT').required()
21
- })
22
- .custom(value => ({
23
- type: 'jumpTo',
24
- value: value.jumpTo
25
- }));
26
- // ---- Main Schema ----
27
- const EventActionId = 'EventActionsSchema';
28
- const ActionsSchema = () => joi_1.default.array()
29
- .items(joi_1.default.alternatives()
30
- .conditional(joi_1.default.string(), {
31
- then: (0, validators_1.ActionCommandSchema)()
32
- })
33
- .conditional(joi_1.default.object({ jumpTo: joi_1.default.exist() }).unknown(), {
34
- then: JumpToEventSchema
35
- })
36
- .conditional(joi_1.default.object({ branchByChance: joi_1.default.exist() }).unknown(), {
37
- then: (0, validators_1.BranchByChanceSchema)(EventActionId)
38
- })
39
- .conditional(joi_1.default.object({ branchByCondition: joi_1.default.exist() }).unknown(), {
40
- then: (0, validators_1.BranchByConditionSchema)(EventActionId)
41
- })
42
- .conditional(joi_1.default.object({ branchByPlayerChoice: joi_1.default.exist() }).unknown(), {
43
- then: (0, validators_1.BranchByPlayerChoiceSchema)(EventActionId)
44
- })
45
- .conditional(joi_1.default.object().min(1).max(1).unknown(), {
46
- then: (0, validators_1.DialogSchema)()
47
- })
48
- .error(errors => errors.map(error => {
49
- if (error.code === 'alternatives.any') {
50
- let allowedTypes = 'command, jumpTo, branchByCondition, branchByPlayerChoice, branchByChance';
51
- error.message = `${error.local.label} does not match any of the allowed types: ${allowedTypes}`;
52
- }
53
- return error;
54
- })))
55
- .custom((array) => {
56
- let commandFoundAfterBranching = false;
57
- let emptyStackRequiresBranchingFound = false;
58
- array.forEach(action => {
59
- if (emptyStackRequiresBranchingFound) {
60
- commandFoundAfterBranching = true;
61
- }
62
- else if (action.type === 'branchByCondition' ||
63
- action.type === 'branchByPlayerChoice' ||
64
- action.type === 'branchByChance') {
65
- emptyStackRequiresBranchingFound = true;
66
- }
67
- });
68
- if (commandFoundAfterBranching) {
69
- throw new Error('There should not be any command after branching.');
70
- }
71
- else {
72
- return array;
73
- }
74
- })
75
- .id(EventActionId);
76
- let EventComponent = class EventComponent extends definition_component_1.DefinitionComponent {
77
- async process(definitions, output) {
78
- await output.addFile({
79
- path: '/_premade/script-engine-definitions/events.ts',
80
- preText: `import { ScriptDefinition } from "script-engine-lib";`,
81
- variableName: 'EventDefinitions',
82
- variableType: 'Readonly<Record<string, ScriptDefinition>>',
83
- variable: helpers_lib_1.JsonHelper.arrayToObject(definitions, 'id')
84
- });
85
- }
86
- };
87
- exports.EventComponent = EventComponent;
88
- exports.EventComponent = EventComponent = __decorate([
89
- (0, definition_component_1.DefinitionComponentDecorator)({
90
- componentName: 'EVENT',
91
- keyName: 'id',
92
- validationSchema: joi_1.default.object()
93
- .keys({
94
- id: joi_1.default.string().unique(_1_script_1.ScriptNames).required(),
95
- actions: ActionsSchema().min(1).required()
96
- })
97
- .required()
98
- })
99
- ], EventComponent);
100
- //# sourceMappingURL=3-event.js.map
@@ -1,7 +0,0 @@
1
- import { DefinitionComponent } from '../../decorators/definition-component';
2
- import { Output } from '../../framework/interfaces';
3
- import { ScriptTestDefinition } from './helpers/script-testing.helper';
4
- export declare class EventTestComponent extends DefinitionComponent<ScriptTestDefinition> {
5
- process(definitions: ScriptTestDefinition[], output: Output): Promise<void>;
6
- private getLocationFinder;
7
- }
@@ -1,89 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __importDefault = (this && this.__importDefault) || function (mod) {
9
- return (mod && mod.__esModule) ? mod : { "default": mod };
10
- };
11
- var EventTestComponent_1;
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.EventTestComponent = void 0;
14
- const joi_1 = __importDefault(require("joi"));
15
- const definition_component_1 = require("../../decorators/definition-component");
16
- const definition_store_1 = require("../../framework/definition-store");
17
- const _3_event_1 = require("./3-event");
18
- const script_testing_helper_1 = require("./helpers/script-testing.helper");
19
- const scripting_setup_1 = require("./scripting-setup");
20
- const CommandEventSchema = joi_1.default.string().custom(value => ({
21
- type: 'command',
22
- value: value
23
- }));
24
- const RunEventSchema = joi_1.default.object()
25
- .keys({
26
- runEvent: joi_1.default.string().reference(_3_event_1.EventComponent).required()
27
- })
28
- .custom(value => ({
29
- type: 'runScript',
30
- value: value.runEvent
31
- }));
32
- const EventTestActionSchema = () => joi_1.default.array()
33
- .items(joi_1.default.alternatives()
34
- .conditional(joi_1.default.string(), {
35
- then: CommandEventSchema
36
- })
37
- .conditional(joi_1.default.object({ runEvent: joi_1.default.exist() }).unknown(), {
38
- then: RunEventSchema
39
- })
40
- .error(errors => errors.map(error => {
41
- if (error.code === 'alternatives.any') {
42
- let allowedTypes = 'command, runEvent';
43
- error.message = `${error.local.label} does not match any of the allowed types: ${allowedTypes}`;
44
- }
45
- return error;
46
- })))
47
- .min(1);
48
- let EventTestComponent = EventTestComponent_1 = class EventTestComponent extends definition_component_1.DefinitionComponent {
49
- async process(definitions, output) {
50
- let allScripts = definition_store_1.DefinitionStore.getDefinitions(_3_event_1.EventComponent);
51
- let scriptTestingHelper = new script_testing_helper_1.ScriptTestingHelper(allScripts, scripting_setup_1.ScriptTestingInternal.eventSimulatorFunctionsConstructor, this.getLocationFinder());
52
- let runtimeErrors = scriptTestingHelper.runTests(definitions.map(definition => ({
53
- cases: definition.cases,
54
- script: definition_store_1.DefinitionStore.getDefinitionOrFail(_3_event_1.EventComponent, definition.script),
55
- scriptInput: scripting_setup_1.ScriptTestingInternal.getEventInput(definition.script),
56
- testDefinitionRef: definition
57
- })), output);
58
- scriptTestingHelper.printErrors(runtimeErrors, output);
59
- }
60
- getLocationFinder() {
61
- return {
62
- getLocationOfDefinition: (key, path) => definition_store_1.DefinitionStore.getLocationInFileById(_3_event_1.EventComponent, key, path),
63
- getLocationOfTestDefinition: (definition, path) => definition_store_1.DefinitionStore.getLocationInFile(EventTestComponent_1, definition, path)
64
- };
65
- }
66
- };
67
- exports.EventTestComponent = EventTestComponent;
68
- exports.EventTestComponent = EventTestComponent = EventTestComponent_1 = __decorate([
69
- (0, definition_component_1.DefinitionComponentDecorator)({
70
- componentName: 'EVENT-TEST',
71
- validationSchema: joi_1.default.object()
72
- .keys({
73
- event: joi_1.default.string().reference(_3_event_1.EventComponent).required(),
74
- cases: joi_1.default.array()
75
- .items(joi_1.default.object()
76
- .keys({
77
- actionsBeforeTesting: EventTestActionSchema().default([]).optional()
78
- })
79
- .required())
80
- .required()
81
- })
82
- .required()
83
- .custom(value => ({
84
- script: value.event,
85
- cases: value.cases
86
- }))
87
- })
88
- ], EventTestComponent);
89
- //# sourceMappingURL=4-event-test.js.map
@@ -1,13 +0,0 @@
1
- import { ScriptEngineSimulatorFunctions } from 'script-engine-lib';
2
- export declare class EventSetup {
3
- private static _eventSimulatorFunctionsConstructor;
4
- private static _richTextTags;
5
- static get EventSimulatorFunctionsConstructor(): new (
6
- ...args: any[]
7
- ) => ScriptEngineSimulatorFunctions;
8
- static get RichTextTags(): Set<string> | undefined;
9
- static set(
10
- eventSimulatorFunctionsConstructor: new (...args: any[]) => ScriptEngineSimulatorFunctions,
11
- richTextTags: Set<string> | undefined
12
- ): void;
13
- }
@@ -1,20 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.EventSetup = void 0;
4
- class EventSetup {
5
- static get EventSimulatorFunctionsConstructor() {
6
- if (!this._eventSimulatorFunctionsConstructor) {
7
- throw new Error('EventSimulatorFunctionsConstructor is not set');
8
- }
9
- return this._eventSimulatorFunctionsConstructor;
10
- }
11
- static get RichTextTags() {
12
- return this._richTextTags;
13
- }
14
- static set(eventSimulatorFunctionsConstructor, richTextTags) {
15
- this._eventSimulatorFunctionsConstructor = eventSimulatorFunctionsConstructor;
16
- this._richTextTags = richTextTags;
17
- }
18
- }
19
- exports.EventSetup = EventSetup;
20
- //# sourceMappingURL=event-setup.js.map
@@ -1,3 +0,0 @@
1
- export declare class QuotesToTagsHelper {
2
- static convert(text: string): string;
3
- }
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QuotesToTagsHelper = void 0;
4
- const script_engine_lib_1 = require("script-engine-lib");
5
- const scripting_setup_1 = require("../scripting-setup");
6
- class QuotesToTagsHelper {
7
- static convert(text) {
8
- let isInsideQuote = false;
9
- let quoteIndex = text.indexOf('"');
10
- while (quoteIndex >= 0) {
11
- let tag = isInsideQuote ? '"</b>' : '<b>"';
12
- text = text.substring(0, quoteIndex) + tag + text.substring(quoteIndex + 1);
13
- isInsideQuote = !isInsideQuote;
14
- quoteIndex = text.indexOf('"', quoteIndex + tag.length);
15
- }
16
- if (isInsideQuote) {
17
- throw new Error('Quote is not closed.');
18
- }
19
- script_engine_lib_1.RichTextValidator.validate(text, scripting_setup_1.ScriptTestingInternal.richTextTags);
20
- return text;
21
- }
22
- }
23
- exports.QuotesToTagsHelper = QuotesToTagsHelper;
24
- //# sourceMappingURL=quotes-to-tags.helper.js.map
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
- const quotes_to_tags_helper_1 = require("./quotes-to-tags.helper");
5
- (0, vitest_1.describe)('QuotesToTagsHelper', () => {
6
- (0, vitest_1.test)('plane text', () => {
7
- let text = '0123';
8
- let result = quotes_to_tags_helper_1.QuotesToTagsHelper.convert(text);
9
- (0, vitest_1.expect)(result).toBe('0123');
10
- });
11
- (0, vitest_1.test)('quote in text', () => {
12
- let text = `"0123"0123`;
13
- let result = quotes_to_tags_helper_1.QuotesToTagsHelper.convert(text);
14
- (0, vitest_1.expect)(result).toBe('<b>"0123"</b>0123');
15
- });
16
- (0, vitest_1.test)('multiple quotes in text', () => {
17
- let text = `"0123"0123"0123"0123`;
18
- let result = quotes_to_tags_helper_1.QuotesToTagsHelper.convert(text);
19
- (0, vitest_1.expect)(result).toBe('<b>"0123"</b>0123<b>"0123"</b>0123');
20
- });
21
- (0, vitest_1.test)('unclosed single quote', () => {
22
- let text = `"0123`;
23
- (0, vitest_1.expect)(() => quotes_to_tags_helper_1.QuotesToTagsHelper.convert(text)).toThrow('Quote is not closed.');
24
- });
25
- (0, vitest_1.test)('unclosed multiple quotes', () => {
26
- let text = `"0123"0123"0123`;
27
- (0, vitest_1.expect)(() => quotes_to_tags_helper_1.QuotesToTagsHelper.convert(text)).toThrow('Quote is not closed.');
28
- });
29
- (0, vitest_1.test)('use together with other tags', () => {
30
- let text = `"0123"<r>0123</r>`;
31
- let result = quotes_to_tags_helper_1.QuotesToTagsHelper.convert(text);
32
- (0, vitest_1.expect)(result).toBe('<b>"0123"</b><r>0123</r>');
33
- });
34
- (0, vitest_1.test)('conflict with other tags', () => {
35
- let text = `"0123<r>01"23</r>`;
36
- (0, vitest_1.expect)(() => quotes_to_tags_helper_1.QuotesToTagsHelper.convert(text)).toThrow(`Mismatched tags: expected closing tag for 'r', but found 'b' at position`);
37
- });
38
- });
39
- //# sourceMappingURL=quotes-to-tags.helper.test.js.map
@@ -1,33 +0,0 @@
1
- import { ScriptDefinition, ScriptEngineSimulatorFunctions, ScriptTestActionDefinition } from 'script-engine-lib';
2
- import { ErrorLog, LocationInFile, Output } from '../../../framework/interfaces';
3
- export interface ScriptTestCasesDefinition {
4
- readonly actionsBeforeTesting: readonly ScriptTestActionDefinition[];
5
- }
6
- export interface ScriptTestDefinition {
7
- readonly script: string;
8
- readonly cases: readonly ScriptTestCasesDefinition[];
9
- }
10
- export interface CustomScriptTestDefinition {
11
- readonly testDefinition: ScriptTestDefinition;
12
- readonly customMessage: string;
13
- }
14
- export interface ScriptTestFullDefinition<T> {
15
- readonly script: ScriptDefinition;
16
- readonly testDefinitionRef: T;
17
- readonly scriptInput: any;
18
- readonly customMessage?: string;
19
- readonly cases: readonly ScriptTestCasesDefinition[];
20
- }
21
- export interface ScriptTestingLocationFinder<T> {
22
- getLocationOfDefinition(key: string, path: readonly string[]): LocationInFile;
23
- getLocationOfTestDefinition(definition: T, path: readonly string[]): LocationInFile;
24
- }
25
- export declare class ScriptTestingHelper<T> {
26
- private functionsConstructor;
27
- private locationFinder;
28
- private scriptTestSimulator;
29
- constructor(allScripts: ScriptDefinition[], functionsConstructor: new (input: any) => ScriptEngineSimulatorFunctions, locationFinder: ScriptTestingLocationFinder<T>);
30
- runTests(testDefinitions: ScriptTestFullDefinition<T>[], output: Output): ErrorLog[];
31
- printErrors(runtimeErrors: ErrorLog[], output: Output): void;
32
- private prepareErrorLog;
33
- }
@@ -1,79 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ScriptTestingHelper = void 0;
4
- const helpers_lib_1 = require("helpers-lib");
5
- const script_engine_lib_1 = require("script-engine-lib");
6
- class ScriptTestingHelper {
7
- constructor(allScripts, functionsConstructor, locationFinder) {
8
- this.functionsConstructor = functionsConstructor;
9
- this.locationFinder = locationFinder;
10
- this.scriptTestSimulator = new script_engine_lib_1.ScriptTestSimulator(allScripts);
11
- }
12
- runTests(testDefinitions, output) {
13
- let errorLogs = [];
14
- testDefinitions.forEach(testDefinition => {
15
- let errorEncountered = false;
16
- testDefinition.cases.forEach((testCase, testCaseIndex) => {
17
- if (!errorEncountered) {
18
- let jsEngine = new helpers_lib_1.JSEngine(new this.functionsConstructor(testDefinition.scriptInput), {});
19
- try {
20
- this.scriptTestSimulator.simulateScript(testDefinition.script, jsEngine, testCase.actionsBeforeTesting);
21
- }
22
- catch (e) {
23
- let errorLog = this.prepareErrorLog(e, testDefinition, testCaseIndex, output);
24
- errorLogs.push(errorLog);
25
- errorEncountered = true;
26
- }
27
- }
28
- });
29
- });
30
- return errorLogs;
31
- }
32
- printErrors(runtimeErrors, output) {
33
- if (runtimeErrors.length === 0) {
34
- this.scriptTestSimulator.getUnvisitedBranchLocations().forEach(location => output.addError({
35
- description: `Event branch is not reaced by any of the combinations during the tests.`,
36
- location: this.locationFinder.getLocationOfDefinition(location.scriptId, location.path)
37
- }));
38
- }
39
- runtimeErrors.forEach(error => output.addError(error));
40
- }
41
- prepareErrorLog(e, testDefinition, testCaseIndex, output) {
42
- if (e instanceof script_engine_lib_1.SimulationError) {
43
- let errorDescription = testDefinition.customMessage ? testDefinition.customMessage + '\n' + e.message : e.message;
44
- return {
45
- description: errorDescription,
46
- location: this.locationFinder.getLocationOfDefinition(e.location.scriptId, e.location.path)
47
- };
48
- }
49
- else if (e instanceof script_engine_lib_1.ActionsBeforeTestingError) {
50
- let errorDescription = testDefinition.customMessage ? testDefinition.customMessage + '\n' + e.message : e.message;
51
- let executedActionLocation = this.locationFinder.getLocationOfTestDefinition(testDefinition.testDefinitionRef, [
52
- 'cases',
53
- `${testCaseIndex}`,
54
- 'actionsBeforeTesting',
55
- `${e.actionIndex}`
56
- ]);
57
- return {
58
- description: errorDescription,
59
- location: executedActionLocation
60
- };
61
- }
62
- else if (e instanceof script_engine_lib_1.BranchingBeforeTestingError) {
63
- let testLocation = this.locationFinder.getLocationOfTestDefinition(testDefinition.testDefinitionRef, []);
64
- let executionHistoryAddition = `Running the test: ${output.convertLocationInFileToLink(testLocation)}\n\n`;
65
- let executionHistoryStart = e.message.indexOf('\n', e.message.indexOf('Execution history')) + 1;
66
- let fullMessage = e.message.slice(0, executionHistoryStart) + executionHistoryAddition + e.message.slice(executionHistoryStart);
67
- let errorDescription = testDefinition.customMessage ? testDefinition.customMessage + '\n' + fullMessage : fullMessage;
68
- return {
69
- description: errorDescription,
70
- location: this.locationFinder.getLocationOfDefinition(e.location.scriptId, e.location.path)
71
- };
72
- }
73
- else {
74
- throw e;
75
- }
76
- }
77
- }
78
- exports.ScriptTestingHelper = ScriptTestingHelper;
79
- //# sourceMappingURL=script-testing.helper.js.map
@@ -1,8 +0,0 @@
1
- import { ScriptEngineSimulatorFunctions } from 'script-engine-lib';
2
- export declare class ScriptSetup {
3
- private static _scriptSimulatorFunctionsConstructor;
4
- static get ScriptSimulatorFunctionsConstructor(): new (
5
- ...args: any[]
6
- ) => ScriptEngineSimulatorFunctions;
7
- static set(scriptSimulatorFunctionsConstructor: new (...args: any[]) => ScriptEngineSimulatorFunctions): void;
8
- }
@@ -1,16 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.ScriptSetup = void 0;
4
- class ScriptSetup {
5
- static get ScriptSimulatorFunctionsConstructor() {
6
- if (!this._scriptSimulatorFunctionsConstructor) {
7
- throw new Error('ScriptSimulatorFunctionsConstructor is not set');
8
- }
9
- return this._scriptSimulatorFunctionsConstructor;
10
- }
11
- static set(scriptSimulatorFunctionsConstructor) {
12
- this._scriptSimulatorFunctionsConstructor = scriptSimulatorFunctionsConstructor;
13
- }
14
- }
15
- exports.ScriptSetup = ScriptSetup;
16
- //# sourceMappingURL=script-setup.js.map
@@ -1,33 +0,0 @@
1
- import { ScriptEngineSimulatorFunctions } from 'script-engine-lib';
2
- import { CustomScriptTestDefinition, ScriptTestCasesDefinition, ScriptTestDefinition } from './helpers/script-testing.helper';
3
- export declare class ScriptTesting<ScriptInputType, EventInputType> {
4
- constructor(scriptSimulatorFunctionsConstructor: new (input: ScriptInputType) => ScriptEngineSimulatorFunctions, eventSimulatorFunctionsConstructor: new (input: EventInputType) => ScriptEngineSimulatorFunctions, richTextTags: Set<string> | undefined);
5
- setScriptInput(scriptId: string, input: ScriptInputType): void;
6
- setEventInput(eventId: string, input: EventInputType): void;
7
- addCustomScriptTestCase(customMessage: string, scriptId: string, testCase: ScriptTestCasesDefinition): void;
8
- addCustomEventTestCase(customMessage: string, eventId: string, testCase: ScriptTestCasesDefinition): void;
9
- }
10
- export declare class ScriptTestingInternal {
11
- private static _scriptSimulatorFunctionsConstructor;
12
- private static _eventSimulatorFunctionsConstructor;
13
- private static _scriptInputs;
14
- private static _eventInputs;
15
- private static _scriptTestCases;
16
- private static _eventTestCases;
17
- private static _richTextTags;
18
- static get scriptSimulatorFunctionsConstructor(): new (...args: unknown[]) => ScriptEngineSimulatorFunctions;
19
- static get eventSimulatorFunctionsConstructor(): new (...args: unknown[]) => ScriptEngineSimulatorFunctions;
20
- static get richTextTags(): Set<string> | undefined;
21
- static get isInitialized(): boolean;
22
- static setup(scriptSimulatorFunctionsConstructor: new (...args: unknown[]) => ScriptEngineSimulatorFunctions, eventSimulatorFunctionsConstructor: new (...args: unknown[]) => ScriptEngineSimulatorFunctions, richTextTags: Set<string> | undefined): void;
23
- static getScriptInput(scriptId: string): unknown;
24
- static getEventInput(eventId: string): unknown;
25
- static getCustomScriptTestCases(): CustomScriptTestDefinition[];
26
- static getCustomEventTestCases(): CustomScriptTestDefinition[];
27
- static isCustomScriptTestCase(testCase: ScriptTestDefinition): boolean;
28
- static isCustomEventTestCase(testCase: ScriptTestDefinition): boolean;
29
- static setScriptInput(scriptId: string, input: unknown): void;
30
- static setEventInput(eventId: string, input: unknown): void;
31
- static addCustomScriptTestCase(scriptId: string, testCase: ScriptTestCasesDefinition, customMessage: string): void;
32
- static addCustomEventTestCase(eventId: string, testCase: ScriptTestCasesDefinition, customMessage: string): void;
33
- }
@@ -1,97 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ScriptTestingInternal = exports.ScriptTesting = void 0;
4
- // Exposed to the user
5
- class ScriptTesting {
6
- constructor(scriptSimulatorFunctionsConstructor, eventSimulatorFunctionsConstructor, richTextTags) {
7
- ScriptTestingInternal.setup(scriptSimulatorFunctionsConstructor, eventSimulatorFunctionsConstructor, richTextTags);
8
- }
9
- setScriptInput(scriptId, input) {
10
- ScriptTestingInternal.setScriptInput(scriptId, input);
11
- }
12
- setEventInput(eventId, input) {
13
- ScriptTestingInternal.setEventInput(eventId, input);
14
- }
15
- addCustomScriptTestCase(customMessage, scriptId, testCase) {
16
- ScriptTestingInternal.addCustomScriptTestCase(scriptId, testCase, customMessage);
17
- }
18
- addCustomEventTestCase(customMessage, eventId, testCase) {
19
- ScriptTestingInternal.addCustomEventTestCase(eventId, testCase, customMessage);
20
- }
21
- }
22
- exports.ScriptTesting = ScriptTesting;
23
- class ScriptTestingInternal {
24
- static { this._scriptInputs = new Map(); }
25
- static { this._eventInputs = new Map(); }
26
- static { this._scriptTestCases = new Map(); }
27
- static { this._eventTestCases = new Map(); }
28
- static get scriptSimulatorFunctionsConstructor() {
29
- if (!this._scriptSimulatorFunctionsConstructor) {
30
- throw new Error('ScriptSimulatorFunctionsConstructor is not set');
31
- }
32
- return this._scriptSimulatorFunctionsConstructor;
33
- }
34
- static get eventSimulatorFunctionsConstructor() {
35
- if (!this._eventSimulatorFunctionsConstructor) {
36
- throw new Error('ScriptSimulatorFunctionsConstructor is not set');
37
- }
38
- return this._eventSimulatorFunctionsConstructor;
39
- }
40
- static get richTextTags() {
41
- return this._richTextTags;
42
- }
43
- static get isInitialized() {
44
- return (this._scriptSimulatorFunctionsConstructor && this._eventSimulatorFunctionsConstructor && this._richTextTags !== undefined);
45
- }
46
- static setup(scriptSimulatorFunctionsConstructor, eventSimulatorFunctionsConstructor, richTextTags) {
47
- this._scriptSimulatorFunctionsConstructor = scriptSimulatorFunctionsConstructor;
48
- this._eventSimulatorFunctionsConstructor = eventSimulatorFunctionsConstructor;
49
- this._richTextTags = richTextTags;
50
- }
51
- static getScriptInput(scriptId) {
52
- return this._scriptInputs.get(scriptId);
53
- }
54
- static getEventInput(eventId) {
55
- return this._eventInputs.get(eventId);
56
- }
57
- static getCustomScriptTestCases() {
58
- return Array.from(this._scriptTestCases.values());
59
- }
60
- static getCustomEventTestCases() {
61
- return Array.from(this._eventTestCases.values());
62
- }
63
- static isCustomScriptTestCase(testCase) {
64
- return this._scriptTestCases.has(testCase.script);
65
- }
66
- static isCustomEventTestCase(testCase) {
67
- return this._eventTestCases.has(testCase.script);
68
- }
69
- static setScriptInput(scriptId, input) {
70
- if (this._scriptInputs.has(scriptId)) {
71
- throw new Error(`Script input for ${scriptId} already set`);
72
- }
73
- this._scriptInputs.set(scriptId, input);
74
- }
75
- static setEventInput(eventId, input) {
76
- if (this._eventInputs.has(eventId)) {
77
- throw new Error(`Event input for ${eventId} already set`);
78
- }
79
- this._eventInputs.set(eventId, input);
80
- }
81
- static addCustomScriptTestCase(scriptId, testCase, customMessage) {
82
- let customTestDefinition = {
83
- testDefinition: { script: scriptId, cases: [testCase] },
84
- customMessage: `Prebuild Test Case:\n${customMessage}`
85
- };
86
- this._scriptTestCases.set(scriptId, customTestDefinition);
87
- }
88
- static addCustomEventTestCase(eventId, testCase, customMessage) {
89
- let customTestDefinition = {
90
- testDefinition: { script: eventId, cases: [testCase] },
91
- customMessage: `Prebuild Test Case:\n${customMessage}`
92
- };
93
- this._eventTestCases.set(eventId, customTestDefinition);
94
- }
95
- }
96
- exports.ScriptTestingInternal = ScriptTestingInternal;
97
- //# sourceMappingURL=scripting-setup.js.map
@@ -1,6 +0,0 @@
1
- import Joi from 'joi';
2
- export declare const ActionCommandSchema: () => Joi.Schema;
3
- export declare const BranchByConditionSchema: (scriptLinkName: string) => Joi.Schema;
4
- export declare const BranchByPlayerChoiceSchema: (scriptLinkName: string) => Joi.Schema;
5
- export declare const BranchByChanceSchema: (scriptLinkName: string) => Joi.Schema;
6
- export declare const DialogSchema: () => Joi.Schema;