@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,23 @@
1
+ import { ApiItemType, ItemId } from '@rentman/backend-types';
2
+ import { ColumnSet } from '../internal';
3
+ export declare class ItemEntry<ItemTypeType extends ApiItemType = any> {
4
+ itemType: ItemTypeType;
5
+ itemId: ItemId;
6
+ columns: ColumnSet<ItemTypeType>;
7
+ private static currentId;
8
+ id: number;
9
+ isLockableSignal: import("@angular/core").WritableSignal<boolean>;
10
+ isLocalSignal: import("@angular/core").WritableSignal<boolean>;
11
+ private outdated;
12
+ constructor(itemType: ItemTypeType, itemId: ItemId, columns: ColumnSet<ItemTypeType>);
13
+ updateId(newItemId: number): void;
14
+ isOutdated(): boolean;
15
+ markOutdated(): void;
16
+ markUpToDate(): void;
17
+ isLocal(): boolean;
18
+ isLockable(): boolean;
19
+ toJSON(): {
20
+ id: number;
21
+ columns: ColumnSet<ItemTypeType>;
22
+ };
23
+ }
@@ -0,0 +1,25 @@
1
+ import { ApiItemType } from '@rentman/backend-types';
2
+ import { ApiRequestColumnArray, ChildCollectionsOption, EntryParent, FieldMap, ItemAggregatedChangesListener, ItemResource, RequestParameters } from '../internal';
3
+ export interface ItemOptions<ItemTypeType extends ApiItemType, RequestColumns extends ApiRequestColumnArray<ItemTypeType> = ApiRequestColumnArray<ItemTypeType>, Children extends ChildCollectionsOption = ChildCollectionsOption> {
4
+ columns: RequestColumns;
5
+ children?: Children;
6
+ abortSignal?: AbortSignal;
7
+ /**
8
+ * Note: When using the `changesListener` option the `context` parameter is untyped. (This would require self
9
+ * reference.)
10
+ *
11
+ * If you need access to the context, you should: either declare (and explicitly type) a named changes listener
12
+ * or use the `registerChangesListener` method on the collection resource.
13
+ */
14
+ changesListener?: ItemAggregatedChangesListener<ItemResource<ItemTypeType, any, any>>;
15
+ immediatelyCallChangesListener?: boolean;
16
+ }
17
+ export interface NewItemOptions<ItemTypeType extends ApiItemType, RequestColumns extends ApiRequestColumnArray<ItemTypeType> = ApiRequestColumnArray<ItemTypeType>, Children extends ChildCollectionsOption = ChildCollectionsOption> extends ItemOptions<ItemTypeType, RequestColumns, Children> {
18
+ parent?: EntryParent;
19
+ templateOptions?: Partial<RequestParameters<ItemTypeType>>;
20
+ defaultValues?: Partial<FieldMap<ItemTypeType>>;
21
+ }
22
+ export interface ItemsByQueryOptions<ItemTypeType extends ApiItemType, RequestColumns extends ApiRequestColumnArray<ItemTypeType> = ApiRequestColumnArray<ItemTypeType>, Children extends ChildCollectionsOption = ChildCollectionsOption> extends ItemOptions<ItemTypeType, RequestColumns, Children> {
23
+ parent?: EntryParent;
24
+ preventCaching?: boolean;
25
+ }
@@ -0,0 +1,135 @@
1
+ import { Signal } from '@angular/core';
2
+ import { ApiItemType } from '@rentman/backend-types';
3
+ import { AggregatedChangesListenerFunction, ApiRequestColumns, DeregFunction, DerivedStringToRequestColumnPath, EntryParentNull, FieldMap, ItemAggregatedChangesListener, ItemEntry, ItemResourceFactory, ItemTypeColumnIds, RequestColumnsFieldMap, RequestColumnsSignalFieldMap, RequestColumnsToDerivedArrayPaths, RequestColumnsToDerivedStringPaths, RequestParameters, RequestToItemColumns, ResolveDerivedValue, ResolveDerivedValues, ResponseColumnMap, TransactionCache } from '../internal';
4
+ /**
5
+ * This type is used to constrain the `Children` type parameter of item resources and collection resources. We don't
6
+ * specify the whole collection resource here to prevent creating a circular type.
7
+ */
8
+ export type ChildCollectionResources = {
9
+ [ChildItemType in ApiItemType]?: {
10
+ itemType: ChildItemType;
11
+ items: any[];
12
+ };
13
+ };
14
+ export type ItemResourceComputedSignalFunction<ItemTypeType extends ApiItemType, RequestColumns extends ApiRequestColumns<ItemTypeType>, ReturnValue = unknown> = (itemResource: {
15
+ transaction: TransactionCache;
16
+ entry: ItemEntry<ItemTypeType>;
17
+ fieldSignals: Readonly<RequestColumnsSignalFieldMap<ItemTypeType, RequestColumns>>;
18
+ getDerivedSignal: <GetDerivedSignalPath extends readonly string[] | string, DefaultValue = unknown>(pathInput: GetDerivedSignalPath, defaultValue?: DefaultValue) => Signal<MaybeDefaultValue<ResolveDerivedValue<ItemTypeType, GetDerivedSignalPath extends string ? DerivedStringToRequestColumnPath<GetDerivedSignalPath> : GetDerivedSignalPath>, DefaultValue>>;
19
+ }) => ReturnValue;
20
+ type MaybeDefaultValue<T, DefaultValue> = DefaultValue extends number | bigint | string | boolean | null | object ? DefaultValue | T : T;
21
+ export declare class ItemResource<ItemTypeType extends ApiItemType = ApiItemType, RequestColumns extends ApiRequestColumns<ItemTypeType> = ItemTypeColumnIds<ItemTypeType>, Children extends ChildCollectionResources | undefined = undefined> {
22
+ protected readonly factory: ItemResourceFactory;
23
+ readonly entry: ItemEntry<ItemTypeType>;
24
+ readonly transaction: TransactionCache;
25
+ private readonly _isNew;
26
+ columns: ResponseColumnMap<ItemTypeType, RequestToItemColumns<ItemTypeType, RequestColumns>>;
27
+ fields: Readonly<RequestColumnsFieldMap<ItemTypeType, RequestColumns>>;
28
+ initial: Readonly<RequestColumnsFieldMap<ItemTypeType, RequestColumns>>;
29
+ fieldSignals: Readonly<RequestColumnsSignalFieldMap<ItemTypeType, RequestColumns>>;
30
+ itemType: ItemTypeType;
31
+ children: Children;
32
+ /**
33
+ * We type this loosely to prevent TypeScript inferring a complex type when comparing item resources.
34
+ */
35
+ private readonly aggregatedChangesListeners;
36
+ private derivedFieldSignals;
37
+ private __computedFunctions;
38
+ constructor(factory: ItemResourceFactory, entry: ItemEntry<ItemTypeType>, transaction: TransactionCache, _isNew: boolean, abortSignal?: AbortSignal | null);
39
+ onConstruct(): void;
40
+ computedSignal<FunctionReference extends ItemResourceComputedSignalFunction<ItemTypeType, RequestColumns>>(functionReference: FunctionReference): Signal<ReturnType<FunctionReference>>;
41
+ /**
42
+ * We type this loosely to prevent TypeScript inferring a complex type when comparing item resources.
43
+ * @internal
44
+ */
45
+ getAggregatedChangesListeners<ChangesListeners extends Set<AggregatedChangesListenerFunction<any, any>>>(accumulator?: ChangesListeners): ChangesListeners;
46
+ clearResource(): void;
47
+ deregisterChangesListener(listener: ItemAggregatedChangesListener<ItemResource<ItemTypeType, RequestColumns, Children>>): void;
48
+ registerChangesListener(listener: ItemAggregatedChangesListener<ItemResource<ItemTypeType, RequestColumns, Children>>): DeregFunction;
49
+ setChildCollectionResources(children: Children): void;
50
+ /**
51
+ * Collects all the fields from this item, useful while debugging when you want to look at the complete fieldset
52
+ * (because this.fields is now a proxy class)
53
+ */
54
+ collectFields(): RequestColumnsFieldMap<ItemTypeType, RequestColumns>;
55
+ /**
56
+ * @description
57
+ * 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
58
+ */
59
+ setFields(values: Partial<FieldMap<ItemTypeType>>): Promise<this>;
60
+ /**
61
+ * Copies the fields of the item resource to `destination`.
62
+ * Note: When you want to create lots of copies, there are some straightforward optimizations that can be done here.
63
+ * @param destination - For the resulting type to be correct, the columns of the destination should be known. Existing
64
+ * properties will be preserved.
65
+ * @param columnIds - The columns that should be copied. Only fields specified in the item resource type can be set here.
66
+ * Will copy all available columns by default. (Note: may include columns not specified in the type.)
67
+ * @returns The `destination` object.
68
+ */
69
+ copyFields<DestinationColumnIds extends ItemTypeColumnIds<ItemTypeType> = [], ColumnIds extends readonly RequestToItemColumns<ItemTypeType, RequestColumns>[number][] = RequestToItemColumns<ItemTypeType, RequestColumns>[number][]>(destination?: FieldMap<ItemTypeType, DestinationColumnIds>, columnIds?: ColumnIds): FieldMap<ItemTypeType, DestinationColumnIds | ColumnIds>;
70
+ /**
71
+ * Fetches the ItemResource's parent with the current fields
72
+ *
73
+ * ----------------
74
+ *
75
+ * @remark
76
+ * Use this if you need to get the parent after an item has been deleted
77
+ */
78
+ getParent(fromInitial?: boolean): EntryParentNull;
79
+ /**
80
+ * @description
81
+ * Utility function to easily check if a field is changed.
82
+ * Will return `false` if the field is changed
83
+ *
84
+ * @example
85
+ * onChange: (
86
+ * itemResource,
87
+ * previous,
88
+ * compareItemField
89
+ * ) {
90
+ * if (!compareItemField('columnId')) {
91
+ * processItem(itemResource);
92
+ * }
93
+ * }
94
+ */
95
+ compareItemField(columnId: RequestToItemColumns<ItemTypeType, RequestColumns>[number], previous: RequestColumnsFieldMap<ItemTypeType, RequestColumns>): boolean;
96
+ hasChanges(): boolean;
97
+ setTransactionParameters(parameters: Partial<RequestParameters<ItemTypeType>>): void;
98
+ /**
99
+ * @description
100
+ * 'isNew' means that the {@link ItemEntry ItemEntry} is a local item and that this resource was created when the {@link ItemEntry ItemEntry} was first created
101
+ */
102
+ isNew(): boolean;
103
+ isLocal(): boolean;
104
+ toJSON(): {
105
+ columns: string[];
106
+ fields: Readonly<RequestColumnsFieldMap<ItemTypeType, RequestColumns>>;
107
+ entry: ItemEntry<ItemTypeType>;
108
+ };
109
+ getDerivedSignal<const T extends RequestColumnsToDerivedStringPaths<RequestColumns>, DefaultValue = unknown>(pathInput: T, defaultValue?: DefaultValue): Signal<MaybeDefaultValue<ResolveDerivedValue<ItemTypeType, DerivedStringToRequestColumnPath<T>>, DefaultValue>>;
110
+ getDerivedSignal<const T extends RequestColumnsToDerivedArrayPaths<RequestColumns>, DefaultValue = unknown>(pathInput: T, defaultValue?: DefaultValue): Signal<MaybeDefaultValue<ResolveDerivedValue<ItemTypeType, T>, DefaultValue>>;
111
+ /**
112
+ * @description
113
+ * Returns the value of the columnPath, or undefined when the path couldn't be traversed
114
+ *
115
+ * @param columnPath Can either be an array of columnIds (['column', 'column2']) or a config column string ('column>column2')
116
+ */
117
+ getDerivedValue<const T extends RequestColumnsToDerivedStringPaths<RequestColumns>, DefaultValue = unknown>(columnPath: T, defaultValue?: DefaultValue): MaybeDefaultValue<ResolveDerivedValue<ItemTypeType, DerivedStringToRequestColumnPath<T>>, DefaultValue>;
118
+ getDerivedValue<const T extends RequestColumnsToDerivedArrayPaths<RequestColumns>, DefaultValue = unknown>(columnPath: T, defaultValue?: DefaultValue): MaybeDefaultValue<ResolveDerivedValue<ItemTypeType, T>, DefaultValue>;
119
+ /**
120
+ * @description
121
+ * Traverses the column path and returns the fields of the derived item, returns undefined if the item isn't found
122
+ *
123
+ * ---------------------
124
+ *
125
+ * @remark
126
+ * Assumes the derived item's values are already cached
127
+ */
128
+ getDerivedValues<const T extends readonly string[]>(columnPath: T): ResolveDerivedValues<ItemTypeType, T> | undefined;
129
+ /**
130
+ * @description
131
+ * Clears all the child CollectionResource attached to an itemResource
132
+ */
133
+ clearChildCollections(): void;
134
+ }
135
+ export {};
@@ -0,0 +1,26 @@
1
+ import { ApiItemType } from '@rentman/backend-types';
2
+ import { ApiRequestColumnArray, ChildCollectionResources, CollectionItemResourceChanges, CollectionResource, ItemEntry, OrderedCollectionResource, RootCollectionOptionsWithLimit } from '../internal';
3
+ export declare class LimitedCollectionResource<ItemTypeType extends ApiItemType, RequestColumns extends ApiRequestColumnArray<ItemTypeType>, Children extends ChildCollectionResources | undefined = undefined> extends OrderedCollectionResource<ItemTypeType, RequestColumns, Children> {
4
+ options: RootCollectionOptionsWithLimit<ItemTypeType>;
5
+ setLimit(newLimit: number): Promise<void>;
6
+ handleMatchedItemEntries(fittingItemEntries: Iterable<ItemEntry<ItemTypeType>>, nonFittingItemEntries: Set<ItemEntry<ItemTypeType>> | undefined, clearChildCollectionResources: boolean): Promise<CollectionItemResourceChanges<CollectionResource<ItemTypeType, RequestColumns, Children>>>;
7
+ /**
8
+ * @returns A *sorted* array of item entries representing `baseItemEntries` with `itemEntriesToBeAdded` and
9
+ * `itemEntriesToBeRemovedSet` applied.
10
+ */
11
+ private applyAddedRemovedItemEntries;
12
+ /**
13
+ * When adding items to or removing items from a collection having a `limit` property set, we want to express the
14
+ * limit in the items that will be added / removed, instead of basing it on items currently present in the
15
+ * collection. This way, when a changes listener is registered, we ensure that:
16
+ *
17
+ * - The changes listener is called only once;
18
+ * - The changes listener is called with item resources representing the final added / removed items.
19
+ */
20
+ private limitItemEntriesToBeAdded;
21
+ /**
22
+ * When were removing items from the collection, we want to add additional items as well, such that we still
23
+ * adhere to the limit. See: {@link limitItemEntriesToBeAdded}.
24
+ */
25
+ private increaseItemEntriesToBeAdded;
26
+ }
@@ -0,0 +1,19 @@
1
+ import { ApiItemType } from '@rentman/backend-types';
2
+ import { AddedRemovedItemResources, ApiRequestColumnArray, ChildCollectionResources, CollectionResource, ItemEntry, ItemResource, ParentIdMap, RootCollectionOptionsWithOrder } from '../internal';
3
+ type CompareFunction<ValueType> = (value1: ValueType, value2: ValueType) => number;
4
+ export declare class OrderedCollectionResource<ItemTypeType extends ApiItemType, RequestColumns extends ApiRequestColumnArray<ItemTypeType>, Children extends ChildCollectionResources | undefined = undefined> extends CollectionResource<ItemTypeType, RequestColumns, Children> {
5
+ options: RootCollectionOptionsWithOrder<ItemTypeType>;
6
+ initializeItems(initialItemEntries: ItemEntry<ItemTypeType>[], childCollectionResourceMap: ParentIdMap<Children>): void;
7
+ /**
8
+ * Note that `updateItemsProperty` is called whenever items are updated, so there's no reason to register a listener
9
+ * as well.
10
+ */
11
+ protected updateItemsProperty(itemEntriesToBeAdded: ItemEntry<ItemTypeType>[], itemEntriesToBeRemovedSet: Set<ItemEntry<ItemTypeType>>, clearChildCollectionResources: boolean): Promise<AddedRemovedItemResources<ItemResource<ItemTypeType, RequestColumns, Children>>>;
12
+ protected getSortCompareTuple(): {
13
+ compareFunction: CompareFunction<unknown>;
14
+ isDescending: boolean;
15
+ };
16
+ protected sortItemResources(): void;
17
+ protected sortItemEntries(itemEntries: ItemEntry<ItemTypeType>[]): ItemEntry<ItemTypeType>[];
18
+ }
19
+ export {};
@@ -0,0 +1,17 @@
1
+ import { ApiItemType, ItemId } from '@rentman/backend-types';
2
+ import { ApiResponseProcessor, ColumnSet, ColumnSetFactory, FieldMap, ItemEntryService, ResponseColumnItemTypeMap } from '../internal';
3
+ export declare class Template<ItemTypeType extends ApiItemType> {
4
+ readonly itemType: ItemTypeType;
5
+ readonly response: ApiResponseProcessor<ItemTypeType>;
6
+ private readonly columnSetFactory;
7
+ private readonly itemEntryService;
8
+ private readonly additionalResponseColumns;
9
+ /**
10
+ * Also contains the additional response columns.
11
+ */
12
+ private readonly responseColumns;
13
+ constructor(itemType: ItemTypeType, response: ApiResponseProcessor<ItemTypeType>, columnSetFactory: ColumnSetFactory, itemEntryService: ItemEntryService, additionalResponseColumns: ResponseColumnItemTypeMap);
14
+ getFields<FieldsItemType extends ApiItemType = ItemTypeType>(itemType?: FieldsItemType, itemId?: ItemId<FieldsItemType>): FieldMap<FieldsItemType>;
15
+ getMainColumnSet(): ColumnSet<ItemTypeType>;
16
+ getColumnSet<ColumnSetItemType extends ApiItemType>(itemType: ColumnSetItemType): ColumnSet<ColumnSetItemType>;
17
+ }
@@ -0,0 +1,31 @@
1
+ import moment from 'moment';
2
+ import { CollectionResource, RmCore } from '../internal';
3
+ export declare const HOLIDAY_ICON = "beach_access";
4
+ declare const holidayColumns: readonly ["id", "date", "name", "yearly"];
5
+ export type HolidayFields = {
6
+ uid: `hol-${number}` | `hol-${number}-${number}`;
7
+ name: string;
8
+ date: moment.Moment;
9
+ };
10
+ /**
11
+ * A service handling 'Holiday' items.
12
+ *
13
+ * Note that methods querying the holiday items have a `rmCoreInstance` parameter. This is to accommodate the app, where
14
+ * multiple users can be logged in simultaneously, each having a separate core instance. The `rmCoreInstance` parameter
15
+ * is optional; when absent the first instance will be picked.
16
+ *
17
+ * Warning: for each core instance, the service should be initialized before querying the holiday items. It will throw
18
+ * an exception otherwise.
19
+ */
20
+ export declare class RmHolidaysService {
21
+ private holidayCollectionResourcesMap;
22
+ rangeContainsHoliday$(start: moment.Moment, end: moment.Moment, rmCoreInstance?: RmCore): boolean;
23
+ getHolidaysInDateRange$(start: moment.Moment, end: moment.Moment, rmCoreInstance?: RmCore): HolidayFields[];
24
+ rangeContainsHoliday(start: moment.Moment, end: moment.Moment, rmCoreInstance?: RmCore): boolean;
25
+ getHolidaysInDateRange(start: moment.Moment, end: moment.Moment, rmCoreInstance?: RmCore): HolidayFields[];
26
+ initialize(rmCoreInstance: RmCore): Promise<void>;
27
+ clear(rmCoreInstance: RmCore): boolean;
28
+ getHolidaysInDateRangeIterator$(start: moment.Moment, end: moment.Moment, rmCoreInstance?: RmCore): Generator<HolidayFields>;
29
+ getHolidaysCollection(rmCoreInstance?: RmCore): CollectionResource<'Holiday', typeof holidayColumns>;
30
+ }
31
+ export {};
@@ -0,0 +1,99 @@
1
+ import { AddedRemovedItemResources, ChangesListenerContextItemResourceShape, CollectionItemChangesListenerContext, CollectionToItemResource, ItemChangesListenerContext } from '../internal';
2
+ /**
3
+ * We're using the array index as the current value here.
4
+ */
5
+ export type PreviousNumber = [never, 0, 1, 2, 3];
6
+ /**
7
+ * `CollectionChildrenShape`, `ItemResourceShape` and `CollectionResourceShape` describe the `children` property of item
8
+ * resources, item resources themselves, and collection resources respectively, using only the properties required
9
+ * to infer the aggregated changes listener context.
10
+ */
11
+ type CollectionChildrenShape = {
12
+ [itemType: string]: CollectionResourceShape;
13
+ };
14
+ type ItemResourceShape = {
15
+ itemType: string;
16
+ children: CollectionChildrenShape | undefined;
17
+ };
18
+ type CollectionResourceShape = {
19
+ itemType: string;
20
+ items: ItemResourceShape[];
21
+ };
22
+ /**
23
+ * Changes listener context for a single collection resource. Includes added, removed, and changed items.
24
+ *
25
+ * Related to the {@link CollectionItemResourceChanges}, but stores {@link CollectionItemChangesListenerContext}
26
+ * instances instead of item resources for changed items.
27
+ */
28
+ export interface CollectionChangesListenerContext<CollectionResourceType extends {
29
+ items: any[];
30
+ }> extends AddedRemovedItemResources<CollectionToItemResource<CollectionResourceType>> {
31
+ changedItems: CollectionItemChangesListenerContext<CollectionResourceType>[];
32
+ collectionResource: CollectionResourceType;
33
+ }
34
+ /**
35
+ * Describes aggregated changes for collections. Does not include children.
36
+ */
37
+ type CollectionAggregatedChanges<CollectionResourceType extends CollectionResourceShape> = {
38
+ [itemType in CollectionResourceType['itemType']]?: CollectionChangesListenerContext<CollectionResourceType>[];
39
+ };
40
+ type CollectionChildrenAggregatedChanges<CollectionChildren extends CollectionChildrenShape> = {
41
+ [childItemType in keyof CollectionChildren]?: CollectionChangesListenerContext<CollectionChildren[childItemType]>[];
42
+ };
43
+ type InferCollectionChildren<CollectionResourceType extends CollectionResourceShape> = CollectionResourceType['items'][number]['children'];
44
+ type UnionToIntersection<Union> = (Union extends any ? (x: Union) => void : never) extends ((x: infer Intersection) => void) ? Intersection : never;
45
+ /**
46
+ * Describes aggregated changes for a specific collection, and recursively includes child collections. We want to use
47
+ * this type independently of the `AggregatedChangesListener` type. It does not need to handle unions in that case.
48
+ *
49
+ * Because `CollectionResourceToAggregatedChanges` is defined as a conditional type it automatically distributes over a
50
+ * union type parameter value.
51
+ */
52
+ type CollectionResourceToAggregatedChanges<CollectionResourceType extends CollectionResourceShape> = InferCollectionChildren<CollectionResourceType> extends CollectionChildrenShape ? CollectionAggregatedChanges<CollectionResourceType> & CollectionDescendantsToAggregatedChanges<InferCollectionChildren<CollectionResourceType>> : CollectionAggregatedChanges<CollectionResourceType>;
53
+ /**
54
+ * Note that `CollectionResourceToAggregatedChanges` and `CollectionDescendantsToAggregatedChanges` are defined in such
55
+ * a way that they always produce a type that adheres to `CollectionResourceAggregatedChanges` or
56
+ * `CollectionChildrenAggregatedChanges`, respectively. This increases the readability of type hints.
57
+ *
58
+ * Because `CollectionDescendantsToAggregatedChanges` is defined as a conditional type it automatically distributes over a
59
+ * union type parameter value.
60
+ */
61
+ export type CollectionDescendantsToAggregatedChanges<CollectionChildrenType extends CollectionChildrenShape, MaxDepth extends PreviousNumber[number] = 3> = [PreviousNumber[MaxDepth]] extends [never] ? CollectionChildrenAggregatedChanges<CollectionChildrenType> : CollectionChildrenAggregatedChanges<CollectionChildrenType> & UnionToIntersection<{
62
+ [childItemType in keyof CollectionChildrenType]: InferCollectionChildren<CollectionChildrenType[childItemType]> extends CollectionChildrenShape ? CollectionDescendantsToAggregatedChanges<InferCollectionChildren<CollectionChildrenType[childItemType]>, PreviousNumber[MaxDepth]> : never;
63
+ }[keyof CollectionChildrenType]>;
64
+ /**
65
+ * Because `ItemResourceToAggregatedChanges` is defined as a conditional type it automatically distributes over a
66
+ * union type parameter value.
67
+ */
68
+ export type ItemResourceToAggregatedChanges<ItemResourceType extends ItemResourceShape> = ItemResourceType extends ChangesListenerContextItemResourceShape ? {
69
+ [itemType in ItemResourceType['itemType']]?: ItemChangesListenerContext<ItemResourceType>[];
70
+ } : never;
71
+ /**
72
+ * We can use this type to loosely describe an aggregated changes listener function by leaving the parameters untyped.
73
+ */
74
+ export type AggregatedChangesListenerFunction<AggregatedCollectionChanges, AggregatedItemChanges> = (aggregatedCollectionChanges: AggregatedCollectionChanges, aggregatedItemChanges: AggregatedItemChanges, isCalledAfterSocketUpdate: boolean) => void;
75
+ /**
76
+ * A convenience type that produces an aggregated changes listener for a single item resource.
77
+ */
78
+ export type ItemAggregatedChangesListener<ItemResourceType extends ItemResourceShape> = AggregatedChangesListenerFunction<ItemResourceType extends {
79
+ children: CollectionChildrenShape;
80
+ } ? CollectionDescendantsToAggregatedChanges<ItemResourceType['children']> : any, ItemResourceToAggregatedChanges<ItemResourceType>>;
81
+ /**
82
+ * The aggregated changes listener function. Use this type when defining an aggregated changes listener.
83
+ *
84
+ * This type should not be used in the core itself. We can use the {@link AggregatedChangesListenerFunction} type instead.
85
+ */
86
+ export type AggregatedChangesListener<CollectionResourceUnion extends CollectionResourceShape | undefined, ItemResourceUnion extends ItemResourceShape | undefined> = AggregatedChangesListenerFunction<UnionToIntersection<(CollectionResourceUnion extends CollectionResourceShape ? CollectionResourceToAggregatedChanges<CollectionResourceUnion> : never) | (ItemResourceUnion extends {
87
+ children: CollectionChildrenShape;
88
+ } ? CollectionDescendantsToAggregatedChanges<ItemResourceUnion['children']> : never)>, UnionToIntersection<ItemResourceUnion extends ItemResourceShape ? ItemResourceToAggregatedChanges<ItemResourceUnion> : never>>;
89
+ /**
90
+ * For each map entry, the listener should match the aggregated changes, but this is not possible to type when using a
91
+ * `Map`.
92
+ *
93
+ * Note that we're using the non-recursive `CollectionAggregatedChanges` type here.
94
+ */
95
+ export type AggregatedChangesByListener = Map<AggregatedChangesListenerFunction<any, any>, {
96
+ collection: CollectionAggregatedChanges<any>;
97
+ item: ItemResourceToAggregatedChanges<any>;
98
+ }>;
99
+ export {};
@@ -0,0 +1,95 @@
1
+ import { ApiEnumApiType, ApiFields, ApiItemType, ApiQueryConditionBaseSimple, ApiQueryConditionComparatorBaseNull, ApiQueryConditionCustom, ApiQueryConditionExtendedSubQueryBase, ApiQueryConditionInBase, ApiQueryConditionLinkedToBase, ApiQueryConditionSearch, ApiQueryConditionShortBase, ApiQueryConditionSubQueryBase, ApiQueryEmpty, ApiQueryWithConditionsBase, EnumApiField, ExtendedSubQuerySubColumnId, ItemApiFields, ValueComparatorTuple, ValueEqualToComparatorTuple } from '@rentman/backend-types';
2
+ import moment from 'moment';
3
+ import { ApiEnumApiTypeToTsTypeMap, ItemTypeColumnId } from './ItemTypesCollection';
4
+ interface ApiField {
5
+ type: keyof ApiEnumApiTypeToTsTypeMap;
6
+ }
7
+ interface DateDurationApiField {
8
+ type: ApiEnumApiType.TYPE_DATETIME | ApiEnumApiType.TYPE_DATE | ApiEnumApiType.TYPE_DURATION | ApiEnumApiType.TYPE_TIMESTAMP | ApiEnumApiType.TYPE_TIMESTAMP_MS;
9
+ }
10
+ interface QueryableApiField extends ApiField {
11
+ type: keyof ApiEnumApiTypeToTsTypeMap;
12
+ queryable: true;
13
+ }
14
+ type ApiFieldToNullType<ApiFieldType extends QueryableApiField> = ApiFieldType extends {
15
+ nullable: false;
16
+ } | DateDurationApiField ? never : null;
17
+ type ApiFieldToValueComparatorTuple<ApiFieldType extends QueryableApiField> = ApiFieldType extends EnumApiField ? ValueEqualToComparatorTuple<keyof ApiFieldType['enum']> : ApiFieldType['type'] extends ApiEnumApiType.TYPE_DATETIME | ApiEnumApiType.TYPE_DATE | ApiEnumApiType.TYPE_TIMESTAMP | ApiEnumApiType.TYPE_TIMESTAMP_MS ? ValueComparatorTuple<moment.Moment | 'NOW'> : ApiFieldType['type'] extends ApiEnumApiType.TYPE_DURATION ? ValueComparatorTuple<moment.Duration> : ApiEnumApiTypeToTsTypeMap[ApiFieldType['type']] extends number ? ValueComparatorTuple<number> : ValueEqualToComparatorTuple<ApiEnumApiTypeToTsTypeMap[ApiFieldType['type']]>;
18
+ /**
19
+ * Note that the types using `ApiQueryConditionComparator`, `ApiQueryConditionIn` and `ApiQueryConditionComparatorShort`
20
+ * are only used for typing individual conditions, and are not part of the final `ApiQuery` type, where they are replaced by
21
+ * `ApiQueryConditionSimple`.
22
+ */
23
+ type ApiFieldToValueType<ApiFieldType extends QueryableApiField> = ApiFieldToValueComparatorTuple<ApiFieldType>['value'] | ApiFieldToNullType<ApiFieldType>;
24
+ export type ApiQueryConditionComparator<ItemTypeType extends ApiItemType, ColumnIdType extends ItemTypeColumnId<ItemTypeType>> = ApiFields[ItemTypeType][ColumnIdType] extends QueryableApiField ? ApiQueryConditionComparatorBaseNull<ColumnIdType, ApiFieldToValueComparatorTuple<ApiFields[ItemTypeType][ColumnIdType]>, ApiFieldToNullType<ApiFields[ItemTypeType][ColumnIdType]>> : never;
25
+ export type ApiQueryConditionIn<ItemTypeType extends ApiItemType, ColumnIdType extends ItemTypeColumnId<ItemTypeType>> = ApiFields[ItemTypeType][ColumnIdType] extends QueryableApiField ? ApiQueryConditionInBase<ColumnIdType, ApiFieldToValueType<ApiFields[ItemTypeType][ColumnIdType]>> : never;
26
+ export type ApiQueryConditionComparatorShort<ItemTypeType extends ApiItemType, ColumnIdType extends ItemTypeColumnId<ItemTypeType>> = ApiFields[ItemTypeType][ColumnIdType] extends QueryableApiField ? ApiQueryConditionShortBase<ColumnIdType, ApiFieldToValueType<ApiFields[ItemTypeType][ColumnIdType]>> : never;
27
+ export interface ApiQueryWithConditions<ItemTypeType extends ApiItemType> extends ApiQueryWithConditionsBase {
28
+ conditions: ApiQuery<ItemTypeType>[];
29
+ }
30
+ export interface ApiQueryConditionLinkedTo<ItemTypeType extends ApiItemType> extends ApiQueryConditionLinkedToBase<ItemTypeType> {
31
+ query?: ApiQuery<ItemTypeType>;
32
+ }
33
+ export interface ApiQueryConditionSubQuery<ItemTypeType extends ApiItemType, ColumnIdType extends keyof ItemApiFields<ItemTypeType>> extends ApiQueryConditionSubQueryBase<ColumnIdType> {
34
+ query: ApiQuery<ItemApiFields<ItemTypeType>[ColumnIdType]['itemType']>;
35
+ }
36
+ export interface ApiQueryConditionExtendedSubQuery<MainItemType extends ApiItemType, ColumnIdType extends keyof ItemApiFields<MainItemType> | 'id', SubItemType extends ApiItemType, SubColumnIdType extends ExtendedSubQuerySubColumnId<MainItemType, ColumnIdType, SubItemType> = ExtendedSubQuerySubColumnId<MainItemType, ColumnIdType, SubItemType>> extends ApiQueryConditionExtendedSubQueryBase<ColumnIdType, SubItemType, SubColumnIdType> {
37
+ query: ApiQuery<SubItemType>;
38
+ }
39
+ type ApiQueryConditionSubQueryUnion<ItemTypeType extends ApiItemType> = {
40
+ [ColumnId in keyof ItemApiFields<ItemTypeType>]: ApiQueryConditionSubQuery<ItemTypeType, ColumnId> | ApiQueryConditionExtendedSubQuery<ItemTypeType, ColumnId, ApiItemType, any>;
41
+ }[keyof ItemApiFields<ItemTypeType>];
42
+ type ApiFieldToQueryConditionSimple<ColumnId extends string | number | symbol, ApiFieldType> = ApiFieldType extends QueryableApiField ? ApiQueryConditionBaseSimple<ColumnId, ApiFieldToValueComparatorTuple<ApiFieldType>, ApiFieldToNullType<ApiFieldType>> : never;
43
+ type ApiQueryConditionSimple<ItemTypeType extends ApiItemType> = {
44
+ [ColumnId in keyof ApiFields[ItemTypeType]]: ApiFieldToQueryConditionSimple<ColumnId, ApiFields[ItemTypeType][ColumnId]>;
45
+ }[keyof ApiFields[ItemTypeType]];
46
+ /**
47
+ * Please note that this type has a few quirks:
48
+ * - `linkedTo` subqueries are only accepted when they apply to all item types. When doing an item-specific subquery,
49
+ * cast like so:
50
+ * ```
51
+ * {
52
+ * linkedTo: 'MateriaalCat',
53
+ * query: {
54
+ * extragescand: true,
55
+ * },
56
+ * } as ApiQueryConditionLinkedTo<'MateriaalCat'> as ApiQuery<'Planningmateriaal'>
57
+ * ```
58
+ * (This could be resolved by moving the link tree to the back-end types.)
59
+ * - Extended subqueries (using the `itemtype` and `field` properties to refer to the subcolumn) should also be
60
+ * cast.
61
+ * ```
62
+ * {
63
+ * key: 'functie',
64
+ * itemType: 'Functieuur',
65
+ * field: 'functie',
66
+ * query: {
67
+ * ...
68
+ * },
69
+ * } as ApiQueryConditionExtendedSubQuery<'Planningpersoneel', 'functie', 'Functieuur'>
70
+ * as ApiQuery<'Planningpersoneel'>;
71
+ * ```
72
+ * - The errors generated by TypeScript for invalid queries can be unhelpful. The query type it picks might
73
+ * not be the most obvious. In these cases you can manually narrow down the type. The `ApiQueryConditionComparator`,
74
+ * `ApiQueryConditionComparatorShort`, and `ApiQueryConditionIn` types have been introduced for this purpose.
75
+ * ```
76
+ * // Type '"sets"' is not comparable to type '"set" | "case" | "item"'.
77
+ * {
78
+ * key: 'type',
79
+ * value: 'sets',
80
+ * comparator: '=',
81
+ * } as ApiQueryConditionComparator<'Materiaal', 'type'>
82
+ * ```
83
+ *
84
+ * This type is mirrored by the `BackendApiQuery` type, the main differences being in the values accepted for date and
85
+ * duration comparisons:
86
+ *
87
+ * - For date comparisons, the back-end query type will accept a string, or `null` for nullable columns.
88
+ * - The front-end type will accept a `moment` object only. For `null` values, use `moment.invalid()`. Additionally,
89
+ * the front-end type will accept the 'NOW' keyword. This will be replaced by the current time whenever matching locally
90
+ * or querying the back-end.
91
+ * - For durations, the back-end type will accept a number (or `null`), whereas the front-end type accepts a
92
+ * `moment.duration` object.
93
+ */
94
+ export type ApiQuery<ItemTypeType extends ApiItemType> = ApiQueryEmpty | ApiQueryConditionSearch | ApiQueryConditionCustom<ItemTypeType> | ApiQueryConditionSimple<ItemTypeType> | ApiQueryWithConditions<ItemTypeType> | ApiQueryConditionLinkedTo<ApiItemType> | ApiQueryConditionSubQueryUnion<ItemTypeType> | ApiQueryConditionExtendedSubQuery<ItemTypeType, 'id', ApiItemType, any>;
95
+ export {};