import { SimpleDB } from "aws-sdk"; import { IsotopeClient, IsotopeClientOptions } from "./client"; import { IsotopeFormatOptions } from "./format"; import { IsotopeSelect } from "./select"; import { DeepPartial } from "./utilities"; /** * Isotope options * * @template T - Data type */ export interface IsotopeOptions { format?: IsotopeFormatOptions; client?: IsotopeClientOptions; domain: string; key: keyof T; } /** * Isotope result * * @template T - Data type */ export interface IsotopeResult { items: T[]; next?: string; } /** * Isotope * * By default this library forces only valid entries to be written to SimpleDB * which means that all non-optional fields need to be defined in the payload. * However, SimpleDB allows reading and writing of partial attribute values, * so it might be desirable in some cases to loosen that restriction and allow * partial reads and writes. Isotope allows both configurations through simple * generic typing. * * The first type argument is mandatory and defines the base type. The second * and third type arguments can be used to specify what exact types PUT and GET * operations return but normally they are equal to the base type. * * @example Allow complete values only * * new Isotope * * @example Allow partial values in PUT and GET operations * * new Isotope> * * @example Allow partial values in GET operations only * * new Isotope> * * @template T - Data type * @template TGet - Data type expected by PUT operation * @template TPut - Data type returned by GET operation */ export declare class Isotope = T, TGet extends DeepPartial = TPut> { protected options: IsotopeOptions; /** * SimpleDB client */ protected client: IsotopeClient; /** * Initialize an isotope * * @param options - Options * @param simpleDBOptions -- Any configuration to be passed directly to SimpleDB */ constructor(options: IsotopeOptions, simpleDBOptions?: SimpleDB.ClientConfiguration); /** * Create an SQL query builder * * @return SQL query builder */ getQueryBuilder(): IsotopeSelect; /** * Create the isotope * * @return Promise resolving with no result */ create(): Promise; /** * Destroy the isotope * * @return Promise resolving with no result */ destroy(): Promise; /** * Retrieve an item * * @param id - Identifier * @param names - Attribute names * * @return Promise resolving with (partial) item */ get(id: string): Promise; get(id: string, names: string[]): Promise | undefined>; /** * Persist an item * * @param data - Data to be persisted * * @return Promise resolving with no result */ put(data: TPut): Promise; /** * Delete an item * * @param id - Identifier * @param names - Attribute names * * @return Promise resolving with no result */ delete(id: string, names?: string[]): Promise; /** * Retrieve a set of items matching a given SQL query expression * * @template TSelect - Data type returned by SELECT operation * * @param expr - Query builder or string containing a SQL query expression * @param prev - Pagination token from previous result * * @return Promise resolving with result */ select(expr: IsotopeSelect | string, prev?: string): Promise>; }