@nocobase/plugin-environment-variables 1.6.0-beta.8 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +5 -5
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +4 -4
- package/package.json +2 -2
package/LICENSE.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Updated Date: February
|
|
1
|
+
Updated Date: February 20, 2025
|
|
2
2
|
|
|
3
3
|
NocoBase License Agreement
|
|
4
4
|
|
|
@@ -88,7 +88,7 @@ Except for Third-Party Open Source Software, the Company owns all copyrights, tr
|
|
|
88
88
|
|
|
89
89
|
6.6 Can sell plugins developed for Software in the Marketplace.
|
|
90
90
|
|
|
91
|
-
6.7 The User with
|
|
91
|
+
6.7 The User with an Enterprise Edition License can sell Upper Layer Application to their clients.
|
|
92
92
|
|
|
93
93
|
6.8 Not restricted by the AGPL-3.0 agreement.
|
|
94
94
|
|
|
@@ -106,9 +106,9 @@ Except for Third-Party Open Source Software, the Company owns all copyrights, tr
|
|
|
106
106
|
|
|
107
107
|
7.4 It is not allowed to provide any form of no-code, zero-code, low-code platform SaaS products to the public using the original or modified Software.
|
|
108
108
|
|
|
109
|
-
7.5 It is not allowed for the User
|
|
109
|
+
7.5 It is not allowed for the User withot an Enterprise Edition license to sell Upper Layer Application to clients without a Commercial license.
|
|
110
110
|
|
|
111
|
-
7.6 It is not allowed for the User with
|
|
111
|
+
7.6 It is not allowed for the User with an Enterprise Edition license to sell Upper Layer Application to clients without a Commercial license with access to further development and configuration.
|
|
112
112
|
|
|
113
113
|
7.7 It is not allowed to publicly sell plugins developed for Software outside of the Marketplace.
|
|
114
114
|
|
|
@@ -126,7 +126,7 @@ Except for Third-Party Open Source Software, the Company owns all copyrights, tr
|
|
|
126
126
|
|
|
127
127
|
8.3 Can be used for commercial purposes without restrictions on the number of applications or users.
|
|
128
128
|
|
|
129
|
-
8.4 The User with
|
|
129
|
+
8.4 The User with an Enterprise Edition License can use the Commercial Plugin in Upper Layer Applications sold to their customers.
|
|
130
130
|
|
|
131
131
|
8.5 Not restricted by the AGPL-3.0 agreement.
|
|
132
132
|
|
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("@formily/core"),require("@nocobase/client"),require("antd"),require("@ant-design/icons"),require("@formily/react"),require("@formily/antd-v5")):"function"==typeof define&&define.amd?define("@nocobase/plugin-environment-variables",["react","@formily/core","@nocobase/client","antd","@ant-design/icons","@formily/react","@formily/antd-v5"],t):"object"==typeof exports?exports["@nocobase/plugin-environment-variables"]=t(require("react"),require("@formily/core"),require("@nocobase/client"),require("antd"),require("@ant-design/icons"),require("@formily/react"),require("@formily/antd-v5")):e["@nocobase/plugin-environment-variables"]=t(e.react,e["@formily/core"],e["@nocobase/client"],e.antd,e["@ant-design/icons"],e["@formily/react"],e["@formily/antd-v5"])}(self,function(e,t,n,r,o,a,l){return function(){"use strict";var i={482:function(e){e.exports=o},632:function(e){e.exports=l},563:function(e){e.exports=t},505:function(e){e.exports=a},772:function(e){e.exports=n},721:function(e){e.exports=r},156:function(t){t.exports=e}},u={};function c(e){var t=u[e];if(void 0!==t)return t.exports;var n=u[e]={exports:{}};return i[e](n,n.exports,c),n.exports}c.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(t,{a:t}),t},c.d=function(e,t){for(var n in t)c.o(t,n)&&!c.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},c.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};c.r(s),c.d(s,{PluginEnvironmentVariablesClient:function(){return U},default:function(){return H}});var f=c("772"),p=c("505"),m=c("156"),d=c.n(m),b=(0,m.createContext)({}),y=function(e){var t=(0,f.useRequest)({url:"environmentVariables?paginate=false"});return d().createElement(b.Provider,{value:{variablesRequest:t}},e.children)},v=(0,p.observer)(function(e){return(0,f.useIsAdminPage)()?d().createElement(y,e):d().createElement(d().Fragment,null,e.children)},{displayName:"EnvironmentVariablesAndSecretsProvider"}),h=c("482"),g=c("632"),x=c("563"),w=c("721"),E=/^[A-Za-z][A-Za-z0-9_]*$/,S=JSON.parse('{"u2":"@nocobase/plugin-environment-variables"}');function O(){var e=(0,f.useApp)();return function(t){return e.i18n.t(t,{ns:[S.u2,"client"]})}}function k(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 A(e){if(Array.isArray(e))return e}function j(e,t,n,r,o,a,l){try{var i=e[a](l),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,o)}function q(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function l(e){j(a,r,o,l,i,"next",e)}function i(e){j(a,r,o,l,i,"throw",e)}l(void 0)})}}function P(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function F(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){var r,o,a;r=e,o=t,a=n[t],o in r?Object.defineProperty(r,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[o]=a})}return e}function I(e,t){return A(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);l=!0);}catch(e){i=!0,r=e}finally{try{!l&&null!=o.return&&o.return()}finally{if(i)throw r}}return a}}(e,t)||R(e,t)||P()}function R(e,t){if(e){if("string"==typeof e)return k(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 k(e,t)}}function C(e,t){var n,r,o,a,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){return function(a){if(n)throw TypeError("Generator is already executing.");for(;l;)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 l.label++,{value:a[1],done:!1};case 5:l.label++,r=a[1],a=[0];continue;case 7:a=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){l=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){l.label=a[1];break}if(6===a[0]&&l.label<o[1]){l.label=o[1],o=a;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(a);break}o[2]&&l.ops.pop(),l.trys.pop();continue}a=t.call(e,l)}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}}([a,i])}}}(0,x.registerValidateRules)({env_name_rule:function(e){return e?E.test(e)?"":"Only letters, numbers and underscores are allowed, and it must start with a letter.":""}});var V=(0,p.createSchemaField)({components:{FormItem:g.FormItem,Input:g.Input,Checkbox:g.Checkbox,Radio:g.Radio}}),T={type:"object",properties:{variables:{type:"string",title:'{{ t("Plain text") }}',"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:10,maxRows:20},placeholder:"FOO=aaa\nBAR=bbb\n "}},secret:{type:"string",title:'{{ t("Encrypted") }}',"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:10,maxRows:20},placeholder:"FOO=aaa\nBAR=bbb\n "}}}},B={type:"object",properties:{name:{type:"string",title:'{{ t("Name") }}',required:!0,"x-validator":{env_name_rule:!0},"x-decorator":"FormItem","x-component":"Input","x-disabled":"{{ !createOnly }}"},type:{type:"string",title:'{{ t("Type") }}',required:!0,"x-decorator":"FormItem","x-component":"Radio.Group",default:"default",enum:[{value:"default",label:'{{t("Plain text")}}'},{value:"secret",label:'{{t("Encrypted")}}'}]},value:{type:"string",title:'{{ t("Value") }}',required:!0,"x-decorator":"FormItem","x-component":"Input.TextArea"}}};function $(e){var t,n=e.request,r=e.setSelectRowKeys,o=w.App.useApp().modal,a=O(),l=(0,f.useAPIClient)(),i=n||{},u=i.data,c=i.loading,s=i.refresh,p={default:{label:a("Plain text"),color:"green"},secret:{label:a("Encrypted"),color:"red"}},m=l.resource("environmentVariables"),b=function(e){o.confirm({title:a("Delete variable"),content:a("Are you sure you want to delete it?"),onOk:function(){return q(function(){return C(this,function(t){switch(t.label){case 0:return[4,m.destroy({filterByTk:e.name})];case 1:return t.sent(),s(),[2]}})})()}})};var y=(t=q(function(e){var t;return C(this,function(r){return(t=(0,g.FormDrawer)({title:a("Edit")},function(){var r;return d().createElement(g.FormLayout,{layout:"vertical"},d().createElement(f.SchemaComponentOptions,{scope:{createOnly:!1,t:a}},d().createElement(V,{schema:B})),d().createElement(g.FormDrawer.Footer,null,d().createElement(g.FormButtonGroup,{align:"right"},d().createElement(g.Reset,{onClick:function(){t.close()}},a("Cancel")),d().createElement(g.Submit,{onSubmit:(r=q(function(t){return C(this,function(r){switch(r.label){case 0:return[4,l.request({url:"environmentVariables:update?filterByTk=".concat(e.name),method:"post",data:F({},t)})];case 1:return r.sent(),n.refresh(),[2]}})}),function(e){return r.apply(this,arguments)})},a("Submit")))))})).open({initialValues:F({},e)}),[2]})}),function(e){return t.apply(this,arguments)});return d().createElement("div",null,d().createElement(w.Table,{loading:c,size:"middle",rowKey:"name",dataSource:null==u?void 0:u.data,pagination:!1,columns:[{title:a("Name"),dataIndex:"name",ellipsis:!0},{title:a("Type"),dataIndex:"type",render:function(e){return d().createElement(w.Tag,{color:p[e].color},p[e].label)}},{title:a("Value"),ellipsis:!0,render:function(e){return d().createElement("div",null,"default"===e.type?e.value:"******")}},{title:a("Actions"),width:200,render:function(e){return d().createElement(w.Space,null,d().createElement("a",{onClick:function(){return y(e)}},a("Edit")),d().createElement("a",{onClick:function(){return b(e)}},a("Delete")))}}],rowSelection:{type:"checkbox",onChange:function(e,t){r(e)}}}))}function _(){var e,t,n,r=(0,f.useAPIClient)(),o=O(),a=w.App.useApp().modal,l=(0,m.useContext)(b).variablesRequest,i=I((0,m.useState)([]),2),u=i[0],c=i[1],s=r.resource("environmentVariables");var y=(e=q(function(e){var t;return C(this,function(n){switch(n.label){case 0:return t=Object.entries(e).map(function(e){var t,n,r=I(e,2),o=r[0];return(t=r[1],n=o,t.trim().split("\n").map(function(e){var t,r=A(t=e.split("="))||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||R(t)||P(),o=r[0],a=r.slice(1);return o&&{name:o.trim(),value:a.join("=").trim(),type:"secret"===n?"secret":"default"}})).filter(Boolean)}),[4,r.request({url:"environmentVariables:create",method:"post",data:t.flat()})];case 1:return n.sent(),[2]}})}),function(t){return e.apply(this,arguments)}),v=[{name:"name",title:o("Name"),operators:[{label:'{{t("contains")}}',value:"$includes",selected:!0},{label:'{{t("does not contain")}}',value:"$notIncludes"},{label:'{{t("is")}}',value:"$eq"},{label:'{{t("is not")}}',value:"$ne"}],schema:{type:"string",title:o("Name"),"x-component":"Input"}},{name:"type",title:o("Type"),operators:[{label:'{{t("is")}}',value:"$match",selected:!0,schema:{"x-component":"Select","x-component-props":{mode:"tags"}}},{label:'{{t("is not")}}',value:"$notMatch",schema:{"x-component":"Select","x-component-props":{mode:"tags"}}}],schema:{type:"string",title:o("Type"),"x-component":"Select",enum:[{value:"default",label:'{{t("Plain text")}}'},{value:"secret",label:'{{t("Encrypted")}}'}]}},{name:"value",title:o("Value"),operators:[{label:'{{t("contains")}}',value:"$includes",selected:!0},{label:'{{t("does not contain")}}',value:"$notIncludes"},{label:'{{t("is")}}',value:"$eq"},{label:'{{t("is not")}}',value:"$ne"}],schema:{type:"string",title:o("Value"),"x-component":"Input"}}];return d().createElement("div",null,(null==l?void 0:null===(n=l.data)||void 0===n?void 0:null===(t=n.meta)||void 0===t?void 0:t.updated)&&d().createElement(w.Alert,{type:"warning",style:{marginBottom:"1.2em",alignItems:"center"},description:d().createElement("div",null,o("Variables and secrets have been updated. A restart is required for the changes to take effect.")," "),action:d().createElement(w.Button,{size:"middle",type:"primary",onClick:q(function(){return C(this,function(e){switch(e.label){case 0:return[4,r.resource("app").refresh()];case 1:return e.sent(),[2]}})})},o("Restart now"))}),d().createElement(w.Card,null,d().createElement("div",{style:{float:"left"}},d().createElement(f.SchemaComponent,{schema:{name:"filter",type:"object",title:'{{ t("Filter") }}',default:{$and:[{name:{$includes:""}}]},"x-component":"Filter.Action",enum:v,"x-use-component-props":function(){var e,t=(0,p.useField)(),n=l.run;return{options:v,onSubmit:(e=q(function(e){return C(this,function(r){return n(e),t.setValue(e),[2]})}),function(t){return e.apply(this,arguments)}),onReset:function(e){t.setValue(e)}}}},scope:{t:o}})),d().createElement(w.Flex,{justify:"end",style:{marginBottom:16}},d().createElement(w.Space,null,d().createElement(w.Button,{icon:d().createElement(h.ReloadOutlined,null),onClick:function(){var e;null==l||null===(e=l.refresh)||void 0===e||e.call(l)}},o("Refresh")),d().createElement(w.Button,{icon:d().createElement(h.DeleteOutlined,null),onClick:function(){u.length>0&&a.confirm({title:o("Delete variable"),content:o("Are you sure you want to delete it?"),onOk:function(){return q(function(){var e;return C(this,function(t){switch(t.label){case 0:return[4,s.destroy({filterByTk:u})];case 1:return t.sent(),null==l||null===(e=l.refresh)||void 0===e||e.call(l),[2]}})})()}})}},o("Delete")),d().createElement(w.Dropdown,{menu:{onClick:function(e){(0,g.FormDrawer)({variable:o("Add variable"),bulk:o("Bulk import")}[e.key],function(){var t;return d().createElement(g.FormLayout,{layout:"vertical"},d().createElement(f.SchemaComponentOptions,{scope:{createOnly:!0,t:o}},d().createElement(V,{schema:"bulk"===e.key?T:B})),d().createElement(g.FormDrawer.Footer,null,d().createElement(g.FormButtonGroup,{align:"right"},d().createElement(g.Reset,null,o("Cancel")),d().createElement(g.Submit,{onSubmit:(t=q(function(t){return C(this,function(n){switch(n.label){case 0:if("bulk"!==e.key)return[3,2];return[4,y(t)];case 1:return n.sent(),l.refresh(),[3,4];case 2:return[4,r.request({url:"environmentVariables:create",method:"post",data:F({},t)})];case 3:n.sent(),l.refresh(),n.label=4;case 4:return[2]}})}),function(e){return t.apply(this,arguments)})},o("Submit")))))}).open({initialValues:{}}).then(console.log).catch(console.log)},items:[{key:"variable",label:o("Add variable")},{type:"divider"},{key:"bulk",label:o("Bulk import")}]}},d().createElement(w.Button,{type:"primary",icon:d().createElement(h.PlusOutlined,null)},o("Add new")," ",d().createElement(h.DownOutlined,null))))),d().createElement($,{request:l,setSelectRowKeys:c})))}function D(){return d().createElement(_,null)}var M=function(){var e,t=O(),n=(0,m.useContext)(b).variablesRequest||{},r=n.data;return!n.loading&&(null==r?void 0:null===(e=r.data)||void 0===e?void 0:e.length)?{name:"$env",title:t("Variables and secrets"),value:"$env",label:t("Variables and secrets"),children:null==r?void 0:r.data.map(function(e){return{title:e.name,name:e.name,value:e.name,label:e.name}}).filter(Boolean)}:null};function z(e,t,n,r,o,a,l){try{var i=e[a](l),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,o)}function G(e,t,n){return(G=J()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&L(o,n.prototype),o}).apply(null,arguments)}function N(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)}}function K(e){return(K=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function L(e,t){return(L=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Z(e){var t="function"==typeof Map?new Map:void 0;return(Z=function(e){var n;if(null===e||(n=e,-1===Function.toString.call(n).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 G(e,arguments,K(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),L(r,e)})(e)}function J(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(J=function(){return!!e})()}var U=function(e){var t,n,r;function o(){var e,t,n;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),e=this,t=o,n=arguments,t=K(t),function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,J()?Reflect.construct(t,n||[],K(e).constructor):t.apply(e,n))}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&L(e,t)}(o,e),t=o,n=[{key:"load",value:function(){var e,t=this;return(e=function(){return function(e,t){var n,r,o,a,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){return function(a){if(n)throw TypeError("Generator is already executing.");for(;l;)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 l.label++,{value:a[1],done:!1};case 5:l.label++,r=a[1],a=[0];continue;case 7:a=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){l=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){l.label=a[1];break}if(6===a[0]&&l.label<o[1]){l.label=o[1],o=a;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(a);break}o[2]&&l.ops.pop(),l.trys.pop();continue}a=t.call(e,l)}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}}([a,i])}}}(this,function(e){return t.app.pluginSettingsManager.add("environment",{title:t.t("Variables and secrets"),icon:"TableOutlined",Component:D}),t.app.addGlobalVar("$env",M),t.app.use(v),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function l(e){z(a,r,o,l,i,"next",e)}function i(e){z(a,r,o,l,i,"throw",e)}l(void 0)})})()}}],N(t.prototype,n),o}(Z(f.Plugin)),H=U;return s}()});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@formily/core"),require("@nocobase/client"),require("antd"),require("@ant-design/icons"),require("@formily/react"),require("react"),require("@formily/antd-v5")):"function"==typeof define&&define.amd?define("@nocobase/plugin-environment-variables",["@formily/core","@nocobase/client","antd","@ant-design/icons","@formily/react","react","@formily/antd-v5"],t):"object"==typeof exports?exports["@nocobase/plugin-environment-variables"]=t(require("@formily/core"),require("@nocobase/client"),require("antd"),require("@ant-design/icons"),require("@formily/react"),require("react"),require("@formily/antd-v5")):e["@nocobase/plugin-environment-variables"]=t(e["@formily/core"],e["@nocobase/client"],e.antd,e["@ant-design/icons"],e["@formily/react"],e.react,e["@formily/antd-v5"])}(self,function(e,t,n,r,o,a,l){return function(){"use strict";var i={482:function(e){e.exports=r},632:function(e){e.exports=l},563:function(t){t.exports=e},505:function(e){e.exports=o},772:function(e){e.exports=t},721:function(e){e.exports=n},156:function(e){e.exports=a}},u={};function c(e){var t=u[e];if(void 0!==t)return t.exports;var n=u[e]={exports:{}};return i[e](n,n.exports,c),n.exports}c.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(t,{a:t}),t},c.d=function(e,t){for(var n in t)c.o(t,n)&&!c.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},c.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};c.r(s),c.d(s,{PluginEnvironmentVariablesClient:function(){return U},default:function(){return H}});var f=c("772"),p=c("505"),m=c("156"),d=c.n(m),b=(0,m.createContext)({}),y=function(e){var t=(0,f.useRequest)({url:"environmentVariables?paginate=false"});return d().createElement(b.Provider,{value:{variablesRequest:t}},e.children)},v=(0,p.observer)(function(e){return(0,f.useIsAdminPage)()?d().createElement(y,e):d().createElement(d().Fragment,null,e.children)},{displayName:"EnvironmentVariablesAndSecretsProvider"}),h=c("482"),g=c("632"),x=c("563"),w=c("721"),E=/^[A-Za-z][A-Za-z0-9_]*$/,S=JSON.parse('{"u2":"@nocobase/plugin-environment-variables"}');function O(){var e=(0,f.useApp)();return function(t){return e.i18n.t(t,{ns:[S.u2,"client"]})}}function k(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 A(e){if(Array.isArray(e))return e}function j(e,t,n,r,o,a,l){try{var i=e[a](l),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,o)}function q(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function l(e){j(a,r,o,l,i,"next",e)}function i(e){j(a,r,o,l,i,"throw",e)}l(void 0)})}}function P(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function F(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){var r,o,a;r=e,o=t,a=n[t],o in r?Object.defineProperty(r,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[o]=a})}return e}function I(e,t){return A(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);l=!0);}catch(e){i=!0,r=e}finally{try{!l&&null!=o.return&&o.return()}finally{if(i)throw r}}return a}}(e,t)||R(e,t)||P()}function R(e,t){if(e){if("string"==typeof e)return k(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 k(e,t)}}function C(e,t){var n,r,o,a,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){return function(a){if(n)throw TypeError("Generator is already executing.");for(;l;)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 l.label++,{value:a[1],done:!1};case 5:l.label++,r=a[1],a=[0];continue;case 7:a=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){l=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){l.label=a[1];break}if(6===a[0]&&l.label<o[1]){l.label=o[1],o=a;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(a);break}o[2]&&l.ops.pop(),l.trys.pop();continue}a=t.call(e,l)}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}}([a,i])}}}(0,x.registerValidateRules)({env_name_rule:function(e){return e?E.test(e)?"":"Only letters, numbers and underscores are allowed, and it must start with a letter.":""}});var T=(0,p.createSchemaField)({components:{FormItem:g.FormItem,Input:g.Input,Checkbox:g.Checkbox,Radio:g.Radio}}),V={type:"object",properties:{variables:{type:"string",title:'{{ t("Plain text") }}',"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:10,maxRows:20},placeholder:"FOO=aaa\nBAR=bbb\n "}},secret:{type:"string",title:'{{ t("Encrypted") }}',"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:10,maxRows:20},placeholder:"FOO=aaa\nBAR=bbb\n "}}}},B={type:"object",properties:{name:{type:"string",title:'{{ t("Name") }}',required:!0,"x-validator":{env_name_rule:!0},"x-decorator":"FormItem","x-component":"Input","x-disabled":"{{ !createOnly }}"},type:{type:"string",title:'{{ t("Type") }}',required:!0,"x-decorator":"FormItem","x-component":"Radio.Group",default:"default",enum:[{value:"default",label:'{{t("Plain text")}}'},{value:"secret",label:'{{t("Encrypted")}}'}]},value:{type:"string",title:'{{ t("Value") }}',required:!0,"x-decorator":"FormItem","x-component":"Input.TextArea"}}};function $(e){var t,n=e.request,r=e.setSelectRowKeys,o=w.App.useApp().modal,a=O(),l=(0,f.useAPIClient)(),i=n||{},u=i.data,c=i.loading,s=i.refresh,p=(0,f.useGlobalTheme)().theme,m={default:{label:a("Plain text"),color:"green"},secret:{label:a("Encrypted"),color:"red"}},b=l.resource("environmentVariables"),y=function(e){o.confirm({title:a("Delete variable"),content:a("Are you sure you want to delete it?"),onOk:function(){return q(function(){return C(this,function(t){switch(t.label){case 0:return[4,b.destroy({filterByTk:e.name})];case 1:return t.sent(),s(),[2]}})})()}})};var v=(t=q(function(e){var t;return C(this,function(r){return(t=(0,f.FormDrawer)({title:a("Edit")},"edit",function(){var r;return d().createElement(g.FormLayout,{layout:"vertical"},d().createElement(f.SchemaComponentOptions,{scope:{createOnly:!1,t:a}},d().createElement(T,{schema:B})),d().createElement(f.FormDrawer.Footer,null,d().createElement(g.FormButtonGroup,{align:"right"},d().createElement(g.Reset,{onClick:function(){t.close()}},a("Cancel")),d().createElement(g.Submit,{onSubmit:(r=q(function(t){return C(this,function(r){switch(r.label){case 0:return[4,l.request({url:"environmentVariables:update?filterByTk=".concat(e.name),method:"post",data:F({},t)})];case 1:return r.sent(),n.refresh(),[2]}})}),function(e){return r.apply(this,arguments)})},a("Submit")))))},p)).open({initialValues:F({},e)}),[2]})}),function(e){return t.apply(this,arguments)});return d().createElement("div",null,d().createElement(w.Table,{loading:c,size:"middle",rowKey:"name",dataSource:null==u?void 0:u.data,pagination:!1,columns:[{title:a("Name"),dataIndex:"name",ellipsis:!0},{title:a("Type"),dataIndex:"type",render:function(e){return d().createElement(w.Tag,{color:m[e].color},m[e].label)}},{title:a("Value"),ellipsis:!0,render:function(e){return d().createElement("div",null,"default"===e.type?e.value:"******")}},{title:a("Actions"),width:200,render:function(e){return d().createElement(w.Space,null,d().createElement("a",{onClick:function(){return v(e)}},a("Edit")),d().createElement("a",{onClick:function(){return y(e)}},a("Delete")))}}],rowSelection:{type:"checkbox",onChange:function(e,t){r(e)}}}))}function _(){var e,t,n,r=(0,f.useAPIClient)(),o=O(),a=w.App.useApp().modal,l=(0,m.useContext)(b).variablesRequest,i=I((0,m.useState)([]),2),u=i[0],c=i[1],s=r.resource("environmentVariables"),y=(0,f.useGlobalTheme)().theme;var v=(e=q(function(e){var t;return C(this,function(n){switch(n.label){case 0:return t=Object.entries(e).map(function(e){var t,n,r=I(e,2),o=r[0];return(t=r[1],n=o,t.trim().split("\n").map(function(e){var t,r=A(t=e.split("="))||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||R(t)||P(),o=r[0],a=r.slice(1);return o&&{name:o.trim(),value:a.join("=").trim(),type:"secret"===n?"secret":"default"}})).filter(Boolean)}),[4,r.request({url:"environmentVariables:create",method:"post",data:t.flat()})];case 1:return n.sent(),[2]}})}),function(t){return e.apply(this,arguments)}),x=[{name:"name",title:o("Name"),operators:[{label:'{{t("contains")}}',value:"$includes",selected:!0},{label:'{{t("does not contain")}}',value:"$notIncludes"},{label:'{{t("is")}}',value:"$eq"},{label:'{{t("is not")}}',value:"$ne"}],schema:{type:"string",title:o("Name"),"x-component":"Input"}},{name:"type",title:o("Type"),operators:[{label:'{{t("is")}}',value:"$match",selected:!0,schema:{"x-component":"Select","x-component-props":{mode:"tags"}}},{label:'{{t("is not")}}',value:"$notMatch",schema:{"x-component":"Select","x-component-props":{mode:"tags"}}}],schema:{type:"string",title:o("Type"),"x-component":"Select",enum:[{value:"default",label:'{{t("Plain text")}}'},{value:"secret",label:'{{t("Encrypted")}}'}]}},{name:"value",title:o("Value"),operators:[{label:'{{t("contains")}}',value:"$includes",selected:!0},{label:'{{t("does not contain")}}',value:"$notIncludes"},{label:'{{t("is")}}',value:"$eq"},{label:'{{t("is not")}}',value:"$ne"}],schema:{type:"string",title:o("Value"),"x-component":"Input"}}];return d().createElement("div",null,(null==l?void 0:null===(n=l.data)||void 0===n?void 0:null===(t=n.meta)||void 0===t?void 0:t.updated)&&d().createElement(w.Alert,{type:"warning",style:{marginBottom:"1.2em",alignItems:"center"},description:d().createElement("div",null,o("Variables and secrets have been updated. A restart is required for the changes to take effect.")," "),action:d().createElement(w.Button,{size:"middle",type:"primary",onClick:q(function(){return C(this,function(e){switch(e.label){case 0:return[4,r.resource("app").refresh()];case 1:return e.sent(),[2]}})})},o("Restart now"))}),d().createElement(w.Card,null,d().createElement("div",{style:{float:"left"}},d().createElement(f.SchemaComponent,{schema:{name:"filter",type:"object",title:'{{ t("Filter") }}',default:{$and:[{name:{$includes:""}}]},"x-component":"Filter.Action",enum:x,"x-use-component-props":function(){var e,t=(0,p.useField)(),n=l.run;return{options:x,onSubmit:(e=q(function(e){return C(this,function(r){return n(e),t.setValue(e),[2]})}),function(t){return e.apply(this,arguments)}),onReset:function(e){t.setValue(e)}}}},scope:{t:o}})),d().createElement(w.Flex,{justify:"end",style:{marginBottom:16}},d().createElement(w.Space,null,d().createElement(w.Button,{icon:d().createElement(h.ReloadOutlined,null),onClick:function(){var e;null==l||null===(e=l.refresh)||void 0===e||e.call(l)}},o("Refresh")),d().createElement(w.Button,{icon:d().createElement(h.DeleteOutlined,null),onClick:function(){u.length>0&&a.confirm({title:o("Delete variable"),content:o("Are you sure you want to delete it?"),onOk:function(){return q(function(){var e;return C(this,function(t){switch(t.label){case 0:return[4,s.destroy({filterByTk:u})];case 1:return t.sent(),null==l||null===(e=l.refresh)||void 0===e||e.call(l),[2]}})})()}})}},o("Delete")),d().createElement(w.Dropdown,{menu:{onClick:function(e){(0,f.FormDrawer)({variable:o("Add variable"),bulk:o("Bulk import")}[e.key],"add-new",function(){var t;return d().createElement(g.FormLayout,{layout:"vertical"},d().createElement(f.SchemaComponentOptions,{scope:{createOnly:!0,t:o}},d().createElement(T,{schema:"bulk"===e.key?V:B})),d().createElement(f.FormDrawer.Footer,null,d().createElement(g.FormButtonGroup,{align:"right"},d().createElement(g.Reset,null,o("Cancel")),d().createElement(g.Submit,{onSubmit:(t=q(function(t){return C(this,function(n){switch(n.label){case 0:if("bulk"!==e.key)return[3,2];return[4,v(t)];case 1:return n.sent(),l.refresh(),[3,4];case 2:return[4,r.request({url:"environmentVariables:create",method:"post",data:F({},t)})];case 3:n.sent(),l.refresh(),n.label=4;case 4:return[2]}})}),function(e){return t.apply(this,arguments)})},o("Submit")))))},y).open({initialValues:{}}).then(console.log).catch(console.log)},items:[{key:"variable",label:o("Add variable")},{type:"divider"},{key:"bulk",label:o("Bulk import")}]}},d().createElement(w.Button,{type:"primary",icon:d().createElement(h.PlusOutlined,null)},o("Add new")," ",d().createElement(h.DownOutlined,null))))),d().createElement($,{request:l,setSelectRowKeys:c})))}function D(){return d().createElement(_,null)}var G=function(){var e,t=O(),n=(0,m.useContext)(b).variablesRequest||{},r=n.data;return!n.loading&&(null==r?void 0:null===(e=r.data)||void 0===e?void 0:e.length)?{name:"$env",title:t("Variables and secrets"),value:"$env",label:t("Variables and secrets"),children:null==r?void 0:r.data.map(function(e){return{title:e.name,name:e.name,value:e.name,label:e.name}}).filter(Boolean)}:null};function M(e,t,n,r,o,a,l){try{var i=e[a](l),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,o)}function z(e,t,n){return(z=J()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&L(o,n.prototype),o}).apply(null,arguments)}function N(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)}}function K(e){return(K=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function L(e,t){return(L=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Z(e){var t="function"==typeof Map?new Map:void 0;return(Z=function(e){var n;if(null===e||(n=e,-1===Function.toString.call(n).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 z(e,arguments,K(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),L(r,e)})(e)}function J(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(J=function(){return!!e})()}var U=function(e){var t,n,r;function o(){var e,t,n;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),e=this,t=o,n=arguments,t=K(t),function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,J()?Reflect.construct(t,n||[],K(e).constructor):t.apply(e,n))}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&L(e,t)}(o,e),t=o,n=[{key:"load",value:function(){var e,t=this;return(e=function(){return function(e,t){var n,r,o,a,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){return function(a){if(n)throw TypeError("Generator is already executing.");for(;l;)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 l.label++,{value:a[1],done:!1};case 5:l.label++,r=a[1],a=[0];continue;case 7:a=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){l=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){l.label=a[1];break}if(6===a[0]&&l.label<o[1]){l.label=o[1],o=a;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(a);break}o[2]&&l.ops.pop(),l.trys.pop();continue}a=t.call(e,l)}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}}([a,i])}}}(this,function(e){return t.app.pluginSettingsManager.add("environment",{title:t.t("Variables and secrets"),icon:"TableOutlined",Component:D}),t.app.addGlobalVar("$env",G),t.app.use(v),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function l(e){M(a,r,o,l,i,"next",e)}function i(e){M(a,r,o,l,i,"throw",e)}l(void 0)})})()}}],N(t.prototype,n),o}(Z(f.Plugin)),H=U;return s}()});
|
package/dist/externalVersion.js
CHANGED
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"@formily/react": "2.3.0",
|
|
12
|
-
"@nocobase/client": "1.6.0
|
|
12
|
+
"@nocobase/client": "1.6.0",
|
|
13
13
|
"react": "18.2.0",
|
|
14
|
-
"@nocobase/server": "1.6.0
|
|
15
|
-
"@ant-design/icons": "5.
|
|
14
|
+
"@nocobase/server": "1.6.0",
|
|
15
|
+
"@ant-design/icons": "5.6.1",
|
|
16
16
|
"@formily/antd-v5": "1.1.9",
|
|
17
17
|
"@formily/core": "2.3.0",
|
|
18
18
|
"antd": "5.12.8",
|
|
19
|
-
"@nocobase/database": "1.6.0
|
|
19
|
+
"@nocobase/database": "1.6.0"
|
|
20
20
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-environment-variables",
|
|
3
|
-
"version": "1.6.0
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"main": "dist/server/index.js",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@nocobase/client": "1.x",
|
|
@@ -16,5 +16,5 @@
|
|
|
16
16
|
"keywords": [
|
|
17
17
|
"System management"
|
|
18
18
|
],
|
|
19
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "7422d72a4e515a11300860028a26030ed5732135"
|
|
20
20
|
}
|