@rentman/rm-core 66.1.7 → 66.1.8-children-query-as-function
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/dist/rm-core.js +1 -1
- package/dist/rm-core.js.map +1 -1
- package/dist/types/src/classes/cache/CachedQueryHandlerBase.d.ts +1 -0
- package/dist/types/src/classes/cache/transaction/TransactionCache.d.ts +0 -1
- package/dist/types/src/classes/cache/transaction/TransactionCachedQueryHandler.d.ts +14 -11
- package/dist/types/src/models/CollectionOptions.d.ts +3 -2
- package/package.json +1 -1
|
@@ -10,6 +10,7 @@ export interface ParentCachedQueryItemTuple<ItemTypeType extends ApiItemType> {
|
|
|
10
10
|
readonly cachedQueryItem: CachedQueryItem<ItemTypeType>;
|
|
11
11
|
readonly options: CollectionOptions<ItemTypeType>;
|
|
12
12
|
children: CachedQueryItemsItemTypeTuple<ApiItemType>[] | null;
|
|
13
|
+
readonly parentItemId?: ItemId;
|
|
13
14
|
}
|
|
14
15
|
export interface CachedQueryItemTuple<ItemTypeType extends ApiItemType> extends ParentCachedQueryItemTuple<ItemTypeType> {
|
|
15
16
|
children: null;
|
|
@@ -369,7 +369,6 @@ export declare class TransactionCache extends AbstractCache {
|
|
|
369
369
|
clearItemError(itemEntryId: ItemEntry['id'], columnId?: string, errorKey?: string): void;
|
|
370
370
|
clearItemError(itemEntryId: ItemEntry['id'], columnId: string, errorKey?: string): void;
|
|
371
371
|
clearItemError(itemEntryId: ItemEntry['id'], columnId: string, errorKey: string): void;
|
|
372
|
-
private updateSignals;
|
|
373
372
|
/**
|
|
374
373
|
* This method:
|
|
375
374
|
* - calls changes listeners for single items;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { ApiItemType, ItemId } from '@rentman/backend-types';
|
|
2
|
-
import { ApiQuery, CachedQueryHandlerBase, CachedQueryHandlerCollectionTuple, CachedQueryItem, CachedQueryItemsItemTypeTuple, CachedQueryItemTuple, CachedQueryOptions, ChangesDeltaBase, ChildCollectionsOption, CollectionItemResourceChanges, CollectionOptions, CollectionQuery, CollectionResource, EntryParent, ItemIdConversionMap, LinkCollectionBatchQueryTuple, MatchesAccumulatorMap, MatchingResultsAccumulatorMapType, MatchingResultsAccumulatorTuple, ParentCachedQueryItemTuple, RequestColumnsOperationsCache, RequireOnly, TransactionCache, TransactionCollectionHandlerDependencyInterface } from '../../../internal';
|
|
2
|
+
import { ApiQuery, CachedQueryHandlerBase, CachedQueryHandlerCollectionTuple, CachedQueryItem, CachedQueryItemsItemTypeTuple, CachedQueryItemTuple, CachedQueryOptions, ChangesDeltaBase, ChildCollectionsOption, ChildrenQueryFunction, CollectionItemResourceChanges, CollectionOptions, CollectionQuery, CollectionResource, EntryParent, ItemIdConversionMap, LinkCollectionBatchQueryTuple, MatchesAccumulatorMap, MatchingResultsAccumulatorMapType, MatchingResultsAccumulatorTuple, ParentCachedQueryItemTuple, RequestColumnsOperationsCache, RequireOnly, TransactionCache, TransactionCollectionHandlerDependencyInterface } from '../../../internal';
|
|
3
3
|
import { RootQueryNode } from '../../matcher/RootQueryNode';
|
|
4
|
-
export interface LinkCollectionOptionsItemTypeTuple<ItemTypeType extends ApiItemType> {
|
|
5
|
-
itemType: ItemTypeType;
|
|
6
|
-
linkCollectionOptions: LinkCollectionOptionsTuple<ItemTypeType>;
|
|
7
|
-
}
|
|
8
4
|
interface CollectionQueryTuple<ItemTypeType extends ApiItemType> {
|
|
9
5
|
parsedQuery: CollectionQuery<ItemTypeType>;
|
|
10
6
|
options: CollectionOptions<ItemTypeType>;
|
|
11
7
|
}
|
|
12
|
-
interface
|
|
8
|
+
interface QueryCallbackCollectionOptionsTuple<ItemTypeType extends ApiItemType> {
|
|
13
9
|
collectionQueryTuples: CollectionQueryTuple<ItemTypeType>[];
|
|
10
|
+
parentItemIds: ItemId[];
|
|
11
|
+
batchQuery: CollectionQuery<ItemTypeType>;
|
|
12
|
+
}
|
|
13
|
+
export interface QueryCallbackCollectionOptionsItemTypeTuple<ItemTypeType extends ApiItemType> {
|
|
14
|
+
itemType: ItemTypeType;
|
|
15
|
+
queryCallbackCollectionOptions: QueryCallbackCollectionOptionsTuple<ItemTypeType>;
|
|
16
|
+
parentItemIds: ItemId[];
|
|
14
17
|
}
|
|
15
18
|
interface TransactionCachedQueryHandlerCollectionTuple<ItemTypeType extends ApiItemType> extends CachedQueryHandlerCollectionTuple<ItemTypeType> {
|
|
16
19
|
collectionResources?: WeakRef<CollectionResource<ItemTypeType, any, any>>[];
|
|
@@ -61,13 +64,14 @@ export declare class TransactionCachedQueryHandler extends CachedQueryHandlerBas
|
|
|
61
64
|
* Fetches collections linked to the passed parents
|
|
62
65
|
* @returns An array of cached query items. The items are in the same order as the parent IDs.
|
|
63
66
|
*/
|
|
64
|
-
__fetchLinkedCachedQueryItems<const ItemTypeType extends ApiItemType>(itemType: ItemTypeType, linkCollectionOptionsTuple: LinkCollectionOptionsTuple<ItemTypeType>): Promise<CachedQueryItemTuple<ItemTypeType>[]>;
|
|
65
67
|
createBatchLinkedToQuery<ItemTypeType extends ApiItemType>(parentItemType: ApiItemType, parentItemIds: ItemId[], additionalQuery?: ApiQuery<ItemTypeType>): CollectionQuery<ItemTypeType>;
|
|
68
|
+
private getOrCreateChildrenQueryFunction;
|
|
66
69
|
/**
|
|
67
70
|
* The order of the `collectionQueryTuples` property of the result will be the same as the order of
|
|
68
71
|
* `parentItemIds`.
|
|
69
72
|
*/
|
|
70
|
-
|
|
73
|
+
processCollectionOptions<ItemTypeType extends ApiItemType>(itemType: ItemTypeType, parentItemIds: ItemId[], queryFn: ChildrenQueryFunction<ItemTypeType>, bareOptions: CollectionOptions<ItemTypeType>): QueryCallbackCollectionOptionsTuple<ItemTypeType>;
|
|
74
|
+
__fetchCachedQueryItems<const ItemTypeType extends ApiItemType>(itemType: ItemTypeType, queryCallbackCollectionOptionsTuple: QueryCallbackCollectionOptionsTuple<ItemTypeType>): Promise<CachedQueryItemTuple<ItemTypeType>[]>;
|
|
71
75
|
__fetchParentCachedQueryItem<const ItemTypeType extends ApiItemType>(itemType: ItemTypeType, options: CollectionOptions<ItemTypeType>): Promise<ParentCachedQueryItemTuple<ItemTypeType>>;
|
|
72
76
|
__fetchChildCachedQueryItems(parentItemType: ApiItemType, parentItemIds: ItemId[], childCollectionOptions: ChildCollectionsOption): Promise<CachedQueryItemsItemTypeTuple<ApiItemType>[]>;
|
|
73
77
|
/**
|
|
@@ -77,8 +81,7 @@ export declare class TransactionCachedQueryHandler extends CachedQueryHandlerBas
|
|
|
77
81
|
* todo: Rename this method and {@link __fetchItemEntriesByQueryData} to something that's easier to understand.
|
|
78
82
|
*/
|
|
79
83
|
__fetchParentItemEntriesByQueryData<ItemTypeType extends ApiItemType>(itemType: ItemTypeType, options: CollectionOptions<ItemTypeType>, columnsOperationsCache: RequestColumnsOperationsCache<ItemTypeType>, collectionQuery: CollectionQuery<ItemTypeType>): Promise<ParentCachedQueryItemTuple<ItemTypeType>>;
|
|
80
|
-
private
|
|
81
|
-
fetchChildCachedQueryItems(linkCollectionOptionsItemTypeTuples: LinkCollectionOptionsItemTypeTuple<ApiItemType>[]): Promise<CachedQueryItemsItemTypeTuple<ApiItemType>[]>;
|
|
84
|
+
private fetchChildCachedQueryItems;
|
|
82
85
|
/**
|
|
83
86
|
* Updates the items included in cached queries and collection resources based on query matcher results. Note that
|
|
84
87
|
* method does not clear child collection resources of removed item resources.
|
|
@@ -94,7 +97,7 @@ export declare class TransactionCachedQueryHandler extends CachedQueryHandlerBas
|
|
|
94
97
|
* Sets the `children` property for each of the cached queries in `cachedQueryItemTuples`. Assumes the `children`
|
|
95
98
|
* *options* property is the same for all cached query items.
|
|
96
99
|
*
|
|
97
|
-
* The `children` property will remain `null` if
|
|
100
|
+
* The `children` property will remain `null` if the children option is unset.
|
|
98
101
|
*/
|
|
99
102
|
private resolveParentCachedQueryItems;
|
|
100
103
|
private resolveLocalCachedQueryItem;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ApiItemType } from '@rentman/backend-types';
|
|
1
|
+
import { ApiItemType, ItemId } from '@rentman/backend-types';
|
|
2
2
|
import { AggregatedChangesListener, ApiQuery, ApiRequestColumnArray, ApiRequestColumns, ChildCollectionResources, CollectionItemChangesListener, CollectionResource, EntryParent, ItemEntry, ItemResource, ItemTypeColumnId } from '../internal';
|
|
3
|
+
export type ChildrenQueryFunction<ItemType extends ApiItemType> = (parentItemIds: ItemId[]) => ApiQuery<ItemType>;
|
|
3
4
|
export interface CollectionResourceOrder<ItemTypeType extends ApiItemType> {
|
|
4
5
|
field: ItemTypeColumnId<ItemTypeType>;
|
|
5
6
|
order?: 'desc' | 'asc';
|
|
@@ -28,7 +29,7 @@ export type ChildCollectionsOption = {
|
|
|
28
29
|
* operations cache.
|
|
29
30
|
*/
|
|
30
31
|
export interface CachedQueryOptions<ItemType extends ApiItemType> {
|
|
31
|
-
query?: ApiQuery<ItemType>;
|
|
32
|
+
query?: ApiQuery<ItemType> | ChildrenQueryFunction<ItemType>;
|
|
32
33
|
parent?: EntryParent;
|
|
33
34
|
order?: CollectionResourceOrder<ItemType>;
|
|
34
35
|
/**
|