UNPKG

dynamodb-toolbox

Version:

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

31 lines (30 loc) 1.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseMapExtension = void 0; const index_js_1 = require("../../../../../entity/actions/update/symbols/index.js"); const index_js_2 = require("../../../../../schema/actions/parse/index.js"); const isObject_js_1 = require("../../../../../utils/validation/isObject.js"); const parseMapExtension = (schema, input, { transform = true, valuePath } = {}) => { if ((0, isObject_js_1.isObject)(input)) { return { isExtension: true, *extensionParser() { const parser = new index_js_2.Parser(schema).start(input, { fill: false, transform, valuePath }); const parsedValue = { [index_js_1.$SET]: parser.next().value }; if (transform) { yield parsedValue; } else { return parsedValue; } const transformedValue = { [index_js_1.$SET]: parser.next().value }; return transformedValue; } }; } return { isExtension: false, unextendedInput: input }; }; exports.parseMapExtension = parseMapExtension;