import { Context } from "hono";
import { ActionExecutionResult, CodeExecutionLog, DataAdapters, Hook } from "@authhero/adapter-interfaces";
import { Bindings, Variables } from "../types";
import { HookEvent, OnExecuteCredentialsExchangeAPI } from "../types/Hooks";
/**
 * Auth0 uses `post-login` for what we internally call `post-user-login`.
 * Normalize when writing execution records so the public API matches Auth0.
 */
export declare function toAuth0TriggerId(internal: string): string;
type CodeHook = Extract<Hook, {
    code_id: string;
}>;
export declare function isCodeHook(hook: Hook): hook is CodeHook;
/**
 * Build a serializable event object from a HookEvent.
 * Strips the `ctx` property (Hono context) which cannot be serialized,
 * and returns a plain JSON-compatible object.
 */
export declare function buildSerializableEvent(event: HookEvent, secrets?: Record<string, string>): Record<string, unknown>;
/**
 * Replay recorded API calls from code hook execution against real API objects.
 * Handles calls like "accessToken.setCustomClaim" by navigating the api object.
 */
export declare function replayApiCalls(apiCalls: Array<{
    method: string;
    args: unknown[];
}>, api: Record<string, any>): void;
export type HandleCodeHookOutcome = {
    result: ActionExecutionResult;
    logs: CodeExecutionLog[];
    /** True if api.access.deny was recorded by the executor. */
    denied: boolean;
};
/**
 * Execute a code hook by fetching the code from the database, running it
 * through the code executor, and replaying API calls against the real api
 * object.
 *
 * Returns the per-action result (Auth0 shape) so the caller can aggregate
 * results across all actions on a trigger into a single `action_executions`
 * record. Returns `null` when the code cannot be located or the executor is
 * unavailable — the caller decides whether to surface that.
 */
export declare function handleCodeHook(ctx: Context<{
    Bindings: Bindings;
    Variables: Variables;
}>, data: DataAdapters, hook: {
    code_id: string;
    hook_id: string;
}, event: HookEvent, triggerId: string, api: Record<string, any>): Promise<HandleCodeHookOutcome | null>;
/**
 * Aggregate per-action outcomes into an Auth0-shape execution record and
 * persist it via the adapter. Returns the generated execution_id (uuid)
 * so the caller can embed it in the surrounding tenant log.
 */
export declare function persistActionExecution(data: DataAdapters, tenant_id: string, triggerId: string, outcomes: HandleCodeHookOutcome[]): Promise<string | null>;
/**
 * Execute code hooks for the credentials-exchange trigger.
 * Filters enabled code hooks from the provided hooks list and executes them.
 *
 * Returns the persisted `execution_id` so the caller can embed it in the
 * surrounding tenant log (the standard token-exchange log entry). The
 * execution record itself follows Auth0's shape — see
 * GET /api/v2/actions/executions/:id.
 */
export declare function handleCredentialsExchangeCodeHooks(ctx: Context<{
    Bindings: Bindings;
    Variables: Variables;
}>, hooks: any[], event: HookEvent, api: OnExecuteCredentialsExchangeAPI): Promise<string | null>;
export {};
