"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deploy = deploy;
exports.prune = prune;
const hotmesh_1 = require("@hotmeshio/hotmesh");
const db_1 = require("../lib/db");
const APP_ID = 'durable';
/**
 * Deploy the server-side prune() Postgres function and run
 * any schema migrations (e.g. adding the `pruned_at` column).
 * Idempotent — safe to call on every startup.
 */
async function deploy() {
    await hotmesh_1.DBA.deploy((0, db_1.getConnection)(), APP_ID);
}
/**
 * Prune expired jobs, streams, and/or execution artifacts.
 *
 * - `jobs` — hard-delete expired job rows older than `expire`
 * - `streams` — hard-delete expired stream messages (engine + worker) older than `expire`
 * - `attributes` — strip execution artifacts from completed jobs
 *   (preserves jdata, udata, jmark for execution export)
 * - `entities` — allowlist: only prune these entity types
 * - `pruneTransient` — also delete jobs where entity IS NULL
 * - `keepHmark` — preserve hmark rows during stripping
 */
async function prune(options) {
    return hotmesh_1.DBA.prune({ appId: APP_ID, connection: (0, db_1.getConnection)(), ...options });
}
