@rentman/rm-core 12.1.1 → 12.1.3
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.
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import { ApiEnumApiType, ApiEnumItemType
|
|
1
|
+
import { ApiEnumApiType, ApiEnumItemType } from '@rentman/backend-types';
|
|
2
2
|
import moment from 'moment';
|
|
3
3
|
import { ApiEnumApiTypeToTsTypeMap, ColumnInfo, FieldMap, ItemTypeColumnIds } from '../internal';
|
|
4
|
-
declare type GetChangesResult<ItemTypeType extends ApiEnumItemType = any, ColumnId extends keyof ApiFields[ItemTypeType] = any> = {
|
|
5
|
-
oldValue: FieldMap<ItemTypeType, [ColumnId]>[ColumnId];
|
|
6
|
-
newValue: FieldMap<ItemTypeType, [ColumnId]>[ColumnId];
|
|
7
|
-
column: ResponseColumn<ItemTypeType, ColumnId>;
|
|
8
|
-
};
|
|
9
4
|
/**
|
|
10
5
|
* @description
|
|
11
6
|
* A service which provides functions to transform data that comes from/goes to the API
|
|
@@ -29,24 +24,10 @@ export declare class ApiFormatter {
|
|
|
29
24
|
* Currently only used for Moment objects
|
|
30
25
|
*/
|
|
31
26
|
isExpensiveFormat(columnType: ApiEnumApiType): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* @description
|
|
34
|
-
* Overwrites the values in 'changes' if the values in 'initial' and 'changes' are the same and the parent transaction
|
|
35
|
-
* copied over the field (leaving user changes intact)
|
|
36
|
-
*
|
|
37
|
-
* We have to check the parent transaction because on a child transaction initial/modified can be equal (the copied field of the parent)
|
|
38
|
-
* and will then incorrectly be overwritten by applyChangesFromParent
|
|
39
|
-
*
|
|
40
|
-
* Note: parentChanges can be undefined for local items
|
|
41
|
-
*/
|
|
42
|
-
mergeCopyFields<ItemTypeType extends ApiEnumItemType, ColumnIds extends ItemTypeColumnIds<ItemTypeType> = any>(parentChanges: FieldMap<ItemTypeType, ColumnIds> | undefined, changes: FieldMap<ItemTypeType, ColumnIds>, initial: FieldMap<ItemTypeType, ColumnIds>, newInitial: FieldMap<ItemTypeType, ColumnIds>, columns: ColumnInfo<ItemTypeType>[]): FieldMap<ItemTypeType, ColumnIds>;
|
|
43
27
|
formatRequestLocal<ItemTypeType extends ApiEnumItemType>(fields: FieldMap<ItemTypeType>, columns: ColumnInfo<ItemTypeType>[]): {
|
|
44
28
|
[columnId: string]: any;
|
|
45
29
|
};
|
|
46
|
-
hasChanges<ItemTypeType extends ApiEnumItemType>(initial: FieldMap<ItemTypeType>, modified: FieldMap<ItemTypeType>, columns: ColumnInfo<ItemTypeType>[], includeReadOnlyColumns?: boolean, forceCompare?: boolean): boolean;
|
|
47
|
-
getChanges<ItemTypeType extends ApiEnumItemType = any, ColumnIds extends ItemTypeColumnIds<ItemTypeType> = any>(initial: FieldMap<ItemTypeType, ColumnIds>, modified: FieldMap<ItemTypeType, ColumnIds>, columns: ColumnInfo<ItemTypeType, ColumnIds[number]>[]): GetChangesResult<ItemTypeType, ColumnIds[number]>[];
|
|
48
30
|
copyFields<ItemTypeType extends ApiEnumItemType = any, ColumnIds extends ItemTypeColumnIds<ItemTypeType> = any>(source: Partial<FieldMap<ItemTypeType, ColumnIds>>, destination: Partial<FieldMap<ItemTypeType>>, columns: ColumnInfo<ItemTypeType, ColumnIds[number]>[]): FieldMap<ItemTypeType, ColumnIds>;
|
|
49
|
-
shallowCopyFields<ItemTypeType extends ApiEnumItemType>(shallowSource: FieldMap<ItemTypeType>, deepSource: FieldMap<ItemTypeType>, destination: FieldMap<ItemTypeType>, columns: ColumnInfo<ItemTypeType>[]): FieldMap<ItemTypeType>;
|
|
50
31
|
setDefaultValues<ItemTypeType extends ApiEnumItemType = any>(destination: FieldMap<ItemTypeType>, columns: ColumnInfo<ItemTypeType>[]): FieldMap<ItemTypeType>;
|
|
51
32
|
/**
|
|
52
33
|
* @description
|
|
@@ -73,4 +54,3 @@ export declare class ApiFormatter {
|
|
|
73
54
|
cloneDate(date: moment.Moment): moment.Moment;
|
|
74
55
|
identity<T>(input: T): T;
|
|
75
56
|
}
|
|
76
|
-
export {};
|
|
@@ -5,10 +5,25 @@ export declare type ChangesDeltaResult = {
|
|
|
5
5
|
created: ItemEntry[];
|
|
6
6
|
};
|
|
7
7
|
export declare enum ChangesDeltaItemUpdateMode {
|
|
8
|
+
/**
|
|
9
|
+
* For create/update responses you always want to overwrite whatever is cached
|
|
10
|
+
*/
|
|
8
11
|
CLEAR_ALWAYS = "overwrite",
|
|
12
|
+
/**
|
|
13
|
+
* For socket messages you want to clear the user's changes if they are the same as what is received
|
|
14
|
+
*/
|
|
9
15
|
CLEAR_WHEN_SAME = "same",
|
|
16
|
+
/**
|
|
17
|
+
* For user changes you want to store them if they are different than on a parent
|
|
18
|
+
*/
|
|
10
19
|
KEEP_WHEN_DIFFERENT = "different",
|
|
20
|
+
/**
|
|
21
|
+
* Used when expanding local items
|
|
22
|
+
*/
|
|
11
23
|
APPEND = "append",
|
|
24
|
+
/**
|
|
25
|
+
* Used for query responses (you don't want to do anything with user changes)
|
|
26
|
+
*/
|
|
12
27
|
QUERY = "query"
|
|
13
28
|
}
|
|
14
29
|
/**
|