@nocobase/resourcer 2.0.19 → 2.0.21

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.
Files changed (2) hide show
  1. package/lib/utils.js +12 -0
  2. package/package.json +3 -3
package/lib/utils.js CHANGED
@@ -223,6 +223,17 @@ function smartParse(str) {
223
223
  }
224
224
  }
225
225
  __name(smartParse, "smartParse");
226
+ function normalizeIndexedObjectToArray(value) {
227
+ if (!value || Array.isArray(value) || typeof value !== "object") {
228
+ return value;
229
+ }
230
+ const keys = Object.keys(value);
231
+ if (!keys.length || !keys.every((key) => /^\d+$/.test(key))) {
232
+ return value;
233
+ }
234
+ return keys.sort((a, b) => Number(a) - Number(b)).map((key) => value[key]);
235
+ }
236
+ __name(normalizeIndexedObjectToArray, "normalizeIndexedObjectToArray");
226
237
  function parseQuery(input) {
227
238
  const query = import_qs.default.parse(input, {
228
239
  // 原始 query string 中如果一个键连等号“=”都没有可以被认为是 null 类型
@@ -238,6 +249,7 @@ function parseQuery(input) {
238
249
  if (typeof query.filterByTk === "string") {
239
250
  query.filterByTk = smartParse(query.filterByTk);
240
251
  }
252
+ query.filterByTk = normalizeIndexedObjectToArray(query.filterByTk);
241
253
  return query;
242
254
  }
243
255
  __name(parseQuery, "parseQuery");
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@nocobase/resourcer",
3
- "version": "2.0.19",
3
+ "version": "2.0.21",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
7
7
  "license": "Apache-2.0",
8
8
  "dependencies": {
9
- "@nocobase/utils": "2.0.19",
9
+ "@nocobase/utils": "2.0.21",
10
10
  "deepmerge": "^4.2.2",
11
11
  "koa-compose": "^4.1.0",
12
12
  "lodash": "^4.17.21",
@@ -18,5 +18,5 @@
18
18
  "url": "git+https://github.com/nocobase/nocobase.git",
19
19
  "directory": "packages/resourcer"
20
20
  },
21
- "gitHead": "0b865bb88a155478d45ea0178b14d76d5250f4b8"
21
+ "gitHead": "147f39c871299c60820cc9b98034fbfcc342a629"
22
22
  }