@rentman/rm-core 2.3.0 → 3.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 (112) hide show
  1. package/changelog.md +8 -0
  2. package/dist/rm-core.js +9252 -8681
  3. package/dist/rm-core.min.js +16 -1
  4. package/dist/{src → types}/classes/ApiFormatter.d.ts +1 -1
  5. package/dist/{src → types}/classes/cache/ItemHandlerBase.d.ts +1 -1
  6. package/dist/{src → types}/classes/cache/server/ServerItemHandler.d.ts +1 -1
  7. package/dist/{src → types}/classes/cache/transaction/TransactionCache.d.ts +54 -157
  8. package/dist/{src → types}/classes/index.d.ts +1 -0
  9. package/dist/types/factories/CollectionResourceFactory.d.ts +16 -0
  10. package/dist/{src → types}/factories/ItemEntryFactory.d.ts +3 -5
  11. package/dist/types/factories/ItemResourceFactory.d.ts +17 -0
  12. package/dist/types/models/CollectionResource.d.ts +62 -0
  13. package/dist/{src → types}/models/CollectionResourceOptions.d.ts +0 -4
  14. package/dist/{src → types}/models/ItemResource.d.ts +12 -6
  15. package/dist/types/models/ItemResourceOptions.d.ts +6 -0
  16. package/dist/{src → types}/models/index.d.ts +0 -6
  17. package/dist/{src → types}/types/ItemTypesCollection.d.ts +5 -5
  18. package/package.json +9 -9
  19. package/dist/src/factories/CollectionResourceFactory.d.ts +0 -35
  20. package/dist/src/factories/ItemResourceFactory.d.ts +0 -32
  21. package/dist/src/models/CollectionEditResource.d.ts +0 -17
  22. package/dist/src/models/CollectionResource.d.ts +0 -52
  23. package/dist/src/models/CollectionViewResource.d.ts +0 -7
  24. package/dist/src/models/EditResource.d.ts +0 -16
  25. package/dist/src/models/ItemResourceOptions.d.ts +0 -9
  26. package/dist/src/models/LocalViewResource.d.ts +0 -7
  27. package/dist/src/models/RemoteViewResource.d.ts +0 -7
  28. package/dist/src/models/ViewResource.d.ts +0 -8
  29. /package/dist/{src → types}/classes/ApiRequestService.d.ts +0 -0
  30. /package/dist/{src → types}/classes/ApiResponseProcessor.d.ts +0 -0
  31. /package/dist/{src → types}/classes/ChangesCompilation.d.ts +0 -0
  32. /package/dist/{src → types}/classes/ChangesDelta.d.ts +0 -0
  33. /package/dist/{src → types}/classes/ChangesDeltaBase.d.ts +0 -0
  34. /package/dist/{src → types}/classes/ChangesProcessor.d.ts +0 -0
  35. /package/dist/{src → types}/classes/CollectionCache.d.ts +0 -0
  36. /package/dist/{src → types}/classes/CollectionEntryService.d.ts +0 -0
  37. /package/dist/{src → types}/classes/CollectionMatcher.d.ts +0 -0
  38. /package/dist/{src → types}/classes/CollectionMatcherBase.d.ts +0 -0
  39. /package/dist/{src → types}/classes/CollectionResourceService.d.ts +0 -0
  40. /package/dist/{src → types}/classes/ColumnCache.d.ts +0 -0
  41. /package/dist/{src → types}/classes/ColumnExpansion.d.ts +0 -0
  42. /package/dist/{src → types}/classes/ColumnHandler.d.ts +0 -0
  43. /package/dist/{src → types}/classes/ColumnInfo.d.ts +0 -0
  44. /package/dist/{src → types}/classes/ColumnSet.d.ts +0 -0
  45. /package/dist/{src → types}/classes/ColumnSubsetCache.d.ts +0 -0
  46. /package/dist/{src → types}/classes/ColumnUtil.d.ts +0 -0
  47. /package/dist/{src → types}/classes/CreateRequest.d.ts +0 -0
  48. /package/dist/{src → types}/classes/InternalChangesDelta.d.ts +0 -0
  49. /package/dist/{src → types}/classes/ItemCache.d.ts +0 -0
  50. /package/dist/{src → types}/classes/ItemCreateService.d.ts +0 -0
  51. /package/dist/{src → types}/classes/ItemEntryService.d.ts +0 -0
  52. /package/dist/{src → types}/classes/KeyService.d.ts +0 -0
  53. /package/dist/{src → types}/classes/LockService.d.ts +0 -0
  54. /package/dist/{src → types}/classes/ModuleChangesCompilation.d.ts +0 -0
  55. /package/dist/{src → types}/classes/QueryColumnExtractor.d.ts +0 -0
  56. /package/dist/{src → types}/classes/QueryMatcher.d.ts +0 -0
  57. /package/dist/{src → types}/classes/QueryParser.d.ts +0 -0
  58. /package/dist/{src → types}/classes/QueryParserBase.d.ts +0 -0
  59. /package/dist/{src → types}/classes/QueryService.d.ts +0 -0
  60. /package/dist/{src → types}/classes/RequestBuffer.d.ts +0 -0
  61. /package/dist/{src → types}/classes/RequestBufferManager.d.ts +0 -0
  62. /package/dist/{src → types}/classes/RequestColumnExpansion.d.ts +0 -0
  63. /package/dist/{src → types}/classes/SocketMessageHandler.d.ts +0 -0
  64. /package/dist/{src → types}/classes/TemplateCache.d.ts +0 -0
  65. /package/dist/{src → types}/classes/Util.d.ts +0 -0
  66. /package/dist/{src → types}/classes/cache/AbstractCache.d.ts +0 -0
  67. /package/dist/{src → types}/classes/cache/CollectionHandlerBase.d.ts +0 -0
  68. /package/dist/{src → types}/classes/cache/CollectionMatcherCacheProcessor.d.ts +0 -0
  69. /package/dist/{src → types}/classes/cache/server/ServerCache.d.ts +0 -0
  70. /package/dist/{src → types}/classes/cache/server/ServerCollectionHandler.d.ts +0 -0
  71. /package/dist/{src → types}/classes/cache/transaction/TransactionCollectionHandler.d.ts +0 -0
  72. /package/dist/{src → types}/classes/cache/transaction/TransactionEventHandler.d.ts +0 -0
  73. /package/dist/{src → types}/classes/cache/transaction/TransactionItemHandler.d.ts +0 -0
  74. /package/dist/{src → types}/classes/cache/transaction/TransactionValidator.d.ts +0 -0
  75. /package/dist/{src → types}/constants.d.ts +0 -0
  76. /package/dist/{src → types}/core.d.ts +0 -0
  77. /package/dist/{src → types}/factories/ApiResponseProcessorFactory.d.ts +0 -0
  78. /package/dist/{src → types}/factories/ChangesCompilationFactory.d.ts +0 -0
  79. /package/dist/{src → types}/factories/ChangesDeltaFactory.d.ts +0 -0
  80. /package/dist/{src → types}/factories/ChangesProcessorFactory.d.ts +0 -0
  81. /package/dist/{src → types}/factories/CollectionCacheFactory.d.ts +0 -0
  82. /package/dist/{src → types}/factories/CollectionEntryFactory.d.ts +0 -0
  83. /package/dist/{src → types}/factories/CollectionMatcherFactory.d.ts +0 -0
  84. /package/dist/{src → types}/factories/ColumnExpansionFactory.d.ts +0 -0
  85. /package/dist/{src → types}/factories/ColumnInfoFactory.d.ts +0 -0
  86. /package/dist/{src → types}/factories/ColumnSetFactory.d.ts +0 -0
  87. /package/dist/{src → types}/factories/ColumnSubsetCacheFactory.d.ts +0 -0
  88. /package/dist/{src → types}/factories/CreateRequestFactory.d.ts +0 -0
  89. /package/dist/{src → types}/factories/ItemCacheFactory.d.ts +0 -0
  90. /package/dist/{src → types}/factories/ModuleChangesCompilationFactory.d.ts +0 -0
  91. /package/dist/{src → types}/factories/QueryMatcherFactory.d.ts +0 -0
  92. /package/dist/{src → types}/factories/QueryParserFactory.d.ts +0 -0
  93. /package/dist/{src → types}/factories/RequestColumnExpansionFactory.d.ts +0 -0
  94. /package/dist/{src → types}/factories/TemplateFactory.d.ts +0 -0
  95. /package/dist/{src → types}/factories/TransactionCacheFactory.d.ts +0 -0
  96. /package/dist/{src → types}/factories/index.d.ts +0 -0
  97. /package/dist/{src → types}/index.d.ts +0 -0
  98. /package/dist/{src → types}/interfaces/ApiRequestServiceInterface.d.ts +0 -0
  99. /package/dist/{src → types}/interfaces/AuthInterface.d.ts +0 -0
  100. /package/dist/{src → types}/interfaces/ErrorHandlerInterface.d.ts +0 -0
  101. /package/dist/{src → types}/interfaces/ExceptionHandlerInterface.d.ts +0 -0
  102. /package/dist/{src → types}/interfaces/LinkTreeServiceInterface.d.ts +0 -0
  103. /package/dist/{src → types}/interfaces/PromiseLibraryInterface.d.ts +0 -0
  104. /package/dist/{src → types}/interfaces/SocketMessageInterface.d.ts +0 -0
  105. /package/dist/{src → types}/interfaces/index.d.ts +0 -0
  106. /package/dist/{src → types}/models/CollectionEntry.d.ts +0 -0
  107. /package/dist/{src → types}/models/CollectionEntryOptions.d.ts +0 -0
  108. /package/dist/{src → types}/models/ItemEntry.d.ts +0 -0
  109. /package/dist/{src → types}/models/ItemEntryOptions.d.ts +0 -0
  110. /package/dist/{src → types}/models/Template.d.ts +0 -0
  111. /package/dist/{src → types}/types/PromiseInterface.d.ts +0 -0
  112. /package/dist/{src → types}/types/index.d.ts +0 -0
