dyo-tools 0.3.0 → 0.3.2
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/core/DTBunch.js +1 -1
- package/dist/core/DTBunch.js.map +1 -1
- package/dist/core/DTComponentPhysical.d.ts +2 -1
- package/dist/core/DTComponentPhysical.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/assets/main.js +59 -59
- package/docs/assets/style.css +1414 -1414
- package/package.json +1 -1
- package/src/constants.ts +85 -85
- package/src/core/DTAction.ts +52 -52
- package/src/core/DTBunch.ts +467 -467
- package/src/core/DTComponent.ts +225 -225
- package/src/core/DTComponentPhysical.ts +54 -53
- package/src/core/DTComponentWithMeta.ts +65 -65
- package/src/core/DTElement.ts +102 -102
- package/src/core/DTError.ts +78 -78
- package/src/core/DTManager.ts +465 -465
- package/src/core/DTMaster.ts +318 -318
- package/src/core/DTModule.ts +90 -90
- package/src/index.ts +17 -17
- package/src/libs/DYOFinder.ts +175 -175
- package/src/libs/player/DTPlayer.element.ts +9 -9
- package/src/libs/player/DTPlayer.manager.ts +84 -84
- package/src/types/core.ts +169 -169
- package/src/types/index.ts +2 -2
- package/src/types/player.ts +6 -6
- package/test/core/DTBunch.spec.ts +13 -0
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
import DYOToolsManager from '../../core/DTManager';
|
|
2
|
-
import DYOToolsPlayer from './DTPlayer.element';
|
|
3
|
-
import { DTBunchFilters, DTManagerOptions, DTPlayerManagerSimpleConfiguration } from '../../types';
|
|
4
|
-
import { DTPlayer } from '../../index';
|
|
5
|
-
|
|
6
|
-
export default class DYOToolsPlayerManager extends DYOToolsManager<DYOToolsPlayer> {
|
|
7
|
-
/**
|
|
8
|
-
* Defining component domain to "player".
|
|
9
|
-
*/
|
|
10
|
-
protected _domain = 'player';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Applying the parent constructor. The key is **player** by default.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* The constructor uses a Configuration JSON Object, with following properties :
|
|
17
|
-
* * **players** : Default player configuration.
|
|
18
|
-
* If **players** is a number, it generates this number of DTPlayer instances and add it to the library.
|
|
19
|
-
* If **players** is an array of DTPlayer instances, it adds these to the library.
|
|
20
|
-
* * **errors** : Set **errors** option of the Manager.
|
|
21
|
-
*
|
|
22
|
-
* @param configuration DTPlayerManagerSimpleConfiguration Optional configuration to apply.
|
|
23
|
-
*/
|
|
24
|
-
constructor(configuration?: DTPlayerManagerSimpleConfiguration) {
|
|
25
|
-
super('player');
|
|
26
|
-
|
|
27
|
-
// Simple Configuration
|
|
28
|
-
const finalConfig = configuration ?? {};
|
|
29
|
-
const finalOptions: DTManagerOptions = this._options;
|
|
30
|
-
if (finalConfig.players) {
|
|
31
|
-
if (typeof finalConfig.players === 'number' && finalConfig.players > 0) {
|
|
32
|
-
let i = 1;
|
|
33
|
-
while (i <= finalConfig.players) {
|
|
34
|
-
const player = new DTPlayer(`player${i}`);
|
|
35
|
-
this._library.add(player);
|
|
36
|
-
i += 1;
|
|
37
|
-
}
|
|
38
|
-
} else if (Array.isArray(finalConfig.players)) {
|
|
39
|
-
this._library.addMany(finalConfig.players);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (finalConfig.errors) {
|
|
44
|
-
finalOptions.errors = finalConfig.errors;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Get one DTPlayer instance by id into the library.
|
|
50
|
-
*
|
|
51
|
-
* @param id string _id property of the DTPlayer instance to get.
|
|
52
|
-
*/
|
|
53
|
-
getPlayer(id: string): DYOToolsPlayer {
|
|
54
|
-
return this._library.get(id);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Add one DTPlayer instance into the library.
|
|
59
|
-
*
|
|
60
|
-
* @param player DYOToolsPlayer instance to add.
|
|
61
|
-
*/
|
|
62
|
-
addPlayer(player: DYOToolsPlayer): void {
|
|
63
|
-
this._library.add(player);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Remove one DTPlayer instance by id from the library.
|
|
68
|
-
*
|
|
69
|
-
* @param id string _id property of the DTPlayer instance to remove.
|
|
70
|
-
*/
|
|
71
|
-
removePlayer(id: string): void {
|
|
72
|
-
this._library.remove(id);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Find DTPlayer instances into the Library.
|
|
77
|
-
*
|
|
78
|
-
* @see [find](#find) method for search specifications.
|
|
79
|
-
* @param filters DTBunchFilters filters to apply.
|
|
80
|
-
*/
|
|
81
|
-
findPlayers(filters: Partial<DTBunchFilters>): DYOToolsPlayer[] {
|
|
82
|
-
return this._library.find(filters);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
1
|
+
import DYOToolsManager from '../../core/DTManager';
|
|
2
|
+
import DYOToolsPlayer from './DTPlayer.element';
|
|
3
|
+
import { DTBunchFilters, DTManagerOptions, DTPlayerManagerSimpleConfiguration } from '../../types';
|
|
4
|
+
import { DTPlayer } from '../../index';
|
|
5
|
+
|
|
6
|
+
export default class DYOToolsPlayerManager extends DYOToolsManager<DYOToolsPlayer> {
|
|
7
|
+
/**
|
|
8
|
+
* Defining component domain to "player".
|
|
9
|
+
*/
|
|
10
|
+
protected _domain = 'player';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Applying the parent constructor. The key is **player** by default.
|
|
14
|
+
*
|
|
15
|
+
*
|
|
16
|
+
* The constructor uses a Configuration JSON Object, with following properties :
|
|
17
|
+
* * **players** : Default player configuration.
|
|
18
|
+
* If **players** is a number, it generates this number of DTPlayer instances and add it to the library.
|
|
19
|
+
* If **players** is an array of DTPlayer instances, it adds these to the library.
|
|
20
|
+
* * **errors** : Set **errors** option of the Manager.
|
|
21
|
+
*
|
|
22
|
+
* @param configuration DTPlayerManagerSimpleConfiguration Optional configuration to apply.
|
|
23
|
+
*/
|
|
24
|
+
constructor(configuration?: DTPlayerManagerSimpleConfiguration) {
|
|
25
|
+
super('player');
|
|
26
|
+
|
|
27
|
+
// Simple Configuration
|
|
28
|
+
const finalConfig = configuration ?? {};
|
|
29
|
+
const finalOptions: DTManagerOptions = this._options;
|
|
30
|
+
if (finalConfig.players) {
|
|
31
|
+
if (typeof finalConfig.players === 'number' && finalConfig.players > 0) {
|
|
32
|
+
let i = 1;
|
|
33
|
+
while (i <= finalConfig.players) {
|
|
34
|
+
const player = new DTPlayer(`player${i}`);
|
|
35
|
+
this._library.add(player);
|
|
36
|
+
i += 1;
|
|
37
|
+
}
|
|
38
|
+
} else if (Array.isArray(finalConfig.players)) {
|
|
39
|
+
this._library.addMany(finalConfig.players);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (finalConfig.errors) {
|
|
44
|
+
finalOptions.errors = finalConfig.errors;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get one DTPlayer instance by id into the library.
|
|
50
|
+
*
|
|
51
|
+
* @param id string _id property of the DTPlayer instance to get.
|
|
52
|
+
*/
|
|
53
|
+
getPlayer(id: string): DYOToolsPlayer {
|
|
54
|
+
return this._library.get(id);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Add one DTPlayer instance into the library.
|
|
59
|
+
*
|
|
60
|
+
* @param player DYOToolsPlayer instance to add.
|
|
61
|
+
*/
|
|
62
|
+
addPlayer(player: DYOToolsPlayer): void {
|
|
63
|
+
this._library.add(player);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Remove one DTPlayer instance by id from the library.
|
|
68
|
+
*
|
|
69
|
+
* @param id string _id property of the DTPlayer instance to remove.
|
|
70
|
+
*/
|
|
71
|
+
removePlayer(id: string): void {
|
|
72
|
+
this._library.remove(id);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Find DTPlayer instances into the Library.
|
|
77
|
+
*
|
|
78
|
+
* @see [find](#find) method for search specifications.
|
|
79
|
+
* @param filters DTBunchFilters filters to apply.
|
|
80
|
+
*/
|
|
81
|
+
findPlayers(filters: Partial<DTBunchFilters>): DYOToolsPlayer[] {
|
|
82
|
+
return this._library.find(filters);
|
|
83
|
+
}
|
|
84
|
+
}
|
package/src/types/core.ts
CHANGED
|
@@ -1,169 +1,169 @@
|
|
|
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 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
|
+
}
|
package/src/types/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './core';
|
|
2
|
-
export * from './player';
|
|
1
|
+
export * from './core';
|
|
2
|
+
export * from './player';
|
package/src/types/player.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
|
+
errors?: boolean;
|
|
6
|
+
}
|
|
@@ -532,6 +532,19 @@ describe('class DYOToolsBunch', () => {
|
|
|
532
532
|
|
|
533
533
|
expect((managerTest.th_get_library().add as any).mock.calls.length).toBe(0);
|
|
534
534
|
});
|
|
535
|
+
|
|
536
|
+
test('manager context - not add item into the manager if the caller is the library', () => {
|
|
537
|
+
const managerTest = new DTManagerStub();
|
|
538
|
+
jest.spyOn(bunchTest, 'getContext').mockImplementation(
|
|
539
|
+
(contextType) => contextType === 'manager' && managerTest,
|
|
540
|
+
);
|
|
541
|
+
jest.spyOn(managerTest, 'getLibrary').mockImplementation(() => managerTest.th_get_library());
|
|
542
|
+
jest.spyOn(managerTest.th_get_library(), 'add');
|
|
543
|
+
|
|
544
|
+
managerTest.th_get_library().addAtIndex(objectToAdd, 5);
|
|
545
|
+
|
|
546
|
+
expect((managerTest.th_get_library().add as any).mock.calls.length).toBe(0);
|
|
547
|
+
});
|
|
535
548
|
});
|
|
536
549
|
|
|
537
550
|
describe('add()', () => {
|