@nocobase/plugin-data-source-main 2.1.0-alpha.3 → 2.1.0-alpha.31
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/LICENSE +201 -661
- package/README.md +79 -10
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +9 -8
- package/dist/server/mcp-post-processors.d.ts +19 -0
- package/dist/server/mcp-post-processors.js +90 -0
- package/dist/server/migrations/20251214100636-id2integer.js +1 -1
- package/dist/server/modeling/capabilities.d.ts +62 -0
- package/dist/server/modeling/capabilities.js +175 -0
- package/dist/server/modeling/collections.d.ts +114 -0
- package/dist/server/modeling/collections.js +257 -0
- package/dist/server/modeling/constants.d.ts +26 -0
- package/dist/server/modeling/constants.js +225 -0
- package/dist/server/modeling/fields.d.ts +13 -0
- package/dist/server/modeling/fields.js +566 -0
- package/dist/server/modeling/service.d.ts +36 -0
- package/dist/server/modeling/service.js +170 -0
- package/dist/server/models/collection.js +4 -3
- package/dist/server/models/field.d.ts +1 -0
- package/dist/server/models/field.js +21 -0
- package/dist/server/repositories/collection-repository.js +6 -0
- package/dist/server/resourcers/collections.d.ts +5 -0
- package/dist/server/resourcers/collections.js +87 -66
- package/dist/server/server.js +5 -2
- package/dist/swagger/index.d.ts +1373 -32
- package/dist/swagger/index.js +1102 -68
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
# NocoBase
|
|
2
2
|
|
|
3
3
|
<video width="100%" controls>
|
|
4
|
-
|
|
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-first, open-source no-code 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
|
|
11
|
-
|
|
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
|
-
|
|
23
|
-
https://
|
|
29
|
+
Forum:
|
|
30
|
+
https://forum.nocobase.com/
|
|
24
31
|
|
|
25
|
-
|
|
26
|
-
https://www.nocobase.com/en/
|
|
32
|
+
Use Cases:
|
|
33
|
+
https://www.nocobase.com/en/blog/tags/customer-stories
|
|
27
34
|
|
|
35
|
+
## Release Notes
|
|
28
36
|
|
|
29
|
-
|
|
30
|
-
|
|
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
|
+

|
|
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
|
+

|
|
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
|
+

|
|
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
|
+