@@ -1,4 +1,4 @@
1
- import * as moment from 'moment';
1
+ import moment from 'moment';
2
2
  import { ColumnInfo } from '../classes';
3
3
  import { FieldMap, ItemType } from '../types';
4
4
  export declare class ApiFormatter {
@@ -50,7 +50,7 @@ export declare abstract class ItemHandlerBase {
50
50
  * @description
51
51
  * Processes the passed {@link ChangesDeltaItemUpdateDelta update delta} on the transaction, if there are no {@link TransactionItemHandler.itemChanges itemChanges} the new values will not be processed
52
52
  */
53
- abstract processItemEntryChanges(itemEntryChangesTuple: ChangesDeltaItemUpdateDelta): void;
53
+ abstract processItemEntryChanges(itemEntryChangesTuple: ChangesDeltaItemUpdateDelta, forceOverwrite: boolean, updateInitial: boolean, isCalledAfterSocketUpdate: boolean, createItemChangesIfNoneExist: boolean): void;
54
54
  /**
55
55
  * @description
56
56
  * Traverses the column path and returns the fields of the derived item, returns undefined if the item isn't found
@@ -23,7 +23,7 @@ export declare class ServerItemHandler extends ItemHandlerBase {
23
23
  * @description
24
24
  * Processes updates on a cached entry
25
25
  */
26
- processItemEntryChanges<ItemTypeType extends ItemType = any>(itemEntryChangesTuple: ChangesDeltaItemUpdateDelta<ItemTypeType>, _forceOverwrite?: boolean, _updateInitial?: boolean, _isCalledAfterSocketUpdate?: boolean, _createItemChangesIfNoneExist?: boolean): FieldMap<ItemTypeType>;
26
+ processItemEntryChanges<ItemTypeType extends ItemType = any>(itemEntryChangesTuple: ChangesDeltaItemUpdateDelta<ItemTypeType>, _forceOverwrite?: boolean, _updateInitial?: boolean, _isCalledAfterSocketUpdate?: boolean, _createItemChangesIfNoneExist?: boolean): FieldMap<ItemTypeType> | null;
27
27
  copyTransactionItemEntryChanges(itemEntryChanges: TransactionItemEntryChanges, entry: ItemEntry): ServerItemEntryChanges;
28
28
  fetchItemEntry<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemId: ItemId, options: ItemEntryOptions): PromiseInterface<ItemEntry<ItemTypeType>>;
29
29
  fetchItemEntriesByQuery<ItemTypeType extends ItemType>(itemType: ItemTypeType, query: ApiQuery, entryOptions: ItemEntryOptions): PromiseInterface<Array<ItemEntry<ItemTypeType>>>;
@@ -3,7 +3,7 @@ import { CollectionCacheFactory, CollectionEntryFactory, CollectionMatcherFactor
3
3
  import { ChangesDeltaFactory } from '../../../factories/ChangesDeltaFactory';
4
4
  import { AuthInterface, ErrorHandlerInterface, ExceptionHandlerInterface, PromiseLibraryInterface } from '../../../interfaces';
5
5
  import { LinkTreeServiceInterface } from '../../../interfaces/LinkTreeServiceInterface';
6
- import { CollectionEditResource, CollectionEntry, CollectionResource, CollectionResourceOptionsInterface, CollectionViewResource, EditResource, ItemEntry, ItemResource, LocalViewResource, RemoteViewResource } from '../../../models';
6
+ import { CollectionEntry, CollectionResource, CollectionResourceOptionsInterface, ItemEntry, ItemResource } from '../../../models';
7
7
  import { ApiQuery, CollectionDefinition, CollectionOptionsInterface, CollectionResourceParentIdMap, ConversionMap, CreateRequestParameterMap, EntryParentNull, FieldMap, ItemId, ItemIdConversionMap, ItemOptionsInterface, ItemResourcesItemTypeMap, ItemType, ItemTypeMap, LinkCollectionDefinition, PromiseInterface } from '../../../types';
8
8
  import { ChangesDelta } from '../../ChangesDelta';
9
9
  import { ChangesDeltaResult } from '../../ChangesDeltaBase';
@@ -20,8 +20,8 @@ import { TemplateCache } from '../../TemplateCache';
20
20
  import { AbstractCache } from '../AbstractCache';
21
21
  import { ServerCache } from '../server/ServerCache';
22
22
  import { TransactionEventHandler } from './TransactionEventHandler';
23
- declare type EditResourceLinks<ItemTypeType extends ItemType> = {
24
- main: EditResource<ItemTypeType>;
23
+ declare type ItemResourceLinks<ItemTypeType extends ItemType> = {
24
+ main: ItemResource<ItemTypeType>;
25
25
  linked: ItemResourcesItemTypeMap;
26
26
  };
27
27
  export declare enum TransactionErrorLevel {
@@ -168,7 +168,7 @@ export declare class TransactionCache extends AbstractCache {
168
168
  * @remark
169
169
  * Use {@link CollectionResource.getParent CollectionResource.getParent} instead of {@link TransactionCache.getParent TransactionCache.getParent} if you're getting the parent in the onRemove callback
170
170
  */
171
- getParent<ItemTypeType extends ItemType>(itemEntry: ItemEntry<ItemTypeType>, fromInitial?: boolean, providedFields?: FieldMap<ItemTypeType>): EntryParentNull;
171
+ getParent<ItemTypeType extends ItemType = any>(itemEntry: ItemEntry<ItemTypeType>, fromInitial?: boolean, providedFields?: FieldMap<ItemTypeType>): EntryParentNull;
172
172
  getCollectionChangesRecursively(collectionEntryId: CollectionEntry['id']): ItemEntry[];
173
173
  /**
174
174
  * @description
@@ -256,123 +256,55 @@ export declare class TransactionCache extends AbstractCache {
256
256
  updateItemIdMap(collectionMap: {
257
257
  [itemId: number]: any;
258
258
  }, conversionMap: ConversionMap): void;
259
- cloneCollection<ItemTypeType extends ItemType>(collectionResource: CollectionResource<ItemTypeType>, options: CollectionOptionsInterface<ItemTypeType> & {
260
- editItems: true;
261
- editCollection: true;
262
- }, conversionMap: ItemIdConversionMap): CollectionEditResource<ItemTypeType, EditResource<ItemTypeType>>;
263
- cloneCollection<ItemTypeType extends ItemType>(collectionResource: CollectionResource<ItemTypeType>, options: CollectionOptionsInterface<ItemTypeType> & {
264
- remoteItems: true;
265
- editCollection: true;
266
- }, conversionMap: ItemIdConversionMap): CollectionEditResource<ItemTypeType, RemoteViewResource<ItemTypeType>>;
267
- cloneCollection<ItemTypeType extends ItemType>(collectionResource: CollectionResource<ItemTypeType>, options: CollectionOptionsInterface<ItemTypeType> & {
268
- editItems: true;
269
- }, conversionMap: ItemIdConversionMap): CollectionViewResource<ItemTypeType, EditResource<ItemTypeType>>;
270
- cloneCollection<ItemTypeType extends ItemType>(collectionResource: CollectionResource<ItemTypeType>, options: CollectionOptionsInterface<ItemTypeType> & {
271
- remoteItems: true;
272
- }, conversionMap: ItemIdConversionMap): CollectionViewResource<ItemTypeType, RemoteViewResource<ItemTypeType>>;
273
- cloneCollection<ItemTypeType extends ItemType>(collectionResource: CollectionResource<ItemTypeType>, options: CollectionOptionsInterface<ItemTypeType> & {
274
- editCollection: true;
275
- }, conversionMap: ItemIdConversionMap): CollectionEditResource<ItemTypeType, LocalViewResource<ItemTypeType>>;
276
- cloneCollection<ItemTypeType extends ItemType>(collectionResource: CollectionResource<ItemTypeType>, options: CollectionOptionsInterface<ItemTypeType>, conversionMap: ItemIdConversionMap): CollectionViewResource<ItemTypeType, LocalViewResource<ItemTypeType>>;
277
- cloneItem<ItemTypeType extends ItemType>(itemResource: ItemResource<ItemTypeType>, options: ItemOptionsInterface & {
278
- edit: true;
279
- }): PromiseInterface<EditResource<ItemTypeType>>;
280
- cloneItem<ItemTypeType extends ItemType>(itemResource: ItemResource<ItemTypeType>, options: ItemOptionsInterface & {
281
- remote: true;
282
- }): PromiseInterface<RemoteViewResource<ItemTypeType>>;
283
- cloneItem<ItemTypeType extends ItemType>(itemResource: ItemResource<ItemTypeType>, options: ItemOptionsInterface): PromiseInterface<LocalViewResource<ItemTypeType>>;
284
- getAllLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
285
- editItems: true;
286
- editCollection: true;
287
- }): PromiseInterface<CollectionResourceParentIdMap<CollectionEditResource<ItemTypeType, EditResource<ItemTypeType>>>>;
288
- getAllLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
289
- remoteItems: true;
290
- editCollection: true;
291
- }): PromiseInterface<CollectionResourceParentIdMap<CollectionEditResource<ItemTypeType, RemoteViewResource<ItemTypeType>>>>;
292
- getAllLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
293
- editCollection: true;
294
- }): PromiseInterface<CollectionResourceParentIdMap<CollectionEditResource<ItemTypeType, LocalViewResource<ItemTypeType>>>>;
295
- getAllLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
296
- editItems: true;
297
- }): PromiseInterface<CollectionResourceParentIdMap<CollectionViewResource<ItemTypeType, EditResource<ItemTypeType>>>>;
298
- getAllLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
299
- remoteItems: true;
300
- }): PromiseInterface<CollectionResourceParentIdMap<CollectionViewResource<ItemTypeType, RemoteViewResource<ItemTypeType>>>>;
301
- getAllLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType>): PromiseInterface<CollectionResourceParentIdMap<CollectionViewResource<ItemTypeType, LocalViewResource<ItemTypeType>>>>;
302
- getLinkCollectionsFromDef<ItemTypeType extends ItemType>(linkType: ItemType, linkIdArray: ItemId[], definition: LinkCollectionDefinition<ItemTypeType>): PromiseInterface<CollectionResourceParentIdMap<CollectionResource<ItemTypeType>>>;
303
- getLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, linkIdArray: ItemId[], itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
304
- editItems: true;
305
- editCollection: true;
306
- }): PromiseInterface<CollectionResourceParentIdMap<CollectionEditResource<ItemTypeType, EditResource<ItemTypeType>>>>;
307
- getLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, linkIdArray: ItemId[], itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
308
- remoteItems: true;
309
- editCollection: true;
310
- }): PromiseInterface<CollectionResourceParentIdMap<CollectionEditResource<ItemTypeType, RemoteViewResource<ItemTypeType>>>>;
311
- getLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, linkIdArray: ItemId[], itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
312
- editCollection: true;
313
- }): PromiseInterface<CollectionResourceParentIdMap<CollectionEditResource<ItemTypeType, LocalViewResource<ItemTypeType>>>>;
314
- getLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, linkIdArray: ItemId[], itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
315
- editItems: true;
316
- }): PromiseInterface<CollectionResourceParentIdMap<CollectionViewResource<ItemTypeType, EditResource<ItemTypeType>>>>;
317
- getLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, linkIdArray: ItemId[], itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
318
- remoteItems: true;
319
- }): PromiseInterface<CollectionResourceParentIdMap<CollectionViewResource<ItemTypeType, RemoteViewResource<ItemTypeType>>>>;
320
- getLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, linkIdArray: ItemId[], itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType>): PromiseInterface<CollectionResourceParentIdMap<CollectionViewResource<ItemTypeType, LocalViewResource<ItemTypeType>>>>;
259
+ /**
260
+ * @description
261
+ * Clones the {@link CollectionEntry CollectionEntry} and all {@link ItemEntry ItemEntries} in it, and sets the parent of the new entries.
262
+ * Returns a {@link CollectionResource CollectionResource} of the newly cloned {@link CollectionEntry CollectionEntry}
263
+ */
264
+ cloneCollection<ItemTypeType extends ItemType>(collectionResource: CollectionResource<ItemTypeType>, options: CollectionOptionsInterface<ItemTypeType>, conversionMap: ItemIdConversionMap): CollectionResource<ItemTypeType>;
265
+ /**
266
+ * @description
267
+ * Clones the {@link ItemEntry ItemEntry} and returns a {@link ItemResource ItemResource} of the newly cloned {@link ItemEntry ItemEntry}
268
+ */
269
+ cloneItem<ItemTypeType extends ItemType>(itemResource: ItemResource<ItemTypeType>, options: ItemOptionsInterface): PromiseInterface<ItemResource<ItemTypeType>>;
270
+ getAllLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType>): PromiseInterface<CollectionResourceParentIdMap<ItemTypeType>>;
271
+ getLinkCollectionsFromDef<ItemTypeType extends ItemType>(linkType: ItemType, linkIdArray: ItemId[], definition: LinkCollectionDefinition<ItemTypeType>): PromiseInterface<CollectionResourceParentIdMap<ItemTypeType>>;
272
+ getLinkCollections<ItemTypeType extends ItemType>(linkType: ItemType, linkIdArray: ItemId[], itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType>): PromiseInterface<CollectionResourceParentIdMap<ItemTypeType>>;
321
273
  getCollectionFromDef<ItemTypeType extends ItemType>(definition: CollectionDefinition<ItemTypeType>): PromiseInterface<CollectionResource<ItemTypeType>>;
322
- getCollection<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
323
- editCollection: true;
324
- editItems: true;
325
- }): PromiseInterface<CollectionEditResource<ItemTypeType, EditResource<ItemTypeType>>>;
326
- getCollection<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
327
- editItems: true;
328
- }): PromiseInterface<CollectionViewResource<ItemTypeType, EditResource<ItemTypeType>>>;
329
- getCollection<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
330
- editCollection: true;
331
- remoteItems: true;
332
- }): PromiseInterface<CollectionEditResource<ItemTypeType, RemoteViewResource<ItemTypeType>>>;
333
- getCollection<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
334
- remoteItems: true;
335
- }): PromiseInterface<CollectionViewResource<ItemTypeType, RemoteViewResource<ItemTypeType>>>;
336
- getCollection<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType> & {
337
- editCollection: true;
338
- }): PromiseInterface<CollectionEditResource<ItemTypeType, LocalViewResource<ItemTypeType>>>;
339
- getCollection<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType>): PromiseInterface<CollectionViewResource<ItemTypeType, LocalViewResource<ItemTypeType>>>;
274
+ getCollection<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType>): PromiseInterface<CollectionResource<ItemTypeType>>;
340
275
  getCollectionDef<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: CollectionOptionsInterface<ItemTypeType>): CollectionDefinition<ItemTypeType>;
