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.
- package/.c8rc.json +4 -4
- package/.eslintignore +1 -1
- package/.eslintrc.json +47 -47
- package/Makefile +34 -34
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +24 -20
- package/dist/constants.js.map +1 -1
- package/dist/core/DTAction.d.ts +6 -4
- package/dist/core/DTAction.d.ts.map +1 -0
- package/dist/core/DTAction.js +3 -6
- package/dist/core/DTAction.js.map +1 -1
- package/dist/core/DTBunch.d.ts +8 -5
- package/dist/core/DTBunch.d.ts.map +1 -0
- package/dist/core/DTBunch.js +54 -20
- package/dist/core/DTBunch.js.map +1 -1
- package/dist/core/DTComponent.d.ts +13 -10
- package/dist/core/DTComponent.d.ts.map +1 -0
- package/dist/core/DTComponent.js +23 -10
- package/dist/core/DTComponent.js.map +1 -1
- package/dist/core/DTComponentPhysical.d.ts +11 -7
- package/dist/core/DTComponentPhysical.d.ts.map +1 -0
- package/dist/core/DTComponentPhysical.js +21 -6
- package/dist/core/DTComponentPhysical.js.map +1 -1
- package/dist/core/DTComponentWithMeta.d.ts +6 -3
- package/dist/core/DTComponentWithMeta.d.ts.map +1 -0
- package/dist/core/DTComponentWithMeta.js +21 -7
- package/dist/core/DTComponentWithMeta.js.map +1 -1
- package/dist/core/DTElement.d.ts +10 -8
- package/dist/core/DTElement.d.ts.map +1 -0
- package/dist/core/DTElement.js +8 -9
- package/dist/core/DTElement.js.map +1 -1
- package/dist/core/DTError.d.ts +8 -7
- package/dist/core/DTError.d.ts.map +1 -0
- package/dist/core/DTError.js +1 -5
- package/dist/core/DTError.js.map +1 -1
- package/dist/core/DTManager.d.ts +17 -14
- package/dist/core/DTManager.d.ts.map +1 -0
- package/dist/core/DTManager.js +84 -26
- package/dist/core/DTManager.js.map +1 -1
- package/dist/core/DTMaster.d.ts +19 -16
- package/dist/core/DTMaster.d.ts.map +1 -0
- package/dist/core/DTMaster.js +48 -31
- package/dist/core/DTMaster.js.map +1 -1
- package/dist/core/DTModule.d.ts +8 -5
- package/dist/core/DTModule.d.ts.map +1 -0
- package/dist/core/DTModule.js +6 -6
- package/dist/core/DTModule.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -28
- package/dist/index.js.map +1 -1
- package/dist/libs/DYOFinder.d.ts +1 -0
- package/dist/libs/DYOFinder.d.ts.map +1 -0
- package/dist/libs/DYOFinder.js +10 -14
- package/dist/libs/DYOFinder.js.map +1 -1
- package/dist/libs/dix/DIXModule.module.d.ts +8 -0
- package/dist/libs/dix/DIXModule.module.d.ts.map +1 -0
- package/dist/libs/dix/DIXModule.module.js +73 -0
- package/dist/libs/player/DTPlayer.element.d.ts +3 -2
- package/dist/libs/player/DTPlayer.element.d.ts.map +1 -0
- package/dist/libs/player/DTPlayer.element.js +2 -6
- package/dist/libs/player/DTPlayer.element.js.map +1 -1
- package/dist/libs/player/DTPlayer.manager.d.ts +8 -7
- package/dist/libs/player/DTPlayer.manager.d.ts.map +1 -0
- package/dist/libs/player/DTPlayer.manager.js +13 -20
- package/dist/libs/player/DTPlayer.manager.js.map +1 -1
- package/dist/tsconfig.dev.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/core.d.ts +40 -12
- package/dist/types/core.d.ts.map +1 -0
- package/dist/types/core.js +2 -6
- package/dist/types/core.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -19
- package/dist/types/index.js.map +1 -1
- package/dist/types/player.d.ts +1 -1
- package/dist/types/player.d.ts.map +1 -0
- package/dist/types/player.js +1 -3
- package/docs/assets/main.js +59 -59
- package/docs/assets/style.css +1414 -1414
- package/integration/data/components/DTHero.ts +42 -0
- package/integration/data/components/DTHeroManager.ts +11 -0
- package/integration/data/components/DTHeroPlayZone.ts +6 -0
- package/integration/data/components/DTHeroPlayerHand.ts +11 -0
- package/integration/data/components/index.ts +5 -0
- package/integration/data/in/heroIn.helper.ts +8 -0
- package/integration/data/in/playerIn.helper.ts +13 -0
- package/integration/data/out/heroOut.helper.ts +48 -0
- package/integration/endings/synchronisation.ending.ts +25 -0
- package/integration/scenes/drawCard.scene.ts +31 -0
- package/integration/scenes/empty.scene.ts +6 -0
- package/integration/scenes/playCard.scene.ts +23 -0
- package/integration/scenes/playerLeave.scene.ts +33 -0
- package/integration/stages/baseDix.stage.ts +137 -0
- package/integration/stages/syncDix.stage.ts +36 -0
- package/integration/tests/scenario1.spec.ts +55 -0
- package/integration/types/index.ts +24 -0
- package/jest-integration.config.ts +25 -0
- package/jest.config.ts +26 -0
- package/package.json +31 -19
- package/src/constants.ts +87 -85
- package/src/core/DTAction.ts +54 -52
- package/src/core/DTBunch.ts +531 -467
- package/src/core/DTComponent.ts +258 -225
- package/src/core/DTComponentPhysical.ts +88 -53
- package/src/core/DTComponentWithMeta.ts +98 -65
- package/src/core/DTElement.ts +111 -102
- package/src/core/DTError.ts +78 -78
- package/src/core/DTManager.ts +555 -465
- package/src/core/DTMaster.ts +366 -318
- package/src/core/DTModule.ts +96 -90
- package/src/libs/dix/DIXModule.module.ts +98 -0
- package/src/libs/player/DTPlayer.element.ts +9 -9
- package/src/libs/player/DTPlayer.manager.ts +70 -84
- package/src/types/core.ts +204 -169
- package/src/types/player.ts +5 -6
- package/test/core/DTAction.double.ts +12 -28
- package/test/core/DTAction.spec.ts +8 -16
- package/test/core/DTBunch.double.ts +49 -135
- package/test/core/DTBunch.spec.ts +163 -238
- package/test/core/DTComponent.double.ts +17 -2
- package/test/core/DTComponent.spec.ts +6 -4
- package/test/core/DTComponentPhysical.double.ts +29 -43
- package/test/core/DTComponentPhysical.spec.ts +22 -19
- package/test/core/DTComponentWithMeta.double.ts +38 -31
- package/test/core/DTComponentWithMeta.spec.ts +23 -18
- package/test/core/DTElement.double.ts +32 -53
- package/test/core/DTElement.spec.ts +15 -38
- package/test/core/DTError.double.ts +18 -53
- package/test/core/DTError.spec.ts +21 -32
- package/test/core/DTManager.double.ts +74 -141
- package/test/core/DTManager.spec.ts +289 -380
- package/test/core/DTMaster.double.ts +56 -80
- package/test/core/DTMaster.spec.ts +185 -232
- package/test/core/DTModule.double.ts +12 -25
- package/test/core/DTModule.spec.ts +14 -28
- package/test/core/copy.spec.ts +9 -30
- package/tsconfig.dev.json +5 -8
- package/tsconfig.json +5 -8
- package/cucumber-report.html +0 -48
- package/docs/assets/navigation.js +0 -1
- package/docs/classes/core_DTAction.DYOToolsAction.html +0 -89
- package/docs/classes/core_DTBunch.DYOToolsBunch.html +0 -254
- package/docs/classes/core_DTComponent.DYOToolsComponent.html +0 -76
- package/docs/classes/core_DTComponentPhysical.DYOToolsComponentPhysical.html +0 -110
- package/docs/classes/core_DTComponentWithMeta.DYOToolsComponentWithMeta.html +0 -96
- package/docs/classes/core_DTElement.DYOToolsElement.html +0 -135
- package/docs/classes/core_DTError.DYOToolsError.html +0 -37
- package/docs/classes/core_DTManager.DYOToolsManager.html +0 -237
- package/docs/classes/core_DTMaster.DYOToolsMaster.html +0 -150
- package/docs/classes/core_DTModule.DYOToolsModule.html +0 -92
- package/docs/classes/libs_DYOFinder.DYOFinder.html +0 -34
- package/docs/classes/libs_player_DTPlayer_element.DYOToolsPlayer.html +0 -134
- package/docs/classes/libs_player_DTPlayer_manager.DYOToolsPlayerManager.html +0 -243
- package/docs/enums/types_core.FilterOperatorType.html +0 -10
- package/docs/hierarchy.html +0 -1
- package/docs/interfaces/types_core.DTBunchFilters.html +0 -6
- package/docs/interfaces/types_core.DTBunchOptions.html +0 -19
- package/docs/interfaces/types_core.DTBunchToObject.html +0 -7
- package/docs/interfaces/types_core.DTComponentOptions.html +0 -5
- package/docs/interfaces/types_core.DTComponentToObject.html +0 -4
- package/docs/interfaces/types_core.DTElementToObject.html +0 -7
- package/docs/interfaces/types_core.DTManagerFilters.html +0 -6
- package/docs/interfaces/types_core.DTManagerOptions.html +0 -8
- package/docs/interfaces/types_core.DTManagerToObject.html +0 -5
- package/docs/interfaces/types_core.DTMasterToObject.html +0 -8
- package/docs/interfaces/types_core.DTModuleToObject.html +0 -6
- package/docs/interfaces/types_core.DYOFinderConfigurationPropDefault.html +0 -4
- package/docs/interfaces/types_core.DYOFinderConfigurationPropObjectSearch.html +0 -4
- package/docs/interfaces/types_core.DYOFinderFilterOperatorAdvanced.html +0 -5
- package/docs/interfaces/types_core.DYOFinderFilterOperatorBase.html +0 -5
- package/docs/interfaces/types_player.DTPlayerManagerSimpleConfiguration.html +0 -3
- package/docs/modules/constants.html +0 -6
- package/docs/modules/core_DTAction.html +0 -2
- package/docs/modules/core_DTBunch.html +0 -2
- package/docs/modules/core_DTComponent.html +0 -2
- package/docs/modules/core_DTComponentPhysical.html +0 -2
- package/docs/modules/core_DTComponentWithMeta.html +0 -2
- package/docs/modules/core_DTElement.html +0 -2
- package/docs/modules/core_DTError.html +0 -2
- package/docs/modules/core_DTManager.html +0 -2
- package/docs/modules/core_DTMaster.html +0 -2
- package/docs/modules/core_DTModule.html +0 -2
- package/docs/modules/libs_DYOFinder.html +0 -2
- package/docs/modules/libs_player_DTPlayer_element.html +0 -2
- package/docs/modules/libs_player_DTPlayer_manager.html +0 -2
- package/docs/modules/types.html +0 -29
- package/docs/modules/types_core.html +0 -28
- package/docs/modules/types_player.html +0 -2
- package/docs/types/types_core.DTAcceptedMetaData.html +0 -2
- package/docs/types/types_core.DTManagerItemType.html +0 -1
- package/docs/types/types_core.DTManagerItemsType.html +0 -2
- package/docs/types/types_core.DYOFinderComponentType.html +0 -1
- package/docs/types/types_core.DYOFinderConfiguration.html +0 -2
- package/docs/types/types_core.DYOFinderConfigurationProp.html +0 -1
- package/docs/types/types_core.DYOFinderFilterOperator.html +0 -1
- package/docs/types/types_core.DYOFinderFilterOperatorArgument.html +0 -1
- package/docs/types/types_core.DYOFinderFilters.html +0 -1
- package/docs/types/types_core.StandardPrimitiveType.html +0 -2
- package/docs/types/types_core.StandardPrimitiveTypeWithArray.html +0 -1
- package/docs/variables/constants.bunchDefaultOptions.html +0 -2
- package/docs/variables/constants.componentBunchDefaultFinderConfiguration.html +0 -1
- package/docs/variables/constants.componentManagerDefaultFinderConfiguration.html +0 -1
- package/docs/variables/constants.componentPhysicalDefaultFinderConfiguration.html +0 -1
- package/docs/variables/constants.managerDefaultOptions.html +0 -2
- package/jest.config.js +0 -6
package/src/types/core.ts
CHANGED
|
@@ -1,169 +1,204 @@
|
|
|
1
|
-
import { DTBunch, DTComponent } from '../index';
|
|
2
|
-
import
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
string
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
owner: Partial<DYOFinderFilterOperatorBase>
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
+
}
|
package/src/types/player.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { DTPlayer } from '../index';
|
|
2
|
-
|
|
3
|
-
export interface DTPlayerManagerSimpleConfiguration {
|
|
4
|
-
players?: number | DTPlayer[];
|
|
5
|
-
|
|
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
|
|
34
|
-
th_get_id(): string {
|
|
35
|
-
return this._id;
|
|
36
|
-
}
|
|
24
|
+
export class DTActionTest extends DTAction<string> {
|
|
37
25
|
|
|
38
|
-
|
|
26
|
+
constructor(
|
|
27
|
+
id: string = IDTest,
|
|
28
|
+
key: string = KeyTest,
|
|
29
|
+
) {
|
|
30
|
+
super(key);
|
|
39
31
|
this._id = id;
|
|
40
32
|
}
|
|
41
33
|
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
68
|
-
|
|
51
|
+
_setId(id: string) {
|
|
52
|
+
this._id = id;
|
|
69
53
|
}
|
|
70
54
|
|
|
71
|
-
|
|
72
|
-
|
|
55
|
+
_setKey(key: string) {
|
|
56
|
+
this._key = key;
|
|
73
57
|
}
|
|
74
58
|
}
|
|
75
59
|
|
|
@@ -1,24 +1,14 @@
|
|
|
1
|
-
import {
|
|
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
|
|
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.
|
|
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(
|
|
45
|
-
expect(
|
|
36
|
+
expect(getContextSpy.mock.calls.length).toBe(1);
|
|
37
|
+
expect(getContextSpy.mock.calls[0][0]).toBe('master');
|
|
46
38
|
});
|
|
47
39
|
});
|
|
48
40
|
|