@rentman/rm-core 1.8.0 → 2.0.0

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 (87) hide show
  1. package/changelog.md +7 -0
  2. package/dist/rm-core.js +7445 -6445
  3. package/dist/rm-core.min.js +1 -1
  4. package/dist/src/classes/ApiFormatter.d.ts +25 -8
  5. package/dist/src/classes/ApiResponseProcessor.d.ts +10 -20
  6. package/dist/src/classes/ChangesCompilation.d.ts +14 -31
  7. package/dist/src/classes/ChangesDelta.d.ts +42 -0
  8. package/dist/src/classes/ChangesDeltaBase.d.ts +33 -0
  9. package/dist/src/classes/ChangesProcessor.d.ts +30 -16
  10. package/dist/src/classes/CollectionCache.d.ts +7 -2
  11. package/dist/src/classes/CollectionEntryService.d.ts +3 -0
  12. package/dist/src/classes/CollectionMatcher.d.ts +8 -41
  13. package/dist/src/classes/CollectionMatcherBase.d.ts +26 -0
  14. package/dist/src/classes/ColumnExpansion.d.ts +4 -0
  15. package/dist/src/classes/ColumnHandler.d.ts +3 -3
  16. package/dist/src/classes/ColumnUtil.d.ts +12 -1
  17. package/dist/src/classes/CreateRequest.d.ts +7 -8
  18. package/dist/src/classes/InternalChangesDelta.d.ts +38 -0
  19. package/dist/src/classes/ItemCache.d.ts +7 -1
  20. package/dist/src/classes/ItemEntryService.d.ts +23 -5
  21. package/dist/src/classes/LockService.d.ts +9 -9
  22. package/dist/src/classes/ModuleChangesCompilation.d.ts +4 -7
  23. package/dist/src/classes/QueryColumnExtractor.d.ts +20 -0
  24. package/dist/src/classes/QueryParser.d.ts +18 -27
  25. package/dist/src/classes/QueryParserBase.d.ts +29 -0
  26. package/dist/src/classes/QueryService.d.ts +1 -1
  27. package/dist/src/classes/RequestBuffer.d.ts +25 -0
  28. package/dist/src/classes/RequestBufferManager.d.ts +31 -0
  29. package/dist/src/classes/RequestColumnExpansion.d.ts +1 -0
  30. package/dist/src/classes/SocketMessageHandler.d.ts +19 -30
  31. package/dist/src/classes/TemplateCache.d.ts +63 -0
  32. package/dist/src/classes/cache/AbstractCache.d.ts +122 -0
  33. package/dist/src/classes/cache/CollectionHandlerBase.d.ts +64 -0
  34. package/dist/src/classes/cache/CollectionMatcherCacheProcessor.d.ts +26 -0
  35. package/dist/src/classes/cache/ItemHandlerBase.d.ts +86 -0
  36. package/dist/src/classes/cache/server/ServerCache.d.ts +87 -0
  37. package/dist/src/classes/cache/server/ServerCollectionHandler.d.ts +43 -0
  38. package/dist/src/classes/cache/server/ServerItemHandler.d.ts +49 -0
  39. package/dist/src/classes/cache/transaction/TransactionCache.d.ts +423 -0
  40. package/dist/src/classes/cache/transaction/TransactionCollectionHandler.d.ts +72 -0
  41. package/dist/src/classes/cache/transaction/TransactionEventHandler.d.ts +19 -0
  42. package/dist/src/classes/cache/transaction/TransactionItemHandler.d.ts +113 -0
  43. package/dist/src/classes/index.d.ts +13 -7
  44. package/dist/src/constants.d.ts +0 -11
  45. package/dist/src/core.d.ts +12 -11
  46. package/dist/src/factories/ChangesCompilationFactory.d.ts +4 -8
  47. package/dist/src/factories/ChangesDeltaFactory.d.ts +9 -0
  48. package/dist/src/factories/ChangesProcessorFactory.d.ts +22 -0
  49. package/dist/src/factories/CollectionCacheFactory.d.ts +2 -1
  50. package/dist/src/factories/CollectionEntryFactory.d.ts +6 -18
  51. package/dist/src/factories/CollectionMatcherFactory.d.ts +3 -2
  52. package/dist/src/factories/CollectionResourceFactory.d.ts +11 -9
  53. package/dist/src/factories/ColumnSetFactory.d.ts +2 -0
  54. package/dist/src/factories/CreateRequestFactory.d.ts +7 -7
  55. package/dist/src/factories/ItemCacheFactory.d.ts +2 -1
  56. package/dist/src/factories/ItemEntryFactory.d.ts +3 -7
  57. package/dist/src/factories/ItemResourceFactory.d.ts +14 -10
  58. package/dist/src/factories/ModuleChangesCompilationFactory.d.ts +3 -4
  59. package/dist/src/factories/TransactionCacheFactory.d.ts +55 -0
  60. package/dist/src/factories/index.d.ts +3 -2
  61. package/dist/src/interfaces/LinkTreeServiceInterface.d.ts +4 -0
  62. package/dist/src/interfaces/index.d.ts +1 -1
  63. package/dist/src/models/CollectionEditResource.d.ts +34 -11
  64. package/dist/src/models/CollectionEntry.d.ts +10 -70
  65. package/dist/src/models/CollectionEntryOptions.d.ts +1 -0
  66. package/dist/src/models/CollectionResource.d.ts +14 -14
  67. package/dist/src/models/CollectionResourceOptions.d.ts +6 -2
  68. package/dist/src/models/CollectionViewResource.d.ts +2 -2
  69. package/dist/src/models/EditResource.d.ts +8 -10
  70. package/dist/src/models/ItemEntry.d.ts +1 -58
  71. package/dist/src/models/ItemEntryOptions.d.ts +0 -1
  72. package/dist/src/models/ItemResource.d.ts +49 -16
  73. package/dist/src/models/LocalViewResource.d.ts +2 -2
  74. package/dist/src/models/RemoteViewResource.d.ts +2 -2
  75. package/dist/src/models/ViewResource.d.ts +2 -2
  76. package/dist/src/types/ItemTypesCollection.d.ts +81 -22
  77. package/package.json +1 -1
  78. package/dist/src/classes/BatchStatus.d.ts +0 -28
  79. package/dist/src/classes/CollectionHandler.d.ts +0 -54
  80. package/dist/src/classes/ItemAdministrator.d.ts +0 -234
  81. package/dist/src/classes/ItemHandler.d.ts +0 -60
  82. package/dist/src/classes/ItemRequestService.d.ts +0 -23
  83. package/dist/src/classes/LocalCache.d.ts +0 -112
  84. package/dist/src/classes/LocalCacheEventHandler.d.ts +0 -19
  85. package/dist/src/factories/BatchStatusFactory.d.ts +0 -9
  86. package/dist/src/factories/LocalCacheFactory.d.ts +0 -16
  87. package/dist/src/interfaces/LocalCacheManagerInterface.d.ts +0 -5
