Skip to content

Commit

Permalink
Merge branch 'n8n-io:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
sutidor authored Oct 9, 2024
2 parents fab5a75 + c2adfc8 commit 0ad4e97
Show file tree
Hide file tree
Showing 76 changed files with 2,776 additions and 3,498 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"overrides": {
"@types/node": "^18.16.16",
"chokidar": "3.5.2",
"esbuild": "^0.20.2",
"esbuild": "^0.21.5",
"formidable": "3.5.1",
"pug": "^3.0.3",
"semver": "^7.5.4",
Expand Down
26 changes: 26 additions & 0 deletions packages/@n8n/config/src/configs/logging.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import { Config, Env, Nested } from '../decorators';
import { StringArray } from '../utils';

/**
* Scopes (areas of functionality) to filter logs by.
*
* `executions` -> execution lifecycle
* `license` -> license SDK
* `scaling` -> scaling mode
*/
export const LOG_SCOPES = ['executions', 'license', 'scaling'] as const;

export type LogScope = (typeof LOG_SCOPES)[number];

@Config
class FileLoggingConfig {
/**
Expand Down Expand Up @@ -44,4 +55,19 @@ export class LoggingConfig {

@Nested
file: FileLoggingConfig;

/**
* Scopes to filter logs by. Nothing is filtered by default.
*
* Currently supported log scopes:
* - `executions`
* - `license`
* - `scaling`
*
* @example
* `N8N_LOG_SCOPES=license`
* `N8N_LOG_SCOPES=license,executions`
*/
@Env('N8N_LOG_SCOPES')
scopes: StringArray<LogScope> = [];
}
3 changes: 3 additions & 0 deletions packages/@n8n/config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import { VersionNotificationsConfig } from './configs/version-notifications.conf
import { WorkflowsConfig } from './configs/workflows.config';
import { Config, Env, Nested } from './decorators';

export { LOG_SCOPES } from './configs/logging.config';
export type { LogScope } from './configs/logging.config';

@Config
export class GlobalConfig {
@Nested
Expand Down
2 changes: 1 addition & 1 deletion packages/@n8n/config/test/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,13 @@ describe('GlobalConfig', () => {
fileSizeMax: 16,
location: 'logs/n8n.log',
},
scopes: [],
},
};

it('should use all default values when no env variables are defined', () => {
process.env = {};
const config = Container.get(GlobalConfig);

expect(deepCopy(config)).toEqual(defaultConfig);
expect(mockFs.readFileSync).not.toHaveBeenCalled();
});
Expand Down
15 changes: 8 additions & 7 deletions packages/@n8n/nodes-langchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,20 @@
"@types/cheerio": "^0.22.15",
"@types/html-to-text": "^9.0.1",
"@types/json-schema": "^7.0.15",
"@types/pg": "^8.11.6",
"@types/temp": "^0.9.1",
"n8n-core": "workspace:*"
},
"dependencies": {
"@getzep/zep-cloud": "1.0.11",
"@aws-sdk/client-sso-oidc": "3.666.0",
"@getzep/zep-cloud": "1.0.12",
"@getzep/zep-js": "0.9.0",
"@google-ai/generativelanguage": "2.6.0",
"@google-cloud/resource-manager": "5.3.0",
"@google/generative-ai": "0.19.0",
"@huggingface/inference": "2.8.0",
"@langchain/anthropic": "0.3.1",
"@langchain/aws": "^0.1.0",
"@langchain/aws": "0.1.0",
"@langchain/cohere": "0.3.0",
"@langchain/community": "0.3.2",
"@langchain/core": "catalog:",
Expand All @@ -149,23 +151,22 @@
"@langchain/qdrant": "0.1.0",
"@langchain/redis": "0.1.0",
"@langchain/textsplitters": "0.1.0",
"@mozilla/readability": "^0.5.0",
"@mozilla/readability": "0.5.0",
"@n8n/typeorm": "0.3.20-12",
"@n8n/vm2": "3.9.25",
"@pinecone-database/pinecone": "3.0.3",
"@qdrant/js-client-rest": "1.11.0",
"@supabase/supabase-js": "2.45.4",
"@types/pg": "^8.11.6",
"@xata.io/client": "0.30.0",
"@xata.io/client": "0.28.4",
"basic-auth": "catalog:",
"cheerio": "1.0.0-rc.12",
"cheerio": "1.0.0",
"cohere-ai": "7.13.2",
"d3-dsv": "2.0.0",
"epub2": "3.0.2",
"form-data": "catalog:",
"generate-schema": "2.6.0",
"html-to-text": "9.0.5",
"jsdom": "^23.0.1",
"jsdom": "23.0.1",
"json-schema-to-zod": "2.1.0",
"langchain": "0.3.2",
"lodash": "catalog:",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CodeExecutionMode, IDataObject, WorkflowExecuteMode } from 'n8n-workflow';
import type { CodeExecutionMode, IDataObject } from 'n8n-workflow';

