mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
perf(tooling): Upgrade to TypeScript 4.8 (#4207)
* ⬆️ Upgrade to TypeScript 4.8 * 🔥 Remove unneeded setting * 📦 Update `package-lock.json` * ⏪ Restore `skipLibCheck` * 📦 Re-update `package-lock.json` * ♻️ Apply feedback * ♻️ Add check to new WhatsApp node * 📦 Update `package-lock.json` * Update package-lock.json * ran `npm run lintfix` Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -51,7 +51,7 @@
|
||||
"jest-environment-jsdom": "^27.5.1",
|
||||
"prettier": "^2.3.2",
|
||||
"ts-jest": "^27.1.3",
|
||||
"typescript": "~4.6.0"
|
||||
"typescript": "~4.8.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@n8n_io/riot-tmpl": "^1.0.1",
|
||||
|
||||
@@ -241,7 +241,7 @@ export class RoutingNode {
|
||||
merge(destinationOptions.options, sourceOptions.options);
|
||||
destinationOptions.preSend.push(...sourceOptions.preSend);
|
||||
destinationOptions.postReceive.push(...sourceOptions.postReceive);
|
||||
if (sourceOptions.requestOperations) {
|
||||
if (sourceOptions.requestOperations && destinationOptions.requestOperations) {
|
||||
destinationOptions.requestOperations = Object.assign(
|
||||
destinationOptions.requestOperations,
|
||||
sourceOptions.requestOperations,
|
||||
|
||||
@@ -1,75 +1,75 @@
|
||||
import { toCronExpression } from "../src/Cron"
|
||||
import { toCronExpression } from '../src/Cron';
|
||||
|
||||
describe('Cron', () => {
|
||||
describe('toCronExpression', () => {
|
||||
test('should generate a valid cron for `everyMinute` triggers', () => {
|
||||
const expression = toCronExpression({
|
||||
mode: 'everyMinute',
|
||||
})
|
||||
expect(expression).toMatch(/^[1-6]?[0-9] \* \* \* \* \*$/)
|
||||
})
|
||||
describe('toCronExpression', () => {
|
||||
test('should generate a valid cron for `everyMinute` triggers', () => {
|
||||
const expression = toCronExpression({
|
||||
mode: 'everyMinute',
|
||||
});
|
||||
expect(expression).toMatch(/^[1-6]?[0-9] \* \* \* \* \*$/);
|
||||
});
|
||||
|
||||
test('should generate a valid cron for `everyHour` triggers', () => {
|
||||
const expression = toCronExpression({
|
||||
mode: 'everyHour',
|
||||
minute: 11,
|
||||
})
|
||||
expect(expression).toMatch(/^[1-6]?[0-9] 11 \* \* \* \*$/)
|
||||
})
|
||||
test('should generate a valid cron for `everyHour` triggers', () => {
|
||||
const expression = toCronExpression({
|
||||
mode: 'everyHour',
|
||||
minute: 11,
|
||||
});
|
||||
expect(expression).toMatch(/^[1-6]?[0-9] 11 \* \* \* \*$/);
|
||||
});
|
||||
|
||||
test('should generate a valid cron for `everyX[minutes]` triggers', () => {
|
||||
const expression = toCronExpression({
|
||||
mode: 'everyX',
|
||||
unit: 'minutes',
|
||||
value: 42,
|
||||
})
|
||||
expect(expression).toMatch(/^[1-6]?[0-9] \*\/42 \* \* \* \*$/)
|
||||
})
|
||||
test('should generate a valid cron for `everyX[minutes]` triggers', () => {
|
||||
const expression = toCronExpression({
|
||||
mode: 'everyX',
|
||||
unit: 'minutes',
|
||||
value: 42,
|
||||
});
|
||||
expect(expression).toMatch(/^[1-6]?[0-9] \*\/42 \* \* \* \*$/);
|
||||
});
|
||||
|
||||
test('should generate a valid cron for `everyX[hours]` triggers', () => {
|
||||
const expression = toCronExpression({
|
||||
mode: 'everyX',
|
||||
unit: 'hours',
|
||||
value: 3,
|
||||
})
|
||||
expect(expression).toMatch(/^[1-6]?[0-9] 0 \*\/3 \* \* \*$/)
|
||||
})
|
||||
test('should generate a valid cron for `everyX[hours]` triggers', () => {
|
||||
const expression = toCronExpression({
|
||||
mode: 'everyX',
|
||||
unit: 'hours',
|
||||
value: 3,
|
||||
});
|
||||
expect(expression).toMatch(/^[1-6]?[0-9] 0 \*\/3 \* \* \*$/);
|
||||
});
|
||||
|
||||
test('should generate a valid cron for `everyDay` triggers', () => {
|
||||
const expression = toCronExpression({
|
||||
mode: 'everyDay',
|
||||
hour: 13,
|
||||
minute: 17,
|
||||
})
|
||||
expect(expression).toMatch(/^[1-6]?[0-9] 17 13 \* \* \*$/)
|
||||
})
|
||||
test('should generate a valid cron for `everyDay` triggers', () => {
|
||||
const expression = toCronExpression({
|
||||
mode: 'everyDay',
|
||||
hour: 13,
|
||||
minute: 17,
|
||||
});
|
||||
expect(expression).toMatch(/^[1-6]?[0-9] 17 13 \* \* \*$/);
|
||||
});
|
||||
|
||||
test('should generate a valid cron for `everyWeek` triggers', () => {
|
||||
const expression = toCronExpression({
|
||||
mode: 'everyWeek',
|
||||
hour: 13,
|
||||
minute: 17,
|
||||
weekday: 4,
|
||||
})
|
||||
expect(expression).toMatch(/^[1-6]?[0-9] 17 13 \* \* 4$/)
|
||||
})
|
||||
test('should generate a valid cron for `everyWeek` triggers', () => {
|
||||
const expression = toCronExpression({
|
||||
mode: 'everyWeek',
|
||||
hour: 13,
|
||||
minute: 17,
|
||||
weekday: 4,
|
||||
});
|
||||
expect(expression).toMatch(/^[1-6]?[0-9] 17 13 \* \* 4$/);
|
||||
});
|
||||
|
||||
test('should generate a valid cron for `everyMonth` triggers', () => {
|
||||
const expression = toCronExpression({
|
||||
mode: 'everyMonth',
|
||||
hour: 13,
|
||||
minute: 17,
|
||||
dayOfMonth: 12,
|
||||
})
|
||||
expect(expression).toMatch(/^[1-6]?[0-9] 17 13 12 \* \*$/)
|
||||
})
|
||||
test('should generate a valid cron for `everyMonth` triggers', () => {
|
||||
const expression = toCronExpression({
|
||||
mode: 'everyMonth',
|
||||
hour: 13,
|
||||
minute: 17,
|
||||
dayOfMonth: 12,
|
||||
});
|
||||
expect(expression).toMatch(/^[1-6]?[0-9] 17 13 12 \* \*$/);
|
||||
});
|
||||
|
||||
test('should trim custom cron expressions', () => {
|
||||
const expression = toCronExpression({
|
||||
mode: 'custom',
|
||||
cronExpression: ' 0 9-17 * * * ',
|
||||
})
|
||||
expect(expression).toEqual('0 9-17 * * *')
|
||||
})
|
||||
})
|
||||
})
|
||||
test('should trim custom cron expressions', () => {
|
||||
const expression = toCronExpression({
|
||||
mode: 'custom',
|
||||
cronExpression: ' 0 9-17 * * * ',
|
||||
});
|
||||
expect(expression).toEqual('0 9-17 * * *');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,43 +2,32 @@
|
||||
* @jest-environment jsdom
|
||||
*/
|
||||
|
||||
import {
|
||||
Expression,
|
||||
Workflow,
|
||||
} from "../src";
|
||||
import * as Helpers from "./Helpers";
|
||||
import {
|
||||
DateTime,
|
||||
Duration,
|
||||
Interval
|
||||
} from "luxon";
|
||||
import { Expression, Workflow } from '../src';
|
||||
import * as Helpers from './Helpers';
|
||||
import { DateTime, Duration, Interval } from 'luxon';
|
||||
|
||||
describe('Expression', () => {
|
||||
describe('getParameterValue()', () => {
|
||||
const nodeTypes = Helpers.NodeTypes();
|
||||
const workflow = new Workflow({ nodes: [
|
||||
{
|
||||
name: 'node',
|
||||
typeVersion: 1,
|
||||
type: 'test.set',
|
||||
id: 'uuid-1234',
|
||||
position: [0, 0],
|
||||
parameters: {}
|
||||
}
|
||||
], connections: {}, active: false, nodeTypes });
|
||||
const workflow = new Workflow({
|
||||
nodes: [
|
||||
{
|
||||
name: 'node',
|
||||
typeVersion: 1,
|
||||
type: 'test.set',
|
||||
id: 'uuid-1234',
|
||||
position: [0, 0],
|
||||
parameters: {},
|
||||
},
|
||||
],
|
||||
connections: {},
|
||||
active: false,
|
||||
nodeTypes,
|
||||
});
|
||||
const expression = new Expression(workflow);
|
||||
|
||||
const evaluate = (value: string) => expression.getParameterValue(
|
||||
value,
|
||||
null,
|
||||
0,
|
||||
0,
|
||||
'node',
|
||||
[],
|
||||
'manual',
|
||||
'',
|
||||
{},
|
||||
);
|
||||
const evaluate = (value: string) =>
|
||||
expression.getParameterValue(value, null, 0, 0, 'node', [], 'manual', '', {});
|
||||
|
||||
it('should not be able to use global built-ins from denylist', () => {
|
||||
expect(evaluate('={{document}}')).toEqual({});
|
||||
@@ -81,8 +70,12 @@ describe('Expression', () => {
|
||||
|
||||
it('should be able to use global built-ins from allowlist', () => {
|
||||
expect(evaluate('={{new Date()}}')).toBeInstanceOf(Date);
|
||||
expect(evaluate('={{DateTime.now().toLocaleString()}}')).toEqual(DateTime.now().toLocaleString());
|
||||
expect(evaluate('={{Interval.after(new Date(), 100)}}')).toEqual(Interval.after(new Date(), 100));
|
||||
expect(evaluate('={{DateTime.now().toLocaleString()}}')).toEqual(
|
||||
DateTime.now().toLocaleString(),
|
||||
);
|
||||
expect(evaluate('={{Interval.after(new Date(), 100)}}')).toEqual(
|
||||
Interval.after(new Date(), 100),
|
||||
);
|
||||
expect(evaluate('={{Duration.fromMillis(100)}}')).toEqual(Duration.fromMillis(100));
|
||||
|
||||
expect(evaluate('={{new Object()}}')).toEqual(new Object());
|
||||
@@ -116,31 +109,41 @@ describe('Expression', () => {
|
||||
expect(evaluate('={{Intl}}')).toEqual(Intl);
|
||||
|
||||
expect(evaluate('={{new String()}}')).toEqual(new String());
|
||||
expect(evaluate('={{new RegExp(\'\')}}')).toEqual(new RegExp(''));
|
||||
expect(evaluate("={{new RegExp('')}}")).toEqual(new RegExp(''));
|
||||
|
||||
expect(evaluate('={{Math}}')).toEqual(Math);
|
||||
expect(evaluate('={{new Number()}}')).toEqual(new Number());
|
||||
expect(evaluate('={{BigInt(\'1\')}}')).toEqual(BigInt('1'));
|
||||
expect(evaluate("={{BigInt('1')}}")).toEqual(BigInt('1'));
|
||||
expect(evaluate('={{Infinity}}')).toEqual(Infinity);
|
||||
expect(evaluate('={{NaN}}')).toEqual(NaN);
|
||||
expect(evaluate('={{isFinite(1)}}')).toEqual(isFinite(1));
|
||||
expect(evaluate('={{isNaN(1)}}')).toEqual(isNaN(1));
|
||||
expect(evaluate('={{parseFloat(\'1\')}}')).toEqual(parseFloat('1'));
|
||||
expect(evaluate('={{parseInt(\'1\', 10)}}')).toEqual(parseInt('1', 10));
|
||||
expect(evaluate("={{parseFloat('1')}}")).toEqual(parseFloat('1'));
|
||||
expect(evaluate("={{parseInt('1', 10)}}")).toEqual(parseInt('1', 10));
|
||||
|
||||
expect(evaluate('={{JSON.stringify({})}}')).toEqual(JSON.stringify({}));
|
||||
expect(evaluate('={{new ArrayBuffer(10)}}')).toEqual(new ArrayBuffer(10));
|
||||
expect(evaluate('={{new SharedArrayBuffer(10)}}')).toEqual(new SharedArrayBuffer(10));
|
||||
expect(evaluate('={{Atomics}}')).toEqual(Atomics);
|
||||
expect(evaluate('={{new DataView(new ArrayBuffer(1))}}')).toEqual(new DataView(new ArrayBuffer(1)));
|
||||
expect(evaluate('={{new DataView(new ArrayBuffer(1))}}')).toEqual(
|
||||
new DataView(new ArrayBuffer(1)),
|
||||
);
|
||||
|
||||
expect(evaluate('={{encodeURI(\'https://google.com\')}}')).toEqual(encodeURI('https://google.com'));
|
||||
expect(evaluate('={{encodeURIComponent(\'https://google.com\')}}')).toEqual(encodeURIComponent('https://google.com'));
|
||||
expect(evaluate('={{decodeURI(\'https://google.com\')}}')).toEqual(decodeURI('https://google.com'));
|
||||
expect(evaluate('={{decodeURIComponent(\'https://google.com\')}}')).toEqual(decodeURIComponent('https://google.com'));
|
||||
expect(evaluate("={{encodeURI('https://google.com')}}")).toEqual(
|
||||
encodeURI('https://google.com'),
|
||||
);
|
||||
expect(evaluate("={{encodeURIComponent('https://google.com')}}")).toEqual(
|
||||
encodeURIComponent('https://google.com'),
|
||||
);
|
||||
expect(evaluate("={{decodeURI('https://google.com')}}")).toEqual(
|
||||
decodeURI('https://google.com'),
|
||||
);
|
||||
expect(evaluate("={{decodeURIComponent('https://google.com')}}")).toEqual(
|
||||
decodeURIComponent('https://google.com'),
|
||||
);
|
||||
|
||||
expect(evaluate('={{Boolean(1)}}')).toEqual(Boolean(1));
|
||||
expect(evaluate('={{Symbol(1).toString()}}')).toEqual(Symbol(1).toString());
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
@@ -119,8 +119,8 @@ export class CredentialsHelper extends ICredentialsHelper {
|
||||
node: INode,
|
||||
credentialsExpired: boolean,
|
||||
): Promise<{ updatedCredentials: boolean; data: ICredentialDataDecryptedObject }> {
|
||||
return { updatedCredentials: false, data: {} }
|
||||
};
|
||||
return { updatedCredentials: false, data: {} };
|
||||
}
|
||||
|
||||
getParentTypes(name: string): string[] {
|
||||
return [];
|
||||
|
||||
@@ -181,11 +181,7 @@ function numericId(length = positiveDigit()) {
|
||||
}
|
||||
|
||||
function alphanumericId() {
|
||||
return chooseRandomly([
|
||||
`john${numericId()}`,
|
||||
`title${numericId(1)}`,
|
||||
numericId(),
|
||||
]);
|
||||
return chooseRandomly([`john${numericId()}`, `title${numericId(1)}`, numericId()]);
|
||||
}
|
||||
|
||||
const chooseRandomly = <T>(array: T[]) => array[Math.floor(Math.random() * array.length)];
|
||||
|
||||
Reference in New Issue
Block a user