341
276
  getLinkCollectionsDef<ItemTypeType extends ItemType>(itemType: ItemTypeType, linkField: string, options: CollectionOptionsInterface<ItemTypeType>): LinkCollectionDefinition<ItemTypeType>;
342
- getItemByState<ItemTypeType extends ItemType>(itemType: ItemTypeType, stateKey: ItemId | string, options: ItemOptionsInterface & {
343
- edit: true;
344
- }, isRoot?: boolean): PromiseInterface<EditResource<ItemTypeType>>;
345
- getItemByState<ItemTypeType extends ItemType>(itemType: ItemTypeType, stateKey: ItemId | string, options: ItemOptionsInterface & {
346
- remote: true;
347
- }, isRoot?: boolean): PromiseInterface<RemoteViewResource<ItemTypeType>>;
348
- getItemByState<ItemTypeType extends ItemType>(itemType: ItemTypeType, stateKey: ItemId | string, options: ItemOptionsInterface, isRoot?: boolean): PromiseInterface<LocalViewResource<ItemTypeType>>;
349
- getDuplicateById<ItemTypeType extends ItemType>(itemType: ItemTypeType, duplicateId: ItemId, options: ItemOptionsInterface, returnLinks: true, isRoot?: boolean): PromiseInterface<EditResourceLinks<ItemTypeType>>;
350
- getDuplicateById<ItemTypeType extends ItemType>(itemType: ItemTypeType, duplicateId: ItemId, options: ItemOptionsInterface, returnLinks?: boolean, isRoot?: boolean): PromiseInterface<EditResource<ItemTypeType>>;
351
- getNewResourceWithId<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemId: ItemId, options: ItemOptionsInterface, returnLinks: true, isRoot?: boolean): PromiseInterface<EditResourceLinks<ItemTypeType>>;
352
- getNewResourceWithId<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemId: ItemId, options: ItemOptionsInterface, returnLinks?: boolean, isRoot?: boolean): PromiseInterface<EditResource<ItemTypeType>>;
353
- getNewResource<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: ItemOptionsInterface, returnLinks: true, isRoot?: boolean): PromiseInterface<EditResourceLinks<ItemTypeType>>;
354
- getNewResource<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: ItemOptionsInterface, returnLinks?: boolean, isRoot?: boolean): PromiseInterface<EditResource<ItemTypeType>>;
355
- getItemsByQuery<ItemTypeType extends ItemType>(itemType: ItemTypeType, query: ApiQuery, options: ItemOptionsInterface & {
356
- edit: true;
357
- }): PromiseInterface<Array<EditResource<ItemTypeType>>>;
358
- getItemsByQuery<ItemTypeType extends ItemType>(itemType: ItemTypeType, query: ApiQuery, options: ItemOptionsInterface & {
359
- remote: true;
360
- }): PromiseInterface<Array<RemoteViewResource<ItemTypeType>>>;
361
- getItemsByQuery<ItemTypeType extends ItemType>(itemType: ItemTypeType, query: ApiQuery, options: ItemOptionsInterface): PromiseInterface<Array<LocalViewResource<ItemTypeType>>>;
362
- getItemsById<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemIds: ItemId[], options: ItemOptionsInterface & {
363
- edit: true;
364
- }): PromiseInterface<Array<EditResource<ItemTypeType>>>;
365
- getItemsById<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemIds: ItemId[], options: ItemOptionsInterface & {
366
- remote: true;
367
- }): PromiseInterface<Array<RemoteViewResource<ItemTypeType>>>;
368
- getItemsById<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemIds: ItemId[], options: ItemOptionsInterface): PromiseInterface<Array<LocalViewResource<ItemTypeType>>>;
369
- getItemById<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemId: ItemId, options: ItemOptionsInterface & {
370
- edit: true;
371
- }, isRoot?: boolean): PromiseInterface<EditResource<ItemTypeType>>;
372
- getItemById<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemId: ItemId, options: ItemOptionsInterface & {
373
- remote: true;
374
- }, isRoot?: boolean): PromiseInterface<RemoteViewResource<ItemTypeType>>;
375
- getItemById<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemId: ItemId, options: ItemOptionsInterface, isRoot?: boolean): PromiseInterface<LocalViewResource<ItemTypeType>>;
277
+ /**
278
+ * @deprecated
279
+ * Use getItemById/getNewResourceWithId
280
+ *
281
+ * @remarks
282
+ * stateKey can be a keyword or a local id (in case of a refresh)
283
+ */
284
+ getItemByState<ItemTypeType extends ItemType>(itemType: ItemTypeType, stateKey: ItemId | string, options?: ItemOptionsInterface, isRoot?: boolean): PromiseInterface<ItemResource<ItemTypeType>>;
285
+ getDuplicateById<ItemTypeType extends ItemType>(itemType: ItemTypeType, duplicateId: ItemId, options: ItemOptionsInterface, returnLinks: true, isRoot?: boolean): PromiseInterface<ItemResourceLinks<ItemTypeType>>;
286
+ getDuplicateById<ItemTypeType extends ItemType>(itemType: ItemTypeType, duplicateId: ItemId, options: ItemOptionsInterface, returnLinks?: boolean, isRoot?: boolean): PromiseInterface<ItemResource<ItemTypeType>>;
287
+ getNewResourceWithId<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemId: ItemId, options: ItemOptionsInterface, returnLinks: true, isRoot?: boolean): PromiseInterface<ItemResourceLinks<ItemTypeType>>;
288
+ getNewResourceWithId<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemId: ItemId, options: ItemOptionsInterface, returnLinks?: boolean, isRoot?: boolean): PromiseInterface<ItemResource<ItemTypeType>>;
289
+ getNewResource<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: ItemOptionsInterface, returnLinks: true, isRoot?: boolean): PromiseInterface<ItemResourceLinks<ItemTypeType>>;
290
+ getNewResource<ItemTypeType extends ItemType>(itemType: ItemTypeType, options: ItemOptionsInterface, returnLinks?: boolean, isRoot?: boolean): PromiseInterface<ItemResource<ItemTypeType>>;
291
+ /**
292
+ * @description
293
+ * Fetches multiple items with their respective changes of the current {@link TransactionCache transaction}
294
+ */
295
+ getItemsByQuery<ItemTypeType extends ItemType>(itemType: ItemTypeType, query: ApiQuery, options?: ItemOptionsInterface): PromiseInterface<Array<ItemResource<ItemTypeType>>>;
296
+ /**
297
+ * @description
298
+ * Fetches multiple items with their respective changes of the current {@link TransactionCache transaction}
299
+ */
300
+ getItemsById<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemIds: ItemId[], options?: ItemOptionsInterface): PromiseInterface<Array<ItemResource<ItemTypeType>>>;
301
+ /**
302
+ * @description
303
+ * Fetches the item with the changes of the current {@link TransactionCache transaction}
304
+ *
305
+ * @param isRoot Sets the item as the root item of the transaction, new items will be linked to this item (if there's a connection in the LinkTree)
306
+ */
307
+ getItemById<ItemTypeType extends ItemType>(itemType: ItemTypeType, itemId: ItemId, options?: ItemOptionsInterface, isRoot?: boolean): PromiseInterface<ItemResource<ItemTypeType>>;
376
308
  /**
377
309
  * @description
378
310
  * Fetches the title of an item, does not create an {@link ItemResource ItemResource}
@@ -417,45 +349,10 @@ export declare class TransactionCache extends AbstractCache {
417
349
  * won't be included
418
350
  */
