definition-generator-framework 1.12.5 → 1.12.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/framework/definition-component.d.ts +11 -9
  2. package/dist/framework/definition-component.js +18 -18
  3. package/dist/framework/definition-generator.d.ts +6 -5
  4. package/dist/framework/definition-generator.js +16 -18
  5. package/dist/framework/file-content-generator/file-content-generator.js +1 -1
  6. package/dist/framework/file-content-generator/file-content-generator.test.js +49 -49
  7. package/dist/framework/framework.d.ts +14 -13
  8. package/dist/framework/framework.data.d.ts +3 -3
  9. package/dist/framework/framework.data.js +13 -7
  10. package/dist/framework/framework.js +36 -33
  11. package/dist/framework/framework.model.d.ts +15 -15
  12. package/dist/framework/framework.model.js +3 -3
  13. package/dist/helpers/common-functions/common-functions.js +1 -1
  14. package/dist/helpers/common-functions/common-functions.spec.js +48 -48
  15. package/dist/helpers/duplicate-helper/duplicate-helper.spec.js +52 -52
  16. package/dist/helpers/output-helper/output-helper.d.ts +26 -26
  17. package/dist/helpers/output-helper/output-helper.js +127 -107
  18. package/dist/helpers/output-helper/output-helper.spec.d.ts +22 -22
  19. package/dist/helpers/output-helper/output-helper.spec.js +223 -211
  20. package/dist/helpers/output-helper/output-helper.test.d.ts +22 -22
  21. package/dist/helpers/output-helper/output-helper.test.js +224 -212
  22. package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.js +133 -125
  23. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.d.ts +1 -1
  24. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.js +174 -156
  25. package/dist/helpers/validator/custom-validators/image.custom-validator.d.ts +6 -6
  26. package/dist/helpers/validator/custom-validators/image.custom-validator.js +40 -39
  27. package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.d.ts +4 -4
  28. package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.js +29 -29
  29. package/dist/helpers/validator/joi-custom-validators.spec.js +284 -240
  30. package/dist/helpers/validator/validator.spec.js +313 -303
  31. package/dist/pipeline/1-select-definitions-helper.d.ts +13 -13
  32. package/dist/pipeline/1-select-definitions-helper.js +68 -72
  33. package/dist/pipeline/1-select-definitions.helper.test.js +40 -40
  34. package/dist/pipeline/1-select-definitions.spec.js +131 -131
  35. package/dist/pipeline/2-structure-parser.helper.spec.js +266 -266
  36. package/dist/pipeline/parsers/array-parser.spec.js +116 -113
  37. package/dist/pipeline/parsers/object-parser.spec.js +159 -153
  38. package/dist/pipeline/parsers/primitive-parser.spec.js +67 -67
  39. package/dist/pre-made-components/assets/3-font.js +4 -4
  40. package/dist/pre-made-components/events/1-event.d.ts +1 -1
  41. package/dist/pre-made-components/events/1-event.js +157 -125
  42. package/dist/pre-made-components/events/2-event-test.d.ts +8 -8
  43. package/dist/pre-made-components/events/2-event-test.js +156 -119
  44. package/dist/pre-made-components/events/2-script-test.js +0 -1
  45. package/dist/pre-made-components/events/event-setup.d.ts +10 -5
  46. package/dist/pre-made-components/events/event-setup.js +15 -15
  47. package/dist/pre-made-components/events/script-setup.d.ts +5 -3
  48. package/dist/pre-made-components/events/script-setup.js +11 -11
  49. package/package.json +5 -10
