@nocobase/database 2.0.0-beta.1 → 2.0.0-beta.2

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.
@@ -45,6 +45,7 @@ export declare class OptionsParser {
45
45
  options?: object;
46
46
  raw?: string;
47
47
  };
48
+ protected normalizeAppends(appends: any): string[];
48
49
  protected parseAppends(appends: Appends, filterParams: any): any;
49
50
  }
50
51
  export {};
@@ -281,9 +281,25 @@ const _OptionsParser = class _OptionsParser {
281
281
  }
282
282
  return obj;
283
283
  }
284
+ normalizeAppends(appends) {
285
+ if (Array.isArray(appends)) {
286
+ return appends.filter((item) => typeof item === "string" && item.length > 0);
287
+ }
288
+ if (import_lodash.default.isPlainObject(appends)) {
289
+ return Object.values(appends).filter((item) => typeof item === "string" && item.length > 0);
290
+ }
291
+ if (typeof appends === "string" && appends.length > 0) {
292
+ return [appends];
293
+ }
294
+ return [];
295
+ }
284
296
  parseAppends(appends, filterParams) {
285
297
  if (!appends) return filterParams;
286
- appends = import_lodash.default.sortBy(appends, (append) => append.split(".").length);
298
+ const appendList = this.normalizeAppends(appends);
299
+ if (!appendList.length) {
300
+ return filterParams;
301
+ }
302
+ const sortedAppends = import_lodash.default.sortBy(appendList, (append) => append.split(".").length);
287
303
  const setInclude = /* @__PURE__ */ __name((model, queryParams, append) => {
288
304
  var _a;
289
305
  const appendWithOptions = this.parseAppendWithOptions(append);
@@ -369,7 +385,7 @@ const _OptionsParser = class _OptionsParser {
369
385
  );
370
386
  }
371
387
  }, "setInclude");
372
- for (const append of appends) {
388
+ for (const append of sortedAppends) {
373
389
  setInclude(this.model, filterParams, append);
374
390
  }
375
391
  debug("filter params: %o", filterParams);
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@nocobase/database",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.2",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
7
7
  "license": "AGPL-3.0",
8
8
  "dependencies": {
9
- "@nocobase/logger": "2.0.0-beta.1",
10
- "@nocobase/utils": "2.0.0-beta.1",
9
+ "@nocobase/logger": "2.0.0-beta.2",
10
+ "@nocobase/utils": "2.0.0-beta.2",
11
11
  "async-mutex": "^0.3.2",
12
12
  "chalk": "^4.1.1",
13
13
  "cron-parser": "4.4.0",
@@ -39,5 +39,5 @@
39
39
  "url": "git+https://github.com/nocobase/nocobase.git",
40
40
  "directory": "packages/database"
41
41
  },
42
- "gitHead": "b3d1f65848fc91e673372ee734dafe6b1cf80586"
42
+ "gitHead": "b77a33ee933ae6e09d2d5dce017ca15d8552d57b"
43
43
  }