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

dynamodb-onetable

Package Overview
Dependencies
Maintainers
1
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dynamodb-onetable - npm Package Compare versions

Comparing version 2.7.2 to 2.7.3

dist/cjs/metrics/test/start.d.ts

4

dist/cjs/Expression.js

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

}
args.ExclusiveStartKey = this.table.marshall(start, params);
if (start[hash]) {
args.ExclusiveStartKey = this.table.marshall(start, params);
}
}

@@ -608,0 +610,0 @@ }

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

const DefaultMetrics = {
chan: 'dbmetrics',
chan: 'dbmetrics', // Default channel
custom: true,

@@ -21,10 +21,10 @@ dimensions: [

],
enable: true,
env: true,
hot: false,
max: 100,
namespace: 'SingleTable/Metrics.1',
period: 60,
properties: {},
source: process.env.AWS_LAMBDA_FUNCTION_NAME || 'Default',
enable: true, // Enabled
env: true, // Observe LOG_FILTER for dbmetrics
hot: false, // Hot partition tracking
max: 100, // Buffer metrics for 100 requests
namespace: 'SingleTable/Metrics.1', // CloudWatch metrics namespace
period: 60, // or buffer for 60 seconds
properties: {}, // Additional properties to emit
source: process.env.AWS_LAMBDA_FUNCTION_NAME || 'Default', // Default source name
tenant: null,

@@ -31,0 +31,0 @@ };

