@nocobase/actions 1.9.0-beta.2 → 1.9.0-beta.5
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/lib/actions/list.js +28 -2
- package/lib/constants.d.ts +1 -0
- package/lib/constants.js +5 -2
- package/package.json +5 -5
package/lib/actions/list.js
CHANGED
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
var __create = Object.create;
|
|
10
11
|
var __defProp = Object.defineProperty;
|
|
11
12
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
13
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
15
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
16
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
15
17
|
var __export = (target, all) => {
|
|
@@ -24,6 +26,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
24
26
|
}
|
|
25
27
|
return to;
|
|
26
28
|
};
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
+
mod
|
|
36
|
+
));
|
|
27
37
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
38
|
var list_exports = {};
|
|
29
39
|
__export(list_exports, {
|
|
@@ -32,6 +42,7 @@ __export(list_exports, {
|
|
|
32
42
|
module.exports = __toCommonJS(list_exports);
|
|
33
43
|
var import_utils = require("../utils");
|
|
34
44
|
var import_constants = require("../constants");
|
|
45
|
+
var import_lodash = __toESM(require("lodash"));
|
|
35
46
|
function totalPage(total, pageSize) {
|
|
36
47
|
return Math.ceil(total / pageSize);
|
|
37
48
|
}
|
|
@@ -49,10 +60,10 @@ function findArgs(ctx) {
|
|
|
49
60
|
}
|
|
50
61
|
__name(findArgs, "findArgs");
|
|
51
62
|
async function listWithPagination(ctx) {
|
|
52
|
-
var _a;
|
|
63
|
+
var _a, _b;
|
|
53
64
|
const { page = import_constants.DEFAULT_PAGE, pageSize = import_constants.DEFAULT_PER_PAGE } = ctx.action.params;
|
|
54
65
|
const repository = (0, import_utils.getRepositoryFromParams)(ctx);
|
|
55
|
-
|
|
66
|
+
let { simplePaginate } = ((_a = repository.collection) == null ? void 0 : _a.options) || {};
|
|
56
67
|
const options = {
|
|
57
68
|
context: ctx,
|
|
58
69
|
...findArgs(ctx),
|
|
@@ -63,6 +74,21 @@ async function listWithPagination(ctx) {
|
|
|
63
74
|
delete options[key];
|
|
64
75
|
}
|
|
65
76
|
});
|
|
77
|
+
if (import_lodash.default.isUndefined(simplePaginate) && import_lodash.default.isFunction(repository["getEstimatedRowCount"])) {
|
|
78
|
+
const count = await repository["getEstimatedRowCount"]();
|
|
79
|
+
if (count > import_constants.SIMPLE_PAGINATION_LIMIT && repository.collection.options.loadedFromCollectionManager) {
|
|
80
|
+
await ctx.app.db.getRepository("collections").update({
|
|
81
|
+
filter: { name: repository.collection.name },
|
|
82
|
+
values: {
|
|
83
|
+
options: {
|
|
84
|
+
...(_b = repository.collection) == null ? void 0 : _b.options,
|
|
85
|
+
simplePaginate: true
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
simplePaginate = true;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
66
92
|
if (simplePaginate) {
|
|
67
93
|
options.limit = options.limit + 1;
|
|
68
94
|
const rows = await repository.find(options);
|
package/lib/constants.d.ts
CHANGED
package/lib/constants.js
CHANGED
|
@@ -27,13 +27,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
27
27
|
var constants_exports = {};
|
|
28
28
|
__export(constants_exports, {
|
|
29
29
|
DEFAULT_PAGE: () => DEFAULT_PAGE,
|
|
30
|
-
DEFAULT_PER_PAGE: () => DEFAULT_PER_PAGE
|
|
30
|
+
DEFAULT_PER_PAGE: () => DEFAULT_PER_PAGE,
|
|
31
|
+
SIMPLE_PAGINATION_LIMIT: () => SIMPLE_PAGINATION_LIMIT
|
|
31
32
|
});
|
|
32
33
|
module.exports = __toCommonJS(constants_exports);
|
|
33
34
|
const DEFAULT_PAGE = 1;
|
|
34
35
|
const DEFAULT_PER_PAGE = 20;
|
|
36
|
+
const SIMPLE_PAGINATION_LIMIT = 3e5;
|
|
35
37
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
38
|
0 && (module.exports = {
|
|
37
39
|
DEFAULT_PAGE,
|
|
38
|
-
DEFAULT_PER_PAGE
|
|
40
|
+
DEFAULT_PER_PAGE,
|
|
41
|
+
SIMPLE_PAGINATION_LIMIT
|
|
39
42
|
});
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/actions",
|
|
3
|
-
"version": "1.9.0-beta.
|
|
3
|
+
"version": "1.9.0-beta.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@nocobase/cache": "1.9.0-beta.
|
|
10
|
-
"@nocobase/database": "1.9.0-beta.
|
|
11
|
-
"@nocobase/resourcer": "1.9.0-beta.
|
|
9
|
+
"@nocobase/cache": "1.9.0-beta.5",
|
|
10
|
+
"@nocobase/database": "1.9.0-beta.5",
|
|
11
|
+
"@nocobase/resourcer": "1.9.0-beta.5"
|
|
12
12
|
},
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
16
16
|
"directory": "packages/actions"
|
|
17
17
|
},
|
|
18
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "9a61c60dd3db5af64244e82447309b0cb17aabb6"
|
|
19
19
|
}
|