/** * Build the runtime methods backing the soft-delete trait. The trait is * applied via `applySoftDeletes()` in `define-model.ts`. * * @example * ```ts * const helpers = createSoftDeleteMethods(model, 'id') * await helpers.softDelete(42) * ``` */ export declare function createSoftDeleteMethods(model: SoftDeleteCapableModel, primaryKey?: string): SoftDeleteHelpers; /** * Convert `traits.useSoftDeletes` into a normalized options object. The * trait accepts either `true` (legacy) or `{ cascade: [...] }` (new), so * downstream code should always go through this resolver. * * @example * ```ts * resolveSoftDeleteOptions(true) // → {} * resolveSoftDeleteOptions({ cascade: ['posts'] }) // → { cascade: ['posts'] } * ``` */ export declare function resolveSoftDeleteOptions(value: unknown): SoftDeleteOptions; /** * Run cascade soft-delete (or restore) for every relation listed in * `options.cascade`. Called by `define-model.ts` immediately after the * parent's own soft-delete or restore succeeds. * * IMPORTANT: cascade is fire-and-forget on the audit/observer side — this * function awaits each child to ensure ordering (parent before children * for delete, vice versa for restore) but does not propagate child * failures up to the caller. The parent operation has already committed. * * @example * ```ts * await cascadeSoftDelete(parentDefinition, options, parentId, 'softDelete') * ``` */ export declare function cascadeSoftDelete(parentDefinition: { name: string, hasMany?: ReadonlyArray, hasOne?: ReadonlyArray }, options: SoftDeleteOptions, parentId: number | string, action: 'softDelete' | 'restore'): Promise; declare interface SoftDeleteCapableModel { where: (...args: unknown[]) => any query?: () => any delete?: (...args: unknown[]) => unknown } /** * Object-form options for `traits.useSoftDeletes`. * * @example * ```ts * traits: { * useSoftDeletes: { * // Names of relations declared on this model (hasMany / hasOne) * // that should be soft-deleted alongside the parent. * cascade: ['posts', 'comments'], * }, * } * ``` */ export declare interface SoftDeleteOptions { cascade?: ReadonlyArray } export declare interface SoftDeleteHelpers { softDelete: (id: number | string) => Promise restore: (id: number | string) => Promise forceDelete: (id: number | string) => Promise withTrashed: () => any onlyTrashed: () => any }