@xapp/dynamo-service
Advanced tools
Comparing version 0.0.64 to 0.0.65
import { ConditionExpression, DynamoService, QueryParams, QueryResult, ScanParams, ScanResult, UpdateBody, UpdateReturnType } from "./DynamoService"; | ||
import { KeySchema, TableSchema } from "./KeySchema"; | ||
export { DynamoService, ConditionExpression, KeySchema, QueryParams, QueryResult, ScanParams, ScanResult, TableSchema, UpdateBody, UpdateReturnType }; | ||
export declare const AWS_COLUMN_REGEX: RegExp; | ||
export interface TableServiceProps { | ||
trimUnknown?: boolean; | ||
trimConstants?: boolean; | ||
ignoreColumnsInGet?: RegExp; | ||
} | ||
@@ -46,2 +48,8 @@ export interface PutAllReturn<T> { | ||
delete(key: Partial<T> | Partial<T>[]): Promise<void>; | ||
private cleanseObjectOfIgnoredGetItems(obj); | ||
private cleanseObjectOfIgnoredGetItems<P>(obj); | ||
private cleanseIgnoredItemsOfDynamoObject(results); | ||
private cleanseIgnoredItemsOfDynamoObject<P>(results); | ||
private cleanseIgnoredItemsOfDynamoObject(results); | ||
private cleanseIgnoredItemsOfDynamoObject<P>(results); | ||
private convertObjectToPutObject(obj); | ||
@@ -48,0 +56,0 @@ private convertObjFromDynamo(dynamoObj); |
@@ -9,2 +9,3 @@ "use strict"; | ||
const slugify = require("slugify"); | ||
exports.AWS_COLUMN_REGEX = /^aws:/; | ||
function getConverter(schema) { | ||
@@ -125,9 +126,15 @@ if (schema.type === "Date") { | ||
get(key, projection) { | ||
return this.db.get(this.tableName, key, projection).then(item => this.convertObjFromDynamo(item)); | ||
return this.db.get(this.tableName, key, projection) | ||
.then(item => this.convertObjFromDynamo(item)) | ||
.then(item => this.cleanseObjectOfIgnoredGetItems(item)); | ||
} | ||
query(params, projection) { | ||
return this.db.query(this.tableName, params, projection).then(items => this.convertObjectsFromDynamo(items)); | ||
return this.db.query(this.tableName, params, projection) | ||
.then(items => this.convertObjectsFromDynamo(items)) | ||
.then(items => this.cleanseIgnoredItemsOfDynamoObject(items)); | ||
} | ||
scan(params, projection) { | ||
return this.db.scan(this.tableName, params, projection).then(items => this.convertObjectsFromDynamo(items)); | ||
return this.db.scan(this.tableName, params, projection) | ||
.then(items => this.convertObjectsFromDynamo(items)) | ||
.then(items => this.cleanseIgnoredItemsOfDynamoObject(items)); | ||
} | ||
@@ -137,2 +144,18 @@ delete(key) { | ||
} | ||
cleanseObjectOfIgnoredGetItems(obj) { | ||
const keys = Object.keys(obj); | ||
const ignoredInGetKeys = (this.props.ignoreColumnsInGet) ? [this.props.ignoreColumnsInGet] : []; | ||
for (let ignored of ignoredInGetKeys) { | ||
for (let key of keys) { | ||
if (ignored.test(key)) { | ||
delete obj[key]; | ||
} | ||
} | ||
} | ||
return obj; | ||
} | ||
cleanseIgnoredItemsOfDynamoObject(results) { | ||
results.Items = results.Items.map(item => this.cleanseObjectOfIgnoredGetItems(item)); | ||
return results; | ||
} | ||
convertObjectToPutObject(obj) { | ||
@@ -139,0 +162,0 @@ let putObj = slugifyKeys(this.slugKeys, obj); |
@@ -5,3 +5,3 @@ export declare const DEFAULT_RETRY_ATTEMPTS = 5; | ||
export declare function backoffObj<T>(obj: T): void; | ||
export declare function backOffFunc<Return>(func: (...args: any[]) => Return | Promise<Return>): (...args: any[]) => Promise<Return>; | ||
export declare function backOffFunc<Return>(func: (...args: any[]) => Return | Promise<Return>, props?: ExecuteProps): (...args: any[]) => Promise<Return>; | ||
export interface ExecuteProps { | ||
@@ -8,0 +8,0 @@ shouldRetry?(e: any): boolean; |
@@ -24,5 +24,5 @@ "use strict"; | ||
exports.backoffObj = backoffObj; | ||
function backOffFunc(func) { | ||
function backOffFunc(func, props) { | ||
return (...args) => { | ||
return backOff(undefined, func, ...args); | ||
return backOff(props, func, ...args); | ||
}; | ||
@@ -29,0 +29,0 @@ } |
{ | ||
"name": "@xapp/dynamo-service", | ||
"version": "0.0.64", | ||
"version": "0.0.65", | ||
"description": "A dynamo help class which will help maintain data integrity.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
143266
3851