import * as tslib_1 from "tslib";
import { tap } from 'rxjs/operators';
import { createLogger } from '../../../logger/logger';
import { createKeyAttributes } from '../../../mapper';
import { prepareAndAddUpdateExpressions } from '../../expression/prepare-and-add-update-expressions.function';
import { addUpdate } from '../../expression/request-expression-builder';
import { WriteRequest } from '../write.request';
var UpdateRequest = /** @class */ (function (_super) {
    tslib_1.__extends(UpdateRequest, _super);
    function UpdateRequest(dynamoRx, modelClazz, partitionKey, sortKey) {
        var _this = _super.call(this, dynamoRx, modelClazz) || this;
        _this.logger = createLogger('dynamo.request.UpdateRequest', modelClazz);
        _this.params.Key = createKeyAttributes(_this.metadata, partitionKey, sortKey);
        return _this;
    }
    UpdateRequest.prototype.updateAttribute = function (attributePath) {
        return addUpdate(attributePath, this, this.metadata);
    };
    UpdateRequest.prototype.operations = function () {
        var updateDefFns = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            updateDefFns[_i] = arguments[_i];
        }
        prepareAndAddUpdateExpressions(this.metadata, this.params, updateDefFns);
        return this;
    };
    UpdateRequest.prototype.execFullResponse = function () {
        var _this = this;
        this.logger.debug('request', this.params);
        return this.dynamoRx.updateItem(this.params).pipe(tap(function (response) { return _this.logger.debug('response', response); }));
    };
    return UpdateRequest;
}(WriteRequest));
export { UpdateRequest };
//# sourceMappingURL=update.request.js.map