Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dynamodb-toolbox

Package Overview
Dependencies
Maintainers
1
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dynamodb-toolbox - npm Package Compare versions

Comparing version 0.2.0-beta to 0.2.0-beta.1

35

__tests__/entity.delete.unit.test.js

@@ -227,2 +227,37 @@ const { Table, Entity } = require('../index')

// Adding this for regression testing
it('Non-Key Index Generated on Delete #74', async () => {
const FoosTable = new Table({
name: 'test-table',
partitionKey: 'pk',
sortKey: 'sk',
indexes: {
'GSI-1': { partitionKey: 'gsi1pk', sortKey: 'gsi1sk' },
},
DocumentClient,
});
const Foos = new Entity({
name: 'Foo',
table: FoosTable,
timestamps: true,
attributes: {
pk: { hidden: true, partitionKey: true, default: (data) => (`FOO#${data.id}`) },
sk: { hidden: true, sortKey: true, default: (data) => (`FOO#${data.id}`) },
// This next `default` gets executed on delete() and fails with "Cannot read property 'tenant' of undefined"
gsi1pk: { hidden: true, default: (data) => (`TENANT#${data.meta.tenant}`) },
gsi1sk: { hidden: true, default: (data) => (`FOO#${data.id}`) },
id: { required: 'always' },
meta: { type: 'map', required: 'always' },
__context__: { hidden: true },
},
});
const key = { id: 'xyz' }
let result = Foos.deleteParams(key) // Fails with v0.2.0-beta. Fine with v0.2.0-alpha
expect(result).toEqual({ TableName: 'test-table', Key: { pk: 'FOO#xyz', sk: 'FOO#xyz' } })
})
})

42

__tests__/misc-tests.js

@@ -34,5 +34,45 @@ // Bootstrap testing

it('Non-Key Index Generated on Delete #74', async () => {
const FoosTable = new Table({
name: 'test-table',
partitionKey: 'pk',
sortKey: 'sk',
indexes: {
'GSI-1': { partitionKey: 'gsi1pk', sortKey: 'gsi1sk' },
},
DocumentClient,
});
const Foos = new Entity({
name: 'Foo',
table: FoosTable,
timestamps: true,
attributes: {
pk: { hidden: true, partitionKey: true, default: (data) => (`FOO#${data.id}`) },
sk: { hidden: true, sortKey: true, default: (data) => (`FOO#${data.id}`) },
// This next `default` gets executed on delete() and fails with "Cannot read property 'tenant' of undefined"
gsi1pk: { hidden: true, default: (data) => (`TENANT#${data.meta.tenant}`) },
gsi1sk: { hidden: true, default: (data) => (`FOO#${data.id}`) },
id: { required: 'always' },
meta: { type: 'map', required: 'always' },
__context__: { hidden: true },
},
});
it('Function default dependency issue #68', async () => {
const foo = {
id: 'xyz',
meta: { tenant: 'abc' },
};
await Foos.put(foo);
const key = { id: foo.id };
await Foos.delete(key); // Fails with v0.2.0-beta. Fine with v0.2.0-alpha
})
it.skip('Function default dependency issue #68', async () => {
const { randomBytes } = require('crypto')

@@ -39,0 +79,0 @@

10

lib/normalizeData.js

@@ -38,5 +38,9 @@ 'use strict'

} else {
map[attr] = map[attr](map)
if (schema[attr].alias) map[schema[attr].alias] = map[attr]
if (schema[attr].map) map[schema[attr].map] = map[attr]
try {
map[attr] = map[attr](map)
if (schema[attr].alias) map[schema[attr].alias] = map[attr]
if (schema[attr].map) map[schema[attr].map] = map[attr]
} catch(e) {
// TODO: Find a better way to prevent this for missing fields
}
return map

@@ -43,0 +47,0 @@ }

{
"name": "dynamodb-toolbox",
"version": "0.2.0-beta",
"version": "0.2.0-beta.1",
"description": "A simple set of tools for working with Amazon DynamoDB and the DocumentClient.",

@@ -5,0 +5,0 @@ "author": "Jeremy Daly <jeremy@jeremydaly.com>",

Sorry, the diff of this file is too big to display

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