@xapp/dynamo-service
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -5,2 +5,11 @@ # Changelog | ||
## [1.4.0](https://github.com/XappMedia/dynamo-service/compare/v1.3.0...v1.4.0) (2019-09-24) | ||
### Features | ||
* putAll in TableService now includes processed items. ([882da92](https://github.com/XappMedia/dynamo-service/commit/882da92)) | ||
## [1.3.0](https://github.com/XappMedia/dynamo-service/compare/v1.2.0...v1.3.0) (2019-08-26) | ||
@@ -7,0 +16,0 @@ |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -8,0 +9,0 @@ }); |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -137,3 +138,3 @@ }); | ||
const queriedItem = yield get({ [testTable.PrimaryKey]: Item[testTable.PrimaryKey] }); | ||
expect(queriedItem.Item).to.deep.equal(Object.assign({}, Item, { "TestAttribute": "This is a transformed object." })); | ||
expect(queriedItem.Item).to.deep.equal(Object.assign(Object.assign({}, Item), { "TestAttribute": "This is a transformed object." })); | ||
})); | ||
@@ -162,3 +163,3 @@ it("Tests that an error is thrown if the interceptor doesn't return anything.", () => __awaiter(this, void 0, void 0, function* () { | ||
Keys.push(newKey); | ||
items.push(Object.assign({}, newKey, { Param1: "One", param2: 2 })); | ||
items.push(Object.assign(Object.assign({}, newKey), { Param1: "One", param2: 2 })); | ||
} | ||
@@ -171,3 +172,3 @@ const unprocessed = yield service.put(testTable.TableName, items); | ||
expect(found).to.exist; | ||
expect(found.Item).to.deep.equal(Object.assign({}, key, { Param1: "One", param2: 2 })); | ||
expect(found.Item).to.deep.equal(Object.assign(Object.assign({}, key), { Param1: "One", param2: 2 })); | ||
++count; | ||
@@ -183,3 +184,3 @@ } | ||
Keys.push(newKey); | ||
items.push(Object.assign({}, newKey, { Param1: "One", param2: 2 })); | ||
items.push(Object.assign(Object.assign({}, newKey), { Param1: "One", param2: 2 })); | ||
} | ||
@@ -201,3 +202,3 @@ yield service.put(testTable.TableName, items); | ||
Keys.push(newKey); | ||
items.push(Object.assign({}, newKey, { Param1: "One", param2: 2 })); | ||
items.push(Object.assign(Object.assign({}, newKey), { Param1: "One", param2: 2 })); | ||
} | ||
@@ -210,3 +211,3 @@ const unprocessed = yield service.put(testTable.TableName, items); | ||
expect(found).to.exist; | ||
expect(found.Item).to.deep.equal(Object.assign({}, key, { Param1: "One", param2: 2, "TestArg": "This is an argument transformed on to the object." })); | ||
expect(found.Item).to.deep.equal(Object.assign(Object.assign({}, key), { Param1: "One", param2: 2, "TestArg": "This is an argument transformed on to the object." })); | ||
++count; | ||
@@ -243,3 +244,3 @@ } | ||
Keys.push(newKey); | ||
items.push(Object.assign({}, newKey, { Param1: "One", param2: 2 })); | ||
items.push(Object.assign(Object.assign({}, newKey), { Param1: "One", param2: 2 })); | ||
} | ||
@@ -262,4 +263,4 @@ const unprocessed = yield service.put(testTable.TableName, items, { attempts: 3 }); | ||
Key2 = { [testTable.PrimaryKey]: getPrimary() }; | ||
Item = Object.assign({}, Key, { Param1: "One", parm2: 2, Nested: { param1: "FirstParam", param2: "SecondParam", param3: "ThirdParam" } }); | ||
Item2 = Object.assign({}, Key2, { Param1: "One2", parm2: 22, ArrayItem: ["One", "Two", "Three"], Nested: { ArrayItem: ["One", "Two", "Three"] } }); | ||
Item = Object.assign(Object.assign({}, Key), { Param1: "One", parm2: 2, Nested: { param1: "FirstParam", param2: "SecondParam", param3: "ThirdParam" } }); | ||
Item2 = Object.assign(Object.assign({}, Key2), { Param1: "One2", parm2: 22, ArrayItem: ["One", "Two", "Three"], Nested: { ArrayItem: ["One", "Two", "Three"] } }); | ||
yield client.put({ TableName, Item }).promise(); | ||
@@ -328,4 +329,4 @@ yield client.put({ TableName, Item: Item2 }).promise(); | ||
Key2 = { [testTable.PrimaryKey]: getPrimary() }; | ||
Item = Object.assign({}, Key, { Param1: "One", parm2: 2 }); | ||
Item2 = Object.assign({}, Key2, { Param1: "One2", parm2: 22 }); | ||
Item = Object.assign(Object.assign({}, Key), { Param1: "One", parm2: 2 }); | ||
Item2 = Object.assign(Object.assign({}, Key2), { Param1: "One2", parm2: 22 }); | ||
yield client.put({ TableName, Item }).promise(); | ||
@@ -355,3 +356,3 @@ yield client.put({ TableName, Item: Item2 }).promise(); | ||
}; | ||
Item = Object.assign({}, Key, { StringParam1: "One", NumberParam1: 2, ObjParam1: { Param: "Value" }, ObjParam2: { Param1: "Value1", Param2: "Value2" }, ListParam1: [1, 2, 3, 4, 5, 6], NestedLIstParam1: { | ||
Item = Object.assign(Object.assign({}, Key), { StringParam1: "One", NumberParam1: 2, ObjParam1: { Param: "Value" }, ObjParam2: { Param1: "Value1", Param2: "Value2" }, ListParam1: [1, 2, 3, 4, 5, 6], NestedLIstParam1: { | ||
list: [{ | ||
@@ -377,3 +378,3 @@ param1: "Value", | ||
const newItem = yield service.update(testTable.TableName, Key, { set: { StringParam1: "Zero" } }, "ALL_NEW"); | ||
const updatedItem = Object.assign({}, Item, { StringParam1: "Zero" }); | ||
const updatedItem = Object.assign(Object.assign({}, Item), { StringParam1: "Zero" }); | ||
expect(newItem).to.deep.equal(updatedItem); | ||
@@ -497,3 +498,3 @@ })); | ||
const newItem = yield service.update(testTable.TableName, Key, { set: { StringParam1: "Zero" } }, ConditionExpression, "ALL_NEW"); | ||
const updatedItem = Object.assign({}, Item, { StringParam1: "Zero" }); | ||
const updatedItem = Object.assign(Object.assign({}, Item), { StringParam1: "Zero" }); | ||
expect(newItem).to.deep.equal(updatedItem); | ||
@@ -574,3 +575,3 @@ })); | ||
Keys.push({ [sortedTable.PrimaryKey]: primaryKey, [sortedTable.SortKey]: getSort(i) }); | ||
Items.push(Object.assign({}, Keys[i], { Param1: "One", param2: 2 })); | ||
Items.push(Object.assign(Object.assign({}, Keys[i]), { Param1: "One", param2: 2 })); | ||
RequestItems[SortedTableName].push({ | ||
@@ -762,3 +763,3 @@ PutRequest: { | ||
TableName: testTable.TableName, | ||
Item: Object.assign({}, Key, { StringParam1: "One", NumberParam1: 2, ObjParam1: { Param: "Value" }, ListParam1: [1, 2, 3, 4, 5, 6] }) | ||
Item: Object.assign(Object.assign({}, Key), { StringParam1: "One", NumberParam1: 2, ObjParam1: { Param: "Value" }, ListParam1: [1, 2, 3, 4, 5, 6] }) | ||
}).promise(); | ||
@@ -792,3 +793,3 @@ })); | ||
TableName: testTable.TableName, | ||
Item: Object.assign({}, Key, { StringParam1: "One", NumberParam1: 2, ObjParam1: { Param: "Value" }, ListParam1: [1, 2, 3, 4, 5, 6] }) | ||
Item: Object.assign(Object.assign({}, Key), { StringParam1: "One", NumberParam1: 2, ObjParam1: { Param: "Value" }, ListParam1: [1, 2, 3, 4, 5, 6] }) | ||
}).promise(); | ||
@@ -795,0 +796,0 @@ Keys.push(Key); |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -61,6 +62,6 @@ }); | ||
if (conditionExpression.ExpressionAttributeNames) { | ||
params.ExpressionAttributeNames = Object.assign({}, params.ExpressionAttributeNames, conditionExpression.ExpressionAttributeNames); | ||
params.ExpressionAttributeNames = Object.assign(Object.assign({}, params.ExpressionAttributeNames), conditionExpression.ExpressionAttributeNames); | ||
} | ||
if (conditionExpression.ExpressionAttributeValues) { | ||
params.ExpressionAttributeValues = Object.assign({}, params.ExpressionAttributeValues, conditionExpression.ExpressionAttributeValues); | ||
params.ExpressionAttributeValues = Object.assign(Object.assign({}, params.ExpressionAttributeValues), conditionExpression.ExpressionAttributeValues); | ||
} | ||
@@ -102,3 +103,3 @@ } | ||
const proj = getProjectionExpression(projection); | ||
params.ExpressionAttributeNames = Object.assign({}, proj.ExpressionAttributeNames, params.ExpressionAttributeNames); | ||
params.ExpressionAttributeNames = Object.assign(Object.assign({}, proj.ExpressionAttributeNames), params.ExpressionAttributeNames); | ||
params.ProjectionExpression = proj.ProjectionExpression; | ||
@@ -139,3 +140,3 @@ } | ||
const proj = getProjectionExpression(projection); | ||
params.ExpressionAttributeNames = Object.assign({}, proj.ExpressionAttributeNames, params.ExpressionAttributeNames); | ||
params.ExpressionAttributeNames = Object.assign(Object.assign({}, proj.ExpressionAttributeNames), params.ExpressionAttributeNames); | ||
params.ProjectionExpression = proj.ProjectionExpression; | ||
@@ -320,3 +321,3 @@ } | ||
if (Object_1.objHasAttrs(setValues)) { | ||
returnValue = Object.assign({}, returnValue, { ExpressionAttributeValues: setValues }); | ||
returnValue = Object.assign(Object.assign({}, returnValue), { ExpressionAttributeValues: setValues }); | ||
} | ||
@@ -328,3 +329,3 @@ if (Object_1.objHasAttrs(setAliasMap)) { | ||
}, {}); | ||
returnValue = Object.assign({}, returnValue, { ExpressionAttributeNames }); | ||
returnValue = Object.assign(Object.assign({}, returnValue), { ExpressionAttributeNames }); | ||
} | ||
@@ -409,3 +410,3 @@ return returnValue; | ||
} | ||
return Object.assign({}, body, { set, remove }); | ||
return Object.assign(Object.assign({}, body), { set, remove }); | ||
} |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -50,3 +51,3 @@ }); | ||
describe(Service.TableService.prototype.put.name, () => { | ||
it("Tests that the item is put.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the item is put.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema(); | ||
@@ -60,3 +61,3 @@ const service = new Service.TableService(tableName, dynamoService, schema); | ||
})); | ||
it("Tests that an item is put even if it doesn't contain optional items.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that an item is put even if it doesn't contain optional items.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema({ optionalParam: { type: "S" } }); | ||
@@ -70,3 +71,3 @@ const service = new Service.TableService(tableName, dynamoService, schema); | ||
})); | ||
it("Tests that a schema is converted.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that a schema is converted.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema({ "stringParam": { type: "S", slugify: true } }); | ||
@@ -77,3 +78,3 @@ const service = new Service.TableService(tableName, dynamoService, schema); | ||
})); | ||
it("Tests that the condition expression is passed.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the condition expression is passed.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema({ "stringParam": { type: "S" } }); | ||
@@ -92,3 +93,3 @@ const service = new Service.TableService(tableName, dynamoService, schema); | ||
})); | ||
it("Tests that the sort key is added to the condition.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the sort key is added to the condition.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema({ "stringParam": { type: "S", sort: true } }); | ||
@@ -102,3 +103,3 @@ const service = new Service.TableService(tableName, dynamoService, schema); | ||
})); | ||
it("Throws an error if the put object is bad.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Throws an error if the put object is bad.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema({ "stringParam": { type: "S", sort: true } }); | ||
@@ -113,3 +114,3 @@ const service = new Service.TableService(tableName, dynamoService, schema); | ||
describe(Service.TableService.prototype.putAll.name, () => { | ||
it("Tests that all the items were put.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that all the items were put.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema(); | ||
@@ -121,3 +122,3 @@ const service = new Service.TableService(tableName, dynamoService, schema); | ||
})); | ||
it("Tests that all items returned from the unprocessed column are converted back.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that all items returned from the unprocessed column are converted back.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const expectedDate = new Date(); | ||
@@ -132,2 +133,3 @@ const schema = buildTableSchema({ createdAt: { type: "Date" } }); | ||
expect(result).to.deep.equal({ | ||
processed: [], | ||
unprocessed: [{ | ||
@@ -139,3 +141,57 @@ primaryKey: "TestKey", | ||
})); | ||
it("Tests that an error is thrown if one of the objects doesn't match the validation.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that all items not returned (i.e. they were processed) are put in the 'processed' attribute.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const expectedDate = new Date(); | ||
const schema = buildTableSchema({ createdAt: { type: "Date" } }); | ||
const service = new Service.TableService(tableName, dynamoService, schema); | ||
dynamoService.put.returns(Promise.resolve([{ | ||
primaryKey: "TestKey", | ||
createdAt: expectedDate.toISOString() | ||
}, { | ||
primaryKey: "TestKey3", | ||
createdAt: expectedDate.toISOString() | ||
}])); | ||
const result = yield service.putAll([ | ||
{ "primaryKey": "TestKey", createdAt: expectedDate }, | ||
{ "primaryKey": "TestKey2", createdAt: expectedDate }, | ||
{ "primaryKey": "TestKey3", createdAt: expectedDate } | ||
]); | ||
expect(result).to.deep.equal({ | ||
processed: [{ | ||
primaryKey: "TestKey2", | ||
createdAt: expectedDate | ||
}], | ||
unprocessed: [{ | ||
primaryKey: "TestKey", | ||
createdAt: expectedDate | ||
}, { | ||
primaryKey: "TestKey3", | ||
createdAt: expectedDate | ||
}] | ||
}); | ||
})); | ||
it("Tests that items without sort keys are handled.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema({}); | ||
const service = new Service.TableService(tableName, dynamoService, schema); | ||
dynamoService.put.returns(Promise.resolve([{ | ||
primaryKey: "TestKey" | ||
}, { | ||
primaryKey: "TestKey3" | ||
}])); | ||
const result = yield service.putAll([ | ||
{ "primaryKey": "TestKey" }, | ||
{ "primaryKey": "TestKey2" }, | ||
{ "primaryKey": "TestKey3" } | ||
]); | ||
expect(result).to.deep.equal({ | ||
processed: [{ | ||
primaryKey: "TestKey2" | ||
}], | ||
unprocessed: [{ | ||
primaryKey: "TestKey" | ||
}, { | ||
primaryKey: "TestKey3" | ||
}] | ||
}); | ||
})); | ||
it("Tests that an error is thrown if one of the objects doesn't match the validation.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema({ sortKey: { type: "S", sort: true } }); | ||
@@ -148,3 +204,3 @@ const service = new Service.TableService(tableName, dynamoService, schema); | ||
describe(Service.TableService.prototype.update.name, () => { | ||
it("Tests that the update object was passed to the service.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the update object was passed to the service.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema(); | ||
@@ -161,3 +217,3 @@ const service = new Service.TableService(tableName, dynamoService, schema); | ||
})); | ||
it("Tests that the object is converted before inserting.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the object is converted before inserting.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema({ stringParam: { type: "S", slugify: true } }); | ||
@@ -174,3 +230,3 @@ const service = new Service.TableService(tableName, dynamoService, schema); | ||
})); | ||
it("Tests that the object returned is converted from the Dynamo style.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the object returned is converted from the Dynamo style.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const expectedDate = new Date(); | ||
@@ -189,3 +245,3 @@ const schema = buildTableSchema({ dateParam: { type: "Date" } }); | ||
})); | ||
it("Tests that an error is thrown if the update object doesn't pass validation.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that an error is thrown if the update object doesn't pass validation.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema({ stringParam: { type: "S", invalidCharacters: ":" } }); | ||
@@ -197,3 +253,3 @@ const service = new Service.TableService(tableName, dynamoService, schema); | ||
describe(Service.TableService.prototype.get.name, () => { | ||
it("Tests that the item is got.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the item is got.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema(); | ||
@@ -205,3 +261,3 @@ const service = new Service.TableService(tableName, dynamoService, schema); | ||
})); | ||
it("Tests that the callback is called with the key.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the callback is called with the key.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema(); | ||
@@ -213,3 +269,3 @@ const service = new Service.TableService(tableName, dynamoService, schema); | ||
})); | ||
it("Tests that the excess objects are cleared from the key.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the excess objects are cleared from the key.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema({ sortKey: { type: "S", sort: true } }); | ||
@@ -223,3 +279,3 @@ const service = new Service.TableService(tableName, dynamoService, schema); | ||
})); | ||
it("Tests that the callback is called with the array of keys.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the callback is called with the array of keys.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema(); | ||
@@ -231,3 +287,3 @@ const service = new Service.TableService(tableName, dynamoService, schema); | ||
})); | ||
it("Tests that the known items are projected on teh columns by default.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the known items are projected on teh columns by default.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema({ param1: { type: "S" }, param2: { type: "S" } }); | ||
@@ -238,3 +294,3 @@ const service = new Service.TableService(tableName, dynamoService, schema); | ||
})); | ||
it("Tests that the projection is passed to the service.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the projection is passed to the service.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema({ param1: { type: "S" }, param2: { type: "S" } }); | ||
@@ -247,3 +303,3 @@ const service = new Service.TableService(tableName, dynamoService, schema); | ||
describe(Service.TableService.prototype.query.name, () => { | ||
it("Tests that the items are queried with default projection.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the items are queried with default projection.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema({ param1: { type: "S" }, param2: { type: "S" } }); | ||
@@ -262,3 +318,3 @@ const service = new Service.TableService(tableName, dynamoService, schema); | ||
})); | ||
it("Tests that the updated projection is used.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the updated projection is used.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema({ param1: { type: "S" }, param2: { type: "S" } }); | ||
@@ -277,3 +333,3 @@ const service = new Service.TableService(tableName, dynamoService, schema); | ||
})); | ||
it("Tests that the object is converted from the dynamodb roots.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the object is converted from the dynamodb roots.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema({ dateParam: { type: "Date" } }); | ||
@@ -302,3 +358,3 @@ const service = new Service.TableService(tableName, dynamoService, schema); | ||
describe(Service.TableService.prototype.scan.name, () => { | ||
it("Tests that the items are queried with default projection.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the items are queried with default projection.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema({ param1: { type: "S" }, param2: { type: "S" } }); | ||
@@ -317,3 +373,3 @@ const service = new Service.TableService(tableName, dynamoService, schema); | ||
})); | ||
it("Tests that the updated projection is used.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the updated projection is used.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema({ param1: { type: "S" }, param2: { type: "S" } }); | ||
@@ -332,3 +388,3 @@ const service = new Service.TableService(tableName, dynamoService, schema); | ||
})); | ||
it("Tests that the object is converted from the dynamodb roots.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the object is converted from the dynamodb roots.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema({ dateParam: { type: "Date" } }); | ||
@@ -357,3 +413,3 @@ const service = new Service.TableService(tableName, dynamoService, schema); | ||
describe(Service.TableService.prototype.delete.name, () => { | ||
it("Tests that the delete function gets the appropriate key.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the delete function gets the appropriate key.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema({ sortParam: { type: "S", sort: true } }); | ||
@@ -367,3 +423,3 @@ const service = new Service.TableService(tableName, dynamoService, schema); | ||
})); | ||
it("Tests that the delete function gets the appropriate keys of an array.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the delete function gets the appropriate keys of an array.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const schema = buildTableSchema({ sortParam: { type: "S", sort: true } }); | ||
@@ -370,0 +426,0 @@ const service = new Service.TableService(tableName, dynamoService, schema); |
@@ -6,3 +6,3 @@ "use strict"; | ||
function booleanSchemaBuilder(key, schema) { | ||
return new BooleanSchemaBuilder_1.default(key, Object.assign({}, schema, { type: "BOOL" })); | ||
return new BooleanSchemaBuilder_1.default(key, Object.assign(Object.assign({}, schema), { type: "BOOL" })); | ||
} | ||
@@ -9,0 +9,0 @@ describe(BooleanSchemaBuilder_1.default.name, () => { |
@@ -8,6 +8,6 @@ "use strict"; | ||
function isoSchemaBuilder(key, schema) { | ||
return new DateSchemaBuilder_1.default(key, Object.assign({}, schema, { type: "Date", dateFormat: "ISO-8601" })); | ||
return new DateSchemaBuilder_1.default(key, Object.assign(Object.assign({}, schema), { type: "Date", dateFormat: "ISO-8601" })); | ||
} | ||
function timestampSchemaBuilder(key, schema) { | ||
return new DateSchemaBuilder_1.default(key, Object.assign({}, schema, { type: "Date", dateFormat: "Timestamp" })); | ||
return new DateSchemaBuilder_1.default(key, Object.assign(Object.assign({}, schema), { type: "Date", dateFormat: "Timestamp" })); | ||
} | ||
@@ -14,0 +14,0 @@ describe("DateSchemaBuilder", () => { |
@@ -6,3 +6,3 @@ "use strict"; | ||
function listSchemaBuilder(key, schema) { | ||
return new ListSchemaBuilder_1.default(key, Object.assign({}, schema, { type: "L" })); | ||
return new ListSchemaBuilder_1.default(key, Object.assign(Object.assign({}, schema), { type: "L" })); | ||
} | ||
@@ -9,0 +9,0 @@ describe(ListSchemaBuilder_1.default.name, () => { |
@@ -9,3 +9,3 @@ "use strict"; | ||
function mapSchemaBuilder(key, schema) { | ||
return new MapSchemaBuilder_1.default(key, Object.assign({}, schema, { type: "M" })); | ||
return new MapSchemaBuilder_1.default(key, Object.assign(Object.assign({}, schema), { type: "M" })); | ||
} | ||
@@ -12,0 +12,0 @@ describe(MapSchemaBuilder_1.default.name, () => { |
@@ -26,3 +26,3 @@ "use strict"; | ||
const parameters = schemas[type]; | ||
const typeSchema = Object.assign({}, parameters, remainingParameters, { type }); | ||
const typeSchema = Object.assign(Object.assign(Object.assign({}, parameters), remainingParameters), { type }); | ||
this.schemas.push(typeSchema); | ||
@@ -29,0 +29,0 @@ this.schemaBuilders[type] = SchemaBuilder_1.getSchemaBuilder(key, typeSchema); |
@@ -11,3 +11,3 @@ "use strict"; | ||
buildNormalSchemaTests({ | ||
schemaBuilder: (key, schema) => new NormalSchemaBuilder_1.default(key, Object.assign({}, schema, { type: "Anything" })), | ||
schemaBuilder: (key, schema) => new NormalSchemaBuilder_1.default(key, Object.assign(Object.assign({}, schema), { type: "Anything" })), | ||
}); | ||
@@ -14,0 +14,0 @@ }); |
@@ -55,3 +55,3 @@ "use strict"; | ||
} | ||
return this.convertObjectFromJavascript(Object.assign({}, baseObject, { [this.key]: current })); | ||
return this.convertObjectFromJavascript(Object.assign(Object.assign({}, baseObject), { [this.key]: current })); | ||
} | ||
@@ -85,3 +85,3 @@ convertUpdateObjectToSchema(baseObject) { | ||
} | ||
return Object.assign({}, baseObject, { [this.key]: current }); | ||
return Object.assign(Object.assign({}, baseObject), { [this.key]: current }); | ||
} | ||
@@ -88,0 +88,0 @@ convertObjectToJavascript(dynamoBaseObject) { |
@@ -6,3 +6,3 @@ "use strict"; | ||
function numberSchemaBuilder(key, schema) { | ||
return new NumberSchemaBuilder_1.default(key, Object.assign({}, schema, { type: "N" })); | ||
return new NumberSchemaBuilder_1.default(key, Object.assign(Object.assign({}, schema), { type: "N" })); | ||
} | ||
@@ -9,0 +9,0 @@ describe(NumberSchemaBuilder_1.default.name, () => { |
@@ -8,3 +8,3 @@ "use strict"; | ||
function schemaBuilder(key, schema) { | ||
return new StringSchemaBuilder_1.default(key, Object.assign({}, schema, { type: "S" })); | ||
return new StringSchemaBuilder_1.default(key, Object.assign(Object.assign({}, schema), { type: "S" })); | ||
} | ||
@@ -11,0 +11,0 @@ describe("StringSchemaBuilder", () => { |
@@ -11,2 +11,3 @@ import { DynamoDB } from "aws-sdk"; | ||
export interface PutAllReturn<T> { | ||
processed: T[]; | ||
unprocessed: T[]; | ||
@@ -13,0 +14,0 @@ } |
@@ -44,3 +44,8 @@ "use strict"; | ||
.then((unprocessed) => ({ | ||
unprocessed: this.convertObjectsReturnedFromDynamo(unprocessed) | ||
unprocessed: unprocessed, | ||
processed: putObjs.filter((po) => !unprocessed.find(up => up[this.primaryKey] === po[this.primaryKey] && | ||
up[this.sortKey] === po[this.sortKey])) | ||
})).then((result) => ({ | ||
unprocessed: this.convertObjectsReturnedFromDynamo(result.unprocessed), | ||
processed: this.convertObjectsReturnedFromDynamo(result.processed) | ||
})); | ||
@@ -64,3 +69,3 @@ } | ||
return this.db.query(this.tableName, params, realProjection) | ||
.then(items => (Object.assign({}, items, { Items: this.convertObjectsReturnedFromDynamo(items.Items) }))); | ||
.then(items => (Object.assign(Object.assign({}, items), { Items: this.convertObjectsReturnedFromDynamo(items.Items) }))); | ||
} | ||
@@ -73,3 +78,3 @@ count(params) { | ||
return this.db.scan(this.tableName, params, realProjection) | ||
.then(items => (Object.assign({}, items, { Items: this.convertObjectsReturnedFromDynamo(items.Items) }))); | ||
.then(items => (Object.assign(Object.assign({}, items), { Items: this.convertObjectsReturnedFromDynamo(items.Items) }))); | ||
} | ||
@@ -76,0 +81,0 @@ delete(key) { |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -44,3 +45,3 @@ }); | ||
describe("backoff", () => { | ||
it("Tests that the callback is called.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the callback is called.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const callback = Sinon.stub(); | ||
@@ -50,3 +51,3 @@ yield Backoff.backOff(undefined, callback); | ||
})); | ||
it("Tests that the callback gets the arguments passed.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the callback gets the arguments passed.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const callback = Sinon.stub(); | ||
@@ -56,3 +57,3 @@ yield Backoff.backOff(undefined, callback, "One", 2, "Three", { Four: "Five" }); | ||
})); | ||
it("Tests that the result of a promise is returned.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the result of a promise is returned.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const callback = Sinon.stub(); | ||
@@ -63,3 +64,3 @@ callback.returns(Promise.resolve(2)); | ||
})); | ||
it("Tests that the result is returned.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the result is returned.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const callback = Sinon.stub(); | ||
@@ -70,3 +71,3 @@ callback.returns(3); | ||
})); | ||
it("Tests that the back off retries each time.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the back off retries each time.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const callback = Sinon.stub(); | ||
@@ -83,3 +84,3 @@ callback.callsFake(() => Promise.reject(new Error("Error per requirement of the test."))); | ||
})); | ||
it("Tests that the error thrown by the callback is thrown by the backoff.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the error thrown by the callback is thrown by the backoff.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const callback = Sinon.stub(); | ||
@@ -99,3 +100,3 @@ const error = new Error("Error per requirement of the test."); | ||
})); | ||
it("Tests that the retries can be overridden.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the retries can be overridden.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const callback = Sinon.stub(); | ||
@@ -113,3 +114,3 @@ callback.callsFake(() => Promise.reject(new Error("Error per requirement of the test."))); | ||
})); | ||
it("Tests that the shouldRetry", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the shouldRetry", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const error = new Error("Error per requirement of the test."); | ||
@@ -142,3 +143,3 @@ const callback = Sinon.stub(); | ||
}); | ||
it("Tests that the promise func returns the correct value.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the promise func returns the correct value.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const backoff = Backoff.backOffFunc(promiseFunc1); | ||
@@ -148,3 +149,3 @@ const value = yield backoff(1, 2, 3, 4, 5); | ||
})); | ||
it("Tests that the promise func to be called with the correct values.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the promise func to be called with the correct values.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const backoff = Backoff.backOffFunc(promiseFunc1); | ||
@@ -154,3 +155,3 @@ yield backoff(1, 2, 3, 4, 5); | ||
})); | ||
it("Tests that the results func to return correct values.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the results func to return correct values.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const backoff = Backoff.backOffFunc(resultFunc1); | ||
@@ -160,3 +161,3 @@ const value = yield backoff(1, 2, 3, 4, 5); | ||
})); | ||
it("Tests that the reject func throws an error.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the reject func throws an error.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const backoff = Backoff.backOffFunc(rejectFunc1); | ||
@@ -173,3 +174,3 @@ let caughtError; | ||
})); | ||
it("Tests that the throws func throws an error.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the throws func throws an error.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const backoff = Backoff.backOffFunc(throwsFunc1); | ||
@@ -186,3 +187,3 @@ let caughtError; | ||
})); | ||
it("Tests that the retry strategy is called with the props.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the retry strategy is called with the props.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const retryStrat = Sinon.stub(); | ||
@@ -219,3 +220,3 @@ retryStrat.onFirstCall().returns(true); | ||
}); | ||
it("Tests that the promiseFunc1 gets called with the appropriate parameters.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the promiseFunc1 gets called with the appropriate parameters.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const copy = Object.assign({}, obj); | ||
@@ -226,3 +227,3 @@ Backoff.backoffObj(copy); | ||
})); | ||
it("Tests that the promiseFunc1 result is captured which returns a Promise.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the promiseFunc1 result is captured which returns a Promise.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const copy = Object.assign({}, obj); | ||
@@ -233,3 +234,3 @@ Backoff.backoffObj(copy); | ||
})); | ||
it("Tests that the objectFunc1 result is captured which returns a straight object.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the objectFunc1 result is captured which returns a straight object.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const copy = Object.assign({}, obj); | ||
@@ -240,3 +241,3 @@ Backoff.backoffObj(copy); | ||
})); | ||
it("Tests that the backoff is called with a failing function.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the backoff is called with a failing function.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const copy = Object.assign({}, obj); | ||
@@ -254,3 +255,3 @@ Backoff.backoffObj(copy); | ||
})); | ||
it("Tests that the backoff is called with a throwing function.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("Tests that the backoff is called with a throwing function.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const copy = Object.assign({}, obj); | ||
@@ -257,0 +258,0 @@ Backoff.backoffObj(copy); |
@@ -188,3 +188,3 @@ "use strict"; | ||
try { | ||
Utils.throwIfDoesNotContain(Object.assign({}, testObj, { param1: undefined }), ["param1"]); | ||
Utils.throwIfDoesNotContain(Object.assign(Object.assign({}, testObj), { param1: undefined }), ["param1"]); | ||
} | ||
@@ -191,0 +191,0 @@ catch (e) { |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -15,3 +16,3 @@ }); | ||
describe("Sleep", () => { | ||
it("It tests that it does pause execution a bit.", () => __awaiter(this, void 0, void 0, function* () { | ||
it("It tests that it does pause execution a bit.", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const time = new Date().getTime(); | ||
@@ -18,0 +19,0 @@ yield Sleep.sleep(500); |
@@ -5,3 +5,3 @@ { | ||
"license": "Apache-2.0", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "A dynamo help class which will help maintain data integrity.", | ||
@@ -8,0 +8,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is too big to display
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
518160
10762