Skip to content

Commit

Permalink
Adds omri changes for july 17 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
andyjoyous committed Jul 17, 2024
1 parent 09f2cf9 commit e76f7f0
Show file tree
Hide file tree
Showing 45 changed files with 1,436 additions and 140 deletions.
8 changes: 8 additions & 0 deletions .env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
DATABASE_URL='postgres://postgres:123@localhost:5432/postgres'
DB_POSTGRESDB_SCHEMA=postgres
DB_TYPE=postgresdb
EXECUTIONS_MODE=queue
N8N_LOG_LEVEL=debug
REDIS_URL='redis://:1234@localhost:6379'
DB_POSTGRESDB_SCHEMA=local
PORT=5678
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ packages/**/.turbo
CHANGELOG-*.md
*.mdx
build-storybook.log
.env
.env.local.with.aws
dump.rdb
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ loglevel = warn
package-manager-strict=false
# https://github.com/pnpm/pnpm/issues/7024
package-import-method=clone-or-copy
pnpm-version=9.5.0
2 changes: 2 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
web: npm start
worker: npm start worker
3 changes: 3 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"stack": "heroku-20"
}
2 changes: 2 additions & 0 deletions docker/images/n8n/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ LABEL org.opencontainers.image.version=${N8N_VERSION}
ENV N8N_VERSION=${N8N_VERSION}
ENV NODE_ENV=production
ENV N8N_RELEASE_TYPE=stable
ENV NODE_FUNCTION_ALLOW_EXTERNAL=*
ENV NODE_FUNCTION_ALLOW_BUILTIN=*
RUN set -eux; \
npm install -g --omit=dev n8n@${N8N_VERSION} --ignore-scripts && \
npm rebuild --prefix=/usr/local/lib/node_modules/n8n sqlite3 && \
Expand Down
35 changes: 33 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "1.50.0",
"private": true,
"engines": {
"node": ">=18.10",
"pnpm": ">=9.1"
"node": "~20.0.0",
"pnpm": "9.5.0"
},
"packageManager": "[email protected]",
"scripts": {
Expand Down Expand Up @@ -36,6 +36,37 @@
"webhook": "./packages/cli/bin/n8n webhook",
"worker": "./packages/cli/bin/n8n worker"
},
"dependencies": {
"@anthropic-ai/sdk": "^0.19.1",
"@aws-sdk/client-s3": "^3.550.0",
"@aws-sdk/s3-request-presigner": "^3.550.0",
"aws-sdk" : "^2.1594.0",
"lodash": "^4.17.21",
"openai": "^4.32.1",
"sharp": "^0.33.3",
"api": "^6.1.1",
"axios": "^1.6.8",
"redis": "^4.6.3",
"bullmq": "^5.5.0",
"zip-to-tz": "^1.1.0",
"dotenv": "^16.4.5",
"nanoid": "^5.0.6",
"uid": "^2.0.2",
"body-parser": "^1.20.2",
"chargebee": "^2.34.0",
"mixpanel": "^0.18.0",
"jwt-decode": "^4.0.0",
"redis-url-parse": "^2.0.0",
"twilio": "^5.0.3",
"firebase-admin": "^12.0.0",
"firebase": "^10.10.0",
"activecampaign": "^1.2.5",
"crypto-js": "4.2.0",
"authorizenet": "1.0.8",
"form-data": "^4.0.0",
"moment": "~2.29.2",
"moment-timezone": "^0.5.28"
},
"devDependencies": {
"@n8n_io/eslint-config": "workspace:*",
"@types/jest": "^29.5.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/n8n
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const ENFORCE_MIN_NODE_VERSION = process.env.E2E_TESTS !== 'true';

if (
(ENFORCE_MIN_NODE_VERSION && !gte(nodeVersion, MINIMUM_SUPPORTED_NODE_VERSION)) ||
![18, 20, 22].includes(major(nodeVersion))
![16, 18, 19, 20, 22].includes(major(nodeVersion))
) {
console.log(`
Your Node.js version ${nodeVersion} is currently not supported by n8n.
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"workflow"
],
"engines": {
"node": ">=18.10"
"node": "~20.0.0"
},
"files": [
"bin",
Expand Down
5 changes: 4 additions & 1 deletion packages/cli/src/AbstractServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ export abstract class AbstractServer {
this.server = http.createServer(app);
}

const PORT = config.getEnv('port');
// const PORT = config.getEnv('port');
const prt = parseInt(process.env.PORT!);
const PORT = prt;
console.log(`port from ENV is ${prt}`);
const ADDRESS = config.getEnv('listen_address');

this.server.on('error', (error: Error & { code: string }) => {
Expand Down
34 changes: 17 additions & 17 deletions packages/cli/src/License.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,75 +234,75 @@ export class License {
}

isSharingEnabled() {
return this.isFeatureEnabled(LICENSE_FEATURES.SHARING);
return true;
}

isLogStreamingEnabled() {
return this.isFeatureEnabled(LICENSE_FEATURES.LOG_STREAMING);
return true;
}

isLdapEnabled() {
return this.isFeatureEnabled(LICENSE_FEATURES.LDAP);
return true;
}

isSamlEnabled() {
return this.isFeatureEnabled(LICENSE_FEATURES.SAML);
return true;
}

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

isAdvancedPermissionsLicensed() {
return this.isFeatureEnabled(LICENSE_FEATURES.ADVANCED_PERMISSIONS);
return true;
}

isDebugInEditorLicensed() {
return this.isFeatureEnabled(LICENSE_FEATURES.DEBUG_IN_EDITOR);
return true;
}

isBinaryDataS3Licensed() {
return this.isFeatureEnabled(LICENSE_FEATURES.BINARY_DATA_S3);
return true;
}

isMultipleMainInstancesLicensed() {
return this.isFeatureEnabled(LICENSE_FEATURES.MULTIPLE_MAIN_INSTANCES);
return true;
}

isVariablesEnabled() {
return this.isFeatureEnabled(LICENSE_FEATURES.VARIABLES);
return true;
}

isSourceControlLicensed() {
return this.isFeatureEnabled(LICENSE_FEATURES.SOURCE_CONTROL);
return true;
}

isExternalSecretsEnabled() {
return this.isFeatureEnabled(LICENSE_FEATURES.EXTERNAL_SECRETS);
return true;
}

isWorkflowHistoryLicensed() {
return this.isFeatureEnabled(LICENSE_FEATURES.WORKFLOW_HISTORY);
return true;
}

isAPIDisabled() {
return this.isFeatureEnabled(LICENSE_FEATURES.API_DISABLED);
}

isWorkerViewLicensed() {
return this.isFeatureEnabled(LICENSE_FEATURES.WORKER_VIEW);
return true;
}

isProjectRoleAdminLicensed() {
return this.isFeatureEnabled(LICENSE_FEATURES.PROJECT_ROLE_ADMIN);
return true;
}

isProjectRoleEditorLicensed() {
return this.isFeatureEnabled(LICENSE_FEATURES.PROJECT_ROLE_EDITOR);
return true;
}

isProjectRoleViewerLicensed() {
return this.isFeatureEnabled(LICENSE_FEATURES.PROJECT_ROLE_VIEWER);
return true;
}

getCurrentEntitlements() {
Expand Down
40 changes: 40 additions & 0 deletions packages/cli/src/ParserHelper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { RedisOptions } from 'ioredis';
import { LoggerProxy as Logger } from 'n8n-workflow';
import { URL } from 'url';
import config from '@/config';

export function parseRedisUrl(): RedisOptions | null {
const redisUri = process.env.REDIS_URL;
if (redisUri) {
const parsedURL = new URL(redisUri);
Logger.debug(`Global Redis is configured`);
return {
host: parsedURL.hostname,
port: parseInt(parsedURL.port),
username: config.getEnv('queue.bull.redis.username'),
password: parsedURL.password,
db: config.getEnv('queue.bull.redis.db'),
};
} else {
Logger.debug(`Global Redis is not configured, working with specific environment variables`);
return null;
}
}

export function parsePostgresUrl(): any {
const postgresUri = process.env.DATABASE_URL;
if (postgresUri) {
const parsedURL = new URL(postgresUri);
Logger.debug(`Global Postgres is configured`);
return {
database: parsedURL.pathname.slice(1),
username: parsedURL.username,
password: parsedURL.password,
host: parsedURL.hostname,
port: parseInt(parsedURL.port),
};
} else {
Logger.debug(`Global Postgres is not configured, working with specific environment variables`);
return null;
}
}
7 changes: 7 additions & 0 deletions packages/cli/src/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import type { IN8nUISettings } from 'n8n-workflow';

import config from '@/config';

import { WorkflowsWithVersionController } from './workflowsWithVersion/workflowsWithVersion.controller';

import {
CLI_DIR,
EDITOR_UI_DIST_DIR,
Expand Down Expand Up @@ -136,6 +138,11 @@ export class Server extends AbstractServer {
await import('@/controllers/cta.controller');
}

// ----------------------------------------
// Workflow with versions
// ----------------------------------------
this.app.use(`/${this.restEndpoint}/workflows-with-versions`, WorkflowsWithVersionController);

// ----------------------------------------
// SAML
// ----------------------------------------
Expand Down
82 changes: 64 additions & 18 deletions packages/cli/src/databases/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { subscribers } from './subscribers';
import { mysqlMigrations } from './migrations/mysqldb';
import { postgresMigrations } from './migrations/postgresdb';
import { sqliteMigrations } from './migrations/sqlite';
import { parsePostgresUrl } from '@/ParserHelper';

const getCommonOptions = () => {
const { tablePrefix: entityPrefix, logging: loggingConfig } =
Expand Down Expand Up @@ -42,17 +43,45 @@ const getCommonOptions = () => {
};
};

// export const getOptionOverrides = (dbType: 'postgresdb' | 'mysqldb') => {
// const globalConfig = Container.get(GlobalConfig);
// const dbConfig = globalConfig.database[dbType];
// return {
// database: dbConfig.database,
// host: dbConfig.host,
// port: dbConfig.port,
// username: dbConfig.user,
// password: dbConfig.password,
// };
// };

export const getOptionOverrides = (dbType: 'postgresdb' | 'mysqldb') => {
const globalConfig = Container.get(GlobalConfig);
const dbConfig = globalConfig.database[dbType];
return {
database: dbConfig.database,
host: dbConfig.host,
port: dbConfig.port,
username: dbConfig.user,
password: dbConfig.password,
};
};
const globalConfig = Container.get(GlobalConfig);
const dbConfig = globalConfig.database[dbType];

let connectionDetails;
if (dbType == 'postgresdb') {
connectionDetails = parsePostgresUrl();
}
if (!connectionDetails) {
connectionDetails = {

database: dbConfig.database,
host: dbConfig.host,
port: dbConfig.port,
username: dbConfig.user,
password: dbConfig.password,

// database: config.getEnv(`database.${dbType}.database`),
// host: config.getEnv(`database.${dbType}.host`),
// port: config.getEnv(`database.${dbType}.port`),
// username: config.getEnv(`database.${dbType}.user`),
// password: config.getEnv(`database.${dbType}.password`),

}
}
return connectionDetails;
}

const getSqliteConnectionOptions = (): SqliteConnectionOptions | SqlitePooledConnectionOptions => {
const globalConfig = Container.get(GlobalConfig);
Expand Down Expand Up @@ -87,14 +116,16 @@ const getPostgresConnectionOptions = (): PostgresConnectionOptions => {
} = postgresConfig;

let ssl: TlsOptions | boolean = postgresConfig.ssl.enabled;
if (sslCa !== '' || sslCert !== '' || sslKey !== '' || !sslRejectUnauthorized) {
ssl = {
ca: sslCa || undefined,
cert: sslCert || undefined,
key: sslKey || undefined,
rejectUnauthorized: sslRejectUnauthorized,
};
}
if (!isPostgresRunningLocally()) {
if (sslCa !== '' || sslCert !== '' || sslKey !== '' || !sslRejectUnauthorized) {
ssl = {
ca: sslCa || undefined,
cert: sslCert || undefined,
key: sslKey || undefined,
rejectUnauthorized: sslRejectUnauthorized,
};
}
}

return {
type: 'postgres',
Expand Down Expand Up @@ -130,3 +161,18 @@ export function getConnectionOptions(): DataSourceOptions {
throw new ApplicationError('Database type currently not supported', { extra: { dbType } });
}
}

function isPostgresRunningLocally(): Boolean {
let host: String | undefined;
const postgresConfig = parsePostgresUrl();

const globalConfig = Container.get(GlobalConfig);
const dbConfig = globalConfig.database['postgresdb'];

if (postgresConfig != null) {
host = postgresConfig.host;
} else {
host = dbConfig.host;
}
return host === ('localhost' || '127.0.0.1');
}
Loading

0 comments on commit e76f7f0

Please sign in to comment.