feat: Add proper INodeTypes polyfill for Task Runner (no-changelog) (#11333)

This commit is contained in:
Val
2024-10-22 15:19:32 +01:00
committed by GitHub
parent 00a48b781e
commit cade9b2d91
9 changed files with 202 additions and 21 deletions

View File

@@ -1,8 +1,9 @@
import { ApplicationError } from 'n8n-workflow';
import { ApplicationError, type INodeTypeDescription } from 'n8n-workflow';
import { nanoid } from 'nanoid';
import { URL } from 'node:url';
import { type MessageEvent, WebSocket } from 'ws';
import { TaskRunnerNodeTypes } from './node-types';
import {
RPC_ALLOW_LIST,
type RunnerMessage,
@@ -58,6 +59,8 @@ export abstract class TaskRunner {
rpcCalls: Map<RPCCall['callId'], RPCCall> = new Map();
nodeTypes: TaskRunnerNodeTypes = new TaskRunnerNodeTypes([]);
constructor(
public taskType: string,
wsUrl: string,
@@ -158,9 +161,17 @@ export abstract class TaskRunner {
break;
case 'broker:rpcresponse':
this.handleRpcResponse(message.callId, message.status, message.data);
break;
case 'broker:nodetypes':
this.setNodeTypes(message.nodeTypes as unknown as INodeTypeDescription[]);
break;
}
}
setNodeTypes(nodeTypes: INodeTypeDescription[]) {
this.nodeTypes = new TaskRunnerNodeTypes(nodeTypes);
}
processDataResponse(requestId: string, data: unknown) {
const request = this.dataRequests.get(requestId);
if (!request) {