@nocobase/plugin-data-source-main 2.1.0-alpha.1 → 2.1.0-alpha.10

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,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("lodash"),require("@nocobase/client")):"function"==typeof define&&define.amd?define("@nocobase/plugin-data-source-main",["lodash","@nocobase/client"],t):"object"==typeof exports?exports["@nocobase/plugin-data-source-main"]=t(require("lodash"),require("@nocobase/client")):e["@nocobase/plugin-data-source-main"]=t(e.lodash,e["@nocobase/client"])}(self,function(e,t){return function(){"use strict";var r={772:function(e){e.exports=t},467:function(t){t.exports=e}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={exports:{}};return r[e](i,i.exports,o),i.exports}o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,{a:t}),t},o.d=function(e,t){for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return!function(){o.r(i);var e=o(772),t=o(467);function r(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){r(e);return}c.done?t(u):Promise.resolve(u).then(n,o)}function n(e,t,r){return(n=l()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&c(o,r.prototype),o}).apply(null,arguments)}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e){var t="function"==typeof Map?new Map:void 0;return(u=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return n(e,arguments,a(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),c(r,e)})(e)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(l=function(){return!!e})()}i.default=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function o(){var e,t,r,n,i;if(!(this instanceof o))throw TypeError("Cannot call a class as a function");return t=o,r=arguments,t=a(t),e=function(e,t){var r;if(t&&("object"==((r=t)&&"undefined"!=typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,l()?Reflect.construct(t,r||[],a(this).constructor):t.apply(this,r)),i=[],(n="collectionPresetFields")in e?Object.defineProperty(e,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[n]=i,e}return o.prototype=Object.create(e&&e.prototype,{constructor:{value:o,writable:!0,configurable:!0}}),e&&c(o,e),n=[{key:"addCollectionPresetField",value:function(e){this.collectionPresetFields.push(e)}},{key:"removeCollectionPresetField",value:function(e){this.collectionPresetFields=(0,t.reject)(this.collectionPresetFields,function(t){return t.value.name===e})}},{key:"getCollectionPresetFields",value:function(){return(0,t.orderBy)(this.collectionPresetFields,["order"],["asc"])}},{key:"load",value:function(){var e,t=this;return(e=function(){return function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){var u=[i,c];if(r)throw TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){return t.addCollectionPresetField({order:100,description:'{{t("Primary key, distributed uniqueness, time-ordering") }}',value:{name:"id",type:"snowflakeId",autoIncrement:!1,primaryKey:!0,allowNull:!1,uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"InputNumber","x-component-props":{stringMode:!0,separator:"0.00",step:"1"},"x-validator":"integer"},interface:"snowflakeId"}}),t.addCollectionPresetField({order:200,description:'{{t("Store the creation time of each record")}}',value:{name:"createdAt",interface:"createdAt",type:"date",field:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}}}),t.addCollectionPresetField({order:300,description:'{{t("Store the creation user of each record") }}',value:{name:"createdBy",interface:"createdBy",type:"belongsTo",target:"users",foreignKey:"createdById",uiSchema:{type:"object",title:'{{t("Created by")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"nickname"}},"x-read-pretty":!0}}}),t.addCollectionPresetField({order:400,description:'{{t("Store the last update time of each record")}}',value:{type:"date",field:"updatedAt",name:"updatedAt",interface:"updatedAt",uiSchema:{type:"datetime",title:'{{t("Last updated at")}}',"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}}}),t.addCollectionPresetField({order:500,description:'{{t("Store the last update user of each record")}}',value:{type:"belongsTo",target:"users",foreignKey:"updatedById",name:"updatedBy",interface:"updatedBy",uiSchema:{type:"object",title:'{{t("Last updated by")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"nickname"}},"x-read-pretty":!0}}}),[2]})},function(){var t=this,n=arguments;return new Promise(function(o,i){var a=e.apply(t,n);function c(e){r(a,o,i,c,u,"next",e)}function u(e){r(a,o,i,c,u,"throw",e)}c(void 0)})})()}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(o.prototype,n),o}(u(e.Plugin))}(),i}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("lodash"),require("@nocobase/client")):"function"==typeof define&&define.amd?define("@nocobase/plugin-data-source-main",["lodash","@nocobase/client"],t):"object"==typeof exports?exports["@nocobase/plugin-data-source-main"]=t(require("lodash"),require("@nocobase/client")):e["@nocobase/plugin-data-source-main"]=t(e.lodash,e["@nocobase/client"])}(self,function(e,t){return function(){"use strict";var r,o={342:function(e){e.exports=t},773:function(t){t.exports=e}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return o[e](r,r.exports,i),r.exports}i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,{a:t}),t},i.d=function(e,t){for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.g.importScripts&&(a=i.g.location+"");var a,c=i.g.document;if(!a&&c&&(c.currentScript&&"SCRIPT"===c.currentScript.tagName.toUpperCase()&&(a=c.currentScript.src),!a)){var u=c.getElementsByTagName("script");if(u.length)for(var l=u.length-1;l>-1&&(!a||!/^http(s?):/.test(a));)a=u[l--].src}if(!a)throw Error("Automatic publicPath is not supported in this browser");i.p=a.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var s={};return"/"!==(r=window.__webpack_public_path__||"/").charAt(r.length-1)&&(r+="/"),i.p=r+"static/plugins/@nocobase/plugin-data-source-main/dist/client/",!function(){i.r(s);var e=i(342),t=i(773);function r(e,t,r,o,n,i,a){try{var c=e[i](a),u=c.value}catch(e){r(e);return}c.done?t(u):Promise.resolve(u).then(o,n)}function o(e,t,r){return(o=u()?Reflect.construct:function(e,t,r){var o=[null];o.push.apply(o,t);var n=new(Function.bind.apply(e,o));return r&&a(n,r.prototype),n}).apply(null,arguments)}function n(e){return(n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){var t="function"==typeof Map?new Map:void 0;return(c=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return o(e,arguments,n(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),a(r,e)})(e)}function u(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(u=function(){return!!e})()}s.default=function(e){var o;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function i(){var e,t,r,o,a;if(!(this instanceof i))throw TypeError("Cannot call a class as a function");return t=i,r=arguments,t=n(t),e=function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,u()?Reflect.construct(t,r||[],n(this).constructor):t.apply(this,r)),a=[],(o="collectionPresetFields")in e?Object.defineProperty(e,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[o]=a,e}return i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&a(i,e),o=[{key:"addCollectionPresetField",value:function(e){this.collectionPresetFields.push(e)}},{key:"removeCollectionPresetField",value:function(e){this.collectionPresetFields=(0,t.reject)(this.collectionPresetFields,function(t){return t.value.name===e})}},{key:"getCollectionPresetFields",value:function(){return(0,t.orderBy)(this.collectionPresetFields,["order"],["asc"])}},{key:"load",value:function(){var e;return(e=function(){return function(e,t){var r,o,n,i={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(a,"next",{value:u(0)}),c(a,"throw",{value:u(1)}),c(a,"return",{value:u(2)}),"function"==typeof Symbol&&c(a,Symbol.iterator,{value:function(){return this}}),a;function u(c){return function(u){var l=[c,u];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(r=1,o&&(n=2&l[0]?o.return:l[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,l[1])).done)return n;switch(o=0,n&&(l=[2&l[0],n.value]),l[0]){case 0:case 1:n=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,o=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(n=(n=i.trys).length>0&&n[n.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!n||l[1]>n[0]&&l[1]<n[3])){i.label=l[1];break}if(6===l[0]&&i.label<n[1]){i.label=n[1],n=l;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(l);break}n[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],o=0}finally{r=n=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(e){return this.addCollectionPresetField({order:100,description:'{{t("Primary key, distributed uniqueness, time-ordering") }}',value:{name:"id",type:"snowflakeId",autoIncrement:!1,primaryKey:!0,allowNull:!1,uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"InputNumber","x-component-props":{stringMode:!0,separator:"0.00",step:"1"},"x-validator":"integer"},interface:"snowflakeId"}}),this.addCollectionPresetField({order:200,description:'{{t("Store the creation time of each record")}}',value:{name:"createdAt",interface:"createdAt",type:"date",field:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}}}),this.addCollectionPresetField({order:300,description:'{{t("Store the creation user of each record") }}',value:{name:"createdBy",interface:"createdBy",type:"belongsTo",target:"users",foreignKey:"createdById",uiSchema:{type:"object",title:'{{t("Created by")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"nickname"}},"x-read-pretty":!0}}}),this.addCollectionPresetField({order:400,description:'{{t("Store the last update time of each record")}}',value:{type:"date",field:"updatedAt",name:"updatedAt",interface:"updatedAt",uiSchema:{type:"datetime",title:'{{t("Last updated at")}}',"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}}}),this.addCollectionPresetField({order:500,description:'{{t("Store the last update user of each record")}}',value:{type:"belongsTo",target:"users",foreignKey:"updatedById",name:"updatedBy",interface:"updatedBy",uiSchema:{type:"object",title:'{{t("Last updated by")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"nickname"}},"x-read-pretty":!0}}}),[2]})},function(){var t=this,o=arguments;return new Promise(function(n,i){var a=e.apply(t,o);function c(e){r(a,n,i,c,u,"next",e)}function u(e){r(a,n,i,c,u,"throw",e)}c(void 0)})}).call(this)}}],function(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(i.prototype,o),i}(c(e.Plugin))}(),s}()});
@@ -8,15 +8,15 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.1.0-alpha.1",
11
+ "@nocobase/client": "2.1.0-alpha.10",
12
12
  "lodash": "4.17.21",
13
- "@nocobase/database": "2.1.0-alpha.1",
14
- "@nocobase/plugin-error-handler": "2.1.0-alpha.1",
15
- "@nocobase/server": "2.1.0-alpha.1",
13
+ "@nocobase/database": "2.1.0-alpha.10",
14
+ "@nocobase/plugin-error-handler": "2.1.0-alpha.10",
15
+ "@nocobase/server": "2.1.0-alpha.10",
16
16
  "sequelize": "6.35.2",
17
17
  "@formily/json-schema": "2.3.7",
18
- "@nocobase/test": "2.1.0-alpha.1",
19
- "@nocobase/utils": "2.1.0-alpha.1",
20
- "@nocobase/actions": "2.1.0-alpha.1",
18
+ "@nocobase/test": "2.1.0-alpha.10",
19
+ "@nocobase/utils": "2.1.0-alpha.10",
20
+ "@nocobase/actions": "2.1.0-alpha.10",
21
21
  "dayjs": "1.11.13"
22
22
  };
@@ -33,7 +33,7 @@ var import_server = require("@nocobase/server");
33
33
  class id2integer_default extends import_server.Migration {
34
34
  on = "afterLoad";
35
35
  // 'beforeLoad' or 'afterLoad'
36
- appVersion = "<2.0.0";
36
+ appVersion = "<2.1.0";
37
37
  async up() {
38
38
  const repo = this.db.getRepository("fields");
39
39
  await repo.update({
@@ -88,8 +88,8 @@ class CollectionModel extends import_database.MagicAttributeModel {
88
88
  if (!collectionOptions.dumpRules) {
89
89
  import_lodash.default.set(collectionOptions, "dumpRules.group", "custom");
90
90
  }
91
- const fieldRepo = this.db.getRepository("collections.fields", name);
92
- const fieldModels = await fieldRepo.find({ transaction });
91
+ const fieldModel = this.db.getModel("fields");
92
+ const fieldModels = await fieldModel.findAll({ where: { collectionName: name }, transaction });
93
93
  collectionOptions["fieldModels"] = fieldModels;
94
94
  collection = this.db.collection(collectionOptions);
95
95
  }
@@ -12,6 +12,7 @@ interface LoadOptions extends Transactionable {
12
12
  }
13
13
  export declare class FieldModel extends MagicAttributeModel {
14
14
  get db(): Database;
15
+ set(key: any, value?: any, options?: any): this;
15
16
  isAssociationField(): boolean;
16
17
  load(loadOptions?: LoadOptions): Promise<import("@nocobase/database").Field>;
17
18
  syncSortByField(options: Transactionable): Promise<void>;
@@ -45,6 +45,24 @@ class FieldModel extends import_database.MagicAttributeModel {
45
45
  get db() {
46
46
  return this.constructor.database;
47
47
  }
48
+ set(key, value, options) {
49
+ if (typeof key === "string") {
50
+ if (key === "defaultValue") {
51
+ return this.setV1(`${this.magicAttribute}.defaultValue`, value, options);
52
+ }
53
+ return super.set(key, value, options);
54
+ }
55
+ if (import_lodash.default.isPlainObject(key) && Object.prototype.hasOwnProperty.call(key, "defaultValue")) {
56
+ const { defaultValue, ...rest } = key;
57
+ const setOptions = value;
58
+ if (Object.keys(rest).length) {
59
+ super.set(rest, setOptions);
60
+ }
61
+ this.setV1(`${this.magicAttribute}.defaultValue`, defaultValue, setOptions);
62
+ return this;
63
+ }
64
+ return super.set(key, value, options);
65
+ }
48
66
  isAssociationField() {
49
67
  return ["belongsTo", "hasOne", "hasMany", "belongsToMany"].includes(this.get("type"));
50
68
  }
@@ -103,6 +121,9 @@ class FieldModel extends import_database.MagicAttributeModel {
103
121
  async syncUniqueIndex(options) {
104
122
  const unique = this.get("unique");
105
123
  const collection = this.getFieldCollection();
124
+ if (!collection) {
125
+ return;
126
+ }
106
127
  const field = collection.getField(this.get("name"));
107
128
  const columnName = collection.model.rawAttributes[this.get("name")].field;
108
129
  const tableName = collection.model.tableName;
@@ -415,22 +415,36 @@ class PluginDataSourceMainServer extends import_server.Plugin {
415
415
  this.app.resourceManager.define(import_views.default);
416
416
  this.app.resourceManager.registerActionHandlers(import_collections.default);
417
417
  this.app.resourceManager.define(import_main_data_source.default);
418
- const handleFieldSource = (fields, rawFields) => {
419
- var _a;
420
- for (const field of import_lodash.default.castArray(fields)) {
421
- if (field.get("source")) {
422
- const [collectionSource, fieldSource] = field.get("source").split(".");
423
- const collectionField = (_a = this.app.db.getCollection(collectionSource)) == null ? void 0 : _a.getField(fieldSource);
424
- if (!collectionField) {
425
- continue;
418
+ const handleFieldSource = ({
419
+ fields,
420
+ isRawValue,
421
+ rawFields
422
+ }) => {
423
+ import_lodash.default.castArray(fields).forEach((field, index) => {
424
+ var _a;
425
+ const source = isRawValue ? field.source : field.get("source");
426
+ if (!source) {
427
+ return;
428
+ }
429
+ const [collectionSource, fieldSource] = source.split(".");
430
+ const collectionField = (_a = this.app.db.getCollection(collectionSource)) == null ? void 0 : _a.getField(fieldSource);
431
+ if (!collectionField) {
432
+ return;
433
+ }
434
+ const newOptions = {};
435
+ import_lodash.default.merge(newOptions, import_lodash.default.omit(collectionField.options, "name"));
436
+ const currentValues = isRawValue ? field : field.get();
437
+ import_lodash.default.mergeWith(newOptions, currentValues, (objValue, srcValue) => {
438
+ if (srcValue === null) {
439
+ return objValue;
426
440
  }
427
- const newOptions = {};
428
- import_lodash.default.merge(newOptions, import_lodash.default.omit(collectionField.options, "name"));
429
- import_lodash.default.mergeWith(newOptions, field.get(), (objValue, srcValue) => {
430
- if (srcValue === null) {
431
- return objValue;
432
- }
433
- });
441
+ });
442
+ if (isRawValue) {
443
+ fields[index] = {
444
+ ...field,
445
+ ...newOptions
446
+ };
447
+ } else {
434
448
  field.set("options", newOptions);
435
449
  }
436
450
  const fieldTypes = import_database.fieldTypeMap[this.db.options.dialect];
@@ -442,16 +456,16 @@ class PluginDataSourceMainServer extends import_server.Plugin {
442
456
  field.set("possibleTypes", possibleTypes);
443
457
  }
444
458
  }
445
- }
459
+ });
446
460
  };
447
461
  this.app.resourceManager.use(async function handleFieldSourceMiddleware(ctx, next) {
448
- var _a, _b;
462
+ var _a;
449
463
  await next();
450
- if (ctx.action.resourceName === "collections" && ctx.action.actionName == "list" && ((_a = ctx.action.params) == null ? void 0 : _a.paginate) == "false") {
464
+ if (ctx.action.resourceName === "collections" && ctx.action.actionName == "listMeta") {
451
465
  for (const collection of ctx.body) {
452
- if (collection.get("view")) {
466
+ if (collection.view === true) {
453
467
  const fields = collection.fields;
454
- handleFieldSource(fields);
468
+ handleFieldSource({ fields, isRawValue: true });
455
469
  }
456
470
  }
457
471
  }
@@ -467,10 +481,10 @@ class PluginDataSourceMainServer extends import_server.Plugin {
467
481
  } catch (err) {
468
482
  }
469
483
  }
470
- handleFieldSource(((_b = ctx.action.params) == null ? void 0 : _b.paginate) == "false" ? ctx.body : ctx.body.rows, rawFields);
484
+ handleFieldSource({ fields: ((_a = ctx.action.params) == null ? void 0 : _a.paginate) == "false" ? ctx.body : ctx.body.rows, rawFields });
471
485
  }
472
486
  if (ctx.action.resourceName == "collections.fields" && ctx.action.actionName == "get") {
473
- handleFieldSource(ctx.body);
487
+ handleFieldSource({ fields: ctx.body });
474
488
  }
475
489
  });
476
490
  this.app.db.extendCollection({