@@ -1,79 +1,79 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const primitive_parser_1 = require("./primitive-parser");
4
- const _mocks_1 = require("../_mocks");
5
- const mocks_1 = require("../../_mocks/mocks");
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ const primitive_parser_1 = require('./primitive-parser');
4
+ const _mocks_1 = require('../_mocks');
5
+ const mocks_1 = require('../../_mocks/mocks');
6
6
  describe('PRIMITIVE PARSER', () => {
7
- test('primitive string', () => {
8
- let result = primitive_parser_1.PrimitiveParser.parse(['text'], mocks_1.SampleLocation1);
9
- expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('text', mocks_1.SampleLocation1));
10
- });
11
- test('primitive quoted string', () => {
12
- let result = primitive_parser_1.PrimitiveParser.parse(['"text with spaces"'], mocks_1.SampleLocation1);
13
- expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('text with spaces', mocks_1.SampleLocation1));
14
- });
15
- test('primitive multiline string', () => {
16
- let result = primitive_parser_1.PrimitiveParser.parse(['`', 'text text', 'text', '`'], mocks_1.SampleLocation1);
17
- expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('text text\ntext', mocks_1.SampleLocation1));
18
- });
19
- test('primitive number', () => {
20
- let result = primitive_parser_1.PrimitiveParser.parse(['123.123'], mocks_1.SampleLocation1);
21
- expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('123.123', mocks_1.SampleLocation1));
22
- });
23
- test('primitive undefined', () => {
24
- let result = primitive_parser_1.PrimitiveParser.parse(['undefined'], mocks_1.SampleLocation1);
25
- expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)(undefined, mocks_1.SampleLocation1));
26
- });
7
+ test('primitive string', () => {
8
+ let result = primitive_parser_1.PrimitiveParser.parse(['text'], mocks_1.SampleLocation1);
9
+ expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('text', mocks_1.SampleLocation1));
10
+ });
11
+ test('primitive quoted string', () => {
12
+ let result = primitive_parser_1.PrimitiveParser.parse(['"text with spaces"'], mocks_1.SampleLocation1);
13
+ expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('text with spaces', mocks_1.SampleLocation1));
14
+ });
15
+ test('primitive multiline string', () => {
16
+ let result = primitive_parser_1.PrimitiveParser.parse(['`', 'text text', 'text', '`'], mocks_1.SampleLocation1);
17
+ expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('text text\ntext', mocks_1.SampleLocation1));
18
+ });
19
+ test('primitive number', () => {
20
+ let result = primitive_parser_1.PrimitiveParser.parse(['123.123'], mocks_1.SampleLocation1);
21
+ expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('123.123', mocks_1.SampleLocation1));
22
+ });
23
+ test('primitive undefined', () => {
24
+ let result = primitive_parser_1.PrimitiveParser.parse(['undefined'], mocks_1.SampleLocation1);
25
+ expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)(undefined, mocks_1.SampleLocation1));
26
+ });
27
27
  });
