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

@xapp/dynamo-service

Package Overview
Dependencies
Maintainers
5
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xapp/dynamo-service - npm Package Compare versions

Comparing version 0.1.13 to 0.1.14

xapp-dynamo-service-0.1.13.tgz

9

CHANGELOG.md

@@ -5,2 +5,11 @@ # Changelog

### [0.1.14](https://github.com/XappMedia/dynamo-service/compare/v0.1.13...v0.1.14) (2019-05-23)
### Bug Fixes
* Allowing nested projections ([0f9fda9](https://github.com/XappMedia/dynamo-service/commit/0f9fda9))
### [0.1.13](https://github.com/XappMedia/dynamo-service/compare/v0.1.12...v0.1.13) (2019-05-22)

@@ -7,0 +16,0 @@

29

dist/service/DynamoService.d.ts

@@ -70,12 +70,27 @@ import { DynamoDB } from "aws-sdk";

update<T>(table: string, key: DynamoDB.DocumentClient.Key, update: UpdateBody<T>, condition: ConditionExpression, returns: UpdateReturnAllType): Promise<T>;
get<T>(table: string, key: DynamoDB.DocumentClient.Key): Promise<T>;
get<T>(table: string, key: DynamoDB.DocumentClient.Key[]): Promise<T[]>;
get<T, P extends keyof T>(table: string, key: DynamoDB.DocumentClient.Key, projection: P | P[]): Promise<Pick<T, P>>;
get<T, P extends keyof T>(table: string, key: DynamoDB.DocumentClient.Key[], projection: P | P[]): Promise<Pick<T, P>[]>;
get<T, P extends keyof T>(table: string, key: DynamoDB.DocumentClient.Key): Promise<T>;
get<T, P extends keyof T>(table: string, key: DynamoDB.DocumentClient.Key[]): Promise<T[]>;
get<T, P extends keyof T>(table: string, key: DynamoDB.DocumentClient.Key, projection: P): Promise<Pick<T, P>>;
get<T, P extends keyof T>(table: string, key: DynamoDB.DocumentClient.Key, projection: P[]): Promise<Pick<T, P>>;
get<T, P extends keyof T>(table: string, key: DynamoDB.DocumentClient.Key[], projection: P): Promise<Pick<T, P>[]>;
get<T, P extends keyof T>(table: string, key: DynamoDB.DocumentClient.Key[], projection: P[]): Promise<Pick<T, P>[]>;
get<T, P extends keyof T>(table: string, key: DynamoDB.DocumentClient.Key, projection: string): Promise<Partial<T>>;
get<T, P extends keyof T>(table: string, key: DynamoDB.DocumentClient.Key, projection: string[]): Promise<Partial<T>>;
get<T, P extends keyof T>(table: string, key: DynamoDB.DocumentClient.Key[], projection: string): Promise<Partial<T>[]>;
get<T, P extends keyof T>(table: string, key: DynamoDB.DocumentClient.Key[], projection: string[]): Promise<Partial<T>[]>;
getAll<T>(tableName: string, key: DynamoDB.DocumentClient.Key[]): Promise<T[]>;
getAll<T, P extends keyof T>(tableName: string, key: DynamoDB.DocumentClient.Key[], projection: P | P[]): Promise<Pick<T, P>[]>;
getAll<T, P extends keyof T>(tableName: string, key: DynamoDB.DocumentClient.Key[], projection: P): Promise<Pick<T, P>[]>;
getAll<T, P extends keyof T>(tableName: string, key: DynamoDB.DocumentClient.Key[], projection: P[]): Promise<Pick<T, P>[]>;
getAll<T>(tableName: string, key: DynamoDB.DocumentClient.Key[], projection: string): Promise<Partial<T>[]>;
getAll<T>(tableName: string, key: DynamoDB.DocumentClient.Key[], projection: string[]): Promise<Partial<T>[]>;
query<T, P extends keyof T>(table: string, myParams: QueryParams): Promise<QueryResult<T>>;
query<T, P extends keyof T>(table: string, myParams: QueryParams, projection: P | P[]): Promise<QueryResult<Pick<T, P>>>;
query<T, P extends keyof T>(table: string, myParams: QueryParams, projection: P): Promise<QueryResult<Pick<T, P>>>;
query<T, P extends keyof T>(table: string, myParams: QueryParams, projection: P[]): Promise<QueryResult<Pick<T, P>>>;
query<T>(table: string, myParams: QueryParams, projection: string): Promise<QueryResult<Partial<T>>>;
query<T>(table: string, myParams: QueryParams, projection: string[]): Promise<QueryResult<Partial<T>>>;
scan<T>(table: string, myParams: ScanParams): Promise<ScanResult<T>>;
scan<T, P extends keyof T>(table: string, myParams: ScanParams, projection: P | P[]): Promise<ScanResult<Pick<T, P>>>;
scan<T, P extends keyof T>(table: string, myParams: ScanParams, projection: P): Promise<ScanResult<Pick<T, P>>>;
scan<T, P extends keyof T>(table: string, myParams: ScanParams, projection: P[]): Promise<ScanResult<Pick<T, P>>>;
scan<T>(table: string, myParams: ScanParams, projection: string): Promise<ScanResult<Partial<T>>>;
scan<T>(table: string, myParams: ScanParams, projection: string[]): Promise<ScanResult<Partial<T>>>;
delete(TableName: string, Key: DynamoDB.DocumentClient.Key | DynamoDB.DocumentClient.Key[]): Promise<void>;

@@ -82,0 +97,0 @@ private batchWrites;

@@ -128,8 +128,6 @@ "use strict";

}
return this.db.scan(params).promise().then((item) => {
return {
Items: item.Items,
LastEvaluatedKey: item.LastEvaluatedKey
};
});
return this.db.scan(params).promise().then((item) => ({
Items: item.Items,
LastEvaluatedKey: item.LastEvaluatedKey
}));
}

