UNPKG

dynamodb-toolbox

Version:

Lightweight and type-safe query builder for DynamoDB and TypeScript.

22 lines (21 loc) 998 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseIndexOption = void 0; const dynamoDBToolboxError_js_1 = require("../errors/dynamoDBToolboxError.js"); const isString_js_1 = require("../utils/validation/isString.js"); const parseIndexOption = (table, index) => { if (!(0, isString_js_1.isString)(index)) { throw new dynamoDBToolboxError_js_1.DynamoDBToolboxError('options.invalidIndexOption', { message: `Invalid index option: '${String(index)}'. 'index' must be a string.`, payload: { index } }); } if (table.indexes[index] === undefined) { throw new dynamoDBToolboxError_js_1.DynamoDBToolboxError('options.invalidIndexOption', { message: `Invalid index option: '${String(index)}'. Index is not defined on Table, please provide an 'indexes' option to its constructor.`, payload: { index } }); } return index; }; exports.parseIndexOption = parseIndexOption;