@bunnarin/plugin-block-sql-console 2.1.31 → 2.1.32
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/dist/client/index.js +1 -1
- package/package.json +1 -1
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("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}()});
|
|
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 l={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}},a={};function u(e){var t=a[e];if(void 0!==t)return t.exports;var n=a[e]={exports:{}};return l[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",l="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var a=window.location.pathname||"/",c=a.indexOf(l);e=c>=0?a.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 I}});var e=u(342),t=u(155),n=u.n(t),r=u(694),o=u(59),l=u(375);function a(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,l,a){try{var u=e[l](a),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 l=e.apply(t,n);function a(e){c(l,r,o,a,u,"next",e)}function u(e){c(l,r,o,a,u,"throw",e)}a(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 y(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 d(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 b(e,t){return(b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function m(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 l=[],a=!0,u=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),!t||l.length!==t);a=!0);}catch(e){u=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(u)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return a(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 a(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,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var i=[u,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(l=0)),l;)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 l.label++,{value:i[1],done:!1};case 5:l.label++,r=i[1],i=[0];continue;case 7:i=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){l=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){l.label=i[1];break}if(6===i[0]&&l.label<o[1]){l.label=o[1],o=i;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(i);break}o[2]&&l.ops.pop(),l.trys.pop();continue}i=t.call(e,l)}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 w=function(e){for(var t,n,r=new Set,o=RegExp("(?<!:):([a-zA-Z0-9_]+)|\\$([a-zA-Z0-9_]+)","g");null!==(t=o.exec(e));)r.add(null!=(n=t[1])?n:t[2]);return Array.from(r)},S=function(e){return e.replace(RegExp("(?<!:):([a-zA-Z0-9_]+)","g"),"$$$1")},E=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)})},O=function(r){r.blockUid;var a=(0,e.useAPIClient)(),u=m((0,t.useState)(""),2),c=u[0],p=u[1],f=m((0,t.useState)({}),2),b=f[0],g=f[1],O=m((0,t.useState)([]),2),x=O[0],T=O[1],j=m((0,t.useState)([]),2),P=j[0],k=j[1],_=m((0,t.useState)(!1),2),q=_[0],C=_[1],A=m((0,t.useState)(!1),2),R=A[0],I=A[1],U=m((0,t.useState)(null),2),$=U[0],L=U[1],N=m((0,t.useState)(null),2),F=N[0],M=N[1],B=w(c),Q=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},D=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:"")}}})),T(e)):(k([]),T([]),o.message.success("Execution completed, no rows returned."))},W=(0,t.useCallback)(function(e){return i(function(){var t,n,r,l,u,c;return v(this,function(i){switch(i.label){case 0:C(!0),i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,a.request({url:"flowSql:run",method:"POST",data:{sql:S(e),type:"selectRows",bind:b}})];case 2:return D(null==(t=i.sent().data)?void 0:t.data),[3,5];case 3:return c=null==(n=i.sent())||null==(u=n.response)||null==(l=u.data)||null==(r=l.error)?void 0:r.message,o.message.error(c||n.message||"Execution failed"),[3,5];case 4:return C(!1),[7];case 5:return[2]}})})()},[a,b]);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"}),B.length>0&&n().createElement(o.Form,{layout:"inline",style:{flexWrap:"wrap",gap:8}},B.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:b[e]||"",onChange:function(t){return g(function(n){return d(y({},n),s({},e,t.target.value))})},style:{width:160}}))})),n().createElement(o.Space,null,n().createElement(o.Button,{type:"primary",icon:n().createElement(l.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=Q(c)))return[3,6];C(!0),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,a.request({url:"flowSql:run",method:"POST",data:{sql:S(e),type:"selectVar",bind:b}})];case 2:return L(null!=(t=Number(null==(n=r.sent().data)?void 0:n.data))?t:0),[3,5];case 3:return r.sent(),L(null),[3,5];case 4:return C(!1),[7];case 5:return[3,7];case 6:L(null),r.label=7;case 7:return M(c),I(!0),[3,9];case 8:W(c),r.label=9;case 9:return[2]}})})()},loading:q},"Run SQL"),x.length>0&&n().createElement(o.Button,{icon:n().createElement(l.CopyOutlined,null),onClick:function(){return E(JSON.stringify(x,null,2))}},"Copy JSON (",x.length," rows)")),P.length>0&&n().createElement(o.Table,{columns:P,dataSource:x.map(function(e,t){return d(y({},e),{key:t})}),pagination:!1,size:"small",scroll:{x:"max-content"}}),n().createElement(o.Modal,{title:n().createElement(o.Space,null,n().createElement(l.WarningOutlined,{style:{color:"#faad14"}}),"Confirm Execution"),open:R,onOk:function(){I(!1),F&&(W(F),M(null))},onCancel:function(){return I(!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!==$?n().createElement(o.Typography.Text,{type:"danger",strong:!0},"This query will affect ",$," row(s)."):n().createElement(o.Typography.Text,{type:"warning"},"Unable to preview affected rows count. Proceed with caution."))))},x=function(r){var a=r.blockUid,u=r.templateSql,c=(0,e.useAPIClient)(),p=w(u),f=m((0,t.useState)({}),2),b=f[0],g=f[1],S=m((0,t.useState)([]),2),O=S[0],x=S[1],T=m((0,t.useState)([]),2),j=T[0],P=T[1],k=m((0,t.useState)(!1),2),_=k[0],q=k[1];return(0,t.useEffect)(function(){g(function(e){var t=y({},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:b[e],onChange:function(t){return g(function(n){return d(y({},n),s({},e,t.target.value))})},style:{width:160}}))})),n().createElement(o.Space,null,n().createElement(o.Button,{type:"primary",icon:n().createElement(l.PlayCircleOutlined,null),onClick:function(){return i(function(){var e,t,n,r,l,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:a,bind:b,type:"selectRows"}})];case 2:return Array.isArray(t=null==(e=s.sent().data)?void 0:e.data)&&t.length>0?(P(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:"")}}})),x(t)):(P([]),x([]),o.message.success("Execution completed, no rows returned.")),[3,5];case 3:return i=null==(n=s.sent())||null==(u=n.response)||null==(l=u.data)||null==(r=l.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:_},"Run SQL"),O.length>0&&n().createElement(o.Button,{icon:n().createElement(l.CopyOutlined,null),onClick:function(){return E(JSON.stringify(O,null,2))}},"Copy JSON (",O.length," rows)")),j.length>0&&n().createElement(o.Table,{columns:j,dataSource:O.map(function(e,t){return d(y({},e),{key:t})}),pagination:!1,size:"small",scroll:{x:"max-content"}}))},T=(0,r.observer)(function(e){var t=e.blockUid,r=e.allowNormalUser,o=e.templateSql;return r?n().createElement(x,{blockUid:t,templateSql:o}):n().createElement(O,{blockUid:t})}),j=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&&b(r,e),t=[{key:"renderComponent",value:function(){var e=!!this.props.allowNormalUser,t=String(this.props.templateSql||"");return n().createElement(T,{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);j.registerFlow({key:"sqlConsoleSettings",title:(0,r.tExpr)("SQL Console Settings"),steps:{normalUserAccess:{title:(0,r.tExpr)("Allow normal users to run"),uiSchema:{allowNormalUser:{type:"boolean","x-component":"Checkbox","x-decorator":"FormItem",title:(0,r.tExpr)("Allow normal users to execute SQL"),description:(0,r.tExpr)("When enabled, normal users run the saved SQL template via ID. Save the SQL template below.")},templateSql:{type:"string","x-component":"Input.TextArea","x-decorator":"FormItem",title:(0,r.tExpr)("SQL Template"),description:(0,r.tExpr)("Use $paramName or :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:["allowNormalUser"],fulfill:{state:{visible:"{{$deps[0]}}"}}}}},defaultParams:function(e){var t,n;return{allowNormalUser:null!=(t=e.model.props.allowNormalUser)&&t,templateSql:null!=(n=e.model.props.templateSql)?n:""}},handler:function(e,t){return i(function(){var n,r;return v(this,function(o){switch(o.label){case 0:if(r=S(null!=(n=t.templateSql)?n:""),e.model.setProps("allowNormalUser",t.allowNormalUser),e.model.setProps("templateSql",r),!(t.allowNormalUser&&r))return[3,4];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,e.api.request({url:"flowSql:save",method:"POST",data:{uid:e.model.uid,sql:r}})];case 2:return o.sent(),[3,4];case 3:return console.error("[SQLConsole] Failed to save SQL template:",o.sent()),[3,4];case 4:return[2]}})})()}}}}),j.define({hide:!1,label:"SQL Console"});var P={SQLConsoleBlockModel:j};function k(e,t,n,r,o,l,a){try{var u=e[l](a),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function _(e,t,n){return(_=R()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&C(o,n.prototype),o}).apply(null,arguments)}function q(e){return(q=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function C(e,t){return(C=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function A(e){var t="function"==typeof Map?new Map:void 0;return(A=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 _(e,arguments,q(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),C(n,e)})(e)}function R(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(R=function(){return!!e})()}var I=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=q(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,R()?Reflect.construct(e,t||[],q(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&C(n,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var i=[u,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(l=0)),l;)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 l.label++,{value:i[1],done:!1};case 5:l.label++,r=i[1],i=[0];continue;case 7:i=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){l=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){l.label=i[1];break}if(6===i[0]&&l.label<o[1]){l.label=o[1],o=i;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(i);break}o[2]&&l.ops.pop(),l.trys.pop();continue}i=t.call(e,l)}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(P),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function a(e){k(l,r,o,a,u,"next",e)}function u(e){k(l,r,o,a,u,"throw",e)}a(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}(A(e.Plugin))}(),f}()});
|