Files
Automata/packages/core/src/LoadNodeListSearch.ts
कारतोफ्फेलस्क्रिप्ट™ 698d96a617 refactor: Setup typescript project references across workflow, core, and cli (#4519)
* refactor: use consistent folder structure across workflow, core, and cli

* setup typescript project references across workflow, core, and cli
2022-11-09 15:25:00 +01:00

37 lines
1.0 KiB
TypeScript

import type { INodeListSearchResult, IWorkflowExecuteAdditionalData } from 'n8n-workflow';
import * as NodeExecuteFunctions from './NodeExecuteFunctions';
import { LoadNodeDetails } from './LoadNodeDetails';
export class LoadNodeListSearch extends LoadNodeDetails {
/**
* Returns the available options via a predefined method
*/
async getOptionsViaMethodName(
methodName: string,
additionalData: IWorkflowExecuteAdditionalData,
filter?: string,
paginationToken?: string,
): Promise<INodeListSearchResult> {
const node = this.getTempNode();
const nodeType = this.workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
const method = nodeType?.methods?.listSearch?.[methodName];
if (typeof method !== 'function') {
throw new Error(
`The node-type "${node.type}" does not have the method "${methodName}" defined!`,
);
}
const thisArgs = NodeExecuteFunctions.getLoadOptionsFunctions(
this.workflow,
node,
this.path,
additionalData,
);
return method.call(thisArgs, filter, paginationToken);
}
}