New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

copy-dynamodb-table

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

copy-dynamodb-table - npm Package Compare versions

Comparing version 2.0.17 to 2.0.18

175

index.js

@@ -5,2 +5,3 @@ 'use strict'

var readline = require('readline')
var parallel = require('async').parallel;

@@ -32,4 +33,4 @@ function copy(values, fn) {

dynamodb: values.destination.dynamodb || new AWS.DynamoDB(values.destination.config || values.config),
active:values.destination.active,
createTableStr : 'Creating Destination Table '
active: values.destination.active,
createTableStr: 'Creating Destination Table '
},

@@ -41,21 +42,21 @@ key: values.key,

log: values.log,
create : values.create
create: values.create
}
if(options.source.active && options.destination.active){ // both tables are active
return startCopying(options,fn)
if (options.source.active && options.destination.active) { // both tables are active
return startCopying(options, fn)
}
if(options.create){ // create table if not exist
return options.source.dynamodb.describeTable({TableName : options.source.tableName},function(err,data){
if(err){
return fn(err,data)
if (options.create) { // create table if not exist
return options.source.dynamodb.describeTable({ TableName: options.source.tableName }, function (err, data) {
if (err) {
return fn(err, data)
}
options.source.active = true
data.Table.TableName = options.destination.tableName
options.destination.dynamodb.createTable(clearTableSchema(data.Table),function(err){
if(err && err.code !== 'ResourceInUseException'){
return fn(err,data)
options.destination.dynamodb.createTable(clearTableSchema(data.Table), function (err) {
if (err && err.code !== 'ResourceInUseException') {
return fn(err, data)
}
waitForActive(options,fn)
waitForActive(options, fn)
// wait for TableStatus to be ACTIVE

@@ -66,7 +67,7 @@ })

checkTables(options,function(err,data){ // check if source and destination table exist
if(err){
return fn(err,data)
checkTables(options, function (err, data) { // check if source and destination table exist
if (err) {
return fn(err, data)
}
startCopying(options,fn)
startCopying(options, fn)
})

@@ -76,28 +77,30 @@

function clearTableSchema(table){
function clearTableSchema(table) {
delete table.TableStatus
delete table.CreationDateTime
delete table.ProvisionedThroughput.LastIncreaseDateTime
delete table.ProvisionedThroughput.LastDecreaseDateTime
delete table.ProvisionedThroughput.NumberOfDecreasesToday
delete table.TableSizeBytes
delete table.ItemCount
delete table.TableArn
delete table.TableId
delete table.LatestStreamLabel
delete table.LatestStreamArn
delete table.BillingModeSummary
delete table.TableStatus;
delete table.CreationDateTime;
if (table.ProvisionedThroughput.ReadCapacityUnits === 0 && table.ProvisionedThroughput.WriteCapacityUnits === 0) {
delete table.ProvisionedThroughput
}
else {
delete table.ProvisionedThroughput.LastIncreaseDateTime;
delete table.ProvisionedThroughput.LastDecreaseDateTime;
delete table.ProvisionedThroughput.NumberOfDecreasesToday;
}
if(table.LocalSecondaryIndexes && table.LocalSecondaryIndexes.length > 0){
for(var i = 0 ; i < table.LocalSecondaryIndexes.length ; i++){
delete table.LocalSecondaryIndexes[i].IndexStatus
delete table.LocalSecondaryIndexes[i].ProvisionedThroughput.LastIncreaseDateTime
delete table.LocalSecondaryIndexes[i].ProvisionedThroughput.LastDecreaseDateTime
delete table.LocalSecondaryIndexes[i].ProvisionedThroughput.NumberOfDecreasesToday
delete table.LocalSecondaryIndexes[i].IndexSizeBytes
delete table.LocalSecondaryIndexes[i].ItemCount
delete table.LocalSecondaryIndexes[i].IndexArn
delete table.LocalSecondaryIndexes[i].LatestStreamLabel
delete table.LocalSecondaryIndexes[i].LatestStreamArn
delete table.TableSizeBytes;
delete table.ItemCount;
delete table.TableArn;
delete table.TableId;
delete table.LatestStreamLabel;
delete table.LatestStreamArn;
if (table.LocalSecondaryIndexes && table.LocalSecondaryIndexes.length > 0) {
for (var i = 0; i < table.LocalSecondaryIndexes.length; i++) {
delete table.LocalSecondaryIndexes[i].IndexStatus;
delete table.LocalSecondaryIndexes[i].IndexSizeBytes;
delete table.LocalSecondaryIndexes[i].ItemCount;
delete table.LocalSecondaryIndexes[i].IndexArn;
delete table.LocalSecondaryIndexes[i].LatestStreamLabel;
delete table.LocalSecondaryIndexes[i].LatestStreamArn;
}

@@ -107,13 +110,18 @@ }

if(table.GlobalSecondaryIndexes && table.GlobalSecondaryIndexes.length > 0){
for(var j = 0 ; j < table.GlobalSecondaryIndexes.length ; j++){
delete table.GlobalSecondaryIndexes[j].IndexStatus
delete table.GlobalSecondaryIndexes[j].ProvisionedThroughput.LastIncreaseDateTime
delete table.GlobalSecondaryIndexes[j].ProvisionedThroughput.LastDecreaseDateTime
delete table.GlobalSecondaryIndexes[j].ProvisionedThroughput.NumberOfDecreasesToday
delete table.GlobalSecondaryIndexes[j].IndexSizeBytes
delete table.GlobalSecondaryIndexes[j].ItemCount
delete table.GlobalSecondaryIndexes[j].IndexArn
delete table.GlobalSecondaryIndexes[j].LatestStreamLabel
delete table.GlobalSecondaryIndexes[j].LatestStreamArn
if (table.GlobalSecondaryIndexes && table.GlobalSecondaryIndexes.length > 0) {
for (var j = 0; j < table.GlobalSecondaryIndexes.length; j++) {
delete table.GlobalSecondaryIndexes[j].IndexStatus;
if (table.GlobalSecondaryIndexes[j].ProvisionedThroughput.ReadCapacityUnits === 0 && table.GlobalSecondaryIndexes[j].ProvisionedThroughput.WriteCapacityUnits === 0) {
delete table.GlobalSecondaryIndexes[j].ProvisionedThroughput
}
else {
delete table.GlobalSecondaryIndexes[j].ProvisionedThroughput.LastIncreaseDateTime;
delete table.GlobalSecondaryIndexes[j].ProvisionedThroughput.LastDecreaseDateTime;
delete table.GlobalSecondaryIndexes[j].ProvisionedThroughput.NumberOfDecreasesToday;
}
delete table.GlobalSecondaryIndexes[j].IndexSizeBytes;
delete table.GlobalSecondaryIndexes[j].ItemCount;
delete table.GlobalSecondaryIndexes[j].IndexArn;
delete table.GlobalSecondaryIndexes[j].LatestStreamLabel;
delete table.GlobalSecondaryIndexes[j].LatestStreamArn;
}

@@ -124,25 +132,31 @@ }

table.SSESpecification = {
Enabled: (table.SSEDescription.Status === 'ENABLED' || table.SSEDescription.Status === 'ENABLING')
}
delete table.SSEDescription
Enabled: (table.SSEDescription.Status === 'ENABLED' || table.SSEDescription.Status === 'ENABLING'),
};
delete table.SSEDescription;
}
return table
if (table.BillingModeSummary) {
table.BillingMode = table.BillingModeSummary.BillingMode
}
delete table.BillingModeSummary;
return table;
}
function checkTables(options,fn){
options.source.dynamodb.describeTable({TableName : options.source.tableName},function(err,sourceData){
if(err){
return fn(err,sourceData)
function checkTables(options, fn) {
options.source.dynamodb.describeTable({ TableName: options.source.tableName }, function (err, sourceData) {
if (err) {
return fn(err, sourceData)
}
if(sourceData.Table.TableStatus !== 'ACTIVE'){
return fn(new Error('Source table not active'),null)
if (sourceData.Table.TableStatus !== 'ACTIVE') {
return fn(new Error('Source table not active'), null)
}
options.source.active = true
options.destination.dynamodb.describeTable({TableName : options.destination.tableName},function(err,destData){
if(err){
return fn(err,destData)
options.destination.dynamodb.describeTable({ TableName: options.destination.tableName }, function (err, destData) {
if (err) {
return fn(err, destData)
}
if(destData.Table.TableStatus !== 'ACTIVE'){
return fn(new Error('Destination table not active'),null)
if (destData.Table.TableStatus !== 'ACTIVE') {
return fn(new Error('Destination table not active'), null)
}

@@ -155,7 +169,7 @@ options.destination.active = true

function waitForActive(options,fn){
setTimeout(function(){
options.destination.dynamodb.describeTable({TableName : options.destination.tableName},function(err,data){
if(err){
return fn(err,data)
function waitForActive(options, fn) {
setTimeout(function () {
options.destination.dynamodb.describeTable({ TableName: options.destination.tableName }, function (err, data) {
if (err) {
return fn(err, data)
}

@@ -168,13 +182,14 @@ if (options.log) {

}
if(data.Table.TableStatus !== 'ACTIVE'){ // wait for active
return waitForActive(options,fn)
if (data.Table.TableStatus !== 'ACTIVE') { // wait for active
return waitForActive(options, fn)
}
options.create = false
options.destination.active = true
startCopying(options,fn)
startCopying(options, fn);
})
},1000) // check every second
}, 1000) // check every second
}
function startCopying(options,fn){
function startCopying(options, fn) {
getItems(options, function (err, data) {

@@ -211,3 +226,3 @@ if (err) {

if (err) {
return fn(err,data)
return fn(err, data)
}

@@ -247,3 +262,3 @@ fn(err, mapItems(data))

if (err) {
return fn(err,data)
return fn(err, data)
}

@@ -254,3 +269,3 @@ var unprocessedItems = data.UnprocessedItems[options.destination.tableName]

options.retries++
options.counter += (options.data.Items.length - unprocessedItems.length)
options.counter += (options.data.Items.length - unprocessedItems.length)

@@ -257,0 +272,0 @@ options.data = {

{
"name": "copy-dynamodb-table",
"version": "2.0.17",
"version": "2.0.18",
"description": "Copy Dynamodb table to another in the same or different zone , It is 100% safe , and speed depends on your destination table user defined write provisioned throughput",

@@ -22,5 +22,5 @@ "keywords": [

"dependencies": {
"aws-sdk": "^2.56.0",
"aws-sdk": "^2.630.0",
"readline": "^1.3.0"
}
}
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