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/types/core.ts CHANGED
@@ -1,169 +1,204 @@
1
- import { DTBunch, DTComponent } from '../index';
2
- import DYOToolsElement from '../core/DTElement';
3
-
4
- /** Constants Enum * */
5
- export enum FilterOperatorType {
6
- EQ = '$eq',
7
- IN = '$in',
8
- NIN = '$nin',
9
- NE = '$ne',
10
- LTE = '$lte',
11
- GTE = '$gte',
12
- CONTAINS = '$contains',
13
- NCONTAINS = '$ncontains',
14
- }
15
-
16
- /** Common Types * */
17
- export type StandardPrimitiveType = string | number | boolean | null | undefined;
18
- export type StandardPrimitiveTypeWithArray = string | number | boolean | Array<string | number | boolean> | null | undefined;
19
-
20
- /** DYO Finder interfaces * */
21
- export type DYOFinderConfiguration = Record<string, DYOFinderConfigurationProp>;
22
- export type DYOFinderComponentType = DTComponent & {
23
- getAll: () => DTComponent[],
24
- };
25
-
26
- export interface DYOFinderConfigurationPropDefault {
27
- operators: FilterOperatorType[],
28
- getValue: (item: DTComponent, ctx?: DTComponent) => StandardPrimitiveType,
29
- objectSearch: false,
30
- }
31
-
32
- export interface DYOFinderConfigurationPropObjectSearch {
33
- operators: FilterOperatorType[],
34
- getValue: (item: DTComponent, ctx?: DTComponent) => Record<string, StandardPrimitiveTypeWithArray>,
35
- objectSearch: true,
36
- }
37
- export type DYOFinderConfigurationProp = DYOFinderConfigurationPropDefault | DYOFinderConfigurationPropObjectSearch;
38
-
39
- export interface DYOFinderFilterOperatorBase {
40
- [FilterOperatorType.EQ]: StandardPrimitiveType
41
- [FilterOperatorType.IN]: Array<StandardPrimitiveType>
42
- [FilterOperatorType.NIN]: Array<StandardPrimitiveType>
43
- [FilterOperatorType.NE]: StandardPrimitiveType
44
- }
45
- export interface DYOFinderFilterOperatorAdvanced {
46
- [FilterOperatorType.LTE]: number
47
- [FilterOperatorType.GTE]: number
48
- [FilterOperatorType.CONTAINS]: StandardPrimitiveType
49
- [FilterOperatorType.NCONTAINS]: StandardPrimitiveType
50
- }
51
-
52
- export type DYOFinderFilterOperator = DYOFinderFilterOperatorBase & DYOFinderFilterOperatorAdvanced;
53
- export type DYOFinderFilterOperatorArgument = Partial<DYOFinderFilterOperator | Record<string, Partial<DYOFinderFilterOperator>>>;
54
- export type DYOFinderFilters = Record<string, DYOFinderFilterOperatorArgument>;
55
-
56
- /** DTComponent interfaces * */
57
- /**
58
- * DTComponent default options configuration.
59
- */
60
- export interface DTComponentOptions {
61
- /**
62
- * Default *false*. If *true*, no exception is thrown when an error occurred, a new DTError instance is
63
- * added to the _errors property array instead. If *false*, throw the exception with a DTError instance.
64
- */
65
- errors: boolean
66
- }
67
-
68
- export interface DTComponentToObject {
69
- id: string
70
- key: string
71
- type: string
72
- }
73
-
74
- /** DTComponentWithMeta interfaces * */
75
- export type DTAcceptedMetaData = Record<
76
- string,
77
- StandardPrimitiveTypeWithArray
78
- >;
79
-
80
- /** DTElement interfaces * */
81
- export interface DTElementToObject<IComponentMeta> extends DTComponentToObject {
82
- owner?: string
83
- meta?: Partial<IComponentMeta>
84
- }
85
-
86
- /** DTBunch interfaces * */
87
- /**
88
- * DTBunch option configuration.
89
- */
90
- export interface DTBunchOptions extends DTComponentOptions {
91
- /**
92
- * Default *false*. If *true*, an error occurred when adding a new DTElement with the same key of an
93
- * existing element into the bunch.
94
- */
95
- uniqueKey: boolean
96
- /**
97
- * Default *false*. If *true*, when a new DTElement is added at existing index (using **addAtIndex**
98
- * or **addManyAtIndex** method), this component replaces the old one. If *false*, this component is added at the specified
99
- * index and other existing component are reindexed with the following index.
100
- */
101
- replaceIndex: boolean
102
- /**
103
- * Default *false*. If *true*, when a new DTElement is added, the owner of this element becomes
104
- * automatically the current bunch owner.
105
- */
106
- inheritOwner: boolean
107
- /**
108
- * Default *false*. If *true*, the container is not changed when a new DTElement is added.
109
- * If *false*, when a new DTElement is added, the container of this element becomes automatically the current bunch instance
110
- * and the element is removed from the old container Component (if defined).
111
- */
112
- virtualContainer: boolean
113
- }
114
-
115
- export interface DTBunchToObject<IComponentMeta> extends DTComponentToObject {
116
- items: Array<DTElementToObject<DTAcceptedMetaData>>
117
- owner?: string
118
- meta?: Partial<IComponentMeta>
119
- }
120
-
121
- export interface DTBunchFilters {
122
- id: Partial<DYOFinderFilterOperatorBase>
123
- key: Partial<DYOFinderFilterOperatorBase>
124
- container: Partial<DYOFinderFilterOperatorBase>
125
- owner: Partial<DYOFinderFilterOperatorBase>
126
- meta: Record<string, Partial<DYOFinderFilterOperatorBase & DYOFinderFilterOperatorAdvanced>>
127
- }
128
-
129
- /** DTManager interfaces * */
130
- export type DTManagerItemsType<IBunchItem extends DYOToolsElement<DTAcceptedMetaData>> = Record<string, DTManagerItemType<IBunchItem>>;
131
- export type DTManagerItemType<IBunchItem extends DYOToolsElement<DTAcceptedMetaData>> = {
132
- scope: string,
133
- item: DTBunch<IBunchItem>,
134
- };
135
-
136
- export interface DTManagerFilters extends DYOFinderFilters {
137
- id: Partial<DYOFinderFilterOperatorBase>
138
- key: Partial<DYOFinderFilterOperatorBase>
139
- owner: Partial<DYOFinderFilterOperatorBase>
140
- scope: Partial<DYOFinderFilterOperatorBase>
141
- meta: Record<string, Partial<DYOFinderFilterOperatorBase & DYOFinderFilterOperatorAdvanced>>
142
- }
143
-
144
- /**
145
- * DTManager option configuration.
146
- */
147
- export interface DTManagerOptions extends DTComponentOptions {
148
- /**
149
- * Default *false*. If *true*, when a bunch instance is removed from the Manager _items, the process performs also
150
- * a removal from the Manager Library of all DTElement instances of the bunch.
151
- */
152
- libraryDeletion: boolean,
153
- }
154
-
155
- export interface DTManagerToObject extends DTComponentToObject {
156
- items: Array<DTBunchToObject<DTAcceptedMetaData> & { scope: string }>
157
- }
158
-
159
- /** DTModule interfaces * */
160
- export interface DTModuleToObject extends DTComponentToObject {
161
- enabled: boolean
162
- }
163
-
164
- /** DTMaster interfaces * */
165
- export interface DTMasterToObject extends DTComponentToObject {
166
- managers: Array<DTManagerToObject>,
167
- actions: Array<DTComponentToObject>,
168
- modules: Array<DTModuleToObject>,
169
- }
1
+ import { DTBunch, DTComponent } from '../index';
2
+ import DTElement from '../core/DTElement';
3
+
4
+ /** Constants Enum * */
5
+ export enum FilterOperatorType {
6
+ EQ = '$eq',
7
+ IN = '$in',
8
+ NIN = '$nin',
9
+ NE = '$ne',
10
+ LTE = '$lte',
11
+ GTE = '$gte',
12
+ CONTAINS = '$contains',
13
+ NCONTAINS = '$ncontains',
14
+ }
15
+
16
+ /** Common Types * */
17
+ export type StandardPrimitiveType = string | number | boolean | null | undefined;
18
+ export type StandardPrimitiveTypeWithArray = string | number | boolean | Array<string | number | boolean> | null | undefined;
19
+
20
+ /** DYO Finder interfaces * */
21
+ export type DYOFinderConfiguration = Record<string, DYOFinderConfigurationProp>;
22
+ export type DYOFinderComponentType = DTComponent & {
23
+ getAll: () => DTComponent[],
24
+ };
25
+
26
+ export interface DYOFinderConfigurationPropDefault {
27
+ operators: FilterOperatorType[],
28
+ getValue: (item: DTComponent, ctx?: DTComponent) => StandardPrimitiveType,
29
+ objectSearch: false,
30
+ }
31
+
32
+ export interface DYOFinderConfigurationPropObjectSearch {
33
+ operators: FilterOperatorType[],
34
+ getValue: (item: DTComponent, ctx?: DTComponent) => Record<string, StandardPrimitiveTypeWithArray>,
35
+ objectSearch: true,
36
+ }
37
+ export type DYOFinderConfigurationProp = DYOFinderConfigurationPropDefault | DYOFinderConfigurationPropObjectSearch;
38
+
39
+ export interface DYOFinderFilterOperatorBase {
40
+ [FilterOperatorType.EQ]: StandardPrimitiveType
41
+ [FilterOperatorType.IN]: Array<StandardPrimitiveType>
42
+ [FilterOperatorType.NIN]: Array<StandardPrimitiveType>
43
+ [FilterOperatorType.NE]: StandardPrimitiveType
44
+ }
45
+ export interface DYOFinderFilterOperatorAdvanced {
46
+ [FilterOperatorType.LTE]: number
47
+ [FilterOperatorType.GTE]: number
48
+ [FilterOperatorType.CONTAINS]: StandardPrimitiveType
49
+ [FilterOperatorType.NCONTAINS]: StandardPrimitiveType
50
+ }
51
+
52
+ export type DYOFinderFilterOperator = DYOFinderFilterOperatorBase & DYOFinderFilterOperatorAdvanced;
53
+ export type DYOFinderFilterOperatorArgument = Partial<DYOFinderFilterOperator | Record<string, Partial<DYOFinderFilterOperator>>>;
54
+ export type DYOFinderFilters = Record<string, DYOFinderFilterOperatorArgument>;
55
+
56
+ /** DTComponent interfaces * */
57
+ /**
58
+ * DTComponent default options configuration.
59
+ */
60
+ export interface DTComponentOptions {
61
+ /**
62
+ * Default *false*. If *true*, no exception is thrown when an error occurred, a new DTError instance is
63
+ * added to the _errors property array instead. If *false*, throw the exception with a DTError instance.
64
+ */
65
+ errors: boolean,
66
+ /**
67
+ * Default undefined. If specified, the string argument passed will be the id of the new DTComponent.
68
+ * Used to synchronize ids between to instances (with the DIX Module). Be careful when using.
69
+ */
70
+ syncId: string | undefined
71
+ }
72
+
73
+ export interface DTComponentToObject {
74
+ id: string
75
+ key: string
76
+ type: string
77
+ }
78
+
79
+ export interface DTComponentToDIXObject {
80
+ key: string
81
+ componentType: string,
82
+ domain?: string
83
+ subKind?: string
84
+ meta?: string
85
+ owner?: string
86
+ }
87
+
88
+ /** DTComponentWithMeta interfaces * */
89
+ export type DTAcceptedMetaData = Record<
90
+ string,
91
+ StandardPrimitiveTypeWithArray
92
+ >;
93
+
94
+ /** DTElement interfaces * */
95
+ export interface DTElementToObject<IComponentMeta> extends DTComponentToObject {
96
+ owner?: string
97
+ meta?: Partial<IComponentMeta>
98
+ }
99
+
100
+ /** DTBunch interfaces * */
101
+ /**
102
+ * DTBunch option configuration.
103
+ */
104
+ export interface DTBunchOptions extends DTComponentOptions {
105
+ /**
106
+ * Default *false*. If *true*, an error occurred when adding a new DTElement with the same key of an
107
+ * existing element into the bunch.
108
+ */
109
+ uniqueKey: boolean
110
+ /**
111
+ * Default *false*. If *true*, when a new DTElement is added at existing index (using **addAtIndex**
112
+ * or **addManyAtIndex** method), this component replaces the old one. If *false*, this component is added at the specified
113
+ * index and other existing component are reindexed with the following index.
114
+ */
115
+ replaceIndex: boolean
116
+ /**
117
+ * Default *false*. If *true*, when a new DTElement is added, the owner of this element becomes
118
+ * automatically the current bunch owner.
119
+ */
120
+ inheritOwner: boolean
121
+ /**
122
+ * Default *false*. If *true*, the container is not changed when a new DTElement is added.
123
+ * If *false*, when a new DTElement is added, the container of this element becomes automatically the current bunch instance
124
+ * and the element is removed from the old container Component (if defined).
125
+ */
126
+ virtualContainer: boolean
127
+ }
128
+
129
+ export interface DTBunchToObject<IComponentMeta> extends DTComponentToObject {
130
+ items: Array<DTElementToObject<DTAcceptedMetaData>>
131
+ owner?: string
132
+ meta?: Partial<IComponentMeta>
133
+ }
134
+
135
+ export interface DTBunchFilters {
136
+ id: Partial<DYOFinderFilterOperatorBase>
137
+ key: Partial<DYOFinderFilterOperatorBase>
138
+ container: Partial<DYOFinderFilterOperatorBase>
139
+ owner: Partial<DYOFinderFilterOperatorBase>
140
+ meta: Record<string, Partial<DYOFinderFilterOperatorBase & DYOFinderFilterOperatorAdvanced>>
141
+ }
142
+
143
+ export interface DTBunchToDIXObject extends DTComponentToDIXObject {
144
+ componentType: 'bunch'
145
+ items: string[]
146
+ scope?: string
147
+ }
148
+
149
+ /** DTManager interfaces * */
150
+ export type DTManagerItemsType<IBunchItem extends DTElement<DTAcceptedMetaData>> = Record<string, DTManagerItemType<IBunchItem>>;
151
+ export type DTManagerItemType<IBunchItem extends DTElement<DTAcceptedMetaData>> = {
152
+ scope: string,
153
+ item: DTBunch<IBunchItem>,
154
+ };
155
+
156
+ export interface DTManagerFilters extends DYOFinderFilters {
157
+ id: Partial<DYOFinderFilterOperatorBase>
158
+ key: Partial<DYOFinderFilterOperatorBase>
159
+ owner: Partial<DYOFinderFilterOperatorBase>
160
+ scope: Partial<DYOFinderFilterOperatorBase>
161
+ meta: Record<string, Partial<DYOFinderFilterOperatorBase & DYOFinderFilterOperatorAdvanced>>
162
+ }
163
+
164
+ /**
165
+ * DTManager option configuration.
166
+ */
167
+ export interface DTManagerOptions extends DTComponentOptions {
168
+ /**
169
+ * Default *false*. If *true*, when a bunch instance is removed from the Manager _items, the process performs also
170
+ * a removal from the Manager Library of all DTElement instances of the bunch.
171
+ */
172
+ libraryDeletion: boolean,
173
+ }
174
+
175
+ export interface DTManagerToObject extends DTComponentToObject {
176
+ items: Array<DTBunchToObject<DTAcceptedMetaData> & { scope: string }>
177
+ }
178
+
179
+ /** DTModule interfaces * */
180
+ export interface DTModuleToObject extends DTComponentToObject {
181
+ enabled: boolean
182
+ }
183
+
184
+ /** DTMaster interfaces * */
185
+ export interface DTMasterToObject extends DTComponentToObject {
186
+ managers: Array<DTManagerToObject>,
187
+ actions: Array<DTComponentToObject>,
188
+ modules: Array<DTModuleToObject>,
189
+ }
190
+
191
+ /** Final DIX Object typing * */
192
+ export interface DIXObject {
193
+ useClass: string,
194
+ key: string
195
+ componentType: string,
196
+ options: string
197
+ meta?: string
198
+ owner?: string
199
+ items?: string[]
200
+ library?: string
201
+ scope?: string,
202
+ scopes?: string[],
203
+ [key: string]: unknown,
204
+ }
@@ -1,6 +1,5 @@
1
- import { DTPlayer } from '../index';
2
-
3
- export interface DTPlayerManagerSimpleConfiguration {
4
- players?: number | DTPlayer[];
5
- errors?: boolean;
6
- }
1
+ import { DTPlayer } from '../index';
2
+
3
+ export interface DTPlayerManagerSimpleConfiguration {
4
+ players?: number | DTPlayer[];
5
+ }
@@ -17,38 +17,22 @@ export const action1ToObject: DTComponentToObject = {
17
17
  type: 'action'
18
18
  }
