import { isEmpty, isString } from 'lodash';
export class ParamUtil {
    static addUpdateExpression(updateExpression, params) {
        ParamUtil.addExpression('UpdateExpression', updateExpression, params);
    }
    static addExpression(expressionType, condition, params) {
        const expressionAttributeNames = Object.assign({}, condition.attributeNames, params.ExpressionAttributeNames);
        const expressionAttributeValues = Object.assign({}, condition.attributeValues, params.ExpressionAttributeValues);
        if (!isEmpty(expressionAttributeNames)) {
            params.ExpressionAttributeNames = expressionAttributeNames;
        }
        if (!isEmpty(expressionAttributeValues)) {
            params.ExpressionAttributeValues = expressionAttributeValues;
        }
        const 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 ${condition.statement}`;
            }
        }
        else {
            ;
            params[expressionType] = condition.statement;
        }
    }
}
//# sourceMappingURL=param-util.js.map