import * as tslib_1 from "tslib";
import { isEmpty, isString } from 'lodash';
import { resolveAttributeValueNameConflicts } from './functions/resolve-attribute-value-name-conflicts.function';
export function addUpdateExpression(updateExpression, params) {
    addExpression('UpdateExpression', updateExpression, params);
}
export function addExpression(expressionType, condition, params) {
    var nameSafeCondition = resolveAttributeValueNameConflicts(condition, params);
    var expressionAttributeNames = tslib_1.__assign({}, params.ExpressionAttributeNames, nameSafeCondition.attributeNames);
    var expressionAttributeValues = tslib_1.__assign({}, params.ExpressionAttributeValues, nameSafeCondition.attributeValues);
    if (!isEmpty(expressionAttributeNames)) {
        params.ExpressionAttributeNames = expressionAttributeNames;
    }
    if (!isEmpty(expressionAttributeValues)) {
        params.ExpressionAttributeValues = expressionAttributeValues;
    }
    var expression = Reflect.get(params, expressionType);
    if (isString(expression)) {
        switch (expressionType) {
            case 'UpdateExpression':
                if (expression !== '') {
                    throw new Error('params.UpdateExpression is not empty, please use the UpdateRequest.operations() method to define all the update operations');
                }
                break;
            default:
                ;
                params[expressionType] = expression + " AND " + nameSafeCondition.statement;
        }
    }
    else {
        ;
        params[expressionType] = nameSafeCondition.statement;
    }
}
//# sourceMappingURL=param-util.js.map