"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("../../decorator/metadata/index");
const index_2 = require("../expression/logical-operator/index");
const param_util_1 = require("../expression/param-util");
const request_expression_builder_1 = require("../expression/request-expression-builder");
const get_table_name_function_1 = require("../get-table-name.function");
class TransactBaseOperation {
    constructor(modelClazz) {
        if (!modelClazz) {
            throw new Error(`please provide the model class`);
        }
        this.modelClazz = modelClazz;
        this.metadata = index_1.metadataForClass(this.modelClazz);
        if (!this.metadata.modelOptions) {
            throw new Error('the given model class has no model decorator');
        }
        this.params = {
            TableName: get_table_name_function_1.getTableName(this.metadata),
        };
    }
    onlyIfAttribute(attributePath) {
        return request_expression_builder_1.addCondition('ConditionExpression', attributePath, this, this.metadata);
    }
    onlyIf(...conditionDefFns) {
        const condition = index_2.and(...conditionDefFns)(undefined, this.metadata);
        param_util_1.addExpression('ConditionExpression', condition, this.params);
        return this;
    }
    returnValuesOnConditionCheckFailure(value) {
        this.params.ReturnValuesOnConditionCheckFailure = value;
        return this;
    }
}
exports.TransactBaseOperation = TransactBaseOperation;
//# sourceMappingURL=transact-base-operation.js.map