/** * Function Operations Module * Handles stored procedures and functions sync logic */ import type { ILegacySyncOptions, TNullable } from '../../types'; import { type SyncDbSide } from '../syncClient'; import { type IRoutineIdentity } from '../routineSql'; import type { Client } from 'pg'; interface IFunctionRow extends IRoutineIdentity { specific_name?: string; data_type: string; routine_definition?: TNullable; } interface IFunctionDefinition { routine_name: string; routine_type: string; data_type: string; routine_definition?: TNullable; } export declare class FunctionOperations { private sourceClient; private targetClient; private options; constructor(sourceClient: Client, targetClient: Client, options: ILegacySyncOptions); /** * Get all functions and procedures from a schema on the given database. */ /** * Routines referenced by any trigger (any table schema). Never auto-drop these. */ getTriggerReferencedRoutineKeys(side: SyncDbSide): Promise>; private isCrossSchemaCatalog; private schemasForSide; getFunctions(side: SyncDbSide): Promise; /** True if the same logical routine (name + type + args) exists in the given schema. */ private routineExistsInSchema; private useCatalogOidForRoutineMatch; private routineKey; private findMatchingRoutine; /** * Desired-state match: shadow materialization first, then same logical routine in shadow schema. */ private findDesiredRoutineMatch; /** * Resolve catalog schema for a routine row (shadow vs target layout). */ private schemaForRoutine; /** * Full routine body from pg_get_functiondef (correct overload by identity args). */ getFunctionDefinition(side: SyncDbSide, routine: IRoutineIdentity): Promise; /** * Compare bodies from the database (catalog rows do not carry definitions). */ private routineBodiesDiffer; /** * Compare two function definitions to detect changes */ compareFunctionDefinitions(sourceFunction: IFunctionDefinition, targetFunction: IFunctionDefinition): boolean; /** * Normalize function definition by replacing schema references */ private normalizeFunctionDefinition; /** * Generate CREATE statement for function/procedure */ generateCreateStatement(definition: string | null, routineName: string, routineType: string, targetSchema: string): string; /** * Clean up function definition to remove malformed parts */ private cleanFunctionDefinition; /** * Handle functions that have changed */ handleFunctionsToUpdate(sourceFunctions: IFunctionRow[], targetFunctions: IFunctionRow[], alterStatements: string[]): Promise; /** * Generate function operations for schema sync */ generateFunctionOperations(): Promise; /** * Handle functions that need to be dropped in target */ handleFunctionsToDrop(alterStatements: string[], sourceFunctions: IFunctionRow[], targetFunctions: IFunctionRow[], triggerReferencedKeys: Set): Promise; /** * Handle functions that need to be created in target */ handleFunctionsToCreate(alterStatements: string[], sourceFunctions: IFunctionRow[], targetFunctions: IFunctionRow[]): Promise; } export {}; //# sourceMappingURL=functions.d.ts.map