import type { AwsLiteDynamoDB, QueryResponse, ScanResponse, UpdateItemResponse, } from "@aws-lite/dynamodb-types" import { Callback } from "./util"; // Turn off automatic exporting export { }; // TableName not needed as the library sets it type TablesParams = Omit; // As above but also overriding the Key field type TablesParamsWithKey = Omit, "Key"> & { Key: Key}; // Just overriding the Items field type ItemsOutput = Omit & { Items: Item[] }; type QueryParams = TablesParams[0]>; type QueryOutput = ItemsOutput; type ScanParams = TablesParams[0]>; type ScanOutput = ItemsOutput; type UpdateParams = TablesParamsWithKey< Parameters[0], Item >; // Depending on the operation, the key attributes may be mandatory, but we don't // know what the key attributes are, so Partial is the best we can do. type Key = Partial; export interface ArcTable { delete(key: Key): Promise<{}>; delete(key: Key, callback: Callback<{}>): void; get(key: Key): Promise; get(key: Key, callback: Callback): void; put(item: Item): Promise; put(item: Item, callback: Callback): void; query(params: QueryParams): Promise>; query(params: QueryParams, callback: Callback>): void; scan(params?: ScanParams): Promise>; scan(params: ScanParams, callback: Callback>): void; scan(callback: Callback>): void; scanAll(params?: ScanParams): Promise; update(params: UpdateParams): AwsLiteDynamoDB["UpdateItem"]; update(params: UpdateParams, callback: Callback): void; } type ArcDBWith = { [tableName in keyof Tables]: ArcTable; }; export type ArcDB = ArcDBWith & { name(name: keyof Tables): string; reflect(): { [tableName in keyof Tables]: string; }; _client: AwsLiteDynamoDB; // _db: DynamoDB; // _doc: DynamoDB.DocumentClient; }; // Permissive by default: allows any table, any inputs, any outputs. type AnyTables = Record; export interface ArcTables { (): Promise>; // legacy methods insert: any; modify: any; update: any; remove: any; destroy: any; all: any; save: any; change: any; }