import { DynamoDBClient } from '@aws-sdk/client-dynamodb'; import { CompoundKey, SortKey } from '@paradoxical-io/types'; import { Metrics, Monitoring } from '../../monitoring'; import { DynamoDao } from '../mapper'; import { DynamoTableName } from '../util'; export declare class PartitionedKeyValueTableDao implements DynamoDao { partitionKey: T; sortKey: SortKey; data: string; md5?: string; } export interface PartitionKeyMappings { sortKeyFieldName: string; sortKeyFieldAWSType: 'S' | 'N'; partitionKeyFieldName: string; dataFieldName: string; md5: 'md5'; } /** * A key value table where the _sort_ key is namespaced. * * The reason for this is to allow to query all the values based on the partition key. Imagine * wanting to answer "give me all the keys for userId X" and get the fact that it has some bank keys * and some user keys, etc. */ export declare class PartitionedKeyValueTable { readonly dynamo: DynamoDBClient; readonly tableName: string; private readonly logger; readonly metrics: Metrics; constructor({ dynamo, tableName, monitoring, }: { dynamo?: DynamoDBClient; tableName: DynamoTableName; monitoring?: Monitoring; }); /** * Method to append data to a key that points to a value list. * * @param key compound key that indexes to a `value[]` * @param data to be appended to the key * @param setInclusion if this returns `true`, then nothing is added to the list * @returns void */ addToSet(key: CompoundKey, data: V | V[], setInclusion?: (left: V, right: V) => boolean): Promise; /** * Clears an entire partition, including all sort keys * @param partition */ clear

(partition: P): Promise; /** * Deletes only a specific sort key * @param key */ delete

(key: CompoundKey

): Promise; /** * If the key exists in the DynamoDB table, returns true. Otherwise, returns false. * @param key */ exists(key: CompoundKey): Promise; /** * Method to check if data exists on a list of values on a key. * * @param key compound key that indexes to a `value[]` * @param data to check if it exists in the value list * @param setInclusion function to check if element exists in a list * @returns */ existsInSet(key: CompoundKey, data: V, setInclusion?: (left: V, right: V) => boolean): Promise; get(key: CompoundKey): Promise; /** * Lists all values in a partition * @param partition */ listAll(partition: string): AsyncGenerator>; /** * Removes an element from a set of data. * * @param key compound key that indexes to a `value[]` * @param data to be removed from the set * @param setInclusion how to determine if the item is in the set * @returns */ removeFromSet(key: CompoundKey, data: V | V[], setInclusion?: (left: V, right: V) => boolean): Promise; /** * Removes an element from a set of data. * * @param key compound key that indexes to a `value[]` * @param toRemove how to determine which item to remove * @returns */ removeFromSetByKey(key: CompoundKey, toRemove: (v: V) => boolean): Promise; set(key: CompoundKey, data: T): Promise; setBatch(keys: Array<{ key: CompoundKey; data: T; }>): Promise; /** * Sets the value if it doesn't exist. Returns true if was inserted or false if not (due to duplicate found) * * Does this atomically. * @param key * @param data */ setIfNotExists(key: CompoundKey, data: T): Promise; /** * Method to update data to a key that points to a value list. * If the data does not exist in the list already, it's still added to the list. * * @param key compound key that indexes to a `value[]` * @param data to be appended to the key * @param setInclusion keys for which this returns `true` are removed from the list before appending the new value * @returns true if the new value was appended to the list, false if the key was not found */ updateInSet(key: CompoundKey, data: V, setInclusion?: (value: V) => boolean): Promise; protected sortKey

(key: CompoundKey

): SortKey; protected partitionKey

(key: CompoundKey

): P; protected mappings(): PartitionKeyMappings; protected getRaw(key: CompoundKey): Promise<{ data: T; md5?: string; } | undefined>; protected setIfMd5Matches(key: CompoundKey, data: T, previousMd5: string | undefined): Promise; private existsRaw; private setRawBatch; private setRawAtomic; private deleteSortKey; private deletePartition; } //# sourceMappingURL=partitionedKeyTable.d.ts.map