import type { Jwk } from '@web5/crypto'; import { TtlCache } from '@web5/common'; import type { Web5PlatformAgent } from './types/agent.js'; import { ProtocolDefinition } from '@tbd54566975/dwn-sdk-js'; export type DataStoreTenantParams = { agent: Web5PlatformAgent; tenant?: string; }; export type DataStoreListParams = DataStoreTenantParams; export type DataStoreGetParams = DataStoreTenantParams & { id: string; useCache?: boolean; }; export type DataStoreSetParams = DataStoreTenantParams & { id: string; data: TStoreObject; preventDuplicates?: boolean; updateExisting?: boolean; useCache?: boolean; }; export type DataStoreDeleteParams = DataStoreTenantParams & { id: string; }; export interface AgentDataStore { delete(params: DataStoreDeleteParams): Promise; get(params: DataStoreGetParams): Promise; list(params: DataStoreTenantParams): Promise; set(params: DataStoreSetParams): Promise; } export declare class DwnDataStore = Jwk> implements AgentDataStore { 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; /** * 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; /** * 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; /** * The protocol assigned to this storage instance. */ protected _recordProtocolDefinition: ProtocolDefinition; /** * Properties to use when writing and querying records with the DWN store. */ protected _recordProperties: { dataFormat: string; }; delete({ id, agent, tenant }: DataStoreDeleteParams): Promise; get({ id, agent, tenant, useCache }: DataStoreGetParams): Promise; list({ agent, tenant }: DataStoreListParams): Promise; set({ id, data, tenant, agent, preventDuplicates, updateExisting, useCache }: DataStoreSetParams): Promise; /** * 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; protected getAllRecords(_params: { agent: Web5PlatformAgent; tenantDid: string; }): Promise; private getRecord; /** * Install the protocol for the given tenant using a `ProtocolsConfigure` message. */ private installProtocol; private lookupRecordId; private getExistingRecordEntry; } export declare class InMemoryDataStore = Jwk> implements AgentDataStore { 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; get({ id, agent, tenant }: DataStoreGetParams): Promise; list({ agent, tenant }: DataStoreListParams): Promise; set({ id, data, tenant, agent, preventDuplicates, updateExisting }: DataStoreSetParams): Promise; } //# sourceMappingURL=store-data.d.ts.map