mirror of
https://github.com/n8n-io/n8n.git
synced 2026-06-02 01:37:07 +02:00
* ⬆️ Upgrade TS to 4.3.5
* 👕 Add ESLint configs
* 🎨 Add Prettier config
* 📦 Add deps and commands
* ⚡ Adjust global .editorconfig to new ruleset
* 🔥 Remove unneeded local .editorconfig
* 📦 Update deps in editor-ui
* 🔨 Limit Prettier to only TS files
* ⚡ Add recommended VSCode extensions
* 👕 Fix build
* 🔥 Remove Vue setting from global config
* ⚡ Disable prefer-default-export per feedback
* ✏️ Add forgotten divider
* 👕 Disable no-plusplus
* 👕 Disable class-methods-use-this
* ✏️ Alphabetize overrides
* 👕 Add one-var consecutive override
* ⏪ Revert one-var consecutive override
This reverts commit b9252cf935.
* 🎨 👕 Lint and format workflow package (#2121)
* 🎨 Format /workflow package
* 👕 Lint /workflow package
* 🎨 Re-format /workflow package
* 👕 Re-lint /workflow package
* ✏️ Fix typo
* ⚡ Consolidate if-checks
* 🔥 Remove prefer-default-export exceptions
* 🔥 Remove no-plusplus exceptions
* 🔥 Remove class-methods-use-this exceptions
* 🎨 👕 Lint and format node-dev package (#2122)
* 🎨 Format /node-dev package
* ⚡ Exclude templates from ESLint config
This keeps the templates consistent with the codebase while preventing lint exceptions from being made part of the templates.
* 👕 Lint /node-dev package
* 🔥 Remove prefer-default-export exceptions
* 🔥 Remove no-plusplus exceptions
* 🎨 👕 Lint and format core package (#2123)
* 🎨 Format /core package
* 👕 Lint /core package
* 🎨 Re-format /core package
* 👕 Re-lint /core package
* 🔥 Remove prefer-default-export exceptions
* 🔥 Remove no-plusplus exceptions
* 🔥 Remove class-methods-use-this exceptions
* 🎨 👕 Lint and format cli package (#2124)
* 🎨 Format /cli package
* 👕 Exclude migrations from linting
* 👕 Lint /cli package
* 🎨 Re-format /cli package
* 👕 Re-lint /cli package
* 👕 Fix build
* 🔥 Remove prefer-default-export exceptions
* ⚡ Update exceptions in ActiveExecutions
* 🔥 Remove no-plusplus exceptions
* 🔥 Remove class-methods-use-this exceptions
* 👕 fix lint issues
* 🔧 use package specific linter, remove tslint command
* 🔨 resolve build issue, sync dependencies
* 🔧 change lint command
Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com>
43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
/* eslint-disable no-prototype-builtins */
|
|
import { INode, IWorkflowCredentials } from 'n8n-workflow';
|
|
// eslint-disable-next-line import/no-cycle
|
|
import { Db } from '.';
|
|
|
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
export async function WorkflowCredentials(nodes: INode[]): Promise<IWorkflowCredentials> {
|
|
// Go through all nodes to find which credentials are needed to execute the workflow
|
|
const returnCredentials: IWorkflowCredentials = {};
|
|
|
|
let node;
|
|
let type;
|
|
let name;
|
|
let foundCredentials;
|
|
// eslint-disable-next-line no-restricted-syntax
|
|
for (node of nodes) {
|
|
if (node.disabled === true || !node.credentials) {
|
|
// eslint-disable-next-line no-continue
|
|
continue;
|
|
}
|
|
|
|
// eslint-disable-next-line no-restricted-syntax
|
|
for (type of Object.keys(node.credentials)) {
|
|
if (!returnCredentials.hasOwnProperty(type)) {
|
|
returnCredentials[type] = {};
|
|
}
|
|
name = node.credentials[type];
|
|
|
|
if (!returnCredentials[type].hasOwnProperty(name)) {
|
|
// eslint-disable-next-line no-await-in-loop, @typescript-eslint/no-non-null-assertion
|
|
foundCredentials = await Db.collections.Credentials!.find({ name, type });
|
|
if (!foundCredentials.length) {
|
|
throw new Error(`Could not find credentials for type "${type}" with name "${name}".`);
|
|
}
|
|
// eslint-disable-next-line prefer-destructuring
|
|
returnCredentials[type][name] = foundCredentials[0];
|
|
}
|
|
}
|
|
}
|
|
|
|
return returnCredentials;
|
|
}
|