"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const operators_1 = require("rxjs/operators");
const dynamo_rx_1 = require("../dynamo-rx");
class TransactWriteRequest {
    constructor() {
        this.dynamoRx = new dynamo_rx_1.DynamoRx();
        this.params = {
            TransactItems: [],
        };
    }
    returnConsumedCapacity(level) {
        this.params.ReturnConsumedCapacity = level;
        return this;
    }
    returnItemCollectionMetrics(returnItemCollectionMetrics) {
        this.params.ReturnItemCollectionMetrics = returnItemCollectionMetrics;
        return this;
    }
    transact(...writeOperations) {
        if (!writeOperations || writeOperations.length === 0) {
            throw new Error('at least one transaction operation must be added');
        }
        if ((this.params.TransactItems.length + writeOperations.length) > 10) {
            throw new Error(`Each transaction can include up to 10 unique items, including conditions.\
       Given operations count: ${this.params.TransactItems.length + writeOperations.length}`);
        }
        this.params.TransactItems.push(...writeOperations.map(wo => wo.transactItem));
        return this;
    }
    execFullResponse() {
        return this.dynamoRx.transactWriteItems(this.params);
    }
    exec() {
        return this.dynamoRx.transactWriteItems(this.params).pipe(operators_1.map(response => {
            return;
        }));
    }
}
exports.TransactWriteRequest = TransactWriteRequest;
//# sourceMappingURL=transact-write.request.js.map