@mastra/core
Version:
48 lines (47 loc) • 1.83 kB
JavaScript
import { t as MastraBase } from "./base-BeUQ6mLP.js";
//#region src/storage/domains/base.ts
/**
* Base class for all storage domains.
* Provides common interface for initialization and data clearing.
*/
var StorageDomain = class extends MastraBase {
/**
* Declares which of this domain's tables are eligible for age-based
* retention, mapping a stable table key → physical table name, timestamp
* anchor column, and whether that column is indexed.
*
* This is the single source of truth used by `prune()` implementations to
* resolve policies to physical deletes. Domains that support retention
* override this; the default is empty (nothing prunable).
*/
static retentionTables = {};
/**
* Initialize the storage domain.
* This should create any necessary tables/collections.
* Default implementation is a no-op - override in adapters that need initialization.
*/
async init() {}
/**
* Delete rows older than each policy's `maxAge`, batched, bounded, and
* cancellable so it is safe to run against very large tables.
*
* - `policies` maps this domain's stable table keys to their retention policy.
* - `options` bound the work (`maxBatches`/`maxRows`), pace it (`pauseMs`),
* and allow cooperative cancellation (`signal`).
*
* Returns one {@link PruneResult} per table touched. A result with
* `done: false` means eligible rows remain — call `prune()` again to continue.
*
* `prune()` only deletes rows. On SQLite/LibSQL freed pages are reused by
* future writes so the file stops growing. Handing disk back to the OS is left
* to the underlying database and the operator to manage.
*
* Default implementation is a no-op (retention not supported).
*/
async prune(_policies, _options) {
return [];
}
};
//#endregion
export { StorageDomain as t };
//# sourceMappingURL=base-Bt5IshKX.js.map