dyo-tools 0.1.0 → 0.3.0

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 (184) hide show
  1. package/.c8rc.json +4 -0
  2. package/.eslintignore +2 -0
  3. package/.eslintrc.json +47 -0
  4. package/Makefile +34 -0
  5. package/README.md +0 -7
  6. package/babel.config.js +1 -0
  7. package/cucumber-report.html +48 -0
  8. package/dist/constants.d.ts +6 -0
  9. package/dist/constants.js +63 -0
  10. package/dist/constants.js.map +1 -0
  11. package/dist/core/DTAction.d.ts +10 -0
  12. package/dist/core/DTAction.js +24 -0
  13. package/dist/core/DTAction.js.map +1 -0
  14. package/dist/core/DTBunch.d.ts +12 -17
  15. package/dist/core/DTBunch.js +39 -115
  16. package/dist/core/DTBunch.js.map +1 -1
  17. package/dist/core/DTComponent.d.ts +13 -5
  18. package/dist/core/DTComponent.js +39 -1
  19. package/dist/core/DTComponent.js.map +1 -1
  20. package/dist/core/DTComponentPhysical.d.ts +12 -0
  21. package/dist/core/DTComponentPhysical.js +22 -0
  22. package/dist/core/DTComponentPhysical.js.map +1 -0
  23. package/dist/core/DTComponentWithMeta.d.ts +2 -2
  24. package/dist/core/DTComponentWithMeta.js.map +1 -1
  25. package/dist/core/DTElement.d.ts +7 -7
  26. package/dist/core/DTElement.js +12 -11
  27. package/dist/core/DTElement.js.map +1 -1
  28. package/dist/core/DTManager.d.ts +33 -0
  29. package/dist/core/DTManager.js +190 -0
  30. package/dist/core/DTManager.js.map +1 -0
  31. package/dist/core/DTMaster.d.ts +24 -0
  32. package/dist/core/DTMaster.js +133 -0
  33. package/dist/core/DTMaster.js.map +1 -0
  34. package/dist/core/DTModule.d.ts +14 -0
  35. package/dist/core/DTModule.js +39 -0
  36. package/dist/core/DTModule.js.map +1 -0
  37. package/dist/index.d.ts +7 -1
  38. package/dist/index.js +15 -3
  39. package/dist/index.js.map +1 -1
  40. package/dist/libs/DYOFinder.d.ts +10 -0
  41. package/dist/libs/DYOFinder.js +96 -0
  42. package/dist/libs/DYOFinder.js.map +1 -0
  43. package/dist/libs/player/DTPlayer.element.d.ts +5 -0
  44. package/dist/libs/player/DTPlayer.element.js +11 -0
  45. package/dist/libs/player/DTPlayer.element.js.map +1 -0
  46. package/dist/libs/player/DTPlayer.manager.d.ts +11 -0
  47. package/dist/libs/player/DTPlayer.manager.js +42 -0
  48. package/dist/libs/player/DTPlayer.manager.js.map +1 -0
  49. package/dist/tsconfig.tsbuildinfo +1 -1321
  50. package/dist/types/core.d.ts +103 -0
  51. package/dist/types/core.js +15 -0
  52. package/dist/types/core.js.map +1 -0
  53. package/dist/types/index.d.ts +2 -58
  54. package/dist/types/index.js +16 -12
  55. package/dist/types/index.js.map +1 -1
  56. package/dist/types/player.d.ts +5 -0
  57. package/dist/types/player.js +3 -0
  58. package/dist/types/player.js.map +1 -0
  59. package/docs/.nojekyll +1 -0
  60. package/docs/assets/highlight.css +29 -0
  61. package/docs/assets/main.js +59 -0
  62. package/docs/assets/navigation.js +1 -0
  63. package/docs/assets/search.js +1 -0
  64. package/docs/assets/style.css +1414 -0
  65. package/docs/classes/core_DTAction.DYOToolsAction.html +89 -0
  66. package/docs/classes/core_DTBunch.DYOToolsBunch.html +254 -0
  67. package/docs/classes/core_DTComponent.DYOToolsComponent.html +76 -0
  68. package/docs/classes/core_DTComponentPhysical.DYOToolsComponentPhysical.html +110 -0
  69. package/docs/classes/core_DTComponentWithMeta.DYOToolsComponentWithMeta.html +96 -0
  70. package/docs/classes/core_DTElement.DYOToolsElement.html +135 -0
  71. package/docs/classes/core_DTError.DYOToolsError.html +37 -0
  72. package/docs/classes/core_DTManager.DYOToolsManager.html +237 -0
  73. package/docs/classes/core_DTMaster.DYOToolsMaster.html +150 -0
  74. package/docs/classes/core_DTModule.DYOToolsModule.html +92 -0
  75. package/docs/classes/libs_DYOFinder.DYOFinder.html +34 -0
  76. package/docs/classes/libs_player_DTPlayer_element.DYOToolsPlayer.html +134 -0
  77. package/docs/classes/libs_player_DTPlayer_manager.DYOToolsPlayerManager.html +243 -0
  78. package/docs/enums/types_core.FilterOperatorType.html +10 -0
  79. package/docs/hierarchy.html +1 -0
  80. package/docs/index.html +1 -0
  81. package/docs/interfaces/types_core.DTBunchFilters.html +6 -0
  82. package/docs/interfaces/types_core.DTBunchOptions.html +19 -0
  83. package/docs/interfaces/types_core.DTBunchToObject.html +7 -0
  84. package/docs/interfaces/types_core.DTComponentOptions.html +5 -0
  85. package/docs/interfaces/types_core.DTComponentToObject.html +4 -0
  86. package/docs/interfaces/types_core.DTElementToObject.html +7 -0
  87. package/docs/interfaces/types_core.DTManagerFilters.html +6 -0
  88. package/docs/interfaces/types_core.DTManagerOptions.html +8 -0
  89. package/docs/interfaces/types_core.DTManagerToObject.html +5 -0
  90. package/docs/interfaces/types_core.DTMasterToObject.html +8 -0
  91. package/docs/interfaces/types_core.DTModuleToObject.html +6 -0
  92. package/docs/interfaces/types_core.DYOFinderConfigurationPropDefault.html +4 -0
  93. package/docs/interfaces/types_core.DYOFinderConfigurationPropObjectSearch.html +4 -0
  94. package/docs/interfaces/types_core.DYOFinderFilterOperatorAdvanced.html +5 -0
  95. package/docs/interfaces/types_core.DYOFinderFilterOperatorBase.html +5 -0
  96. package/docs/interfaces/types_player.DTPlayerManagerSimpleConfiguration.html +3 -0
  97. package/docs/modules/constants.html +6 -0
  98. package/docs/modules/core_DTAction.html +2 -0
  99. package/docs/modules/core_DTBunch.html +2 -0
  100. package/docs/modules/core_DTComponent.html +2 -0
  101. package/docs/modules/core_DTComponentPhysical.html +2 -0
  102. package/docs/modules/core_DTComponentWithMeta.html +2 -0
  103. package/docs/modules/core_DTElement.html +2 -0
  104. package/docs/modules/core_DTError.html +2 -0
  105. package/docs/modules/core_DTManager.html +2 -0
  106. package/docs/modules/core_DTMaster.html +2 -0
  107. package/docs/modules/core_DTModule.html +2 -0
  108. package/docs/modules/libs_DYOFinder.html +2 -0
  109. package/docs/modules/libs_player_DTPlayer_element.html +2 -0
  110. package/docs/modules/libs_player_DTPlayer_manager.html +2 -0
  111. package/docs/modules/types.html +29 -0
  112. package/docs/modules/types_core.html +28 -0
  113. package/docs/modules/types_player.html +2 -0
  114. package/docs/types/types_core.DTAcceptedMetaData.html +2 -0
  115. package/docs/types/types_core.DTManagerItemType.html +1 -0
  116. package/docs/types/types_core.DTManagerItemsType.html +2 -0
  117. package/docs/types/types_core.DYOFinderComponentType.html +1 -0
  118. package/docs/types/types_core.DYOFinderConfiguration.html +2 -0
  119. package/docs/types/types_core.DYOFinderConfigurationProp.html +1 -0
  120. package/docs/types/types_core.DYOFinderFilterOperator.html +1 -0
  121. package/docs/types/types_core.DYOFinderFilterOperatorArgument.html +1 -0
  122. package/docs/types/types_core.DYOFinderFilters.html +1 -0
  123. package/docs/types/types_core.StandardPrimitiveType.html +2 -0
  124. package/docs/types/types_core.StandardPrimitiveTypeWithArray.html +1 -0
  125. package/docs/variables/constants.bunchDefaultOptions.html +2 -0
  126. package/docs/variables/constants.componentBunchDefaultFinderConfiguration.html +1 -0
  127. package/docs/variables/constants.componentManagerDefaultFinderConfiguration.html +1 -0
  128. package/docs/variables/constants.componentPhysicalDefaultFinderConfiguration.html +1 -0
  129. package/docs/variables/constants.managerDefaultOptions.html +2 -0
  130. package/jest.config.js +6 -0
  131. package/package.json +32 -23
  132. package/src/constants.ts +85 -0
  133. package/src/core/DTAction.ts +52 -0
  134. package/src/core/DTBunch.ts +467 -0
  135. package/src/core/DTComponent.ts +225 -0
  136. package/src/core/DTComponentPhysical.ts +53 -0
  137. package/src/core/DTComponentWithMeta.ts +65 -0
  138. package/src/core/DTElement.ts +102 -0
  139. package/src/core/DTError.ts +78 -0
  140. package/src/core/DTManager.ts +465 -0
  141. package/src/core/DTMaster.ts +318 -0
  142. package/src/core/DTModule.ts +90 -0
  143. package/src/index.ts +17 -0
  144. package/src/libs/DYOFinder.ts +175 -0
  145. package/src/libs/player/DTPlayer.element.ts +9 -0
  146. package/src/libs/player/DTPlayer.manager.ts +84 -0
  147. package/src/types/core.ts +169 -0
  148. package/src/types/index.ts +2 -0
  149. package/src/types/player.ts +6 -0
  150. package/test/core/DTAction.double.ts +78 -0
  151. package/test/core/DTAction.spec.ts +76 -0
  152. package/test/core/DTBunch.double.ts +261 -0
  153. package/test/core/DTBunch.spec.ts +897 -0
  154. package/test/core/DTComponent.double.ts +164 -0
  155. package/test/core/DTComponent.spec.ts +295 -0
  156. package/test/core/DTComponentPhysical.double.ts +76 -0
  157. package/test/core/DTComponentPhysical.spec.ts +78 -0
  158. package/test/core/DTComponentWithMeta.double.ts +115 -0
  159. package/test/core/DTComponentWithMeta.spec.ts +124 -0
  160. package/test/core/DTElement.double.ts +163 -0
  161. package/test/core/DTElement.spec.ts +146 -0
  162. package/test/core/DTError.double.ts +92 -0
  163. package/test/core/DTError.spec.ts +89 -0
  164. package/test/core/DTManager.double.ts +216 -0
  165. package/test/core/DTManager.spec.ts +965 -0
  166. package/test/core/DTMaster.double.ts +141 -0
  167. package/test/core/DTMaster.spec.ts +584 -0
  168. package/test/core/DTModule.double.ts +80 -0
  169. package/test/core/DTModule.spec.ts +138 -0
  170. package/test/core/copy.spec.ts +243 -0
  171. package/test/libs/DYOFinder.double.ts +152 -0
  172. package/test/libs/DYOFinder.spec.ts +194 -0
  173. package/test/libs/player/DTPlayer.element.double.ts +55 -0
  174. package/test/libs/player/DTPlayer.element.spec.ts +28 -0
  175. package/test/libs/player/DTPlayer.manager.double.ts +92 -0
  176. package/test/libs/player/DTPlayer.manager.spec.ts +178 -0
  177. package/tsconfig.dev.json +22 -0
  178. package/tsconfig.json +21 -0
  179. package/dist/core/DTPlayer.d.ts +0 -8
  180. package/dist/core/DTPlayer.js +0 -30
  181. package/dist/core/DTPlayer.js.map +0 -1
  182. package/dist/utils/filters.d.ts +0 -6
  183. package/dist/utils/filters.js +0 -39
  184. package/dist/utils/filters.js.map +0 -1
