@nocobase/data-source-manager 2.1.0-beta.2 → 2.1.0-beta.20

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/README.md CHANGED
@@ -1,17 +1,24 @@
1
1
  # NocoBase
2
2
 
3
3
  <video width="100%" controls>
4
- <source src="https://static-docs.nocobase.com/NocoBase0510.mp4" type="video/mp4">
4
+ <source src="https://github.com/user-attachments/assets/4d11a87b-00e2-48f3-9bf7-389d21072d13" type="video/mp4">
5
5
  </video>
6
6
 
7
+ <p align="center">
8
+ <a href="https://trendshift.io/repositories/4112" target="_blank"><img src="https://trendshift.io/api/badge/repositories/4112" alt="nocobase%2Fnocobase | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
9
+ <a href="https://www.producthunt.com/posts/nocobase?embed=true&utm_source=badge-top-post-topic-badge&utm_medium=badge&utm_souce=badge-nocobase" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/top-post-topic-badge.svg?post_id=456520&theme=light&period=weekly&topic_id=267" alt="NocoBase - Scalability&#0045;first&#0044;&#0032;open&#0045;source&#0032;no&#0045;code&#0032;platform | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
10
+ </p>
7
11
 
8
12
  ## What is NocoBase
9
13
 
10
- NocoBase is a scalability-first, open-source no-code development platform.
11
- Instead of investing years of time and millions of dollars in research and development, deploy NocoBase in a few minutes and you'll have a private, controllable, and extremely scalable no-code development platform!
14
+ NocoBase is the most extensible AI-powered no-code platform.
15
+ Total control. Infinite extensibility. AI collaboration.
16
+ Enable your team to adapt quickly and cut costs dramatically.
17
+ No years of development. No millions wasted.
18
+ Deploy NocoBase in minutes — and take control of everything.
12
19
 
13
20
  Homepage:
14
- https://www.nocobase.com/
21
+ https://www.nocobase.com/
15
22
 
16
23
  Online Demo:
17
24
  https://demo.nocobase.com/new
@@ -19,12 +26,74 @@ https://demo.nocobase.com/new
19
26
  Documents:
20
27
  https://docs.nocobase.com/
21
28
 
22
- Commericial license & plugins:
23
- https://www.nocobase.com/en/commercial
29
+ Forum:
30
+ https://forum.nocobase.com/
24
31
 
25
- License agreement:
26
- https://www.nocobase.com/en/agreement
32
+ Use Cases:
33
+ https://www.nocobase.com/en/blog/tags/customer-stories
27
34
 
35
+ ## Release Notes
28
36
 
