UNPKG

dynamodb-toolbox

Version:

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

28 lines (27 loc) 1.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseOptions = void 0; const index_js_1 = require("../../../../entity/actions/parsePaths/index.js"); const rejectExtraOptions_js_1 = require("../../../../options/rejectExtraOptions.js"); const tableName_js_1 = require("../../../../options/tableName.js"); const isEmpty_js_1 = require("../../../../utils/isEmpty.js"); const parseOptions = (entity, options) => { const transactionOptions = {}; const { attributes, tableName, ...extraOptions } = options; (0, rejectExtraOptions_js_1.rejectExtraOptions)(extraOptions); if (attributes !== undefined) { const { ExpressionAttributeNames, ProjectionExpression } = entity .build(index_js_1.EntityPathParser) .parse(attributes); if (!(0, isEmpty_js_1.isEmpty)(ExpressionAttributeNames)) { transactionOptions.ExpressionAttributeNames = ExpressionAttributeNames; } transactionOptions.ProjectionExpression = ProjectionExpression; } if (tableName !== undefined) { // tableName is a meta-option, validated but not used here (0, tableName_js_1.parseTableNameOption)(tableName); } return transactionOptions; }; exports.parseOptions = parseOptions;