@rentman/rm-core 0.0.0-RM4-44763

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 (201) hide show
  1. package/dist/rm-core.js +2 -0
  2. package/dist/rm-core.js.map +1 -0
  3. package/dist/types/src/classes/ApiFormatter.d.ts +66 -0
  4. package/dist/types/src/classes/ApiRequestService.d.ts +18 -0
  5. package/dist/types/src/classes/ApiResponseProcessor.d.ts +31 -0
  6. package/dist/types/src/classes/BusinessLogicManager/AantalBusinessLogicRuleBase.d.ts +36 -0
  7. package/dist/types/src/classes/BusinessLogicManager/AantaltotaalBusinessLogicRuleBase.d.ts +60 -0
  8. package/dist/types/src/classes/BusinessLogicManager/Afspraak/AfspraakRecureindBusinessLogicRule.d.ts +5 -0
  9. package/dist/types/src/classes/BusinessLogicManager/Beschikbaarheid/BeschikbaarheidRecureindBusinessLogicRule.d.ts +5 -0
  10. package/dist/types/src/classes/BusinessLogicManager/BusinessLogicManager.d.ts +66 -0
  11. package/dist/types/src/classes/BusinessLogicManager/BusinessLogicRule.d.ts +81 -0
  12. package/dist/types/src/classes/BusinessLogicManager/BusinessLogicRuleApplyContext.d.ts +32 -0
  13. package/dist/types/src/classes/BusinessLogicManager/BusinessLogicRuleConditionContext.d.ts +41 -0
  14. package/dist/types/src/classes/BusinessLogicManager/BusinessLogicRuleContextBase.d.ts +58 -0
  15. package/dist/types/src/classes/BusinessLogicManager/Contact/ContactAddressBusinessLogicRule.d.ts +22 -0
  16. package/dist/types/src/classes/BusinessLogicManager/Customfield/CustomFieldLinkedItemTypeBusinessLogicRule.d.ts +18 -0
  17. package/dist/types/src/classes/BusinessLogicManager/Customfield/CustomFieldTypeBusinessLogicRule.d.ts +18 -0
  18. package/dist/types/src/classes/BusinessLogicManager/DefaultContactPersonUpdateBusinessLogicRule.d.ts +30 -0
  19. package/dist/types/src/classes/BusinessLogicManager/Documents/DocumentTemplateBusinessLogicRule.d.ts +20 -0
  20. package/dist/types/src/classes/BusinessLogicManager/Exemplaar/ExemplaarAanschafdatumBusinessLogicRule.d.ts +14 -0
  21. package/dist/types/src/classes/BusinessLogicManager/Exemplaar/ExemplaarBarcodeDeleteBusinessLogicRule.d.ts +14 -0
  22. package/dist/types/src/classes/BusinessLogicManager/Factuur/FactuurBetalingsconditieBusinessLogicRule.d.ts +21 -0
  23. package/dist/types/src/classes/BusinessLogicManager/Factuur/FactuurDatumBusinessLogicRule.d.ts +23 -0
  24. package/dist/types/src/classes/BusinessLogicManager/Factuur/FactuurNumberseriesBusinessLogicRule.d.ts +14 -0
  25. package/dist/types/src/classes/BusinessLogicManager/Files/FilesNameExtensionBusinessLogicRule.d.ts +20 -0
  26. package/dist/types/src/classes/BusinessLogicManager/Functie/FunctieNaaminternBusinessLogicRule.d.ts +18 -0
  27. package/dist/types/src/classes/BusinessLogicManager/Functie/FunctieRecureindBusinessLogicRule.d.ts +5 -0
  28. package/dist/types/src/classes/BusinessLogicManager/Functie/FunctieTwowayBusinessLogicRule.d.ts +14 -0
  29. package/dist/types/src/classes/BusinessLogicManager/Functiegroep/FunctiegroepSubprojectBusinessLogicRule.d.ts +17 -0
  30. package/dist/types/src/classes/BusinessLogicManager/Inhuurmateriaal/InhuurmateriaalAantalBusinessLogicRule.d.ts +4 -0
  31. package/dist/types/src/classes/BusinessLogicManager/Inhuurmateriaal/InhuurmateriaalAantaltotaalBusinessLogicRule.d.ts +9 -0
  32. package/dist/types/src/classes/BusinessLogicManager/Materiaal/MateriaalBulkToSerialBusinessLogicRule.d.ts +17 -0
  33. package/dist/types/src/classes/BusinessLogicManager/Materiaal/MateriaalIsCombinationBusinessLogicRule.d.ts +20 -0
  34. package/dist/types/src/classes/BusinessLogicManager/Materiaal/MateriaalIsPhysicalCombinationBulkBusinessLogicRule.d.ts +19 -0
  35. package/dist/types/src/classes/BusinessLogicManager/Materiaal/MateriaalSerialToBulkBusinessLogicRule.d.ts +16 -0
  36. package/dist/types/src/classes/BusinessLogicManager/Materiaal/MateriaalToPhysicalBusinessLogicRule.d.ts +18 -0
  37. package/dist/types/src/classes/BusinessLogicManager/Materiaal/MateriaalToVirtualBusinessLogicRule.d.ts +22 -0
  38. package/dist/types/src/classes/BusinessLogicManager/Materiaal/MateriaalTypePropertiesBusinessLogicRule.d.ts +19 -0
  39. package/dist/types/src/classes/BusinessLogicManager/Materiaal/MateriaalVerhuurBusinessLogicRule.d.ts +19 -0
  40. package/dist/types/src/classes/BusinessLogicManager/Materiaal/SurfaceArticleSizeBusinessLogicRule.d.ts +23 -0
  41. package/dist/types/src/classes/BusinessLogicManager/MateriaalCatFunctieFunctiegroep/LinkedTimeItemBusinessLogicRuleBase.d.ts +46 -0
  42. package/dist/types/src/classes/BusinessLogicManager/MateriaalCatFunctieFunctiegroep/LinkedTimeItemDurationBusinessLogicRule.d.ts +17 -0
  43. package/dist/types/src/classes/BusinessLogicManager/MateriaalCatFunctieFunctiegroep/LinkedTimeItemMateriaalCatBusinessLogicRule.d.ts +25 -0
  44. package/dist/types/src/classes/BusinessLogicManager/MateriaalCatFunctieFunctiegroep/LinkedTimeItemSubprojectBusinessLogicRule.d.ts +48 -0
  45. package/dist/types/src/classes/BusinessLogicManager/MateriaalCatFunctieFunctiegroep/LinkedTimeItemTimeSchemeBusinessLogicRule.d.ts +27 -0
  46. package/dist/types/src/classes/BusinessLogicManager/MateriaalCatFunctieFunctiegroep/LinkedTimeItemTimeSchemeStartBusinessLogicRule.d.ts +18 -0
  47. package/dist/types/src/classes/BusinessLogicManager/MateriaalCatFunctieFunctiegroep/LinkedTimeItemTimeValueStartBusinessLogicRule.d.ts +20 -0
  48. package/dist/types/src/classes/BusinessLogicManager/MateriaalCatFunctieFunctiegroep/TimeColumnUtil.d.ts +132 -0
  49. package/dist/types/src/classes/BusinessLogicManager/OfferteContract/OfferteContractDatumBusinessLogicRule.d.ts +21 -0
  50. package/dist/types/src/classes/BusinessLogicManager/PlanningPersoneelTransport/PlanningPersoneelTransportBusinessLogicRule.d.ts +24 -0
  51. package/dist/types/src/classes/BusinessLogicManager/Planningmateriaal/PlanningmateriaalAantalBusinessLogicRule.d.ts +4 -0
  52. package/dist/types/src/classes/BusinessLogicManager/Planningmateriaal/PlanningmateriaalAantaltotaalBusinessLogicRule.d.ts +9 -0
  53. package/dist/types/src/classes/BusinessLogicManager/Planningmateriaal/PlanningmateriaalOptieBusinessLogicRule.d.ts +26 -0
  54. package/dist/types/src/classes/BusinessLogicManager/Planningmateriaal/PlanningmateriaalParentBusinessLogicRule.d.ts +17 -0
  55. package/dist/types/src/classes/BusinessLogicManager/Planningmateriaal/PlanningmateriaalStaysAtLocationBusinessLogicRule.d.ts +32 -0
  56. package/dist/types/src/classes/BusinessLogicManager/Project/ProjectClientChangedBusinessLogicRule.d.ts +31 -0
  57. package/dist/types/src/classes/BusinessLogicManager/Project/ProjectContactProjectNoteBusinessLogicRule.d.ts +25 -0
  58. package/dist/types/src/classes/BusinessLogicManager/Project/ProjectOneSubLocationAlignBusinessRule.d.ts +26 -0
  59. package/dist/types/src/classes/BusinessLogicManager/ProjectSubproject/ProjectSubprojectDefaultTimeBusinessLogicRule.d.ts +26 -0
  60. package/dist/types/src/classes/BusinessLogicManager/PurchaseOrder/PurchaseOrderApprovalStatusBusinessLogicRule.d.ts +19 -0
  61. package/dist/types/src/classes/BusinessLogicManager/PurchaseOrder/PurchaseOrderOwnerBusinessLogicRule.d.ts +16 -0
  62. package/dist/types/src/classes/BusinessLogicManager/Rate/RateUpdatedBusinessLogicRule.d.ts +14 -0
  63. package/dist/types/src/classes/BusinessLogicManager/RecurrentItem/RecurrentItemRecureindBusinessLogicRule.d.ts +28 -0
  64. package/dist/types/src/classes/BusinessLogicManager/Reparatie/ReparatieExemplaarAantalBusinessLogicRule.d.ts +14 -0
  65. package/dist/types/src/classes/BusinessLogicManager/Reparatie/ReparatieLostItemExemplaarLocationBusinessLogicRule.d.ts +21 -0
  66. package/dist/types/src/classes/BusinessLogicManager/Rol/RolEditOwnDataBusinessLogicRule.d.ts +20 -0
  67. package/dist/types/src/classes/BusinessLogicManager/Rol/RolFileAccessBusinessLogicRule.d.ts +19 -0
  68. package/dist/types/src/classes/BusinessLogicManager/Rol/RolPersoneelsplannerToegangBusinessLogicRule.d.ts +20 -0
  69. package/dist/types/src/classes/BusinessLogicManager/Rol/RolProjectenBewerkenBusinessLogicRule.d.ts +20 -0
  70. package/dist/types/src/classes/BusinessLogicManager/Rol/RolProjectenToegangBusinessLogicRule.d.ts +21 -0
  71. package/dist/types/src/classes/BusinessLogicManager/Rol/RolPurchaseOrderAttachPlanningBusinessLogicRule.d.ts +19 -0
  72. package/dist/types/src/classes/BusinessLogicManager/Rol/RolVisibilityFinancialsBusinessLogicRule.d.ts +35 -0
  73. package/dist/types/src/classes/BusinessLogicManager/Rol/RolWarehosueTrackingLogAccessBusinessLogicRule.d.ts +20 -0
  74. package/dist/types/src/classes/BusinessLogicManager/Setinhoud/SetinhoudCreateFixedBusinessLogicRule.d.ts +21 -0
  75. package/dist/types/src/classes/BusinessLogicManager/Setinhoud/SetinhoudUpdateFixedBusinessLogicRule.d.ts +26 -0
  76. package/dist/types/src/classes/BusinessLogicManager/Subproject/SubprojectInPlanningBusinessLogicRule.d.ts +14 -0
  77. package/dist/types/src/classes/BusinessLogicManager/Subproject/SubprojectOneSubLocationAlignBusinessRule.d.ts +27 -0
  78. package/dist/types/src/classes/BusinessLogicManager/Subproject/SubprojectOneSubNameAlignBusinessRule.d.ts +22 -0
  79. package/dist/types/src/classes/BusinessLogicManager/Tijd/TijdNameChangedBusinessLogicRule.d.ts +21 -0
  80. package/dist/types/src/classes/BusinessLogicManager/Tijd/TijdSubprojectChangedBusinessLogicRule.d.ts +17 -0
  81. package/dist/types/src/classes/BusinessLogicManager/Uren/HoursTypeBusinessLogicRuleBase.d.ts +10 -0
  82. package/dist/types/src/classes/BusinessLogicManager/Uren/UrenCalculatedDurationBusinessLogicRule.d.ts +13 -0
  83. package/dist/types/src/classes/BusinessLogicManager/Uren/UrenCanHaveActivitiesBusinessLogicRule.d.ts +13 -0
  84. package/dist/types/src/classes/BusinessLogicManager/businessLogicRule.decorator.d.ts +13 -0
  85. package/dist/types/src/classes/BusinessLogicManager/registeredBusinessLogicRules.d.ts +66 -0
  86. package/dist/types/src/classes/ChangesCompilation.d.ts +26 -0
  87. package/dist/types/src/classes/ChangesDelta.d.ts +81 -0
  88. package/dist/types/src/classes/ChangesDeltaBase.d.ts +85 -0
  89. package/dist/types/src/classes/ChangesProcessor.d.ts +35 -0
  90. package/dist/types/src/classes/ChildChangesDelta.d.ts +38 -0
  91. package/dist/types/src/classes/ColumnCache.d.ts +22 -0
  92. package/dist/types/src/classes/ColumnExpansion.d.ts +18 -0
  93. package/dist/types/src/classes/ColumnHandler.d.ts +16 -0
  94. package/dist/types/src/classes/ColumnInfo.d.ts +16 -0
  95. package/dist/types/src/classes/ColumnSet.d.ts +79 -0
  96. package/dist/types/src/classes/ColumnUtil.d.ts +97 -0
  97. package/dist/types/src/classes/ConversionMapService.d.ts +23 -0
  98. package/dist/types/src/classes/CreateRequest.d.ts +16 -0
  99. package/dist/types/src/classes/CreatedChangesDelta.d.ts +22 -0
  100. package/dist/types/src/classes/ItemCache.d.ts +26 -0
  101. package/dist/types/src/classes/ItemCreateService.d.ts +14 -0
  102. package/dist/types/src/classes/ItemEntryService.d.ts +29 -0
  103. package/dist/types/src/classes/KeyService.d.ts +10 -0
  104. package/dist/types/src/classes/LockService.d.ts +28 -0
  105. package/dist/types/src/classes/ModuleChangesCompilation.d.ts +20 -0
  106. package/dist/types/src/classes/ParentChangesDelta.d.ts +42 -0
  107. package/dist/types/src/classes/QueryColumnExtractor.d.ts +16 -0
  108. package/dist/types/src/classes/QueryContainsLocalIdParser.d.ts +14 -0
  109. package/dist/types/src/classes/QueryParser.d.ts +18 -0
  110. package/dist/types/src/classes/QueryParserBase.d.ts +32 -0
  111. package/dist/types/src/classes/QueryParserIdUpdater.d.ts +16 -0
  112. package/dist/types/src/classes/QueryService.d.ts +10 -0
  113. package/dist/types/src/classes/RequestBuffer/RequestBuffer.d.ts +13 -0
  114. package/dist/types/src/classes/RequestBuffer/RequestBufferBase.d.ts +37 -0
  115. package/dist/types/src/classes/RequestBuffer/RequestBufferManager.d.ts +24 -0
  116. package/dist/types/src/classes/RequestBuffer/SingleQueryRequestBuffer.d.ts +18 -0
  117. package/dist/types/src/classes/RequestColumnExpansion.d.ts +11 -0
  118. package/dist/types/src/classes/RequestColumnsOperationsCache.d.ts +45 -0
  119. package/dist/types/src/classes/SocketMessageHandler.d.ts +28 -0
  120. package/dist/types/src/classes/TemplateCache.d.ts +61 -0
  121. package/dist/types/src/classes/Util.d.ts +36 -0
  122. package/dist/types/src/classes/cache/AbstractCache.d.ts +86 -0
  123. package/dist/types/src/classes/cache/CachedQueryHandlerBase.d.ts +145 -0
  124. package/dist/types/src/classes/cache/ItemHandlerBase.d.ts +97 -0
  125. package/dist/types/src/classes/cache/ItemMatcherBase.d.ts +90 -0
  126. package/dist/types/src/classes/cache/server/ServerCache.d.ts +83 -0
  127. package/dist/types/src/classes/cache/server/ServerCachedQueryHandler.d.ts +29 -0
  128. package/dist/types/src/classes/cache/server/ServerItemHandler.d.ts +35 -0
  129. package/dist/types/src/classes/cache/transaction/TransactionCache.d.ts +342 -0
  130. package/dist/types/src/classes/cache/transaction/TransactionCachedQueryHandler.d.ts +111 -0
  131. package/dist/types/src/classes/cache/transaction/TransactionEventHandler.d.ts +17 -0
  132. package/dist/types/src/classes/cache/transaction/TransactionItemHandler.d.ts +121 -0
  133. package/dist/types/src/classes/cache/transaction/TransactionValidator.d.ts +25 -0
  134. package/dist/types/src/classes/cache/transaction/TransactionValidatorBase.d.ts +19 -0
  135. package/dist/types/src/classes/cache/transaction/TransactionValidatorWithDependencies.d.ts +15 -0
  136. package/dist/types/src/classes/changes/CollectionItemChangesListenerContext.d.ts +22 -0
  137. package/dist/types/src/classes/changes/ItemChangesListenerContext.d.ts +7 -0
  138. package/dist/types/src/classes/changes/ItemChangesListenerContextBase.d.ts +44 -0
  139. package/dist/types/src/classes/matcher/CompatorQueryNode.d.ts +24 -0
  140. package/dist/types/src/classes/matcher/CustomQueryNode.d.ts +8 -0
  141. package/dist/types/src/classes/matcher/GraphQueryParser.d.ts +34 -0
  142. package/dist/types/src/classes/matcher/IsComparatorQueryNode.d.ts +13 -0
  143. package/dist/types/src/classes/matcher/LinkedToQueryNode.d.ts +9 -0
  144. package/dist/types/src/classes/matcher/NonMatchableQueryNode.d.ts +9 -0
  145. package/dist/types/src/classes/matcher/NotIsComparatorQueryNode.d.ts +14 -0
  146. package/dist/types/src/classes/matcher/QueryNode.d.ts +49 -0
  147. package/dist/types/src/classes/matcher/RootQueryNode.d.ts +14 -0
  148. package/dist/types/src/classes/matcher/SearchQueryNode.d.ts +8 -0
  149. package/dist/types/src/classes/matcher/SubQueryNode.d.ts +8 -0
  150. package/dist/types/src/classes/matcher/ValueTransformers.d.ts +41 -0
  151. package/dist/types/src/classes/matcher/ValuelessEdgeQueryNode.d.ts +11 -0
  152. package/dist/types/src/classes/matcher/greater-smaller-than-comparator-query.node.d.ts +25 -0
  153. package/dist/types/src/constants.d.ts +2 -0
  154. package/dist/types/src/core.d.ts +63 -0
  155. package/dist/types/src/exceptions/CriticalBusinessLogicRuleException.d.ts +4 -0
  156. package/dist/types/src/exceptions/ItemAlreadyExistsException.d.ts +4 -0
  157. package/dist/types/src/exceptions/ItemLockedException.d.ts +2 -0
  158. package/dist/types/src/exceptions/ItemNotFoundException.d.ts +5 -0
  159. package/dist/types/src/exceptions/MissingColumnException.d.ts +6 -0
  160. package/dist/types/src/exceptions/SavingInProgressException.d.ts +2 -0
  161. package/dist/types/src/exceptions/TransactionPendingException.d.ts +2 -0
  162. package/dist/types/src/factories/ApiResponseProcessorFactory.d.ts +5 -0
  163. package/dist/types/src/factories/ChangesCompilationFactory.d.ts +5 -0
  164. package/dist/types/src/factories/ChangesDeltaFactory.d.ts +13 -0
  165. package/dist/types/src/factories/CollectionResourceFactory.d.ts +20 -0
  166. package/dist/types/src/factories/ColumnExpansionFactory.d.ts +7 -0
  167. package/dist/types/src/factories/ColumnInfoFactory.d.ts +7 -0
  168. package/dist/types/src/factories/ColumnSetFactory.d.ts +15 -0
  169. package/dist/types/src/factories/GraphQueryParserFactory.d.ts +10 -0
  170. package/dist/types/src/factories/ItemCacheFactory.d.ts +7 -0
  171. package/dist/types/src/factories/ItemResourceFactory.d.ts +7 -0
  172. package/dist/types/src/factories/ModuleChangesCompilationFactory.d.ts +6 -0
  173. package/dist/types/src/factories/RequestColumnExpansionFactory.d.ts +4 -0
  174. package/dist/types/src/factories/RequestColumnsOperationsCacheFactory.d.ts +7 -0
  175. package/dist/types/src/factories/TransactionCacheFactory.d.ts +12 -0
  176. package/dist/types/src/index.d.ts +11 -0
  177. package/dist/types/src/interfaces/AbstractCacheDependencyInterface.d.ts +46 -0
  178. package/dist/types/src/interfaces/ApiRequestServiceInterface.d.ts +14 -0
  179. package/dist/types/src/interfaces/ErrorHandlerInterface.d.ts +6 -0
  180. package/dist/types/src/interfaces/LinkTreeServiceInterface.d.ts +6 -0
  181. package/dist/types/src/interfaces/ServerCacheDependencyInterface.d.ts +6 -0
  182. package/dist/types/src/interfaces/SocketMessageInterface.d.ts +3 -0
  183. package/dist/types/src/interfaces/TransactionCollectionHandlerDependencyInterface.d.ts +15 -0
  184. package/dist/types/src/interfaces/TransactionItemHandlerDependencyInterface.d.ts +16 -0
  185. package/dist/types/src/internal.d.ts +110 -0
  186. package/dist/types/src/models/CachedQueryItem.d.ts +33 -0
  187. package/dist/types/src/models/CollectionEntry.d.ts +16 -0
  188. package/dist/types/src/models/CollectionOptions.d.ts +111 -0
  189. package/dist/types/src/models/CollectionResource.d.ts +175 -0
  190. package/dist/types/src/models/ItemEntry.d.ts +23 -0
  191. package/dist/types/src/models/ItemOptions.d.ts +25 -0
  192. package/dist/types/src/models/ItemResource.d.ts +135 -0
  193. package/dist/types/src/models/LimitedCollectionResource.d.ts +26 -0
  194. package/dist/types/src/models/OrderedCollectionResource.d.ts +19 -0
  195. package/dist/types/src/models/Template.d.ts +17 -0
  196. package/dist/types/src/services/rm-holidays.service.d.ts +31 -0
  197. package/dist/types/src/types/AggregatedChangesListener.d.ts +99 -0
  198. package/dist/types/src/types/ApiQuery.d.ts +95 -0
  199. package/dist/types/src/types/ItemTypesCollection.d.ts +416 -0
  200. package/package.json +56 -0
  201. package/readme.md +42 -0
