UNPKG

@apilogic/migration-tool-api

Version:

Universal sql/no-sql database serverless migration tool

32 lines 1.22 kB
"use strict"; // src/clients/dynamo/utils/index.ts Object.defineProperty(exports, "__esModule", { value: true }); exports.unmarshall = exports.nullIfEmpty = void 0; const util_dynamodb_1 = require("@aws-sdk/util-dynamodb"); function nullIfEmpty(obj) { if (obj && typeof obj === 'object' && !Array.isArray(obj) && Object.keys(obj).length === 0) { return null; } return obj; } exports.nullIfEmpty = nullIfEmpty; function unmarshall(raw, isRaw) { // If isRaw === true, 'raw' is a DynamoDB AttributeValue map. Convert it first. const content = isRaw ? (0, util_dynamodb_1.unmarshall)(raw) : raw; // v2 compatibility: unwrap old aws-sdk Set wrapper if we ever see it if (content && typeof content === 'object' && content.wrapperName === 'Set') { return content.values; } if (Array.isArray(content)) { return content.map((value) => unmarshall(value, false)); } if (content && typeof content === 'object') { return Object.entries(content).reduce((acc, [key, value]) => { acc[key] = unmarshall(value, false); return acc; }, {}); } return content; } exports.unmarshall = unmarshall; //# sourceMappingURL=index.js.map