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) {
    const nameSafeCondition = resolveAttributeValueNameConflicts(condition, params);
    const expressionAttributeNames = Object.assign({}, params.ExpressionAttributeNames, nameSafeCondition.attributeNames);
    const expressionAttributeValues = Object.assign({}, params.ExpressionAttributeValues, nameSafeCondition.attributeValues);
    if (!isEmpty(expressionAttributeNames)) {
        params.ExpressionAttributeNames = expressionAttributeNames;
    }
    if (!isEmpty(expressionAttributeValues)) {
        params.ExpressionAttributeValues = expressionAttributeValues;
    }
    const expression = params[expressionType];
    if (isString(expression) && expression !== '') {
        switch (expressionType) {
            case 'UpdateExpression':
                throw new Error('params.UpdateExpression is not empty, please use the UpdateRequest.operations() method to define all the update operations');
            default:
                ;
                params[expressionType] = `${expression} AND ${nameSafeCondition.statement}`;
        }
    }
    else {
        ;
        params[expressionType] = nameSafeCondition.statement;
    }
}
//# sourceMappingURL=param-util.js.map