import type { Jwk } from '@enbox/crypto';
import { TtlCache } from '@enbox/common';
import type { EnboxPlatformAgent } from './types/agent.js';
import type { ProtocolDefinition } from '@enbox/dwn-sdk-js';
export type DataStoreTenantParams = {
    agent: EnboxPlatformAgent;
    tenant?: string;
};
export type DataStoreListParams = DataStoreTenantParams;
export type DataStoreGetParams = DataStoreTenantParams & {
    id: string;
    useCache?: boolean;
};
export type DataStoreSetParams<TStoreObject> = DataStoreTenantParams & {
    id: string;
    data: TStoreObject;
    preventDuplicates?: boolean;
    updateExisting?: boolean;
    useCache?: boolean;
};
export type DataStoreDeleteParams = DataStoreTenantParams & {
    id: string;
};
export interface AgentDataStore<TStoreObject> {
    delete(params: DataStoreDeleteParams): Promise<boolean>;
    get(params: DataStoreGetParams): Promise<TStoreObject | undefined>;
    list(params: DataStoreTenantParams): Promise<TStoreObject[]>;
    set(params: DataStoreSetParams<TStoreObject>): Promise<void>;
}
export declare class DwnDataStore<TStoreObject extends Record<string, any> = Jwk> implements AgentDataStore<TStoreObject> {
    protected name: string;
    /**
       * Cache of Store Objects referenced by DWN record ID to Store Objects.
       *
       * Up to 100 entries are retained for 15 minutes.
       */
    protected _cache: TtlCache<string, TStoreObject>;
    /**
     * Index for mappings from Store Identifier to DWN record ID.
     * Since these values don't change, we can use a long TTL.
     *
     * Up to 1,000 entries are retained for 21 days.
     * NOTE: The maximum number for the ttl is 2^31 - 1 milliseconds (24.8 days), setting to 21 days to be safe.
     */
    protected _index: TtlCache<string, string>;
    /**
     * Cache of tenant DIDs that have been initialized with the protocol.
     * This is used to avoid redundant protocol initialization requests.
     *
     * Since these are default protocols and unlikely to change, we can use a long TTL.
     */
    protected _protocolInitializedCache: TtlCache<string, boolean>;
    /**
     * The protocol assigned to this storage instance.
     */
    protected _recordProtocolDefinition: ProtocolDefinition;
    /**
     * Per-tenant encryption resolution cache. Populated during `initialize()`:
     * `true` if the tenant supports encryption (has X25519 keyAgreement).
     * When any type in `_recordProtocolDefinition` has `encryptionRequired: true`,
     * this will always be `true` after successful initialization (since
     * installation fails if encryption is not possible).
     */
    private _tenantEncryptionActive;
    /**
     * Properties to use when writing and querying records with the DWN store.
     * Subclasses MUST override this to include `protocol` and `protocolPath`.
     */
    protected _recordProperties: {
        dataFormat: string;
        protocol: string;
        protocolPath: string;
        schema?: string;
    };
    delete({ id, agent, tenant }: DataStoreDeleteParams): Promise<boolean>;
    get({ id, agent, tenant, useCache }: DataStoreGetParams): Promise<TStoreObject | undefined>;
    list({ agent, tenant }: DataStoreListParams): Promise<TStoreObject[]>;
    set({ id, data, tenant, agent, preventDuplicates, updateExisting, useCache }: DataStoreSetParams<TStoreObject>): Promise<void>;
    /**
     * Initialize the relevant protocol for the given tenant.
     * This confirms that the storage protocol is configured, otherwise it will be installed.
     */
    initialize({ tenant, agent }: DataStoreTenantParams): Promise<void>;
    /**
     * Returns `true` if any type in the protocol definition has `encryptionRequired: true`.
     */
    private get encryptionRequired();
    /**
     * Returns `true` if DWN record-level encryption is active for the given tenant.
     * This is resolved during `initialize()` and cached.
     */
    protected isEncryptionActive(tenantDid: string): boolean;
    protected getAllRecords(_params: {
        agent: EnboxPlatformAgent;
        tenantDid: string;
    }): Promise<TStoreObject[]>;
    private getRecord;
    /**
     * Install the protocol for the given tenant using a `ProtocolsConfigure` message.
     * When any type in the protocol definition has `encryptionRequired: true`,
     * `$encryption` keys are derived and injected into the protocol definition.
     * If the tenant DID lacks an X25519 keyAgreement key, the error propagates
     * — plaintext fallback is not allowed.
     */
    private installProtocol;
    private lookupRecordId;
    private getExistingRecordEntry;
}
export declare class InMemoryDataStore<TStoreObject extends Record<string, any> = Jwk> implements AgentDataStore<TStoreObject> {
    protected name: string;
    /**
     * A private field that contains the Map used as the in-memory data store.
     */
    private store;
    delete({ id, agent, tenant }: DataStoreDeleteParams): Promise<boolean>;
    get({ id, agent, tenant }: DataStoreGetParams): Promise<TStoreObject | undefined>;
    list({ agent, tenant }: DataStoreListParams): Promise<TStoreObject[]>;
    set({ id, data, tenant, agent, preventDuplicates, updateExisting }: DataStoreSetParams<TStoreObject>): Promise<void>;
}
//# sourceMappingURL=store-data.d.ts.map