@rentman/rm-core 8.1.9 → 8.2.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 +8 -0
- package/dist/rm-core.js +378 -207
- package/dist/rm-core.min.js +1 -1
- package/dist/types/classes/CacheSyncer.d.ts +17 -15
- package/dist/types/classes/TemplateCache.d.ts +2 -3
- package/dist/types/classes/Util.d.ts +0 -3
- package/dist/types/classes/cache/CachedQueryHandlerBase.d.ts +5 -1
- package/dist/types/classes/cache/transaction/TransactionCache.d.ts +9 -4
- package/dist/types/classes/cache/transaction/TransactionCachedQueryHandler.d.ts +3 -1
- package/dist/types/classes/cache/transaction/TransactionCollectionHandler.d.ts +1 -1
- package/dist/types/core.d.ts +1 -0
- package/dist/types/factories/CollectionResourceFactory.d.ts +5 -2
- package/dist/types/factories/ItemResourceFactory.d.ts +2 -2
- package/dist/types/models/CollectionOptions.d.ts +26 -7
- package/dist/types/models/CollectionResource.d.ts +33 -20
- package/dist/types/models/ItemResource.d.ts +9 -4
- package/dist/types/types/ItemTypesCollection.d.ts +14 -14
- package/package.json +2 -2
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { ApiEnumItemType } from '@rentman/backend-types';
|
|
2
2
|
import { AbstractCache, ApiRequestService, CachedQueryItem, ChangesDeltaBase, CollectionQuery, CollectionResource, FieldMap, ItemEntry, ItemTypeMap, ParentChangesDelta, PromiseInterface, PromiseLibraryInterface, QueryMatcherFactory, QueryService } from '../internal';
|
|
3
|
-
export declare type CacheSyncerMatches<ItemTypeType extends ApiEnumItemType = any> = {
|
|
4
|
-
[itemId: number]: {
|
|
5
|
-
item: ItemEntry<ItemTypeType>;
|
|
6
|
-
isMatch: boolean | 'maybe';
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
3
|
export declare type CacheSyncerQueryMap = ItemTypeMap<{
|
|
10
4
|
[cachedQueryString: string]: {
|
|
11
5
|
cachedQueryItems: CachedQueryItem[];
|
|
@@ -18,17 +12,25 @@ export declare class CacheSyncer {
|
|
|
18
12
|
private apiRequestService;
|
|
19
13
|
private promiseService;
|
|
20
14
|
private transaction;
|
|
21
|
-
private
|
|
22
|
-
private
|
|
23
|
-
constructor(queryService: QueryService, queryMatcherFactory: QueryMatcherFactory, apiRequestService: ApiRequestService, promiseService: PromiseLibraryInterface, transaction: AbstractCache,
|
|
24
|
-
syncCollections(isCalledAfterSocketUpdate?: boolean, changesDelta?: ChangesDeltaBase): PromiseInterface<void
|
|
15
|
+
private cachedQueryMap;
|
|
16
|
+
private matchedItemEntryMap;
|
|
17
|
+
constructor(queryService: QueryService, queryMatcherFactory: QueryMatcherFactory, apiRequestService: ApiRequestService, promiseService: PromiseLibraryInterface, transaction: AbstractCache, cachedQueryMap: CacheSyncerQueryMap);
|
|
18
|
+
syncCollections(isCalledAfterSocketUpdate?: boolean, changesDelta?: ChangesDeltaBase): PromiseInterface<void>;
|
|
25
19
|
syncCachedQueries(_isCalledAfterSocketUpdate?: boolean, changesDelta?: ChangesDeltaBase): PromiseInterface<void[]>;
|
|
26
20
|
expand<ItemEntryType extends ItemEntry>(itemEntry: ItemEntryType, fields: FieldMap<ItemEntryType['itemType']>): this;
|
|
27
21
|
processDelta(parentChangesDelta: ParentChangesDelta): this;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Returns null if none of the promises resulted in an exception, or the exception otherwise.
|
|
24
|
+
*/
|
|
25
|
+
private resolveAll;
|
|
26
|
+
private syncCollection;
|
|
27
|
+
private syncCachedQuery;
|
|
28
|
+
private groupItemEntries;
|
|
33
29
|
protected _expand<ItemTypeType extends ApiEnumItemType = any>(itemEntry: ItemEntry<ItemTypeType>, matchFunction: (itemType: ItemTypeType, parsedQuery: CollectionQuery) => boolean | 'maybe'): this;
|
|
30
|
+
/**
|
|
31
|
+
* Unlike the functions that use a promise accumulator, this function *can* result in a rejection. It should be handled
|
|
32
|
+
* by the caller.
|
|
33
|
+
*/
|
|
34
|
+
protected processMaybeMatches<ItemTypeType extends ApiEnumItemType>(itemType: ItemTypeType, query: CollectionQuery, maybeItemEntries: ItemEntry<ItemTypeType>[], changesDelta: ChangesDeltaBase | undefined): PromiseInterface<ItemEntry<ItemTypeType>[]>;
|
|
35
|
+
private addMatchedEntriesToCollections;
|
|
34
36
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ApiEnumItemType, ApiFields, ItemId } from '@rentman/backend-types';
|
|
2
|
-
import { ApiRequestService, ApiResponse, ColumnHandler, ColumnUtil, EntryParentNull, ErrorHandlerInterface, PromiseInterface, PromiseLibraryInterface, RequestColumnExpansionFactory,
|
|
2
|
+
import { ApiRequestService, ApiResponse, ColumnHandler, ColumnUtil, EntryParentNull, ErrorHandlerInterface, PromiseInterface, PromiseLibraryInterface, RequestColumnExpansionFactory, Template, TemplateFactory } from '../internal';
|
|
3
3
|
export declare class TemplateCache {
|
|
4
|
-
private core;
|
|
5
4
|
private columnUtil;
|
|
6
5
|
private promiseService;
|
|
7
6
|
private columnHandler;
|
|
@@ -13,7 +12,7 @@ export declare class TemplateCache {
|
|
|
13
12
|
templateResponses: {
|
|
14
13
|
[itemType: string]: ApiResponse;
|
|
15
14
|
};
|
|
16
|
-
constructor(
|
|
15
|
+
constructor(columnUtil: ColumnUtil, promiseService: PromiseLibraryInterface, columnHandler: ColumnHandler, templateFactory: TemplateFactory, errorHandler: ErrorHandlerInterface, requestColumnExpansionFactory: RequestColumnExpansionFactory, apiRequestService: ApiRequestService);
|
|
17
16
|
/**
|
|
18
17
|
* @description
|
|
19
18
|
* Fetches a {@link Template template}, use {@link ItemCreateService.createItemsFromValues createItemsFromValues} to easily create new items from a set of values.
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { PromiseInterface } from '../internal';
|
|
2
2
|
export declare function findIndex<T>(haystack: T[], callback: (item: T) => boolean): number;
|
|
3
|
-
export declare function instantiateOptions(options: {
|
|
4
|
-
[key: string]: any;
|
|
5
|
-
}, values: object): void;
|
|
6
3
|
export declare function shallowMerge(object: any, defaults: any): any;
|
|
7
4
|
export declare function hasProperties(object: any): boolean;
|
|
8
5
|
export declare function getFirstProperty(object: any): string | null;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { ApiEnumItemType, ItemId } from '@rentman/backend-types';
|
|
2
|
-
import { AbstractCache, ApiQuery, ApiRequestColumns, CachedQueryItem, CollectionEntryService, CollectionOptions, CollectionQuery, ColumnSubsetCache, ColumnUtil, ItemEntry, ParentIdMap, PromiseInterface, PromiseLibraryInterface, RequestColumnExpansionFactory } from '../../internal';
|
|
2
|
+
import { AbstractCache, ApiQuery, ApiRequestColumns, CachedQueryItem, CollectionEntryService, CollectionOptions, CollectionQuery, ColumnSubsetCache, ColumnUtil, ItemEntry, ParentIdMap, ParentItemMap, PromiseInterface, PromiseLibraryInterface, RequestColumnExpansionFactory } from '../../internal';
|
|
3
|
+
export declare type CachedQueryItemTree<ItemTypeType extends ApiEnumItemType = any> = {
|
|
4
|
+
item: CachedQueryItem<ItemTypeType>;
|
|
5
|
+
children: ParentItemMap<CachedQueryItemTree> | null;
|
|
6
|
+
};
|
|
3
7
|
export declare abstract class CachedQueryHandlerBase {
|
|
4
8
|
protected collectionEntryService: CollectionEntryService;
|
|
5
9
|
protected columnUtil: ColumnUtil;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApiEnumItemType, ApiFields, ItemId } from '@rentman/backend-types';
|
|
2
|
-
import { AbstractCache, AbstractCacheDependencyInterface, ApiQuery, ApiRequestColumn, ApiRequestColumns, CachedQueryItem, ChangesDelta, ChangesDeltaResult, CollectionDefinition, CollectionOptionsInterface, CollectionQuery, CollectionResource, CollectionResourceParentIdMap, ConversionMap, CreateRequestParameterMap, DeregFunction, EntryParentNull, FieldChangeCallback, FieldMap, InternalChangesDelta, ItemEntry, ItemEntryOptions, ItemIdConversionMap, ItemOptionsInterface, ItemResource, ItemResourcesItemTypeMap, ItemTypeMap, LinkCollectionDefinition, ModuleChangesCompilationResult, OnAfterCreateCallback, ParentChangesDelta, PromiseInterface, RmCore, ServerCache, TransactionCacheCallbackCondition, TransactionCacheCallbackType, TransactionCachedQueryHandler, TransactionCollectionHandler, TransactionEventHandler, TransactionItemEntryChanges, TransactionItemHandler, TransactionOptions, TransactionValidatorFactory } from '../../../internal';
|
|
2
|
+
import { AbstractCache, AbstractCacheDependencyInterface, ApiQuery, ApiRequestColumn, ApiRequestColumns, CachedQueryItem, CachedQueryItemTree, ChangesDelta, ChangesDeltaResult, ChildCollectionOptions, ChildCollectionResources, ChildCollectionResourcesNull, CollectionDefinition, CollectionOptionsInterface, CollectionQuery, CollectionResource, CollectionResourceParentIdMap, ConversionMap, CreateRequestParameterMap, DeregFunction, EntryParentNull, FieldChangeCallback, FieldMap, InternalChangesDelta, ItemEntry, ItemEntryOptions, ItemIdConversionMap, ItemOptionsInterface, ItemResource, ItemResourcesItemTypeMap, ItemTypeMap, LinkCollectionDefinition, ModuleChangesCompilationResult, OnAfterCreateCallback, ParentChangesDelta, ParentItemMap, PromiseInterface, RmCore, ServerCache, TransactionCacheCallbackCondition, TransactionCacheCallbackType, TransactionCachedQueryHandler, TransactionCollectionHandler, TransactionEventHandler, TransactionItemEntryChanges, TransactionItemHandler, TransactionOptions, TransactionValidatorFactory } from '../../../internal';
|
|
3
3
|
declare type ItemResourceLinks<ItemTypeType extends ApiEnumItemType> = {
|
|
4
4
|
main: ItemResource<ItemTypeType>;
|
|
5
5
|
linked: ItemResourcesItemTypeMap;
|
|
@@ -227,6 +227,9 @@ export declare class TransactionCache extends AbstractCache {
|
|
|
227
227
|
}, conversionMap: ConversionMap): void;
|
|
228
228
|
getAllLinkCollections<ItemTypeType extends ApiEnumItemType>(linkType: ApiEnumItemType, itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType>): PromiseInterface<CollectionResourceParentIdMap<ItemTypeType>>;
|
|
229
229
|
getLinkCollectionsFromDef<ItemTypeType extends ApiEnumItemType>(linkType: ApiEnumItemType, linkIdArray: ItemId[], definition: LinkCollectionDefinition<ItemTypeType>): PromiseInterface<CollectionResourceParentIdMap<ItemTypeType>>;
|
|
230
|
+
/**
|
|
231
|
+
* @deprecated Use the `children` collection option instead.
|
|
232
|
+
*/
|
|
230
233
|
getLinkCollections<ItemTypeType extends ApiEnumItemType>(linkType: ApiEnumItemType, linkIdArray: ItemId[], itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType>): PromiseInterface<CollectionResourceParentIdMap<ItemTypeType>>;
|
|
231
234
|
getCollectionFromDef<ItemTypeType extends ApiEnumItemType>(definition: CollectionDefinition<ItemTypeType>): PromiseInterface<CollectionResource<ItemTypeType>>;
|
|
232
235
|
getCollection<ItemTypeType extends ApiEnumItemType, ColumnIds extends Array<keyof ApiFields[ItemTypeType]> = Array<keyof ApiFields[ItemTypeType]>>(itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType>): PromiseInterface<CollectionResource<ItemTypeType, ColumnIds>>;
|
|
@@ -297,10 +300,12 @@ export declare class TransactionCache extends AbstractCache {
|
|
|
297
300
|
* won't be included
|
|
298
301
|
*/
|
|
299
302
|
getDelta(): InternalChangesDelta;
|
|
300
|
-
createItemResource<ItemTypeType extends ApiEnumItemType>(itemEntry: ItemEntry<ItemTypeType>, isNew?: boolean): ItemResource<ItemTypeType>;
|
|
301
|
-
createItemResources<ItemTypeType extends ApiEnumItemType, ColumnIds extends Array<keyof ApiFields[ItemTypeType]
|
|
303
|
+
createItemResource<ItemTypeType extends ApiEnumItemType>(itemEntry: ItemEntry<ItemTypeType>, childCollectionMap?: ChildCollectionResourcesNull, isNew?: boolean): ItemResource<ItemTypeType>;
|
|
304
|
+
createItemResources<ItemTypeType extends ApiEnumItemType, ColumnIds extends Array<keyof ApiFields[ItemTypeType]>>(itemEntries: Array<ItemEntry<ItemTypeType>>, childCollectionResourceMap?: ChildCollectionResourcesNull): Array<ItemResource<ItemTypeType, ColumnIds>>;
|
|
302
305
|
processLinkedItems<ItemTypeType extends ApiEnumItemType>(linkedEntries: ItemTypeMap<ItemEntry[]>): ItemResourcesItemTypeMap<ItemResource<ItemTypeType>>;
|
|
303
|
-
createCollectionResource<ItemTypeType extends ApiEnumItemType>(itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType>, initialEntries: Array<ItemEntry<ItemTypeType
|
|
306
|
+
createCollectionResource<ItemTypeType extends ApiEnumItemType>(itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType>, initialEntries: Array<ItemEntry<ItemTypeType>>, childCollectionResourceMap?: ParentItemMap<CollectionResource> | null): CollectionResource<ItemTypeType>;
|
|
307
|
+
createChildCollectionResources(parentType: ApiEnumItemType, options: ChildCollectionOptions, cachedQueryItems: ParentItemMap<CachedQueryItemTree>): ChildCollectionResources;
|
|
308
|
+
private createChildCollectionResource;
|
|
304
309
|
getChangesFromItemChanges<ItemTypeType extends ApiEnumItemType = any>(changesObject: TransactionItemEntryChanges<FieldMap<ItemTypeType>>): FieldMap<ItemTypeType>;
|
|
305
310
|
/**
|
|
306
311
|
* @description
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApiEnumItemType, ItemId } from '@rentman/backend-types';
|
|
2
|
-
import { ApiQuery, ApiRequestColumns, CachedQueryHandlerBase, CachedQueryItem, CollectionOptions, CollectionQuery, ColumnSubsetCache, ItemEntry, ItemEntryOptions, ItemIdConversionMap, ParentIdMap, PromiseInterface, TransactionCache, TransactionCollectionHandlerDependencyInterface, TransactionItemHandler } from '../../../internal';
|
|
2
|
+
import { ApiQuery, ApiRequestColumns, CachedQueryHandlerBase, CachedQueryItem, CachedQueryItemTree, ChildCollectionOptions, CollectionOptions, CollectionQuery, ColumnSubsetCache, ItemEntry, ItemEntryOptions, ItemIdConversionMap, ParentIdMap, ParentItemMap, PromiseInterface, TransactionCache, TransactionCollectionHandlerDependencyInterface, TransactionItemHandler } from '../../../internal';
|
|
3
3
|
export declare class TransactionCachedQueryHandler extends CachedQueryHandlerBase {
|
|
4
4
|
private dependencies;
|
|
5
5
|
private itemHandler;
|
|
@@ -26,4 +26,6 @@ export declare class TransactionCachedQueryHandler extends CachedQueryHandlerBas
|
|
|
26
26
|
private expandCachedQueryItemEntries;
|
|
27
27
|
private syncCachedQueryWithLocalItems;
|
|
28
28
|
__fetchLinkedCachedQueryItems<ItemTypeType extends ApiEnumItemType>(parentType: ApiEnumItemType, parentIdArray: ItemId[] | (() => ItemId[]), itemType: ItemTypeType, options: CollectionOptions): PromiseInterface<ParentIdMap<CachedQueryItem<ItemTypeType>>>;
|
|
29
|
+
__fetchParentCachedQueryItem<ItemTypeType extends ApiEnumItemType>(itemType: ItemTypeType, options: CollectionOptions): PromiseInterface<CachedQueryItemTree<ItemTypeType>>;
|
|
30
|
+
__fetchChildCachedQueryItems(parentType: ApiEnumItemType, parentIds: ItemId[], childCollectionOptions: ChildCollectionOptions): PromiseInterface<ParentItemMap<CachedQueryItemTree>>;
|
|
29
31
|
}
|
|
@@ -13,7 +13,7 @@ export declare class TransactionCollectionHandler {
|
|
|
13
13
|
constructor(itemHandler: TransactionItemHandler, cachedQueryHandler: TransactionCachedQueryHandler, dependencies: TransactionCollectionHandlerDependencyInterface, transaction: TransactionCache);
|
|
14
14
|
updateLocalItemIdReferences(conversionMap: ItemIdConversionMap): void;
|
|
15
15
|
expandCollectionResource<ItemTypeType extends ApiEnumItemType = any>(collectionResource: CollectionResource<ItemTypeType>, newColumns: ApiRequestColumns): PromiseInterface<void>;
|
|
16
|
-
addResource(resource: CollectionResource):
|
|
16
|
+
addResource(resource: CollectionResource): CollectionResource;
|
|
17
17
|
clearResource(resource: CollectionResource): void;
|
|
18
18
|
/**
|
|
19
19
|
* @description
|
package/dist/types/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApiEnumItemType } from '@rentman/backend-types';
|
|
2
|
-
import { ChangesDeltaFactory, CollectionEntryFactory,
|
|
2
|
+
import { ChangesDeltaFactory, CollectionEntryFactory, CollectionOptions, CollectionResource, ColumnSetFactory, ErrorHandlerInterface, ExceptionHandlerInterface, ItemEntry, ItemEntryService, KeyService, ParentItemMap, PromiseLibraryInterface, QueryService, TransactionCache } from '../internal';
|
|
3
3
|
export declare class CollectionResourceFactory {
|
|
4
4
|
errorHandler: ErrorHandlerInterface;
|
|
5
5
|
exceptionHandler: ExceptionHandlerInterface;
|
|
@@ -11,5 +11,8 @@ export declare class CollectionResourceFactory {
|
|
|
11
11
|
queryService: QueryService;
|
|
12
12
|
columnSetFactory: ColumnSetFactory;
|
|
13
13
|
constructor(errorHandler: ErrorHandlerInterface, exceptionHandler: ExceptionHandlerInterface, keyService: KeyService, promiseService: PromiseLibraryInterface, changesDeltaFactory: ChangesDeltaFactory, itemEntryService: ItemEntryService, collectionEntryFactory: CollectionEntryFactory, queryService: QueryService, columnSetFactory: ColumnSetFactory);
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
construct<ItemTypeType extends ApiEnumItemType>(itemType: ItemTypeType, options: CollectionOptions<ItemTypeType>, transaction: TransactionCache, initialItemEntries: Array<ItemEntry<ItemTypeType>>, childCollectionResourceMap: ParentItemMap<CollectionResource> | null): CollectionResource<ItemTypeType>;
|
|
15
18
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApiEnumItemType, ApiFields } from '@rentman/backend-types';
|
|
2
|
-
import { ApiFormatter, ColumnUtil, ErrorHandlerInterface, ExceptionHandlerInterface, ItemEntry, ItemResource, PromiseLibraryInterface, TransactionCache } from '../internal';
|
|
2
|
+
import { ApiFormatter, ChildCollectionResourcesNull, ColumnUtil, ErrorHandlerInterface, ExceptionHandlerInterface, ItemEntry, ItemResource, PromiseLibraryInterface, TransactionCache } from '../internal';
|
|
3
3
|
export declare class ItemResourceFactory {
|
|
4
4
|
apiFormatter: ApiFormatter;
|
|
5
5
|
errorHandler: ErrorHandlerInterface;
|
|
@@ -7,5 +7,5 @@ export declare class ItemResourceFactory {
|
|
|
7
7
|
exceptionHandler: ExceptionHandlerInterface;
|
|
8
8
|
columnUtil: ColumnUtil;
|
|
9
9
|
constructor(apiFormatter: ApiFormatter, errorHandler: ErrorHandlerInterface, promiseService: PromiseLibraryInterface, exceptionHandler: ExceptionHandlerInterface, columnUtil: ColumnUtil);
|
|
10
|
-
construct<ItemTypeType extends ApiEnumItemType, ColumnIds extends Array<keyof ApiFields[ItemTypeType]> = Array<keyof ApiFields[ItemTypeType]
|
|
10
|
+
construct<ItemTypeType extends ApiEnumItemType, ColumnIds extends Array<keyof ApiFields[ItemTypeType]> = Array<keyof ApiFields[ItemTypeType]>, Children extends ChildCollectionResourcesNull = any>(itemEntry: ItemEntry<ItemTypeType>, transaction: TransactionCache, childCollections: Children, isNew?: boolean): ItemResource<ItemTypeType, ColumnIds, Children>;
|
|
11
11
|
}
|
|
@@ -1,23 +1,42 @@
|
|
|
1
1
|
import { ApiEnumItemType, ApiFields } from '@rentman/backend-types';
|
|
2
|
-
import { ApiQuery, ApiRequestColumns, ApiRequestLimit, CollectionResource, EntryParentNull, FieldChangeCallback, ItemResource } from '../internal';
|
|
3
|
-
export declare type
|
|
4
|
-
export declare type CollectionResourceOnAddCallback<ItemTypeType extends ApiEnumItemType, ColumnIds extends Array<keyof ApiFields[ItemTypeType]> = Array<keyof ApiFields[ItemTypeType]
|
|
5
|
-
export declare type
|
|
6
|
-
|
|
2
|
+
import { ApiQuery, ApiRequestColumns, ApiRequestLimit, ChildCollectionResourcesNull, CollectionResource, EntryParentNull, FieldChangeCallback, ItemResource } from '../internal';
|
|
3
|
+
export declare type CollectionResourceOnRemoveCallback<ItemTypeType extends ApiEnumItemType, ColumnIds extends Array<keyof ApiFields[ItemTypeType]> = Array<keyof ApiFields[ItemTypeType]>, Children extends ChildCollectionResourcesNull = any> = (itemResources: Array<ItemResource<ItemTypeType, ColumnIds, Children>>, collectionResource: CollectionResource<ItemTypeType, ColumnIds, Children>, isCalledAfterSocketUpdate: boolean) => void;
|
|
4
|
+
export declare type CollectionResourceOnAddCallback<ItemTypeType extends ApiEnumItemType, ColumnIds extends Array<keyof ApiFields[ItemTypeType]> = Array<keyof ApiFields[ItemTypeType]>, Children extends ChildCollectionResourcesNull = any> = (itemResources: Array<ItemResource<ItemTypeType, ColumnIds, Children>>, collectionResource: CollectionResource<ItemTypeType, ColumnIds, Children>, isInitialCall: boolean, isCalledAfterSocketUpdate: boolean) => void;
|
|
5
|
+
export declare type ChildCollectionOptions = {
|
|
6
|
+
[ChildItemType in ApiEnumItemType]?: CollectionOptions<ChildItemType>;
|
|
7
|
+
};
|
|
8
|
+
export interface CollectionOptionsInterface<ItemTypeType extends ApiEnumItemType = any, ColumnIds extends Array<keyof ApiFields[ItemTypeType]> = Array<keyof ApiFields[ItemTypeType]>> {
|
|
9
|
+
columns?: ApiRequestColumns;
|
|
10
|
+
query?: ApiQuery | null;
|
|
11
|
+
queryColumns?: ApiRequestColumns;
|
|
12
|
+
parent?: EntryParentNull;
|
|
13
|
+
limit?: ApiRequestLimit | null;
|
|
14
|
+
onAdd?: CollectionResourceOnAddCallback<ItemTypeType, ColumnIds>;
|
|
15
|
+
onRemove?: CollectionResourceOnRemoveCallback<ItemTypeType, ColumnIds>;
|
|
16
|
+
onChange?: FieldChangeCallback;
|
|
17
|
+
custom?: any;
|
|
18
|
+
callOnAddWithInitialItems?: boolean;
|
|
19
|
+
children?: {
|
|
20
|
+
[ChildItemType in ApiEnumItemType]?: CollectionOptionsInterface<ChildItemType>;
|
|
21
|
+
} | null;
|
|
22
|
+
preventCaching?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare class CollectionOptions<ItemTypeType extends ApiEnumItemType = any, ColumnIds extends Array<keyof ApiFields[ItemTypeType]> = Array<keyof ApiFields[ItemTypeType]>> implements Required<CollectionOptionsInterface> {
|
|
7
25
|
columns: ApiRequestColumns;
|
|
8
26
|
query: ApiQuery | null;
|
|
9
27
|
queryColumns: ApiRequestColumns;
|
|
10
28
|
parent: EntryParentNull;
|
|
11
29
|
limit: ApiRequestLimit | null;
|
|
12
30
|
onAdd: CollectionResourceOnAddCallback<ItemTypeType, ColumnIds>;
|
|
13
|
-
onRemove:
|
|
31
|
+
onRemove: CollectionResourceOnRemoveCallback<ItemTypeType, ColumnIds>;
|
|
14
32
|
onChange: FieldChangeCallback;
|
|
15
33
|
custom: any;
|
|
16
34
|
callOnAddWithInitialItems: boolean;
|
|
35
|
+
children: ChildCollectionOptions | null;
|
|
17
36
|
/**
|
|
18
37
|
* @description
|
|
19
38
|
* Prevents a CachedQueryItem from being cached (the CollectionResource will still be cached), you can use this when you fetch an Itemtype for which the backend doesn't send socket messages (so it never automatically updates)
|
|
20
39
|
*/
|
|
21
40
|
preventCaching: boolean;
|
|
22
|
-
constructor(
|
|
41
|
+
constructor(optionsInterface: CollectionOptionsInterface<ItemTypeType, ColumnIds>);
|
|
23
42
|
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { ApiEnumItemType, ApiFields, ItemId } from '@rentman/backend-types';
|
|
2
|
-
import { ApiRequestLimit, ChangesDeltaResult, CollectionEntry, CollectionOptions, CollectionResourceFactory, CompareFieldCallback, DeregFunction, FieldMap, ItemEntry, ItemResource,
|
|
3
|
-
export declare class CollectionResource<ItemTypeType extends ApiEnumItemType = any, ColumnIds extends Array<keyof ApiFields[ItemTypeType]> = Array<keyof ApiFields[ItemTypeType]
|
|
2
|
+
import { ApiRequestLimit, ChangesDeltaResult, ChildCollectionResourcesNull, CollectionEntry, CollectionOptions, CollectionResourceFactory, CompareFieldCallback, DeregFunction, FieldMap, ItemEntry, ItemResource, OnAddCallback, OnChangeCallback, OnRemoveCallback, PromiseInterface, ResponseColumnItemTypeMap, TransactionCache } from '../internal';
|
|
3
|
+
export declare class CollectionResource<ItemTypeType extends ApiEnumItemType = any, ColumnIds extends Array<keyof ApiFields[ItemTypeType]> = Array<keyof ApiFields[ItemTypeType]>, Children extends ChildCollectionResourcesNull = any> {
|
|
4
4
|
protected factory: CollectionResourceFactory;
|
|
5
5
|
options: CollectionOptions<ItemTypeType, ColumnIds>;
|
|
6
6
|
transaction: TransactionCache;
|
|
7
7
|
entry: CollectionEntry<ItemTypeType, ColumnIds>;
|
|
8
8
|
columns: ResponseColumnItemTypeMap;
|
|
9
|
-
items: Array<ItemResource<ItemTypeType, ColumnIds>>;
|
|
10
|
-
protected itemIdMap:
|
|
9
|
+
items: Array<ItemResource<ItemTypeType, ColumnIds, Children>>;
|
|
10
|
+
protected itemIdMap: {
|
|
11
|
+
[itemId: number]: ItemResource<ItemTypeType, ColumnIds, Children>;
|
|
12
|
+
};
|
|
11
13
|
private fieldChangeDeregFns;
|
|
12
14
|
private readonly onChangeCallbacks;
|
|
13
15
|
private readonly onAddCallbacks;
|
|
@@ -17,7 +19,7 @@ export declare class CollectionResource<ItemTypeType extends ApiEnumItemType = a
|
|
|
17
19
|
* We store the ItemIds of the items that were taking out the collections so that we can include those when doing a not-in when having a limit
|
|
18
20
|
*/
|
|
19
21
|
private removedItemIds;
|
|
20
|
-
constructor(factory: CollectionResourceFactory, options: CollectionOptions<ItemTypeType, ColumnIds>, transaction: TransactionCache, itemType: ItemTypeType, initialItemEntries: Array<ItemEntry<ItemTypeType
|
|
22
|
+
constructor(factory: CollectionResourceFactory, options: CollectionOptions<ItemTypeType, ColumnIds>, transaction: TransactionCache, itemType: ItemTypeType, initialItemEntries: Array<ItemEntry<ItemTypeType>>, childCollectionResourceMap: Children);
|
|
21
23
|
onConstruct(): void;
|
|
22
24
|
/**
|
|
23
25
|
* @description
|
|
@@ -25,9 +27,9 @@ export declare class CollectionResource<ItemTypeType extends ApiEnumItemType = a
|
|
|
25
27
|
*/
|
|
26
28
|
refresh(): PromiseInterface<void>;
|
|
27
29
|
setLimit(newLimit: number | ApiRequestLimit): void;
|
|
28
|
-
onAdd(callback: OnAddCallback<ItemTypeType, ColumnIds>): DeregFunction;
|
|
30
|
+
onAdd(callback: OnAddCallback<ItemTypeType, ColumnIds, Children>): DeregFunction;
|
|
29
31
|
onChange(callback: OnChangeCallback<ItemTypeType, ColumnIds>): DeregFunction;
|
|
30
|
-
onRemove(callback: OnRemoveCallback<ItemTypeType, ColumnIds>): DeregFunction;
|
|
32
|
+
onRemove(callback: OnRemoveCallback<ItemTypeType, ColumnIds, Children>): DeregFunction;
|
|
31
33
|
__clear(): void;
|
|
32
34
|
/**
|
|
33
35
|
* @deprecated
|
|
@@ -39,26 +41,37 @@ export declare class CollectionResource<ItemTypeType extends ApiEnumItemType = a
|
|
|
39
41
|
addItems(valuesArray: Array<Partial<FieldMap<ItemTypeType, ColumnIds>>>): PromiseInterface<ChangesDeltaResult>;
|
|
40
42
|
addItem(values: Partial<FieldMap<ItemTypeType>>): PromiseInterface<ChangesDeltaResult>;
|
|
41
43
|
getIdArray(): ItemId[];
|
|
42
|
-
getItemById(itemId: ItemId): ItemResource<ItemTypeType, ColumnIds>;
|
|
43
|
-
|
|
44
|
+
getItemById(itemId: ItemId): ItemResource<ItemTypeType, ColumnIds, Children>;
|
|
45
|
+
/**
|
|
46
|
+
* Creates item resources and adds them to the `items` array.
|
|
47
|
+
* @param itemEntriesToBeAdded
|
|
48
|
+
*/
|
|
49
|
+
addItemEntries(itemEntriesToBeAdded: Array<ItemEntry<ItemTypeType>>, isInitialCall?: boolean, isCalledAfterSocketUpdate?: boolean): PromiseInterface<Array<ItemResource<ItemTypeType, ColumnIds, Children>>>;
|
|
50
|
+
/**
|
|
51
|
+
* Creates item resources and adds them to the `items` array. This function is also called when the collection
|
|
52
|
+
* resource is constructed. When adding item resources to the collection externally, {@link addItemEntries} should
|
|
53
|
+
* be called.
|
|
54
|
+
* @param itemEntriesToBeAdded - These item entries are assumed not to be in the collection yet.
|
|
55
|
+
*/
|
|
56
|
+
private addItemResources;
|
|
44
57
|
/**
|
|
45
58
|
* @description
|
|
46
59
|
* Returns the {@link ItemResource ItemResources} that where removed from the {@link CollectionResource collection}.
|
|
47
60
|
* Filters on {@link ItemResource ItemResource}.{@link ItemEntry entry} === {@link ItemEntry entry}
|
|
48
61
|
*/
|
|
49
|
-
removeItemResources(itemEntries: Array<ItemEntry<ItemTypeType>>, isCalledAfterSocketUpdate: boolean): Array<ItemResource<ItemTypeType, ColumnIds>>;
|
|
50
|
-
callOnAdd(itemResources: Array<ItemResource<ItemTypeType, ColumnIds>>, isInitialCall?: boolean, isCalledAfterSocketUpdate?: boolean): void;
|
|
62
|
+
removeItemResources(itemEntries: Array<ItemEntry<ItemTypeType>>, isCalledAfterSocketUpdate: boolean): Array<ItemResource<ItemTypeType, ColumnIds, Children>>;
|
|
63
|
+
callOnAdd(itemResources: Array<ItemResource<ItemTypeType, ColumnIds, Children>>, isInitialCall?: boolean, isCalledAfterSocketUpdate?: boolean): void;
|
|
51
64
|
callOnChange(itemEntry: ItemEntry<ItemTypeType>, compareField: CompareFieldCallback<FieldMap<ItemTypeType, ColumnIds>>, fields: FieldMap<ItemTypeType, ColumnIds>, isCalledAfterSocketUpdate: boolean, previous: FieldMap<ItemTypeType, ColumnIds>): void;
|
|
52
|
-
callOnRemove(itemResources: Array<ItemResource<ItemTypeType, ColumnIds>>, isCalledAfterSocketUpdate: boolean): void;
|
|
53
|
-
forEach(callback: (itemResource: ItemResource<ItemTypeType, ColumnIds>) => void): void;
|
|
54
|
-
filter(callback: (itemResource: ItemResource<ItemTypeType, ColumnIds>) => boolean): Array<ItemResource<ItemTypeType, ColumnIds>>;
|
|
55
|
-
first(callback: (itemResource: ItemResource<ItemTypeType, ColumnIds>) => boolean): ItemResource<ItemTypeType, ColumnIds> | null;
|
|
56
|
-
some(callback: (itemResource: ItemResource<ItemTypeType, ColumnIds>) => boolean): boolean;
|
|
57
|
-
groupBy(argument: string | ((itemResource: ItemResource<ItemTypeType, ColumnIds>) => string | null)): {
|
|
58
|
-
[key: string]: Array<ItemResource<ItemTypeType, ColumnIds>>;
|
|
65
|
+
callOnRemove(itemResources: Array<ItemResource<ItemTypeType, ColumnIds, Children>>, isCalledAfterSocketUpdate: boolean): void;
|
|
66
|
+
forEach(callback: (itemResource: ItemResource<ItemTypeType, ColumnIds, Children>) => void): void;
|
|
67
|
+
filter(callback: (itemResource: ItemResource<ItemTypeType, ColumnIds, Children>) => boolean): Array<ItemResource<ItemTypeType, ColumnIds, Children>>;
|
|
68
|
+
first(callback: (itemResource: ItemResource<ItemTypeType, ColumnIds, Children>) => boolean): ItemResource<ItemTypeType, ColumnIds, Children> | null;
|
|
69
|
+
some(callback: (itemResource: ItemResource<ItemTypeType, ColumnIds, Children>) => boolean): boolean;
|
|
70
|
+
groupBy(argument: string | ((itemResource: ItemResource<ItemTypeType, ColumnIds, Children>) => string | null)): {
|
|
71
|
+
[key: string]: Array<ItemResource<ItemTypeType, ColumnIds, Children>>;
|
|
59
72
|
};
|
|
60
|
-
map<U>(argument: string | ((itemResource: ItemResource<ItemTypeType, ColumnIds>) => U)): U[];
|
|
61
|
-
reduce<U>(callback: (itemResource: ItemResource<ItemTypeType, ColumnIds>, value: U) => U, value: U): U;
|
|
73
|
+
map<U>(argument: string | ((itemResource: ItemResource<ItemTypeType, ColumnIds, Children>) => U)): U[];
|
|
74
|
+
reduce<U>(callback: (itemResource: ItemResource<ItemTypeType, ColumnIds, Children>, value: U) => U, value: U): U;
|
|
62
75
|
/**
|
|
63
76
|
* @description
|
|
64
77
|
* Removes the reference to the {@link CollectionResource CollectionResource} from the {@link CollectionEntry CollectionEntry}
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { ApiEnumItemType, ApiFields } from '@rentman/backend-types';
|
|
2
|
-
import { EntryParentNull, ExtractApiItemType, FieldMap, ItemEntry, ItemResourceFactory, PromiseInterface, ResponseColumnMap, TransactionCache } from '../internal';
|
|
3
|
-
export declare
|
|
2
|
+
import { CollectionResource, EntryParentNull, ExtractApiItemType, FieldMap, ItemEntry, ItemResourceFactory, PromiseInterface, ResponseColumnMap, TransactionCache } from '../internal';
|
|
3
|
+
export declare type ChildCollectionResources = {
|
|
4
|
+
[ChildItemType in ApiEnumItemType]?: CollectionResource<ChildItemType>;
|
|
5
|
+
};
|
|
6
|
+
export declare type ChildCollectionResourcesNull = ChildCollectionResources | null;
|
|
7
|
+
export declare class ItemResource<ItemTypeType extends ApiEnumItemType = any, ColumnIds extends Array<keyof ApiFields[ItemTypeType]> = Array<keyof ApiFields[ItemTypeType]>, Children extends ChildCollectionResourcesNull = any> {
|
|
4
8
|
protected readonly factory: ItemResourceFactory;
|
|
5
9
|
readonly entry: ItemEntry<ItemTypeType>;
|
|
6
|
-
protected readonly _isNew: boolean;
|
|
7
10
|
protected readonly transaction: TransactionCache;
|
|
11
|
+
children: Children;
|
|
12
|
+
private readonly _isNew;
|
|
8
13
|
columns: ResponseColumnMap<ItemTypeType, ColumnIds>;
|
|
9
14
|
fields: FieldMap<ItemTypeType, ColumnIds>;
|
|
10
15
|
initial: Readonly<FieldMap<ItemTypeType, ColumnIds>>;
|
|
11
|
-
constructor(factory: ItemResourceFactory, entry: ItemEntry<ItemTypeType>,
|
|
16
|
+
constructor(factory: ItemResourceFactory, entry: ItemEntry<ItemTypeType>, transaction: TransactionCache, children: Children, _isNew: boolean);
|
|
12
17
|
onConstruct(): void;
|
|
13
18
|
/**
|
|
14
19
|
* @description
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ApiEnumApiType, ApiEnumApiTypeTsTypeMapping, ApiEnumItemType, ApiFields, ApiQuery as BackendApiQuery, ApiQueryConditionComparator as BackendTypesApiQueryConditionComparator, ApiQueryConditionComparatorShort as BackendApiQueryConditionComparatorShort, ApiQueryConditionCustom, ApiQueryConditionIn, ApiQueryConditionInShort, ApiQueryConditionLinkedTo, ApiQueryConditionSearch, ApiQueryConditionSubQuery, GetColumnType, ItemId } from '@rentman/backend-types';
|
|
2
2
|
import moment from 'moment';
|
|
3
|
-
import { ApiResponseProcessor, CollectionOptions, CollectionResource, ColumnSet, ItemEntry, ItemEntryOptionsInterface, ItemResource, RequestColumnExpansion } from '../internal';
|
|
3
|
+
import { ApiResponseProcessor, ChildCollectionResourcesNull, CollectionOptions, CollectionResource, ColumnSet, ItemEntry, ItemEntryOptionsInterface, ItemResource, RequestColumnExpansion } from '../internal';
|
|
4
4
|
export declare type ApiEnumApiTypeToTsTypeMap = {
|
|
5
5
|
[ApiEnumApiType.TYPE_TOKEN]: string;
|
|
6
6
|
[ApiEnumApiType.TYPE_ID]: number;
|
|
@@ -182,9 +182,6 @@ export interface FunctionChangesResolveSocketMessage extends SocketMessage {
|
|
|
182
182
|
[key: string]: any;
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
|
-
export declare type ItemResourceItemIdMap<T extends ItemResource = ItemResource> = {
|
|
186
|
-
[itemId: number]: T;
|
|
187
|
-
};
|
|
188
185
|
export declare type ItemResourcesItemTypeMap<T extends ItemResource = ItemResource> = {
|
|
189
186
|
[itemType: string]: T[];
|
|
190
187
|
};
|
|
@@ -193,6 +190,11 @@ export declare type ItemMap<T> = {
|
|
|
193
190
|
[itemId: string]: T;
|
|
194
191
|
};
|
|
195
192
|
};
|
|
193
|
+
export declare type ParentItemMap<T> = {
|
|
194
|
+
[parentId: number]: {
|
|
195
|
+
[itemType: string]: T;
|
|
196
|
+
};
|
|
197
|
+
};
|
|
196
198
|
export declare type ItemEntryMap<ItemTypeType extends ApiEnumItemType = any> = ItemMap<ItemEntry<ItemTypeType>>;
|
|
197
199
|
export declare type ItemEntryParentIdMap<ItemTypeType extends ApiEnumItemType> = ParentIdMap<Array<ItemEntry<ItemTypeType>>>;
|
|
198
200
|
export declare type ConversionMap = {
|
|
@@ -313,19 +315,17 @@ export declare type FieldChangeCallback<ItemTypeType extends ApiEnumItemType = a
|
|
|
313
315
|
export declare type DeregFunction = () => void;
|
|
314
316
|
export declare type OnChangeCallbackArgs<ItemTypeType extends ApiEnumItemType = any, ColumnIds extends Array<keyof ApiFields[ItemTypeType]> = Array<keyof ApiFields[ItemTypeType]>> = FieldChangeCallbackArgs<ItemTypeType, ColumnIds>;
|
|
315
317
|
export declare type OnChangeCallback<ItemTypeType extends ApiEnumItemType = any, ColumnIds extends Array<keyof ApiFields[ItemTypeType]> = Array<keyof ApiFields[ItemTypeType]>> = FieldChangeCallback<ItemTypeType, ColumnIds>;
|
|
316
|
-
export declare type
|
|
317
|
-
itemResources: Array<ItemResource<ItemTypeType, ColumnIds>>;
|
|
318
|
-
collectionResource: CollectionResource<ItemTypeType, ColumnIds>;
|
|
318
|
+
export declare type OnAddCallback<ItemTypeType extends ApiEnumItemType, ColumnIds extends Array<keyof ApiFields[ItemTypeType]>, Children extends ChildCollectionResourcesNull> = (args: {
|
|
319
|
+
itemResources: Array<ItemResource<ItemTypeType, ColumnIds, Children>>;
|
|
320
|
+
collectionResource: CollectionResource<ItemTypeType, ColumnIds, Children>;
|
|
319
321
|
isInitialCall: boolean;
|
|
320
322
|
isCalledAfterSocketUpdate: boolean;
|
|
321
|
-
};
|
|
322
|
-
export declare type
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
collectionResource: CollectionResource<ItemTypeType, ColumnIds>;
|
|
323
|
+
}) => void;
|
|
324
|
+
export declare type OnRemoveCallback<ItemTypeType extends ApiEnumItemType, ColumnIds extends Array<keyof ApiFields[ItemTypeType]>, Children extends ChildCollectionResourcesNull> = (args: {
|
|
325
|
+
itemResources: Array<ItemResource<ItemTypeType, ColumnIds, Children>>;
|
|
326
|
+
collectionResource: CollectionResource<ItemTypeType, ColumnIds, Children>;
|
|
326
327
|
isCalledAfterSocketUpdate: boolean;
|
|
327
|
-
};
|
|
328
|
-
export declare type OnRemoveCallback<ItemTypeType extends ApiEnumItemType = any, ColumnIds extends Array<keyof ApiFields[ItemTypeType]> = Array<keyof ApiFields[ItemTypeType]>> = (args: OnRemoveCallbackArgs<ItemTypeType, ColumnIds>) => void;
|
|
328
|
+
}) => void;
|
|
329
329
|
/************************************/
|
|
330
330
|
export declare type ApiQueryConditionComparatorShort<ItemTypeType extends ApiEnumItemType = any, ColumnId extends keyof ApiFields[ItemTypeType] = any> = BackendApiQueryConditionComparatorShort<ItemTypeType, ColumnId> & {
|
|
331
331
|
[_T in ColumnId]: 'NOW' | ApiEnumApiTypeTsTypeMapping[ExtractApiType<ApiFields[ItemTypeType][ColumnId]>];
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rentman/rm-core",
|
|
3
|
-
"version": "8.1
|
|
3
|
+
"version": "8.2.1",
|
|
4
4
|
"description": "Rentman core functionalities",
|
|
5
5
|
"main": "./dist/rm-core.js",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@rentman/backend-types": "
|
|
8
|
+
"@rentman/backend-types": "*",
|
|
9
9
|
"@babel/runtime": "^7.8.3"
|
|
10
10
|
},
|
|
11
11
|
"repository": {
|