import { ValidationError } from '@/js-task-runner/errors/validation-error';
import {
Expand Down Expand Up @@ -31,65 +31,25 @@ describe('JsTaskRunner', () => {
});

describe('console', () => {
test.each<[CodeExecutionMode, WorkflowExecuteMode]>([
['runOnceForAllItems', 'cli'],
['runOnceForAllItems', 'error'],
['runOnceForAllItems', 'integrated'],
['runOnceForAllItems', 'internal'],
['runOnceForAllItems', 'retry'],
['runOnceForAllItems', 'trigger'],
['runOnceForAllItems', 'webhook'],
['runOnceForEachItem', 'cli'],
['runOnceForEachItem', 'error'],
['runOnceForEachItem', 'integrated'],
['runOnceForEachItem', 'internal'],
['runOnceForEachItem', 'retry'],
['runOnceForEachItem', 'trigger'],
['runOnceForEachItem', 'webhook'],
])(
'should make an rpc call for console log in %s mode when workflow mode is %s',
async (nodeMode, workflowMode) => {
jest.spyOn(console, 'log').mockImplementation(() => {});
test.each<[CodeExecutionMode]>([['runOnceForAllItems'], ['runOnceForEachItem']])(
'should make an rpc call for console log in %s mode',
async (nodeMode) => {
jest.spyOn(jsTaskRunner, 'makeRpcCall').mockResolvedValue(undefined);
const task = newTaskWithSettings({
code: "console.log('Hello', 'world!'); return {}",
nodeMode,
workflowMode,
});

await execTaskWithParams({
task,
taskData: newAllCodeTaskData([wrapIntoJson({})]),
});

expect(console.log).toHaveBeenCalledWith('[JS Code]', 'Hello world!');
expect(jsTaskRunner.makeRpcCall).toHaveBeenCalledWith(task.taskId, 'logNodeOutput', [
'Hello world!',
]);
},
);

test.each<[CodeExecutionMode, WorkflowExecuteMode]>([
['runOnceForAllItems', 'manual'],
['runOnceForEachItem', 'manual'],
])(
"shouldn't make an rpc call for console log in %s mode when workflow mode is %s",
async (nodeMode, workflowMode) => {
jest.spyOn(jsTaskRunner, 'makeRpcCall').mockResolvedValue(undefined);
const task = newTaskWithSettings({
code: "console.log('Hello', 'world!'); return {}",
nodeMode,
workflowMode,
});

await execTaskWithParams({
task,
taskData: newAllCodeTaskData([wrapIntoJson({})]),
});

expect(jsTaskRunner.makeRpcCall).not.toHaveBeenCalled();
},
);
});

describe('runOnceForAllItems', () => {
Expand Down
20 changes: 8 additions & 12 deletions packages/@n8n/task-runner/src/js-task-runner/js-task-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ type CustomConsole = {
log: (...args: unknown[]) => void;
};

const noop = () => {};

export class JsTaskRunner extends TaskRunner {
constructor(
taskType: string,
Expand Down Expand Up @@ -110,16 +108,14 @@ export class JsTaskRunner extends TaskRunner {
});

const customConsole = {
log:
settings.workflowMode === 'manual'
? noop
: (...args: unknown[]) => {
const logOutput = args
.map((arg) => (typeof arg === 'object' && arg !== null ? JSON.stringify(arg) : arg))
.join(' ');
console.log('[JS Code]', logOutput);
void this.makeRpcCall(task.taskId, 'logNodeOutput', [logOutput]);
},
// Send log output back to the main process. It will take care of forwarding
// it to the UI or printing to console.
log: (...args: unknown[]) => {
const logOutput = args
.map((arg) => (typeof arg === 'object' && arg !== null ? JSON.stringify(arg) : arg))
.join(' ');
void this.makeRpcCall(task.taskId, 'logNodeOutput', [logOutput]);
},
};

const result =
Expand Down
14 changes: 7 additions & 7 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@
"!dist/**/e2e.*"
],
"devDependencies": {
"@redocly/cli": "^1.6.0",
"@redocly/cli": "^1.25.5",
"@types/aws4": "^1.5.1",
"@types/bcryptjs": "^2.4.2",
"@types/compression": "1.0.1",
"@types/convict": "^6.1.1",
"@types/cookie-parser": "^1.4.2",
"@types/cookie-parser": "^1.4.7",
"@types/express": "catalog:",
"@types/flat": "^5.0.5",
"@types/formidable": "^3.4.5",
Expand Down Expand Up @@ -111,14 +111,14 @@
"class-validator": "0.14.0",
"compression": "1.7.4",
"convict": "6.2.4",
"cookie-parser": "1.4.6",
"cookie-parser": "1.4.7",
"csrf": "3.1.0",
"curlconverter": "3.21.0",
"dotenv": "8.6.0",
"express": "4.21.0",
"express": "4.21.1",
"express-async-errors": "3.1.1",
"express-handlebars": "7.1.2",
"express-openapi-validator": "5.3.3",
"express-openapi-validator": "5.3.7",
"express-prom-bundle": "6.6.0",
"express-rate-limit": "7.2.0",
"fast-glob": "catalog:",
Expand All @@ -145,7 +145,7 @@
"nodemailer": "6.9.9",
"oauth-1.0a": "2.2.6",
"open": "7.4.2",
"openapi-types": "10.0.0",
"openapi-types": "12.1.3",
"otpauth": "9.1.1",
"p-cancelable": "2.1.1",
"p-lazy": "3.1.0",
Expand All @@ -166,7 +166,7 @@
"sqlite3": "5.1.7",
"sse-channel": "4.0.0",
"sshpk": "1.17.0",
"swagger-ui-express": "5.0.0",
"swagger-ui-express": "5.0.1",
"syslog-client": "1.1.1",
"typedi": "catalog:",
"uuid": "catalog:",
Expand Down
Loading

0 comments on commit 0ad4e97

Please sign in to comment.