n8n
Version:
n8n Workflow Automation Tool
95 lines (94 loc) • 6.44 kB
TypeScript
import { Logger } from '@n8n/backend-common';
import { WorkflowsConfig } from '@n8n/config';
import type { WorkflowEntity, IWorkflowDb } from '@n8n/db';
import { WorkflowRepository } from '@n8n/db';
import { ActiveWorkflowTriggers, ErrorReporter, InstanceSettings, type IGetExecutePollFunctions, type IGetExecuteTriggerFunctions } from 'n8n-core';
import type { ExecutionError, IWorkflowBase, IWorkflowExecuteAdditionalData, WorkflowActivateMode, WorkflowExecuteMode, WorkflowId } from 'n8n-workflow';
import { Workflow } from 'n8n-workflow';
import { ActivationErrorsService } from './activation-errors.service';
import { MessageEventBus } from './eventbus/message-event-bus/message-event-bus';
import { ExternalHooks } from './external-hooks';
import { NodeTypes } from './node-types';
import { Push } from './push';
import { Publisher } from './scaling/pubsub/publisher.service';
import { PubSubCommandMap } from './scaling/pubsub/pubsub.event-map';
import type { ScheduleTriggerCollectionSession } from './scheduling/schedule-trigger-node/schedule-trigger-job-registrar';
import { PollTriggerJobRegistrar } from './scheduling/poll-trigger-node/poll-trigger-job-registrar';
import { ScheduleTriggerJobRegistrar } from './scheduling/schedule-trigger-node/schedule-trigger-job-registrar';
import { ActiveWorkflowsService } from './services/active-workflows.service';
import { WebhookService } from './webhooks/webhook.service';
import { WorkflowStaticDataService } from './workflows/workflow-static-data.service';
import { TriggerExecutionContextFactory } from './workflows/triggers/trigger-execution-context.factory';
export declare class ActiveWorkflowManager {
private readonly logger;
private readonly errorReporter;
private readonly activeWorkflowTriggers;
private readonly externalHooks;
private readonly nodeTypes;
private readonly webhookService;
private readonly workflowRepository;
private readonly activationErrorsService;
private readonly workflowStaticDataService;
private readonly activeWorkflowsService;
private readonly instanceSettings;
private readonly publisher;
private readonly workflowsConfig;
private readonly push;
private readonly triggerExecutionContextFactory;
private readonly eventBus;
private readonly scheduleTriggerJobRegistrar;
private readonly pollTriggerJobRegistrar;
private queuedActivations;
constructor(logger: Logger, errorReporter: ErrorReporter, activeWorkflowTriggers: ActiveWorkflowTriggers, externalHooks: ExternalHooks, nodeTypes: NodeTypes, webhookService: WebhookService, workflowRepository: WorkflowRepository, activationErrorsService: ActivationErrorsService, workflowStaticDataService: WorkflowStaticDataService, activeWorkflowsService: ActiveWorkflowsService, instanceSettings: InstanceSettings, publisher: Publisher, workflowsConfig: WorkflowsConfig, push: Push, triggerExecutionContextFactory: TriggerExecutionContextFactory, eventBus: MessageEventBus, scheduleTriggerJobRegistrar: ScheduleTriggerJobRegistrar, pollTriggerJobRegistrar: PollTriggerJobRegistrar);
init(): Promise<void>;
getAllWorkflowActivationErrors(): Promise<import("./services/cache/cache.types").Hash<string>>;
removeAll(): Promise<void>;
allActiveInMemory(): string[];
addWebhooks(workflow: Workflow, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, activation: WorkflowActivateMode, nodeIds?: Set<string>): Promise<boolean>;
clearWebhooks(workflowId: WorkflowId): Promise<void>;
private deregisterWebhooks;
getExecutePollFunctions(workflowData: IWorkflowDb, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, activation: WorkflowActivateMode, resolveWorkflowData: () => Promise<IWorkflowBase>): IGetExecutePollFunctions;
getExecuteTriggerFunctions(workflowData: IWorkflowDb, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, activation: WorkflowActivateMode, resolveWorkflowData: () => Promise<IWorkflowBase>, scheduleCollectionSession: ScheduleTriggerCollectionSession): IGetExecuteTriggerFunctions;
executeErrorWorkflow(error: ExecutionError, workflowData: IWorkflowBase, mode: WorkflowExecuteMode): void;
private isActivationInProgress;
addActiveWorkflows(activationMode: 'init' | 'leadershipChange'): Promise<void>;
private activateWorkflow;
clearAllActivationErrors(): Promise<void>;
addAllNonWebhookTriggerWorkflows(): Promise<void>;
removeAllNonWebhookTriggerWorkflows(): Promise<void>;
add(workflowId: WorkflowId, activationMode: WorkflowActivateMode, existingWorkflow?: WorkflowEntity, { shouldPublish }?: {
shouldPublish: boolean;
}): Promise<{
webhooks: boolean;
triggersAndPollers: boolean;
}>;
handleDisplayWorkflowActivation({ workflowId, activeVersionId, }: PubSubCommandMap['display-workflow-activation']): void;
handleDisplayWorkflowDeactivation({ workflowId }: {
workflowId: string;
}): void;
handleDisplayWorkflowActivationError({ workflowId, errorMessage, errorDescription, nodeId, }: {
workflowId: string;
errorMessage: string;
errorDescription?: string;
nodeId?: string;
}): void;
handleAddWebhooksAndNonWebhookTriggers({ workflowId, activeVersionId, activationMode, }: PubSubCommandMap['add-webhooks-triggers-and-pollers']): Promise<void>;
private countTriggers;
private addQueuedWorkflowActivation;
private removeQueuedWorkflowActivation;
removeAllQueuedWorkflowActivations(): void;
remove(workflowId: WorkflowId): Promise<void>;
handleRemoveNonWebhookTriggers({ workflowId, }: PubSubCommandMap['remove-triggers-and-pollers']): Promise<void>;
private removeDurableJobs;
removeNonWebhookTriggers(workflowId: WorkflowId): Promise<void>;
addNonWebhookTriggers(dbWorkflow: WorkflowEntity, workflow: Workflow, { activationMode, executionMode, additionalData, resolveWorkflowData, nodeIds, }: {
activationMode: WorkflowActivateMode;
executionMode: WorkflowExecuteMode;
additionalData: IWorkflowExecuteAdditionalData;
resolveWorkflowData: () => Promise<IWorkflowBase>;
nodeIds?: Set<string>;
}): Promise<boolean>;
removeActivationError(workflowId: WorkflowId): Promise<void>;
shouldAddWebhooks(activationMode: WorkflowActivateMode): boolean;
shouldAddNonWebhookTriggers(): boolean;
}