@@ -0,0 +1,342 @@
1
+ import { WritableSignal } from '@angular/core';
2
+ import { ApiItemType, ItemId } from '@rentman/backend-types';
3
+ import { AbstractCache, AbstractCacheDependencyInterface, ApiQuery, ApiRequestColumnArray, ApiRequestColumns, CachedQueryItem, ChangesDelta, ChangesDeltaResult, ChildChangesDelta, ChildCollectionResources, CollectionOptions, CollectionQuery, CollectionResource, ConversionMap, CreateRequestParameterMap, DeregFunction, FieldMap, ItemAggregatedChangesListener, ItemChangesListener, ItemEntry, ItemIdConversionMap, ItemOptions, ItemResource, ItemResourcesItemTypeMap, ItemsByQueryOptions, ItemTypeMap, LimitedCollectionResource, ModuleChangesCompilationResult, NewItemOptions, OnAfterCreateCallback, ParentChangesDelta, ParentIdMap, RmCore, RootCollectionOptions, ServerCache, TransactionCacheCallbackCondition, TransactionCacheCallbackType, TransactionCachedQueryHandler, TransactionEventHandler, TransactionItemHandler, TransactionOptions, TransactionValidator, TransactionValidatorFactory } from '../../../internal';
4
+ import { TransactionValidatorWithDependencies } from './TransactionValidatorWithDependencies';
5
+ type ItemResourceLinks<ItemTypeType extends ApiItemType, ColumnIds extends ApiRequestColumnArray<ItemTypeType>, Children extends ChildCollectionResources | undefined> = {
6
+ main: ItemResource<ItemTypeType, ColumnIds, Children>;
7
+ linked: ItemResourcesItemTypeMap;
8
+ };
9
+ export declare enum TransactionErrorLevel {
10
+ warning = "warning",
11
+ error = "error"
12
+ }
13
+ export type TransactionError = {
14
+ fieldString: string;
15
+ string: string;
16
+ level: TransactionErrorLevel;
17
+ location?: string;
18
+ };
19
+ export type GlobalTransactionError = {
20
+ string: string;
21
+ level: TransactionErrorLevel;
22
+ };
23
+ /**
24
+ * Converts child CollectionOptionsInterfaces to CollectionResources.
25
+ */
26
+ export type OptionsToChildCollections<OptionsType> = OptionsType extends {
27
+ children: {
28
+ [itemType: string]: {
29
+ columns: any;
30
+ };
31
+ };
32
+ } ? {
33
+ [ChildItemType in keyof OptionsType['children']]: ChildItemType extends ApiItemType ? OptionsToCollectionResource<ChildItemType, OptionsType['children'][ChildItemType]> : never;
34
+ } : undefined;
35
+ export type OptionsToCollectionResource<ItemTypeType extends ApiItemType, OptionsType extends {
36
+ columns: ApiRequestColumnArray<ItemTypeType>;
37
+ }> = OptionsType extends {
38
+ order: {
39
+ limit: number;
40
+ };
41
+ } ? LimitedCollectionResource<ItemTypeType, OptionsType['columns'], OptionsToChildCollections<OptionsType>> : CollectionResource<ItemTypeType, OptionsType['columns'], OptionsToChildCollections<OptionsType>>;
42
+ /**
43
+ * @description
44
+ * The {@link TransactionCache TransactionCache} is responsible for keeping track of newly created {@link ItemEntry ItemEntries}
45
+ * and {@link CollectionEntry CollectionEntries}, and the changes of existing ItemEntries and CollectionEntries.
46
+ *
47
+ * 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
48
+ */
49
+ export declare class TransactionCache extends AbstractCache {
50
+ /**
51
+ * @description
52
+ * For debugging purposes
53
+ */
54
+ id?: string | undefined;
55
+ /**
56
+ * @description
57
+ * A map of all item errors, can be populated using {@link TransactionValidator.setGlobalError TransactionValidator.setGlobalError} and {@link TransactionValidator.setItemError TransactionValidator.setItemError}.
58
+ * Contains a translation and level for every error
59
+ */
60
+ errors: {
61
+ item: WritableSignal<{
62
+ [itemEntryId: string]: {
63
+ [columnId: string]: {
64
+ [errorKey: string]: TransactionError;
65
+ };
66
+ };
67
+ }>;
68
+ global: WritableSignal<{
69
+ [key: string]: GlobalTransactionError;
70
+ }>;
71
+ };
72
+ firstError: import("@angular/core").Signal<GlobalTransactionError | undefined>;
73
+ firstErrorString: import("@angular/core").Signal<string | undefined>;
74
+ rootItemSignal: WritableSignal<ItemEntry<any> | undefined>;
75
+ /**
76
+ * @description
77
+ * Stores additional request parameters for when the transaction is stored to the server
78
+ */
79
+ tabRequestParameters: {};
80
+ hasChangesSignal: WritableSignal<boolean>;
81
+ /**
82
+ * @description
83
+ * The transaction's parent
84
+ */
85
+ readonly parent: AbstractCache;
86
+ readonly itemHandler: TransactionItemHandler;
87
+ readonly cachedQueryHandler: TransactionCachedQueryHandler;
88
+ readonly eventHandler: TransactionEventHandler;
89
+ readonly validator?: TransactionValidator;
90
+ validatorWithDependencies?: TransactionValidatorWithDependencies<any>;
91
+ private readonly options;
92
+ private changesDeltasBeingApplied;
93
+ private transactionStateSignal;
94
+ isSavingSignal: import("@angular/core").Signal<boolean>;
95
+ isReadySignal: import("@angular/core").Signal<boolean>;
96
+ isPendingSignal: import("@angular/core").Signal<boolean>;
97
+ isDestroyedSignal: WritableSignal<boolean>;
98
+ isValidSignal: import("@angular/core").Signal<boolean>;
99
+ constructor(dependencies: AbstractCacheDependencyInterface, core: RmCore, parent: AbstractCache,
100
+ /**
101
+ * @description
102
+ * For debugging purposes
103
+ */
104
+ id?: string | undefined, validatorFactory?: TransactionValidatorFactory, options?: Partial<TransactionOptions>);
105
+ /**
106
+ * @description
107
+ * Stores the 'root' {@link ItemEntry ItemEntry}, this {@link ItemEntry ItemEntry} can be used as request parent to store the whole transaction at once
108
+ */
109
+ get rootItem(): ItemEntry | undefined;
110
+ /**
111
+ * @description
112
+ * Is true when the current transaction has:
113
+ * - Newly created items
114
+ * - Removed items (from collections)
115
+ * - Changes on existing items
116
+ */
117
+ get hasChanges(): boolean;
118
+ /**
119
+ * @description
120
+ * Is true while the {@link TransactionCache TransactionCache} is applying changes to the parent (can either be through a merge or an Api save)
121
+ */
122
+ get isSaving(): boolean;
123
+ /**
124
+ * @description
125
+ * Is true while the {@link TransactionCache TransactionCache} is ready to handle new saves
126
+ */
127
+ get isReady(): boolean;
128
+ get isValid(): boolean;
129
+ attachValidator(validator: TransactionValidatorWithDependencies<any>): void;
130
+ /**
131
+ * @description
132
+ * Checks if the transaction is pending (or saving) on itself and on all of its children recursively
133
+ * This can be used to block a transaction if one of the children is still loading (for instance for a file upload)
134
+ */
135
+ isPending(): boolean;
136
+ /**
137
+ * @description
138
+ * Sets the transactionstate to pending, must recieve a promise as a parameter, on promise resolve, transactionstate gets put back to ready
139
+ * If the transaction is already in state saving, we use that and let the save function return it to ready
140
+ * @param promise
141
+ */
142
+ setPending(promise: Promise<any>): Promise<any>;
143
+ createChild(id?: string, validatorFactory?: TransactionValidatorFactory, options?: TransactionOptions): TransactionCache;
144
+ destroy(): void;
145
+ isDestroyed(): boolean;
146
+ expandCollectionResource<ItemTypeType extends ApiItemType>(collectionResource: CollectionResource<ItemTypeType>, newColumns: ApiRequestColumns<ItemTypeType>): Promise<CollectionResource<ItemTypeType>>;
147
+ /**
148
+ * @description
149
+ * Expands the collections with the new request columns. All collections should have the same query (excluding the
150
+ * parent).
151
+ */
152
+ expandCollectionResources<const ItemTypeType extends ApiItemType, CollectionResourceType extends CollectionResource<ItemTypeType, any, any>>(itemType: ItemTypeType, collections: ParentIdMap<CollectionResourceType>, newColumns: ApiRequestColumnArray<ItemTypeType>): Promise<ParentIdMap<CollectionResourceType>>;
153
+ registerFieldChangeCallback<const ItemTypeType extends ApiItemType>(itemType: ItemTypeType, itemId: ItemId, callback: ItemChangesListener<ItemTypeType>): DeregFunction;
154
+ createChangesDelta(logMissingColumnErrors?: boolean): ChangesDelta;
155
+ getFirstErrorString(): undefined | string;
156
+ /**
157
+ * @description
158
+ * Should only be called by {@link TransactionValidator TransactionValidator}
159
+ * @internal
160
+ */
161
+ _setGlobalError(key: string, isInvalid: boolean, saveButtonErrorTranslationFn: () => string, level: TransactionErrorLevel): void;
162
+ /**
163
+ * @description
164
+ * Should only be called by {@link TransactionValidator TransactionValidator}
165
+ * @internal
166
+ */
167
+ _setItemError(itemEntryId: ItemEntry['id'], columnId: string, errorKey: string, isInvalid: boolean, fieldErrorTranslationFn: () => string, saveButtonErrorTranslationFn: () => string, level: TransactionErrorLevel, location?: string): void;
168
+ /**
169
+ * @description
170
+ * Merges the passed changes from the parent Transaction into this Transaction's own changes and then propagates
171
+ * them to all child Transactions, this assumes that an action is already handled in a parent, so it does't handle created entries
172
+ * and removes entries that were in {@link TransactionItemHandler.deletedItems deletedItems} since they are already deleted
173
+ *
174
+ * ------------------
175
+ *
176
+ * The difference between {@link TransactionCache.applyChangesFromParent} and {@link TransactionCache.applyChangesDelta} is that applyChangesFromParent assumes
177
+ * the change has already been processed, and applyChangesDelta will process the changes once you save the transaction
178
+ *
179
+ * ------------------
180
+ * Use {@link TransactionCache.applyChangesDelta applyChangesDelta} if you want to apply changes from outside the core
181
+ */
182
+ applyChangesFromParent(parentChangesDelta: ParentChangesDelta, isCalledAfterSocketUpdate?: boolean, conversionMap?: ItemIdConversionMap): Promise<void>;
183
+ /**
184
+ * Applies changes to this transaction and its children.
185
+ *
186
+ * The difference between {@link TransactionCache.applyChangesFromParent} and {@link TransactionCache.applyChangesDelta}
187
+ * is that applyChangesFromParent assumes the change has already been processed on the parent, and applyChangesDelta
188
+ * will process the changes itself.
189
+ *
190
+ * Please note that the resulting promise resolves before deletes have been processed. Deletes are processed after
191
+ * the changes have been applied to child transactions. This is reflected by the `allChildrenDonePromise` on the
192
+ * result.
193
+ *
194
+ * However, {@link TransactionCache.save} waits until the complete changes delta has been applied, so calling `save`
195
+ * after `applyChangesDelta` should not cause any problems.
196
+ */
197
+ applyChangesDelta(changesDelta: ChangesDelta | ChildChangesDelta): Promise<ChangesDeltaResult>;
198
+ private trackChangesDeltaBeingApplied;
199
+ getRootTransaction(): TransactionCache;
200
+ getServerCache(): ServerCache;
201
+ getCollectionChangesRecursively<const ItemTypeType extends ApiItemType>(itemType: ItemTypeType, parsedQuery: CollectionQuery<ItemTypeType>): CachedQueryItem<ItemTypeType> | undefined;
202
+ /**
203
+ * @description
204
+ * Returns whether or not the {@link TransactionCache.rootItem rootItem} is uses locks
205
+ */
206
+ isLockable(rootItem?: ItemEntry | undefined): rootItem is ItemEntry;
207
+ /**
208
+ * @description
209
+ * Saves the transaction, this has a different effect depending on the transaction's parent.
210
+ *
211
+ * - If the parent is another {@link TransactionCache TransactionCache} it will merge the changes of the child transaction in the the parent transaction
212
+ * - If the parent is the {@link ServerCache ServerCache} it will save the changes to the APi
213
+ */
214
+ save(closeTab?: boolean, parameters?: CreateRequestParameterMap, breakUpByParent?: boolean, onAfterCreateCallback?: OnAfterCreateCallback): Promise<ItemIdConversionMap>;
215
+ /**
216
+ * Rejects when another user is holding the lock, as opposed to {@link LockService.fetchLock}.
217
+ */
218
+ fetchLock(): Promise<void>;
219
+ detectChanges(force?: boolean): boolean;
220
+ /**
221
+ * @description
222
+ * 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.
223
+ */
224
+ clearItem(itemResource: ItemResource<any>): void;
225
+ clearItemEntry<ItemTypeType extends ApiItemType>(itemEntry: ItemEntry<ItemTypeType>): FieldMap<ItemTypeType> | undefined;
226
+ /**
227
+ * @description
228
+ * Adds a callback that will fire before the transaction is saved, rejecting this callback will prevent the transaction from saving
229
+ */
230
+ onBeforeSave(key: string, callback: TransactionCacheCallbackType['onBeforeSave'], condition?: TransactionCacheCallbackCondition, priority?: number): () => void;
231
+ /**
232
+ * @description
233
+ * Adds a callback that will fire when the transaction is saved successfully
234
+ */
235
+ onSaveSuccess(key: string, callback: TransactionCacheCallbackType['onSaveSuccess'], condition?: TransactionCacheCallbackCondition, priority?: number): () => void;
236
+ /**
237
+ * @description
238
+ * Adds a callback that will fire when the root item of the transaction is deleted
239
+ */
240
+ onRootItemDeleted(key: string, callback: TransactionCacheCallbackType['onRootItemDelete'], condition?: TransactionCacheCallbackCondition, priority?: number): () => void;
241
+ /**
242
+ * @description
243
+ * Returns a {@link ModuleChangesCompilationResult ModuleChangesCompilationResult} for the transaction
244
+ */
245
+ getModuleChanges(): ModuleChangesCompilationResult;
246
+ /**
247
+ * @description
248
+ * Updates the passed map with the new {@link ConversionMap CconversionMap} values
249
+ */
250
+ updateItemIdMap(collectionMap: {
251
+ [itemId: number]: any;
252
+ }, conversionMap: ConversionMap): void;
253
+ /**
254
+ * @deprecated Use the `children` collection option instead.
255
+ */
256
+ getLinkCollections<const ItemTypeType extends ApiItemType, const OptionsType extends CollectionOptions<ItemTypeType>>(linkType: ApiItemType, linkIdArray: ItemId[], itemType: ItemTypeType, options: OptionsType): Promise<ParentIdMap<OptionsToCollectionResource<ItemTypeType, OptionsType>>>;
257
+ getCollection<const ItemTypeType extends ApiItemType, const OptionsType extends RootCollectionOptions<ItemTypeType>>(itemType: ItemTypeType, options: OptionsType): Promise<OptionsToCollectionResource<ItemTypeType, OptionsType>>;
258
+ getNewResourceWithId<const ItemTypeType extends ApiItemType, const OptionsType extends NewItemOptions<ItemTypeType>>(itemType: ItemTypeType, itemId: ItemId, options: OptionsType, returnLinks: true, isRoot?: boolean): Promise<ItemResourceLinks<ItemTypeType, OptionsType['columns'], OptionsToChildCollections<OptionsType>>>;
259
+ getNewResourceWithId<const ItemTypeType extends ApiItemType, const OptionsType extends NewItemOptions<ItemTypeType>>(itemType: ItemTypeType, itemId: ItemId, options: OptionsType, returnLinks?: boolean, isRoot?: boolean): Promise<ItemResource<ItemTypeType, OptionsType['columns'], OptionsToChildCollections<OptionsType>>>;
260
+ getNewResource<const ItemTypeType extends ApiItemType, const OptionsType extends NewItemOptions<ItemTypeType>>(itemType: ItemTypeType, options: OptionsType, returnLinks: true, isRoot?: boolean): Promise<ItemResourceLinks<ItemTypeType, OptionsType['columns'], OptionsToChildCollections<OptionsType>>>;
261
+ getNewResource<const ItemTypeType extends ApiItemType, const OptionsType extends NewItemOptions<ItemTypeType>>(itemType: ItemTypeType, options: OptionsType, returnLinks?: boolean, isRoot?: boolean): Promise<ItemResource<ItemTypeType, OptionsType['columns'], OptionsToChildCollections<OptionsType>>>;
262
+ /**
263
+ * @description
264
+ * Fetches multiple items with their respective changes of the current {@link TransactionCache transaction}
265
+ */
266
+ getItemsByQuery<const ItemTypeType extends ApiItemType, const OptionsType extends ItemsByQueryOptions<ItemTypeType>>(itemType: ItemTypeType, query: ApiQuery<ItemTypeType>, options: OptionsType): Promise<ItemResource<ItemTypeType, OptionsType['columns'], OptionsToChildCollections<OptionsType>>[]>;
267
+ /**
268
+ * @description
269
+ * Fetches multiple items with their respective changes of the current {@link TransactionCache transaction}
270
+ */
271
+ getItemsById<const ItemTypeType extends ApiItemType, const OptionsType extends ItemOptions<ItemTypeType>>(itemType: ItemTypeType, itemIds: ItemId[], options: OptionsType): Promise<ItemResource<ItemTypeType, OptionsType['columns'], OptionsToChildCollections<OptionsType>>[]>;
272
+ /**
273
+ * @description
274
+ * Fetches the item with the changes of the current {@link TransactionCache transaction}
275
+ *
276
+ * @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)
277
+ */
278
+ getItemById<const ItemTypeType extends ApiItemType, const OptionsType extends ItemOptions<ItemTypeType>>(itemType: ItemTypeType, itemId: ItemId, options: OptionsType, isRoot?: boolean): Promise<ItemResource<ItemTypeType, OptionsType['columns'], OptionsToChildCollections<OptionsType>>>;
279
+ /**
280
+ * @description
281
+ * Fetches the title of an item, does not create an {@link ItemResource ItemResource}
282
+ */
283
+ fetchTitle(itemType: ApiItemType, itemId: ItemId): Promise<string>;
284
+ /**
285
+ * @description
286
+ * Merges the passed child Transaction into this transaction and then propagates them to the other child transactions
287
+ */
288
+ applyChangesFromChild(childTransaction: TransactionCache): Promise<ItemIdConversionMap>;
289
+ /**
290
+ * @description
291
+ * Gets an ItemEntry from the cache, doesn't do a API request, used for saving
292
+ */
293
+ getLocalItemEntry(itemEntryId: ItemEntry['id']): ItemEntry;
294
+ /**
295
+ * @description
296
+ * Gets an ItemEntry from the cache by ItemId. Looks at the current as well as the parent transaction.
297
+ */
298
+ getLocalItemEntryByItemId<const ItemTypeType extends ApiItemType>(itemType: ItemTypeType, itemId: ItemEntry<ItemTypeType>['itemId']): ItemEntry<ItemTypeType>;
299
+ containsLocalItemEntryByItemId(itemType: ApiItemType, itemId: ItemEntry['itemId']): boolean;
300
+ /**
301
+ * @description
302
+ * Returns the complete {@link ChildChangesDelta} of the TransactionCache, this only takes into account the end
303
+ * result (initial is compared to changes), so changing something and reverting it won't be included.
304
+ */
305
+ getDelta(): ChildChangesDelta;
306
+ createItemResource<ItemTypeType extends ApiItemType, RequestColumns extends ApiRequestColumns<ItemTypeType>, Children extends ChildCollectionResources | undefined = undefined>(itemEntry: ItemEntry<ItemTypeType>, childCollectionMap?: Children, isNew?: boolean, onChange?: ItemAggregatedChangesListener<ItemResource<ItemTypeType, RequestColumns, Children>>, abortSignal?: AbortSignal): ItemResource<ItemTypeType, RequestColumns, Children>;
307
+ createItemResources<ItemTypeType extends ApiItemType, RequestColumns extends ApiRequestColumns<ItemTypeType>, Children extends ChildCollectionResources | undefined = undefined>(itemEntries: Iterable<ItemEntry<ItemTypeType>>, childCollectionResourceMap?: ParentIdMap<Children>, changesListener?: ItemAggregatedChangesListener<ItemResource<ItemTypeType, any, any>>, abortSignal?: AbortSignal): ItemResource<ItemTypeType, RequestColumns, Children>[];
308
+ processLinkedItems(linkedEntries: ItemTypeMap<ItemEntry[]>, onChange?: ItemAggregatedChangesListener<any>, abortSignal?: AbortSignal): ItemResourcesItemTypeMap;
309
+ clearItemError(itemEntryId?: ItemEntry['id'], columnId?: string, errorKey?: string): void;
310
+ clearItemError(itemEntryId: ItemEntry['id'], columnId?: string, errorKey?: string): void;
311
+ clearItemError(itemEntryId: ItemEntry['id'], columnId: string, errorKey?: string): void;
312
+ clearItemError(itemEntryId: ItemEntry['id'], columnId: string, errorKey: string): void;
313
+ private doApplyChangesDelta;
314
+ private updateSignals;
315
+ /**
316
+ * This method:
317
+ * - calls changes listeners for single items;
318
+ * - runs validators for single items;
319
+ * - calls changes listeners for collections;
320
+ * - calls aggregated changes listeners;
321
+ *
322
+ * When this method is called, all collections should already be updated. This ensures collections used in changes
323
+ * listeners and validators are up-to-date.
324
+ *
325
+ * @param changesDelta - Newly created items as well as previous values for changed items are read from this
326
+ * changes delta.
327
+ * {@link processUpdatesFromDelta} should have been called already. TODO: Express this in the type somehow.
328
+ */
329
+ private runChangesListenersAndValidators;
330
+ private clearChildCollectionResources;
331
+ /**
332
+ * Sets a default value for all columns required to match / fit in collections.
333
+ *
334
+ * This whole step could be removed once we always request all columns when doing a columns request. (RM4-25895).
335
+ * We could set a default value for all columns when creating a local item, even if the column is not included in
336
+ * the template.
337
+ */
338
+ private expandLocalItemsFromDelta;
339
+ private clearGlobalError;
340
+ private maybeCallInitialChangesListener;
341
+ }
342
+ export {};
@@ -0,0 +1,111 @@
1
+ import { ApiItemType, ItemId } from '@rentman/backend-types';
2
+ import { ApiQuery, CachedQueryHandlerBase, CachedQueryHandlerCollectionTuple, CachedQueryItem, CachedQueryItemsItemTypeTuple, CachedQueryItemTuple, CachedQueryOptions, ChildCollectionsOption, CollectionItemResourceChanges, CollectionOptions, CollectionQuery, CollectionResource, EntryParent, ItemIdConversionMap, LinkCollectionBatchQueryTuple, MatchesAccumulatorMap, MatchingResultsAccumulatorMapType, ParentCachedQueryItemTuple, RequestColumnsOperationsCache, TransactionCache, TransactionCollectionHandlerDependencyInterface } from '../../../internal';
3
+ import { RootQueryNode } from '../../matcher/RootQueryNode';
4
+ export interface LinkCollectionOptionsItemTypeTuple<ItemTypeType extends ApiItemType> {
5
+ itemType: ItemTypeType;
6
+ linkCollectionOptions: LinkCollectionOptionsTuple<ItemTypeType>;
7
+ }
8
+ interface CollectionQueryTuple<ItemTypeType extends ApiItemType> {
9
+ parsedQuery: CollectionQuery<ItemTypeType>;
10
+ options: CollectionOptions<ItemTypeType>;
11
+ }
12
+ interface LinkCollectionOptionsTuple<ItemTypeType extends ApiItemType> extends LinkCollectionBatchQueryTuple<ItemTypeType> {
13
+ collectionQueryTuples: CollectionQueryTuple<ItemTypeType>[];
14
+ }
15
+ interface TransactionCachedQueryHandlerCollectionTuple<ItemTypeType extends ApiItemType> extends CachedQueryHandlerCollectionTuple<ItemTypeType> {
16
+ collectionResources?: WeakRef<CollectionResource<ItemTypeType, any, any>>[];
17
+ }
18
+ export declare class TransactionCachedQueryHandler extends CachedQueryHandlerBase {
19
+ protected dependencies: TransactionCollectionHandlerDependencyInterface;
20
+ /**
21
+ * As opposed to the server cache, where `collections` only contains cached queries, on the transaction cache
22
+ * `collections` can contain collection resources as well.
23
+ */
24
+ protected collections: {
25
+ [ItemType in ApiItemType]?: {
26
+ [queryString: string]: TransactionCachedQueryHandlerCollectionTuple<ItemType> | undefined;
27
+ };
28
+ };
29
+ protected transaction: TransactionCache;
30
+ constructor(dependencies: TransactionCollectionHandlerDependencyInterface, transaction: TransactionCache);
31
+ getCollectionResources<const ItemTypeType extends ApiItemType>(itemType: ItemTypeType, queryString: string, cleanUpStaleResources?: boolean): Generator<CollectionResource<ItemTypeType, any, any>>;
32
+ /**
33
+ * This method is called when constructing a collection resource. There should be no need to call it in any other
34
+ * situation.
35
+ */
36
+ addCollectionResource<CollectionResourceType extends CollectionResource<any, any, any>>(resource: CollectionResourceType): CollectionResourceType;
37
+ /**
38
+ * Iterates over all collection resources that don't have an associated cached query.
39
+ */
40
+ getUncachedCollectionsIterator<ItemTypeType extends ApiItemType>(itemType: ItemTypeType): Generator<CollectionResource<ItemTypeType>>;
41
+ clearCollectionResource<ItemTypeType extends ApiItemType>(resource: CollectionResource<ItemTypeType, any, any>): void;
42
+ /**
43
+ * @description
44
+ * Updates all cached queries which references one of the updated IDs in the conversionMap
45
+ *
46
+ * @param conversionMap ConversionMap with the updated IDs
47
+ */
48
+ updateLocalItemIdReferences(conversionMap: ItemIdConversionMap): void;
49
+ __maybeExpandCachedQuery<const ItemTypeType extends ApiItemType>(itemType: ItemTypeType, queryString: string, columnsOperationsCache: RequestColumnsOperationsCache<ItemTypeType>, batchedLinkedToQuery?: CollectionQuery<ItemTypeType>): Promise<CachedQueryItem<ItemTypeType>>;
50
+ __fetchItemEntriesByQueryData<const ItemTypeType extends ApiItemType>(itemType: ItemTypeType, options: CachedQueryOptions<ItemTypeType>, columnsOperationsCache: RequestColumnsOperationsCache<ItemTypeType>, collectionQuery: CollectionQuery<ItemTypeType>, linkCollectionBatchQueryTuple?: LinkCollectionBatchQueryTuple<ItemTypeType>): Promise<CachedQueryItem<ItemTypeType>>;
51
+ /**
52
+ * @remark
53
+ * todo not only linkedTo should be checked, but it should check if there's a local ID anywhere in the query
54
+ * ({<field>: <localId>}) is also a local query
55
+ */
56
+ isLocal<ItemTypeType extends ApiItemType>(options: {
57
+ parent?: EntryParent;
58
+ }, query: ApiQuery<ItemTypeType>): boolean;
59
+ /**
60
+ * @description
61
+ * Fetches collections linked to the passed parents
62
+ * @returns An array of cached query items. The items are in the same order as the parent IDs.
63
+ */
64
+ __fetchLinkedCachedQueryItems<const ItemTypeType extends ApiItemType>(itemType: ItemTypeType, linkCollectionOptionsTuple: LinkCollectionOptionsTuple<ItemTypeType>): Promise<CachedQueryItemTuple<ItemTypeType>[]>;
65
+ createBatchLinkedToQuery<ItemTypeType extends ApiItemType>(parentItemType: ApiItemType, parentItemIds: ItemId[], additionalQuery?: ApiQuery<ItemTypeType>): CollectionQuery<ItemTypeType>;
66
+ /**
67
+ * The order of the `collectionQueryTuples` property of the result will be the same as the order of
68
+ * `parentItemIds`.
69
+ */
70
+ processLinkCollectionOptions<ItemTypeType extends ApiItemType>(itemType: ItemTypeType, parentItemType: ApiItemType, parentItemIds: ItemId[], options: CollectionOptions<ItemTypeType>): LinkCollectionOptionsTuple<ItemTypeType>;
71
+ __fetchParentCachedQueryItem<const ItemTypeType extends ApiItemType>(itemType: ItemTypeType, options: CollectionOptions<ItemTypeType>): Promise<ParentCachedQueryItemTuple<ItemTypeType>>;
72
+ __fetchChildCachedQueryItems(parentItemType: ApiItemType, parentItemIds: ItemId[], childCollectionOptions: ChildCollectionsOption): Promise<CachedQueryItemsItemTypeTuple<ApiItemType>[]>;
73
+ /**
74
+ * Fetches a cached query, respecting children. Like {@link __fetchItemEntriesByQueryData}, assumes the options are
75
+ * processed already.
76
+ *
77
+ * todo: Rename this method and {@link __fetchItemEntriesByQueryData} to something that's easier to understand.
78
+ */
79
+ __fetchParentItemEntriesByQueryData<ItemTypeType extends ApiItemType>(itemType: ItemTypeType, options: CollectionOptions<ItemTypeType>, columnsOperationsCache: RequestColumnsOperationsCache<ItemTypeType>, collectionQuery: CollectionQuery<ItemTypeType>): Promise<ParentCachedQueryItemTuple<ItemTypeType>>;
80
+ private cloneOptions;
81
+ fetchChildCachedQueryItems(linkCollectionOptionsItemTypeTuples: LinkCollectionOptionsItemTypeTuple<ApiItemType>[]): Promise<CachedQueryItemsItemTypeTuple<ApiItemType>[]>;
82
+ /**
83
+ * Updates the items included in cached queries and collection resources based on query matcher results. Note that
84
+ * method does not clear child collection resources of removed item resources.
85
+ */
86
+ applyMatchingResultsToCollections(matchingResultsAccumulatorMap: MatchesAccumulatorMap<MatchingResultsAccumulatorMapType>): Promise<CollectionItemResourceChanges<any>[]>;
87
+ protected clearCollectionTupleIfEmpty<ItemTypeType extends ApiItemType>(itemType: ItemTypeType, queryString: string, didAlreadyClearResourceRefs?: boolean): void;
88
+ protected getQueryGraphsForItemType<ItemTypeType extends ApiItemType>(itemType: ItemTypeType): Set<RootQueryNode<ItemTypeType>>;
89
+ protected getCollectionQueries<ItemTypeType extends ApiItemType>(itemType: ItemTypeType, queryString: string): Set<CollectionQuery<ItemTypeType>>;
90
+ private getCollectionResourcesByTuple;
91
+ private updateQueryLocalItemIdReferences;
92
+ /**
93
+ * Sets the `children` property for each of the cached queries in `cachedQueryItemTuples`. Assumes the `children`
94
+ * *options* property is the same for all cached query items.
95
+ *
96
+ * The `children` property will remain `null` if the children option is unset.
97
+ */
98
+ private resolveParentCachedQueryItems;
99
+ private resolveLocalCachedQueryItem;
100
+ private mergeColumnsAndExpandLocalItems;
101
+ private getLocalItemEntries;
102
+ /**
103
+ * For all items with changes on the transaction, check whether they fit the query. This will catch both items
104
+ * that now fit the query and items that no longer fit the query. Because items that are created on this transaction
105
+ * are also considered to have changes, this will cover those, too.
106
+ */
107
+ private matchItemEntriesWithChangesToCachedQuery;
108
+ private syncCachedQueryWithLocalItems;
109
+ private cleanUpQueryString;
110
+ }
111
+ export {};
@@ -0,0 +1,17 @@
1
+ import { ErrorHandlerInterface, ItemIdConversionMap, TransactionCache } from '../../../internal';
2
+ export type TransactionCacheCallbackCondition = 'always' | 'onClose' | 'skipOnClose';
3
+ export type TransactionCacheCallbackType = {
4
+ onBeforeSave: (transaction: TransactionCache) => any;
5
+ onSaveSuccess: (transaction: TransactionCache, conversionMap: ItemIdConversionMap) => any;
6
+ onRootItemDelete: () => any;
7
+ };
8
+ export declare class TransactionEventHandler {
9
+ private errorHandler;
10
+ private callbacks;
11
+ constructor(errorHandler: ErrorHandlerInterface);
12
+ clear(): void;
13
+ registerCallback<T extends keyof TransactionCacheCallbackType>(type: T, key: string, callback: TransactionCacheCallbackType[T], condition?: TransactionCacheCallbackCondition, priority?: number): () => void;
14
+ executeCallbacks<T extends keyof TransactionCacheCallbackType>(type: T, execute: (callback: TransactionCacheCallbackType[T]) => any, closeTab: boolean): Promise<any>;
15
+ private getPriorityLevel;
16
+ private executeCallbacksPriorityLevel;
17
+ }
@@ -0,0 +1,121 @@
1
+ import { ApiItemType, ItemId } from '@rentman/backend-types';
2
+ import { ApiRequestColumns, ChangesDelta, ChangesDeltaBase, ChangesDeltaBaseItemUpdateDelta, ChangesDeltaItemCreateDelta, ChangesDeltaResult, DeregFunction, FieldMap, ItemChangesListenerContext, ItemEntry, ItemHandlerBase, ItemHandlerFieldsProxyTarget, ItemIdConversionMap, ItemResource, ItemTypeColumnIds, ItemTypeMap, ModifyFieldsCallback, NewItemOptions, ParentChangesDelta, RequestColumnsOperationsCache, ResponseColumnItemTypeMap, TransactionCache, TransactionItemHandlerDependencyInterface } from '../../../internal';
3
+ export type TransactionDeletedItem = {
4
+ entry: ItemEntry;
5
+ isCascaded: boolean;
6
+ };
7
+ export interface TransactionItemHandlerFieldsProxyTarget<ItemTypeType extends ApiItemType> extends ItemHandlerFieldsProxyTarget<ItemTypeType> {
8
+ itemHandler: TransactionItemHandler;
9
+ }
10
+ export type ItemChangesListener<ItemTypeType extends ApiItemType, ColumnIds extends ItemTypeColumnIds<ItemTypeType> = ItemTypeColumnIds<ItemTypeType>> = (args: ItemChangesListenerContext<ItemResource<ItemTypeType, ColumnIds>>) => void;
11
+ /**
12
+ * See {@link ItemHandlerBase.fieldsProxyHandler}.
13
+ */
14
+ export declare const initialProxyHandler: ProxyHandler<TransactionItemHandlerFieldsProxyTarget<any>>;
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 __fetchCachedQueryItem the entry from the server
19
+ */
20
+ export declare class TransactionItemHandler extends ItemHandlerBase {
21
+ private dependencies;
22
+ transaction: TransactionCache;
23
+ fieldChangeCallbacks: {
24
+ [itemType: string]: {
25
+ [itemId: string]: ItemChangesListener<any, any>[];
26
+ };
27
+ };
28
+ /**
29
+ * @warning
30
+ * Can contain both local and non-local {@link ItemEntry itemEntries}
31
+ */
32
+ deletedItems: ItemTypeMap<TransactionDeletedItem[]>;
33
+ itemResourcesPerEntry: Map<ItemEntry, WeakRef<ItemResource<any, any, any>>[]>;
34
+ constructor(dependencies: TransactionItemHandlerDependencyInterface, transaction: TransactionCache);
35
+ registerItemResource(itemResource: ItemResource<any, any, any>): void;
36
+ getItemResources<const ItemTypeType extends ApiItemType>(itemEntry: ItemEntry<ItemTypeType>, cleanUpStaleResources?: boolean): Generator<ItemResource<ItemTypeType, any, any>>;
37
+ cleanUpItemResourcesForEntry(itemEntry: ItemEntry<any>): void;
38
+ clearItemEntry<ItemTypeType extends ApiItemType>(itemEntry: ItemEntry<ItemTypeType>): FieldMap<ItemTypeType> | undefined;
39
+ addToDeletedItems(itemEntry: ItemEntry<any>, isCascaded: boolean): void;
40
+ removeFromDeletedItems(itemEntry: ItemEntry<any>): void;
41
+ getDeletedItemsIterator<ItemTypeType extends ApiItemType>(itemType: ItemTypeType): IterableIterator<ItemEntry<ItemTypeType>>;
42
+ getDeletedItemsAmount<ItemTypeType extends ApiItemType>(itemType: ItemTypeType): number;
43
+ /**
44
+ * Construct a proxy object for the initial fields of the item. Reading a field will traverse the transaction chain.
45
+ * The fields will come from the parent transaction, if avaiable.
46
+ */
47
+ constructInitialProxy<ItemTypeType extends ApiItemType>(itemEntry: ItemEntry<ItemTypeType>): FieldMap<ItemTypeType>;
48
+ getItemEntriesWithChangesIterator(): Generator<ItemEntry<any>>;
49
+ /**
50
+ * Processes the changes on the transaction, and stores the changes as well as the previous values in
51
+ * `parentChangesDelta`. Also handles changes listeners and validators.
52
+ *
53
+ * Note: Even though both the server item handler and the transaction item handler have a
54
+ * {@link processUpdatesFromDelta} method, it is not defined on the superclass as the transaction item handler
55
+ * introduces the `createItemChangesIfNoneExist` parameter.
56
+ */
57
+ processUpdatesFromDelta(updated: {
58
+ [itemEntryId: number]: ChangesDeltaBaseItemUpdateDelta<any>;
59
+ }, createItemChangesIfNoneExist: boolean, parentChangesDelta: ParentChangesDelta): void;
60
+ updateLocalItemIdReferences(itemType: ApiItemType, oldItemId: ItemId, newItemId: ItemId, changesDelta: ChangesDeltaBase): void;
61
+ registerFieldChangeCallback<ItemTypeType extends ApiItemType>(itemType: ItemTypeType, itemId: ItemId, callback: ItemChangesListener<ItemTypeType>): DeregFunction;
62
+ createItemEntry(createTuple: ChangesDeltaItemCreateDelta): ItemEntry;
63
+ /**
64
+ * @description
65
+ * Gets the local {@link FieldMap changes} of the {@link ItemEntry entry} on the {@link TransactionCache transaction} in a formatted way the API accepts
66
+ */
67
+ formatRequest<ItemEntryType extends ItemEntry>(entry: ItemEntryType): {
68
+ [columnId: string]: any;
69
+ };
70
+ detectChanges(): boolean;
71
+ /**
72
+ * @description
73
+ * Checks if the transaction has changes for the passed {@link ItemEntry.id ItemEntryId}
74
+ */
75
+ detectEntryChanges(itemEntryId: ItemEntry['id']): boolean;
76
+ cloneItemEntries<ItemTypeType extends ApiItemType>(changesDelta: ChangesDelta, itemEntries: ItemEntry<ItemTypeType>[], conversionMap?: ItemIdConversionMap, modifyFieldsCallback?: ModifyFieldsCallback): ItemId[];
77
+ cloneItemEntry<ItemTypeType extends ApiItemType>(changesDelta: ChangesDelta, sourceEntry: ItemEntry<ItemTypeType>, conversionMap?: ItemIdConversionMap, modifyFieldsCallback?: ModifyFieldsCallback): ItemId;
78
+ fetchItemEntry<ItemTypeType extends ApiItemType>(itemType: ItemTypeType, itemId: ItemId, requestColumns: ApiRequestColumns<ItemTypeType>): Promise<ItemEntry<ItemTypeType>>;
79
+ fetchItemEntries<ItemTypeType extends ApiItemType>(itemType: ItemTypeType, itemIds: ItemId[], requestColumns: ApiRequestColumns<ItemTypeType>): Promise<ItemEntry<ItemTypeType>[]>;
80
+ /**
81
+ * @description
82
+ * Fetches a template and creates a new {@link ItemEntry ItemEntry}, will error if the ItemEntry with the given ItemId already exists
83
+ */
84
+ fetchNewItemEntry<ItemTypeType extends ApiItemType>(itemType: ItemTypeType, itemId: ItemId, options: NewItemOptions<ItemTypeType>, isRoot?: boolean): Promise<ChangesDeltaResult>;
85
+ fetchItemEntryData<ItemTypeType extends ApiItemType>(itemType: ItemTypeType, itemIds: Iterable<ItemId>, columnsOperationsCache: RequestColumnsOperationsCache<ItemTypeType>, refreshAggregateColumns: boolean, forceRequest?: boolean): Promise<ItemEntry<ItemTypeType>[]>;
86
+ fetchTitle<ItemTypeType extends ApiItemType>(itemType: ItemTypeType, itemId: ItemId): Promise<string>;
87
+ /**
88
+ * `expandLocalItemEntries` ensures values are available for the columns passed in `requestColumns`. As this method
89
+ * only handles local items, it will set a default value.
90
+ *
91
+ * This is not handled using a changes delta because:
92
+ * - these changes are strictly limited to the current transaction;
93
+ * - existing fields are not affected, so no changes hooks should be triggered.
94
+ *
95
+ * @param itemEntries - Only local item entries (stored on this transaction only) should be passed here.
96
+ */
97
+ expandLocalItemEntries<ItemTypeType extends ApiItemType>(itemType: ItemTypeType, itemEntries: ItemEntry<ItemTypeType>[], requestColumns: ApiRequestColumns<ItemTypeType>, responseColumns: Partial<ResponseColumnItemTypeMap>, refreshAggregateColumns: boolean): Promise<void>;
98
+ /**
99
+ * If the entry was previously deleted, and somehow updated by another call (could be from server) we don't want to
100
+ * re-add it to collections.
101
+ */
102
+ itemIsDeleted<ItemTypeType extends ApiItemType>(itemEntry: ItemEntry<ItemTypeType>): boolean;
103
+ clearItemResource(resource: ItemResource<any, any, any>): void;
104
+ /**
105
+ * @description
106
+ * Processes on a cached entry, if there are no {@link TransactionItemHandler.itemChanges itemChanges} the new
107
+ * values will not be processed unless `createItemChangesIfNoneExist` is set.
108
+ *
109
+ * Note: Even though both the server item handler and the transaction item handler have a
110
+ * {@link processItemEntryChanges} method, it is not defined on the superclass as the transaction item handler
111
+ * introduces a `createItemChangesIfNoneExist` parameter.
112
+ *
113
+ * @param createItemChangesIfNoneExist Is `true` when called from `applyChangesDelta`. We assume that when
114
+ * `applyChangesDelta` is called with updates that aren't on the transaction they should be added.
115
+ *
116
+ * @returns An object containing a previous value for each applied change. Because of the nature of item changes
117
+ * it may also include changes applied on ancestor transactions. Is `null` when no changes have been made.
118
+ */
119
+ protected processItemEntryChanges<ItemTypeType extends ApiItemType>(itemEntryChangesTuple: ChangesDeltaBaseItemUpdateDelta<ItemTypeType>, createItemChangesIfNoneExist: boolean): Readonly<Partial<FieldMap<ItemTypeType>>> | null;
120
+ private fetchLocalItemEntryData;
121
+ }
@@ -0,0 +1,25 @@
1
+ import { ApiItemType } from '@rentman/backend-types';
2
+ import { FieldMap, ItemChangesListenerContext, ItemEntry, ItemResource, ItemTypeColumnIds, TransactionCache } from '../../../internal';
3
+ import { TransactionValidatorBase } from './TransactionValidatorBase';
4
+ export interface TransactionValidatorFactory {
5
+ construct(transaction: TransactionCache): TransactionValidator;
6
+ }
7
+ export type TransactionValidatorCompareField<ItemTypeType extends ApiItemType, ColumnIds extends ItemTypeColumnIds<ItemTypeType> = ItemTypeColumnIds<ItemTypeType>> = ItemChangesListenerContext<ItemResource<ItemTypeType, ColumnIds>>['compareField'];
8
+ export declare abstract class TransactionValidator extends TransactionValidatorBase {
9
+ /**
10
+ * @description
11
+ * Will be called after {@link TransactionCache.applyChangesFromParent applyChangesFromParent}, {@link TransactionCache.applyChangesFromChild applyChangesFromChild} or {@link TransactionCache.applyChangesDelta applyChangesDelta} is called
12
+ * Allows you to set {@link TransactionCache.errors global errors}
13
+ */
14
+ abstract validateTransaction(): void;
15
+ /**
16
+ * @description
17
+ * Will be called whenever an item is changed, allows you to set errors on the transaction
18
+ * @param itemEntry
19
+ * @param fields
20
+ * @param previous Previous contain only fields changed on this transaction
21
+ * @param compareField
22
+ */
23
+ abstract validateItem<ItemTypeType extends ApiItemType>(itemEntry: ItemEntry<ItemTypeType>, fields: FieldMap<ItemTypeType>, previous: Partial<FieldMap<ItemTypeType>>, compareField: TransactionValidatorCompareField<ItemTypeType>): void;
24
+ protected hasFields<ItemTypeType extends ApiItemType, ColumnIds extends ItemTypeColumnIds<ItemTypeType>>(fields: FieldMap<ItemTypeType, []>, columnIds: ColumnIds): fields is FieldMap<ItemTypeType, ColumnIds>;
25
+ }
@@ -0,0 +1,19 @@
1
+ import { ItemEntry, TransactionCache, TransactionErrorLevel } from '../../../internal';
2
+ export declare abstract class TransactionValidatorBase {
3
+ protected transaction: TransactionCache;
4
+ private lastCallIdMap;
5
+ isPendingSignal: import("@angular/core").Signal<boolean>;
6
+ protected _lastCallId: number;
7
+ constructor(transaction: TransactionCache);
8
+ /**
9
+ * @description
10
+ * Will return `true` if there are any validators pending
11
+ */
12
+ isPending(): boolean;
13
+ setItemError(itemEntryId: ItemEntry['id'], columnId: string, errorKey: string, isInvalid: boolean | Promise<boolean>, fieldErrorTranslationFn: () => string, saveButtonErrorTranslationFn?: () => string, level?: TransactionErrorLevel, location?: string): void;
14
+ setGlobalError(key: string, isInvalid: boolean | Promise<boolean>, saveButtonErrorTranslationFn: () => string, level?: TransactionErrorLevel): void;
15
+ private getHash;
16
+ private deleteLastCall;
17
+ private setLastCall;
18
+ private isLastCall;
19
+ }