@tachybase/actions 0.23.22 → 0.23.40
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 +14 -2
- package/package.json +5 -5
package/lib/actions/list.js
CHANGED
|
@@ -40,11 +40,12 @@ function totalPage(total, pageSize) {
|
|
|
40
40
|
return Math.ceil(total / pageSize);
|
|
41
41
|
}
|
|
42
42
|
__name(totalPage, "totalPage");
|
|
43
|
+
const MAX_ASSOCIATION_SORT_DEPTH = 2;
|
|
43
44
|
function findArgs(ctx) {
|
|
44
45
|
var _a, _b, _c;
|
|
45
46
|
const resourceName = ctx.action.resourceName;
|
|
46
47
|
const params = ctx.action.params;
|
|
47
|
-
const includeSort = ((_a = params.sort) == null ? void 0 : _a.filter((item) => item.split(".").length > 1)) ?? [];
|
|
48
|
+
const includeSort = ((_a = params.sort) == null ? void 0 : _a.filter((item) => typeof item === "string" && item.split(".").length > 1)) ?? [];
|
|
48
49
|
const sortItems = [];
|
|
49
50
|
includeSort.forEach((sort2) => {
|
|
50
51
|
const parts = sort2[0] === "-" ? sort2.slice(1, sort2.length).split(".") : sort2.split(".");
|
|
@@ -61,14 +62,25 @@ function findArgs(ctx) {
|
|
|
61
62
|
});
|
|
62
63
|
}
|
|
63
64
|
});
|
|
65
|
+
const associationAppend = /* @__PURE__ */ new Set();
|
|
64
66
|
sortItems.forEach((item) => {
|
|
65
67
|
var _a2;
|
|
66
68
|
const i = ((_a2 = params.appends) == null ? void 0 : _a2.findIndex((append) => append === item.prefix)) ?? -1;
|
|
67
69
|
if (i !== -1) {
|
|
68
70
|
params.appends[i] = `${item.prefix}(${import_querystring.default.stringify({ sort: item.sortItems })})`;
|
|
71
|
+
} else if (item.prefix) {
|
|
72
|
+
associationAppend.add(item.prefix);
|
|
69
73
|
}
|
|
70
74
|
});
|
|
71
|
-
|
|
75
|
+
if (associationAppend.size) {
|
|
76
|
+
if (!params.appends) {
|
|
77
|
+
params.appends = [];
|
|
78
|
+
}
|
|
79
|
+
for (const prefix of associationAppend) {
|
|
80
|
+
params.appends.push(prefix);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
params.sort = ((_b = params.sort) == null ? void 0 : _b.filter((item) => item.split(".").length <= 1 + MAX_ASSOCIATION_SORT_DEPTH)) ?? [];
|
|
72
84
|
if (params.tree) {
|
|
73
85
|
const [collectionName, associationName] = resourceName.split(".");
|
|
74
86
|
const collection = ctx.db.getCollection(resourceName);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/actions",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.40",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"koa": "^2.15.3",
|
|
10
10
|
"lodash": "4.17.21",
|
|
11
11
|
"sequelize": "^6.37.5",
|
|
12
|
-
"@tachybase/
|
|
13
|
-
"@tachybase/
|
|
14
|
-
"@tachybase/utils": "0.23.
|
|
15
|
-
"@tachybase/
|
|
12
|
+
"@tachybase/database": "0.23.40",
|
|
13
|
+
"@tachybase/resourcer": "0.23.40",
|
|
14
|
+
"@tachybase/utils": "0.23.40",
|
|
15
|
+
"@tachybase/cache": "0.23.40"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/koa": "^2.15.0",
|