import { StorageModel } from 'lemon-model';
export { StorageModel };
/**
 * Abstract Concept of `StorageService`
 * - simplified `storage-service` for `NoSQL` data.
 */
export interface StorageService<T extends StorageModel> {
    /**
     * say hello(name)
     *
     * @returns     simple service name like `storage-service:${name}`
     */
    hello(): string;
    /**
     * read (or error `404 NOT FOUND - id:...`)
     *
     * @param id        unique-id
     */
    read(id: string): Promise<T>;
    /**
     * read or create if not-found.
     *
     * @param id        unique-id
     * @param model     auto creation if not-found.
     */
    readOrCreate(id: string, model: T): Promise<T>;
    /**
     * save (or create) of model.
     * - WARN! overwrite if exists
     *
     * @param id        unique-id
     * @param model     data.
     */
    save(id: string, model: T): Promise<T>;
    /**
     * update some attributes of model
     * - NOTE! it will create if not exist.
     *
     * @param id        unique-id
     * @param model     data
     * @param incrementals (optional) incrementals like `count = count + 1`
     */
    update(id: string, model: T, incrementals?: T): Promise<T>;
    /**
     * increment number attribute (or overwrite string field)
     * - NOTE! increments only number type.
     *
     * @param id        unique-id
     * @param model     data (ONLY number is supportable)
     * @param $update   (optional) update-set.
     */
    increment(id: string, model: T, $update?: T): Promise<T>;
    /**
     * delete item by id
     *
     * @param id        unique-id
     */
    delete(id: string): Promise<T>;
}
/** ****************************************************************************************************************
 *  Data Storage Service
 ** ****************************************************************************************************************/
import { KEY_TYPE } from '../dynamo/';
/**
 * class: `DynamoStorageService`
 * - service via DynamoDB with id + json data.
 */
export declare class DynamoStorageService<T extends StorageModel> implements StorageService<T> {
    private _table;
    private _idName;
    private _fields;
    private $dynamo;
    constructor(table: string, fields: string[], idName?: string, idType?: KEY_TYPE);
    /**
     * say hello()
     * @param name  (optional) given name
     */
    hello: () => string;
    /**
     * (extended) get copy of fields.
     */
    fields: () => string[];
    /**
     * Read whole model via database.
     *
     * @param id        id
     */
    read(id: string): Promise<T>;
    /**
     * auto-create if not found.
     *
     * @param id
     * @param model
     */
    readOrCreate(id: string, model: T): Promise<T>;
    /**
     * simply save(or overwrite) all model
     *
     * @param id        id
     * @param model     whole object.
     */
    save(id: string, model: T): Promise<T>;
    /**
     * update some attributes
     *
     * @param id        id
     * @param model     attributes to update
     * @param incrementals (optional) attributes to increment
     */
    update(id: string, model: T, incrementals?: T): Promise<T>;
    /**
     * increment number attribute (or overwrite string field)
     * - if not exists, then just update property with base zero 0.
     *
     * @param id        id
     * @param model     attributes of number.
     * @param $update   (optional) update-set.
     */
    increment(id: string, model: T, $update?: T): Promise<T>;
    /**
     * delete set.
     * - if not exists, then just update property with base zero 0.
     *
     * @param id        id
     */
    delete(id: string): Promise<T>;
}
/** ****************************************************************************************************************
 *  Dummy Data Service
 ** ****************************************************************************************************************/
/**
 * class: `DummyStorageService`
 * - service in-memory dummy data
 *
 * **NOTE**
 * - this dummy service should be replaceable with real service `DynamoStorageService`
 */
export declare class DummyStorageService<T extends StorageModel> implements StorageService<T> {
    private name;
    private idName;
    constructor(dataFile: string, name?: string, idName?: string);
    private buffer;
    load(data: StorageModel[]): void;
    /**
     * say hello()
     * @param name  (optional) given name
     */
    hello: () => string;
    read(id: string): Promise<T>;
    protected readSafe(id: string): Promise<T>;
    readOrCreate(id: string, model: T): Promise<T>;
    save(id: string, item: T): Promise<T>;
    private $locks;
    update(id: string, item: T, $inc?: T): Promise<T>;
    increment(id: string, $inc: T, $upt?: T): Promise<T>;
    delete(id: string): Promise<T>;
}