419
351
  getDelta(): InternalChangesDelta;
420
- createItemResource<ItemTypeType extends ItemType>(itemEntry: ItemEntry<ItemTypeType>, options: ItemOptionsInterface<EditResource<ItemTypeType>> & {
421
- edit: true;
422
- }, isRoot?: boolean, isNew?: boolean): EditResource<ItemTypeType>;
423
- createItemResource<ItemTypeType extends ItemType>(itemEntry: ItemEntry<ItemTypeType>, options: ItemOptionsInterface<RemoteViewResource<ItemTypeType>> & {
424
- remote: true;
425
- }, isRoot?: boolean, isNew?: boolean): RemoteViewResource<ItemTypeType>;
426
- createItemResource<ItemTypeType extends ItemType>(itemEntry: ItemEntry<ItemTypeType>, options: ItemOptionsInterface<LocalViewResource<ItemTypeType>>, isRoot?: boolean, isNew?: boolean): LocalViewResource<ItemTypeType>;
427
- createItemResources<ItemTypeType extends ItemType>(itemEntries: Array<ItemEntry<ItemTypeType>>, options: ItemOptionsInterface & {
428
- edit: true;
429
- }): Array<EditResource<ItemTypeType>>;
430
- createItemResources<ItemTypeType extends ItemType>(itemEntries: Array<ItemEntry<ItemTypeType>>, options: ItemOptionsInterface & {
431
- remote: true;
432
- }): Array<RemoteViewResource<ItemTypeType>>;
433
- createItemResources<ItemTypeType extends ItemType>(itemEntries: Array<ItemEntry<ItemTypeType>>, options: ItemOptionsInterface): Array<LocalViewResource<ItemTypeType>>;
434
- processLinkedItems<ItemTypeType extends ItemType>(linkedEntries: ItemTypeMap<ItemEntry[]>, options: ItemOptionsInterface & {
435
- edit: true;
436
- }): ItemResourcesItemTypeMap<EditResource<ItemTypeType>>;
437
- processLinkedItems<ItemTypeType extends ItemType>(linkedEntries: ItemTypeMap<ItemEntry[]>, options: ItemOptionsInterface & {
438
- remote: true;
439
- }): ItemResourcesItemTypeMap<RemoteViewResource<ItemTypeType>>;
440
- processLinkedItems<ItemTypeType extends ItemType>(linkedEntries: ItemTypeMap<ItemEntry[]>, options: ItemOptionsInterface): ItemResourcesItemTypeMap<LocalViewResource<ItemTypeType>>;
441
- createCollectionResource<ItemTypeType extends ItemType>(collectionEntry: CollectionEntry<ItemTypeType>, resourceOptions: CollectionResourceOptionsInterface<ItemTypeType> & {
442
- editItems: true;
443
- editCollection: true;
444
- }): CollectionEditResource<ItemTypeType, EditResource<ItemTypeType>>;
445
- createCollectionResource<ItemTypeType extends ItemType>(collectionEntry: CollectionEntry<ItemTypeType>, resourceOptions: CollectionResourceOptionsInterface<ItemTypeType> & {
446
- remoteItems: true;
447
- editCollection: true;
448
- }): CollectionEditResource<ItemTypeType, RemoteViewResource<ItemTypeType>>;
449
- createCollectionResource<ItemTypeType extends ItemType>(collectionEntry: CollectionEntry<ItemTypeType>, resourceOptions: CollectionResourceOptionsInterface<ItemTypeType> & {
450
- editCollection: true;
451
- }): CollectionEditResource<ItemTypeType, LocalViewResource<ItemTypeType>>;
452
- createCollectionResource<ItemTypeType extends ItemType>(collectionEntry: CollectionEntry<ItemTypeType>, resourceOptions: CollectionResourceOptionsInterface<ItemTypeType> & {
453
- editItems: true;
454
- }): CollectionViewResource<ItemTypeType, EditResource<ItemTypeType>>;
455
- createCollectionResource<ItemTypeType extends ItemType>(collectionEntry: CollectionEntry<ItemTypeType>, resourceOptions: CollectionResourceOptionsInterface<ItemTypeType> & {
456
- remoteItems: true;
457
- }): CollectionViewResource<ItemTypeType, RemoteViewResource<ItemTypeType>>;
458
- createCollectionResource<ItemTypeType extends ItemType>(collectionEntry: CollectionEntry<ItemTypeType>, resourceOptions: CollectionResourceOptionsInterface<ItemTypeType>): CollectionViewResource<ItemTypeType, LocalViewResource<ItemTypeType>>;
352
+ createItemResource<ItemTypeType extends ItemType>(itemEntry: ItemEntry<ItemTypeType>, options: ItemOptionsInterface, isRoot?: boolean, isNew?: boolean): ItemResource<ItemTypeType>;
353
+ createItemResources<ItemTypeType extends ItemType>(itemEntries: Array<ItemEntry<ItemTypeType>>, options: ItemOptionsInterface): Array<ItemResource<ItemTypeType>>;
354
+ processLinkedItems<ItemTypeType extends ItemType>(linkedEntries: ItemTypeMap<ItemEntry[]>, options: ItemOptionsInterface): ItemResourcesItemTypeMap<ItemResource<ItemTypeType>>;
355
+ createCollectionResource<ItemTypeType extends ItemType>(collectionEntry: CollectionEntry<ItemTypeType>, resourceOptions: CollectionResourceOptionsInterface<ItemTypeType>): CollectionResource<ItemTypeType>;
459
356
  getChangesFromItemChanges<ItemTypeType extends ItemType = any>(changesObject: TransactionItemEntryChanges<ItemTypeType>): FieldMap<ItemTypeType>;
