n8n
Version:
n8n Workflow Automation Tool
178 lines (177 loc) • 5.85 kB
TypeScript
import type { Response } from 'express';
import type { INodeExecutionData, INodeTypeBaseDescription } from 'n8n-workflow';
import type WebSocket from 'ws';
import type { TaskRunner } from './task-broker.service';
import type { AuthlessRequest } from '../requests';
export type DataRequestType = 'input' | 'node' | 'all';
export interface TaskResultData {
result: INodeExecutionData[];
customData?: Record<string, string>;
}
export interface TaskRunnerServerInitRequest extends AuthlessRequest<{}, {}, {}, {
id: TaskRunner['id'];
token?: string;
}> {
ws: WebSocket;
}
export type TaskRunnerServerInitResponse = Response & {
req: TaskRunnerServerInitRequest;
};
export declare namespace N8nMessage {
namespace ToRunner {
interface InfoRequest {
type: 'broker:inforequest';
}
interface RunnerRegistered {
type: 'broker:runnerregistered';
}
interface TaskOfferAccept {
type: 'broker:taskofferaccept';
taskId: string;
offerId: string;
}
interface TaskCancel {
type: 'broker:taskcancel';
taskId: string;
reason: string;
}
interface TaskSettings {
type: 'broker:tasksettings';
taskId: string;
settings: unknown;
}
interface RPCResponse {
type: 'broker:rpcresponse';
callId: string;
taskId: string;
status: 'success' | 'error';
data: unknown;
}
interface TaskDataResponse {
type: 'broker:taskdataresponse';
taskId: string;
requestId: string;
data: unknown;
}
interface NodeTypes {
type: 'broker:nodetypes';
nodeTypes: INodeTypeBaseDescription[];
}
type All = InfoRequest | TaskOfferAccept | TaskCancel | TaskSettings | RunnerRegistered | RPCResponse | TaskDataResponse | NodeTypes;
}
namespace ToRequester {
interface TaskReady {
type: 'broker:taskready';
requestId: string;
taskId: string;
}
interface TaskDone {
type: 'broker:taskdone';
taskId: string;
data: TaskResultData;
}
interface TaskError {
type: 'broker:taskerror';
taskId: string;
error: unknown;
}
interface TaskDataRequest {
type: 'broker:taskdatarequest';
taskId: string;
requestId: string;
requestType: DataRequestType;
param?: string;
}
interface RPC {
type: 'broker:rpc';
callId: string;
taskId: string;
name: (typeof RPC_ALLOW_LIST)[number];
params: unknown[];
}
type All = TaskReady | TaskDone | TaskError | TaskDataRequest | RPC;
}
}
export declare namespace RequesterMessage {
namespace ToN8n {
interface TaskSettings {
type: 'requester:tasksettings';
taskId: string;
settings: unknown;
}
interface TaskCancel {
type: 'requester:taskcancel';
taskId: string;
reason: string;
}
interface TaskDataResponse {
type: 'requester:taskdataresponse';
taskId: string;
requestId: string;
data: unknown;
}
interface RPCResponse {
type: 'requester:rpcresponse';
taskId: string;
callId: string;
status: 'success' | 'error';
data: unknown;
}
interface TaskRequest {
type: 'requester:taskrequest';
requestId: string;
taskType: string;
}
type All = TaskSettings | TaskCancel | RPCResponse | TaskDataResponse | TaskRequest;
}
}
export declare namespace RunnerMessage {
namespace ToN8n {
interface Info {
type: 'runner:info';
name: string;
types: string[];
}
interface TaskAccepted {
type: 'runner:taskaccepted';
taskId: string;
}
interface TaskRejected {
type: 'runner:taskrejected';
taskId: string;
reason: string;
}
interface TaskDone {
type: 'runner:taskdone';
taskId: string;
data: TaskResultData;
}
interface TaskError {
type: 'runner:taskerror';
taskId: string;
error: unknown;
}
interface TaskOffer {
type: 'runner:taskoffer';
offerId: string;
taskType: string;
validFor: number;
}
interface TaskDataRequest {
type: 'runner:taskdatarequest';
taskId: string;
requestId: string;
requestType: DataRequestType;
param?: string;
}
interface RPC {
type: 'runner:rpc';
callId: string;
taskId: string;
name: (typeof RPC_ALLOW_LIST)[number];
params: unknown[];
}
type All = Info | TaskDone | TaskError | TaskAccepted | TaskRejected | TaskOffer | RPC | TaskDataRequest;
}
}
export declare const RPC_ALLOW_LIST: readonly ["logNodeOutput", "helpers.httpRequestWithAuthentication", "helpers.requestWithAuthenticationPaginated", "helpers.getBinaryDataBuffer", "helpers.getSSHClient", "helpers.createReadStream", "helpers.writeContentToFile", "helpers.prepareBinaryData", "helpers.setBinaryDataBuffer", "helpers.copyBinaryFile", "helpers.binaryToBuffer", "helpers.getBinaryStream", "helpers.getBinaryMetadata", "helpers.createDeferredPromise", "helpers.httpRequest"];