import type { Dialect } from '@enbox/dwn-sql-store'; import type { AdminMessageSummary, AdminModuleSummary, GlobalStats, TenantExport, TenantStats } from './types.js'; /** * Provides cross-tenant SQL queries for admin operations. * The DWN SDK's store interfaces are always tenant-scoped — this store * runs direct SQL for operations like listing tenants and computing aggregates. */ export declare class AdminStore { private readonly db; private cachedGlobalStats; private cachedGlobalStatsTimestamp; private readonly cacheTtlMs; private constructor(); /** * Creates an `AdminStore` from a storage URL string. * @param storageUrl - A SQL connection URL (sqlite://, postgres://, mysql://). * @param cacheTtlMs - TTL for cached global stats in milliseconds. Default: 60_000. * @returns An `AdminStore` instance, or `undefined` if the URL uses a non-SQL backend. */ static create(storageUrl: string, cacheTtlMs?: number): AdminStore | undefined; /** * Creates an `AdminStore` from an already-initialized Kysely dialect. * Used when the admin store should share the same database connection as the DWN stores * (e.g., in-memory SQLite for tests). */ static createFromDialect(dialect: Dialect, cacheTtlMs?: number): AdminStore; /** * Returns `true` if the DWN SQL tables exist (i.e. the admin store shares the same DB as the DWN). */ isAvailable(): Promise; /** * Returns a paginated list of distinct tenant DIDs from the message store. * * @see https://github.com/enboxorg/enbox/issues/390 */ getDistinctTenants(options?: { cursor?: string; limit?: number; search?: string; }): Promise<{ tenants: string[]; cursor?: string; }>; /** * Returns the total count of distinct tenants. */ getTenantCount(): Promise; /** * Returns aggregate statistics for a single tenant. */ getTenantStats(did: string): Promise; /** * Returns the total number of messages for a tenant. */ getTenantMessageCount(did: string): Promise; /** * Returns the total data storage in bytes for a tenant. * * Uses the latest base-state rows in `messageStoreMessages` rather than * `dataRefs` so both inline and external data are counted, while retained * metadata-only history is excluded. */ getTenantStorageSize(did: string): Promise; /** * Returns the list of distinct modules used by a tenant. */ getTenantModules(did: string): Promise; /** * Returns global server statistics. Results are cached with the configured TTL. * Pass `refresh: true` to force recalculation. */ getGlobalStats(options?: { refresh?: boolean; }): Promise; /** * Deletes all DWN data for a tenant from every SQL table. * @returns The number of messages deleted. */ purgeTenantData(did: string): Promise; /** * Returns the number of suspended tenants from the registration table. * Returns 0 if the registration table doesn't exist. */ getSuspendedTenantCount(): Promise; /** * Returns paginated message metadata for a single tenant. * Only returns metadata columns — never returns `encodedMessageBytes` (raw message content). */ getTenantMessages(did: string, options?: { interface?: string; method?: string; module?: string; limit?: number; cursor?: number; }): Promise<{ messages: AdminMessageSummary[]; cursor?: number; }>; /** * Returns per-module message counts for a tenant. */ getTenantModuleCounts(did: string): Promise; /** * Exports all message metadata and data records for a tenant as an array. * Returns `{ messages, data, metadata }` for streaming/serialization. * * @see https://github.com/enboxorg/enbox/issues/391 */ exportTenantData(did: string): Promise; /** * Closes the underlying database connection. */ close(): Promise; } //# sourceMappingURL=admin-store.d.ts.map