import * as tslib_1 from "tslib";
import { map } from 'rxjs/operators';
import { and } from '../expression/logical-operator';
import { addExpression } from '../expression/param-util';
import { addCondition } from '../expression/request-expression-builder';
import { StandardRequest } from './standard.request';
var WriteRequest = /** @class */ (function (_super) {
    tslib_1.__extends(WriteRequest, _super);
    function WriteRequest(dynamoRx, modelClazz) {
        return _super.call(this, dynamoRx, modelClazz) || this;
    }
    WriteRequest.prototype.returnItemCollectionMetrics = function (returnItemCollectionMetrics) {
        this.params.ReturnItemCollectionMetrics = returnItemCollectionMetrics;
        return this;
    };
    WriteRequest.prototype.onlyIfAttribute = function (attributePath) {
        return addCondition('ConditionExpression', attributePath, this, this.metadata);
    };
    /**
     * @param conditionDefFns
     */
    WriteRequest.prototype.onlyIf = function () {
        var conditionDefFns = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            conditionDefFns[_i] = arguments[_i];
        }
        var condition = and.apply(void 0, tslib_1.__spread(conditionDefFns))(undefined, this.metadata);
        addExpression('ConditionExpression', condition, this.params);
        return this;
    };
    /*
     * The ReturnValues parameter is used by several DynamoDB operations; however,
     * DeleteItem/PutItem/UpdateItem does not recognize any values other than NONE or ALL_OLD.
     */
    WriteRequest.prototype.returnValues = function (returnValues) {
        this.params.ReturnValues = returnValues;
        return this;
    };
    WriteRequest.prototype.exec = function () {
        return this.execFullResponse().pipe(map(function (response) {
            return;
        }));
    };
    return WriteRequest;
}(StandardRequest));
export { WriteRequest };
//# sourceMappingURL=write.request.js.map