mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-20 09:01:39 -08:00
d548161632
* ✨ Implement security audit * ⚡ Use logger * 🧪 Fix test * ⚡ Switch logger with stdout * 🎨 Set new logo * ⚡ Fill out Public API schema * ✏️ Fix typo * ⚡ Break dependency cycle * ⚡ Add security settings values * 🧪 Test security settings * ⚡ Add publicly accessible instance warning * ⚡ Add metric to CLI command * ✏️ Fix typo * 🔥 Remove unneeded path alias * 📘 Add type import * 🔥 Remove inferrable output type * ⚡ Set description at correct level * ⚡ Rename constant for consistency * ⚡ Sort URLs * ⚡ Rename local var * ⚡ Shorten name * ✏️ Improve phrasing * ⚡ Improve naming * ⚡ Fix casing * ✏️ Add docline * ✏️ Relocate comment * ⚡ Add singular/plurals * 🔥 Remove unneeded await * ✏️ Improve test description * ⚡ Optimize with sets * ⚡ Adjust post master merge * ✏️ Improve naming * ⚡ Adjust in spy * 🧪 Fix outdated instance test * 🧪 Make diagnostics check consistent * ⚡ Refactor `getAllExistingCreds` * ⚡ Create helper `getNodeTypes` * 🐛 Fix `InternalHooksManager` call * 🚚 Rename `execution` to `nodes` risk * ⚡ Add options to CLI command * ⚡ Make days configurable * :revert: Undo changes to `BaseCommand` * ⚡ Improve CLI command UX * ⚡ Change no-report return value Empty array to trigger empty state on FE. * ⚡ Add empty check to `reportInstanceRisk` * 🧪 Extend Jest `expect` * 📘 Augment `jest.Matchers` * 🧪 Set extend as setup file * 🔧 Override lint rule for `.d.ts` * ⚡ Use new matcher * ⚡ Update check * 📘 Improve typings * ⚡ Adjust instance risk check * ✏️ Rename `execution` → `nodes` in Public API schema * ✏️ Add clarifying comment * ✏️ Fix typo * ⚡ Validate categories in CLI command * ✏️ Improve naming * ✏️ Make audit reference consistent * 📘 Fix typing * ⚡ Use `finally` in CLI command
53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
import { CliWorkflowOperationError, SubworkflowOperationError } from 'n8n-workflow';
|
|
import type { INode } from 'n8n-workflow';
|
|
|
|
function findWorkflowStart(executionMode: 'integrated' | 'cli') {
|
|
return function (nodes: INode[]) {
|
|
const executeWorkflowTriggerNode = nodes.find(
|
|
(node) => node.type === 'n8n-nodes-base.executeWorkflowTrigger',
|
|
);
|
|
|
|
if (executeWorkflowTriggerNode) return executeWorkflowTriggerNode;
|
|
|
|
const startNode = nodes.find((node) => node.type === 'n8n-nodes-base.start');
|
|
|
|
if (startNode) return startNode;
|
|
|
|
const title = 'Missing node to start execution';
|
|
const description =
|
|
"Please make sure the workflow you're calling contains an Execute Workflow Trigger node";
|
|
|
|
if (executionMode === 'integrated') {
|
|
throw new SubworkflowOperationError(title, description);
|
|
}
|
|
|
|
throw new CliWorkflowOperationError(title, description);
|
|
};
|
|
}
|
|
|
|
export const findSubworkflowStart = findWorkflowStart('integrated');
|
|
|
|
export const findCliWorkflowStart = findWorkflowStart('cli');
|
|
|
|
export const alphabetizeKeys = (obj: INode) =>
|
|
Object.keys(obj)
|
|
.sort()
|
|
.reduce<Partial<INode>>(
|
|
(acc, key) => ({
|
|
...acc,
|
|
// @ts-expect-error @TECH_DEBT Adding index signature to INode causes type issues downstream
|
|
[key]: obj[key],
|
|
}),
|
|
{},
|
|
);
|
|
|
|
export const separate = <T>(array: T[], test: (element: T) => boolean) => {
|
|
const pass: T[] = [];
|
|
const fail: T[] = [];
|
|
|
|
array.forEach((i) => (test(i) ? pass : fail).push(i));
|
|
|
|
return [pass, fail];
|
|
};
|