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,57 @@
|
||||
import type { IExecuteFunctions, INodeExecutionData, JsonObject } from 'n8n-workflow';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
|
||||
import * as contact from './contact';
|
||||
import * as customer from './customer';
|
||||
import type { SyncroMsp } from './Interfaces';
|
||||
import * as rmm from './rmm';
|
||||
import * as ticket from './ticket';
|
||||
|
||||
export async function router(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const operationResult: INodeExecutionData[] = [];
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const resource = this.getNodeParameter<SyncroMsp>('resource', i);
|
||||
let operation = this.getNodeParameter('operation', i);
|
||||
let responseData: INodeExecutionData[] = [];
|
||||
if (operation === 'del') {
|
||||
operation = 'delete';
|
||||
}
|
||||
|
||||
const syncroMsp = {
|
||||
resource,
|
||||
operation,
|
||||
} as SyncroMsp;
|
||||
|
||||
try {
|
||||
if (syncroMsp.resource === 'customer') {
|
||||
responseData = await customer[syncroMsp.operation].execute.call(this, i);
|
||||
} else if (syncroMsp.resource === 'ticket') {
|
||||
responseData = await ticket[syncroMsp.operation].execute.call(this, i);
|
||||
} else if (syncroMsp.resource === 'contact') {
|
||||
responseData = await contact[syncroMsp.operation].execute.call(this, i);
|
||||
} else if (syncroMsp.resource === 'rmm') {
|
||||
responseData = await rmm[syncroMsp.operation].execute.call(this, i);
|
||||
}
|
||||
|
||||
const executionData = this.helpers.constructExecutionMetaData(responseData, {
|
||||
itemData: { item: i },
|
||||
});
|
||||
|
||||
operationResult.push(...executionData);
|
||||
} catch (err) {
|
||||
if (this.continueOnFail()) {
|
||||
const executionErrorData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray({ error: err.message }),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
operationResult.push(...executionErrorData);
|
||||
} else {
|
||||
throw new NodeApiError(this.getNode(), err as JsonObject, { itemIndex: i });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [operationResult];
|
||||
}
|
||||
Reference in New Issue
Block a user