import { DynamoDBClient } from '@aws-sdk/client-dynamodb'; import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb'; export { DataStoreNotFoundError, DataStoreServiceError, DataStoreUnavailableError } from './errors.js'; /** * Create the DynamoDB client used by the data store, configured for resilient reads under * throttling: adaptive retries, bounded attempts, and hard per-attempt timeouts. * * @returns A configured DynamoDB client */ export declare function createDalDynamoDBClient(): DynamoDBClient; /** * A class for reading entries from the data store. * * This class uses a singleton pattern. * Use DataStore.getDataStore() to get the singleton instance. */ export declare class DataStore { private _tableName; private _ddb; private static _instance; /** @internal Test hook: inject a document client for unit tests */ static _testDocumentClient: DynamoDBDocumentClient | null; /** @internal Test hook: inject logMRTError for unit tests */ static _testLogMRTError: ((namespace: string, err: unknown, context?: Record) => void) | null; /** @internal Test hook: inject a deterministic random source (returns [0, 1)) for unit tests */ static _testRandom: (() => number) | null; private constructor(); /** * Get or create a DynamoDB document client (for abstraction of attribute values). * * @private * @returns The DynamoDB document client * @throws {DataStoreUnavailableError} The data store is unavailable */ private getClient; /** * Resolve the DynamoDB partition key for a read, applying shard selection. * * Reads the shard count from `MRT_NUM_SHARDS` (default 1) and picks a random * shard `i` in `[0, N)`. Shard 0 is the legacy unsuffixed partition key, so * when `MRT_NUM_SHARDS` is unset or 1 this is identical to today's behavior. * There is no runtime fallback: writers fan out to every shard, so every shard * a reader can pick is guaranteed to exist. * * @private * @returns The `projectEnvironment` partition key value to read */ private resolveShardPartitionKey; /** * Get or create the singleton DataStore instance. * * @returns The singleton DataStore instance */ static getDataStore(): DataStore; /** * Whether the data store can be used in the current environment. * * @returns true if the data store is available, false otherwise */ isDataStoreAvailable(): boolean; /** * Fetch an entry from the data store. * * @param key The data store entry's key * @returns An object containing the entry's key and value * @throws {DataStoreUnavailableError} The data store is unavailable * @throws {DataStoreNotFoundError} An entry with the given key cannot be found * @throws {DataStoreServiceError} An internal error occurred */ getEntry(key: string): Promise | undefined>; }