mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
refactor: Upgrade to TypeScript 5.5 (no-changelog) (#9828)
This commit is contained in:
parent
1ba656ef4a
commit
e33a47311f
|
@ -77,7 +77,7 @@
|
||||||
"semver": "^7.5.4",
|
"semver": "^7.5.4",
|
||||||
"tslib": "^2.6.2",
|
"tslib": "^2.6.2",
|
||||||
"tsconfig-paths": "^4.2.0",
|
"tsconfig-paths": "^4.2.0",
|
||||||
"typescript": "^5.4.2",
|
"typescript": "^5.5.2",
|
||||||
"ws": ">=8.17.1"
|
"ws": ">=8.17.1"
|
||||||
},
|
},
|
||||||
"patchedDependencies": {
|
"patchedDependencies": {
|
||||||
|
|
|
@ -116,7 +116,7 @@ export class ExternalSecretsManager {
|
||||||
)
|
)
|
||||||
).map((i) => (i.status === 'rejected' ? null : i.value));
|
).map((i) => (i.status === 'rejected' ? null : i.value));
|
||||||
this.providers = Object.fromEntries(
|
this.providers = Object.fromEntries(
|
||||||
(providers.filter((p) => p !== null) as SecretsProvider[]).map((s) => [s.name, s]),
|
providers.filter((p): p is SecretsProvider => p !== null).map((s) => [s.name, s]),
|
||||||
);
|
);
|
||||||
this.cachedSettings = settings;
|
this.cachedSettings = settings;
|
||||||
await this.updateSecrets();
|
await this.updateSecrets();
|
||||||
|
|
|
@ -458,7 +458,7 @@ export class VaultProvider extends SecretsProvider {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.map((i) => (i.status === 'rejected' ? null : i.value))
|
.map((i) => (i.status === 'rejected' ? null : i.value))
|
||||||
.filter((v) => v !== null) as Array<[string, IDataObject]>,
|
.filter((v): v is [string, IDataObject] => v !== null),
|
||||||
);
|
);
|
||||||
const name = path.substring(0, path.length - 1);
|
const name = path.substring(0, path.length - 1);
|
||||||
return [name, data];
|
return [name, data];
|
||||||
|
@ -480,7 +480,7 @@ export class VaultProvider extends SecretsProvider {
|
||||||
return [basePath.substring(0, basePath.length - 1), value[1]];
|
return [basePath.substring(0, basePath.length - 1), value[1]];
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
).filter((v) => v !== null) as Array<[string, IDataObject]>,
|
).filter((v): v is [string, IDataObject] => v !== null),
|
||||||
);
|
);
|
||||||
this.cachedSecrets = secrets;
|
this.cachedSecrets = secrets;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1047,10 +1047,8 @@ function getWorkflowHooksIntegrated(
|
||||||
const hookFunctions = hookFunctionsSave();
|
const hookFunctions = hookFunctionsSave();
|
||||||
const preExecuteFunctions = hookFunctionsPreExecute();
|
const preExecuteFunctions = hookFunctionsPreExecute();
|
||||||
for (const key of Object.keys(preExecuteFunctions)) {
|
for (const key of Object.keys(preExecuteFunctions)) {
|
||||||
if (hookFunctions[key] === undefined) {
|
const hooks = hookFunctions[key] ?? [];
|
||||||
hookFunctions[key] = [];
|
hooks.push.apply(hookFunctions[key], preExecuteFunctions[key]);
|
||||||
}
|
|
||||||
hookFunctions[key]!.push.apply(hookFunctions[key], preExecuteFunctions[key]);
|
|
||||||
}
|
}
|
||||||
return new WorkflowHooks(hookFunctions, mode, executionId, workflowData);
|
return new WorkflowHooks(hookFunctions, mode, executionId, workflowData);
|
||||||
}
|
}
|
||||||
|
@ -1069,10 +1067,8 @@ export function getWorkflowHooksWorkerExecuter(
|
||||||
const hookFunctions = hookFunctionsSaveWorker();
|
const hookFunctions = hookFunctionsSaveWorker();
|
||||||
const preExecuteFunctions = hookFunctionsPreExecute();
|
const preExecuteFunctions = hookFunctionsPreExecute();
|
||||||
for (const key of Object.keys(preExecuteFunctions)) {
|
for (const key of Object.keys(preExecuteFunctions)) {
|
||||||
if (hookFunctions[key] === undefined) {
|
const hooks = hookFunctions[key] ?? [];
|
||||||
hookFunctions[key] = [];
|
hooks.push.apply(hookFunctions[key], preExecuteFunctions[key]);
|
||||||
}
|
|
||||||
hookFunctions[key]!.push.apply(hookFunctions[key], preExecuteFunctions[key]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new WorkflowHooks(hookFunctions, mode, executionId, workflowData, optionalParameters);
|
return new WorkflowHooks(hookFunctions, mode, executionId, workflowData, optionalParameters);
|
||||||
|
@ -1139,18 +1135,14 @@ export function getWorkflowHooksMain(
|
||||||
const hookFunctions = hookFunctionsSave();
|
const hookFunctions = hookFunctionsSave();
|
||||||
const pushFunctions = hookFunctionsPush();
|
const pushFunctions = hookFunctionsPush();
|
||||||
for (const key of Object.keys(pushFunctions)) {
|
for (const key of Object.keys(pushFunctions)) {
|
||||||
if (hookFunctions[key] === undefined) {
|
const hooks = hookFunctions[key] ?? [];
|
||||||
hookFunctions[key] = [];
|
hooks.push.apply(hookFunctions[key], pushFunctions[key]);
|
||||||
}
|
|
||||||
hookFunctions[key]!.push.apply(hookFunctions[key], pushFunctions[key]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const preExecuteFunctions = hookFunctionsPreExecute();
|
const preExecuteFunctions = hookFunctionsPreExecute();
|
||||||
for (const key of Object.keys(preExecuteFunctions)) {
|
for (const key of Object.keys(preExecuteFunctions)) {
|
||||||
if (hookFunctions[key] === undefined) {
|
const hooks = hookFunctions[key] ?? [];
|
||||||
hookFunctions[key] = [];
|
hooks.push.apply(hookFunctions[key], preExecuteFunctions[key]);
|
||||||
}
|
|
||||||
hookFunctions[key]!.push.apply(hookFunctions[key], preExecuteFunctions[key]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hookFunctions.nodeExecuteBefore) hookFunctions.nodeExecuteBefore = [];
|
if (!hookFunctions.nodeExecuteBefore) hookFunctions.nodeExecuteBefore = [];
|
||||||
|
|
|
@ -737,8 +737,10 @@ export class ExecuteBatch extends BaseCommand {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodeEdgeCases[nodeName].capResults !== undefined) {
|
const capResults = nodeEdgeCases[nodeName].capResults;
|
||||||
executionDataArray.splice(nodeEdgeCases[nodeName].capResults!);
|
|
||||||
|
if (capResults !== undefined) {
|
||||||
|
executionDataArray.splice(capResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodeEdgeCases[nodeName].ignoredProperties !== undefined) {
|
if (nodeEdgeCases[nodeName].ignoredProperties !== undefined) {
|
||||||
|
|
|
@ -235,13 +235,14 @@ export class SourceControlExportService {
|
||||||
data: ICredentialDataDecryptedObject,
|
data: ICredentialDataDecryptedObject,
|
||||||
): ICredentialDataDecryptedObject => {
|
): ICredentialDataDecryptedObject => {
|
||||||
for (const [key] of Object.entries(data)) {
|
for (const [key] of Object.entries(data)) {
|
||||||
|
const value = data[key];
|
||||||
try {
|
try {
|
||||||
if (data[key] === null) {
|
if (value === null) {
|
||||||
delete data[key]; // remove invalid null values
|
delete data[key]; // remove invalid null values
|
||||||
} else if (typeof data[key] === 'object') {
|
} else if (typeof value === 'object') {
|
||||||
data[key] = this.replaceCredentialData(data[key] as ICredentialDataDecryptedObject);
|
data[key] = this.replaceCredentialData(value as ICredentialDataDecryptedObject);
|
||||||
} else if (typeof data[key] === 'string') {
|
} else if (typeof value === 'string') {
|
||||||
data[key] = stringContainsExpression(data[key] as string) ? data[key] : '';
|
data[key] = stringContainsExpression(value) ? data[key] : '';
|
||||||
} else if (typeof data[key] === 'number') {
|
} else if (typeof data[key] === 'number') {
|
||||||
// TODO: leaving numbers in for now, but maybe we should remove them
|
// TODO: leaving numbers in for now, but maybe we should remove them
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -84,8 +84,8 @@ export class SourceControlImportService {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
return remoteWorkflowFilesParsed.filter(
|
return remoteWorkflowFilesParsed.filter(
|
||||||
(e) => e !== undefined,
|
(e): e is SourceControlWorkflowVersionId => e !== undefined,
|
||||||
) as SourceControlWorkflowVersionId[];
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getLocalVersionIdsFromDb(): Promise<SourceControlWorkflowVersionId[]> {
|
public async getLocalVersionIdsFromDb(): Promise<SourceControlWorkflowVersionId[]> {
|
||||||
|
|
|
@ -148,13 +148,15 @@ export class Telemetry {
|
||||||
properties.success ? 'success' : 'error'
|
properties.success ? 'success' : 'error'
|
||||||
}`;
|
}`;
|
||||||
|
|
||||||
if (!this.executionCountsBuffer[workflowId][key]) {
|
const executionTrackDataKey = this.executionCountsBuffer[workflowId][key];
|
||||||
|
|
||||||
|
if (!executionTrackDataKey) {
|
||||||
this.executionCountsBuffer[workflowId][key] = {
|
this.executionCountsBuffer[workflowId][key] = {
|
||||||
count: 1,
|
count: 1,
|
||||||
first: execTime,
|
first: execTime,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
this.executionCountsBuffer[workflowId][key]!.count++;
|
executionTrackDataKey.count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -85,6 +85,7 @@ export class ActiveWorkflows {
|
||||||
if (triggerResponse !== undefined) {
|
if (triggerResponse !== undefined) {
|
||||||
// If a response was given save it
|
// If a response was given save it
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
||||||
this.activeWorkflows[workflowId].triggerResponses!.push(triggerResponse);
|
this.activeWorkflows[workflowId].triggerResponses!.push(triggerResponse);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -105,6 +106,7 @@ export class ActiveWorkflows {
|
||||||
|
|
||||||
for (const pollNode of pollingNodes) {
|
for (const pollNode of pollingNodes) {
|
||||||
try {
|
try {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
||||||
this.activeWorkflows[workflowId].pollResponses!.push(
|
this.activeWorkflows[workflowId].pollResponses!.push(
|
||||||
await this.activatePolling(
|
await this.activatePolling(
|
||||||
pollNode,
|
pollNode,
|
||||||
|
|
|
@ -3679,7 +3679,7 @@ export function getExecuteFunctions(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return inputData[inputName][inputIndex] as INodeExecutionData[];
|
return inputData[inputName][inputIndex];
|
||||||
},
|
},
|
||||||
getInputSourceData: (inputIndex = 0, inputName = 'main') => {
|
getInputSourceData: (inputIndex = 0, inputName = 'main') => {
|
||||||
if (executeData?.source === null) {
|
if (executeData?.source === null) {
|
||||||
|
|
|
@ -36,6 +36,7 @@ module.exports = {
|
||||||
'@typescript-eslint/no-unsafe-argument': 'warn',
|
'@typescript-eslint/no-unsafe-argument': 'warn',
|
||||||
'@typescript-eslint/prefer-optional-chain': 'warn',
|
'@typescript-eslint/prefer-optional-chain': 'warn',
|
||||||
'@typescript-eslint/restrict-plus-operands': 'warn',
|
'@typescript-eslint/restrict-plus-operands': 'warn',
|
||||||
|
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
|
||||||
},
|
},
|
||||||
|
|
||||||
overrides: [
|
overrides: [
|
||||||
|
|
|
@ -377,8 +377,10 @@ export function applyDeclarativeNodeOptionParameters(nodeType: INodeType): void
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
if (parameters[existingRequestOptionsIndex]?.options) {
|
const options = parameters[existingRequestOptionsIndex]?.options;
|
||||||
parameters[existingRequestOptionsIndex].options!.sort((a, b) => {
|
|
||||||
|
if (options) {
|
||||||
|
options.sort((a, b) => {
|
||||||
if ('displayName' in a && 'displayName' in b) {
|
if ('displayName' in a && 'displayName' in b) {
|
||||||
if (a.displayName < b.displayName) {
|
if (a.displayName < b.displayName) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -441,12 +441,8 @@ export class RoutingNode {
|
||||||
// Sort the returned options
|
// Sort the returned options
|
||||||
const sortKey = action.properties.key;
|
const sortKey = action.properties.key;
|
||||||
inputData.sort((a, b) => {
|
inputData.sort((a, b) => {
|
||||||
const aSortValue = a.json[sortKey]
|
const aSortValue = a.json[sortKey]?.toString().toLowerCase() ?? '';
|
||||||
? (a.json[sortKey]?.toString().toLowerCase() as string)
|
const bSortValue = b.json[sortKey]?.toString().toLowerCase() ?? '';
|
||||||
: '';
|
|
||||||
const bSortValue = b.json[sortKey]
|
|
||||||
? (b.json[sortKey]?.toString().toLowerCase() as string)
|
|
||||||
: '';
|
|
||||||
if (aSortValue < bSortValue) {
|
if (aSortValue < bSortValue) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,9 @@ export class WorkflowHooks {
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
async executeHookFunctions(hookName: string, parameters: any[]) {
|
async executeHookFunctions(hookName: string, parameters: any[]) {
|
||||||
if (this.hookFunctions[hookName] !== undefined && Array.isArray(this.hookFunctions[hookName])) {
|
const hooks = this.hookFunctions[hookName];
|
||||||
for (const hookFunction of this.hookFunctions[hookName]!) {
|
if (hooks !== undefined && Array.isArray(hooks)) {
|
||||||
|
for (const hookFunction of hooks) {
|
||||||
await hookFunction.apply(this, parameters);
|
await hookFunction.apply(this, parameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,8 +186,8 @@ for (const evaluator of ['tmpl', 'tournament'] as const) {
|
||||||
}
|
}
|
||||||
test(t.expression, () => {
|
test(t.expression, () => {
|
||||||
const evaluationTests = t.tests.filter(
|
const evaluationTests = t.tests.filter(
|
||||||
(test) => test.type === 'evaluation',
|
(test): test is ExpressionTestEvaluation => test.type === 'evaluation',
|
||||||
) as ExpressionTestEvaluation[];
|
);
|
||||||
|
|
||||||
for (const test of evaluationTests) {
|
for (const test of evaluationTests) {
|
||||||
const input = test.input.map((d) => ({ json: d })) as any;
|
const input = test.input.map((d) => ({ json: d })) as any;
|
||||||
|
@ -209,8 +209,8 @@ for (const evaluator of ['tmpl', 'tournament'] as const) {
|
||||||
}
|
}
|
||||||
test(t.expression, () => {
|
test(t.expression, () => {
|
||||||
for (const test of t.tests.filter(
|
for (const test of t.tests.filter(
|
||||||
(test) => test.type === 'transform',
|
(test): test is ExpressionTestTransform => test.type === 'transform',
|
||||||
) as ExpressionTestTransform[]) {
|
)) {
|
||||||
const expr = t.expression;
|
const expr = t.expression;
|
||||||
expect(extendSyntax(expr, test.forceTransform)).toEqual(test.result ?? expr);
|
expect(extendSyntax(expr, test.forceTransform)).toEqual(test.result ?? expr);
|
||||||
}
|
}
|
||||||
|
|
552
pnpm-lock.yaml
552
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue