first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
||||
import { NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
import * as alert from './alert';
|
||||
import * as case_ from './case';
|
||||
import * as comment from './comment';
|
||||
import * as log from './log';
|
||||
import type { TheHiveType } from './node.type';
|
||||
import * as observable from './observable';
|
||||
import * as page from './page';
|
||||
import * as query from './query';
|
||||
import * as task from './task';
|
||||
|
||||
export async function router(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
const length = items.length;
|
||||
|
||||
const resource = this.getNodeParameter<TheHiveType>('resource', 0);
|
||||
const operation = this.getNodeParameter('operation', 0);
|
||||
|
||||
let executionData: INodeExecutionData[] = [];
|
||||
|
||||
const theHiveNodeData = {
|
||||
resource,
|
||||
operation,
|
||||
} as TheHiveType;
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
try {
|
||||
switch (theHiveNodeData.resource) {
|
||||
case 'alert':
|
||||
executionData = await alert[theHiveNodeData.operation].execute.call(this, i, items[i]);
|
||||
break;
|
||||
case 'case':
|
||||
executionData = await case_[theHiveNodeData.operation].execute.call(this, i, items[i]);
|
||||
break;
|
||||
case 'comment':
|
||||
executionData = await comment[theHiveNodeData.operation].execute.call(this, i);
|
||||
break;
|
||||
case 'log':
|
||||
executionData = await log[theHiveNodeData.operation].execute.call(this, i, items[i]);
|
||||
break;
|
||||
case 'observable':
|
||||
executionData = await observable[theHiveNodeData.operation].execute.call(
|
||||
this,
|
||||
i,
|
||||
items[i],
|
||||
);
|
||||
break;
|
||||
case 'page':
|
||||
executionData = await page[theHiveNodeData.operation].execute.call(this, i);
|
||||
break;
|
||||
case 'query':
|
||||
executionData = await query[theHiveNodeData.operation].execute.call(this, i);
|
||||
break;
|
||||
case 'task':
|
||||
executionData = await task[theHiveNodeData.operation].execute.call(this, i, items[i]);
|
||||
break;
|
||||
default:
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not supported!`,
|
||||
);
|
||||
}
|
||||
returnData.push(...executionData);
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray({ error: error.message }),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
continue;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
return [returnData];
|
||||
}
|
||||
Reference in New Issue
Block a user