UNPKG

auto-builder-sdk

Version:

SDK for building Auto Builder workflow plugins

139 lines (138 loc) 5.36 kB
export interface PluginMetadata { name: string; version: string; engines: { 'auto-builder': string; }; main: string; nodes: string[]; sandbox?: { enabled?: boolean; timeoutMs?: number; memoryMb?: number; }; } export declare const log: { debug: { (...data: any[]): void; (message?: any, ...optionalParams: any[]): void; }; info: { (...data: any[]): void; (message?: any, ...optionalParams: any[]): void; }; warn: { (...data: any[]): void; (message?: any, ...optionalParams: any[]): void; }; error: { (...data: any[]): void; (message?: any, ...optionalParams: any[]): void; }; }; export declare class NodeOperationError extends Error { node?: unknown; constructor(node: unknown, message: string); } /** * Backward compatibility utility to extract input data from both old and new formats * Handles the transition from flat JSON structure to namespaced structure */ export declare const extractInputData: (inputData: any[], fallbackToLegacy?: boolean) => any; /** * Extract data from a specific namespace in the new format * Used when you specifically want data from a particular node type */ export declare const extractNamespacedData: (inputData: any[], nodeType: string) => any; export declare class NodeApiError extends Error { httpStatusCode?: number; constructor(node: unknown, message: string, opts?: { httpStatusCode?: number; }); } export declare class ParameterResolver { private static deepClone; private static getNestedValue; private static resolveStringTemplate; private static resolveTemplates; static resolve(parameters: any, context: any): any; } export declare class BaseNodeExecutor { resolveParameters(parameters: any, context: any): any; getCredentials(credentialId: string): Promise<any>; handleContinueOnFail(error: Error, node: { continueOnFail?: boolean; }): { json: { error: string; timestamp: string; }; binary: {}; pairedItem: { item: number; }; }[]; /** * Get the position of this node among nodes of the same type in the workflow */ protected getWorkflowNodePosition(node: any, context: any): number; /** * Generate a unique prefix for this node based on its type and position in the workflow * This automatically handles cases where the same node type appears multiple times */ protected generateNodePrefix(node: any, context: any): string; /** * Create a namespaced result object (industry standard approach) * Instead of prefixing every key, we namespace the entire result under the node type */ protected createNamespacedResult(result: any, nodeType: string, nodePosition: number): any; } /** * Get the position of a node among nodes of the same type in the workflow */ export declare const getWorkflowNodePosition: (node: any, context: any) => number; /** * Create a namespaced result object (industry standard approach) * Instead of prefixing every key, we namespace the entire result under the node type */ export declare const createNamespacedResult: (result: any, nodeType: string, nodePosition: number) => any; /** * Create a formatted result that merges input data with namespaced node results * This prevents key conflicts while preserving all data from previous nodes * Automatically determines the namespace based on node type and workflow position * * @param inputData - The input data from previous nodes * @param result - The result data from this node's operation * @param context - The execution context (contains node and workflow info) * @param dataItemIndex - The index of the current data item being processed (0, 1, 2...) * @param options - Optional configuration for output format * @returns Formatted result object with namespaced keys */ export declare const createFormattedResult: (inputData: any, result: any, context: any, dataItemIndex: number, options?: { legacyMode?: boolean; customPrefix?: string; includeBothFormats?: boolean; }) => any; /** * Create a formatted error result that merges input data with namespaced error information * Automatically determines the namespace based on node type and workflow position * * @param inputData - The input data from previous nodes * @param error - The error that occurred * @param context - The execution context (contains node and workflow info) * @param dataItemIndex - The index of the current data item being processed (0, 1, 2...) * @param options - Optional configuration for output format * @returns Formatted error result with namespaced keys */ export declare const createFormattedErrorResult: (inputData: any, error: Error, context: any, dataItemIndex: number, options?: { legacyMode?: boolean; customPrefix?: string; includeBothFormats?: boolean; }) => any; export declare const validatePlugin: <T extends PluginMetadata>(meta: T) => T; export declare const definePlugin: <T extends PluginMetadata>(meta: T) => T; export declare const registerCredential: (def: { name: string; }) => void; export declare const getCredentialDef: (name: string) => any; export declare const listCredentialDefinitions: () => any[];