"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const lodash_1 = require("lodash");
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 (!lodash_1.isEmpty(expressionAttributeNames)) {
            params.ExpressionAttributeNames = expressionAttributeNames;
        }
        if (!lodash_1.isEmpty(expressionAttributeValues)) {
            params.ExpressionAttributeValues = expressionAttributeValues;
        }
        const expression = Reflect.get(params, expressionType);
        if (lodash_1.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;
        }
    }
}
exports.ParamUtil = ParamUtil;
//# sourceMappingURL=param-util.js.map