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';
export class UpdateRequest extends WriteRequest {
    constructor(dynamoRx, modelClazz, partitionKey, sortKey) {
        super(dynamoRx, modelClazz);
        this.logger = createLogger('dynamo.request.UpdateRequest', modelClazz);
        this.params.Key = createKeyAttributes(this.metadata, partitionKey, sortKey);
    }
    updateAttribute(attributePath) {
        return addUpdate(attributePath, this, this.metadata);
    }
    operations(...updateDefFns) {
        prepareAndAddUpdateExpressions(this.metadata, this.params, updateDefFns);
        return this;
    }
    execFullResponse() {
        this.logger.debug('request', this.params);
        return this.dynamoRx.updateItem(this.params).pipe(tap(response => this.logger.debug('response', response)));
    }
}
//# sourceMappingURL=update.request.js.map