"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEnvParam = exports.getDynamoDbDocumentClient = exports.overrideDynamoDbDocumentClientWithTestClient = void 0;
const dynamodb_1 = __importDefault(require("aws-sdk/clients/dynamodb"));
/**************************
 * Dynamo Document Client *
 **************************/
const createDocumentClient = () => {
    return new dynamodb_1.default.DocumentClient();
};
let documentClient = createDocumentClient();
const overrideDynamoDbDocumentClientWithTestClient = (testDocumentClient) => {
    documentClient = testDocumentClient;
};
exports.overrideDynamoDbDocumentClientWithTestClient = overrideDynamoDbDocumentClientWithTestClient;
const getDynamoDbDocumentClient = () => {
    return documentClient;
};
exports.getDynamoDbDocumentClient = getDynamoDbDocumentClient;
/*****************
 * Env Variables *
 *****************/
const getEnvParam = (paramName) => {
    const maybeEnvParamValue = process.env[paramName];
    const isEnvParamValid = typeof maybeEnvParamValue === 'string' && maybeEnvParamValue.length > 0;
    if (!isEnvParamValid) {
        throw new Error(`Invalid env param ${paramName}`);
    }
    return maybeEnvParamValue;
};
exports.getEnvParam = getEnvParam;
