Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into node-354-support-…
Browse files Browse the repository at this point in the history
…binary-streaming-for-the-respond
  • Loading branch information
agobrech committed Mar 8, 2023
2 parents 1998153 + c81656d commit 897528f
Show file tree
Hide file tree
Showing 163 changed files with 2,306 additions and 1,797 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages/cli/src/databases/migrations/ @n8n-io/migrations-review
3 changes: 2 additions & 1 deletion .github/workflows/docker-base-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ jobs:
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: ./docker/images/n8n-base
build-args: |
NODE_VERSION=${{github.event.inputs.node_version}}
platforms: linux/amd64,linux/arm64,linux/arm/v7
provenance: false
push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/base:${{ github.event.inputs.node_version }}
3 changes: 2 additions & 1 deletion .github/workflows/docker-images-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ jobs:
shell: bash

- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: .
file: ./docker/images/n8n-custom/Dockerfile
platforms: linux/amd64
provenance: false
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/n8n:${{ github.event.inputs.tag || 'nightly' }}
no-cache: true
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ jobs:
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: ./docker/images/n8n${{ matrix.docker-context }}
build-args: |
N8N_VERSION=${{ steps.vars.outputs.tag }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
provenance: false
push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/n8n:${{ steps.vars.outputs.tag }}${{ matrix.docker-context }}
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ on:
description: 'GitHub branch to test.'
required: false
default: 'master'
spec:
description: 'Specify specs.'
required: false
default: 'e2e/*'
type: string
user:
description: 'User who kicked this off.'
required: false
Expand Down
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"recommendations": [
"streetsidesoftware.code-spell-checker",
"dangmai.workspace-default-settings",
"dbaeumer.vscode-eslint",
"EditorConfig.EditorConfig",
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@
"bull": "^4.10.2",
"callsites": "^3.1.0",
"change-case": "^4.1.1",
"class-validator": "^0.14.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"client-oauth2": "^4.2.5",
"compression": "^1.7.4",
"connect-history-api-fallback": "^1.6.0",
Expand Down Expand Up @@ -205,6 +205,7 @@
"validator": "13.7.0",
"winston": "^3.3.3",
"ws": "^8.12.0",
"xmllint-wasm": "^3.0.1",
"yamljs": "^0.3.0"
}
}
4 changes: 2 additions & 2 deletions packages/cli/src/CommunityNodes/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const executeCommand = async (

try {
await fsAccess(downloadFolder);
} catch (_) {
} catch {
await fsMkdir(downloadFolder);
// Also init the folder since some versions
// of npm complain if the folder is empty
Expand Down Expand Up @@ -154,7 +154,7 @@ export function matchMissingPackages(
return parsedPackageData.packageName;

// eslint-disable-next-line no-empty
} catch (_) {}
} catch {}
return undefined;
});

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/CurlConverterHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const isJsonRequest = (curlJson: CurlJson): boolean => {
try {
JSON.parse(bodyKey);
return true;
} catch (_) {
} catch {
return false;
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ export interface IN8nUISettings {
ldap: boolean;
saml: boolean;
logStreaming: boolean;
advancedExecutionFilters: boolean;
};
hideUsagePage: boolean;
license: {
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/src/License.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ export class License {
return this.isFeatureEnabled(LICENSE_FEATURES.SAML);
}

isAdvancedExecutionFiltersEnabled() {
return this.isFeatureEnabled(LICENSE_FEATURES.ADVANCED_EXECUTION_FILTERS);
}

getCurrentEntitlements() {
return this.manager?.getCurrentEntitlements() ?? [];
}
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/LoadNodesAndCredentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export class LoadNodesAndCredentials implements INodesAndCredentials {
const removeCommand = `npm remove ${packageName}`;
try {
await executeCommand(removeCommand);
} catch (_) {}
} catch {}

throw new Error(RESPONSE_ERROR_MESSAGES.PACKAGE_DOES_NOT_CONTAIN_NODES);
}
Expand Down Expand Up @@ -284,7 +284,7 @@ export class LoadNodesAndCredentials implements INodesAndCredentials {
const removeCommand = `npm remove ${packageName}`;
try {
await executeCommand(removeCommand);
} catch (_) {}
} catch {}
throw new Error(RESPONSE_ERROR_MESSAGES.PACKAGE_DOES_NOT_CONTAIN_NODES);
}
}
Expand Down Expand Up @@ -418,7 +418,7 @@ export class LoadNodesAndCredentials implements INodesAndCredentials {
await fsAccess(checkPath);
// Folder exists, so use it.
return path.dirname(checkPath);
} catch (_) {} // Folder does not exist so get next one
} catch {} // Folder does not exist so get next one
}
throw new Error('Could not find "node_modules" folder!');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const validCredentialType = (
): express.Response | void => {
try {
Container.get(CredentialTypes).getByName(req.body.type);
} catch (_) {
} catch {
return res.status(400).json({ message: 'req.body.type is not a known type' });
}

Expand Down
29 changes: 22 additions & 7 deletions packages/cli/src/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ import { PostHogClient } from './posthog';
import { eventBus } from './eventbus';
import { Container } from 'typedi';
import { InternalHooks } from './InternalHooks';
import { getStatusUsingPreviousExecutionStatusMethod } from './executions/executionHelpers';
import {
getStatusUsingPreviousExecutionStatusMethod,
isAdvancedExecutionFiltersEnabled,
} from './executions/executionHelpers';
import { getSamlLoginLabel, isSamlLoginEnabled, isSamlLicensed } from './sso/saml/samlHelpers';
import { samlControllerPublic } from './sso/saml/routes/saml.controller.public.ee';
import { SamlService } from './sso/saml/saml.service.ee';
Expand Down Expand Up @@ -300,6 +303,7 @@ class Server extends AbstractServer {
ldap: false,
saml: false,
logStreaming: config.getEnv('enterprise.features.logStreaming'),
advancedExecutionFilters: config.getEnv('enterprise.features.advancedExecutionFilters'),
},
hideUsagePage: config.getEnv('hideUsagePage'),
license: {
Expand Down Expand Up @@ -328,6 +332,7 @@ class Server extends AbstractServer {
logStreaming: isLogStreamingEnabled(),
ldap: isLdapEnabled(),
saml: isSamlLicensed(),
advancedExecutionFilters: isAdvancedExecutionFiltersEnabled(),
});

if (isLdapEnabled()) {
Expand Down Expand Up @@ -515,10 +520,16 @@ class Server extends AbstractServer {
// SAML
// ----------------------------------------

// initialize SamlService
await SamlService.getInstance().init();
// initialize SamlService if it is licensed, even if not enabled, to
// set up the initial environment
if (isSamlLicensed()) {
try {
await SamlService.getInstance().init();
} catch (error) {
LoggerProxy.error(`SAML initialization failed: ${error.message}`);
}
}

// public SAML endpoints
this.app.use(`/${this.restEndpoint}/sso/saml`, samlControllerPublic);
this.app.use(`/${this.restEndpoint}/sso/saml`, samlControllerProtected);

Expand Down Expand Up @@ -1287,8 +1298,9 @@ class Server extends AbstractServer {
},
};

this.app.use('/icons/:packageName/*/*.(svg|png)', async (req, res) => {
const { packageName } = req.params;
const serveIcons: express.RequestHandler = async (req, res) => {
let { scope, packageName } = req.params;
if (scope) packageName = `@${scope}/${packageName}`;
const loader = this.loadNodesAndCredentials.loaders[packageName];
if (loader) {
const pathPrefix = `/icons/${packageName}/`;
Expand All @@ -1303,7 +1315,10 @@ class Server extends AbstractServer {
}

res.sendStatus(404);
});
};

this.app.use('/icons/@:scope/:packageName/*/*.(svg|png)', serveIcons);
this.app.use('/icons/:packageName/*/*.(svg|png)', serveIcons);

this.app.use(
'/',
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/api/nodes.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ nodesController.get(
if (missingPackages) {
hydratedPackages = matchMissingPackages(hydratedPackages, missingPackages);
}
} catch (_) {
} catch {
// Do nothing if setting is missing
}

Expand Down
4 changes: 4 additions & 0 deletions packages/cli/src/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,10 @@ export const schema = {
format: Boolean,
default: false,
},
advancedExecutionFilters: {
format: Boolean,
default: false,
},
},
},

Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export enum LICENSE_FEATURES {
LDAP = 'feat:ldap',
SAML = 'feat:saml',
LOG_STREAMING = 'feat:logStreaming',
ADVANCED_EXECUTION_FILTERS = 'feat:advancedExecutionFilters',
}

export const CREDENTIAL_BLANKING_VALUE = '__n8n_BLANK_VALUE_e5362baf-c777-4d57-a609-6eaf1f9e87f6';
2 changes: 1 addition & 1 deletion packages/cli/src/controllers/translation.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class TranslationController {
async getNodeTranslationHeaders() {
try {
await access(`${NODE_HEADERS_PATH}.js`);
} catch (_) {
} catch {
return; // no headers available
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function makeUpdateParams(fetchedWorkflows: PinData.FetchedWorkflow[]) {
if (typeof rawPinData === 'string') {
try {
pinDataPerWorkflow = JSON.parse(rawPinData);
} catch (_) {
} catch {
pinDataPerWorkflow = {};
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class MessageEventBusDestinationWebhook
let encryptionKey: string | undefined;
try {
encryptionKey = await UserSettings.getEncryptionKey();
} catch (_) {}
} catch {}
if (encryptionKey) {
this.credentialsHelper = new CredentialsHelper(encryptionKey);
}
Expand Down Expand Up @@ -173,9 +173,9 @@ export class MessageEventBusDestinationWebhook
acc: Promise<{ [key: string]: any }>,
cur: { name: string; value: string; parameterType?: string; inputDataFieldName?: string },
) => {
const acumulator = await acc;
acumulator[cur.name] = cur.value;
return acumulator;
const accumulator = await acc;
accumulator[cur.name] = cur.value;
return accumulator;
};

// Get parameters defined in the UI
Expand All @@ -189,7 +189,7 @@ export class MessageEventBusDestinationWebhook
// query is specified using JSON
try {
JSON.parse(this.jsonQuery);
} catch (_) {
} catch {
console.log('JSON parameter need to be an valid JSON');
}
this.axiosRequestOptions.params = jsonParse(this.jsonQuery);
Expand All @@ -207,7 +207,7 @@ export class MessageEventBusDestinationWebhook
// body is specified using JSON
try {
JSON.parse(this.jsonHeaders);
} catch (_) {
} catch {
console.log('JSON parameter need to be an valid JSON');
}
this.axiosRequestOptions.headers = jsonParse(this.jsonHeaders);
Expand Down Expand Up @@ -302,27 +302,27 @@ export class MessageEventBusDestinationWebhook
if (this.genericAuthType === 'httpBasicAuth') {
try {
httpBasicAuth = await this.matchDecryptedCredentialType('httpBasicAuth');
} catch (_) {}
} catch {}
} else if (this.genericAuthType === 'httpDigestAuth') {
try {
httpDigestAuth = await this.matchDecryptedCredentialType('httpDigestAuth');
} catch (_) {}
} catch {}
} else if (this.genericAuthType === 'httpHeaderAuth') {
try {
httpHeaderAuth = await this.matchDecryptedCredentialType('httpHeaderAuth');
} catch (_) {}
} catch {}
} else if (this.genericAuthType === 'httpQueryAuth') {
try {
httpQueryAuth = await this.matchDecryptedCredentialType('httpQueryAuth');
} catch (_) {}
} catch {}
} else if (this.genericAuthType === 'oAuth1Api') {
try {
oAuth1Api = await this.matchDecryptedCredentialType('oAuth1Api');
} catch (_) {}
} catch {}
} else if (this.genericAuthType === 'oAuth2Api') {
try {
oAuth2Api = await this.matchDecryptedCredentialType('oAuth2Api');
} catch (_) {}
} catch {}
}
}

Expand Down
12 changes: 11 additions & 1 deletion packages/cli/src/executions/executionHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { IExecutionFlattedDb } from '../Interfaces';
import type { IExecutionFlattedDb } from '@/Interfaces';
import type { ExecutionStatus } from 'n8n-workflow';
import { getLicense } from '@/License';
import config from '@/config';

export function getStatusUsingPreviousExecutionStatusMethod(
execution: IExecutionFlattedDb,
Expand All @@ -16,3 +18,11 @@ export function getStatusUsingPreviousExecutionStatusMethod(
return 'unknown';
}
}

export function isAdvancedExecutionFiltersEnabled(): boolean {
const license = getLicense();
return (
config.getEnv('enterprise.features.advancedExecutionFilters') ||
license.isAdvancedExecutionFiltersEnabled()
);
}
Loading

0 comments on commit 897528f

Please sign in to comment.