460
357
  private createCollectionResources;
461
358
  /**
@@ -36,6 +36,7 @@ export * from './cache/transaction/TransactionItemHandler';
36
36
  export * from './cache/transaction/TransactionCollectionHandler';
37
37
  export * from './cache/transaction/TransactionEventHandler';
38
38
  export * from './cache/transaction/TransactionValidator';
39
+ export * from './ChangesDeltaBase';
39
40
  export * from './ChangesDelta';
40
41
  export * from './InternalChangesDelta';
41
42
  export * from './RequestBufferManager';
@@ -0,0 +1,16 @@
1
+ import { ItemEntryService, KeyService } from '../classes';
2
+ import { TransactionCache } from '../classes/cache/transaction/TransactionCache';
3
+ import { ErrorHandlerInterface, ExceptionHandlerInterface, PromiseLibraryInterface } from '../interfaces';
4
+ import { CollectionEntry, CollectionResource, CollectionResourceOptionsInterface } from '../models';
5
+ import { ItemType } from '../types';
6
+ import { ChangesDeltaFactory } from './ChangesDeltaFactory';
7
+ export declare class CollectionResourceFactory {
8
+ errorHandler: ErrorHandlerInterface;
9
+ exceptionHandler: ExceptionHandlerInterface;
10
+ keyService: KeyService;
11
+ promiseService: PromiseLibraryInterface;
12
+ changesDeltaFactory: ChangesDeltaFactory;
13
+ itemEntryService: ItemEntryService;
14
+ constructor(errorHandler: ErrorHandlerInterface, exceptionHandler: ExceptionHandlerInterface, keyService: KeyService, promiseService: PromiseLibraryInterface, changesDeltaFactory: ChangesDeltaFactory, itemEntryService: ItemEntryService);
15
+ construct<ItemTypeType extends ItemType>(collectionEntry: CollectionEntry<ItemTypeType>, options: CollectionResourceOptionsInterface<ItemTypeType>, transaction: TransactionCache): CollectionResource<ItemTypeType>;
16
+ }
@@ -1,17 +1,15 @@
1
1
  import { ApiFormatter, ColumnSet, ItemEntryService, KeyService } from '../classes';
2
- import { ColumnSetFactory, ItemResourceFactory } from '../factories';
3
- import { AuthInterface, ExceptionHandlerInterface, PromiseLibraryInterface } from '../interfaces';
2
+ import { ColumnSetFactory } from '../factories';
3
+ import { ExceptionHandlerInterface, PromiseLibraryInterface } from '../interfaces';
4
4
  import { ItemEntry } from '../models';
5
5
  import { ItemId, ItemType } from '../types';
6
6
  export declare class ItemEntryFactory {
7
- authInterface: AuthInterface;
8
7
  apiFormatter: ApiFormatter;
9
8
  columnSetFactory: ColumnSetFactory;
10
9
  exceptionHandler: ExceptionHandlerInterface;
11
10
  itemEntryService: ItemEntryService;
12
- itemResourceFactory: ItemResourceFactory;
13
11
  keyService: KeyService;
14
12
  promiseService: PromiseLibraryInterface;
15
- constructor(authInterface: AuthInterface, apiFormatter: ApiFormatter, columnSetFactory: ColumnSetFactory, exceptionHandler: ExceptionHandlerInterface, itemEntryService: ItemEntryService, itemResourceFactory: ItemResourceFactory, keyService: KeyService, promiseService: PromiseLibraryInterface);
13
+ constructor(apiFormatter: ApiFormatter, columnSetFactory: ColumnSetFactory, exceptionHandler: ExceptionHandlerInterface, itemEntryService: ItemEntryService, keyService: KeyService, promiseService: PromiseLibraryInterface);
16
14
  construct<ItemTypeType extends ItemType>(itemId: ItemId, columnInfo: ColumnSet<ItemTypeType>): ItemEntry<ItemTypeType>;
17
15
  }
@@ -0,0 +1,17 @@
1
+ import { ApiFormatter, ColumnUtil } from '../classes';
2
+ import { TransactionCache } from '../classes/cache/transaction/TransactionCache';
3
+ import { ErrorHandlerInterface, ExceptionHandlerInterface, PromiseLibraryInterface } from '../interfaces';
4
+ import { ItemEntry, ItemResource } from '../models';
5
+ import { ItemOptionsInterface, ItemType } from '../types';
6
+ export declare type ResourceConstructor<ItemTypeType extends ItemType> = (itemEntry: ItemEntry<ItemTypeType>) => ItemResource<ItemTypeType>;
7
+ export declare class ItemResourceFactory {
8
+ apiFormatter: ApiFormatter;
9
+ errorHandler: ErrorHandlerInterface;
10
+ promiseService: PromiseLibraryInterface;
11
+ exceptionHandler: ExceptionHandlerInterface;
12
+ columnUtil: ColumnUtil;
13
+ constructor(apiFormatter: ApiFormatter, errorHandler: ErrorHandlerInterface, promiseService: PromiseLibraryInterface, exceptionHandler: ExceptionHandlerInterface, columnUtil: ColumnUtil);
14
+ getConstructor<ItemTypeType extends ItemType>(options: ItemOptionsInterface, transaction: TransactionCache): ResourceConstructor<ItemTypeType>;
15
+ construct<ItemTypeType extends ItemType>(itemEntry: ItemEntry<ItemTypeType>, options: ItemOptionsInterface<ItemTypeType>, transaction: TransactionCache, isNew?: boolean): ItemResource<ItemTypeType>;
16
+ private constructWithOptions;
17
+ }
@@ -0,0 +1,62 @@
1
+ import { TransactionCache } from '../classes/cache/transaction/TransactionCache';
2
+ import { ChangesDeltaResult } from '../classes/ChangesDeltaBase';
3
+ import { CollectionResourceFactory } from '../factories';
4
+ import { CollectionEntry, CollectionResourceOptions, ItemEntry, ItemResource } from '../models';
5
+ import { FieldMap, ItemId, ItemResourceItemIdMap, ItemType, PromiseInterface, QueryCallback, ResponseColumnItemTypeMap } from '../types';
6
+ export declare class CollectionResource<ItemTypeType extends ItemType = any> {
7
+ protected factory: CollectionResourceFactory;
8
+ entry: CollectionEntry<ItemTypeType>;
9
+ options: CollectionResourceOptions<ItemTypeType>;
10
+ transaction: TransactionCache;
11
+ items: Array<ItemResource<ItemTypeType>>;
12
+ columns: ResponseColumnItemTypeMap;
13
+ protected itemIdMap: ItemResourceItemIdMap<ItemResource<ItemTypeType>>;
14
+ private readonly onChange;
15
+ constructor(factory: CollectionResourceFactory, entry: CollectionEntry<ItemTypeType>, options: CollectionResourceOptions<ItemTypeType>, transaction: TransactionCache);
16
+ onConstruct(): void;
17
+ /**
18
+ * @deprecated
19
+ * Use {@link ChangesDelta.setItemMoved ChangesDelta.setItemMoved}
20
+ */
21
+ moveItems(itemEntries: Array<ItemEntry<ItemTypeType>>, destinationResource: CollectionResource<ItemTypeType>): void;
22
+ removeItems(idArray: ItemId[]): void;
23
+ removeItem(itemId: ItemId): void;
24
+ addItems(valuesArray: Array<FieldMap<ItemTypeType>>): PromiseInterface<ChangesDeltaResult>;
25
+ addItem(values: FieldMap<ItemTypeType>): PromiseInterface<ChangesDeltaResult>;
26
+ getIdArray(): ItemId[];
27
+ getItemById(itemId: number): ItemResource<ItemTypeType>;
28
+ addItemResources(itemEntries: Array<ItemEntry<ItemTypeType>>, isInitialCall?: boolean): Array<ItemResource<ItemTypeType>>;
29
+ /**
30
+ * @description
31
+ * Returns the {@link ItemResource ItemResources} that where removed from the {@link CollectionResource collection}.
32
+ * Filters on {@link ItemResource ItemResource}.{@link ItemEntry entry} === {@link ItemEntry entry}
33
+ */
34
+ removeItemResources(itemEntries: Array<ItemEntry<ItemTypeType>>): Array<ItemResource<ItemTypeType>>;
35
+ callOnAdd(itemResources: Array<ItemResource<ItemTypeType>>, isInitialCall?: boolean): void;
36
+ callOnRemove(itemResources: Array<ItemResource<ItemTypeType>>): void;
37
+ forEach(callback: (itemResource: ItemResource<ItemTypeType>) => void): void;
38
+ filter(callback: (itemResource: ItemResource<ItemTypeType>) => boolean): Array<ItemResource<ItemTypeType>>;
39
+ first(callback: (itemResource: ItemResource<ItemTypeType>) => boolean): ItemResource<ItemTypeType> | null;
40
+ some(callback: (itemResource: ItemResource<ItemTypeType>) => boolean): boolean;
41
+ groupBy(argument: string | ((itemResource: ItemResource<ItemTypeType>) => string | null)): {
42
+ [key: string]: Array<ItemResource<ItemTypeType>>;
43
+ };
44
+ map<U>(argument: string | ((itemResource: ItemResource<ItemTypeType>) => U)): U[];
45
+ reduce<U>(callback: (itemResource: ItemResource<ItemTypeType>, value: U) => U, value: U): U;
46
+ /**
47
+ * @description
48
+ * Fetches new items and adds them to the collection
49
+ *
50
+ * @remarks
51
+ * - Used to return {@link ItemResource ItemResources}, but you should the {@link CollectionResource.onAdd onAdd) instead
52
+ */
53
+ extend(queryCallback: QueryCallback): PromiseInterface<CollectionEntry<ItemTypeType>>;
54
+ /**
55
+ * @description
56
+ * Removes the reference to the {@link CollectionResource CollectionResource} from the {@link CollectionEntry CollectionEntry}
57
+ *
58
+ * @remarks
59
+ * - Doesn't revert changes on the items themselves
60
+ */
61
+ clearResource(clearItems?: boolean): void;
62
+ }
@@ -6,10 +6,6 @@ export declare type CollectionResourceInitialCallback<ItemTypeType extends ItemT
6
6
  export declare type OnItemsCreatedCallback = (conversionMap: ConversionMap) => void;
