@rentman/rm-core 4.0.1 → 4.0.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.
Files changed (109) hide show
  1. package/changelog.md +692 -685
  2. package/dist/rm-core.js +9521 -9468
  3. package/dist/rm-core.min.js +2 -2
  4. package/dist/types/classes/ApiFormatter.d.ts +55 -55
  5. package/dist/types/classes/ApiRequestService.d.ts +20 -20
  6. package/dist/types/classes/ApiResponseProcessor.d.ts +31 -31
  7. package/dist/types/classes/ChangesCompilation.d.ts +34 -34
  8. package/dist/types/classes/ChangesDelta.d.ts +59 -59
  9. package/dist/types/classes/ChangesDeltaBase.d.ts +50 -50
  10. package/dist/types/classes/ChangesProcessor.d.ts +47 -47
  11. package/dist/types/classes/CollectionCache.d.ts +38 -38
  12. package/dist/types/classes/CollectionEntryService.d.ts +25 -25
  13. package/dist/types/classes/CollectionMatcher.d.ts +9 -9
  14. package/dist/types/classes/CollectionMatcherBase.d.ts +26 -26
  15. package/dist/types/classes/CollectionResourceService.d.ts +6 -6
  16. package/dist/types/classes/ColumnCache.d.ts +21 -21
  17. package/dist/types/classes/ColumnExpansion.d.ts +22 -22
  18. package/dist/types/classes/ColumnHandler.d.ts +21 -21
  19. package/dist/types/classes/ColumnInfo.d.ts +14 -14
  20. package/dist/types/classes/ColumnSet.d.ts +39 -39
  21. package/dist/types/classes/ColumnSubsetCache.d.ts +8 -8
  22. package/dist/types/classes/ColumnUtil.d.ts +99 -99
  23. package/dist/types/classes/ConversionMapService.d.ts +27 -27
  24. package/dist/types/classes/CreateRequest.d.ts +19 -19
  25. package/dist/types/classes/CreatedChangesDelta.d.ts +15 -15
  26. package/dist/types/classes/InternalChangesDelta.d.ts +39 -39
  27. package/dist/types/classes/ItemCache.d.ts +29 -29
  28. package/dist/types/classes/ItemCreateService.d.ts +24 -24
  29. package/dist/types/classes/ItemEntryService.d.ts +34 -34
  30. package/dist/types/classes/KeyService.d.ts +16 -16
  31. package/dist/types/classes/LockService.d.ts +32 -32
  32. package/dist/types/classes/ModuleChangesCompilation.d.ts +18 -18
  33. package/dist/types/classes/QueryColumnExtractor.d.ts +20 -20
  34. package/dist/types/classes/QueryLocalLinkedToParser.d.ts +17 -0
  35. package/dist/types/classes/QueryMatcher.d.ts +14 -14
  36. package/dist/types/classes/QueryParser.d.ts +25 -25
  37. package/dist/types/classes/QueryParserBase.d.ts +29 -29
  38. package/dist/types/classes/QueryService.d.ts +17 -14
  39. package/dist/types/classes/RequestBuffer.d.ts +28 -28
  40. package/dist/types/classes/RequestBufferManager.d.ts +24 -24
  41. package/dist/types/classes/RequestColumnExpansion.d.ts +15 -15
  42. package/dist/types/classes/SocketMessageHandler.d.ts +31 -31
  43. package/dist/types/classes/TemplateCache.d.ts +66 -66
  44. package/dist/types/classes/Util.d.ts +30 -30
  45. package/dist/types/classes/cache/AbstractCache.d.ts +101 -101
  46. package/dist/types/classes/cache/CollectionHandlerBase.d.ts +68 -68
  47. package/dist/types/classes/cache/CollectionMatcherCacheProcessor.d.ts +26 -26
  48. package/dist/types/classes/cache/ItemHandlerBase.d.ts +95 -95
  49. package/dist/types/classes/cache/server/ServerCache.d.ts +83 -83
  50. package/dist/types/classes/cache/server/ServerCollectionHandler.d.ts +44 -44
  51. package/dist/types/classes/cache/server/ServerItemHandler.d.ts +51 -51
  52. package/dist/types/classes/cache/transaction/TransactionCache.d.ts +336 -336
  53. package/dist/types/classes/cache/transaction/TransactionCollectionHandler.d.ts +62 -62
  54. package/dist/types/classes/cache/transaction/TransactionEventHandler.d.ts +24 -24
  55. package/dist/types/classes/cache/transaction/TransactionItemHandler.d.ts +90 -90
  56. package/dist/types/classes/cache/transaction/TransactionValidator.d.ts +28 -28
  57. package/dist/types/classes/index.d.ts +46 -46
  58. package/dist/types/constants.d.ts +7 -7
  59. package/dist/types/core.d.ts +52 -52
  60. package/dist/types/factories/ApiResponseProcessorFactory.d.ts +6 -6
  61. package/dist/types/factories/ChangesCompilationFactory.d.ts +6 -6
  62. package/dist/types/factories/ChangesDeltaFactory.d.ts +11 -11
  63. package/dist/types/factories/ChangesProcessorFactory.d.ts +22 -22
  64. package/dist/types/factories/CollectionCacheFactory.d.ts +8 -8
  65. package/dist/types/factories/CollectionEntryFactory.d.ts +11 -11
  66. package/dist/types/factories/CollectionMatcherFactory.d.ts +9 -9
  67. package/dist/types/factories/CollectionResourceFactory.d.ts +16 -16
  68. package/dist/types/factories/ColumnExpansionFactory.d.ts +8 -8
  69. package/dist/types/factories/ColumnInfoFactory.d.ts +7 -7
  70. package/dist/types/factories/ColumnSetFactory.d.ts +19 -19
  71. package/dist/types/factories/ColumnSubsetCacheFactory.d.ts +6 -6
  72. package/dist/types/factories/CreateRequestFactory.d.ts +11 -11
  73. package/dist/types/factories/ItemCacheFactory.d.ts +8 -8
  74. package/dist/types/factories/ItemEntryFactory.d.ts +15 -15
  75. package/dist/types/factories/ItemResourceFactory.d.ts +14 -14
  76. package/dist/types/factories/ModuleChangesCompilationFactory.d.ts +5 -5
  77. package/dist/types/factories/QueryMatcherFactory.d.ts +7 -7
  78. package/dist/types/factories/QueryParserFactory.d.ts +6 -6
  79. package/dist/types/factories/RequestColumnExpansionFactory.d.ts +6 -6
  80. package/dist/types/factories/TemplateFactory.d.ts +10 -10
  81. package/dist/types/factories/TransactionCacheFactory.d.ts +15 -15
  82. package/dist/types/factories/index.d.ts +22 -22
  83. package/dist/types/index.d.ts +7 -7
  84. package/dist/types/interfaces/AbstractCacheDependencyInterface.d.ts +44 -44
  85. package/dist/types/interfaces/ApiRequestServiceInterface.d.ts +11 -11
  86. package/dist/types/interfaces/AuthInterface.d.ts +9 -9
  87. package/dist/types/interfaces/ErrorHandlerInterface.d.ts +5 -5
  88. package/dist/types/interfaces/ExceptionHandlerInterface.d.ts +3 -3
  89. package/dist/types/interfaces/LinkTreeServiceInterface.d.ts +4 -4
  90. package/dist/types/interfaces/PromiseLibraryInterface.d.ts +25 -25
  91. package/dist/types/interfaces/ServerCacheDependencyInterface.d.ts +7 -7
  92. package/dist/types/interfaces/SocketMessageInterface.d.ts +3 -3
  93. package/dist/types/interfaces/TransactionCollectionHandlerDependencyInterface.d.ts +21 -20
  94. package/dist/types/interfaces/TransactionItemHandlerDependencyInterface.d.ts +26 -26
  95. package/dist/types/interfaces/index.d.ts +11 -11
  96. package/dist/types/models/CollectionEntry.d.ts +27 -27
  97. package/dist/types/models/CollectionEntryOptions.d.ts +13 -13
  98. package/dist/types/models/CollectionResource.d.ts +63 -63
  99. package/dist/types/models/CollectionResourceOptions.d.ts +23 -23
  100. package/dist/types/models/ItemEntry.d.ts +19 -19
  101. package/dist/types/models/ItemEntryOptions.d.ts +8 -8
  102. package/dist/types/models/ItemResource.d.ts +84 -84
  103. package/dist/types/models/Template.d.ts +11 -11
  104. package/dist/types/models/index.d.ts +8 -8
  105. package/dist/types/types/ItemTypesCollection.d.ts +263 -263
  106. package/dist/types/types/PromiseInterface.d.ts +2 -2
  107. package/dist/types/types/index.d.ts +2 -2
  108. package/package.json +36 -36
  109. package/readme.md +15 -15
