@nocobase/database 2.0.0-alpha.63 → 2.0.0-alpha.65

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.
@@ -41,9 +41,9 @@ __export(options_parser_exports, {
41
41
  });
42
42
  module.exports = __toCommonJS(options_parser_exports);
43
43
  var import_lodash = __toESM(require("lodash"));
44
- var import_qs = __toESM(require("qs"));
45
44
  var import_sequelize = require("sequelize");
46
45
  var import_filter_parser = __toESM(require("./filter-parser"));
46
+ var import_qs = __toESM(require("qs"));
47
47
  const debug = require("debug")("noco-database");
48
48
  const _OptionsParser = class _OptionsParser {
49
49
  options;
@@ -300,7 +300,7 @@ const _OptionsParser = class _OptionsParser {
300
300
  return filterParams;
301
301
  }
302
302
  const sortedAppends = import_lodash.default.sortBy(appendList, (append) => append.split(".").length);
303
- const setInclude = /* @__PURE__ */ __name((model, queryParams, append) => {
303
+ const setInclude = /* @__PURE__ */ __name((model, queryParams, append, parentAs) => {
304
304
  var _a;
305
305
  const appendWithOptions = this.parseAppendWithOptions(append);
306
306
  append = appendWithOptions.name;
@@ -339,10 +339,21 @@ const _OptionsParser = class _OptionsParser {
339
339
  return;
340
340
  }
341
341
  if (existIncludeIndex == -1) {
342
- queryParams["include"].push({
342
+ const association = associations[appendAssociation];
343
+ if (!association) {
344
+ throw new Error(`association ${appendAssociation} in ${model.name} not found`);
345
+ }
346
+ let includeOptions = {
343
347
  association: appendAssociation,
344
348
  options: appendWithOptions.options || {}
345
- });
349
+ };
350
+ if (association.associationType === "BelongsToArray") {
351
+ includeOptions = {
352
+ ...includeOptions,
353
+ ...association.generateInclude(parentAs)
354
+ };
355
+ }
356
+ queryParams["include"].push(includeOptions);
346
357
  existIncludeIndex = queryParams["include"].length - 1;
347
358
  }
348
359
  if (lastLevel) {
@@ -378,11 +389,8 @@ const _OptionsParser = class _OptionsParser {
378
389
  if (appendWithOptions.raw) {
379
390
  nextAppend += appendWithOptions.raw;
380
391
  }
381
- setInclude(
382
- model.associations[queryParams["include"][existIncludeIndex].association].target,
383
- queryParams["include"][existIncludeIndex],
384
- nextAppend
385
- );
392
+ const association = model.associations[queryParams["include"][existIncludeIndex].association];
393
+ setInclude(association.target, queryParams["include"][existIncludeIndex], nextAppend, association.as);
386
394
  }
387
395
  }, "setInclude");
388
396
  for (const append of sortedAppends) {
@@ -40,7 +40,6 @@ __export(view_inference_exports, {
40
40
  ViewFieldInference: () => ViewFieldInference
41
41
  });
42
42
  module.exports = __toCommonJS(view_inference_exports);
43
- var import_mathjs = require("mathjs");
44
43
  var import_field_type_map = __toESM(require("./field-type-map"));
45
44
  const _ViewFieldInference = class _ViewFieldInference {
46
45
  static extractTypeFromDefinition(typeDefinition) {
@@ -137,7 +136,7 @@ const _ViewFieldInference = class _ViewFieldInference {
137
136
  }
138
137
  const queryType = this.extractTypeFromDefinition(options.type);
139
138
  const mappedType = fieldTypeMap[queryType];
140
- if ((0, import_mathjs.isArray)(mappedType)) {
139
+ if (Array.isArray(mappedType)) {
141
140
  return {
142
141
  type: mappedType[0],
143
142
  possibleTypes: mappedType
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@nocobase/database",
3
- "version": "2.0.0-alpha.63",
3
+ "version": "2.0.0-alpha.65",
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-alpha.63",
10
- "@nocobase/utils": "2.0.0-alpha.63",
9
+ "@nocobase/logger": "2.0.0-alpha.65",
10
+ "@nocobase/utils": "2.0.0-alpha.65",
11
11
  "async-mutex": "^0.3.2",
12
12
  "chalk": "^4.1.1",
13
13
  "cron-parser": "4.4.0",
@@ -20,7 +20,6 @@
20
20
  "graphlib": "^2.1.8",
21
21
  "joi": "^17.13.3",
22
22
  "lodash": "^4.17.21",
23
- "mathjs": "^10.6.1",
24
23
  "nanoid": "^3.3.11",
25
24
  "node-fetch": "^2.6.7",
26
25
  "node-sql-parser": "^4.18.0",
@@ -39,5 +38,5 @@
39
38
  "url": "git+https://github.com/nocobase/nocobase.git",
40
39
  "directory": "packages/database"
41
40
  },
42
- "gitHead": "0d5e9eb45e4d0f3ba70d7561a0d296d12a4d8bf8"
41
+ "gitHead": "790dd7ba2bb5b1dc905163f11c7b492a5b862365"
43
42
  }