@rentman/rm-core 8.1.7 → 8.1.8-dev1
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 +923 -917
- package/dist/rm-core.js +18307 -11023
- package/dist/rm-core.min.js +1 -16
- package/dist/types/classes/ApiFormatter.d.ts +73 -66
- package/dist/types/classes/ApiRequestService.d.ts +18 -21
- package/dist/types/classes/ApiResponseProcessor.d.ts +29 -30
- package/dist/types/classes/CacheSyncer.d.ts +36 -0
- package/dist/types/classes/ChangesCompilation.d.ts +33 -36
- package/dist/types/classes/ChangesDelta.d.ts +61 -68
- package/dist/types/classes/ChangesDeltaBase.d.ts +76 -79
- package/dist/types/classes/ChangesProcessor.d.ts +40 -45
- package/dist/types/classes/CollectionEntryService.d.ts +23 -27
- package/dist/types/classes/CollectionResourceService.d.ts +6 -7
- package/dist/types/classes/ColumnCache.d.ts +21 -22
- package/dist/types/classes/ColumnExpansion.d.ts +21 -23
- package/dist/types/classes/ColumnHandler.d.ts +20 -22
- package/dist/types/classes/ColumnInfo.d.ts +14 -14
- package/dist/types/classes/ColumnSet.d.ts +37 -39
- package/dist/types/classes/ColumnSubsetCache.d.ts +14 -15
- package/dist/types/classes/ColumnUtil.d.ts +100 -101
- package/dist/types/classes/ConversionMapService.d.ts +25 -28
- package/dist/types/classes/CreateRequest.d.ts +17 -20
- package/dist/types/classes/CreatedChangesDelta.d.ts +17 -18
- package/dist/types/classes/InternalChangesDelta.d.ts +47 -51
- package/dist/types/classes/ItemCache.d.ts +27 -30
- package/dist/types/classes/ItemCreateService.d.ts +18 -25
- package/dist/types/classes/ItemEntryService.d.ts +32 -35
- package/dist/types/classes/KeyService.d.ts +18 -18
- package/dist/types/classes/LockService.d.ts +29 -32
- package/dist/types/classes/ModuleChangesCompilation.d.ts +18 -19
- package/dist/types/classes/ParentChangesDelta.d.ts +39 -47
- package/dist/types/classes/QueryColumnExtractor.d.ts +18 -20
- package/dist/types/classes/QueryContainsLocalIdParser.d.ts +15 -17
- package/dist/types/classes/QueryLinkedToParser.d.ts +15 -16
- package/dist/types/classes/QueryLocallyMatchableParser.d.ts +18 -19
- package/dist/types/classes/QueryMatcher.d.ts +18 -19
- package/dist/types/classes/QueryParser.d.ts +25 -26
- package/dist/types/classes/QueryParserBase.d.ts +20 -20
- package/dist/types/classes/QueryParserIdUpdater.d.ts +15 -16
- package/dist/types/classes/QueryService.d.ts +12 -13
- package/dist/types/classes/RequestBuffer.d.ts +24 -29
- package/dist/types/classes/RequestBufferManager.d.ts +20 -26
- package/dist/types/classes/RequestColumnExpansion.d.ts +15 -16
- package/dist/types/classes/SocketMessageHandler.d.ts +34 -43
- package/dist/types/classes/TemplateCache.d.ts +63 -70
- package/dist/types/classes/Util.d.ts +28 -31
- package/dist/types/classes/cache/AbstractCache.d.ts +95 -112
- package/dist/types/classes/cache/CachedQueryHandlerBase.d.ts +68 -75
- package/dist/types/classes/cache/ItemHandlerBase.d.ts +95 -106
- package/dist/types/classes/cache/server/ServerCache.d.ts +82 -94
- package/dist/types/classes/cache/server/ServerCachedQueryHandler.d.ts +25 -34
- package/dist/types/classes/cache/server/ServerItemHandler.d.ts +44 -53
- package/dist/types/classes/cache/transaction/TransactionCache.d.ts +319 -327
- package/dist/types/classes/cache/transaction/TransactionCachedQueryHandler.d.ts +31 -30
- package/dist/types/classes/cache/transaction/TransactionCollectionHandler.d.ts +24 -30
- package/dist/types/classes/cache/transaction/TransactionEventHandler.d.ts +21 -24
- package/dist/types/classes/cache/transaction/TransactionItemHandler.d.ts +89 -97
- package/dist/types/classes/cache/transaction/TransactionValidator.d.ts +33 -35
- package/dist/types/constants.d.ts +7 -7
- package/dist/types/core.d.ts +45 -51
- package/dist/types/factories/ApiResponseProcessorFactory.d.ts +6 -6
- package/dist/types/factories/CacheSyncerFactory.d.ts +10 -0
- package/dist/types/factories/ChangesCompilationFactory.d.ts +5 -6
- package/dist/types/factories/ChangesDeltaFactory.d.ts +13 -15
- package/dist/types/factories/ChangesProcessorFactory.d.ts +13 -19
- package/dist/types/factories/CollectionEntryFactory.d.ts +11 -14
- package/dist/types/factories/CollectionResourceFactory.d.ts +18 -22
- package/dist/types/factories/ColumnExpansionFactory.d.ts +7 -9
- package/dist/types/factories/ColumnInfoFactory.d.ts +7 -8
- package/dist/types/factories/ColumnSetFactory.d.ts +18 -20
- package/dist/types/factories/ColumnSubsetCacheFactory.d.ts +8 -9
- package/dist/types/factories/CreateRequestFactory.d.ts +9 -11
- package/dist/types/factories/ItemCacheFactory.d.ts +6 -8
- package/dist/types/factories/ItemEntryFactory.d.ts +12 -15
- package/dist/types/factories/ItemResourceFactory.d.ts +11 -14
- package/dist/types/factories/ModuleChangesCompilationFactory.d.ts +4 -5
- package/dist/types/factories/QueryMatcherFactory.d.ts +7 -8
- package/dist/types/factories/QueryParserFactory.d.ts +5 -6
- package/dist/types/factories/RequestColumnExpansionFactory.d.ts +8 -9
- package/dist/types/factories/TemplateFactory.d.ts +8 -11
- package/dist/types/factories/TransactionCacheFactory.d.ts +13 -15
- package/dist/types/index.d.ts +1 -7
- package/dist/types/interfaces/AbstractCacheDependencyInterface.d.ts +36 -43
- package/dist/types/interfaces/ApiRequestServiceInterface.d.ts +12 -12
- package/dist/types/interfaces/AuthInterface.d.ts +10 -10
- package/dist/types/interfaces/ErrorHandlerInterface.d.ts +5 -5
- package/dist/types/interfaces/ExceptionHandlerInterface.d.ts +3 -3
- package/dist/types/interfaces/LinkTreeServiceInterface.d.ts +4 -4
- package/dist/types/interfaces/PromiseLibraryInterface.d.ts +25 -25
- package/dist/types/interfaces/ServerCacheDependencyInterface.d.ts +5 -7
- package/dist/types/interfaces/SocketMessageInterface.d.ts +3 -3
- package/dist/types/interfaces/TransactionCollectionHandlerDependencyInterface.d.ts +17 -21
- package/dist/types/interfaces/TransactionItemHandlerDependencyInterface.d.ts +22 -27
- package/dist/types/internal.d.ts +104 -0
- package/dist/types/models/CachedQueryItem.d.ts +19 -0
- package/dist/types/models/CollectionEntry.d.ts +21 -24
- package/dist/types/models/CollectionOptions.d.ts +42 -24
- package/dist/types/models/CollectionResource.d.ts +87 -78
- package/dist/types/models/ItemEntry.d.ts +18 -19
- package/dist/types/models/ItemEntryOptions.d.ts +8 -8
- package/dist/types/models/ItemResource.d.ts +90 -88
- package/dist/types/models/Template.d.ts +11 -13
- package/dist/types/types/ItemTypesCollection.d.ts +343 -345
- package/dist/types/types/PromiseInterface.d.ts +2 -2
- package/package.json +48 -38
- package/readme.md +15 -15
- package/dist/types/classes/CollectionMatcherBase.d.ts +0 -22
- package/dist/types/classes/CollectionMatcherCachedCollectionProcessor.d.ts +0 -32
- package/dist/types/classes/cache/CollectionMatcherCachedQueryProcessor.d.ts +0 -36
- package/dist/types/classes/index.d.ts +0 -46
- package/dist/types/factories/CollectionMatcherFactory.d.ts +0 -19
- package/dist/types/factories/index.d.ts +0 -21
- package/dist/types/interfaces/index.d.ts +0 -11
- package/dist/types/models/index.d.ts +0 -7
- package/dist/types/types/index.d.ts +0 -2
|
@@ -1,112 +1,95 @@
|
|
|
1
|
-
import { ApiEnumItemType } from '@rentman/backend-types';
|
|
2
|
-
import { RmCore } from '../../core';
|
|
3
|
-
import { AbstractCacheDependencyInterface } from '../../
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @description
|
|
40
|
-
*
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
abstract
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
*
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
abstract
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
protected
|
|
95
|
-
|
|
96
|
-
* @description
|
|
97
|
-
* Called by applyChangesDelta from ServerCache and TransactionCache. Applies creates, updates and moves, doesn't apply deletes
|
|
98
|
-
*
|
|
99
|
-
* @private
|
|
100
|
-
*/
|
|
101
|
-
protected _applyChangesDelta(changesDelta: ChangesDelta | InternalChangesDelta): {
|
|
102
|
-
result: ChangesDeltaResult;
|
|
103
|
-
parentChangesDelta: ParentChangesDelta;
|
|
104
|
-
matchingDelta: ParentChangesDelta;
|
|
105
|
-
undoFunctions: Array<(changesDelta: InternalChangesDelta) => void>;
|
|
106
|
-
};
|
|
107
|
-
/**
|
|
108
|
-
* @description
|
|
109
|
-
* Ensures that for all updated items in the delta the required derived values are present
|
|
110
|
-
*/
|
|
111
|
-
protected fetchUpdatedDerivedValuesFromDelta(changesDelta: ChangesDeltaBase): PromiseInterface<void>;
|
|
112
|
-
}
|
|
1
|
+
import { ApiEnumItemType } from '@rentman/backend-types';
|
|
2
|
+
import { RmCore } from '../../core';
|
|
3
|
+
import { AbstractCacheDependencyInterface, ApiRequestColumn, CachedQueryItem, ChangesDelta, ChangesDeltaBase, ChangesDeltaResult, CollectionQuery, CollectionResourceParentIdMap, EntryParentNull, FieldMap, InternalChangesDelta, ItemCache, ItemEntry, ItemHandlerBase, ItemIdConversionMap, OnAfterCreateCallback, ParentChangesDelta, PromiseInterface, ServerCache, ServerCachedQueryHandler, ServerItemEntryChanges, TransactionCache, TransactionCachedQueryHandler, TransactionItemEntryChanges, TransactionValidatorFactory } from '../../internal';
|
|
4
|
+
export declare type TransactionOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* @description
|
|
7
|
+
* Sets the TransactionCache to 'transparent' mode, whenever {@link AbstractCache.createChild createChild} is called it will actually be called on the parent
|
|
8
|
+
*/
|
|
9
|
+
transparent: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare abstract class AbstractCache {
|
|
12
|
+
dependencies: AbstractCacheDependencyInterface;
|
|
13
|
+
core: RmCore;
|
|
14
|
+
children: TransactionCache[];
|
|
15
|
+
readonly itemHandler: ItemHandlerBase;
|
|
16
|
+
readonly cachedQueryHandler: TransactionCachedQueryHandler | ServerCachedQueryHandler;
|
|
17
|
+
parent: AbstractCache | null;
|
|
18
|
+
protected constructor(dependencies: AbstractCacheDependencyInterface, core: RmCore);
|
|
19
|
+
abstract createChild(id?: string, validatorFactory?: TransactionValidatorFactory, options?: TransactionOptions): TransactionCache;
|
|
20
|
+
onChildDestroy(cache: TransactionCache): void;
|
|
21
|
+
/**
|
|
22
|
+
* @description
|
|
23
|
+
* Expands the items in the collections with the passed columns
|
|
24
|
+
*
|
|
25
|
+
* todo[limit] move to TransactionCache ?
|
|
26
|
+
*/
|
|
27
|
+
abstract expandCollectionResources<ItemTypeType extends ApiEnumItemType>(itemType: ItemTypeType, collections: CollectionResourceParentIdMap<ItemTypeType>, newColumns: ApiRequestColumn[]): PromiseInterface<CollectionResourceParentIdMap>;
|
|
28
|
+
/**
|
|
29
|
+
* @description
|
|
30
|
+
* Returns {@link ItemEntry ItemEntries} that fit the collection's query, copies over the collectionChanges on all transactions in the chain.
|
|
31
|
+
*/
|
|
32
|
+
abstract getCollectionChangesRecursively<ItemTypeType extends ApiEnumItemType>(itemType: ItemTypeType, parsedQuery: CollectionQuery): CachedQueryItem<ItemTypeType> | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* @description
|
|
35
|
+
* Returns this transaction and all parents
|
|
36
|
+
*/
|
|
37
|
+
getTransactionChain(): AbstractCache[];
|
|
38
|
+
/**
|
|
39
|
+
* @description
|
|
40
|
+
* Returns the {@link TransactionItemHandler.entries ItemCache} of the transaction
|
|
41
|
+
*/
|
|
42
|
+
getCurrentItemEntryCache(): ItemCache;
|
|
43
|
+
abstract getServerCache(): ServerCache;
|
|
44
|
+
abstract getLocalItemEntry(itemEntryId: ItemEntry['id']): ItemEntry | undefined;
|
|
45
|
+
abstract getLocalItemEntryByItemId(itemType: ApiEnumItemType, itemId: ItemEntry['itemId']): ItemEntry | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* @description
|
|
48
|
+
* Applies changes from a child transaction to a parent
|
|
49
|
+
*/
|
|
50
|
+
abstract applyChangesFromChild(transaction: TransactionCache, breakUpByParent?: boolean, onAfterCreateCallback?: OnAfterCreateCallback): PromiseInterface<ItemIdConversionMap>;
|
|
51
|
+
/**
|
|
52
|
+
* @description
|
|
53
|
+
* Called by a parent transaction, propagates changes downwards to all child caches
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* - Should only be used by the core
|
|
57
|
+
*
|
|
58
|
+
* todo[cache] Should we refetch derived values just like in applyChangesDelta ?
|
|
59
|
+
*
|
|
60
|
+
* @internal
|
|
61
|
+
*/
|
|
62
|
+
abstract applyChangesFromParent(parentChangesDelta: ParentChangesDelta, isCalledAfterSocketUpdate: boolean): void;
|
|
63
|
+
abstract getParent<ItemTypeType extends ApiEnumItemType = any>(itemEntry: ItemEntry<ItemTypeType>, fromInitial?: boolean, providedFields?: FieldMap<ItemTypeType>): EntryParentNull;
|
|
64
|
+
abstract getItemChangesRecursively(itemEntryId: ItemEntry['id'], copyFields?: boolean): FieldMap;
|
|
65
|
+
abstract getLocalItemEntryChangesTuple(itemEntryId: ItemEntry['id']): any;
|
|
66
|
+
/**
|
|
67
|
+
* @description
|
|
68
|
+
* Because the `itemChanges` object differs between the {@link ServerItemHandler.itemChanges ServerItemHandler} and the {@link TransactionItemHandler.itemChanges TransactionItemHandler} we need a function to normalise those values
|
|
69
|
+
*
|
|
70
|
+
* @remarks
|
|
71
|
+
* - Should only be used by the core
|
|
72
|
+
*
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
abstract getChangesFromItemChanges<ItemTypeType extends ApiEnumItemType = any>(changesObject: ServerItemEntryChanges<ItemTypeType> | TransactionItemEntryChanges<FieldMap<ItemTypeType>>): FieldMap<ItemTypeType>;
|
|
76
|
+
abstract applyChangesDelta(changesDelta: ChangesDelta): PromiseInterface<ChangesDeltaResult>;
|
|
77
|
+
protected getParentFromFields<ItemTypeType extends ApiEnumItemType = any>(itemEntry: ItemEntry<ItemTypeType>, fields: FieldMap<ItemTypeType>): EntryParentNull;
|
|
78
|
+
/**
|
|
79
|
+
* @description
|
|
80
|
+
* Called by applyChangesDelta from ServerCache and TransactionCache. Applies creates, updates and moves, doesn't apply deletes
|
|
81
|
+
*
|
|
82
|
+
* @private
|
|
83
|
+
*/
|
|
84
|
+
protected _applyChangesDelta(changesDelta: ChangesDelta | InternalChangesDelta): {
|
|
85
|
+
result: ChangesDeltaResult;
|
|
86
|
+
parentChangesDelta: ParentChangesDelta;
|
|
87
|
+
matchingDelta: ParentChangesDelta;
|
|
88
|
+
undoFunctions: Array<(changesDelta: InternalChangesDelta) => void>;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* @description
|
|
92
|
+
* Ensures that for all updated items in the delta the required derived values are present
|
|
93
|
+
*/
|
|
94
|
+
protected fetchUpdatedDerivedValuesFromDelta(changesDelta: ChangesDeltaBase): PromiseInterface<void>;
|
|
95
|
+
}
|
|
@@ -1,75 +1,68 @@
|
|
|
1
|
-
import { ApiEnumItemType, ItemId } from '@rentman/backend-types';
|
|
2
|
-
import { RequestColumnExpansionFactory } from '../../
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
protected transaction: AbstractCache;
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
*
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
* @
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
* @
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* @description
|
|
71
|
-
* Expands the option's {@link CollectionOptions.columns columns} with the columns required for the {@link CollectionMatcherCachedCollectionProcessor CollectionMatcher} to function.
|
|
72
|
-
* Data fetched for a parent transaction might also fit in a child transaction, so those {@link CollectionOptions.queryColumns queryColumns} should also be taken into account
|
|
73
|
-
*/
|
|
74
|
-
expandColumnsWithQueryColumns(itemType: ApiEnumItemType, options: CollectionOptions, query: ApiQuery): void;
|
|
75
|
-
}
|
|
1
|
+
import { ApiEnumItemType, ItemId } from '@rentman/backend-types';
|
|
2
|
+
import { AbstractCache, ApiQuery, ApiRequestColumns, CachedQueryItem, CollectionEntryService, CollectionOptions, CollectionQuery, ColumnSubsetCache, ColumnUtil, ItemEntry, ParentIdMap, ParentItemMap, PromiseInterface, PromiseLibraryInterface, RequestColumnExpansionFactory } from '../../internal';
|
|
3
|
+
export declare type CachedQueryItemTree<ItemTypeType extends ApiEnumItemType = any> = {
|
|
4
|
+
item: CachedQueryItem<ItemTypeType>;
|
|
5
|
+
children: ParentItemMap<CachedQueryItemTree> | null;
|
|
6
|
+
};
|
|
7
|
+
export declare abstract class CachedQueryHandlerBase {
|
|
8
|
+
protected collectionEntryService: CollectionEntryService;
|
|
9
|
+
protected columnUtil: ColumnUtil;
|
|
10
|
+
protected requestColumnExpansionFactory: RequestColumnExpansionFactory;
|
|
11
|
+
protected promiseService: PromiseLibraryInterface;
|
|
12
|
+
protected transaction: AbstractCache;
|
|
13
|
+
/**
|
|
14
|
+
* @description
|
|
15
|
+
* Items (per ItemType) that fit in a query
|
|
16
|
+
*
|
|
17
|
+
* @remark
|
|
18
|
+
* Contains the requestColumns so that new items can include these columns (saving requests when they match)
|
|
19
|
+
*/
|
|
20
|
+
cachedQueries: {
|
|
21
|
+
[itemType: string]: {
|
|
22
|
+
[queryString: string]: CachedQueryItem;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
protected constructor(collectionEntryService: CollectionEntryService, columnUtil: ColumnUtil, requestColumnExpansionFactory: RequestColumnExpansionFactory, promiseService: PromiseLibraryInterface, transaction: AbstractCache);
|
|
26
|
+
/**
|
|
27
|
+
* Every time a cached query item is created, either 'resolve' or 'reject' has to be called on the cached query item.
|
|
28
|
+
*/
|
|
29
|
+
setCachedQuery<ItemTypeType extends ApiEnumItemType>(itemType: ItemTypeType, parsedQuery: CollectionQuery, requestColumns: ApiRequestColumns, itemEntries?: Array<ItemEntry<ItemTypeType>>): CachedQueryItem<ItemTypeType>;
|
|
30
|
+
/**
|
|
31
|
+
* Every time a cached query item is created, either 'resolve' or 'reject' has to be called on the cached query item.
|
|
32
|
+
*/
|
|
33
|
+
protected constructCachedQuery<ItemTypeType extends ApiEnumItemType>(itemType: ItemTypeType, parsedQuery: CollectionQuery, itemEntries: Array<ItemEntry<ItemTypeType>>, requestColumns: ApiRequestColumns): CachedQueryItem<ItemTypeType>;
|
|
34
|
+
getCachedQueryItems<ItemTypeType extends ApiEnumItemType>(itemType: ItemTypeType, queryString: string): undefined | Array<ItemEntry<ItemTypeType>>;
|
|
35
|
+
getCachedQueryObjectsByItemType(itemType: ApiEnumItemType): CachedQueryItem[];
|
|
36
|
+
/**
|
|
37
|
+
* @description
|
|
38
|
+
* Fetches a {@link CollectionEntry CollectionEntry} with the given options
|
|
39
|
+
*/
|
|
40
|
+
abstract __fetchCachedQueryItem<ItemTypeType extends ApiEnumItemType>(itemType: ItemTypeType, options: CollectionOptions): PromiseInterface<CachedQueryItem<ItemTypeType>>;
|
|
41
|
+
/**
|
|
42
|
+
* @description
|
|
43
|
+
* Fetches collections linked to the passed parents
|
|
44
|
+
*/
|
|
45
|
+
abstract __fetchItemEntriesByQueryData<ItemTypeType extends ApiEnumItemType>(itemType: ItemTypeType, options: CollectionOptions<ItemTypeType>, columnSubsetCache: ColumnSubsetCache<ItemTypeType>, collectionQuery: CollectionQuery): PromiseInterface<CachedQueryItem<ItemTypeType>>;
|
|
46
|
+
/**
|
|
47
|
+
* @description
|
|
48
|
+
* Fetches collections linked to the passed parents
|
|
49
|
+
*/
|
|
50
|
+
abstract __fetchLinkedCachedQueryItems<ItemTypeType extends ApiEnumItemType>(parentType: ApiEnumItemType, parentIdArray: ItemId[] | (() => ItemId[]), itemType: ItemTypeType, options: CollectionOptions): PromiseInterface<ParentIdMap<CachedQueryItem<ItemTypeType>>>;
|
|
51
|
+
/**
|
|
52
|
+
* @description
|
|
53
|
+
* Adds the passed {@link ItemEntry ItemEntries} to the Transaction's query cache,
|
|
54
|
+
* will skip the ItemEntry if the `skipEntryFilterFn` callback returns `true`
|
|
55
|
+
*/
|
|
56
|
+
protected __addItemEntriesToCachedQueries<ItemTypeType extends ApiEnumItemType>(itemType: ItemTypeType, parsedQuery: CollectionQuery, itemEntries: Array<ItemEntry<ItemTypeType>>, skipEntryFilterFn: (temEntry: ItemEntry) => boolean): void;
|
|
57
|
+
/**
|
|
58
|
+
* @description
|
|
59
|
+
* Removes the passed {@link ItemId ItemIds} from the Transaction's query cache
|
|
60
|
+
*/
|
|
61
|
+
__removeItemEntriesFromCachedQueries<ItemTypeType extends ApiEnumItemType>(itemType: ItemTypeType, parsedQuery: CollectionQuery, itemEntries: Array<ItemEntry<ItemTypeType>>): Array<ItemEntry<ItemTypeType>>;
|
|
62
|
+
/**
|
|
63
|
+
* @description
|
|
64
|
+
* Expands the option's {@link CollectionOptions.columns columns} with the columns required for the {@link CollectionMatcherCachedCollectionProcessor CollectionMatcher} to function.
|
|
65
|
+
* Data fetched for a parent transaction might also fit in a child transaction, so those {@link CollectionOptions.queryColumns queryColumns} should also be taken into account
|
|
66
|
+
*/
|
|
67
|
+
expandColumnsWithQueryColumns(itemType: ApiEnumItemType, options: CollectionOptions, query: ApiQuery): void;
|
|
68
|
+
}
|
|
@@ -1,106 +1,95 @@
|
|
|
1
|
-
import { ApiEnumItemType, ItemId } from '@rentman/backend-types';
|
|
2
|
-
import { ItemCacheFactory, ItemEntryFactory, RequestColumnExpansionFactory } from '../../
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
protected columnUtil: ColumnUtil;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
*
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
* @
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
*
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*/
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
*
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*/
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* @description
|
|
98
|
-
* Creates a new {@link ItemEntry ItemEntry} from the passed {@link ChangesDeltaItemCreateDelta ChangesDeltaItemCreateDelta} and stores it in this transaction's {@link ItemCache ItemCache}
|
|
99
|
-
*/
|
|
100
|
-
createItemEntry(createTuple: ChangesDeltaItemCreateDelta): ItemEntry;
|
|
101
|
-
/**
|
|
102
|
-
* @description
|
|
103
|
-
* Gets the value of the given column, will look into the current delta before attempting to read itemChanges
|
|
104
|
-
*/
|
|
105
|
-
protected getItemIdByColumn<ItemTypeType extends ApiEnumItemType>(itemEntry: ItemEntry<ItemTypeType>, column: ColumnInfo<ItemTypeType>, changesDelta?: ChangesDeltaBase): ItemId;
|
|
106
|
-
}
|
|
1
|
+
import { ApiEnumItemType, ItemId } from '@rentman/backend-types';
|
|
2
|
+
import { AbstractCache, ApiFormatter, ApiQuery, ChangesDeltaBase, ChangesDeltaItemCreateDelta, ChangesDeltaItemUpdateDelta, ColumnInfo, ColumnUtil, ErrorHandlerInterface, FieldMap, ItemCache, ItemCacheFactory, ItemEntry, ItemEntryFactory, ItemEntryOptions, PromiseInterface, PromiseLibraryInterface, RequestColumnExpansionFactory, TransactionItemEntryChanges } from '../../internal';
|
|
3
|
+
export declare enum ItemCacheStatus {
|
|
4
|
+
CACHED = "cached",
|
|
5
|
+
NOT_CACHED = "not_cached",
|
|
6
|
+
NO_CHANGES = "no_changes"
|
|
7
|
+
}
|
|
8
|
+
export declare type ProcessItemEntryChangesResult<ItemTypeType extends ApiEnumItemType> = {
|
|
9
|
+
status: ItemCacheStatus.NO_CHANGES | ItemCacheStatus.NOT_CACHED;
|
|
10
|
+
previous: null;
|
|
11
|
+
} | {
|
|
12
|
+
status: ItemCacheStatus.CACHED;
|
|
13
|
+
previous: FieldMap<ItemTypeType>;
|
|
14
|
+
};
|
|
15
|
+
export declare abstract class ItemHandlerBase {
|
|
16
|
+
protected columnUtil: ColumnUtil;
|
|
17
|
+
protected apiFormatter: ApiFormatter;
|
|
18
|
+
protected itemEntryFactory: ItemEntryFactory;
|
|
19
|
+
protected promiseService: PromiseLibraryInterface;
|
|
20
|
+
protected errorHandler: ErrorHandlerInterface;
|
|
21
|
+
protected requestColumnExpansionFactory: RequestColumnExpansionFactory;
|
|
22
|
+
protected transaction: AbstractCache;
|
|
23
|
+
readonly entries: ItemCache;
|
|
24
|
+
abstract itemChanges: {
|
|
25
|
+
[itemEntryId: string]: any;
|
|
26
|
+
};
|
|
27
|
+
protected constructor(columnUtil: ColumnUtil, apiFormatter: ApiFormatter, itemEntryFactory: ItemEntryFactory, promiseService: PromiseLibraryInterface, errorHandler: ErrorHandlerInterface, requestColumnExpansionFactory: RequestColumnExpansionFactory, itemCacheFactory: ItemCacheFactory, transaction: AbstractCache);
|
|
28
|
+
/**
|
|
29
|
+
* @description
|
|
30
|
+
* Copies the passed ItemEntryChanges into a format the implementing ItemHandler can put in his ItemChanges
|
|
31
|
+
* @param itemEntryChanges
|
|
32
|
+
* @param entry
|
|
33
|
+
*/
|
|
34
|
+
abstract copyTransactionItemEntryChanges(itemEntryChanges: TransactionItemEntryChanges, entry: ItemEntry): any;
|
|
35
|
+
/**
|
|
36
|
+
* @description
|
|
37
|
+
* Fetches the ItemEntries for the given query, does not look in the cache, since we don't know which ItemIds belong to the query !
|
|
38
|
+
*/
|
|
39
|
+
abstract fetchItemEntriesByQuery<ItemTypeType extends ApiEnumItemType>(itemType: ItemTypeType, query: ApiQuery, entryOptions: ItemEntryOptions): PromiseInterface<Array<ItemEntry<ItemTypeType>>>;
|
|
40
|
+
/**
|
|
41
|
+
* @description
|
|
42
|
+
* Fetches the ItemEntries for the given ItemIds
|
|
43
|
+
*/
|
|
44
|
+
abstract fetchItemEntries<ItemTypeType extends ApiEnumItemType>(itemType: ItemTypeType, itemIds: ItemId[], options: ItemEntryOptions): PromiseInterface<Array<ItemEntry<ItemTypeType>>>;
|
|
45
|
+
/**
|
|
46
|
+
* @description
|
|
47
|
+
* Fetches an ItemEntry with the given itemId
|
|
48
|
+
*/
|
|
49
|
+
abstract fetchItemEntry<ItemTypeType extends ApiEnumItemType>(itemType: ItemTypeType, itemId: ItemId, options: ItemEntryOptions, isRoot?: boolean): PromiseInterface<ItemEntry<ItemTypeType>>;
|
|
50
|
+
/**
|
|
51
|
+
* @description
|
|
52
|
+
* Processes the passed {@link ChangesDeltaItemUpdateDelta update delta} on the transaction, if there are no {@link TransactionItemHandler.itemChanges itemChanges} the new values will not be processed
|
|
53
|
+
*/
|
|
54
|
+
abstract processItemEntryChanges<ItemTypeType extends ApiEnumItemType>(itemEntryChangesTuple: ChangesDeltaItemUpdateDelta<ItemTypeType>, isCalledAfterSocketUpdate: boolean, createItemChangesIfNoneExist: boolean): ProcessItemEntryChangesResult<ItemTypeType>;
|
|
55
|
+
/**
|
|
56
|
+
* @description
|
|
57
|
+
* Traverses the column path and returns the fields of the derived item, returns undefined if the item isn't found
|
|
58
|
+
*
|
|
59
|
+
* ---------------------
|
|
60
|
+
*
|
|
61
|
+
* @remark
|
|
62
|
+
* Assumes the derived item's values are already cached
|
|
63
|
+
*/
|
|
64
|
+
getDerivedValues(itemEntry: ItemEntry, columnPath: string[]): Readonly<FieldMap> | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* @description
|
|
67
|
+
* Returns the value of the columnPath, or undefined when the path couldn't be traversed
|
|
68
|
+
*
|
|
69
|
+
* @param itemEntry The root entry to start the path from
|
|
70
|
+
* @param columnPath Can either be an array of columnIds (['column', 'column2']) or a config column string ('column>column2')
|
|
71
|
+
*/
|
|
72
|
+
getDerivedValue<T extends any = any>(itemEntry: ItemEntry, columnPath: string[] | string): T | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* @description
|
|
75
|
+
* Clears the entry from this transaction, removing it from the {@link ItemCache ItemCache} and removing all changes
|
|
76
|
+
*/
|
|
77
|
+
clearItemEntry(entry: ItemEntry): void;
|
|
78
|
+
/**
|
|
79
|
+
* @description
|
|
80
|
+
* Recursively fetches derived values as separate requests, instead of as columns of a primary item
|
|
81
|
+
* Can be used when derived values of a local item have to be fetched, since a local item can't be used as root item of a query
|
|
82
|
+
*/
|
|
83
|
+
fetchDerivedValuesByColumn<ItemTypeType extends ApiEnumItemType>(itemEntries: Array<ItemEntry<ItemTypeType>>, rootColumn: ColumnInfo<ItemTypeType>, changesDelta?: ChangesDeltaBase): PromiseInterface<void | Array<ItemEntry<ItemTypeType>>>;
|
|
84
|
+
resolveDerivedValues<ItemTypeType extends ApiEnumItemType>(itemEntries: Array<ItemEntry<ItemTypeType>>, columns: Array<ColumnInfo<ItemTypeType>>, changesDelta?: ChangesDeltaBase): PromiseInterface<Array<ItemEntry<ItemTypeType>>>;
|
|
85
|
+
/**
|
|
86
|
+
* @description
|
|
87
|
+
* Creates a new {@link ItemEntry ItemEntry} from the passed {@link ChangesDeltaItemCreateDelta ChangesDeltaItemCreateDelta} and stores it in this transaction's {@link ItemCache ItemCache}
|
|
88
|
+
*/
|
|
89
|
+
createItemEntry(createTuple: ChangesDeltaItemCreateDelta): ItemEntry;
|
|
90
|
+
/**
|
|
91
|
+
* @description
|
|
92
|
+
* Gets the value of the given column, will look into the current delta before attempting to read itemChanges
|
|
93
|
+
*/
|
|
94
|
+
protected getItemIdByColumn<ItemTypeType extends ApiEnumItemType>(itemEntry: ItemEntry<ItemTypeType>, column: ColumnInfo<ItemTypeType>, changesDelta?: ChangesDeltaBase): ItemId;
|
|
95
|
+
}
|