@rentman/rm-core 2.0.14 → 2.0.16
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 +189 -56
- package/dist/rm-core.min.js +1 -1
- package/dist/src/classes/ChangesDeltaBase.d.ts +17 -1
- package/dist/src/classes/CollectionCache.d.ts +1 -0
- package/dist/src/classes/RequestBuffer.d.ts +5 -2
- package/dist/src/classes/RequestBufferManager.d.ts +3 -2
- package/dist/src/classes/cache/AbstractCache.d.ts +6 -0
- package/dist/src/classes/cache/CollectionHandlerBase.d.ts +5 -1
- package/dist/src/classes/cache/server/ServerCache.d.ts +2 -1
- package/dist/src/classes/cache/server/ServerItemHandler.d.ts +1 -1
- package/dist/src/classes/cache/transaction/TransactionCache.d.ts +6 -0
- package/dist/src/classes/cache/transaction/TransactionItemHandler.d.ts +2 -1
- package/dist/src/models/CollectionResource.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ItemEntry } from '../models';
|
|
2
|
-
import { ColumnExpansionResult, EntryParentNull, FieldMap, ItemType } from '../types';
|
|
2
|
+
import { ColumnExpansionResult, EntryParentNull, FieldMap, ItemId, ItemType } from '../types';
|
|
3
3
|
import { ItemEntryService } from './ItemEntryService';
|
|
4
4
|
export declare type ChangesDeltaResult = {
|
|
5
5
|
rollback: () => void;
|
|
@@ -26,7 +26,23 @@ export declare abstract class ChangesDeltaBase {
|
|
|
26
26
|
deleted: {
|
|
27
27
|
[itemType: string]: ChangesDeltaItemDeleteDelta;
|
|
28
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
_queryResults: {
|
|
33
|
+
[itemType: string]: {
|
|
34
|
+
[queryString: string]: ItemId[];
|
|
35
|
+
};
|
|
36
|
+
};
|
|
29
37
|
protected constructor(itemEntryService: ItemEntryService);
|
|
38
|
+
/**
|
|
39
|
+
* @description
|
|
40
|
+
* Adds a hint for the {@link CollectionMatcherBase CollectionMatcherBase] to the ChangesDelta, when the CollectionMatcher encounters a collection
|
|
41
|
+
* with the exact query, it will use the hint instead of running the matcher
|
|
42
|
+
*
|
|
43
|
+
* @private
|
|
44
|
+
*/
|
|
45
|
+
_setQueryResult(itemType: ItemType, queryString: string, itemIds: ItemId[]): void;
|
|
30
46
|
setItemUpdated<ItemEntryType extends ItemEntry>(entry: ItemEntryType, fields: FieldMap<ItemEntryType['itemType']>, columnExpansionResult?: ColumnExpansionResult<ItemEntryType['itemType']> | null, parent?: EntryParentNull): void;
|
|
31
47
|
setItemDeleted(deleted: ItemEntry): void;
|
|
32
48
|
setItemsDeleted(deleted: ItemEntry[]): void;
|
|
@@ -29,6 +29,7 @@ export declare class CollectionCache {
|
|
|
29
29
|
*/
|
|
30
30
|
getByFittingItem<ItemTypeType extends ItemType>(itemType: ItemTypeType, fields: FieldMap, parent: EntryParentNull): CollectionMatchResult<ItemTypeType>;
|
|
31
31
|
getByQuery<ItemTypeType extends ItemType>(itemType: ItemTypeType, query: CollectionQuery): CollectionEntry<ItemTypeType> | null;
|
|
32
|
+
getByQueryString<ItemTypeType extends ItemType>(itemType: ItemTypeType, queryString: string): CollectionEntry<ItemTypeType> | null;
|
|
32
33
|
getByKey<ItemTypeType extends ItemType>(itemType: ItemTypeType, entryKey: string): Array<CollectionEntry<ItemTypeType>>;
|
|
33
34
|
/**
|
|
34
35
|
* @deprecated
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RequestColumnExpansionFactory } from '../factories';
|
|
1
|
+
import { ChangesDeltaFactory, RequestColumnExpansionFactory } from '../factories';
|
|
2
2
|
import { PromiseLibraryInterface } from '../interfaces';
|
|
3
3
|
import { ApiRequestColumns, ItemId, ItemType, PromiseInterface } from '../types';
|
|
4
4
|
import { ApiRequestService } from './ApiRequestService';
|
|
@@ -9,17 +9,20 @@ export declare class RequestBuffer {
|
|
|
9
9
|
private promiseLibrary;
|
|
10
10
|
private apiRequestService;
|
|
11
11
|
private requestColumnExpansionFactory;
|
|
12
|
+
private changesDeltaFactory;
|
|
12
13
|
private serverCache;
|
|
13
14
|
private itemType;
|
|
14
15
|
private deferred;
|
|
15
16
|
private requestColumnExpansion;
|
|
16
17
|
private singleItemIds;
|
|
17
18
|
private queries;
|
|
18
|
-
constructor(promiseLibrary: PromiseLibraryInterface, apiRequestService: ApiRequestService, requestColumnExpansionFactory: RequestColumnExpansionFactory, serverCache: ServerCache, itemType: ItemType);
|
|
19
|
+
constructor(promiseLibrary: PromiseLibraryInterface, apiRequestService: ApiRequestService, requestColumnExpansionFactory: RequestColumnExpansionFactory, changesDeltaFactory: ChangesDeltaFactory, serverCache: ServerCache, itemType: ItemType);
|
|
19
20
|
containsId(itemId: ItemId): boolean;
|
|
20
21
|
containsQuery(queryString: string): boolean;
|
|
21
22
|
addSingleItem(itemId: ItemId, requestColumns: ApiRequestColumns): PromiseInterface<RequestBufferResponse>;
|
|
22
23
|
addQuery(query: [object, string], requestColumns: ApiRequestColumns): PromiseInterface<RequestBufferResponse>;
|
|
23
24
|
flush(): PromiseInterface<RequestBufferResponse>;
|
|
24
25
|
getPromise(): PromiseInterface<RequestBufferResponse>;
|
|
26
|
+
private hasMultipleQueries;
|
|
27
|
+
private getFirstQueryString;
|
|
25
28
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RequestColumnExpansionFactory } from '../factories';
|
|
1
|
+
import { ChangesDeltaFactory, RequestColumnExpansionFactory } from '../factories';
|
|
2
2
|
import { ErrorHandlerInterface, PromiseLibraryInterface } from '../interfaces';
|
|
3
3
|
import { ApiRequestColumns, ItemId, ItemType, PromiseInterface } from '../types';
|
|
4
4
|
import { ApiRequestService } from './ApiRequestService';
|
|
@@ -12,12 +12,13 @@ export declare class RequestBufferManager {
|
|
|
12
12
|
private requestColumnExpansionFactory;
|
|
13
13
|
private keyService;
|
|
14
14
|
private errorHandler;
|
|
15
|
+
private changesDeltaFactory;
|
|
15
16
|
private pendingBufferMap;
|
|
16
17
|
private pendingTrueBufferMap;
|
|
17
18
|
private pendingQueryBufferMap;
|
|
18
19
|
private pendingTemplateBufferMap;
|
|
19
20
|
private serverCache;
|
|
20
|
-
constructor(promiseLibrary: PromiseLibraryInterface, apiRequestService: ApiRequestService, requestColumnExpansionFactory: RequestColumnExpansionFactory, keyService: KeyService, errorHandler: ErrorHandlerInterface);
|
|
21
|
+
constructor(promiseLibrary: PromiseLibraryInterface, apiRequestService: ApiRequestService, requestColumnExpansionFactory: RequestColumnExpansionFactory, keyService: KeyService, errorHandler: ErrorHandlerInterface, changesDeltaFactory: ChangesDeltaFactory);
|
|
21
22
|
setServerCache(serverCache: ServerCache): void;
|
|
22
23
|
containsId(itemType: ItemType, itemId: ItemId): boolean;
|
|
23
24
|
containsQuery(itemType: ItemType, queryString: string): boolean;
|
|
@@ -70,6 +70,12 @@ export declare abstract class AbstractCache {
|
|
|
70
70
|
protected constructor(core: RmCore, columnCache: ColumnCache, requestBufferManager: RequestBufferManager, requestColumnExpansionFactory: RequestColumnExpansionFactory, queryMatcherFactory: QueryMatcherFactory, authInterface: AuthInterface, changesDeltaFactory: ChangesDeltaFactory, lockService: LockService, moduleChangesCompilationFactory: ModuleChangesCompilationFactory, collectionResourceFactory: CollectionResourceFactory, itemResourceFactory: ItemResourceFactory, templateCache: TemplateCache, itemCacheFactory: ItemCacheFactory, collectionCacheFactory: CollectionCacheFactory, errorHandler: ErrorHandlerInterface, exceptionHandler: ExceptionHandlerInterface, promiseService: PromiseLibraryInterface, apiRequestService: ApiRequestService, columnExpansionFactory: ColumnExpansionFactory, columnHandler: ColumnHandler, columnSetFactory: ColumnSetFactory, columnSubsetCacheFactory: ColumnSubsetCacheFactory, columnUtil: ColumnUtil, itemEntryFactory: ItemEntryFactory, itemEntryService: ItemEntryService, keyService: KeyService, collectionEntryFactory: CollectionEntryFactory, collectionEntryService: CollectionEntryService, collectionMatcherFactory: CollectionMatcherFactory, queryParserFactory: QueryParserFactory, queryService: QueryService, apiFormatter: ApiFormatter, linkTreeService: LinkTreeServiceInterface);
|
|
71
71
|
createChild(id?: string): TransactionCache;
|
|
72
72
|
onChildDestroy(cache: TransactionCache): void;
|
|
73
|
+
abstract getLocalCollectionEntryByQueryString(itemType: ItemType, queryString: string): CollectionEntry | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* @description
|
|
76
|
+
* Returns {@link ItemEntry ItemEntries} that fit the collection's query, copies over the collectionChanges on all transactions in the chain.
|
|
77
|
+
*/
|
|
78
|
+
abstract getCollectionChangesRecursively(collectionEntryId: CollectionEntry['id']): ItemEntry[];
|
|
73
79
|
/**
|
|
74
80
|
* @description
|
|
75
81
|
* Returns this transaction and all parents
|
|
@@ -13,9 +13,13 @@ export declare abstract class CollectionHandlerBase {
|
|
|
13
13
|
protected transaction: AbstractCache;
|
|
14
14
|
entries: CollectionCache;
|
|
15
15
|
collectionChanges: {
|
|
16
|
-
[
|
|
16
|
+
[itemType: string]: {
|
|
17
|
+
[queryString: string]: ItemEntry[];
|
|
18
|
+
};
|
|
17
19
|
};
|
|
18
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>>;
|
|
19
23
|
/**
|
|
20
24
|
* @description
|
|
21
25
|
* Creates a new {@link CollectionEntry CollectionEntry} and stores it in this transaction's {@link CollectionCache CollectionCache}
|
|
@@ -41,7 +41,7 @@ export declare class ServerCache extends AbstractCache {
|
|
|
41
41
|
parent: null;
|
|
42
42
|
constructor(changesProcessorFactory: ChangesProcessorFactory, core: RmCore, columnCache: ColumnCache, requestBufferManager: RequestBufferManager, requestColumnExpansionFactory: RequestColumnExpansionFactory, queryMatcherFactory: QueryMatcherFactory, authInterface: AuthInterface, changesDeltaFactory: ChangesDeltaFactory, lockService: LockService, moduleChangesCompilationFactory: ModuleChangesCompilationFactory, collectionResourceFactory: CollectionResourceFactory, itemResourceFactory: ItemResourceFactory, templateCache: TemplateCache, itemCacheFactory: ItemCacheFactory, collectionCacheFactory: CollectionCacheFactory, errorHandler: ErrorHandlerInterface, exceptionHandler: ExceptionHandlerInterface, promiseService: PromiseLibraryInterface, apiFormatter: ApiFormatter, apiRequestService: ApiRequestService, columnExpansionFactory: ColumnExpansionFactory, columnHandler: ColumnHandler, columnSetFactory: ColumnSetFactory, columnSubsetCacheFactory: ColumnSubsetCacheFactory, columnUtil: ColumnUtil, itemEntryFactory: ItemEntryFactory, itemEntryService: ItemEntryService, keyService: KeyService, collectionEntryFactory: CollectionEntryFactory, collectionEntryService: CollectionEntryService, collectionMatcherFactory: CollectionMatcherFactory, queryParserFactory: QueryParserFactory, queryService: QueryService, linkTreeService: LinkTreeServiceInterface);
|
|
43
43
|
getServerCache(): ServerCache;
|
|
44
|
-
processResponse(response: ApiResponseProcessor, requestColumnMap: ApiRequestColumnMap, isCalledAfterApiSave?: boolean, isCalledAfterSocketUpdate?: boolean): PromiseInterface<ChangesDeltaResult>;
|
|
44
|
+
processResponse(response: ApiResponseProcessor, requestColumnMap: ApiRequestColumnMap, isCalledAfterApiSave?: boolean, isCalledAfterSocketUpdate?: boolean, changesDelta?: ChangesDelta): PromiseInterface<ChangesDeltaResult>;
|
|
45
45
|
/**
|
|
46
46
|
* @description
|
|
47
47
|
* Applies the changes of the changesDelta created by the API call ({@link ChangesProcessor ChangesProcessor}/{@link SocketMessageHandler SocketMessageHandler}, or manually through a module function) on all caches
|
|
@@ -93,6 +93,7 @@ export declare class ServerCache extends AbstractCache {
|
|
|
93
93
|
applyChangesDelta(changesDelta: ChangesDelta, isCalledAfterApiSave?: boolean, isCalledAfterSocketUpdate?: boolean): PromiseInterface<ChangesDeltaResult>;
|
|
94
94
|
getLocalItemEntry(itemEntryId: ItemEntry['id']): ItemEntry | undefined;
|
|
95
95
|
getLocalItemEntryByItemId(itemType: ItemType, itemId: ItemEntry['itemId']): ItemEntry | undefined;
|
|
96
|
+
getLocalCollectionEntryByQueryString(itemType: ItemType, queryString: string): CollectionEntry | undefined;
|
|
96
97
|
getLocalCollectionEntry(collectionEntryId: CollectionEntry['id']): CollectionEntry | undefined;
|
|
97
98
|
getChangesFromItemChanges<ItemTypeType extends ItemType = any>(changesObject: ServerItemEntryChanges<ItemTypeType>): FieldMap<ItemTypeType>;
|
|
98
99
|
}
|
|
@@ -23,7 +23,7 @@ export declare class ServerItemHandler extends ItemHandlerBase {
|
|
|
23
23
|
* @description
|
|
24
24
|
* Processes updates on a cached entry
|
|
25
25
|
*/
|
|
26
|
-
processItemEntryChanges<ItemTypeType extends ItemType = any>(itemEntryChangesTuple: ChangesDeltaItemUpdateDelta<ItemTypeType>, _forceOverwrite?: boolean, _updateInitial?: boolean, _isCalledAfterSocketUpdate?: boolean): FieldMap<ItemTypeType>;
|
|
26
|
+
processItemEntryChanges<ItemTypeType extends ItemType = any>(itemEntryChangesTuple: ChangesDeltaItemUpdateDelta<ItemTypeType>, _forceOverwrite?: boolean, _updateInitial?: boolean, _isCalledAfterSocketUpdate?: boolean, _createItemChangesIfNoneExist?: boolean): FieldMap<ItemTypeType>;
|
|
27
27
|
copyTransactionItemEntryChanges(itemEntryChanges: TransactionItemEntryChanges, entry: ItemEntry): ServerItemEntryChanges;
|
|
28
28
|
fetchItemEntry<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemId: ItemId, options: ItemEntryOptions): PromiseInterface<ItemEntry<ItemTypeType>>;
|
|
29
29
|
fetchItemEntriesByQuery<ItemTypeType extends ItemType>(itemType: ItemTypeType, query: ApiQuery, entryOptions: ItemEntryOptions): PromiseInterface<Array<ItemEntry<ItemTypeType>>>;
|
|
@@ -120,6 +120,7 @@ export declare class TransactionCache extends AbstractCache {
|
|
|
120
120
|
* Use {@link CollectionResource.getParent CollectionResource.getParent} instead of {@link TransactionCache.getParent TransactionCache.getParent} if you're getting the parent in the onRemove callback
|
|
121
121
|
*/
|
|
122
122
|
getParent<ItemTypeType extends ItemType>(itemEntry: ItemEntry<ItemTypeType>, fromInitial?: boolean, providedFields?: FieldMap<ItemTypeType>): EntryParentNull;
|
|
123
|
+
getCollectionChangesRecursively(collectionEntryId: CollectionEntry['id']): ItemEntry[];
|
|
123
124
|
/**
|
|
124
125
|
* @description
|
|
125
126
|
* Traverses the transaction chain and returns the changes of the item on the first transaction
|
|
@@ -351,6 +352,11 @@ export declare class TransactionCache extends AbstractCache {
|
|
|
351
352
|
* Gets an ItemEntry from the cache by ItemId
|
|
352
353
|
*/
|
|
353
354
|
getLocalItemEntryByItemId(itemType: ItemType, itemId: ItemEntry['itemId']): ItemEntry | undefined;
|
|
355
|
+
/**
|
|
356
|
+
* @description
|
|
357
|
+
* Gets an CollectionEntry from the cache, doesn't do a API request, used for saving
|
|
358
|
+
*/
|
|
359
|
+
getLocalCollectionEntryByQueryString(itemType: ItemType, queryString: string): CollectionEntry | undefined;
|
|
354
360
|
/**
|
|
355
361
|
* @description
|
|
356
362
|
* Gets an CollectionEntry from the cache, doesn't do a API request, used for saving
|
|
@@ -78,11 +78,12 @@ export declare class TransactionItemHandler extends ItemHandlerBase {
|
|
|
78
78
|
* @param forceOverwrite Instead of calling {@link ApiFormatter.mergeCopyFields mergeCopyFields}, {@link ApiFormatter.copyFields copyFields} will be used (because API values are always right)
|
|
79
79
|
* @param updateInitial Should be `true` if called by applyChangesFromParent
|
|
80
80
|
* @param isCalledAfterSocketUpdate Indicates that the change is done by a different user
|
|
81
|
+
* @param createItemChangesIfNoneExist Is `true` when called from `applyChangesDelta`, we can assume that when you call `applyChangesDelta` with updates that aren't on the transaction yet you want to add those
|
|
81
82
|
*
|
|
82
83
|
* @returns
|
|
83
84
|
* The previous changes {@link FieldMap FieldMap}
|
|
84
85
|
*/
|
|
85
|
-
processItemEntryChanges<ItemTypeType extends ItemType = any>(itemEntryChangesTuple: ChangesDeltaItemUpdateDelta<ItemTypeType>, forceOverwrite?: boolean, updateInitial?: boolean, isCalledAfterSocketUpdate?: boolean): FieldMap<ItemTypeType> | null;
|
|
86
|
+
processItemEntryChanges<ItemTypeType extends ItemType = any>(itemEntryChangesTuple: ChangesDeltaItemUpdateDelta<ItemTypeType>, forceOverwrite?: boolean, updateInitial?: boolean, isCalledAfterSocketUpdate?: boolean, createItemChangesIfNoneExist?: boolean): FieldMap<ItemTypeType> | null;
|
|
86
87
|
cloneItemEntries<ItemTypeType extends ItemType>(itemEntries: Array<ItemEntry<ItemTypeType>>, conversionMap?: ItemIdConversionMap, modifyFieldsCallback?: ModifyFieldsCallback): PromiseInterface<ChangesDeltaResult>;
|
|
87
88
|
cloneItemEntry<ItemTypeType extends ItemType>(changesDelta: ChangesDelta, sourceEntry: ItemEntry<ItemTypeType>, newFields?: FieldMap<ItemTypeType>, conversionMap?: ItemIdConversionMap, modifyFieldsCallback?: ModifyFieldsCallback): ItemId;
|
|
88
89
|
fetchItemEntriesByQuery<ItemTypeType extends ItemType>(itemType: ItemTypeType, query: ApiQuery, entryOptions: ItemEntryOptions): PromiseInterface<Array<ItemEntry<ItemTypeType>>>;
|
|
@@ -7,7 +7,7 @@ export declare abstract class CollectionResource<ItemTypeType extends ItemType =
|
|
|
7
7
|
entry: CollectionEntry<ItemTypeType>;
|
|
8
8
|
options: CollectionResourceOptions<ItemTypeType>;
|
|
9
9
|
transaction: TransactionCache;
|
|
10
|
-
items: T[]
|
|
10
|
+
items: Readonly<T[]>;
|
|
11
11
|
columns: ResponseColumnItemTypeMap;
|
|
12
12
|
protected itemIdMap: ItemResourceItemIdMap<T>;
|
|
13
13
|
private readonly onChange;
|