Skip to content

Commit

Permalink
perf(tooling): Upgrade to TypeScript 4.8 (#4207)
Browse files Browse the repository at this point in the history
* ⬆️ 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>
  • Loading branch information
ivov and netroy authored Oct 5, 2022
1 parent cc2a2e4 commit 9089dbe
Show file tree
Hide file tree
Showing 39 changed files with 37,651 additions and 27,520 deletions.
64,775 changes: 37,448 additions & 27,327 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"supertest": "^6.2.2",
"ts-jest": "^27.1.3",
"ts-node": "^8.9.1",
"typescript": "~4.6.0"
"typescript": "~4.8.0"
},
"dependencies": {
"@oclif/command": "^1.5.18",
Expand Down
8 changes: 7 additions & 1 deletion packages/cli/src/Db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
EntityTarget,
getRepository,
LoggerOptions,
ObjectLiteral,
Repository,
} from 'typeorm';
import { TlsOptions } from 'tls';
Expand All @@ -38,7 +39,9 @@ export async function transaction<T>(fn: (entityManager: EntityManager) => Promi
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);
}

Expand Down Expand Up @@ -183,9 +186,12 @@ export async function init(
}
}

// @ts-ignore
collections.Credentials = linkRepository(entities.CredentialsEntity);
// @ts-ignore
collections.Execution = linkRepository(entities.ExecutionEntity);
collections.Workflow = linkRepository(entities.WorkflowEntity);
// @ts-ignore
collections.Webhook = linkRepository(entities.WebhookEntity);
collections.Tag = linkRepository(entities.TagEntity);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import express from 'express';

import { FindManyOptions, In } from 'typeorm';
import { FindManyOptions, In, ObjectLiteral } from 'typeorm';

