import * as AWS from 'aws-sdk';
import * as Util from '@dra2020/util';
import * as Context from '@dra2020/context';
import * as LogAbstract from '@dra2020/logabstract';
import * as FSM from '@dra2020/fsm';
import * as DB from '@dra2020/dbabstract';
import * as Storage from '@dra2020/storage';
export interface Environment {
    context: Context.IContext;
    log: LogAbstract.ILog;
    fsmManager: FSM.FsmManager;
    storageManager: Storage.StorageManager;
}
export interface EnvironmentEx {
    context: Context.IContext;
    log: LogAbstract.ILog;
    fsmManager: FSM.FsmManager;
    storageManager: Storage.StorageManager;
    dbx: DynamoClient;
}
declare class FsmAPIWatch extends FSM.Fsm {
    constructor(env: Environment);
    get env(): Environment;
    tick(): void;
}
declare class FsmListTables extends FSM.Fsm {
    tables: any;
    workStack: string[];
    constructor(env: Environment);
    get env(): EnvironmentEx;
    tick(): void;
}
export declare function create(env: Environment): DB.DBClient;
export declare class DynamoClient extends DB.DBClient {
    serializerUpdate: FSM.FsmSerializer;
    fsmAPIWatch: FsmAPIWatch;
    fsmListTables: FsmListTables;
    dynamodb: AWS.DynamoDB;
    dynamostream: AWS.DynamoDBStreams;
    pendingCols: DynamoCollection[];
    existingCols: {
        [name: string]: DynamoCollection;
    };
    bList: boolean;
    constructor(env: Environment);
    get env(): EnvironmentEx;
    get Production(): boolean;
    get DBName(): string;
    get dynamoErrorFrequency(): number;
    createCollection(name: string, options: any): DB.DBCollection;
    createStream(col: DynamoCollection): FSM.FsmArray;
    closeStream(col: DynamoCollection): void;
    ensureCollection(col: DynamoCollection): void;
    createUpdate(col: DynamoCollection, query: any, values: any): DB.DBUpdate;
    createUnset(col: DynamoCollection, query: any, values: any): DB.DBUnset;
    createDelete(col: DynamoCollection, query: any): DB.DBDelete;
    createFind(col: DynamoCollection, filter: any): DB.DBFind;
    createQuery(col: DynamoCollection, filter: any): DB.DBQuery;
    createIndex(col: DynamoCollection, uid: string): DB.DBIndex;
    createClose(): DB.DBClose;
    forceError(): boolean;
    tick(): void;
}
export declare class DynamoCollection extends DB.DBCollection {
    attributeIndex: any;
    keyIndex: any;
    fsmStream: FsmTableStream;
    constructor(env: Environment, client: DynamoClient, name: string, options: any);
    get env(): Environment;
    get dynclient(): DynamoClient;
    get dynamodb(): AWS.DynamoDB;
    createStream(): FSM.FsmArray;
    closeStream(): void;
    constructIndex(): void;
    addConditionExpression(query: any, key: any): void;
    toInternalQuery(query: any): any;
    toInternalExpression(o: any): any;
    toTestExpression(expr: any): string;
    toUpdateExpression(expr: any): string;
    toRemoveExpression(expr: any): string;
    toExternal(result: any): any;
    forceError(): boolean;
    tick(): void;
}
export declare class DynamoUpdate extends DB.DBUpdate {
    trace: LogAbstract.AsyncTimer;
    constructor(env: Environment, col: DynamoCollection, query: any, values: any);
    get env(): Environment;
    get dyncol(): DynamoCollection;
    forceError(): boolean;
    tick(): void;
}
export declare class DynamoUnset extends DB.DBUnset {
    trace: LogAbstract.AsyncTimer;
    constructor(env: Environment, col: DynamoCollection, query: any, values: any);
    get env(): Environment;
    get dyncol(): DynamoCollection;
    forceError(): boolean;
    tick(): void;
}
export declare class DynamoDelete extends DB.DBDelete {
    trace: LogAbstract.AsyncTimer;
    constructor(env: Environment, col: DynamoCollection, query: any);
    get env(): Environment;
    get dyncol(): DynamoCollection;
    forceError(): boolean;
    tick(): void;
}
export declare class DynamoFind extends DB.DBFind {
    trace: LogAbstract.AsyncTimer;
    constructor(env: Environment, col: DynamoCollection, filter: any);
    get env(): Environment;
    get dyncol(): DynamoCollection;
    forceError(): boolean;
    tick(): void;
}
export declare class DynamoQuery extends DB.DBQuery {
    trace: LogAbstract.AsyncTimer;
    lastKey: any;
    constructor(env: Environment, col: DynamoCollection, filter: any);
    get env(): Environment;
    get dyncol(): DynamoCollection;
    forceError(): boolean;
    doScan(): void;
    tick(): void;
}
export declare class DynamoIndex extends DB.DBIndex {
    constructor(env: Environment, col: DynamoCollection, uid: string);
}
export declare class DynamoClose extends DB.DBClose {
    constructor(env: Environment, client: DynamoClient);
}
interface RangeDescription {
    StartingSequenceNumber: string;
    EndingSequenceNumber?: string;
}
interface ShardDescription {
    ShardId: string;
    SequenceNumberRange: RangeDescription;
    ShardIterator?: string;
    ParentShardId?: string;
    LastSequenceNumber?: string;
}
export declare class FsmTableShards extends FSM.Fsm {
    table: any;
    stream: any;
    lastKey: string;
    fsmResult: FSM.FsmArray;
    constructor(env: Environment, table: any);
    get env(): EnvironmentEx;
    tick(): void;
}
declare class FsmReadOneShard extends FSM.Fsm {
    col: DynamoCollection;
    stream: any;
    shard: ShardDescription;
    shardClosed: boolean;
    fsmResult: FSM.FsmArray;
    elapsed: Util.Elapsed;
    nTries: number;
    constructor(env: Environment, col: DynamoCollection, stream: any, shard: ShardDescription, fsmResult: FSM.FsmArray);
    get env(): EnvironmentEx;
    tick(): void;
}
export declare class FsmTableStream extends FSM.Fsm {
    col: DynamoCollection;
    table: any;
    fsmShards: FsmTableShards;
    shardsDone: any;
    shardsLast: any;
    shardsQueue: FsmReadOneShard[];
    fsmResult: FSM.FsmArray;
    elapsed: Util.Elapsed;
    constructor(env: Environment, col: DB.DBCollection);
    get env(): Environment;
    end(): void;
    error(): void;
    tick(): void;
}
export {};
