export type getOptions = { meta?: boolean reverse?: boolean limit?: number start?: string label?: labels } export type getOptionsMeta = { meta: true reverse?: boolean limit?: number start?: string label?: labels } export type setOptions = { ttl?: number | string | null overwrite?: boolean label1?: string | [string] | null label2?: string | [string] | null label3?: string | [string] | null label4?: string | [string] | null label5?: string | [string] | null default?: any created?: number removeNulls?: boolean exists?: boolean // true = only write if the item exists, false = only write if the item does not exist meta?: boolean } export type setOptionsMeta = { ttl?: number | string | null overwrite?: boolean label1?: string | [string] | null label2?: string | [string] | null label3?: string | [string] | null label4?: string | [string] | null label5?: string | [string] | null default?: any created?: number removeNulls?: boolean exists?: boolean // true = only write if the item exists, false = only write if the item does not exist meta: true } export interface scanOptions { meta?: boolean limit?: number start?: string label?: labels attributes?: string[] segment?: number totalSegments?: number count?: boolean } export interface seedOptions { overwrite?: boolean } export type setBatchOptions = | { meta?: boolean // for returning updated item removeNulls?: boolean } | boolean export type addOptions = { overwrite?: boolean meta?: boolean } export type Optional = T | undefined export type Metadata = { created?: Date modified?: Date ttl?: Date label1?: string label2?: string label3?: string label4?: string label5?: string } export type KeyValue = { key: string value: T } export type KeyValueMeta = KeyValue & Metadata export type GetResponse = T | undefined export type GetResponseKeyValue = KeyValue | undefined export type GetResponseMeta = KeyValueMeta | undefined export type GetBatchResponse = { items: KeyValue[] lastKey?: string next?: () => Promise> } export type GetBatchResponseMeta = { items: KeyValueMeta[] lastKey?: string next?: () => Promise> } export type ScanResponse = Optional<{ items: KeyValue[] lastKey?: string next?: () => Promise> }> export type BatchSetItem = { key: string value: T default?: Partial ttl?: number label1?: string label2?: string label3?: string label4?: string label5?: string } export type SetResponse = T export type SetResponseMeta = KeyValueMeta export type SetBatchResponse = { items: KeyValue[]; unprocessed?: KeyValue[] } export type AddResponse = KeyValue | T | undefined export enum Labels { Label1 = 'label1', Label2 = 'label2', Label3 = 'label3', Label4 = 'label4', Label5 = 'label5' } export type labels = 'label1' | 'label2' | 'label3' | 'label4' | 'label5' type LabelQuery = Labels | labels export type indexPk = `pk${string}` export type indexSk = `sk${string}` export interface key { pk: string sk: string [key: indexPk]: string [key: indexSk]: string kv?: boolean default?: boolean } // .get types type Whitespace = '\n' | ' ' type Trim = T extends `${Whitespace}${infer U}` ? Trim : T extends `${infer U}${Whitespace}` ? Trim : T type WildcardQuery = `${string}:${string | ''}*` type ComparisonQuery = `${string}:${string | ''}${Trim<'<'> | Trim<'>'> | Trim<'<='> | Trim<'>='>}${string}` type RangeQuery = `${string}:${string}${Trim<'|'>}${string}` type ValidListeners = 'created' | 'updated' | 'deleted' | '*' type ListenerPath = ValidListeners | `${ValidListeners}:${string}` | `${ValidListeners}:${WildcardQuery}` export type Query = WildcardQuery | ComparisonQuery | RangeQuery type DataEventHandler = (event: { previous?: any; item: any; name: ValidListeners }) => void export declare interface Data { get(keys: Query | string[], options: false): Promise> get(keys: Query | string[], options: true): Promise> get(keys: Query | string[], options: getOptionsMeta): Promise> get(keys: Query | string[], options?: getOptions): Promise> get(keys: string, options: false): Promise> get(keys: string, options: true): Promise> get(keys: string, options: getOptionsMeta): Promise> get(keys: string, options?: getOptions): Promise> getByLabel( label: LabelQuery, keys: Query | string[] | string, options?: getOptions | boolean ): Promise> getByLabel( label: LabelQuery, keys: Query | string[] | string, options: getOptionsMeta ): Promise> getByLabel(label: LabelQuery, keys: Query | string[] | string, options: true): Promise> getByLabel(label: LabelQuery, keys: Query | string[] | string, options: false): Promise> scan(options: scanOptions | boolean): Promise> set(keys: BatchSetItem[], opts?: setBatchOptions | boolean): Promise> set(keys: string, value: T | Partial, options: false): Promise> set(keys: string, value: T | Partial, options: true): Promise> set(keys: string, value: T | Partial, options: setOptionsMeta): Promise> set(keys: string, value: T | Partial, options?: setOptions): Promise> seed(data: any[] | string, options?: { overwrite?: boolean } | boolean): Promise<{ items: number }> remove(keys: string | string[]): Promise add(key: string, value: number, opts?: addOptions | boolean): Promise> add( key: string, attribute: number | string, value: number | addOptions | boolean, opts?: addOptions | boolean ): Promise> on: ( name: ListenerPath | ListenerPath[], ...handler: [{ timeout: number }, DataEventHandler] | [DataEventHandler] ) => void } export declare const data: Data