@rentman/rm-core 5.0.0 → 6.0.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/changelog.md +8 -0
- package/dist/rm-core.js +8485 -8219
- package/dist/rm-core.min.js +2 -2
- package/dist/types/classes/ApiResponseProcessor.d.ts +2 -2
- package/dist/types/classes/CollectionEntryService.d.ts +7 -6
- package/dist/types/classes/CollectionMatcherBase.d.ts +8 -13
- package/dist/types/classes/CollectionMatcherCachedCollectionProcessor.d.ts +31 -0
- package/dist/types/classes/CollectionResourceService.d.ts +4 -3
- package/dist/types/classes/ColumnSet.d.ts +1 -2
- package/dist/types/classes/ColumnSubsetCache.d.ts +4 -2
- package/dist/types/classes/KeyService.d.ts +2 -1
- package/dist/types/classes/{QueryLocalLinkedToParser.d.ts → QueryLinkedToParser.d.ts} +4 -5
- package/dist/types/classes/QueryLocallyMatchableParser.d.ts +19 -0
- package/dist/types/classes/QueryMatcher.d.ts +4 -0
- package/dist/types/classes/QueryParser.d.ts +1 -2
- package/dist/types/classes/QueryParserBase.d.ts +7 -7
- package/dist/types/classes/QueryParserIdUpdater.d.ts +16 -0
- package/dist/types/classes/QueryService.d.ts +2 -1
- package/dist/types/classes/RequestBuffer.d.ts +7 -7
- package/dist/types/classes/RequestBufferManager.d.ts +1 -0
- package/dist/types/classes/RequestColumnExpansion.d.ts +2 -2
- package/dist/types/classes/SocketMessageHandler.d.ts +14 -6
- package/dist/types/classes/cache/AbstractCache.d.ts +20 -19
- package/dist/types/classes/cache/CachedQueryHandlerBase.d.ts +73 -0
- package/dist/types/classes/cache/CollectionMatcherCachedQueryProcessor.d.ts +35 -0
- package/dist/types/classes/cache/ItemHandlerBase.d.ts +3 -5
- package/dist/types/classes/cache/server/ServerCache.d.ts +12 -13
- package/dist/types/classes/cache/server/ServerCachedQueryHandler.d.ts +34 -0
- package/dist/types/classes/cache/server/ServerItemHandler.d.ts +2 -1
- package/dist/types/classes/cache/transaction/TransactionCache.d.ts +22 -28
- package/dist/types/classes/cache/transaction/TransactionCachedQueryHandler.d.ts +23 -0
- package/dist/types/classes/cache/transaction/TransactionCollectionHandler.d.ts +15 -40
- package/dist/types/classes/cache/transaction/TransactionItemHandler.d.ts +2 -2
- package/dist/types/classes/index.d.ts +3 -3
- package/dist/types/core.d.ts +1 -2
- package/dist/types/factories/CollectionEntryFactory.d.ts +7 -4
- package/dist/types/factories/CollectionMatcherFactory.d.ts +14 -4
- package/dist/types/factories/CollectionResourceFactory.d.ts +10 -4
- package/dist/types/factories/ColumnSubsetCacheFactory.d.ts +3 -2
- package/dist/types/factories/QueryParserFactory.d.ts +1 -1
- package/dist/types/factories/index.d.ts +0 -1
- package/dist/types/interfaces/AbstractCacheDependencyInterface.d.ts +1 -2
- package/dist/types/interfaces/TransactionCollectionHandlerDependencyInterface.d.ts +1 -2
- package/dist/types/models/CollectionEntry.d.ts +7 -8
- package/dist/types/models/CollectionOptions.d.ts +18 -0
- package/dist/types/models/CollectionResource.d.ts +30 -21
- package/dist/types/models/index.d.ts +1 -2
- package/dist/types/types/ItemTypesCollection.d.ts +32 -32
- package/package.json +1 -1
- package/dist/types/classes/CollectionCache.d.ts +0 -38
- package/dist/types/classes/CollectionMatcher.d.ts +0 -9
- package/dist/types/classes/cache/CollectionHandlerBase.d.ts +0 -68
- package/dist/types/classes/cache/CollectionMatcherCacheProcessor.d.ts +0 -26
- package/dist/types/classes/cache/server/ServerCollectionHandler.d.ts +0 -44
- package/dist/types/factories/CollectionCacheFactory.d.ts +0 -8
- package/dist/types/models/CollectionEntryOptions.d.ts +0 -13
- package/dist/types/models/CollectionResourceOptions.d.ts +0 -21
|
@@ -1,40 +1,53 @@
|
|
|
1
1
|
import { TransactionCache } from '../classes/cache/transaction/TransactionCache';
|
|
2
2
|
import { ChangesDeltaResult } from '../classes/ChangesDeltaBase';
|
|
3
3
|
import { CollectionResourceFactory } from '../factories';
|
|
4
|
-
import { CollectionEntry,
|
|
5
|
-
import { FieldMap, ItemId, ItemResourceItemIdMap, ItemType,
|
|
4
|
+
import { CollectionEntry, CollectionOptions, ItemEntry, ItemResource } from '../models';
|
|
5
|
+
import { ApiRequestLimit, CompareFieldCallback, DeregFunction, FieldMap, ItemId, ItemResourceItemIdMap, ItemType, OnAddCallback, OnChangeCallback, OnRemoveCallback, PromiseInterface, ResponseColumnItemTypeMap } from '../types';
|
|
6
6
|
export declare class CollectionResource<ItemTypeType extends ItemType = any> {
|
|
7
7
|
protected factory: CollectionResourceFactory;
|
|
8
|
-
|
|
9
|
-
options: CollectionResourceOptions<ItemTypeType>;
|
|
8
|
+
options: CollectionOptions<ItemTypeType>;
|
|
10
9
|
transaction: TransactionCache;
|
|
11
|
-
|
|
10
|
+
entry: CollectionEntry<ItemTypeType>;
|
|
12
11
|
columns: ResponseColumnItemTypeMap;
|
|
12
|
+
items: Array<ItemResource<ItemTypeType>>;
|
|
13
13
|
protected itemIdMap: ItemResourceItemIdMap<ItemResource<ItemTypeType>>;
|
|
14
14
|
private fieldChangeDeregFns;
|
|
15
|
-
private readonly
|
|
16
|
-
|
|
15
|
+
private readonly onChangeCallbacks;
|
|
16
|
+
private readonly onAddCallbacks;
|
|
17
|
+
private readonly onRemoveCallbacks;
|
|
18
|
+
/**
|
|
19
|
+
* @description
|
|
20
|
+
* We store the ItemIds of the items that were taking out the collections so that we can include those when doing a not-in when having a limit
|
|
21
|
+
*/
|
|
22
|
+
private removedItemIds;
|
|
23
|
+
constructor(factory: CollectionResourceFactory, options: CollectionOptions<ItemTypeType>, transaction: TransactionCache, itemType: ItemTypeType, initialItemEntries: Array<ItemEntry<ItemTypeType>>);
|
|
17
24
|
onConstruct(): void;
|
|
25
|
+
setLimit(newLimit: number | ApiRequestLimit): void;
|
|
26
|
+
onAdd(callback: OnAddCallback): DeregFunction;
|
|
27
|
+
onChange(callback: OnChangeCallback): DeregFunction;
|
|
28
|
+
onRemove(callback: OnRemoveCallback): DeregFunction;
|
|
29
|
+
__clear(): void;
|
|
18
30
|
/**
|
|
19
31
|
* @deprecated
|
|
20
32
|
* Use {@link ChangesDelta.setItemMoved ChangesDelta.setItemMoved}
|
|
21
33
|
*/
|
|
22
34
|
moveItems(itemEntries: Array<ItemEntry<ItemTypeType>>, destinationResource: CollectionResource<ItemTypeType>): void;
|
|
23
|
-
removeItems(idArray: ItemId[]):
|
|
24
|
-
removeItem(itemId: ItemId):
|
|
35
|
+
removeItems(idArray: ItemId[]): PromiseInterface<ChangesDeltaResult>;
|
|
36
|
+
removeItem(itemId: ItemId): PromiseInterface<ChangesDeltaResult>;
|
|
25
37
|
addItems(valuesArray: Array<FieldMap<ItemTypeType>>): PromiseInterface<ChangesDeltaResult>;
|
|
26
38
|
addItem(values: FieldMap<ItemTypeType>): PromiseInterface<ChangesDeltaResult>;
|
|
27
39
|
getIdArray(): ItemId[];
|
|
28
40
|
getItemById(itemId: number): ItemResource<ItemTypeType>;
|
|
29
|
-
addItemResources(
|
|
41
|
+
addItemResources(itemEntriesToBeAdded: Array<ItemEntry<ItemTypeType>>, isInitialCall?: boolean, isCalledAfterSocketUpdate?: boolean): Array<ItemResource<ItemTypeType>>;
|
|
30
42
|
/**
|
|
31
43
|
* @description
|
|
32
44
|
* Returns the {@link ItemResource ItemResources} that where removed from the {@link CollectionResource collection}.
|
|
33
45
|
* Filters on {@link ItemResource ItemResource}.{@link ItemEntry entry} === {@link ItemEntry entry}
|
|
34
46
|
*/
|
|
35
|
-
removeItemResources(itemEntries: Array<ItemEntry<ItemTypeType
|
|
36
|
-
callOnAdd(itemResources: Array<ItemResource<ItemTypeType>>, isInitialCall?: boolean): void;
|
|
37
|
-
|
|
47
|
+
removeItemResources(itemEntries: Array<ItemEntry<ItemTypeType>>, isCalledAfterSocketUpdate: boolean): Array<ItemResource<ItemTypeType>>;
|
|
48
|
+
callOnAdd(itemResources: Array<ItemResource<ItemTypeType>>, isInitialCall?: boolean, isCalledAfterSocketUpdate?: boolean): void;
|
|
49
|
+
callOnChange(itemEntry: ItemEntry<ItemTypeType>, compareField: CompareFieldCallback, fields: FieldMap<ItemTypeType>, isCalledAfterSocketUpdate: boolean, previous: FieldMap<ItemTypeType>): void;
|
|
50
|
+
callOnRemove(itemResources: Array<ItemResource<ItemTypeType>>, isCalledAfterSocketUpdate: boolean): void;
|
|
38
51
|
forEach(callback: (itemResource: ItemResource<ItemTypeType>) => void): void;
|
|
39
52
|
filter(callback: (itemResource: ItemResource<ItemTypeType>) => boolean): Array<ItemResource<ItemTypeType>>;
|
|
40
53
|
first(callback: (itemResource: ItemResource<ItemTypeType>) => boolean): ItemResource<ItemTypeType> | null;
|
|
@@ -44,14 +57,6 @@ export declare class CollectionResource<ItemTypeType extends ItemType = any> {
|
|
|
44
57
|
};
|
|
45
58
|
map<U>(argument: string | ((itemResource: ItemResource<ItemTypeType>) => U)): U[];
|
|
46
59
|
reduce<U>(callback: (itemResource: ItemResource<ItemTypeType>, value: U) => U, value: U): U;
|
|
47
|
-
/**
|
|
48
|
-
* @description
|
|
49
|
-
* Fetches new items and adds them to the collection
|
|
50
|
-
*
|
|
51
|
-
* @remarks
|
|
52
|
-
* - Used to return {@link ItemResource ItemResources}, but you should the {@link CollectionResource.onAdd onAdd) instead
|
|
53
|
-
*/
|
|
54
|
-
extend(queryCallback: QueryCallback): PromiseInterface<CollectionEntry<ItemTypeType>>;
|
|
55
60
|
/**
|
|
56
61
|
* @description
|
|
57
62
|
* Removes the reference to the {@link CollectionResource CollectionResource} from the {@link CollectionEntry CollectionEntry}
|
|
@@ -60,4 +65,8 @@ export declare class CollectionResource<ItemTypeType extends ItemType = any> {
|
|
|
60
65
|
* - Doesn't revert changes on the items themselves
|
|
61
66
|
*/
|
|
62
67
|
clearResource(): void;
|
|
68
|
+
private registerListeners;
|
|
69
|
+
private __registerCallback;
|
|
70
|
+
private limitAfterRemove;
|
|
71
|
+
private limitAfterAdd;
|
|
63
72
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export * from './ItemEntryOptions';
|
|
2
2
|
export * from './ItemEntry';
|
|
3
3
|
export * from './ItemResource';
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './CollectionResourceOptions';
|
|
4
|
+
export * from './CollectionOptions';
|
|
6
5
|
export * from './CollectionEntry';
|
|
7
6
|
export * from './CollectionResource';
|
|
8
7
|
export * from './Template';
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { ApiResponseProcessor,
|
|
2
|
-
import {
|
|
1
|
+
import { ApiResponseProcessor, ColumnSet, RequestColumnExpansion } from '../classes';
|
|
2
|
+
import { CollectionResource, ItemEntry, ItemEntryOptionsInterface, ItemResource } from '../models';
|
|
3
|
+
import { CollectionOptions } from '../models/CollectionOptions';
|
|
4
|
+
export declare type ParentIdMap<T> = {
|
|
5
|
+
[parentId: number]: T;
|
|
6
|
+
};
|
|
3
7
|
export declare type EntryParent = {
|
|
4
8
|
itemType: string;
|
|
5
9
|
itemId: number;
|
|
@@ -13,13 +17,9 @@ export declare type FieldMap<_ItemTypeType extends ItemType = any> = {
|
|
|
13
17
|
[key: string]: any;
|
|
14
18
|
};
|
|
15
19
|
export declare type ItemOptionsInterface = ItemEntryOptionsInterface;
|
|
16
|
-
export declare type CollectionOptionsInterface<ItemTypeType extends ItemType = any> = CollectionEntryOptionsInterface & CollectionResourceOptionsInterface<ItemTypeType>;
|
|
17
20
|
export interface CollectionDefinition<ItemTypeType extends ItemType = any> {
|
|
18
21
|
itemType: ItemTypeType;
|
|
19
|
-
options:
|
|
20
|
-
entry: CollectionEntryOptions;
|
|
21
|
-
resource: CollectionResourceOptions<ItemTypeType>;
|
|
22
|
-
};
|
|
22
|
+
options: CollectionOptions;
|
|
23
23
|
}
|
|
24
24
|
export interface LinkCollectionDefinition<ItemTypeType extends ItemType = any> extends CollectionDefinition<ItemTypeType> {
|
|
25
25
|
linkField: string;
|
|
@@ -129,9 +129,7 @@ export declare type ItemMap<T> = {
|
|
|
129
129
|
};
|
|
130
130
|
};
|
|
131
131
|
export declare type ItemEntryMap<ItemTypeType extends ItemType> = ItemMap<ItemEntry<ItemTypeType>>;
|
|
132
|
-
export declare type ItemEntryParentIdMap<ItemTypeType extends ItemType> =
|
|
133
|
-
[parentId: number]: Array<ItemEntry<ItemTypeType>>;
|
|
134
|
-
};
|
|
132
|
+
export declare type ItemEntryParentIdMap<ItemTypeType extends ItemType> = ParentIdMap<Array<ItemEntry<ItemTypeType>>>;
|
|
135
133
|
export declare type ConversionMap = {
|
|
136
134
|
[itemId: number]: number;
|
|
137
135
|
};
|
|
@@ -142,29 +140,11 @@ export declare type CreateRequestParameterMap<T = any> = ItemMap<T>;
|
|
|
142
140
|
export declare type ItemError = {
|
|
143
141
|
message: string;
|
|
144
142
|
};
|
|
145
|
-
export declare type QueryParams = any;
|
|
146
143
|
export declare type CollectionQuery = {
|
|
147
144
|
object: object;
|
|
148
145
|
string: string;
|
|
149
146
|
};
|
|
150
|
-
export declare type
|
|
151
|
-
export declare type CollectionEntryParentIdMap<ItemTypeType extends ItemType> = {
|
|
152
|
-
[parentId: number]: CollectionEntry<ItemTypeType>;
|
|
153
|
-
};
|
|
154
|
-
export declare type CollectionResourceParentIdMap<ItemTypeType extends ItemType = any> = {
|
|
155
|
-
[parentId: number]: CollectionResource<ItemTypeType>;
|
|
156
|
-
};
|
|
157
|
-
export declare type CollectionMatchResult<ItemTypeType extends ItemType> = {
|
|
158
|
-
fitting: Array<CollectionEntry<ItemTypeType>>;
|
|
159
|
-
notfitting: Array<CollectionEntry<ItemTypeType>>;
|
|
160
|
-
maybe: Array<CollectionEntry<ItemTypeType>>;
|
|
161
|
-
};
|
|
162
|
-
export interface ExtendedCollectionMatchResult<ItemTypeType extends ItemType> extends CollectionMatchResult<ItemTypeType> {
|
|
163
|
-
collection: CollectionEntry<ItemTypeType>;
|
|
164
|
-
}
|
|
165
|
-
export interface GroupedExtendedCollectionMatchResult<ItemTypeType extends ItemType> {
|
|
166
|
-
[collectionId: number]: ExtendedCollectionMatchResult<ItemTypeType>;
|
|
167
|
-
}
|
|
147
|
+
export declare type CollectionResourceParentIdMap<ItemTypeType extends ItemType = any> = ParentIdMap<CollectionResource<ItemTypeType>>;
|
|
168
148
|
export declare type ResponseColumn = any;
|
|
169
149
|
export declare type ResponseColumnMap = {
|
|
170
150
|
[columnId: string]: ResponseColumn;
|
|
@@ -212,7 +192,6 @@ export declare type ApiRequestColumnMap = {
|
|
|
212
192
|
export declare type ApiRequestLimit = {
|
|
213
193
|
field: string;
|
|
214
194
|
limit: number;
|
|
215
|
-
offset?: number;
|
|
216
195
|
order?: 'desc' | 'asc';
|
|
217
196
|
};
|
|
218
197
|
export declare type ApiRequestMoveItems = {
|
|
@@ -231,7 +210,6 @@ export declare type CreateRequestEntry<ItemTypeType extends ItemType> = {
|
|
|
231
210
|
};
|
|
232
211
|
columns: RequestColumnExpansion;
|
|
233
212
|
items: ItemEntryMap<ItemTypeType>;
|
|
234
|
-
collections: CollectionMatcher;
|
|
235
213
|
};
|
|
236
214
|
export declare enum ApiLinkTreeType {
|
|
237
215
|
ITEMTABLE = "itemtable",
|
|
@@ -259,5 +237,27 @@ export declare type ModifyFieldsCallback = <ItemTypeType extends ItemType>(itemT
|
|
|
259
237
|
* Returns 'false' if the field changed
|
|
260
238
|
*/
|
|
261
239
|
export declare type CompareFieldCallback<ItemTypeType extends ItemType = any> = (field: keyof FieldMap<ItemTypeType>) => boolean;
|
|
262
|
-
export declare type
|
|
240
|
+
export declare type FieldChangeCallbackArgs<ItemTypeType extends ItemType = any> = {
|
|
241
|
+
itemEntry: ItemEntry<ItemTypeType>;
|
|
242
|
+
compareField: CompareFieldCallback;
|
|
243
|
+
fields: FieldMap<ItemTypeType>;
|
|
244
|
+
isCalledAfterSocketUpdate: boolean;
|
|
245
|
+
previous: FieldMap<ItemTypeType>;
|
|
246
|
+
};
|
|
247
|
+
export declare type FieldChangeCallback<ItemTypeType extends ItemType = any> = (args: FieldChangeCallbackArgs<ItemTypeType>) => void;
|
|
263
248
|
export declare type DeregFunction = () => void;
|
|
249
|
+
export declare type OnChangeCallbackArgs<ItemTypeType extends ItemType = any> = FieldChangeCallbackArgs<ItemTypeType>;
|
|
250
|
+
export declare type OnChangeCallback<ItemTypeType extends ItemType = any> = FieldChangeCallback<ItemTypeType>;
|
|
251
|
+
export declare type OnAddCallbackArgs<ItemTypeType extends ItemType = any> = {
|
|
252
|
+
itemResources: Array<ItemResource<ItemTypeType>>;
|
|
253
|
+
collectionResource: CollectionResource<ItemTypeType>;
|
|
254
|
+
isInitialCall: boolean;
|
|
255
|
+
isCalledAfterSocketUpdate: boolean;
|
|
256
|
+
};
|
|
257
|
+
export declare type OnAddCallback<ItemTypeType extends ItemType = any> = (args: OnAddCallbackArgs<ItemTypeType>) => void;
|
|
258
|
+
export declare type OnRemoveCallbackArgs<ItemTypeType extends ItemType = any> = {
|
|
259
|
+
itemResources: Array<ItemResource<ItemTypeType>>;
|
|
260
|
+
collectionResource: CollectionResource<ItemTypeType>;
|
|
261
|
+
isCalledAfterSocketUpdate: boolean;
|
|
262
|
+
};
|
|
263
|
+
export declare type OnRemoveCallback<ItemTypeType extends ItemType = any> = (args: OnRemoveCallbackArgs<ItemTypeType>) => void;
|
package/package.json
CHANGED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { QueryMatcherFactory } from '../factories';
|
|
2
|
-
import { CollectionEntry, CollectionResource } from '../models';
|
|
3
|
-
import { CollectionMatchResult, CollectionQuery, EntryParentNull, FieldMap, ItemId, ItemType } from '../types';
|
|
4
|
-
import { AbstractCache } from './cache/AbstractCache';
|
|
5
|
-
export declare class CollectionCache {
|
|
6
|
-
private queryMatcherFactory;
|
|
7
|
-
private transaction;
|
|
8
|
-
private entries;
|
|
9
|
-
constructor(queryMatcherFactory: QueryMatcherFactory, transaction: AbstractCache);
|
|
10
|
-
getByEntryId(collectionEntryId: CollectionEntry['id']): CollectionEntry | undefined;
|
|
11
|
-
contains(collectionEntry: CollectionEntry<any>): boolean;
|
|
12
|
-
some(callback: (entry: CollectionEntry<any>) => boolean): boolean;
|
|
13
|
-
forEach(callback: (entry: CollectionEntry<any>) => void): void;
|
|
14
|
-
toArray(): CollectionEntry<any>[];
|
|
15
|
-
add<T extends CollectionEntry<any>>(collectionEntry: T): T;
|
|
16
|
-
clear(collectionEntry?: CollectionEntry<any>): boolean;
|
|
17
|
-
getByItemType<ItemTypeType extends ItemType>(itemType: ItemTypeType): CollectionEntry<ItemTypeType>[];
|
|
18
|
-
matchParent(collectionEntry: CollectionEntry<any>, itemType: string, itemId: ItemId): boolean;
|
|
19
|
-
getByParent<ItemTypeType extends ItemType>(parentType: ItemType, parentId: ItemId, itemType: ItemTypeType): CollectionEntry<ItemTypeType> | null;
|
|
20
|
-
getCollectionsByParent(parentType: ItemType, parentId: ItemId): CollectionEntry<any>[];
|
|
21
|
-
/**
|
|
22
|
-
* @description
|
|
23
|
-
* Gets {@link CollectionEntry CollectionEntries} which contain the item with the passed ItemType/ItemId
|
|
24
|
-
*/
|
|
25
|
-
getByContainingItem<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemId: ItemId): CollectionEntry<ItemTypeType>[];
|
|
26
|
-
/**
|
|
27
|
-
* @description
|
|
28
|
-
* Checks if the passed fields would fit in the collections using the {@link QueryMatcher QueryMatcher}
|
|
29
|
-
*/
|
|
30
|
-
getByFittingItem<ItemTypeType extends ItemType>(itemType: ItemTypeType, fields: FieldMap, parent: EntryParentNull): CollectionMatchResult<ItemTypeType>;
|
|
31
|
-
getByQuery<ItemTypeType extends ItemType>(itemType: ItemTypeType, query: CollectionQuery): CollectionEntry<ItemTypeType> | null;
|
|
32
|
-
getByQueryString<ItemTypeType extends ItemType>(itemType: ItemTypeType, queryString: string): CollectionEntry<ItemTypeType> | null;
|
|
33
|
-
getByKey<ItemTypeType extends ItemType>(itemType: ItemTypeType, entryKey: string): Array<CollectionEntry<ItemTypeType>>;
|
|
34
|
-
/**
|
|
35
|
-
* @deprecated
|
|
36
|
-
*/
|
|
37
|
-
getResourceByKey<ItemTypeType extends ItemType>(itemType: ItemTypeType, resourceKey: string): Array<CollectionResource<ItemTypeType>>;
|
|
38
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { QueryMatcherFactory } from '../factories';
|
|
2
|
-
import { CollectionEntry } from '../models';
|
|
3
|
-
import { ItemType } from '../types';
|
|
4
|
-
import { AbstractCache } from './cache/AbstractCache';
|
|
5
|
-
import { CollectionMatcherBase } from './CollectionMatcherBase';
|
|
6
|
-
export declare class CollectionMatcher extends CollectionMatcherBase {
|
|
7
|
-
constructor(queryMatcherFactory: QueryMatcherFactory, transaction: AbstractCache, getCollectionEntries: (itemType: ItemType) => CollectionEntry[]);
|
|
8
|
-
getCollectionsWithFittingItems(): CollectionEntry[];
|
|
9
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { CollectionCacheFactory, RequestColumnExpansionFactory } from '../../factories';
|
|
2
|
-
import { CollectionEntry, CollectionEntryOptions, ItemEntry } from '../../models';
|
|
3
|
-
import { ApiQuery, ApiRequestColumn, CollectionEntryParentIdMap, CollectionResourceParentIdMap, ItemId, ItemType, PromiseInterface, QueryCallback } from '../../types';
|
|
4
|
-
import { CollectionCache } from '../CollectionCache';
|
|
5
|
-
import { CollectionEntryService } from '../CollectionEntryService';
|
|
6
|
-
import { CollectionMatcher } from '../CollectionMatcher';
|
|
7
|
-
import { ColumnUtil } from '../ColumnUtil';
|
|
8
|
-
import { AbstractCache } from './AbstractCache';
|
|
9
|
-
export declare abstract class CollectionHandlerBase {
|
|
10
|
-
protected collectionEntryService: CollectionEntryService;
|
|
11
|
-
protected columnUtil: ColumnUtil;
|
|
12
|
-
protected requestColumnExpansionFactory: RequestColumnExpansionFactory;
|
|
13
|
-
protected transaction: AbstractCache;
|
|
14
|
-
entries: CollectionCache;
|
|
15
|
-
collectionChanges: {
|
|
16
|
-
[itemType: string]: {
|
|
17
|
-
[queryString: string]: ItemEntry[];
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
protected constructor(collectionEntryService: CollectionEntryService, columnUtil: ColumnUtil, requestColumnExpansionFactory: RequestColumnExpansionFactory, collectionCacheFactory: CollectionCacheFactory, transaction: AbstractCache);
|
|
21
|
-
setCollectionChanges<ItemTypeType extends ItemType>(itemType: ItemTypeType, queryString: string, itemEntries: Array<ItemEntry<ItemTypeType>>): void;
|
|
22
|
-
getCollectionChanges<ItemTypeType extends ItemType>(itemType: ItemTypeType, queryString: string): undefined | Array<ItemEntry<ItemTypeType>>;
|
|
23
|
-
/**
|
|
24
|
-
* @description
|
|
25
|
-
* Creates a new {@link CollectionEntry CollectionEntry} and stores it in this transaction's {@link CollectionCache CollectionCache}
|
|
26
|
-
*/
|
|
27
|
-
createCollectionEntry<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionEntryOptions): CollectionEntry<ItemTypeType>;
|
|
28
|
-
/**
|
|
29
|
-
* @description
|
|
30
|
-
* Creates a {@link CollectionMatcher CollectionMatcher} with the transaction's collections
|
|
31
|
-
*/
|
|
32
|
-
abstract getCollectionMatcher(): CollectionMatcher;
|
|
33
|
-
/**
|
|
34
|
-
* @description
|
|
35
|
-
* Fetches a {@link CollectionEntry CollectionEntry} with the given options
|
|
36
|
-
*/
|
|
37
|
-
abstract fetchCollectionEntry<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionEntryOptions): PromiseInterface<CollectionEntry<ItemTypeType>>;
|
|
38
|
-
/**
|
|
39
|
-
* @description
|
|
40
|
-
* Fetches collections linked to the passed parents
|
|
41
|
-
*/
|
|
42
|
-
abstract fetchLinkedCollectionEntries<ItemTypeType extends ItemType>(parentType: ItemType, parentIdArray: ItemId[] | (() => ItemId[]), itemType: ItemTypeType, options: CollectionEntryOptions): PromiseInterface<CollectionEntryParentIdMap<ItemTypeType>>;
|
|
43
|
-
/**
|
|
44
|
-
* @description
|
|
45
|
-
* Expands the items in the collections with the passed columns
|
|
46
|
-
*/
|
|
47
|
-
abstract expandCollectionEntries<ItemTypeType extends ItemType>(parentType: ItemType, itemType: ItemTypeType, collections: CollectionResourceParentIdMap, newColumns: ApiRequestColumn[]): PromiseInterface<CollectionResourceParentIdMap>;
|
|
48
|
-
/**
|
|
49
|
-
* @description
|
|
50
|
-
* Extends the collections' {@link CollectionEntry.queryParams queryParams} and {@link CollectionEntry.query queries} and fetches the {@link ItemEntry ItemEntries} with the new queries
|
|
51
|
-
*/
|
|
52
|
-
abstract extendCollectionEntries<T extends CollectionResourceParentIdMap>(parentType: ItemType, itemType: ItemType, options: CollectionEntryOptions, queryCallback: QueryCallback, collections: T): PromiseInterface<void>;
|
|
53
|
-
/**
|
|
54
|
-
* @description
|
|
55
|
-
* Adds the passed {@link ItemEntry ItemEntries} to the collection's changes on the transaction,
|
|
56
|
-
* will skip the ItemEntry if the `skipEntryFilterFn` callback returns `true`
|
|
57
|
-
*/
|
|
58
|
-
protected _addItemEntriesToCollectionChanges<CollectionEntryType extends CollectionEntry>(collectionEntry: CollectionEntryType, itemEntries: Array<ItemEntry<CollectionEntryType['itemType']>>, skipEntryFilterFn: (temEntry: ItemEntry) => boolean, isCalledAfterSocketUpdate: boolean): void;
|
|
59
|
-
protected abstract handleAddedItemEntriesCallback<CollectionEntryType extends CollectionEntry>(collectionEntry: CollectionEntryType, addedEntries: Array<ItemEntry<CollectionEntryType['itemType']>>, isCalledAfterSocketUpdate: boolean): void;
|
|
60
|
-
removeItemEntriesFromCollectionChanges(collectionEntry: CollectionEntry, idArray: ItemId[], isCalledAfterSocketUpdate?: boolean): void | never[];
|
|
61
|
-
protected abstract handleRemovedItemEntriesCallback<CollectionEntryType extends CollectionEntry>(collectionEntry: CollectionEntryType, removedItemEntries: Array<ItemEntry<CollectionEntryType['itemType']>>, isCalledAfterSocketUpdate: boolean): void;
|
|
62
|
-
/**
|
|
63
|
-
* @description
|
|
64
|
-
* Expands the option's {@link CollectionEntryOptions.columns columns} with the columns required for the {@link CollectionMatcher CollectionMatcher} to function.
|
|
65
|
-
* Data fetched for a parent transaction might also fit in a child transaction, so those {@link CollectionEntryOptions.queryColumns queryColumns} should also be taken into account
|
|
66
|
-
*/
|
|
67
|
-
protected expandColumnsWithQueryColumns(itemType: ItemType, options: CollectionEntryOptions, query: ApiQuery): void;
|
|
68
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { QueryMatcherFactory } from '../../factories';
|
|
2
|
-
import { CollectionEntry, ItemEntry } from '../../models';
|
|
3
|
-
import { ItemId, ItemType } from '../../types';
|
|
4
|
-
import { ApiRequestService } from '../ApiRequestService';
|
|
5
|
-
import { CollectionMatcher } from '../CollectionMatcher';
|
|
6
|
-
import { AbstractCache } from './AbstractCache';
|
|
7
|
-
export declare type GroupedCollectionMatcherResult<ItemTypeType extends ItemType> = {
|
|
8
|
-
fitting: Array<ItemEntry<ItemTypeType>>;
|
|
9
|
-
notFitting: ItemId[];
|
|
10
|
-
maybe: Array<ItemEntry<ItemTypeType>>;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* @description
|
|
14
|
-
* Processes a delta and adds the items to the right collections, this is the ONLY class that should change collection items
|
|
15
|
-
*
|
|
16
|
-
* ------
|
|
17
|
-
*
|
|
18
|
-
* @remark
|
|
19
|
-
* The CollectionMatcherCacheProcessor is allowed to directly access/modify the transaction because it's ONLY called from applyChangesFromParent
|
|
20
|
-
*/
|
|
21
|
-
export declare class CollectionMatcherCacheProcessor extends CollectionMatcher {
|
|
22
|
-
private apiRequestService;
|
|
23
|
-
constructor(apiRequestService: ApiRequestService, queryMatcherFactory: QueryMatcherFactory, transaction: AbstractCache, getCollectionEntries: (itemType: ItemType) => CollectionEntry[]);
|
|
24
|
-
removeFromAndAddToCollections(isCalledAfterSocketUpdate?: boolean): void;
|
|
25
|
-
private groupItemEntries;
|
|
26
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { CollectionCacheFactory, CollectionMatcherFactory, ColumnExpansionFactory, ColumnSubsetCacheFactory, RequestColumnExpansionFactory } from '../../../factories';
|
|
2
|
-
import { ApiQuery, ApiRequestColumns, ApiRequestService, CollectionEntryOptions, CollectionMatcher, ColumnUtil, ItemEntryOptions, PromiseInterface } from '../../../index';
|
|
3
|
-
import { ErrorHandlerInterface, PromiseLibraryInterface } from '../../../interfaces';
|
|
4
|
-
import { CollectionEntry, ItemEntry } from '../../../models';
|
|
5
|
-
import { ApiRequestColumn, CollectionEntryParentIdMap, CollectionResourceParentIdMap, ItemId, ItemType, QueryCallback } from '../../../types';
|
|
6
|
-
import { CollectionEntryService, QueryService } from '../../index';
|
|
7
|
-
import { RequestBufferManager } from '../../RequestBufferManager';
|
|
8
|
-
import { CollectionHandlerBase } from '../CollectionHandlerBase';
|
|
9
|
-
import { ServerCache } from './ServerCache';
|
|
10
|
-
import { ServerItemHandler } from './ServerItemHandler';
|
|
11
|
-
export declare class ServerCollectionHandler extends CollectionHandlerBase {
|
|
12
|
-
private columnSubsetCacheFactory;
|
|
13
|
-
private requestBufferManager;
|
|
14
|
-
private columnExpansionFactory;
|
|
15
|
-
private apiRequestService;
|
|
16
|
-
private collectionMatcherFactory;
|
|
17
|
-
private errorHandler;
|
|
18
|
-
private itemHandler;
|
|
19
|
-
private promiseService;
|
|
20
|
-
private queryService;
|
|
21
|
-
protected transaction: ServerCache;
|
|
22
|
-
constructor(columnSubsetCacheFactory: ColumnSubsetCacheFactory, requestBufferManager: RequestBufferManager, requestColumnExpansionFactory: RequestColumnExpansionFactory, columnExpansionFactory: ColumnExpansionFactory, apiRequestService: ApiRequestService, collectionCacheFactory: CollectionCacheFactory, collectionEntryService: CollectionEntryService, collectionMatcherFactory: CollectionMatcherFactory, errorHandler: ErrorHandlerInterface, itemHandler: ServerItemHandler, promiseService: PromiseLibraryInterface, queryService: QueryService, columnUtil: ColumnUtil, transaction: ServerCache);
|
|
23
|
-
fetchItemEntriesByQuery<ItemTypeType extends ItemType>(itemType: ItemTypeType, query: ApiQuery, options: ItemEntryOptions): PromiseInterface<Array<ItemEntry<ItemTypeType>>>;
|
|
24
|
-
getCollectionMatcher(): CollectionMatcher;
|
|
25
|
-
fetchCollectionEntry<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionEntryOptions): PromiseInterface<CollectionEntry<ItemTypeType>>;
|
|
26
|
-
fetchLinkedCollectionEntries<ItemTypeType extends ItemType>(parentType: ItemType, parentIdArray: ItemId[] | (() => ItemId[]), itemType: ItemTypeType, options: CollectionEntryOptions): PromiseInterface<CollectionEntryParentIdMap<ItemTypeType>>;
|
|
27
|
-
extendCollectionEntry<CollectionEntryType extends CollectionEntry>(collectionEntry: CollectionEntryType, queryCallback: QueryCallback): PromiseInterface<CollectionEntryType>;
|
|
28
|
-
expandCollectionEntries<ItemTypeType extends ItemType>(parentType: ItemType, itemType: ItemTypeType, collections: CollectionResourceParentIdMap, newRequestColumns: ApiRequestColumn[]): PromiseInterface<CollectionResourceParentIdMap>;
|
|
29
|
-
extendCollectionEntries<T extends CollectionResourceParentIdMap>(parentType: ItemType, itemType: ItemType, options: CollectionEntryOptions, queryCallback: QueryCallback, collections: T): PromiseInterface<void>;
|
|
30
|
-
addItemEntriesToCollectionChanges<CollectionEntryType extends CollectionEntry>(collectionEntry: CollectionEntryType, itemEntries: Array<ItemEntry<CollectionEntryType['itemType']>>, isCalledAfterSocketUpdate?: boolean): void;
|
|
31
|
-
/**
|
|
32
|
-
* @description
|
|
33
|
-
* Expands the columns of the items in the collection
|
|
34
|
-
*/
|
|
35
|
-
expandCollectionEntry<CollectionEntryType extends CollectionEntry>(collectionEntry: CollectionEntryType, newColumns: ApiRequestColumns): PromiseInterface<CollectionEntryType>;
|
|
36
|
-
protected handleAddedItemEntriesCallback<CollectionEntryType extends CollectionEntry>(_collectionEntry: CollectionEntryType, addedEntries: Array<ItemEntry<CollectionEntryType['itemType']>>): void;
|
|
37
|
-
protected handleRemovedItemEntriesCallback<CollectionEntryType extends CollectionEntry>(_collectionEntry: CollectionEntryType, removedItemEntries: Array<ItemEntry<CollectionEntryType['itemType']>>): void;
|
|
38
|
-
/**
|
|
39
|
-
* @description
|
|
40
|
-
* Fetches the data for the passed ItemType/options, will do nothing if the requested CollectionEntry/columns are already cached.
|
|
41
|
-
* Will create a new {@link CollectionEntry CollectionEntry} if the CollectionEntry didn't exist yet
|
|
42
|
-
*/
|
|
43
|
-
private fetchCollectionData;
|
|
44
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { CollectionCache } from '../classes';
|
|
2
|
-
import { AbstractCache } from '../classes/cache/AbstractCache';
|
|
3
|
-
import { QueryMatcherFactory } from '../factories';
|
|
4
|
-
export declare class CollectionCacheFactory {
|
|
5
|
-
private queryMatcherFactory;
|
|
6
|
-
constructor(queryMatcherFactory: QueryMatcherFactory);
|
|
7
|
-
construct(transaction: AbstractCache): CollectionCache;
|
|
8
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ApiQuery, ApiRequestColumns, ApiRequestLimit, EntryParentNull } from '../types';
|
|
2
|
-
export declare type CollectionEntryOptionsInterface = Partial<CollectionEntryOptions>;
|
|
3
|
-
export declare class CollectionEntryOptions {
|
|
4
|
-
columns: ApiRequestColumns;
|
|
5
|
-
query: ApiQuery | null;
|
|
6
|
-
queryParams: any;
|
|
7
|
-
queryColumns: ApiRequestColumns;
|
|
8
|
-
parent: EntryParentNull;
|
|
9
|
-
deferRequest: boolean;
|
|
10
|
-
limit: ApiRequestLimit | null;
|
|
11
|
-
entryKey: string | null;
|
|
12
|
-
constructor(values: CollectionEntryOptionsInterface);
|
|
13
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { CollectionEntry, CollectionResource, ItemEntry, ItemResource } from '../models';
|
|
2
|
-
import { FieldChangeCallback, ItemType } from '../types';
|
|
3
|
-
export declare type CollectionResourceCallback<ItemTypeType extends ItemType> = (itemResources: Array<ItemResource<ItemTypeType>>, collectionResource: CollectionResource<ItemTypeType>) => void;
|
|
4
|
-
export declare type CollectionResourceOnAddCallback<ItemTypeType extends ItemType> = (itemResources: Array<ItemResource<ItemTypeType>>, collectionResource: CollectionResource<ItemTypeType>, isInitialCall: boolean) => void;
|
|
5
|
-
export declare type CollectionResourceInitialCallback<ItemTypeType extends ItemType> = (itemEntries: Array<ItemEntry<ItemTypeType>>, collectionEntry: CollectionEntry<ItemTypeType>) => void;
|
|
6
|
-
export declare type CollectionResourceOptionsInterface<ItemTypeType extends ItemType> = Partial<CollectionResourceOptions<ItemTypeType>>;
|
|
7
|
-
export declare class CollectionResourceOptions<ItemTypeType extends ItemType> {
|
|
8
|
-
callOnAddWithInitialItems: boolean;
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated
|
|
11
|
-
* You should use register a {@link TransactionCache.registerFieldChangeCallback field change callback} and compare previous.id with fields.id
|
|
12
|
-
*/
|
|
13
|
-
onAdd: CollectionResourceOnAddCallback<ItemTypeType>;
|
|
14
|
-
onRemove: CollectionResourceCallback<ItemTypeType>;
|
|
15
|
-
onChange: FieldChangeCallback;
|
|
16
|
-
onAddInitial: CollectionResourceInitialCallback<ItemTypeType>;
|
|
17
|
-
onRemoveInitial: CollectionResourceInitialCallback<ItemTypeType>;
|
|
18
|
-
resourceKey: string | null;
|
|
19
|
-
custom: any;
|
|
20
|
-
constructor(values: CollectionResourceOptionsInterface<ItemTypeType>);
|
|
21
|
-
}
|