28
28
  describe('PRIMITIVE PARSER - Error Detection', () => {
29
- let expectErrorHelper = new _mocks_1.ExpectErrorHelper(primitive_parser_1.PrimitiveParser);
30
- test.each([' text', 'some text'])('primitive with space "%s"', (item) => {
31
- expectErrorHelper.expect([item], {
32
- description: `Unexpected space! "${item}"`,
33
- location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
34
- });
29
+ let expectErrorHelper = new _mocks_1.ExpectErrorHelper(primitive_parser_1.PrimitiveParser);
30
+ test.each([' text', 'some text'])('primitive with space "%s"', item => {
31
+ expectErrorHelper.expect([item], {
32
+ description: `Unexpected space! "${item}"`,
33
+ location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
35
34
  });
36
- test('not closed quote string', () => {
37
- expectErrorHelper.expect(['"some text'], {
38
- description: 'Quote is not get closed!',
39
- location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
40
- });
35
+ });
36
+ test('not closed quote string', () => {
37
+ expectErrorHelper.expect(['"some text'], {
38
+ description: 'Quote is not get closed!',
39
+ location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
41
40
  });
42
- test('invalid quote text', () => {
43
- expectErrorHelper.expect(['"some "text"'], {
44
- description: 'There should be only one opening and one closeing quote!',
45
- location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
46
- });
41
+ });
42
+ test('invalid quote text', () => {
43
+ expectErrorHelper.expect(['"some "text"'], {
44
+ description: 'There should be only one opening and one closeing quote!',
45
+ location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
47
46
  });
48
- test('multiline primitive', () => {
49
- expectErrorHelper.expect(['text', 'secondRow'], {
50
- description: 'Invalid row! "secondRow"',
51
- location: { line: mocks_1.SampleLocation1.line + 2, path: mocks_1.SampleLocation1.path }
52
- });
47
+ });
48
+ test('multiline primitive', () => {
49
+ expectErrorHelper.expect(['text', 'secondRow'], {
50
+ description: 'Invalid row! "secondRow"',
51
+ location: { line: mocks_1.SampleLocation1.line + 2, path: mocks_1.SampleLocation1.path }
53
52
  });
54
- test('multiline string no character after backtick - openning', () => {
55
- expectErrorHelper.expect(['`test', 'something'], {
56
- description: 'There should be new line after backtick "`test"!',
57
- location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
58
- });
53
+ });
54
+ test('multiline string no character after backtick - openning', () => {
55
+ expectErrorHelper.expect(['`test', 'something'], {
56
+ description: 'There should be new line after backtick "`test"!',
57
+ location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
59
58
  });
60
- test('multiline string no character after backtick - closing', () => {
61
- expectErrorHelper.expect(['`', 'test', '`,'], {
62
- description: 'There should be new line after backtick "`,"!',
63
- location: { line: mocks_1.SampleLocation1.line + 3, path: mocks_1.SampleLocation1.path }
64
- });
59
+ });
60
+ test('multiline string no character after backtick - closing', () => {
61
+ expectErrorHelper.expect(['`', 'test', '`,'], {
62
+ description: 'There should be new line after backtick "`,"!',
63
+ location: { line: mocks_1.SampleLocation1.line + 3, path: mocks_1.SampleLocation1.path }
65
64
  });
66
- test('multiline string should end with backtick', () => {
67
- expectErrorHelper.expect(['`', 'test`'], {
68
- description: 'Multiline string should end with backtick in new line "test`"!',
69
- location: { line: mocks_1.SampleLocation1.line + 2, path: mocks_1.SampleLocation1.path }
70
- });
65
+ });
66
+ test('multiline string should end with backtick', () => {
67
+ expectErrorHelper.expect(['`', 'test`'], {
68
+ description: 'Multiline string should end with backtick in new line "test`"!',
69
+ location: { line: mocks_1.SampleLocation1.line + 2, path: mocks_1.SampleLocation1.path }
71
70
  });
72
- test('multiline string should end with backtick in the same coding indent', () => {
73
- expectErrorHelper.expect(['`', 'test', ' `'], {
74
- description: 'Invalid coding indent!',
75
- location: { line: mocks_1.SampleLocation1.line + 3, path: mocks_1.SampleLocation1.path }
76
- });
71
+ });
72
+ test('multiline string should end with backtick in the same coding indent', () => {
73
+ expectErrorHelper.expect(['`', 'test', ' `'], {
74
+ description: 'Invalid coding indent!',
75
+ location: { line: mocks_1.SampleLocation1.line + 3, path: mocks_1.SampleLocation1.path }
77
76
  });
77
+ });
78
78
  });
79
- //# sourceMappingURL=primitive-parser.spec.js.map
79
+ //# sourceMappingURL=primitive-parser.spec.js.map
@@ -17,10 +17,10 @@ const helpers_lib_1 = require("helpers-lib");
17
17
  const joi_1 = __importDefault(require("joi"));
18
18
  const definition_component_1 = require("../../decorators/definition-component");
19
19
  const index_file_generator_1 = require("../../framework/index-file-generator/index-file-generator");
20
- const INDEX_ENTRY = `
21
- export interface FontDefinition {
22
- readonly id: string;
23
- readonly fontFamily: string;
20
+ const INDEX_ENTRY = `
21
+ export interface FontDefinition {
22
+ readonly id: string;
23
+ readonly fontFamily: string;
24
24
  }`;
25
25
  let FontComponent = class FontComponent extends definition_component_1.DefinitionComponent {
26
26
  constructor() {
@@ -2,5 +2,5 @@ import { ScriptDefinition } from 'script-engine-lib';
2
2
  import { DefinitionComponent } from '../../decorators/definition-component';
3
3
  import { Output } from '../../framework/interfaces';
4
4
  export declare class EventComponent extends DefinitionComponent<ScriptDefinition> {
5
- process(definitions: ScriptDefinition[], output: Output): Promise<void>;
5
+ process(definitions: ScriptDefinition[], output: Output): Promise<void>;
6
6
  }
@@ -1,174 +1,206 @@
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;
1
+ 'use strict';
2
+ var __decorate =
3
+ (this && this.__decorate) ||
4
+ function (decorators, target, key, desc) {
5
+ var c = arguments.length,
6
+ r = c < 3 ? target : desc === null ? (desc = Object.getOwnPropertyDescriptor(target, key)) : desc,
7
+ d;
8
+ if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function')
9
+ r = Reflect.decorate(decorators, target, key, desc);
10
+ else
11
+ for (var i = decorators.length - 1; i >= 0; i--)
12
+ if ((d = decorators[i])) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
13
  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 });
14
+ };
15
+ var __importDefault =
16
+ (this && this.__importDefault) ||
17
+ function (mod) {
18
+ return mod && mod.__esModule ? mod : { default: mod };
19
+ };
20
+ Object.defineProperty(exports, '__esModule', { value: true });
12
21
  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 quotes_to_tags_helper_1 = require("./helpers/quotes-to-tags.helper");
22
+ const helpers_lib_1 = require('helpers-lib');
23
+ const joi_1 = __importDefault(require('joi'));
24
+ const definition_component_1 = require('../../decorators/definition-component');
25
+ const quotes_to_tags_helper_1 = require('./helpers/quotes-to-tags.helper');
17
26
  // ---- Conditions ----
18
- const ActionCommandSchema = () => joi_1.default.string().custom(value => ({
27
+ const ActionCommandSchema = () =>
28
+ joi_1.default.string().custom(value => ({
19
29
  type: 'command',
20
30
  value: value
21
- }));
31
+ }));
22
32
  // ---- Branches ----
23
- const JumpToSchema = joi_1.default.object()
24
- .keys({
33
+ const JumpToSchema = joi_1.default
34
+ .object()
35
+ .keys({
25
36
  jumpTo: joi_1.default.string().lazyReference('EVENT').required()
26
- })
27
- .custom(value => ({
37
+ })
38
+ .custom(value => ({
28
39
  type: 'jumpTo',
29
40
  value: value.jumpTo
30
- }));
31
- const BranchByConditionSchema = joi_1.default.object()
32
- .keys({
33
- branchByCondition: joi_1.default.array()
34
- .items(joi_1.default.object().keys({
35
- condition: joi_1.default.string().optional(),
36
- actions: joi_1.default.link('#EventActionsSchema').default([]).optional()
37
- }))
38
- .custom((array, helpers) => {
41
+ }));
42
+ const BranchByConditionSchema = joi_1.default
43
+ .object()
44
+ .keys({
45
+ branchByCondition: joi_1.default
46
+ .array()
47
+ .items(
48
+ joi_1.default.object().keys({
49
+ condition: joi_1.default.string().optional(),
50
+ actions: joi_1.default.link('#EventActionsSchema').default([]).optional()
51
+ })
52
+ )
53
+ .custom((array, helpers) => {
39
54
  let length = array.length;
40
55
  if (length > 1) {
41
- for (let i = 0; i < length - 1; i++) {
42
- if (array[i].condition === undefined) {
43
- throw new Error(`Element at index ${i} must have "condition"`);
44
- }
45
- }
46
- }
47
- else if (length === 1) {
48
- if (array[0].condition === undefined) {
49
- throw new Error('Single element must have "condition"');
56
+ for (let i = 0; i < length - 1; i++) {
57
+ if (array[i].condition === undefined) {
58
+ throw new Error(`Element at index ${i} must have "condition"`);
50
59
  }
60
+ }
61
+ } else if (length === 1) {
62
+ if (array[0].condition === undefined) {
63
+ throw new Error('Single element must have "condition"');
64
+ }
51
65
  }
52
66
  return array;
53
- })
54
- })
55
- .custom(value => ({
67
+ })
68
+ })
69
+ .custom(value => ({
56
70
  type: 'branchByCondition',
57
71
  value: value.branchByCondition
58
- }));
59
- const BranchByPlayerChoiceSchema = joi_1.default.object()
60
- .keys({
61
- branchByPlayerChoice: joi_1.default.array().items(joi_1.default.object().keys({
72
+ }));
73
+ const BranchByPlayerChoiceSchema = joi_1.default
74
+ .object()
75
+ .keys({
76
+ branchByPlayerChoice: joi_1.default.array().items(
77
+ joi_1.default.object().keys({
62
78
  text: joi_1.default.string().min(2).required(),
63
79
  condition: joi_1.default.string().optional(),
64
80
  actions: joi_1.default.link('#EventActionsSchema').default([]).optional()
65
- }))
66
- })
67
- .custom(value => ({
81
+ })
82
+ )
83
+ })
84
+ .custom(value => ({
68
85
  type: 'branchByPlayerChoice',
69
86
  value: value.branchByPlayerChoice
70
- }));
71
- const BranchByChanceSchema = joi_1.default.object()
72
- .keys({
73
- branchByChance: joi_1.default.array().items(joi_1.default.object().keys({
87
+ }));
88
+ const BranchByChanceSchema = joi_1.default
89
+ .object()
90
+ .keys({
91
+ branchByChance: joi_1.default.array().items(
92
+ joi_1.default.object().keys({
74
93
  label: joi_1.default.string().required(),
75
94
  weight: joi_1.default.number().integer().min(1).max(100).required(),
76
95
  condition: joi_1.default.string().optional(),
77
96
  actions: joi_1.default.link('#EventActionsSchema').default([]).optional()
78
- }))
79
- })
80
- .custom(value => ({
97
+ })
98
+ )
99
+ })
100
+ .custom(value => ({
81
101
  type: 'branchByChance',
82
102
  value: value.branchByChance
83
- }));
103
+ }));
84
104
  // ---- Dialog ----
85
- const DialogSchema = joi_1.default.object()
86
- .min(1)
87
- .max(1)
88
- .custom(value => {
105
+ const DialogSchema = joi_1.default
106
+ .object()
107
+ .min(1)
108
+ .max(1)
109
+ .custom(value => {
89
110
  let keys = Object.keys(value);
90
111
  if (keys.length !== 1) {
91
- throw new Error('object must have exactly one key/value pair');
112
+ throw new Error('object must have exactly one key/value pair');
92
113
  }
93
114
  let key = keys[0];
94
115
  let text = value[key];
95
116
  if (typeof text !== 'string') {
96
- throw new Error('value must be a string');
117
+ throw new Error('value must be a string');
97
118
  }
98
119
  text = quotes_to_tags_helper_1.QuotesToTagsHelper.convert(text);
99
120
  return { type: 'dialog', value: { text, speaker: key } };
100
- });
121
+ });
101
122
  // ---- Main Schema ----
102
- const ActionsSchema = () => joi_1.default.array()
103
- .items(joi_1.default.alternatives()
104
- .conditional(joi_1.default.string(), {
105
- then: ActionCommandSchema()
106
- })
107
- .conditional(joi_1.default.object({ jumpTo: joi_1.default.exist() }).unknown(), {
108
- then: JumpToSchema
109
- })
110
- .conditional(joi_1.default.object({ branchByChance: joi_1.default.exist() }).unknown(), {
111
- then: BranchByChanceSchema
112
- })
113
- .conditional(joi_1.default.object({ branchByCondition: joi_1.default.exist() }).unknown(), {
114
- then: BranchByConditionSchema
115
- })
116
- .conditional(joi_1.default.object({ branchByPlayerChoice: joi_1.default.exist() }).unknown(), {
117
- then: BranchByPlayerChoiceSchema
118
- })
119
- .conditional(joi_1.default.object().min(1).max(1).unknown(), {
120
- then: DialogSchema
121
- })
122
- .error(errors => errors.map(error => {
123
- if (error.code === 'alternatives.any') {
124
- let allowedTypes = 'command, jumpTo, branchByCondition, branchByPlayerChoice, branchByChance';
125
- error.message = `${error.local.label} does not match any of the allowed types: ${allowedTypes}`;
126
- }
127
- return error;
128
- })))
129
- .custom((array) => {
130
- let commandFoundAfterBranching = false;
131
- let emptyStackRequiresBranchingFound = false;
132
- array.forEach(action => {
123
+ const ActionsSchema = () =>
124
+ joi_1.default
125
+ .array()
126
+ .items(
127
+ joi_1.default
128
+ .alternatives()
129
+ .conditional(joi_1.default.string(), {
130
+ then: ActionCommandSchema()
131
+ })
132
+ .conditional(joi_1.default.object({ jumpTo: joi_1.default.exist() }).unknown(), {
133
+ then: JumpToSchema
134
+ })
135
+ .conditional(joi_1.default.object({ branchByChance: joi_1.default.exist() }).unknown(), {
136
+ then: BranchByChanceSchema
137
+ })
138
+ .conditional(joi_1.default.object({ branchByCondition: joi_1.default.exist() }).unknown(), {
139
+ then: BranchByConditionSchema
140
+ })
141
+ .conditional(joi_1.default.object({ branchByPlayerChoice: joi_1.default.exist() }).unknown(), {
142
+ then: BranchByPlayerChoiceSchema
143
+ })
144
+ .conditional(joi_1.default.object().min(1).max(1).unknown(), {
145
+ then: DialogSchema
146
+ })
147
+ .error(errors =>
148
+ errors.map(error => {
149
+ if (error.code === 'alternatives.any') {
150
+ let allowedTypes = 'command, jumpTo, branchByCondition, branchByPlayerChoice, branchByChance';
151
+ error.message = `${error.local.label} does not match any of the allowed types: ${allowedTypes}`;
152
+ }
153
+ return error;
154
+ })
155
+ )
156
+ )
157
+ .custom(array => {
158
+ let commandFoundAfterBranching = false;
159
+ let emptyStackRequiresBranchingFound = false;
160
+ array.forEach(action => {
133
161
  if (emptyStackRequiresBranchingFound) {
134
- commandFoundAfterBranching = true;
135
- }
136
- else if (action.type === 'branchByCondition' ||
137
- action.type === 'branchByPlayerChoice' ||
138
- action.type === 'branchByChance') {
139
- emptyStackRequiresBranchingFound = true;
162
+ commandFoundAfterBranching = true;
163
+ } else if (
164
+ action.type === 'branchByCondition' ||
165
+ action.type === 'branchByPlayerChoice' ||
166
+ action.type === 'branchByChance'
167
+ ) {
168
+ emptyStackRequiresBranchingFound = true;
140
169
  }
141
- });
142
- if (commandFoundAfterBranching) {
170
+ });
171
+ if (commandFoundAfterBranching) {
143
172
  throw new Error('There should not be any command after branching.');
144
- }
145
- else {
173
+ } else {
146
174
  return array;
147
- }
148
- })
175
+ }
176
+ })
149
177
  .id('EventActionsSchema');
150
178
  let EventComponent = class EventComponent extends definition_component_1.DefinitionComponent {
151
- async process(definitions, output) {
152
- await output.addFile({
153
- path: '/_premade/events/events.ts',
154
- preText: `import { ScriptDefinition } from "script-engine-lib";`,
155
- variableName: 'EventDefinitions',
156
- variableType: 'Readonly<Record<string, ScriptDefinition>>',
157
- variable: helpers_lib_1.JsonHelper.arrayToObject(definitions, 'id')
158
- });
159
- }
179
+ async process(definitions, output) {
180
+ await output.addFile({
181
+ path: '/_premade/events/events.ts',
182
+ preText: `import { ScriptDefinition } from "script-engine-lib";`,
183
+ variableName: 'EventDefinitions',
184
+ variableType: 'Readonly<Record<string, ScriptDefinition>>',
185
+ variable: helpers_lib_1.JsonHelper.arrayToObject(definitions, 'id')
186
+ });
187
+ }
160
188
  };
161
189
  exports.EventComponent = EventComponent;
162
- exports.EventComponent = EventComponent = __decorate([
190
+ exports.EventComponent = EventComponent = __decorate(
191
+ [
163
192
  (0, definition_component_1.DefinitionComponentDecorator)({
164
- componentName: 'EVENT',
165
- keyName: 'id',
166
- validationSchema: joi_1.default.object()
167
- .keys({
168
- id: joi_1.default.string().required(),
169
- actions: ActionsSchema().min(1).required()
193
+ componentName: 'EVENT',
194
+ keyName: 'id',
195
+ validationSchema: joi_1.default
196
+ .object()
197
+ .keys({
198
+ id: joi_1.default.string().required(),
199
+ actions: ActionsSchema().min(1).required()
170
200
  })
171
- .required()
201
+ .required()
172
202
  })
173
- ], EventComponent);
174
- //# sourceMappingURL=1-event.js.map
203
+ ],
204
+ EventComponent
205
+ );
206
+ //# sourceMappingURL=1-event.js.map
@@ -2,17 +2,17 @@ import { ScriptTestActionDefinition } from 'script-engine-lib';
2
2
  import { DefinitionComponent } from '../../decorators/definition-component';
3
3
  import { Output } from '../../framework/interfaces';
4
4
  interface EventTestCasesDefinition {
5
- readonly actionsBeforeTesting: readonly ScriptTestActionDefinition[];
5
+ readonly actionsBeforeTesting: readonly ScriptTestActionDefinition[];
6
6
  }
7
7
  interface EventTestDefinition {
8
- readonly event: string;
9
- readonly cases: readonly EventTestCasesDefinition[];
8
+ readonly event: string;
9
+ readonly cases: readonly EventTestCasesDefinition[];
10
10
  }
11
11
  export declare class EventTestComponent extends DefinitionComponent<EventTestDefinition> {
12
- process(definitions: EventTestDefinition[], output: Output): Promise<void>;
13
- private createEventTestSimulator;
14
- private runTests;
15
- private prepareErrorLog;
16
- private printErrors;
12
+ process(definitions: EventTestDefinition[], output: Output): Promise<void>;
13
+ private createEventTestSimulator;
14
+ private runTests;
15
+ private prepareErrorLog;
16
+ private printErrors;
17
17
  }
18
18
  export {};