@rentman/rm-core 2.0.4 → 2.0.6
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 +12 -0
- package/dist/rm-core.js +51 -45
- package/dist/rm-core.min.js +1 -1
- package/dist/src/classes/ApiFormatter.d.ts +1 -6
- package/dist/src/classes/ChangesProcessor.d.ts +3 -2
- package/dist/src/classes/cache/transaction/TransactionCache.d.ts +5 -1
- package/dist/src/factories/ChangesProcessorFactory.d.ts +3 -2
- package/dist/src/models/CollectionResource.d.ts +1 -1
- package/dist/src/models/CollectionResourceOptions.d.ts +1 -0
- package/dist/src/models/ItemResource.d.ts +10 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as moment from 'moment';
|
|
2
2
|
import { ColumnInfo } from '../classes';
|
|
3
|
-
import { FieldMap, ItemType
|
|
3
|
+
import { FieldMap, ItemType } from '../types';
|
|
4
4
|
export declare class ApiFormatter {
|
|
5
5
|
MOMENT_INVALID: string;
|
|
6
6
|
SERVER_DATETIME_FORMAT: string;
|
|
@@ -21,11 +21,6 @@ export declare class ApiFormatter {
|
|
|
21
21
|
* Overwrites the values in 'changes' if the values in 'initial' and 'changes' are the same (leaving user changes intact)
|
|
22
22
|
*/
|
|
23
23
|
mergeCopyFields<ItemTypeType extends ItemType>(initial: FieldMap<ItemTypeType>, changes: FieldMap<ItemTypeType>, newInitial: FieldMap<ItemTypeType>, columns: Array<ColumnInfo<ItemTypeType>>): FieldMap<ItemTypeType>;
|
|
24
|
-
/**
|
|
25
|
-
* @description
|
|
26
|
-
* Clones the fields from `source` to `destination`, calls {@link ApiFormatter.isExpensiveFormat isExpensiveFormat} to determine if values should immediately be cloned, or the getter should be cloned
|
|
27
|
-
*/
|
|
28
|
-
lazyClone(apiColumn: ResponseColumn, source: object, destination: object, key: string): void;
|
|
29
24
|
formatRequest<ItemTypeType extends ItemType>(initial: FieldMap<ItemTypeType>, modified: FieldMap<ItemTypeType>, columns: Array<ColumnInfo<any>>): FieldMap<ItemTypeType>;
|
|
30
25
|
formatRequestLocal<ItemTypeType extends ItemType>(fields: FieldMap<ItemTypeType>, columns: Array<ColumnInfo<any>>): FieldMap<ItemTypeType>;
|
|
31
26
|
hasChanges(initial: FieldMap, modified: FieldMap, columns: Array<ColumnInfo<any>>, includeReadOnlyColumns?: boolean): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiRequestService, CollectionEntryService, ItemEntryService } from '../classes';
|
|
1
|
+
import { ApiFormatter, 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,6 +10,7 @@ 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;
|
|
13
14
|
private changesDeltaFactory;
|
|
14
15
|
private apiRequestService;
|
|
15
16
|
private changesCompilationFactory;
|
|
@@ -25,7 +26,7 @@ export declare class ChangesProcessor {
|
|
|
25
26
|
private onAfterCreateCallback?;
|
|
26
27
|
private itemIdConversionMap;
|
|
27
28
|
private serverCache;
|
|
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);
|
|
29
|
+
constructor(apiFormatter: ApiFormatter, 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);
|
|
29
30
|
/**
|
|
30
31
|
* @description
|
|
31
32
|
* Executes the requests in the order of:
|
|
@@ -114,8 +114,12 @@ export declare class TransactionCache extends AbstractCache {
|
|
|
114
114
|
*
|
|
115
115
|
* @param itemEntry The entry to get the parent from
|
|
116
116
|
* @param fromInitial If `true` the parent values will be read from {@link TransactionItemEntryChanges.initial initial} (Useful for when you've moved an entry)
|
|
117
|
+
* @param providedFields Use the provided fields instead of the cached fields, used by {@link CollectionResource.getParent CollectionResource.getParent}
|
|
118
|
+
*
|
|
119
|
+
* @remark
|
|
120
|
+
* Use {@link CollectionResource.getParent CollectionResource.getParent} instead of {@link TransactionCache.getParent TransactionCache.getParent} if you're getting the parent in the onRemove callback
|
|
117
121
|
*/
|
|
118
|
-
getParent(itemEntry: ItemEntry
|
|
122
|
+
getParent<ItemTypeType extends ItemType>(itemEntry: ItemEntry<ItemTypeType>, fromInitial?: boolean, providedFields?: FieldMap<ItemTypeType>): EntryParentNull;
|
|
119
123
|
/**
|
|
120
124
|
* @description
|
|
121
125
|
* Traverses the transaction chain and returns the changes of the item on the first transaction
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiRequestService, ChangesProcessor, CollectionEntryService, ItemEntryService, OnAfterCreateCallback } from '../classes';
|
|
1
|
+
import { ApiFormatter, 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,6 +7,7 @@ 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;
|
|
10
11
|
private changesDeltaFactory;
|
|
11
12
|
private apiRequestService;
|
|
12
13
|
private changesCompilationFactory;
|
|
@@ -17,6 +18,6 @@ export declare class ChangesProcessorFactory {
|
|
|
17
18
|
private requestColumnExpansionFactory;
|
|
18
19
|
private collectionEntryService;
|
|
19
20
|
private itemEntryService;
|
|
20
|
-
constructor(changesDeltaFactory: ChangesDeltaFactory, apiRequestService: ApiRequestService, changesCompilationFactory: ChangesCompilationFactory, columnExpansionFactory: ColumnExpansionFactory, createRequestFactory: CreateRequestFactory, errorHandler: ErrorHandlerInterface, promiseService: PromiseLibraryInterface, requestColumnExpansionFactory: RequestColumnExpansionFactory, collectionEntryService: CollectionEntryService, itemEntryService: ItemEntryService);
|
|
21
|
+
constructor(apiFormatter: ApiFormatter, changesDeltaFactory: ChangesDeltaFactory, apiRequestService: ApiRequestService, changesCompilationFactory: ChangesCompilationFactory, columnExpansionFactory: ColumnExpansionFactory, createRequestFactory: CreateRequestFactory, errorHandler: ErrorHandlerInterface, promiseService: PromiseLibraryInterface, requestColumnExpansionFactory: RequestColumnExpansionFactory, collectionEntryService: CollectionEntryService, itemEntryService: ItemEntryService);
|
|
21
22
|
construct(transaction: TransactionCache, breakUpByParent?: boolean, onAfterCreateCallback?: OnAfterCreateCallback): ChangesProcessor;
|
|
22
23
|
}
|
|
@@ -15,7 +15,7 @@ export declare abstract class CollectionResource<ItemTypeType extends ItemType =
|
|
|
15
15
|
onConstruct(): void;
|
|
16
16
|
getIdArray(): ItemId[];
|
|
17
17
|
getItemById(itemId: number): T;
|
|
18
|
-
addItemResources(itemEntries: Array<ItemEntry<ItemTypeType>>,
|
|
18
|
+
addItemResources(itemEntries: Array<ItemEntry<ItemTypeType>>, isInitialCall?: boolean): T[];
|
|
19
19
|
/**
|
|
20
20
|
* @description
|
|
21
21
|
* Returns the {@link ItemResource ItemResources} that where removed from the {@link CollectionResource collection}.
|
|
@@ -10,6 +10,7 @@ export declare class CollectionResourceOptions<ItemTypeType extends ItemType> {
|
|
|
10
10
|
remoteItems: boolean;
|
|
11
11
|
editCollection: boolean;
|
|
12
12
|
enableSave: boolean;
|
|
13
|
+
callOnAddWithInitialItems: boolean;
|
|
13
14
|
/**
|
|
14
15
|
* @deprecated
|
|
15
16
|
* You should use itemResource.onChange and compare previous.id with fields.id
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TransactionCache } from '../classes';
|
|
2
2
|
import { ItemResourceFactory } from '../factories';
|
|
3
3
|
import { ItemEntry, ItemResourceOptions } from '../models';
|
|
4
|
-
import { FieldMap, ItemType, ResponseColumn } from '../types';
|
|
4
|
+
import { EntryParentNull, FieldMap, ItemType, ResponseColumn } from '../types';
|
|
5
5
|
export declare abstract class ItemResource<ItemTypeType extends ItemType = any> {
|
|
6
6
|
protected readonly factory: ItemResourceFactory;
|
|
7
7
|
readonly entry: ItemEntry<ItemTypeType>;
|
|
@@ -15,6 +15,15 @@ export declare abstract class ItemResource<ItemTypeType extends ItemType = any>
|
|
|
15
15
|
initial: Readonly<FieldMap<ItemTypeType>>;
|
|
16
16
|
protected constructor(factory: ItemResourceFactory, entry: ItemEntry<ItemTypeType>, options: ItemResourceOptions<ItemResource<ItemTypeType>>, _isNew: boolean, transaction: TransactionCache);
|
|
17
17
|
onConstruct(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Fetches the ItemResource's parent with the current fields
|
|
20
|
+
*
|
|
21
|
+
* ----------------
|
|
22
|
+
*
|
|
23
|
+
* @remark
|
|
24
|
+
* Use this if you need to get the parent after an item has been deleted
|
|
25
|
+
*/
|
|
26
|
+
getParent(fromInitial?: boolean): EntryParentNull;
|
|
18
27
|
/**
|
|
19
28
|
* @deprecated
|
|
20
29
|
* Use {@link TransactionCache.applyChangesDelta transaction.applyChangesDelta} instead
|