@rentman/rm-core 8.0.3 → 8.1.1
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 +11 -0
- package/dist/rm-core.js +3127 -2789
- package/dist/rm-core.min.js +2 -2
- package/dist/types/classes/ApiFormatter.d.ts +3 -3
- package/dist/types/classes/ChangesDelta.d.ts +7 -1
- package/dist/types/classes/ChangesDeltaBase.d.ts +35 -7
- package/dist/types/classes/CollectionMatcherBase.d.ts +2 -2
- package/dist/types/classes/ConversionMapService.d.ts +1 -1
- package/dist/types/classes/InternalChangesDelta.d.ts +12 -1
- package/dist/types/classes/ParentChangesDelta.d.ts +47 -0
- package/dist/types/classes/TemplateCache.d.ts +11 -8
- package/dist/types/classes/cache/AbstractCache.d.ts +16 -7
- package/dist/types/classes/cache/ItemHandlerBase.d.ts +3 -6
- package/dist/types/classes/cache/server/ServerCache.d.ts +19 -8
- package/dist/types/classes/cache/server/ServerItemHandler.d.ts +2 -2
- package/dist/types/classes/cache/transaction/TransactionCache.d.ts +13 -12
- package/dist/types/classes/cache/transaction/TransactionItemHandler.d.ts +4 -6
- package/dist/types/factories/ChangesDeltaFactory.d.ts +8 -6
- package/dist/types/factories/RequestColumnExpansionFactory.d.ts +4 -1
- package/dist/types/factories/TemplateFactory.d.ts +2 -2
- package/dist/types/models/Template.d.ts +3 -2
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ApiEnumApiType,
|
|
1
|
+
import { ApiEnumApiType, ApiEnumItemType, ApiFields, ResponseColumn } from '@rentman/backend-types';
|
|
2
2
|
import moment from 'moment';
|
|
3
3
|
import { ColumnInfo } from '../classes';
|
|
4
|
-
import { FieldMap } from '../types';
|
|
4
|
+
import { ApiEnumApiTypeToTsTypeMap, FieldMap } from '../types';
|
|
5
5
|
declare type GetChangesResult<ItemTypeType extends ApiEnumItemType = any, ColumnId extends keyof ApiFields[ItemTypeType] = any> = {
|
|
6
6
|
oldValue: FieldMap<ItemTypeType, [ColumnId]>[ColumnId];
|
|
7
7
|
newValue: FieldMap<ItemTypeType, [ColumnId]>[ColumnId];
|
|
@@ -42,7 +42,7 @@ export declare class ApiFormatter {
|
|
|
42
42
|
* @description
|
|
43
43
|
* Compares the given fields, returns `true` when the fields are equal
|
|
44
44
|
*/
|
|
45
|
-
compareFields<ColumnType extends ApiEnumApiType>(columnType: ColumnType, first?:
|
|
45
|
+
compareFields<ColumnType extends ApiEnumApiType>(columnType: ColumnType, first?: ApiEnumApiTypeToTsTypeMap[ColumnType], second?: ApiEnumApiTypeToTsTypeMap[ColumnType]): boolean;
|
|
46
46
|
compareFloats(a: number, b: number): boolean;
|
|
47
47
|
compareMomentObjects(first: moment.Moment, second: moment.Moment): boolean;
|
|
48
48
|
compareDurations(first: moment.Duration, second: moment.Duration): boolean;
|
|
@@ -7,6 +7,7 @@ import { ColumnSet } from './ColumnSet';
|
|
|
7
7
|
import { CreatedChangesDelta } from './CreatedChangesDelta';
|
|
8
8
|
import { ItemCreateService } from './ItemCreateService';
|
|
9
9
|
import { ItemEntryService } from './ItemEntryService';
|
|
10
|
+
export declare type ChangesDeltaItemDeleteDelta = ItemEntry;
|
|
10
11
|
/**
|
|
11
12
|
* @description
|
|
12
13
|
* ChangesDelta used to apply changes from outside of the core to a transaction
|
|
@@ -22,6 +23,9 @@ export declare class ChangesDelta extends ChangesDeltaBase {
|
|
|
22
23
|
private errorHandler;
|
|
23
24
|
private itemCreateService;
|
|
24
25
|
created: CreatedChangesDelta;
|
|
26
|
+
deleted: {
|
|
27
|
+
[itemType: string]: ChangesDeltaItemDeleteDelta[];
|
|
28
|
+
};
|
|
25
29
|
constructor(errorHandler: ErrorHandlerInterface, itemCreateService: ItemCreateService, itemEntryService: ItemEntryService);
|
|
26
30
|
/**
|
|
27
31
|
* @description
|
|
@@ -32,6 +36,8 @@ export declare class ChangesDelta extends ChangesDeltaBase {
|
|
|
32
36
|
* - If you want to set a parent set the proper field, you can't pass it as a separate object
|
|
33
37
|
*/
|
|
34
38
|
setItemCreated<ItemTypeType extends ApiEnumItemType, Fields extends Partial<FieldMap<ItemTypeType>>>(itemType: ItemTypeType, values: Fields): PromiseInterface<this>;
|
|
39
|
+
setItemDeleted(deleted: ChangesDeltaItemDeleteDelta): this;
|
|
40
|
+
setItemsDeleted(deleted: ChangesDeltaItemDeleteDelta[]): this;
|
|
35
41
|
/**
|
|
36
42
|
* @description
|
|
37
43
|
* Fetches a template for the passed itemType and processes the passed values and sets the items to be created when the delta is applied
|
|
@@ -57,6 +63,6 @@ export declare class ChangesDelta extends ChangesDeltaBase {
|
|
|
57
63
|
* @description
|
|
58
64
|
* Convenience function to assign the proper parent fields, will call {@link ChangesDeltaBase.setItemUpdated setItemUpdated} internally
|
|
59
65
|
*/
|
|
60
|
-
setItemMoved(entry: ItemEntry, to: EntryParent): this;
|
|
66
|
+
setItemMoved(entry: ItemEntry, to: EntryParent, updateModified?: boolean, updateInitial?: boolean): this;
|
|
61
67
|
isEmpty(): boolean;
|
|
62
68
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ApiEnumItemType, ItemId } from '@rentman/backend-types';
|
|
2
2
|
import { ItemEntry } from '../models';
|
|
3
3
|
import { ColumnExpansionResult, EntryParentNull, FieldMap, ItemIdConversionMap } from '../types';
|
|
4
|
+
import { TransactionItemEntryChanges } from './cache/transaction/TransactionItemHandler';
|
|
4
5
|
import { ItemEntryService } from './ItemEntryService';
|
|
5
6
|
export declare type ChangesDeltaResult = {
|
|
7
|
+
itemIdConversionMap: ItemIdConversionMap;
|
|
6
8
|
created: ItemEntry[];
|
|
7
9
|
};
|
|
8
10
|
/**
|
|
@@ -16,17 +18,44 @@ export declare type ChangesDeltaItemUpdateDelta<ItemTypeType extends ApiEnumItem
|
|
|
16
18
|
fields: FieldMap<ItemTypeType>;
|
|
17
19
|
parent: EntryParentNull;
|
|
18
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* @description
|
|
23
|
+
* Should be set to `true` when either the changes are made by the user, or when it's the direct result (not derived value) of a create/update API call
|
|
24
|
+
*/
|
|
25
|
+
updateModified: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* @description
|
|
28
|
+
* Should be set to `true` when the changes are a result of an API call
|
|
29
|
+
*/
|
|
30
|
+
updateInitial: boolean;
|
|
19
31
|
};
|
|
20
|
-
export declare type ChangesDeltaItemDeleteDelta = ItemEntry[];
|
|
21
32
|
export declare abstract class ChangesDeltaBase {
|
|
22
33
|
protected itemEntryService: ItemEntryService;
|
|
23
34
|
updated: {
|
|
24
35
|
[itemEntryId: number]: ChangesDeltaItemUpdateDelta;
|
|
25
36
|
};
|
|
26
|
-
deleted: {
|
|
27
|
-
[itemType: string]: ChangesDeltaItemDeleteDelta;
|
|
28
|
-
};
|
|
29
37
|
itemIdConversionMap: ItemIdConversionMap;
|
|
38
|
+
/**
|
|
39
|
+
* Only contains remote items, when rolling back local items the whole entries are deleted.
|
|
40
|
+
*/
|
|
41
|
+
restored: {
|
|
42
|
+
[itemEntryId: number]: {
|
|
43
|
+
entry: ItemEntry;
|
|
44
|
+
changes: TransactionItemEntryChanges;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* @private
|
|
49
|
+
* @warning
|
|
50
|
+
* Do not set in frontend
|
|
51
|
+
*/
|
|
52
|
+
__isUndo: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* @private
|
|
55
|
+
* @warning
|
|
56
|
+
* Do not set in frontend
|
|
57
|
+
*/
|
|
58
|
+
__isRedo: boolean;
|
|
30
59
|
/**
|
|
31
60
|
* @private
|
|
32
61
|
*/
|
|
@@ -44,8 +73,7 @@ export declare abstract class ChangesDeltaBase {
|
|
|
44
73
|
* @private
|
|
45
74
|
*/
|
|
46
75
|
_setQueryResult(itemType: ApiEnumItemType, queryString: string, itemIds: ItemId[]): void;
|
|
47
|
-
setItemUpdated<ItemTypeType extends ApiEnumItemType>(entry: ItemEntry<ItemTypeType>, fields: Partial<FieldMap<ItemTypeType>>, columnExpansionResult?: ColumnExpansionResult<ItemTypeType> | null, parent?: EntryParentNull): this;
|
|
48
|
-
|
|
49
|
-
setItemsDeleted(deleted: ItemEntry[]): this;
|
|
76
|
+
setItemUpdated<ItemTypeType extends ApiEnumItemType>(entry: ItemEntry<ItemTypeType>, fields: Partial<FieldMap<ItemTypeType>>, columnExpansionResult?: ColumnExpansionResult<ItemTypeType> | null, parent?: EntryParentNull, updateModified?: boolean, updateInitial?: boolean): this;
|
|
77
|
+
setItemRestored(itemEntry: ItemEntry, transactionItemEntryChanges: TransactionItemEntryChanges): void;
|
|
50
78
|
isEmpty(): boolean;
|
|
51
79
|
}
|
|
@@ -3,7 +3,7 @@ import { AbstractCache, CollectionQuery, FieldMap, QueryService } from '../';
|
|
|
3
3
|
import { QueryMatcherFactory } from '../factories/';
|
|
4
4
|
import { ItemEntry } from '../models';
|
|
5
5
|
import { GroupedCollectionMatcherResult } from './cache/CollectionMatcherCachedQueryProcessor';
|
|
6
|
-
import {
|
|
6
|
+
import { ParentChangesDelta } from './ParentChangesDelta';
|
|
7
7
|
export declare type CollectionMatcherMatches<ItemTypeType extends ApiEnumItemType = any> = {
|
|
8
8
|
[itemId: number]: {
|
|
9
9
|
item: ItemEntry<ItemTypeType>;
|
|
@@ -16,7 +16,7 @@ export declare abstract class CollectionMatcherBase {
|
|
|
16
16
|
protected transaction: AbstractCache;
|
|
17
17
|
protected constructor(queryService: QueryService, queryMatcherFactory: QueryMatcherFactory, transaction: AbstractCache);
|
|
18
18
|
expand<ItemEntryType extends ItemEntry>(itemEntry: ItemEntryType, fields: FieldMap<ItemEntryType['itemType']>): this;
|
|
19
|
-
processDelta(
|
|
19
|
+
processDelta(parentChangesDelta: ParentChangesDelta): this;
|
|
20
20
|
protected groupItemEntries<ItemTypeType extends ApiEnumItemType>(matches: CollectionMatcherMatches<ItemTypeType>): GroupedCollectionMatcherResult<ItemTypeType>;
|
|
21
21
|
protected abstract _expand<ItemTypeType extends ApiEnumItemType = any>(itemEntry: ItemEntry<ItemTypeType>, matchFunction: (itemType: ItemTypeType, parsedQuery: CollectionQuery) => boolean | 'maybe'): this;
|
|
22
22
|
}
|
|
@@ -15,7 +15,7 @@ export declare class ConversionMapService {
|
|
|
15
15
|
constructor(keyService: KeyService);
|
|
16
16
|
createLocalConversionMap(itemType: ApiEnumItemType, itemId: ItemId, doExtend: boolean | undefined, apiResponse: ApiResponse): ItemIdConversionMap;
|
|
17
17
|
expandLocalConversionMap(parentType: ApiEnumItemType, parentId: ItemId, apiResponse: ApiResponse, conversionMap: ItemIdConversionMap): void;
|
|
18
|
-
expandConversionMap(
|
|
18
|
+
expandConversionMap(itemType: ApiEnumItemType, itemId: ItemId, conversionMap: ItemIdConversionMap, newItemId?: ItemId): ItemId;
|
|
19
19
|
batchExpandConversionMap(itemEntries: Array<ItemEntry<any>>, conversionMap: ItemIdConversionMap): ItemIdConversionMap;
|
|
20
20
|
getConversionValue(itemType: ApiEnumItemType, itemId: ItemId, map: ItemIdConversionMap): ItemId | undefined;
|
|
21
21
|
/**
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { ApiEnumItemType } from '@rentman/backend-types';
|
|
2
2
|
import { ItemEntry } from '../models';
|
|
3
3
|
import { EntryParent, FieldMap, ItemIdConversionMap } from '../types';
|
|
4
|
+
import { TransactionItemEntryChanges } from './cache/transaction/TransactionItemHandler';
|
|
4
5
|
import { ChangesDeltaBase } from './ChangesDeltaBase';
|
|
5
6
|
import { ItemEntryService } from './ItemEntryService';
|
|
6
7
|
export declare type InternalCreateDelta<ItemTypeType extends ApiEnumItemType = any> = {
|
|
7
8
|
entry: ItemEntry<ItemTypeType>;
|
|
8
9
|
fields: FieldMap<ItemTypeType>;
|
|
9
10
|
};
|
|
11
|
+
export declare type InternalChangesDeltaItemDeleteDelta = {
|
|
12
|
+
entry: ItemEntry;
|
|
13
|
+
changes: TransactionItemEntryChanges;
|
|
14
|
+
};
|
|
10
15
|
/**
|
|
11
16
|
* @description
|
|
12
17
|
* ChangesDelta used internally by the core
|
|
@@ -16,12 +21,15 @@ export declare type InternalCreateDelta<ItemTypeType extends ApiEnumItemType = a
|
|
|
16
21
|
* The difference between {@link InternalChangesDelta InternalChangesDelta} and {@link ChangesDelta ChangesDelta} is that the InternalChangesDelta
|
|
17
22
|
* assumes 'created' entries are already existing, so it has a different format.
|
|
18
23
|
*
|
|
19
|
-
* Use this when calling {@link TransactionCache.
|
|
24
|
+
* Use this when calling {@link TransactionCache.applyChangesFromChild applyChangesFromChild}
|
|
20
25
|
*/
|
|
21
26
|
export declare class InternalChangesDelta extends ChangesDeltaBase {
|
|
22
27
|
created: {
|
|
23
28
|
[itemEntryId: string]: InternalCreateDelta;
|
|
24
29
|
};
|
|
30
|
+
deleted: {
|
|
31
|
+
[itemType: string]: InternalChangesDeltaItemDeleteDelta[];
|
|
32
|
+
};
|
|
25
33
|
moved: {
|
|
26
34
|
[itemEntryId: number]: {
|
|
27
35
|
entry: ItemEntry;
|
|
@@ -30,6 +38,9 @@ export declare class InternalChangesDelta extends ChangesDeltaBase {
|
|
|
30
38
|
};
|
|
31
39
|
itemIdConversionMap: ItemIdConversionMap;
|
|
32
40
|
constructor(itemEntryService: ItemEntryService);
|
|
41
|
+
setItemDeleted(tuple: InternalChangesDeltaItemDeleteDelta): this;
|
|
42
|
+
setItemsDeleted(deleted: InternalChangesDeltaItemDeleteDelta[]): this;
|
|
43
|
+
private itemIsDeleted;
|
|
33
44
|
setItemCreated<ItemTypeType extends ApiEnumItemType>(itemEntry: ItemEntry<ItemTypeType>, fields: FieldMap<ItemTypeType>): void;
|
|
34
45
|
/**
|
|
35
46
|
* @remark
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ApiEnumItemType } from '@rentman/backend-types';
|
|
2
|
+
import { ItemEntry } from '../models';
|
|
3
|
+
import { EntryParent, FieldMap, ItemIdConversionMap } from '../types';
|
|
4
|
+
import { ChangesDeltaItemDeleteDelta } from './ChangesDelta';
|
|
5
|
+
import { ChangesDeltaBase } from './ChangesDeltaBase';
|
|
6
|
+
import { ItemEntryService } from './ItemEntryService';
|
|
7
|
+
export declare type InternalCreateDelta<ItemTypeType extends ApiEnumItemType = any> = {
|
|
8
|
+
entry: ItemEntry<ItemTypeType>;
|
|
9
|
+
fields: FieldMap<ItemTypeType>;
|
|
10
|
+
};
|
|
11
|
+
export declare type ParentChangesDeltaItemDeleteDelta = ItemEntry;
|
|
12
|
+
/**
|
|
13
|
+
* @description
|
|
14
|
+
* ChangesDelta used internally by the core
|
|
15
|
+
*
|
|
16
|
+
* ----------
|
|
17
|
+
*
|
|
18
|
+
* The difference between {@link ParentChangesDelta ParentChangesDelta} and {@link ChangesDelta ChangesDelta} is that the ParentChangesDelta
|
|
19
|
+
* assumes 'created' entries are already existing, and deletedEntries don't have changes (since you cannot undo an action that happened on a parent on a child transaction)
|
|
20
|
+
*
|
|
21
|
+
* Use this when calling {@link TransactionCache.applyChangesFromParent applyChangesFromParent}
|
|
22
|
+
*/
|
|
23
|
+
export declare class ParentChangesDelta extends ChangesDeltaBase {
|
|
24
|
+
created: {
|
|
25
|
+
[itemEntryId: string]: InternalCreateDelta;
|
|
26
|
+
};
|
|
27
|
+
deleted: {
|
|
28
|
+
[itemType: string]: ParentChangesDeltaItemDeleteDelta[];
|
|
29
|
+
};
|
|
30
|
+
moved: {
|
|
31
|
+
[itemEntryId: number]: {
|
|
32
|
+
entry: ItemEntry;
|
|
33
|
+
to: EntryParent;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
itemIdConversionMap: ItemIdConversionMap;
|
|
37
|
+
constructor(itemEntryService: ItemEntryService);
|
|
38
|
+
setItemDeleted(deleted: ChangesDeltaItemDeleteDelta): this;
|
|
39
|
+
setItemsDeleted(deleted: ChangesDeltaItemDeleteDelta[]): this;
|
|
40
|
+
setItemCreated<ItemTypeType extends ApiEnumItemType>(itemEntry: ItemEntry<ItemTypeType>, fields: FieldMap<ItemTypeType>): void;
|
|
41
|
+
/**
|
|
42
|
+
* @remark
|
|
43
|
+
* Parent fields are non-writable so we need to keep track of moved entries another way (to do a linkTo request)
|
|
44
|
+
*/
|
|
45
|
+
setItemMoved(entry: ItemEntry, to: EntryParent): void;
|
|
46
|
+
isEmpty(): boolean;
|
|
47
|
+
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { ApiEnumItemType, ApiFields, ItemId } from '@rentman/backend-types';
|
|
2
|
+
import { RmCore } from '../core';
|
|
2
3
|
import { RequestColumnExpansionFactory, TemplateFactory } from '../factories';
|
|
3
4
|
import { ErrorHandlerInterface, PromiseLibraryInterface } from '../interfaces';
|
|
4
5
|
import { Template } from '../models';
|
|
5
|
-
import { EntryParentNull, PromiseInterface } from '../types';
|
|
6
|
+
import { ApiResponse, EntryParentNull, PromiseInterface } from '../types';
|
|
6
7
|
import { ApiRequestService } from './ApiRequestService';
|
|
7
8
|
import { ColumnHandler } from './ColumnHandler';
|
|
8
9
|
import { ColumnUtil } from './ColumnUtil';
|
|
9
10
|
export declare class TemplateCache {
|
|
11
|
+
private core;
|
|
10
12
|
private columnUtil;
|
|
11
13
|
private promiseService;
|
|
12
14
|
private columnHandler;
|
|
@@ -15,19 +17,20 @@ export declare class TemplateCache {
|
|
|
15
17
|
private requestColumnExpansionFactory;
|
|
16
18
|
private apiRequestService;
|
|
17
19
|
private pendingTemplateBufferMap;
|
|
18
|
-
|
|
19
|
-
[itemType: string]:
|
|
20
|
+
templateResponses: {
|
|
21
|
+
[itemType: string]: ApiResponse;
|
|
20
22
|
};
|
|
21
|
-
constructor(columnUtil: ColumnUtil, promiseService: PromiseLibraryInterface, columnHandler: ColumnHandler, templateFactory: TemplateFactory, errorHandler: ErrorHandlerInterface, requestColumnExpansionFactory: RequestColumnExpansionFactory, apiRequestService: ApiRequestService);
|
|
23
|
+
constructor(core: RmCore, columnUtil: ColumnUtil, promiseService: PromiseLibraryInterface, columnHandler: ColumnHandler, templateFactory: TemplateFactory, errorHandler: ErrorHandlerInterface, requestColumnExpansionFactory: RequestColumnExpansionFactory, apiRequestService: ApiRequestService);
|
|
22
24
|
/**
|
|
23
25
|
* @description
|
|
24
|
-
* Fetches a {@link Template template}, {@link
|
|
26
|
+
* Fetches a {@link Template template}, use {@link ItemCreateService.createItemsFromValues createItemsFromValues} to easily create new items from a set of values.
|
|
27
|
+
* The best way to process the template's values is to call {@link ItemCreateService.processTemplate processTemplate}
|
|
25
28
|
*
|
|
26
29
|
* @param itemType The {@link ApiEnumItemType ItemType} of the template item
|
|
27
30
|
* @param itemId Used for caching, multiple concurrent template calls for the same itemId will return the same template
|
|
28
31
|
* @param templateOptions
|
|
29
32
|
* @param templateColumns Additional columns to be fetched, will be stored in the template - warning - the Template won't have values for those columns
|
|
30
|
-
* @param entryParentOrParentItemType An optional {@link EntryParentNull entry parent} or {@link
|
|
33
|
+
* @param entryParentOrParentItemType An optional {@link EntryParentNull entry parent} or {@link ApiEnumItemType parent itemType}, if the parent is passed the templateColumns will be expanded with the proper link columns (Through {@link ColumnUtil.getColumnsFromLink ColumnUtil.getColumnsFromLink})
|
|
31
34
|
*
|
|
32
35
|
* @example
|
|
33
36
|
* ```
|
|
@@ -51,13 +54,13 @@ export declare class TemplateCache {
|
|
|
51
54
|
* for (const itemResource of selectedItems) {
|
|
52
55
|
* changesDelta.setItemCreated(
|
|
53
56
|
* core.keyService.getLocalId(),
|
|
54
|
-
* template.
|
|
57
|
+
* template.getFields(),
|
|
55
58
|
* template.columns,
|
|
56
59
|
* parent,
|
|
57
60
|
* );
|
|
58
61
|
* }
|
|
59
62
|
*
|
|
60
|
-
* transaction.applyChangesDelta(changesDelta);
|
|
63
|
+
* return transaction.applyChangesDelta(changesDelta);
|
|
61
64
|
* );
|
|
62
65
|
* ```
|
|
63
66
|
*/
|
|
@@ -4,10 +4,11 @@ import { AbstractCacheDependencyInterface } from '../../interfaces';
|
|
|
4
4
|
import { ItemEntry } from '../../models';
|
|
5
5
|
import { ApiRequestColumn, CollectionQuery, CollectionResourceParentIdMap, EntryParentNull, FieldMap, ItemIdConversionMap, PromiseInterface } from '../../types';
|
|
6
6
|
import { ChangesDelta } from '../ChangesDelta';
|
|
7
|
-
import { ChangesDeltaResult } from '../ChangesDeltaBase';
|
|
7
|
+
import { ChangesDeltaBase, ChangesDeltaResult } from '../ChangesDeltaBase';
|
|
8
8
|
import { OnAfterCreateCallback } from '../ChangesProcessor';
|
|
9
9
|
import { InternalChangesDelta } from '../InternalChangesDelta';
|
|
10
10
|
import { ItemCache } from '../ItemCache';
|
|
11
|
+
import { ParentChangesDelta } from '../ParentChangesDelta';
|
|
11
12
|
import { CachedQueryItem } from './CachedQueryHandlerBase';
|
|
12
13
|
import { ItemHandlerBase } from './ItemHandlerBase';
|
|
13
14
|
import { ServerCache } from './server/ServerCache';
|
|
@@ -17,6 +18,13 @@ import { TransactionCache } from './transaction/TransactionCache';
|
|
|
17
18
|
import { TransactionCachedQueryHandler } from './transaction/TransactionCachedQueryHandler';
|
|
18
19
|
import { TransactionItemEntryChanges } from './transaction/TransactionItemHandler';
|
|
19
20
|
import { TransactionValidatorFactory } from './transaction/TransactionValidator';
|
|
21
|
+
export declare type TransactionOptions = {
|
|
22
|
+
/**
|
|
23
|
+
* @description
|
|
24
|
+
* Sets the TransactionCache to 'transparent' mode, whenever {@link AbstractCache.createChild createChild} is called it will actually be called on the parent
|
|
25
|
+
*/
|
|
26
|
+
transparent: boolean;
|
|
27
|
+
};
|
|
20
28
|
export declare abstract class AbstractCache {
|
|
21
29
|
dependencies: AbstractCacheDependencyInterface;
|
|
22
30
|
core: RmCore;
|
|
@@ -25,7 +33,7 @@ export declare abstract class AbstractCache {
|
|
|
25
33
|
readonly cachedQueryHandler: TransactionCachedQueryHandler | ServerCachedQueryHandler;
|
|
26
34
|
parent: AbstractCache | null;
|
|
27
35
|
protected constructor(dependencies: AbstractCacheDependencyInterface, core: RmCore);
|
|
28
|
-
abstract createChild(id?: string, validatorFactory?: TransactionValidatorFactory): TransactionCache;
|
|
36
|
+
abstract createChild(id?: string, validatorFactory?: TransactionValidatorFactory, options?: TransactionOptions): TransactionCache;
|
|
29
37
|
onChildDestroy(cache: TransactionCache): void;
|
|
30
38
|
/**
|
|
31
39
|
* @description
|
|
@@ -68,7 +76,7 @@ export declare abstract class AbstractCache {
|
|
|
68
76
|
*
|
|
69
77
|
* @internal
|
|
70
78
|
*/
|
|
71
|
-
abstract applyChangesFromParent(
|
|
79
|
+
abstract applyChangesFromParent(parentChangesDelta: ParentChangesDelta, isCalledAfterSocketUpdate: boolean): void;
|
|
72
80
|
abstract getParent<ItemTypeType extends ApiEnumItemType = any>(itemEntry: ItemEntry<ItemTypeType>, fromInitial?: boolean, providedFields?: FieldMap<ItemTypeType>): EntryParentNull;
|
|
73
81
|
abstract getItemChangesRecursively(itemEntryId: ItemEntry['id'], copyFields?: boolean): FieldMap;
|
|
74
82
|
abstract getLocalItemEntryChangesTuple(itemEntryId: ItemEntry['id']): any;
|
|
@@ -90,14 +98,15 @@ export declare abstract class AbstractCache {
|
|
|
90
98
|
*
|
|
91
99
|
* @private
|
|
92
100
|
*/
|
|
93
|
-
protected _applyChangesDelta(changesDelta: ChangesDelta): {
|
|
101
|
+
protected _applyChangesDelta(changesDelta: ChangesDelta | InternalChangesDelta): {
|
|
94
102
|
result: ChangesDeltaResult;
|
|
95
|
-
|
|
96
|
-
matchingDelta:
|
|
103
|
+
parentChangesDelta: ParentChangesDelta;
|
|
104
|
+
matchingDelta: ParentChangesDelta;
|
|
105
|
+
undoFunctions: Array<(changesDelta: InternalChangesDelta) => void>;
|
|
97
106
|
};
|
|
98
107
|
/**
|
|
99
108
|
* @description
|
|
100
109
|
* Ensures that for all updated items in the delta the required derived values are present
|
|
101
110
|
*/
|
|
102
|
-
protected fetchUpdatedDerivedValuesFromDelta(changesDelta:
|
|
111
|
+
protected fetchUpdatedDerivedValuesFromDelta(changesDelta: ChangesDeltaBase): PromiseInterface<void>;
|
|
103
112
|
}
|
|
@@ -2,16 +2,14 @@ import { ApiEnumItemType, ItemId } from '@rentman/backend-types';
|
|
|
2
2
|
import { ItemCacheFactory, ItemEntryFactory, RequestColumnExpansionFactory } from '../../factories';
|
|
3
3
|
import { ErrorHandlerInterface, PromiseLibraryInterface } from '../../interfaces';
|
|
4
4
|
import { ItemEntry, ItemEntryOptions } from '../../models';
|
|
5
|
-
import { ApiQuery,
|
|
5
|
+
import { ApiQuery, FieldMap, PromiseInterface } from '../../types';
|
|
6
6
|
import { ApiFormatter } from '../ApiFormatter';
|
|
7
7
|
import { ChangesDeltaBase, ChangesDeltaItemUpdateDelta } from '../ChangesDeltaBase';
|
|
8
8
|
import { ColumnInfo } from '../ColumnInfo';
|
|
9
9
|
import { ColumnUtil } from '../ColumnUtil';
|
|
10
10
|
import { ChangesDeltaItemCreateDelta } from '../CreatedChangesDelta';
|
|
11
|
-
import { InternalChangesDelta } from '../InternalChangesDelta';
|
|
12
11
|
import { ItemCache } from '../ItemCache';
|
|
13
12
|
import { AbstractCache } from './AbstractCache';
|
|
14
|
-
import { ServerItemEntryChanges } from './server/ServerItemHandler';
|
|
15
13
|
import { TransactionItemEntryChanges } from './transaction/TransactionItemHandler';
|
|
16
14
|
export declare enum ItemCacheStatus {
|
|
17
15
|
CACHED = "cached",
|
|
@@ -35,7 +33,7 @@ export declare abstract class ItemHandlerBase {
|
|
|
35
33
|
protected transaction: AbstractCache;
|
|
36
34
|
readonly entries: ItemCache;
|
|
37
35
|
abstract itemChanges: {
|
|
38
|
-
[itemEntryId: string]:
|
|
36
|
+
[itemEntryId: string]: any;
|
|
39
37
|
};
|
|
40
38
|
protected constructor(columnUtil: ColumnUtil, apiFormatter: ApiFormatter, itemEntryFactory: ItemEntryFactory, promiseService: PromiseLibraryInterface, errorHandler: ErrorHandlerInterface, requestColumnExpansionFactory: RequestColumnExpansionFactory, itemCacheFactory: ItemCacheFactory, transaction: AbstractCache);
|
|
41
39
|
/**
|
|
@@ -64,7 +62,7 @@ export declare abstract class ItemHandlerBase {
|
|
|
64
62
|
* @description
|
|
65
63
|
* 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
|
|
66
64
|
*/
|
|
67
|
-
abstract processItemEntryChanges<ItemTypeType extends ApiEnumItemType>(itemEntryChangesTuple: ChangesDeltaItemUpdateDelta<ItemTypeType>,
|
|
65
|
+
abstract processItemEntryChanges<ItemTypeType extends ApiEnumItemType>(itemEntryChangesTuple: ChangesDeltaItemUpdateDelta<ItemTypeType>, isCalledAfterSocketUpdate: boolean, createItemChangesIfNoneExist: boolean): ProcessItemEntryChangesResult<ItemTypeType>;
|
|
68
66
|
/**
|
|
69
67
|
* @description
|
|
70
68
|
* Traverses the column path and returns the fields of the derived item, returns undefined if the item isn't found
|
|
@@ -105,5 +103,4 @@ export declare abstract class ItemHandlerBase {
|
|
|
105
103
|
* Gets the value of the given column, will look into the current delta before attempting to read itemChanges
|
|
106
104
|
*/
|
|
107
105
|
protected getItemIdByColumn<ItemTypeType extends ApiEnumItemType>(itemEntry: ItemEntry<ItemTypeType>, column: ColumnInfo<ItemTypeType>, changesDelta?: ChangesDeltaBase): ItemId;
|
|
108
|
-
expandColumnsWithCachedQueryColumns(itemType: ApiEnumItemType, requestColumns?: ApiRequestColumns): ApiRequestColumns;
|
|
109
106
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ApiEnumItemType } from '@rentman/backend-types';
|
|
2
|
-
import { ChangesDelta,
|
|
2
|
+
import { ChangesDelta, TransactionCache, TransactionOptions, TransactionValidatorFactory } from '../..';
|
|
3
3
|
import { RmCore } from '../../../core';
|
|
4
4
|
import { ServerCacheDependencyInterface } from '../../../interfaces/ServerCacheDependencyInterface';
|
|
5
5
|
import { ItemEntry } from '../../../models';
|
|
6
|
-
import { ApiRequestColumn, ApiRequestColumnMap, CollectionQuery, CollectionResourceParentIdMap, EntryParent, EntryParentNull, FieldMap, ItemIdConversionMap, PromiseInterface } from '../../../types';
|
|
6
|
+
import { ApiRequestColumn, ApiRequestColumnMap, CollectionQuery, CollectionResourceParentIdMap, EntryParent, EntryParentNull, FieldMap, ItemIdConversionMap, ItemTypeMap, PromiseInterface } from '../../../types';
|
|
7
7
|
import { ApiResponseProcessor } from '../../ApiResponseProcessor';
|
|
8
8
|
import { ChangesDeltaResult } from '../../ChangesDeltaBase';
|
|
9
9
|
import { OnAfterCreateCallback } from '../../ChangesProcessor';
|
|
10
|
+
import { ParentChangesDelta } from '../../ParentChangesDelta';
|
|
10
11
|
import { AbstractCache } from '../AbstractCache';
|
|
11
12
|
import { CachedQueryItem } from '../CachedQueryHandlerBase';
|
|
12
13
|
import { ServerCachedQueryHandler } from './ServerCachedQueryHandler';
|
|
@@ -25,14 +26,24 @@ export declare class ServerCache extends AbstractCache {
|
|
|
25
26
|
parent: null;
|
|
26
27
|
constructor(dependencies: ServerCacheDependencyInterface, core: RmCore);
|
|
27
28
|
getServerCache(): ServerCache;
|
|
28
|
-
createChild(id?: string, validatorFactory?: TransactionValidatorFactory): TransactionCache;
|
|
29
|
+
createChild(id?: string, validatorFactory?: TransactionValidatorFactory, options?: TransactionOptions): TransactionCache;
|
|
29
30
|
expandCollectionResources<ItemTypeType extends ApiEnumItemType>(itemType: ItemTypeType, collections: CollectionResourceParentIdMap<ItemTypeType>, newRequestColumns: ApiRequestColumn[]): PromiseInterface<CollectionResourceParentIdMap>;
|
|
30
|
-
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @param response
|
|
34
|
+
* @param requestColumnMap
|
|
35
|
+
* @param isCalledAfterSocketUpdate
|
|
36
|
+
* @param changesDelta
|
|
37
|
+
* @param conversionMap
|
|
38
|
+
* @param directRequestItemMap Should be a map of ItemType->ItemId of items that were directly part of the create/update request (queries should be excluded from this because we don't want to overwrite the user's changes (derived values are also queries))
|
|
39
|
+
*/
|
|
40
|
+
processResponse(response: ApiResponseProcessor, requestColumnMap: ApiRequestColumnMap, isCalledAfterSocketUpdate?: boolean, changesDelta?: ChangesDelta, directRequestItemMap?: ItemTypeMap<Record<string, boolean>>, conversionMap?: ItemIdConversionMap): PromiseInterface<ChangesDeltaResult>;
|
|
31
41
|
/**
|
|
32
42
|
* @description
|
|
33
|
-
* Applies
|
|
43
|
+
* Applies changes to this transaction and its children
|
|
44
|
+
* ServerCache.applyChangesFromParent should be used when processing an API update/create/delete
|
|
34
45
|
*/
|
|
35
|
-
applyChangesFromParent(
|
|
46
|
+
applyChangesFromParent(parentChangesDelta: ParentChangesDelta, isCalledAfterSocketUpdate?: boolean): PromiseInterface<void>;
|
|
36
47
|
/**
|
|
37
48
|
* @description
|
|
38
49
|
* Gets the fields required to set the parent
|
|
@@ -74,9 +85,9 @@ export declare class ServerCache extends AbstractCache {
|
|
|
74
85
|
/**
|
|
75
86
|
* @description
|
|
76
87
|
* Applies changes to this transaction and its children
|
|
77
|
-
*
|
|
88
|
+
* ServerCache.applyChangesDelta should be used when processing an API response which should create new entries on the ServerCache (such as a Query)
|
|
78
89
|
*/
|
|
79
|
-
applyChangesDelta(changesDelta: ChangesDelta,
|
|
90
|
+
applyChangesDelta(changesDelta: ChangesDelta, isCalledAfterSocketUpdate?: boolean, conversionMap?: ItemIdConversionMap): PromiseInterface<ChangesDeltaResult>;
|
|
80
91
|
getLocalItemEntry(itemEntryId: ItemEntry['id']): ItemEntry | undefined;
|
|
81
92
|
getLocalItemEntryByItemId(itemType: ApiEnumItemType, itemId: ItemEntry['itemId']): ItemEntry | undefined;
|
|
82
93
|
getChangesFromItemChanges<ItemTypeType extends ApiEnumItemType = any>(changesObject: ServerItemEntryChanges<ItemTypeType>): FieldMap<ItemTypeType>;
|
|
@@ -25,7 +25,7 @@ export declare class ServerItemHandler extends ItemHandlerBase {
|
|
|
25
25
|
* @description
|
|
26
26
|
* Processes updates on a cached entry
|
|
27
27
|
*/
|
|
28
|
-
processItemEntryChanges<ItemTypeType extends ApiEnumItemType = any>(itemEntryChangesTuple: ChangesDeltaItemUpdateDelta<ItemTypeType>,
|
|
28
|
+
processItemEntryChanges<ItemTypeType extends ApiEnumItemType = any>(itemEntryChangesTuple: ChangesDeltaItemUpdateDelta<ItemTypeType>, _isCalledAfterSocketUpdate?: boolean, _createItemChangesIfNoneExist?: boolean): ProcessItemEntryChangesResult<ItemTypeType>;
|
|
29
29
|
copyTransactionItemEntryChanges(itemEntryChanges: TransactionItemEntryChanges, entry: ItemEntry): ServerItemEntryChanges;
|
|
30
30
|
fetchItemEntry<ItemTypeType extends ApiEnumItemType>(itemType: ItemTypeType, itemId: ItemId, options: ItemEntryOptions): PromiseInterface<ItemEntry<ItemTypeType>>;
|
|
31
31
|
fetchItemEntriesByQuery<ItemTypeType extends ApiEnumItemType>(itemType: ItemTypeType, query: ApiQuery, entryOptions: ItemEntryOptions): PromiseInterface<Array<ItemEntry<ItemTypeType>>>;
|
|
@@ -43,7 +43,7 @@ export declare class ServerItemHandler extends ItemHandlerBase {
|
|
|
43
43
|
* General way to process an API response.
|
|
44
44
|
* Will call {@link ChangesDelta.setItemCreated setItemCreated} if an entry doesn't exist yet, and otherwise {@link ChangesDelta.setItemUpdated setItemUpdated} if it does.
|
|
45
45
|
*/
|
|
46
|
-
processApiResponse<ItemTypeType extends ApiEnumItemType>(changesDelta: ChangesDelta, response: ApiResponseProcessor, itemType: ItemTypeType, itemIdOfExistingItem: ItemId, itemIdInResponse: ItemId, columnSet: ColumnSet<ItemTypeType>, columnExpansion: ColumnExpansion<ItemTypeType
|
|
46
|
+
processApiResponse<ItemTypeType extends ApiEnumItemType>(changesDelta: ChangesDelta, response: ApiResponseProcessor, itemType: ItemTypeType, itemIdOfExistingItem: ItemId, itemIdInResponse: ItemId, columnSet: ColumnSet<ItemTypeType>, columnExpansion: ColumnExpansion<ItemTypeType>, updateModified?: boolean): void;
|
|
47
47
|
/**
|
|
48
48
|
* @description
|
|
49
49
|
* Fetches the data for the passed ItemType/ItemId/columns, will do nothing if the requested ItemEntry/columns are already cached.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApiEnumItemType, ApiFields, ItemId } from '@rentman/backend-types';
|
|
2
|
-
import { ChangesDelta, InternalChangesDelta, ServerCache, TransactionCollectionHandler, TransactionItemEntryChanges, TransactionItemHandler, TransactionValidatorFactory } from '../..';
|
|
2
|
+
import { ChangesDelta, InternalChangesDelta, ServerCache, TransactionCollectionHandler, TransactionItemEntryChanges, TransactionItemHandler, TransactionOptions, TransactionValidatorFactory } from '../..';
|
|
3
3
|
import { RmCore } from '../../../core';
|
|
4
4
|
import { AbstractCacheDependencyInterface } from '../../../interfaces/AbstractCacheDependencyInterface';
|
|
5
5
|
import { CollectionResource, ItemEntry, ItemEntryOptions, ItemResource } from '../../../models';
|
|
@@ -8,6 +8,7 @@ import { ApiQuery, ApiRequestColumn, ApiRequestColumns, CollectionDefinition, Co
|
|
|
8
8
|
import { ChangesDeltaResult } from '../../ChangesDeltaBase';
|
|
9
9
|
import { OnAfterCreateCallback } from '../../ChangesProcessor';
|
|
10
10
|
import { ModuleChangesCompilationResult } from '../../ModuleChangesCompilation';
|
|
11
|
+
import { ParentChangesDelta } from '../../ParentChangesDelta';
|
|
11
12
|
import { AbstractCache } from '../AbstractCache';
|
|
12
13
|
import { CachedQueryItem } from '../CachedQueryHandlerBase';
|
|
13
14
|
import { TransactionCachedQueryHandler } from './TransactionCachedQueryHandler';
|
|
@@ -20,6 +21,7 @@ export declare enum TransactionErrorLevel {
|
|
|
20
21
|
warning = "warning",
|
|
21
22
|
error = "error"
|
|
22
23
|
}
|
|
24
|
+
export declare type UndoFunction = () => PromiseInterface<ChangesDeltaResult>;
|
|
23
25
|
/**
|
|
24
26
|
* @description
|
|
25
27
|
* The {@link TransactionCache TransactionCache} is responsible for keeping track of newly created {@link ItemEntry ItemEntries}
|
|
@@ -91,14 +93,20 @@ export declare class TransactionCache extends AbstractCache {
|
|
|
91
93
|
readonly collectionHandler: TransactionCollectionHandler;
|
|
92
94
|
readonly eventHandler: TransactionEventHandler;
|
|
93
95
|
private readonly validator?;
|
|
96
|
+
private readonly options;
|
|
94
97
|
private _isValid;
|
|
98
|
+
private historyStep;
|
|
99
|
+
private undoDeltas;
|
|
100
|
+
private appliedDeltas;
|
|
95
101
|
constructor(dependencies: AbstractCacheDependencyInterface, core: RmCore, parent: AbstractCache,
|
|
96
102
|
/**
|
|
97
103
|
* @description
|
|
98
104
|
* For debugging purposes
|
|
99
105
|
*/
|
|
100
|
-
id?: string | undefined, validatorFactory?: TransactionValidatorFactory);
|
|
101
|
-
|
|
106
|
+
id?: string | undefined, validatorFactory?: TransactionValidatorFactory, options?: Partial<TransactionOptions>);
|
|
107
|
+
undo(): ReturnType<UndoFunction>;
|
|
108
|
+
redo(): ReturnType<TransactionCache['applyChangesDelta']>;
|
|
109
|
+
createChild(id?: string, validatorFactory?: TransactionValidatorFactory, options?: TransactionOptions): TransactionCache;
|
|
102
110
|
destroy(): void;
|
|
103
111
|
expandCollectionResource(collectionResource: CollectionResource, newColumns: ApiRequestColumns): PromiseInterface<void>;
|
|
104
112
|
/**
|
|
@@ -138,11 +146,8 @@ export declare class TransactionCache extends AbstractCache {
|
|
|
138
146
|
*
|
|
139
147
|
* ------------------
|
|
140
148
|
* Use {@link TransactionCache.applyChangesDelta applyChangesDelta} if you want to apply changes from outside the core
|
|
141
|
-
*
|
|
142
|
-
* @param internalChangesDelta Changes to be applied
|
|
143
|
-
* @param isCalledAfterApiSave If 'isCalledAfterApiSave' is true local changes will always be overwritten (instead of only when there are no changes)
|
|
144
149
|
*/
|
|
145
|
-
applyChangesFromParent(
|
|
150
|
+
applyChangesFromParent(parentChangesDelta: ParentChangesDelta, isCalledAfterSocketUpdate?: boolean, conversionMap?: ItemIdConversionMap): PromiseInterface<void>;
|
|
146
151
|
/**
|
|
147
152
|
* @description
|
|
148
153
|
* Applies changes to this transaction and its children
|
|
@@ -151,12 +156,8 @@ export declare class TransactionCache extends AbstractCache {
|
|
|
151
156
|
*
|
|
152
157
|
* The difference between {@link TransactionCache.applyChangesFromParent} and {@link TransactionCache.applyChangesDelta} is that applyChangesFromParent assumes
|
|
153
158
|
* the change has already been processed, and applyChangesDelta will process the changes itself (result vs cause)
|
|
154
|
-
*
|
|
155
|
-
* ------------------
|
|
156
|
-
*
|
|
157
|
-
* Differs from {@link ServerCache.applyChangesDelta ServerCache.applyChangesDelta} in the handling of deleted entries and the applyChangesFromParent call
|
|
158
159
|
*/
|
|
159
|
-
applyChangesDelta(changesDelta: ChangesDelta): PromiseInterface<ChangesDeltaResult>;
|
|
160
|
+
applyChangesDelta(changesDelta: ChangesDelta | InternalChangesDelta): PromiseInterface<ChangesDeltaResult>;
|
|
160
161
|
getServerCache(): ServerCache;
|
|
161
162
|
/**
|
|
162
163
|
* @description
|
|
@@ -4,7 +4,7 @@ import { ItemEntry, ItemEntryOptions } from '../../../models';
|
|
|
4
4
|
import { ApiQuery, ApiRequestColumns, DeregFunction, FieldChangeCallback, FieldMap, ItemIdConversionMap, ItemTypeMap, ModifyFieldsCallback, PromiseInterface, ResponseColumnItemTypeMap } from '../../../types';
|
|
5
5
|
import { ChangesDelta } from '../../ChangesDelta';
|
|
6
6
|
import { ChangesDeltaBase, ChangesDeltaItemUpdateDelta, ChangesDeltaResult } from '../../ChangesDeltaBase';
|
|
7
|
-
import { ChangesDeltaItemCreateDelta, ColumnSubsetCache
|
|
7
|
+
import { ChangesDeltaItemCreateDelta, ColumnSubsetCache } from '../../index';
|
|
8
8
|
import { ItemHandlerBase, ProcessItemEntryChangesResult } from '../ItemHandlerBase';
|
|
9
9
|
import { TransactionCache } from './TransactionCache';
|
|
10
10
|
import { TransactionValidator } from './TransactionValidator';
|
|
@@ -35,6 +35,7 @@ export declare class TransactionItemHandler extends ItemHandlerBase {
|
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
37
|
constructor(dependencies: TransactionItemHandlerDependencyInterface, transaction: TransactionCache, validator?: TransactionValidator | undefined);
|
|
38
|
+
updateLocalItemIdReferences(itemType: ApiEnumItemType, oldItemId: ItemId, newItemId: ItemId, changesDelta?: ChangesDeltaBase, isCalledAfterSave?: boolean): void;
|
|
38
39
|
registerFieldChangeCallback<ItemTypeType extends ApiEnumItemType>(itemType: ItemTypeType, itemId: ItemId, callback: FieldChangeCallback<ItemTypeType>): DeregFunction;
|
|
39
40
|
copyTransactionItemEntryChanges(itemEntryChanges: TransactionItemEntryChanges, entry: ItemEntry): TransactionItemEntryChanges;
|
|
40
41
|
createItemEntry(createTuple: ChangesDeltaItemCreateDelta): ItemEntry;
|
|
@@ -57,11 +58,9 @@ export declare class TransactionItemHandler extends ItemHandlerBase {
|
|
|
57
58
|
detectEntryChanges(itemEntryId: ItemEntry['id']): boolean;
|
|
58
59
|
/**
|
|
59
60
|
* @description
|
|
60
|
-
* Processes on a cached entry, if there are no {@link TransactionItemHandler.itemChanges itemChanges} the new values will not be processed
|
|
61
|
+
* Processes on a cached entry, if there are no {@link TransactionItemHandler.itemChanges itemChanges} the new values will not be processed unless `createItemChangesIfNoneExist` is set
|
|
61
62
|
*
|
|
62
63
|
* @param itemEntryChangesTuple The changes tuple
|
|
63
|
-
* @param forceOverwrite Instead of calling {@link ApiFormatter.mergeCopyFields mergeCopyFields}, {@link ApiFormatter.copyFields copyFields} will be used (because API values are always right)
|
|
64
|
-
* @param updateInitial Should be `true` if called by applyChangesFromParent
|
|
65
64
|
* @param isCalledAfterSocketUpdate Indicates that the change is done by a different user
|
|
66
65
|
* @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
|
|
67
66
|
* @param changesDelta Will be used to check which items should/shouldn't be updated when updating local ID references
|
|
@@ -69,7 +68,7 @@ export declare class TransactionItemHandler extends ItemHandlerBase {
|
|
|
69
68
|
* @returns
|
|
70
69
|
* The previous changes {@link FieldMap FieldMap}, returns `null` when the item was not cached or no fields were changed.
|
|
71
70
|
*/
|
|
72
|
-
processItemEntryChanges<ItemTypeType extends ApiEnumItemType = any>(itemEntryChangesTuple: ChangesDeltaItemUpdateDelta<ItemTypeType>,
|
|
71
|
+
processItemEntryChanges<ItemTypeType extends ApiEnumItemType = any>(itemEntryChangesTuple: ChangesDeltaItemUpdateDelta<ItemTypeType>, isCalledAfterSocketUpdate?: boolean, createItemChangesIfNoneExist?: boolean): ProcessItemEntryChangesResult<ItemTypeType>;
|
|
73
72
|
cloneItemEntries<ItemTypeType extends ApiEnumItemType>(changesDelta: ChangesDelta, itemEntries: Array<ItemEntry<ItemTypeType>>, conversionMap?: ItemIdConversionMap, modifyFieldsCallback?: ModifyFieldsCallback): ItemId[];
|
|
74
73
|
cloneItemEntry<ItemTypeType extends ApiEnumItemType>(changesDelta: ChangesDelta, sourceEntry: ItemEntry<ItemTypeType>, conversionMap?: ItemIdConversionMap, modifyFieldsCallback?: ModifyFieldsCallback): ItemId;
|
|
75
74
|
fetchItemEntriesByQuery<ItemTypeType extends ApiEnumItemType>(itemType: ItemTypeType, query: ApiQuery, entryOptions: ItemEntryOptions): PromiseInterface<Array<ItemEntry<ItemTypeType>>>;
|
|
@@ -95,5 +94,4 @@ export declare class TransactionItemHandler extends ItemHandlerBase {
|
|
|
95
94
|
private getColumnDifference;
|
|
96
95
|
private expandLocalItemEntry;
|
|
97
96
|
private getLocalValues;
|
|
98
|
-
private updateLocalItemIdReferences;
|
|
99
97
|
}
|