dyo-tools 0.3.0 → 0.4.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 (208) hide show
  1. package/.c8rc.json +4 -4
  2. package/.eslintignore +1 -1
  3. package/.eslintrc.json +47 -47
  4. package/Makefile +34 -34
  5. package/dist/constants.d.ts +1 -0
  6. package/dist/constants.d.ts.map +1 -0
  7. package/dist/constants.js +24 -20
  8. package/dist/constants.js.map +1 -1
  9. package/dist/core/DTAction.d.ts +6 -4
  10. package/dist/core/DTAction.d.ts.map +1 -0
  11. package/dist/core/DTAction.js +3 -6
  12. package/dist/core/DTAction.js.map +1 -1
  13. package/dist/core/DTBunch.d.ts +8 -5
  14. package/dist/core/DTBunch.d.ts.map +1 -0
  15. package/dist/core/DTBunch.js +54 -20
  16. package/dist/core/DTBunch.js.map +1 -1
  17. package/dist/core/DTComponent.d.ts +13 -10
  18. package/dist/core/DTComponent.d.ts.map +1 -0
  19. package/dist/core/DTComponent.js +23 -10
  20. package/dist/core/DTComponent.js.map +1 -1
  21. package/dist/core/DTComponentPhysical.d.ts +11 -7
  22. package/dist/core/DTComponentPhysical.d.ts.map +1 -0
  23. package/dist/core/DTComponentPhysical.js +21 -6
  24. package/dist/core/DTComponentPhysical.js.map +1 -1
  25. package/dist/core/DTComponentWithMeta.d.ts +6 -3
  26. package/dist/core/DTComponentWithMeta.d.ts.map +1 -0
  27. package/dist/core/DTComponentWithMeta.js +21 -7
  28. package/dist/core/DTComponentWithMeta.js.map +1 -1
  29. package/dist/core/DTElement.d.ts +10 -8
  30. package/dist/core/DTElement.d.ts.map +1 -0
  31. package/dist/core/DTElement.js +8 -9
  32. package/dist/core/DTElement.js.map +1 -1
  33. package/dist/core/DTError.d.ts +8 -7
  34. package/dist/core/DTError.d.ts.map +1 -0
  35. package/dist/core/DTError.js +1 -5
  36. package/dist/core/DTError.js.map +1 -1
  37. package/dist/core/DTManager.d.ts +17 -14
  38. package/dist/core/DTManager.d.ts.map +1 -0
  39. package/dist/core/DTManager.js +84 -26
  40. package/dist/core/DTManager.js.map +1 -1
  41. package/dist/core/DTMaster.d.ts +19 -16
  42. package/dist/core/DTMaster.d.ts.map +1 -0
  43. package/dist/core/DTMaster.js +48 -31
  44. package/dist/core/DTMaster.js.map +1 -1
  45. package/dist/core/DTModule.d.ts +8 -5
  46. package/dist/core/DTModule.d.ts.map +1 -0
  47. package/dist/core/DTModule.js +6 -6
  48. package/dist/core/DTModule.js.map +1 -1
  49. package/dist/index.d.ts +1 -0
  50. package/dist/index.d.ts.map +1 -0
  51. package/dist/index.js +12 -28
  52. package/dist/index.js.map +1 -1
  53. package/dist/libs/DYOFinder.d.ts +1 -0
  54. package/dist/libs/DYOFinder.d.ts.map +1 -0
  55. package/dist/libs/DYOFinder.js +10 -14
  56. package/dist/libs/DYOFinder.js.map +1 -1
  57. package/dist/libs/dix/DIXModule.module.d.ts +8 -0
  58. package/dist/libs/dix/DIXModule.module.d.ts.map +1 -0
  59. package/dist/libs/dix/DIXModule.module.js +73 -0
  60. package/dist/libs/player/DTPlayer.element.d.ts +3 -2
  61. package/dist/libs/player/DTPlayer.element.d.ts.map +1 -0
  62. package/dist/libs/player/DTPlayer.element.js +2 -6
  63. package/dist/libs/player/DTPlayer.element.js.map +1 -1
  64. package/dist/libs/player/DTPlayer.manager.d.ts +8 -7
  65. package/dist/libs/player/DTPlayer.manager.d.ts.map +1 -0
  66. package/dist/libs/player/DTPlayer.manager.js +13 -20
  67. package/dist/libs/player/DTPlayer.manager.js.map +1 -1
  68. package/dist/tsconfig.dev.tsbuildinfo +1 -0
  69. package/dist/tsconfig.tsbuildinfo +1 -1
  70. package/dist/types/core.d.ts +40 -12
  71. package/dist/types/core.d.ts.map +1 -0
  72. package/dist/types/core.js +2 -6
  73. package/dist/types/core.js.map +1 -1
  74. package/dist/types/index.d.ts +1 -0
  75. package/dist/types/index.d.ts.map +1 -0
  76. package/dist/types/index.js +2 -19
  77. package/dist/types/index.js.map +1 -1
  78. package/dist/types/player.d.ts +1 -1
  79. package/dist/types/player.d.ts.map +1 -0
  80. package/dist/types/player.js +1 -3
  81. package/docs/assets/main.js +59 -59
  82. package/docs/assets/style.css +1414 -1414
  83. package/integration/data/components/DTHero.ts +42 -0
  84. package/integration/data/components/DTHeroManager.ts +11 -0
  85. package/integration/data/components/DTHeroPlayZone.ts +6 -0
  86. package/integration/data/components/DTHeroPlayerHand.ts +11 -0
  87. package/integration/data/components/index.ts +5 -0
  88. package/integration/data/in/heroIn.helper.ts +8 -0
  89. package/integration/data/in/playerIn.helper.ts +13 -0
  90. package/integration/data/out/heroOut.helper.ts +48 -0
  91. package/integration/endings/synchronisation.ending.ts +25 -0
  92. package/integration/scenes/drawCard.scene.ts +31 -0
  93. package/integration/scenes/empty.scene.ts +6 -0
  94. package/integration/scenes/playCard.scene.ts +23 -0
  95. package/integration/scenes/playerLeave.scene.ts +33 -0
  96. package/integration/stages/baseDix.stage.ts +137 -0
  97. package/integration/stages/syncDix.stage.ts +36 -0
  98. package/integration/tests/scenario1.spec.ts +55 -0
  99. package/integration/types/index.ts +24 -0
  100. package/jest-integration.config.ts +25 -0
  101. package/jest.config.ts +26 -0
  102. package/package.json +31 -19
  103. package/src/constants.ts +87 -85
  104. package/src/core/DTAction.ts +54 -52
  105. package/src/core/DTBunch.ts +531 -467
  106. package/src/core/DTComponent.ts +258 -225
  107. package/src/core/DTComponentPhysical.ts +88 -53
  108. package/src/core/DTComponentWithMeta.ts +98 -65
  109. package/src/core/DTElement.ts +111 -102
  110. package/src/core/DTError.ts +78 -78
  111. package/src/core/DTManager.ts +555 -465
  112. package/src/core/DTMaster.ts +366 -318
  113. package/src/core/DTModule.ts +96 -90
  114. package/src/libs/dix/DIXModule.module.ts +98 -0
  115. package/src/libs/player/DTPlayer.element.ts +9 -9
  116. package/src/libs/player/DTPlayer.manager.ts +70 -84
  117. package/src/types/core.ts +204 -169
  118. package/src/types/player.ts +5 -6
  119. package/test/core/DTAction.double.ts +12 -28
  120. package/test/core/DTAction.spec.ts +8 -16
  121. package/test/core/DTBunch.double.ts +49 -135
  122. package/test/core/DTBunch.spec.ts +163 -238
  123. package/test/core/DTComponent.double.ts +17 -2
  124. package/test/core/DTComponent.spec.ts +6 -4
  125. package/test/core/DTComponentPhysical.double.ts +29 -43
  126. package/test/core/DTComponentPhysical.spec.ts +22 -19
  127. package/test/core/DTComponentWithMeta.double.ts +38 -31
  128. package/test/core/DTComponentWithMeta.spec.ts +23 -18
  129. package/test/core/DTElement.double.ts +32 -53
  130. package/test/core/DTElement.spec.ts +15 -38
  131. package/test/core/DTError.double.ts +18 -53
  132. package/test/core/DTError.spec.ts +21 -32
  133. package/test/core/DTManager.double.ts +74 -141
  134. package/test/core/DTManager.spec.ts +289 -380
  135. package/test/core/DTMaster.double.ts +56 -80
  136. package/test/core/DTMaster.spec.ts +185 -232
  137. package/test/core/DTModule.double.ts +12 -25
  138. package/test/core/DTModule.spec.ts +14 -28
  139. package/test/core/copy.spec.ts +9 -30
  140. package/tsconfig.dev.json +5 -8
  141. package/tsconfig.json +5 -8
  142. package/cucumber-report.html +0 -48
  143. package/docs/assets/navigation.js +0 -1
  144. package/docs/classes/core_DTAction.DYOToolsAction.html +0 -89
  145. package/docs/classes/core_DTBunch.DYOToolsBunch.html +0 -254
  146. package/docs/classes/core_DTComponent.DYOToolsComponent.html +0 -76
  147. package/docs/classes/core_DTComponentPhysical.DYOToolsComponentPhysical.html +0 -110
  148. package/docs/classes/core_DTComponentWithMeta.DYOToolsComponentWithMeta.html +0 -96
  149. package/docs/classes/core_DTElement.DYOToolsElement.html +0 -135
  150. package/docs/classes/core_DTError.DYOToolsError.html +0 -37
  151. package/docs/classes/core_DTManager.DYOToolsManager.html +0 -237
  152. package/docs/classes/core_DTMaster.DYOToolsMaster.html +0 -150
  153. package/docs/classes/core_DTModule.DYOToolsModule.html +0 -92
  154. package/docs/classes/libs_DYOFinder.DYOFinder.html +0 -34
  155. package/docs/classes/libs_player_DTPlayer_element.DYOToolsPlayer.html +0 -134
  156. package/docs/classes/libs_player_DTPlayer_manager.DYOToolsPlayerManager.html +0 -243
  157. package/docs/enums/types_core.FilterOperatorType.html +0 -10
  158. package/docs/hierarchy.html +0 -1
  159. package/docs/interfaces/types_core.DTBunchFilters.html +0 -6
  160. package/docs/interfaces/types_core.DTBunchOptions.html +0 -19
  161. package/docs/interfaces/types_core.DTBunchToObject.html +0 -7
  162. package/docs/interfaces/types_core.DTComponentOptions.html +0 -5
  163. package/docs/interfaces/types_core.DTComponentToObject.html +0 -4
  164. package/docs/interfaces/types_core.DTElementToObject.html +0 -7
  165. package/docs/interfaces/types_core.DTManagerFilters.html +0 -6
  166. package/docs/interfaces/types_core.DTManagerOptions.html +0 -8
  167. package/docs/interfaces/types_core.DTManagerToObject.html +0 -5
  168. package/docs/interfaces/types_core.DTMasterToObject.html +0 -8
  169. package/docs/interfaces/types_core.DTModuleToObject.html +0 -6
  170. package/docs/interfaces/types_core.DYOFinderConfigurationPropDefault.html +0 -4
  171. package/docs/interfaces/types_core.DYOFinderConfigurationPropObjectSearch.html +0 -4
  172. package/docs/interfaces/types_core.DYOFinderFilterOperatorAdvanced.html +0 -5
  173. package/docs/interfaces/types_core.DYOFinderFilterOperatorBase.html +0 -5
  174. package/docs/interfaces/types_player.DTPlayerManagerSimpleConfiguration.html +0 -3
  175. package/docs/modules/constants.html +0 -6
  176. package/docs/modules/core_DTAction.html +0 -2
  177. package/docs/modules/core_DTBunch.html +0 -2
  178. package/docs/modules/core_DTComponent.html +0 -2
  179. package/docs/modules/core_DTComponentPhysical.html +0 -2
  180. package/docs/modules/core_DTComponentWithMeta.html +0 -2
  181. package/docs/modules/core_DTElement.html +0 -2
  182. package/docs/modules/core_DTError.html +0 -2
  183. package/docs/modules/core_DTManager.html +0 -2
  184. package/docs/modules/core_DTMaster.html +0 -2
  185. package/docs/modules/core_DTModule.html +0 -2
  186. package/docs/modules/libs_DYOFinder.html +0 -2
  187. package/docs/modules/libs_player_DTPlayer_element.html +0 -2
  188. package/docs/modules/libs_player_DTPlayer_manager.html +0 -2
  189. package/docs/modules/types.html +0 -29
  190. package/docs/modules/types_core.html +0 -28
  191. package/docs/modules/types_player.html +0 -2
  192. package/docs/types/types_core.DTAcceptedMetaData.html +0 -2
  193. package/docs/types/types_core.DTManagerItemType.html +0 -1
  194. package/docs/types/types_core.DTManagerItemsType.html +0 -2
  195. package/docs/types/types_core.DYOFinderComponentType.html +0 -1
  196. package/docs/types/types_core.DYOFinderConfiguration.html +0 -2
  197. package/docs/types/types_core.DYOFinderConfigurationProp.html +0 -1
  198. package/docs/types/types_core.DYOFinderFilterOperator.html +0 -1
  199. package/docs/types/types_core.DYOFinderFilterOperatorArgument.html +0 -1
  200. package/docs/types/types_core.DYOFinderFilters.html +0 -1
  201. package/docs/types/types_core.StandardPrimitiveType.html +0 -2
  202. package/docs/types/types_core.StandardPrimitiveTypeWithArray.html +0 -1
  203. package/docs/variables/constants.bunchDefaultOptions.html +0 -2
  204. package/docs/variables/constants.componentBunchDefaultFinderConfiguration.html +0 -1
  205. package/docs/variables/constants.componentManagerDefaultFinderConfiguration.html +0 -1
  206. package/docs/variables/constants.componentPhysicalDefaultFinderConfiguration.html +0 -1
  207. package/docs/variables/constants.managerDefaultOptions.html +0 -2
  208. package/jest.config.js +0 -6
