Skip to content

Commit

Permalink
Merge branch 'master' into replace-v-html
Browse files Browse the repository at this point in the history
  • Loading branch information
tomi committed Sep 18, 2024
2 parents 417b702 + 989f69d commit 6e2282f
Show file tree
Hide file tree
Showing 29 changed files with 445 additions and 404 deletions.
1 change: 1 addition & 0 deletions cypress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"start": "cd ..; pnpm start"
},
"devDependencies": {
"@n8n/api-types": "workspace:*",
"@types/lodash": "catalog:",
"eslint-plugin-cypress": "^3.3.0",
"n8n-workflow": "workspace:*"
Expand Down
6 changes: 3 additions & 3 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'cypress-real-events';
import FakeTimers from '@sinonjs/fake-timers';
import type { IN8nUISettings } from 'n8n-workflow';
import type { FrontendSettings } from '@n8n/api-types';
import { WorkflowPage } from '../pages';
import {
BACKEND_BASE_URL,
Expand Down Expand Up @@ -86,8 +86,8 @@ Cypress.Commands.add('signout', () => {
cy.getCookie(N8N_AUTH_COOKIE).should('not.exist');
});

export let settings: Partial<IN8nUISettings>;
Cypress.Commands.add('overrideSettings', (value: Partial<IN8nUISettings>) => {
export let settings: Partial<FrontendSettings>;
Cypress.Commands.add('overrideSettings', (value: Partial<FrontendSettings>) => {
settings = value;
});

Expand Down
4 changes: 2 additions & 2 deletions cypress/support/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Load type definitions that come with Cypress module
/// <reference types="cypress" />

import type { IN8nUISettings } from 'n8n-workflow';
import type { FrontendSettings } from '@n8n/api-types';

Cypress.Keyboard.defaults({
keystrokeDelay: 0,
Expand Down Expand Up @@ -45,7 +45,7 @@ declare global {
*/
signinAsMember(index?: number): void;
signout(): void;
overrideSettings(value: Partial<IN8nUISettings>): void;
overrideSettings(value: Partial<FrontendSettings>): void;
enableFeature(feature: string): void;
disableFeature(feature: string): void;
enableQueueMode(): void;
Expand Down
172 changes: 172 additions & 0 deletions packages/@n8n/api-types/src/frontend-settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
import type { ExpressionEvaluatorType, LogLevel, WorkflowSettings } from 'n8n-workflow';

export interface IVersionNotificationSettings {
enabled: boolean;
endpoint: string;
infoUrl: string;
}

export interface ITelemetryClientConfig {
url: string;
key: string;
}

export interface ITelemetrySettings {
enabled: boolean;
config?: ITelemetryClientConfig;
}

export type AuthenticationMethod = 'email' | 'ldap' | 'saml';

export interface IUserManagementSettings {
quota: number;
showSetupOnFirstLoad?: boolean;
smtpSetup: boolean;
authenticationMethod: AuthenticationMethod;
}

export interface FrontendSettings {
isDocker?: boolean;
databaseType: 'sqlite' | 'mariadb' | 'mysqldb' | 'postgresdb';
endpointForm: string;
endpointFormTest: string;
endpointFormWaiting: string;
endpointWebhook: string;
endpointWebhookTest: string;
saveDataErrorExecution: WorkflowSettings.SaveDataExecution;
saveDataSuccessExecution: WorkflowSettings.SaveDataExecution;
saveManualExecutions: boolean;
saveExecutionProgress: boolean;
executionTimeout: number;
maxExecutionTimeout: number;
workflowCallerPolicyDefaultOption: WorkflowSettings.CallerPolicy;
oauthCallbackUrls: {
oauth1: string;
oauth2: string;
};
timezone: string;
urlBaseWebhook: string;
urlBaseEditor: string;
versionCli: string;
nodeJsVersion: string;
concurrency: number;
authCookie: {
secure: boolean;
};
binaryDataMode: 'default' | 'filesystem' | 's3';
releaseChannel: 'stable' | 'beta' | 'nightly' | 'dev';
n8nMetadata?: {
userId?: string;
[key: string]: string | number | undefined;
};
versionNotifications: IVersionNotificationSettings;
instanceId: string;
telemetry: ITelemetrySettings;
posthog: {
enabled: boolean;
apiHost: string;
apiKey: string;
autocapture: boolean;
disableSessionRecording: boolean;
debug: boolean;
};
personalizationSurveyEnabled: boolean;
defaultLocale: string;
userManagement: IUserManagementSettings;
sso: {
saml: {
loginLabel: string;
loginEnabled: boolean;
};
ldap: {
loginLabel: string;
loginEnabled: boolean;
};
};
publicApi: {
enabled: boolean;
latestVersion: number;
path: string;
swaggerUi: {
enabled: boolean;
};
};
workflowTagsDisabled: boolean;
logLevel: LogLevel;
hiringBannerEnabled: boolean;
previewMode: boolean;
templates: {
enabled: boolean;
host: string;
};
missingPackages?: boolean;
executionMode: 'regular' | 'queue';
pushBackend: 'sse' | 'websocket';
communityNodesEnabled: boolean;
aiAssistant: {
enabled: boolean;
};
deployment: {
type: string;
};
isNpmAvailable: boolean;
allowedModules: {
builtIn?: string[];
external?: string[];
};
enterprise: {
sharing: boolean;
ldap: boolean;
saml: boolean;
logStreaming: boolean;
advancedExecutionFilters: boolean;
variables: boolean;
sourceControl: boolean;
auditLogs: boolean;
externalSecrets: boolean;
showNonProdBanner: boolean;
debugInEditor: boolean;
binaryDataS3: boolean;
workflowHistory: boolean;
workerView: boolean;
advancedPermissions: boolean;
projects: {
team: {
limit: number;
};
};
};
hideUsagePage: boolean;
license: {
planName?: string;
consumerId: string;
environment: 'development' | 'production' | 'staging';
};
variables: {
limit: number;
};
expressions: {
evaluator: ExpressionEvaluatorType;
};
mfa: {
enabled: boolean;
};
banners: {
dismissed: string[];
};
ai: {
enabled: boolean;
};
workflowHistory: {
pruneTime: number;
licensePruneTime: number;
};
pruning: {
isEnabled: boolean;
maxAge: number;
maxCount: number;
};
security: {
blockFileAccessToN8nFiles: boolean;
};
}
3 changes: 2 additions & 1 deletion packages/@n8n/api-types/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export type * from './datetime';
export type * from './push';
export type * from './scaling';
export type * from './datetime';
export type * from './frontend-settings';
export type * from './user';

export type { Collaborator } from './push/collaboration';
Expand Down
12 changes: 12 additions & 0 deletions packages/@n8n/benchmark/scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ else
sudo chown -R "$CURRENT_USER":"$CURRENT_USER" /n8n
fi

### Remove unneeded dependencies
# TTY
sudo systemctl disable [email protected]
sudo systemctl disable [email protected]
# Snap
sudo systemctl disable snapd.service
sudo apt remove snapd
# Unattended upgrades
sudo systemctl disable unattended-upgrades.service
# Cron
sudo systemctl disable cron.service

# Include nodejs v20 repository
curl -fsSL https://deb.nodesource.com/setup_20.x -o nodesource_setup.sh
sudo -E bash nodesource_setup.sh
Expand Down
6 changes: 6 additions & 0 deletions packages/@n8n/benchmark/scripts/run-in-cloud.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ async function runBenchmarksOnVm(config, benchmarkEnv) {
const bootstrapScriptPath = path.join(scriptsDir, 'bootstrap.sh');
await sshClient.ssh(`chmod a+x ${bootstrapScriptPath} && ${bootstrapScriptPath}`);

// Benchmarking the VM
const vmBenchmarkScriptPath = path.join(scriptsDir, 'vm-benchmark.sh');
await sshClient.ssh(`chmod a+x ${vmBenchmarkScriptPath} && ${vmBenchmarkScriptPath}`, {
verbose: true,
});

// Give some time for the VM to be ready
await sleep(1000);

Expand Down
13 changes: 13 additions & 0 deletions packages/@n8n/benchmark/scripts/vm-benchmark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# Install fio
sudo apt-get -y install fio > /dev/null

# Run the disk benchmark
fio --name=rand_rw --ioengine=libaio --rw=randrw --rwmixread=70 --bs=4k --numjobs=4 --size=1G --runtime=30 --directory=/n8n --group_reporting

# Remove files
sudo rm /n8n/rand_rw.*

# Uninstall fio
sudo apt-get -y remove fio
2 changes: 1 addition & 1 deletion packages/cli/src/events/relay-event-map.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { AuthenticationMethod } from '@n8n/api-types';
import type {
AuthenticationMethod,
IPersonalizationSurveyAnswersV4,
IRun,
IWorkflowBase,
Expand Down
6 changes: 0 additions & 6 deletions packages/cli/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,6 @@ export interface IExternalHooksFunctions {
};
}

export interface IVersionNotificationSettings {
enabled: boolean;
endpoint: string;
infoUrl: string;
}

export interface IPersonalizationSurveyAnswers {
email: string | null;
codingSkill: string | null;
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { FrontendSettings } from '@n8n/api-types';
import { exec as callbackExec } from 'child_process';
import cookieParser from 'cookie-parser';
import express from 'express';
import { access as fsAccess } from 'fs/promises';
import helmet from 'helmet';
import { InstanceSettings } from 'n8n-core';
import type { IN8nUISettings } from 'n8n-workflow';
import { resolve } from 'path';
import { Container, Service } from 'typedi';
import { promisify } from 'util';
Expand Down Expand Up @@ -252,7 +252,7 @@ export class Server extends AbstractServer {
this.app.get(
`/${this.restEndpoint}/settings`,
ResponseHelper.send(
async (req: express.Request): Promise<IN8nUISettings> =>
async (req: express.Request): Promise<FrontendSettings> =>
frontendService.getSettings(req.headers['push-ref'] as string),
),
);
Expand Down
12 changes: 4 additions & 8 deletions packages/cli/src/services/frontend.service.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import type { FrontendSettings, ITelemetrySettings } from '@n8n/api-types';
import { GlobalConfig } from '@n8n/config';
import { createWriteStream } from 'fs';
import { mkdir } from 'fs/promises';
import uniq from 'lodash/uniq';
import { InstanceSettings } from 'n8n-core';
import type {
ICredentialType,
IN8nUISettings,
INodeTypeBaseDescription,
ITelemetrySettings,
} from 'n8n-workflow';
import type { ICredentialType, INodeTypeBaseDescription } from 'n8n-workflow';
import fs from 'node:fs';
import path from 'path';
import { Container, Service } from 'typedi';
Expand Down Expand Up @@ -37,7 +33,7 @@ import { UrlService } from './url.service';

@Service()
export class FrontendService {
settings: IN8nUISettings;
settings: FrontendSettings;

private communityPackagesService?: CommunityPackagesService;

Expand Down Expand Up @@ -247,7 +243,7 @@ export class FrontendService {
this.writeStaticJSON('credentials', credentials);
}

getSettings(pushRef?: string): IN8nUISettings {
getSettings(pushRef?: string): FrontendSettings {
this.eventService.emit('session-started', { pushRef });

const restEndpoint = this.globalConfig.endpoints.rest;
Expand Down
Loading

0 comments on commit 6e2282f

Please sign in to comment.