@nocobase/data-source-manager 1.9.0-alpha.3 → 1.9.0-alpha.4
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/default-actions/list.js +33 -2
- package/package.json +7 -7
|
@@ -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,14 +26,24 @@ 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, {
|
|
30
40
|
list: () => list
|
|
31
41
|
});
|
|
32
42
|
module.exports = __toCommonJS(list_exports);
|
|
43
|
+
var import_actions = require("@nocobase/actions");
|
|
33
44
|
var import_utils = require("@nocobase/utils");
|
|
34
45
|
var import_utils2 = require("./utils");
|
|
46
|
+
var import_lodash = __toESM(require("lodash"));
|
|
35
47
|
function totalPage(total, pageSize) {
|
|
36
48
|
return Math.ceil(total / pageSize);
|
|
37
49
|
}
|
|
@@ -57,10 +69,10 @@ function findArgs(ctx) {
|
|
|
57
69
|
}
|
|
58
70
|
__name(findArgs, "findArgs");
|
|
59
71
|
async function listWithPagination(ctx) {
|
|
60
|
-
var _a;
|
|
72
|
+
var _a, _b;
|
|
61
73
|
const { page = 1, pageSize = 50 } = ctx.action.params;
|
|
62
74
|
const repository = ctx.getCurrentRepository();
|
|
63
|
-
|
|
75
|
+
let { simplePaginate } = ((_a = repository.collection) == null ? void 0 : _a.options) || {};
|
|
64
76
|
const options = {
|
|
65
77
|
context: ctx,
|
|
66
78
|
...findArgs(ctx),
|
|
@@ -71,6 +83,25 @@ async function listWithPagination(ctx) {
|
|
|
71
83
|
delete options[key];
|
|
72
84
|
}
|
|
73
85
|
});
|
|
86
|
+
if (import_lodash.default.isUndefined(simplePaginate) && import_lodash.default.isFunction(repository["getEstimatedRowCount"])) {
|
|
87
|
+
const count = await repository.getEstimatedRowCount();
|
|
88
|
+
if (count > import_actions.SIMPLE_PAGINATION_LIMIT) {
|
|
89
|
+
const resourceName = ctx.action.resourceName;
|
|
90
|
+
const collection = ctx.dataSource.collectionManager.getCollection(resourceName);
|
|
91
|
+
await ctx.app.db.getRepository("dataSourcesCollections").updateOrCreate({
|
|
92
|
+
filterKeys: ["name", "dataSourceKey"],
|
|
93
|
+
values: {
|
|
94
|
+
name: collection.name,
|
|
95
|
+
dataSourceKey: ctx.dataSource.options.name,
|
|
96
|
+
options: {
|
|
97
|
+
...(_b = repository.collection) == null ? void 0 : _b.options,
|
|
98
|
+
simplePaginate: true
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
simplePaginate = true;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
74
105
|
if (simplePaginate) {
|
|
75
106
|
options.limit = options.limit + 1;
|
|
76
107
|
const rows = await repository.find(options);
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/data-source-manager",
|
|
3
|
-
"version": "1.9.0-alpha.
|
|
3
|
+
"version": "1.9.0-alpha.4",
|
|
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/actions": "1.9.0-alpha.
|
|
10
|
-
"@nocobase/cache": "1.9.0-alpha.
|
|
11
|
-
"@nocobase/database": "1.9.0-alpha.
|
|
12
|
-
"@nocobase/resourcer": "1.9.0-alpha.
|
|
13
|
-
"@nocobase/utils": "1.9.0-alpha.
|
|
9
|
+
"@nocobase/actions": "1.9.0-alpha.4",
|
|
10
|
+
"@nocobase/cache": "1.9.0-alpha.4",
|
|
11
|
+
"@nocobase/database": "1.9.0-alpha.4",
|
|
12
|
+
"@nocobase/resourcer": "1.9.0-alpha.4",
|
|
13
|
+
"@nocobase/utils": "1.9.0-alpha.4",
|
|
14
14
|
"@types/jsonwebtoken": "^8.5.8",
|
|
15
15
|
"jsonwebtoken": "^9.0.2"
|
|
16
16
|
},
|
|
@@ -19,5 +19,5 @@
|
|
|
19
19
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
20
20
|
"directory": "packages/auth"
|
|
21
21
|
},
|
|
22
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "1475e0633935382429b3dec490e786df2d492878"
|
|
23
23
|
}
|