@rentman/rm-core 2.0.6 → 2.0.8
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 +10 -0
- package/dist/rm-core.js +105 -102
- package/dist/rm-core.min.js +1 -1
- package/dist/src/classes/ChangesProcessor.d.ts +2 -3
- package/dist/src/classes/cache/AbstractCache.d.ts +2 -1
- package/dist/src/classes/cache/ItemHandlerBase.d.ts +12 -5
- package/dist/src/classes/cache/server/ServerCache.d.ts +12 -1
- package/dist/src/classes/cache/server/ServerItemHandler.d.ts +8 -7
- package/dist/src/classes/cache/transaction/TransactionCache.d.ts +2 -2
- package/dist/src/classes/cache/transaction/TransactionItemHandler.d.ts +4 -3
- package/dist/src/factories/ChangesProcessorFactory.d.ts +2 -3
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ApiRequestService, CollectionEntryService, ItemEntryService } from '../classes';
|
|
2
2
|
import { ChangesCompilationFactory, ColumnExpansionFactory, CreateRequestFactory, RequestColumnExpansionFactory } from '../factories';
|
|
3
3
|
import { ChangesDeltaFactory } from '../factories/ChangesDeltaFactory';
|
|
4
4
|
import { ErrorHandlerInterface, PromiseLibraryInterface } from '../interfaces';
|
|
@@ -10,7 +10,6 @@ export declare type OnAfterCreateCallback = (conversionMap: ItemIdConversionMap)
|
|
|
10
10
|
* Executes the changes from a specific {@link TransactionCache transaction} and returns a {@link ChangesDelta ChangesDelta}
|
|
11
11
|
*/
|
|
12
12
|
export declare class ChangesProcessor {
|
|
13
|
-
private apiFormatter;
|
|
14
13
|
private changesDeltaFactory;
|
|
15
14
|
private apiRequestService;
|
|
16
15
|
private changesCompilationFactory;
|
|
@@ -26,7 +25,7 @@ export declare class ChangesProcessor {
|
|
|
26
25
|
private onAfterCreateCallback?;
|
|
27
26
|
private itemIdConversionMap;
|
|
28
27
|
private serverCache;
|
|
29
|
-
constructor(
|
|
28
|
+
constructor(changesDeltaFactory: ChangesDeltaFactory, apiRequestService: ApiRequestService, changesCompilationFactory: ChangesCompilationFactory, columnExpansionFactory: ColumnExpansionFactory, createRequestFactory: CreateRequestFactory, errorHandler: ErrorHandlerInterface, promiseService: PromiseLibraryInterface, requestColumnExpansionFactory: RequestColumnExpansionFactory, collectionEntryService: CollectionEntryService, itemEntryService: ItemEntryService, transaction: TransactionCache, breakUpByParent?: boolean | undefined, onAfterCreateCallback?: OnAfterCreateCallback | undefined);
|
|
30
29
|
/**
|
|
31
30
|
* @description
|
|
32
31
|
* Executes the requests in the order of:
|
|
@@ -101,7 +101,7 @@ export declare abstract class AbstractCache {
|
|
|
101
101
|
* @internal
|
|
102
102
|
*/
|
|
103
103
|
abstract applyChangesFromParent(internalChangesDelta: InternalChangesDelta, isCalledAfterApiSave: boolean, isCalledAfterSocketUpdate: boolean): void;
|
|
104
|
-
abstract getParent(itemEntry: ItemEntry
|
|
104
|
+
abstract getParent<ItemTypeType extends ItemType = any>(itemEntry: ItemEntry<ItemTypeType>, fromInitial?: boolean, providedFields?: FieldMap<ItemTypeType>): EntryParentNull;
|
|
105
105
|
abstract getItemChangesRecursively(itemEntryId: ItemEntry['id'], copyFields?: boolean): FieldMap;
|
|
106
106
|
abstract getLocalItemEntryChangesTuple(itemEntryId: ItemEntry['id']): any;
|
|
107
107
|
/**
|
|
@@ -115,6 +115,7 @@ export declare abstract class AbstractCache {
|
|
|
115
115
|
*/
|
|
116
116
|
abstract getChangesFromItemChanges<ItemTypeType extends ItemType = any>(changesObject: ServerItemEntryChanges<ItemTypeType> | TransactionItemEntryChanges<ItemTypeType>): FieldMap<ItemTypeType>;
|
|
117
117
|
abstract applyChangesDelta(changesDelta: ChangesDelta): PromiseInterface<ChangesDeltaResult>;
|
|
118
|
+
protected getParentFromFields<ItemTypeType extends ItemType = any>(itemEntry: ItemEntry<ItemTypeType>, fields: FieldMap<ItemTypeType>): EntryParentNull;
|
|
118
119
|
/**
|
|
119
120
|
* @description
|
|
120
121
|
* Called by applyChangesDelta from ServerCache and TransactionCache. Applies creates, updates and moves, doesn't apply deletes
|
|
@@ -21,6 +21,13 @@ export declare abstract class ItemHandlerBase {
|
|
|
21
21
|
readonly entries: ItemCache;
|
|
22
22
|
abstract itemChanges: ServerItemEntryChanges | TransactionItemEntryChanges;
|
|
23
23
|
protected constructor(columnUtil: ColumnUtil, apiFormatter: ApiFormatter, itemEntryFactory: ItemEntryFactory, promiseService: PromiseLibraryInterface, errorHandler: ErrorHandlerInterface, itemCacheFactory: ItemCacheFactory, transaction: AbstractCache);
|
|
24
|
+
/**
|
|
25
|
+
* @description
|
|
26
|
+
* Copies the passed ItemEntryChanges into a format the implementing ItemHandler can put in his ItemChanges
|
|
27
|
+
* @param itemEntryChanges
|
|
28
|
+
* @param entry
|
|
29
|
+
*/
|
|
30
|
+
abstract copyTransactionItemEntryChanges(itemEntryChanges: TransactionItemEntryChanges, entry: ItemEntry): any;
|
|
24
31
|
/**
|
|
25
32
|
* @description
|
|
26
33
|
* Fetches the ItemEntries for the given query, does not look in the cache, since we don't know which ItemIds belong to the query !
|
|
@@ -66,11 +73,6 @@ export declare abstract class ItemHandlerBase {
|
|
|
66
73
|
* Clears the entry from this transaction, removing it from the {@link ItemCache ItemCache} and removing all changes
|
|
67
74
|
*/
|
|
68
75
|
clearItemEntry(entry: ItemEntry): void;
|
|
69
|
-
/**
|
|
70
|
-
* @description
|
|
71
|
-
* Creates a new {@link ItemEntry ItemEntry} from the passed {@link ChangesDeltaItemCreateDelta ChangesDeltaItemCreateDelta} and stores it in this transaction's {@link ItemCache ItemCache}
|
|
72
|
-
*/
|
|
73
|
-
protected createItemEntry(createTuple: ChangesDeltaItemCreateDelta): ItemEntry;
|
|
74
76
|
/**
|
|
75
77
|
* @description
|
|
76
78
|
* Recursively fetches derived values as separate requests, instead of as columns of a primary item
|
|
@@ -78,6 +80,11 @@ export declare abstract class ItemHandlerBase {
|
|
|
78
80
|
*/
|
|
79
81
|
fetchDerivedValuesByColumn<ItemTypeType extends ItemType>(itemEntries: Array<ItemEntry<ItemTypeType>>, rootColumn: ColumnInfo<ItemTypeType>, changesDelta?: ChangesDeltaBase): PromiseInterface<void | Array<ItemEntry<ItemTypeType>>>;
|
|
80
82
|
resolveDerivedValues<ItemTypeType extends ItemType>(itemEntries: Array<ItemEntry<ItemTypeType>>, columns: Array<ColumnInfo<ItemTypeType>>, changesDelta?: ChangesDeltaBase): PromiseInterface<Array<ItemEntry<ItemTypeType>>>;
|
|
83
|
+
/**
|
|
84
|
+
* @description
|
|
85
|
+
* Creates a new {@link ItemEntry ItemEntry} from the passed {@link ChangesDeltaItemCreateDelta ChangesDeltaItemCreateDelta} and stores it in this transaction's {@link ItemCache ItemCache}
|
|
86
|
+
*/
|
|
87
|
+
protected createItemEntry(createTuple: ChangesDeltaItemCreateDelta): ItemEntry;
|
|
81
88
|
/**
|
|
82
89
|
* @description
|
|
83
90
|
* Gets the value of the given column, will look into the current delta before attempting to read itemChanges
|
|
@@ -52,7 +52,18 @@ export declare class ServerCache extends AbstractCache {
|
|
|
52
52
|
* Gets the fields required to set the parent
|
|
53
53
|
*/
|
|
54
54
|
getLinkFieldsByParent<ItemTypeType extends ItemType>(parent: EntryParent, itemType: ItemTypeType): Partial<FieldMap<ItemTypeType>>;
|
|
55
|
-
|
|
55
|
+
/**
|
|
56
|
+
* @description
|
|
57
|
+
* Gets the entry's parent
|
|
58
|
+
*
|
|
59
|
+
* @param itemEntry The entry to get the parent from
|
|
60
|
+
* @param _fromInitial Unused parameter, there for alignment with {@link TransactionCache.getParent TransactionCache.getParent]
|
|
61
|
+
* @param _providedFields Unused parameter, there for alignment with {@link TransactionCache.getParent TransactionCache.getParent]
|
|
62
|
+
*
|
|
63
|
+
* @remark
|
|
64
|
+
* Use {@link CollectionResource.getParent CollectionResource.getParent} instead of {@link TransactionCache.getParent TransactionCache.getParent} if you're getting the parent in the onRemove callback
|
|
65
|
+
*/
|
|
66
|
+
getParent<ItemTypeType extends ItemType = any>(itemEntry: ItemEntry<ItemTypeType>, _fromInitial?: boolean, _providedFields?: FieldMap<ItemTypeType>): EntryParentNull;
|
|
56
67
|
getItemChangesRecursively(itemEntryId: ItemEntry['id'], copyFields?: boolean): FieldMap;
|
|
57
68
|
/**
|
|
58
69
|
* @description
|
|
@@ -4,7 +4,7 @@ import { ItemEntry, ItemEntryOptions } from '../../../models';
|
|
|
4
4
|
import { ApiQuery, ApiRequestColumns, FieldMap, ItemId, ItemType, PromiseInterface } from '../../../types';
|
|
5
5
|
import { ChangesDelta, ChangesDeltaItemCreateDelta } from '../../ChangesDelta';
|
|
6
6
|
import { ChangesDeltaItemUpdateDelta } from '../../ChangesDeltaBase';
|
|
7
|
-
import { ApiFormatter, ApiResponseProcessor, ColumnExpansion, ColumnSet, ColumnUtil, QueryService, RequestBufferManager, RequestBufferResponse } from '../../index';
|
|
7
|
+
import { ApiFormatter, ApiResponseProcessor, ColumnExpansion, ColumnSet, ColumnUtil, QueryService, RequestBufferManager, RequestBufferResponse, TransactionItemEntryChanges } from '../../index';
|
|
8
8
|
import { ItemHandlerBase } from '../ItemHandlerBase';
|
|
9
9
|
import { ServerCache } from './ServerCache';
|
|
10
10
|
export declare type ServerItemEntryChanges<ItemTypeType extends ItemType = any> = FieldMap<ItemTypeType>;
|
|
@@ -24,15 +24,10 @@ export declare class ServerItemHandler extends ItemHandlerBase {
|
|
|
24
24
|
* Processes updates on a cached entry
|
|
25
25
|
*/
|
|
26
26
|
processItemEntryChanges<ItemTypeType extends ItemType = any>(itemEntryChangesTuple: ChangesDeltaItemUpdateDelta<ItemTypeType>, _forceOverwrite?: boolean, _updateInitial?: boolean, _isCalledAfterSocketUpdate?: boolean): FieldMap<ItemTypeType>;
|
|
27
|
+
copyTransactionItemEntryChanges(itemEntryChanges: TransactionItemEntryChanges, entry: ItemEntry): ServerItemEntryChanges;
|
|
27
28
|
fetchItemEntry<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemId: ItemId, options: ItemEntryOptions): PromiseInterface<ItemEntry<ItemTypeType>>;
|
|
28
29
|
fetchItemEntriesByQuery<ItemTypeType extends ItemType>(itemType: ItemTypeType, query: ApiQuery, entryOptions: ItemEntryOptions): PromiseInterface<Array<ItemEntry<ItemTypeType>>>;
|
|
29
30
|
fetchItemEntries<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemIds: ItemId[], options: ItemEntryOptions): PromiseInterface<Array<ItemEntry<ItemTypeType>>>;
|
|
30
|
-
/**
|
|
31
|
-
* @description
|
|
32
|
-
* Fetches the data for the passed ItemType/ItemId/columns, will do nothing if the requested ItemEntry/columns are already cached.
|
|
33
|
-
* Will create a new {@link ItemEntry ItemEntry} if the ItemEntry didn't exist yet
|
|
34
|
-
*/
|
|
35
|
-
private fetchItemEntryData;
|
|
36
31
|
/**
|
|
37
32
|
* @description
|
|
38
33
|
* Fetches the data for the ItemEntries linked to the parent Items
|
|
@@ -46,4 +41,10 @@ export declare class ServerItemHandler extends ItemHandlerBase {
|
|
|
46
41
|
* Will call {@link ChangesDelta.setItemCreated setItemCreated} if an entry doesn't exist yet, and otherwise {@link ChangesDelta.setItemUpdated setItemUpdated} if it does.
|
|
47
42
|
*/
|
|
48
43
|
processApiResponse<ItemTypeType extends ItemType>(changesDelta: ChangesDelta, response: ApiResponseProcessor, itemType: ItemTypeType, itemId: ItemId, columnSet: ColumnSet<ItemTypeType>, columnExpansion: ColumnExpansion<ItemTypeType>): void;
|
|
44
|
+
/**
|
|
45
|
+
* @description
|
|
46
|
+
* Fetches the data for the passed ItemType/ItemId/columns, will do nothing if the requested ItemEntry/columns are already cached.
|
|
47
|
+
* Will create a new {@link ItemEntry ItemEntry} if the ItemEntry didn't exist yet
|
|
48
|
+
*/
|
|
49
|
+
private fetchItemEntryData;
|
|
49
50
|
}
|
|
@@ -383,7 +383,6 @@ export declare class TransactionCache extends AbstractCache {
|
|
|
383
383
|
remote: true;
|
|
384
384
|
}): ItemResourcesItemTypeMap<RemoteViewResource<ItemTypeType>>;
|
|
385
385
|
processLinkedItems<ItemTypeType extends ItemType>(linkedEntries: ItemTypeMap<ItemEntry[]>, options: ItemOptionsInterface): ItemResourcesItemTypeMap<LocalViewResource<ItemTypeType>>;
|
|
386
|
-
private createCollectionResources;
|
|
387
386
|
createCollectionResource<ItemTypeType extends ItemType>(collectionEntry: CollectionEntry<ItemTypeType>, resourceOptions: CollectionResourceOptionsInterface<ItemTypeType> & {
|
|
388
387
|
editItems: true;
|
|
389
388
|
editCollection: true;
|
|
@@ -407,11 +406,12 @@ export declare class TransactionCache extends AbstractCache {
|
|
|
407
406
|
* Returns this transaction and all parents
|
|
408
407
|
*/
|
|
409
408
|
getTransactionChain(): AbstractCache[];
|
|
409
|
+
getChangesFromItemChanges<ItemTypeType extends ItemType = any>(changesObject: TransactionItemEntryChanges<ItemTypeType>): FieldMap<ItemTypeType>;
|
|
410
|
+
private createCollectionResources;
|
|
410
411
|
/**
|
|
411
412
|
* @description
|
|
412
413
|
* Fetches all required columns to match/fit in collections
|
|
413
414
|
*/
|
|
414
415
|
private expandItemsFromDelta;
|
|
415
|
-
getChangesFromItemChanges<ItemTypeType extends ItemType = any>(changesObject: TransactionItemEntryChanges<ItemTypeType>): FieldMap<ItemTypeType>;
|
|
416
416
|
}
|
|
417
417
|
export {};
|
|
@@ -36,6 +36,7 @@ export declare class TransactionItemHandler extends ItemHandlerBase {
|
|
|
36
36
|
[itemEntryId: number]: ItemResource[];
|
|
37
37
|
};
|
|
38
38
|
constructor(changesDeltaFactory: ChangesDeltaFactory, exceptionHandler: ExceptionHandlerInterface, templateCache: TemplateCache, columnExpansionFactory: ColumnExpansionFactory, columnHandler: ColumnHandler, columnSetFactory: ColumnSetFactory, columnSubsetCacheFactory: ColumnSubsetCacheFactory, errorHandler: ErrorHandlerInterface, itemEntryService: ItemEntryService, keyService: KeyService, promiseService: PromiseLibraryInterface, columnUtil: ColumnUtil, apiFormatter: ApiFormatter, itemEntryFactory: ItemEntryFactory, itemCacheFactory: ItemCacheFactory, transaction: TransactionCache);
|
|
39
|
+
copyTransactionItemEntryChanges(itemEntryChanges: TransactionItemEntryChanges, entry: ItemEntry): TransactionItemEntryChanges;
|
|
39
40
|
createItemEntry(createTuple: ChangesDeltaItemCreateDelta): ItemEntry;
|
|
40
41
|
/**
|
|
41
42
|
* @description
|
|
@@ -81,7 +82,7 @@ export declare class TransactionItemHandler extends ItemHandlerBase {
|
|
|
81
82
|
* @returns
|
|
82
83
|
* The previous changes {@link FieldMap FieldMap}
|
|
83
84
|
*/
|
|
84
|
-
processItemEntryChanges<ItemTypeType extends ItemType = any>(itemEntryChangesTuple: ChangesDeltaItemUpdateDelta<ItemTypeType>, forceOverwrite?: boolean, updateInitial?: boolean, isCalledAfterSocketUpdate?: boolean): FieldMap<ItemTypeType
|
|
85
|
+
processItemEntryChanges<ItemTypeType extends ItemType = any>(itemEntryChangesTuple: ChangesDeltaItemUpdateDelta<ItemTypeType>, forceOverwrite?: boolean, updateInitial?: boolean, isCalledAfterSocketUpdate?: boolean): FieldMap<ItemTypeType> | null;
|
|
85
86
|
cloneItemEntries<ItemTypeType extends ItemType>(itemEntries: Array<ItemEntry<ItemTypeType>>, conversionMap?: ItemIdConversionMap, modifyFieldsCallback?: (sourceEntry: ItemEntry<ItemTypeType>, fields: FieldMap<ItemTypeType>) => void): PromiseInterface<ChangesDeltaResult>;
|
|
86
87
|
cloneItemEntry<ItemTypeType extends ItemType>(changesDelta: ChangesDelta, sourceEntry: ItemEntry<ItemTypeType>, newFields?: FieldMap<ItemTypeType>, conversionMap?: ItemIdConversionMap, modifyFieldsCallback?: (sourceEntry: ItemEntry<ItemTypeType>, fields: FieldMap<ItemTypeType>) => void): ItemId;
|
|
87
88
|
fetchItemEntriesByQuery<ItemTypeType extends ItemType>(itemType: ItemTypeType, query: ApiQuery, entryOptions: ItemEntryOptions): PromiseInterface<Array<ItemEntry<ItemTypeType>>>;
|
|
@@ -94,8 +95,6 @@ export declare class TransactionItemHandler extends ItemHandlerBase {
|
|
|
94
95
|
fetchItemEntries<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemIds: ItemId[], options: ItemEntryOptions): PromiseInterface<Array<ItemEntry<ItemTypeType>>>;
|
|
95
96
|
fetchTitle(itemType: ItemType, itemId: ItemId): PromiseInterface<string>;
|
|
96
97
|
resolveLocalItemEntry<ItemTypeType extends ItemType>(changesDelta: ChangesDelta, itemEntry: ItemEntry<ItemTypeType>, columnSubsetCache: ColumnSubsetCache<ItemTypeType>, options: ItemEntryOptions): PromiseInterface<ItemEntry<ItemTypeType>>;
|
|
97
|
-
private getColumnDifference;
|
|
98
|
-
private resolveLocal;
|
|
99
98
|
createLocalEntries(changesDelta: ChangesDelta, parentType: ItemType, localParentId: ItemId, template: Template<ItemType>, itemIdConversion: ItemIdConversionMap, filterItemEntry?: <ItemTypeType extends ItemType>(itemType: ItemTypeType, fields: FieldMap<ItemTypeType>) => boolean, // return true to include item
|
|
100
99
|
modifyFieldsCallback?: <ItemTypeType extends ItemType>(itemType: ItemTypeType, fields: FieldMap<ItemTypeType>, itemIdConversionMap: ItemIdConversionMap) => void): void;
|
|
101
100
|
expandLocalItemEntries<ItemTypeType extends ItemType>(changesDelta: ChangesDeltaBase, itemType: ItemTypeType, itemEntries: Array<ItemEntry<ItemTypeType>>, requestColumns: ApiRequestColumns, responseColumns: ResponseColumnItemTypeMap): PromiseInterface<Array<ItemEntry<ItemTypeType>>>;
|
|
@@ -109,6 +108,8 @@ export declare class TransactionItemHandler extends ItemHandlerBase {
|
|
|
109
108
|
*/
|
|
110
109
|
fetchLocalItemEntryData<ItemTypeType extends ItemType>(changesDelta: ChangesDelta, itemType: ItemTypeType, itemId: ItemId, columnSubsetCache: ColumnSubsetCache<ItemTypeType>, options: ItemEntryOptions): PromiseInterface<any>;
|
|
111
110
|
fetchLocalItemEntries<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemIds: ItemId[], options: ItemEntryOptions): PromiseInterface<Array<ItemEntry<ItemTypeType>>>;
|
|
111
|
+
private getColumnDifference;
|
|
112
|
+
private resolveLocal;
|
|
112
113
|
private expandLocalItemEntry;
|
|
113
114
|
private getLocalValues;
|
|
114
115
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ApiRequestService, ChangesProcessor, CollectionEntryService, ItemEntryService, OnAfterCreateCallback } from '../classes';
|
|
2
2
|
import { TransactionCache } from '../classes/cache/transaction/TransactionCache';
|
|
3
3
|
import { ErrorHandlerInterface, PromiseLibraryInterface } from '../interfaces';
|
|
4
4
|
import { ChangesCompilationFactory } from './ChangesCompilationFactory';
|
|
@@ -7,7 +7,6 @@ import { ColumnExpansionFactory } from './ColumnExpansionFactory';
|
|
|
7
7
|
import { CreateRequestFactory } from './CreateRequestFactory';
|
|
8
8
|
import { RequestColumnExpansionFactory } from './RequestColumnExpansionFactory';
|
|
9
9
|
export declare class ChangesProcessorFactory {
|
|
10
|
-
private apiFormatter;
|
|
11
10
|
private changesDeltaFactory;
|
|
12
11
|
private apiRequestService;
|
|
13
12
|
private changesCompilationFactory;
|
|
@@ -18,6 +17,6 @@ export declare class ChangesProcessorFactory {
|
|
|
18
17
|
private requestColumnExpansionFactory;
|
|
19
18
|
private collectionEntryService;
|
|
20
19
|
private itemEntryService;
|
|
21
|
-
constructor(
|
|
20
|
+
constructor(changesDeltaFactory: ChangesDeltaFactory, apiRequestService: ApiRequestService, changesCompilationFactory: ChangesCompilationFactory, columnExpansionFactory: ColumnExpansionFactory, createRequestFactory: CreateRequestFactory, errorHandler: ErrorHandlerInterface, promiseService: PromiseLibraryInterface, requestColumnExpansionFactory: RequestColumnExpansionFactory, collectionEntryService: CollectionEntryService, itemEntryService: ItemEntryService);
|
|
22
21
|
construct(transaction: TransactionCache, breakUpByParent?: boolean, onAfterCreateCallback?: OnAfterCreateCallback): ChangesProcessor;
|
|
23
22
|
}
|