package/src/constants.ts CHANGED
@@ -1,85 +1,87 @@
1
- import {
2
- DTAcceptedMetaData,
3
- DTBunchOptions,
4
- DTManagerOptions,
5
- DYOFinderConfiguration,
6
- FilterOperatorType,
7
- StandardPrimitiveType,
8
- } from './types';
9
- import {
10
- DTBunch, DTComponentPhysical, DTElement, DTManager,
11
- } from './index';
12
-
13
- /* ********************** CORE CONSTANTS ********************** */
14
- /** DTBunch constants * */
15
- export const bunchDefaultOptions: DTBunchOptions = {
16
- errors: false,
17
- uniqueKey: false,
18
- inheritOwner: false,
19
- replaceIndex: false,
20
- virtualContainer: false,
21
- };
22
-
23
- /** DTManager constants * */
24
- export const managerDefaultOptions: DTManagerOptions = {
25
- errors: false,
26
- libraryDeletion: false,
27
- };
28
-
29
- /** DYOFinder configuration constants * */
30
- const baseOperators = [
31
- FilterOperatorType.EQ,
32
- FilterOperatorType.IN,
33
- FilterOperatorType.NIN,
34
- FilterOperatorType.NE,
35
- ];
36
- const advancedOperators = [
37
- ...baseOperators,
38
- FilterOperatorType.GTE,
39
- FilterOperatorType.LTE,
40
- FilterOperatorType.CONTAINS,
41
- FilterOperatorType.NCONTAINS,
42
- ];
43
-
44
- export const componentPhysicalDefaultFinderConfiguration: DYOFinderConfiguration = {
45
- id: {
46
- operators: baseOperators,
47
- getValue: (item: DTComponentPhysical<DTAcceptedMetaData>) => item.getId(),
48
- objectSearch: false,
49
- },
50
- key: {
51
- operators: baseOperators,
52
- getValue: (item: DTComponentPhysical<DTAcceptedMetaData>) => item.getKey(),
53
- objectSearch: false,
54
- },
55
- owner: {
56
- operators: baseOperators,
57
- getValue: (item: DTComponentPhysical<DTAcceptedMetaData>) => item.getOwner(),
58
- objectSearch: false,
59
- },
60
- meta: {
61
- operators: advancedOperators,
62
- getValue: (item: DTComponentPhysical<DTAcceptedMetaData>) => item.getManyMeta(),
63
- objectSearch: true,
64
- },
65
- };
66
-
67
- export const componentManagerDefaultFinderConfiguration: DYOFinderConfiguration = {
68
- ...componentPhysicalDefaultFinderConfiguration,
69
- scope: {
70
- operators: baseOperators,
71
- getValue(item: DTBunch<DTElement<DTAcceptedMetaData>>, ctx: DTManager<DTElement<DTAcceptedMetaData>>): StandardPrimitiveType {
72
- return ctx.getScope(item.getId());
73
- },
74
- objectSearch: false,
75
- },
76
- };
77
-
78
- export const componentBunchDefaultFinderConfiguration: DYOFinderConfiguration = {
79
- ...componentPhysicalDefaultFinderConfiguration,
80
- container: {
81
- operators: baseOperators,
82
- getValue: (item: DTElement<DTAcceptedMetaData>) => (item.getContainer() ? item.getContainer().getId() : null),
83
- objectSearch: false,
84
- },
85
- };
1
+ import {
2
+ DTAcceptedMetaData,
3
+ DTBunchOptions,
4
+ DTManagerOptions,
5
+ DYOFinderConfiguration,
6
+ FilterOperatorType,
7
+ StandardPrimitiveType,
8
+ } from './types';
9
+ import {
10
+ DTBunch, DTComponentPhysical, DTElement, DTManager,
11
+ } from './index';
12
+
13
+ /* ********************** CORE CONSTANTS ********************** */
14
+ /** DTBunch constants * */
15
+ export const bunchDefaultOptions: DTBunchOptions = {
16
+ errors: false,
17
+ syncId: undefined,
18
+ uniqueKey: false,
19
+ inheritOwner: false,
20
+ replaceIndex: false,
21
+ virtualContainer: false,
22
+ };
23
+
24
+ /** DTManager constants * */
25
+ export const managerDefaultOptions: DTManagerOptions = {
26
+ errors: false,
27
+ syncId: undefined,
28
+ libraryDeletion: false,
29
+ };
30
+
31
+ /** DYOFinder configuration constants * */
32
+ const baseOperators = [
33
+ FilterOperatorType.EQ,
34
+ FilterOperatorType.IN,
35
+ FilterOperatorType.NIN,
36
+ FilterOperatorType.NE,
37
+ ];
38
+ const advancedOperators = [
39
+ ...baseOperators,
40
+ FilterOperatorType.GTE,
41
+ FilterOperatorType.LTE,
42
+ FilterOperatorType.CONTAINS,
43
+ FilterOperatorType.NCONTAINS,
44
+ ];
45
+
46
+ export const componentPhysicalDefaultFinderConfiguration: DYOFinderConfiguration = {
47
+ id: {
48
+ operators: baseOperators,
49
+ getValue: (item: DTComponentPhysical<DTAcceptedMetaData>) => item.getId(),
50
+ objectSearch: false,
51
+ },
52
+ key: {
53
+ operators: baseOperators,
54
+ getValue: (item: DTComponentPhysical<DTAcceptedMetaData>) => item.getKey(),
55
+ objectSearch: false,
56
+ },
57
+ owner: {
58
+ operators: baseOperators,
59
+ getValue: (item: DTComponentPhysical<DTAcceptedMetaData>) => item.getOwner(),
60
+ objectSearch: false,
61
+ },
62
+ meta: {
63
+ operators: advancedOperators,
64
+ getValue: (item: DTComponentPhysical<DTAcceptedMetaData>) => item.getManyMeta(),
65
+ objectSearch: true,
66
+ },
67
+ };
68
+
69
+ export const componentManagerDefaultFinderConfiguration: DYOFinderConfiguration = {
70
+ ...componentPhysicalDefaultFinderConfiguration,
71
+ scope: {
72
+ operators: baseOperators,
73
+ getValue(item: DTBunch<DTElement<DTAcceptedMetaData>>, ctx: DTManager<DTElement<DTAcceptedMetaData>>): StandardPrimitiveType {
74
+ return ctx.getScope(item.getId());
75
+ },
76
+ objectSearch: false,
77
+ },
78
+ };
79
+
80
+ export const componentBunchDefaultFinderConfiguration: DYOFinderConfiguration = {
81
+ ...componentPhysicalDefaultFinderConfiguration,
82
+ container: {
83
+ operators: baseOperators,
84
+ getValue: (item: DTElement<DTAcceptedMetaData>) => (item.getContainer() ? item.getContainer().getId() : null),
85
+ objectSearch: false,
86
+ },
87
+ };
@@ -1,52 +1,54 @@
1
- import DYOToolsComponent from './DTComponent';
2
- import { DTComponentToObject } from '../types';
3
- import DYOToolsMaster from './DTMaster';
4
-
5
- export default abstract class DYOToolsAction<Payload = unknown> extends DYOToolsComponent {
6
- /**
7
- * Defining component type to "action".
8
- */
9
- protected _componentType: string = 'action';
10
-
11
- /**
12
- * Returns Master component from context, or undefined.
13
- */
14
- getMaster(): DYOToolsMaster | undefined {
15
- return this.getContext<DYOToolsMaster>('master');
16
- }
17
-
18
- /**
19
- * Abstract method for action execution process.
20
- *
21
- * @param payload Object Payload to pass for action execution.
22
- * @returns Promise
23
- */
24
- abstract execute(payload: Payload): Promise<void>;
25
-
26
- /**
27
- * Return String representation of the Action instance.
28
- *
29
- * @returns String representation of the Action.
30
- */
31
- toString(): string {
32
- return `Component ${this._key} - Type: Action`;
33
- }
34
-
35
- /**
36
- * Return JSON Object representation of the Action instance.
37
- *
38
- * JSON Object returned has the following structure :
39
- * * **id** : _id property of the Action.
40
- * * **key** : _key property of the Action.
41
- * * **type** : _componentType property of the Action.
42
- *
43
- * @returns JSON Object representation of the Action.
44
- */
45
- toObject(): DTComponentToObject {
46
- return {
47
- id: this._id,
48
- key: this._key,
49
- type: this._componentType,
50
- };
51
- }
52
- }
1
+ import DTComponent from './DTComponent';
2
+ import { DTComponentToObject } from '../types';
3
+ import DTMaster from './DTMaster';
4
+
5
+ export default abstract class DTAction<Payload = unknown> extends DTComponent {
6
+ /**
7
+ * Defining component type to "action".
8
+ */
9
+ protected _componentType: string = 'action';
10
+
11
+ /**
12
+ * Returns Master component from context, or undefined.
13
+ */
14
+ getMaster(): DTMaster | undefined {
15
+ return this.getContext<DTMaster>('master');
16
+ }
17
+
18
+ /**
19
+ * Abstract method for action execution process.
20
+ *
21
+ * @param payload Object Payload to pass for action execution.
22
+ * @returns Promise
23
+ */
24
+ abstract execute(payload: Payload): Promise<void>;
25
+
26
+ /**
27
+ * Return String representation of the Action instance.
28
+ *
29
+ * @returns String representation of the Action.
30
+ */
31
+ toString(): string {
32
+ return `Component ${this._key} - Type: Action`;
33
+ }
34
+
35
+ /**
36
+ * Return JSON Object representation of the Action instance.
37
+ *
38
+ * JSON Object returned has the following structure :
39
+ * * **id** : _id property of the Action.
40
+ * * **key** : _key property of the Action.
41
+ * * **type** : _componentType property of the Action.
42
+ *
43
+ * @returns JSON Object representation of the Action.
44
+ */
45
+ toObject(): DTComponentToObject {
46
+ return {
47
+ id: this._id,
48
+ key: this._key,
49
+ type: this._componentType,
50
+ };
51
+ }
52
+
53
+ updateFromDix() {}
54
+ }