import { tap } from 'rxjs/operators';
import { createLogger } from '../logger/logger';
import { DynamoRx } from './dynamo-rx';
import { getTableName } from './get-table-name.function';
import { BatchGetSingleTableRequest, DeleteRequest, GetRequest, PutRequest, QueryRequest, ScanRequest, TransactGetSingleTableRequest, UpdateRequest, } from './request';
import { BatchWriteSingleTableRequest } from './request/batchwritesingletable/batch-write-single-table.request';
var DynamoStore = /** @class */ (function () {
    function DynamoStore(modelClazz) {
        this.modelClazz = modelClazz;
        this.logger = createLogger('dynamo.DynamoStore', modelClazz);
        this.dynamoRx = new DynamoRx();
        this.tableName = getTableName(modelClazz);
        this.logger.debug('instance created');
    }
    Object.defineProperty(DynamoStore.prototype, "dynamoDb", {
        get: function () {
            return this.dynamoRx.dynamoDb;
        },
        enumerable: true,
        configurable: true
    });
    DynamoStore.prototype.put = function (item) {
        return new PutRequest(this.dynamoRx, this.modelClazz, item);
    };
    DynamoStore.prototype.get = function (partitionKey, sortKey) {
        return new GetRequest(this.dynamoRx, this.modelClazz, partitionKey, sortKey);
    };
    DynamoStore.prototype.update = function (partitionKey, sortKey) {
        return new UpdateRequest(this.dynamoRx, this.modelClazz, partitionKey, sortKey);
    };
    DynamoStore.prototype.delete = function (partitionKey, sortKey) {
        return new DeleteRequest(this.dynamoRx, this.modelClazz, partitionKey, sortKey);
    };
    DynamoStore.prototype.scan = function () {
        return new ScanRequest(this.dynamoRx, this.modelClazz);
    };
    DynamoStore.prototype.query = function () {
        return new QueryRequest(this.dynamoRx, this.modelClazz);
    };
    /**
     * This is a special implementation of BatchGetItem request, because it only supports one table,
     * if you wish to retrieve items from multiple tables
     * create an instance of BatchGetItemInput and use store.makeRequest with it.
     */
    DynamoStore.prototype.batchGet = function (keys) {
        return new BatchGetSingleTableRequest(this.dynamoRx, this.modelClazz, keys);
    };
    /**
     * This is a special implementation of batchWriteItem request, because it only supports one table,
     * if you wish to write items to multiple tables
     * create an instance of BatchWriteItemInput and use store.makeRequest with it.
     */
    DynamoStore.prototype.batchWrite = function () {
        return new BatchWriteSingleTableRequest(this.dynamoRx, this.modelClazz);
    };
    DynamoStore.prototype.transactGet = function (keys) {
        return new TransactGetSingleTableRequest(this.dynamoRx, this.modelClazz, keys);
    };
    DynamoStore.prototype.makeRequest = function (operation, params) {
        var _this = this;
        this.logger.debug('request', params);
        return this.dynamoRx.makeRequest(operation, params).pipe(tap(function (response) { return _this.logger.debug('response', response); }));
    };
    return DynamoStore;
}());
export { DynamoStore };
//# sourceMappingURL=dynamo-store.js.map