@karmaniverous/entity-manager 4.3.0-0 → 4.3.0-1
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.
|
@@ -9,6 +9,8 @@ var _map2 = _interopRequireDefault(require("lodash/map"));
|
|
|
9
9
|
var _size2 = _interopRequireDefault(require("lodash/size"));
|
|
10
10
|
var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
|
|
11
11
|
var _fromPairs2 = _interopRequireDefault(require("lodash/fromPairs"));
|
|
12
|
+
var _parseInt2 = _interopRequireDefault(require("lodash/parseInt"));
|
|
13
|
+
var _isString2 = _interopRequireDefault(require("lodash/isString"));
|
|
12
14
|
var _isPlainObject2 = _interopRequireDefault(require("lodash/isPlainObject"));
|
|
13
15
|
var _isInteger2 = _interopRequireDefault(require("lodash/isInteger"));
|
|
14
16
|
var _isUndefined2 = _interopRequireDefault(require("lodash/isUndefined"));
|
|
@@ -251,7 +253,10 @@ class EntityManager {
|
|
|
251
253
|
if (!(0, _isFunction2.default)(shardQuery)) throw new Error('shardQuery must be a function');
|
|
252
254
|
if (!(0, _isUndefined2.default)(limit) && !((0, _isInteger2.default)(limit) && limit >= 1)) throw new Error('limit must be a positive integer');
|
|
253
255
|
if (!(0, _isUndefined2.default)(pageKeys) && !(0, _isPlainObject2.default)(pageKeys)) throw new Error('pageKeys must be an object');
|
|
254
|
-
if (!(0, _isUndefined2.default)(
|
|
256
|
+
if (!(0, _isUndefined2.default)(pages) && !/^(?:\d+|all)$/i.test(pages.toString())) throw new Error("pages must be a positive integer or 'all'");
|
|
257
|
+
|
|
258
|
+
// Parse pages.
|
|
259
|
+
if ((0, _isString2.default)(pages)) pages = pages.toLowerCase() === 'all' ? Infinity : (0, _parseInt2.default)(pages);
|
|
255
260
|
|
|
256
261
|
// Generate default pageKeys if not provided
|
|
257
262
|
pageKeys ??= (0, _fromPairs2.default)(this.getKeySpace(entityToken, keyToken, item).map(shardedKey => [shardedKey, undefined]));
|
|
@@ -315,7 +320,7 @@ class EntityManager {
|
|
|
315
320
|
result.items = [...result.items, ...pageResult.items];
|
|
316
321
|
result.pageKeys = pageResult.pageKeys;
|
|
317
322
|
page++;
|
|
318
|
-
} while (
|
|
323
|
+
} while (page < pages && !(0, _isEmpty2.default)(result.pageKeys));
|
|
319
324
|
return result;
|
|
320
325
|
}
|
|
321
326
|
|
|
@@ -238,13 +238,13 @@ export class EntityManager {
|
|
|
238
238
|
throw new Error('limit must be a positive integer');
|
|
239
239
|
if (!_.isUndefined(pageKeys) && !_.isPlainObject(pageKeys))
|
|
240
240
|
throw new Error('pageKeys must be an object');
|
|
241
|
-
if (
|
|
242
|
-
!_.isUndefined(pageKeys) &&
|
|
243
|
-
!(_.isInteger(pages) && pages >= 1) &&
|
|
244
|
-
pages !== 'all'
|
|
245
|
-
)
|
|
241
|
+
if (!_.isUndefined(pages) && !/^(?:\d+|all)$/i.test(pages.toString()))
|
|
246
242
|
throw new Error("pages must be a positive integer or 'all'");
|
|
247
243
|
|
|
244
|
+
// Parse pages.
|
|
245
|
+
if (_.isString(pages))
|
|
246
|
+
pages = pages.toLowerCase() === 'all' ? Infinity : _.parseInt(pages);
|
|
247
|
+
|
|
248
248
|
// Generate default pageKeys if not provided
|
|
249
249
|
pageKeys ??= _.fromPairs(
|
|
250
250
|
this.getKeySpace(entityToken, keyToken, item).map((shardedKey) => [
|
|
@@ -297,7 +297,7 @@ export class EntityManager {
|
|
|
297
297
|
result.items = [...result.items, ...pageResult.items];
|
|
298
298
|
result.pageKeys = pageResult.pageKeys;
|
|
299
299
|
page++;
|
|
300
|
-
} while (
|
|
300
|
+
} while (page < pages && !_.isEmpty(result.pageKeys));
|
|
301
301
|
|
|
302
302
|
return result;
|
|
303
303
|
}
|