@nocobase/plugin-data-source-main 2.1.0-alpha.12 → 2.1.0-alpha.14

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.
@@ -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("@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={},s=window.__nocobase_public_path__||"";if(!s&&window.location&&window.location.pathname){var p=window.location.pathname||"/",d=p.indexOf("/v2/");s=d>=0?p.slice(0,d+1):"/"}return s&&(s=s.replace(/\/v2\/?$/,"/")),s||(s="/"),"/"!==s.charAt(s.length-1)&&(s+="/"),n.p=s+"static/plugins/@nocobase/plugin-data-source-main/dist/client/",!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}()});
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}()});
@@ -8,15 +8,16 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.1.0-alpha.12",
11
+ "@nocobase/client": "2.1.0-alpha.14",
12
12
  "lodash": "4.17.21",
13
- "@nocobase/database": "2.1.0-alpha.12",
14
- "@nocobase/plugin-error-handler": "2.1.0-alpha.12",
15
- "@nocobase/server": "2.1.0-alpha.12",
13
+ "@nocobase/ai": "2.1.0-alpha.14",
14
+ "@nocobase/database": "2.1.0-alpha.14",
15
+ "@nocobase/plugin-error-handler": "2.1.0-alpha.14",
16
+ "@nocobase/server": "2.1.0-alpha.14",
16
17
  "sequelize": "6.35.2",
17
18
  "@formily/json-schema": "2.3.7",
18
- "@nocobase/test": "2.1.0-alpha.12",
19
- "@nocobase/utils": "2.1.0-alpha.12",
20
- "@nocobase/actions": "2.1.0-alpha.12",
19
+ "@nocobase/test": "2.1.0-alpha.14",
20
+ "@nocobase/utils": "2.1.0-alpha.14",
21
+ "@nocobase/actions": "2.1.0-alpha.14",
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
+ });
@@ -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, _e;
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) !== "calendar" && ((_c = collection.options) == null ? void 0 : _c.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 (!((_d = field.uiSchema) == null ? void 0 : _d.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: (_e = collection.options) == null ? void 0 : _e.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;