|
|
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>
|
package/dist/client/index.js
CHANGED
|
@@ -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("
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client"),require("lodash")):"function"==typeof define&&define.amd?define("@nocobase/plugin-data-source-main",["@nocobase/client","lodash"],t):"object"==typeof exports?exports["@nocobase/plugin-data-source-main"]=t(require("@nocobase/client"),require("lodash")):e["@nocobase/plugin-data-source-main"]=t(e["@nocobase/client"],e.lodash)}(self,function(e,t){return function(){"use strict";var r={342:function(t){t.exports=e},773:function(e){e.exports=t}},o={};function n(e){var t=o[e];if(void 0!==t)return t.exports;var i=o[e]={exports:{}};return r[e](i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.g.importScripts&&(i=n.g.location+"");var i,a=n.g.document;if(!i&&a&&(a.currentScript&&"SCRIPT"===a.currentScript.tagName.toUpperCase()&&(i=a.currentScript.src),!i)){var c=a.getElementsByTagName("script");if(c.length)for(var u=c.length-1;u>-1&&(!i||!/^http(s?):/.test(i));)i=c[u--].src}if(!i)throw Error("Automatic publicPath is not supported in this browser");n.p=i.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var l={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-data-source-main/dist/client/")}if(!e){if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var o=window.location.pathname||"/",i=o.indexOf("/v2/");e=i>=0?o.slice(0,i+1):"/"}e&&(e=e.replace(/\/v2\/?$/,"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-data-source-main/dist/client/"}n.p=e}(),!function(){n.r(l);var e=n(342),t=n(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 i(e){return(i=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,i(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})()}l.default=function(e){var o;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t,r,o,a;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,r=arguments,t=i(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||[],i(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 n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&a(n,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)}}(n.prototype,o),n}(c(e.Plugin))}(),l}()});
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,15 +8,16 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "2.1.0-alpha.
|
|
12
|
-
"lodash": "4.
|
|
13
|
-
"@nocobase/
|
|
14
|
-
"@nocobase/
|
|
15
|
-
"@nocobase/
|
|
11
|
+
"@nocobase/client": "2.1.0-alpha.31",
|
|
12
|
+
"lodash": "4.18.1",
|
|
13
|
+
"@nocobase/ai": "2.1.0-alpha.31",
|
|
14
|
+
"@nocobase/database": "2.1.0-alpha.31",
|
|
15
|
+
"@nocobase/plugin-error-handler": "2.1.0-alpha.31",
|
|
16
|
+
"@nocobase/server": "2.1.0-alpha.31",
|
|
16
17
|
"sequelize": "6.35.2",
|
|
17
18
|
"@formily/json-schema": "2.3.7",
|
|
18
|
-
"@nocobase/test": "2.1.0-alpha.
|
|
19
|
-
"@nocobase/utils": "2.1.0-alpha.
|
|
20
|
-
"@nocobase/actions": "2.1.0-alpha.
|
|
19
|
+
"@nocobase/test": "2.1.0-alpha.31",
|
|
20
|
+
"@nocobase/utils": "2.1.0-alpha.31",
|
|
21
|
+
"@nocobase/actions": "2.1.0-alpha.31",
|
|
21
22
|
"dayjs": "1.11.13"
|
|
22
23
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import type { McpToolsManager } from '@nocobase/ai';
|
|
10
|
+
export declare function simplifyCollectionsListResult(result: any): {
|
|
11
|
+
data: any;
|
|
12
|
+
meta: any;
|
|
13
|
+
nextActions: string[];
|
|
14
|
+
};
|
|
15
|
+
export declare function simplifyFieldsListResult(result: any): {
|
|
16
|
+
data: any;
|
|
17
|
+
meta: any;
|
|
18
|
+
};
|
|
19
|
+
export declare function registerDataSourceMainMcpPostProcessors(manager: McpToolsManager): void;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var mcp_post_processors_exports = {};
|
|
28
|
+
__export(mcp_post_processors_exports, {
|
|
29
|
+
registerDataSourceMainMcpPostProcessors: () => registerDataSourceMainMcpPostProcessors,
|
|
30
|
+
simplifyCollectionsListResult: () => simplifyCollectionsListResult,
|
|
31
|
+
simplifyFieldsListResult: () => simplifyFieldsListResult
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(mcp_post_processors_exports);
|
|
34
|
+
function toArray(value) {
|
|
35
|
+
if (Array.isArray(value)) {
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
if (Array.isArray(value == null ? void 0 : value.data)) {
|
|
39
|
+
return value.data;
|
|
40
|
+
}
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
function pickCollectionSummary(item) {
|
|
44
|
+
return {
|
|
45
|
+
key: item == null ? void 0 : item.key,
|
|
46
|
+
name: item == null ? void 0 : item.name,
|
|
47
|
+
title: item == null ? void 0 : item.title,
|
|
48
|
+
description: item == null ? void 0 : item.description
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function pickFieldSummary(item) {
|
|
52
|
+
var _a;
|
|
53
|
+
return {
|
|
54
|
+
key: item == null ? void 0 : item.key,
|
|
55
|
+
name: item == null ? void 0 : item.name,
|
|
56
|
+
type: item == null ? void 0 : item.type,
|
|
57
|
+
title: (_a = item == null ? void 0 : item.uiSchema) == null ? void 0 : _a.title,
|
|
58
|
+
description: item == null ? void 0 : item.description,
|
|
59
|
+
collectionName: item == null ? void 0 : item.collectionName
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function simplifyCollectionsListResult(result) {
|
|
63
|
+
const items = toArray(result);
|
|
64
|
+
return {
|
|
65
|
+
data: items.map((item) => pickCollectionSummary(item)),
|
|
66
|
+
meta: result == null ? void 0 : result.meta,
|
|
67
|
+
nextActions: [
|
|
68
|
+
"Use collections:get with filterByTk=<collectionName> to inspect one collection in detail.",
|
|
69
|
+
"Use collections.fields:list with sourceId=<collectionName> to inspect fields when needed."
|
|
70
|
+
]
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function simplifyFieldsListResult(result) {
|
|
74
|
+
const items = toArray(result);
|
|
75
|
+
return {
|
|
76
|
+
data: items.map((item) => pickFieldSummary(item)),
|
|
77
|
+
meta: result == null ? void 0 : result.meta
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function registerDataSourceMainMcpPostProcessors(manager) {
|
|
81
|
+
manager.registerToolResultPostProcessor("collections", "list", simplifyCollectionsListResult);
|
|
82
|
+
manager.registerToolResultPostProcessor("collections", "listMeta", simplifyCollectionsListResult);
|
|
83
|
+
manager.registerToolResultPostProcessor("collections.fields", "list", simplifyFieldsListResult);
|
|
84
|
+
}
|
|
85
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
86
|
+
0 && (module.exports = {
|
|
87
|
+
registerDataSourceMainMcpPostProcessors,
|
|
88
|
+
simplifyCollectionsListResult,
|
|
89
|
+
simplifyFieldsListResult
|
|
90
|
+
});
|
|
@@ -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.
|
|
36
|
+
appVersion = "<2.1.0";
|
|
37
37
|
async up() {
|
|
38
38
|
const repo = this.db.getRepository("fields");
|
|
39
39
|
await repo.update({
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { PlainObject, TemplateName } from './constants';
|
|
10
|
+
export declare function getPluginRequirement(interfaceOrTemplate?: string): {
|
|
11
|
+
runtimeName: string;
|
|
12
|
+
packageName: string;
|
|
13
|
+
capability: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function assertModelingSupport(app: any, input: {
|
|
16
|
+
template?: TemplateName;
|
|
17
|
+
fields?: PlainObject[];
|
|
18
|
+
viewName?: string;
|
|
19
|
+
schema?: string;
|
|
20
|
+
inherits?: string | string[];
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
export declare function inspectModeling(app: any, collectionName?: string): {
|
|
23
|
+
templates: TemplateName[];
|
|
24
|
+
pluginStates: {
|
|
25
|
+
name: any;
|
|
26
|
+
packageName: any;
|
|
27
|
+
enabled: any;
|
|
28
|
+
}[];
|
|
29
|
+
collections: {
|
|
30
|
+
name: any;
|
|
31
|
+
title: any;
|
|
32
|
+
template: any;
|
|
33
|
+
}[];
|
|
34
|
+
name?: undefined;
|
|
35
|
+
options?: undefined;
|
|
36
|
+
fields?: undefined;
|
|
37
|
+
} | {
|
|
38
|
+
name: any;
|
|
39
|
+
options: any;
|
|
40
|
+
fields: any[];
|
|
41
|
+
pluginStates: {
|
|
42
|
+
name: any;
|
|
43
|
+
packageName: any;
|
|
44
|
+
enabled: any;
|
|
45
|
+
}[];
|
|
46
|
+
templates?: undefined;
|
|
47
|
+
collections?: undefined;
|
|
48
|
+
};
|
|
49
|
+
export declare function verifyCollectionDefinition(app: any, collectionName: string): {
|
|
50
|
+
valid: boolean;
|
|
51
|
+
issues: string[];
|
|
52
|
+
data: {
|
|
53
|
+
name: any;
|
|
54
|
+
template: any;
|
|
55
|
+
fields: {
|
|
56
|
+
name: any;
|
|
57
|
+
interface: any;
|
|
58
|
+
type: any;
|
|
59
|
+
title: any;
|
|
60
|
+
}[];
|
|
61
|
+
};
|
|
62
|
+
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
var capabilities_exports = {};
|
|
38
|
+
__export(capabilities_exports, {
|
|
39
|
+
assertModelingSupport: () => assertModelingSupport,
|
|
40
|
+
getPluginRequirement: () => getPluginRequirement,
|
|
41
|
+
inspectModeling: () => inspectModeling,
|
|
42
|
+
verifyCollectionDefinition: () => verifyCollectionDefinition
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(capabilities_exports);
|
|
45
|
+
var import_lodash = __toESM(require("lodash"));
|
|
46
|
+
var import_constants = require("./constants");
|
|
47
|
+
var import_fields = require("./fields");
|
|
48
|
+
function getPluginRequirement(interfaceOrTemplate) {
|
|
49
|
+
return interfaceOrTemplate ? import_constants.PLUGIN_REQUIREMENTS[interfaceOrTemplate] : void 0;
|
|
50
|
+
}
|
|
51
|
+
async function assertModelingSupport(app, input) {
|
|
52
|
+
var _a;
|
|
53
|
+
const required = import_lodash.default.uniqBy(
|
|
54
|
+
[
|
|
55
|
+
input.template ? getPluginRequirement(input.template) : void 0,
|
|
56
|
+
...(input.fields || []).map((field) => getPluginRequirement((0, import_fields.normalizeInterfaceName)(field.interface)))
|
|
57
|
+
].filter(Boolean),
|
|
58
|
+
"runtimeName"
|
|
59
|
+
);
|
|
60
|
+
for (const requirement of required) {
|
|
61
|
+
const plugin = app.pm.get(requirement.runtimeName);
|
|
62
|
+
if (!(plugin == null ? void 0 : plugin.enabled)) {
|
|
63
|
+
throw new Error(
|
|
64
|
+
`${requirement.capability} requires plugin ${requirement.packageName} (runtime name: ${requirement.runtimeName}) to be enabled`
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if ((input.template === "view" || input.viewName) && input.viewName) {
|
|
69
|
+
const views = await app.db.queryInterface.listViews({
|
|
70
|
+
schema: input.schema || process.env.COLLECTION_MANAGER_SCHEMA || ((_a = app.db.options) == null ? void 0 : _a.schema) || process.env.DB_SCHEMA || "public"
|
|
71
|
+
});
|
|
72
|
+
if (!views.find((view) => view.name === input.viewName)) {
|
|
73
|
+
throw new Error(`view collection requires upstream database view ${input.viewName} to exist first`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (input.template === "inherit" && input.inherits) {
|
|
77
|
+
for (const parent of import_lodash.default.castArray(input.inherits)) {
|
|
78
|
+
if (!app.db.hasCollection(parent)) {
|
|
79
|
+
throw new Error(`inherit collection requires parent collection ${parent} to exist first`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function inspectModeling(app, collectionName) {
|
|
85
|
+
const pluginStates = [...app.pm.getPlugins().values()].map((plugin) => {
|
|
86
|
+
var _a;
|
|
87
|
+
return {
|
|
88
|
+
name: plugin.name,
|
|
89
|
+
packageName: (_a = plugin.options) == null ? void 0 : _a.packageName,
|
|
90
|
+
enabled: plugin.enabled
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
if (!collectionName) {
|
|
94
|
+
return {
|
|
95
|
+
templates: import_constants.TEMPLATE_NAMES,
|
|
96
|
+
pluginStates,
|
|
97
|
+
collections: [...app.db.collections.values()].filter((collection2) => {
|
|
98
|
+
var _a;
|
|
99
|
+
return (_a = collection2.options) == null ? void 0 : _a.loadedFromCollectionManager;
|
|
100
|
+
}).map((collection2) => {
|
|
101
|
+
var _a, _b;
|
|
102
|
+
return {
|
|
103
|
+
name: collection2.name,
|
|
104
|
+
title: (_a = collection2.options) == null ? void 0 : _a.title,
|
|
105
|
+
template: (_b = collection2.options) == null ? void 0 : _b.template
|
|
106
|
+
};
|
|
107
|
+
})
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
const collection = app.db.getCollection(collectionName);
|
|
111
|
+
if (!collection) {
|
|
112
|
+
throw new Error(`collection ${collectionName} not found`);
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
name: collection.name,
|
|
116
|
+
options: collection.options,
|
|
117
|
+
fields: [...collection.fields.values()].map((field) => field.options),
|
|
118
|
+
pluginStates
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function verifyCollectionDefinition(app, collectionName) {
|
|
122
|
+
var _a, _b, _c, _d;
|
|
123
|
+
const collection = app.db.getCollection(collectionName);
|
|
124
|
+
if (!collection) {
|
|
125
|
+
throw new Error(`collection ${collectionName} not found`);
|
|
126
|
+
}
|
|
127
|
+
const issues = [];
|
|
128
|
+
const fields = [...collection.fields.values()].map((field) => field.options);
|
|
129
|
+
const fieldNames = new Set(fields.map((field) => field.name));
|
|
130
|
+
const relationBackingFieldNames = new Set(
|
|
131
|
+
fields.flatMap((field) => [field.foreignKey, field.otherKey].filter(Boolean))
|
|
132
|
+
);
|
|
133
|
+
const shouldSkipPresentationChecks = (field) => field.isForeignKey === true || relationBackingFieldNames.has(field.name) || ["exclude", "meta", "sort"].includes(field.name);
|
|
134
|
+
if (!((_a = collection.options) == null ? void 0 : _a.template)) {
|
|
135
|
+
issues.push("Collection template is missing.");
|
|
136
|
+
}
|
|
137
|
+
if (!fieldNames.has("id") && ((_b = collection.options) == null ? void 0 : _b.template) !== "view") {
|
|
138
|
+
issues.push("Primary key field `id` is missing.");
|
|
139
|
+
}
|
|
140
|
+
for (const field of fields) {
|
|
141
|
+
if (!field.interface && !shouldSkipPresentationChecks(field)) {
|
|
142
|
+
issues.push(`Field ${field.name} is missing interface.`);
|
|
143
|
+
}
|
|
144
|
+
if (!field.type) {
|
|
145
|
+
issues.push(`Field ${field.name} is missing type.`);
|
|
146
|
+
}
|
|
147
|
+
if (!((_c = field.uiSchema) == null ? void 0 : _c.title) && !shouldSkipPresentationChecks(field)) {
|
|
148
|
+
issues.push(`Field ${field.name} is missing uiSchema.title.`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
valid: issues.length === 0,
|
|
153
|
+
issues,
|
|
154
|
+
data: {
|
|
155
|
+
name: collection.name,
|
|
156
|
+
template: (_d = collection.options) == null ? void 0 : _d.template,
|
|
157
|
+
fields: fields.map((field) => {
|
|
158
|
+
var _a2;
|
|
159
|
+
return {
|
|
160
|
+
name: field.name,
|
|
161
|
+
interface: field.interface,
|
|
162
|
+
type: field.type,
|
|
163
|
+
title: (_a2 = field.uiSchema) == null ? void 0 : _a2.title
|
|
164
|
+
};
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
170
|
+
0 && (module.exports = {
|
|
171
|
+
assertModelingSupport,
|
|
172
|
+
getPluginRequirement,
|
|
173
|
+
inspectModeling,
|
|
174
|
+
verifyCollectionDefinition
|
|
175
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { PlainObject } from './constants';
|
|
10
|
+
export declare function buildTemplateBaseline(input: PlainObject): {
|
|
11
|
+
template: "general";
|
|
12
|
+
logging: any;
|
|
13
|
+
autoGenId: boolean;
|
|
14
|
+
fields: PlainObject[];
|
|
15
|
+
view?: undefined;
|
|
16
|
+
tree?: undefined;
|
|
17
|
+
createdBy?: undefined;
|
|
18
|
+
updatedBy?: undefined;
|
|
19
|
+
createdAt?: undefined;
|
|
20
|
+
updatedAt?: undefined;
|
|
21
|
+
sortable?: undefined;
|
|
22
|
+
schema?: undefined;
|
|
23
|
+
inherits?: undefined;
|
|
24
|
+
} | {
|
|
25
|
+
template: "tree";
|
|
26
|
+
logging: any;
|
|
27
|
+
view: boolean;
|
|
28
|
+
tree: any;
|
|
29
|
+
autoGenId: boolean;
|
|
30
|
+
fields: PlainObject[];
|
|
31
|
+
createdBy?: undefined;
|
|
32
|
+
updatedBy?: undefined;
|
|
33
|
+
createdAt?: undefined;
|
|
34
|
+
updatedAt?: undefined;
|
|
35
|
+
sortable?: undefined;
|
|
36
|
+
schema?: undefined;
|
|
37
|
+
inherits?: undefined;
|
|
38
|
+
} | {
|
|
39
|
+
template: "file";
|
|
40
|
+
logging: any;
|
|
41
|
+
view: boolean;
|
|
42
|
+
createdBy: boolean;
|
|
43
|
+
updatedBy: boolean;
|
|
44
|
+
fields: PlainObject[];
|
|
45
|
+
autoGenId?: undefined;
|
|
46
|
+
tree?: undefined;
|
|
47
|
+
createdAt?: undefined;
|
|
48
|
+
updatedAt?: undefined;
|
|
49
|
+
sortable?: undefined;
|
|
50
|
+
schema?: undefined;
|
|
51
|
+
inherits?: undefined;
|
|
52
|
+
} | {
|
|
53
|
+
template: "calendar";
|
|
54
|
+
logging: any;
|
|
55
|
+
createdBy: boolean;
|
|
56
|
+
updatedBy: boolean;
|
|
57
|
+
createdAt: boolean;
|
|
58
|
+
updatedAt: boolean;
|
|
59
|
+
sortable: any;
|
|
60
|
+
fields: PlainObject[];
|
|
61
|
+
autoGenId?: undefined;
|
|
62
|
+
view?: undefined;
|
|
63
|
+
tree?: undefined;
|
|
64
|
+
schema?: undefined;
|
|
65
|
+
inherits?: undefined;
|
|
66
|
+
} | {
|
|
67
|
+
template: "view";
|
|
68
|
+
view: boolean;
|
|
69
|
+
schema: any;
|
|
70
|
+
logging?: undefined;
|
|
71
|
+
autoGenId?: undefined;
|
|
72
|
+
fields?: undefined;
|
|
73
|
+
tree?: undefined;
|
|
74
|
+
createdBy?: undefined;
|
|
75
|
+
updatedBy?: undefined;
|
|
76
|
+
createdAt?: undefined;
|
|
77
|
+
updatedAt?: undefined;
|
|
78
|
+
sortable?: undefined;
|
|
79
|
+
inherits?: undefined;
|
|
80
|
+
} | {
|
|
81
|
+
template: "inherit";
|
|
82
|
+
inherits: any;
|
|
83
|
+
logging?: undefined;
|
|
84
|
+
autoGenId?: undefined;
|
|
85
|
+
fields?: undefined;
|
|
86
|
+
view?: undefined;
|
|
87
|
+
tree?: undefined;
|
|
88
|
+
createdBy?: undefined;
|
|
89
|
+
updatedBy?: undefined;
|
|
90
|
+
createdAt?: undefined;
|
|
91
|
+
updatedAt?: undefined;
|
|
92
|
+
sortable?: undefined;
|
|
93
|
+
schema?: undefined;
|
|
94
|
+
} | {
|
|
95
|
+
template: "sql";
|
|
96
|
+
logging?: undefined;
|
|
97
|
+
autoGenId?: undefined;
|
|
98
|
+
fields?: undefined;
|
|
99
|
+
view?: undefined;
|
|
100
|
+
tree?: undefined;
|
|
101
|
+
createdBy?: undefined;
|
|
102
|
+
updatedBy?: undefined;
|
|
103
|
+
createdAt?: undefined;
|
|
104
|
+
updatedAt?: undefined;
|
|
105
|
+
sortable?: undefined;
|
|
106
|
+
schema?: undefined;
|
|
107
|
+
inherits?: undefined;
|
|
108
|
+
};
|
|
109
|
+
export declare function normalizeCollectionInput(input: PlainObject, options?: {
|
|
110
|
+
mode?: 'create' | 'update';
|
|
111
|
+
}): PlainObject;
|
|
112
|
+
export declare function composeCollectionDefinition(input: PlainObject, options?: {
|
|
113
|
+
mode?: 'create' | 'update';
|
|
114
|
+
}): PlainObject;
|