aws-dynamodb-query-iterator
Advanced tools
Comparing version 0.7.3-pull-request-167-3 to 0.7.3-pull-request-167-4
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var mergeConsumedCapacities_1 = require("./mergeConsumedCapacities"); | ||
const mergeConsumedCapacities_1 = require("./mergeConsumedCapacities"); | ||
if (Symbol && !Symbol.asyncIterator) { | ||
Symbol.asyncIterator = Symbol.for("__@@asyncIterator__"); | ||
} | ||
var DynamoDbPaginator = /** @class */ (function () { | ||
function DynamoDbPaginator(limit) { | ||
class DynamoDbPaginator { | ||
constructor(limit) { | ||
this.limit = limit; | ||
@@ -17,78 +17,60 @@ this._count = 0; | ||
*/ | ||
DynamoDbPaginator.prototype[Symbol.asyncIterator] = function () { | ||
[Symbol.asyncIterator]() { | ||
return this; | ||
}; | ||
Object.defineProperty(DynamoDbPaginator.prototype, "consumedCapacity", { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
get: function () { | ||
return this._consumedCapacity; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(DynamoDbPaginator.prototype, "count", { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
get: function () { | ||
return this._count; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(DynamoDbPaginator.prototype, "lastEvaluatedKey", { | ||
/** | ||
* Get the LastEvaluatedKey of the last result page yielded by this | ||
* paginator or undefined if the scan has already been exhausted. | ||
*/ | ||
get: function () { | ||
return this._lastKey; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
DynamoDbPaginator.prototype.next = function () { | ||
var _this = this; | ||
this.lastResolved = this.lastResolved.then(function () { | ||
if (_this.count >= (_this.limit === undefined ? Infinity : _this.limit)) { | ||
get consumedCapacity() { | ||
return this._consumedCapacity; | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
get count() { | ||
return this._count; | ||
} | ||
/** | ||
* Get the LastEvaluatedKey of the last result page yielded by this | ||
* paginator or undefined if the scan has already been exhausted. | ||
*/ | ||
get lastEvaluatedKey() { | ||
return this._lastKey; | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
next() { | ||
this.lastResolved = this.lastResolved.then(() => { | ||
if (this.count >= (this.limit === undefined ? Infinity : this.limit)) { | ||
return { done: true }; | ||
} | ||
return _this.getNext().then(function (_a) { | ||
var done = _a.done, value = _a.value; | ||
return this.getNext().then(({ done, value }) => { | ||
if (value && !done) { | ||
_this._lastKey = value.LastEvaluatedKey; | ||
_this._count += (value.Items || []).length; | ||
_this._scannedCount += (value.ScannedCount || 0); | ||
_this._consumedCapacity = mergeConsumedCapacities_1.mergeConsumedCapacities(_this._consumedCapacity, value.ConsumedCapacity); | ||
this._lastKey = value.LastEvaluatedKey; | ||
this._count += (value.Items || []).length; | ||
this._scannedCount += (value.ScannedCount || 0); | ||
this._consumedCapacity = mergeConsumedCapacities_1.mergeConsumedCapacities(this._consumedCapacity, value.ConsumedCapacity); | ||
} | ||
return { value: value, done: done }; | ||
return { value, done }; | ||
}); | ||
}); | ||
return this.lastResolved; | ||
}; | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
DynamoDbPaginator.prototype.return = function () { | ||
return() { | ||
// Prevent any further use of this iterator | ||
this.lastResolved = Promise.reject(new Error('Iteration has been manually interrupted and may not be resumed')); | ||
this.lastResolved.catch(function () { }); | ||
this.lastResolved.catch(() => { }); | ||
return Promise.resolve({ done: true }); | ||
}; | ||
Object.defineProperty(DynamoDbPaginator.prototype, "scannedCount", { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
get: function () { | ||
return this._scannedCount; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
DynamoDbPaginator.prototype.getNextPageSize = function (requestedPageSize) { | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
get scannedCount() { | ||
return this._scannedCount; | ||
} | ||
getNextPageSize(requestedPageSize) { | ||
if (this.limit === undefined) { | ||
@@ -98,6 +80,5 @@ return requestedPageSize; | ||
return Math.min(requestedPageSize === undefined ? Infinity : requestedPageSize, this.limit - this.count); | ||
}; | ||
return DynamoDbPaginator; | ||
}()); | ||
} | ||
} | ||
exports.DynamoDbPaginator = DynamoDbPaginator; | ||
//# sourceMappingURL=DynamoDbPaginator.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./ParallelScanIterator"), exports); | ||
@@ -5,0 +5,0 @@ tslib_1.__exportStar(require("./ParallelScanPaginator"), exports); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
if (Symbol && !Symbol.asyncIterator) { | ||
Symbol.asyncIterator = Symbol.for("__@@asyncIterator__"); | ||
} | ||
var ItemIterator = /** @class */ (function () { | ||
function ItemIterator(paginator) { | ||
class ItemIterator { | ||
constructor(paginator) { | ||
this.paginator = paginator; | ||
@@ -17,36 +16,27 @@ this._iteratedCount = 0; | ||
*/ | ||
ItemIterator.prototype[Symbol.asyncIterator] = function () { | ||
[Symbol.asyncIterator]() { | ||
return this; | ||
}; | ||
Object.defineProperty(ItemIterator.prototype, "consumedCapacity", { | ||
/** | ||
* The capacity units consumed by the Scan operation. The data returned | ||
* includes the total provisioned throughput consumed, along with statistics | ||
* for the table and any indexes involved in the operation. ConsumedCapacity | ||
* is only returned if the ReturnConsumedCapacity parameter was specified. | ||
*/ | ||
get: function () { | ||
return this.paginator.consumedCapacity; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(ItemIterator.prototype, "count", { | ||
/** | ||
* The number of items that have been iterated over. | ||
*/ | ||
get: function () { | ||
return this._iteratedCount; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
} | ||
/** | ||
* The capacity units consumed by the Scan operation. The data returned | ||
* includes the total provisioned throughput consumed, along with statistics | ||
* for the table and any indexes involved in the operation. ConsumedCapacity | ||
* is only returned if the ReturnConsumedCapacity parameter was specified. | ||
*/ | ||
get consumedCapacity() { | ||
return this.paginator.consumedCapacity; | ||
} | ||
/** | ||
* The number of items that have been iterated over. | ||
*/ | ||
get count() { | ||
return this._iteratedCount; | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
ItemIterator.prototype.next = function () { | ||
var _this = this; | ||
this.lastResolved = this.lastResolved.then(function () { return _this.getNext(); }); | ||
next() { | ||
this.lastResolved = this.lastResolved.then(() => this.getNext()); | ||
return this.lastResolved; | ||
}; | ||
} | ||
/** | ||
@@ -61,35 +51,30 @@ * Detaches the underlying paginator from this iterator and returns it. The | ||
*/ | ||
ItemIterator.prototype.pages = function () { | ||
pages() { | ||
// Prevent the iterator from being used further and squelch any uncaught | ||
// promise rejection warnings | ||
this.lastResolved = Promise.reject(new Error('The underlying paginator has been detached from this iterator.')); | ||
this.lastResolved.catch(function () { }); | ||
this.lastResolved.catch(() => { }); | ||
return this.paginator; | ||
}; | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
ItemIterator.prototype.return = function () { | ||
return() { | ||
// Prevent any further use of this iterator | ||
this.lastResolved = Promise.reject(new Error('Iteration has been manually interrupted and may not be resumed')); | ||
this.lastResolved.catch(function () { }); | ||
this.lastResolved.catch(() => { }); | ||
// Clear the pending queue to free up memory | ||
this.pending.length = 0; | ||
return this.paginator.return().then(doneSigil); | ||
}; | ||
Object.defineProperty(ItemIterator.prototype, "scannedCount", { | ||
/** | ||
* The number of items evaluated, before any ScanFilter is applied. A high | ||
* scannedCount value with few, or no, Count results indicates an | ||
* inefficient Scan operation. For more information, see Count and | ||
* ScannedCount in the Amazon DynamoDB Developer Guide. | ||
*/ | ||
get: function () { | ||
return this.paginator.scannedCount; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
ItemIterator.prototype.getNext = function () { | ||
var _this = this; | ||
} | ||
/** | ||
* The number of items evaluated, before any ScanFilter is applied. A high | ||
* scannedCount value with few, or no, Count results indicates an | ||
* inefficient Scan operation. For more information, see Count and | ||
* ScannedCount in the Amazon DynamoDB Developer Guide. | ||
*/ | ||
get scannedCount() { | ||
return this.paginator.scannedCount; | ||
} | ||
getNext() { | ||
if (this.pending.length > 0) { | ||
@@ -102,14 +87,11 @@ this._iteratedCount++; | ||
} | ||
return this.paginator.next().then(function (_a) { | ||
var _b; | ||
var done = _a.done, value = _a.value; | ||
return this.paginator.next().then(({ done, value }) => { | ||
if (done) { | ||
return { done: done }; | ||
return { done }; | ||
} | ||
(_b = _this.pending).push.apply(_b, tslib_1.__spread(value.Items || [])); | ||
return _this.getNext(); | ||
this.pending.push(...value.Items || []); | ||
return this.getNext(); | ||
}); | ||
}; | ||
return ItemIterator; | ||
}()); | ||
} | ||
} | ||
exports.ItemIterator = ItemIterator; | ||
@@ -116,0 +98,0 @@ function doneSigil() { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
/** | ||
@@ -33,46 +32,15 @@ * @internal | ||
function mergeCapacityMaps(a, b) { | ||
var e_1, _a, e_2, _b, e_3, _c; | ||
if (a || b) { | ||
var out = {}; | ||
const out = {}; | ||
a = a || {}; | ||
b = b || {}; | ||
var keys = new Set(); | ||
try { | ||
for (var _d = tslib_1.__values([a, b]), _e = _d.next(); !_e.done; _e = _d.next()) { | ||
var map = _e.value; | ||
try { | ||
for (var _f = (e_2 = void 0, tslib_1.__values(Object.keys(map))), _g = _f.next(); !_g.done; _g = _f.next()) { | ||
var indexName = _g.value; | ||
keys.add(indexName); | ||
} | ||
} | ||
catch (e_2_1) { e_2 = { error: e_2_1 }; } | ||
finally { | ||
try { | ||
if (_g && !_g.done && (_b = _f.return)) _b.call(_f); | ||
} | ||
finally { if (e_2) throw e_2.error; } | ||
} | ||
const keys = new Set(); | ||
for (const map of [a, b]) { | ||
for (const indexName of Object.keys(map)) { | ||
keys.add(indexName); | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (_e && !_e.done && (_a = _d.return)) _a.call(_d); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
for (const key of keys) { | ||
out[key] = mergeCapacities(a[key], b[key]); | ||
} | ||
try { | ||
for (var keys_1 = tslib_1.__values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) { | ||
var key = keys_1_1.value; | ||
out[key] = mergeCapacities(a[key], b[key]); | ||
} | ||
} | ||
catch (e_3_1) { e_3 = { error: e_3_1 }; } | ||
finally { | ||
try { | ||
if (keys_1_1 && !keys_1_1.done && (_c = keys_1.return)) _c.call(keys_1); | ||
} | ||
finally { if (e_3) throw e_3.error; } | ||
} | ||
return out; | ||
@@ -79,0 +47,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var ItemIterator_1 = require("./ItemIterator"); | ||
var ParallelScanPaginator_1 = require("./ParallelScanPaginator"); | ||
var ParallelScanIterator = /** @class */ (function (_super) { | ||
tslib_1.__extends(ParallelScanIterator, _super); | ||
function ParallelScanIterator(client, input, scanState) { | ||
return _super.call(this, new ParallelScanPaginator_1.ParallelScanPaginator(client, input, scanState)) || this; | ||
const ItemIterator_1 = require("./ItemIterator"); | ||
const ParallelScanPaginator_1 = require("./ParallelScanPaginator"); | ||
class ParallelScanIterator extends ItemIterator_1.ItemIterator { | ||
constructor(client, input, scanState) { | ||
super(new ParallelScanPaginator_1.ParallelScanPaginator(client, input, scanState)); | ||
} | ||
return ParallelScanIterator; | ||
}(ItemIterator_1.ItemIterator)); | ||
} | ||
exports.ParallelScanIterator = ParallelScanIterator; | ||
//# sourceMappingURL=ParallelScanIterator.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var mergeConsumedCapacities_1 = require("./mergeConsumedCapacities"); | ||
var ScanPaginator_1 = require("./ScanPaginator"); | ||
const mergeConsumedCapacities_1 = require("./mergeConsumedCapacities"); | ||
const ScanPaginator_1 = require("./ScanPaginator"); | ||
if (Symbol && !Symbol.asyncIterator) { | ||
Symbol.asyncIterator = Symbol.for("__@@asyncIterator__"); | ||
} | ||
var ParallelScanPaginator = /** @class */ (function () { | ||
function ParallelScanPaginator(client, input, scanState) { | ||
if (scanState === void 0) { scanState = nullScanState(input.TotalSegments); } | ||
class ParallelScanPaginator { | ||
constructor(client, input, scanState = nullScanState(input.TotalSegments)) { | ||
this.pending = []; | ||
this.lastResolved = Promise.resolve(); | ||
var TotalSegments = input.TotalSegments; | ||
const { TotalSegments } = input; | ||
if (scanState.length !== TotalSegments) { | ||
throw new Error("Parallel scan state must have a length equal to the number of " | ||
+ ("scan segments. Expected an array of " + TotalSegments + " but") | ||
+ ("received an array with " + scanState.length + " elements.")); | ||
throw new Error(`Parallel scan state must have a length equal to the number of ` | ||
+ `scan segments. Expected an array of ${TotalSegments} but` | ||
+ `received an array with ${scanState.length} elements.`); | ||
} | ||
this.iterators = new Array(TotalSegments); | ||
for (var i = 0; i < TotalSegments; i++) { | ||
var iterator = new ScanPaginator_1.ScanPaginator(client, tslib_1.__assign(tslib_1.__assign({}, input), { Segment: i, ExclusiveStartKey: scanState[i].LastEvaluatedKey })); | ||
for (let i = 0; i < TotalSegments; i++) { | ||
const iterator = new ScanPaginator_1.ScanPaginator(client, { | ||
...input, | ||
Segment: i, | ||
ExclusiveStartKey: scanState[i].LastEvaluatedKey, | ||
}); | ||
this.iterators[i] = iterator; | ||
@@ -30,3 +32,3 @@ // If the segment has not been initialized or a pagination token has | ||
} | ||
this._scanState = tslib_1.__spread(scanState); | ||
this._scanState = [...scanState]; | ||
} | ||
@@ -36,109 +38,78 @@ /** | ||
*/ | ||
ParallelScanPaginator.prototype[Symbol.asyncIterator] = function () { | ||
[Symbol.asyncIterator]() { | ||
return this; | ||
}; | ||
Object.defineProperty(ParallelScanPaginator.prototype, "consumedCapacity", { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
get: function () { | ||
return this.iterators.reduce(function (merged, paginator) { return mergeConsumedCapacities_1.mergeConsumedCapacities(merged, paginator.consumedCapacity); }, undefined); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(ParallelScanPaginator.prototype, "count", { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
get: function () { | ||
return this.iterators.reduce(function (sum, paginator) { return sum + paginator.count; }, 0); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
ParallelScanPaginator.prototype.next = function () { | ||
var _this = this; | ||
this.lastResolved = this.lastResolved.then(function () { return _this.getNext(); }); | ||
get consumedCapacity() { | ||
return this.iterators.reduce((merged, paginator) => mergeConsumedCapacities_1.mergeConsumedCapacities(merged, paginator.consumedCapacity), undefined); | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
get count() { | ||
return this.iterators.reduce((sum, paginator) => sum + paginator.count, 0); | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
next() { | ||
this.lastResolved = this.lastResolved.then(() => this.getNext()); | ||
return this.lastResolved; | ||
}; | ||
ParallelScanPaginator.prototype.getNext = function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var _a, iterator, _b, value, done, segment, i; | ||
return tslib_1.__generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
if (this.pending.length === 0) { | ||
return [2 /*return*/, doneSigil()]; | ||
} | ||
return [4 /*yield*/, Promise.race(this.pending.map(function (pending) { return pending.result; }))]; | ||
case 1: | ||
_a = _c.sent(), iterator = _a.iterator, _b = _a.result, value = _b.value, done = _b.done, segment = _a.segment; | ||
// Update the scan state for this segment. This will either be the last | ||
// evaluated key (for an unfinished segment) or undefined (for a | ||
// completed segment). | ||
this._scanState[segment] = { | ||
initialized: true, | ||
LastEvaluatedKey: value && value.LastEvaluatedKey, | ||
}; | ||
// Remove the result from the pending set. | ||
for (i = this.pending.length - 1; i >= 0; i--) { | ||
if (this.pending[i].iterator === iterator) { | ||
this.pending.splice(i, 1); | ||
} | ||
} | ||
// If the iterator is not finished, add its next result to the pending | ||
// set. | ||
if (!done) { | ||
this.refillPending(iterator, segment); | ||
return [2 /*return*/, { value: value, done: done }]; | ||
} | ||
else { | ||
// If a segment has finished but there are still outstanding | ||
// requests, recur. A done sigil will be returned when the pending | ||
// queue is empty. | ||
return [2 /*return*/, this.getNext()]; | ||
} | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
} | ||
async getNext() { | ||
if (this.pending.length === 0) { | ||
return doneSigil(); | ||
} | ||
// Grab the next available result from any segment. | ||
const { iterator, result: { value, done }, segment, } = await Promise.race(this.pending.map(pending => pending.result)); | ||
// Update the scan state for this segment. This will either be the last | ||
// evaluated key (for an unfinished segment) or undefined (for a | ||
// completed segment). | ||
this._scanState[segment] = { | ||
initialized: true, | ||
LastEvaluatedKey: value && value.LastEvaluatedKey, | ||
}; | ||
// Remove the result from the pending set. | ||
for (let i = this.pending.length - 1; i >= 0; i--) { | ||
if (this.pending[i].iterator === iterator) { | ||
this.pending.splice(i, 1); | ||
} | ||
} | ||
// If the iterator is not finished, add its next result to the pending | ||
// set. | ||
if (!done) { | ||
this.refillPending(iterator, segment); | ||
return { value, done }; | ||
} | ||
else { | ||
// If a segment has finished but there are still outstanding | ||
// requests, recur. A done sigil will be returned when the pending | ||
// queue is empty. | ||
return this.getNext(); | ||
} | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
ParallelScanPaginator.prototype.return = function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
return tslib_1.__generator(this, function (_a) { | ||
this.pending.length = 0; | ||
return [2 /*return*/, Promise.all(this.iterators.map(function (iterator) { return iterator.return(); })) | ||
.then(doneSigil)]; | ||
}); | ||
}); | ||
}; | ||
Object.defineProperty(ParallelScanPaginator.prototype, "scannedCount", { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
get: function () { | ||
return this.iterators.reduce(function (sum, paginator) { return sum + paginator.scannedCount; }, 0); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(ParallelScanPaginator.prototype, "scanState", { | ||
/** | ||
* A snapshot of the current state of a parallel scan. May be used to resume | ||
* a parallel scan with a separate paginator. | ||
*/ | ||
get: function () { | ||
return tslib_1.__spread(this._scanState); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
ParallelScanPaginator.prototype.refillPending = function (iterator, segment) { | ||
async return() { | ||
this.pending.length = 0; | ||
return Promise.all(this.iterators.map(iterator => iterator.return())) | ||
.then(doneSigil); | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
get scannedCount() { | ||
return this.iterators.reduce((sum, paginator) => sum + paginator.scannedCount, 0); | ||
} | ||
/** | ||
* A snapshot of the current state of a parallel scan. May be used to resume | ||
* a parallel scan with a separate paginator. | ||
*/ | ||
get scanState() { | ||
return [...this._scanState]; | ||
} | ||
refillPending(iterator, segment) { | ||
// Use .push to reorder segments within the array of pending results. | ||
@@ -153,7 +124,6 @@ // Promise.race will iterate over the array of pending results until a | ||
result: iterator.next() | ||
.then(function (result) { return ({ iterator: iterator, result: result, segment: segment }); }), | ||
.then(result => ({ iterator, result, segment })), | ||
}); | ||
}; | ||
return ParallelScanPaginator; | ||
}()); | ||
} | ||
} | ||
exports.ParallelScanPaginator = ParallelScanPaginator; | ||
@@ -167,4 +137,4 @@ function doneSigil() { | ||
function nullScanState(length) { | ||
var target = new Array(length); | ||
for (var i = 0; i < length; i++) { | ||
const target = new Array(length); | ||
for (let i = 0; i < length; i++) { | ||
target[i] = { initialized: false }; | ||
@@ -171,0 +141,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var ItemIterator_1 = require("./ItemIterator"); | ||
var QueryPaginator_1 = require("./QueryPaginator"); | ||
var QueryIterator = /** @class */ (function (_super) { | ||
tslib_1.__extends(QueryIterator, _super); | ||
function QueryIterator(client, input, limit) { | ||
return _super.call(this, new QueryPaginator_1.QueryPaginator(client, input, limit)) || this; | ||
const ItemIterator_1 = require("./ItemIterator"); | ||
const QueryPaginator_1 = require("./QueryPaginator"); | ||
class QueryIterator extends ItemIterator_1.ItemIterator { | ||
constructor(client, input, limit) { | ||
super(new QueryPaginator_1.QueryPaginator(client, input, limit)); | ||
} | ||
return QueryIterator; | ||
}(ItemIterator_1.ItemIterator)); | ||
} | ||
exports.QueryIterator = QueryIterator; | ||
//# sourceMappingURL=QueryIterator.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var DynamoDbPaginator_1 = require("./DynamoDbPaginator"); | ||
var QueryPaginator = /** @class */ (function (_super) { | ||
tslib_1.__extends(QueryPaginator, _super); | ||
function QueryPaginator(client, input, limit) { | ||
var _this = _super.call(this, limit) || this; | ||
_this.client = client; | ||
_this.nextRequest = tslib_1.__assign({}, input); | ||
return _this; | ||
const DynamoDbPaginator_1 = require("./DynamoDbPaginator"); | ||
class QueryPaginator extends DynamoDbPaginator_1.DynamoDbPaginator { | ||
constructor(client, input, limit) { | ||
super(limit); | ||
this.client = client; | ||
this.nextRequest = { ...input }; | ||
} | ||
QueryPaginator.prototype.getNext = function () { | ||
var _this = this; | ||
getNext() { | ||
if (this.nextRequest) { | ||
return this.client.query(tslib_1.__assign(tslib_1.__assign({}, this.nextRequest), { Limit: this.getNextPageSize(this.nextRequest.Limit) })) | ||
return this.client.query({ | ||
...this.nextRequest, | ||
Limit: this.getNextPageSize(this.nextRequest.Limit) | ||
}) | ||
.promise() | ||
.then(function (output) { | ||
if (_this.nextRequest && output.LastEvaluatedKey) { | ||
_this.nextRequest = tslib_1.__assign(tslib_1.__assign({}, _this.nextRequest), { ExclusiveStartKey: output.LastEvaluatedKey }); | ||
.then(output => { | ||
if (this.nextRequest && output.LastEvaluatedKey) { | ||
this.nextRequest = { | ||
...this.nextRequest, | ||
ExclusiveStartKey: output.LastEvaluatedKey | ||
}; | ||
} | ||
else { | ||
_this.nextRequest = undefined; | ||
this.nextRequest = undefined; | ||
} | ||
@@ -32,6 +34,5 @@ return Promise.resolve({ | ||
return Promise.resolve({ done: true }); | ||
}; | ||
return QueryPaginator; | ||
}(DynamoDbPaginator_1.DynamoDbPaginator)); | ||
} | ||
} | ||
exports.QueryPaginator = QueryPaginator; | ||
//# sourceMappingURL=QueryPaginator.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var ItemIterator_1 = require("./ItemIterator"); | ||
var ScanPaginator_1 = require("./ScanPaginator"); | ||
var ScanIterator = /** @class */ (function (_super) { | ||
tslib_1.__extends(ScanIterator, _super); | ||
function ScanIterator(client, input, limit) { | ||
return _super.call(this, new ScanPaginator_1.ScanPaginator(client, input, limit)) || this; | ||
const ItemIterator_1 = require("./ItemIterator"); | ||
const ScanPaginator_1 = require("./ScanPaginator"); | ||
class ScanIterator extends ItemIterator_1.ItemIterator { | ||
constructor(client, input, limit) { | ||
super(new ScanPaginator_1.ScanPaginator(client, input, limit)); | ||
} | ||
return ScanIterator; | ||
}(ItemIterator_1.ItemIterator)); | ||
} | ||
exports.ScanIterator = ScanIterator; | ||
//# sourceMappingURL=ScanIterator.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var DynamoDbPaginator_1 = require("./DynamoDbPaginator"); | ||
var ScanPaginator = /** @class */ (function (_super) { | ||
tslib_1.__extends(ScanPaginator, _super); | ||
function ScanPaginator(client, input, limit) { | ||
var _this = _super.call(this, limit) || this; | ||
_this.client = client; | ||
_this.nextRequest = tslib_1.__assign(tslib_1.__assign({}, input), { Limit: _this.getNextPageSize(input.Limit) }); | ||
return _this; | ||
const DynamoDbPaginator_1 = require("./DynamoDbPaginator"); | ||
class ScanPaginator extends DynamoDbPaginator_1.DynamoDbPaginator { | ||
constructor(client, input, limit) { | ||
super(limit); | ||
this.client = client; | ||
this.nextRequest = { | ||
...input, | ||
Limit: this.getNextPageSize(input.Limit), | ||
}; | ||
} | ||
ScanPaginator.prototype.getNext = function () { | ||
var _this = this; | ||
getNext() { | ||
if (this.nextRequest) { | ||
return this.client.scan(tslib_1.__assign(tslib_1.__assign({}, this.nextRequest), { Limit: this.getNextPageSize(this.nextRequest.Limit) })) | ||
return this.client.scan({ | ||
...this.nextRequest, | ||
Limit: this.getNextPageSize(this.nextRequest.Limit) | ||
}) | ||
.promise() | ||
.then(function (output) { | ||
if (_this.nextRequest && output.LastEvaluatedKey) { | ||
_this.nextRequest = tslib_1.__assign(tslib_1.__assign({}, _this.nextRequest), { ExclusiveStartKey: output.LastEvaluatedKey }); | ||
.then(output => { | ||
if (this.nextRequest && output.LastEvaluatedKey) { | ||
this.nextRequest = { | ||
...this.nextRequest, | ||
ExclusiveStartKey: output.LastEvaluatedKey | ||
}; | ||
} | ||
else { | ||
_this.nextRequest = undefined; | ||
this.nextRequest = undefined; | ||
} | ||
@@ -32,6 +37,5 @@ return Promise.resolve({ | ||
return Promise.resolve({ done: true }); | ||
}; | ||
return ScanPaginator; | ||
}(DynamoDbPaginator_1.DynamoDbPaginator)); | ||
} | ||
} | ||
exports.ScanPaginator = ScanPaginator; | ||
//# sourceMappingURL=ScanPaginator.js.map |
{ | ||
"name": "aws-dynamodb-query-iterator", | ||
"version": "0.7.3-pull-request-167-3", | ||
"version": "0.7.3-pull-request-167-4", | ||
"description": "Abstraction for DynamoDB queries and scans that handles pagination and parallel worker coordination", | ||
@@ -44,3 +44,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "7cfb733e819ee0a5a3cfc7ee8f1f4222f0ac7954" | ||
"gitHead": "78e82a3c68facefa4d2daebc382340b99ac72954" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
66624
799