@nocobase/database 1.9.0-beta.1 → 1.9.0-beta.11

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 (40) hide show
  1. package/lib/collection.d.ts +7 -0
  2. package/lib/collection.js +67 -0
  3. package/lib/cursor-builder.js +4 -3
  4. package/lib/database.d.ts +2 -1
  5. package/lib/database.js +31 -3
  6. package/lib/dialects/mysql-dialect.d.ts +2 -1
  7. package/lib/dialects/mysql-dialect.js +5 -2
  8. package/lib/eager-loading/eager-loading-tree.js +2 -20
  9. package/lib/fields/field.d.ts +25 -2
  10. package/lib/fields/index.d.ts +3 -1
  11. package/lib/fields/index.js +3 -1
  12. package/lib/fields/number-field.d.ts +1 -1
  13. package/lib/fields/snowflake-id-field.d.ts +29 -0
  14. package/lib/fields/snowflake-id-field.js +79 -0
  15. package/lib/fields/string-field.d.ts +1 -1
  16. package/lib/index.d.ts +2 -0
  17. package/lib/index.js +8 -0
  18. package/lib/inherited-sync-runner.js +5 -0
  19. package/lib/interfaces/number-interface.d.ts +1 -0
  20. package/lib/interfaces/number-interface.js +28 -0
  21. package/lib/magic-attribute-model.js +3 -0
  22. package/lib/operators/empty.d.ts +1 -4
  23. package/lib/operators/index.d.ts +1 -2
  24. package/lib/options-parser.js +1 -1
  25. package/lib/query-interface/postgres-query-interface.d.ts +3 -1
  26. package/lib/query-interface/postgres-query-interface.js +9 -2
  27. package/lib/query-interface/query-interface.d.ts +3 -1
  28. package/lib/relation-repository/belongs-to-many-repository.js +5 -0
  29. package/lib/relation-repository/relation-repository.js +1 -0
  30. package/lib/repository.d.ts +3 -0
  31. package/lib/repository.js +87 -2
  32. package/lib/update-associations.js +25 -0
  33. package/lib/utils/field-validation.d.ts +59 -0
  34. package/lib/utils/field-validation.js +143 -0
  35. package/lib/utils/filter-include.d.ts +55 -0
  36. package/lib/utils/filter-include.js +118 -0
  37. package/lib/utils.d.ts +1 -0
  38. package/lib/utils.js +22 -0
  39. package/lib/view/view-inference.js +1 -0
  40. package/package.json +5 -4
package/lib/utils.js CHANGED
@@ -45,6 +45,7 @@ __export(utils_exports, {
45
45
  md5: () => md5,
46
46
  patchSequelizeQueryInterface: () => patchSequelizeQueryInterface,
47
47
  percent2float: () => percent2float,
48
+ processIncludes: () => processIncludes,
48
49
  snakeCase: () => snakeCase
49
50
  });
50
51
  module.exports = __toCommonJS(utils_exports);
@@ -140,6 +141,26 @@ function getKeysByPrefix(keys, prefix) {
140
141
  return keys.filter((key) => key.startsWith(`${prefix}.`)).map((key) => key.substring(prefix.length + 1));
141
142
  }
142
143
  __name(getKeysByPrefix, "getKeysByPrefix");
144
+ function processIncludes(includes, model, parentAs = "") {
145
+ includes.forEach((include, index) => {
146
+ const association = model.associations[include.association];
147
+ if (association == null ? void 0 : association.generateInclude) {
148
+ includes[index] = {
149
+ ...include,
150
+ ...association.generateInclude(parentAs)
151
+ };
152
+ }
153
+ if (include.include && Array.isArray(include.include) && include.include.length > 0) {
154
+ const nextModel = association == null ? void 0 : association.target;
155
+ if (!nextModel) {
156
+ return;
157
+ }
158
+ processIncludes(include.include, nextModel, parentAs ? `${parentAs}->${association.as}` : association.as);
159
+ }
160
+ });
161
+ return includes;
162
+ }
163
+ __name(processIncludes, "processIncludes");
143
164
  // Annotate the CommonJS export names for ESM import in node:
144
165
  0 && (module.exports = {
145
166
  checkIdentifier,
@@ -150,5 +171,6 @@ __name(getKeysByPrefix, "getKeysByPrefix");
150
171
  md5,
151
172
  patchSequelizeQueryInterface,
152
173
  percent2float,
174
+ processIncludes,
153
175
  snakeCase
154
176
  });
@@ -108,6 +108,7 @@ const _ViewFieldInference = class _ViewFieldInference {
108
108
  if (collectionField) {
109
109
  if (collectionField.options.interface) {
110
110
  inferResult.type = collectionField.type;
111
+ inferResult.interface = collectionField.options.interface;
111
112
  inferResult.source = `${collectionField.collection.name}.${collectionField.name}`;
112
113
  }
113
114
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@nocobase/database",
3
- "version": "1.9.0-beta.1",
3
+ "version": "1.9.0-beta.11",
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": "1.9.0-beta.1",
10
- "@nocobase/utils": "1.9.0-beta.1",
9
+ "@nocobase/logger": "1.9.0-beta.11",
10
+ "@nocobase/utils": "1.9.0-beta.11",
11
11
  "async-mutex": "^0.3.2",
12
12
  "chalk": "^4.1.1",
13
13
  "cron-parser": "4.4.0",
@@ -18,6 +18,7 @@
18
18
  "flat": "^5.0.2",
19
19
  "glob": "^7.1.6",
20
20
  "graphlib": "^2.1.8",
21
+ "joi": "^17.13.3",
21
22
  "lodash": "^4.17.21",
22
23
  "mathjs": "^10.6.1",
23
24
  "nanoid": "^3.3.11",
@@ -38,5 +39,5 @@
38
39
  "url": "git+https://github.com/nocobase/nocobase.git",
39
40
  "directory": "packages/database"
40
41
  },
41
- "gitHead": "e0597219574e23bbf15b57848cb9b0fb4953634f"
42
+ "gitHead": "373bc3f829a928bb3cd3dad327dedf3afe2ab407"
42
43
  }