import { DynamoDB } from 'aws-sdk'; import { DocumentClient } from 'aws-sdk/clients/dynamodb'; /** * Objects with open properties */ export interface AnyObject { [property: string]: any; } export declare type QueryInput = DynamoDB.DocumentClient.QueryInput; /** * DynamoDB supported operators */ export declare type DynamoDBOperators = '=' | '>' | '>=' | '<' | '<=' | '<>' | 'BETWEEN' | 'BEGINS_WITH' | 'IN' | 'EXISTS' | 'CONTAINS'; /** * Operators for where clauses */ export declare type FilterOperators = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'inq' | 'between' | 'like' | 'exists' | 'beginsWith'; /** * Matching predicate comparison */ export declare type PredicateComparison = { eq?: PT; neq?: PT; gt?: PT; gte?: PT; lt?: PT; lte?: PT; inq?: PT[]; nin?: PT[]; between?: [PT, PT]; exists?: boolean; like?: PT; nlike?: PT; ilike?: PT; nilike?: PT; beginsWith?: PT; }; /** * Value types for `{propertyName: value}` */ export declare type ShortHandEqualType = string | number | boolean | Date; /** * Key types of a given model, excluding operators */ export declare type KeyOf = Exclude, FilterOperators>; /** * Condition clause * * @example * ```ts * { * name: {inq: ['John', 'Mary']}, * status: 'ACTIVE', * age: {gte: 40} * } * ``` */ export declare type Condition = { [P in KeyOf]?: PredicateComparison | (MT[P] & ShortHandEqualType); }; /** * Where clause * * @example * ```ts * { * name: {inq: ['John', 'Mary']}, * status: 'ACTIVE' * and: [...], * or: [...], * } * ``` */ export declare type Where = Condition | AndClause | OrClause; /** * And clause * * @example * ```ts * { * and: [...], * } * ``` */ export interface AndClause { and: Where[]; } /** * Or clause * * @example * ```ts * { * or: [...], * } * ``` */ export interface OrClause { or: Where[]; } /** * Order by direction */ export declare enum Direction { ASC = "ASC", DESC = "DESC" } /** * Selection of fields * * Example: * fields: ['id', 'isActive] */ export declare type Fields = Array; /** * Query filter object */ export interface Filter { /** * The matching criteria */ where?: Where; /** * To include/exclude fields */ fields?: Fields; /** * Maximum number of entities */ limit?: number; /** * Sort order. Only works with sort keys */ orderBy?: Direction; /** * Only be used with cursor based `query` */ prevCursor?: string; } declare type TableIndex = { partitionKeyName: string; sortKeyName?: string; }; export interface TableConfig { name: string; /** * A record of table index and it's key names * Required on query and get operations dealing with indexes * A default index is always required] * eg: indexes: { default: { partitionKeyName: 'pk', sortKeyName: 'sk' } } */ indexes: { default: TableIndex; } & Record; cursorSecret?: string; } export declare enum ConditionExpressionKind { Comparison = "comparison", AndOr = "AND_OR" } declare type ConditionExpressionItem = { kind: ConditionExpressionKind.Comparison; key: string; comparator: FilterOperators; value: string | number | boolean | Array; }; declare type AndOrExpression = { kind: ConditionExpressionKind.AndOr; value: 'AND' | 'OR'; }; export declare type ConditionExpressionInput = ConditionExpressionItem | AndOrExpression; export interface ConditionExpressionReturn { expression: DocumentClient.ConditionExpression; attrValues: DocumentClient.ExpressionAttributeValueMap; attrNames: DocumentClient.ExpressionAttributeNameMap; } export {};