From d754ce922dcf8333ebfd782df04af98f66e15c4b Mon Sep 17 00:00:00 2001 From: Alex Grozav Date: Fri, 4 Jul 2025 14:55:39 +0300 Subject: [PATCH] feat: Upgrade `nodes-base` package to use modern tsconfig.json (no-changelog) (#16884) --- package.json | 2 + packages/@n8n/nodes-langchain/tsconfig.json | 2 +- .../typescript-config/modern/tsconfig.json | 1 + packages/cli/tsconfig.json | 2 +- .../nodes-base/credentials/Aws.credentials.ts | 2 +- .../nodes/Code/JsTaskRunnerSandbox.ts | 4 +- .../Evaluation/test/Evaluation.node.test.ts | 11 ++-- .../test/EvaluationTrigger.node.test.ts | 16 ++--- .../nodes/Freshservice/GenericFunctions.ts | 1 + .../nodes/FreshworksCrm/GenericFunctions.ts | 1 + .../nodes-base/nodes/FreshworksCrm/types.ts | 5 ++ .../Sheet/v2/actions/utils/readOperation.ts | 2 +- .../itemList/splitOutItems.operation.ts | 2 +- .../nodes/Magento/GenericFunctions.ts | 4 +- .../nodes-base/nodes/Magento/Magento2.node.ts | 10 +-- .../v3/actions/mode/combineByPosition.ts | 4 +- .../Microsoft/SharePoint/helpers/utils.ts | 2 +- .../Teams/MicrosoftTeamsTrigger.node.ts | 3 +- .../nodes/Notion/shared/GenericFunctions.ts | 3 +- .../nodes/RabbitMQ/GenericFunctions.ts | 4 +- .../SeaTable/v2/SeaTableTriggerV2.node.ts | 5 +- .../nodes-base/nodes/Set/v2/helpers/utils.ts | 2 +- .../nodes/Taiga/GenericFunctions.ts | 1 + packages/nodes-base/nodes/Taiga/Taiga.node.ts | 9 +++ .../nodes/Taiga/TaigaTrigger.node.ts | 1 + packages/nodes-base/nodes/Taiga/types.ts | 22 +++---- packages/nodes-base/nodes/Totp/Totp.node.ts | 2 +- .../nodes/Transform/SplitOut/SplitOut.node.ts | 2 +- packages/nodes-base/package.json | 4 +- packages/nodes-base/shims.d.ts | 1 + packages/nodes-base/tsconfig.build.cjs.json | 24 +++++++ packages/nodes-base/tsconfig.build.json | 17 ----- packages/nodes-base/tsconfig.json | 31 +++++++--- packages/nodes-base/tsup.config.ts | 62 ------------------- patches/ics.patch | 12 ++++ patches/minifaker.patch | 12 ++++ pnpm-lock.yaml | 20 +++--- 37 files changed, 165 insertions(+), 143 deletions(-) create mode 100644 packages/nodes-base/shims.d.ts create mode 100644 packages/nodes-base/tsconfig.build.cjs.json delete mode 100644 packages/nodes-base/tsconfig.build.json delete mode 100644 packages/nodes-base/tsup.config.ts create mode 100644 patches/ics.patch create mode 100644 patches/minifaker.patch diff --git a/package.json b/package.json index 508aa0963e..f7a1b9372d 100644 --- a/package.json +++ b/package.json @@ -116,6 +116,8 @@ "vue-tsc@2.2.8": "patches/vue-tsc@2.2.8.patch", "element-plus@2.4.3": "patches/element-plus@2.4.3.patch", "js-base64": "patches/js-base64.patch", + "ics": "patches/ics.patch", + "minifaker": "patches/minifaker.patch", "z-vue-scan": "patches/z-vue-scan.patch" } } diff --git a/packages/@n8n/nodes-langchain/tsconfig.json b/packages/@n8n/nodes-langchain/tsconfig.json index 3b4aa3bb2e..bd7dfcd743 100644 --- a/packages/@n8n/nodes-langchain/tsconfig.json +++ b/packages/@n8n/nodes-langchain/tsconfig.json @@ -25,7 +25,7 @@ ], "references": [ { "path": "../../core/tsconfig.build.json" }, - { "path": "../../nodes-base/tsconfig.build.json" }, + { "path": "../../nodes-base/tsconfig.build.cjs.json" }, { "path": "../../workflow/tsconfig.build.esm.json" } ] } diff --git a/packages/@n8n/typescript-config/modern/tsconfig.json b/packages/@n8n/typescript-config/modern/tsconfig.json index 5bb072ca78..c2da3eb14c 100644 --- a/packages/@n8n/typescript-config/modern/tsconfig.json +++ b/packages/@n8n/typescript-config/modern/tsconfig.json @@ -8,6 +8,7 @@ "moduleDetection": "force", "isolatedModules": true, "verbatimModuleSyntax": true, + "incremental": true, "strict": true, "noUncheckedIndexedAccess": true, diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.json index e880f47585..dc76dfb183 100644 --- a/packages/cli/tsconfig.json +++ b/packages/cli/tsconfig.json @@ -21,7 +21,7 @@ "include": ["src/**/*.ts", "test/**/*.ts", "src/sso.ee/saml/saml-schema-metadata-2.0.xsd"], "references": [ { "path": "../core/tsconfig.build.json" }, - { "path": "../nodes-base/tsconfig.build.json" }, + { "path": "../nodes-base/tsconfig.build.cjs.json" }, { "path": "../workflow/tsconfig.build.esm.json" }, { "path": "../@n8n/api-types/tsconfig.build.json" }, { "path": "../@n8n/client-oauth2/tsconfig.build.json" }, diff --git a/packages/nodes-base/credentials/Aws.credentials.ts b/packages/nodes-base/credentials/Aws.credentials.ts index 569a9d28e9..7b977624e4 100644 --- a/packages/nodes-base/credentials/Aws.credentials.ts +++ b/packages/nodes-base/credentials/Aws.credentials.ts @@ -498,7 +498,7 @@ export class Aws implements ICredentialType { path, body: bodyContent, region, - } as Request; + } as unknown as Request; const securityHeaders = { accessKeyId: `${credentials.accessKeyId}`.trim(), diff --git a/packages/nodes-base/nodes/Code/JsTaskRunnerSandbox.ts b/packages/nodes-base/nodes/Code/JsTaskRunnerSandbox.ts index 8a506ce40c..874ce8af8d 100644 --- a/packages/nodes-base/nodes/Code/JsTaskRunnerSandbox.ts +++ b/packages/nodes-base/nodes/Code/JsTaskRunnerSandbox.ts @@ -37,7 +37,7 @@ export class JsTaskRunnerSandbox { return executionResult.ok ? executionResult.result - : this.throwExecutionError(executionResult.error); + : this.throwExecutionError('error' in executionResult ? executionResult.error : {}); } async runCodeForEachItem(numInputItems: number): Promise { @@ -64,7 +64,7 @@ export class JsTaskRunnerSandbox { ); if (!executionResult.ok) { - return this.throwExecutionError(executionResult.error); + return this.throwExecutionError('error' in executionResult ? executionResult.error : {}); } executionResults = executionResults.concat(executionResult.result); diff --git a/packages/nodes-base/nodes/Evaluation/test/Evaluation.node.test.ts b/packages/nodes-base/nodes/Evaluation/test/Evaluation.node.test.ts index 708db7651e..bdec1c79de 100644 --- a/packages/nodes-base/nodes/Evaluation/test/Evaluation.node.test.ts +++ b/packages/nodes-base/nodes/Evaluation/test/Evaluation.node.test.ts @@ -4,6 +4,7 @@ import { type AssignmentCollectionValue, type IExecuteFunctions, type INodeTypes, + type NodeParameterValueType, } from 'n8n-workflow'; import { GoogleSheet } from '../../Google/Sheet/v2/helpers/GoogleSheet'; @@ -62,7 +63,7 @@ describe('Test Evaluation', () => { sheetMode: 'id', operation: 'setOutputs', }; - return mockParams[key] ?? fallbackValue; + return (mockParams[key] ?? fallbackValue) as NodeParameterValueType; }, ); @@ -88,7 +89,7 @@ describe('Test Evaluation', () => { sheetMode: 'id', operation: 'setOutputs', }; - return mockParams[key] ?? fallbackValue; + return (mockParams[key] ?? fallbackValue) as NodeParameterValueType; }, ); @@ -125,7 +126,7 @@ describe('Test Evaluation', () => { sheetMode: 'id', operation: 'setOutputs', }; - return mockParams[key] ?? fallbackValue; + return (mockParams[key] ?? fallbackValue) as NodeParameterValueType; }, ); mockExecuteFunctions.getParentNodes.mockReturnValue([]); @@ -152,7 +153,7 @@ describe('Test Evaluation', () => { sheetMode: 'id', operation: 'setOutputs', }; - return mockParams[key] ?? fallbackValue; + return (mockParams[key] ?? fallbackValue) as NodeParameterValueType; }, ); @@ -299,7 +300,7 @@ describe('Test Evaluation', () => { const mockParams: { [key: string]: unknown } = { operation: 'checkIfEvaluating', }; - return mockParams[key] ?? fallbackValue; + return (mockParams[key] ?? fallbackValue) as NodeParameterValueType; }, ); }); diff --git a/packages/nodes-base/nodes/Evaluation/test/EvaluationTrigger.node.test.ts b/packages/nodes-base/nodes/Evaluation/test/EvaluationTrigger.node.test.ts index 001acd2bb4..d68b0616b7 100644 --- a/packages/nodes-base/nodes/Evaluation/test/EvaluationTrigger.node.test.ts +++ b/packages/nodes-base/nodes/Evaluation/test/EvaluationTrigger.node.test.ts @@ -1,5 +1,5 @@ import { mock } from 'jest-mock-extended'; -import type { IExecuteFunctions } from 'n8n-workflow'; +import type { IExecuteFunctions, NodeParameterValueType } from 'n8n-workflow'; import { GoogleSheet } from '../../Google/Sheet/v2/helpers/GoogleSheet'; import { EvaluationTrigger } from '../EvaluationTrigger/EvaluationTrigger.node.ee'; @@ -72,7 +72,7 @@ describe('Evaluation Trigger Node', () => { sheetName, sheetMode: 'id', }; - return mockParams[key] ?? fallbackValue; + return (mockParams[key] ?? fallbackValue) as NodeParameterValueType; }, ); @@ -123,7 +123,7 @@ describe('Evaluation Trigger Node', () => { sheetName, sheetMode: 'id', }; - return mockParams[key] ?? fallbackValue; + return (mockParams[key] ?? fallbackValue) as NodeParameterValueType; }, ); @@ -174,7 +174,7 @@ describe('Evaluation Trigger Node', () => { sheetName, sheetMode: 'id', }; - return mockParams[key] ?? fallbackValue; + return (mockParams[key] ?? fallbackValue) as NodeParameterValueType; }, ); @@ -213,7 +213,7 @@ describe('Evaluation Trigger Node', () => { limitRows: true, maxRows: 1, }; - return mockParams[key] ?? fallbackValue; + return (mockParams[key] ?? fallbackValue) as NodeParameterValueType; }, ); @@ -282,7 +282,7 @@ describe('Evaluation Trigger Node', () => { sheetName, sheetMode: 'id', }; - return mockParams[key] ?? fallbackValue; + return (mockParams[key] ?? fallbackValue) as NodeParameterValueType; }, ); @@ -364,7 +364,7 @@ describe('Evaluation Trigger Node', () => { limitRows: true, maxRows: 2, }; - return mockParams[key] ?? fallbackValue; + return (mockParams[key] ?? fallbackValue) as NodeParameterValueType; }, ); @@ -431,7 +431,7 @@ describe('Evaluation Trigger Node', () => { sheetName, sheetMode: 'id', }; - return mockParams[key] ?? fallbackValue; + return (mockParams[key] ?? fallbackValue) as NodeParameterValueType; }, ); diff --git a/packages/nodes-base/nodes/Freshservice/GenericFunctions.ts b/packages/nodes-base/nodes/Freshservice/GenericFunctions.ts index 4dc8467f3f..ce9b566659 100644 --- a/packages/nodes-base/nodes/Freshservice/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Freshservice/GenericFunctions.ts @@ -13,6 +13,7 @@ import { NodeApiError, NodeOperationError } from 'n8n-workflow'; import type { AddressFixedCollection, FreshserviceCredentials, + LoadedResource, LoadedUser, RolesParameter, } from './types'; diff --git a/packages/nodes-base/nodes/FreshworksCrm/GenericFunctions.ts b/packages/nodes-base/nodes/FreshworksCrm/GenericFunctions.ts index e34aa8e160..6c4c748009 100644 --- a/packages/nodes-base/nodes/FreshworksCrm/GenericFunctions.ts +++ b/packages/nodes-base/nodes/FreshworksCrm/GenericFunctions.ts @@ -12,6 +12,7 @@ import { NodeApiError, NodeOperationError } from 'n8n-workflow'; import type { FreshworksConfigResponse, FreshworksCrmApiCredentials, + LoadedResource, SalesAccounts, ViewsResponse, } from './types'; diff --git a/packages/nodes-base/nodes/FreshworksCrm/types.ts b/packages/nodes-base/nodes/FreshworksCrm/types.ts index cada7f7407..142fb48c1e 100644 --- a/packages/nodes-base/nodes/FreshworksCrm/types.ts +++ b/packages/nodes-base/nodes/FreshworksCrm/types.ts @@ -7,6 +7,11 @@ export type FreshworksConfigResponse = { [key: string]: T[]; }; +export type LoadedResource = { + id: string; + name: string; +}; + export type LoadOption = { name: string; value: string; diff --git a/packages/nodes-base/nodes/Google/Sheet/v2/actions/utils/readOperation.ts b/packages/nodes-base/nodes/Google/Sheet/v2/actions/utils/readOperation.ts index b69eec7799..7f0d77356b 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v2/actions/utils/readOperation.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v2/actions/utils/readOperation.ts @@ -56,7 +56,7 @@ export async function readSheet( data, headerRow: keyRowIndex, firstDataRow: dataStartRowIndex, - } = prepareSheetData(sheetData, dataLocationOnSheetOptions); + } = prepareSheetData(sheetData, dataLocationOnSheetOptions as RangeDetectionOptions); let responseData = []; diff --git a/packages/nodes-base/nodes/ItemLists/V3/actions/itemList/splitOutItems.operation.ts b/packages/nodes-base/nodes/ItemLists/V3/actions/itemList/splitOutItems.operation.ts index 2c437a6a74..bd75edfa11 100644 --- a/packages/nodes-base/nodes/ItemLists/V3/actions/itemList/splitOutItems.operation.ts +++ b/packages/nodes-base/nodes/ItemLists/V3/actions/itemList/splitOutItems.operation.ts @@ -154,7 +154,7 @@ export async function execute( } if (typeof entityToSplit !== 'object' || entityToSplit === null) { - entityToSplit = [entityToSplit]; + entityToSplit = [entityToSplit] as unknown as IDataObject[]; } if (!Array.isArray(entityToSplit)) { diff --git a/packages/nodes-base/nodes/Magento/GenericFunctions.ts b/packages/nodes-base/nodes/Magento/GenericFunctions.ts index 2817d51ccb..5dbb30ac37 100644 --- a/packages/nodes-base/nodes/Magento/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Magento/GenericFunctions.ts @@ -193,7 +193,9 @@ export function getAddressesUi(): INodeProperties { }; } -export function adjustAddresses(addresses: [{ street: string; [key: string]: string }]): Address[] { +export function adjustAddresses( + addresses: Array<{ street: string; [key: string]: string }>, +): Address[] { const _addresses: Address[] = []; for (let i = 0; i < addresses.length; i++) { if (addresses[i]?.region === '') { diff --git a/packages/nodes-base/nodes/Magento/Magento2.node.ts b/packages/nodes-base/nodes/Magento/Magento2.node.ts index 9f1a07c76f..5484c7f721 100644 --- a/packages/nodes-base/nodes/Magento/Magento2.node.ts +++ b/packages/nodes-base/nodes/Magento/Magento2.node.ts @@ -169,6 +169,7 @@ export class Magento2 implements INodeType { )) as CustomerAttributeMetadata[]; const returnData: INodePropertyOptions[] = []; for (const attribute of attributes) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-boolean-literal-compare if (attribute.system === false && attribute.frontend_label !== '') { returnData.push({ name: attribute.frontend_label as string, @@ -189,6 +190,7 @@ export class Magento2 implements INodeType { )) as CustomerAttributeMetadata[]; const returnData: INodePropertyOptions[] = []; for (const attribute of attributes) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-boolean-literal-compare if (attribute.system === true && attribute.frontend_label !== null) { returnData.push({ name: attribute.frontend_label as string, @@ -346,7 +348,7 @@ export class Magento2 implements INodeType { body.customer!.addresses = adjustAddresses(addresses?.address || []); - body.customer!.custom_attributes = customAttributes?.customAttribute || {}; + body.customer!.custom_attributes = customAttributes?.customAttribute || []; body.customer!.extension_attributes = [ 'amazon_id', @@ -490,7 +492,7 @@ export class Magento2 implements INodeType { body.customer!.addresses = adjustAddresses(addresses?.address || []); - body.customer!.custom_attributes = customAttributes?.customAttribute || {}; + body.customer!.custom_attributes = customAttributes?.customAttribute || []; body.customer!.extension_attributes = [ 'amazon_id', @@ -661,7 +663,7 @@ export class Magento2 implements INodeType { }, }; - body.product!.custom_attributes = customAttributes?.customAttribute || {}; + body.product!.custom_attributes = customAttributes?.customAttribute || []; Object.assign(body.product!, rest); @@ -776,7 +778,7 @@ export class Magento2 implements INodeType { }, }; - body.product!.custom_attributes = customAttributes?.customAttribute || {}; + body.product!.custom_attributes = customAttributes?.customAttribute || []; Object.assign(body.product!, rest); diff --git a/packages/nodes-base/nodes/Merge/v3/actions/mode/combineByPosition.ts b/packages/nodes-base/nodes/Merge/v3/actions/mode/combineByPosition.ts index 9702160948..41a9c65600 100644 --- a/packages/nodes-base/nodes/Merge/v3/actions/mode/combineByPosition.ts +++ b/packages/nodes-base/nodes/Merge/v3/actions/mode/combineByPosition.ts @@ -91,8 +91,8 @@ export async function execute( const mergeIntoSingleObject = selectMergeMethod(clashHandling); for (let i = 0; i < numEntries; i++) { - const preferredEntry = preferred[i] ?? {}; - const restEntries = inputsData.map((input) => input[i] ?? {}); + const preferredEntry = preferred[i] ?? ({} as INodeExecutionData); + const restEntries = inputsData.map((input) => input[i] ?? ({} as INodeExecutionData)); const json = { ...mergeIntoSingleObject( diff --git a/packages/nodes-base/nodes/Microsoft/SharePoint/helpers/utils.ts b/packages/nodes-base/nodes/Microsoft/SharePoint/helpers/utils.ts index c30ad9549f..8af7d628f4 100644 --- a/packages/nodes-base/nodes/Microsoft/SharePoint/helpers/utils.ts +++ b/packages/nodes-base/nodes/Microsoft/SharePoint/helpers/utils.ts @@ -207,7 +207,7 @@ export async function handleErrorPostReceive( if (resource === 'file' && operation === 'download' && Buffer.isBuffer(response.body)) { response.body = jsonParse((response.body as Buffer).toString()); } - const error = (response.body as IErrorResponse)?.error ?? {}; + const error = (response.body as IErrorResponse)?.error ?? ({} as IErrorResponse['error']); if (resource === 'file') { if (operation === 'download') { diff --git a/packages/nodes-base/nodes/Microsoft/Teams/MicrosoftTeamsTrigger.node.ts b/packages/nodes-base/nodes/Microsoft/Teams/MicrosoftTeamsTrigger.node.ts index 08a8965aeb..3cfa229f30 100644 --- a/packages/nodes-base/nodes/Microsoft/Teams/MicrosoftTeamsTrigger.node.ts +++ b/packages/nodes-base/nodes/Microsoft/Teams/MicrosoftTeamsTrigger.node.ts @@ -8,6 +8,7 @@ import type { IDataObject, ILoadOptionsFunctions, JsonObject, + INodeExecutionData, } from 'n8n-workflow'; import { NodeApiError, NodeConnectionTypes } from 'n8n-workflow'; @@ -388,7 +389,7 @@ export class MicrosoftTeamsTrigger implements INodeType { workflowData: eventNotifications.map((event) => [ { json: (event.resourceData as IDataObject) ?? event, - }, + } as INodeExecutionData, ]), }; diff --git a/packages/nodes-base/nodes/Notion/shared/GenericFunctions.ts b/packages/nodes-base/nodes/Notion/shared/GenericFunctions.ts index 11a339379d..aac49b3902 100644 --- a/packages/nodes-base/nodes/Notion/shared/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Notion/shared/GenericFunctions.ts @@ -271,8 +271,7 @@ function getTexts(texts: TextData[]) { type: 'mention', mention: { type: text.mentionType, - //@ts-expect-error any - [text.mentionType]: { id: text[text.mentionType] as string }, + [text.mentionType]: { id: text[text.mentionType as keyof TextData] as string }, }, annotations: text.annotationUi, }); diff --git a/packages/nodes-base/nodes/RabbitMQ/GenericFunctions.ts b/packages/nodes-base/nodes/RabbitMQ/GenericFunctions.ts index cca2cd9e6f..83999ca86d 100644 --- a/packages/nodes-base/nodes/RabbitMQ/GenericFunctions.ts +++ b/packages/nodes-base/nodes/RabbitMQ/GenericFunctions.ts @@ -184,10 +184,10 @@ export const parseMessage = async ( }; } else { let content: IDataObject | string = message.content.toString(); - if (options.jsonParseBody) { + if ('jsonParseBody' in options && options.jsonParseBody) { content = jsonParse(content); } - if (options.onlyContent) { + if ('onlyContent' in options && options.onlyContent) { return { json: content as IDataObject }; } else { message.content = content as unknown as Buffer; diff --git a/packages/nodes-base/nodes/SeaTable/v2/SeaTableTriggerV2.node.ts b/packages/nodes-base/nodes/SeaTable/v2/SeaTableTriggerV2.node.ts index 651b95e6be..3139bddaf7 100644 --- a/packages/nodes-base/nodes/SeaTable/v2/SeaTableTriggerV2.node.ts +++ b/packages/nodes-base/nodes/SeaTable/v2/SeaTableTriggerV2.node.ts @@ -208,7 +208,10 @@ export class SeaTableTriggerV2 implements INodeType { const newRows: any = []; for (const row of rows) { if (assetColumnType === 'digital-sign') { - const signature = (row[assetColumn] as IColumnDigitalSignature) || []; + const signature = (row[assetColumn] as IColumnDigitalSignature) || { + sign_time: undefined, + }; + if (signature.sign_time) { if (new Date(signature.sign_time) > new Date(startDate)) { newRows.push(signature); diff --git a/packages/nodes-base/nodes/Set/v2/helpers/utils.ts b/packages/nodes-base/nodes/Set/v2/helpers/utils.ts index 6ec6dd647b..ddfe933159 100644 --- a/packages/nodes-base/nodes/Set/v2/helpers/utils.ts +++ b/packages/nodes-base/nodes/Set/v2/helpers/utils.ts @@ -206,7 +206,7 @@ export const validateEntry = ( if (ignoreErrors) { return { name, value: value ?? null }; } else { - const message = `${validationResult.errorMessage} [item ${itemIndex}]`; + const message = `${'errorMessage' in validationResult ? validationResult.errorMessage : 'Error'} [item ${itemIndex}]`; throw new NodeOperationError(node, message, { itemIndex, description, diff --git a/packages/nodes-base/nodes/Taiga/GenericFunctions.ts b/packages/nodes-base/nodes/Taiga/GenericFunctions.ts index 1a0a208867..be671e51dc 100644 --- a/packages/nodes-base/nodes/Taiga/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Taiga/GenericFunctions.ts @@ -11,6 +11,7 @@ import type { IRequestOptions, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; +import type { LoadedResource, Resource } from './types'; export async function getAuthorization( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, diff --git a/packages/nodes-base/nodes/Taiga/Taiga.node.ts b/packages/nodes-base/nodes/Taiga/Taiga.node.ts index b02b271a91..94cd923ac3 100644 --- a/packages/nodes-base/nodes/Taiga/Taiga.node.ts +++ b/packages/nodes-base/nodes/Taiga/Taiga.node.ts @@ -26,6 +26,15 @@ import { throwOnEmptyUpdate, toOptions, } from './GenericFunctions'; +import type { + LoadedEpic, + LoadedResource, + LoadedTags, + LoadedUser, + LoadedUserStory, + Operation, + Resource, +} from './types'; export class Taiga implements INodeType { description: INodeTypeDescription = { diff --git a/packages/nodes-base/nodes/Taiga/TaigaTrigger.node.ts b/packages/nodes-base/nodes/Taiga/TaigaTrigger.node.ts index d32056a210..4d326e37ff 100644 --- a/packages/nodes-base/nodes/Taiga/TaigaTrigger.node.ts +++ b/packages/nodes-base/nodes/Taiga/TaigaTrigger.node.ts @@ -11,6 +11,7 @@ import { } from 'n8n-workflow'; import { getAutomaticSecret, taigaApiRequest } from './GenericFunctions'; +import type { Operations, Resources, WebhookPayload } from './types'; // import { // createHmac, diff --git a/packages/nodes-base/nodes/Taiga/types.ts b/packages/nodes-base/nodes/Taiga/types.ts index 9528d0db34..31c7595afd 100644 --- a/packages/nodes-base/nodes/Taiga/types.ts +++ b/packages/nodes-base/nodes/Taiga/types.ts @@ -1,38 +1,38 @@ -type Resource = 'epic' | 'issue' | 'task' | 'userStory'; +export type Resource = 'epic' | 'issue' | 'task' | 'userStory'; -type Operation = 'create' | 'delete' | 'update' | 'get' | 'getAll'; +export type Operation = 'create' | 'delete' | 'update' | 'get' | 'getAll'; -type LoadedResource = { +export type LoadedResource = { id: string; name: string; }; -type LoadOption = { +export type LoadOption = { value: string; name: string; }; -type LoadedUser = { +export type LoadedUser = { id: string; full_name_display: string; }; -type LoadedUserStory = { +export type LoadedUserStory = { id: string; subject: string; }; -type LoadedEpic = LoadedUserStory; +export type LoadedEpic = LoadedUserStory; -type LoadedTags = { +export type LoadedTags = { [tagName: string]: string | null; // hex color }; -type Operations = 'all' | 'create' | 'delete' | 'change'; +export type Operations = 'all' | 'create' | 'delete' | 'change'; -type Resources = 'all' | 'issue' | 'milestone' | 'task' | 'userstory' | 'wikipage'; +export type Resources = 'all' | 'issue' | 'milestone' | 'task' | 'userstory' | 'wikipage'; -type WebhookPayload = { +export type WebhookPayload = { action: Operations; type: Resources; by: Record; diff --git a/packages/nodes-base/nodes/Totp/Totp.node.ts b/packages/nodes-base/nodes/Totp/Totp.node.ts index 36a53b5193..4a66c5c977 100644 --- a/packages/nodes-base/nodes/Totp/Totp.node.ts +++ b/packages/nodes-base/nodes/Totp/Totp.node.ts @@ -5,7 +5,7 @@ import type { INodeTypeDescription, } from 'n8n-workflow'; import { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow'; -import OTPAuth from 'otpauth'; +import * as OTPAuth from 'otpauth'; export class Totp implements INodeType { description: INodeTypeDescription = { diff --git a/packages/nodes-base/nodes/Transform/SplitOut/SplitOut.node.ts b/packages/nodes-base/nodes/Transform/SplitOut/SplitOut.node.ts index e28239d777..f1b59e5490 100644 --- a/packages/nodes-base/nodes/Transform/SplitOut/SplitOut.node.ts +++ b/packages/nodes-base/nodes/Transform/SplitOut/SplitOut.node.ts @@ -173,7 +173,7 @@ export class SplitOut implements INodeType { } if (typeof entityToSplit !== 'object' || entityToSplit === null) { - entityToSplit = [entityToSplit]; + entityToSplit = [entityToSplit] as unknown as IDataObject[]; } if (!Array.isArray(entityToSplit)) { diff --git a/packages/nodes-base/package.json b/packages/nodes-base/package.json index 596ab84b00..55f0baa078 100644 --- a/packages/nodes-base/package.json +++ b/packages/nodes-base/package.json @@ -8,12 +8,12 @@ "copy-nodes-json": "node scripts/copy-nodes-json.js .", "dev": "pnpm watch", "typecheck": "tsc --noEmit", - "build": "tsup --tsconfig tsconfig.build.json && pnpm copy-nodes-json && tsc-alias -p tsconfig.build.json && pnpm n8n-copy-static-files && pnpm n8n-generate-translations && pnpm n8n-generate-metadata", + "build": "tsc --build tsconfig.build.cjs.json && pnpm copy-nodes-json && tsc-alias -p tsconfig.build.cjs.json && pnpm n8n-copy-static-files && pnpm n8n-generate-translations && pnpm n8n-generate-metadata", "format": "biome format --write .", "format:check": "biome ci .", "lint": "eslint nodes credentials utils test --quiet && node ./scripts/validate-load-options-methods.js", "lintfix": "eslint nodes credentials utils test --fix", - "watch": "tsup --watch --tsconfig tsconfig.build.json --onSuccess \"pnpm copy-nodes-json && tsc-alias -p tsconfig.build.json && pnpm n8n-generate-metadata\"", + "watch": "tsc-watch -p tsconfig.build.cjs.json --onCompilationComplete \"pnpm copy-nodes-json && tsc-alias -p tsconfig.build.cjs.json\" --onSuccess \"pnpm n8n-generate-metadata\"", "test": "jest", "test:dev": "jest --watch" }, diff --git a/packages/nodes-base/shims.d.ts b/packages/nodes-base/shims.d.ts new file mode 100644 index 0000000000..3109ac7df9 --- /dev/null +++ b/packages/nodes-base/shims.d.ts @@ -0,0 +1 @@ +declare module 'minifaker'; diff --git a/packages/nodes-base/tsconfig.build.cjs.json b/packages/nodes-base/tsconfig.build.cjs.json new file mode 100644 index 0000000000..b14d7ad826 --- /dev/null +++ b/packages/nodes-base/tsconfig.build.cjs.json @@ -0,0 +1,24 @@ +{ + "extends": ["./tsconfig.json", "@n8n/typescript-config/modern/tsconfig.cjs.json"], + "compilerOptions": { + "outDir": "dist", + "module": "commonjs", + "tsBuildInfoFile": "dist/typecheck.tsbuildinfo" + }, + "include": [ + "credentials/**/*.ts", + "credentials/translations/**/*.json", + "nodes/**/*.ts", + "nodes/**/*.json", + "types/**/*.ts", + "utils/**/*.ts" + ], + "exclude": [ + "node_modules", + "nodes/**/*.test.ts", + "credentials/**/*.test.ts", + "utils/**/*.test.ts", + "test/**", + "../core/nodes-testing" + ] +} diff --git a/packages/nodes-base/tsconfig.build.json b/packages/nodes-base/tsconfig.build.json deleted file mode 100644 index ee2e033ea3..0000000000 --- a/packages/nodes-base/tsconfig.build.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": ["./tsconfig.json", "@n8n/typescript-config/tsconfig.build.json"], - "compilerOptions": { - "outDir": "dist", - "composite": true, - "tsBuildInfoFile": "dist/build.tsbuildinfo" - }, - "include": [ - "credentials/**/*.ts", - "credentials/translations/**/*.json", - "nodes/**/*.ts", - "nodes/**/*.json", - "types/**/*.ts", - "utils/**/*.ts" - ], - "exclude": ["nodes/**/*.test.ts", "credentials/**/*.test.ts", "utils/**/*.test.ts", "test/**"] -} diff --git a/packages/nodes-base/tsconfig.json b/packages/nodes-base/tsconfig.json index 98fdad63d6..ba87358ec2 100644 --- a/packages/nodes-base/tsconfig.json +++ b/packages/nodes-base/tsconfig.json @@ -1,8 +1,5 @@ { - "extends": [ - "@n8n/typescript-config/tsconfig.common.json", - "@n8n/typescript-config/tsconfig.backend.json" - ], + "extends": ["@n8n/typescript-config/modern/tsconfig.json"], "compilerOptions": { "paths": { "@credentials/*": ["./credentials/*"], @@ -11,19 +8,39 @@ "@nodes-testing/*": ["../core/nodes-testing/*"] }, "tsBuildInfoFile": "dist/typecheck.tsbuildinfo", + "emitDecoratorMetadata": true, "experimentalDecorators": true, - // TODO: remove all options below this line + + // TODO: remove all options below this line to align with the modern config + // TODO: "module" to be removed when we migrate to vitest + "module": "commonjs", + // TODO: "moduleResolution" to be removed when we migrate to vitest + "moduleResolution": "node", "noImplicitReturns": false, - "useUnknownInCatchVariables": false + "useUnknownInCatchVariables": false, + "isolatedModules": false, + "verbatimModuleSyntax": false, + "noUncheckedIndexedAccess": false, + "noImplicitOverride": false, + + "noImplicitAny": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "strictNullChecks": true, + "preserveConstEnums": true }, "include": [ + "shims.d.ts", "credentials/**/*.ts", "nodes/**/*.ts", "nodes/**/*.json", "test/**/*.ts", "types/**/*.ts", - "utils/**/*.ts" + "utils/**/*.ts", + "types/**/*.ts", + "../core/nodes-testing/**/*.ts", + "../../node_modules/jest-expect-message/types/index.d.ts" ], "references": [ { "path": "../@n8n/imap/tsconfig.build.json" }, diff --git a/packages/nodes-base/tsup.config.ts b/packages/nodes-base/tsup.config.ts deleted file mode 100644 index ff535a2480..0000000000 --- a/packages/nodes-base/tsup.config.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { defineConfig } from 'tsup'; -import glob from 'fast-glob'; -import { resolve } from 'path'; -import { readFile } from 'fs/promises'; - -const packagesDir = resolve(__dirname, '..'); -const aiNodesDir = resolve(packagesDir, '@n8n', 'nodes-langchain'); -const cliDir = resolve(packagesDir, 'cli'); - -const externalFiles = [ - ...(await glob('nodes/**/*.ts', { cwd: aiNodesDir, absolute: true })), - ...(await glob('test/integration/**/*.ts', { cwd: cliDir, absolute: true })), -]; - -const externalFilesContents = externalFiles.map((filePath) => readFile(filePath, 'utf-8')); - -// Files used in other packages -const externalPackageImports = (await Promise.all(externalFilesContents)).reduce( - (acc, fileContents) => { - const regex = /from\s+['"](n8n-nodes-base[^'"]+)['"]/g; - let match; - while ((match = regex.exec(fileContents)) !== null) { - acc.add(match[1]); - } - - return acc; - }, - new Set(), -); - -const externalPackageDependencies = Array.from(externalPackageImports).map( - (i) => i.replace(/^n8n-nodes-base\/(dist\/)?/, '') + '.ts', -); - -const commonIgnoredFiles = ['!**/*.d.ts', '!**/*.test.ts']; - -export default defineConfig([ - { - entry: [ - '{credentials,nodes,test,types,utils}/**/*.ts', - ...commonIgnoredFiles, - ...externalPackageDependencies.map((path) => `!${path}`), - ], - format: ['cjs'], - dts: false, - bundle: false, - sourcemap: true, - silent: true, - }, - { - entry: [...externalPackageDependencies, ...commonIgnoredFiles], - format: ['cjs'], - dts: { - compilerOptions: { - composite: false, - }, - }, - bundle: false, - sourcemap: true, - silent: true, - }, -]); diff --git a/patches/ics.patch b/patches/ics.patch new file mode 100644 index 0000000000..3d470f4103 --- /dev/null +++ b/patches/ics.patch @@ -0,0 +1,12 @@ +diff --git a/package.json b/package.json +index c69d9542b6f211d7dd3da0d11eb62002ed480457..a85c007d243ff0323c6ee271768147a848737241 100644 +--- a/package.json ++++ b/package.json +@@ -3,6 +3,7 @@ + "version": "2.40.0", + "description": "iCal (ics) file generator", + "exports": { ++ "types": "./index.d.ts", + "require": "./index.js", + "default": "./dist/index.js" + }, diff --git a/patches/minifaker.patch b/patches/minifaker.patch new file mode 100644 index 0000000000..439a491140 --- /dev/null +++ b/patches/minifaker.patch @@ -0,0 +1,12 @@ +diff --git a/package.json b/package.json +index 6ee7fa8ca1fc6daf7322b5278becb4e38c55eef8..7ebf0a67338ae7635a13d73952e7b4fa9c6c0f6b 100644 +--- a/package.json ++++ b/package.json +@@ -7,6 +7,7 @@ + "module": "./dist/esm/index.js", + "exports": { + ".": { ++ "types": "./dist/types/index.d.ts", + "import": "./dist/esm/index.js", + "require": "./dist/cjs/index.js" + }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2b45d4df81..a4f1d61a38 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -219,9 +219,15 @@ patchedDependencies: element-plus@2.4.3: hash: 3bc4ea0a42ad52c6bbc3d06c12c2963d55b57d6b5b8d436e46e7fd8ff8c10661 path: patches/element-plus@2.4.3.patch + ics: + hash: 163587ad2fa9bc787ed09cd5e958eace08b4aa8aaca651869e9434ba674e158d + path: patches/ics.patch js-base64: hash: bb02fdf69495c7b0768791b60ab6e1a002053b8decd19a174f5755691e5c9500 path: patches/js-base64.patch + minifaker: + hash: bc707e2c34a2464da2c9c93ead33e80fd9883a00434ef64907ddc45208a08b33 + path: patches/minifaker.patch pdfjs-dist@5.3.31: hash: 421253c8e411cdaef58ba96d2bb44ae0784e1b3e446f5caca50710daa1fa5dcd path: patches/pdfjs-dist@5.3.31.patch @@ -2665,7 +2671,7 @@ importers: version: 0.6.3 ics: specifier: 2.40.0 - version: 2.40.0 + version: 2.40.0(patch_hash=163587ad2fa9bc787ed09cd5e958eace08b4aa8aaca651869e9434ba674e158d) isbot: specifier: 3.6.13 version: 3.6.13 @@ -2701,7 +2707,7 @@ importers: version: 3.6.7 minifaker: specifier: 1.34.1 - version: 1.34.1 + version: 1.34.1(patch_hash=bc707e2c34a2464da2c9c93ead33e80fd9883a00434ef64907ddc45208a08b33) moment-timezone: specifier: 0.5.37 version: 0.5.37 @@ -21141,7 +21147,7 @@ snapshots: '@types/serve-static@1.15.0': dependencies: '@types/mime': 3.0.1 - '@types/node': 20.17.57 + '@types/node': 20.19.1 '@types/shelljs@0.8.11': dependencies: @@ -21162,11 +21168,11 @@ snapshots: '@types/ssh2-streams@0.1.12': dependencies: - '@types/node': 20.17.57 + '@types/node': 20.19.1 '@types/ssh2@0.5.52': dependencies: - '@types/node': 20.17.57 + '@types/node': 20.19.1 '@types/ssh2-streams': 0.1.12 '@types/ssh2@1.11.6': @@ -25392,7 +25398,7 @@ snapshots: dependencies: safer-buffer: 2.1.2 - ics@2.40.0: + ics@2.40.0(patch_hash=163587ad2fa9bc787ed09cd5e958eace08b4aa8aaca651869e9434ba674e158d): dependencies: nanoid: 3.3.11 yup: 0.32.11 @@ -27070,7 +27076,7 @@ snapshots: min-indent@1.0.1: {} - minifaker@1.34.1: + minifaker@1.34.1(patch_hash=bc707e2c34a2464da2c9c93ead33e80fd9883a00434ef64907ddc45208a08b33): dependencies: '@types/uuid': 8.3.4 nanoid: 3.3.11