n8n/packages/cli/src/utils.ts

53 lines
1.5 KiB
TypeScript
Raw Normal View History

/* eslint-disable @typescript-eslint/no-unsafe-assignment */
feat(editor, core, cli): implement new workflow experience (#4358) * feat(ExecuteWorkflowTrigger node): Implement ExecuteWorkflowTrigger node (#4108) * feat(ExecuteWorkflowTrigger node): Implement ExecuteWorkflowTrigger node * feat(editor): Do not show duplicate button if canvas contains `maxNodes` amount of nodes * feat(ManualTrigger node): Implement ManualTrigger node (#4110) * feat(ManualTrigger node): Implement ManualTrigger node * :memo: Remove generics doc items from ManualTrigger node * feat(editor-ui): Trigger tab redesign (#4150) * :construction: Begin with TriggerPanel implementation, add Other Trigger Nodes subcategory * :construction: Extracted categorized categories/subcategory/nodes rendering into its own component — CategorizedItems, removed SubcategoryPanel, added translations * :sparkles: Implement MainPanel background scrim * :recycle: Move `categoriesWithNodes`, 'visibleNodeTypes` and 'categorizedItems` to store, implemented dynamic categories count based on `selectedType` * :bug: Fix SlideTransition for all the NodeCreato panels * :lipstick: Fix cursos for CategoryItem and NodeItem * :bug: Make sure ALL_NODE_FILTER is always set when MainPanel is mounted * :art: Address PR comments * label: Use Array type for CategorizedItems props * :label: Add proper types for Vue props * 🎨 Use standard component registration for CategorizedItems inside TriggerHelperPanel * 🎨 Use kebab case for main-panel and icon component * :label: Improve types * feat(editor-ui): Redesign search input inside node creator panel (#4204) * :construction: Begin with TriggerPanel implementation, add Other Trigger Nodes subcategory * :construction: Extracted categorized categories/subcategory/nodes rendering into its own component — CategorizedItems, removed SubcategoryPanel, added translations * :sparkles: Implement MainPanel background scrim * :recycle: Move `categoriesWithNodes`, 'visibleNodeTypes` and 'categorizedItems` to store, implemented dynamic categories count based on `selectedType` * :bug: Fix SlideTransition for all the NodeCreato panels * :lipstick: Fix cursos for CategoryItem and NodeItem * :bug: Make sure ALL_NODE_FILTER is always set when MainPanel is mounted * :art: Address PR comments * label: Use Array type for CategorizedItems props * :label: Add proper types for Vue props * 🎨 Use standard component registration for CategorizedItems inside TriggerHelperPanel * :sparkles: Redesign search input and unify usage of categorized items * :label: Use lowercase "Boolean" as `isSearchVisible` computed return type * :fire: Remove useless emit * :sparkles: Implement no result view based on subcategory, minor fixes * :art: Remove unused properties * feat(node-email): Change EmailReadImap display name and name (#4239) * feat(editor-ui): Implement "Choose a Triger" action and related behaviour (#4226) * :sparkles: Implement "Choose a Triger" action and related behaviour * :mute: Lint fix * :recycle: Remove PlaceholderTrigger node, add a button instead * :art: Merge onMouseEnter and onMouseLeave to a single function * :bulb: Add comment * :fire: Remove PlaceholderNode registration * :art: Rename TriggerPlaceholderButton to CanvasAddButton * :sparkles: Add method to unregister custom action and rework CanvasAddButton centering logic * :art: Run `setRecenteredCanvasAddButtonPosition` on `CanvasAddButton` mount * fix(editor): Fix selecting of node from node-creator panel by clicking * :twisted_rightwards_arrows: Merge fixes * fix(editor): Show execute workflow trigger instead of workflow trigger in the trigger helper panel * feat(editor): Fix node creator panel slide transition (#4261) * fix(editor): Fix node creator panel slide-in/slide-out transitions * :art: Fix naming * :art: Use kebab-case for transition component name * feat(editor): Disable execution and show notice when user tries to run workflow without enabled triggers * fix(editor): Address first batch of new WF experience review (#4279) * fix(editor): Fix first batch of review items * bug(editor): Fix nodeview canvas add button centering * :mute: Fix linter errors * bug(ManualTrigger Node): Fix manual trigger node execution * fix(editor): Do not show canvas add button in execution or demo mode and prevent clicking if creator is open * fix(editor): do not show pin data tooltip for manual trigger node * fix(editor): do not use nodeViewOffset on zoomToFit * :lipstick: Add margin for last node creator item and set font-weight to 700 for category title * :sparkles: Position welcome note next to the added trigger node * :bug: Remve always true welcome note * feat(editor): Minor UI and UX tweaks (#4328) * :lipstick: Make top viewport buttons less prominent * :sparkles: Allow user to switch to all tabs if it contains filter results, move nodecreator state props to its own module * :mute: Fix linting errors * :mute: Fix linting errors * :mute: Fix linting errors * chore(build): Ping Turbo version to 1.5.5 * :lipstick: Minor traigger panel and node view style changes * :speech_balloon: Update display name of execute workflow trigger * feat(core, editor): Update subworkflow execution logic (#4269) * :sparkles: Implement `findWorkflowStart` * :zap: Extend `WorkflowOperationError` * :zap: Add `WorkflowOperationError` to toast * :blue_book: Extend interface * :sparkles: Add `subworkflowExecutionError` to store * :sparkles: Create `SubworkflowOperationError` * :zap: Render subworkflow error as node error * :truck: Move subworkflow start validation to `cli` * :zap: Reset subworkflow execution error state * :fire: Remove unused import * :zap: Adjust CLI commands * :fire: Remove unneeded check * :fire: Remove stray log * :zap: Simplify syntax * :zap: Sort in case both Start and EWT present * :recycle: Address Omar's feedback * :fire: Remove unneeded lint exception * :pencil2: Fix copy * :shirt: Fix lint * fix: moved find start node function to catchable place Co-authored-by: Omar Ajoue <krynble@gmail.com> * :lipstick: Change ExecuteWorkflow node to primary * :sparkles: Allow user to navigate to all tab if it contains search results * :bug: Fixed canvas control button while in demo, disable workflow activation for non-activavle nodes and revert zoomToFit bottom offset * :fix: Do not chow request text if there's results * :speech_balloon: Update noResults text Co-authored-by: Iván Ovejero <ivov.src@gmail.com> Co-authored-by: Omar Ajoue <krynble@gmail.com>
2022-10-18 05:23:22 -07:00
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],
}),
{},
);
feat(core): Security audit (#5034) * :sparkles: Implement security audit * :zap: Use logger * :test_tube: Fix test * :zap: Switch logger with stdout * :art: Set new logo * :zap: Fill out Public API schema * :pencil2: Fix typo * :zap: Break dependency cycle * :zap: Add security settings values * :test_tube: Test security settings * :zap: Add publicly accessible instance warning * :zap: Add metric to CLI command * :pencil2: Fix typo * :fire: Remove unneeded path alias * :blue_book: Add type import * :fire: Remove inferrable output type * :zap: Set description at correct level * :zap: Rename constant for consistency * :zap: Sort URLs * :zap: Rename local var * :zap: Shorten name * :pencil2: Improve phrasing * :zap: Improve naming * :zap: Fix casing * :pencil2: Add docline * :pencil2: Relocate comment * :zap: Add singular/plurals * :fire: Remove unneeded await * :pencil2: Improve test description * :zap: Optimize with sets * :zap: Adjust post master merge * :pencil2: Improve naming * :zap: Adjust in spy * :test_tube: Fix outdated instance test * :test_tube: Make diagnostics check consistent * :zap: Refactor `getAllExistingCreds` * :zap: Create helper `getNodeTypes` * :bug: Fix `InternalHooksManager` call * :truck: Rename `execution` to `nodes` risk * :zap: Add options to CLI command * :zap: Make days configurable * :revert: Undo changes to `BaseCommand` * :zap: Improve CLI command UX * :zap: Change no-report return value Empty array to trigger empty state on FE. * :zap: Add empty check to `reportInstanceRisk` * :test_tube: Extend Jest `expect` * :blue_book: Augment `jest.Matchers` * :test_tube: Set extend as setup file * :wrench: Override lint rule for `.d.ts` * :zap: Use new matcher * :zap: Update check * :blue_book: Improve typings * :zap: Adjust instance risk check * :pencil2: Rename `execution` → `nodes` in Public API schema * :pencil2: Add clarifying comment * :pencil2: Fix typo * :zap: Validate categories in CLI command * :pencil2: Improve naming * :pencil2: Make audit reference consistent * :blue_book: Fix typing * :zap: Use `finally` in CLI command
2023-01-05 04:28:40 -08:00
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];
};