@@ -0,0 +1,423 @@
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 { CollectionEditResource, CollectionEntry, CollectionResource, CollectionResourceOptionsInterface, CollectionViewResource, EditResource, ItemEntry, ItemResource, LocalViewResource, RemoteViewResource } from '../../../models';
7
+ import { ApiQuery, CollectionDefinition, CollectionOptionsInterface, CollectionResourceParentIdMap, ConversionMap, CreateRequestParameterMap, EntryParentNull, FieldMap, ItemId, ItemIdConversionMap, ItemOptionsInterface, ItemResourcesItemTypeMap, ItemType, ItemTypeMap, LinkCollectionDefinition, PromiseInterface } from '../../../types';
8
+ import { ChangesDelta } from '../../ChangesDelta';
9
+ import { ChangesDeltaResult } from '../../ChangesDeltaBase';
10
+ import { CollectionEntryService } from '../../CollectionEntryService';
11
+ import { ColumnHandler } from '../../ColumnHandler';
12
+ import { ColumnUtil } from '../../ColumnUtil';
13
+ import { ApiFormatter, ApiRequestService, CollectionCache, ColumnCache, ItemCache, LockService, ModuleChangesCompilationResult, OnAfterCreateCallback, RequestBufferManager, TransactionCacheCallbackCondition, TransactionCacheCallbackType, TransactionCollectionHandler, TransactionItemEntryChanges, TransactionItemHandler } from '../../index';
14
+ import { InternalChangesDelta } from '../../InternalChangesDelta';
15
+ import { ItemEntryService } from '../../ItemEntryService';
16
+ import { KeyService } from '../../KeyService';
17
+ import { QueryService } from '../../QueryService';
18
+ import { TemplateCache } from '../../TemplateCache';
19
+ import { AbstractCache } from '../AbstractCache';
20
+ import { ServerCache } from '../server/ServerCache';
21
+ declare type EditResourceLinks<ItemTypeType extends ItemType> = {
22
+ main: EditResource<ItemTypeType>;
23
+ linked: ItemResourcesItemTypeMap;
24
+ };
25
+ /**
26
+ * @description
27
+ * The {@link TransactionCache TransactionCache} is responsible for keeping track of newly created {@link ItemEntry ItemEntries}
28
+ * and {@link CollectionEntry CollectionEntries}, and the changes of existing ItemEntries and CollectionEntries.
29
+ *
30
+ * The TransactionCache is also responsible for creating {@link ItemResource ItemResources}, which is a combination of an {@link ItemEntry ItemEntry} and the current transaction's changes on this ItemEntry
31
+ */
32
+ export declare class TransactionCache extends AbstractCache {
33
+ /**
34
+ * @description
35
+ * For debugging purposes
36
+ */
37
+ id?: string | undefined;
38
+ /**
39
+ * @description
40
+ * Stores the 'root' {@link ItemEntry ItemEntry}, this {@link ItemEntry ItemEntry} can be used as request parent to store the whole transaction at once
41
+ */
42
+ rootItem: ItemEntry<any> | undefined;
43
+ /**
44
+ * @description
45
+ * Stores additional request parameters for when the transaction is stored to the server
46
+ */
47
+ tabRequestParameters: {};
48
+ /**
49
+ * @description
50
+ * Is true while the {@link TransactionCache TransactionCache} is applying changes to the parent (can either be through a merge or an Api save)
51
+ */
52
+ isSaving: boolean;
53
+ /**
54
+ * @description
55
+ * Is true when the current transaction has:
56
+ * - Newly created items
57
+ * - Removed items (from collections)
58
+ * - Changes on existing items
59
+ */
60
+ hasChanges: boolean;
61
+ /**
62
+ * @description
63
+ * The transaction's parent
64
+ */
65
+ readonly parent: AbstractCache;
66
+ readonly itemHandler: TransactionItemHandler;
67
+ readonly collectionHandler: TransactionCollectionHandler;
68
+ private readonly eventHandler;
69
+ private changesInterval;
70
+ 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, parent: AbstractCache,
71
+ /**
72
+ * @description
73
+ * For debugging purposes
74
+ */
75
+ id?: string | undefined);
76
+ destroy(): void;
77
+ createChangesDelta(): ChangesDelta;
78
+ /**
79
+ * @description
80
+ * Merges the passed changes from the parent Transaction into this Transaction's own changes and then propagates
81
+ * them to all child Transactions, this assumes that an action is already handled in a parent, so it does't handle created entries
82
+ * and removes entries that were in {@link TransactionItemHandler.deletedItems deletedItems} since they are already deleted
83
+ *
84
+ * ------------------
85
+ *
86
+ * The difference between {@link TransactionCache.applyChangesFromParent} and {@link TransactionCache.applyChangesDelta} is that applyChangesFromParent assumes
87
+ * the change has already been processed, and applyChangesDelta will process the changes once you save the transaction
88
+ *
89
+ * ------------------
90
+ * Use {@link TransactionCache.applyChangesDelta applyChangesDelta} if you want to apply changes from outside the core
91
+ *
92
+ * @param internalChangesDelta Changes to be applied
93
+ * @param isCalledAfterApiSave If 'isCalledAfterApiSave' is true local changes will always be overwritten (instead of only when there are no changes)
94
+ */
95
+ applyChangesFromParent(internalChangesDelta: InternalChangesDelta, isCalledAfterApiSave?: boolean): void;
96
+ /**
97
+ * @description
98
+ * Applies changes to this transaction and its children
99
+ *
100
+ * ------------------
101
+ *
102
+ * The difference between {@link TransactionCache.applyChangesFromParent} and {@link TransactionCache.applyChangesDelta} is that applyChangesFromParent assumes
103
+ * the change has already been processed, and applyChangesDelta will process the changes itself (result vs cause)
104
+ *
105
+ * ------------------
106
+ *
107
+ * Differs from {@link ServerCache.applyChangesDelta ServerCache.applyChangesDelta} in the handling of deleted entries and the applyChangesFromParent call
108
+ */
109
+ applyChangesDelta(changesDelta: ChangesDelta): PromiseInterface<ChangesDeltaResult>;
110
+ getServerCache(): ServerCache;
111
+ /**
112
+ * @description
113
+ * Gets the entry's parent from the closest transaction
114
+ *
115
+ * @param itemEntry The entry to get the parent from
116
+ * @param fromInitial If `true` the parent values will be read from {@link TransactionItemEntryChanges.initial initial} (Useful for when you've moved an entry)
117
+ */
118
+ getParent(itemEntry: ItemEntry, fromInitial?: boolean): EntryParentNull;
119
+ /**
120
+ * @description
121
+ * Traverses the transaction chain and returns the changes of the item on the first transaction
122
+ *
123
+ * @param copyFields If set, will call {@link ApiFormatter.copyFields ApiFormatter.copyFields}, otherwise just returns the object
124
+ */
125
+ getItemChangesRecursively(itemEntryId: ItemEntry['id'], copyFields?: boolean): FieldMap;
126
+ /**
127
+ * @description
128
+ * Removes the {@link ItemResource ItemResource} from the transaction, preventing the {@link ItemResource.options.onChange the onChange callback} from being called.
129
+ * You should call this function when the resource is no longer needed
130
+ *
131
+ * @remark
132
+ * Does not remove changes
133
+ */
134
+ clearItemResource(resource: ItemResource): void;
135
+ /**
136
+ * @description
137
+ * Removes the {@link CollectionResource CollectionResource} from the transaction, preventing the {@link CollectionResource.options.onAdd onAdd} and {@link CollectionResource.options.onRemove onRemove} callbacks from being called.
138
+ * You should call this function when the resource is no longer needed
139
+ *
140
+ * @remark
141
+ * Does not remove changes
142
+ */
143
+ clearCollectionResource(resource: CollectionResource): void;
144
+ /**
145
+ * @description
146
+ * Returns whether or not the {@link TransactionCache.rootItem rootItem} is uses locks
147
+ */
148
+ isLockable(): boolean;
149
+ /**
150
+ * @description
151
+ * Disables the transaction's changes watcher, the transaction will no longer automatically detect changes on items
152
+ */
153
+ disableChangesWatcher(): void;
154
+ /**
155
+ * @description
156
+ * Enables the transaction's changes watcher, the transaction will now automatically detect changes on items
157
+ */
158
+ enableChangesWatcher(): void;
159
+ /**
160
+ * @description
161
+ * Saves the transaction, this has a different effect depending on the transaction's parent.
162
+ *
163
+ * - If the parent is another {@link TransactionCache TransactionCache} it will merge the changes of the child transaction in the the parent transaction
164
+ * - If the parent is the {@link ServerCache ServerCache} it will save the changes to the APi
165
+ */
166
+ save(closeTab?: boolean, parameters?: CreateRequestParameterMap, breakUpByParent?: boolean, onAfterCreateCallback?: OnAfterCreateCallback): PromiseInterface<void>;
167
+ detectChanges(): boolean;
168
+ /**
169
+ * @description
170
+ * Removes an {@link ItemEntry ItemEntry} through an {@link ItemResource ItemResource} from the {@link TransactionCache TransactionCache} which means that changes on this entry will no longer be tracked.
171
+ */
172
+ clearItem(itemResource: ItemResource<any>): void;
173
+ /**
174
+ * @description
175
+ * Removes an {@link ItemEntry ItemEntry} from the {@link TransactionCache TransactionCache} which means that changes on this entry will no longer be tracked.
176
+ */
177
+ clearItemEntry(itemEntry: ItemEntry<any>): void;
178
+ /**
179
+ * @description
180
+ * Removes a {@link CollectionEntry CollectionEntry} through a {@link CollectionResource CollectionResource} from the {@link TransactionCache TransactionCache} which means that changes on this collection will no longer be tracked.
181
+ */
182
+ clearCollection(collectionResource: CollectionResource<any>): void;
183
+ /**
184
+ * @description
185
+ * Adds a callback that will fire before the transaction is saved, rejecting this callback will prevent the transaction from saving
186
+ */
187
+ onBeforeSave(key: string, callback: TransactionCacheCallbackType['onBeforeSave'], condition?: TransactionCacheCallbackCondition, priority?: number): () => void;
188
+ /**
189
+ * @description
190
+ * Adds a callback that will fire when the transaction is saved successfully
191
+ */
192
+ onSaveSuccess(key: string, callback: TransactionCacheCallbackType['onSaveSuccess'], condition?: TransactionCacheCallbackCondition, priority?: number): () => void;
193
+ /**
194
+ * @description
195
+ * Returns a {@link ModuleChangesCompilationResult ModuleChangesCompilationResult} for the transaction
196
+ */
197
+ getModuleChanges(): ModuleChangesCompilationResult;
198
+ /**
199
+ * @description
200
+ * Updates the passed map with the new {@link ConversionMap CconversionMap} values
201
+ */
202
+ updateItemIdMap(collectionMap: {
203
+ [itemId: number]: any;
204
+ }, conversionMap: ConversionMap): void;
205
+ /**
206
+ * @description
207
+ * Returns the {@link TransactionCollectionHandler.entries CollectionCache} of the transaction
208
+ */
209
+ getCurrentCollectionEntryCache(): CollectionCache;
210
+ /**
211
+ * @description
212
+ * Returns the {@link TransactionItemHandler.entries ItemCache} of the transaction
213
+ */
214
+ getCurrentItemEntryCache(): ItemCache;
215
+ cloneCollection<ItemTypeType extends ItemType>(collectionResource: CollectionResource<ItemTypeType>, options: CollectionOptionsInterface<ItemTypeType> & {
216
+ editItems: true;
217
+ editCollection: true;
218
+ }, conversionMap: ItemIdConversionMap): CollectionEditResource<ItemTypeType, EditResource<ItemTypeType>>;
219
+ cloneCollection<ItemTypeType extends ItemType>(collectionResource: CollectionResource<ItemTypeType>, options: CollectionOptionsInterface<ItemTypeType> & {
220
+ remoteItems: true;
221
+ editCollection: true;
222
+ }, conversionMap: ItemIdConversionMap): CollectionEditResource<ItemTypeType, RemoteViewResource<ItemTypeType>>;
223
+ cloneCollection<ItemTypeType extends ItemType>(collectionResource: CollectionResource<ItemTypeType>, options: CollectionOptionsInterface<ItemTypeType> & {
224
+ editItems: true;
225
+ }, conversionMap: ItemIdConversionMap): CollectionViewResource<ItemTypeType, EditResource<ItemTypeType>>;
226
+ cloneCollection<ItemTypeType extends ItemType>(collectionResource: CollectionResource<ItemTypeType>, options: CollectionOptionsInterface<ItemTypeType> & {
227
+ remoteItems: true;
228
+ }, conversionMap: ItemIdConversionMap): CollectionViewResource<ItemTypeType, RemoteViewResource<ItemTypeType>>;
229
+ cloneCollection<ItemTypeType extends ItemType>(collectionResource: CollectionResource<ItemTypeType>, options: CollectionOptionsInterface<ItemTypeType> & {
230
+ editCollection: true;
231
+ }, conversionMap: ItemIdConversionMap): CollectionEditResource<ItemTypeType, LocalViewResource<ItemTypeType>>;
232
+ cloneCollection<ItemTypeType extends ItemType>(collectionResource: CollectionResource<ItemTypeType>, options: CollectionOptionsInterface<ItemTypeType>, conversionMap: ItemIdConversionMap): CollectionViewResource<ItemTypeType, LocalViewResource<ItemTypeType>>;
233
+ cloneItem<ItemTypeType extends ItemType>(itemResource: ItemResource<ItemTypeType>, options: ItemOptionsInterface & {
234
+ edit: true;
235
+ }): PromiseInterface<EditResource<ItemTypeType>>;
236
+ cloneItem<ItemTypeType extends ItemType>(itemResource: ItemResource<ItemTypeType>, options: ItemOptionsInterface & {
237
+ remote: true;
238
+ }): PromiseInterface<RemoteViewResource<ItemTypeType>>;
239
+ cloneItem<ItemTypeType extends ItemType>(itemResource: ItemResource<ItemTypeType>, options: ItemOptionsInterface): PromiseInterface<LocalViewResource<ItemTypeType>>;
240
+ getAllLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
241
+ editItems: true;
242
+ editCollection: true;
243
+ }): PromiseInterface<CollectionResourceParentIdMap<CollectionEditResource<ItemTypeType, EditResource<ItemTypeType>>>>;
244
+ getAllLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
245
+ remoteItems: true;
246
+ editCollection: true;
247
+ }): PromiseInterface<CollectionResourceParentIdMap<CollectionEditResource<ItemTypeType, RemoteViewResource<ItemTypeType>>>>;
248
+ getAllLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
249
+ editCollection: true;
250
+ }): PromiseInterface<CollectionResourceParentIdMap<CollectionEditResource<ItemTypeType, LocalViewResource<ItemTypeType>>>>;
251
+ getAllLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
252
+ editItems: true;
253
+ }): PromiseInterface<CollectionResourceParentIdMap<CollectionViewResource<ItemTypeType, EditResource<ItemTypeType>>>>;
254
+ getAllLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
255
+ remoteItems: true;
256
+ }): PromiseInterface<CollectionResourceParentIdMap<CollectionViewResource<ItemTypeType, RemoteViewResource<ItemTypeType>>>>;
257
+ getAllLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType>): PromiseInterface<CollectionResourceParentIdMap<CollectionViewResource<ItemTypeType, LocalViewResource<ItemTypeType>>>>;
258
+ getLinkCollectionsFromDef<ItemTypeType extends ItemType>(linkType: ItemType, linkIdArray: ItemId[], definition: LinkCollectionDefinition<ItemTypeType>): PromiseInterface<CollectionResourceParentIdMap<CollectionResource<ItemTypeType>>>;
259
+ getLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, linkIdArray: ItemId[], itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
260
+ editItems: true;
261
+ editCollection: true;
262
+ }): PromiseInterface<CollectionResourceParentIdMap<CollectionEditResource<ItemTypeType, EditResource<ItemTypeType>>>>;
263
+ getLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, linkIdArray: ItemId[], itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
264
+ remoteItems: true;
265
+ editCollection: true;
266
+ }): PromiseInterface<CollectionResourceParentIdMap<CollectionEditResource<ItemTypeType, RemoteViewResource<ItemTypeType>>>>;
267
+ getLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, linkIdArray: ItemId[], itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
268
+ editCollection: true;
269
+ }): PromiseInterface<CollectionResourceParentIdMap<CollectionEditResource<ItemTypeType, LocalViewResource<ItemTypeType>>>>;
270
+ getLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, linkIdArray: ItemId[], itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
271
+ editItems: true;
272
+ }): PromiseInterface<CollectionResourceParentIdMap<CollectionViewResource<ItemTypeType, EditResource<ItemTypeType>>>>;
273
+ getLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, linkIdArray: ItemId[], itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
274
+ remoteItems: true;
275
+ }): PromiseInterface<CollectionResourceParentIdMap<CollectionViewResource<ItemTypeType, RemoteViewResource<ItemTypeType>>>>;
276
+ getLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, linkIdArray: ItemId[], itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType>): PromiseInterface<CollectionResourceParentIdMap<CollectionViewResource<ItemTypeType, LocalViewResource<ItemTypeType>>>>;
277
+ getCollectionFromDef<ItemTypeType extends ItemType>(definition: CollectionDefinition<ItemTypeType>): PromiseInterface<CollectionResource<ItemTypeType>>;
278
+ getCollection<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
279
+ editCollection: true;
280
+ editItems: true;
281
+ }): PromiseInterface<CollectionEditResource<ItemTypeType, EditResource<ItemTypeType>>>;
282
+ getCollection<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
283
+ editItems: true;
284
+ }): PromiseInterface<CollectionViewResource<ItemTypeType, EditResource<ItemTypeType>>>;
285
+ getCollection<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
286
+ editCollection: true;
287
+ remoteItems: true;
288
+ }): PromiseInterface<CollectionEditResource<ItemTypeType, RemoteViewResource<ItemTypeType>>>;
289
+ getCollection<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
290
+ remoteItems: true;
291
+ }): PromiseInterface<CollectionViewResource<ItemTypeType, RemoteViewResource<ItemTypeType>>>;
292
+ getCollection<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
293
+ editCollection: true;
294
+ }): PromiseInterface<CollectionEditResource<ItemTypeType, LocalViewResource<ItemTypeType>>>;
295
+ getCollection<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType>): PromiseInterface<CollectionViewResource<ItemTypeType, LocalViewResource<ItemTypeType>>>;
296
+ getCollectionDef<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType>): CollectionDefinition<ItemTypeType>;
297
+ getLinkCollectionsDef<ItemTypeType extends ItemType>(itemType: ItemTypeType, linkField: string, options: CollectionOptionsInterface<ItemTypeType>): LinkCollectionDefinition<ItemTypeType>;
298
+ getItemByState<ItemTypeType extends ItemType>(itemType: ItemTypeType, stateKey: ItemId | string, options: ItemOptionsInterface & {
299
+ edit: true;
300
+ }, isRoot?: boolean): PromiseInterface<EditResource<ItemTypeType>>;
301
+ getItemByState<ItemTypeType extends ItemType>(itemType: ItemTypeType, stateKey: ItemId | string, options: ItemOptionsInterface & {
302
+ remote: true;
303
+ }, isRoot?: boolean): PromiseInterface<RemoteViewResource<ItemTypeType>>;
304
+ getItemByState<ItemTypeType extends ItemType>(itemType: ItemTypeType, stateKey: ItemId | string, options: ItemOptionsInterface, isRoot?: boolean): PromiseInterface<LocalViewResource<ItemTypeType>>;
305
+ getDuplicateById<ItemTypeType extends ItemType>(itemType: ItemTypeType, duplicateId: ItemId, options: ItemOptionsInterface, returnLinks: true, isRoot?: boolean): PromiseInterface<EditResourceLinks<ItemTypeType>>;
306
+ getDuplicateById<ItemTypeType extends ItemType>(itemType: ItemTypeType, duplicateId: ItemId, options: ItemOptionsInterface, returnLinks?: boolean, isRoot?: boolean): PromiseInterface<EditResource<ItemTypeType>>;
307
+ getNewResourceWithId<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemId: ItemId, options: ItemOptionsInterface, returnLinks: true, isRoot?: boolean): PromiseInterface<EditResourceLinks<ItemTypeType>>;
308
+ getNewResourceWithId<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemId: ItemId, options: ItemOptionsInterface, returnLinks?: boolean, isRoot?: boolean): PromiseInterface<EditResource<ItemTypeType>>;
309
+ getNewResource<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: ItemOptionsInterface, returnLinks: true, isRoot?: boolean): PromiseInterface<EditResourceLinks<ItemTypeType>>;
310
+ getNewResource<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: ItemOptionsInterface, returnLinks?: boolean, isRoot?: boolean): PromiseInterface<EditResource<ItemTypeType>>;
311
+ getItemsByQuery<ItemTypeType extends ItemType>(itemType: ItemTypeType, query: ApiQuery, options: ItemOptionsInterface & {
312
+ edit: true;
313
+ }): PromiseInterface<Array<EditResource<ItemTypeType>>>;
314
+ getItemsByQuery<ItemTypeType extends ItemType>(itemType: ItemTypeType, query: ApiQuery, options: ItemOptionsInterface & {
315
+ remote: true;
316
+ }): PromiseInterface<Array<RemoteViewResource<ItemTypeType>>>;
317
+ getItemsByQuery<ItemTypeType extends ItemType>(itemType: ItemTypeType, query: ApiQuery, options: ItemOptionsInterface): PromiseInterface<Array<LocalViewResource<ItemTypeType>>>;
318
+ getItemsById<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemIds: ItemId[], options: ItemOptionsInterface & {
319
+ edit: true;
320
+ }): PromiseInterface<Array<EditResource<ItemTypeType>>>;
321
+ getItemsById<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemIds: ItemId[], options: ItemOptionsInterface & {
322
+ remote: true;
323
+ }): PromiseInterface<Array<RemoteViewResource<ItemTypeType>>>;
324
+ getItemsById<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemIds: ItemId[], options: ItemOptionsInterface): PromiseInterface<Array<LocalViewResource<ItemTypeType>>>;
325
+ getItemById<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemId: ItemId, options: ItemOptionsInterface & {
326
+ edit: true;
327
+ }, isRoot?: boolean): PromiseInterface<EditResource<ItemTypeType>>;
328
+ getItemById<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemId: ItemId, options: ItemOptionsInterface & {
329
+ remote: true;
330
+ }, isRoot?: boolean): PromiseInterface<RemoteViewResource<ItemTypeType>>;
331
+ getItemById<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemId: ItemId, options: ItemOptionsInterface, isRoot?: boolean): PromiseInterface<LocalViewResource<ItemTypeType>>;
332
+ /**
333
+ * @description
334
+ * Fetches the title of an item, does not create an {@link ItemResource ItemResource}
335
+ */
336
+ fetchTitle(itemType: ItemType, itemId: ItemId): PromiseInterface<string>;
337
+ /**
338
+ * @description
339
+ * Merges the passed child Transaction into this transaction and then propagates them to the other child transactions
340
+ */
341
+ applyChangesFromChild(childTransaction: TransactionCache, _breakUpByParent?: boolean, _onAfterCreateCallback?: OnAfterCreateCallback): PromiseInterface<ItemIdConversionMap>;
342
+ /**
343
+ * @description
344
+ * Gets an already cached {@link ItemEntry ItemEntry} and the changes of this specific transaction for that entry
345
+ */
346
+ getLocalItemEntryChangesTuple(itemEntryId: ItemEntry['id']): {
347
+ entry: ItemEntry;
348
+ changes: TransactionItemEntryChanges;
349
+ };
350
+ /**
351
+ * @description
352
+ * Gets an ItemEntry from the cache, doesn't do a API request, used for saving
353
+ */
354
+ getLocalItemEntry(itemEntryId: ItemEntry['id']): ItemEntry | undefined;
355
+ /**
356
+ * @description
357
+ * Gets an ItemEntry from the cache by ItemId
358
+ */
359
+ getLocalItemEntryByItemId(itemType: ItemType, itemId: ItemEntry['itemId']): ItemEntry | undefined;
360
+ /**
361
+ * @description
362
+ * Gets an CollectionEntry from the cache, doesn't do a API request, used for saving
363
+ */
364
+ getLocalCollectionEntry(collectionEntryId: CollectionEntry['id']): CollectionEntry | undefined;
365
+ /**
366
+ * @description
367
+ * Returns the complete {@link InternalChangesDelta InternalChangesDelta} of the TransactionCache, this only takes into account the end result (initial is compared to changes), so changing something and reverting it
368
+ * won't be included
369
+ */
370
+ getDelta(): InternalChangesDelta;
371
+ createItemResource<ItemTypeType extends ItemType>(itemEntry: ItemEntry<ItemTypeType>, options: ItemOptionsInterface & {
372
+ edit: true;
373
+ }, isRoot?: boolean, isNew?: boolean): EditResource<ItemTypeType>;
374
+ createItemResource<ItemTypeType extends ItemType>(itemEntry: ItemEntry<ItemTypeType>, options: ItemOptionsInterface & {
375
+ remote: true;
376
+ }, isRoot?: boolean, isNew?: boolean): RemoteViewResource<ItemTypeType>;
377
+ createItemResource<ItemTypeType extends ItemType>(itemEntry: ItemEntry<ItemTypeType>, options: ItemOptionsInterface, isRoot?: boolean, isNew?: boolean): LocalViewResource<ItemTypeType>;
378
+ createItemResources<ItemTypeType extends ItemType>(itemEntries: Array<ItemEntry<ItemTypeType>>, options: ItemOptionsInterface & {
379
+ edit: true;
380
+ }): Array<EditResource<ItemTypeType>>;
381
+ createItemResources<ItemTypeType extends ItemType>(itemEntries: Array<ItemEntry<ItemTypeType>>, options: ItemOptionsInterface & {
382
+ remote: true;
383
+ }): Array<RemoteViewResource<ItemTypeType>>;
384
+ createItemResources<ItemTypeType extends ItemType>(itemEntries: Array<ItemEntry<ItemTypeType>>, options: ItemOptionsInterface): Array<LocalViewResource<ItemTypeType>>;
385
+ processLinkedItems<ItemTypeType extends ItemType>(linkedEntries: ItemTypeMap<ItemEntry[]>, options: ItemOptionsInterface & {
386
+ edit: true;
387
+ }): ItemResourcesItemTypeMap<EditResource<ItemTypeType>>;
388
+ processLinkedItems<ItemTypeType extends ItemType>(linkedEntries: ItemTypeMap<ItemEntry[]>, options: ItemOptionsInterface & {
389
+ remote: true;
390
+ }): ItemResourcesItemTypeMap<RemoteViewResource<ItemTypeType>>;
391
+ processLinkedItems<ItemTypeType extends ItemType>(linkedEntries: ItemTypeMap<ItemEntry[]>, options: ItemOptionsInterface): ItemResourcesItemTypeMap<LocalViewResource<ItemTypeType>>;
392
+ private createCollectionResources;
393
+ createCollectionResource<ItemTypeType extends ItemType>(collectionEntry: CollectionEntry<ItemTypeType>, resourceOptions: CollectionResourceOptionsInterface<ItemTypeType> & {
394
+ editItems: true;
395
+ editCollection: true;
396
+ }): CollectionEditResource<ItemTypeType, EditResource<ItemTypeType>>;
397
+ createCollectionResource<ItemTypeType extends ItemType>(collectionEntry: CollectionEntry<ItemTypeType>, resourceOptions: CollectionResourceOptionsInterface<ItemTypeType> & {
398
+ remoteItems: true;
399
+ editCollection: true;
400
+ }): CollectionEditResource<ItemTypeType, RemoteViewResource<ItemTypeType>>;
401
+ createCollectionResource<ItemTypeType extends ItemType>(collectionEntry: CollectionEntry<ItemTypeType>, resourceOptions: CollectionResourceOptionsInterface<ItemTypeType> & {
402
+ editCollection: true;
403
+ }): CollectionEditResource<ItemTypeType, LocalViewResource<ItemTypeType>>;
404
+ createCollectionResource<ItemTypeType extends ItemType>(collectionEntry: CollectionEntry<ItemTypeType>, resourceOptions: CollectionResourceOptionsInterface<ItemTypeType> & {
405
+ editItems: true;
406
+ }): CollectionViewResource<ItemTypeType, EditResource<ItemTypeType>>;
407
+ createCollectionResource<ItemTypeType extends ItemType>(collectionEntry: CollectionEntry<ItemTypeType>, resourceOptions: CollectionResourceOptionsInterface<ItemTypeType> & {
408
+ remoteItems: true;
409
+ }): CollectionViewResource<ItemTypeType, RemoteViewResource<ItemTypeType>>;
410
+ createCollectionResource<ItemTypeType extends ItemType>(collectionEntry: CollectionEntry<ItemTypeType>, resourceOptions: CollectionResourceOptionsInterface<ItemTypeType>): CollectionViewResource<ItemTypeType, LocalViewResource<ItemTypeType>>;
411
+ /**
412
+ * @description
413
+ * Returns this transaction and all parents
414
+ */
415
+ getTransactionChain(): AbstractCache[];
416
+ /**
417
+ * @description
418
+ * Fetches all required columns to match/fit in collections
419
+ */
420
+ private expandItemsFromDelta;
421
+ getChangesFromItemChanges<ItemTypeType extends ItemType = any>(changesObject: TransactionItemEntryChanges<ItemTypeType>): FieldMap<ItemTypeType>;
422
+ }
423
+ export {};
@@ -0,0 +1,72 @@
1
+ import { CollectionCacheFactory, CollectionMatcherFactory, ColumnExpansionFactory, ColumnSubsetCacheFactory, RequestColumnExpansionFactory } from '../../../factories';
2
+ import { ChangesDeltaFactory } from '../../../factories/ChangesDeltaFactory';
3
+ import { ApiRequestColumns, ChangesDelta, CollectionEntryOptions, CollectionResource, ColumnUtil, ConversionMap, EntryParent, ExceptionHandlerInterface, ItemIdConversionMap, PromiseInterface } from '../../../index';
4
+ import { ErrorHandlerInterface, PromiseLibraryInterface } from '../../../interfaces';
5
+ import { CollectionEntry, ItemEntry } from '../../../models';
6
+ import { ApiRequestColumn, CollectionEntryParentIdMap, CollectionResourceParentIdMap, ItemId, ItemType, QueryCallback } from '../../../types';
7
+ import { CollectionEntryService, CollectionMatcher, ColumnHandler, KeyService, TransactionItemHandler } from '../../index';
8
+ import { CollectionHandlerBase } from '../CollectionHandlerBase';
9
+ import { TransactionCache } from './TransactionCache';
10
+ export declare class TransactionCollectionHandler extends CollectionHandlerBase {
11
+ private columnSubsetCacheFactory;
12
+ private columnExpansionFactory;
13
+ private changesDeltaFactory;
14
+ private collectionMatcherFactory;
15
+ private columnHandler;
16
+ private errorHandler;
17
+ private itemHandler;
18
+ private keyService;
19
+ private promiseService;
20
+ private exceptionHandler;
21
+ protected transaction: TransactionCache;
22
+ collectionResources: {
23
+ [collectionEntryId: number]: CollectionResource[];
24
+ };
25
+ constructor(requestColumnExpansionFactory: RequestColumnExpansionFactory, columnUtil: ColumnUtil, columnSubsetCacheFactory: ColumnSubsetCacheFactory, columnExpansionFactory: ColumnExpansionFactory, changesDeltaFactory: ChangesDeltaFactory, collectionCacheFactory: CollectionCacheFactory, collectionEntryService: CollectionEntryService, collectionMatcherFactory: CollectionMatcherFactory, columnHandler: ColumnHandler, errorHandler: ErrorHandlerInterface, itemHandler: TransactionItemHandler, keyService: KeyService, promiseService: PromiseLibraryInterface, exceptionHandler: ExceptionHandlerInterface, transaction: TransactionCache);
26
+ getAllCollectionsByItemType<ItemTypeType extends ItemType>(itemType: ItemTypeType): Array<CollectionEntry<ItemTypeType>>;
27
+ createCollectionEntry<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionEntryOptions): CollectionEntry<ItemTypeType>;
28
+ /**
29
+ * @description
30
+ * Calls the {@link CollectionResourceOptions.onItemsCreated onItemsCreated} callback whenever a create request is done on {@link ItemEntry ItemEntries} that fit in the collection
31
+ * Can be used to update maps that use {@link ItemEntry.itemId ItemEntry.itemId}
32
+ *
33
+ * @deprecated
34
+ * You should use itemResource.onChange and compare previous.id with fields.id
35
+ */
36
+ onItemEntriesCreated(collectionEntry: CollectionEntry, conversionMap: ConversionMap): void;
37
+ clearEntry(entry: CollectionEntry): void;
38
+ addResource(resource: CollectionResource): void;
39
+ clearResource(resource: CollectionResource): void;
40
+ /**
41
+ * @description
42
+ * Updates the parents of the passed {@link ItemEntry ItemEntries}, returns `void` because you should use the {@link CollectionResourceOptions.onAdd onAdd} and {@link CollectionResourceOptions.onRemove onRemove} callbacks
43
+ */
44
+ moveItems<CollectionEntryType extends CollectionEntry>(sourceCollectionEntry: CollectionEntryType, destinationCollectionEntry: CollectionEntryType, itemEntries: Array<ItemEntry<CollectionEntryType['itemType']>>): void;
45
+ extendCollectionEntry<CollectionEntryType extends CollectionEntry>(collectionEntry: CollectionEntryType, queryCallback: QueryCallback): PromiseInterface<CollectionEntryType>;
46
+ cloneCollectionEntry<CollectionEntryType extends CollectionEntry>(sourceEntry: CollectionEntryType, parent: EntryParent, conversionMap?: ItemIdConversionMap): CollectionEntry<CollectionEntryType['itemType']>;
47
+ getCollectionMatcher(): CollectionMatcher;
48
+ fetchCollectionEntry<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionEntryOptions): PromiseInterface<CollectionEntry<ItemTypeType>>;
49
+ fetchLinkedCollectionEntries<ItemTypeType extends ItemType>(parentType: ItemType, parentIdArray: ItemId[] | (() => ItemId[]), itemType: ItemTypeType, options: CollectionEntryOptions): PromiseInterface<CollectionEntryParentIdMap<ItemTypeType>>;
50
+ expandCollectionEntries<ItemTypeType extends ItemType>(parentType: ItemType, itemType: ItemTypeType, collections: CollectionResourceParentIdMap, newColumns: ApiRequestColumn[]): PromiseInterface<CollectionResourceParentIdMap>;
51
+ extendCollectionEntries<T extends CollectionResourceParentIdMap>(parentType: ItemType, itemType: ItemType, options: CollectionEntryOptions, queryCallback: QueryCallback, collections: T): PromiseInterface<void>;
52
+ addItemEntriesToCollectionChanges<CollectionEntryType extends CollectionEntry>(collectionEntry: CollectionEntryType, itemEntries: Array<ItemEntry<CollectionEntryType['itemType']>>): void;
53
+ isLocal(options: CollectionEntryOptions): boolean;
54
+ expandCollectionEntry<CollectionEntryType extends CollectionEntry>(changesDelta: ChangesDelta, collectionEntry: CollectionEntryType, newColumns: ApiRequestColumns): PromiseInterface<CollectionEntryType>;
55
+ /**
56
+ * @description
57
+ * When {@link ItemEntry ItemEntries} are added to the changes of a {@link CollectionEntry CollectionEntry} all {@link CollectionResource CollectionResources}
58
+ * should get new {@link ItemResource ItemResources} for the newly added entries
59
+ */
60
+ protected handleAddedItemEntriesCallback<CollectionEntryType extends CollectionEntry>(collectionEntry: CollectionEntryType, addedEntries: Array<ItemEntry<CollectionEntryType['itemType']>>): void;
61
+ /**
62
+ * @description
63
+ * When {@link ItemEntry ItemEntries} are removed from the changes of a {@link CollectionEntry CollectionEntry} the {@link ItemResource ItemResources} of the ItemEntries should be removed from all {@link CollectionResource CollectionResources}
64
+ */
65
+ protected handleRemovedItemEntriesCallback<CollectionEntryType extends CollectionEntry>(collectionEntry: CollectionEntryType, removedItemEntries: Array<ItemEntry<CollectionEntryType['itemType']>>): void;
66
+ private fetchCollectionData;
67
+ /**
68
+ * @description
69
+ * Fetches {@link CollectionEntry CollectionEntries} of which the parents are local
70
+ */
71
+ private fetchLinkedLocalCollectionEntries;
72
+ }
@@ -0,0 +1,19 @@
1
+ import { ErrorHandlerInterface, ExceptionHandlerInterface, PromiseLibraryInterface } from '../../../interfaces';
2
+ import { ItemIdConversionMap, PromiseInterface } from '../../../types';
3
+ import { TransactionCache } from './TransactionCache';
4
+ export declare type TransactionCacheCallbackCondition = 'always' | 'onClose' | 'skipOnClose';
5
+ export declare type TransactionCacheCallbackType = {
6
+ onBeforeSave: (transaction: TransactionCache) => any;
7
+ onSaveSuccess: (transaction: TransactionCache, conversionMap: ItemIdConversionMap) => any;
8
+ };
9
+ export declare class TransactionEventHandler {
10
+ private errorHandler;
11
+ private exceptionHandler;
12
+ private promiseService;
13
+ private callbacks;
14
+ constructor(errorHandler: ErrorHandlerInterface, exceptionHandler: ExceptionHandlerInterface, promiseService: PromiseLibraryInterface);
15
+ registerCallback<T extends keyof TransactionCacheCallbackType>(type: T, key: string, callback: TransactionCacheCallbackType[T], condition?: TransactionCacheCallbackCondition, priority?: number): () => void;
16
+ executeCallbacks<T extends keyof TransactionCacheCallbackType>(type: T, execute: (callback: TransactionCacheCallbackType[T]) => any, closeTab: boolean): PromiseInterface<any>;
17
+ private getPriorityLevel;
18
+ private executeCallbacksPriorityLevel;
19
+ }
@@ -0,0 +1,113 @@
1
+ import { ChangesDeltaFactory, ColumnExpansionFactory, ColumnSetFactory, ColumnSubsetCacheFactory, ItemCacheFactory, ItemEntryFactory } from '../../../factories';
2
+ import { ErrorHandlerInterface, ExceptionHandlerInterface, PromiseLibraryInterface } from '../../../interfaces';
3
+ import { ItemEntry, ItemEntryOptions, ItemResource, Template } from '../../../models';
4
+ import { ApiQuery, ApiRequestColumns, EntryParentNull, FieldMap, ItemId, ItemIdConversionMap, ItemType, ItemTypeMap, PromiseInterface, ResponseColumnItemTypeMap } from '../../../types';
5
+ import { ChangesDelta, ChangesDeltaItemCreateDelta } from '../../ChangesDelta';
6
+ import { ChangesDeltaBase, ChangesDeltaItemUpdateDelta, ChangesDeltaResult } from '../../ChangesDeltaBase';
7
+ import { ApiFormatter, ColumnHandler, ColumnInfo, ColumnSubsetCache, ColumnUtil, ItemEntryService, KeyService } from '../../index';
8
+ import { TemplateCache } from '../../TemplateCache';
9
+ import { ItemHandlerBase } from '../ItemHandlerBase';
10
+ import { TransactionCache } from './TransactionCache';
11
+ export declare type TransactionItemEntryChanges<ItemTypeType extends ItemType = any> = {
12
+ initial: FieldMap<ItemTypeType>;
13
+ changes: FieldMap<ItemTypeType>;
14
+ };
15
+ /**
16
+ * @description
17
+ * In a {@link TransactionCache Transaction} only local items can be stored, so all entries in {@link TransactionItemHandler.entries this.entries} are local
18
+ * If a non-local entry is requested it should be passed on to the {@link ServerItemHandler ServerItemHandler} which will fetchCollectionEntry the entry from the server
19
+ */
20
+ export declare class TransactionItemHandler extends ItemHandlerBase {
21
+ private changesDeltaFactory;
22
+ private exceptionHandler;
23
+ private templateCache;
24
+ private columnExpansionFactory;
25
+ private columnHandler;
26
+ private columnSetFactory;
27
+ private columnSubsetCacheFactory;
28
+ private itemEntryService;
29
+ private keyService;
30
+ protected transaction: TransactionCache;
31
+ deletedItems: ItemTypeMap<ItemEntry[]>;
32
+ itemChanges: {
33
+ [itemEntryId: number]: TransactionItemEntryChanges;
34
+ };
35
+ itemResources: {
36
+ [itemEntryId: number]: ItemResource[];
37
+ };
38
+ constructor(changesDeltaFactory: ChangesDeltaFactory, exceptionHandler: ExceptionHandlerInterface, templateCache: TemplateCache, columnExpansionFactory: ColumnExpansionFactory, columnHandler: ColumnHandler, columnSetFactory: ColumnSetFactory, columnSubsetCacheFactory: ColumnSubsetCacheFactory, errorHandler: ErrorHandlerInterface, itemEntryService: ItemEntryService, keyService: KeyService, promiseService: PromiseLibraryInterface, columnUtil: ColumnUtil, apiFormatter: ApiFormatter, itemEntryFactory: ItemEntryFactory, itemCacheFactory: ItemCacheFactory, transaction: TransactionCache);
39
+ createItemEntry(createTuple: ChangesDeltaItemCreateDelta): ItemEntry;
40
+ /**
41
+ * @description
42
+ * Gets the local {@link FieldMap changes} of the {@link ItemEntry entry} on the {@link TransactionCache transaction} in a formatted way the API accepts
43
+ */
44
+ formatRequest<ItemEntryType extends ItemEntry>(entry: ItemEntryType): FieldMap<ItemEntryType['itemType']>;
45
+ /**
46
+ * @description
47
+ * Fetches a new {@link Template template} and creates new {@link ItemEntry itemEntries} with the passed values
48
+ */
49
+ createItems<ItemTypeType extends ItemType>(itemType: ItemTypeType, valuesArray: Array<FieldMap<ItemTypeType>>, parent: EntryParentNull): PromiseInterface<ChangesDeltaResult>;
50
+ clearItemEntry(entry: ItemEntry): void;
51
+ /**
52
+ * @description
53
+ * Stores am {@link ItemResource ItemResource} on the transaction, used to call {@link ItemResource.options.onChange the onChange callback}
54
+ */
55
+ addResource(resource: ItemResource): void;
56
+ /**
57
+ * @description
58
+ * Removes a resource from the transaction, preventing the {@link ItemResource.options.onChange the onChange callback} from being called.
59
+ * You should call this function when the resource is no longer needed
60
+ */
61
+ clearResource(resource: ItemResource): void;
62
+ detectChanges(): boolean;
63
+ /**
64
+ * @description
65
+ * Checks if the transaction has changes for the passed {@link ItemEntry.id ItemEntryId}
66
+ *
67
+ * -----
68
+ * @remarks
69
+ * Compares every field (of the entry) in {@link TransactionItemHandler.itemChanges itemChanges} with the initial fields, because fields are copied over when creating a resource having something in itemChanges doesn't actually mean that there are changes (just that a resource has been made)
70
+ */
71
+ detectEntryChanges(itemEntryId: ItemEntry['id']): boolean;
72
+ /**
73
+ * @description
74
+ * Processes on a cached entry, if there are no {@link TransactionItemHandler.itemChanges itemChanges} the new values will not be processed, unless forceOverwrite is set
75
+ *
76
+ * @param itemEntryChangesTuple The changes tuple
77
+ * @param forceOverwrite Instead of calling {@link ApiFormatter.mergeCopyFields mergeCopyFields}, {@link ApiFormatter.copyFields copyFields} will be used (because API values are always right)
78
+ * @param updateInitial Should be `true` if called by applyChangesFromParent
79
+ *
80
+ * @returns
81
+ * The previous changes {@link FieldMap FieldMap}
82
+ */
83
+ processItemEntryChanges<ItemTypeType extends ItemType = any>(itemEntryChangesTuple: ChangesDeltaItemUpdateDelta<ItemTypeType>, forceOverwrite?: boolean, updateInitial?: boolean): FieldMap<ItemTypeType>;
84
+ cloneItemEntries<ItemTypeType extends ItemType>(itemEntries: Array<ItemEntry<ItemTypeType>>, conversionMap?: ItemIdConversionMap, modifyFieldsCallback?: (sourceEntry: ItemEntry<ItemTypeType>, fields: FieldMap<ItemTypeType>) => void): PromiseInterface<ChangesDeltaResult>;
85
+ cloneItemEntry<ItemTypeType extends ItemType>(changesDelta: ChangesDelta, sourceEntry: ItemEntry<ItemTypeType>, newFields?: FieldMap<ItemTypeType>, conversionMap?: ItemIdConversionMap, modifyFieldsCallback?: (sourceEntry: ItemEntry<ItemTypeType>, fields: FieldMap<ItemTypeType>) => void): ItemId;
86
+ fetchItemEntriesByQuery<ItemTypeType extends ItemType>(itemType: ItemTypeType, query: ApiQuery, entryOptions: ItemEntryOptions): PromiseInterface<Array<ItemEntry<ItemTypeType>>>;
87
+ fetchItemEntry<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemId: ItemId, options: ItemEntryOptions): PromiseInterface<ItemEntry<ItemTypeType>>;
88
+ /**
89
+ * @description
90
+ * Fetches a template and creates a new {@link ItemEntry ItemEntry}, will error if the ItemEntry with the given ItemId already exists
91
+ */
92
+ fetchNewItemEntry<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemId: ItemId, options: ItemEntryOptions): PromiseInterface<ChangesDeltaResult>;
93
+ fetchItemEntries<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemIds: ItemId[], options: ItemEntryOptions): PromiseInterface<Array<ItemEntry<ItemTypeType>>>;
94
+ fetchTitle(itemType: ItemType, itemId: ItemId): PromiseInterface<string>;
95
+ resolveLocalItemEntry<ItemTypeType extends ItemType>(changesDelta: ChangesDelta, itemEntry: ItemEntry<ItemTypeType>, columnSubsetCache: ColumnSubsetCache<ItemTypeType>, options: ItemEntryOptions): PromiseInterface<ItemEntry<ItemTypeType>>;
96
+ private getColumnDifference;
97
+ private resolveLocal;
98
+ createLocalEntries(changesDelta: ChangesDelta, parentType: ItemType, localParentId: ItemId, template: Template<ItemType>, itemIdConversion: ItemIdConversionMap, filterItemEntry?: <ItemTypeType extends ItemType>(itemType: ItemTypeType, fields: FieldMap<ItemTypeType>) => boolean, // return true to include item
99
+ modifyFieldsCallback?: <ItemTypeType extends ItemType>(itemType: ItemTypeType, fields: FieldMap<ItemTypeType>, itemIdConversionMap: ItemIdConversionMap) => void): void;
100
+ expandLocalItemEntries<ItemTypeType extends ItemType>(changesDelta: ChangesDeltaBase, itemType: ItemTypeType, itemEntries: Array<ItemEntry<ItemTypeType>>, requestColumns: ApiRequestColumns, responseColumns: ResponseColumnItemTypeMap): PromiseInterface<Array<ItemEntry<ItemTypeType>>>;
101
+ updateItemValues<ItemTypeType extends ItemType>(changes: FieldMap<ItemTypeType>, parent: EntryParentNull, itemColumns: Array<ColumnInfo<ItemTypeType>>, conversionMap: ItemIdConversionMap): FieldMap<ItemTypeType>;
102
+ /**
103
+ * @description
104
+ * Fetches the data for the passed ItemType/ItemId/columns, is able to fetchCollectionEntry non-local derived values.
105
+ *
106
+ * @remark
107
+ * Assumes the the ItemEntry with the given ItemType-ItemId is already cached
108
+ */
109
+ fetchLocalItemEntryData<ItemTypeType extends ItemType>(changesDelta: ChangesDelta, itemType: ItemTypeType, itemId: ItemId, columnSubsetCache: ColumnSubsetCache<ItemTypeType>, options: ItemEntryOptions): PromiseInterface<any>;
110
+ fetchLocalItemEntries<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemIds: ItemId[], options: ItemEntryOptions): PromiseInterface<Array<ItemEntry<ItemTypeType>>>;
111
+ private expandLocalItemEntry;
112
+ private getLocalValues;
113
+ }