/** * Action Manager * * Manages reusable database actions (query templates). * Actions allow defining common database operations that can be * executed with different input parameters. * * Uses ProductBuilder for persistence to the backend. */ import { DatabaseActionType } from '../types/enums'; import { IActionDefinition, IActionTemplate, IActionCreateOptions, IActionUpdateOptions, IActionExecuteOptions, IPlaceholder, IParsedTemplate } from '../types/action.interface'; import { IWhereClause } from '../types/query.interface'; /** * DatabaseService reference type (to avoid circular imports) */ interface IDatabaseServiceRef { getConfig(): { workspace_id: string; public_key: string; user_id: string; token: string; env_type: string; access_key: string; } | null; } /** * Action Manager for managing reusable database actions * Uses ProductBuilder for persistent storage */ export declare class ActionManager { private databaseService; private productBuilders; constructor(databaseService: IDatabaseServiceRef); /** * Create a new ProductBuilder instance */ private createNewProductBuilder; /** * Get or create a ProductBuilder instance for the given product tag */ private getProductBuilder; /** * Create a new database action * @param options Action creation options */ create(options: IActionCreateOptions): Promise; /** * Update an existing database action * @param options Action update options */ update(options: IActionUpdateOptions): Promise; /** * Fetch a specific database action * @param tag Action tag in format: product:database:action * @returns Action definition or null */ fetch(tag: string): Promise; /** * Fetch all database actions for a database * @param tag Database tag in format: product:database * @returns Array of action definitions */ fetchAll(tag: string): Promise; /** * Delete a database action * @param tag Action tag in format: product:database:action */ delete(tag: string): Promise; /** * Execute a database action * * Note: Action execution is handled through the ProcessorService. * This method validates the action exists and returns the action definition * for the caller to execute through the appropriate channel. * * @param options Execution options * @returns Action result */ execute(options: IActionExecuteOptions): Promise; /** * Parse a template and extract placeholders * @param template Action template * @returns Parsed template with placeholder info */ parseTemplate(template: IActionTemplate): IParsedTemplate; /** * Extract all placeholders from a template * @param template Action template * @returns Array of placeholder definitions */ extractPlaceholders(template: IActionTemplate): IPlaceholder[]; /** * Validate input against placeholder requirements * @param template Action template * @param input Input values * @returns True if valid */ validateInput(template: IActionTemplate, input: Record): boolean; /** * Parse action tag into components * Supports formats: * - product:database:action * - database:action (uses default product) */ private parseActionTag; /** * Map internal operation type to ProductDatabaseActionTypes */ private mapOperationType; /** * Convert IProductDatabaseAction to IActionDefinition */ private convertToActionDefinition; /** * Map ProductDatabaseActionTypes to DatabaseActionType */ private mapProductActionType; /** * Parse stored template (may be string or object) */ private parseStoredTemplate; /** * Resolve template placeholders with input values */ private resolveTemplate; private resolveObject; private resolvePlaceholdersInString; } /** * Action Builder for fluent action creation */ export declare class ActionBuilder { private options; /** * Set action name */ name(name: string): this; /** * Set action tag */ tag(tag: string): this; /** * Set table name */ table(tableName: string): this; /** * Set operation type */ operation(operation: DatabaseActionType | string): this; /** * Set description */ description(description: string): this; /** * Set template */ template(template: IActionTemplate): this; /** * Set filter template */ filter(filterTemplate: IWhereClause): this; /** * Build the action options */ build(): IActionCreateOptions; } /** * Create a new action builder */ export declare function createAction(): ActionBuilder; export {};