@@ -0,0 +1,89 @@
1
+ import {afterEach, beforeEach, describe, expect, jest, test,} from '@jest/globals';
2
+ import {CodeTest, DTErrorTest, MessageTest, TimestampTest,} from './DTError.double';
3
+ import {DTComponentStub, IDTest as ComponentIdTest} from './DTComponent.double';
4
+
5
+ /************************* TESTS SUITES *******************************/
6
+ describe('class DYOToolsError', () => {
7
+ let errorTest: DTErrorTest;
8
+
9
+ beforeEach(() => {
10
+ errorTest = new DTErrorTest(CodeTest, MessageTest);
11
+ });
12
+
13
+ afterEach(() => {
14
+ jest.resetAllMocks();
15
+ });
16
+
17
+ describe('constructor()', () => {
18
+ test('creation with standard field (code, message and timestamp)', () => {
19
+ const newError = new DTErrorTest(CodeTest, MessageTest);
20
+ const currentDate = new Date();
21
+
22
+ expect(newError.th_get_code()).toBe(CodeTest);
23
+ expect(newError.th_get_message()).toBe(MessageTest);
24
+ expect(newError.th_get_timestamp().toDateString()).toBe(currentDate.toDateString());
25
+ expect(newError.th_get_timestamp().toTimeString()).toBe(currentDate.toTimeString());
26
+ expect(newError.th_get_initiator()).toBeUndefined();
27
+ expect(newError.th_get_convicted()).toBeUndefined();
28
+ });
29
+
30
+ test('creation with initiator component', () => {
31
+ const initiatorMock = new DTComponentStub('initiator');
32
+ const newError = new DTErrorTest(CodeTest, MessageTest, initiatorMock);
33
+
34
+ expect(newError.th_get_initiator().getId()).toBe(`${ComponentIdTest}-initiator`);
35
+ });
36
+
37
+ test('creation with initiator and convicted component', () => {
38
+ const initiatorMock = new DTComponentStub('initiator');
39
+ const convictedMock = new DTComponentStub('convicted');
40
+ const newError = new DTErrorTest(CodeTest, MessageTest, initiatorMock, convictedMock);
41
+
42
+ expect(newError.th_get_convicted().getId()).toBe(`${ComponentIdTest}-convicted`);
43
+ });
44
+ });
45
+
46
+ describe('getCode()', () => {
47
+ test('return code property', () => {
48
+ expect(errorTest.getCode()).toBe(CodeTest);
49
+ });
50
+ });
51
+
52
+ describe('getMessage()', () => {
53
+ test('return message property', () => {
54
+ expect(errorTest.getMessage()).toBe(MessageTest);
55
+ });
56
+ });
57
+
58
+ describe('getTimestamp()', () => {
59
+ test('return timestamp property', () => {
60
+ errorTest.th_set_timestamp(new Date(TimestampTest));
61
+
62
+ expect(errorTest.getTimestamp().getTime()).toBe(TimestampTest);
63
+ });
64
+ });
65
+
66
+ describe('getInitiator()', () => {
67
+ test('return empty initiator component by default', () => {
68
+ expect(errorTest.getInitiator()).toBeUndefined();
69
+ });
70
+
71
+ test('return initiator component when set', () => {
72
+ errorTest.th_set_initiator(new DTComponentStub('initiator'));
73
+
74
+ expect(errorTest.getInitiator().getId()).toBe(`${ComponentIdTest}-initiator`);
75
+ });
76
+ });
77
+
78
+ describe('getConvicted()', () => {
79
+ test('return empty convicted component by default', () => {
80
+ expect(errorTest.getConvicted()).toBeUndefined();
81
+ });
82
+
83
+ test('return convicted component when set', () => {
84
+ errorTest.th_set_convicted(new DTComponentStub('convicted'));
85
+
86
+ expect(errorTest.getConvicted().getId()).toBe(`${ComponentIdTest}-convicted`);
87
+ });
88
+ });
89
+ });
@@ -0,0 +1,216 @@
1
+ import {expect} from '@jest/globals';
2
+ import {DTElement, DTManager} from '../../src';
3
+ import {
4
+ bunch1IdTest,
5
+ bunch1toObjectTest,
6
+ bunch2IdTest,
7
+ bunch2toObjectTest,
8
+ bunch3IdTest,
9
+ bunch3toObjectTest,
10
+ defaultOptions,
11
+ DTBunchStubLibrary,
12
+ DTBunchTest,
13
+ generateMockedElements,
14
+ } from './DTBunch.double';
15
+ import {DTAcceptedMetaData, DTManagerItemsType, DTManagerOptions, DTManagerToObject} from '../../src/types';
16
+ import DYOFinder from '../../src/libs/DYOFinder';
17
+
18
+ /** ****************** STUB PROPERTIES CONSTANTS
19
+ * Fixed properties to use with double classes, avoid auto generated and easy checking on test
20
+ * **** */
21
+ export const IDTest = 'DTManager-id-1234567';
22
+ export const KeyTest = 'DTManager-key-1234567';
23
+ export const DomainTest = 'DTManager-domain-test';
24
+ export const ScopesTest = ['DTManager-scope-test1', 'DTManager-scope-test2'];
25
+
26
+ // Specific Manager constants
27
+ export const manager1IDTest = `${IDTest}_1`;
28
+ export const manager1KeyTest = `${KeyTest}_1`;
29
+
30
+ export const manager1ToObject: DTManagerToObject = {
31
+ id: manager1IDTest,
32
+ key: manager1KeyTest,
33
+ type: 'manager',
34
+ items: [
35
+ {
36
+ scope: 'default',
37
+ ...bunch1toObjectTest
38
+ }
39
+ ]
40
+ }
41
+
42
+ /** ****************** HELPER TEST CLASS
43
+ * Helper test class, inherits the main component
44
+ * Providing methods to property access and other facilities, in order to avoid using class methods
45
+ * **** */
46
+ export class DTManagerTest extends DTManager<DTElement<DTAcceptedMetaData>> {
47
+ th_get_id(): string {
48
+ return this._id;
49
+ }
50
+
51
+ th_set_id(id: string): void {
52
+ this._id = id;
53
+ }
54
+
55
+ th_get_key(): string {
56
+ return this._key;
57
+ }
58
+
59
+ th_set_key(key: string): void {
60
+ this._key = key;
61
+ }
62
+
63
+ th_get_componentType(): string {
64
+ return this._componentType;
65
+ }
66
+
67
+ th_get_domain(): string {
68
+ return this._domain;
69
+ }
70
+
71
+ th_set_domain(domain: string): void {
72
+ this._domain = domain;
73
+ }
74
+
75
+ th_get_items(): any {
76
+ return this._items;
77
+ }
78
+
79
+ th_set_items(items: DTManagerItemsType<DTElement<DTAcceptedMetaData>>): void {
80
+ this._items = items;
81
+ }
82
+
83
+ th_get_single_item(id: string): any {
84
+ return this._items[id];
85
+ }
86
+
87
+ th_get_scopes(): any {
88
+ return this._scopes;
89
+ }
90
+
91
+ th_set_scopes(scopes: any): void {
92
+ this._scopes = scopes;
93
+ }
94
+
95
+ th_get_library(): any {
96
+ return this._library;
97
+ }
98
+
99
+ th_set_library(library: any): void {
100
+ this._library = library;
101
+ }
102
+
103
+ th_set_options(options: any): void {
104
+ this._options = {
105
+ ...this._options,
106
+ ...options,
107
+ };
108
+ }
109
+
110
+ th_get_finder(): DYOFinder {
111
+ return this._finder;
112
+ }
113
+
114
+ th_get_options(): DTManagerOptions {
115
+ return this._options;
116
+ }
117
+ }
118
+
119
+ /** ****************** STUB CLASS
120
+ * Stub class, for using in other component
121
+ * **** */
122
+ export class DTManagerStub extends DTManagerTest {
123
+ constructor() {
124
+ super();
125
+ this._id = IDTest;
126
+ this._key = KeyTest;
127
+ this._errors = [];
128
+ this._library = new DTBunchStubLibrary();
129
+ this._scopes = [
130
+ 'default',
131
+ 'virtual',
132
+ ...ScopesTest,
133
+ ];
134
+ }
135
+
136
+ getId(): string {
137
+ return IDTest;
138
+ }
139
+
140
+ getKey(): string {
141
+ return KeyTest;
142
+ }
143
+ }
144
+
145
+ export class DTManagerStubDomain extends DTManagerTest {
146
+ protected _domain = DomainTest;
147
+
148
+ getDomain(): string {
149
+ return DomainTest;
150
+ }
151
+ }
152
+
153
+ /** ****************** HELPER METHODS
154
+ * Additional helper methods to use with testing
155
+ * **** */
156
+ // Add mocked bunches and elements to a Manager
157
+ export function populateManager(manager: DTManagerTest): DTManagerTest {
158
+ const mockedElements = generateMockedElements(5);
159
+
160
+ // Library
161
+ manager.th_set_library(new DTBunchStubLibrary(mockedElements));
162
+
163
+ // Scopes
164
+ manager.th_set_scopes(ScopesTest);
165
+
166
+ // Bunches
167
+ const bunch1 = new DTBunchTest();
168
+ bunch1.th_set_items(mockedElements);
169
+ bunch1.th_set_id(bunch1IdTest);
170
+ jest.spyOn(bunch1, 'getId').mockImplementation(() => bunch1IdTest);
171
+ jest.spyOn(bunch1, 'getOptions').mockImplementation(() => ({ ...defaultOptions }));
172
+ jest.spyOn(bunch1, 'getAll').mockImplementation(function () { return this._items; });
173
+ jest.spyOn(bunch1, 'toObject').mockImplementation(() => bunch1toObjectTest);
174
+
175
+ const bunch2 = new DTBunchTest();
176
+ bunch2.th_set_items([]);
177
+ bunch2.th_set_id(bunch2IdTest);
178
+ jest.spyOn(bunch2, 'getId').mockImplementation(() => bunch2IdTest);
179
+ jest.spyOn(bunch2, 'getOptions').mockImplementation(() => ({ ...defaultOptions }));
180
+ jest.spyOn(bunch2, 'getAll').mockImplementation(function () { return this._items; });
181
+ jest.spyOn(bunch2, 'toObject').mockImplementation(() => bunch2toObjectTest);
182
+
183
+ const bunch3 = new DTBunchTest();
184
+ bunch3.th_set_items([]);
185
+ bunch3.th_set_id(bunch3IdTest);
186
+ bunch3.th_set_options({ virtualContainer: true });
187
+ jest.spyOn(bunch3, 'getId').mockImplementation(() => bunch3IdTest);
188
+ jest.spyOn(bunch3, 'getOptions').mockImplementation(() => ({ ...defaultOptions, virtualContainer: true }));
189
+ jest.spyOn(bunch3, 'getAll').mockImplementation(function () { return this._items; });
190
+ jest.spyOn(bunch3, 'toObject').mockImplementation(() => bunch3toObjectTest);
191
+
192
+ const items: DTManagerItemsType<DTElement<DTAcceptedMetaData>> = {
193
+ [bunch1.th_get_id()]: {
194
+ scope: 'default',
195
+ item: bunch1,
196
+ },
197
+ [bunch2.th_get_id()]: {
198
+ scope: ScopesTest[0],
199
+ item: bunch2,
200
+ },
201
+ [bunch3.th_get_id()]: {
202
+ scope: 'virtual',
203
+ item: bunch3,
204
+ },
205
+ };
206
+ manager.th_set_items(items);
207
+
208
+ return manager;
209
+ }
210
+
211
+ export const checkManagerItem = (managerTest: DTManagerTest, bunchId: string, scope: string): void => {
212
+ expect(managerTest.th_get_single_item(bunchId)).toBeDefined();
213
+ expect(Object.keys(managerTest.th_get_single_item(bunchId))).toStrictEqual(['scope', 'item']);
214
+ expect(managerTest.th_get_single_item(bunchId).scope).toBe(scope);
215
+ expect(managerTest.th_get_single_item(bunchId).item.th_get_id()).toBe(bunchId);
216
+ };