mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 12:44:07 -08: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:
parent
cc2a2e438b
commit
9089dbe942
31707
package-lock.json
generated
31707
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -101,7 +101,7 @@
|
||||||
"supertest": "^6.2.2",
|
"supertest": "^6.2.2",
|
||||||
"ts-jest": "^27.1.3",
|
"ts-jest": "^27.1.3",
|
||||||
"ts-node": "^8.9.1",
|
"ts-node": "^8.9.1",
|
||||||
"typescript": "~4.6.0"
|
"typescript": "~4.8.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@oclif/command": "^1.5.18",
|
"@oclif/command": "^1.5.18",
|
||||||
|
|
|
@ -13,6 +13,7 @@ import {
|
||||||
EntityTarget,
|
EntityTarget,
|
||||||
getRepository,
|
getRepository,
|
||||||
LoggerOptions,
|
LoggerOptions,
|
||||||
|
ObjectLiteral,
|
||||||
Repository,
|
Repository,
|
||||||
} from 'typeorm';
|
} from 'typeorm';
|
||||||
import { TlsOptions } from 'tls';
|
import { TlsOptions } from 'tls';
|
||||||
|
@ -38,7 +39,9 @@ export async function transaction<T>(fn: (entityManager: EntityManager) => Promi
|
||||||
return connection.transaction(fn);
|
return connection.transaction(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function linkRepository<Entity>(entityClass: EntityTarget<Entity>): Repository<Entity> {
|
export function linkRepository<Entity extends ObjectLiteral>(
|
||||||
|
entityClass: EntityTarget<Entity>,
|
||||||
|
): Repository<Entity> {
|
||||||
return getRepository(entityClass, connection.name);
|
return getRepository(entityClass, connection.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,9 +186,12 @@ export async function init(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
collections.Credentials = linkRepository(entities.CredentialsEntity);
|
collections.Credentials = linkRepository(entities.CredentialsEntity);
|
||||||
|
// @ts-ignore
|
||||||
collections.Execution = linkRepository(entities.ExecutionEntity);
|
collections.Execution = linkRepository(entities.ExecutionEntity);
|
||||||
collections.Workflow = linkRepository(entities.WorkflowEntity);
|
collections.Workflow = linkRepository(entities.WorkflowEntity);
|
||||||
|
// @ts-ignore
|
||||||
collections.Webhook = linkRepository(entities.WebhookEntity);
|
collections.Webhook = linkRepository(entities.WebhookEntity);
|
||||||
collections.Tag = linkRepository(entities.TagEntity);
|
collections.Tag = linkRepository(entities.TagEntity);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
|
|
||||||
import { FindManyOptions, In } from 'typeorm';
|
import { FindManyOptions, In, ObjectLiteral } from 'typeorm';
|
||||||
|
|
||||||
import { ActiveWorkflowRunner, Db } from '../../../..';
|
import { ActiveWorkflowRunner, Db } from '../../../..';
|
||||||
import config = require('../../../../../config');
|
import config = require('../../../../../config');
|
||||||
|
@ -110,7 +110,7 @@ export = {
|
||||||
let workflows: WorkflowEntity[];
|
let workflows: WorkflowEntity[];
|
||||||
let count: number;
|
let count: number;
|
||||||
|
|
||||||
const query: FindManyOptions<WorkflowEntity> = {
|
const query: FindManyOptions<WorkflowEntity> & { where: ObjectLiteral } = {
|
||||||
skip: offset,
|
skip: offset,
|
||||||
take: limit,
|
take: limit,
|
||||||
where: {
|
where: {
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
"jest": "^27.4.7",
|
"jest": "^27.4.7",
|
||||||
"source-map-support": "^0.5.9",
|
"source-map-support": "^0.5.9",
|
||||||
"ts-jest": "^27.1.3",
|
"ts-jest": "^27.1.3",
|
||||||
"typescript": "~4.6.0"
|
"typescript": "~4.8.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
|
|
|
@ -964,18 +964,16 @@ export async function requestOAuth2(
|
||||||
// Signs the request by adding authorization headers or query parameters depending
|
// Signs the request by adding authorization headers or query parameters depending
|
||||||
// on the token-type used.
|
// on the token-type used.
|
||||||
const newRequestOptions = token.sign(requestOptions as clientOAuth2.RequestObject);
|
const newRequestOptions = token.sign(requestOptions as clientOAuth2.RequestObject);
|
||||||
|
const newRequestHeaders = (newRequestOptions.headers = newRequestOptions.headers ?? {});
|
||||||
// If keep bearer is false remove the it from the authorization header
|
// If keep bearer is false remove the it from the authorization header
|
||||||
if (oAuth2Options?.keepBearer === false) {
|
if (oAuth2Options?.keepBearer === false) {
|
||||||
|
newRequestHeaders.Authorization =
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
newRequestOptions?.headers?.Authorization =
|
newRequestHeaders.Authorization.split(' ')[1];
|
||||||
// @ts-ignore
|
|
||||||
newRequestOptions?.headers?.Authorization.split(' ')[1];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
if (oAuth2Options?.keyToIncludeInAccessTokenHeader) {
|
if (oAuth2Options?.keyToIncludeInAccessTokenHeader) {
|
||||||
Object.assign(newRequestOptions.headers, {
|
Object.assign(newRequestHeaders, {
|
||||||
// @ts-ignore
|
|
||||||
[oAuth2Options.keyToIncludeInAccessTokenHeader]: token.accessToken,
|
[oAuth2Options.keyToIncludeInAccessTokenHeader]: token.accessToken,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1030,10 +1028,8 @@ export async function requestOAuth2(
|
||||||
);
|
);
|
||||||
const refreshedRequestOption = newToken.sign(requestOptions as clientOAuth2.RequestObject);
|
const refreshedRequestOption = newToken.sign(requestOptions as clientOAuth2.RequestObject);
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
if (oAuth2Options?.keyToIncludeInAccessTokenHeader) {
|
if (oAuth2Options?.keyToIncludeInAccessTokenHeader) {
|
||||||
Object.assign(newRequestOptions.headers, {
|
Object.assign(newRequestHeaders, {
|
||||||
// @ts-ignore
|
|
||||||
[oAuth2Options.keyToIncludeInAccessTokenHeader]: token.accessToken,
|
[oAuth2Options.keyToIncludeInAccessTokenHeader]: token.accessToken,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1108,6 +1104,7 @@ export async function requestOAuth2(
|
||||||
|
|
||||||
// Make the request again with the new token
|
// Make the request again with the new token
|
||||||
const newRequestOptions = newToken.sign(requestOptions as clientOAuth2.RequestObject);
|
const newRequestOptions = newToken.sign(requestOptions as clientOAuth2.RequestObject);
|
||||||
|
newRequestOptions.headers = newRequestOptions.headers ?? {};
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (oAuth2Options?.keyToIncludeInAccessTokenHeader) {
|
if (oAuth2Options?.keyToIncludeInAccessTokenHeader) {
|
||||||
|
|
|
@ -74,7 +74,7 @@ export async function prepareUserSettings(): Promise<IUserSettings> {
|
||||||
|
|
||||||
export async function getEncryptionKey(): Promise<string> {
|
export async function getEncryptionKey(): Promise<string> {
|
||||||
if (process.env[ENCRYPTION_KEY_ENV_OVERWRITE] !== undefined) {
|
if (process.env[ENCRYPTION_KEY_ENV_OVERWRITE] !== undefined) {
|
||||||
return process.env[ENCRYPTION_KEY_ENV_OVERWRITE] as string;
|
return process.env[ENCRYPTION_KEY_ENV_OVERWRITE];
|
||||||
}
|
}
|
||||||
|
|
||||||
const userSettings = await getUserSettings();
|
const userSettings = await getUserSettings();
|
||||||
|
@ -233,7 +233,7 @@ export function getUserSettingsPath(): string {
|
||||||
export function getUserN8nFolderPath(): string {
|
export function getUserN8nFolderPath(): string {
|
||||||
let userFolder;
|
let userFolder;
|
||||||
if (process.env[USER_FOLDER_ENV_OVERWRITE] !== undefined) {
|
if (process.env[USER_FOLDER_ENV_OVERWRITE] !== undefined) {
|
||||||
userFolder = process.env[USER_FOLDER_ENV_OVERWRITE] as string;
|
userFolder = process.env[USER_FOLDER_ENV_OVERWRITE];
|
||||||
} else {
|
} else {
|
||||||
userFolder = getUserHome();
|
userFolder = getUserHome();
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,8 +43,7 @@ export class CredentialsHelper extends ICredentialsHelper {
|
||||||
credentialsExpired: boolean,
|
credentialsExpired: boolean,
|
||||||
): Promise<ICredentialDataDecryptedObject | undefined> {
|
): Promise<ICredentialDataDecryptedObject | undefined> {
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
getParentTypes(name: string): string[] {
|
getParentTypes(name: string): string[] {
|
||||||
return [];
|
return [];
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
"storybook-addon-designs": "^6.3.1",
|
"storybook-addon-designs": "^6.3.1",
|
||||||
"storybook-addon-themes": "^6.1.0",
|
"storybook-addon-themes": "^6.1.0",
|
||||||
"trim": ">=0.0.3",
|
"trim": ">=0.0.3",
|
||||||
"typescript": "~4.6.0",
|
"typescript": "~4.8.0",
|
||||||
"vite": "2.9.5",
|
"vite": "2.9.5",
|
||||||
"vite-plugin-vue2": "1.9.3",
|
"vite-plugin-vue2": "1.9.3",
|
||||||
"vitest": "0.9.3",
|
"vitest": "0.9.3",
|
||||||
|
|
|
@ -95,7 +95,7 @@
|
||||||
"sass-loader": "^8.0.2",
|
"sass-loader": "^8.0.2",
|
||||||
"string-template-parser": "^1.2.6",
|
"string-template-parser": "^1.2.6",
|
||||||
"tslint": "^6.1.2",
|
"tslint": "^6.1.2",
|
||||||
"typescript": "~4.6.0",
|
"typescript": "~4.8.0",
|
||||||
"vite": "2.9",
|
"vite": "2.9",
|
||||||
"vite-plugin-html": "^3.2.0",
|
"vite-plugin-html": "^3.2.0",
|
||||||
"vite-plugin-monaco-editor": "^1.0.10",
|
"vite-plugin-monaco-editor": "^1.0.10",
|
||||||
|
|
|
@ -66,6 +66,6 @@
|
||||||
"replace-in-file": "^6.0.0",
|
"replace-in-file": "^6.0.0",
|
||||||
"request": "^2.88.2",
|
"request": "^2.88.2",
|
||||||
"tmp-promise": "^3.0.2",
|
"tmp-promise": "^3.0.2",
|
||||||
"typescript": "~4.6.0"
|
"typescript": "~4.8.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,9 @@ export class PushoverApi implements ICredentialType {
|
||||||
credentials: ICredentialDataDecryptedObject,
|
credentials: ICredentialDataDecryptedObject,
|
||||||
requestOptions: IHttpRequestOptions,
|
requestOptions: IHttpRequestOptions,
|
||||||
): Promise<IHttpRequestOptions> {
|
): Promise<IHttpRequestOptions> {
|
||||||
if (requestOptions.method === 'GET') {
|
if (requestOptions.method === 'GET' && requestOptions.qs) {
|
||||||
Object.assign(requestOptions.qs, { token: credentials.apiKey });
|
Object.assign(requestOptions.qs, { token: credentials.apiKey });
|
||||||
} else {
|
} else if (requestOptions.body) {
|
||||||
Object.assign(requestOptions.body, { token: credentials.apiKey });
|
Object.assign(requestOptions.body, { token: credentials.apiKey });
|
||||||
}
|
}
|
||||||
return requestOptions;
|
return requestOptions;
|
||||||
|
|
|
@ -48,7 +48,7 @@ export class WooCommerceApi implements ICredentialType {
|
||||||
user: credentials.consumerKey as string,
|
user: credentials.consumerKey as string,
|
||||||
password: credentials.consumerSecret as string,
|
password: credentials.consumerSecret as string,
|
||||||
};
|
};
|
||||||
if (credentials.includeCredentialsInQuery === true) {
|
if (credentials.includeCredentialsInQuery === true && requestOptions.qs) {
|
||||||
delete requestOptions.auth;
|
delete requestOptions.auth;
|
||||||
Object.assign(requestOptions.qs, {
|
Object.assign(requestOptions.qs, {
|
||||||
consumer_key: credentials.consumerKey,
|
consumer_key: credentials.consumerKey,
|
||||||
|
|
|
@ -235,7 +235,7 @@ export class ActionNetwork implements INodeType {
|
||||||
|
|
||||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
|
|
||||||
if (Object.keys(additionalFields).length) {
|
if (Object.keys(additionalFields).length && body.person) {
|
||||||
Object.assign(body.person, adjustPersonPayload(additionalFields));
|
Object.assign(body.person, adjustPersonPayload(additionalFields));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -599,7 +599,7 @@ export class AwsS3 implements INodeType {
|
||||||
binary: {},
|
binary: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (items[i].binary !== undefined) {
|
if (items[i].binary !== undefined && newItem.binary) {
|
||||||
// Create a shallow copy of the binary data so that the old
|
// Create a shallow copy of the binary data so that the old
|
||||||
// data references which do not get changed still stay behind
|
// data references which do not get changed still stay behind
|
||||||
// but the incoming data does not get changed.
|
// but the incoming data does not get changed.
|
||||||
|
|
|
@ -382,6 +382,7 @@ export class AwsTranscribe implements INodeType {
|
||||||
body.LanguageCode = this.getNodeParameter('languageCode', i) as string;
|
body.LanguageCode = this.getNodeParameter('languageCode', i) as string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (body.Settings) {
|
||||||
if (options.channelIdentification) {
|
if (options.channelIdentification) {
|
||||||
Object.assign(body.Settings, {
|
Object.assign(body.Settings, {
|
||||||
ChannelIdentification: options.channelIdentification,
|
ChannelIdentification: options.channelIdentification,
|
||||||
|
@ -419,6 +420,7 @@ export class AwsTranscribe implements INodeType {
|
||||||
VocabularyFilterMethod: options.vocabularyFilterMethod,
|
VocabularyFilterMethod: options.vocabularyFilterMethod,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const action = 'Transcribe.StartTranscriptionJob';
|
const action = 'Transcribe.StartTranscriptionJob';
|
||||||
responseData = await awsApiRequestREST.call(
|
responseData = await awsApiRequestREST.call(
|
||||||
|
|
|
@ -53,7 +53,7 @@ export async function get(this: IExecuteFunctions, index: number) {
|
||||||
binary: {},
|
binary: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (items[index].binary !== undefined) {
|
if (items[index].binary !== undefined && newItem.binary) {
|
||||||
// Create a shallow copy of the binary data so that the old
|
// Create a shallow copy of the binary data so that the old
|
||||||
// data references which do not get changed still stay behind
|
// data references which do not get changed still stay behind
|
||||||
// but the incoming data does not get changed.
|
// but the incoming data does not get changed.
|
||||||
|
|
|
@ -40,7 +40,7 @@ export async function download(this: IExecuteFunctions, index: number) {
|
||||||
binary: {},
|
binary: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (items[index].binary !== undefined) {
|
if (items[index].binary !== undefined && newItem.binary) {
|
||||||
// Create a shallow copy of the binary data so that the old
|
// Create a shallow copy of the binary data so that the old
|
||||||
// data references which do not get changed still stay behind
|
// data references which do not get changed still stay behind
|
||||||
// but the incoming data does not get changed.
|
// but the incoming data does not get changed.
|
||||||
|
|
|
@ -53,7 +53,7 @@ export async function upload(this: IExecuteFunctions, index: number) {
|
||||||
resolveWithFullResponse: true,
|
resolveWithFullResponse: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (options.hasOwnProperty('share')) {
|
if (options.hasOwnProperty('share') && body.formData) {
|
||||||
Object.assign(body.formData, options.share ? { share: 'yes' } : { share: 'no' });
|
Object.assign(body.formData, options.share ? { share: 'yes' } : { share: 'no' });
|
||||||
}
|
}
|
||||||
//endpoint
|
//endpoint
|
||||||
|
|
|
@ -40,7 +40,7 @@ export async function download(this: IExecuteFunctions, index: number) {
|
||||||
binary: {},
|
binary: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (items[index].binary !== undefined) {
|
if (items[index].binary !== undefined && newItem.binary) {
|
||||||
// Create a shallow copy of the binary data so that the old
|
// Create a shallow copy of the binary data so that the old
|
||||||
// data references which do not get changed still stay behind
|
// data references which do not get changed still stay behind
|
||||||
// but the incoming data does not get changed.
|
// but the incoming data does not get changed.
|
||||||
|
|
|
@ -51,7 +51,9 @@ export async function upload(this: IExecuteFunctions, index: number) {
|
||||||
resolveWithFullResponse: true,
|
resolveWithFullResponse: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (body.formData) {
|
||||||
Object.assign(body.formData, share ? { share: 'yes' } : { share: 'no' });
|
Object.assign(body.formData, share ? { share: 'yes' } : { share: 'no' });
|
||||||
|
}
|
||||||
|
|
||||||
//endpoint
|
//endpoint
|
||||||
const endpoint = `files`;
|
const endpoint = `files`;
|
||||||
|
|
|
@ -1262,7 +1262,7 @@ export class EditImage implements INodeType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.binary !== undefined) {
|
if (item.binary !== undefined && newItem.binary) {
|
||||||
// Create a shallow copy of the binary data so that the old
|
// Create a shallow copy of the binary data so that the old
|
||||||
// data references which do not get changed still stay behind
|
// data references which do not get changed still stay behind
|
||||||
// but the incoming data does not get changed.
|
// but the incoming data does not get changed.
|
||||||
|
|
|
@ -456,7 +456,7 @@ export class Ftp implements INodeType {
|
||||||
binary: {},
|
binary: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (items[i].binary !== undefined) {
|
if (items[i].binary !== undefined && newItem.binary) {
|
||||||
// Create a shallow copy of the binary data so that the old
|
// Create a shallow copy of the binary data so that the old
|
||||||
// data references which do not get changed still stay behind
|
// data references which do not get changed still stay behind
|
||||||
// but the incoming data does not get changed.
|
// but the incoming data does not get changed.
|
||||||
|
|
|
@ -422,7 +422,7 @@ export class HomeAssistant implements INodeType {
|
||||||
mimeType = responseData.headers['content-type'];
|
mimeType = responseData.headers['content-type'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items[i].binary !== undefined) {
|
if (items[i].binary !== undefined && newItem.binary) {
|
||||||
// Create a shallow copy of the binary data so that the old
|
// Create a shallow copy of the binary data so that the old
|
||||||
// data references which do not get changed still stay behind
|
// data references which do not get changed still stay behind
|
||||||
// but the incoming data does not get changed.
|
// but the incoming data does not get changed.
|
||||||
|
|
|
@ -69,7 +69,7 @@ export const questionsOperations: INodeProperties[] = [
|
||||||
binary: {},
|
binary: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (items[i].binary !== undefined) {
|
if (items[i].binary !== undefined && newItem.binary) {
|
||||||
Object.assign(newItem.binary, items[i].binary);
|
Object.assign(newItem.binary, items[i].binary);
|
||||||
}
|
}
|
||||||
items[i] = newItem;
|
items[i] = newItem;
|
||||||
|
|
|
@ -32,7 +32,7 @@ export async function postmarkApiRequest(
|
||||||
uri: 'https://api.postmarkapp.com' + endpoint,
|
uri: 'https://api.postmarkapp.com' + endpoint,
|
||||||
json: true,
|
json: true,
|
||||||
};
|
};
|
||||||
if (body === {}) {
|
if (Object.keys(body).length === 0) {
|
||||||
delete options.body;
|
delete options.body;
|
||||||
}
|
}
|
||||||
options = Object.assign({}, options, option);
|
options = Object.assign({}, options, option);
|
||||||
|
|
|
@ -78,7 +78,7 @@ export class ReadBinaryFile implements INodeType {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (item.binary !== undefined) {
|
if (item.binary !== undefined && newItem.binary) {
|
||||||
// Create a shallow copy of the binary data so that the old
|
// Create a shallow copy of the binary data so that the old
|
||||||
// data references which do not get changed still stay behind
|
// data references which do not get changed still stay behind
|
||||||
// but the incoming data does not get changed.
|
// but the incoming data does not get changed.
|
||||||
|
|
|
@ -233,7 +233,7 @@ export class SecurityScorecard implements INodeType {
|
||||||
binary: {},
|
binary: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (items[i].binary !== undefined) {
|
if (items[i].binary !== undefined && newItem.binary) {
|
||||||
// Create a shallow copy of the binary data so that the old
|
// Create a shallow copy of the binary data so that the old
|
||||||
// data references which do not get changed still stay behind
|
// data references which do not get changed still stay behind
|
||||||
// but the incoming data does not get changed.
|
// but the incoming data does not get changed.
|
||||||
|
|
|
@ -323,7 +323,7 @@ export class Ssh implements INodeType {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (items[i].binary !== undefined) {
|
if (items[i].binary !== undefined && newItem.binary) {
|
||||||
// Create a shallow copy of the binary data so that the old
|
// Create a shallow copy of the binary data so that the old
|
||||||
// data references which do not get changed still stay behind
|
// data references which do not get changed still stay behind
|
||||||
// but the incoming data does not get changed.
|
// but the incoming data does not get changed.
|
||||||
|
|
|
@ -49,8 +49,10 @@ export async function storyblokApiRequest(
|
||||||
|
|
||||||
options.uri = `https://mapi.storyblok.com${resource}`;
|
options.uri = `https://mapi.storyblok.com${resource}`;
|
||||||
|
|
||||||
|
if (options.headers) {
|
||||||
Object.assign(options.headers, { Authorization: credentials.accessToken });
|
Object.assign(options.headers, { Authorization: credentials.accessToken });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return this.helpers.request!(options);
|
return this.helpers.request!(options);
|
||||||
|
|
|
@ -52,7 +52,9 @@ export async function setType(this: IExecuteSingleFunctions, requestOptions: IHt
|
||||||
actualType = 'template';
|
actualType = 'template';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (requestOptions.body) {
|
||||||
Object.assign(requestOptions.body, { type: actualType });
|
Object.assign(requestOptions.body, { type: actualType });
|
||||||
|
}
|
||||||
|
|
||||||
return requestOptions;
|
return requestOptions;
|
||||||
}
|
}
|
||||||
|
|
|
@ -742,7 +742,7 @@
|
||||||
"n8n-workflow": "~0.118.0",
|
"n8n-workflow": "~0.118.0",
|
||||||
"ts-jest": "^27.1.3",
|
"ts-jest": "^27.1.3",
|
||||||
"tslint": "^6.1.2",
|
"tslint": "^6.1.2",
|
||||||
"typescript": "~4.6.0"
|
"typescript": "~4.8.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@kafkajs/confluent-schema-registry": "1.0.6",
|
"@kafkajs/confluent-schema-registry": "1.0.6",
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
"jest-environment-jsdom": "^27.5.1",
|
"jest-environment-jsdom": "^27.5.1",
|
||||||
"prettier": "^2.3.2",
|
"prettier": "^2.3.2",
|
||||||
"ts-jest": "^27.1.3",
|
"ts-jest": "^27.1.3",
|
||||||
"typescript": "~4.6.0"
|
"typescript": "~4.8.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@n8n_io/riot-tmpl": "^1.0.1",
|
"@n8n_io/riot-tmpl": "^1.0.1",
|
||||||
|
|
|
@ -241,7 +241,7 @@ export class RoutingNode {
|
||||||
merge(destinationOptions.options, sourceOptions.options);
|
merge(destinationOptions.options, sourceOptions.options);
|
||||||
destinationOptions.preSend.push(...sourceOptions.preSend);
|
destinationOptions.preSend.push(...sourceOptions.preSend);
|
||||||
destinationOptions.postReceive.push(...sourceOptions.postReceive);
|
destinationOptions.postReceive.push(...sourceOptions.postReceive);
|
||||||
if (sourceOptions.requestOperations) {
|
if (sourceOptions.requestOperations && destinationOptions.requestOperations) {
|
||||||
destinationOptions.requestOperations = Object.assign(
|
destinationOptions.requestOperations = Object.assign(
|
||||||
destinationOptions.requestOperations,
|
destinationOptions.requestOperations,
|
||||||
sourceOptions.requestOperations,
|
sourceOptions.requestOperations,
|
||||||
|
|
|
@ -1,48 +1,48 @@
|
||||||
import { toCronExpression } from "../src/Cron"
|
import { toCronExpression } from '../src/Cron';
|
||||||
|
|
||||||
describe('Cron', () => {
|
describe('Cron', () => {
|
||||||
describe('toCronExpression', () => {
|
describe('toCronExpression', () => {
|
||||||
test('should generate a valid cron for `everyMinute` triggers', () => {
|
test('should generate a valid cron for `everyMinute` triggers', () => {
|
||||||
const expression = toCronExpression({
|
const expression = toCronExpression({
|
||||||
mode: 'everyMinute',
|
mode: 'everyMinute',
|
||||||
})
|
});
|
||||||
expect(expression).toMatch(/^[1-6]?[0-9] \* \* \* \* \*$/)
|
expect(expression).toMatch(/^[1-6]?[0-9] \* \* \* \* \*$/);
|
||||||
})
|
});
|
||||||
|
|
||||||
test('should generate a valid cron for `everyHour` triggers', () => {
|
test('should generate a valid cron for `everyHour` triggers', () => {
|
||||||
const expression = toCronExpression({
|
const expression = toCronExpression({
|
||||||
mode: 'everyHour',
|
mode: 'everyHour',
|
||||||
minute: 11,
|
minute: 11,
|
||||||
})
|
});
|
||||||
expect(expression).toMatch(/^[1-6]?[0-9] 11 \* \* \* \*$/)
|
expect(expression).toMatch(/^[1-6]?[0-9] 11 \* \* \* \*$/);
|
||||||
})
|
});
|
||||||
|
|
||||||
test('should generate a valid cron for `everyX[minutes]` triggers', () => {
|
test('should generate a valid cron for `everyX[minutes]` triggers', () => {
|
||||||
const expression = toCronExpression({
|
const expression = toCronExpression({
|
||||||
mode: 'everyX',
|
mode: 'everyX',
|
||||||
unit: 'minutes',
|
unit: 'minutes',
|
||||||
value: 42,
|
value: 42,
|
||||||
})
|
});
|
||||||
expect(expression).toMatch(/^[1-6]?[0-9] \*\/42 \* \* \* \*$/)
|
expect(expression).toMatch(/^[1-6]?[0-9] \*\/42 \* \* \* \*$/);
|
||||||
})
|
});
|
||||||
|
|
||||||
test('should generate a valid cron for `everyX[hours]` triggers', () => {
|
test('should generate a valid cron for `everyX[hours]` triggers', () => {
|
||||||
const expression = toCronExpression({
|
const expression = toCronExpression({
|
||||||
mode: 'everyX',
|
mode: 'everyX',
|
||||||
unit: 'hours',
|
unit: 'hours',
|
||||||
value: 3,
|
value: 3,
|
||||||
})
|
});
|
||||||
expect(expression).toMatch(/^[1-6]?[0-9] 0 \*\/3 \* \* \*$/)
|
expect(expression).toMatch(/^[1-6]?[0-9] 0 \*\/3 \* \* \*$/);
|
||||||
})
|
});
|
||||||
|
|
||||||
test('should generate a valid cron for `everyDay` triggers', () => {
|
test('should generate a valid cron for `everyDay` triggers', () => {
|
||||||
const expression = toCronExpression({
|
const expression = toCronExpression({
|
||||||
mode: 'everyDay',
|
mode: 'everyDay',
|
||||||
hour: 13,
|
hour: 13,
|
||||||
minute: 17,
|
minute: 17,
|
||||||
})
|
});
|
||||||
expect(expression).toMatch(/^[1-6]?[0-9] 17 13 \* \* \*$/)
|
expect(expression).toMatch(/^[1-6]?[0-9] 17 13 \* \* \*$/);
|
||||||
})
|
});
|
||||||
|
|
||||||
test('should generate a valid cron for `everyWeek` triggers', () => {
|
test('should generate a valid cron for `everyWeek` triggers', () => {
|
||||||
const expression = toCronExpression({
|
const expression = toCronExpression({
|
||||||
|
@ -50,9 +50,9 @@ describe('Cron', () => {
|
||||||
hour: 13,
|
hour: 13,
|
||||||
minute: 17,
|
minute: 17,
|
||||||
weekday: 4,
|
weekday: 4,
|
||||||
})
|
});
|
||||||
expect(expression).toMatch(/^[1-6]?[0-9] 17 13 \* \* 4$/)
|
expect(expression).toMatch(/^[1-6]?[0-9] 17 13 \* \* 4$/);
|
||||||
})
|
});
|
||||||
|
|
||||||
test('should generate a valid cron for `everyMonth` triggers', () => {
|
test('should generate a valid cron for `everyMonth` triggers', () => {
|
||||||
const expression = toCronExpression({
|
const expression = toCronExpression({
|
||||||
|
@ -60,16 +60,16 @@ describe('Cron', () => {
|
||||||
hour: 13,
|
hour: 13,
|
||||||
minute: 17,
|
minute: 17,
|
||||||
dayOfMonth: 12,
|
dayOfMonth: 12,
|
||||||
})
|
});
|
||||||
expect(expression).toMatch(/^[1-6]?[0-9] 17 13 12 \* \*$/)
|
expect(expression).toMatch(/^[1-6]?[0-9] 17 13 12 \* \*$/);
|
||||||
})
|
});
|
||||||
|
|
||||||
test('should trim custom cron expressions', () => {
|
test('should trim custom cron expressions', () => {
|
||||||
const expression = toCronExpression({
|
const expression = toCronExpression({
|
||||||
mode: 'custom',
|
mode: 'custom',
|
||||||
cronExpression: ' 0 9-17 * * * ',
|
cronExpression: ' 0 9-17 * * * ',
|
||||||
})
|
});
|
||||||
expect(expression).toEqual('0 9-17 * * *')
|
expect(expression).toEqual('0 9-17 * * *');
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
|
@ -2,43 +2,32 @@
|
||||||
* @jest-environment jsdom
|
* @jest-environment jsdom
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { Expression, Workflow } from '../src';
|
||||||
Expression,
|
import * as Helpers from './Helpers';
|
||||||
Workflow,
|
import { DateTime, Duration, Interval } from 'luxon';
|
||||||
} from "../src";
|
|
||||||
import * as Helpers from "./Helpers";
|
|
||||||
import {
|
|
||||||
DateTime,
|
|
||||||
Duration,
|
|
||||||
Interval
|
|
||||||
} from "luxon";
|
|
||||||
|
|
||||||
describe('Expression', () => {
|
describe('Expression', () => {
|
||||||
describe('getParameterValue()', () => {
|
describe('getParameterValue()', () => {
|
||||||
const nodeTypes = Helpers.NodeTypes();
|
const nodeTypes = Helpers.NodeTypes();
|
||||||
const workflow = new Workflow({ nodes: [
|
const workflow = new Workflow({
|
||||||
|
nodes: [
|
||||||
{
|
{
|
||||||
name: 'node',
|
name: 'node',
|
||||||
typeVersion: 1,
|
typeVersion: 1,
|
||||||
type: 'test.set',
|
type: 'test.set',
|
||||||
id: 'uuid-1234',
|
id: 'uuid-1234',
|
||||||
position: [0, 0],
|
position: [0, 0],
|
||||||
parameters: {}
|
parameters: {},
|
||||||
}
|
},
|
||||||
], connections: {}, active: false, nodeTypes });
|
],
|
||||||
|
connections: {},
|
||||||
|
active: false,
|
||||||
|
nodeTypes,
|
||||||
|
});
|
||||||
const expression = new Expression(workflow);
|
const expression = new Expression(workflow);
|
||||||
|
|
||||||
const evaluate = (value: string) => expression.getParameterValue(
|
const evaluate = (value: string) =>
|
||||||
value,
|
expression.getParameterValue(value, null, 0, 0, 'node', [], 'manual', '', {});
|
||||||
null,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
'node',
|
|
||||||
[],
|
|
||||||
'manual',
|
|
||||||
'',
|
|
||||||
{},
|
|
||||||
);
|
|
||||||
|
|
||||||
it('should not be able to use global built-ins from denylist', () => {
|
it('should not be able to use global built-ins from denylist', () => {
|
||||||
expect(evaluate('={{document}}')).toEqual({});
|
expect(evaluate('={{document}}')).toEqual({});
|
||||||
|
@ -81,8 +70,12 @@ describe('Expression', () => {
|
||||||
|
|
||||||
it('should be able to use global built-ins from allowlist', () => {
|
it('should be able to use global built-ins from allowlist', () => {
|
||||||
expect(evaluate('={{new Date()}}')).toBeInstanceOf(Date);
|
expect(evaluate('={{new Date()}}')).toBeInstanceOf(Date);
|
||||||
expect(evaluate('={{DateTime.now().toLocaleString()}}')).toEqual(DateTime.now().toLocaleString());
|
expect(evaluate('={{DateTime.now().toLocaleString()}}')).toEqual(
|
||||||
expect(evaluate('={{Interval.after(new Date(), 100)}}')).toEqual(Interval.after(new Date(), 100));
|
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('={{Duration.fromMillis(100)}}')).toEqual(Duration.fromMillis(100));
|
||||||
|
|
||||||
expect(evaluate('={{new Object()}}')).toEqual(new Object());
|
expect(evaluate('={{new Object()}}')).toEqual(new Object());
|
||||||
|
@ -116,31 +109,41 @@ describe('Expression', () => {
|
||||||
expect(evaluate('={{Intl}}')).toEqual(Intl);
|
expect(evaluate('={{Intl}}')).toEqual(Intl);
|
||||||
|
|
||||||
expect(evaluate('={{new String()}}')).toEqual(new String());
|
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('={{Math}}')).toEqual(Math);
|
||||||
expect(evaluate('={{new Number()}}')).toEqual(new Number());
|
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('={{Infinity}}')).toEqual(Infinity);
|
||||||
expect(evaluate('={{NaN}}')).toEqual(NaN);
|
expect(evaluate('={{NaN}}')).toEqual(NaN);
|
||||||
expect(evaluate('={{isFinite(1)}}')).toEqual(isFinite(1));
|
expect(evaluate('={{isFinite(1)}}')).toEqual(isFinite(1));
|
||||||
expect(evaluate('={{isNaN(1)}}')).toEqual(isNaN(1));
|
expect(evaluate('={{isNaN(1)}}')).toEqual(isNaN(1));
|
||||||
expect(evaluate('={{parseFloat(\'1\')}}')).toEqual(parseFloat('1'));
|
expect(evaluate("={{parseFloat('1')}}")).toEqual(parseFloat('1'));
|
||||||
expect(evaluate('={{parseInt(\'1\', 10)}}')).toEqual(parseInt('1', 10));
|
expect(evaluate("={{parseInt('1', 10)}}")).toEqual(parseInt('1', 10));
|
||||||
|
|
||||||
expect(evaluate('={{JSON.stringify({})}}')).toEqual(JSON.stringify({}));
|
expect(evaluate('={{JSON.stringify({})}}')).toEqual(JSON.stringify({}));
|
||||||
expect(evaluate('={{new ArrayBuffer(10)}}')).toEqual(new ArrayBuffer(10));
|
expect(evaluate('={{new ArrayBuffer(10)}}')).toEqual(new ArrayBuffer(10));
|
||||||
expect(evaluate('={{new SharedArrayBuffer(10)}}')).toEqual(new SharedArrayBuffer(10));
|
expect(evaluate('={{new SharedArrayBuffer(10)}}')).toEqual(new SharedArrayBuffer(10));
|
||||||
expect(evaluate('={{Atomics}}')).toEqual(Atomics);
|
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("={{encodeURI('https://google.com')}}")).toEqual(
|
||||||
expect(evaluate('={{encodeURIComponent(\'https://google.com\')}}')).toEqual(encodeURIComponent('https://google.com'));
|
encodeURI('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("={{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('={{Boolean(1)}}')).toEqual(Boolean(1));
|
||||||
expect(evaluate('={{Symbol(1).toString()}}')).toEqual(Symbol(1).toString());
|
expect(evaluate('={{Symbol(1).toString()}}')).toEqual(Symbol(1).toString());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
|
|
|
@ -119,8 +119,8 @@ export class CredentialsHelper extends ICredentialsHelper {
|
||||||
node: INode,
|
node: INode,
|
||||||
credentialsExpired: boolean,
|
credentialsExpired: boolean,
|
||||||
): Promise<{ updatedCredentials: boolean; data: ICredentialDataDecryptedObject }> {
|
): Promise<{ updatedCredentials: boolean; data: ICredentialDataDecryptedObject }> {
|
||||||
return { updatedCredentials: false, data: {} }
|
return { updatedCredentials: false, data: {} };
|
||||||
};
|
}
|
||||||
|
|
||||||
getParentTypes(name: string): string[] {
|
getParentTypes(name: string): string[] {
|
||||||
return [];
|
return [];
|
||||||
|
|
|
@ -181,11 +181,7 @@ function numericId(length = positiveDigit()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function alphanumericId() {
|
function alphanumericId() {
|
||||||
return chooseRandomly([
|
return chooseRandomly([`john${numericId()}`, `title${numericId(1)}`, numericId()]);
|
||||||
`john${numericId()}`,
|
|
||||||
`title${numericId(1)}`,
|
|
||||||
numericId(),
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const chooseRandomly = <T>(array: T[]) => array[Math.floor(Math.random() * array.length)];
|
const chooseRandomly = <T>(array: T[]) => array[Math.floor(Math.random() * array.length)];
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"sourceMap": true
|
"sourceMap": true,
|
||||||
|
"skipLibCheck": true
|
||||||
},
|
},
|
||||||
"exclude": ["**/dist/**/*", "**/node_modules/**/*"]
|
"exclude": ["**/dist/**/*", "**/node_modules/**/*"]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue