@n8n/task-runner 1.3.0 → 1.5.0
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/build.tsbuildinfo +1 -1
- package/dist/config/base-runner-config.d.ts +6 -0
- package/dist/config/base-runner-config.js +42 -0
- package/dist/config/base-runner-config.js.map +1 -0
- package/dist/config/js-runner-config.d.ts +4 -0
- package/dist/config/js-runner-config.js +32 -0
- package/dist/config/js-runner-config.js.map +1 -0
- package/dist/config/main-config.d.ts +6 -0
- package/dist/config/main-config.js +30 -0
- package/dist/config/main-config.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/js-task-runner/built-ins-parser/acorn-helpers.d.ts +6 -0
- package/dist/js-task-runner/built-ins-parser/acorn-helpers.js +23 -0
- package/dist/js-task-runner/built-ins-parser/acorn-helpers.js.map +1 -0
- package/dist/js-task-runner/built-ins-parser/built-ins-parser-state.d.ts +18 -0
- package/dist/js-task-runner/built-ins-parser/built-ins-parser-state.js +56 -0
- package/dist/js-task-runner/built-ins-parser/built-ins-parser-state.js.map +1 -0
- package/dist/js-task-runner/built-ins-parser/built-ins-parser.d.ts +10 -0
- package/dist/js-task-runner/built-ins-parser/built-ins-parser.js +89 -0
- package/dist/js-task-runner/built-ins-parser/built-ins-parser.js.map +1 -0
- package/dist/js-task-runner/js-task-runner.d.ts +4 -10
- package/dist/js-task-runner/js-task-runner.js +39 -18
- package/dist/js-task-runner/js-task-runner.js.map +1 -1
- package/dist/message-types.d.ts +177 -0
- package/dist/message-types.js +3 -0
- package/dist/message-types.js.map +1 -0
- package/dist/node-types.d.ts +3 -0
- package/dist/node-types.js +22 -0
- package/dist/node-types.js.map +1 -1
- package/dist/runner-types.d.ts +60 -157
- package/dist/runner-types.js.map +1 -1
- package/dist/start.js +7 -19
- package/dist/start.js.map +1 -1
- package/dist/task-runner.d.ts +25 -13
- package/dist/task-runner.js +41 -21
- package/dist/task-runner.js.map +1 -1
- package/package.json +22 -6
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import type { INodeTypeBaseDescription } from 'n8n-workflow';
|
|
2
|
+
import type { NeededNodeType, RPC_ALLOW_LIST, TaskDataRequestParams, TaskResultData } from './runner-types';
|
|
3
|
+
export declare namespace BrokerMessage {
|
|
4
|
+
namespace ToRunner {
|
|
5
|
+
interface InfoRequest {
|
|
6
|
+
type: 'broker:inforequest';
|
|
7
|
+
}
|
|
8
|
+
interface RunnerRegistered {
|
|
9
|
+
type: 'broker:runnerregistered';
|
|
10
|
+
}
|
|
11
|
+
interface TaskOfferAccept {
|
|
12
|
+
type: 'broker:taskofferaccept';
|
|
13
|
+
taskId: string;
|
|
14
|
+
offerId: string;
|
|
15
|
+
}
|
|
16
|
+
interface TaskCancel {
|
|
17
|
+
type: 'broker:taskcancel';
|
|
18
|
+
taskId: string;
|
|
19
|
+
reason: string;
|
|
20
|
+
}
|
|
21
|
+
interface TaskSettings {
|
|
22
|
+
type: 'broker:tasksettings';
|
|
23
|
+
taskId: string;
|
|
24
|
+
settings: unknown;
|
|
25
|
+
}
|
|
26
|
+
interface RPCResponse {
|
|
27
|
+
type: 'broker:rpcresponse';
|
|
28
|
+
callId: string;
|
|
29
|
+
taskId: string;
|
|
30
|
+
status: 'success' | 'error';
|
|
31
|
+
data: unknown;
|
|
32
|
+
}
|
|
33
|
+
interface TaskDataResponse {
|
|
34
|
+
type: 'broker:taskdataresponse';
|
|
35
|
+
taskId: string;
|
|
36
|
+
requestId: string;
|
|
37
|
+
data: unknown;
|
|
38
|
+
}
|
|
39
|
+
interface NodeTypes {
|
|
40
|
+
type: 'broker:nodetypes';
|
|
41
|
+
taskId: string;
|
|
42
|
+
requestId: string;
|
|
43
|
+
nodeTypes: INodeTypeBaseDescription[];
|
|
44
|
+
}
|
|
45
|
+
type All = InfoRequest | TaskOfferAccept | TaskCancel | TaskSettings | RunnerRegistered | RPCResponse | TaskDataResponse | NodeTypes;
|
|
46
|
+
}
|
|
47
|
+
namespace ToRequester {
|
|
48
|
+
interface TaskReady {
|
|
49
|
+
type: 'broker:taskready';
|
|
50
|
+
requestId: string;
|
|
51
|
+
taskId: string;
|
|
52
|
+
}
|
|
53
|
+
interface TaskDone {
|
|
54
|
+
type: 'broker:taskdone';
|
|
55
|
+
taskId: string;
|
|
56
|
+
data: TaskResultData;
|
|
57
|
+
}
|
|
58
|
+
interface TaskError {
|
|
59
|
+
type: 'broker:taskerror';
|
|
60
|
+
taskId: string;
|
|
61
|
+
error: unknown;
|
|
62
|
+
}
|
|
63
|
+
interface TaskDataRequest {
|
|
64
|
+
type: 'broker:taskdatarequest';
|
|
65
|
+
taskId: string;
|
|
66
|
+
requestId: string;
|
|
67
|
+
requestParams: TaskDataRequestParams;
|
|
68
|
+
}
|
|
69
|
+
interface NodeTypesRequest {
|
|
70
|
+
type: 'broker:nodetypesrequest';
|
|
71
|
+
taskId: string;
|
|
72
|
+
requestId: string;
|
|
73
|
+
requestParams: NeededNodeType[];
|
|
74
|
+
}
|
|
75
|
+
interface RPC {
|
|
76
|
+
type: 'broker:rpc';
|
|
77
|
+
callId: string;
|
|
78
|
+
taskId: string;
|
|
79
|
+
name: (typeof RPC_ALLOW_LIST)[number];
|
|
80
|
+
params: unknown[];
|
|
81
|
+
}
|
|
82
|
+
type All = TaskReady | TaskDone | TaskError | TaskDataRequest | NodeTypesRequest | RPC;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export declare namespace RequesterMessage {
|
|
86
|
+
namespace ToBroker {
|
|
87
|
+
interface TaskSettings {
|
|
88
|
+
type: 'requester:tasksettings';
|
|
89
|
+
taskId: string;
|
|
90
|
+
settings: unknown;
|
|
91
|
+
}
|
|
92
|
+
interface TaskCancel {
|
|
93
|
+
type: 'requester:taskcancel';
|
|
94
|
+
taskId: string;
|
|
95
|
+
reason: string;
|
|
96
|
+
}
|
|
97
|
+
interface TaskDataResponse {
|
|
98
|
+
type: 'requester:taskdataresponse';
|
|
99
|
+
taskId: string;
|
|
100
|
+
requestId: string;
|
|
101
|
+
data: unknown;
|
|
102
|
+
}
|
|
103
|
+
interface NodeTypesResponse {
|
|
104
|
+
type: 'requester:nodetypesresponse';
|
|
105
|
+
taskId: string;
|
|
106
|
+
requestId: string;
|
|
107
|
+
nodeTypes: INodeTypeBaseDescription[];
|
|
108
|
+
}
|
|
109
|
+
interface RPCResponse {
|
|
110
|
+
type: 'requester:rpcresponse';
|
|
111
|
+
taskId: string;
|
|
112
|
+
callId: string;
|
|
113
|
+
status: 'success' | 'error';
|
|
114
|
+
data: unknown;
|
|
115
|
+
}
|
|
116
|
+
interface TaskRequest {
|
|
117
|
+
type: 'requester:taskrequest';
|
|
118
|
+
requestId: string;
|
|
119
|
+
taskType: string;
|
|
120
|
+
}
|
|
121
|
+
type All = TaskSettings | TaskCancel | RPCResponse | TaskDataResponse | NodeTypesResponse | TaskRequest;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
export declare namespace RunnerMessage {
|
|
125
|
+
namespace ToBroker {
|
|
126
|
+
interface Info {
|
|
127
|
+
type: 'runner:info';
|
|
128
|
+
name: string;
|
|
129
|
+
types: string[];
|
|
130
|
+
}
|
|
131
|
+
interface TaskAccepted {
|
|
132
|
+
type: 'runner:taskaccepted';
|
|
133
|
+
taskId: string;
|
|
134
|
+
}
|
|
135
|
+
interface TaskRejected {
|
|
136
|
+
type: 'runner:taskrejected';
|
|
137
|
+
taskId: string;
|
|
138
|
+
reason: string;
|
|
139
|
+
}
|
|
140
|
+
interface TaskDone {
|
|
141
|
+
type: 'runner:taskdone';
|
|
142
|
+
taskId: string;
|
|
143
|
+
data: TaskResultData;
|
|
144
|
+
}
|
|
145
|
+
interface TaskError {
|
|
146
|
+
type: 'runner:taskerror';
|
|
147
|
+
taskId: string;
|
|
148
|
+
error: unknown;
|
|
149
|
+
}
|
|
150
|
+
interface TaskOffer {
|
|
151
|
+
type: 'runner:taskoffer';
|
|
152
|
+
offerId: string;
|
|
153
|
+
taskType: string;
|
|
154
|
+
validFor: number;
|
|
155
|
+
}
|
|
156
|
+
interface TaskDataRequest {
|
|
157
|
+
type: 'runner:taskdatarequest';
|
|
158
|
+
taskId: string;
|
|
159
|
+
requestId: string;
|
|
160
|
+
requestParams: TaskDataRequestParams;
|
|
161
|
+
}
|
|
162
|
+
interface NodeTypesRequest {
|
|
163
|
+
type: 'runner:nodetypesrequest';
|
|
164
|
+
taskId: string;
|
|
165
|
+
requestId: string;
|
|
166
|
+
requestParams: NeededNodeType[];
|
|
167
|
+
}
|
|
168
|
+
interface RPC {
|
|
169
|
+
type: 'runner:rpc';
|
|
170
|
+
callId: string;
|
|
171
|
+
taskId: string;
|
|
172
|
+
name: (typeof RPC_ALLOW_LIST)[number];
|
|
173
|
+
params: unknown[];
|
|
174
|
+
}
|
|
175
|
+
type All = Info | TaskDone | TaskError | TaskAccepted | TaskRejected | TaskOffer | RPC | TaskDataRequest | NodeTypesRequest;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-types.js","sourceRoot":"","sources":["../src/message-types.ts"],"names":[],"mappings":""}
|
package/dist/node-types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type IDataObject, type INodeType, type INodeTypeDescription, type INodeTypes, type IVersionedNodeType } from 'n8n-workflow';
|
|
2
|
+
import type { NeededNodeType } from './runner-types';
|
|
2
3
|
export declare const DEFAULT_NODETYPE_VERSION = 1;
|
|
3
4
|
export declare class TaskRunnerNodeTypes implements INodeTypes {
|
|
4
5
|
private nodeTypesByVersion;
|
|
@@ -7,4 +8,6 @@ export declare class TaskRunnerNodeTypes implements INodeTypes {
|
|
|
7
8
|
getByName(_nodeType: string): INodeType | IVersionedNodeType;
|
|
8
9
|
getByNameAndVersion(nodeType: string, version?: number): INodeType;
|
|
9
10
|
getKnownTypes(): IDataObject;
|
|
11
|
+
addNodeTypeDescriptions(nodeTypeDescriptions: INodeTypeDescription[]): void;
|
|
12
|
+
onlyUnknown(nodeTypes: NeededNodeType[]): NeededNodeType[];
|
|
10
13
|
}
|
package/dist/node-types.js
CHANGED
|
@@ -40,6 +40,28 @@ class TaskRunnerNodeTypes {
|
|
|
40
40
|
getKnownTypes() {
|
|
41
41
|
throw new n8n_workflow_1.ApplicationError('Unimplemented `getKnownTypes`', { level: 'error' });
|
|
42
42
|
}
|
|
43
|
+
addNodeTypeDescriptions(nodeTypeDescriptions) {
|
|
44
|
+
const newNodeTypes = this.parseNodeTypes(nodeTypeDescriptions);
|
|
45
|
+
for (const [name, newVersions] of newNodeTypes.entries()) {
|
|
46
|
+
if (!this.nodeTypesByVersion.has(name)) {
|
|
47
|
+
this.nodeTypesByVersion.set(name, newVersions);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
const existingVersions = this.nodeTypesByVersion.get(name);
|
|
51
|
+
for (const [version, nodeType] of newVersions.entries()) {
|
|
52
|
+
existingVersions.set(version, nodeType);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
onlyUnknown(nodeTypes) {
|
|
58
|
+
return nodeTypes.filter(({ name, version }) => {
|
|
59
|
+
const existingVersions = this.nodeTypesByVersion.get(name);
|
|
60
|
+
if (!existingVersions)
|
|
61
|
+
return true;
|
|
62
|
+
return !existingVersions.has(version);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
43
65
|
}
|
|
44
66
|
exports.TaskRunnerNodeTypes = TaskRunnerNodeTypes;
|
|
45
67
|
//# sourceMappingURL=node-types.js.map
|
package/dist/node-types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-types.js","sourceRoot":"","sources":["../src/node-types.ts"],"names":[],"mappings":";;;AAAA,+CAOsB;
|
|
1
|
+
{"version":3,"file":"node-types.js","sourceRoot":"","sources":["../src/node-types.ts"],"names":[],"mappings":";;;AAAA,+CAOsB;AAMT,QAAA,wBAAw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O,IAAI,CAAC;YAEnC,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AA5ED,kDA4EC"}
|
package/dist/runner-types.d.ts
CHANGED
|
@@ -1,164 +1,67 @@
|
|
|
1
|
-
import type { INodeExecutionData,
|
|
2
|
-
export
|
|
1
|
+
import type { EnvProviderState, IDataObject, IExecuteData, IExecuteFunctions, INode, INodeExecutionData, INodeParameters, IRunExecutionData, ITaskDataConnections, IWorkflowExecuteAdditionalData, Workflow, WorkflowExecuteMode, WorkflowParameters } from 'n8n-workflow';
|
|
2
|
+
export interface TaskDataRequestParams {
|
|
3
|
+
dataOfNodes: string[] | 'all';
|
|
4
|
+
prevNode: boolean;
|
|
5
|
+
input: boolean;
|
|
6
|
+
env: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface DataRequestResponse {
|
|
9
|
+
workflow: Omit<WorkflowParameters, 'nodeTypes'>;
|
|
10
|
+
inputData: ITaskDataConnections;
|
|
11
|
+
node: INode;
|
|
12
|
+
runExecutionData: IRunExecutionData;
|
|
13
|
+
runIndex: number;
|
|
14
|
+
itemIndex: number;
|
|
15
|
+
activeNodeName: string;
|
|
16
|
+
connectionInputData: INodeExecutionData[];
|
|
17
|
+
siblingParameters: INodeParameters;
|
|
18
|
+
mode: WorkflowExecuteMode;
|
|
19
|
+
envProviderState: EnvProviderState;
|
|
20
|
+
executeData?: IExecuteData;
|
|
21
|
+
defaultReturnRunIndex: number;
|
|
22
|
+
selfData: IDataObject;
|
|
23
|
+
contextNodeName: string;
|
|
24
|
+
additionalData: PartialAdditionalData;
|
|
25
|
+
}
|
|
3
26
|
export interface TaskResultData {
|
|
4
27
|
result: INodeExecutionData[];
|
|
5
28
|
customData?: Record<string, string>;
|
|
6
29
|
}
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
interface TaskSettings {
|
|
26
|
-
type: 'broker:tasksettings';
|
|
27
|
-
taskId: string;
|
|
28
|
-
settings: unknown;
|
|
29
|
-
}
|
|
30
|
-
interface RPCResponse {
|
|
31
|
-
type: 'broker:rpcresponse';
|
|
32
|
-
callId: string;
|
|
33
|
-
taskId: string;
|
|
34
|
-
status: 'success' | 'error';
|
|
35
|
-
data: unknown;
|
|
36
|
-
}
|
|
37
|
-
interface TaskDataResponse {
|
|
38
|
-
type: 'broker:taskdataresponse';
|
|
39
|
-
taskId: string;
|
|
40
|
-
requestId: string;
|
|
41
|
-
data: unknown;
|
|
42
|
-
}
|
|
43
|
-
interface NodeTypes {
|
|
44
|
-
type: 'broker:nodetypes';
|
|
45
|
-
nodeTypes: INodeTypeBaseDescription[];
|
|
46
|
-
}
|
|
47
|
-
type All = InfoRequest | TaskOfferAccept | TaskCancel | TaskSettings | RunnerRegistered | RPCResponse | TaskDataResponse | NodeTypes;
|
|
48
|
-
}
|
|
49
|
-
namespace ToRequester {
|
|
50
|
-
interface TaskReady {
|
|
51
|
-
type: 'broker:taskready';
|
|
52
|
-
requestId: string;
|
|
53
|
-
taskId: string;
|
|
54
|
-
}
|
|
55
|
-
interface TaskDone {
|
|
56
|
-
type: 'broker:taskdone';
|
|
57
|
-
taskId: string;
|
|
58
|
-
data: TaskResultData;
|
|
59
|
-
}
|
|
60
|
-
interface TaskError {
|
|
61
|
-
type: 'broker:taskerror';
|
|
62
|
-
taskId: string;
|
|
63
|
-
error: unknown;
|
|
64
|
-
}
|
|
65
|
-
interface TaskDataRequest {
|
|
66
|
-
type: 'broker:taskdatarequest';
|
|
67
|
-
taskId: string;
|
|
68
|
-
requestId: string;
|
|
69
|
-
requestType: DataRequestType;
|
|
70
|
-
param?: string;
|
|
71
|
-
}
|
|
72
|
-
interface RPC {
|
|
73
|
-
type: 'broker:rpc';
|
|
74
|
-
callId: string;
|
|
75
|
-
taskId: string;
|
|
76
|
-
name: (typeof RPC_ALLOW_LIST)[number];
|
|
77
|
-
params: unknown[];
|
|
78
|
-
}
|
|
79
|
-
type All = TaskReady | TaskDone | TaskError | TaskDataRequest | RPC;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
export declare namespace RequesterMessage {
|
|
83
|
-
namespace ToN8n {
|
|
84
|
-
interface TaskSettings {
|
|
85
|
-
type: 'requester:tasksettings';
|
|
86
|
-
taskId: string;
|
|
87
|
-
settings: unknown;
|
|
88
|
-
}
|
|
89
|
-
interface TaskCancel {
|
|
90
|
-
type: 'requester:taskcancel';
|
|
91
|
-
taskId: string;
|
|
92
|
-
reason: string;
|
|
93
|
-
}
|
|
94
|
-
interface TaskDataResponse {
|
|
95
|
-
type: 'requester:taskdataresponse';
|
|
96
|
-
taskId: string;
|
|
97
|
-
requestId: string;
|
|
98
|
-
data: unknown;
|
|
99
|
-
}
|
|
100
|
-
interface RPCResponse {
|
|
101
|
-
type: 'requester:rpcresponse';
|
|
102
|
-
taskId: string;
|
|
103
|
-
callId: string;
|
|
104
|
-
status: 'success' | 'error';
|
|
105
|
-
data: unknown;
|
|
106
|
-
}
|
|
107
|
-
interface TaskRequest {
|
|
108
|
-
type: 'requester:taskrequest';
|
|
109
|
-
requestId: string;
|
|
110
|
-
taskType: string;
|
|
111
|
-
}
|
|
112
|
-
type All = TaskSettings | TaskCancel | RPCResponse | TaskDataResponse | TaskRequest;
|
|
113
|
-
}
|
|
30
|
+
export interface TaskData {
|
|
31
|
+
executeFunctions: IExecuteFunctions;
|
|
32
|
+
inputData: ITaskDataConnections;
|
|
33
|
+
node: INode;
|
|
34
|
+
workflow: Workflow;
|
|
35
|
+
runExecutionData: IRunExecutionData;
|
|
36
|
+
runIndex: number;
|
|
37
|
+
itemIndex: number;
|
|
38
|
+
activeNodeName: string;
|
|
39
|
+
connectionInputData: INodeExecutionData[];
|
|
40
|
+
siblingParameters: INodeParameters;
|
|
41
|
+
mode: WorkflowExecuteMode;
|
|
42
|
+
envProviderState: EnvProviderState;
|
|
43
|
+
executeData?: IExecuteData;
|
|
44
|
+
defaultReturnRunIndex: number;
|
|
45
|
+
selfData: IDataObject;
|
|
46
|
+
contextNodeName: string;
|
|
47
|
+
additionalData: IWorkflowExecuteAdditionalData;
|
|
114
48
|
}
|
|
115
|
-
export
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
taskId: string;
|
|
129
|
-
reason: string;
|
|
130
|
-
}
|
|
131
|
-
interface TaskDone {
|
|
132
|
-
type: 'runner:taskdone';
|
|
133
|
-
taskId: string;
|
|
134
|
-
data: TaskResultData;
|
|
135
|
-
}
|
|
136
|
-
interface TaskError {
|
|
137
|
-
type: 'runner:taskerror';
|
|
138
|
-
taskId: string;
|
|
139
|
-
error: unknown;
|
|
140
|
-
}
|
|
141
|
-
interface TaskOffer {
|
|
142
|
-
type: 'runner:taskoffer';
|
|
143
|
-
offerId: string;
|
|
144
|
-
taskType: string;
|
|
145
|
-
validFor: number;
|
|
146
|
-
}
|
|
147
|
-
interface TaskDataRequest {
|
|
148
|
-
type: 'runner:taskdatarequest';
|
|
149
|
-
taskId: string;
|
|
150
|
-
requestId: string;
|
|
151
|
-
requestType: DataRequestType;
|
|
152
|
-
param?: string;
|
|
153
|
-
}
|
|
154
|
-
interface RPC {
|
|
155
|
-
type: 'runner:rpc';
|
|
156
|
-
callId: string;
|
|
157
|
-
taskId: string;
|
|
158
|
-
name: (typeof RPC_ALLOW_LIST)[number];
|
|
159
|
-
params: unknown[];
|
|
160
|
-
}
|
|
161
|
-
type All = Info | TaskDone | TaskError | TaskAccepted | TaskRejected | TaskOffer | RPC | TaskDataRequest;
|
|
162
|
-
}
|
|
49
|
+
export interface PartialAdditionalData {
|
|
50
|
+
executionId?: string;
|
|
51
|
+
restartExecutionId?: string;
|
|
52
|
+
restApiUrl: string;
|
|
53
|
+
instanceBaseUrl: string;
|
|
54
|
+
formWaitingBaseUrl: string;
|
|
55
|
+
webhookBaseUrl: string;
|
|
56
|
+
webhookWaitingBaseUrl: string;
|
|
57
|
+
webhookTestBaseUrl: string;
|
|
58
|
+
currentNodeParameters?: INodeParameters;
|
|
59
|
+
executionTimeoutTimestamp?: number;
|
|
60
|
+
userId?: string;
|
|
61
|
+
variables: IDataObject;
|
|
163
62
|
}
|
|
164
63
|
export declare const RPC_ALLOW_LIST: readonly ["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", "logNodeOutput"];
|
|
64
|
+
export type NeededNodeType = {
|
|
65
|
+
name: string;
|
|
66
|
+
version: number;
|
|
67
|
+
};
|
package/dist/runner-types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner-types.js","sourceRoot":"","sources":["../src/runner-types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"runner-types.js","sourceRoot":"","sources":["../src/runner-types.ts"],"names":[],"mappings":";;;AAyFa,QAAA,cAAc,GAAG;IAC7B,uCAAuC;IACvC,4CAA4C;IAI5C,6BAA6B;IAG7B,sBAAsB;IACtB,0BAA0B;IAE1B,4BAA4B;IAC5B,2BAA2B;IAC3B,6BAA6B;IAC7B,wBAAwB;IACxB,wBAAwB;IAGxB,yBAAyB;IACzB,2BAA2B;IAC3B,+BAA+B;IAC/B,qBAAqB;IACrB,eAAe;CACN,CAAC"}
|
package/dist/start.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
7
|
+
const typedi_1 = __importDefault(require("typedi"));
|
|
8
|
+
const main_config_1 = require("./config/main-config");
|
|
4
9
|
const js_task_runner_1 = require("./js-task-runner/js-task-runner");
|
|
5
10
|
let runner;
|
|
6
11
|
let isShuttingDown = false;
|
|
7
|
-
function readAndParseConfig() {
|
|
8
|
-
const grantToken = process.env.N8N_RUNNERS_GRANT_TOKEN;
|
|
9
|
-
if (!grantToken) {
|
|
10
|
-
throw new n8n_workflow_1.ApplicationError('Missing N8N_RUNNERS_GRANT_TOKEN environment variable');
|
|
11
|
-
}
|
|
12
|
-
return {
|
|
13
|
-
n8nUri: process.env.N8N_RUNNERS_N8N_URI ?? '127.0.0.1:5679',
|
|
14
|
-
grantToken,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
12
|
function createSignalHandler(signal) {
|
|
18
13
|
return async function onSignal() {
|
|
19
14
|
if (isShuttingDown) {
|
|
@@ -37,15 +32,8 @@ function createSignalHandler(signal) {
|
|
|
37
32
|
};
|
|
38
33
|
}
|
|
39
34
|
void (async function start() {
|
|
40
|
-
const config =
|
|
41
|
-
|
|
42
|
-
runner = new js_task_runner_1.JsTaskRunner({
|
|
43
|
-
wsUrl,
|
|
44
|
-
grantToken: config.grantToken,
|
|
45
|
-
maxConcurrency: 5,
|
|
46
|
-
allowedBuiltInModules: process.env.NODE_FUNCTION_ALLOW_BUILTIN,
|
|
47
|
-
allowedExternalModules: process.env.NODE_FUNCTION_ALLOW_EXTERNAL,
|
|
48
|
-
});
|
|
35
|
+
const config = typedi_1.default.get(main_config_1.MainConfig);
|
|
36
|
+
runner = new js_task_runner_1.JsTaskRunner(config);
|
|
49
37
|
process.on('SIGINT', createSignalHandler('SIGINT'));
|
|
50
38
|
process.on('SIGTERM', createSignalHandler('SIGTERM'));
|
|
51
39
|
})().catch((e) => {
|
package/dist/start.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../src/start.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../src/start.ts"],"names":[],"mappings":";;;;;AAAA,+CAA2C;AAC3C,oDAA+B;AAE/B,sDAAkD;AAClD,oEAA+D;AAE/D,IAAI,MAAgC,CAAC;AACrC,IAAI,cAAc,GAAG,KAAK,CAAC;AAE3B,SAAS,mBAAmB,CAAC,MAAc;IAC1C,OAAO,KAAK,UAAU,QAAQ;QAC7B,IAAI,cAAc,EAAE,CAAC;YACpB,OAAO;QACR,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,YAAY,MAAM,2BAA2B,CAAC,CAAC;QAE3D,cAAc,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC;YACJ,IAAI,MAAM,EAAE,CAAC;gBACZ,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;gBACpB,MAAM,GAAG,SAAS,CAAC;YACpB,CAAC;QACF,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,MAAM,KAAK,GAAG,IAAA,0BAAW,EAAC,CAAC,CAAC,CAAC;YAC7B,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QACxD,CAAC;gBAAS,CAAC;YACV,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACjB,CAAC;IACF,CAAC,CAAC;AACH,CAAC;AAED,KAAK,CAAC,KAAK,UAAU,KAAK;IACzB,MAAM,MAAM,GAAG,gBAAS,CAAC,GAAG,CAAC,wBAAU,CAAC,CAAC;IAEzC,MAAM,GAAG,IAAI,6BAAY,CAAC,MAAM,CAAC,CAAC;IAElC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC;IACpD,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC,CAAC;AACvD,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;IAChB,MAAM,KAAK,GAAG,IAAA,0BAAW,EAAC,CAAC,CAAC,CAAC;IAC7B,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC,CAAC"}
|
package/dist/task-runner.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { type INodeTypeDescription } from 'n8n-workflow';
|
|
2
1
|
import { WebSocket } from 'ws';
|
|
2
|
+
import type { BaseRunnerConfig } from './config/base-runner-config';
|
|
3
|
+
import type { BrokerMessage, RunnerMessage } from './message-types';
|
|
3
4
|
import { TaskRunnerNodeTypes } from './node-types';
|
|
4
|
-
import { type
|
|
5
|
+
import { type TaskResultData } from './runner-types';
|
|
5
6
|
export interface Task<T = unknown> {
|
|
6
7
|
taskId: string;
|
|
7
8
|
settings?: T;
|
|
@@ -17,6 +18,11 @@ interface DataRequest {
|
|
|
17
18
|
resolve: (data: unknown) => void;
|
|
18
19
|
reject: (error: unknown) => void;
|
|
19
20
|
}
|
|
21
|
+
interface NodeTypesRequest {
|
|
22
|
+
requestId: string;
|
|
23
|
+
resolve: (data: unknown) => void;
|
|
24
|
+
reject: (error: unknown) => void;
|
|
25
|
+
}
|
|
20
26
|
interface RPCCall {
|
|
21
27
|
callId: string;
|
|
22
28
|
resolve: (data: unknown) => void;
|
|
@@ -25,10 +31,11 @@ interface RPCCall {
|
|
|
25
31
|
export interface RPCCallObject {
|
|
26
32
|
[name: string]: ((...args: unknown[]) => Promise<unknown>) | RPCCallObject;
|
|
27
33
|
}
|
|
28
|
-
export
|
|
34
|
+
export interface TaskRunnerOpts extends BaseRunnerConfig {
|
|
29
35
|
taskType: string;
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
name?: string;
|
|
37
|
+
}
|
|
38
|
+
export declare abstract class TaskRunner {
|
|
32
39
|
id: string;
|
|
33
40
|
ws: WebSocket;
|
|
34
41
|
canSendOffers: boolean;
|
|
@@ -36,28 +43,33 @@ export declare abstract class TaskRunner {
|
|
|
36
43
|
offerInterval: NodeJS.Timeout | undefined;
|
|
37
44
|
openOffers: Map<TaskOffer['offerId'], TaskOffer>;
|
|
38
45
|
dataRequests: Map<DataRequest['requestId'], DataRequest>;
|
|
46
|
+
nodeTypesRequests: Map<NodeTypesRequest['requestId'], NodeTypesRequest>;
|
|
39
47
|
rpcCalls: Map<RPCCall['callId'], RPCCall>;
|
|
40
48
|
nodeTypes: TaskRunnerNodeTypes;
|
|
41
|
-
|
|
49
|
+
taskType: string;
|
|
50
|
+
maxConcurrency: number;
|
|
51
|
+
name: string;
|
|
52
|
+
constructor(opts: TaskRunnerOpts);
|
|
42
53
|
private receiveMessage;
|
|
43
54
|
private stopTaskOffers;
|
|
44
55
|
private startTaskOffers;
|
|
45
56
|
deleteStaleOffers(): void;
|
|
46
57
|
sendOffers(): void;
|
|
47
|
-
send(message: RunnerMessage.
|
|
48
|
-
onMessage(message:
|
|
49
|
-
setNodeTypes(nodeTypes: INodeTypeDescription[]): void;
|
|
58
|
+
send(message: RunnerMessage.ToBroker.All): void;
|
|
59
|
+
onMessage(message: BrokerMessage.ToRunner.All): void;
|
|
50
60
|
processDataResponse(requestId: string, data: unknown): void;
|
|
61
|
+
processNodeTypesResponse(requestId: string, nodeTypes: unknown): void;
|
|
51
62
|
hasOpenTasks(): boolean;
|
|
52
63
|
offerAccepted(offerId: string, taskId: string): void;
|
|
53
64
|
taskCancelled(taskId: string): void;
|
|
54
65
|
taskErrored(taskId: string, error: unknown): void;
|
|
55
|
-
taskDone(taskId: string, data: RunnerMessage.
|
|
66
|
+
taskDone(taskId: string, data: RunnerMessage.ToBroker.TaskDone['data']): void;
|
|
56
67
|
receivedSettings(taskId: string, settings: unknown): Promise<void>;
|
|
57
68
|
executeTask(_task: Task): Promise<TaskResultData>;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
requestNodeTypes<T = unknown>(taskId: Task['taskId'], requestParams: RunnerMessage.ToBroker.NodeTypesRequest['requestParams']): Promise<T>;
|
|
70
|
+
requestData<T = unknown>(taskId: Task['taskId'], requestParams: RunnerMessage.ToBroker.TaskDataRequest['requestParams']): Promise<T>;
|
|
71
|
+
makeRpcCall(taskId: string, name: RunnerMessage.ToBroker.RPC['name'], params: unknown[]): Promise<unknown>;
|
|
72
|
+
handleRpcResponse(callId: string, status: BrokerMessage.ToRunner.RPCResponse['status'], data: unknown): void;
|
|
61
73
|
buildRpcCallObject(taskId: string): RPCCallObject;
|
|
62
74
|
stop(): Promise<void>;
|
|
63
75
|
private closeConnection;
|