From a6fe16cdb50974746c2d3a3369adf177710dfe64 Mon Sep 17 00:00:00 2001 From: Charlie Kolb Date: Fri, 29 Nov 2024 10:55:54 +0100 Subject: [PATCH] Add batch --- .../@n8n/client-oauth2/src/ClientOAuth2.ts | 3 +-- packages/@n8n/client-oauth2/src/CodeFlow.ts | 4 ++-- packages/@n8n/client-oauth2/src/utils.ts | 1 + .../@n8n/nodes-langchain/utils/logWrapper.ts | 1 - packages/cli/src/config/index.ts | 5 +++-- .../oauth/oauth1-credential.controller.ts | 3 ++- packages/cli/src/credentials-helper.ts | 6 +++--- packages/cli/src/credentials-overwrites.ts | 3 +-- .../cli/src/credentials/credentials.service.ts | 3 ++- .../1630330987096-UpdateWorkflowCredentials.ts | 18 ++++++++++++------ .../repositories/execution.repository.ts | 2 +- packages/cli/src/ldap/helpers.ee.ts | 3 ++- packages/cli/src/load-nodes-and-credentials.ts | 2 +- .../credentials/credentials.service.ts | 3 ++- packages/cli/src/push/index.ts | 3 ++- .../nodes-base/nodes/Flow/FlowTrigger.node.ts | 1 - 16 files changed, 35 insertions(+), 26 deletions(-) diff --git a/packages/@n8n/client-oauth2/src/ClientOAuth2.ts b/packages/@n8n/client-oauth2/src/ClientOAuth2.ts index 676249254a..91679438cb 100644 --- a/packages/@n8n/client-oauth2/src/ClientOAuth2.ts +++ b/packages/@n8n/client-oauth2/src/ClientOAuth2.ts @@ -115,8 +115,7 @@ export class ClientOAuth2 { const body = this.parseResponseBody(response.data); - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore + // @ts-expect-error getAuthError is not correctly typed const authErr = getAuthError(body); if (authErr) throw authErr; diff --git a/packages/@n8n/client-oauth2/src/CodeFlow.ts b/packages/@n8n/client-oauth2/src/CodeFlow.ts index 6d0fff235e..4a1c97d7b6 100644 --- a/packages/@n8n/client-oauth2/src/CodeFlow.ts +++ b/packages/@n8n/client-oauth2/src/CodeFlow.ts @@ -76,8 +76,8 @@ export class CodeFlow { const data = typeof url.search === 'string' ? qs.parse(url.search.substring(1)) : url.search || {}; - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore + // @Cleanup: URL above should never not be a string, so we shouldn't need the fallback that breaks type-safety here + // @ts-expect-error We don't mind this throwing, as that's what we're about to do const error = getAuthError(data); if (error) throw error; diff --git a/packages/@n8n/client-oauth2/src/utils.ts b/packages/@n8n/client-oauth2/src/utils.ts index 550c1dcf99..9f00515c92 100644 --- a/packages/@n8n/client-oauth2/src/utils.ts +++ b/packages/@n8n/client-oauth2/src/utils.ts @@ -35,6 +35,7 @@ export function getAuthError(body: { error: string; error_description?: string; }): Error | undefined { + // @Cleanup: This should explicitly handle optional `error` on body, which is how this function is used by callers const message: string | undefined = ERROR_RESPONSES[body.error] ?? body.error_description ?? body.error; diff --git a/packages/@n8n/nodes-langchain/utils/logWrapper.ts b/packages/@n8n/nodes-langchain/utils/logWrapper.ts index fa1a38b31a..073b005162 100644 --- a/packages/@n8n/nodes-langchain/utils/logWrapper.ts +++ b/packages/@n8n/nodes-langchain/utils/logWrapper.ts @@ -394,7 +394,6 @@ export function logWrapper( return async ( query: string, k?: number, - // @ts-ignore filter?: BiquadFilterType | undefined, _callbacks?: Callbacks | undefined, ): Promise => { diff --git a/packages/cli/src/config/index.ts b/packages/cli/src/config/index.ts index 63497600fe..0745863dd0 100644 --- a/packages/cli/src/config/index.ts +++ b/packages/cli/src/config/index.ts @@ -49,7 +49,7 @@ if (!inE2ETests && !inTest) { // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access const innerData = data[prefix]; if (prefix in globalConfig) { - // @ts-ignore + // @ts-expect-error We verify `prefix` is in `globalConfig` above merge(globalConfig[prefix], innerData); } else { const flattenedData: Record = flatten(innerData); @@ -69,7 +69,8 @@ if (!inE2ETests && !inTest) { Object.entries(process.env).forEach(([envName, fileName]) => { if (envName.endsWith('_FILE') && fileName) { const configEnvName = envName.replace(/_FILE$/, ''); - // @ts-ignore + // @Cleanup: Check if we can use `config.getEnv(configEnvName)` instead + // @ts-expect-error This uses the private `_env` property @Internal // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access const key = config._env[configEnvName]?.[0] as string; if (key) { diff --git a/packages/cli/src/controllers/oauth/oauth1-credential.controller.ts b/packages/cli/src/controllers/oauth/oauth1-credential.controller.ts index 0211c463a9..ec0e3805fe 100644 --- a/packages/cli/src/controllers/oauth/oauth1-credential.controller.ts +++ b/packages/cli/src/controllers/oauth/oauth1-credential.controller.ts @@ -77,7 +77,8 @@ export class OAuth1CredentialController extends AbstractOAuthController { const data = oauth.toHeader(oauth.authorize(options)); - // @ts-ignore + // @Cleanup: Move this to the declaration of `options` and type to `RequestOptions & { headers: OAuth.Header} + // @ts-expect-error This intentionally sets a new property options.headers = data; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment diff --git a/packages/cli/src/credentials-helper.ts b/packages/cli/src/credentials-helper.ts index 967ee9efe4..ead5669346 100644 --- a/packages/cli/src/credentials-helper.ts +++ b/packages/cli/src/credentials-helper.ts @@ -130,12 +130,12 @@ export class CredentialsHelper extends ICredentialsHelper { node, ); - // @ts-ignore + // @ts-expect-error These transfer all properties from a type subset to a wider type if (!requestOptions[outerKey]) { - // @ts-ignore + // @ts-expect-error These transfer all properties from a type subset to a wider type requestOptions[outerKey] = {}; } - // @ts-ignore + // @ts-expect-error These transfer all properties from a type subset to a wider type requestOptions[outerKey][keyResolved] = valueResolved; }); }); diff --git a/packages/cli/src/credentials-overwrites.ts b/packages/cli/src/credentials-overwrites.ts index ed1b492dc6..0536b98ca8 100644 --- a/packages/cli/src/credentials-overwrites.ts +++ b/packages/cli/src/credentials-overwrites.ts @@ -51,8 +51,7 @@ export class CredentialsOverwrites { const returnData = deepCopy(data); // Overwrite only if there is currently no data set for (const key of Object.keys(overwrites)) { - // @ts-ignore - if ([null, undefined, ''].includes(returnData[key])) { + if (([null, undefined, ''] as unknown[]).includes(returnData[key])) { returnData[key] = overwrites[key]; } } diff --git a/packages/cli/src/credentials/credentials.service.ts b/packages/cli/src/credentials/credentials.service.ts index f9bbf89e57..5bb2151e31 100644 --- a/packages/cli/src/credentials/credentials.service.ts +++ b/packages/cli/src/credentials/credentials.service.ts @@ -289,7 +289,8 @@ export class CredentialsService { // Do not overwrite the oauth data else data like the access or refresh token would get lost // every time anybody changes anything on the credentials even if it is just the name. if (decryptedData.oauthTokenData) { - // @ts-ignore + // @Cleanup We should instead properly define the type of `updateData` + // @ts-expect-error updateData has an incorrect type due to the cast in its definition updateData.data.oauthTokenData = decryptedData.oauthTokenData; } return updateData; diff --git a/packages/cli/src/databases/migrations/common/1630330987096-UpdateWorkflowCredentials.ts b/packages/cli/src/databases/migrations/common/1630330987096-UpdateWorkflowCredentials.ts index 3976ad3109..e9f73cf9a0 100644 --- a/packages/cli/src/databases/migrations/common/1630330987096-UpdateWorkflowCredentials.ts +++ b/packages/cli/src/databases/migrations/common/1630330987096-UpdateWorkflowCredentials.ts @@ -146,10 +146,12 @@ export class UpdateWorkflowCredentials1630330987096 implements ReversibleMigrati (credentials) => credentials.id == creds.id && credentials.type === type, ); if (matchingCredentials) { - // @ts-ignore + // @Problem This should drop `.name`? Unless we intentionally need it like this when generating the SQL + // @ts-expect-error This appears to actually be incorrect node.credentials[type] = matchingCredentials.name; } else { - // @ts-ignore + // @Problem This should drop `.name`? Unless we intentionally need it like this when generating the SQL + // @ts-expect-error This appears to actually be incorrect node.credentials[type] = creds.name; } credentialsUpdated = true; @@ -188,10 +190,12 @@ export class UpdateWorkflowCredentials1630330987096 implements ReversibleMigrati (credentials) => credentials.id == creds.id && credentials.type === type, ); if (matchingCredentials) { - // @ts-ignore + // @Problem This should drop `.name`? Unless we intentionally need it like this when generating the SQL + // @ts-expect-error This appears to actually be incorrect node.credentials[type] = matchingCredentials.name; } else { - // @ts-ignore + // @Problem This should drop `.name`? Unless we intentionally need it like this when generating the SQL + // @ts-expect-error This appears to actually be incorrect node.credentials[type] = creds.name; } credentialsUpdated = true; @@ -230,10 +234,12 @@ export class UpdateWorkflowCredentials1630330987096 implements ReversibleMigrati (credentials) => credentials.id == creds.id && credentials.type === type, ); if (matchingCredentials) { - // @ts-ignore + // @Problem This should drop `.name`? Unless we intentionally need it like this when generating the SQL + // @ts-expect-error This appears to actually be incorrect node.credentials[type] = matchingCredentials.name; } else { - // @ts-ignore + // @Problem This should drop `.name`? Unless we intentionally need it like this when generating the SQL + // @ts-expect-error This appears to actually be incorrect node.credentials[type] = creds.name; } credentialsUpdated = true; diff --git a/packages/cli/src/databases/repositories/execution.repository.ts b/packages/cli/src/databases/repositories/execution.repository.ts index 5bef675a79..8ff97cbe0f 100644 --- a/packages/cli/src/databases/repositories/execution.repository.ts +++ b/packages/cli/src/databases/repositories/execution.repository.ts @@ -394,7 +394,7 @@ export class ExecutionRepository extends Repository { if (data) { executionData.data = stringify(data); } - // @ts-ignore + // @ts-expect-error A deeply nested error type does not line up with unknown await this.executionDataRepository.update({ executionId }, executionData); } } diff --git a/packages/cli/src/ldap/helpers.ee.ts b/packages/cli/src/ldap/helpers.ee.ts index 7af0917054..e7ab09bd24 100644 --- a/packages/cli/src/ldap/helpers.ee.ts +++ b/packages/cli/src/ldap/helpers.ee.ts @@ -76,7 +76,8 @@ export const createFilter = (filter: string, userFilter: string) => { }; export const escapeFilter = (filter: string): string => { - //@ts-ignore + // @Problem Create a class that extends Filter instead + // @ts-expect-error This creates an instance of an abstract class, see https://github.com/n8n-io/n8n/pull/3835/files#r1042626072 return new Filter().escape(filter); /* eslint-disable-line */ }; diff --git a/packages/cli/src/load-nodes-and-credentials.ts b/packages/cli/src/load-nodes-and-credentials.ts index 22273fb894..1d1861c81c 100644 --- a/packages/cli/src/load-nodes-and-credentials.ts +++ b/packages/cli/src/load-nodes-and-credentials.ts @@ -68,7 +68,7 @@ export class LoadNodesAndCredentials { const delimiter = process.platform === 'win32' ? ';' : ':'; process.env.NODE_PATH = module.paths.join(delimiter); - // @ts-ignore + // @ts-expect-error This is a NodeJS internal function @Internal // eslint-disable-next-line @typescript-eslint/no-unsafe-call module.constructor._initPaths(); diff --git a/packages/cli/src/public-api/v1/handlers/credentials/credentials.service.ts b/packages/cli/src/public-api/v1/handlers/credentials/credentials.service.ts index 2477ef928f..ebd2e84826 100644 --- a/packages/cli/src/public-api/v1/handlers/credentials/credentials.service.ts +++ b/packages/cli/src/public-api/v1/handlers/credentials/credentials.service.ts @@ -111,7 +111,8 @@ export async function encryptCredential(credential: CredentialsEntity): Promise< // Encrypt the data const coreCredential = new Credentials({ id: null, name: credential.name }, credential.type); - // @ts-ignore + // @Cleanup Investigate whether ICredentialsEncrypted['data'] is incorrect and a change is feasible + // @ts-expect-error Either this is mistyped, or `ICredentialsEncrypted['data']` is mistyped coreCredential.setData(credential.data); return coreCredential.getDataToSave() as ICredentialsDb; diff --git a/packages/cli/src/push/index.ts b/packages/cli/src/push/index.ts index bfbfb43a51..cab8f60775 100644 --- a/packages/cli/src/push/index.ts +++ b/packages/cli/src/push/index.ts @@ -131,7 +131,8 @@ export const setupPushServer = (restEndpoint: string, server: Server, app: Appli return response; }; - // @ts-ignore + // @Problem: Find a public alternative + // @ts-expect-error This uses a private function https://github.com/expressjs/express/blob/e4a61bd88e2f170eab64d937f3bf6c0812b4a649/lib/application.js#L153 // eslint-disable-next-line @typescript-eslint/no-unsafe-call app.handle(request, response); }); diff --git a/packages/nodes-base/nodes/Flow/FlowTrigger.node.ts b/packages/nodes-base/nodes/Flow/FlowTrigger.node.ts index fc19041f18..02bc332c32 100644 --- a/packages/nodes-base/nodes/Flow/FlowTrigger.node.ts +++ b/packages/nodes-base/nodes/Flow/FlowTrigger.node.ts @@ -137,7 +137,6 @@ export class FlowTrigger implements INodeType { if (resource === 'task') { resourceIds = (this.getNodeParameter('taskIds') as string).split(','); } - // @ts-ignore for (const resourceId of resourceIds) { body = { organization_id: credentials.organizationId as number,