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

dynalite

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dynalite - npm Package Compare versions

Comparing version 0.2.6 to 0.2.7

12

actions/createTable.js

@@ -32,2 +32,9 @@

}
if (data.GlobalSecondaryIndexes) {
data.GlobalSecondaryIndexes.forEach(function(index) {
index.IndexSizeBytes = 0
index.ItemCount = 0
index.IndexStatus = 'CREATING'
})
}

@@ -41,2 +48,7 @@ tableDb.put(key, data, function(err) {

data.TableStatus = 'ACTIVE'
if (data.GlobalSecondaryIndexes) {
data.GlobalSecondaryIndexes.forEach(function(index) {
index.IndexStatus = 'ACTIVE'
})
}

@@ -43,0 +55,0 @@ tableDb.put(key, data, function(err) {

1

actions/deleteTable.js

@@ -21,2 +21,3 @@

table.TableStatus = 'DELETING'
delete table.GlobalSecondaryIndexes

@@ -23,0 +24,0 @@ tableDb.put(key, table, function(err) {

6

package.json
{
"name": "dynalite",
"version": "0.2.6",
"version": "0.2.7",
"description": "A mock implementation of Amazon's DynamoDB built on LevelDB",

@@ -8,4 +8,4 @@ "main": "index.js",

"scripts": {
"test": "mocha --require should --reporter spec -t $([ $REMOTE ] && echo 30s || echo 4s) -b",
"coverage": "istanbul cover ./node_modules/.bin/_mocha -- --require should -t 4s -b"
"test": "mocha --require should --reporter spec -t $([ $REMOTE ] && echo 30s || echo 4s)",
"coverage": "istanbul cover ./node_modules/.bin/_mocha -- --require should -t 4s"
},

@@ -12,0 +12,0 @@ "repository": "mhart/dynalite",

@@ -67,6 +67,6 @@ dynalite

- Add config settings to turn on/off strict checking
- Allow for other persistence types (LevelDOWN-Hyper, etc)
- Use efficient range scans for `Query` calls
- Explore edge cases with `Query` and `ScanIndexForward: false` (combine with above)
- Implement `ReturnItemCollectionMetrics` on all remaining endpoints
- Implement size info for tables and indexes
- Is the `ListTables` limit of names returned 100 if no `Limit` supplied?

@@ -73,0 +73,0 @@

@@ -111,2 +111,67 @@ exports.types = {

},
GlobalSecondaryIndexes: {
type: 'List',
children: {
type: 'Structure',
children: {
Projection: {
type: 'Structure',
notNull: true,
children: {
ProjectionType: {
type: 'String',
enum: ['ALL', 'INCLUDE', 'KEYS_ONLY'],
},
NonKeyAttributes: {
type: 'List',
lengthGreaterThanOrEqual: 1,
children: 'String'
},
}
},
IndexName: {
type: 'String',
notNull: true,
regex: '[a-zA-Z0-9_.-]+',
lengthGreaterThanOrEqual: 3,
lengthLessThanOrEqual: 255,
},
ProvisionedThroughput: {
type: 'Structure',
notNull: true,
children: {
WriteCapacityUnits: {
type: 'Long',
notNull: true,
greaterThanOrEqual: 1,
},
ReadCapacityUnits: {
type: 'Long',
notNull: true,
greaterThanOrEqual: 1,
}
},
},
KeySchema: {
type: 'List',
notNull: true,
lengthGreaterThanOrEqual: 1,
lengthLessThanOrEqual: 2,
children: {
type: 'Structure',
children: {
AttributeName: {
type: 'String',
notNull: true,
},
KeyType: {
type: 'String',
notNull: true,
}
}
}
},
}
},
},
}

@@ -146,10 +211,12 @@

if (!data.LocalSecondaryIndexes && data.KeySchema.length != data.AttributeDefinitions.length)
// TODO: Clean this up!
if (!data.LocalSecondaryIndexes && !data.GlobalSecondaryIndexes && data.KeySchema.length != data.AttributeDefinitions.length)
return 'One or more parameter values were invalid: Number of attributes in KeySchema does not ' +
'exactly match number of attributes defined in AttributeDefinitions'
var indexNames = Object.create(null)
if (data.LocalSecondaryIndexes) {
var indexKeys
var tableHash = data.KeySchema[0].AttributeName
var indexNames = Object.create(null)

@@ -207,6 +274,47 @@ if (!data.LocalSecondaryIndexes.length)

if (data.LocalSecondaryIndexes.length > 5)
return 'One or more parameter values were invalid: Number of indexes exceeds per-table limit of 5'
return 'One or more parameter values were invalid: LocalSecondaryIndex count exceeds the per-table limit of 5'
}
if (data.GlobalSecondaryIndexes) {
var indexKeys
if (!data.GlobalSecondaryIndexes.length)
return 'One or more parameter values were invalid: List of GlobalSecondaryIndexes is empty'
for (var i = 0; i < data.GlobalSecondaryIndexes.length; i++) {
var indexName = data.GlobalSecondaryIndexes[i].IndexName
indexKeys = data.GlobalSecondaryIndexes[i].KeySchema.map(function(key) { return key.AttributeName }).reverse()
if (indexKeys.some(function(key) { return !~defns.indexOf(key) }))
return 'One or more parameter values were invalid: ' +
'Some index key attributes are not defined in AttributeDefinitions. ' +
'Keys: [' + indexKeys.join(', ') + '], AttributeDefinitions: [' + defns.join(', ') + ']'
if (data.GlobalSecondaryIndexes[i].KeySchema[1] &&
data.GlobalSecondaryIndexes[i].KeySchema[0].AttributeName ==
data.GlobalSecondaryIndexes[i].KeySchema[1].AttributeName)
return 'Both the Hash Key and the Range Key element in the KeySchema have the same name'
if (data.GlobalSecondaryIndexes[i].KeySchema[0].KeyType != 'HASH')
return 'Invalid KeySchema: The first KeySchemaElement is not a HASH key type'
if (data.GlobalSecondaryIndexes[i].KeySchema[1] &&
data.GlobalSecondaryIndexes[i].KeySchema[1].KeyType != 'RANGE')
return 'Invalid KeySchema: The second KeySchemaElement is not a RANGE key type'
if (data.GlobalSecondaryIndexes[i].Projection.ProjectionType == null)
return 'One or more parameter values were invalid: Unknown ProjectionType: null'
var projectionType = data.GlobalSecondaryIndexes[i].Projection.ProjectionType
if (data.GlobalSecondaryIndexes[i].Projection.NonKeyAttributes && projectionType != 'INCLUDE')
return 'One or more parameter values were invalid: ' +
'ProjectionType is ' + projectionType + ', but NonKeyAttributes is specified'
if (indexNames[indexName])
return 'One or more parameter values were invalid: Duplicate index name: ' + indexName
indexNames[indexName] = true
}
if (data.GlobalSecondaryIndexes.length > 5)
return 'One or more parameter values were invalid: GlobalSecondaryIndex count exceeds the per-table limit of 5'
}
}

@@ -10,3 +10,2 @@ exports.types = {

type: 'Structure',
notNull: true,
children: {

@@ -25,2 +24,39 @@ WriteCapacityUnits: {

},
GlobalSecondaryIndexUpdates: {
type: 'List',
children: {
type: 'Structure',
children: {
Update: {
type: 'Structure',
notNull: true,
children: {
IndexName: {
type: 'String',
notNull: true,
regex: '[a-zA-Z0-9_.-]+',
lengthGreaterThanOrEqual: 3,
lengthLessThanOrEqual: 255,
},
ProvisionedThroughput: {
type: 'Structure',
notNull: true,
children: {
WriteCapacityUnits: {
type: 'Long',
notNull: true,
greaterThanOrEqual: 1,
},
ReadCapacityUnits: {
type: 'Long',
notNull: true,
greaterThanOrEqual: 1,
}
},
},
}
},
},
},
},
}

@@ -30,8 +66,21 @@

if (data.ProvisionedThroughput.ReadCapacityUnits > 1000000000000)
return 'Given value ' + data.ProvisionedThroughput.ReadCapacityUnits + ' for ReadCapacityUnits is out of bounds'
if (data.ProvisionedThroughput.WriteCapacityUnits > 1000000000000)
return 'Given value ' + data.ProvisionedThroughput.WriteCapacityUnits + ' for WriteCapacityUnits is out of bounds'
if (!data.ProvisionedThroughput && (!data.GlobalSecondaryIndexUpdates || !data.GlobalSecondaryIndexUpdates.length))
return 'At least one of ProvisionedThroughput or GlobalSecondaryIndexUpdates is required'
if (data.ProvisionedThroughput) {
if (data.ProvisionedThroughput.ReadCapacityUnits > 1000000000000)
return 'Given value ' + data.ProvisionedThroughput.ReadCapacityUnits + ' for ReadCapacityUnits is out of bounds'
if (data.ProvisionedThroughput.WriteCapacityUnits > 1000000000000)
return 'Given value ' + data.ProvisionedThroughput.WriteCapacityUnits + ' for WriteCapacityUnits is out of bounds'
}
if (data.GlobalSecondaryIndexUpdates) {
for (var i = 0; i < data.GlobalSecondaryIndexUpdates.length; i++) {
if (data.GlobalSecondaryIndexUpdates[i].Update.ProvisionedThroughput.ReadCapacityUnits > 1000000000000)
return 'Given value ' + data.GlobalSecondaryIndexUpdates[i].Update.ProvisionedThroughput.ReadCapacityUnits + ' for ReadCapacityUnits is out of bounds for index ' + data.GlobalSecondaryIndexUpdates[i].Update.IndexName
if (data.GlobalSecondaryIndexUpdates[i].Update.ProvisionedThroughput.WriteCapacityUnits > 1000000000000)
return 'Given value ' + data.GlobalSecondaryIndexUpdates[i].Update.ProvisionedThroughput.WriteCapacityUnits + ' for WriteCapacityUnits is out of bounds for index ' + data.GlobalSecondaryIndexUpdates[i].Update.IndexName
}
}
}
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