@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.
- package/dist/rm-core.js +2 -0
- package/dist/rm-core.js.map +1 -0
- package/dist/types/src/classes/ApiFormatter.d.ts +66 -0
- package/dist/types/src/classes/ApiRequestService.d.ts +18 -0
- package/dist/types/src/classes/ApiResponseProcessor.d.ts +31 -0
- package/dist/types/src/classes/BusinessLogicManager/AantalBusinessLogicRuleBase.d.ts +36 -0
- package/dist/types/src/classes/BusinessLogicManager/AantaltotaalBusinessLogicRuleBase.d.ts +60 -0
- package/dist/types/src/classes/BusinessLogicManager/Afspraak/AfspraakRecureindBusinessLogicRule.d.ts +5 -0
- package/dist/types/src/classes/BusinessLogicManager/Beschikbaarheid/BeschikbaarheidRecureindBusinessLogicRule.d.ts +5 -0
- package/dist/types/src/classes/BusinessLogicManager/BusinessLogicManager.d.ts +66 -0
- package/dist/types/src/classes/BusinessLogicManager/BusinessLogicRule.d.ts +81 -0
- package/dist/types/src/classes/BusinessLogicManager/BusinessLogicRuleApplyContext.d.ts +32 -0
- package/dist/types/src/classes/BusinessLogicManager/BusinessLogicRuleConditionContext.d.ts +41 -0
- package/dist/types/src/classes/BusinessLogicManager/BusinessLogicRuleContextBase.d.ts +58 -0
- package/dist/types/src/classes/BusinessLogicManager/Contact/ContactAddressBusinessLogicRule.d.ts +22 -0
- package/dist/types/src/classes/BusinessLogicManager/Customfield/CustomFieldLinkedItemTypeBusinessLogicRule.d.ts +18 -0
- package/dist/types/src/classes/BusinessLogicManager/Customfield/CustomFieldTypeBusinessLogicRule.d.ts +18 -0
- package/dist/types/src/classes/BusinessLogicManager/DefaultContactPersonUpdateBusinessLogicRule.d.ts +30 -0
- package/dist/types/src/classes/BusinessLogicManager/Documents/DocumentTemplateBusinessLogicRule.d.ts +20 -0
- package/dist/types/src/classes/BusinessLogicManager/Exemplaar/ExemplaarAanschafdatumBusinessLogicRule.d.ts +14 -0
- package/dist/types/src/classes/BusinessLogicManager/Exemplaar/ExemplaarBarcodeDeleteBusinessLogicRule.d.ts +14 -0
- package/dist/types/src/classes/BusinessLogicManager/Factuur/FactuurBetalingsconditieBusinessLogicRule.d.ts +21 -0
- package/dist/types/src/classes/BusinessLogicManager/Factuur/FactuurDatumBusinessLogicRule.d.ts +23 -0
- package/dist/types/src/classes/BusinessLogicManager/Factuur/FactuurNumberseriesBusinessLogicRule.d.ts +14 -0
- package/dist/types/src/classes/BusinessLogicManager/Files/FilesNameExtensionBusinessLogicRule.d.ts +20 -0
- package/dist/types/src/classes/BusinessLogicManager/Functie/FunctieNaaminternBusinessLogicRule.d.ts +18 -0
- package/dist/types/src/classes/BusinessLogicManager/Functie/FunctieRecureindBusinessLogicRule.d.ts +5 -0
- package/dist/types/src/classes/BusinessLogicManager/Functie/FunctieTwowayBusinessLogicRule.d.ts +14 -0
- package/dist/types/src/classes/BusinessLogicManager/Functiegroep/FunctiegroepSubprojectBusinessLogicRule.d.ts +17 -0
- package/dist/types/src/classes/BusinessLogicManager/Inhuurmateriaal/InhuurmateriaalAantalBusinessLogicRule.d.ts +4 -0
- package/dist/types/src/classes/BusinessLogicManager/Inhuurmateriaal/InhuurmateriaalAantaltotaalBusinessLogicRule.d.ts +9 -0
- package/dist/types/src/classes/BusinessLogicManager/Materiaal/MateriaalBulkToSerialBusinessLogicRule.d.ts +17 -0
- package/dist/types/src/classes/BusinessLogicManager/Materiaal/MateriaalIsCombinationBusinessLogicRule.d.ts +20 -0
- package/dist/types/src/classes/BusinessLogicManager/Materiaal/MateriaalIsPhysicalCombinationBulkBusinessLogicRule.d.ts +19 -0
- package/dist/types/src/classes/BusinessLogicManager/Materiaal/MateriaalSerialToBulkBusinessLogicRule.d.ts +16 -0
- package/dist/types/src/classes/BusinessLogicManager/Materiaal/MateriaalToPhysicalBusinessLogicRule.d.ts +18 -0
- package/dist/types/src/classes/BusinessLogicManager/Materiaal/MateriaalToVirtualBusinessLogicRule.d.ts +22 -0
- package/dist/types/src/classes/BusinessLogicManager/Materiaal/MateriaalTypePropertiesBusinessLogicRule.d.ts +19 -0
- package/dist/types/src/classes/BusinessLogicManager/Materiaal/MateriaalVerhuurBusinessLogicRule.d.ts +19 -0
- package/dist/types/src/classes/BusinessLogicManager/Materiaal/SurfaceArticleSizeBusinessLogicRule.d.ts +23 -0
- package/dist/types/src/classes/BusinessLogicManager/MateriaalCatFunctieFunctiegroep/LinkedTimeItemBusinessLogicRuleBase.d.ts +46 -0
- package/dist/types/src/classes/BusinessLogicManager/MateriaalCatFunctieFunctiegroep/LinkedTimeItemDurationBusinessLogicRule.d.ts +17 -0
- package/dist/types/src/classes/BusinessLogicManager/MateriaalCatFunctieFunctiegroep/LinkedTimeItemMateriaalCatBusinessLogicRule.d.ts +25 -0
- package/dist/types/src/classes/BusinessLogicManager/MateriaalCatFunctieFunctiegroep/LinkedTimeItemSubprojectBusinessLogicRule.d.ts +48 -0
- package/dist/types/src/classes/BusinessLogicManager/MateriaalCatFunctieFunctiegroep/LinkedTimeItemTimeSchemeBusinessLogicRule.d.ts +27 -0
- package/dist/types/src/classes/BusinessLogicManager/MateriaalCatFunctieFunctiegroep/LinkedTimeItemTimeSchemeStartBusinessLogicRule.d.ts +18 -0
- package/dist/types/src/classes/BusinessLogicManager/MateriaalCatFunctieFunctiegroep/LinkedTimeItemTimeValueStartBusinessLogicRule.d.ts +20 -0
- package/dist/types/src/classes/BusinessLogicManager/MateriaalCatFunctieFunctiegroep/TimeColumnUtil.d.ts +132 -0
- package/dist/types/src/classes/BusinessLogicManager/OfferteContract/OfferteContractDatumBusinessLogicRule.d.ts +21 -0
- package/dist/types/src/classes/BusinessLogicManager/PlanningPersoneelTransport/PlanningPersoneelTransportBusinessLogicRule.d.ts +24 -0
- package/dist/types/src/classes/BusinessLogicManager/Planningmateriaal/PlanningmateriaalAantalBusinessLogicRule.d.ts +4 -0
- package/dist/types/src/classes/BusinessLogicManager/Planningmateriaal/PlanningmateriaalAantaltotaalBusinessLogicRule.d.ts +9 -0
- package/dist/types/src/classes/BusinessLogicManager/Planningmateriaal/PlanningmateriaalOptieBusinessLogicRule.d.ts +26 -0
- package/dist/types/src/classes/BusinessLogicManager/Planningmateriaal/PlanningmateriaalParentBusinessLogicRule.d.ts +17 -0
- package/dist/types/src/classes/BusinessLogicManager/Planningmateriaal/PlanningmateriaalStaysAtLocationBusinessLogicRule.d.ts +32 -0
- package/dist/types/src/classes/BusinessLogicManager/Project/ProjectClientChangedBusinessLogicRule.d.ts +31 -0
- package/dist/types/src/classes/BusinessLogicManager/Project/ProjectContactProjectNoteBusinessLogicRule.d.ts +25 -0
- package/dist/types/src/classes/BusinessLogicManager/Project/ProjectOneSubLocationAlignBusinessRule.d.ts +26 -0
- package/dist/types/src/classes/BusinessLogicManager/ProjectSubproject/ProjectSubprojectDefaultTimeBusinessLogicRule.d.ts +26 -0
- package/dist/types/src/classes/BusinessLogicManager/PurchaseOrder/PurchaseOrderApprovalStatusBusinessLogicRule.d.ts +19 -0
- package/dist/types/src/classes/BusinessLogicManager/PurchaseOrder/PurchaseOrderOwnerBusinessLogicRule.d.ts +16 -0
- package/dist/types/src/classes/BusinessLogicManager/Rate/RateUpdatedBusinessLogicRule.d.ts +14 -0
- package/dist/types/src/classes/BusinessLogicManager/RecurrentItem/RecurrentItemRecureindBusinessLogicRule.d.ts +28 -0
- package/dist/types/src/classes/BusinessLogicManager/Reparatie/ReparatieExemplaarAantalBusinessLogicRule.d.ts +14 -0
- package/dist/types/src/classes/BusinessLogicManager/Reparatie/ReparatieLostItemExemplaarLocationBusinessLogicRule.d.ts +21 -0
- package/dist/types/src/classes/BusinessLogicManager/Rol/RolEditOwnDataBusinessLogicRule.d.ts +20 -0
- package/dist/types/src/classes/BusinessLogicManager/Rol/RolFileAccessBusinessLogicRule.d.ts +19 -0
- package/dist/types/src/classes/BusinessLogicManager/Rol/RolPersoneelsplannerToegangBusinessLogicRule.d.ts +20 -0
- package/dist/types/src/classes/BusinessLogicManager/Rol/RolProjectenBewerkenBusinessLogicRule.d.ts +20 -0
- package/dist/types/src/classes/BusinessLogicManager/Rol/RolProjectenToegangBusinessLogicRule.d.ts +21 -0
- package/dist/types/src/classes/BusinessLogicManager/Rol/RolPurchaseOrderAttachPlanningBusinessLogicRule.d.ts +19 -0
- package/dist/types/src/classes/BusinessLogicManager/Rol/RolVisibilityFinancialsBusinessLogicRule.d.ts +35 -0
- package/dist/types/src/classes/BusinessLogicManager/Rol/RolWarehosueTrackingLogAccessBusinessLogicRule.d.ts +20 -0
- package/dist/types/src/classes/BusinessLogicManager/Setinhoud/SetinhoudCreateFixedBusinessLogicRule.d.ts +21 -0
- package/dist/types/src/classes/BusinessLogicManager/Setinhoud/SetinhoudUpdateFixedBusinessLogicRule.d.ts +26 -0
- package/dist/types/src/classes/BusinessLogicManager/Subproject/SubprojectInPlanningBusinessLogicRule.d.ts +14 -0
- package/dist/types/src/classes/BusinessLogicManager/Subproject/SubprojectOneSubLocationAlignBusinessRule.d.ts +27 -0
- package/dist/types/src/classes/BusinessLogicManager/Subproject/SubprojectOneSubNameAlignBusinessRule.d.ts +22 -0
- package/dist/types/src/classes/BusinessLogicManager/Tijd/TijdNameChangedBusinessLogicRule.d.ts +21 -0
- package/dist/types/src/classes/BusinessLogicManager/Tijd/TijdSubprojectChangedBusinessLogicRule.d.ts +17 -0
- package/dist/types/src/classes/BusinessLogicManager/Uren/HoursTypeBusinessLogicRuleBase.d.ts +10 -0
- package/dist/types/src/classes/BusinessLogicManager/Uren/UrenCalculatedDurationBusinessLogicRule.d.ts +13 -0
- package/dist/types/src/classes/BusinessLogicManager/Uren/UrenCanHaveActivitiesBusinessLogicRule.d.ts +13 -0
- package/dist/types/src/classes/BusinessLogicManager/businessLogicRule.decorator.d.ts +13 -0
- package/dist/types/src/classes/BusinessLogicManager/registeredBusinessLogicRules.d.ts +66 -0
- package/dist/types/src/classes/ChangesCompilation.d.ts +26 -0
- package/dist/types/src/classes/ChangesDelta.d.ts +81 -0
- package/dist/types/src/classes/ChangesDeltaBase.d.ts +85 -0
- package/dist/types/src/classes/ChangesProcessor.d.ts +35 -0
- package/dist/types/src/classes/ChildChangesDelta.d.ts +38 -0
- package/dist/types/src/classes/ColumnCache.d.ts +22 -0
- package/dist/types/src/classes/ColumnExpansion.d.ts +18 -0
- package/dist/types/src/classes/ColumnHandler.d.ts +16 -0
- package/dist/types/src/classes/ColumnInfo.d.ts +16 -0
- package/dist/types/src/classes/ColumnSet.d.ts +79 -0
- package/dist/types/src/classes/ColumnUtil.d.ts +97 -0
- package/dist/types/src/classes/ConversionMapService.d.ts +23 -0
- package/dist/types/src/classes/CreateRequest.d.ts +16 -0
- package/dist/types/src/classes/CreatedChangesDelta.d.ts +22 -0
- package/dist/types/src/classes/ItemCache.d.ts +26 -0
- package/dist/types/src/classes/ItemCreateService.d.ts +14 -0
- package/dist/types/src/classes/ItemEntryService.d.ts +29 -0
- package/dist/types/src/classes/KeyService.d.ts +10 -0
- package/dist/types/src/classes/LockService.d.ts +28 -0
- package/dist/types/src/classes/ModuleChangesCompilation.d.ts +20 -0
- package/dist/types/src/classes/ParentChangesDelta.d.ts +42 -0
- package/dist/types/src/classes/QueryColumnExtractor.d.ts +16 -0
- package/dist/types/src/classes/QueryContainsLocalIdParser.d.ts +14 -0
- package/dist/types/src/classes/QueryParser.d.ts +18 -0
- package/dist/types/src/classes/QueryParserBase.d.ts +32 -0
- package/dist/types/src/classes/QueryParserIdUpdater.d.ts +16 -0
- package/dist/types/src/classes/QueryService.d.ts +10 -0
- package/dist/types/src/classes/RequestBuffer/RequestBuffer.d.ts +13 -0
- package/dist/types/src/classes/RequestBuffer/RequestBufferBase.d.ts +37 -0
- package/dist/types/src/classes/RequestBuffer/RequestBufferManager.d.ts +24 -0
- package/dist/types/src/classes/RequestBuffer/SingleQueryRequestBuffer.d.ts +18 -0
- package/dist/types/src/classes/RequestColumnExpansion.d.ts +11 -0
- package/dist/types/src/classes/RequestColumnsOperationsCache.d.ts +45 -0
- package/dist/types/src/classes/SocketMessageHandler.d.ts +28 -0
- package/dist/types/src/classes/TemplateCache.d.ts +61 -0
- package/dist/types/src/classes/Util.d.ts +36 -0
- package/dist/types/src/classes/cache/AbstractCache.d.ts +86 -0
- package/dist/types/src/classes/cache/CachedQueryHandlerBase.d.ts +145 -0
- package/dist/types/src/classes/cache/ItemHandlerBase.d.ts +97 -0
- package/dist/types/src/classes/cache/ItemMatcherBase.d.ts +90 -0
- package/dist/types/src/classes/cache/server/ServerCache.d.ts +83 -0
- package/dist/types/src/classes/cache/server/ServerCachedQueryHandler.d.ts +29 -0
- package/dist/types/src/classes/cache/server/ServerItemHandler.d.ts +35 -0
- package/dist/types/src/classes/cache/transaction/TransactionCache.d.ts +342 -0
- package/dist/types/src/classes/cache/transaction/TransactionCachedQueryHandler.d.ts +111 -0
- package/dist/types/src/classes/cache/transaction/TransactionEventHandler.d.ts +17 -0
- package/dist/types/src/classes/cache/transaction/TransactionItemHandler.d.ts +121 -0
- package/dist/types/src/classes/cache/transaction/TransactionValidator.d.ts +25 -0
- package/dist/types/src/classes/cache/transaction/TransactionValidatorBase.d.ts +19 -0
- package/dist/types/src/classes/cache/transaction/TransactionValidatorWithDependencies.d.ts +15 -0
- package/dist/types/src/classes/changes/CollectionItemChangesListenerContext.d.ts +22 -0
- package/dist/types/src/classes/changes/ItemChangesListenerContext.d.ts +7 -0
- package/dist/types/src/classes/changes/ItemChangesListenerContextBase.d.ts +44 -0
- package/dist/types/src/classes/matcher/CompatorQueryNode.d.ts +24 -0
- package/dist/types/src/classes/matcher/CustomQueryNode.d.ts +8 -0
- package/dist/types/src/classes/matcher/GraphQueryParser.d.ts +34 -0
- package/dist/types/src/classes/matcher/IsComparatorQueryNode.d.ts +13 -0
- package/dist/types/src/classes/matcher/LinkedToQueryNode.d.ts +9 -0
- package/dist/types/src/classes/matcher/NonMatchableQueryNode.d.ts +9 -0
- package/dist/types/src/classes/matcher/NotIsComparatorQueryNode.d.ts +14 -0
- package/dist/types/src/classes/matcher/QueryNode.d.ts +49 -0
- package/dist/types/src/classes/matcher/RootQueryNode.d.ts +14 -0
- package/dist/types/src/classes/matcher/SearchQueryNode.d.ts +8 -0
- package/dist/types/src/classes/matcher/SubQueryNode.d.ts +8 -0
- package/dist/types/src/classes/matcher/ValueTransformers.d.ts +41 -0
- package/dist/types/src/classes/matcher/ValuelessEdgeQueryNode.d.ts +11 -0
- package/dist/types/src/classes/matcher/greater-smaller-than-comparator-query.node.d.ts +25 -0
- package/dist/types/src/constants.d.ts +2 -0
- package/dist/types/src/core.d.ts +63 -0
- package/dist/types/src/exceptions/CriticalBusinessLogicRuleException.d.ts +4 -0
- package/dist/types/src/exceptions/ItemAlreadyExistsException.d.ts +4 -0
- package/dist/types/src/exceptions/ItemLockedException.d.ts +2 -0
- package/dist/types/src/exceptions/ItemNotFoundException.d.ts +5 -0
- package/dist/types/src/exceptions/MissingColumnException.d.ts +6 -0
- package/dist/types/src/exceptions/SavingInProgressException.d.ts +2 -0
- package/dist/types/src/exceptions/TransactionPendingException.d.ts +2 -0
- package/dist/types/src/factories/ApiResponseProcessorFactory.d.ts +5 -0
- package/dist/types/src/factories/ChangesCompilationFactory.d.ts +5 -0
- package/dist/types/src/factories/ChangesDeltaFactory.d.ts +13 -0
- package/dist/types/src/factories/CollectionResourceFactory.d.ts +20 -0
- package/dist/types/src/factories/ColumnExpansionFactory.d.ts +7 -0
- package/dist/types/src/factories/ColumnInfoFactory.d.ts +7 -0
- package/dist/types/src/factories/ColumnSetFactory.d.ts +15 -0
- package/dist/types/src/factories/GraphQueryParserFactory.d.ts +10 -0
- package/dist/types/src/factories/ItemCacheFactory.d.ts +7 -0
- package/dist/types/src/factories/ItemResourceFactory.d.ts +7 -0
- package/dist/types/src/factories/ModuleChangesCompilationFactory.d.ts +6 -0
- package/dist/types/src/factories/RequestColumnExpansionFactory.d.ts +4 -0
- package/dist/types/src/factories/RequestColumnsOperationsCacheFactory.d.ts +7 -0
- package/dist/types/src/factories/TransactionCacheFactory.d.ts +12 -0
- package/dist/types/src/index.d.ts +11 -0
- package/dist/types/src/interfaces/AbstractCacheDependencyInterface.d.ts +46 -0
- package/dist/types/src/interfaces/ApiRequestServiceInterface.d.ts +14 -0
- package/dist/types/src/interfaces/ErrorHandlerInterface.d.ts +6 -0
- package/dist/types/src/interfaces/LinkTreeServiceInterface.d.ts +6 -0
- package/dist/types/src/interfaces/ServerCacheDependencyInterface.d.ts +6 -0
- package/dist/types/src/interfaces/SocketMessageInterface.d.ts +3 -0
- package/dist/types/src/interfaces/TransactionCollectionHandlerDependencyInterface.d.ts +15 -0
- package/dist/types/src/interfaces/TransactionItemHandlerDependencyInterface.d.ts +16 -0
- package/dist/types/src/internal.d.ts +110 -0
- package/dist/types/src/models/CachedQueryItem.d.ts +33 -0
- package/dist/types/src/models/CollectionEntry.d.ts +16 -0
- package/dist/types/src/models/CollectionOptions.d.ts +111 -0
- package/dist/types/src/models/CollectionResource.d.ts +175 -0
- package/dist/types/src/models/ItemEntry.d.ts +23 -0
- package/dist/types/src/models/ItemOptions.d.ts +25 -0
- package/dist/types/src/models/ItemResource.d.ts +135 -0
- package/dist/types/src/models/LimitedCollectionResource.d.ts +26 -0
- package/dist/types/src/models/OrderedCollectionResource.d.ts +19 -0
- package/dist/types/src/models/Template.d.ts +17 -0
- package/dist/types/src/services/rm-holidays.service.d.ts +31 -0
- package/dist/types/src/types/AggregatedChangesListener.d.ts +99 -0
- package/dist/types/src/types/ApiQuery.d.ts +95 -0
- package/dist/types/src/types/ItemTypesCollection.d.ts +416 -0
- package/package.json +56 -0
- package/readme.md +42 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ApiEnumApiType, ApiItemType } from '@rentman/backend-types';
|
|
2
|
+
import moment from 'moment';
|
|
3
|
+
import { ApiEnumApiTypeToTsTypeMap, FieldMap, ItemTypeColumnId, ItemTypeColumnIds, ResponseColumnMap } from '../types/ItemTypesCollection';
|
|
4
|
+
import { ColumnInfo } from './ColumnInfo';
|
|
5
|
+
/**
|
|
6
|
+
* @description
|
|
7
|
+
* A service which provides functions to transform data that comes from/goes to the API
|
|
8
|
+
*
|
|
9
|
+
* @warning
|
|
10
|
+
* The code in these functions can be *very hot* on large databases, therefore performance must be kept in mind.
|
|
11
|
+
* This is also the reason why all column types are written out instead of using the enum
|
|
12
|
+
*/
|
|
13
|
+
export declare abstract class ApiFormatter {
|
|
14
|
+
static readonly SERVER_DATETIME_FORMAT: string;
|
|
15
|
+
static readonly SERVER_DATE_FORMAT: string;
|
|
16
|
+
/**
|
|
17
|
+
* @description
|
|
18
|
+
* Returns if a column type is an 'expensive' type, meaning that the action to format the field takes significant CPU time
|
|
19
|
+
*
|
|
20
|
+
* ----
|
|
21
|
+
* @remarks
|
|
22
|
+
* Currently only used for Moment objects
|
|
23
|
+
*/
|
|
24
|
+
static isExpensiveFormat(columnType: ApiEnumApiType): boolean;
|
|
25
|
+
static formatRequestLocal<ItemTypeType extends ApiItemType>(fields: FieldMap<ItemTypeType>, columns: ColumnInfo<ItemTypeType>[]): {
|
|
26
|
+
[columnId: string]: any;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* TODO: Since we're never writing to fields directly, we could consider replacing `copyFields` by
|
|
30
|
+
* {@link shallowCopyFields}.
|
|
31
|
+
*/
|
|
32
|
+
static copyFields<ItemTypeType extends ApiItemType = any, ColumnIds extends ItemTypeColumnIds<ItemTypeType> = any>(source: Partial<FieldMap<ItemTypeType, ColumnIds>>, destination: Partial<FieldMap<ItemTypeType>>, columns: ColumnInfo<ItemTypeType, ColumnIds[number]>[]): FieldMap<ItemTypeType, ColumnIds>;
|
|
33
|
+
/**
|
|
34
|
+
* Iterates over source properties, doesn't clone complex objects. Overwrites properties already in `destination`.
|
|
35
|
+
*
|
|
36
|
+
* Note: we iterate over the keys of `source` here because this method is typically called when we want to make a
|
|
37
|
+
* copy of changed fields in a changes delta.
|
|
38
|
+
*/
|
|
39
|
+
static shallowCopyFields<ItemTypeType extends ApiItemType, ColumnIds extends ItemTypeColumnIds<ItemTypeType> = any>(source: Partial<FieldMap<ItemTypeType, ColumnIds>>, destination: Partial<FieldMap<ItemTypeType>>, responseColumns: ResponseColumnMap<ItemTypeType>, onMissingColumn?: (columnId: ItemTypeColumnId<ItemTypeType>) => void): Partial<FieldMap<ItemTypeType, ColumnIds>>;
|
|
40
|
+
static setDefaultValues<ItemTypeType extends ApiItemType = any>(destination: Partial<FieldMap<ItemTypeType>>, columns: ColumnInfo<ItemTypeType>[]): FieldMap<ItemTypeType>;
|
|
41
|
+
/**
|
|
42
|
+
* @description
|
|
43
|
+
* Compares the given fields, returns `true` when the fields are equal
|
|
44
|
+
*/
|
|
45
|
+
static compareFields<ColumnType extends ApiEnumApiType>(columnType: ColumnType, first?: ApiEnumApiTypeToTsTypeMap[ColumnType], second?: ApiEnumApiTypeToTsTypeMap[ColumnType]): boolean;
|
|
46
|
+
static compareFloats(a: number, b: number): boolean;
|
|
47
|
+
static compareMomentObjects(first: moment.Moment, second: moment.Moment): boolean;
|
|
48
|
+
static compareDurations(first: moment.Duration, second: moment.Duration): boolean;
|
|
49
|
+
static formatResponseValue(columnType: string, value: any): any;
|
|
50
|
+
static formatRequestValue(columnType: string, value: any): any;
|
|
51
|
+
static formatResponseDate(value: null | any): moment.Moment;
|
|
52
|
+
static formatResponseDuration(value: null | number): moment.Duration;
|
|
53
|
+
static formatResponseColor(value: string | null): string | null;
|
|
54
|
+
static formatRequestDateTime(value: moment.Moment): string | null;
|
|
55
|
+
static formatRequestDate(value: moment.Moment): string | null;
|
|
56
|
+
static formatRequestDuration(value: moment.Duration): number;
|
|
57
|
+
static formatRequestColor(value: string | null): string | null;
|
|
58
|
+
static getDefaultValue(columnType: ApiEnumApiType): any;
|
|
59
|
+
static hasValue(columnType: ApiEnumApiType, value: any): boolean;
|
|
60
|
+
static isDefaultValue(columnType: ApiEnumApiType, value: any): boolean;
|
|
61
|
+
static clone(columnType: string, value: any): any;
|
|
62
|
+
static getCloneFunction(columnType: string): typeof ApiFormatter.cloneDuration | typeof ApiFormatter.cloneDate;
|
|
63
|
+
static cloneDuration(duration: moment.Duration): moment.Duration;
|
|
64
|
+
static cloneDate(date: moment.Moment): moment.Moment;
|
|
65
|
+
static identity<T>(input: T): T;
|
|
66
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ApiItemType, BackendApiQuery, ItemId } from '@rentman/backend-types';
|
|
2
|
+
import { ApiRequestColumnMap, ApiRequestColumns, ApiRequestItemMap, ApiRequestLimit, ApiRequestServiceInterface, ApiResponseProcessor, ApiResponseProcessorFactory, FieldMap, RequestParameters } from '../internal';
|
|
3
|
+
export declare class ApiRequestService {
|
|
4
|
+
private externalApiRequestService;
|
|
5
|
+
private apiResponseProcessorFactory;
|
|
6
|
+
constructor(externalApiRequestService: ApiRequestServiceInterface, apiResponseProcessorFactory: ApiResponseProcessorFactory);
|
|
7
|
+
template<ItemTypeType extends ApiItemType = any>(itemType: ItemTypeType, params?: Partial<RequestParameters<ItemTypeType>>): Promise<ApiResponseProcessor>;
|
|
8
|
+
create<ItemTypeType extends ApiItemType>(itemType: ItemTypeType, itemId: ItemId, values: Partial<FieldMap<ItemTypeType>>, columns: ApiRequestColumnMap, parentType?: ApiItemType, parentId?: ItemId, uniqueTransactionId?: string): Promise<ApiResponseProcessor>;
|
|
9
|
+
delete<ItemTypeType extends ApiItemType>(itemType: ApiItemType, itemIds: ItemId[], uniqueTransactionId?: string): Promise<ApiResponseProcessor<ItemTypeType>>;
|
|
10
|
+
updateItems<ItemTypeType extends ApiItemType>(itemType: ItemTypeType, items: ApiRequestItemMap, columns: ApiRequestColumnMap, uniqueTransactionId?: string): Promise<ApiResponseProcessor<ItemTypeType>>;
|
|
11
|
+
requestSkeleton<ItemTypeType extends ApiItemType = ApiItemType>(params: any, requestCanceler?: Promise<any>): Promise<ApiResponseProcessor<ItemTypeType>>;
|
|
12
|
+
columns<ItemTypeType extends ApiItemType>(itemType: ItemTypeType, columns: {
|
|
13
|
+
[itemType: string]: ApiRequestColumns | true;
|
|
14
|
+
}, params?: any): Promise<ApiResponseProcessor<ItemTypeType>>;
|
|
15
|
+
query<ItemTypeType extends ApiItemType>(itemType: ItemTypeType, query: BackendApiQuery<ItemTypeType>, columns: ApiRequestColumnMap, limit?: ApiRequestLimit<ItemTypeType>): Promise<ApiResponseProcessor<ItemTypeType>>;
|
|
16
|
+
module<ResponseType = unknown>(module: string, method: string, params: Record<string, unknown>): Promise<ResponseType>;
|
|
17
|
+
processResponse<ItemTypeType extends ApiItemType = ApiItemType>(request: any): Promise<ApiResponseProcessor<ItemTypeType>>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ApiItemType, ItemId, ResponseColumn, UnknownResponseColumn } from '@rentman/backend-types';
|
|
2
|
+
import { ApiResponse, ColumnInfo, DerivedStringToRequestColumnPath, FieldMap, ItemTypeMap, ResolveDerivedValue, ResponseColumnItemTypeMap, ResponseColumnMap } from '../internal';
|
|
3
|
+
export declare class ApiResponseProcessor<RequestItemType extends ApiItemType = any> {
|
|
4
|
+
response: ApiResponse<RequestItemType>;
|
|
5
|
+
itemType: RequestItemType;
|
|
6
|
+
columns: ItemTypeMap<UnknownResponseColumn[]>;
|
|
7
|
+
links: ApiResponse<RequestItemType>['links'];
|
|
8
|
+
cacheable: boolean;
|
|
9
|
+
map: any;
|
|
10
|
+
items: ApiResponse<RequestItemType>['items'];
|
|
11
|
+
columnIndexMap: {
|
|
12
|
+
[itemType: string]: {
|
|
13
|
+
[columnId: string]: number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
columnMap: ResponseColumnItemTypeMap;
|
|
17
|
+
constructor(response: ApiResponse<RequestItemType>);
|
|
18
|
+
static addLazyFormattingFunction<Fields extends FieldMap<any>, ColumnId extends keyof Fields>(columnId: ColumnId, columnType: string, initialValue: any, destination: Fields): void;
|
|
19
|
+
fetchColumnObject(itemType: ApiItemType): ResponseColumnMap;
|
|
20
|
+
fetchDerivedValue<T extends string, DefaultValue = undefined>(initialItemId: ItemId, columnPath: T, defaultValue?: DefaultValue): ResolveDerivedValue<RequestItemType, DerivedStringToRequestColumnPath<T>>;
|
|
21
|
+
fetchDerivedValue<T extends readonly string[], DefaultValue = undefined>(initialItemId: ItemId, columnPath: T, defaultValue?: DefaultValue): ResolveDerivedValue<RequestItemType, T>;
|
|
22
|
+
fetchValue(itemType: ApiItemType, itemId: ItemId, columnId: string): any;
|
|
23
|
+
fetchColumnArray<const ItemTypeType extends ApiItemType>(itemType: ItemTypeType): ResponseColumn<ItemTypeType>[];
|
|
24
|
+
fetchDerivedObject(itemType: ApiItemType, itemId: ItemId, rootColumns: ColumnInfo[]): {};
|
|
25
|
+
fetchDerivedValues(value: any, column: ColumnInfo, destination: any): void;
|
|
26
|
+
fetchObject<const ItemTypeType extends ApiItemType>(itemType: ItemTypeType, itemId: string | ItemId): FieldMap<ItemTypeType> | undefined;
|
|
27
|
+
fetchObjectArray<const ItemTypeType extends ApiItemType>(itemType: ItemTypeType, idArray?: ItemId[] | null): FieldMap<ItemTypeType>[];
|
|
28
|
+
fetchColumnsObject(): ResponseColumnItemTypeMap;
|
|
29
|
+
private createColumnMaps;
|
|
30
|
+
private replaceTempItemTypeIdsWithLocalIds;
|
|
31
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ItemId } from '@rentman/backend-types';
|
|
2
|
+
import { ItemResource } from '../../models/ItemResource';
|
|
3
|
+
import { GetFieldValueType } from '../../types/ItemTypesCollection';
|
|
4
|
+
import { TransactionCache } from '../cache/transaction/TransactionCache';
|
|
5
|
+
import { ChangesDeltaItemCreateDelta } from '../CreatedChangesDelta';
|
|
6
|
+
import { BLR_SKIP_RULE, BusinessLogicRule } from './BusinessLogicRule';
|
|
7
|
+
import { BusinessLogicRuleApplyContext } from './BusinessLogicRuleApplyContext';
|
|
8
|
+
import { BusinessLogicRuleConditionContext } from './BusinessLogicRuleConditionContext';
|
|
9
|
+
import { BusinessLogicRuleContextBase } from './BusinessLogicRuleContextBase';
|
|
10
|
+
export declare const commonEquipmentColumns: readonly ["id", "aantal", "parent", "materiaal"];
|
|
11
|
+
type MateriaalTypeMap = {
|
|
12
|
+
[equipmentId: number]: GetFieldValueType<'Materiaal', 'type'>;
|
|
13
|
+
};
|
|
14
|
+
type MateriaalType = 'Planningmateriaal' | 'Inhuurmateriaal';
|
|
15
|
+
type ConditionResult<ItemTypeType extends MateriaalType> = {
|
|
16
|
+
created: ChangesDeltaItemCreateDelta<ItemTypeType>[];
|
|
17
|
+
updated: ItemId[];
|
|
18
|
+
};
|
|
19
|
+
type Dependency<ItemTypeType extends MateriaalType> = {
|
|
20
|
+
createdTuples: ChangesDeltaItemCreateDelta<ItemTypeType>[];
|
|
21
|
+
updatedItemResources: ItemResource<ItemTypeType, typeof commonEquipmentColumns>[];
|
|
22
|
+
materiaalTypeMap: MateriaalTypeMap;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* @description
|
|
26
|
+
* If Planningmateriaal 'aantal' is changed make sure it is rounded for rental items.
|
|
27
|
+
* Note: We're assuming 'aantal' is fractional only for sets & set's content here.
|
|
28
|
+
*/
|
|
29
|
+
export declare abstract class AantalBusinessLogicRuleBase<ItemTypeType extends MateriaalType> extends BusinessLogicRule<ConditionResult<ItemTypeType>, Dependency<ItemTypeType>> {
|
|
30
|
+
protected readonly itemType: ItemTypeType;
|
|
31
|
+
condition({ previousChangesDelta, transaction, }: BusinessLogicRuleConditionContext): ConditionResult<ItemTypeType> | typeof BLR_SKIP_RULE;
|
|
32
|
+
dependency(transaction: TransactionCache, conditionResult: ConditionResult<ItemTypeType>, context: BusinessLogicRuleContextBase): Promise<Dependency<ItemTypeType>>;
|
|
33
|
+
apply(context: BusinessLogicRuleApplyContext, dependency: Dependency<ItemTypeType>): void;
|
|
34
|
+
private getMateriaalTypeMap;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ItemId } from '@rentman/backend-types';
|
|
2
|
+
import { TransactionCache } from '../cache/transaction/TransactionCache';
|
|
3
|
+
import { BLR_SKIP_RULE, BusinessLogicRule } from './BusinessLogicRule';
|
|
4
|
+
import { BusinessLogicRuleApplyContext } from './BusinessLogicRuleApplyContext';
|
|
5
|
+
import { BusinessLogicRuleConditionContext } from './BusinessLogicRuleConditionContext';
|
|
6
|
+
import { BusinessLogicRuleContextBase, LatestItem } from './BusinessLogicRuleContextBase';
|
|
7
|
+
declare const commonEquipmentColumns: readonly ["id", "aantal", "aantaltotaal", "parent", "materiaal"];
|
|
8
|
+
export declare const plannedEquipmentColumns: readonly ["id", "aantal", "aantaltotaal", "parent", "materiaal", "categorie"];
|
|
9
|
+
export declare const subhireEquipmentColumns: readonly ["id", "aantal", "aantaltotaal", "parent", "materiaal", "inhuurgroep"];
|
|
10
|
+
type PlannedEquipmentItemType = 'Planningmateriaal' | 'Inhuurmateriaal';
|
|
11
|
+
type LatestEquipmentItem<ItemTypeType extends PlannedEquipmentItemType> = {
|
|
12
|
+
Planningmateriaal: LatestItem<'Planningmateriaal', typeof commonEquipmentColumns>;
|
|
13
|
+
Inhuurmateriaal: LatestItem<'Inhuurmateriaal', typeof commonEquipmentColumns>;
|
|
14
|
+
}[ItemTypeType];
|
|
15
|
+
type LatestEquipmentItemIdMap<ItemTypeType extends PlannedEquipmentItemType> = Map<ItemId, LatestEquipmentItem<ItemTypeType>>;
|
|
16
|
+
type LatestEquipmentItemParentMap<ItemTypeType extends PlannedEquipmentItemType> = Map<ItemId | null, LatestEquipmentItem<ItemTypeType>[]>;
|
|
17
|
+
type EquipmentIsPhysicalMap = Map<ItemId<'Materiaal'> | null, boolean>;
|
|
18
|
+
interface Dependency<ItemTypeType extends PlannedEquipmentItemType> {
|
|
19
|
+
/**
|
|
20
|
+
* Because the fractional total quantity is not stored with the item (only the ceiled value is), we need to
|
|
21
|
+
* calculate it starting at the root item(s) of the items we'd like to update.
|
|
22
|
+
*/
|
|
23
|
+
rootItemIds: Iterable<ItemId<ItemTypeType>>;
|
|
24
|
+
/**
|
|
25
|
+
* We're requesting all planned equipment items in affected groups because we need both the ancestors and the
|
|
26
|
+
* descendants of the created / updated items. The ancestors to determine the root items, and the descendants
|
|
27
|
+
* because their total quantity will change as well.
|
|
28
|
+
*/
|
|
29
|
+
affectedEquipmentItemsByParent: LatestEquipmentItemParentMap<ItemTypeType>;
|
|
30
|
+
affectedEquipmentItemsById: LatestEquipmentItemIdMap<ItemTypeType>;
|
|
31
|
+
equipmentIsPhysicalMap: EquipmentIsPhysicalMap;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @description
|
|
35
|
+
* If Planningmateriaal total is changed recalculate the fields
|
|
36
|
+
* Note: We're assuming 'aantal' is fractional only for sets here.
|
|
37
|
+
*/
|
|
38
|
+
export declare abstract class AantaltotaalBusinessLogicRuleBase<ItemTypeType extends PlannedEquipmentItemType> extends BusinessLogicRule<LatestEquipmentItem<ItemTypeType>[], Dependency<ItemTypeType>> {
|
|
39
|
+
protected abstract readonly itemType: ItemTypeType;
|
|
40
|
+
protected abstract readonly groupingProperties: {
|
|
41
|
+
Planningmateriaal: {
|
|
42
|
+
itemType: 'MateriaalCat';
|
|
43
|
+
columnId: 'categorie';
|
|
44
|
+
};
|
|
45
|
+
Inhuurmateriaal: {
|
|
46
|
+
itemType: 'Inhuurgroep';
|
|
47
|
+
columnId: 'inhuurgroep';
|
|
48
|
+
};
|
|
49
|
+
}[ItemTypeType];
|
|
50
|
+
protected abstract readonly requestColumns: {
|
|
51
|
+
Planningmateriaal: typeof plannedEquipmentColumns;
|
|
52
|
+
Inhuurmateriaal: typeof subhireEquipmentColumns;
|
|
53
|
+
}[ItemTypeType];
|
|
54
|
+
condition(context: BusinessLogicRuleConditionContext): Promise<LatestEquipmentItem<ItemTypeType>[] | typeof BLR_SKIP_RULE>;
|
|
55
|
+
dependency(_transaction: TransactionCache, affectedEquipmentItems: LatestEquipmentItem<ItemTypeType>[], context: BusinessLogicRuleContextBase): Promise<Dependency<ItemTypeType>>;
|
|
56
|
+
apply(context: BusinessLogicRuleApplyContext, dependency: Dependency<ItemTypeType>): void;
|
|
57
|
+
private fetchEquipmentIsPhysicalMap;
|
|
58
|
+
private updatePlannedEquipmentItem;
|
|
59
|
+
}
|
|
60
|
+
export {};
|
package/dist/types/src/classes/BusinessLogicManager/Afspraak/AfspraakRecureindBusinessLogicRule.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RecurrentItemRecureindBusinessLogicRule } from '../RecurrentItem/RecurrentItemRecureindBusinessLogicRule';
|
|
2
|
+
export declare class AfspraakRecureindBusinessLogicRule extends RecurrentItemRecureindBusinessLogicRule<'Afspraak', 'tot'> {
|
|
3
|
+
protected itemType: "Afspraak";
|
|
4
|
+
protected toField: "tot";
|
|
5
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RecurrentItemRecureindBusinessLogicRule } from '../RecurrentItem/RecurrentItemRecureindBusinessLogicRule';
|
|
2
|
+
export declare class BeschikbaarheidRecureindBusinessLogicRule extends RecurrentItemRecureindBusinessLogicRule<'Beschikbaarheid', 'plantot'> {
|
|
3
|
+
protected itemType: "Beschikbaarheid";
|
|
4
|
+
protected toField: "plantot";
|
|
5
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ApiModuleFunctionResponse } from '@rentman/backend-types';
|
|
2
|
+
import { ErrorHandlerInterface } from '../../interfaces/ErrorHandlerInterface';
|
|
3
|
+
import { HasFlagFn } from '../../types/ItemTypesCollection';
|
|
4
|
+
import { TransactionCache } from '../cache/transaction/TransactionCache';
|
|
5
|
+
import { ChangesDelta } from '../ChangesDelta';
|
|
6
|
+
import { BusinessLogicRule, BusinessLogicRuleConditionConfirmFn, BusinessLogicRuleConfirmFnWithDependency } from './BusinessLogicRule';
|
|
7
|
+
import { BusinessLogicRuleConstructor } from './businessLogicRule.decorator';
|
|
8
|
+
/**
|
|
9
|
+
* @description
|
|
10
|
+
* The BusinessLogicManager is responsible for calling all business rules with a ChangesDelta and storing their results for the {@link BusinessLogicRule business logic phases}.
|
|
11
|
+
*/
|
|
12
|
+
export declare class BusinessLogicManager {
|
|
13
|
+
private errorHandler;
|
|
14
|
+
/**
|
|
15
|
+
* We set the business logic rule instances using a constructor parameter to facilitate testing of combinations
|
|
16
|
+
* of rules.
|
|
17
|
+
*/
|
|
18
|
+
private readonly businessLogicRuleInstances;
|
|
19
|
+
constructor(errorHandler: ErrorHandlerInterface,
|
|
20
|
+
/**
|
|
21
|
+
* We set the business logic rule instances using a constructor parameter to facilitate testing of combinations
|
|
22
|
+
* of rules.
|
|
23
|
+
*/
|
|
24
|
+
businessLogicRuleInstances: readonly BusinessLogicRule<any, any, any>[]);
|
|
25
|
+
static constructBusinessLogicRules(locals: ApiModuleFunctionResponse<'locals', 'getLocals'>, hasFlagFn: HasFlagFn, businessLogicRuleClasses?: readonly BusinessLogicRuleConstructor[]): BusinessLogicRule<any, any, any>[];
|
|
26
|
+
/**
|
|
27
|
+
* @description
|
|
28
|
+
* Allows the implementer to add a confirm function which is called after the condition of the business rule has fired
|
|
29
|
+
* And before the dependency is fetched, preventing unnessesary dependecy calls
|
|
30
|
+
* With this confirm the process can be aborted without applying the changes from the delta
|
|
31
|
+
*/
|
|
32
|
+
setBusinessLogicRuleConfirmation<BusinessLogicRuleType extends BusinessLogicRule<any, any, any>>(businessLogicRuleClass: BusinessLogicRuleConstructor<BusinessLogicRuleType>, confirmFunction: BusinessLogicRuleType extends BusinessLogicRule<infer Condition, any, infer Options> ? BusinessLogicRuleConditionConfirmFn<Condition, Options> : never): void;
|
|
33
|
+
/**
|
|
34
|
+
* @description
|
|
35
|
+
* Allows the implementer to add a confirm function which is called after the dependency of the business rule is fetched
|
|
36
|
+
* And before the apply step is fired.
|
|
37
|
+
* With this confirm the process can be aborted without applying the changes from the delta
|
|
38
|
+
*/
|
|
39
|
+
setBusinessLogicRulePostDependencyConfirmation<BusinessLogicRuleType extends BusinessLogicRule<any, any, any>>(businessLogicRuleClass: BusinessLogicRuleConstructor<BusinessLogicRuleType>, confirmFunction: BusinessLogicRuleType extends BusinessLogicRule<infer Condition, infer Dependency, infer Options> ? BusinessLogicRuleConfirmFnWithDependency<Condition, Dependency, Options> : never): void;
|
|
40
|
+
/**
|
|
41
|
+
* @description
|
|
42
|
+
* Handles the business logic for a given ChangesDelta. It will provide a *new* ChangesDelta on which the business
|
|
43
|
+
* rules can apply their data, so that if new changes are made on *only those new changes* the business logic can be
|
|
44
|
+
* run again.
|
|
45
|
+
*
|
|
46
|
+
* example:
|
|
47
|
+
* - `Functie.twoway` changes the `Functie.afstand` field
|
|
48
|
+
* - In a second iteration (recursive call) the `Functie.afstand` field updates `Functie.prijs`
|
|
49
|
+
* (by doing `Functie.afstand` * `Functie.kilometerprijs`)
|
|
50
|
+
* - In a third iteration (2nd recursive call) the `Functie.kilometerprijs` has no business logic, so the function
|
|
51
|
+
* exits early (`rulesToRun.size === 0`) and the recursion ends
|
|
52
|
+
*
|
|
53
|
+
* @param transaction The transaction the ChangesDelta will be applied on
|
|
54
|
+
* @param mergedChangesDelta - A changes delta containing the source changes, plus the changes made during *all*
|
|
55
|
+
* previous rule application cycles.
|
|
56
|
+
* @param previousChangesDelta - A changes delta containing source changes, *or* the changes made during the last
|
|
57
|
+
* rule application cycle only. Should be used to determine whether the business logic rule should run.
|
|
58
|
+
*
|
|
59
|
+
* @private should only be called by the core
|
|
60
|
+
*/
|
|
61
|
+
handleBusinessLogic(transaction: TransactionCache, mergedChangesDelta: ChangesDelta, previousChangesDelta?: ChangesDelta): Promise<ChangesDelta | null>;
|
|
62
|
+
private findBusinessLogicRuleInstance;
|
|
63
|
+
private applyRules;
|
|
64
|
+
private waitForRuleDependencies;
|
|
65
|
+
private extractRulesToRun;
|
|
66
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { ApiItemType, ApiModuleFunctionResponse, ResponseColumn } from '@rentman/backend-types';
|
|
2
|
+
import { ItemEntry } from '../../models/ItemEntry';
|
|
3
|
+
import { GetFieldValueType, HasFlagFn, ItemTypeColumnId } from '../../types/ItemTypesCollection';
|
|
4
|
+
import { TransactionCache } from '../cache/transaction/TransactionCache';
|
|
5
|
+
import { BusinessLogicRuleApplyContext } from './BusinessLogicRuleApplyContext';
|
|
6
|
+
import { BusinessLogicRuleConditionContext } from './BusinessLogicRuleConditionContext';
|
|
7
|
+
import { BusinessLogicRuleContextBase } from './BusinessLogicRuleContextBase';
|
|
8
|
+
export declare const BLR_SKIP_RULE: unique symbol;
|
|
9
|
+
export declare const BLR_CONTINUE_WITH_DEFAULTS: unique symbol;
|
|
10
|
+
/**
|
|
11
|
+
* As the 'condition' function can return any value, we introduce a unique identifier to return when a business
|
|
12
|
+
* logic rule confirm function has been rejected, and changes should be abandoned.
|
|
13
|
+
*/
|
|
14
|
+
export declare const BLR_ABANDON_CHANGES: unique symbol;
|
|
15
|
+
export interface RuleConditionResultTuple {
|
|
16
|
+
ruleInstance: BusinessLogicRule<any, any, any>;
|
|
17
|
+
conditionResult: any;
|
|
18
|
+
confirmResult?: any;
|
|
19
|
+
}
|
|
20
|
+
export interface RuleDependencyResultTuple extends RuleConditionResultTuple {
|
|
21
|
+
dependencyResult: any;
|
|
22
|
+
confirmResult?: any;
|
|
23
|
+
}
|
|
24
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
25
|
+
export type BusinessLogicRuleConditionConfirmFn<ConditionResult, ConfirmResult> = (conditionResult: ConditionResult, transaction: TransactionCache) => MaybePromise<ConfirmResult | typeof BLR_SKIP_RULE | typeof BLR_ABANDON_CHANGES | typeof BLR_CONTINUE_WITH_DEFAULTS>;
|
|
26
|
+
export type BusinessLogicRuleConfirmFnWithDependency<ConditionResult, Dependency, ConfirmResult> = (conditionResult: ConditionResult, dependency: Dependency, transaction: TransactionCache) => MaybePromise<ConfirmResult | typeof BLR_SKIP_RULE | typeof BLR_ABANDON_CHANGES | typeof BLR_CONTINUE_WITH_DEFAULTS>;
|
|
27
|
+
export type BusinessLogicConditionResult<ItemTypeType extends ApiItemType, ColumnId extends ItemTypeColumnId<ItemTypeType>> = {
|
|
28
|
+
itemEntry: ItemEntry<ItemTypeType>;
|
|
29
|
+
responseColumn: ResponseColumn<ItemTypeType, ColumnId>;
|
|
30
|
+
oldValue: GetFieldValueType<ItemTypeType, ColumnId>;
|
|
31
|
+
newValue: GetFieldValueType<ItemTypeType, ColumnId>;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* @description
|
|
35
|
+
* A business rule is a class that does some data transformation depending on other fields.
|
|
36
|
+
* You can hook into any data change using the {@link BusinessLogicRule.condition `condition`} function (also deletes/creates)
|
|
37
|
+
*
|
|
38
|
+
* All business rule logic is always run in these phases:
|
|
39
|
+
* 1. condition checking - handled by the {@link BusinessLogicRule.condition `condition`} function
|
|
40
|
+
* 2. dependency fetching - handled by the {@link BusinessLogicRule.dependency `dependency`} function
|
|
41
|
+
* 3. rule applying - handled by the {@link BusinessLogicRule.apply `apply`} function
|
|
42
|
+
*/
|
|
43
|
+
export declare abstract class BusinessLogicRule<ConditionResult, DependencyType, ConfirmResult = undefined> {
|
|
44
|
+
protected readonly locals: ApiModuleFunctionResponse<'locals', 'getLocals'>;
|
|
45
|
+
protected readonly hasFlag: HasFlagFn;
|
|
46
|
+
confirm: BusinessLogicRuleConditionConfirmFn<ConditionResult, ConfirmResult> | null;
|
|
47
|
+
postDependencyConfirm: BusinessLogicRuleConfirmFnWithDependency<ConditionResult, DependencyType, ConfirmResult> | null;
|
|
48
|
+
constructor(locals: ApiModuleFunctionResponse<'locals', 'getLocals'>, hasFlag: HasFlagFn);
|
|
49
|
+
/**
|
|
50
|
+
* @description
|
|
51
|
+
* The {@link BusinessLogicRule.dependency `dependency`} function gets the result of the
|
|
52
|
+
* {@link BusinessLogicRule.condition `condition`} function and has to ensure that the data that the
|
|
53
|
+
* {@link BusinessLogicRule.apply `apply`} function reads/writes is fetched (because you cannot write columns you don't have).
|
|
54
|
+
*
|
|
55
|
+
* @param transaction The transaction that the delta is being applied on
|
|
56
|
+
* @param conditionResult The result of the {@link BusinessLogicRule.condition `condition`} call
|
|
57
|
+
*/
|
|
58
|
+
abstract dependency(transaction: TransactionCache, conditionResult: ConditionResult, context: BusinessLogicRuleContextBase): Promise<DependencyType>;
|
|
59
|
+
/**
|
|
60
|
+
* @description
|
|
61
|
+
* The {@link BusinessLogicRule.apply `apply`} function gets the result of the
|
|
62
|
+
* {@link BusinessLogicRule.dependency `dependency`} function and is responsible for actually doing the business
|
|
63
|
+
* logic. In this function other fields can be updated or new items can be created.
|
|
64
|
+
*
|
|
65
|
+
* @remark
|
|
66
|
+
* Do not alter data in the `changesDelta` but use the `destinationChangesDelta`, this is so that for the changed
|
|
67
|
+
* values in the `destinationChangesDelta` business logic can also be done.
|
|
68
|
+
*
|
|
69
|
+
* @param dependencies The result of the {@link BusinessLogicRule.dependency `dependency`} function
|
|
70
|
+
*/
|
|
71
|
+
abstract apply(context: BusinessLogicRuleApplyContext, dependencies: DependencyType, conditionResult: ConditionResult, confirmResult: ConfirmResult): void;
|
|
72
|
+
/**
|
|
73
|
+
* @description
|
|
74
|
+
* The {@link BusinessLogicRule.condition `condition`} function should extract the items from the {@link ChangesDelta `ChangesDelta`} so that the {@link BusinessLogicRule.dependency `dependency`} function can fetch the required data for the business rule.
|
|
75
|
+
* This function can return `undefined` if the rule does not apply to the items in the given ChangesDelta.
|
|
76
|
+
*
|
|
77
|
+
* @protected
|
|
78
|
+
*/
|
|
79
|
+
abstract condition(context: BusinessLogicRuleConditionContext): Promise<ConditionResult | typeof BLR_SKIP_RULE> | ConditionResult | typeof BLR_SKIP_RULE;
|
|
80
|
+
}
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ApiItemType } from '@rentman/backend-types';
|
|
2
|
+
import { ItemEntry } from '../../models/ItemEntry';
|
|
3
|
+
import { FieldMap, GetFieldValueType, ItemTypeColumnId } from '../../types/ItemTypesCollection';
|
|
4
|
+
import { TransactionCache } from '../cache/transaction/TransactionCache';
|
|
5
|
+
import { ChangesDelta } from '../ChangesDelta';
|
|
6
|
+
import { BusinessLogicRuleContextBase } from './BusinessLogicRuleContextBase';
|
|
7
|
+
/**
|
|
8
|
+
* Class that represents the context for the business logic rule `apply()` function.
|
|
9
|
+
*/
|
|
10
|
+
export declare class BusinessLogicRuleApplyContext extends BusinessLogicRuleContextBase {
|
|
11
|
+
readonly destinationChangesDelta: ChangesDelta;
|
|
12
|
+
/**
|
|
13
|
+
* @param destinationChangesDelta - Changes should be written to this changes delta.
|
|
14
|
+
*/
|
|
15
|
+
constructor(transactionCache: TransactionCache, previousChangesDelta: ChangesDelta, mergedChangesDelta: ChangesDelta, destinationChangesDelta: ChangesDelta);
|
|
16
|
+
/**
|
|
17
|
+
* An alias for `destinationChangesDelta.setItemUpdated().
|
|
18
|
+
*
|
|
19
|
+
* In most cases, `setUpdatedValue()`, would be preferred, because it only sets the value when differs from the
|
|
20
|
+
* current value.
|
|
21
|
+
*/
|
|
22
|
+
setItemUpdated<ItemTypeType extends ApiItemType>(entry: ItemEntry<ItemTypeType>, fields: Partial<FieldMap<ItemTypeType>>): void;
|
|
23
|
+
/**
|
|
24
|
+
* An alias for `destinationChangesDelta.setItemsDeleted().
|
|
25
|
+
*/
|
|
26
|
+
setItemsDeleted<ItemTypeType extends ApiItemType>(entries: ItemEntry<ItemTypeType>[]): void;
|
|
27
|
+
/**
|
|
28
|
+
* Convenience function to write an updated value to the destination changes delta. Only sets the value when differs
|
|
29
|
+
* from the current value.
|
|
30
|
+
*/
|
|
31
|
+
setUpdatedValue<ItemTypeType extends ApiItemType, ColumnId extends ItemTypeColumnId<ItemTypeType>>(entry: ItemEntry<ItemTypeType>, columnId: ColumnId, newValue: GetFieldValueType<ItemTypeType, ColumnId>): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ApiItemType, ItemId } from '@rentman/backend-types';
|
|
2
|
+
import { ErrorHandlerInterface } from '../../interfaces/ErrorHandlerInterface';
|
|
3
|
+
import { GetFieldValueType, ItemTypeColumnId } from '../../types/ItemTypesCollection';
|
|
4
|
+
import { TransactionCache } from '../cache/transaction/TransactionCache';
|
|
5
|
+
import { ChangesDelta, ChangesDeltaItemUpdateDelta } from '../ChangesDelta';
|
|
6
|
+
import { BLR_SKIP_RULE, BusinessLogicConditionResult } from './BusinessLogicRule';
|
|
7
|
+
import { BusinessLogicRuleContextBase } from './BusinessLogicRuleContextBase';
|
|
8
|
+
/**
|
|
9
|
+
* Class that represents the context for the business logic rule `condition()` function.
|
|
10
|
+
*
|
|
11
|
+
* Please note that, while the transaction, merged changes delta and previous changes delta are available on the
|
|
12
|
+
* class instance, using the helper functions is preferred.
|
|
13
|
+
*/
|
|
14
|
+
export declare class BusinessLogicRuleConditionContext extends BusinessLogicRuleContextBase {
|
|
15
|
+
private errorHandler;
|
|
16
|
+
constructor(transaction: TransactionCache, previousChangesDelta: ChangesDelta, mergedChangesDelta: ChangesDelta, errorHandler: ErrorHandlerInterface);
|
|
17
|
+
/**
|
|
18
|
+
* @description
|
|
19
|
+
* This function will compare the stored changes with the given changes, and return a
|
|
20
|
+
* {@link BusinessLogicConditionResult} if the fields have been changed, `null` otherwise.
|
|
21
|
+
* If either the source or changed field is `undefined` it will always return `null` (not changed)
|
|
22
|
+
*
|
|
23
|
+
* @param tuple The {@link ChangesDelta.updated update tuple} from a ChangesDelta
|
|
24
|
+
* @param columnId The columnId of the field that should've been changed for the ID to be included
|
|
25
|
+
*/
|
|
26
|
+
fieldChanged<ItemTypeType extends ApiItemType, ColumnId extends ItemTypeColumnId<ItemTypeType>>(tuple: ChangesDeltaItemUpdateDelta<ItemTypeType>, columnId: ColumnId): null | BusinessLogicConditionResult<ItemTypeType, ColumnId>;
|
|
27
|
+
/**
|
|
28
|
+
* This function is a utility function that will return the {@link ItemId ItemIds} of updated items in the
|
|
29
|
+
* {@link ChangesDelta ChangesDelta} which match the {@link ApiItemType ItemType} and of which the provided
|
|
30
|
+
* column's field has changed.
|
|
31
|
+
*
|
|
32
|
+
* @param itemType The ItemType of the item you want to compare a field from
|
|
33
|
+
* @param columnId The columnId of the field that should've been changed for the ID to be included
|
|
34
|
+
*/
|
|
35
|
+
getItemIdsWithUpdatedField<ItemTypeType extends ApiItemType>(itemType: ItemTypeType, columnId: ItemTypeColumnId<ItemTypeType>): ItemId[] | typeof BLR_SKIP_RULE;
|
|
36
|
+
/**
|
|
37
|
+
* Like {@link getItemIdsWithUpdatedField}, but allows for a new value to be provided. Only IDs of items where the
|
|
38
|
+
* field has been updated to the new value will be included in the result.
|
|
39
|
+
*/
|
|
40
|
+
getItemIdsWithFieldUpdatedTo<ItemTypeType extends ApiItemType, ColumnId extends ItemTypeColumnId<ItemTypeType>>(itemType: ItemTypeType, columnId: ColumnId, newValue: GetFieldValueType<ItemTypeType, ColumnId>): ItemId[] | typeof BLR_SKIP_RULE;
|
|
41
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ApiItemType, ItemId } from '@rentman/backend-types';
|
|
2
|
+
import { ChangesDelta, ChangesDeltaItemCreateDelta, ChangesDeltaItemUpdateDelta, FieldMap, GetFieldValueType, ItemEntry, ItemTypeColumnId, TransactionCache } from '../../internal';
|
|
3
|
+
export type LatestItemColumnsArray<ItemTypeType extends ApiItemType> = readonly ItemTypeColumnId<ItemTypeType>[];
|
|
4
|
+
export type UpdatedLatestItem<ItemTypeType extends ApiItemType, ColumnIds extends LatestItemColumnsArray<ItemTypeType>> = {
|
|
5
|
+
itemEntry: ItemEntry<ItemTypeType>;
|
|
6
|
+
updatedTuple?: ChangesDeltaItemUpdateDelta<ItemTypeType>;
|
|
7
|
+
fields: FieldMap<ItemTypeType, ColumnIds>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* A 'latest' item can either be:
|
|
11
|
+
* - A created changes delta (for created items).
|
|
12
|
+
* - An object containing an item entry and a `fields` property (for updated items). The `fields` property will
|
|
13
|
+
* read updated values from the changes delta if available.
|
|
14
|
+
*
|
|
15
|
+
* In both cases, we can access the latest values through the `fields` property.
|
|
16
|
+
*/
|
|
17
|
+
export type LatestItem<ItemTypeType extends ApiItemType, ColumnIds extends LatestItemColumnsArray<ItemTypeType>> = UpdatedLatestItem<ItemTypeType, ColumnIds> | ChangesDeltaItemCreateDelta<ItemTypeType>;
|
|
18
|
+
export declare abstract class BusinessLogicRuleContextBase {
|
|
19
|
+
readonly transaction: TransactionCache;
|
|
20
|
+
readonly previousChangesDelta: ChangesDelta;
|
|
21
|
+
readonly mergedChangesDelta: ChangesDelta;
|
|
22
|
+
/**
|
|
23
|
+
* @param transaction - The transaction the business logic rule is being applied on.
|
|
24
|
+
* @param previousChangesDelta - A changes delta containing source changes, *or* the changes made during the last
|
|
25
|
+
* rule application cycle only. Should be used to determine whether the business logic rule should run.
|
|
26
|
+
* @param mergedChangesDelta - A changes delta containing the source changes, plus the changes made during *all*
|
|
27
|
+
* previous rule application cycles.
|
|
28
|
+
*/
|
|
29
|
+
protected constructor(transaction: TransactionCache, previousChangesDelta: ChangesDelta, mergedChangesDelta: ChangesDelta);
|
|
30
|
+
/**
|
|
31
|
+
* This function will get the latest value of the given itemEntry by first looking in the merged changes delta.
|
|
32
|
+
* It will return the value found in the transaction chain otherwise.
|
|
33
|
+
*
|
|
34
|
+
* You could assume this function never returns `undefined` if you fetch the resource in your dependency function.
|
|
35
|
+
*/
|
|
36
|
+
getLatestValue<ItemTypeType extends ApiItemType, ColumnId extends ItemTypeColumnId<ItemTypeType>>(entry: ItemEntry<ItemTypeType>, columnId: ColumnId): GetFieldValueType<ItemTypeType, ColumnId> | undefined;
|
|
37
|
+
isUpdatedLatestItem<ItemTypeType extends ApiItemType, ColumnIds extends LatestItemColumnsArray<ItemTypeType>>(latestItem: LatestItem<ItemTypeType, ColumnIds>): latestItem is UpdatedLatestItem<ItemTypeType, ColumnIds>;
|
|
38
|
+
collectFields<ItemTypeType extends ApiItemType>(latestItem: LatestItem<ItemTypeType, any>): FieldMap<ItemTypeType>;
|
|
39
|
+
/**
|
|
40
|
+
* The equivalent of `getLinkCollections` on the transaction. Returns an array of 'latest' items for each parent
|
|
41
|
+
* ID. Covers the merged changes delta as well as the transaction. Currently doesn't take deleted items into account.
|
|
42
|
+
*
|
|
43
|
+
* TODO: Instead of replicating transaction functionality in the business rule context, we should apply business
|
|
44
|
+
* logic rules on a child transaction.
|
|
45
|
+
*/
|
|
46
|
+
fetchLatestItemsByParent<ParentItemType extends ApiItemType, ItemTypeType extends ApiItemType, ColumnIds extends LatestItemColumnsArray<ItemTypeType>>(parentItemType: ParentItemType, parentItemIds: ItemId<ParentItemType>[], itemType: ItemTypeType, requestColumns: ColumnIds): Promise<Map<ItemId<ParentItemType>, LatestItem<ItemTypeType, ColumnIds>[]>>;
|
|
47
|
+
/**
|
|
48
|
+
* This method should only be used when we're sure the items do not occur in the created changes. Generally,
|
|
49
|
+
* {@link fetchLatestItemsById} should be used instead.
|
|
50
|
+
*/
|
|
51
|
+
fetchUpdatedLatestItemsById<ItemTypeType extends ApiItemType, ColumnIds extends LatestItemColumnsArray<ItemTypeType>>(itemType: ItemTypeType, itemIds: ItemId[], requestColumns: ColumnIds): Promise<UpdatedLatestItem<ItemTypeType, ColumnIds>[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Returns an array of {@link LatestItem}s, taking both changes on the transaction and the merged changes delta into
|
|
54
|
+
* account.
|
|
55
|
+
*/
|
|
56
|
+
fetchLatestItemsById<ItemTypeType extends ApiItemType, ColumnIds extends LatestItemColumnsArray<ItemTypeType>>(itemType: ItemTypeType, itemIds: Iterable<ItemId>, requestColumns: ColumnIds): Promise<LatestItem<ItemTypeType, ColumnIds>[]>;
|
|
57
|
+
private constructLatestItems;
|
|
58
|
+
}
|
package/dist/types/src/classes/BusinessLogicManager/Contact/ContactAddressBusinessLogicRule.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ItemId } from '@rentman/backend-types';
|
|
2
|
+
import { ItemResource } from '../../../models/ItemResource';
|
|
3
|
+
import { TransactionCache } from '../../cache/transaction/TransactionCache';
|
|
4
|
+
import { BLR_SKIP_RULE, BusinessLogicRule } from '../BusinessLogicRule';
|
|
5
|
+
import { BusinessLogicRuleApplyContext } from '../BusinessLogicRuleApplyContext';
|
|
6
|
+
import { BusinessLogicRuleConditionContext } from '../BusinessLogicRuleConditionContext';
|
|
7
|
+
declare const ADDRESS_FIELDS: readonly ["straat", "huisnummer", "postcode", "stad", "provincie", "land"];
|
|
8
|
+
declare const ADDRESS_PREFIXES: readonly ["bezoek", "post", "factuur"];
|
|
9
|
+
type RequestColumns = ({
|
|
10
|
+
[Prefix in typeof ADDRESS_PREFIXES[number]]: {
|
|
11
|
+
[Field in typeof ADDRESS_FIELDS[number]]: `${Prefix}${Field}`;
|
|
12
|
+
}[typeof ADDRESS_FIELDS[number]];
|
|
13
|
+
}[typeof ADDRESS_PREFIXES[number]])[];
|
|
14
|
+
type ConditionResult = ItemId[];
|
|
15
|
+
type Dependency = ItemResource<'Contact', RequestColumns>[];
|
|
16
|
+
export declare class ContactAddressBusinessLogicRule extends BusinessLogicRule<ConditionResult, Dependency> {
|
|
17
|
+
condition(context: BusinessLogicRuleConditionContext): ConditionResult | typeof BLR_SKIP_RULE;
|
|
18
|
+
dependency(transaction: TransactionCache, contactIds: ConditionResult): Promise<Dependency>;
|
|
19
|
+
apply(context: BusinessLogicRuleApplyContext, contactResources: Dependency): void;
|
|
20
|
+
private addressEqualsVisitingAddress;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ItemId } from '@rentman/backend-types';
|
|
2
|
+
import { ItemResource } from '../../../models/ItemResource';
|
|
3
|
+
import { TransactionCache } from '../../cache/transaction/TransactionCache';
|
|
4
|
+
import { BLR_SKIP_RULE, BusinessLogicRule } from '../BusinessLogicRule';
|
|
5
|
+
import { BusinessLogicRuleApplyContext } from '../BusinessLogicRuleApplyContext';
|
|
6
|
+
import { BusinessLogicRuleConditionContext } from '../BusinessLogicRuleConditionContext';
|
|
7
|
+
type ConditionResult = ItemId[];
|
|
8
|
+
type Dependency = ItemResource<'Customfield', ['defaultvalue']>[];
|
|
9
|
+
/**
|
|
10
|
+
* @description
|
|
11
|
+
* If the 'type' field changes we reset the 'defaultvalue' and 'attribute' fields so that they do not contain invalid values
|
|
12
|
+
*/
|
|
13
|
+
export declare class CustomFieldLinkedItemTypeBusinessLogicRule extends BusinessLogicRule<ConditionResult, Dependency> {
|
|
14
|
+
condition(context: BusinessLogicRuleConditionContext): ConditionResult | typeof BLR_SKIP_RULE;
|
|
15
|
+
dependency(transaction: TransactionCache, functionIds: ConditionResult): Promise<Dependency>;
|
|
16
|
+
apply(context: BusinessLogicRuleApplyContext, customFieldResources: Dependency): void;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ItemId } from '@rentman/backend-types';
|
|
2
|
+
import { ItemResource } from '../../../models/ItemResource';
|
|
3
|
+
import { TransactionCache } from '../../cache/transaction/TransactionCache';
|
|
4
|
+
import { BLR_SKIP_RULE, BusinessLogicRule } from '../BusinessLogicRule';
|
|
5
|
+
import { BusinessLogicRuleApplyContext } from '../BusinessLogicRuleApplyContext';
|
|
6
|
+
import { BusinessLogicRuleConditionContext } from '../BusinessLogicRuleConditionContext';
|
|
7
|
+
type ConditionResult = ItemId[];
|
|
8
|
+
type Dependency = ItemResource<'Customfield', ['defaultvalue', 'attributes', 'type']>[];
|
|
9
|
+
/**
|
|
10
|
+
* @description
|
|
11
|
+
* If the 'type' field changes we reset the 'defaultvalue' and 'attribute' fields so that they do not contain invalid values
|
|
12
|
+
*/
|
|
13
|
+
export declare class CustomFieldTypeBusinessLogicRule extends BusinessLogicRule<ConditionResult, Dependency> {
|
|
14
|
+
condition(context: BusinessLogicRuleConditionContext): ConditionResult | typeof BLR_SKIP_RULE;
|
|
15
|
+
dependency(transaction: TransactionCache, functionIds: ConditionResult): Promise<Dependency>;
|
|
16
|
+
apply(context: BusinessLogicRuleApplyContext, customFieldResources: Dependency): void;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
package/dist/types/src/classes/BusinessLogicManager/DefaultContactPersonUpdateBusinessLogicRule.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ApiItemType, ItemId } from '@rentman/backend-types';
|
|
2
|
+
import { ItemEntry } from '../../models/ItemEntry';
|
|
3
|
+
import { ItemResource } from '../../models/ItemResource';
|
|
4
|
+
import { ItemTypeColumnId } from '../../types/ItemTypesCollection';
|
|
5
|
+
import { TransactionCache } from '../cache/transaction/TransactionCache';
|
|
6
|
+
import { BLR_SKIP_RULE, BusinessLogicRule } from './BusinessLogicRule';
|
|
7
|
+
import { BusinessLogicRuleApplyContext } from './BusinessLogicRuleApplyContext';
|
|
8
|
+
import { BusinessLogicRuleConditionContext } from './BusinessLogicRuleConditionContext';
|
|
9
|
+
type ConditionResult = {
|
|
10
|
+
[ItemTypeType in ApiItemType]?: Map<ItemEntry, {
|
|
11
|
+
[ColumnId in ItemTypeColumnId<ItemTypeType>]?: ItemId<'Contact'>;
|
|
12
|
+
}>;
|
|
13
|
+
};
|
|
14
|
+
declare const dependencyColumns: readonly ["id", "contactpersoon"];
|
|
15
|
+
type Dependency = {
|
|
16
|
+
conditionResult: ConditionResult;
|
|
17
|
+
contactMap: {
|
|
18
|
+
[contactId: string]: ItemResource<'Contact', typeof dependencyColumns>;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* This business rule is responsible for setting the default contactperson related to a
|
|
23
|
+
* selected contact for itemTypes that have fields for this.
|
|
24
|
+
*/
|
|
25
|
+
export declare class DefaultContactPersonUpdateBusinessLogicRule extends BusinessLogicRule<ConditionResult, Dependency> {
|
|
26
|
+
condition(context: BusinessLogicRuleConditionContext): ConditionResult | typeof BLR_SKIP_RULE;
|
|
27
|
+
dependency(transaction: TransactionCache, conditionResult: ConditionResult): Promise<Dependency>;
|
|
28
|
+
apply(context: BusinessLogicRuleApplyContext, dependencyResult: Dependency): void;
|
|
29
|
+
}
|
|
30
|
+
export {};
|