29
- ## Contact Us:
30
- hello@nocobase.com
37
+ Our [blog](https://www.nocobase.com/en/blog/timeline) is regularly updated with release notes and provides a weekly summary.
38
+
39
+ ## Distinctive features
40
+
41
+ ### 1. Data model-driven, not form/table–driven
42
+
43
+ Instead of being constrained by forms or tables, NocoBase adopts a data model–driven approach, separating data structure from user interface to unlock unlimited possibilities.
44
+
45
+ - UI and data structure are fully decoupled
46
+ - Multiple blocks and actions can be created for the same table or record in any quantity or form
47
+ - Supports the main database, external databases, and third-party APIs as data sources
48
+
49
+ ![model](https://static-docs.nocobase.com/model.png)
50
+
51
+ ### 2. AI employees, integrated into your business systems
52
+ Unlike standalone AI demos, NocoBase allows you to embed AI capabilities seamlessly into your interfaces, workflows, and data context, making AI truly useful in real business scenarios.
53
+
54
+ - Define AI employees for roles such as translator, analyst, researcher, or assistant
55
+ - Seamless AI–human collaboration in interfaces and workflows
56
+ - Ensure AI usage is secure, transparent, and customizable for your business needs
57
+
58
+ ![AI-employee](https://static-docs.nocobase.com/ai-employee-home.png)
59
+
60
+ ### 3. What you see is what you get, incredibly easy to use
61
+
62
+ While enabling the development of complex business systems, NocoBase keeps the experience simple and intuitive.
63
+
64
+ - One-click switch between usage mode and configuration mode
65
+ - Pages serve as a canvas to arrange blocks and actions, similar to Notion
66
+ - Configuration mode is designed for ordinary users, not just programmers
67
+
68
+ ![wysiwyg](https://static-docs.nocobase.com/wysiwyg.gif)
69
+
70
+ ### 4. Everything is a plugin, designed for extension
71
+ Adding more no-code features will never cover every business case. NocoBase is built for extension through its plugin-based microkernel architecture.
72
+
73
+ - All functionalities are plugins, similar to WordPress
74
+ - Plugins are ready to use upon installation
75
+ - Pages, blocks, actions, APIs, and data sources can all be extended through custom plugins
76
+
77
+ ![plugins](https://static-docs.nocobase.com/plugins.png)
78
+
79
+ ## Installation
80
+
81
+ NocoBase supports three installation methods:
82
+
83
+ - <a target="_blank" href="https://docs.nocobase.com/welcome/getting-started/installation/docker-compose">Installing With Docker (👍Recommended)</a>
84
+
85
+ Suitable for no-code scenarios, no code to write. When upgrading, just download the latest image and reboot.
86
+
87
+ - <a target="_blank" href="https://docs.nocobase.com/welcome/getting-started/installation/create-nocobase-app">Installing from create-nocobase-app CLI</a>
88
+
89
+ The business code of the project is completely independent and supports low-code development.
90
+
91
+ - <a target="_blank" href="https://docs.nocobase.com/welcome/getting-started/installation/git-clone">Installing from Git source code</a>
92
+
93
+ If you want to experience the latest unreleased version, or want to participate in the contribution, you need to make changes and debug on the source code, it is recommended to choose this installation method, which requires a high level of development skills, and if the code has been updated, you can git pull the latest code.
94
+
95
+ ## How NocoBase works
96
+
97
+ <video width="100%" controls>
98
+ <source src="https://github.com/user-attachments/assets/8d183b44-9bb5-4792-b08f-bc08fe8dfaaf" type="video/mp4">
99
+ </video>
@@ -7,7 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import { DataSource } from './data-source';
10
- import { CollectionOptions, ICollection, ICollectionManager, IFieldInterface, IRepository, MergeOptions } from './types';
10
+ import { CollectionOptions, ICollection, ICollectionManager, IField, IFieldInterface, IRepository, MergeOptions } from './types';
11
11
  export declare class CollectionManager implements ICollectionManager {
12
12
  dataSource: DataSource;
13
13
  protected collections: Map<string, ICollection>;
@@ -25,6 +25,7 @@ export declare class CollectionManager implements ICollectionManager {
25
25
  getFieldInterface(name: string): {
26
26
  new (options: any): IFieldInterface | undefined;
27
27
  };
28
+ isNumericField(field?: IField): boolean;
28
29
  registerCollectionTemplates(): void;
29
30
  registerModels(models: Record<string, any>): void;
30
31
  registerRepositories(repositories: Record<string, any>): void;
@@ -32,6 +32,7 @@ __export(collection_manager_exports, {
32
32
  module.exports = __toCommonJS(collection_manager_exports);
33
33
  var import_collection = require("./collection");
34
34
  var import_repository = require("./repository");
35
+ var import_utils = require("./utils");
35
36
  const _CollectionManager = class _CollectionManager {
36
37
  dataSource;
37
38
  collections = /* @__PURE__ */ new Map();
@@ -77,6 +78,9 @@ const _CollectionManager = class _CollectionManager {
77
78
  getFieldInterface(name) {
78
79
  return;
79
80
  }
81
+ isNumericField(field) {
82
+ return (0, import_utils.isNumericField)(field);
83
+ }
80
84
  /* istanbul ignore next -- @preserve */
81
85
  registerCollectionTemplates() {
82
86
  }
@@ -23,4 +23,6 @@ export declare abstract class DatabaseDataSource<T extends DatabaseIntrospector
23
23
  };
24
24
  }): CollectionOptions[];
25
25
  private mergeFieldOptions;
26
+ private hasCompatibleStorageType;
27
+ private getFieldStorageType;
26
28
  }
@@ -58,19 +58,34 @@ const _DatabaseDataSource = class _DatabaseDataSource extends import_data_source
58
58
  const loadedCollection = loadedCollections[collection.name];
59
59
  if (!loadedCollection) return collection;
60
60
  const collectionFields = collection.fields || [];
61
- const loadedFieldsObj = Object.fromEntries(
62
- (loadedCollection.fields || []).map((f) => [f.columnName || f.field || f.name, f])
61
+ const loadedFieldsByName = Object.fromEntries((loadedCollection.fields || []).map((f) => [f.name, f]));
62
+ const loadedFieldsByColumn = (loadedCollection.fields || []).reduce(
63
+ (result, field) => {
64
+ const key = field.columnName || field.field || field.name;
65
+ result[key] = result[key] || [];
66
+ result[key].push(field);
67
+ return result;
68
+ },
69
+ {}
63
70
  );
71
+ const isAliasField = /* @__PURE__ */ __name((field) => Boolean((field == null ? void 0 : field.field) && field.name !== field.field), "isAliasField");
64
72
  const newFields = collectionFields.map((field) => {
65
- const loadedField = loadedFieldsObj[field.name];
73
+ var _a, _b;
74
+ const loadedField = loadedFieldsByName[field.name] || ((_a = loadedFieldsByColumn[field.columnName || field.field || field.name]) == null ? void 0 : _a.find(
75
+ (candidate) => !isAliasField(candidate)
76
+ )) || ((_b = loadedFieldsByColumn[field.columnName || field.field || field.name]) == null ? void 0 : _b[0]);
66
77
  if (!loadedField) return field;
67
78
  if (loadedField.possibleTypes) {
68
79
  loadedField.possibleTypes = field.possibleTypes;
69
80
  }
70
81
  return this.mergeFieldOptions(field, loadedField);
71
82
  });
83
+ const loadedMappedFields = (loadedCollection.fields || []).filter(
84
+ (field) => isAliasField(field) && !newFields.find((newField) => newField.name === field.name)
85
+ );
86
+ newFields.push(...loadedMappedFields);
72
87
  const loadedAssociationFields = (loadedCollection.fields || []).filter(
73
- (field) => ["belongsTo", "belongsToMany", "hasMany", "hasOne", "belongsToArray"].includes(field.type)
88
+ (field) => ["belongsTo", "belongsToMany", "hasMany", "hasOne", "belongsToArray"].includes(field.type) && !newFields.find((newField) => newField.name === field.name)
74
89
  );
75
90
  newFields.push(...loadedAssociationFields);
76
91
  return {
@@ -85,18 +100,77 @@ const _DatabaseDataSource = class _DatabaseDataSource extends import_data_source
85
100
  ...fieldOptions,
86
101
  ...modelOptions
87
102
  };
88
- if (fieldOptions.rawType && modelOptions.rawType && fieldOptions.rawType !== modelOptions.rawType) {
103
+ const dbSyncedKeys = ["allowNull"];
104
+ const incomingPossibleTypes = Array.isArray(fieldOptions.possibleTypes) ? fieldOptions.possibleTypes : fieldOptions.type ? [fieldOptions.type] : [];
105
+ const hasCompatibleStorageType = this.hasCompatibleStorageType(fieldOptions.type, modelOptions.type);
106
+ const shouldUseIncomingType = Boolean(fieldOptions.rawType) && Boolean(modelOptions.rawType || modelOptions.type) && (modelOptions.rawType ? fieldOptions.rawType !== modelOptions.rawType && !hasCompatibleStorageType : !incomingPossibleTypes.includes(modelOptions.type) && !hasCompatibleStorageType);
107
+ if (shouldUseIncomingType) {
89
108
  newOptions.type = fieldOptions.type;
90
109
  newOptions.interface = fieldOptions.interface;
91
110
  newOptions.rawType = fieldOptions.rawType;
92
111
  }
93
112
  for (const key of [.../* @__PURE__ */ new Set([...Object.keys(modelOptions), ...Object.keys(fieldOptions)])]) {
94
- if (modelOptions[key] === null && fieldOptions[key]) {
113
+ const shouldUseIncoming = dbSyncedKeys.includes(key) || modelOptions[key] === null && key in fieldOptions;
114
+ if (shouldUseIncoming) {
95
115
  newOptions[key] = fieldOptions[key];
96
116
  }
97
117
  }
98
118
  return newOptions;
99
119
  }
120
+ hasCompatibleStorageType(incomingType, loadedType) {
121
+ if (!incomingType || !loadedType || incomingType === loadedType) {
122
+ return false;
123
+ }
124
+ const incomingStorageType = this.getFieldStorageType(incomingType);
125
+ const loadedStorageType = this.getFieldStorageType(loadedType);
126
+ if (!incomingStorageType || !loadedStorageType) {
127
+ return false;
128
+ }
129
+ return incomingStorageType === loadedStorageType;
130
+ }
131
+ getFieldStorageType(type) {
132
+ var _a, _b, _c, _d;
133
+ if (!type) {
134
+ return;
135
+ }
136
+ const db = (_a = this.collectionManager) == null ? void 0 : _a.db;
137
+ if (!db) {
138
+ return;
139
+ }
140
+ try {
141
+ const fieldClass = db.fieldTypes.get(type);
142
+ if (!fieldClass) {
143
+ return;
144
+ }
145
+ const descriptor = Object.getOwnPropertyDescriptor(fieldClass.prototype, "dataType");
146
+ const collection = {
147
+ name: "__sync_probe__",
148
+ options: {
149
+ underscored: false
150
+ },
151
+ isView() {
152
+ return false;
153
+ }
154
+ };
155
+ const dataType = (_b = descriptor == null ? void 0 : descriptor.get) == null ? void 0 : _b.call({
156
+ options: {
157
+ type
158
+ },
159
+ database: db,
160
+ collection,
161
+ context: {
162
+ database: db,
163
+ collection
164
+ }
165
+ });
166
+ if (typeof dataType === "string") {
167
+ return dataType;
168
+ }
169
+ return (dataType == null ? void 0 : dataType.key) || ((_c = dataType == null ? void 0 : dataType.constructor) == null ? void 0 : _c.key) || ((_d = dataType == null ? void 0 : dataType.constructor) == null ? void 0 : _d.name);
170
+ } catch {
171
+ return;
172
+ }
173
+ }
100
174
  };
101
175
  __name(_DatabaseDataSource, "DatabaseDataSource");
102
176
  let DatabaseDataSource = _DatabaseDataSource;
@@ -6,7 +6,9 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
+ import coreActions from '@nocobase/actions';
9
10
  import { list } from './default-actions/list';
10
11
  export declare function loadDefaultActions(): {
11
12
  list: typeof list;
13
+ query: typeof coreActions.query;
12
14
  };
@@ -7,9 +7,11 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
+ var __create = Object.create;
10
11
  var __defProp = Object.defineProperty;
11
12
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
13
  var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
13
15
  var __hasOwnProp = Object.prototype.hasOwnProperty;
14
16
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
15
17
  var __export = (target, all) => {
@@ -24,12 +26,21 @@ var __copyProps = (to, from, except, desc) => {
24
26
  }
25
27
  return to;
26
28
  };
29
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
30
+ // If the importer is in node compatibility mode or this is not an ESM
31
+ // file that has been converted to a CommonJS file using a Babel-
32
+ // compatible transform (i.e. "__esModule" has not been set), then set
33
+ // "default" to the CommonJS "module.exports" for node compatibility.
34
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
+ mod
36
+ ));
27
37
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
38
  var load_default_actions_exports = {};
29
39
  __export(load_default_actions_exports, {
30
40
  loadDefaultActions: () => loadDefaultActions
31
41
  });
32
42
  module.exports = __toCommonJS(load_default_actions_exports);
43
+ var import_actions = __toESM(require("@nocobase/actions"));
33
44
  var import_list = require("./default-actions/list");
34
45
  var import_proxy_to_repository = require("./default-actions/proxy-to-repository");
35
46
  const actions = {
@@ -97,7 +108,8 @@ function loadDefaultActions() {
97
108
  carry[key] = (0, import_proxy_to_repository.proxyToRepository)(actions[key].params, actions[key].method);
98
109
  return carry;
99
110
  }, {}),
100
- list: import_list.list
111
+ list: import_list.list,
112
+ query: import_actions.default.query
101
113
  };
102
114
  }
103
115
  __name(loadDefaultActions, "loadDefaultActions");
@@ -8,7 +8,7 @@
8
8
  */
9
9
  import { Database } from '@nocobase/database';
10
10
  import { DataSource } from './data-source';
11
- import { CollectionOptions, ICollection, ICollectionManager, IFieldInterface, IRepository, MergeOptions } from './types';
11
+ import { CollectionOptions, ICollection, ICollectionManager, IField, IFieldInterface, IRepository, MergeOptions } from './types';
12
12
  export declare class SequelizeCollectionManager implements ICollectionManager {
13
13
  db: Database;
14
14
  options: any;
@@ -35,4 +35,5 @@ export declare class SequelizeCollectionManager implements ICollectionManager {
35
35
  getFieldInterface(name: string): {
36
36
  new (options: any): IFieldInterface | undefined;
37
37
  };
38
+ isNumericField(field?: IField): boolean;
38
39
  }
@@ -31,6 +31,7 @@ __export(sequelize_collection_manager_exports, {
31
31
  });
32
32
  module.exports = __toCommonJS(sequelize_collection_manager_exports);
33
33
  var import_database = require("@nocobase/database");
34
+ var import_utils = require("./utils");
34
35
  /* istanbul ignore file -- @preserve */
35
36
  const _SequelizeCollectionManager = class _SequelizeCollectionManager {
36
37
  db;
@@ -109,6 +110,9 @@ const _SequelizeCollectionManager = class _SequelizeCollectionManager {
109
110
  getFieldInterface(name) {
110
111
  return this.db.interfaceManager.getInterfaceType(name);
111
112
  }
113
+ isNumericField(field) {
114
+ return (0, import_utils.isNumericField)(field);
115
+ }
112
116
  };
113
117
  __name(_SequelizeCollectionManager, "SequelizeCollectionManager");
114
118
  let SequelizeCollectionManager = _SequelizeCollectionManager;
package/lib/types.d.ts CHANGED
@@ -102,6 +102,7 @@ export interface ICollectionManager {
102
102
  registerFieldInterfaces(interfaces: Record<string, new (options: any) => IFieldInterface>): void;
103
103
  registerFieldInterface(name: string, fieldInterface: new (options: any) => IFieldInterface): void;
104
104
  getFieldInterface(name: string): new (options: any) => IFieldInterface | undefined;
105
+ isNumericField(field?: IField): boolean;
105
106
  registerCollectionTemplates(templates: Record<string, any>): void;
106
107
  registerModels(models: Record<string, any>): void;
107
108
  registerRepositories(repositories: Record<string, new (collection: ICollection) => IRepository>): void;
package/lib/utils.d.ts CHANGED
@@ -8,3 +8,8 @@
8
8
  */
9
9
  export declare function parseCollectionName(collection: string): string[];
10
10
  export declare function joinCollectionName(dataSourceName: string, collectionName: string): string;
11
+ export declare function isNumericField(field?: {
12
+ options?: {
13
+ type?: string;
14
+ };
15
+ }): boolean;
package/lib/utils.js CHANGED
@@ -27,6 +27,7 @@ var __copyProps = (to, from, except, desc) => {
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
  var utils_exports = {};
29
29
  __export(utils_exports, {
30
+ isNumericField: () => isNumericField,
30
31
  joinCollectionName: () => joinCollectionName,
31
32
  parseCollectionName: () => parseCollectionName
32
33
  });
@@ -48,8 +49,16 @@ function joinCollectionName(dataSourceName, collectionName) {
48
49
  return `${dataSourceName}:${collectionName}`;
49
50
  }
50
51
  __name(joinCollectionName, "joinCollectionName");
52
+ const NUMERIC_FIELD_TYPES = /* @__PURE__ */ new Set(["integer", "bigInt", "float", "double", "decimal"]);
53
+ function isNumericField(field) {
54
+ var _a;
55
+ const fieldType = (_a = field == null ? void 0 : field.options) == null ? void 0 : _a.type;
56
+ return typeof fieldType === "string" && NUMERIC_FIELD_TYPES.has(fieldType);
57
+ }
58
+ __name(isNumericField, "isNumericField");
51
59
  // Annotate the CommonJS export names for ESM import in node:
52
60
  0 && (module.exports = {
61
+ isNumericField,
53
62
  joinCollectionName,
54
63
  parseCollectionName
55
64
  });
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@nocobase/data-source-manager",
3
- "version": "2.1.0-beta.2",
3
+ "version": "2.1.0-beta.20",
4
4
  "description": "",
5
- "license": "AGPL-3.0",
5
+ "license": "Apache-2.0",
6
6
  "main": "./lib/index.js",
7
7
  "types": "./lib/index.d.ts",
8
8
  "dependencies": {
9
- "@nocobase/actions": "2.1.0-beta.2",
10
- "@nocobase/cache": "2.1.0-beta.2",
11
- "@nocobase/database": "2.1.0-beta.2",
12
- "@nocobase/resourcer": "2.1.0-beta.2",
13
- "@nocobase/utils": "2.1.0-beta.2",
9
+ "@nocobase/actions": "2.1.0-beta.20",
10
+ "@nocobase/cache": "2.1.0-beta.20",
11
+ "@nocobase/database": "2.1.0-beta.20",
12
+ "@nocobase/resourcer": "2.1.0-beta.20",
13
+ "@nocobase/utils": "2.1.0-beta.20",
14
14
  "@types/jsonwebtoken": "^8.5.8",
15
15
  "jsonwebtoken": "^9.0.2"
16
16
  },
@@ -19,5 +19,5 @@
19
19
  "url": "git+https://github.com/nocobase/nocobase.git",
20
20
  "directory": "packages/auth"
21
21
  },
22
- "gitHead": "d80433799fb4a8d59ded4d7eea114d585a137ea0"
22
+ "gitHead": "5515f27380c0c5410f7d1e5e5858364fcd838e5e"
23
23
  }