@bunnarin/plugin-block-sql-console 2.1.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/README.md ADDED
@@ -0,0 +1 @@
1
+ # @bunnarin/plugin-block-sql-console
package/client-v2.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './dist/client-v2';
2
+ export { default } from './dist/client-v2';
package/client-v2.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/client-v2/index.js');
package/client.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './dist/client';
2
+ export { default } from './dist/client';
package/client.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/client/index.js');
@@ -0,0 +1 @@
1
+ export { default } from './plugin';
@@ -0,0 +1,10 @@
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
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("antd"),require("@nocobase/client"),require("@ant-design/icons"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@bunnarin/plugin-block-sql-console",["react","antd","@nocobase/client","@ant-design/icons","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@bunnarin/plugin-block-sql-console"]=t(require("react"),require("antd"),require("@nocobase/client"),require("@ant-design/icons"),require("@nocobase/flow-engine")):e["@bunnarin/plugin-block-sql-console"]=t(e.react,e.antd,e["@nocobase/client"],e["@ant-design/icons"],e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o){return function(){"use strict";var a={375:function(e){e.exports=r},342:function(e){e.exports=n},694:function(e){e.exports=o},59:function(e){e.exports=t},155:function(t){t.exports=e}},l={};function u(e){var t=l[e];if(void 0!==t)return t.exports;var n=l[e]={exports:{}};return a[e](n,n.exports,u),n.exports}u.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(t,{a:t}),t},u.d=function(e,t){for(var n in t)u.o(t,n)&&!u.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},u.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),u.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},u.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.g.importScripts&&(c=u.g.location+"");var c,i=u.g.document;if(!c&&i&&(i.currentScript&&"SCRIPT"===i.currentScript.tagName.toUpperCase()&&(c=i.currentScript.src),!c)){var s=i.getElementsByTagName("script");if(s.length)for(var p=s.length-1;p>-1&&(!c||!/^http(s?):/.test(c));)c=s[p--].src}if(!c)throw Error("Automatic publicPath is not supported in this browser");u.p=c.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var f={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@bunnarin/plugin-block-sql-console/dist/client/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@bunnarin/plugin-block-sql-console/dist/client/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",a="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var l=window.location.pathname||"/",c=l.indexOf(a);e=c>=0?l.slice(0,c+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@bunnarin/plugin-block-sql-console/dist/client/"}u.p=e}(),!function(){u.r(f),u.d(f,{default:function(){return C}});var e=u(342),t=u(155),n=u.n(t),r=u(694),o=u(59),a=u(375);function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function c(e,t,n,r,o,a,l){try{var u=e[a](l),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function i(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function l(e){c(a,r,o,l,u,"next",e)}function u(e){c(a,r,o,l,u,"throw",e)}l(void 0)})}}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){s(e,t,n[t])})}return e}function y(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function d(e,t){return(d=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function b(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],l=!0,u=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);l=!0);}catch(e){u=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(u)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return l(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return l(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function g(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(g=function(){return!!e})()}function v(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(l,"next",{value:c(0)}),u(l,"throw",{value:c(1)}),u(l,"return",{value:c(2)}),"function"==typeof Symbol&&u(l,Symbol.iterator,{value:function(){return this}}),l;function c(u){return function(c){var i=[u,c];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,i[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}}var S=function(e){navigator.clipboard.writeText(e).then(function(){return o.message.success("Copied to clipboard")}).catch(function(e){return o.message.error("Failed to copy: "+e)})},w=function(r){r.blockUid;var l=(0,e.useAPIClient)(),u=b((0,t.useState)(""),2),c=u[0],p=u[1],f=b((0,t.useState)({}),2),d=f[0],g=f[1],w=b((0,t.useState)([]),2),E=w[0],O=w[1],x=b((0,t.useState)([]),2),T=x[0],k=x[1],P=b((0,t.useState)(!1),2),j=P[0],q=P[1],_=b((0,t.useState)(!1),2),A=_[0],C=_[1],I=b((0,t.useState)(null),2),R=I[0],$=I[1],F=b((0,t.useState)(null),2),L=F[0],U=F[1],N=Array.from(new Set(Array.from(c.matchAll(/\$([a-zA-Z0-9_]+)/g)).map(function(e){return e[1]}))),M=function(e){var t=e.trim().replace(/\s+/g," "),n=t.match(/^UPDATE\s+([a-zA-Z0-9_"]+)\s+SET\s+(?:.*?)(\s+WHERE\s+.*)?$/i);if(n)return"SELECT count(*) as count FROM ".concat(n[1]).concat(n[2]||"");var r=t.match(/^DELETE\s+FROM\s+([a-zA-Z0-9_"]+)(\s+WHERE\s+.*)?$/i);return r?"SELECT count(*) as count FROM ".concat(r[1]).concat(r[2]||""):null},B=function(e){Array.isArray(e)&&e.length>0?(k(Object.keys(e[0]).map(function(e){return{title:e,dataIndex:e,key:e,render:function(e){return(void 0===e?"undefined":h(e))==="object"&&null!==e?JSON.stringify(e):String(null!=e?e:"")}}})),O(e)):(k([]),O([]),o.message.success("Execution completed, no rows returned."))},Q=(0,t.useCallback)(function(e){return i(function(){var t,n,r,a,u,c;return v(this,function(i){switch(i.label){case 0:q(!0),i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,l.request({url:"flowSql:run",method:"POST",data:{sql:e,type:"selectRows",bind:d}})];case 2:return B(null==(t=i.sent().data)?void 0:t.data),[3,5];case 3:return c=null==(n=i.sent())||null==(u=n.response)||null==(a=u.data)||null==(r=a.error)?void 0:r.message,o.message.error(c||n.message||"Execution failed"),[3,5];case 4:return q(!1),[7];case 5:return[2]}})})()},[l,d]);return n().createElement(o.Space,{direction:"vertical",style:{width:"100%",display:"flex"}},n().createElement(o.Input.TextArea,{style:{fontFamily:"monospace",minHeight:180},value:c,onChange:function(e){return p(e.target.value)},placeholder:"Enter SQL query... e.g. SELECT * FROM users WHERE status = $status LIMIT 10"}),N.length>0&&n().createElement(o.Form,{layout:"inline",style:{flexWrap:"wrap",gap:8}},N.map(function(e){return n().createElement(o.Form.Item,{key:e,label:n().createElement(o.Tag,{color:"blue"},"$",e),style:{marginBottom:8}},n().createElement(o.Input,{placeholder:"Value for $".concat(e),value:d[e]||"",onChange:function(t){return g(function(n){return y(m({},n),s({},e,t.target.value))})},style:{width:160}}))})),n().createElement(o.Space,null,n().createElement(o.Button,{type:"primary",icon:n().createElement(a.PlayCircleOutlined,null),onClick:function(){return i(function(){var e,t,n;return v(this,function(r){switch(r.label){case 0:if(!c.trim())return o.message.warning("Please enter a SQL query"),[2];if(!/^(UPDATE|DELETE)\b/i.test(c.trim()))return[3,8];if(!(e=M(c)))return[3,6];q(!0),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,l.request({url:"flowSql:run",method:"POST",data:{sql:e,type:"selectVar",bind:d}})];case 2:return $(null!=(t=Number(null==(n=r.sent().data)?void 0:n.data))?t:0),[3,5];case 3:return r.sent(),$(null),[3,5];case 4:return q(!1),[7];case 5:return[3,7];case 6:$(null),r.label=7;case 7:return U(c),C(!0),[3,9];case 8:Q(c),r.label=9;case 9:return[2]}})})()},loading:j},"Run SQL"),E.length>0&&n().createElement(o.Button,{icon:n().createElement(a.CopyOutlined,null),onClick:function(){return S(JSON.stringify(E,null,2))}},"Copy JSON")),T.length>0&&n().createElement(o.Table,{columns:T,dataSource:E.map(function(e,t){return y(m({},e),{key:t})}),pagination:!1,size:"small",scroll:{x:"max-content"}}),n().createElement(o.Modal,{title:n().createElement(o.Space,null,n().createElement(a.WarningOutlined,{style:{color:"#faad14"}}),"Confirm Execution"),open:A,onOk:function(){C(!1),L&&(Q(L),U(null))},onCancel:function(){return C(!1)},okText:"Execute",okButtonProps:{danger:!0}},n().createElement(o.Typography.Text,null,"You are about to execute a data modification query (UPDATE/DELETE)."),n().createElement("div",{style:{marginTop:12}},null!==R?n().createElement(o.Typography.Text,{type:"danger",strong:!0},"This query will affect ",R," row(s)."):n().createElement(o.Typography.Text,{type:"warning"},"Unable to preview affected rows count. Proceed with caution."))))},E=function(r){var l=r.blockUid,u=r.templateSql,c=(0,e.useAPIClient)(),p=Array.from(new Set(Array.from(u.matchAll(/\$([a-zA-Z0-9_]+)/g)).map(function(e){return e[1]}))),f=b((0,t.useState)({}),2),d=f[0],g=f[1],w=b((0,t.useState)([]),2),E=w[0],O=w[1],x=b((0,t.useState)([]),2),T=x[0],k=x[1],P=b((0,t.useState)(!1),2),j=P[0],q=P[1];return(0,t.useEffect)(function(){g(function(e){var t=m({},e);return p.forEach(function(e){void 0===t[e]&&(t[e]="")}),t})},[u,JSON.stringify(p)]),n().createElement(o.Space,{direction:"vertical",style:{width:"100%",display:"flex"}},n().createElement(o.Typography.Title,{level:5},"SQL Template"),n().createElement("pre",{style:{padding:12,background:"#f5f5f5",borderRadius:4,margin:0,fontFamily:"monospace"}},u),p.length>0&&n().createElement(o.Form,{layout:"inline",style:{flexWrap:"wrap",gap:8,marginTop:12}},p.map(function(e){return n().createElement(o.Form.Item,{key:e,label:n().createElement(o.Tag,{color:"blue"},"$",e),style:{marginBottom:8}},n().createElement(o.Input,{placeholder:"Value for $".concat(e),value:d[e],onChange:function(t){return g(function(n){return y(m({},n),s({},e,t.target.value))})},style:{width:160}}))})),n().createElement(o.Space,null,n().createElement(o.Button,{type:"primary",icon:n().createElement(a.PlayCircleOutlined,null),onClick:function(){return i(function(){var e,t,n,r,a,u,i;return v(this,function(s){switch(s.label){case 0:q(!0),s.label=1;case 1:return s.trys.push([1,3,4,5]),[4,c.request({url:"flowSql:runById",method:"POST",data:{uid:l,bind:d,type:"selectRows"}})];case 2:return Array.isArray(t=null==(e=s.sent().data)?void 0:e.data)&&t.length>0?(k(Object.keys(t[0]).map(function(e){return{title:e,dataIndex:e,key:e,render:function(e){return(void 0===e?"undefined":h(e))==="object"&&null!==e?JSON.stringify(e):String(null!=e?e:"")}}})),O(t)):(k([]),O([]),o.message.success("Execution completed, no rows returned.")),[3,5];case 3:return i=null==(n=s.sent())||null==(u=n.response)||null==(a=u.data)||null==(r=a.error)?void 0:r.message,o.message.error(i||n.message||"Execution failed"),[3,5];case 4:return q(!1),[7];case 5:return[2]}})})()},loading:j},"Run SQL"),E.length>0&&n().createElement(o.Button,{icon:n().createElement(a.CopyOutlined,null),onClick:function(){return S(JSON.stringify(E,null,2))}},"Copy JSON")),T.length>0&&n().createElement(o.Table,{columns:T,dataSource:E.map(function(e,t){return y(m({},e),{key:t})}),pagination:!1,size:"small",scroll:{x:"max-content"}}))},O=(0,r.observer)(function(e){var t=e.blockUid,r=e.allowNormalUser,o=e.templateSql;return r?n().createElement(E,{blockUid:t,templateSql:o}):n().createElement(w,{blockUid:t})}),x=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=p(e),function(e,t){if(t&&("object"===h(t)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,g()?Reflect.construct(e,t||[],p(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&d(r,e),t=[{key:"renderComponent",value:function(){var e=!!this.props.allowNormalUser,t=String(this.props.templateSql||"");return n().createElement(O,{blockUid:this.uid,allowNormalUser:e,templateSql:t})}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(r.prototype,t),r}(e.BlockModel);x.registerFlow({key:"sqlConsoleSettings",title:(0,r.tExpr)("SQL Console Settings"),steps:{normalUserAccess:{title:(0,r.tExpr)("SQL Template & Access"),uiSchema:{saveAsTemplate:{type:"boolean","x-component":"Checkbox","x-decorator":"FormItem",title:(0,r.tExpr)("Save as a reusable SQL Template"),description:(0,r.tExpr)("Saves the query so other blocks or APIs can run it via flowSql:runById using this block's ID.")},templateSql:{type:"string","x-component":"Input.TextArea","x-decorator":"FormItem",title:(0,r.tExpr)("SQL Template"),description:(0,r.tExpr)("Use $paramName for user-supplied bind parameters. e.g. SELECT * FROM users WHERE status = $status"),"x-component-props":{style:{fontFamily:"monospace",minHeight:120},placeholder:"SELECT * FROM users WHERE status = $status"},"x-reactions":{dependencies:["saveAsTemplate"],fulfill:{state:{visible:"{{$deps[0]}}"}}}},allowNormalUser:{type:"boolean","x-component":"Checkbox","x-decorator":"FormItem",title:(0,r.tExpr)("Allow normal users to execute from this block"),description:(0,r.tExpr)("When enabled, this block will switch to Template Mode, allowing any logged-in user to execute the template above."),"x-reactions":{dependencies:["saveAsTemplate"],fulfill:{state:{visible:"{{$deps[0]}}"}}}}},defaultParams:function(e){var t,n,r;return{saveAsTemplate:null!=(t=e.model.props.saveAsTemplate)&&t,allowNormalUser:null!=(n=e.model.props.allowNormalUser)&&n,templateSql:null!=(r=e.model.props.templateSql)?r:""}},handler:function(e,t){return i(function(){var n;return v(this,function(r){switch(r.label){case 0:if(e.model.setProps("saveAsTemplate",t.saveAsTemplate),e.model.setProps("allowNormalUser",t.allowNormalUser),e.model.setProps("templateSql",null!=(n=t.templateSql)?n:""),!(t.saveAsTemplate&&t.templateSql))return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,e.api.request({url:"flowSql:save",method:"POST",data:{uid:e.model.uid,sql:t.templateSql}})];case 2:return r.sent(),[3,4];case 3:return console.error("[SQLConsole] Failed to save SQL template:",r.sent()),[3,4];case 4:return[2]}})})()}}}}),x.define({hide:!1,label:"SQL Console"});var T={SQLConsoleBlockModel:x};function k(e,t,n,r,o,a,l){try{var u=e[a](l),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function P(e,t,n){return(P=A()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&q(o,n.prototype),o}).apply(null,arguments)}function j(e){return(j=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function q(e,t){return(q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _(e){var t="function"==typeof Map?new Map:void 0;return(_=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,n)}function n(){return P(e,arguments,j(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),q(n,e)})(e)}function A(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(A=function(){return!!e})()}var C=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=j(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,A()?Reflect.construct(e,t||[],j(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&q(n,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(l,"next",{value:c(0)}),u(l,"throw",{value:c(1)}),u(l,"return",{value:c(2)}),"function"==typeof Symbol&&u(l,Symbol.iterator,{value:function(){return this}}),l;function c(u){return function(c){var i=[u,c];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,i[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}}(this,function(e){return this.flowEngine.registerModels(T),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function l(e){k(a,r,o,l,u,"next",e)}function u(e){k(a,r,o,l,u,"throw",e)}l(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(_(e.Plugin))}(),f}()});
@@ -0,0 +1,10 @@
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
+ export declare function useT(): (str: string) => string;
10
+ export declare function tExpr(key: string): string;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { BlockModel } from '@nocobase/client';
3
+ export declare class SQLConsoleBlockModel extends BlockModel {
4
+ renderComponent(): React.JSX.Element;
5
+ }
@@ -0,0 +1,11 @@
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 { ModelConstructor } from '@nocobase/flow-engine';
10
+ declare const _default: Record<string, ModelConstructor>;
11
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import { Plugin } from '@nocobase/client';
2
+ export declare class PluginBlockSqlConsoleClient extends Plugin {
3
+ load(): Promise<void>;
4
+ }
5
+ export default PluginBlockSqlConsoleClient;
@@ -0,0 +1 @@
1
+ export { default } from './plugin';
@@ -0,0 +1,10 @@
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
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client-v2")):"function"==typeof define&&define.amd?define("@bunnarin/plugin-block-sql-console/client-v2",["@nocobase/client-v2"],t):"object"==typeof exports?exports["@bunnarin/plugin-block-sql-console/client-v2"]=t(require("@nocobase/client-v2")):e["@bunnarin/plugin-block-sql-console/client-v2"]=t(e["@nocobase/client-v2"])}(self,function(e){return function(){"use strict";var t={485:function(t){t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,r),i.exports}r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.g.importScripts&&(o=r.g.location+"");var o,i=r.g.document;if(!o&&i&&(i.currentScript&&"SCRIPT"===i.currentScript.tagName.toUpperCase()&&(o=i.currentScript.src),!o)){var c=i.getElementsByTagName("script");if(c.length)for(var u=c.length-1;u>-1&&(!o||!/^http(s?):/.test(o));)o=c[u--].src}if(!o)throw Error("Automatic publicPath is not supported in this browser");r.p=o.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var l={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@bunnarin/plugin-block-sql-console/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var o=window.__webpack_public_path__||"";o&&("/"!==o.charAt(o.length-1)&&(o+="/"),e=o+"static/plugins/@bunnarin/plugin-block-sql-console/dist/client-v2/")}if(!e){var i=window.__nocobase_modern_client_prefix__||"v",c="/"+(i=String(i).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var u=window.location.pathname||"/",l=u.indexOf(c);e=l>=0?u.slice(0,l+1):"/"}e&&(e=e.replace(RegExp("/"+i+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@bunnarin/plugin-block-sql-console/dist/client-v2/"}r.p=e}(),!function(){r.r(l),r.d(l,{default:function(){return a}});var e=r(485);function t(e,t,n,r,o,i,c){try{var u=e[i](c),l=u.value}catch(e){n(e);return}u.done?t(l):Promise.resolve(l).then(r,o)}function n(e,t,r){return(n=u()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&i(o,n.prototype),o}).apply(null,arguments)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=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 n(e,arguments,o(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),i(r,e)})(e)}function u(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(u=function(){return!!e})()}var a=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=o(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"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(e,t||[],o(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&i(r,e),n=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(c,"next",{value:l(0)}),u(c,"throw",{value:l(1)}),u(c,"return",{value:l(2)}),"function"==typeof Symbol&&u(c,Symbol.iterator,{value:function(){return this}}),c;function l(u){return function(l){var a=[u,l];if(n)throw TypeError("Generator is already executing.");for(;c&&(c=0,a[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}}(this,function(e){return[2]})},function(){var n=this,r=arguments;return new Promise(function(o,i){var c=e.apply(n,r);function u(e){t(c,o,i,u,l,"next",e)}function l(e){t(c,o,i,u,l,"throw",e)}u(void 0)})})()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(r.prototype,n),r}(c(e.Plugin))}(),l}()});
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { BlockModel } from '@nocobase/client-v2';
3
+ export declare class SQLConsoleBlockModel extends BlockModel {
4
+ onInit(options: any): void;
5
+ renderComponent(): React.JSX.Element;
6
+ }
@@ -0,0 +1,5 @@
1
+ import { Plugin } from '@nocobase/client-v2';
2
+ export declare class PluginBlockSqlConsoleClientV2 extends Plugin {
3
+ load(): Promise<void>;
4
+ }
5
+ export default PluginBlockSqlConsoleClientV2;
@@ -0,0 +1,18 @@
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
+ module.exports = {
11
+ "@nocobase/flow-engine": "2.1.31",
12
+ "@nocobase/client": "2.1.31",
13
+ "@nocobase/client-v2": "2.1.31",
14
+ "@nocobase/server": "2.1.31",
15
+ "react": "18.2.0",
16
+ "antd": "5.24.2",
17
+ "@ant-design/icons": "5.6.1"
18
+ };
@@ -0,0 +1,2 @@
1
+ export * from './server';
2
+ export { default } from './server';
package/dist/index.js ADDED
@@ -0,0 +1,48 @@
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
29
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
30
+ // If the importer is in node compatibility mode or this is not an ESM
31
+ // file that has been converted to a CommonJS file using a Babel-
32
+ // compatible transform (i.e. "__esModule" has not been set), then set
33
+ // "default" to the CommonJS "module.exports" for node compatibility.
34
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
+ mod
36
+ ));
37
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
+ var src_exports = {};
39
+ __export(src_exports, {
40
+ default: () => import_server.default
41
+ });
42
+ module.exports = __toCommonJS(src_exports);
43
+ __reExport(src_exports, require("./server"), module.exports);
44
+ var import_server = __toESM(require("./server"));
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ ...require("./server")
48
+ });
@@ -0,0 +1 @@
1
+ {}
@@ -0,0 +1 @@
1
+ {}
@@ -0,0 +1 @@
1
+ export { default } from './plugin';
@@ -0,0 +1,42 @@
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 server_exports = {};
38
+ __export(server_exports, {
39
+ default: () => import_plugin.default
40
+ });
41
+ module.exports = __toCommonJS(server_exports);
42
+ var import_plugin = __toESM(require("./plugin"));
@@ -0,0 +1,11 @@
1
+ import { Plugin } from '@nocobase/server';
2
+ export declare class PluginBlockSqlConsoleServer extends Plugin {
3
+ afterAdd(): Promise<void>;
4
+ beforeLoad(): Promise<void>;
5
+ load(): Promise<void>;
6
+ install(): Promise<void>;
7
+ afterEnable(): Promise<void>;
8
+ afterDisable(): Promise<void>;
9
+ remove(): Promise<void>;
10
+ }
11
+ export default PluginBlockSqlConsoleServer;
@@ -0,0 +1,54 @@
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 plugin_exports = {};
28
+ __export(plugin_exports, {
29
+ PluginBlockSqlConsoleServer: () => PluginBlockSqlConsoleServer,
30
+ default: () => plugin_default
31
+ });
32
+ module.exports = __toCommonJS(plugin_exports);
33
+ var import_server = require("@nocobase/server");
34
+ class PluginBlockSqlConsoleServer extends import_server.Plugin {
35
+ async afterAdd() {
36
+ }
37
+ async beforeLoad() {
38
+ }
39
+ async load() {
40
+ }
41
+ async install() {
42
+ }
43
+ async afterEnable() {
44
+ }
45
+ async afterDisable() {
46
+ }
47
+ async remove() {
48
+ }
49
+ }
50
+ var plugin_default = PluginBlockSqlConsoleServer;
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ PluginBlockSqlConsoleServer
54
+ });
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@bunnarin/plugin-block-sql-console",
3
+ "version": "2.1.31",
4
+ "main": "dist/server/index.js",
5
+ "dependencies": {},
6
+ "peerDependencies": {
7
+ "@nocobase/client": "2.x",
8
+ "@nocobase/client-v2": "2.x",
9
+ "@nocobase/server": "2.x",
10
+ "@nocobase/test": "2.x"
11
+ },
12
+ "keywords": [
13
+ "Blocks"
14
+ ],
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/bunnarin/plugin-block-sql-console"
21
+ }
22
+ }
package/server.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './dist/server';
2
+ export { default } from './dist/server';
package/server.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/server/index.js');