@@ -346,10 +344,26 @@ delete(TableName, Key) {

}
const expression = [].concat(projectionExpression);
const lastExpressionIndex = expression.length - 1;
let ProjectionExpression = "";
let ExpressionAttributeNames = {};
const expression = [].concat(projectionExpression);
let keyCount = 0;
expression.forEach((value, index) => {
const key = "#__dynoservice_proj" + index;
ExpressionAttributeNames[key] = value;
ProjectionExpression += key;
if (index < expression.length - 1) {
const splitValues = value.split(".");
const lastSplitValueIndex = splitValues.length - 1;
splitValues.forEach((split, splitIndex) => {
const middleOfSplit = splitIndex < lastSplitValueIndex;
const name = (middleOfSplit) ?
split :
split.replace(/\[\d\]$/, "");
const key = "#__dynoservice_proj" + keyCount++;
ExpressionAttributeNames[key] = name;
ProjectionExpression += key;
if (middleOfSplit) {
ProjectionExpression += ".";
}
if (name.length < split.length) {
ProjectionExpression += split.slice(name.length);
}
});
if (index < lastExpressionIndex) {
ProjectionExpression += ",";

@@ -356,0 +370,0 @@ }

@@ -0,1 +1,2 @@

import { DynamoDB } from "aws-sdk";
import { ConditionExpression, DynamoService, QueryParams, QueryResult, ScanParams, ScanResult, UpdateBody, UpdateReturnAllType, UpdateReturnNoneType, UpdateReturnType, UpdateReturnUpdatedType } from "../DynamoService";

@@ -13,3 +14,6 @@ import { KeySchema, TableSchema } from "../KeySchema";

}
export declare class TableService<T extends object> {
export interface DynamoObject {
[key: string]: DynamoDB.DocumentClient.AttributeValue;
}
export declare class TableService<T extends DynamoObject> {
readonly tableName: string;

@@ -35,10 +39,22 @@ readonly tableSchema: TableSchema<T>;

update(key: Partial<T>, obj: UpdateBody<T>, conditionExpression: ConditionExpression, returnType: UpdateReturnAllType): Promise<T>;
get(key: Partial<T>): Promise<T>;
get(key: Partial<T>[]): Promise<T[]>;
get<P extends keyof T>(key: Partial<T>, projection: P | P[]): Promise<Pick<T, P>>;
get<P extends keyof T>(key: Partial<T>[], projection: P | P[]): Promise<Pick<T, P>[]>;
get<P extends keyof T>(key: Partial<T>): Promise<T>;
get<P extends keyof T>(key: Partial<T>[]): Promise<T[]>;
get<P extends keyof T>(key: Partial<T>, projection: P): Promise<Pick<T, P>>;
get<P extends keyof T>(key: Partial<T>, projection: P[]): Promise<Pick<T, P>>;
get<P extends keyof T>(key: Partial<T>[], projection: P): Promise<Pick<T, P>[]>;
get<P extends keyof T>(key: Partial<T>[], projection: P[]): Promise<Pick<T, P>[]>;
get<P extends keyof T>(key: Partial<T>, projection: string): Promise<Partial<T>>;
get<P extends keyof T>(key: Partial<T>, projection: string[]): Promise<Partial<T>>;
get<P extends keyof T>(key: Partial<T>[], projection: string): Promise<Partial<T>[]>;
get<P extends keyof T>(key: Partial<T>[], projection: string[]): Promise<Partial<T>[]>;
query(params: QueryParams): Promise<QueryResult<T>>;
query<P extends keyof T>(params: QueryParams, projection: P | P[]): Promise<QueryResult<Pick<T, P>>>;
query<P extends keyof T>(params: QueryParams, projection: P): Promise<QueryResult<Pick<T, P>>>;
query<P extends keyof T>(params: QueryParams, projection: P[]): Promise<QueryResult<Pick<T, P>>>;
query(params: QueryParams, projection: string): Promise<QueryResult<Partial<T>>>;
query(params: QueryParams, projection: string[]): Promise<QueryResult<Partial<T>>>;
scan(params: ScanParams): Promise<ScanResult<T>>;
scan<P extends keyof T>(params: ScanParams, projection: P | P[]): Promise<ScanResult<Pick<T, P>>>;
scan<P extends keyof T>(params: ScanParams, projection: P): Promise<ScanResult<Pick<T, P>>>;
scan<P extends keyof T>(params: ScanParams, projection: P[]): Promise<ScanResult<Pick<T, P>>>;
scan(params: ScanParams, projection: string): Promise<ScanResult<Partial<T>>>;
scan(params: ScanParams, projection: string[]): Promise<ScanResult<Partial<T>>>;
delete(key: Partial<T> | Partial<T>[]): Promise<void>;

@@ -45,0 +61,0 @@ private convertObjectsReturnedFromDynamo;

@@ -58,7 +58,8 @@ "use strict";

const realKey = (Array.isArray(key)) ? key.map(key => this.getKey(key)) : this.getKey(key);
const realProjection = projection || this.knownKeys;
return this.db.get(this.tableName, realKey, realProjection).then(item => (item) ? this.convertObjectsReturnedFromDynamo(item) : item);
const realProjection = (projection || this.knownKeys);
return this.db.get(this.tableName, realKey, realProjection)
.then(item => (item) ? this.convertObjectsReturnedFromDynamo(item) : item);
}
query(params, projection) {
const realProjection = projection || this.knownKeys;
const realProjection = (projection || this.knownKeys);
return this.db.query(this.tableName, params, realProjection)

@@ -68,3 +69,3 @@ .then(items => (Object.assign({}, items, { Items: this.convertObjectsReturnedFromDynamo(items.Items) })));

scan(params, projection) {
const realProjection = projection || this.knownKeys;
const realProjection = (projection || this.knownKeys);
return this.db.scan(this.tableName, params, realProjection)

@@ -71,0 +72,0 @@ .then(items => (Object.assign({}, items, { Items: this.convertObjectsReturnedFromDynamo(items.Items) })));

{
"name": "@xapp/dynamo-service",
"version": "0.1.13",
"version": "0.1.14",
"description": "A dynamo help class which will help maintain data integrity.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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