@rentman/rm-core 2.0.11 → 2.0.12

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 (107) hide show
  1. package/changelog.md +600 -595
  2. package/dist/rm-core.js +9348 -9342
  3. package/dist/rm-core.min.js +1 -1
  4. package/dist/src/classes/ApiFormatter.d.ts +55 -55
  5. package/dist/src/classes/ApiRequestService.d.ts +20 -20
  6. package/dist/src/classes/ApiResponseProcessor.d.ts +29 -29
  7. package/dist/src/classes/ChangesCompilation.d.ts +34 -34
  8. package/dist/src/classes/ChangesDelta.d.ts +42 -42
  9. package/dist/src/classes/ChangesDeltaBase.d.ts +33 -33
  10. package/dist/src/classes/ChangesProcessor.d.ts +47 -47
  11. package/dist/src/classes/CollectionCache.d.ts +37 -37
  12. package/dist/src/classes/CollectionEntryService.d.ts +25 -25
  13. package/dist/src/classes/CollectionMatcher.d.ts +9 -9
  14. package/dist/src/classes/CollectionMatcherBase.d.ts +26 -26
  15. package/dist/src/classes/CollectionResourceService.d.ts +6 -6
  16. package/dist/src/classes/ColumnCache.d.ts +21 -21
  17. package/dist/src/classes/ColumnExpansion.d.ts +22 -22
  18. package/dist/src/classes/ColumnHandler.d.ts +21 -21
  19. package/dist/src/classes/ColumnInfo.d.ts +14 -14
  20. package/dist/src/classes/ColumnSet.d.ts +39 -39
  21. package/dist/src/classes/ColumnSubsetCache.d.ts +8 -8
  22. package/dist/src/classes/ColumnUtil.d.ts +99 -99
  23. package/dist/src/classes/CreateRequest.d.ts +19 -19
  24. package/dist/src/classes/InternalChangesDelta.d.ts +38 -38
  25. package/dist/src/classes/ItemCache.d.ts +29 -29
  26. package/dist/src/classes/ItemEntryService.d.ts +41 -41
  27. package/dist/src/classes/KeyService.d.ts +16 -16
  28. package/dist/src/classes/LockService.d.ts +32 -32
  29. package/dist/src/classes/ModuleChangesCompilation.d.ts +18 -18
  30. package/dist/src/classes/QueryColumnExtractor.d.ts +20 -20
  31. package/dist/src/classes/QueryMatcher.d.ts +14 -14
  32. package/dist/src/classes/QueryParser.d.ts +25 -25
  33. package/dist/src/classes/QueryParserBase.d.ts +29 -29
  34. package/dist/src/classes/QueryService.d.ts +14 -14
  35. package/dist/src/classes/RequestBuffer.d.ts +25 -25
  36. package/dist/src/classes/RequestBufferManager.d.ts +31 -31
  37. package/dist/src/classes/RequestColumnExpansion.d.ts +15 -15
  38. package/dist/src/classes/SocketMessageHandler.d.ts +31 -31
  39. package/dist/src/classes/TemplateCache.d.ts +63 -63
  40. package/dist/src/classes/Util.d.ts +28 -28
  41. package/dist/src/classes/cache/AbstractCache.d.ts +140 -140
  42. package/dist/src/classes/cache/CollectionHandlerBase.d.ts +64 -64
  43. package/dist/src/classes/cache/CollectionMatcherCacheProcessor.d.ts +26 -26
  44. package/dist/src/classes/cache/ItemHandlerBase.d.ts +95 -95
  45. package/dist/src/classes/cache/server/ServerCache.d.ts +98 -98
  46. package/dist/src/classes/cache/server/ServerCollectionHandler.d.ts +43 -43
  47. package/dist/src/classes/cache/server/ServerItemHandler.d.ts +50 -50
  48. package/dist/src/classes/cache/transaction/TransactionCache.d.ts +412 -412
  49. package/dist/src/classes/cache/transaction/TransactionCollectionHandler.d.ts +72 -72
  50. package/dist/src/classes/cache/transaction/TransactionEventHandler.d.ts +19 -19
  51. package/dist/src/classes/cache/transaction/TransactionItemHandler.d.ts +114 -114
  52. package/dist/src/classes/index.d.ts +41 -41
  53. package/dist/src/constants.d.ts +7 -7
  54. package/dist/src/core.d.ts +49 -49
  55. package/dist/src/factories/ApiResponseProcessorFactory.d.ts +6 -6
  56. package/dist/src/factories/ChangesCompilationFactory.d.ts +6 -6
  57. package/dist/src/factories/ChangesDeltaFactory.d.ts +9 -9
  58. package/dist/src/factories/ChangesProcessorFactory.d.ts +22 -22
  59. package/dist/src/factories/CollectionCacheFactory.d.ts +8 -8
  60. package/dist/src/factories/CollectionEntryFactory.d.ts +11 -11
  61. package/dist/src/factories/CollectionMatcherFactory.d.ts +9 -9
  62. package/dist/src/factories/CollectionResourceFactory.d.ts +34 -34
  63. package/dist/src/factories/ColumnExpansionFactory.d.ts +8 -8
  64. package/dist/src/factories/ColumnInfoFactory.d.ts +7 -7
  65. package/dist/src/factories/ColumnSetFactory.d.ts +19 -19
  66. package/dist/src/factories/ColumnSubsetCacheFactory.d.ts +6 -6
  67. package/dist/src/factories/CreateRequestFactory.d.ts +11 -11
  68. package/dist/src/factories/ItemCacheFactory.d.ts +8 -8
  69. package/dist/src/factories/ItemEntryFactory.d.ts +17 -17
  70. package/dist/src/factories/ItemResourceFactory.d.ts +32 -32
  71. package/dist/src/factories/ModuleChangesCompilationFactory.d.ts +5 -5
  72. package/dist/src/factories/QueryMatcherFactory.d.ts +7 -7
  73. package/dist/src/factories/QueryParserFactory.d.ts +6 -6
  74. package/dist/src/factories/RequestColumnExpansionFactory.d.ts +6 -6
  75. package/dist/src/factories/TemplateFactory.d.ts +10 -10
  76. package/dist/src/factories/TransactionCacheFactory.d.ts +55 -55
  77. package/dist/src/factories/index.d.ts +22 -22
  78. package/dist/src/index.d.ts +7 -7
  79. package/dist/src/interfaces/ApiRequestServiceInterface.d.ts +11 -11
  80. package/dist/src/interfaces/AuthInterface.d.ts +9 -9
  81. package/dist/src/interfaces/ErrorHandlerInterface.d.ts +5 -5
  82. package/dist/src/interfaces/ExceptionHandlerInterface.d.ts +3 -3
  83. package/dist/src/interfaces/LinkTreeServiceInterface.d.ts +4 -4
  84. package/dist/src/interfaces/PromiseLibraryInterface.d.ts +25 -25
  85. package/dist/src/interfaces/SocketMessageInterface.d.ts +3 -3
  86. package/dist/src/interfaces/index.d.ts +7 -7
  87. package/dist/src/models/CollectionEditResource.d.ts +17 -17
  88. package/dist/src/models/CollectionEntry.d.ts +27 -27
  89. package/dist/src/models/CollectionEntryOptions.d.ts +13 -13
  90. package/dist/src/models/CollectionResource.d.ts +52 -52
  91. package/dist/src/models/CollectionResourceOptions.d.ts +27 -27
  92. package/dist/src/models/CollectionViewResource.d.ts +7 -7
  93. package/dist/src/models/EditResource.d.ts +16 -16
  94. package/dist/src/models/ItemEntry.d.ts +19 -19
  95. package/dist/src/models/ItemEntryOptions.d.ts +9 -9
  96. package/dist/src/models/ItemResource.d.ts +87 -87
  97. package/dist/src/models/ItemResourceOptions.d.ts +9 -9
  98. package/dist/src/models/LocalViewResource.d.ts +7 -7
  99. package/dist/src/models/RemoteViewResource.d.ts +7 -7
  100. package/dist/src/models/Template.d.ts +11 -11
  101. package/dist/src/models/ViewResource.d.ts +8 -8
  102. package/dist/src/models/index.d.ts +15 -15
  103. package/dist/src/types/ItemTypesCollection.d.ts +262 -262
  104. package/dist/src/types/PromiseInterface.d.ts +2 -2
  105. package/dist/src/types/index.d.ts +2 -2
  106. package/package.json +36 -36
  107. package/readme.md +15 -15
