import {Subscription} from '@essential-projects/event_aggregator_contracts'; import {IIdentity} from '@essential-projects/iam_contracts'; import { APIs, DataModels, IConsumerApiAccessor, Messages, } from '@process-engine/consumer_api_contracts'; export class InternalAccessor implements IConsumerApiAccessor { private readonly applicationInfoService: APIs.IApplicationInfoConsumerApi; private readonly emptyActivityService: APIs.IEmptyActivityConsumerApi; private readonly eventService: APIs.IEventConsumerApi; private readonly externalTaskService: APIs.IExternalTaskConsumerApi; private readonly manualTaskService: APIs.IManualTaskConsumerApi; private readonly notificationService: APIs.INotificationConsumerApi; private readonly processModelService: APIs.IProcessModelConsumerApi; private readonly userTaskService: APIs.IUserTaskConsumerApi; private readonly flowNodeInstanceService: APIs.IFlowNodeInstanceConsumerApi; constructor( applicationInfoService: APIs.IApplicationInfoConsumerApi, emptyActivityService: APIs.IEmptyActivityConsumerApi, eventService: APIs.IEventConsumerApi, externalTaskService: APIs.IExternalTaskConsumerApi, manualTaskService: APIs.IManualTaskConsumerApi, notificationService: APIs.INotificationConsumerApi, processModelService: APIs.IProcessModelConsumerApi, userTaskService: APIs.IUserTaskConsumerApi, flowNodeInstanceService: APIs.IFlowNodeInstanceConsumerApi, ) { this.applicationInfoService = applicationInfoService; this.emptyActivityService = emptyActivityService; this.eventService = eventService; this.externalTaskService = externalTaskService; this.manualTaskService = manualTaskService; this.notificationService = notificationService; this.processModelService = processModelService; this.userTaskService = userTaskService; this.flowNodeInstanceService = flowNodeInstanceService; } // Application Info public async getApplicationInfo(identity: IIdentity): Promise { return this.applicationInfoService.getApplicationInfo(identity); } // Process models and instances public async getProcessModels( identity: IIdentity, offset: number = 0, limit: number = 0, ): Promise { return this.processModelService.getProcessModels(identity, offset, limit); } public async getProcessModelById(identity: IIdentity, processModelId: string): Promise { return this.processModelService.getProcessModelById(identity, processModelId); } public async getProcessModelByProcessInstanceId(identity: IIdentity, processInstanceId: string): Promise { return this.processModelService.getProcessModelByProcessInstanceId(identity, processInstanceId); } public async startProcessInstance( identity: IIdentity, processModelId: string, payload?: DataModels.ProcessModels.ProcessStartRequestPayload, startCallbackType?: DataModels.ProcessModels.StartCallbackType, startEventId?: string, endEventId?: string, ): Promise { return this.processModelService.startProcessInstance(identity, processModelId, payload, startCallbackType, startEventId, endEventId); } public async getProcessResultForCorrelation( identity: IIdentity, correlationId: string, processModelId: string, ): Promise { return this.processModelService.getProcessResultForCorrelation(identity, correlationId, processModelId); } public async getProcessInstancesByIdentity( identity: IIdentity, offset: number = 0, limit: number = 0, ): Promise { return this.processModelService.getProcessInstancesByIdentity(identity, offset, limit); } // Empty Activities public async getEmptyActivitiesForProcessModel( identity: IIdentity, processModelId: string, offset: number = 0, limit: number = 0, ): Promise { return this.emptyActivityService.getEmptyActivitiesForProcessModel(identity, processModelId, offset, limit); } public async getEmptyActivitiesForProcessInstance( identity: IIdentity, processInstanceId: string, offset: number = 0, limit: number = 0, ): Promise { return this.emptyActivityService.getEmptyActivitiesForProcessInstance(identity, processInstanceId, offset, limit); } public async getEmptyActivitiesForCorrelation( identity: IIdentity, correlationId: string, offset: number = 0, limit: number = 0, ): Promise { return this.emptyActivityService.getEmptyActivitiesForCorrelation(identity, correlationId, offset, limit); } public async getEmptyActivitiesForProcessModelInCorrelation( identity: IIdentity, processModelId: string, correlationId: string, offset: number = 0, limit: number = 0, ): Promise { return this.emptyActivityService.getEmptyActivitiesForProcessModelInCorrelation(identity, processModelId, correlationId, offset, limit); } public async getWaitingEmptyActivitiesByIdentity( identity: IIdentity, offset: number = 0, limit: number = 0, ): Promise { return this.emptyActivityService.getWaitingEmptyActivitiesByIdentity(identity, offset, limit); } public async finishEmptyActivity( identity: IIdentity, processInstanceId: string, correlationId: string, emptyActivityInstanceId: string, ): Promise { return this.emptyActivityService.finishEmptyActivity(identity, processInstanceId, correlationId, emptyActivityInstanceId); } // Events public async getEventsForProcessModel( identity: IIdentity, processModelId: string, offset: number = 0, limit: number = 0, ): Promise { return this.eventService.getEventsForProcessModel(identity, processModelId, offset, limit); } public async getEventsForCorrelation( identity: IIdentity, correlationId: string, offset: number = 0, limit: number = 0, ): Promise { return this.eventService.getEventsForCorrelation(identity, correlationId, offset, limit); } public async getEventsForProcessModelInCorrelation( identity: IIdentity, processModelId: string, correlationId: string, offset: number = 0, limit: number = 0, ): Promise { return this.eventService.getEventsForProcessModelInCorrelation(identity, processModelId, correlationId, offset, limit); } public async triggerMessageEvent(identity: IIdentity, messageName: string, payload?: DataModels.Events.EventTriggerPayload): Promise { return this.eventService.triggerMessageEvent(identity, messageName, payload); } public async triggerSignalEvent(identity: IIdentity, signalName: string, payload?: DataModels.Events.EventTriggerPayload): Promise { return this.eventService.triggerSignalEvent(identity, signalName, payload); } // ExternalTask public async fetchAndLockExternalTasks( identity: IIdentity, workerId: string, topicName: string, maxTasks: number, longPollingTimeout: number, lockDuration: number, ): Promise>> { return this .externalTaskService .fetchAndLockExternalTasks(identity, workerId, topicName, maxTasks, longPollingTimeout, lockDuration); } public async extendLock(identity: IIdentity, workerId: string, externalTaskId: string, additionalDuration: number): Promise { return this.externalTaskService.extendLock(identity, workerId, externalTaskId, additionalDuration); } public async handleBpmnError( identity: IIdentity, workerId: string, externalTaskId: string, errorCode: string, errorMessage?: string, ): Promise { return this.externalTaskService.handleBpmnError(identity, workerId, externalTaskId, errorCode, errorMessage); } public async handleServiceError( identity: IIdentity, workerId: string, externalTaskId: string, errorMessage: string, errorDetails: string, errorCode?: string, ): Promise { return this.externalTaskService.handleServiceError(identity, workerId, externalTaskId, errorMessage, errorDetails, errorCode); } public async finishExternalTask(identity: IIdentity, workerId: string, externalTaskId: string, payload: TResultType): Promise { return this.externalTaskService.finishExternalTask(identity, workerId, externalTaskId, payload); } // ManualTasks public async getManualTasksForProcessModel( identity: IIdentity, processModelId: string, offset: number = 0, limit: number = 0, ): Promise { return this.manualTaskService.getManualTasksForProcessModel(identity, processModelId, offset, limit); } public async getManualTasksForProcessInstance( identity: IIdentity, processInstanceId: string, offset: number = 0, limit: number = 0, ): Promise { return this.manualTaskService.getManualTasksForProcessInstance(identity, processInstanceId, offset, limit); } public async getManualTasksForCorrelation( identity: IIdentity, correlationId: string, offset: number = 0, limit: number = 0, ): Promise { return this.manualTaskService.getManualTasksForCorrelation(identity, correlationId, offset, limit); } public async getManualTasksForProcessModelInCorrelation( identity: IIdentity, processModelId: string, correlationId: string, offset: number = 0, limit: number = 0, ): Promise { return this.manualTaskService.getManualTasksForProcessModelInCorrelation(identity, processModelId, correlationId, offset, limit); } public async getWaitingManualTasksByIdentity( identity: IIdentity, offset: number = 0, limit: number = 0, ): Promise { return this.manualTaskService.getWaitingManualTasksByIdentity(identity, offset, limit); } public async finishManualTask( identity: IIdentity, processInstanceId: string, correlationId: string, manualTaskInstanceId: string, ): Promise { return this.manualTaskService.finishManualTask(identity, processInstanceId, correlationId, manualTaskInstanceId); } // UserTasks public async getUserTasksForProcessModel( identity: IIdentity, processModelId: string, offset: number = 0, limit: number = 0, ): Promise { return this.userTaskService.getUserTasksForProcessModel(identity, processModelId, offset, limit); } public async getUserTasksForProcessInstance( identity: IIdentity, processInstanceId: string, offset: number = 0, limit: number = 0, ): Promise { return this.userTaskService.getUserTasksForProcessInstance(identity, processInstanceId, offset, limit); } public async getUserTasksForCorrelation( identity: IIdentity, correlationId: string, offset: number = 0, limit: number = 0, ): Promise { return this.userTaskService.getUserTasksForCorrelation(identity, correlationId, offset, limit); } public async getUserTasksForProcessModelInCorrelation( identity: IIdentity, processModelId: string, correlationId: string, offset: number = 0, limit: number = 0, ): Promise { return this.userTaskService.getUserTasksForProcessModelInCorrelation(identity, processModelId, correlationId, offset, limit); } public async getWaitingUserTasksByIdentity( identity: IIdentity, offset: number = 0, limit: number = 0, ): Promise { return this.userTaskService.getWaitingUserTasksByIdentity(identity, offset, limit); } public async finishUserTask( identity: IIdentity, processInstanceId: string, correlationId: string, userTaskInstanceId: string, userTaskResult: DataModels.UserTasks.UserTaskResult, ): Promise { return this.userTaskService.finishUserTask(identity, processInstanceId, correlationId, userTaskInstanceId, userTaskResult); } // Tasks public async getAllSuspendedTasks( identity: IIdentity, offset: number = 0, limit: number = 0, ): Promise { return this.flowNodeInstanceService.getAllSuspendedTasks(identity, offset, limit); } public async getSuspendedTasksForProcessModel( identity: IIdentity, processModelId: string, offset: number = 0, limit: number = 0, ): Promise { return this.flowNodeInstanceService.getSuspendedTasksForProcessModel(identity, processModelId, offset, limit); } public async getSuspendedTasksForProcessInstance( identity: IIdentity, processInstanceId: string, offset: number = 0, limit: number = 0, ): Promise { return this.flowNodeInstanceService.getSuspendedTasksForProcessInstance(identity, processInstanceId, offset, limit); } public async getSuspendedTasksForCorrelation( identity: IIdentity, correlationId: string, offset: number = 0, limit: number = 0, ): Promise { return this.flowNodeInstanceService.getSuspendedTasksForCorrelation(identity, correlationId, offset, limit); } public async getSuspendedTasksForProcessModelInCorrelation( identity: IIdentity, processModelId: string, correlationId: string, offset: number = 0, limit: number = 0, ): Promise { return this.flowNodeInstanceService.getSuspendedTasksForProcessModelInCorrelation(identity, processModelId, correlationId, offset, limit); } // Notifications public async onActivityReached( identity: IIdentity, callback: Messages.CallbackTypes.OnActivityReachedCallback, subscribeOnce: boolean = false, ): Promise { return this.notificationService.onActivityReached(identity, callback, subscribeOnce); } public async onActivityFinished( identity: IIdentity, callback: Messages.CallbackTypes.OnActivityFinishedCallback, subscribeOnce: boolean = false, ): Promise { return this.notificationService.onActivityFinished(identity, callback, subscribeOnce); } public async onEmptyActivityWaiting( identity: IIdentity, callback: Messages.CallbackTypes.OnEmptyActivityWaitingCallback, subscribeOnce: boolean = false, ): Promise { return this.notificationService.onEmptyActivityWaiting(identity, callback, subscribeOnce); } public async onEmptyActivityFinished( identity: IIdentity, callback: Messages.CallbackTypes.OnEmptyActivityFinishedCallback, subscribeOnce: boolean = false, ): Promise { return this.notificationService.onEmptyActivityFinished(identity, callback, subscribeOnce); } public async onEmptyActivityForIdentityWaiting( identity: IIdentity, callback: Messages.CallbackTypes.OnEmptyActivityWaitingCallback, subscribeOnce: boolean = false, ): Promise { return this.notificationService.onEmptyActivityForIdentityWaiting(identity, callback, subscribeOnce); } public async onEmptyActivityForIdentityFinished( identity: IIdentity, callback: Messages.CallbackTypes.OnEmptyActivityFinishedCallback, subscribeOnce: boolean = false, ): Promise { return this.notificationService.onEmptyActivityForIdentityFinished(identity, callback, subscribeOnce); } public async onUserTaskWaiting( identity: IIdentity, callback: Messages.CallbackTypes.OnUserTaskWaitingCallback, subscribeOnce: boolean = false, ): Promise { return this.notificationService.onUserTaskWaiting(identity, callback, subscribeOnce); } public async onUserTaskFinished( identity: IIdentity, callback: Messages.CallbackTypes.OnUserTaskFinishedCallback, subscribeOnce: boolean = false, ): Promise { return this.notificationService.onUserTaskFinished(identity, callback, subscribeOnce); } public async onUserTaskForIdentityWaiting( identity: IIdentity, callback: Messages.CallbackTypes.OnUserTaskWaitingCallback, subscribeOnce: boolean = false, ): Promise { return this.notificationService.onUserTaskForIdentityWaiting(identity, callback, subscribeOnce); } public async onUserTaskForIdentityFinished( identity: IIdentity, callback: Messages.CallbackTypes.OnUserTaskFinishedCallback, subscribeOnce: boolean = false, ): Promise { return this.notificationService.onUserTaskForIdentityFinished(identity, callback, subscribeOnce); } public async onBoundaryEventTriggered( identity: IIdentity, callback: Messages.CallbackTypes.OnBoundaryEventTriggeredCallback, subscribeOnce: boolean = false, ): Promise { return this.notificationService.onBoundaryEventTriggered(identity, callback, subscribeOnce); } public async onIntermediateThrowEventTriggered( identity: IIdentity, callback: Messages.CallbackTypes.OnIntermediateThrowEventTriggeredCallback, subscribeOnce: boolean = false, ): Promise { return this.notificationService.onIntermediateThrowEventTriggered(identity, callback, subscribeOnce); } public async onIntermediateCatchEventReached( identity: IIdentity, callback: Messages.CallbackTypes.OnIntermediateCatchEventReachedCallback, subscribeOnce: boolean = false, ): Promise { return this.notificationService.onIntermediateCatchEventReached(identity, callback, subscribeOnce); } public async onIntermediateCatchEventFinished( identity: IIdentity, callback: Messages.CallbackTypes.OnIntermediateCatchEventFinishedCallback, subscribeOnce: boolean = false, ): Promise { return this.notificationService.onIntermediateCatchEventFinished(identity, callback, subscribeOnce); } public async onManualTaskWaiting( identity: IIdentity, callback: Messages.CallbackTypes.OnManualTaskWaitingCallback, subscribeOnce: boolean = false, ): Promise { return this.notificationService.onManualTaskWaiting(identity, callback, subscribeOnce); } public async onManualTaskFinished( identity: IIdentity, callback: Messages.CallbackTypes.OnManualTaskFinishedCallback, subscribeOnce: boolean = false, ): Promise { return this.notificationService.onManualTaskFinished(identity, callback, subscribeOnce); } public async onManualTaskForIdentityWaiting( identity: IIdentity, callback: Messages.CallbackTypes.OnManualTaskWaitingCallback, subscribeOnce: boolean = false, ): Promise { return this.notificationService.onManualTaskForIdentityWaiting(identity, callback, subscribeOnce); } public async onManualTaskForIdentityFinished( identity: IIdentity, callback: Messages.CallbackTypes.OnManualTaskFinishedCallback, subscribeOnce: boolean = false, ): Promise { return this.notificationService.onManualTaskForIdentityFinished(identity, callback, subscribeOnce); } public async onProcessStarted( identity: IIdentity, callback: Messages.CallbackTypes.OnProcessStartedCallback, subscribeOnce: boolean = false, ): Promise { return this.notificationService.onProcessStarted(identity, callback, subscribeOnce); } public async onProcessWithProcessModelIdStarted( identity: IIdentity, callback: Messages.CallbackTypes.OnProcessStartedCallback, processModelId: string, subscribeOnce: boolean = false, ): Promise { return this.notificationService.onProcessWithProcessModelIdStarted(identity, callback, processModelId, subscribeOnce); } public async onProcessTerminated( identity: IIdentity, callback: Messages.CallbackTypes.OnProcessTerminatedCallback, subscribeOnce: boolean = false, ): Promise { return this.notificationService.onProcessTerminated(identity, callback, subscribeOnce); } public async onProcessError( identity: IIdentity, callback: Messages.CallbackTypes.OnProcessErrorCallback, subscribeOnce: boolean = false, ): Promise { return this.notificationService.onProcessError(identity, callback, subscribeOnce); } public async onProcessEnded( identity: IIdentity, callback: Messages.CallbackTypes.OnProcessEndedCallback, subscribeOnce: boolean = false, ): Promise { return this.notificationService.onProcessEnded(identity, callback, subscribeOnce); } public async removeSubscription(identity: IIdentity, subscription: Subscription): Promise { return this.notificationService.removeSubscription(identity, subscription); } }