import { ActiveWorkflowRunner, Db } from '../../../..';
import config = require('../../../../../config');
Expand Down Expand Up @@ -110,7 +110,7 @@ export = {
let workflows: WorkflowEntity[];
let count: number;

const query: FindManyOptions<WorkflowEntity> = {
const query: FindManyOptions<WorkflowEntity> & { where: ObjectLiteral } = {
skip: offset,
take: limit,
where: {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"jest": "^27.4.7",
"source-map-support": "^0.5.9",
"ts-jest": "^27.1.3",
"typescript": "~4.6.0"
"typescript": "~4.8.0"
},
"dependencies": {
"axios": "^0.21.1",
Expand Down
15 changes: 6 additions & 9 deletions packages/core/src/NodeExecuteFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -964,18 +964,16 @@ export async function requestOAuth2(
// Signs the request by adding authorization headers or query parameters depending
// on the token-type used.
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 (oAuth2Options?.keepBearer === false) {
// @ts-ignore
newRequestOptions?.headers?.Authorization =
newRequestHeaders.Authorization =
// @ts-ignore
newRequestOptions?.headers?.Authorization.split(' ')[1];
newRequestHeaders.Authorization.split(' ')[1];
}

// @ts-ignore
if (oAuth2Options?.keyToIncludeInAccessTokenHeader) {
Object.assign(newRequestOptions.headers, {
// @ts-ignore
Object.assign(newRequestHeaders, {
[oAuth2Options.keyToIncludeInAccessTokenHeader]: token.accessToken,
});
}
Expand Down Expand Up @@ -1030,10 +1028,8 @@ export async function requestOAuth2(
);
const refreshedRequestOption = newToken.sign(requestOptions as clientOAuth2.RequestObject);

// @ts-ignore
if (oAuth2Options?.keyToIncludeInAccessTokenHeader) {
Object.assign(newRequestOptions.headers, {
// @ts-ignore
Object.assign(newRequestHeaders, {
[oAuth2Options.keyToIncludeInAccessTokenHeader]: token.accessToken,
});
}
Expand Down Expand Up @@ -1108,6 +1104,7 @@ export async function requestOAuth2(

// Make the request again with the new token
const newRequestOptions = newToken.sign(requestOptions as clientOAuth2.RequestObject);
newRequestOptions.headers = newRequestOptions.headers ?? {};

// @ts-ignore
if (oAuth2Options?.keyToIncludeInAccessTokenHeader) {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/UserSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export async function prepareUserSettings(): Promise<IUserSettings> {

export async function getEncryptionKey(): Promise<string> {
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();
Expand Down Expand Up @@ -233,7 +233,7 @@ export function getUserSettingsPath(): string {
export function getUserN8nFolderPath(): string {
let userFolder;
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 {
userFolder = getUserHome();
}
Expand Down
3 changes: 1 addition & 2 deletions packages/core/test/Helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ export class CredentialsHelper extends ICredentialsHelper {
credentialsExpired: boolean,
): Promise<ICredentialDataDecryptedObject | undefined> {
return undefined;
};

}

getParentTypes(name: string): string[] {
return [];
Expand Down
2 changes: 1 addition & 1 deletion packages/design-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"storybook-addon-designs": "^6.3.1",
"storybook-addon-themes": "^6.1.0",
"trim": ">=0.0.3",
"typescript": "~4.6.0",
"typescript": "~4.8.0",
"vite": "2.9.5",
"vite-plugin-vue2": "1.9.3",
"vitest": "0.9.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"sass-loader": "^8.0.2",
"string-template-parser": "^1.2.6",
"tslint": "^6.1.2",
"typescript": "~4.6.0",
"typescript": "~4.8.0",
"vite": "2.9",
"vite-plugin-html": "^3.2.0",
"vite-plugin-monaco-editor": "^1.0.10",
Expand Down
2 changes: 1 addition & 1 deletion packages/node-dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@
"replace-in-file": "^6.0.0",
"request": "^2.88.2",
"tmp-promise": "^3.0.2",
"typescript": "~4.6.0"
"typescript": "~4.8.0"
}
}
4 changes: 2 additions & 2 deletions packages/nodes-base/credentials/PushoverApi.credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export class PushoverApi implements ICredentialType {
credentials: ICredentialDataDecryptedObject,
requestOptions: IHttpRequestOptions,
): Promise<IHttpRequestOptions> {
if (requestOptions.method === 'GET') {
if (requestOptions.method === 'GET' && requestOptions.qs) {
Object.assign(requestOptions.qs, { token: credentials.apiKey });
} else {
} else if (requestOptions.body) {
Object.assign(requestOptions.body, { token: credentials.apiKey });
}
return requestOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class WooCommerceApi implements ICredentialType {
user: credentials.consumerKey as string,
password: credentials.consumerSecret as string,
};
if (credentials.includeCredentialsInQuery === true) {
if (credentials.includeCredentialsInQuery === true && requestOptions.qs) {
delete requestOptions.auth;
Object.assign(requestOptions.qs, {
consumer_key: credentials.consumerKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export class ActionNetwork implements INodeType {

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));
}

Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Aws/S3/AwsS3.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ export class AwsS3 implements INodeType {
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
// data references which do not get changed still stay behind
// but the incoming data does not get changed.
Expand Down
64 changes: 33 additions & 31 deletions packages/nodes-base/nodes/Aws/Transcribe/AwsTranscribe.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,42 +382,44 @@ export class AwsTranscribe implements INodeType {
body.LanguageCode = this.getNodeParameter('languageCode', i) as string;
}

if (options.channelIdentification) {
Object.assign(body.Settings, {
ChannelIdentification: options.channelIdentification,
});
}
if (body.Settings) {
if (options.channelIdentification) {
Object.assign(body.Settings, {
ChannelIdentification: options.channelIdentification,
});
}

if (options.maxAlternatives) {
Object.assign(body.Settings, {
ShowAlternatives: true,
MaxAlternatives: options.maxAlternatives,
});
}
if (options.maxAlternatives) {
Object.assign(body.Settings, {
ShowAlternatives: true,
MaxAlternatives: options.maxAlternatives,
});
}

if (options.maxSpeakerLabels) {
Object.assign(body.Settings, {
ShowSpeakerLabels: true,
MaxSpeakerLabels: options.maxSpeakerLabels,
});
}
if (options.maxSpeakerLabels) {
Object.assign(body.Settings, {
ShowSpeakerLabels: true,
MaxSpeakerLabels: options.maxSpeakerLabels,
});
}

if (options.vocabularyName) {
Object.assign(body.Settings, {
VocabularyName: options.vocabularyName,
});
}
if (options.vocabularyName) {
Object.assign(body.Settings, {
VocabularyName: options.vocabularyName,
});
}

if (options.vocabularyFilterName) {
Object.assign(body.Settings, {
VocabularyFilterName: options.vocabularyFilterName,
});
}
if (options.vocabularyFilterName) {
Object.assign(body.Settings, {
VocabularyFilterName: options.vocabularyFilterName,
});
}

if (options.vocabularyFilterMethod) {
Object.assign(body.Settings, {
VocabularyFilterMethod: options.vocabularyFilterMethod,
});
if (options.vocabularyFilterMethod) {
Object.assign(body.Settings, {
VocabularyFilterMethod: options.vocabularyFilterMethod,
});
}
}

const action = 'Transcribe.StartTranscriptionJob';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export async function get(this: IExecuteFunctions, index: number) {
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
// data references which do not get changed still stay behind
// but the incoming data does not get changed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function download(this: IExecuteFunctions, index: number) {
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
// data references which do not get changed still stay behind
// but the incoming data does not get changed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export async function upload(this: IExecuteFunctions, index: number) {
resolveWithFullResponse: true,
};

if (options.hasOwnProperty('share')) {
if (options.hasOwnProperty('share') && body.formData) {
Object.assign(body.formData, options.share ? { share: 'yes' } : { share: 'no' });
}
//endpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function download(this: IExecuteFunctions, index: number) {
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
// data references which do not get changed still stay behind
// but the incoming data does not get changed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ export async function upload(this: IExecuteFunctions, index: number) {
resolveWithFullResponse: true,
};

Object.assign(body.formData, share ? { share: 'yes' } : { share: 'no' });
if (body.formData) {
Object.assign(body.formData, share ? { share: 'yes' } : { share: 'no' });
}

//endpoint
const endpoint = `files`;
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/EditImage/EditImage.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
// data references which do not get changed still stay behind
// but the incoming data does not get changed.
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Ftp/Ftp.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ export class Ftp implements INodeType {
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
// data references which do not get changed still stay behind
// but the incoming data does not get changed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ export class HomeAssistant implements INodeType {
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
// data references which do not get changed still stay behind
// but the incoming data does not get changed.
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Metabase/QuestionsDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const questionsOperations: INodeProperties[] = [
binary: {},
};

if (items[i].binary !== undefined) {
if (items[i].binary !== undefined && newItem.binary) {
Object.assign(newItem.binary, items[i].binary);
}
items[i] = newItem;
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Postmark/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function postmarkApiRequest(
uri: 'https://api.postmarkapp.com' + endpoint,
json: true,
};
if (body === {}) {
if (Object.keys(body).length === 0) {
delete options.body;
}
options = Object.assign({}, options, option);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
// data references which do not get changed still stay behind
// but the incoming data does not get changed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export class SecurityScorecard implements INodeType {
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
// data references which do not get changed still stay behind
// but the incoming data does not get changed.
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Ssh/Ssh.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
// data references which do not get changed still stay behind
// but the incoming data does not get changed.
Expand Down
Loading

0 comments on commit 9089dbe

Please sign in to comment.