7
7
  export declare type CollectionResourceOptionsInterface<ItemTypeType extends ItemType> = Partial<CollectionResourceOptions<ItemTypeType>>;
8
8
  export declare class CollectionResourceOptions<ItemTypeType extends ItemType> {
9
- editItems: boolean;
10
- remoteItems: boolean;
11
- editCollection: boolean;
12
- enableSave: boolean;
13
9
  callOnAddWithInitialItems: boolean;
14
10
  /**
15
11
  * @deprecated
@@ -1,20 +1,26 @@
1
1
  import { TransactionCache } from '../classes';
2
2
  import { ItemResourceFactory } from '../factories';
3
3
  import { ItemEntry, ItemResourceOptions } from '../models';
4
- import { EntryParentNull, FieldMap, ItemType, ResponseColumn } from '../types';
5
- export declare abstract class ItemResource<ItemTypeType extends ItemType = any> {
4
+ import { EntryParentNull, FieldMap, ItemType, PromiseInterface, ResponseColumn } from '../types';
5
+ export declare class ItemResource<ItemTypeType extends ItemType = any> {
6
6
  protected readonly factory: ItemResourceFactory;
7
7
  readonly entry: ItemEntry<ItemTypeType>;
8
- readonly options: ItemResourceOptions<ItemResource<ItemTypeType>>;
8
+ readonly options: ItemResourceOptions<ItemTypeType>;
9
9
  protected readonly _isNew: boolean;
10
10
  protected readonly transaction: TransactionCache;
11
11
  columns: {
12
12
  [columnId: string]: ResponseColumn;
13
13
  };
14
- fields: Readonly<FieldMap<ItemTypeType>>;
14
+ fields: FieldMap<ItemTypeType>;
15
15
  initial: Readonly<FieldMap<ItemTypeType>>;
16
- protected constructor(factory: ItemResourceFactory, entry: ItemEntry<ItemTypeType>, options: ItemResourceOptions<ItemResource<ItemTypeType>>, _isNew: boolean, transaction: TransactionCache);
16
+ constructor(factory: ItemResourceFactory, entry: ItemEntry<ItemTypeType>, options: ItemResourceOptions<ItemTypeType>, _isNew: boolean, transaction: TransactionCache);
17
17
  onConstruct(): void;
18
+ /**
19
+ * @description
20
+ * Updates the fields of the item and calls onChange, when updating many fields of many items it's better to create a {@link ChangesDelta ChangesDelta} yourself so all changes can be applied at once
21
+ */
22
+ setFields(values: FieldMap<ItemTypeType>): PromiseInterface<this>;
23
+ copyFields(destination?: FieldMap<ItemTypeType>): FieldMap<ItemTypeType>;
18
24
  /**
19
25
  * Fetches the ItemResource's parent with the current fields
20
26
  *
@@ -64,7 +70,7 @@ export declare abstract class ItemResource<ItemTypeType extends ItemType = any>
64
70
  clearResource(): void;
65
71
  toJSON(): {
66
72
  columns: string[];
67
- fields: Readonly<FieldMap<ItemTypeType>>;
73
+ fields: FieldMap<ItemTypeType>;
68
74
  entry: ItemEntry<ItemTypeType>;
69
75
  };
70
76
  /**
@@ -0,0 +1,6 @@
1
+ import { ItemType, OnChangeFunction } from '../types';
2
+ export declare type ItemResourceOptionsInterface<ItemTypeType extends ItemType = any> = Partial<ItemResourceOptions<ItemTypeType>>;
3
+ export declare class ItemResourceOptions<ItemTypeType extends ItemType = any> {
4
+ onChange: OnChangeFunction<ItemTypeType>;
5
+ constructor(values: ItemResourceOptionsInterface<ItemTypeType>);
6
+ }
@@ -2,14 +2,8 @@ export * from './ItemEntryOptions';
2
2
  export * from './ItemResourceOptions';
3
3
  export * from './ItemEntry';
4
4
  export * from './ItemResource';
5
- export * from './ViewResource';
6
- export * from './EditResource';
7
5
  export * from './CollectionEntryOptions';
8
6
  export * from './CollectionResourceOptions';
9
7
  export * from './CollectionEntry';
10
8
  export * from './CollectionResource';
11
- export * from './CollectionViewResource';
12
- export * from './CollectionEditResource';
13
9
  export * from './Template';
14
- export * from './RemoteViewResource';
15
- export * from './LocalViewResource';
@@ -12,7 +12,7 @@ export declare type EntryParentNull = EntryParent | null;
12
12
  export declare type FieldMap<_ItemTypeType extends ItemType = any> = {
13
13
  [key: string]: any;
14
14
  };
15
- export declare type ItemOptionsInterface<ItemResourceType extends ItemResource<any> = ItemResource> = ItemEntryOptionsInterface & ItemResourceOptionsInterface<ItemResourceType>;
15
+ export declare type ItemOptionsInterface<ItemTypeType extends ItemType = any> = ItemEntryOptionsInterface & ItemResourceOptionsInterface<ItemTypeType>;
16
16
  export declare type CollectionOptionsInterface<ItemTypeType extends ItemType = any> = CollectionEntryOptionsInterface & CollectionResourceOptionsInterface<ItemTypeType>;
17
17
  export interface CollectionDefinition<ItemTypeType extends ItemType = any> {
18
18
  itemType: ItemTypeType;
@@ -24,12 +24,12 @@ export interface CollectionDefinition<ItemTypeType extends ItemType = any> {
24
24
  export interface LinkCollectionDefinition<ItemTypeType extends ItemType = any> extends CollectionDefinition<ItemTypeType> {
25
25
  linkField: string;
26
26
  }
27
- export declare type OnChangeFunction<ItemResourceType extends ItemResource<any> = ItemResource<any>> = (itemResource: ItemResourceType, previous: FieldMap<ItemResourceType['entry']['itemType']>,
27
+ export declare type OnChangeFunction<ItemTypeType extends ItemType = any> = (itemResource: ItemResource<ItemTypeType>, previous: FieldMap<ItemTypeType>,
28
28
  /**
29
29
  * @description
30
30
  * Returns 'false' if the field changed
31
31
  */
32
- compareField: (field: keyof FieldMap<ItemResourceType['entry']['itemType']>) => boolean, isCalledAfterSocketUpdate: boolean) => void;
32
+ compareField: (field: keyof FieldMap<ItemTypeType>) => boolean, isCalledAfterSocketUpdate: boolean) => void;
33
33
  export declare const enum StateKeyType {
34
34
  New = "new",
35
35
  Duplicate = "duplicate"
@@ -157,8 +157,8 @@ export declare type QueryCallback = (queryParams: QueryParams) => QueryParams;
157
157
  export declare type CollectionEntryParentIdMap<ItemTypeType extends ItemType> = {
158
158
  [parentId: number]: CollectionEntry<ItemTypeType>;
159
159
  };
160
- export declare type CollectionResourceParentIdMap<T extends CollectionResource<any> = CollectionResource<any>> = {
161
- [parentId: number]: T;
160
+ export declare type CollectionResourceParentIdMap<ItemTypeType extends ItemType = any> = {
161
+ [parentId: number]: CollectionResource<ItemTypeType>;
162
162
  };
163
163
  export declare type CollectionMatchResult<ItemTypeType extends ItemType> = {
164
164
  fitting: Array<CollectionEntry<ItemTypeType>>;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@rentman/rm-core",
3
- "version": "2.3.0",
3
+ "version": "3.0.0",
4
4
  "description": "Rentman core functionalities",
5
5
  "main": "./dist/rm-core.js",
6
- "types": "./dist/src/index.d.ts",
6
+ "types": "./dist/types/index.d.ts",
7
7
  "dependencies": {},
8
8
  "repository": {
9
9
  "type": "git",
@@ -13,14 +13,14 @@
13
13
  "@types/moment": "^2.13.0",
14
14
  "@types/q": "^1.5.0",
15
15
  "clean-webpack-plugin": "^0.1.19",
16
- "ts-loader": "^4.4.1",
17
- "tslint": "^5.12.1",
18
- "typescript": "3.3.3",
19
- "typescript-tslint-plugin": "^0.5.3",
16
+ "ts-loader": "^6.2.1",
17
+ "tslint": "5.19.0",
18
+ "typescript": "^3.7.2",
19
+ "typescript-tslint-plugin": "^0.5.5",
20
20
  "uglifyjs-webpack-plugin": "^1.2.5",
21
- "webpack": "^4.16.3",
22
- "webpack-cli": "^3.0.6",
23
- "webpack-merge": "^4.1.3"
21
+ "webpack": "4.41.2",
22
+ "webpack-cli": "3.3.6",
23
+ "webpack-merge": "^4.1.4"
24
24
  },
25
25
  "files": [
26
26
  "dist"
@@ -1,35 +0,0 @@
1
- import { ItemEntryService, KeyService } from '../classes';
2
- import { TransactionCache } from '../classes/cache/transaction/TransactionCache';
3
- import { ItemResourceFactory } from '../factories';
4
- import { ErrorHandlerInterface, ExceptionHandlerInterface, PromiseLibraryInterface } from '../interfaces';
5
- import { CollectionEditResource, CollectionEntry, CollectionResourceOptionsInterface, CollectionViewResource, EditResource, LocalViewResource, RemoteViewResource } from '../models';
6
- import { ItemType } from '../types';
7
- import { ChangesDeltaFactory } from './ChangesDeltaFactory';
8
- export declare class CollectionResourceFactory {
9
- errorHandler: ErrorHandlerInterface;
10
- exceptionHandler: ExceptionHandlerInterface;
11
- itemResourceFactory: ItemResourceFactory;
12
- keyService: KeyService;
13
- promiseService: PromiseLibraryInterface;
14
- changesDeltaFactory: ChangesDeltaFactory;
15
- itemEntryService: ItemEntryService;
16
- constructor(errorHandler: ErrorHandlerInterface, exceptionHandler: ExceptionHandlerInterface, itemResourceFactory: ItemResourceFactory, keyService: KeyService, promiseService: PromiseLibraryInterface, changesDeltaFactory: ChangesDeltaFactory, itemEntryService: ItemEntryService);
17
- construct<ItemTypeType extends ItemType>(collectionEntry: CollectionEntry<ItemTypeType>, options: CollectionResourceOptionsInterface<ItemTypeType> & {
18
- editItems: true;
19
- editCollection: true;
20
- }, transaction: TransactionCache): CollectionEditResource<ItemTypeType, EditResource<ItemTypeType>>;
21
- construct<ItemTypeType extends ItemType>(collectionEntry: CollectionEntry<ItemTypeType>, options: CollectionResourceOptionsInterface<ItemTypeType> & {
22
- remoteItems: true;
23
- editCollection: true;
24
- }, transaction: TransactionCache): CollectionEditResource<ItemTypeType, RemoteViewResource<ItemTypeType>>;
25
- construct<ItemTypeType extends ItemType>(collectionEntry: CollectionEntry<ItemTypeType>, options: CollectionResourceOptionsInterface<ItemTypeType> & {
26
- editCollection: true;
27
- }, transaction: TransactionCache): CollectionEditResource<ItemTypeType, LocalViewResource<ItemTypeType>>;
28
- construct<ItemTypeType extends ItemType>(collectionEntry: CollectionEntry<ItemTypeType>, options: CollectionResourceOptionsInterface<ItemTypeType> & {
29
- editItems: true;
30
- }, transaction: TransactionCache): CollectionViewResource<ItemTypeType, EditResource<ItemTypeType>>;
31
- construct<ItemTypeType extends ItemType>(collectionEntry: CollectionEntry<ItemTypeType>, options: CollectionResourceOptionsInterface<ItemTypeType> & {
32
- remoteItems: true;
33
- }, transaction: TransactionCache): CollectionViewResource<ItemTypeType, RemoteViewResource<ItemTypeType>>;
34
- construct<ItemTypeType extends ItemType>(collectionEntry: CollectionEntry<ItemTypeType>, options: CollectionResourceOptionsInterface<ItemTypeType>, transaction: TransactionCache): CollectionViewResource<ItemTypeType, LocalViewResource<ItemTypeType>>;
35
- }