mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
ci: @n8n/task-runner package setup (no-changelog) (#11067)
This commit is contained in:
committed by
GitHub
parent
4546649c61
commit
49c71469f4
@@ -1,59 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@n8n/task-runner",
|
|
||||||
"private": true,
|
|
||||||
"version": "0.1.0",
|
|
||||||
"description": "",
|
|
||||||
"main": "dist/start.js",
|
|
||||||
"scripts": {
|
|
||||||
"start": "node dist/start.js",
|
|
||||||
"dev": "pnpm build && pnpm start",
|
|
||||||
"build": "tsc -p ./tsconfig.build.json",
|
|
||||||
"test": "jest",
|
|
||||||
"lint": "eslint .",
|
|
||||||
"lintfix": "eslint . --fix",
|
|
||||||
"watch": "tsc -w -p ./tsconfig.build.json"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=20.15",
|
|
||||||
"pnpm": ">=9.5"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"src/",
|
|
||||||
"dist/",
|
|
||||||
"package.json",
|
|
||||||
"tsconfig.json"
|
|
||||||
],
|
|
||||||
"main": "dist/start.js",
|
|
||||||
"module": "src/start.ts",
|
|
||||||
"types": "dist/start.d.ts",
|
|
||||||
"packageManager": "pnpm@9.6.0",
|
|
||||||
"devDependencies": {
|
|
||||||
"@n8n_io/eslint-config": "^0.0.2",
|
|
||||||
"@types/jest": "^29.5.0",
|
|
||||||
"@types/node": "^18.13.0",
|
|
||||||
"@types/ws": "^8.5.12",
|
|
||||||
"@typescript-eslint/eslint-plugin": "^6.1.0",
|
|
||||||
"eslint": "^8.38.0",
|
|
||||||
"eslint-config-airbnb-typescript": "^17.1.0",
|
|
||||||
"eslint-config-prettier": "^8.8.0",
|
|
||||||
"eslint-plugin-n8n-local-rules": "^1.0.0",
|
|
||||||
"eslint-plugin-prettier": "^5.0.0",
|
|
||||||
"eslint-plugin-unicorn": "^48.0.0",
|
|
||||||
"eslint-plugin-unused-imports": "^3.0.0",
|
|
||||||
"jest": "^29.5.0",
|
|
||||||
"nodemon": "^2.0.20",
|
|
||||||
"prettier": "^3.0.0",
|
|
||||||
"ts-jest": "^29.1.0",
|
|
||||||
"ts-node": "^10.9.1",
|
|
||||||
"tsc-alias": "^1.8.7",
|
|
||||||
"typescript": "^5.0.0"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"jmespath": "^0.16.0",
|
|
||||||
"luxon": "^3.5.0",
|
|
||||||
"n8n-workflow": "workspace:*",
|
|
||||||
"n8n-core": "workspace:*",
|
|
||||||
"nanoid": "^3.3.6",
|
|
||||||
"ws": "^8.18.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
29
packages/@n8n/task-runner/package.json
Normal file
29
packages/@n8n/task-runner/package.json
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"name": "@n8n/task-runner",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"scripts": {
|
||||||
|
"clean": "rimraf dist .turbo",
|
||||||
|
"start": "node dist/start.js",
|
||||||
|
"dev": "pnpm build && pnpm start",
|
||||||
|
"typecheck": "tsc --noEmit",
|
||||||
|
"build": "tsc -p ./tsconfig.build.json",
|
||||||
|
"format": "biome format --write src",
|
||||||
|
"format:check": "biome ci src",
|
||||||
|
"test": "echo \"Error: no tests in this package\" && exit 0",
|
||||||
|
"lint": "eslint . --quiet",
|
||||||
|
"lintfix": "eslint . --fix",
|
||||||
|
"watch": "tsc -p tsconfig.build.json --watch"
|
||||||
|
},
|
||||||
|
"main": "dist/start.js",
|
||||||
|
"module": "src/start.ts",
|
||||||
|
"types": "dist/start.d.ts",
|
||||||
|
"files": [
|
||||||
|
"dist/**/*"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"n8n-workflow": "workspace:*",
|
||||||
|
"n8n-core": "workspace:*",
|
||||||
|
"nanoid": "^3.3.6",
|
||||||
|
"ws": "^8.18.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { ApplicationError } from 'n8n-workflow';
|
||||||
import * as a from 'node:assert/strict';
|
import * as a from 'node:assert/strict';
|
||||||
|
|
||||||
export type AuthOpts = {
|
export type AuthOpts = {
|
||||||
@@ -23,7 +24,9 @@ export async function authenticate(opts: AuthOpts) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`Invalid response status ${response.status}: ${await response.text()}`);
|
throw new ApplicationError(
|
||||||
|
`Invalid response status ${response.status}: ${await response.text()}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = (await response.json()) as { data: { token: string } };
|
const { data } = (await response.json()) as { data: { token: string } };
|
||||||
@@ -34,9 +37,11 @@ export async function authenticate(opts: AuthOpts) {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
const error = e as Error;
|
const error = e as Error;
|
||||||
|
throw new ApplicationError(
|
||||||
throw new Error(`Could not connect to n8n message broker ${opts.n8nUri}: ${error.message}`, {
|
`Could not connect to n8n message broker ${opts.n8nUri}: ${error.message}`,
|
||||||
|
{
|
||||||
cause: error,
|
cause: error,
|
||||||
});
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
import { runInNewContext, type Context } from 'node:vm';
|
import { getAdditionalKeys } from 'n8n-core';
|
||||||
import * as a from 'node:assert';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
type INode,
|
type INode,
|
||||||
type INodeType,
|
type INodeType,
|
||||||
@@ -8,8 +6,6 @@ import {
|
|||||||
type IWorkflowExecuteAdditionalData,
|
type IWorkflowExecuteAdditionalData,
|
||||||
WorkflowDataProxy,
|
WorkflowDataProxy,
|
||||||
type WorkflowParameters,
|
type WorkflowParameters,
|
||||||
} from 'n8n-workflow';
|
|
||||||
import {
|
|
||||||
type IDataObject,
|
type IDataObject,
|
||||||
type IExecuteData,
|
type IExecuteData,
|
||||||
type INodeExecutionData,
|
type INodeExecutionData,
|
||||||
@@ -19,7 +15,8 @@ import {
|
|||||||
Workflow,
|
Workflow,
|
||||||
type WorkflowExecuteMode,
|
type WorkflowExecuteMode,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
import { getAdditionalKeys } from 'n8n-core';
|
import * as a from 'node:assert';
|
||||||
|
import { runInNewContext, type Context } from 'node:vm';
|
||||||
|
|
||||||
import type { TaskResultData } from './runner-types';
|
import type { TaskResultData } from './runner-types';
|
||||||
import { type Task, TaskRunner } from './task-runner';
|
import { type Task, TaskRunner } from './task-runner';
|
||||||
@@ -1,10 +1,8 @@
|
|||||||
|
import { ApplicationError, ensureError } from 'n8n-workflow';
|
||||||
import * as a from 'node:assert/strict';
|
import * as a from 'node:assert/strict';
|
||||||
import { ensureError } from 'n8n-workflow';
|
|
||||||
|
|
||||||
import { JsTaskRunner } from './code';
|
|
||||||
import { authenticate } from './authenticator';
|
import { authenticate } from './authenticator';
|
||||||
|
import { JsTaskRunner } from './code';
|
||||||
let _runner: JsTaskRunner;
|
|
||||||
|
|
||||||
type Config = {
|
type Config = {
|
||||||
n8nUri: string;
|
n8nUri: string;
|
||||||
@@ -16,7 +14,7 @@ function readAndParseConfig(): Config {
|
|||||||
const authToken = process.env.N8N_RUNNERS_AUTH_TOKEN;
|
const authToken = process.env.N8N_RUNNERS_AUTH_TOKEN;
|
||||||
const grantToken = process.env.N8N_RUNNERS_GRANT_TOKEN;
|
const grantToken = process.env.N8N_RUNNERS_GRANT_TOKEN;
|
||||||
if (!authToken && !grantToken) {
|
if (!authToken && !grantToken) {
|
||||||
throw new Error(
|
throw new ApplicationError(
|
||||||
'Missing task runner authentication. Use either N8N_RUNNERS_AUTH_TOKEN or N8N_RUNNERS_GRANT_TOKEN to configure it',
|
'Missing task runner authentication. Use either N8N_RUNNERS_AUTH_TOKEN or N8N_RUNNERS_GRANT_TOKEN to configure it',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -42,7 +40,7 @@ void (async function start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const wsUrl = `ws://${config.n8nUri}/runners/_ws`;
|
const wsUrl = `ws://${config.n8nUri}/runners/_ws`;
|
||||||
_runner = new JsTaskRunner('javascript', wsUrl, grantToken, 5);
|
new JsTaskRunner('javascript', wsUrl, grantToken, 5);
|
||||||
})().catch((e) => {
|
})().catch((e) => {
|
||||||
const error = ensureError(e);
|
const error = ensureError(e);
|
||||||
console.error('Task runner failed to start', { error });
|
console.error('Task runner failed to start', { error });
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { URL } from 'node:url';
|
import { ApplicationError, ensureError } from 'n8n-workflow';
|
||||||
import { nanoid } from 'nanoid';
|
import { nanoid } from 'nanoid';
|
||||||
|
import { URL } from 'node:url';
|
||||||
import { type MessageEvent, WebSocket } from 'ws';
|
import { type MessageEvent, WebSocket } from 'ws';
|
||||||
import { ensureError } from 'n8n-workflow';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
RPC_ALLOW_LIST,
|
RPC_ALLOW_LIST,
|
||||||
@@ -267,7 +267,7 @@ export abstract class TaskRunner {
|
|||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
async executeTask(_task: Task): Promise<TaskResultData> {
|
async executeTask(_task: Task): Promise<TaskResultData> {
|
||||||
throw new Error('Unimplemented');
|
throw new ApplicationError('Unimplemented');
|
||||||
}
|
}
|
||||||
|
|
||||||
async requestData<T = unknown>(
|
async requestData<T = unknown>(
|
||||||
@@ -354,7 +354,7 @@ export abstract class TaskRunner {
|
|||||||
obj = obj[s];
|
obj = obj[s];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
obj[s] = async (...args: unknown[]) => this.makeRpcCall(taskId, r, args);
|
obj[s] = async (...args: unknown[]) => await this.makeRpcCall(taskId, r, args);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return rpcObject;
|
return rpcObject;
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
{
|
{
|
||||||
"extends": ["./tsconfig.json", "../../../tsconfig.build.json"],
|
"extends": ["./tsconfig.json", "../../../tsconfig.build.json"],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"composite": true,
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"tsBuildInfoFile": "dist/build.tsbuildinfo"
|
"tsBuildInfoFile": "dist/build.tsbuildinfo"
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts"],
|
"include": ["src/**/*.ts"],
|
||||||
"exclude": ["test/**", "src/**/__tests__/**"]
|
"exclude": ["src/**/__tests__/**"]
|
||||||
}
|
}
|
||||||
@@ -2,13 +2,11 @@
|
|||||||
"extends": ["../../../tsconfig.json", "../../../tsconfig.backend.json"],
|
"extends": ["../../../tsconfig.json", "../../../tsconfig.backend.json"],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"rootDir": ".",
|
"rootDir": ".",
|
||||||
"emitDecoratorMetadata": true,
|
|
||||||
"experimentalDecorators": true,
|
|
||||||
"baseUrl": "src",
|
"baseUrl": "src",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["./*"]
|
"@/*": ["./*"]
|
||||||
},
|
},
|
||||||
"tsBuildInfoFile": "dist/typecheck.tsbuildinfo"
|
"tsBuildInfoFile": "dist/typecheck.tsbuildinfo"
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts", "test/**/*.ts"]
|
"include": ["src/**/*.ts"]
|
||||||
}
|
}
|
||||||
553
pnpm-lock.yaml
generated
553
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user