dyo-tools 0.4.0 → 0.4.1
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/{dist/index.d.ts → index.d.ts} +1 -0
- package/{dist/index.d.ts.map → index.d.ts.map} +1 -1
- package/{dist/index.js → index.js} +1 -0
- package/package.json +6 -56
- package/.c8rc.json +0 -4
- package/.eslintignore +0 -2
- package/.eslintrc.json +0 -47
- package/Makefile +0 -34
- package/README.md +0 -0
- package/babel.config.js +0 -1
- package/docs/.nojekyll +0 -1
- package/docs/assets/highlight.css +0 -29
- package/docs/assets/main.js +0 -59
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1414
- package/docs/index.html +0 -1
- package/integration/data/components/DTHero.ts +0 -42
- package/integration/data/components/DTHeroManager.ts +0 -11
- package/integration/data/components/DTHeroPlayZone.ts +0 -6
- package/integration/data/components/DTHeroPlayerHand.ts +0 -11
- package/integration/data/components/index.ts +0 -5
- package/integration/data/in/heroIn.helper.ts +0 -8
- package/integration/data/in/playerIn.helper.ts +0 -13
- package/integration/data/out/heroOut.helper.ts +0 -48
- package/integration/endings/synchronisation.ending.ts +0 -25
- package/integration/scenes/drawCard.scene.ts +0 -31
- package/integration/scenes/empty.scene.ts +0 -6
- package/integration/scenes/playCard.scene.ts +0 -23
- package/integration/scenes/playerLeave.scene.ts +0 -33
- package/integration/stages/baseDix.stage.ts +0 -137
- package/integration/stages/syncDix.stage.ts +0 -36
- package/integration/tests/scenario1.spec.ts +0 -55
- package/integration/types/index.ts +0 -24
- package/jest-integration.config.ts +0 -25
- package/jest.config.ts +0 -26
- package/src/constants.ts +0 -87
- package/src/core/DTAction.ts +0 -54
- package/src/core/DTBunch.ts +0 -531
- package/src/core/DTComponent.ts +0 -258
- package/src/core/DTComponentPhysical.ts +0 -88
- package/src/core/DTComponentWithMeta.ts +0 -98
- package/src/core/DTElement.ts +0 -111
- package/src/core/DTError.ts +0 -78
- package/src/core/DTManager.ts +0 -555
- package/src/core/DTMaster.ts +0 -366
- package/src/core/DTModule.ts +0 -96
- package/src/index.ts +0 -17
- package/src/libs/DYOFinder.ts +0 -175
- package/src/libs/dix/DIXModule.module.ts +0 -98
- package/src/libs/player/DTPlayer.element.ts +0 -9
- package/src/libs/player/DTPlayer.manager.ts +0 -70
- package/src/types/core.ts +0 -204
- package/src/types/index.ts +0 -2
- package/src/types/player.ts +0 -5
- package/test/core/DTAction.double.ts +0 -62
- package/test/core/DTAction.spec.ts +0 -68
- package/test/core/DTBunch.double.ts +0 -175
- package/test/core/DTBunch.spec.ts +0 -822
- package/test/core/DTComponent.double.ts +0 -179
- package/test/core/DTComponent.spec.ts +0 -297
- package/test/core/DTComponentPhysical.double.ts +0 -62
- package/test/core/DTComponentPhysical.spec.ts +0 -81
- package/test/core/DTComponentWithMeta.double.ts +0 -122
- package/test/core/DTComponentWithMeta.spec.ts +0 -129
- package/test/core/DTElement.double.ts +0 -142
- package/test/core/DTElement.spec.ts +0 -123
- package/test/core/DTError.double.ts +0 -57
- package/test/core/DTError.spec.ts +0 -78
- package/test/core/DTManager.double.ts +0 -149
- package/test/core/DTManager.spec.ts +0 -874
- package/test/core/DTMaster.double.ts +0 -117
- package/test/core/DTMaster.spec.ts +0 -537
- package/test/core/DTModule.double.ts +0 -67
- package/test/core/DTModule.spec.ts +0 -124
- package/test/core/copy.spec.ts +0 -222
- package/test/libs/DYOFinder.double.ts +0 -152
- package/test/libs/DYOFinder.spec.ts +0 -194
- package/test/libs/player/DTPlayer.element.double.ts +0 -55
- package/test/libs/player/DTPlayer.element.spec.ts +0 -28
- package/test/libs/player/DTPlayer.manager.double.ts +0 -92
- package/test/libs/player/DTPlayer.manager.spec.ts +0 -178
- package/tsconfig.dev.json +0 -19
- package/tsconfig.json +0 -18
- /package/{dist/constants.d.ts → constants.d.ts} +0 -0
- /package/{dist/constants.d.ts.map → constants.d.ts.map} +0 -0
- /package/{dist/constants.js → constants.js} +0 -0
- /package/{dist/constants.js.map → constants.js.map} +0 -0
- /package/{dist/core → core}/DTAction.d.ts +0 -0
- /package/{dist/core → core}/DTAction.d.ts.map +0 -0
- /package/{dist/core → core}/DTAction.js +0 -0
- /package/{dist/core → core}/DTAction.js.map +0 -0
- /package/{dist/core → core}/DTBunch.d.ts +0 -0
- /package/{dist/core → core}/DTBunch.d.ts.map +0 -0
- /package/{dist/core → core}/DTBunch.js +0 -0
- /package/{dist/core → core}/DTBunch.js.map +0 -0
- /package/{dist/core → core}/DTComponent.d.ts +0 -0
- /package/{dist/core → core}/DTComponent.d.ts.map +0 -0
- /package/{dist/core → core}/DTComponent.js +0 -0
- /package/{dist/core → core}/DTComponent.js.map +0 -0
- /package/{dist/core → core}/DTComponentPhysical.d.ts +0 -0
- /package/{dist/core → core}/DTComponentPhysical.d.ts.map +0 -0
- /package/{dist/core → core}/DTComponentPhysical.js +0 -0
- /package/{dist/core → core}/DTComponentPhysical.js.map +0 -0
- /package/{dist/core → core}/DTComponentWithMeta.d.ts +0 -0
- /package/{dist/core → core}/DTComponentWithMeta.d.ts.map +0 -0
- /package/{dist/core → core}/DTComponentWithMeta.js +0 -0
- /package/{dist/core → core}/DTComponentWithMeta.js.map +0 -0
- /package/{dist/core → core}/DTElement.d.ts +0 -0
- /package/{dist/core → core}/DTElement.d.ts.map +0 -0
- /package/{dist/core → core}/DTElement.js +0 -0
- /package/{dist/core → core}/DTElement.js.map +0 -0
- /package/{dist/core → core}/DTError.d.ts +0 -0
- /package/{dist/core → core}/DTError.d.ts.map +0 -0
- /package/{dist/core → core}/DTError.js +0 -0
- /package/{dist/core → core}/DTError.js.map +0 -0
- /package/{dist/core → core}/DTManager.d.ts +0 -0
- /package/{dist/core → core}/DTManager.d.ts.map +0 -0
- /package/{dist/core → core}/DTManager.js +0 -0
- /package/{dist/core → core}/DTManager.js.map +0 -0
- /package/{dist/core → core}/DTMaster.d.ts +0 -0
- /package/{dist/core → core}/DTMaster.d.ts.map +0 -0
- /package/{dist/core → core}/DTMaster.js +0 -0
- /package/{dist/core → core}/DTMaster.js.map +0 -0
- /package/{dist/core → core}/DTModule.d.ts +0 -0
- /package/{dist/core → core}/DTModule.d.ts.map +0 -0
- /package/{dist/core → core}/DTModule.js +0 -0
- /package/{dist/core → core}/DTModule.js.map +0 -0
- /package/{dist/index.js.map → index.js.map} +0 -0
- /package/{dist/libs → libs}/DYOFinder.d.ts +0 -0
- /package/{dist/libs → libs}/DYOFinder.d.ts.map +0 -0
- /package/{dist/libs → libs}/DYOFinder.js +0 -0
- /package/{dist/libs → libs}/DYOFinder.js.map +0 -0
- /package/{dist/libs → libs}/dix/DIXModule.module.d.ts +0 -0
- /package/{dist/libs → libs}/dix/DIXModule.module.d.ts.map +0 -0
- /package/{dist/libs → libs}/dix/DIXModule.module.js +0 -0
- /package/{dist/libs → libs}/player/DTPlayer.element.d.ts +0 -0
- /package/{dist/libs → libs}/player/DTPlayer.element.d.ts.map +0 -0
- /package/{dist/libs → libs}/player/DTPlayer.element.js +0 -0
- /package/{dist/libs → libs}/player/DTPlayer.element.js.map +0 -0
- /package/{dist/libs → libs}/player/DTPlayer.manager.d.ts +0 -0
- /package/{dist/libs → libs}/player/DTPlayer.manager.d.ts.map +0 -0
- /package/{dist/libs → libs}/player/DTPlayer.manager.js +0 -0
- /package/{dist/libs → libs}/player/DTPlayer.manager.js.map +0 -0
- /package/{dist/tsconfig.dev.tsbuildinfo → tsconfig.dev.tsbuildinfo} +0 -0
- /package/{dist/tsconfig.tsbuildinfo → tsconfig.tsbuildinfo} +0 -0
- /package/{dist/types → types}/core.d.ts +0 -0
- /package/{dist/types → types}/core.d.ts.map +0 -0
- /package/{dist/types → types}/core.js +0 -0
- /package/{dist/types → types}/core.js.map +0 -0
- /package/{dist/types → types}/index.d.ts +0 -0
- /package/{dist/types → types}/index.d.ts.map +0 -0
- /package/{dist/types → types}/index.js +0 -0
- /package/{dist/types → types}/index.js.map +0 -0
- /package/{dist/types → types}/player.d.ts +0 -0
- /package/{dist/types → types}/player.d.ts.map +0 -0
- /package/{dist/types → types}/player.js +0 -0
- /package/{dist/types → types}/player.js.map +0 -0
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import * as CoreComponents from '../../index';
|
|
2
|
-
import { DIXObject } from '../../types';
|
|
3
|
-
|
|
4
|
-
type DTElementClass = new (key: string, options: Record<string, unknown>) => CoreComponents.DTComponent;
|
|
5
|
-
type DTBunchClass = new (key: string, items: unknown[], options: Record<string, unknown>) => CoreComponents.DTComponent;
|
|
6
|
-
type DTManagerClass = new (key: string, items: unknown[], scopes: unknown[], options: Record<string, unknown>) => CoreComponents.DTComponent;
|
|
7
|
-
type DTMasterClass = DTElementClass;
|
|
8
|
-
|
|
9
|
-
export default class DTDIXModule extends CoreComponents.DTModule {
|
|
10
|
-
overrides: Record<string, unknown>;
|
|
11
|
-
|
|
12
|
-
constructor(overrides: Record<string, unknown> = {}) {
|
|
13
|
-
super('dix');
|
|
14
|
-
this.overrides = {
|
|
15
|
-
...CoreComponents,
|
|
16
|
-
...overrides,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
syncNewItem(id: string, dix: Record<string, DIXObject>): CoreComponents.DTComponent | undefined {
|
|
21
|
-
const dixObject = dix[id];
|
|
22
|
-
let instance: CoreComponents.DTComponent | undefined;
|
|
23
|
-
const errorsEnabled = this._options.errors;
|
|
24
|
-
|
|
25
|
-
if (dixObject) {
|
|
26
|
-
switch (dixObject.componentType) {
|
|
27
|
-
case 'bunch':
|
|
28
|
-
try {
|
|
29
|
-
const UseClass = this.overrides[dixObject.useClass] as DTBunchClass;
|
|
30
|
-
instance = new UseClass(dixObject.key, [], { ...(JSON.parse(dixObject.options) ?? {}), syncId: id });
|
|
31
|
-
} catch (err: unknown) {
|
|
32
|
-
if (errorsEnabled) {
|
|
33
|
-
const UseClass = this.overrides.DTBunch as DTBunchClass;
|
|
34
|
-
instance = new UseClass(dixObject.key, [], { ...(JSON.parse(dixObject.options) ?? {}), syncId: id });
|
|
35
|
-
}
|
|
36
|
-
this.triggerError(new CoreComponents.DTError(
|
|
37
|
-
'dix_module_instance_error',
|
|
38
|
-
`Bunch Class ${dixObject.useClass} doesn't exist in DIX Module`,
|
|
39
|
-
this,
|
|
40
|
-
));
|
|
41
|
-
}
|
|
42
|
-
break;
|
|
43
|
-
case 'manager':
|
|
44
|
-
try {
|
|
45
|
-
const UseClass = this.overrides[dixObject.useClass] as DTManagerClass;
|
|
46
|
-
instance = new UseClass(dixObject.key, [], [], { ...(JSON.parse(dixObject.options) ?? {}), syncId: id });
|
|
47
|
-
} catch (err: unknown) {
|
|
48
|
-
if (errorsEnabled) {
|
|
49
|
-
const UseClass = this.overrides.DTManager as DTManagerClass;
|
|
50
|
-
instance = new UseClass(dixObject.key, [], [], { ...(JSON.parse(dixObject.options) ?? {}), syncId: id });
|
|
51
|
-
}
|
|
52
|
-
this.triggerError(new CoreComponents.DTError(
|
|
53
|
-
'dix_module_instance_error',
|
|
54
|
-
`Manager Class ${dixObject.useClass} doesn't exist in DIX Module`,
|
|
55
|
-
this,
|
|
56
|
-
));
|
|
57
|
-
}
|
|
58
|
-
break;
|
|
59
|
-
case 'master':
|
|
60
|
-
try {
|
|
61
|
-
const UseClass = this.overrides[dixObject.useClass] as DTMasterClass;
|
|
62
|
-
instance = new UseClass(dixObject.key, { ...(JSON.parse(dixObject.options) ?? {}), syncId: id });
|
|
63
|
-
} catch (err: unknown) {
|
|
64
|
-
if (errorsEnabled) {
|
|
65
|
-
const UseClass = this.overrides.DTElement as DTMasterClass;
|
|
66
|
-
instance = new UseClass(dixObject.key, { ...(JSON.parse(dixObject.options) ?? {}), syncId: id });
|
|
67
|
-
}
|
|
68
|
-
this.triggerError(new CoreComponents.DTError(
|
|
69
|
-
'dix_module_instance_error',
|
|
70
|
-
`Master Class ${dixObject.useClass} doesn't exist in DIX Module`,
|
|
71
|
-
this,
|
|
72
|
-
));
|
|
73
|
-
}
|
|
74
|
-
break;
|
|
75
|
-
case 'element':
|
|
76
|
-
default:
|
|
77
|
-
try {
|
|
78
|
-
const UseClass = this.overrides[dixObject.useClass] as DTElementClass;
|
|
79
|
-
instance = new UseClass(dixObject.key, { ...(JSON.parse(dixObject.options) ?? {}), syncId: id });
|
|
80
|
-
// console.log('Je test pour : ', instance.getKey(), instance.getId(), instance.getOptions(), id);
|
|
81
|
-
} catch (err: unknown) {
|
|
82
|
-
if (errorsEnabled) {
|
|
83
|
-
const UseClass = this.overrides.DTElement as DTElementClass;
|
|
84
|
-
instance = new UseClass(dixObject.key, { ...(JSON.parse(dixObject.options) ?? {}), syncId: id });
|
|
85
|
-
}
|
|
86
|
-
this.triggerError(new CoreComponents.DTError(
|
|
87
|
-
'dix_module_instance_error',
|
|
88
|
-
`Element Class ${dixObject.useClass} doesn't exist in DIX Module`,
|
|
89
|
-
this,
|
|
90
|
-
));
|
|
91
|
-
}
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return instance;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DTAcceptedMetaData } from '../../types';
|
|
2
|
-
import DTElement from '../../core/DTElement';
|
|
3
|
-
|
|
4
|
-
export default class DTPlayer<IComponentMeta extends DTAcceptedMetaData = DTAcceptedMetaData> extends DTElement<IComponentMeta> {
|
|
5
|
-
/**
|
|
6
|
-
* Defining component domain to "player".
|
|
7
|
-
*/
|
|
8
|
-
protected _domain = 'player';
|
|
9
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import DTManager from '../../core/DTManager';
|
|
2
|
-
import DTPlayer from './DTPlayer.element';
|
|
3
|
-
import { DTBunchFilters, DTPlayerManagerSimpleConfiguration } from '../../types';
|
|
4
|
-
|
|
5
|
-
export default class DTPlayerManager extends DTManager<DTPlayer> {
|
|
6
|
-
/**
|
|
7
|
-
* Defining component domain to "player".
|
|
8
|
-
*/
|
|
9
|
-
protected _domain = 'player';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Simply configure the manager with a configuration JSON Object
|
|
13
|
-
* **players** : Default player configuration.
|
|
14
|
-
* If **players** is a number, it generates this number of DTPlayer instances and add it to the library.
|
|
15
|
-
* If **players** is an array of DTPlayer instances, it adds these to the library.
|
|
16
|
-
*
|
|
17
|
-
* @param configuration DTPlayerManagerSimpleConfiguration Optional configuration to apply.
|
|
18
|
-
*/
|
|
19
|
-
configure(configuration: DTPlayerManagerSimpleConfiguration) {
|
|
20
|
-
if (configuration.players) {
|
|
21
|
-
if (typeof configuration.players === 'number' && configuration.players > 0) {
|
|
22
|
-
let i = 1;
|
|
23
|
-
while (i <= configuration.players) {
|
|
24
|
-
const player = new DTPlayer(`player${i}`);
|
|
25
|
-
this._library.add(player);
|
|
26
|
-
i += 1;
|
|
27
|
-
}
|
|
28
|
-
} else if (Array.isArray(configuration.players)) {
|
|
29
|
-
this._library.addMany(configuration.players);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Get one DTPlayer instance by id into the library.
|
|
36
|
-
*
|
|
37
|
-
* @param id string _id property of the DTPlayer instance to get.
|
|
38
|
-
*/
|
|
39
|
-
getPlayer(id: string): DTPlayer {
|
|
40
|
-
return this._library.get(id);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Add one DTPlayer instance into the library.
|
|
45
|
-
*
|
|
46
|
-
* @param player DYOToolsPlayer instance to add.
|
|
47
|
-
*/
|
|
48
|
-
addPlayer(player: DTPlayer): void {
|
|
49
|
-
this._library.add(player);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Remove one DTPlayer instance by id from the library.
|
|
54
|
-
*
|
|
55
|
-
* @param id string _id property of the DTPlayer instance to remove.
|
|
56
|
-
*/
|
|
57
|
-
removePlayer(id: string): void {
|
|
58
|
-
this._library.remove(id);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Find DTPlayer instances into the Library.
|
|
63
|
-
*
|
|
64
|
-
* @see [find](#find) method for search specifications.
|
|
65
|
-
* @param filters DTBunchFilters filters to apply.
|
|
66
|
-
*/
|
|
67
|
-
findPlayers(filters: Partial<DTBunchFilters>): DTPlayer[] {
|
|
68
|
-
return this._library.find(filters);
|
|
69
|
-
}
|
|
70
|
-
}
|
package/src/types/core.ts
DELETED
|
@@ -1,204 +0,0 @@
|
|
|
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/index.ts
DELETED
package/src/types/player.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import {DTAction} from "../../src";
|
|
2
|
-
import {DTComponentToObject} from "../../src/types";
|
|
3
|
-
|
|
4
|
-
/** ****************** STUB PROPERTIES CONSTANTS
|
|
5
|
-
* Fixed properties to use with double classes, avoid auto generated and easy checking on test
|
|
6
|
-
* **** */
|
|
7
|
-
export const IDTest = 'DTAction-id-1234567';
|
|
8
|
-
export const KeyTest = 'DTAction-key-1234567';
|
|
9
|
-
|
|
10
|
-
// Specific Manager constants
|
|
11
|
-
export const action1IDTest = `${IDTest}_1`;
|
|
12
|
-
export const action1KeyTest = `${KeyTest}_1`;
|
|
13
|
-
|
|
14
|
-
export const action1ToObject: DTComponentToObject = {
|
|
15
|
-
id: action1IDTest,
|
|
16
|
-
key: action1KeyTest,
|
|
17
|
-
type: 'action'
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/** ****************** HELPER TEST CLASS
|
|
21
|
-
* Helper test class, inherits the main component
|
|
22
|
-
* Providing methods to property access and other facilities, in order to avoid using class methods
|
|
23
|
-
* **** */
|
|
24
|
-
export class DTActionTest extends DTAction<string> {
|
|
25
|
-
|
|
26
|
-
constructor(
|
|
27
|
-
id: string = IDTest,
|
|
28
|
-
key: string = KeyTest,
|
|
29
|
-
) {
|
|
30
|
-
super(key);
|
|
31
|
-
this._id = id;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async execute(payload: string): Promise<void> {
|
|
35
|
-
throw `${this._key} : ${payload}`;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
/** ****************** STUB CLASS
|
|
41
|
-
* Stub class, for using in other component
|
|
42
|
-
* **** */
|
|
43
|
-
export class DTActionStub extends DTActionTest {
|
|
44
|
-
constructor() {
|
|
45
|
-
super();
|
|
46
|
-
this._id = IDTest;
|
|
47
|
-
this._key = KeyTest;
|
|
48
|
-
this._errors = [];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
_setId(id: string) {
|
|
52
|
-
this._id = id;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
_setKey(key: string) {
|
|
56
|
-
this._key = key;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/** ****************** HELPER METHODS
|
|
61
|
-
* Additional helper methods to use with testing
|
|
62
|
-
* **** */
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import {DTAction, DTComponent} from "../../src";
|
|
2
|
-
import {afterEach, beforeEach, describe, expect, jest, test} from "@jest/globals";
|
|
3
|
-
import {DTActionTest, IDTest, KeyTest} from "./DTAction.double";
|
|
4
|
-
|
|
5
|
-
/** *********************** TESTS SUITES ****************************** */
|
|
6
|
-
describe('class DTAction' +
|
|
7
|
-
'', () => {
|
|
8
|
-
let actionTest: DTActionTest;
|
|
9
|
-
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
actionTest = new DTActionTest();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
afterEach(() => {
|
|
15
|
-
jest.resetAllMocks();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
describe('inheritance', () => {
|
|
19
|
-
test('check good inheritance for class', () => {
|
|
20
|
-
expect(DTAction.prototype instanceof DTComponent).toBeTruthy();
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
describe('_componentType', () => {
|
|
25
|
-
test('componentType must be "action"', () => {
|
|
26
|
-
expect(actionTest.getComponentType()).toBe('action');
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe('getMaster', () => {
|
|
31
|
-
test('call get context with master accessor', () => {
|
|
32
|
-
const getContextSpy = jest.spyOn(actionTest, 'getContext');
|
|
33
|
-
|
|
34
|
-
actionTest.getMaster();
|
|
35
|
-
|
|
36
|
-
expect(getContextSpy.mock.calls.length).toBe(1);
|
|
37
|
-
expect(getContextSpy.mock.calls[0][0]).toBe('master');
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
describe('execute', () => {
|
|
42
|
-
test('throw payload in test implementation', async () => {
|
|
43
|
-
const payload = `execute action`;
|
|
44
|
-
const expectedPayload = `${KeyTest} : execute action`;
|
|
45
|
-
|
|
46
|
-
await expect(actionTest.execute(payload)).rejects.toBe(expectedPayload);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
describe('toString', () => {
|
|
51
|
-
test('string output standard', () => {
|
|
52
|
-
const toStringAction = actionTest.toString();
|
|
53
|
-
|
|
54
|
-
expect(toStringAction).toBe(`Component ${KeyTest} - Type: Action`);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
describe('toObject', () => {
|
|
59
|
-
test('toObject output standard', () => {
|
|
60
|
-
const toObjectAction: any = actionTest.toObject();
|
|
61
|
-
|
|
62
|
-
expect(Object.keys(toObjectAction)).toStrictEqual(['id', 'key', 'type']);
|
|
63
|
-
expect(toObjectAction.id).toBe(IDTest);
|
|
64
|
-
expect(toObjectAction.key).toBe(KeyTest);
|
|
65
|
-
expect(toObjectAction.type).toBe('action');
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
});
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import {DTBunch} from '../../src';
|
|
2
|
-
import {bunchDefaultOptions, bunchDefaultOptions as DTBunchDefaultOptions} from '../../src/constants';
|
|
3
|
-
import {
|
|
4
|
-
HaileiMetaData,
|
|
5
|
-
IldressMetaData,
|
|
6
|
-
IMetaDataTest,
|
|
7
|
-
MaydenaMetaData,
|
|
8
|
-
MeldrineMetaData,
|
|
9
|
-
YssaliaMetaData,
|
|
10
|
-
} from './DTComponentWithMeta.double';
|
|
11
|
-
import {DIXObject, DTBunchOptions, DTElementToObject} from '../../src/types';
|
|
12
|
-
import {
|
|
13
|
-
DTElementStub,
|
|
14
|
-
HaileiIdTest,
|
|
15
|
-
HaileiKeyTest,
|
|
16
|
-
HaileiToObjectTest,
|
|
17
|
-
IldressIdTest,
|
|
18
|
-
IldressKeyTest,
|
|
19
|
-
IldressToObjectTest,
|
|
20
|
-
MaydenaIdTest,
|
|
21
|
-
MaydenaKeyTest,
|
|
22
|
-
MaydenaToObjectTest,
|
|
23
|
-
MeldrineIdTest,
|
|
24
|
-
MeldrineKeyTest,
|
|
25
|
-
MeldrineToObjectTest,
|
|
26
|
-
YssaliaIdTest,
|
|
27
|
-
YssaliaKeyTest,
|
|
28
|
-
YssaliaToObjectTest,
|
|
29
|
-
} from './DTElement.double';
|
|
30
|
-
|
|
31
|
-
/** ****************** STUB PROPERTIES CONSTANTS
|
|
32
|
-
* Fixed properties to use with double classes, avoid auto generated and easy checking on test
|
|
33
|
-
* **** */
|
|
34
|
-
// Global Bunch constants
|
|
35
|
-
export const IDTest = 'DTBunch-id-1234567';
|
|
36
|
-
export const IDTestLibrary = 'DTBunch-id-library-1234567';
|
|
37
|
-
export const KeyTest = 'DTBunch-key-1234567';
|
|
38
|
-
|
|
39
|
-
// Specific Bunch constants
|
|
40
|
-
export const bunch1IdTest = `${IDTest}_1`;
|
|
41
|
-
export const bunch1toObjectTest = {
|
|
42
|
-
id: bunch1IdTest, key: KeyTest, type: 'bunch', items: [
|
|
43
|
-
HaileiToObjectTest,
|
|
44
|
-
MeldrineToObjectTest,
|
|
45
|
-
MaydenaToObjectTest,
|
|
46
|
-
IldressToObjectTest,
|
|
47
|
-
YssaliaToObjectTest
|
|
48
|
-
],
|
|
49
|
-
};
|
|
50
|
-
export const bunch2IdTest = `${IDTest}_2`;
|
|
51
|
-
export const bunch2toObjectTest = {
|
|
52
|
-
id: bunch2IdTest, key: KeyTest, type: 'bunch', items: [],
|
|
53
|
-
};
|
|
54
|
-
export const bunch3IdTest = `${IDTest}_3`;
|
|
55
|
-
export const bunch3toObjectTest = {
|
|
56
|
-
id: bunch3IdTest, key: KeyTest, type: 'bunch', items: [],
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
/** ****************** HELPER TEST CLASS
|
|
61
|
-
* Helper test class, inherits the main component
|
|
62
|
-
* Providing methods to property access and other facilities, in order to avoid using class methods
|
|
63
|
-
* **** */
|
|
64
|
-
export class DTBunchTest extends DTBunch<DTElementStub, IMetaDataTest> {
|
|
65
|
-
|
|
66
|
-
constructor(
|
|
67
|
-
id: string = IDTest,
|
|
68
|
-
key: string = KeyTest,
|
|
69
|
-
items: DTElementStub[] = [],
|
|
70
|
-
options: Partial<DTBunchOptions> = bunchDefaultOptions,
|
|
71
|
-
owner: string | undefined = undefined,
|
|
72
|
-
) {
|
|
73
|
-
super(key, items, options);
|
|
74
|
-
this._id = id;
|
|
75
|
-
this._owner = owner;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
_getFinder() {
|
|
79
|
-
return this._finder;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/** ****************** STUB CLASS
|
|
84
|
-
* Stub class, for using in other component
|
|
85
|
-
* **** */
|
|
86
|
-
export class DTBunchStub extends DTBunch<DTElementStub> {
|
|
87
|
-
constructor(items: Array<DTElementStub> = [], options: Partial<DTBunchOptions> = {}) {
|
|
88
|
-
super();
|
|
89
|
-
this._id = IDTest;
|
|
90
|
-
this._key = KeyTest;
|
|
91
|
-
this._errors = [];
|
|
92
|
-
this._items = items;
|
|
93
|
-
this._options = {
|
|
94
|
-
...DTBunchDefaultOptions,
|
|
95
|
-
...options,
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
_setId(id: string) {
|
|
100
|
-
this._id = id;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Specific Stub Library for Manager
|
|
105
|
-
export class DTBunchStubLibrary extends DTBunch<DTElementStub> {
|
|
106
|
-
constructor(items: Array<DTElementStub> = []) {
|
|
107
|
-
super();
|
|
108
|
-
this._id = IDTestLibrary;
|
|
109
|
-
this._key = 'library';
|
|
110
|
-
this._errors = [];
|
|
111
|
-
this._items = items;
|
|
112
|
-
this._options = {
|
|
113
|
-
...DTBunchDefaultOptions,
|
|
114
|
-
virtualContainer: true,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/** ****************** HELPER METHODS
|
|
120
|
-
* Additional helper methods to use with testing
|
|
121
|
-
* **** */
|
|
122
|
-
|
|
123
|
-
// Function to generate Stub DTElement collection
|
|
124
|
-
export const generateStubElements = (numberElements: number, owner?: string): DTElementStub[] => {
|
|
125
|
-
const mockedElements: DTElementStub[] = [];
|
|
126
|
-
const mockedData: Array<{ id: string, key: string, meta: IMetaDataTest, toObject: DTElementToObject<IMetaDataTest> }> = [
|
|
127
|
-
{
|
|
128
|
-
id: HaileiIdTest,
|
|
129
|
-
key: HaileiKeyTest,
|
|
130
|
-
meta: HaileiMetaData,
|
|
131
|
-
toObject: HaileiToObjectTest,
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
id: MeldrineIdTest,
|
|
135
|
-
key: MeldrineKeyTest,
|
|
136
|
-
meta: MeldrineMetaData,
|
|
137
|
-
toObject: MeldrineToObjectTest,
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
id: MaydenaIdTest,
|
|
141
|
-
key: MaydenaKeyTest,
|
|
142
|
-
meta: MaydenaMetaData,
|
|
143
|
-
toObject: MaydenaToObjectTest,
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
id: IldressIdTest,
|
|
147
|
-
key: IldressKeyTest,
|
|
148
|
-
meta: IldressMetaData,
|
|
149
|
-
toObject: IldressToObjectTest,
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
id: YssaliaIdTest,
|
|
153
|
-
key: YssaliaKeyTest,
|
|
154
|
-
meta: YssaliaMetaData,
|
|
155
|
-
toObject: YssaliaToObjectTest,
|
|
156
|
-
},
|
|
157
|
-
];
|
|
158
|
-
|
|
159
|
-
for (let i = 0; i < numberElements; i++) {
|
|
160
|
-
const selectedData = i % 5;
|
|
161
|
-
const mockedElement = new DTElementStub(
|
|
162
|
-
0,
|
|
163
|
-
(mockedData[selectedData].id + "-" + i),
|
|
164
|
-
mockedData[selectedData].key,
|
|
165
|
-
mockedData[selectedData].meta,
|
|
166
|
-
owner,
|
|
167
|
-
mockedData[selectedData].toObject,
|
|
168
|
-
);
|
|
169
|
-
|
|
170
|
-
mockedElements.push(mockedElement);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return mockedElements;
|
|
174
|
-
};
|
|
175
|
-
|