19
19
 
20
- /******************** STUB ABSTRACT IMPLEMENTATION
21
- * Implementation of abstract component class for tests
22
- * *****/
23
- export class DTActionImpl extends DTAction<string> {
24
- async execute(payload: string): Promise<void> {
25
- throw `${this._key} : ${payload}`;
26
- }
27
- }
28
-
29
20
  /** ****************** HELPER TEST CLASS
30
21
  * Helper test class, inherits the main component
31
22
  * Providing methods to property access and other facilities, in order to avoid using class methods
32
23
  * **** */
33
- export class DTActionTest extends DTActionImpl {
34
- th_get_id(): string {
35
- return this._id;
36
- }
24
+ export class DTActionTest extends DTAction<string> {
37
25
 
38
- th_set_id(id: string): void {
26
+ constructor(
27
+ id: string = IDTest,
28
+ key: string = KeyTest,
29
+ ) {
30
+ super(key);
39
31
  this._id = id;
40
32
  }
41
33
 
42
- th_get_key(): string {
43
- return this._key;
44
- }
45
-
46
- th_set_key(key: string): void {
47
- this._key = key;
48
- }
49
-
50
- th_get_componentType(): string {
51
- return this._componentType;
34
+ async execute(payload: string): Promise<void> {
35
+ throw `${this._key} : ${payload}`;
52
36
  }
53
37
  }
54
38
 
@@ -64,12 +48,12 @@ export class DTActionStub extends DTActionTest {
64
48
  this._errors = [];
65
49
  }
66
50
 
67
- getId(): string {
68
- return IDTest;
51
+ _setId(id: string) {
52
+ this._id = id;
69
53
  }
70
54
 
71
- getKey(): string {
72
- return KeyTest;
55
+ _setKey(key: string) {
56
+ this._key = key;
73
57
  }
74
58
  }
75
59
 
@@ -1,24 +1,14 @@
1
- import {DTComponent, DTAction} from "../../src";
2
- import {mockOverriddenMethods} from "./DTComponent.double";
1
+ import {DTAction, DTComponent} from "../../src";
3
2
  import {afterEach, beforeEach, describe, expect, jest, test} from "@jest/globals";
4
3
  import {DTActionTest, IDTest, KeyTest} from "./DTAction.double";
5
4
 
6
- /** ****************** MOCK DEPENDENCIES
7
- * Dependencies used by the component are mocked with Jest
8
- * **** */
9
- jest.mock('../../src/core/DTComponent');
10
- jest.mock('../../src/core/DTError');
11
- // Add specific mock for inherited methods to have a basic implementation
12
- mockOverriddenMethods(DTComponent);
13
-
14
5
  /** *********************** TESTS SUITES ****************************** */
15
- describe('class DYOToolsAction', () => {
6
+ describe('class DTAction' +
7
+ '', () => {
16
8
  let actionTest: DTActionTest;
17
9
 
18
10
  beforeEach(() => {
19
11
  actionTest = new DTActionTest();
20
- actionTest.th_set_id(IDTest);
21
- actionTest.th_set_key(KeyTest);
22
12
  });
23
13
 
24
14
  afterEach(() => {
@@ -33,16 +23,18 @@ describe('class DYOToolsAction', () => {
33
23
 
34
24
  describe('_componentType', () => {
35
25
  test('componentType must be "action"', () => {
36
- expect(actionTest.th_get_componentType()).toBe('action');
26
+ expect(actionTest.getComponentType()).toBe('action');
37
27
  });
38
28
  });
39
29
 
40
30
  describe('getMaster', () => {
41
31
  test('call get context with master accessor', () => {
32
+ const getContextSpy = jest.spyOn(actionTest, 'getContext');
33
+
42
34
  actionTest.getMaster();
43
35
 
44
- expect((actionTest.getContext as any).mock.calls.length).toBe(1);
45
- expect((actionTest.getContext as any).mock.calls[0][0]).toBe('master');
36
+ expect(getContextSpy.mock.calls.length).toBe(1);
37
+ expect(getContextSpy.mock.calls[0][0]).toBe('master');
46
38
  });
47
39
  });
48
40