@@ -246,10 +246,27 @@ "use strict";

}
let span = metric.spans.find((s) => period <= s.period);
if (!span) {
span = metric.spans[metric.spans.length - 1];
period = span.period;
let span;
if (options.start) {
span = metric.spans.find((s) => (s.end - s.period) <= options.start / 1000);
if (!span) {
span = metric.spans[metric.spans.length - 1];
period = span.period;
}
}
else {
span = metric.spans.find((s) => period <= s.period);
if (!span) {
span = metric.spans[metric.spans.length - 1];
period = span.period;
}
}
this.addValue(metric, timestamp, { count: 0, sum: 0 }, 0, period);
let result;
if (metric && span) {
if (options.start) {
let interval = span.period / span.samples;
let end = span.points.length - Math.ceil((span.end - (options.start / 1000 + period)) / interval);
let front = end - Math.round(period / interval);
span.end -= (span.points.length - end) * interval;
span.points = span.points.slice(front, end);
}
if (options.accumulate) {

@@ -256,0 +273,0 @@ result = this.accumulateMetric(metric, span, statistic, owner, timestamp);

@@ -260,10 +260,27 @@ "use strict";

}
let span = metric.spans.find((s) => period <= s.period);
if (!span) {
span = metric.spans[metric.spans.length - 1];
period = span.period;
let span;
if (options.start) {
span = metric.spans.find((s) => (s.end - s.period) <= options.start / 1000);
if (!span) {
span = metric.spans[metric.spans.length - 1];
period = span.period;
}
}
else {
span = metric.spans.find((s) => period <= s.period);
if (!span) {
span = metric.spans[metric.spans.length - 1];
period = span.period;
}
}
this.addValue(metric, timestamp, { count: 0, sum: 0 }, 0, period);
let result;
if (metric && span) {
if (options.start) {
let interval = span.period / span.samples;
let end = span.points.length - Math.ceil((span.end - (options.start / 1000 + period)) / interval);
let front = end - Math.round(period / interval);
span.end -= (span.points.length - end) * interval;
span.points = span.points.slice(front, end);
}
if (options.accumulate) {

@@ -270,0 +287,0 @@ result = this.accumulateMetric(metric, span, statistic, owner, timestamp);

@@ -23,3 +23,3 @@ "use strict";

version: { type: 'number', default: Version, encode: ['pk', '#', '1'] },
id: { type: 'string' },
id: { type: 'string' }, // Never stored. Preserved on query
spans: {

@@ -26,0 +26,0 @@ type: 'array',

@@ -44,6 +44,2 @@ import { DynamoDBClient, QueryCommand } from '@aws-sdk/client-dynamodb';

count: number;
max?: number;
min?: number;
pvalues?: number[];
sum?: number;
timestamp?: number;

@@ -106,2 +102,3 @@ value?: number;

owner?: string;
start?: number;
timestamp?: number;

@@ -108,0 +105,0 @@ };

@@ -26,7 +26,7 @@ "use strict";

exports.DefaultSpans = [
{ period: 5 * 60, samples: 10 },
{ period: 60 * 60, samples: 12 },
{ period: 24 * 60 * 60, samples: 12 },
{ period: 7 * 24 * 60 * 60, samples: 14 },
{ period: 28 * 24 * 60 * 60, samples: 14 },
{ period: 5 * 60, samples: 10 }, // 300, 5 mins, interval: 30 secs
{ period: 60 * 60, samples: 12 }, // 3600, 1 hr, interval: 5 mins
{ period: 24 * 60 * 60, samples: 12 }, // 86400, 24 hrs, interval: 2 hrs
{ period: 7 * 24 * 60 * 60, samples: 14 }, // 604,800, 7 days, interval: 1/2 day
{ period: 28 * 24 * 60 * 60, samples: 14 }, // 2,419,200, 28 days, interval: 2 days
{ period: 365 * 24 * 60 * 60, samples: 12 }, // 31,536,000, 1 year, interval: 1 month

@@ -315,11 +315,24 @@ ];

}
/*
Map the period to the closest span that has a period equal or larger.
If the period is too big, then use the largest span period.
*/
let span = metric.spans.find((s) => period <= s.period);
if (!span) {
span = metric.spans[metric.spans.length - 1];
period = span.period;
let span;
if (options.start) {
/*
Map the period that encompasses the start
*/
span = metric.spans.find((s) => (s.end - s.period) <= options.start / 1000);
if (!span) {
span = metric.spans[metric.spans.length - 1];
period = span.period;
}
}
else {
/*
Map the period to the closest span that has a period equal or larger.
If the period is too big, then use the largest span period.
*/
span = metric.spans.find((s) => period <= s.period);
if (!span) {
span = metric.spans[metric.spans.length - 1];
period = span.period;
}
}
/*

@@ -333,2 +346,9 @@ Aggregate data for all spans less than the desired span.

if (metric && span) {
if (options.start) {
let interval = span.period / span.samples;
let end = span.points.length - Math.ceil((span.end - (options.start / 1000 + period)) / interval);
let front = end - Math.round(period / interval);
span.end -= (span.points.length - end) * interval;
span.points = span.points.slice(front, end);
}
if (options.accumulate) {

@@ -335,0 +355,0 @@ result = this.accumulateMetric(metric, span, statistic, owner, timestamp);

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -11,3 +34,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

const client_dynamodb_2 = require("@aws-sdk/client-dynamodb");
const dynamo_db_local_1 = __importDefault(require("dynamo-db-local"));
const DynamoDbLocal = __importStar(require("dynamo-db-local"));
const wait_port_1 = __importDefault(require("wait-port"));

@@ -19,3 +42,3 @@ const PORT = parseInt(process.env.PORT || '4765');

*/
let dynamodb = dynamo_db_local_1.default.spawn({ port: PORT });
let dynamodb = DynamoDbLocal.spawn({ port: PORT });
console.info('\nSpawn DynamoDB', dynamodb.pid);

@@ -22,0 +45,0 @@ await (0, wait_port_1.default)({ host: '0.0.0.0', port: PORT, timeout: 10000 });

@@ -602,3 +602,5 @@ /*

}
args.ExclusiveStartKey = this.table.marshall(start, params);
if (start[hash]) {
args.ExclusiveStartKey = this.table.marshall(start, params);
}
}

@@ -605,0 +607,0 @@ }

@@ -6,3 +6,3 @@ /*

const DefaultMetrics = {
chan: 'dbmetrics',
chan: 'dbmetrics', // Default channel
custom: true,

@@ -18,10 +18,10 @@ dimensions: [

],
enable: true,
env: true,
hot: false,
max: 100,
namespace: 'SingleTable/Metrics.1',
period: 60,
properties: {},
source: process.env.AWS_LAMBDA_FUNCTION_NAME || 'Default',
enable: true, // Enabled
env: true, // Observe LOG_FILTER for dbmetrics
hot: false, // Hot partition tracking
max: 100, // Buffer metrics for 100 requests
namespace: 'SingleTable/Metrics.1', // CloudWatch metrics namespace
period: 60, // or buffer for 60 seconds
properties: {}, // Additional properties to emit
source: process.env.AWS_LAMBDA_FUNCTION_NAME || 'Default', // Default source name
tenant: null,

@@ -28,0 +28,0 @@ };

@@ -246,10 +246,27 @@ "use strict";

}
let span = metric.spans.find((s) => period <= s.period);
if (!span) {
span = metric.spans[metric.spans.length - 1];
period = span.period;
let span;
if (options.start) {
span = metric.spans.find((s) => (s.end - s.period) <= options.start / 1000);
if (!span) {
span = metric.spans[metric.spans.length - 1];
period = span.period;
}
}
else {
span = metric.spans.find((s) => period <= s.period);
if (!span) {
span = metric.spans[metric.spans.length - 1];
period = span.period;
}
}
this.addValue(metric, timestamp, { count: 0, sum: 0 }, 0, period);
let result;
if (metric && span) {
if (options.start) {
let interval = span.period / span.samples;
let end = span.points.length - Math.ceil((span.end - (options.start / 1000 + period)) / interval);
let front = end - Math.round(period / interval);
span.end -= (span.points.length - end) * interval;
span.points = span.points.slice(front, end);
}
if (options.accumulate) {

@@ -256,0 +273,0 @@ result = this.accumulateMetric(metric, span, statistic, owner, timestamp);

@@ -254,10 +254,27 @@ import process from 'process';

}
let span = metric.spans.find((s) => period <= s.period);
if (!span) {
span = metric.spans[metric.spans.length - 1];
period = span.period;
let span;
if (options.start) {
span = metric.spans.find((s) => (s.end - s.period) <= options.start / 1000);
if (!span) {
span = metric.spans[metric.spans.length - 1];
period = span.period;
}
}
else {
span = metric.spans.find((s) => period <= s.period);
if (!span) {
span = metric.spans[metric.spans.length - 1];
period = span.period;
}
}
this.addValue(metric, timestamp, { count: 0, sum: 0 }, 0, period);
let result;
if (metric && span) {
if (options.start) {
let interval = span.period / span.samples;
let end = span.points.length - Math.ceil((span.end - (options.start / 1000 + period)) / interval);
let front = end - Math.round(period / interval);
span.end -= (span.points.length - end) * interval;
span.points = span.points.slice(front, end);
}
if (options.accumulate) {

@@ -264,0 +281,0 @@ result = this.accumulateMetric(metric, span, statistic, owner, timestamp);

@@ -19,3 +19,3 @@ /*

version: { type: 'number', default: Version, encode: ['pk', '#', '1'] },
id: { type: 'string' },
id: { type: 'string' }, // Never stored. Preserved on query
spans: {

@@ -22,0 +22,0 @@ type: 'array',

@@ -44,6 +44,2 @@ import { DynamoDBClient, QueryCommand } from '@aws-sdk/client-dynamodb';

count: number;
max?: number;
min?: number;
pvalues?: number[];
sum?: number;
timestamp?: number;

@@ -106,2 +102,3 @@ value?: number;

owner?: string;
start?: number;
timestamp?: number;

@@ -108,0 +105,0 @@ };

@@ -20,7 +20,7 @@ /*

export const DefaultSpans = [
{ period: 5 * 60, samples: 10 },
{ period: 60 * 60, samples: 12 },
{ period: 24 * 60 * 60, samples: 12 },
{ period: 7 * 24 * 60 * 60, samples: 14 },
{ period: 28 * 24 * 60 * 60, samples: 14 },
{ period: 5 * 60, samples: 10 }, // 300, 5 mins, interval: 30 secs
{ period: 60 * 60, samples: 12 }, // 3600, 1 hr, interval: 5 mins
{ period: 24 * 60 * 60, samples: 12 }, // 86400, 24 hrs, interval: 2 hrs
{ period: 7 * 24 * 60 * 60, samples: 14 }, // 604,800, 7 days, interval: 1/2 day
{ period: 28 * 24 * 60 * 60, samples: 14 }, // 2,419,200, 28 days, interval: 2 days
{ period: 365 * 24 * 60 * 60, samples: 12 }, // 31,536,000, 1 year, interval: 1 month

@@ -309,11 +309,24 @@ ];

}
/*
Map the period to the closest span that has a period equal or larger.
If the period is too big, then use the largest span period.
*/
let span = metric.spans.find((s) => period <= s.period);
if (!span) {
span = metric.spans[metric.spans.length - 1];
period = span.period;
let span;
if (options.start) {
/*
Map the period that encompasses the start
*/
span = metric.spans.find((s) => (s.end - s.period) <= options.start / 1000);
if (!span) {
span = metric.spans[metric.spans.length - 1];
period = span.period;
}
}
else {
/*
Map the period to the closest span that has a period equal or larger.
If the period is too big, then use the largest span period.
*/
span = metric.spans.find((s) => period <= s.period);
if (!span) {
span = metric.spans[metric.spans.length - 1];
period = span.period;
}
}
/*

@@ -327,2 +340,9 @@ Aggregate data for all spans less than the desired span.

if (metric && span) {
if (options.start) {
let interval = span.period / span.samples;
let end = span.points.length - Math.ceil((span.end - (options.start / 1000 + period)) / interval);
let front = end - Math.round(period / interval);
span.end -= (span.points.length - end) * interval;
span.points = span.points.slice(front, end);
}
if (options.accumulate) {

@@ -329,0 +349,0 @@ result = this.accumulateMetric(metric, span, statistic, owner, timestamp);

@@ -6,3 +6,3 @@ /*

import { CreateTableCommand, DescribeTableCommand } from '@aws-sdk/client-dynamodb';
import DynamoDbLocal from 'dynamo-db-local';
import * as DynamoDbLocal from 'dynamo-db-local';
import waitPort from 'wait-port';

@@ -9,0 +9,0 @@ const PORT = parseInt(process.env.PORT || '4765');

{
"name": "dynamodb-onetable",
"version": "2.7.2",
"version": "2.7.3",
"description": "DynamoDB access library for single-table designs",

@@ -47,19 +47,19 @@ "main": "dist/cjs/index.js",

"dependencies": {
"@aws-sdk/client-dynamodb": "^3.410.0",
"@aws-sdk/util-dynamodb": "^3.410.0",
"custom-metrics": "^0.8.1"
"@aws-sdk/client-dynamodb": "^3.598.0",
"@aws-sdk/util-dynamodb": "^3.598.0",
"custom-metrics": "^1.0.1"
},
"devDependencies": {
"@types/aws-lambda": "^8.10.120",
"@types/jest": "^29.5.4",
"@types/node": "^20.6.0",
"aws-sdk": "^2.1456.0",
"@types/aws-lambda": "^8.10.138",
"@types/jest": "^29.5.12",
"@types/node": "^20.14.2",
"aws-sdk": "^2.1642.0",
"dataloader": "^2.2.2",
"dynamo-db-local": "^7.0.0",
"eslint": "^8.49.0",
"dynamo-db-local": "^9.1.1",
"eslint": "^9.5.0",
"jest": "^29.7.0",
"ts-jest": "^29.1.1",
"typescript": "^5.2.2",
"utility-types": "^3.10.0",
"wait-port": "^1.0.4"
"ts-jest": "^29.1.5",
"typescript": "^5.4.5",
"utility-types": "^3.11.0",
"wait-port": "^1.1.0"
},

@@ -66,0 +66,0 @@ "files": [

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

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