@@ -1,140 +1,140 @@
1
- import { RmCore } from '../../core';
2
- import { CollectionCacheFactory, CollectionEntryFactory, CollectionMatcherFactory, CollectionResourceFactory, ColumnExpansionFactory, ColumnSetFactory, ColumnSubsetCacheFactory, ItemCacheFactory, ItemEntryFactory, ItemResourceFactory, ModuleChangesCompilationFactory, QueryMatcherFactory, QueryParserFactory, RequestColumnExpansionFactory } from '../../factories';
3
- import { ChangesDeltaFactory } from '../../factories/ChangesDeltaFactory';
4
- import { AuthInterface, ErrorHandlerInterface, ExceptionHandlerInterface, PromiseLibraryInterface } from '../../interfaces';
5
- import { LinkTreeServiceInterface } from '../../interfaces/LinkTreeServiceInterface';
6
- import { CollectionEntry, ItemEntry } from '../../models';
7
- import { EntryParentNull, FieldMap, ItemIdConversionMap, ItemType, PromiseInterface } from '../../types';
8
- import { ApiFormatter } from '../ApiFormatter';
9
- import { ApiRequestService } from '../ApiRequestService';
10
- import { ChangesDelta } from '../ChangesDelta';
11
- import { ChangesDeltaResult } from '../ChangesDeltaBase';
12
- import { OnAfterCreateCallback } from '../ChangesProcessor';
13
- import { CollectionCache } from '../CollectionCache';
14
- import { CollectionEntryService } from '../CollectionEntryService';
15
- import { ColumnCache } from '../ColumnCache';
16
- import { ColumnHandler } from '../ColumnHandler';
17
- import { ColumnUtil } from '../ColumnUtil';
18
- import { InternalChangesDelta } from '../InternalChangesDelta';
19
- import { ItemCache } from '../ItemCache';
20
- import { ItemEntryService } from '../ItemEntryService';
21
- import { KeyService } from '../KeyService';
22
- import { LockService } from '../LockService';
23
- import { QueryService } from '../QueryService';
24
- import { RequestBufferManager } from '../RequestBufferManager';
25
- import { TemplateCache } from '../TemplateCache';
26
- import { ServerCache } from './server/ServerCache';
27
- import { ServerCollectionHandler } from './server/ServerCollectionHandler';
28
- import { ServerItemEntryChanges, ServerItemHandler } from './server/ServerItemHandler';
29
- import { TransactionCache } from './transaction/TransactionCache';
30
- import { TransactionCollectionHandler } from './transaction/TransactionCollectionHandler';
31
- import { TransactionItemEntryChanges, TransactionItemHandler } from './transaction/TransactionItemHandler';
32
- export declare abstract class AbstractCache {
33
- core: RmCore;
34
- protected columnCache: ColumnCache;
35
- protected requestBufferManager: RequestBufferManager;
36
- protected requestColumnExpansionFactory: RequestColumnExpansionFactory;
37
- protected queryMatcherFactory: QueryMatcherFactory;
38
- protected authInterface: AuthInterface;
39
- protected changesDeltaFactory: ChangesDeltaFactory;
40
- protected lockService: LockService;
41
- protected moduleChangesCompilationFactory: ModuleChangesCompilationFactory;
42
- protected collectionResourceFactory: CollectionResourceFactory;
43
- protected itemResourceFactory: ItemResourceFactory;
44
- protected templateCache: TemplateCache;
45
- protected itemCacheFactory: ItemCacheFactory;
46
- protected collectionCacheFactory: CollectionCacheFactory;
47
- protected errorHandler: ErrorHandlerInterface;
48
- protected exceptionHandler: ExceptionHandlerInterface;
49
- protected promiseService: PromiseLibraryInterface;
50
- protected apiRequestService: ApiRequestService;
51
- protected columnExpansionFactory: ColumnExpansionFactory;
52
- protected columnHandler: ColumnHandler;
53
- protected columnSetFactory: ColumnSetFactory;
54
- protected columnSubsetCacheFactory: ColumnSubsetCacheFactory;
55
- protected columnUtil: ColumnUtil;
56
- protected itemEntryFactory: ItemEntryFactory;
57
- protected itemEntryService: ItemEntryService;
58
- protected keyService: KeyService;
59
- protected collectionEntryFactory: CollectionEntryFactory;
60
- protected collectionEntryService: CollectionEntryService;
61
- protected collectionMatcherFactory: CollectionMatcherFactory;
62
- protected queryParserFactory: QueryParserFactory;
63
- protected queryService: QueryService;
64
- protected apiFormatter: ApiFormatter;
65
- protected linkTreeService: LinkTreeServiceInterface;
66
- children: TransactionCache[];
67
- readonly itemHandler: TransactionItemHandler | ServerItemHandler;
68
- readonly collectionHandler: TransactionCollectionHandler | ServerCollectionHandler;
69
- parent: AbstractCache | null;
70
- protected constructor(core: RmCore, columnCache: ColumnCache, requestBufferManager: RequestBufferManager, requestColumnExpansionFactory: RequestColumnExpansionFactory, queryMatcherFactory: QueryMatcherFactory, authInterface: AuthInterface, changesDeltaFactory: ChangesDeltaFactory, lockService: LockService, moduleChangesCompilationFactory: ModuleChangesCompilationFactory, collectionResourceFactory: CollectionResourceFactory, itemResourceFactory: ItemResourceFactory, templateCache: TemplateCache, itemCacheFactory: ItemCacheFactory, collectionCacheFactory: CollectionCacheFactory, errorHandler: ErrorHandlerInterface, exceptionHandler: ExceptionHandlerInterface, promiseService: PromiseLibraryInterface, apiRequestService: ApiRequestService, columnExpansionFactory: ColumnExpansionFactory, columnHandler: ColumnHandler, columnSetFactory: ColumnSetFactory, columnSubsetCacheFactory: ColumnSubsetCacheFactory, columnUtil: ColumnUtil, itemEntryFactory: ItemEntryFactory, itemEntryService: ItemEntryService, keyService: KeyService, collectionEntryFactory: CollectionEntryFactory, collectionEntryService: CollectionEntryService, collectionMatcherFactory: CollectionMatcherFactory, queryParserFactory: QueryParserFactory, queryService: QueryService, apiFormatter: ApiFormatter, linkTreeService: LinkTreeServiceInterface);
71
- createChild(id?: string): TransactionCache;
72
- onChildDestroy(cache: TransactionCache): void;
73
- /**
74
- * @description
75
- * Returns this transaction and all parents
76
- */
77
- getTransactionChain(): AbstractCache[];
78
- /**
79
- * @description
80
- * Returns the {@link TransactionCollectionHandler.entries CollectionCache} of the transaction
81
- */
82
- getCurrentCollectionEntryCache(): CollectionCache;
83
- /**
84
- * @description
85
- * Returns the {@link TransactionItemHandler.entries ItemCache} of the transaction
86
- */
87
- getCurrentItemEntryCache(): ItemCache;
88
- abstract getServerCache(): ServerCache;
89
- abstract getLocalItemEntry(itemEntryId: ItemEntry['id']): ItemEntry | undefined;
90
- abstract getLocalItemEntryByItemId(itemType: ItemType, itemId: ItemEntry['itemId']): ItemEntry | undefined;
91
- abstract getLocalCollectionEntry(collectionEntryId: CollectionEntry['id']): CollectionEntry | undefined;
92
- /**
93
- * @description
94
- * Applies changes from a child transaction to a parent
95
- */
96
- abstract applyChangesFromChild(transaction: TransactionCache, breakUpByParent?: boolean, onAfterCreateCallback?: OnAfterCreateCallback): PromiseInterface<ItemIdConversionMap>;
97
- /**
98
- * @description
99
- * Called by a parent transaction, propagates changes downwards to all child caches
100
- *
101
- * @remarks
102
- * - Should only be used by the core
103
- *
104
- * todo[cache] Should we refetch derived values just like in applyChangesDelta ?
105
- *
106
- * @internal
107
- */
108
- abstract applyChangesFromParent(internalChangesDelta: InternalChangesDelta, isCalledAfterApiSave: boolean, isCalledAfterSocketUpdate: boolean): void;
109
- abstract getParent<ItemTypeType extends ItemType = any>(itemEntry: ItemEntry<ItemTypeType>, fromInitial?: boolean, providedFields?: FieldMap<ItemTypeType>): EntryParentNull;
110
- abstract getItemChangesRecursively(itemEntryId: ItemEntry['id'], copyFields?: boolean): FieldMap;
111
- abstract getLocalItemEntryChangesTuple(itemEntryId: ItemEntry['id']): any;
112
- /**
113
- * @description
114
- * 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
115
- *
116
- * @remarks
117
- * - Should only be used by the core
118
- *
119
- * @internal
120
- */
121
- abstract getChangesFromItemChanges<ItemTypeType extends ItemType = any>(changesObject: ServerItemEntryChanges<ItemTypeType> | TransactionItemEntryChanges<ItemTypeType>): FieldMap<ItemTypeType>;
122
- abstract applyChangesDelta(changesDelta: ChangesDelta): PromiseInterface<ChangesDeltaResult>;
123
- protected getParentFromFields<ItemTypeType extends ItemType = any>(itemEntry: ItemEntry<ItemTypeType>, fields: FieldMap<ItemTypeType>): EntryParentNull;
124
- /**
125
- * @description
126
- * Called by applyChangesDelta from ServerCache and TransactionCache. Applies creates, updates and moves, doesn't apply deletes
127
- *
128
- * @private
129
- */
130
- protected _applyChangesDelta(changesDelta: ChangesDelta): {
131
- result: ChangesDeltaResult;
132
- internalChangesDelta: InternalChangesDelta;
133
- rollbackFunctions: Array<(changesDelta: ChangesDelta) => void>;
134
- };
135
- /**
136
- * @description
137
- * Ensures that for all updated items in the delta the required derived values are present
138
- */
139
- protected fetchUpdatedDerivedValuesFromDelta(changesDelta: ChangesDelta): PromiseInterface<ItemEntry[][]>;
140
- }
1
+ import { RmCore } from '../../core';
2
+ import { CollectionCacheFactory, CollectionEntryFactory, CollectionMatcherFactory, CollectionResourceFactory, ColumnExpansionFactory, ColumnSetFactory, ColumnSubsetCacheFactory, ItemCacheFactory, ItemEntryFactory, ItemResourceFactory, ModuleChangesCompilationFactory, QueryMatcherFactory, QueryParserFactory, RequestColumnExpansionFactory } from '../../factories';
3
+ import { ChangesDeltaFactory } from '../../factories/ChangesDeltaFactory';
4
+ import { AuthInterface, ErrorHandlerInterface, ExceptionHandlerInterface, PromiseLibraryInterface } from '../../interfaces';
5
+ import { LinkTreeServiceInterface } from '../../interfaces/LinkTreeServiceInterface';
6
+ import { CollectionEntry, ItemEntry } from '../../models';
7
+ import { EntryParentNull, FieldMap, ItemIdConversionMap, ItemType, PromiseInterface } from '../../types';
8
+ import { ApiFormatter } from '../ApiFormatter';
9
+ import { ApiRequestService } from '../ApiRequestService';
10
+ import { ChangesDelta } from '../ChangesDelta';
11
+ import { ChangesDeltaResult } from '../ChangesDeltaBase';
12
+ import { OnAfterCreateCallback } from '../ChangesProcessor';
13
+ import { CollectionCache } from '../CollectionCache';
14
+ import { CollectionEntryService } from '../CollectionEntryService';
15
+ import { ColumnCache } from '../ColumnCache';
16
+ import { ColumnHandler } from '../ColumnHandler';
17
+ import { ColumnUtil } from '../ColumnUtil';
18
+ import { InternalChangesDelta } from '../InternalChangesDelta';
19
+ import { ItemCache } from '../ItemCache';
20
+ import { ItemEntryService } from '../ItemEntryService';
21
+ import { KeyService } from '../KeyService';
22
+ import { LockService } from '../LockService';
23
+ import { QueryService } from '../QueryService';
24
+ import { RequestBufferManager } from '../RequestBufferManager';
25
+ import { TemplateCache } from '../TemplateCache';
26
+ import { ServerCache } from './server/ServerCache';
27
+ import { ServerCollectionHandler } from './server/ServerCollectionHandler';
28
+ import { ServerItemEntryChanges, ServerItemHandler } from './server/ServerItemHandler';
29
+ import { TransactionCache } from './transaction/TransactionCache';
30
+ import { TransactionCollectionHandler } from './transaction/TransactionCollectionHandler';
31
+ import { TransactionItemEntryChanges, TransactionItemHandler } from './transaction/TransactionItemHandler';
32
+ export declare abstract class AbstractCache {
33
+ core: RmCore;
34
+ protected columnCache: ColumnCache;
35
+ protected requestBufferManager: RequestBufferManager;
36
+ protected requestColumnExpansionFactory: RequestColumnExpansionFactory;
37
+ protected queryMatcherFactory: QueryMatcherFactory;
38
+ protected authInterface: AuthInterface;
39
+ protected changesDeltaFactory: ChangesDeltaFactory;
40
+ protected lockService: LockService;
41
+ protected moduleChangesCompilationFactory: ModuleChangesCompilationFactory;
42
+ protected collectionResourceFactory: CollectionResourceFactory;
43
+ protected itemResourceFactory: ItemResourceFactory;
44
+ protected templateCache: TemplateCache;
45
+ protected itemCacheFactory: ItemCacheFactory;
46
+ protected collectionCacheFactory: CollectionCacheFactory;
47
+ protected errorHandler: ErrorHandlerInterface;
48
+ protected exceptionHandler: ExceptionHandlerInterface;
49
+ protected promiseService: PromiseLibraryInterface;
50
+ protected apiRequestService: ApiRequestService;
51
+ protected columnExpansionFactory: ColumnExpansionFactory;
52
+ protected columnHandler: ColumnHandler;
53
+ protected columnSetFactory: ColumnSetFactory;
54
+ protected columnSubsetCacheFactory: ColumnSubsetCacheFactory;
55
+ protected columnUtil: ColumnUtil;
56
+ protected itemEntryFactory: ItemEntryFactory;
57
+ protected itemEntryService: ItemEntryService;
58
+ protected keyService: KeyService;
59
+ protected collectionEntryFactory: CollectionEntryFactory;
60
+ protected collectionEntryService: CollectionEntryService;
61
+ protected collectionMatcherFactory: CollectionMatcherFactory;
62
+ protected queryParserFactory: QueryParserFactory;
63
+ protected queryService: QueryService;
64
+ protected apiFormatter: ApiFormatter;
65
+ protected linkTreeService: LinkTreeServiceInterface;
66
+ children: TransactionCache[];
67
+ readonly itemHandler: TransactionItemHandler | ServerItemHandler;
68
+ readonly collectionHandler: TransactionCollectionHandler | ServerCollectionHandler;
69
+ parent: AbstractCache | null;
70
+ protected constructor(core: RmCore, columnCache: ColumnCache, requestBufferManager: RequestBufferManager, requestColumnExpansionFactory: RequestColumnExpansionFactory, queryMatcherFactory: QueryMatcherFactory, authInterface: AuthInterface, changesDeltaFactory: ChangesDeltaFactory, lockService: LockService, moduleChangesCompilationFactory: ModuleChangesCompilationFactory, collectionResourceFactory: CollectionResourceFactory, itemResourceFactory: ItemResourceFactory, templateCache: TemplateCache, itemCacheFactory: ItemCacheFactory, collectionCacheFactory: CollectionCacheFactory, errorHandler: ErrorHandlerInterface, exceptionHandler: ExceptionHandlerInterface, promiseService: PromiseLibraryInterface, apiRequestService: ApiRequestService, columnExpansionFactory: ColumnExpansionFactory, columnHandler: ColumnHandler, columnSetFactory: ColumnSetFactory, columnSubsetCacheFactory: ColumnSubsetCacheFactory, columnUtil: ColumnUtil, itemEntryFactory: ItemEntryFactory, itemEntryService: ItemEntryService, keyService: KeyService, collectionEntryFactory: CollectionEntryFactory, collectionEntryService: CollectionEntryService, collectionMatcherFactory: CollectionMatcherFactory, queryParserFactory: QueryParserFactory, queryService: QueryService, apiFormatter: ApiFormatter, linkTreeService: LinkTreeServiceInterface);
71
+ createChild(id?: string): TransactionCache;
72
+ onChildDestroy(cache: TransactionCache): void;
73
+ /**
74
+ * @description
75
+ * Returns this transaction and all parents
76
+ */
77
+ getTransactionChain(): AbstractCache[];
78
+ /**
79
+ * @description
80
+ * Returns the {@link TransactionCollectionHandler.entries CollectionCache} of the transaction
81
+ */
82
+ getCurrentCollectionEntryCache(): CollectionCache;
83
+ /**
84
+ * @description
85
+ * Returns the {@link TransactionItemHandler.entries ItemCache} of the transaction
86
+ */
87
+ getCurrentItemEntryCache(): ItemCache;
88
+ abstract getServerCache(): ServerCache;
89
+ abstract getLocalItemEntry(itemEntryId: ItemEntry['id']): ItemEntry | undefined;
90
+ abstract getLocalItemEntryByItemId(itemType: ItemType, itemId: ItemEntry['itemId']): ItemEntry | undefined;
91
+ abstract getLocalCollectionEntry(collectionEntryId: CollectionEntry['id']): CollectionEntry | undefined;
92
+ /**
93
+ * @description
94
+ * Applies changes from a child transaction to a parent
95
+ */
96
+ abstract applyChangesFromChild(transaction: TransactionCache, breakUpByParent?: boolean, onAfterCreateCallback?: OnAfterCreateCallback): PromiseInterface<ItemIdConversionMap>;
97
+ /**
98
+ * @description
99
+ * Called by a parent transaction, propagates changes downwards to all child caches
100
+ *
101
+ * @remarks
102
+ * - Should only be used by the core
103
+ *
104
+ * todo[cache] Should we refetch derived values just like in applyChangesDelta ?
105
+ *
106
+ * @internal
107
+ */
108
+ abstract applyChangesFromParent(internalChangesDelta: InternalChangesDelta, isCalledAfterApiSave: boolean, isCalledAfterSocketUpdate: boolean): void;
109
+ abstract getParent<ItemTypeType extends ItemType = any>(itemEntry: ItemEntry<ItemTypeType>, fromInitial?: boolean, providedFields?: FieldMap<ItemTypeType>): EntryParentNull;
110
+ abstract getItemChangesRecursively(itemEntryId: ItemEntry['id'], copyFields?: boolean): FieldMap;
111
+ abstract getLocalItemEntryChangesTuple(itemEntryId: ItemEntry['id']): any;
112
+ /**
113
+ * @description
114
+ * 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
115
+ *
116
+ * @remarks
117
+ * - Should only be used by the core
118
+ *
119
+ * @internal
120
+ */
121
+ abstract getChangesFromItemChanges<ItemTypeType extends ItemType = any>(changesObject: ServerItemEntryChanges<ItemTypeType> | TransactionItemEntryChanges<ItemTypeType>): FieldMap<ItemTypeType>;
122
+ abstract applyChangesDelta(changesDelta: ChangesDelta): PromiseInterface<ChangesDeltaResult>;
123
+ protected getParentFromFields<ItemTypeType extends ItemType = any>(itemEntry: ItemEntry<ItemTypeType>, fields: FieldMap<ItemTypeType>): EntryParentNull;
124
+ /**
125
+ * @description
126
+ * Called by applyChangesDelta from ServerCache and TransactionCache. Applies creates, updates and moves, doesn't apply deletes
127
+ *
128
+ * @private
129
+ */
130
+ protected _applyChangesDelta(changesDelta: ChangesDelta): {
131
+ result: ChangesDeltaResult;
132
+ internalChangesDelta: InternalChangesDelta;
133
+ rollbackFunctions: Array<(changesDelta: ChangesDelta) => void>;
134
+ };
135
+ /**
136
+ * @description
137
+ * Ensures that for all updated items in the delta the required derived values are present
138
+ */
139
+ protected fetchUpdatedDerivedValuesFromDelta(changesDelta: ChangesDelta): PromiseInterface<ItemEntry[][]>;
140
+ }
@@ -1,64 +1,64 @@
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
- [collectionEntryId: number]: ItemEntry[];
17
- };
18
- protected constructor(collectionEntryService: CollectionEntryService, columnUtil: ColumnUtil, requestColumnExpansionFactory: RequestColumnExpansionFactory, collectionCacheFactory: CollectionCacheFactory, transaction: AbstractCache);
19
- /**
20
- * @description
21
- * Creates a new {@link CollectionEntry CollectionEntry} and stores it in this transaction's {@link CollectionCache CollectionCache}
22
- */
23
- createCollectionEntry<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionEntryOptions): CollectionEntry<ItemTypeType>;
24
- /**
25
- * @description
26
- * Creates a {@link CollectionMatcher CollectionMatcher} with the transaction's collections
27
- */
28
- abstract getCollectionMatcher(): CollectionMatcher;
29
- /**
30
- * @description
31
- * Fetches a {@link CollectionEntry CollectionEntry} with the given options
32
- */
33
- abstract fetchCollectionEntry<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionEntryOptions): PromiseInterface<CollectionEntry<ItemTypeType>>;
34
- /**
35
- * @description
36
- * Fetches collections linked to the passed parents
37
- */
38
- abstract fetchLinkedCollectionEntries<ItemTypeType extends ItemType>(parentType: ItemType, parentIdArray: ItemId[] | (() => ItemId[]), itemType: ItemTypeType, options: CollectionEntryOptions): PromiseInterface<CollectionEntryParentIdMap<ItemTypeType>>;
39
- /**
40
- * @description
41
- * Expands the items in the collections with the passed columns
42
- */
43
- abstract expandCollectionEntries<ItemTypeType extends ItemType>(parentType: ItemType, itemType: ItemTypeType, collections: CollectionResourceParentIdMap, newColumns: ApiRequestColumn[]): PromiseInterface<CollectionResourceParentIdMap>;
44
- /**
45
- * @description
46
- * Extends the collections' {@link CollectionEntry.queryParams queryParams} and {@link CollectionEntry.query queries} and fetches the {@link ItemEntry ItemEntries} with the new queries
47
- */
48
- abstract extendCollectionEntries<T extends CollectionResourceParentIdMap>(parentType: ItemType, itemType: ItemType, options: CollectionEntryOptions, queryCallback: QueryCallback, collections: T): PromiseInterface<void>;
49
- /**
50
- * @description
51
- * Adds the passed {@link ItemEntry ItemEntries} to the collection's changes on the transaction,
52
- * will skip the ItemEntry if the `skipEntryFilterFn` callback returns `true`
53
- */
54
- protected _addItemEntriesToCollectionChanges<CollectionEntryType extends CollectionEntry>(collectionEntry: CollectionEntryType, itemEntries: Array<ItemEntry<CollectionEntryType['itemType']>>, skipEntryFilterFn: (temEntry: ItemEntry) => boolean, isCalledAfterSocketUpdate: boolean): void;
55
- protected abstract handleAddedItemEntriesCallback<CollectionEntryType extends CollectionEntry>(collectionEntry: CollectionEntryType, addedEntries: Array<ItemEntry<CollectionEntryType['itemType']>>, isCalledAfterSocketUpdate: boolean): void;
56
- removeItemEntriesFromCollectionChanges(collectionEntry: CollectionEntry, idArray: ItemId[], isCalledAfterSocketUpdate?: boolean): void | never[];
57
- protected abstract handleRemovedItemEntriesCallback<CollectionEntryType extends CollectionEntry>(collectionEntry: CollectionEntryType, removedItemEntries: Array<ItemEntry<CollectionEntryType['itemType']>>, isCalledAfterSocketUpdate: boolean): void;
58
- /**
59
- * @description
60
- * Expands the option's {@link CollectionEntryOptions.columns columns} with the columns required for the {@link CollectionMatcher CollectionMatcher} to function.
61
- * 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
62
- */
63
- protected expandColumnsWithQueryColumns(itemType: ItemType, options: CollectionEntryOptions, query: ApiQuery): void;
64
- }
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
+ [collectionEntryId: number]: ItemEntry[];
17
+ };
18
+ protected constructor(collectionEntryService: CollectionEntryService, columnUtil: ColumnUtil, requestColumnExpansionFactory: RequestColumnExpansionFactory, collectionCacheFactory: CollectionCacheFactory, transaction: AbstractCache);
19
+ /**
20
+ * @description
21
+ * Creates a new {@link CollectionEntry CollectionEntry} and stores it in this transaction's {@link CollectionCache CollectionCache}
22
+ */
23
+ createCollectionEntry<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionEntryOptions): CollectionEntry<ItemTypeType>;
24
+ /**
25
+ * @description
26
+ * Creates a {@link CollectionMatcher CollectionMatcher} with the transaction's collections
27
+ */
28
+ abstract getCollectionMatcher(): CollectionMatcher;
29
+ /**
30
+ * @description
31
+ * Fetches a {@link CollectionEntry CollectionEntry} with the given options
32
+ */
33
+ abstract fetchCollectionEntry<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionEntryOptions): PromiseInterface<CollectionEntry<ItemTypeType>>;
34
+ /**
35
+ * @description
36
+ * Fetches collections linked to the passed parents
37
+ */
38
+ abstract fetchLinkedCollectionEntries<ItemTypeType extends ItemType>(parentType: ItemType, parentIdArray: ItemId[] | (() => ItemId[]), itemType: ItemTypeType, options: CollectionEntryOptions): PromiseInterface<CollectionEntryParentIdMap<ItemTypeType>>;
39
+ /**
40
+ * @description
41
+ * Expands the items in the collections with the passed columns
42
+ */
43
+ abstract expandCollectionEntries<ItemTypeType extends ItemType>(parentType: ItemType, itemType: ItemTypeType, collections: CollectionResourceParentIdMap, newColumns: ApiRequestColumn[]): PromiseInterface<CollectionResourceParentIdMap>;
44
+ /**
45
+ * @description
46
+ * Extends the collections' {@link CollectionEntry.queryParams queryParams} and {@link CollectionEntry.query queries} and fetches the {@link ItemEntry ItemEntries} with the new queries
47
+ */
48
+ abstract extendCollectionEntries<T extends CollectionResourceParentIdMap>(parentType: ItemType, itemType: ItemType, options: CollectionEntryOptions, queryCallback: QueryCallback, collections: T): PromiseInterface<void>;
49
+ /**
50
+ * @description
51
+ * Adds the passed {@link ItemEntry ItemEntries} to the collection's changes on the transaction,
52
+ * will skip the ItemEntry if the `skipEntryFilterFn` callback returns `true`
53
+ */
54
+ protected _addItemEntriesToCollectionChanges<CollectionEntryType extends CollectionEntry>(collectionEntry: CollectionEntryType, itemEntries: Array<ItemEntry<CollectionEntryType['itemType']>>, skipEntryFilterFn: (temEntry: ItemEntry) => boolean, isCalledAfterSocketUpdate: boolean): void;
55
+ protected abstract handleAddedItemEntriesCallback<CollectionEntryType extends CollectionEntry>(collectionEntry: CollectionEntryType, addedEntries: Array<ItemEntry<CollectionEntryType['itemType']>>, isCalledAfterSocketUpdate: boolean): void;
56
+ removeItemEntriesFromCollectionChanges(collectionEntry: CollectionEntry, idArray: ItemId[], isCalledAfterSocketUpdate?: boolean): void | never[];
57
+ protected abstract handleRemovedItemEntriesCallback<CollectionEntryType extends CollectionEntry>(collectionEntry: CollectionEntryType, removedItemEntries: Array<ItemEntry<CollectionEntryType['itemType']>>, isCalledAfterSocketUpdate: boolean): void;
58
+ /**
59
+ * @description
60
+ * Expands the option's {@link CollectionEntryOptions.columns columns} with the columns required for the {@link CollectionMatcher CollectionMatcher} to function.
61
+ * 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
62
+ */
63
+ protected expandColumnsWithQueryColumns(itemType: ItemType, options: CollectionEntryOptions, query: ApiQuery): void;
64
+ }
@@ -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
+ }