@pristine-ts/aws 0.0.163 → 0.0.167
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/cjs/clients/dynamodb.client.js +39 -19
- package/dist/lib/cjs/clients/dynamodb.client.js.map +1 -1
- package/dist/lib/cjs/enums/dynamodb-sort-order.enum.js +12 -0
- package/dist/lib/cjs/enums/dynamodb-sort-order.enum.js.map +1 -0
- package/dist/lib/cjs/enums/enums.js +1 -0
- package/dist/lib/cjs/enums/enums.js.map +1 -1
- package/dist/lib/cjs/options/find-by-secondary-index.options.js +3 -0
- package/dist/lib/cjs/options/find-by-secondary-index.options.js.map +1 -0
- package/dist/lib/cjs/options/list.options.js +3 -0
- package/dist/lib/cjs/options/list.options.js.map +1 -0
- package/dist/lib/cjs/options/options.js +16 -0
- package/dist/lib/cjs/options/options.js.map +1 -0
- package/dist/lib/cjs/options/pagination.options.js +3 -0
- package/dist/lib/cjs/options/pagination.options.js.map +1 -0
- package/dist/lib/cjs/results/list.result.js +43 -0
- package/dist/lib/cjs/results/list.result.js.map +1 -0
- package/dist/lib/cjs/results/pagination.result.js +3 -0
- package/dist/lib/cjs/results/pagination.result.js.map +1 -0
- package/dist/lib/cjs/results/results.js +15 -0
- package/dist/lib/cjs/results/results.js.map +1 -0
- package/dist/lib/esm/clients/dynamodb.client.js +39 -19
- package/dist/lib/esm/clients/dynamodb.client.js.map +1 -1
- package/dist/lib/esm/enums/dynamodb-sort-order.enum.js +9 -0
- package/dist/lib/esm/enums/dynamodb-sort-order.enum.js.map +1 -0
- package/dist/lib/esm/enums/enums.js +1 -0
- package/dist/lib/esm/enums/enums.js.map +1 -1
- package/dist/lib/esm/options/find-by-secondary-index.options.js +2 -0
- package/dist/lib/esm/options/find-by-secondary-index.options.js.map +1 -0
- package/dist/lib/esm/options/list.options.js +2 -0
- package/dist/lib/esm/options/list.options.js.map +1 -0
- package/dist/lib/esm/options/options.js +4 -0
- package/dist/lib/esm/options/options.js.map +1 -0
- package/dist/lib/esm/options/pagination.options.js +2 -0
- package/dist/lib/esm/options/pagination.options.js.map +1 -0
- package/dist/lib/esm/results/list.result.js +39 -0
- package/dist/lib/esm/results/list.result.js.map +1 -0
- package/dist/lib/esm/results/pagination.result.js +2 -0
- package/dist/lib/esm/results/pagination.result.js.map +1 -0
- package/dist/lib/esm/results/results.js +3 -0
- package/dist/lib/esm/results/results.js.map +1 -0
- package/dist/types/clients/dynamodb.client.d.ts +7 -14
- package/dist/types/enums/dynamodb-sort-order.enum.d.ts +7 -0
- package/dist/types/enums/enums.d.ts +1 -0
- package/dist/types/interfaces/dynamodb-client.interface.d.ts +7 -14
- package/dist/types/options/find-by-secondary-index.options.d.ts +13 -0
- package/dist/types/options/list.options.d.ts +6 -0
- package/dist/types/options/options.d.ts +3 -0
- package/dist/types/options/pagination.options.d.ts +6 -0
- package/dist/types/results/list.result.d.ts +12 -0
- package/dist/types/results/pagination.result.d.ts +4 -0
- package/dist/types/results/results.d.ts +2 -0
- package/package.json +7 -7
|
@@ -40,6 +40,8 @@ const dynamodb_validation_error_1 = require("../errors/dynamodb-validation.error
|
|
|
40
40
|
const dynamodb_error_1 = require("../errors/dynamodb.error");
|
|
41
41
|
const common_1 = require("@pristine-ts/common");
|
|
42
42
|
const aws_module_keyname_1 = require("../aws.module.keyname");
|
|
43
|
+
const list_result_1 = require("../results/list.result");
|
|
44
|
+
const dynamodb_sort_order_enum_1 = require("../enums/dynamodb-sort-order.enum");
|
|
43
45
|
let DynamodbClient = class DynamodbClient {
|
|
44
46
|
constructor(logHandler, region) {
|
|
45
47
|
this.logHandler = logHandler;
|
|
@@ -98,13 +100,20 @@ let DynamodbClient = class DynamodbClient {
|
|
|
98
100
|
}
|
|
99
101
|
/**
|
|
100
102
|
* Lists all the objects of a type (table).
|
|
101
|
-
* @param
|
|
103
|
+
* @param options The options to use to list.
|
|
102
104
|
*/
|
|
103
|
-
list(
|
|
105
|
+
list(options) {
|
|
104
106
|
var e_1, _a;
|
|
105
107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
106
108
|
try {
|
|
107
|
-
|
|
109
|
+
let scanOptions;
|
|
110
|
+
if (options.pagination) {
|
|
111
|
+
scanOptions = {
|
|
112
|
+
startKey: options.pagination.startKey,
|
|
113
|
+
pageSize: options.pagination.pageSize
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
const iterator = (yield this.getMapperClient()).scan(options.classType, scanOptions);
|
|
108
117
|
const items = [];
|
|
109
118
|
try {
|
|
110
119
|
for (var iterator_1 = __asyncValues(iterator), iterator_1_1; iterator_1_1 = yield iterator_1.next(), !iterator_1_1.done;) {
|
|
@@ -120,11 +129,15 @@ let DynamodbClient = class DynamodbClient {
|
|
|
120
129
|
finally { if (e_1) throw e_1.error; }
|
|
121
130
|
}
|
|
122
131
|
this.logHandler.debug("DYNAMODB CLIENT - List items", { items }, aws_module_keyname_1.AwsModuleKeyname);
|
|
123
|
-
|
|
132
|
+
const paginationResult = {
|
|
133
|
+
count: iterator.count,
|
|
134
|
+
lastEvaluatedKey: iterator.pages().lastEvaluatedKey,
|
|
135
|
+
};
|
|
136
|
+
return new list_result_1.ListResult(items, paginationResult);
|
|
124
137
|
}
|
|
125
138
|
catch (error) {
|
|
126
|
-
error = this.convertError(error, this.getTableName(classType.prototype));
|
|
127
|
-
this.logHandler.error("DYNAMODB CLIENT - Error listing", { error,
|
|
139
|
+
error = this.convertError(error, this.getTableName(options.classType.prototype));
|
|
140
|
+
this.logHandler.error("DYNAMODB CLIENT - Error listing", { error, options, AwsModuleKeyname: aws_module_keyname_1.AwsModuleKeyname });
|
|
128
141
|
throw error;
|
|
129
142
|
}
|
|
130
143
|
});
|
|
@@ -217,20 +230,23 @@ let DynamodbClient = class DynamodbClient {
|
|
|
217
230
|
}
|
|
218
231
|
/**
|
|
219
232
|
* Lists the item by secondary index.
|
|
220
|
-
* @param
|
|
221
|
-
* @param keyCondition The key condition for the secondary index. (ie: {secondaryId: value}).
|
|
222
|
-
* @param secondaryIndexName The name of the secondary index in DynamoDb.
|
|
223
|
-
* @param filterKeysAndValues A map containing the filters keys and values to apply when listing by secondary index. Every key in the map represents an AND and the values represent ORs. (ie: {filterKey1: filterValue, filterKey2: [value1, value1]} means you need filterKey1 to equal filterValue AND filterKey2 to equal value1 OR value2)
|
|
224
|
-
* @param expiresAtFilter A filter to get only the ones that the expiration is later then the value. Can either be a Date or a number representing the timestamp in seconds. (ie: {expiresAt: new Date()}).
|
|
233
|
+
* @param options The options to use.
|
|
225
234
|
*/
|
|
226
|
-
findBySecondaryIndex(
|
|
235
|
+
findBySecondaryIndex(options) {
|
|
227
236
|
var e_2, _a;
|
|
237
|
+
var _b;
|
|
228
238
|
return __awaiter(this, void 0, void 0, function* () {
|
|
229
239
|
try {
|
|
230
|
-
const filterExpression = this.createFilterExpression(filterKeysAndValues, expiresAtFilter);
|
|
231
|
-
const queryOptions = { indexName: secondaryIndexName, filter: filterExpression };
|
|
232
|
-
|
|
233
|
-
|
|
240
|
+
const filterExpression = this.createFilterExpression(options.filterKeysAndValues, options.expiresAtFilter);
|
|
241
|
+
const queryOptions = { indexName: options.secondaryIndexName, filter: filterExpression };
|
|
242
|
+
if (options.pagination) {
|
|
243
|
+
queryOptions.pageSize = options.pagination.pageSize;
|
|
244
|
+
queryOptions.startKey = options.pagination.startKey;
|
|
245
|
+
}
|
|
246
|
+
// Makes the default scanIndexForward = false so that most recent come first.
|
|
247
|
+
queryOptions.scanIndexForward = ((_b = options === null || options === void 0 ? void 0 : options.pagination) === null || _b === void 0 ? void 0 : _b.order) === dynamodb_sort_order_enum_1.DynamodbSortOrderEnum.Asc;
|
|
248
|
+
this.logHandler.debug("DYNAMODB CLIENT - Querying with options", { queryOptions, options }, aws_module_keyname_1.AwsModuleKeyname);
|
|
249
|
+
const iterator = (yield this.getMapperClient()).query(options.classType, options.keyCondition, queryOptions);
|
|
234
250
|
const items = [];
|
|
235
251
|
try {
|
|
236
252
|
for (var iterator_2 = __asyncValues(iterator), iterator_2_1; iterator_2_1 = yield iterator_2.next(), !iterator_2_1.done;) {
|
|
@@ -246,11 +262,15 @@ let DynamodbClient = class DynamodbClient {
|
|
|
246
262
|
finally { if (e_2) throw e_2.error; }
|
|
247
263
|
}
|
|
248
264
|
this.logHandler.debug("DYNAMODB CLIENT - Found items", { items }, aws_module_keyname_1.AwsModuleKeyname);
|
|
249
|
-
|
|
265
|
+
const paginationResult = {
|
|
266
|
+
count: iterator.count,
|
|
267
|
+
lastEvaluatedKey: iterator.pages().lastEvaluatedKey,
|
|
268
|
+
};
|
|
269
|
+
return new list_result_1.ListResult(items, paginationResult);
|
|
250
270
|
}
|
|
251
271
|
catch (error) {
|
|
252
|
-
error = this.convertError(error, this.getTableName(classType.prototype));
|
|
253
|
-
this.logHandler.error("DYNAMODB CLIENT - Error finding by secondary index", { error,
|
|
272
|
+
error = this.convertError(error, this.getTableName(options.classType.prototype));
|
|
273
|
+
this.logHandler.error("DYNAMODB CLIENT - Error finding by secondary index", { error, options }, aws_module_keyname_1.AwsModuleKeyname);
|
|
254
274
|
throw error;
|
|
255
275
|
}
|
|
256
276
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamodb.client.js","sourceRoot":"","sources":["../../../../src/clients/dynamodb.client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"dynamodb.client.js","sourceRoot":"","sources":["../../../../src/clients/dynamodb.client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAoD;AACpD,uFAMsD;AAEtD,uFAAsH;AACtH,uCAA8C;AAC9C,2FAAoF;AACpF,qGAA8F;AAC9F,6FAAsF;AACtF,mFAA8E;AAC9E,6DAAyD;AAEzD,gDAA0C;AAE1C,8DAAyD;AAGzD,wDAAoD;AAEpD,gFAA0E;AAI1E,IAAa,cAAc,GAA3B,MAAa,cAAc;IAKvB,YACoD,UAA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ACtB,OAAO,IAAI,mDAAuB,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;gBACrE;oBACI,OAAO,IAAI,8BAAa,CAAC,0BAA0B,GAAG,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;aACvG;SACJ;QACD,OAAO,IAAI,8BAAa,CAAC,wBAAwB,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;IACrF,CAAC;IAED;;;;;OAKG;IACK,+BAA+B,CAAiC,SAAsC,EAAE,kBAA2C;QACvJ,MAAM,IAAI,GAAM,IAAI,SAAS,EAAE,CAAC;QAChC,MAAM,cAAc,GAAW,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;QAClE,aAAa;QACb,IAAI,CAAC,cAAc,CAAC,GAAG,kBAAkB,CAAC,cAAc,CAAC,CAAC;QAE1D,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ,CAAA;AAhVY,cAAc;IAF1B,YAAG,CAAC,yBAAyB,CAAC;IAC9B,qBAAU,EAAE;IAOJ,WAAA,iBAAM,CAAC,qBAAqB,CAAC,CAAA;IAC7B,WAAA,iBAAM,CAAC,uBAAuB,CAAC,CAAA;;GAP3B,cAAc,CAgV1B;AAhVY,wCAAc"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DynamodbSortOrderEnum = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Sort order for dynamodb queries
|
|
6
|
+
*/
|
|
7
|
+
var DynamodbSortOrderEnum;
|
|
8
|
+
(function (DynamodbSortOrderEnum) {
|
|
9
|
+
DynamodbSortOrderEnum["Asc"] = "ASC";
|
|
10
|
+
DynamodbSortOrderEnum["Desc"] = "DESC";
|
|
11
|
+
})(DynamodbSortOrderEnum = exports.DynamodbSortOrderEnum || (exports.DynamodbSortOrderEnum = {}));
|
|
12
|
+
//# sourceMappingURL=dynamodb-sort-order.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamodb-sort-order.enum.js","sourceRoot":"","sources":["../../../../src/enums/dynamodb-sort-order.enum.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAC7B,oCAAW,CAAA;IACX,sCAAa,CAAA;AACjB,CAAC,EAHW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAGhC"}
|
|
@@ -11,6 +11,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./dynamodb-event-type.enum"), exports);
|
|
14
|
+
__exportStar(require("./dynamodb-sort-order.enum"), exports);
|
|
14
15
|
__exportStar(require("./event-bridge-event-type.enum"), exports);
|
|
15
16
|
__exportStar(require("./kafka-event-type.enum"), exports);
|
|
16
17
|
__exportStar(require("./s3-event-type.enum"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../../src/enums/enums.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6DAA2C;AAC3C,iEAA+C;AAC/C,0DAAwC;AACxC,uDAAqC;AACrC,wDAAsC;AACtC,wDAAsC"}
|
|
1
|
+
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../../src/enums/enums.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6DAA2C;AAC3C,6DAA2C;AAC3C,iEAA+C;AAC/C,0DAAwC;AACxC,uDAAqC;AACrC,wDAAsC;AACtC,wDAAsC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-by-secondary-index.options.js","sourceRoot":"","sources":["../../../../src/options/find-by-secondary-index.options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.options.js","sourceRoot":"","sources":["../../../../src/options/list.options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./find-by-secondary-index.options"), exports);
|
|
14
|
+
__exportStar(require("./list.options"), exports);
|
|
15
|
+
__exportStar(require("./pagination.options"), exports);
|
|
16
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../../src/options/options.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oEAAkD;AAClD,iDAA+B;AAC/B,uDAAqC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.options.js","sourceRoot":"","sources":["../../../../src/options/pagination.options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ListResult = void 0;
|
|
4
|
+
class ListResult {
|
|
5
|
+
constructor(_items, _paginationResult) {
|
|
6
|
+
this._items = _items;
|
|
7
|
+
this._paginationResult = _paginationResult;
|
|
8
|
+
this.index = 0;
|
|
9
|
+
this.done = false;
|
|
10
|
+
}
|
|
11
|
+
[Symbol.iterator]() {
|
|
12
|
+
return this;
|
|
13
|
+
}
|
|
14
|
+
next() {
|
|
15
|
+
if (this.done) {
|
|
16
|
+
return {
|
|
17
|
+
done: this.done,
|
|
18
|
+
value: undefined,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
if (this.index === this._items.length) {
|
|
22
|
+
this.done = true;
|
|
23
|
+
return {
|
|
24
|
+
done: this.done,
|
|
25
|
+
value: this._items[this.index],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const value = this._items[this.index];
|
|
29
|
+
this.index += 1;
|
|
30
|
+
return {
|
|
31
|
+
done: false,
|
|
32
|
+
value,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
get paginationResult() {
|
|
36
|
+
return this._paginationResult;
|
|
37
|
+
}
|
|
38
|
+
get items() {
|
|
39
|
+
return this._items;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.ListResult = ListResult;
|
|
43
|
+
//# sourceMappingURL=list.result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.result.js","sourceRoot":"","sources":["../../../../src/results/list.result.ts"],"names":[],"mappings":";;;AAGA,MAAa,UAAU;IAInB,YAAoB,MAAW,EAAU,iBAAoC;QAAzD,WAAM,GAAN,MAAM,CAAK;QAAU,sBAAiB,GAAjB,iBAAiB,CAAmB;QACzE,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,CAAC,MAAM,CAAC,QAAQ,CAAC;QACb,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,IAAI;QACA,IAAG,IAAI,CAAC,IAAI,EAAC;YACT,OAAO;gBACH,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,KAAK,EAAE,SAAS;aACnB,CAAC;SACL;QAED,IAAG,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,MAAM,CAAC,MAAM,EAAC;YACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YACjB,OAAO;gBACH,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;aACjC,CAAC;SACL;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;QAChB,OAAO;YACH,IAAI,EAAE,KAAK;YACX,KAAK;SACR,CAAC;IACN,CAAC;IAED,IAAI,gBAAgB;QAChB,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAClC,CAAC;IAED,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;CACJ;AA5CD,gCA4CC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.result.js","sourceRoot":"","sources":["../../../../src/results/pagination.result.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./list.result"), exports);
|
|
14
|
+
__exportStar(require("./pagination.result"), exports);
|
|
15
|
+
//# sourceMappingURL=results.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"results.js","sourceRoot":"","sources":["../../../../src/results/results.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gDAA8B;AAC9B,sDAAoC"}
|
|
@@ -37,6 +37,8 @@ import { DynamodbValidationError } from "../errors/dynamodb-validation.error";
|
|
|
37
37
|
import { DynamodbError } from "../errors/dynamodb.error";
|
|
38
38
|
import { tag } from "@pristine-ts/common";
|
|
39
39
|
import { AwsModuleKeyname } from "../aws.module.keyname";
|
|
40
|
+
import { ListResult } from "../results/list.result";
|
|
41
|
+
import { DynamodbSortOrderEnum } from "../enums/dynamodb-sort-order.enum";
|
|
40
42
|
let DynamodbClient = class DynamodbClient {
|
|
41
43
|
constructor(logHandler, region) {
|
|
42
44
|
this.logHandler = logHandler;
|
|
@@ -95,13 +97,20 @@ let DynamodbClient = class DynamodbClient {
|
|
|
95
97
|
}
|
|
96
98
|
/**
|
|
97
99
|
* Lists all the objects of a type (table).
|
|
98
|
-
* @param
|
|
100
|
+
* @param options The options to use to list.
|
|
99
101
|
*/
|
|
100
|
-
list(
|
|
102
|
+
list(options) {
|
|
101
103
|
var e_1, _a;
|
|
102
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
103
105
|
try {
|
|
104
|
-
|
|
106
|
+
let scanOptions;
|
|
107
|
+
if (options.pagination) {
|
|
108
|
+
scanOptions = {
|
|
109
|
+
startKey: options.pagination.startKey,
|
|
110
|
+
pageSize: options.pagination.pageSize
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
const iterator = (yield this.getMapperClient()).scan(options.classType, scanOptions);
|
|
105
114
|
const items = [];
|
|
106
115
|
try {
|
|
107
116
|
for (var iterator_1 = __asyncValues(iterator), iterator_1_1; iterator_1_1 = yield iterator_1.next(), !iterator_1_1.done;) {
|
|
@@ -117,11 +126,15 @@ let DynamodbClient = class DynamodbClient {
|
|
|
117
126
|
finally { if (e_1) throw e_1.error; }
|
|
118
127
|
}
|
|
119
128
|
this.logHandler.debug("DYNAMODB CLIENT - List items", { items }, AwsModuleKeyname);
|
|
120
|
-
|
|
129
|
+
const paginationResult = {
|
|
130
|
+
count: iterator.count,
|
|
131
|
+
lastEvaluatedKey: iterator.pages().lastEvaluatedKey,
|
|
132
|
+
};
|
|
133
|
+
return new ListResult(items, paginationResult);
|
|
121
134
|
}
|
|
122
135
|
catch (error) {
|
|
123
|
-
error = this.convertError(error, this.getTableName(classType.prototype));
|
|
124
|
-
this.logHandler.error("DYNAMODB CLIENT - Error listing", { error,
|
|
136
|
+
error = this.convertError(error, this.getTableName(options.classType.prototype));
|
|
137
|
+
this.logHandler.error("DYNAMODB CLIENT - Error listing", { error, options, AwsModuleKeyname });
|
|
125
138
|
throw error;
|
|
126
139
|
}
|
|
127
140
|
});
|
|
@@ -214,20 +227,23 @@ let DynamodbClient = class DynamodbClient {
|
|
|
214
227
|
}
|
|
215
228
|
/**
|
|
216
229
|
* Lists the item by secondary index.
|
|
217
|
-
* @param
|
|
218
|
-
* @param keyCondition The key condition for the secondary index. (ie: {secondaryId: value}).
|
|
219
|
-
* @param secondaryIndexName The name of the secondary index in DynamoDb.
|
|
220
|
-
* @param filterKeysAndValues A map containing the filters keys and values to apply when listing by secondary index. Every key in the map represents an AND and the values represent ORs. (ie: {filterKey1: filterValue, filterKey2: [value1, value1]} means you need filterKey1 to equal filterValue AND filterKey2 to equal value1 OR value2)
|
|
221
|
-
* @param expiresAtFilter A filter to get only the ones that the expiration is later then the value. Can either be a Date or a number representing the timestamp in seconds. (ie: {expiresAt: new Date()}).
|
|
230
|
+
* @param options The options to use.
|
|
222
231
|
*/
|
|
223
|
-
findBySecondaryIndex(
|
|
232
|
+
findBySecondaryIndex(options) {
|
|
224
233
|
var e_2, _a;
|
|
234
|
+
var _b;
|
|
225
235
|
return __awaiter(this, void 0, void 0, function* () {
|
|
226
236
|
try {
|
|
227
|
-
const filterExpression = this.createFilterExpression(filterKeysAndValues, expiresAtFilter);
|
|
228
|
-
const queryOptions = { indexName: secondaryIndexName, filter: filterExpression };
|
|
229
|
-
|
|
230
|
-
|
|
237
|
+
const filterExpression = this.createFilterExpression(options.filterKeysAndValues, options.expiresAtFilter);
|
|
238
|
+
const queryOptions = { indexName: options.secondaryIndexName, filter: filterExpression };
|
|
239
|
+
if (options.pagination) {
|
|
240
|
+
queryOptions.pageSize = options.pagination.pageSize;
|
|
241
|
+
queryOptions.startKey = options.pagination.startKey;
|
|
242
|
+
}
|
|
243
|
+
// Makes the default scanIndexForward = false so that most recent come first.
|
|
244
|
+
queryOptions.scanIndexForward = ((_b = options === null || options === void 0 ? void 0 : options.pagination) === null || _b === void 0 ? void 0 : _b.order) === DynamodbSortOrderEnum.Asc;
|
|
245
|
+
this.logHandler.debug("DYNAMODB CLIENT - Querying with options", { queryOptions, options }, AwsModuleKeyname);
|
|
246
|
+
const iterator = (yield this.getMapperClient()).query(options.classType, options.keyCondition, queryOptions);
|
|
231
247
|
const items = [];
|
|
232
248
|
try {
|
|
233
249
|
for (var iterator_2 = __asyncValues(iterator), iterator_2_1; iterator_2_1 = yield iterator_2.next(), !iterator_2_1.done;) {
|
|
@@ -243,11 +259,15 @@ let DynamodbClient = class DynamodbClient {
|
|
|
243
259
|
finally { if (e_2) throw e_2.error; }
|
|
244
260
|
}
|
|
245
261
|
this.logHandler.debug("DYNAMODB CLIENT - Found items", { items }, AwsModuleKeyname);
|
|
246
|
-
|
|
262
|
+
const paginationResult = {
|
|
263
|
+
count: iterator.count,
|
|
264
|
+
lastEvaluatedKey: iterator.pages().lastEvaluatedKey,
|
|
265
|
+
};
|
|
266
|
+
return new ListResult(items, paginationResult);
|
|
247
267
|
}
|
|
248
268
|
catch (error) {
|
|
249
|
-
error = this.convertError(error, this.getTableName(classType.prototype));
|
|
250
|
-
this.logHandler.error("DYNAMODB CLIENT - Error finding by secondary index", { error,
|
|
269
|
+
error = this.convertError(error, this.getTableName(options.classType.prototype));
|
|
270
|
+
this.logHandler.error("DYNAMODB CLIENT - Error finding by secondary index", { error, options }, AwsModuleKeyname);
|
|
251
271
|
throw error;
|
|
252
272
|
}
|
|
253
273
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamodb.client.js","sourceRoot":"","sources":["../../../../src/clients/dynamodb.client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"dynamodb.client.js","sourceRoot":"","sources":["../../../../src/clients/dynamodb.client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EACH,UAAU,EACV,aAAa,EAIhB,MAAM,8CAA8C,CAAC;AAEtD,OAAO,EAAuB,MAAM,EAAE,WAAW,EAAgB,MAAM,8CAA8C,CAAC;AACtH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AACpF,OAAO,EAAE,8BAA8B,EAAE,MAAM,8CAA8C,CAAC;AAC9F,OAAO,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AACtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAI1E,IAAa,cAAc,GAA3B,MAAa,cAAc;IAKvB,YACoD,UAA+B,EAC7B,MAAc;QADhB,eAAU,GAAV,UAAU,CAAqB;QAC7B,WAAM,GAAN,MAAM,CAAQ;IAEpE,CAAC;IAED;;OAEG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CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;aACvG;SACJ;QACD,OAAO,IAAI,aAAa,CAAC,wBAAwB,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;IACrF,CAAC;IAED;;;;;OAKG;IACK,+BAA+B,CAAiC,SAAsC,EAAE,kBAA2C;QACvJ,MAAM,IAAI,GAAM,IAAI,SAAS,EAAE,CAAC;QAChC,MAAM,cAAc,GAAW,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;QAClE,aAAa;QACb,IAAI,CAAC,cAAc,CAAC,GAAG,kBAAkB,CAAC,cAAc,CAAC,CAAC;QAE1D,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ,CAAA;AAhVY,cAAc;IAF1B,GAAG,CAAC,yBAAyB,CAAC;IAC9B,UAAU,EAAE;IAOJ,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;IAC7B,WAAA,MAAM,CAAC,uBAAuB,CAAC,CAAA;;GAP3B,cAAc,CAgV1B;SAhVY,cAAc"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sort order for dynamodb queries
|
|
3
|
+
*/
|
|
4
|
+
export var DynamodbSortOrderEnum;
|
|
5
|
+
(function (DynamodbSortOrderEnum) {
|
|
6
|
+
DynamodbSortOrderEnum["Asc"] = "ASC";
|
|
7
|
+
DynamodbSortOrderEnum["Desc"] = "DESC";
|
|
8
|
+
})(DynamodbSortOrderEnum || (DynamodbSortOrderEnum = {}));
|
|
9
|
+
//# sourceMappingURL=dynamodb-sort-order.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamodb-sort-order.enum.js","sourceRoot":"","sources":["../../../../src/enums/dynamodb-sort-order.enum.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAC7B,oCAAW,CAAA;IACX,sCAAa,CAAA;AACjB,CAAC,EAHW,qBAAqB,KAArB,qBAAqB,QAGhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../../src/enums/enums.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../../src/enums/enums.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-by-secondary-index.options.js","sourceRoot":"","sources":["../../../../src/options/find-by-secondary-index.options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.options.js","sourceRoot":"","sources":["../../../../src/options/list.options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../../src/options/options.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.options.js","sourceRoot":"","sources":["../../../../src/options/pagination.options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export class ListResult {
|
|
2
|
+
constructor(_items, _paginationResult) {
|
|
3
|
+
this._items = _items;
|
|
4
|
+
this._paginationResult = _paginationResult;
|
|
5
|
+
this.index = 0;
|
|
6
|
+
this.done = false;
|
|
7
|
+
}
|
|
8
|
+
[Symbol.iterator]() {
|
|
9
|
+
return this;
|
|
10
|
+
}
|
|
11
|
+
next() {
|
|
12
|
+
if (this.done) {
|
|
13
|
+
return {
|
|
14
|
+
done: this.done,
|
|
15
|
+
value: undefined,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
if (this.index === this._items.length) {
|
|
19
|
+
this.done = true;
|
|
20
|
+
return {
|
|
21
|
+
done: this.done,
|
|
22
|
+
value: this._items[this.index],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const value = this._items[this.index];
|
|
26
|
+
this.index += 1;
|
|
27
|
+
return {
|
|
28
|
+
done: false,
|
|
29
|
+
value,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
get paginationResult() {
|
|
33
|
+
return this._paginationResult;
|
|
34
|
+
}
|
|
35
|
+
get items() {
|
|
36
|
+
return this._items;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=list.result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.result.js","sourceRoot":"","sources":["../../../../src/results/list.result.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,UAAU;IAInB,YAAoB,MAAW,EAAU,iBAAoC;QAAzD,WAAM,GAAN,MAAM,CAAK;QAAU,sBAAiB,GAAjB,iBAAiB,CAAmB;QACzE,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,CAAC,MAAM,CAAC,QAAQ,CAAC;QACb,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,IAAI;QACA,IAAG,IAAI,CAAC,IAAI,EAAC;YACT,OAAO;gBACH,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,KAAK,EAAE,SAAS;aACnB,CAAC;SACL;QAED,IAAG,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,MAAM,CAAC,MAAM,EAAC;YACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YACjB,OAAO;gBACH,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;aACjC,CAAC;SACL;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;QAChB,OAAO;YACH,IAAI,EAAE,KAAK;YACX,KAAK;SACR,CAAC;IACN,CAAC;IAED,IAAI,gBAAgB;QAChB,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAClC,CAAC;IAED,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.result.js","sourceRoot":"","sources":["../../../../src/results/pagination.result.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"results.js","sourceRoot":"","sources":["../../../../src/results/results.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC"}
|
|
@@ -3,6 +3,9 @@ import { DataMapper, StringToAnyObjectMap } from "@awslabs-community-fork/dynamo
|
|
|
3
3
|
import { ZeroArgumentsConstructor } from "@awslabs-community-fork/dynamodb-data-marshaller";
|
|
4
4
|
import { LogHandlerInterface } from "@pristine-ts/logging";
|
|
5
5
|
import { DynamodbClientInterface } from "../interfaces/dynamodb-client.interface";
|
|
6
|
+
import { ListOptions } from "../options/list.options";
|
|
7
|
+
import { FindBySecondaryIndexOptions } from "../options/find-by-secondary-index.options";
|
|
8
|
+
import { ListResult } from "../results/list.result";
|
|
6
9
|
export declare class DynamodbClient implements DynamodbClientInterface {
|
|
7
10
|
private readonly logHandler;
|
|
8
11
|
private readonly region;
|
|
@@ -33,9 +36,9 @@ export declare class DynamodbClient implements DynamodbClientInterface {
|
|
|
33
36
|
}): Promise<T>;
|
|
34
37
|
/**
|
|
35
38
|
* Lists all the objects of a type (table).
|
|
36
|
-
* @param
|
|
39
|
+
* @param options The options to use to list.
|
|
37
40
|
*/
|
|
38
|
-
list<T extends StringToAnyObjectMap>(
|
|
41
|
+
list<T extends StringToAnyObjectMap>(options: ListOptions<T>): Promise<ListResult<T>>;
|
|
39
42
|
/**
|
|
40
43
|
* Creates an entry in DynamoDb if this id does not already exist.
|
|
41
44
|
* @param item The item to create.
|
|
@@ -61,19 +64,9 @@ export declare class DynamodbClient implements DynamodbClientInterface {
|
|
|
61
64
|
}): Promise<void>;
|
|
62
65
|
/**
|
|
63
66
|
* Lists the item by secondary index.
|
|
64
|
-
* @param
|
|
65
|
-
* @param keyCondition The key condition for the secondary index. (ie: {secondaryId: value}).
|
|
66
|
-
* @param secondaryIndexName The name of the secondary index in DynamoDb.
|
|
67
|
-
* @param filterKeysAndValues A map containing the filters keys and values to apply when listing by secondary index. Every key in the map represents an AND and the values represent ORs. (ie: {filterKey1: filterValue, filterKey2: [value1, value1]} means you need filterKey1 to equal filterValue AND filterKey2 to equal value1 OR value2)
|
|
68
|
-
* @param expiresAtFilter A filter to get only the ones that the expiration is later then the value. Can either be a Date or a number representing the timestamp in seconds. (ie: {expiresAt: new Date()}).
|
|
67
|
+
* @param options The options to use.
|
|
69
68
|
*/
|
|
70
|
-
findBySecondaryIndex<T extends StringToAnyObjectMap>(
|
|
71
|
-
[propertyName: string]: string | boolean | number;
|
|
72
|
-
}, secondaryIndexName: string, filterKeysAndValues?: {
|
|
73
|
-
[key: string]: string | number | boolean | string[] | number[];
|
|
74
|
-
}, expiresAtFilter?: {
|
|
75
|
-
[key: string]: number | Date;
|
|
76
|
-
}): Promise<T[]>;
|
|
69
|
+
findBySecondaryIndex<T extends StringToAnyObjectMap>(options: FindBySecondaryIndexOptions<T>): Promise<ListResult<T>>;
|
|
77
70
|
/**
|
|
78
71
|
* Creates the filter conditions for DynamoDb.
|
|
79
72
|
* @param filterKeysAndValues A map containing the filters keys and values to apply when listing by secondary index. Every key in the map represents an AND and the values represent ORs. (ie: {filterKey1: filterValue, filterKey2: [value1, value1]} means you need filterKey1 to equal filterValue AND filterKey2 to equal value1 OR value2)
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { DynamoDB } from "@aws-sdk/client-dynamodb";
|
|
2
2
|
import { DataMapper, StringToAnyObjectMap } from "@awslabs-community-fork/dynamodb-data-mapper";
|
|
3
3
|
import { ZeroArgumentsConstructor } from "@awslabs-community-fork/dynamodb-data-marshaller";
|
|
4
|
+
import { ListOptions } from "../options/list.options";
|
|
5
|
+
import { FindBySecondaryIndexOptions } from "../options/find-by-secondary-index.options";
|
|
6
|
+
import { ListResult } from "../results/list.result";
|
|
4
7
|
/**
|
|
5
8
|
* The DynamodbClient Interface defines the methods that a Dynamodb Client must implement.
|
|
6
9
|
*/
|
|
@@ -23,9 +26,9 @@ export interface DynamodbClientInterface {
|
|
|
23
26
|
}): Promise<T>;
|
|
24
27
|
/**
|
|
25
28
|
* Lists all the objects of a type (table).
|
|
26
|
-
* @param
|
|
29
|
+
* @param options The options to use to list.
|
|
27
30
|
*/
|
|
28
|
-
list<T extends StringToAnyObjectMap>(
|
|
31
|
+
list<T extends StringToAnyObjectMap>(options: ListOptions<T>): Promise<ListResult<T>>;
|
|
29
32
|
/**
|
|
30
33
|
* Creates an entry in DynamoDb if this id does not already exist.
|
|
31
34
|
* @param item The item to create.
|
|
@@ -51,17 +54,7 @@ export interface DynamodbClientInterface {
|
|
|
51
54
|
}): Promise<void>;
|
|
52
55
|
/**
|
|
53
56
|
* Lists the item by secondary index.
|
|
54
|
-
* @param
|
|
55
|
-
* @param keyCondition The key condition for the secondary index. (ie: {secondaryId: value}).
|
|
56
|
-
* @param secondaryIndexName The name of the secondary index in DynamoDb.
|
|
57
|
-
* @param filterKeysAndValues A map containing the filters keys and values to apply when listing by secondary index. Every key in the map represents an AND and the values represent ORs. (ie: {filterKey1: filterValue, filterKey2: [value1, value1]} means you need filterKey1 to equal filterValue AND filterKey2 to equal value1 OR value2)
|
|
58
|
-
* @param expiresAtFilter A filter to get only the ones that the expiration is later then the value. Can either be a Date or a number representing the timestamp in seconds. (ie: {expiresAt: new Date()}).
|
|
57
|
+
* @param options The options to use.
|
|
59
58
|
*/
|
|
60
|
-
findBySecondaryIndex<T extends StringToAnyObjectMap>(
|
|
61
|
-
[propertyName: string]: string | boolean | number;
|
|
62
|
-
}, secondaryIndexName: string, filterKeysAndValues?: {
|
|
63
|
-
[key: string]: string | number | boolean | string[] | number[];
|
|
64
|
-
}, expiresAtFilter?: {
|
|
65
|
-
[key: string]: number | Date;
|
|
66
|
-
}): Promise<T[]>;
|
|
59
|
+
findBySecondaryIndex<T extends StringToAnyObjectMap>(options: FindBySecondaryIndexOptions<T>): Promise<ListResult<T>>;
|
|
67
60
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ListOptions } from "./list.options";
|
|
2
|
+
export interface FindBySecondaryIndexOptions<T> extends ListOptions<T> {
|
|
3
|
+
keyCondition: {
|
|
4
|
+
[propertyName: string]: string | boolean | number;
|
|
5
|
+
};
|
|
6
|
+
secondaryIndexName: string;
|
|
7
|
+
filterKeysAndValues?: {
|
|
8
|
+
[key: string]: string | number | boolean | string[] | number[];
|
|
9
|
+
};
|
|
10
|
+
expiresAtFilter?: {
|
|
11
|
+
[key: string]: number | Date;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PaginationResult } from "./pagination.result";
|
|
2
|
+
export declare class ListResult<T> implements IterableIterator<T> {
|
|
3
|
+
private _items;
|
|
4
|
+
private _paginationResult?;
|
|
5
|
+
private index;
|
|
6
|
+
private done;
|
|
7
|
+
constructor(_items: T[], _paginationResult?: PaginationResult | undefined);
|
|
8
|
+
[Symbol.iterator](): ListResult<T>;
|
|
9
|
+
next(): IteratorResult<T, T | undefined>;
|
|
10
|
+
get paginationResult(): PaginationResult | undefined;
|
|
11
|
+
get items(): T[];
|
|
12
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pristine-ts/aws",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.167",
|
|
4
4
|
"description": "",
|
|
5
5
|
"module": "dist/lib/esm/aws.module.js",
|
|
6
6
|
"main": "dist/lib/cjs/aws.module.js",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"@awslabs-community-fork/dynamodb-data-mapper": "^0.7.9",
|
|
24
24
|
"@awslabs-community-fork/dynamodb-data-marshaller": "^0.7.9",
|
|
25
25
|
"@awslabs-community-fork/dynamodb-expressions": "^0.7.9",
|
|
26
|
-
"@pristine-ts/common": "^0.0.
|
|
27
|
-
"@pristine-ts/event": "^0.0.
|
|
28
|
-
"@pristine-ts/logging": "^0.0.
|
|
29
|
-
"@pristine-ts/networking": "^0.0.
|
|
30
|
-
"@pristine-ts/security": "^0.0.
|
|
26
|
+
"@pristine-ts/common": "^0.0.167",
|
|
27
|
+
"@pristine-ts/event": "^0.0.167",
|
|
28
|
+
"@pristine-ts/logging": "^0.0.167",
|
|
29
|
+
"@pristine-ts/networking": "^0.0.167",
|
|
30
|
+
"@pristine-ts/security": "^0.0.167"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"src/*.{js,ts}"
|
|
67
67
|
]
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "199caaccfe024ee23218b491a814ed58c2b719cd"
|
|
70
70
|
}
|