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