UNPKG

dynamodb-toolbox

Version:

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

34 lines (33 loc) 1.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseMapExtension = void 0; const index_js_1 = require("../../../../../schema/actions/parse/index.js"); const index_js_2 = require("../../symbols/index.js"); const parseMapExtension = (schema, input, { transform = true, valuePath } = {}) => { if ((0, index_js_2.isSetting)(input) && input[index_js_2.$SET] !== undefined) { return { isExtension: true, *extensionParser() { const parser = new index_js_1.Parser(schema).start(input[index_js_2.$SET], { fill: false, transform, valuePath: [...(valuePath !== null && valuePath !== void 0 ? valuePath : []), '$SET'] }); const parsedValue = { [index_js_2.$SET]: parser.next().value }; if (transform) { yield parsedValue; } else { return parsedValue; } const transformedValue = { [index_js_2.$SET]: parser.next().value }; return transformedValue; } }; } return { isExtension: false, unextendedInput: input }; }; exports.parseMapExtension = parseMapExtension;