auto-builder-sdk
Version:
SDK for building Auto Builder workflow plugins
256 lines (255 loc) • 6.94 kB
TypeScript
export interface IWorkflow {
id: string;
name: string;
description?: string;
nodes: INode[];
connections: IConnections;
settings: IWorkflowSettings;
active: boolean;
erpaiAppId?: string;
erpaiTenantId?: string;
createdBy?: string;
updatedBy?: string;
deleted: boolean;
createdAt: Date;
updatedAt: Date;
}
export interface INode {
id: string;
name: string;
type: string;
typeVersion: number;
position: [number, number];
parameters: Record<string, any>;
credentials?: Record<string, string>;
disabled?: boolean;
continueOnFail?: boolean;
retryOnFail?: boolean;
maxTries?: number;
waitBetween?: number;
alwaysOutputData?: boolean;
}
export interface IConnections {
[key: string]: {
[key: string]: IConnection[][];
};
}
export interface IConnection {
node: string;
type: string;
index: number;
}
export interface IWorkflowSettings {
executionOrder?: 'v0' | 'v1';
saveManualExecutions?: boolean;
saveDataErrorExecution?: 'all' | 'none';
saveDataSuccessExecution?: 'all' | 'none';
timezone?: string;
[key: string]: any;
}
export interface IWorkflowExecution {
id: string;
workflowId: string;
status: ExecutionStatus;
startedAt: Date;
finishedAt?: Date;
executionData?: IExecutionData;
errorMessage?: string;
mode: ExecutionMode;
nodeExecutions?: INodeExecution[];
}
export interface INodeExecution {
id: string;
workflowExecutionId: string;
nodeId: string;
nodeType: string;
status: ExecutionStatus;
inputData?: INodeExecutionData[];
outputData?: INodeExecutionData[];
errorMessage?: string;
executedAt: Date;
executionTime?: number;
}
export interface IExecutionData {
startData?: {
destinationNode?: string;
runNodeFilter?: string[];
};
resultData?: {
runData: IRunData;
pinData?: IPinData;
lastNodeExecuted?: string;
};
executionData?: {
contextData: IRunExecutionData;
nodeExecutionStack: IExecuteData[];
metadata: IExecutionMetadata;
waitingExecution: IWaitingForExecution;
waitingExecutionSource: IWaitingForExecutionSource;
};
}
export interface INodeExecutionData {
json: IDataObject;
binary?: IBinaryKeyData;
pairedItem?: IPairedItemData | IPairedItemData[];
source?: ISourceData[];
error?: NodeApiError | NodeOperationError;
}
export interface IDataObject {
[key: string]: any;
}
export interface IBinaryKeyData {
[key: string]: IBinaryData;
}
export interface IBinaryData {
data: string;
mimeType: string;
fileName?: string;
directory?: string;
fileExtension?: string;
fileSize?: string;
fileType?: string;
}
export interface IPairedItemData {
item: number;
input?: number;
}
export interface ISourceData {
previousNode: string;
previousNodeOutput?: number;
previousNodeRun?: number;
}
export interface IRunData {
[key: string]: ITaskData[];
}
export interface ITaskData {
startTime: number;
executionTime: number;
executionStatus?: 'success' | 'error';
data?: ITaskDataConnections;
error?: NodeApiError | NodeOperationError;
source: Array<ISourceData | null>;
}
export interface ITaskDataConnections {
main?: INodeExecutionData[][];
[key: string]: INodeExecutionData[][] | undefined;
}
export interface IPinData {
[key: string]: INodeExecutionData[];
}
export interface IRunExecutionData {
[key: string]: any;
}
export interface IExecuteData {
node: INode;
data: ITaskDataConnections;
source: ISourceData;
}
export interface IExecutionMetadata {
[key: string]: any;
}
export interface IWaitingForExecution {
[key: string]: any;
}
export interface IWaitingForExecutionSource {
[key: string]: any;
}
export interface IExecutionContext {
executionId: string;
workflowId: string;
workflow: IWorkflow;
node: INode;
inputData: INodeExecutionData[];
runIndex: number;
itemIndex: number;
mode: ExecutionMode;
timezone: string;
variables: IDataObject;
/**
* Lazily obtains an ERP-AI Deskera bearer token scoped to the current user/org.
* Provided by the auto-builder engine at runtime.
*/
getDeskeraToken?: () => Promise<string>;
continueOnFail?: boolean;
}
export interface INodeExecutor {
nodeType: string;
execute(node: INode, inputData: INodeExecutionData[], context: IExecutionContext): Promise<INodeExecutionData[]>;
}
export declare class NodeApiError extends Error {
readonly httpStatusCode?: number;
readonly errorMessage: string;
readonly description?: string;
readonly context?: IDataObject;
readonly functionality?: string;
}
export declare class NodeOperationError extends Error {
readonly description: string;
readonly context?: IDataObject;
}
export type ExecutionStatus = 'new' | 'running' | 'success' | 'error' | 'waiting' | 'canceled' | 'crashed' | 'unknown';
export type ExecutionMode = 'cli' | 'error' | 'integrated' | 'internal' | 'manual' | 'retry' | 'trigger' | 'webhook';
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
export type NodeConnectionType = 'main' | 'ai_agent' | 'ai_chain' | 'ai_document' | 'ai_embedding' | 'ai_language_model' | 'ai_memory' | 'ai_output_parser' | 'ai_retriever' | 'ai_text_splitter' | 'ai_tool' | 'ai_vector_store';
export interface ApiResponse<T = any> {
success: boolean;
data?: T;
error?: string;
message?: string;
}
export interface PaginatedResponse<T> extends ApiResponse<T[]> {
data: T[];
pagination: {
page: number;
pageSize: number;
total: number;
totalPages: number;
};
}
export interface WorkflowCreateRequest {
name: string;
description?: string;
nodes: INode[];
connections: IConnections;
settings?: IWorkflowSettings;
erpaiAppId?: string;
}
export interface WorkflowUpdateRequest extends Partial<WorkflowCreateRequest> {
active?: boolean;
}
export interface UserSession {
userId: string;
userEmail: string;
orgName: string;
orgRole: string;
orgId: string;
rawToken: string;
}
export interface ApiWorkflowExecution {
id: string;
workflowId: string;
workflowName?: string;
status: ExecutionStatus;
startTime: string;
endTime?: string;
executedBy?: string;
trigger?: string;
mode: ExecutionMode;
nodeExecutions?: ApiNodeExecution[];
error?: string;
executionTime?: number;
totalNodes?: number;
executedNodes?: number;
failedNodes?: number;
}
export interface ApiNodeExecution {
id: string;
nodeId: string;
nodeType: string;
startTime: string;
endTime?: string;
status: ExecutionStatus;
data?: any;
error?: string;
executionTime?: number;
}