@karmaniverous/entity-manager 4.3.2 → 4.4.0
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.
|
@@ -255,6 +255,9 @@ class EntityManager {
|
|
|
255
255
|
if (!(0, _isUndefined2.default)(pageKeys) && !(0, _isPlainObject2.default)(pageKeys)) throw new Error('pageKeys must be an object');
|
|
256
256
|
if (!(0, _isUndefined2.default)(pages) && !/^(?:\d+|all)$/i.test(pages.toString())) throw new Error("pages must be a positive integer or 'all'");
|
|
257
257
|
|
|
258
|
+
// Apply default limit.
|
|
259
|
+
limit ??= this.#entityManager.getEntityConfig(entityToken).defaultLimit;
|
|
260
|
+
|
|
258
261
|
// Parse pages.
|
|
259
262
|
if ((0, _isString2.default)(pages)) pages = pages.toLowerCase() === 'all' ? Infinity : (0, _parseInt2.default)(pages);
|
|
260
263
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.PrivateEntityManager = void 0;
|
|
6
|
+
exports.PrivateEntityManager = exports.DEFAULT_LIMIT = void 0;
|
|
7
7
|
var _isInteger2 = _interopRequireDefault(require("lodash/isInteger"));
|
|
8
8
|
var _isPlainObject2 = _interopRequireDefault(require("lodash/isPlainObject"));
|
|
9
9
|
var _range2 = _interopRequireDefault(require("lodash/range"));
|
|
@@ -26,6 +26,8 @@ var _mapValues2 = _interopRequireDefault(require("lodash/mapValues"));
|
|
|
26
26
|
var _jsonschema = require("jsonschema");
|
|
27
27
|
var _stringHash = _interopRequireDefault(require("string-hash"));
|
|
28
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
|
+
const DEFAULT_LIMIT = exports.DEFAULT_LIMIT = 25;
|
|
30
|
+
|
|
29
31
|
/**
|
|
30
32
|
* EntityManager config validation schema.
|
|
31
33
|
*
|
|
@@ -40,6 +42,9 @@ const configSchema = {
|
|
|
40
42
|
'^\\w+$': {
|
|
41
43
|
type: 'object',
|
|
42
44
|
properties: {
|
|
45
|
+
defaultLimit: {
|
|
46
|
+
type: 'integer'
|
|
47
|
+
},
|
|
43
48
|
indexes: {
|
|
44
49
|
type: 'object',
|
|
45
50
|
additionalProperties: {
|
|
@@ -169,6 +174,7 @@ class PrivateEntityManager {
|
|
|
169
174
|
const conformedConfig = {
|
|
170
175
|
entities: (0, _mapValues2.default)(entities, _ref => {
|
|
171
176
|
let {
|
|
177
|
+
defaultLimit = DEFAULT_LIMIT,
|
|
172
178
|
indexes = {},
|
|
173
179
|
keys = {},
|
|
174
180
|
sharding: {
|
|
@@ -180,6 +186,7 @@ class PrivateEntityManager {
|
|
|
180
186
|
} = {}
|
|
181
187
|
} = _ref;
|
|
182
188
|
return {
|
|
189
|
+
defaultLimit,
|
|
183
190
|
indexes,
|
|
184
191
|
keys,
|
|
185
192
|
sharding: {
|
|
@@ -241,6 +241,9 @@ export class EntityManager {
|
|
|
241
241
|
if (!_.isUndefined(pages) && !/^(?:\d+|all)$/i.test(pages.toString()))
|
|
242
242
|
throw new Error("pages must be a positive integer or 'all'");
|
|
243
243
|
|
|
244
|
+
// Apply default limit.
|
|
245
|
+
limit ??= this.#entityManager.getEntityConfig(entityToken).defaultLimit;
|
|
246
|
+
|
|
244
247
|
// Parse pages.
|
|
245
248
|
if (_.isString(pages))
|
|
246
249
|
pages = pages.toLowerCase() === 'all' ? Infinity : _.parseInt(pages);
|
|
@@ -2,6 +2,8 @@ import { validate } from 'jsonschema';
|
|
|
2
2
|
import _ from 'lodash';
|
|
3
3
|
import stringHash from 'string-hash';
|
|
4
4
|
|
|
5
|
+
export const DEFAULT_LIMIT = 25;
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* EntityManager config validation schema.
|
|
7
9
|
*
|
|
@@ -16,6 +18,9 @@ const configSchema = {
|
|
|
16
18
|
'^\\w+$': {
|
|
17
19
|
type: 'object',
|
|
18
20
|
properties: {
|
|
21
|
+
defaultLimit: {
|
|
22
|
+
type: 'integer',
|
|
23
|
+
},
|
|
19
24
|
indexes: {
|
|
20
25
|
type: 'object',
|
|
21
26
|
additionalProperties: {
|
|
@@ -135,6 +140,7 @@ export class PrivateEntityManager {
|
|
|
135
140
|
entities: _.mapValues(
|
|
136
141
|
entities,
|
|
137
142
|
({
|
|
143
|
+
defaultLimit = DEFAULT_LIMIT,
|
|
138
144
|
indexes = {},
|
|
139
145
|
keys = {},
|
|
140
146
|
sharding: {
|
|
@@ -145,6 +151,7 @@ export class PrivateEntityManager {
|
|
|
145
151
|
timestamp,
|
|
146
152
|
} = {},
|
|
147
153
|
}) => ({
|
|
154
|
+
defaultLimit,
|
|
148
155
|
indexes,
|
|
149
156
|
keys,
|
|
150
157
|
sharding: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@karmaniverous/entity-manager",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -26,25 +26,25 @@
|
|
|
26
26
|
"string-hash": "^1.1.3"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@babel/cli": "^7.23.
|
|
30
|
-
"@babel/core": "^7.23.
|
|
31
|
-
"@babel/eslint-parser": "^7.
|
|
32
|
-
"@babel/plugin-syntax-import-assertions": "^7.
|
|
33
|
-
"@babel/preset-env": "^7.23.
|
|
34
|
-
"@babel/register": "^7.
|
|
35
|
-
"@karmaniverous/edge-logger": "^1.3.
|
|
29
|
+
"@babel/cli": "^7.23.4",
|
|
30
|
+
"@babel/core": "^7.23.7",
|
|
31
|
+
"@babel/eslint-parser": "^7.23.3",
|
|
32
|
+
"@babel/plugin-syntax-import-assertions": "^7.23.3",
|
|
33
|
+
"@babel/preset-env": "^7.23.7",
|
|
34
|
+
"@babel/register": "^7.23.7",
|
|
35
|
+
"@karmaniverous/edge-logger": "^1.3.7",
|
|
36
36
|
"@karmaniverous/tagged-templates": "^0.1.2",
|
|
37
|
-
"@types/node": "^20.
|
|
37
|
+
"@types/node": "^20.10.6",
|
|
38
38
|
"babel-plugin-lodash": "^3.3.4",
|
|
39
|
-
"chai": "^
|
|
39
|
+
"chai": "^5.0.0",
|
|
40
40
|
"concat-md": "^0.5.1",
|
|
41
|
-
"eslint": "^8.
|
|
42
|
-
"eslint-plugin-jsdoc": "^
|
|
41
|
+
"eslint": "^8.56.0",
|
|
42
|
+
"eslint-plugin-jsdoc": "^48.0.2",
|
|
43
43
|
"eslint-plugin-mocha": "^10.2.0",
|
|
44
44
|
"eslint-plugin-promise": "^6.1.1",
|
|
45
45
|
"jsdoc-to-markdown": "^8.0.0",
|
|
46
46
|
"mocha": "^10.2.0",
|
|
47
|
-
"release-it": "^
|
|
47
|
+
"release-it": "^17.0.1"
|
|
48
48
|
},
|
|
49
49
|
"exports": {
|
|
50
50
|
".": {
|