Socket
Socket
Sign inDemoInstall

@aws/dynamodb-data-marshaller

Package Overview
Dependencies
Maintainers
12
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws/dynamodb-data-marshaller - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

0

build/index.d.ts

@@ -0,0 +0,0 @@ export * from './InvalidSchemaError';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { SchemaType } from "./SchemaType";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ "use strict";

import { SchemaType } from './SchemaType';
export declare function isKey(fieldSchema: SchemaType, indexName?: string): boolean;

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { KeyType } from './SchemaType';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=KeySchema.js.map
import { KeySchema } from './KeySchema';
import { Schema } from './Schema';
export declare function keysFromSchema(schema: Schema): KeySchema;

24

build/keysFromSchema.js

@@ -5,2 +5,3 @@ "use strict";

function keysFromSchema(schema) {
var e_1, _a, e_2, _b;
var attributes = {};

@@ -10,4 +11,4 @@ var tableKeys = {};

try {
for (var _a = tslib_1.__values(Object.keys(schema)), _b = _a.next(); !_b.done; _b = _a.next()) {
var propertyName = _b.value;
for (var _c = tslib_1.__values(Object.keys(schema)), _d = _c.next(); !_d.done; _d = _c.next()) {
var propertyName = _d.value;
var fieldSchema = schema[propertyName];

@@ -19,3 +20,3 @@ if (fieldSchema.type === 'Binary' ||

fieldSchema.type === 'String') {
var _c = fieldSchema.attributeName, attributeName = _c === void 0 ? propertyName : _c;
var _e = fieldSchema.attributeName, attributeName = _e === void 0 ? propertyName : _e;
if (fieldSchema.keyType) {

@@ -29,4 +30,4 @@ attributes[attributeName] = attributeType(fieldSchema);

try {
for (var _d = tslib_1.__values(Object.keys(fieldSchema.indexKeyConfigurations)), _e = _d.next(); !_e.done; _e = _d.next()) {
var indexName = _e.value;
for (var _f = tslib_1.__values(Object.keys(fieldSchema.indexKeyConfigurations)), _g = _f.next(); !_g.done; _g = _f.next()) {
var indexName = _g.value;
if (!(indexName in indexKeys)) {

@@ -39,8 +40,8 @@ indexKeys[indexName] = {};

}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (_e && !_e.done && (_f = _d.return)) _f.call(_d);
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
}
finally { if (e_1) throw e_1.error; }
finally { if (e_2) throw e_2.error; }
}

@@ -51,11 +52,10 @@ }

}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_b && !_b.done && (_g = _a.return)) _g.call(_a);
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
}
finally { if (e_2) throw e_2.error; }
finally { if (e_1) throw e_1.error; }
}
return { attributes: attributes, tableKeys: tableKeys, indexKeys: indexKeys };
var e_2, _g, e_1, _f;
}

@@ -62,0 +62,0 @@ exports.keysFromSchema = keysFromSchema;

@@ -0,0 +0,0 @@ import { Schema } from './Schema';

@@ -145,31 +145,31 @@ "use strict";

function normalizeUpdateExpression(expression, schema) {
var e_1, _a, e_2, _b;
var normalized = new dynamodb_expressions_1.UpdateExpression;
try {
for (var mapsToTransform_1 = tslib_1.__values(mapsToTransform), mapsToTransform_1_1 = mapsToTransform_1.next(); !mapsToTransform_1_1.done; mapsToTransform_1_1 = mapsToTransform_1.next()) {
var _a = tslib_1.__read(mapsToTransform_1_1.value, 2), dataSet = _a[0], exprMethod = _a[1];
var _c = tslib_1.__read(mapsToTransform_1_1.value, 2), dataSet = _c[0], exprMethod = _c[1];
try {
for (var _b = tslib_1.__values(expression[dataSet]), _c = _b.next(); !_c.done; _c = _b.next()) {
var _d = tslib_1.__read(_c.value, 2), path = _d[0], value = _d[1];
for (var _d = tslib_1.__values(expression[dataSet]), _e = _d.next(); !_e.done; _e = _d.next()) {
var _f = tslib_1.__read(_e.value, 2), path = _f[0], value = _f[1];
normalized[exprMethod](toSchemaName_1.toSchemaName(path, schema), value);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (_c && !_c.done && (_e = _b.return)) _e.call(_b);
if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
}
finally { if (e_1) throw e_1.error; }
finally { if (e_2) throw e_2.error; }
}
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (mapsToTransform_1_1 && !mapsToTransform_1_1.done && (_f = mapsToTransform_1.return)) _f.call(mapsToTransform_1);
if (mapsToTransform_1_1 && !mapsToTransform_1_1.done && (_a = mapsToTransform_1.return)) _a.call(mapsToTransform_1);
}
finally { if (e_2) throw e_2.error; }
finally { if (e_1) throw e_1.error; }
}
expression.toRemove.forEach(function (el) { return normalized.remove(toSchemaName_1.toSchemaName(el, schema)); });
return normalized;
var e_2, _f, e_1, _e;
}

@@ -176,0 +176,0 @@ function normalizeIfPath(path, schema) {

@@ -0,0 +0,0 @@ import { Schema } from './Schema';

@@ -15,8 +15,9 @@ "use strict";

function marshallItem(schema, input) {
var e_1, _a;
var marshalled = {};
try {
for (var _a = tslib_1.__values(Object.keys(schema)), _b = _a.next(); !_b.done; _b = _a.next()) {
var key = _b.value;
for (var _b = tslib_1.__values(Object.keys(schema)), _c = _b.next(); !_c.done; _c = _b.next()) {
var key = _c.value;
var value = input[key];
var _c = schema[key].attributeName, attributeName = _c === void 0 ? key : _c;
var _d = schema[key].attributeName, attributeName = _d === void 0 ? key : _d;
var marshalledValue = marshallValue(schema[key], value);

@@ -31,3 +32,3 @@ if (marshalledValue) {

try {
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}

@@ -37,3 +38,2 @@ finally { if (e_1) throw e_1.error; }

return marshalled;
var e_1, _d;
}

@@ -49,2 +49,3 @@ exports.marshallItem = marshallItem;

function marshallValue(schemaType, input) {
var e_2, _a, e_3, _b, e_4, _c, e_5, _d, e_6, _e, e_7, _f;
if (input === undefined) {

@@ -60,3 +61,3 @@ var defaultProvider = schemaType.defaultProvider;

if (schemaType.type === 'Any') {
var _a = schemaType.onEmpty, onEmpty = _a === void 0 ? 'nullify' : _a, _b = schemaType.onInvalid, onInvalid = _b === void 0 ? 'omit' : _b, _c = schemaType.unwrapNumbers, unwrapNumbers = _c === void 0 ? false : _c;
var _g = schemaType.onEmpty, onEmpty = _g === void 0 ? 'nullify' : _g, _h = schemaType.onInvalid, onInvalid = _h === void 0 ? 'omit' : _h, _j = schemaType.unwrapNumbers, unwrapNumbers = _j === void 0 ? false : _j;
var marshaller = new dynamodb_auto_marshaller_1.Marshaller({ onEmpty: onEmpty, onInvalid: onInvalid, unwrapNumbers: unwrapNumbers });

@@ -78,3 +79,3 @@ return marshaller.marshallValue(input);

if (schemaType.type === 'Collection') {
var _d = schemaType.onEmpty, onEmpty = _d === void 0 ? 'nullify' : _d, _e = schemaType.onInvalid, onInvalid = _e === void 0 ? 'omit' : _e, _f = schemaType.unwrapNumbers, unwrapNumbers = _f === void 0 ? false : _f;
var _k = schemaType.onEmpty, onEmpty = _k === void 0 ? 'nullify' : _k, _l = schemaType.onInvalid, onInvalid = _l === void 0 ? 'omit' : _l, _m = schemaType.unwrapNumbers, unwrapNumbers = _m === void 0 ? false : _m;
var marshaller = new dynamodb_auto_marshaller_1.Marshaller({ onEmpty: onEmpty, onInvalid: onInvalid, unwrapNumbers: unwrapNumbers });

@@ -94,3 +95,3 @@ var collected = [];

try {
if (input_1_1 && !input_1_1.done && (_g = input_1.return)) _g.call(input_1);
if (input_1_1 && !input_1_1.done && (_a = input_1.return)) _a.call(input_1);
}

@@ -121,3 +122,3 @@ finally { if (e_2) throw e_2.error; }

if (schemaType.type === 'Hash') {
var _h = schemaType.onEmpty, onEmpty = _h === void 0 ? 'nullify' : _h, _j = schemaType.onInvalid, onInvalid = _j === void 0 ? 'omit' : _j, _k = schemaType.unwrapNumbers, unwrapNumbers = _k === void 0 ? false : _k;
var _o = schemaType.onEmpty, onEmpty = _o === void 0 ? 'nullify' : _o, _p = schemaType.onInvalid, onInvalid = _p === void 0 ? 'omit' : _p, _q = schemaType.unwrapNumbers, unwrapNumbers = _q === void 0 ? false : _q;
var marshaller = new dynamodb_auto_marshaller_1.Marshaller({ onEmpty: onEmpty, onInvalid: onInvalid, unwrapNumbers: unwrapNumbers });

@@ -140,3 +141,3 @@ return { M: marshaller.marshallItem(input) };

try {
if (input_2_1 && !input_2_1.done && (_l = input_2.return)) _l.call(input_2);
if (input_2_1 && !input_2_1.done && (_b = input_2.return)) _b.call(input_2);
}

@@ -152,3 +153,3 @@ finally { if (e_3) throw e_3.error; }

for (var input_3 = tslib_1.__values(input), input_3_1 = input_3.next(); !input_3_1.done; input_3_1 = input_3.next()) {
var _m = tslib_1.__read(input_3_1.value, 2), key = _m[0], value = _m[1];
var _r = tslib_1.__read(input_3_1.value, 2), key = _r[0], value = _r[1];
var marshalledValue = marshallValue(schemaType.memberType, value);

@@ -163,3 +164,3 @@ if (marshalledValue) {

try {
if (input_3_1 && !input_3_1.done && (_o = input_3.return)) _o.call(input_3);
if (input_3_1 && !input_3_1.done && (_c = input_3.return)) _c.call(input_3);
}

@@ -171,4 +172,4 @@ finally { if (e_4) throw e_4.error; }

try {
for (var _p = tslib_1.__values(Object.keys(input)), _q = _p.next(); !_q.done; _q = _p.next()) {
var key = _q.value;
for (var _s = tslib_1.__values(Object.keys(input)), _t = _s.next(); !_t.done; _t = _s.next()) {
var key = _t.value;
var marshalledValue = marshallValue(schemaType.memberType, input[key]);

@@ -183,3 +184,3 @@ if (marshalledValue) {

try {
if (_q && !_q.done && (_r = _p.return)) _r.call(_p);
if (_t && !_t.done && (_d = _s.return)) _d.call(_s);
}

@@ -213,3 +214,3 @@ finally { if (e_5) throw e_5.error; }

try {
if (input_4_1 && !input_4_1.done && (_s = input_4.return)) _s.call(input_4);
if (input_4_1 && !input_4_1.done && (_e = input_4.return)) _e.call(input_4);
}

@@ -241,3 +242,3 @@ finally { if (e_6) throw e_6.error; }

try {
if (original_1_1 && !original_1_1.done && (_t = original_1.return)) _t.call(original_1);
if (original_1_1 && !original_1_1.done && (_f = original_1.return)) _f.call(original_1);
}

@@ -266,3 +267,2 @@ finally { if (e_7) throw e_7.error; }

throw new InvalidSchemaError_1.InvalidSchemaError(schemaType, 'Unrecognized schema node');
var e_2, _g, e_3, _l, e_4, _o, e_5, _r, e_6, _s, e_7, _t;
}

@@ -286,2 +286,3 @@ exports.marshallValue = marshallValue;

function marshallSet(value, marshaller, isEmpty, setTag) {
var e_8, _a, _b;
var collected = [];

@@ -310,3 +311,2 @@ try {

return _b = {}, _b[setTag] = collected, _b;
var e_8, _a, _b;
}

@@ -313,0 +313,0 @@ function isArrayBuffer(arg) {

@@ -0,0 +0,0 @@ import { Schema } from './Schema';

@@ -7,9 +7,10 @@ "use strict";

function marshallKey(schema, input, indexName) {
var e_1, _a;
var marshalled = {};
try {
for (var _a = tslib_1.__values(Object.keys(schema)), _b = _a.next(); !_b.done; _b = _a.next()) {
var propertyKey = _b.value;
for (var _b = tslib_1.__values(Object.keys(schema)), _c = _b.next(); !_c.done; _c = _b.next()) {
var propertyKey = _c.value;
var fieldSchema = schema[propertyKey];
if (isKey_1.isKey(fieldSchema, indexName)) {
var _c = fieldSchema.attributeName, attributeName = _c === void 0 ? propertyKey : _c;
var _d = fieldSchema.attributeName, attributeName = _d === void 0 ? propertyKey : _d;
var value = marshallItem_1.marshallValue(fieldSchema, input[propertyKey]);

@@ -25,3 +26,3 @@ if (value) {

try {
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}

@@ -31,5 +32,4 @@ finally { if (e_1) throw e_1.error; }

return marshalled;
var e_1, _d;
}
exports.marshallKey = marshallKey;
//# sourceMappingURL=marshallKey.js.map

@@ -0,0 +0,0 @@ import { SchemaType } from "./SchemaType";

@@ -9,2 +9,3 @@ "use strict";

function isSchema(arg) {
var e_1, _a;
if (!Boolean(arg) || typeof arg !== 'object') {

@@ -14,4 +15,4 @@ return false;

try {
for (var _a = tslib_1.__values(Object.keys(arg)), _b = _a.next(); !_b.done; _b = _a.next()) {
var key = _b.value;
for (var _b = tslib_1.__values(Object.keys(arg)), _c = _b.next(); !_c.done; _c = _b.next()) {
var key = _c.value;
if (!SchemaType_1.isSchemaType(arg[key])) {

@@ -25,3 +26,3 @@ return false;

try {
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}

@@ -31,5 +32,4 @@ finally { if (e_1) throw e_1.error; }

return true;
var e_1, _c;
}
exports.isSchema = isSchema;
//# sourceMappingURL=Schema.js.map

@@ -0,0 +0,0 @@ import { ScalarAttributeType } from './KeySchema';

@@ -38,3 +38,4 @@ "use strict";

function isKeyableType(arg) {
var _a = arg, keyType = _a.keyType, indexKeyConfigurations = _a.indexKeyConfigurations;
var e_1, _a;
var _b = arg, keyType = _b.keyType, indexKeyConfigurations = _b.indexKeyConfigurations;
if (!(keyType === undefined || keyType in exports.KeyTypes)) {

@@ -46,4 +47,4 @@ return false;

try {
for (var _b = tslib_1.__values(Object.keys(indexKeyConfigurations)), _c = _b.next(); !_c.done; _c = _b.next()) {
var indexName = _c.value;
for (var _c = tslib_1.__values(Object.keys(indexKeyConfigurations)), _d = _c.next(); !_d.done; _d = _c.next()) {
var indexName = _d.value;
if (!(indexKeyConfigurations[indexName] in exports.KeyTypes)) {

@@ -57,3 +58,3 @@ return false;

try {
if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
}

@@ -65,3 +66,2 @@ finally { if (e_1) throw e_1.error; }

return idxKeysType === 'undefined';
var e_1, _d;
}

@@ -108,3 +108,4 @@ function isSchemaType(arg, alreadyVisited) {

function isDocumentType(arg, alreadyVisited) {
var _a = arg, valueConstructor = _a.valueConstructor, members = _a.members;
var e_2, _a;
var _b = arg, valueConstructor = _b.valueConstructor, members = _b.members;
if (!members || typeof members !== 'object') {

@@ -114,4 +115,4 @@ return false;

try {
for (var _b = tslib_1.__values(Object.keys(members)), _c = _b.next(); !_c.done; _c = _b.next()) {
var key = _c.value;
for (var _c = tslib_1.__values(Object.keys(members)), _d = _c.next(); !_d.done; _d = _c.next()) {
var key = _d.value;
if (!isSchemaType(members[key], alreadyVisited)) {

@@ -125,3 +126,3 @@ return false;

try {
if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
}

@@ -131,5 +132,5 @@ finally { if (e_2) throw e_2.error; }

return ['function', 'undefined',].indexOf(typeof valueConstructor) > -1;
var e_2, _d;
}
function isTupleType(arg, alreadyVisited) {
var e_3, _a;
var members = arg.members;

@@ -155,4 +156,3 @@ if (!Array.isArray(members)) {

return true;
var e_3, _a;
}
//# sourceMappingURL=SchemaType.js.map

@@ -0,0 +0,0 @@ import { AttributePath } from '@aws/dynamodb-expressions';

@@ -6,2 +6,3 @@ "use strict";

function toSchemaName(path, schema) {
var e_1, _a;
if (typeof path === 'string') {

@@ -43,3 +44,2 @@ path = new dynamodb_expressions_1.AttributePath(path);

return new dynamodb_expressions_1.AttributePath(elements);
var e_1, _a;
}

@@ -46,0 +46,0 @@ exports.toSchemaName = toSchemaName;

@@ -0,0 +0,0 @@ import { Schema } from "./Schema";

@@ -16,2 +16,3 @@ "use strict";

function unmarshallItem(schema, input, valueConstructor) {
var e_1, _a;
var unmarshalled = valueConstructor

@@ -21,5 +22,5 @@ ? new valueConstructor()

try {
for (var _a = tslib_1.__values(Object.keys(schema)), _b = _a.next(); !_b.done; _b = _a.next()) {
var key = _b.value;
var _c = schema[key].attributeName, attributeName = _c === void 0 ? key : _c;
for (var _b = tslib_1.__values(Object.keys(schema)), _c = _b.next(); !_c.done; _c = _b.next()) {
var key = _c.value;
var _d = schema[key].attributeName, attributeName = _d === void 0 ? key : _d;
if (attributeName in input) {

@@ -33,3 +34,3 @@ unmarshalled[key] = unmarshallValue(schema[key], input[attributeName]);

try {
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}

@@ -39,3 +40,2 @@ finally { if (e_1) throw e_1.error; }

return unmarshalled;
var e_1, _d;
}

@@ -102,2 +102,3 @@ exports.unmarshallItem = unmarshallItem;

function unmarshallList(schemaType, input) {
var e_2, _a;
var list = [];

@@ -118,9 +119,9 @@ try {

return list;
var e_2, _a;
}
function unmarshallMap(schemaType, input) {
var e_3, _a;
var map = new Map();
try {
for (var _a = tslib_1.__values(Object.keys(input)), _b = _a.next(); !_b.done; _b = _a.next()) {
var key = _b.value;
for (var _b = tslib_1.__values(Object.keys(input)), _c = _b.next(); !_c.done; _c = _b.next()) {
var key = _c.value;
map.set(key, unmarshallValue(schemaType.memberType, input[key]));

@@ -132,3 +133,3 @@ }

try {
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}

@@ -138,5 +139,5 @@ finally { if (e_3) throw e_3.error; }

return map;
var e_3, _c;
}
function unmarshallNumberSet(input) {
var e_4, _a;
var set = new Set();

@@ -157,5 +158,5 @@ try {

return set;
var e_4, _a;
}
function unmarshallStringSet(input) {
var e_5, _a;
var set = new Set();

@@ -176,3 +177,2 @@ try {

return set;
var e_5, _a;
}

@@ -179,0 +179,0 @@ function unmarshallTuple(schemaType, input) {

{
"name": "@aws/dynamodb-data-marshaller",
"version": "0.5.0",
"version": "0.6.0",
"description": "A schema-based data marshaller for Amazon DynamoDB",

@@ -31,6 +31,6 @@ "keywords": [

"devDependencies": {
"@types/jest": "^22",
"@types/jest": "^23",
"@types/node": "^8.0.4",
"aws-sdk": "^2.7.0",
"jest": "^22",
"jest": "^23",
"typedoc": "^0.11.0",

@@ -40,4 +40,4 @@ "typescript": "^2.7"

"dependencies": {
"@aws/dynamodb-auto-marshaller": "^0.5.0",
"@aws/dynamodb-expressions": "^0.5.0",
"@aws/dynamodb-auto-marshaller": "^0.6.0",
"@aws/dynamodb-expressions": "^0.6.0",
"tslib": "^1.8.1",

@@ -44,0 +44,0 @@ "utf8-bytes": "^0.0.1"

@@ -0,0 +0,0 @@ # Amazon DynamoDB Data Marshaller

@@ -0,0 +0,0 @@ {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc