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 agent from './agent/Agent.resource';
|
||||
import { cleanOutputForToolUse } from './common/output.utils';
|
||||
import * as extraction from './extraction/Extraction.resource';
|
||||
import * as file from './file/File.resource';
|
||||
import * as interaction from './interaction/Interaction.resource';
|
||||
import type { AirtopType } from './node.type';
|
||||
import * as session from './session/Session.resource';
|
||||
import * as window from './window/Window.resource';
|
||||
import type { IAirtopNodeExecutionData } from '../transport/types';
|
||||
|
||||
export async function router(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const operationResult: INodeExecutionData[] = [];
|
||||
let responseData: IAirtopNodeExecutionData[] = [];
|
||||
const nodeType = this.getNode().type;
|
||||
const isCalledAsTool = nodeType.includes('airtopTool');
|
||||
|
||||
const items = this.getInputData();
|
||||
const resource = this.getNodeParameter<AirtopType>('resource', 0);
|
||||
const operation = this.getNodeParameter('operation', 0);
|
||||
|
||||
const airtopNodeData = {
|
||||
resource,
|
||||
operation,
|
||||
} as AirtopType;
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
try {
|
||||
switch (airtopNodeData.resource) {
|
||||
case 'agent':
|
||||
responseData = await agent[airtopNodeData.operation].execute.call(this, i);
|
||||
break;
|
||||
case 'session':
|
||||
responseData = await session[airtopNodeData.operation].execute.call(this, i);
|
||||
break;
|
||||
case 'window':
|
||||
responseData = await window[airtopNodeData.operation].execute.call(this, i);
|
||||
break;
|
||||
case 'interaction':
|
||||
responseData = await interaction[airtopNodeData.operation].execute.call(this, i);
|
||||
break;
|
||||
case 'extraction':
|
||||
responseData = await extraction[airtopNodeData.operation].execute.call(this, i);
|
||||
break;
|
||||
case 'file':
|
||||
responseData = await file[airtopNodeData.operation].execute.call(this, i);
|
||||
break;
|
||||
default:
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The resource "${resource}" is not supported!`,
|
||||
);
|
||||
}
|
||||
|
||||
// Get cleaner output when called as tool
|
||||
if (isCalledAsTool) {
|
||||
responseData = cleanOutputForToolUse(responseData);
|
||||
}
|
||||
|
||||
const executionData = this.helpers.constructExecutionMetaData(responseData, {
|
||||
itemData: { item: i },
|
||||
});
|
||||
|
||||
operationResult.push.apply(operationResult, executionData);
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
operationResult.push({
|
||||
json: this.getInputData(i)[0].json,
|
||||
error: error as NodeOperationError,
|
||||
});
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [operationResult];
|
||||
}
|
||||
Reference in New Issue
Block a user