@@ -1,66 +1,66 @@
1
- import { RequestColumnExpansionFactory, TemplateFactory } from '../factories';
2
- import { ErrorHandlerInterface, PromiseLibraryInterface } from '../interfaces';
3
- import { Template } from '../models';
4
- import { EntryParentNull, ItemId, ItemType, PromiseInterface } from '../types';
5
- import { ApiRequestService } from './ApiRequestService';
6
- import { ColumnHandler } from './ColumnHandler';
7
- import { ColumnUtil } from './ColumnUtil';
8
- export declare class TemplateCache {
9
- private columnUtil;
10
- private promiseService;
11
- private columnHandler;
12
- private templateFactory;
13
- private errorHandler;
14
- private requestColumnExpansionFactory;
15
- private apiRequestService;
16
- private pendingTemplateBufferMap;
17
- templates: {
18
- [itemType: string]: Template<any>;
19
- };
20
- constructor(columnUtil: ColumnUtil, promiseService: PromiseLibraryInterface, columnHandler: ColumnHandler, templateFactory: TemplateFactory, errorHandler: ErrorHandlerInterface, requestColumnExpansionFactory: RequestColumnExpansionFactory, apiRequestService: ApiRequestService);
21
- /**
22
- * @description
23
- * Fetches a {@link Template template}, {@link TransactionItemHandler.createItems TransactionItemHandler.createItems} is a convenience function for this
24
- *
25
- * @param itemType The {@link ItemType ItemType} of the template item
26
- * @param itemId Used for caching, multiple concurrent template calls for the same itemId will return the same template
27
- * @param templateOptions
28
- * @param templateColumns Additional columns to be fetched, will be stored in the template - warning - the Template won't have values for those columns
29
- * @param entryParentOrParentItemType An optional {@link EntryParentNull entry parent} or {@link ItemType parent itemType}, if the parent is passed the templateColumns will be expanded with the proper link columns (Through {@link ColumnUtil.getColumnsFromLink ColumnUtil.getColumnsFromLink})
30
- *
31
- * @example
32
- * ```
33
- * const parent: EntryParent = {
34
- * itemType: 'Functie',
35
- * itemId: 10,
36
- * };
37
- *
38
- * return core.templateCache
39
- * .fetchTemplate(
40
- * 'Planningpersoneel',
41
- * undefined,
42
- * {},
43
- * {},
44
- * parent,
45
- * )
46
- * .then(
47
- * (template: Template<'Planningpersoneel'>) => {
48
- * const changesDelta = transaction.createChangesDelta();
49
- *
50
- * for (const itemResource of selectedItems) {
51
- * changesDelta.setItemCreated(
52
- * core.keyService.getLocalId(),
53
- * template.fields,
54
- * template.columns,
55
- * parent,
56
- * );
57
- * }
58
- *
59
- * transaction.applyChangesDelta(changesDelta);
60
- * );
61
- * ```
62
- */
63
- fetchTemplate<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemId?: ItemId, templateOptions?: any, templateColumns?: any, entryParentOrParentItemType?: EntryParentNull | ItemType): PromiseInterface<Template<ItemTypeType>>;
64
- private fetchTemplateById;
65
- private constructTemplateBuffer;
66
- }
1
+ import { RequestColumnExpansionFactory, TemplateFactory } from '../factories';
2
+ import { ErrorHandlerInterface, PromiseLibraryInterface } from '../interfaces';
3
+ import { Template } from '../models';
4
+ import { EntryParentNull, ItemId, ItemType, PromiseInterface } from '../types';
5
+ import { ApiRequestService } from './ApiRequestService';
6
+ import { ColumnHandler } from './ColumnHandler';
7
+ import { ColumnUtil } from './ColumnUtil';
8
+ export declare class TemplateCache {
9
+ private columnUtil;
10
+ private promiseService;
11
+ private columnHandler;
12
+ private templateFactory;
13
+ private errorHandler;
14
+ private requestColumnExpansionFactory;
15
+ private apiRequestService;
16
+ private pendingTemplateBufferMap;
17
+ templates: {
18
+ [itemType: string]: Template<any>;
19
+ };
20
+ constructor(columnUtil: ColumnUtil, promiseService: PromiseLibraryInterface, columnHandler: ColumnHandler, templateFactory: TemplateFactory, errorHandler: ErrorHandlerInterface, requestColumnExpansionFactory: RequestColumnExpansionFactory, apiRequestService: ApiRequestService);
21
+ /**
22
+ * @description
23
+ * Fetches a {@link Template template}, {@link TransactionItemHandler.createItems TransactionItemHandler.createItems} is a convenience function for this
24
+ *
25
+ * @param itemType The {@link ItemType ItemType} of the template item
26
+ * @param itemId Used for caching, multiple concurrent template calls for the same itemId will return the same template
27
+ * @param templateOptions
28
+ * @param templateColumns Additional columns to be fetched, will be stored in the template - warning - the Template won't have values for those columns
29
+ * @param entryParentOrParentItemType An optional {@link EntryParentNull entry parent} or {@link ItemType parent itemType}, if the parent is passed the templateColumns will be expanded with the proper link columns (Through {@link ColumnUtil.getColumnsFromLink ColumnUtil.getColumnsFromLink})
30
+ *
31
+ * @example
32
+ * ```
33
+ * const parent: EntryParent = {
34
+ * itemType: 'Functie',
35
+ * itemId: 10,
36
+ * };
37
+ *
38
+ * return core.templateCache
39
+ * .fetchTemplate(
40
+ * 'Planningpersoneel',
41
+ * undefined,
42
+ * {},
43
+ * {},
44
+ * parent,
45
+ * )
46
+ * .then(
47
+ * (template: Template<'Planningpersoneel'>) => {
48
+ * const changesDelta = transaction.createChangesDelta();
49
+ *
50
+ * for (const itemResource of selectedItems) {
51
+ * changesDelta.setItemCreated(
52
+ * core.keyService.getLocalId(),
53
+ * template.fields,
54
+ * template.columns,
55
+ * parent,
56
+ * );
57
+ * }
58
+ *
59
+ * transaction.applyChangesDelta(changesDelta);
60
+ * );
61
+ * ```
62
+ */
63
+ fetchTemplate<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemId?: ItemId, templateOptions?: any, templateColumns?: any, entryParentOrParentItemType?: EntryParentNull | ItemType): PromiseInterface<Template<ItemTypeType>>;
64
+ private fetchTemplateById;
65
+ private constructTemplateBuffer;
66
+ }
@@ -1,30 +1,30 @@
1
- import { PromiseInterface } from '../types';
2
- export declare function instantiateOptions(options: {
3
- [key: string]: any;
4
- }, values: object): void;
5
- export declare function shallowMerge(object: any, defaults: any): any;
6
- export declare function hasProperties(object: any): boolean;
7
- export declare function getFirstProperty(object: any): string | null;
8
- export declare function inArray(needle: any, haystack: any): boolean;
9
- export declare function filterArray<T>(source: T[], callback: (elem: T) => boolean): boolean;
10
- export declare function emptyArray(array: any): void;
11
- export declare function pathExists(source: any, path: any): boolean;
12
- export declare function createPath<T>(object: any, path: Array<number | string>, defaults: any[]): T;
13
- export declare function getPath(object: {}, path: Array<number | string>, create?: boolean): any;
14
- export declare function extend(dst: any, ...args: any[]): any;
15
- export declare function merge(dst: any, ...args: any[]): any;
16
- export declare function isObject(value: any): boolean;
17
- export declare function isBlankObject(value: any): boolean;
18
- export declare function isString(value: any): boolean;
19
- export declare function isNumber(value: any): boolean;
20
- export declare function isDate(value: any): boolean;
21
- export declare const isArray: (arg: any) => arg is any[];
22
- export declare function isFunction<T>(value: any): value is T;
23
- export declare function isPromiseLike<T = any>(obj: any): obj is PromiseInterface<T>;
24
- export declare function isRegExp(value: any): boolean;
25
- export declare function isBoolean(value: any): boolean;
26
- export declare function isElement(node: any): boolean;
27
- export declare function isWindow(obj: any): boolean;
28
- export declare function isDefined(value: any): boolean;
29
- export declare function equals(o1: any, o2: any): boolean;
30
- export declare function copy(source: any, destination?: any, maxDepth?: any): any;
1
+ import { PromiseInterface } from '../types';
2
+ export declare function instantiateOptions(options: {
3
+ [key: string]: any;
4
+ }, values: object): void;
5
+ export declare function shallowMerge(object: any, defaults: any): any;
6
+ export declare function hasProperties(object: any): boolean;
7
+ export declare function getFirstProperty(object: any): string | null;
8
+ export declare function inArray(needle: any, haystack: any): boolean;
9
+ export declare function filterArray<T>(source: T[], callback: (elem: T) => boolean): boolean;
10
+ export declare function emptyArray(array: any): void;
11
+ export declare function pathExists(source: any, path: any): boolean;
12
+ export declare function createPath<T>(object: any, path: Array<number | string>, defaults: any[]): T;
13
+ export declare function getPath(object: {}, path: Array<number | string>, create?: boolean): any;
14
+ export declare function extend(dst: any, ...args: any[]): any;
15
+ export declare function merge(dst: any, ...args: any[]): any;
16
+ export declare function isObject(value: any): boolean;
17
+ export declare function isBlankObject(value: any): boolean;
18
+ export declare function isString(value: any): boolean;
19
+ export declare function isNumber(value: any): boolean;
20
+ export declare function isDate(value: any): boolean;
21
+ export declare const isArray: (arg: any) => arg is any[];
22
+ export declare function isFunction<T>(value: any): value is T;
23
+ export declare function isPromiseLike<T = any>(obj: any): obj is PromiseInterface<T>;
24
+ export declare function isRegExp(value: any): boolean;
25
+ export declare function isBoolean(value: any): boolean;
26
+ export declare function isElement(node: any): boolean;
27
+ export declare function isWindow(obj: any): boolean;
28
+ export declare function isDefined(value: any): boolean;
29
+ export declare function equals(o1: any, o2: any): boolean;
30
+ export declare function copy(source: any, destination?: any, maxDepth?: any): any;
@@ -1,101 +1,101 @@
1
- import { RmCore } from '../../core';
2
- import { AbstractCacheDependencyInterface } from '../../interfaces';
3
- import { CollectionEntry, ItemEntry } from '../../models';
4
- import { EntryParentNull, FieldMap, ItemIdConversionMap, ItemType, PromiseInterface } from '../../types';
5
- import { ChangesDelta } from '../ChangesDelta';
6
- import { ChangesDeltaResult } from '../ChangesDeltaBase';
7
- import { OnAfterCreateCallback } from '../ChangesProcessor';
8
- import { CollectionCache } from '../CollectionCache';
9
- import { InternalChangesDelta } from '../InternalChangesDelta';
10
- import { ItemCache } from '../ItemCache';
11
- import { ServerCache } from './server/ServerCache';
12
- import { ServerCollectionHandler } from './server/ServerCollectionHandler';
13
- import { ServerItemEntryChanges, ServerItemHandler } from './server/ServerItemHandler';
14
- import { TransactionCache } from './transaction/TransactionCache';
15
- import { TransactionCollectionHandler } from './transaction/TransactionCollectionHandler';
16
- import { TransactionItemEntryChanges, TransactionItemHandler } from './transaction/TransactionItemHandler';
17
- import { TransactionValidatorFactory } from './transaction/TransactionValidator';
18
- export declare abstract class AbstractCache {
19
- protected dependencies: AbstractCacheDependencyInterface;
20
- core: RmCore;
21
- children: TransactionCache[];
22
- readonly itemHandler: TransactionItemHandler | ServerItemHandler;
23
- readonly collectionHandler: TransactionCollectionHandler | ServerCollectionHandler;
24
- parent: AbstractCache | null;
25
- protected constructor(dependencies: AbstractCacheDependencyInterface, core: RmCore);
26
- createChild(id?: string, validatorFactory?: TransactionValidatorFactory): TransactionCache;
27
- onChildDestroy(cache: TransactionCache): void;
28
- abstract getLocalCollectionEntryByQueryString(itemType: ItemType, queryString: string): CollectionEntry | undefined;
29
- /**
30
- * @description
31
- * Returns {@link ItemEntry ItemEntries} that fit the collection's query, copies over the collectionChanges on all transactions in the chain.
32
- */
33
- abstract getCollectionChangesRecursively(collectionEntryId: CollectionEntry['id']): ItemEntry[];
34
- /**
35
- * @description
36
- * Returns this transaction and all parents
37
- */
38
- getTransactionChain(): AbstractCache[];
39
- /**
40
- * @description
41
- * Returns the {@link TransactionCollectionHandler.entries CollectionCache} of the transaction
42
- */
43
- getCurrentCollectionEntryCache(): CollectionCache;
44
- /**
45
- * @description
46
- * Returns the {@link TransactionItemHandler.entries ItemCache} of the transaction
47
- */
48
- getCurrentItemEntryCache(): ItemCache;
49
- abstract getServerCache(): ServerCache;
50
- abstract getLocalItemEntry(itemEntryId: ItemEntry['id']): ItemEntry | undefined;
51
- abstract getLocalItemEntryByItemId(itemType: ItemType, itemId: ItemEntry['itemId']): ItemEntry | undefined;
52
- abstract getLocalCollectionEntry(collectionEntryId: CollectionEntry['id']): CollectionEntry | undefined;
53
- /**
54
- * @description
55
- * Applies changes from a child transaction to a parent
56
- */
57
- abstract applyChangesFromChild(transaction: TransactionCache, breakUpByParent?: boolean, onAfterCreateCallback?: OnAfterCreateCallback): PromiseInterface<ItemIdConversionMap>;
58
- /**
59
- * @description
60
- * Called by a parent transaction, propagates changes downwards to all child caches
61
- *
62
- * @remarks
63
- * - Should only be used by the core
64
- *
65
- * todo[cache] Should we refetch derived values just like in applyChangesDelta ?
66
- *
67
- * @internal
68
- */
69
- abstract applyChangesFromParent(internalChangesDelta: InternalChangesDelta, isCalledAfterApiSave: boolean, isCalledAfterSocketUpdate: boolean): void;
70
- abstract getParent<ItemTypeType extends ItemType = any>(itemEntry: ItemEntry<ItemTypeType>, fromInitial?: boolean, providedFields?: FieldMap<ItemTypeType>): EntryParentNull;
71
- abstract getItemChangesRecursively(itemEntryId: ItemEntry['id'], copyFields?: boolean): FieldMap;
72
- abstract getLocalItemEntryChangesTuple(itemEntryId: ItemEntry['id']): any;
73
- /**
74
- * @description
75
- * Because the `itemChanges` object differs between the {@link ServerItemHandler.itemChanges ServerItemHandler} and the {@link TransactionItemHandler.itemChanges TransactionItemHandler} we need a function to normalise those values
76
- *
77
- * @remarks
78
- * - Should only be used by the core
79
- *
80
- * @internal
81
- */
82
- abstract getChangesFromItemChanges<ItemTypeType extends ItemType = any>(changesObject: ServerItemEntryChanges<ItemTypeType> | TransactionItemEntryChanges<ItemTypeType>): FieldMap<ItemTypeType>;
83
- abstract applyChangesDelta(changesDelta: ChangesDelta): PromiseInterface<ChangesDeltaResult>;
84
- protected getParentFromFields<ItemTypeType extends ItemType = any>(itemEntry: ItemEntry<ItemTypeType>, fields: FieldMap<ItemTypeType>): EntryParentNull;
85
- /**
86
- * @description
87
- * Called by applyChangesDelta from ServerCache and TransactionCache. Applies creates, updates and moves, doesn't apply deletes
88
- *
89
- * @private
90
- */
91
- protected _applyChangesDelta(changesDelta: ChangesDelta): {
92
- result: ChangesDeltaResult;
93
- internalChangesDelta: InternalChangesDelta;
94
- rollbackFunctions: Array<(changesDelta: ChangesDelta) => void>;
95
- };
96
- /**
97
- * @description
98
- * Ensures that for all updated items in the delta the required derived values are present
99
- */
100
- protected fetchUpdatedDerivedValuesFromDelta(changesDelta: ChangesDelta): PromiseInterface<ItemEntry[][]>;
101
- }
1
+ import { RmCore } from '../../core';
2
+ import { AbstractCacheDependencyInterface } from '../../interfaces';
3
+ import { CollectionEntry, ItemEntry } from '../../models';
4
+ import { EntryParentNull, FieldMap, ItemIdConversionMap, ItemType, PromiseInterface } from '../../types';
5
+ import { ChangesDelta } from '../ChangesDelta';
6
+ import { ChangesDeltaResult } from '../ChangesDeltaBase';
7
+ import { OnAfterCreateCallback } from '../ChangesProcessor';
8
+ import { CollectionCache } from '../CollectionCache';
9
+ import { InternalChangesDelta } from '../InternalChangesDelta';
10
+ import { ItemCache } from '../ItemCache';
11
+ import { ServerCache } from './server/ServerCache';
12
+ import { ServerCollectionHandler } from './server/ServerCollectionHandler';
13
+ import { ServerItemEntryChanges, ServerItemHandler } from './server/ServerItemHandler';
14
+ import { TransactionCache } from './transaction/TransactionCache';
15
+ import { TransactionCollectionHandler } from './transaction/TransactionCollectionHandler';
16
+ import { TransactionItemEntryChanges, TransactionItemHandler } from './transaction/TransactionItemHandler';
17
+ import { TransactionValidatorFactory } from './transaction/TransactionValidator';
18
+ export declare abstract class AbstractCache {
19
+ protected dependencies: AbstractCacheDependencyInterface;
20
+ core: RmCore;
21
+ children: TransactionCache[];
22
+ readonly itemHandler: TransactionItemHandler | ServerItemHandler;
23
+ readonly collectionHandler: TransactionCollectionHandler | ServerCollectionHandler;
24
+ parent: AbstractCache | null;
25
+ protected constructor(dependencies: AbstractCacheDependencyInterface, core: RmCore);
26
+ createChild(id?: string, validatorFactory?: TransactionValidatorFactory): TransactionCache;
27
+ onChildDestroy(cache: TransactionCache): void;
28
+ abstract getLocalCollectionEntryByQueryString(itemType: ItemType, queryString: string): CollectionEntry | undefined;
29
+ /**
30
+ * @description
31
+ * Returns {@link ItemEntry ItemEntries} that fit the collection's query, copies over the collectionChanges on all transactions in the chain.
32
+ */
33
+ abstract getCollectionChangesRecursively(collectionEntryId: CollectionEntry['id']): ItemEntry[];
34
+ /**
35
+ * @description
36
+ * Returns this transaction and all parents
37
+ */
38
+ getTransactionChain(): AbstractCache[];
39
+ /**
40
+ * @description
41
+ * Returns the {@link TransactionCollectionHandler.entries CollectionCache} of the transaction
42
+ */
43
+ getCurrentCollectionEntryCache(): CollectionCache;
44
+ /**
45
+ * @description
46
+ * Returns the {@link TransactionItemHandler.entries ItemCache} of the transaction
47
+ */
48
+ getCurrentItemEntryCache(): ItemCache;
49
+ abstract getServerCache(): ServerCache;
50
+ abstract getLocalItemEntry(itemEntryId: ItemEntry['id']): ItemEntry | undefined;
51
+ abstract getLocalItemEntryByItemId(itemType: ItemType, itemId: ItemEntry['itemId']): ItemEntry | undefined;
52
+ abstract getLocalCollectionEntry(collectionEntryId: CollectionEntry['id']): CollectionEntry | undefined;
53
+ /**
54
+ * @description
55
+ * Applies changes from a child transaction to a parent
56
+ */
57
+ abstract applyChangesFromChild(transaction: TransactionCache, breakUpByParent?: boolean, onAfterCreateCallback?: OnAfterCreateCallback): PromiseInterface<ItemIdConversionMap>;
58
+ /**
59
+ * @description
60
+ * Called by a parent transaction, propagates changes downwards to all child caches
61
+ *
62
+ * @remarks
63
+ * - Should only be used by the core
64
+ *
65
+ * todo[cache] Should we refetch derived values just like in applyChangesDelta ?
66
+ *
67
+ * @internal
68
+ */
69
+ abstract applyChangesFromParent(internalChangesDelta: InternalChangesDelta, isCalledAfterApiSave: boolean, isCalledAfterSocketUpdate: boolean): void;
70
+ abstract getParent<ItemTypeType extends ItemType = any>(itemEntry: ItemEntry<ItemTypeType>, fromInitial?: boolean, providedFields?: FieldMap<ItemTypeType>): EntryParentNull;
71
+ abstract getItemChangesRecursively(itemEntryId: ItemEntry['id'], copyFields?: boolean): FieldMap;
72
+ abstract getLocalItemEntryChangesTuple(itemEntryId: ItemEntry['id']): any;
73
+ /**
74
+ * @description
75
+ * Because the `itemChanges` object differs between the {@link ServerItemHandler.itemChanges ServerItemHandler} and the {@link TransactionItemHandler.itemChanges TransactionItemHandler} we need a function to normalise those values
76
+ *
77
+ * @remarks
78
+ * - Should only be used by the core
79
+ *
80
+ * @internal
81
+ */
82
+ abstract getChangesFromItemChanges<ItemTypeType extends ItemType = any>(changesObject: ServerItemEntryChanges<ItemTypeType> | TransactionItemEntryChanges<ItemTypeType>): FieldMap<ItemTypeType>;
83
+ abstract applyChangesDelta(changesDelta: ChangesDelta): PromiseInterface<ChangesDeltaResult>;
84
+ protected getParentFromFields<ItemTypeType extends ItemType = any>(itemEntry: ItemEntry<ItemTypeType>, fields: FieldMap<ItemTypeType>): EntryParentNull;
85
+ /**
86
+ * @description
87
+ * Called by applyChangesDelta from ServerCache and TransactionCache. Applies creates, updates and moves, doesn't apply deletes
88
+ *
89
+ * @private
90
+ */
91
+ protected _applyChangesDelta(changesDelta: ChangesDelta): {
92
+ result: ChangesDeltaResult;
93
+ internalChangesDelta: InternalChangesDelta;
94
+ rollbackFunctions: Array<(changesDelta: ChangesDelta) => void>;
95
+ };
96
+ /**
97
+ * @description
98
+ * Ensures that for all updated items in the delta the required derived values are present
99
+ */
100
+ protected fetchUpdatedDerivedValuesFromDelta(changesDelta: ChangesDelta): PromiseInterface<ItemEntry[][]>;
101
+ }
@@ -1,68 +1,68 @@
1
- import { CollectionCacheFactory, RequestColumnExpansionFactory } from '../../factories';
2
- import { CollectionEntry, CollectionEntryOptions, ItemEntry } from '../../models';
3
- import { ApiQuery, ApiRequestColumn, CollectionEntryParentIdMap, CollectionResourceParentIdMap, ItemId, ItemType, PromiseInterface, QueryCallback } from '../../types';
4
- import { CollectionCache } from '../CollectionCache';
5
- import { CollectionEntryService } from '../CollectionEntryService';
6
- import { CollectionMatcher } from '../CollectionMatcher';
7
- import { ColumnUtil } from '../ColumnUtil';
8
- import { AbstractCache } from './AbstractCache';
9
- export declare abstract class CollectionHandlerBase {
10
- protected collectionEntryService: CollectionEntryService;
11
- protected columnUtil: ColumnUtil;
12
- protected requestColumnExpansionFactory: RequestColumnExpansionFactory;
13
- protected transaction: AbstractCache;
14
- entries: CollectionCache;
15
- collectionChanges: {
16
- [itemType: string]: {
17
- [queryString: string]: ItemEntry[];
18
- };
19
- };
20
- protected constructor(collectionEntryService: CollectionEntryService, columnUtil: ColumnUtil, requestColumnExpansionFactory: RequestColumnExpansionFactory, collectionCacheFactory: CollectionCacheFactory, transaction: AbstractCache);
21
- setCollectionChanges<ItemTypeType extends ItemType>(itemType: ItemTypeType, queryString: string, itemEntries: Array<ItemEntry<ItemTypeType>>): void;
22
- getCollectionChanges<ItemTypeType extends ItemType>(itemType: ItemTypeType, queryString: string): undefined | Array<ItemEntry<ItemTypeType>>;
23
- /**
24
- * @description
25
- * Creates a new {@link CollectionEntry CollectionEntry} and stores it in this transaction's {@link CollectionCache CollectionCache}
26
- */
27
- createCollectionEntry<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionEntryOptions): CollectionEntry<ItemTypeType>;
28
- /**
29
- * @description
30
- * Creates a {@link CollectionMatcher CollectionMatcher} with the transaction's collections
31
- */
32
- abstract getCollectionMatcher(): CollectionMatcher;
33
- /**
34
- * @description
35
- * Fetches a {@link CollectionEntry CollectionEntry} with the given options
36
- */
37
- abstract fetchCollectionEntry<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionEntryOptions): PromiseInterface<CollectionEntry<ItemTypeType>>;
38
- /**
39
- * @description
40
- * Fetches collections linked to the passed parents
41
- */
42
- abstract fetchLinkedCollectionEntries<ItemTypeType extends ItemType>(parentType: ItemType, parentIdArray: ItemId[] | (() => ItemId[]), itemType: ItemTypeType, options: CollectionEntryOptions): PromiseInterface<CollectionEntryParentIdMap<ItemTypeType>>;
43
- /**
44
- * @description
45
- * Expands the items in the collections with the passed columns
46
- */
47
- abstract expandCollectionEntries<ItemTypeType extends ItemType>(parentType: ItemType, itemType: ItemTypeType, collections: CollectionResourceParentIdMap, newColumns: ApiRequestColumn[]): PromiseInterface<CollectionResourceParentIdMap>;
48
- /**
49
- * @description
50
- * Extends the collections' {@link CollectionEntry.queryParams queryParams} and {@link CollectionEntry.query queries} and fetches the {@link ItemEntry ItemEntries} with the new queries
51
- */
52
- abstract extendCollectionEntries<T extends CollectionResourceParentIdMap>(parentType: ItemType, itemType: ItemType, options: CollectionEntryOptions, queryCallback: QueryCallback, collections: T): PromiseInterface<void>;
53
- /**
54
- * @description
55
- * Adds the passed {@link ItemEntry ItemEntries} to the collection's changes on the transaction,
56
- * will skip the ItemEntry if the `skipEntryFilterFn` callback returns `true`
57
- */
58
- protected _addItemEntriesToCollectionChanges<CollectionEntryType extends CollectionEntry>(collectionEntry: CollectionEntryType, itemEntries: Array<ItemEntry<CollectionEntryType['itemType']>>, skipEntryFilterFn: (temEntry: ItemEntry) => boolean, isCalledAfterSocketUpdate: boolean): void;
59
- protected abstract handleAddedItemEntriesCallback<CollectionEntryType extends CollectionEntry>(collectionEntry: CollectionEntryType, addedEntries: Array<ItemEntry<CollectionEntryType['itemType']>>, isCalledAfterSocketUpdate: boolean): void;
60
- removeItemEntriesFromCollectionChanges(collectionEntry: CollectionEntry, idArray: ItemId[], isCalledAfterSocketUpdate?: boolean): void | never[];
61
- protected abstract handleRemovedItemEntriesCallback<CollectionEntryType extends CollectionEntry>(collectionEntry: CollectionEntryType, removedItemEntries: Array<ItemEntry<CollectionEntryType['itemType']>>, isCalledAfterSocketUpdate: boolean): void;
62
- /**
63
- * @description
64
- * Expands the option's {@link CollectionEntryOptions.columns columns} with the columns required for the {@link CollectionMatcher CollectionMatcher} to function.
65
- * Data fetched for a parent transaction might also fit in a child transaction, so those {@link CollectionEntryOptions.queryColumns queryColumns} should also be taken into account
66
- */
67
- protected expandColumnsWithQueryColumns(itemType: ItemType, options: CollectionEntryOptions, query: ApiQuery): void;
68
- }
1
+ import { CollectionCacheFactory, RequestColumnExpansionFactory } from '../../factories';
2
+ import { CollectionEntry, CollectionEntryOptions, ItemEntry } from '../../models';
3
+ import { ApiQuery, ApiRequestColumn, CollectionEntryParentIdMap, CollectionResourceParentIdMap, ItemId, ItemType, PromiseInterface, QueryCallback } from '../../types';
4
+ import { CollectionCache } from '../CollectionCache';
5
+ import { CollectionEntryService } from '../CollectionEntryService';
6
+ import { CollectionMatcher } from '../CollectionMatcher';
7
+ import { ColumnUtil } from '../ColumnUtil';
8
+ import { AbstractCache } from './AbstractCache';
9
+ export declare abstract class CollectionHandlerBase {
10
+ protected collectionEntryService: CollectionEntryService;
11
+ protected columnUtil: ColumnUtil;
12
+ protected requestColumnExpansionFactory: RequestColumnExpansionFactory;
13
+ protected transaction: AbstractCache;
14
+ entries: CollectionCache;
15
+ collectionChanges: {
16
+ [itemType: string]: {
17
+ [queryString: string]: ItemEntry[];
18
+ };
19
+ };
20
+ protected constructor(collectionEntryService: CollectionEntryService, columnUtil: ColumnUtil, requestColumnExpansionFactory: RequestColumnExpansionFactory, collectionCacheFactory: CollectionCacheFactory, transaction: AbstractCache);
21
+ setCollectionChanges<ItemTypeType extends ItemType>(itemType: ItemTypeType, queryString: string, itemEntries: Array<ItemEntry<ItemTypeType>>): void;
22
+ getCollectionChanges<ItemTypeType extends ItemType>(itemType: ItemTypeType, queryString: string): undefined | Array<ItemEntry<ItemTypeType>>;
23
+ /**
24
+ * @description
25
+ * Creates a new {@link CollectionEntry CollectionEntry} and stores it in this transaction's {@link CollectionCache CollectionCache}
26
+ */
27
+ createCollectionEntry<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionEntryOptions): CollectionEntry<ItemTypeType>;
28
+ /**
29
+ * @description
30
+ * Creates a {@link CollectionMatcher CollectionMatcher} with the transaction's collections
31
+ */
32
+ abstract getCollectionMatcher(): CollectionMatcher;
33
+ /**
34
+ * @description
35
+ * Fetches a {@link CollectionEntry CollectionEntry} with the given options
36
+ */
37
+ abstract fetchCollectionEntry<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionEntryOptions): PromiseInterface<CollectionEntry<ItemTypeType>>;
38
+ /**
39
+ * @description
40
+ * Fetches collections linked to the passed parents
41
+ */
42
+ abstract fetchLinkedCollectionEntries<ItemTypeType extends ItemType>(parentType: ItemType, parentIdArray: ItemId[] | (() => ItemId[]), itemType: ItemTypeType, options: CollectionEntryOptions): PromiseInterface<CollectionEntryParentIdMap<ItemTypeType>>;
43
+ /**
44
+ * @description
45
+ * Expands the items in the collections with the passed columns
46
+ */
47
+ abstract expandCollectionEntries<ItemTypeType extends ItemType>(parentType: ItemType, itemType: ItemTypeType, collections: CollectionResourceParentIdMap, newColumns: ApiRequestColumn[]): PromiseInterface<CollectionResourceParentIdMap>;
48
+ /**
49
+ * @description
50
+ * Extends the collections' {@link CollectionEntry.queryParams queryParams} and {@link CollectionEntry.query queries} and fetches the {@link ItemEntry ItemEntries} with the new queries
51
+ */
52
+ abstract extendCollectionEntries<T extends CollectionResourceParentIdMap>(parentType: ItemType, itemType: ItemType, options: CollectionEntryOptions, queryCallback: QueryCallback, collections: T): PromiseInterface<void>;
53
+ /**
54
+ * @description
55
+ * Adds the passed {@link ItemEntry ItemEntries} to the collection's changes on the transaction,
56
+ * will skip the ItemEntry if the `skipEntryFilterFn` callback returns `true`
57
+ */
58
+ protected _addItemEntriesToCollectionChanges<CollectionEntryType extends CollectionEntry>(collectionEntry: CollectionEntryType, itemEntries: Array<ItemEntry<CollectionEntryType['itemType']>>, skipEntryFilterFn: (temEntry: ItemEntry) => boolean, isCalledAfterSocketUpdate: boolean): void;
59
+ protected abstract handleAddedItemEntriesCallback<CollectionEntryType extends CollectionEntry>(collectionEntry: CollectionEntryType, addedEntries: Array<ItemEntry<CollectionEntryType['itemType']>>, isCalledAfterSocketUpdate: boolean): void;
60
+ removeItemEntriesFromCollectionChanges(collectionEntry: CollectionEntry, idArray: ItemId[], isCalledAfterSocketUpdate?: boolean): void | never[];
61
+ protected abstract handleRemovedItemEntriesCallback<CollectionEntryType extends CollectionEntry>(collectionEntry: CollectionEntryType, removedItemEntries: Array<ItemEntry<CollectionEntryType['itemType']>>, isCalledAfterSocketUpdate: boolean): void;
62
+ /**
63
+ * @description
64
+ * Expands the option's {@link CollectionEntryOptions.columns columns} with the columns required for the {@link CollectionMatcher CollectionMatcher} to function.
65
+ * Data fetched for a parent transaction might also fit in a child transaction, so those {@link CollectionEntryOptions.queryColumns queryColumns} should also be taken into account
66
+ */
67
+ protected expandColumnsWithQueryColumns(itemType: ItemType, options: CollectionEntryOptions, query: ApiQuery): void;
68
+ }
@@ -1,26 +1,26 @@
1
- import { QueryMatcherFactory } from '../../factories';
2
- import { CollectionEntry, ItemEntry } from '../../models';
3
- import { ItemId, ItemType } from '../../types';
4
- import { ApiRequestService } from '../ApiRequestService';
5
- import { CollectionMatcher } from '../CollectionMatcher';
6
- import { AbstractCache } from './AbstractCache';
7
- export declare type GroupedCollectionMatcherResult<ItemTypeType extends ItemType> = {
8
- fitting: Array<ItemEntry<ItemTypeType>>;
9
- notFitting: ItemId[];
10
- maybe: Array<ItemEntry<ItemTypeType>>;
11
- };
12
- /**
13
- * @description
14
- * Processes a delta and adds the items to the right collections, this is the ONLY class that should change collection items
15
- *
16
- * ------
17
- *
18
- * @remark
19
- * The CollectionMatcherCacheProcessor is allowed to directly access/modify the transaction because it's ONLY called from applyChangesFromParent
20
- */
21
- export declare class CollectionMatcherCacheProcessor extends CollectionMatcher {
22
- private apiRequestService;
23
- constructor(apiRequestService: ApiRequestService, queryMatcherFactory: QueryMatcherFactory, transaction: AbstractCache, getCollectionEntries: (itemType: ItemType) => CollectionEntry[]);
24
- removeFromAndAddToCollections(isCalledAfterSocketUpdate?: boolean): void;
25
- private groupItemEntries;
26
- }
1
+ import { QueryMatcherFactory } from '../../factories';
2
+ import { CollectionEntry, ItemEntry } from '../../models';
3
+ import { ItemId, ItemType } from '../../types';
4
+ import { ApiRequestService } from '../ApiRequestService';
5
+ import { CollectionMatcher } from '../CollectionMatcher';
6
+ import { AbstractCache } from './AbstractCache';
7
+ export declare type GroupedCollectionMatcherResult<ItemTypeType extends ItemType> = {
8
+ fitting: Array<ItemEntry<ItemTypeType>>;
9
+ notFitting: ItemId[];
10
+ maybe: Array<ItemEntry<ItemTypeType>>;
11
+ };
12
+ /**
13
+ * @description
14
+ * Processes a delta and adds the items to the right collections, this is the ONLY class that should change collection items
15
+ *
16
+ * ------
17
+ *
18
+ * @remark
19
+ * The CollectionMatcherCacheProcessor is allowed to directly access/modify the transaction because it's ONLY called from applyChangesFromParent
20
+ */
21
+ export declare class CollectionMatcherCacheProcessor extends CollectionMatcher {
22
+ private apiRequestService;
23
+ constructor(apiRequestService: ApiRequestService, queryMatcherFactory: QueryMatcherFactory, transaction: AbstractCache, getCollectionEntries: (itemType: ItemType) => CollectionEntry[]);
24
+ removeFromAndAddToCollections(isCalledAfterSocketUpdate?: boolean): void;
25
+ private groupItemEntries;
26
+ }