@nocobase/plugin-environment-variables 1.6.0-alpha.10
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 +159 -0
- package/README.md +1 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/EnvironmentVariablesAndSecretsProvider.d.ts +12 -0
- package/dist/client/components/EnvironmentPage.d.ts +10 -0
- package/dist/client/components/EnvironmentTabs.d.ts +6 -0
- package/dist/client/index.d.ts +13 -0
- package/dist/client/index.js +10 -0
- package/dist/client/locale.d.ts +10 -0
- package/dist/client/utils.d.ts +15 -0
- package/dist/externalVersion.js +20 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +48 -0
- package/dist/locale/en-US.json +1 -0
- package/dist/locale/zh-CN.json +16 -0
- package/dist/re.d.ts +9 -0
- package/dist/re.js +36 -0
- package/dist/server/AesEncryptor.d.ts +17 -0
- package/dist/server/AesEncryptor.js +97 -0
- package/dist/server/collections/environmentVariables.d.ts +10 -0
- package/dist/server/collections/environmentVariables.js +56 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +42 -0
- package/dist/server/plugin.d.ts +26 -0
- package/dist/server/plugin.js +185 -0
- package/package.json +18 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
Updated Date: October 15, 2024
|
|
2
|
+
|
|
3
|
+
NocoBase License Agreement
|
|
4
|
+
|
|
5
|
+
NOCOBASE PTE. LTD.,a Singaporean Exempt Private Company Limited by Shares with its principal place of business located at #03-01 ROBINSON 112 ("The Company") https://www.nocobase.com/ issues this License Agreement ("Agreement") to you. You, as an individual or a company ("the User"), will be deemed to voluntarily accept all terms of this Agreement by using NocoBase (including but not limited to obtaining NocoBase source code or installation package in any form, installing and using NocoBase, purchasing NocoBase commercial license and services, purchasing NocoBase commercial plugins). If the User does not agree to any term of this Agreement, or cannot accurately understand our interpretation of the relevant terms, please stop using it immediately.
|
|
6
|
+
|
|
7
|
+
This Agreement applies to any use, quotation, contract, invoice, and all software delivered by the Company. The User and the Company or NocoBase's agents can no longer sign a separate license agreement for the sale and delivery of the software.
|
|
8
|
+
|
|
9
|
+
The Company reserves the right to formulate and modify this Agreement from time to time as needed. If there are changes, the Company will announce them in the form of website announcements, without further individual notification. The changed Agreement will automatically take effect once it is announced, becoming part of this Agreement.
|
|
10
|
+
|
|
11
|
+
==============
|
|
12
|
+
1. Definitions
|
|
13
|
+
==============
|
|
14
|
+
|
|
15
|
+
1.1 "Software" refers to the NocoBase kernel and plugins placed in the same code repository as the kernel, including their source code, installation packages, images, and all their modifications, updates, and upgrades.
|
|
16
|
+
|
|
17
|
+
1.2 "Community Edition" refers to the free version of the Software provided to the User through public channels.
|
|
18
|
+
|
|
19
|
+
1.3 "Commercial Edition" refers to the paid version of the Software purchased by the User from the Company or its agents, downloaded through exclusive channels, and includes additional benefits. It consists of three versions: Standard Edition, Professional Edition, and Enterprise Edition.
|
|
20
|
+
|
|
21
|
+
1.4 "Marketplace" refers to the marketplace provided by the Company for selling Software plugins and solutions.
|
|
22
|
+
|
|
23
|
+
1.5 "Commercial Plugin" refers to the paid plugins sold in the Marketplace.
|
|
24
|
+
|
|
25
|
+
1.6 "Upper Layer Application" refers to a specific business use case application serving internal or external customers of the User, developed based on Software and Commercial Plugins, such as ERP/CRM.
|
|
26
|
+
|
|
27
|
+
1.7 "Customer" refers to the clients who purchase the User's Upper Layer Application.
|
|
28
|
+
|
|
29
|
+
1.8 "Third-Party Open Source Software" refers to open source software provided with Software and Commercial Plugins. They are licensed through various published open source software licenses or copyright notices accompanying such software.
|
|
30
|
+
|
|
31
|
+
===================================
|
|
32
|
+
2. Intellectual Property Protection
|
|
33
|
+
===================================
|
|
34
|
+
|
|
35
|
+
Except for Third-Party Open Source Software, the Company owns all copyrights, trademark rights, patent rights, trade secrets, and other intellectual property rights of the Software, and has registered and protected them in relevant countries and regions according to the "Paris Convention" or "TRIPS Agreement", ensuring that the intellectual property rights of the Software and Commercial Plugins are internationally recognized and protected.
|
|
36
|
+
|
|
37
|
+
=============
|
|
38
|
+
3. Disclaimer
|
|
39
|
+
=============
|
|
40
|
+
|
|
41
|
+
3.1 The User shall not use the Software and Commercial Plugins to engage in activities that violate local laws and regulations, religious beliefs. All legal responsibilities and legal consequences arising from the use of Software and Commercial Plugins shall be borne by the User.
|
|
42
|
+
|
|
43
|
+
3.2 The Company shall not be liable for any direct, indirect, special, incidental, or consequential damages (including but not limited to loss of profits, business interruption, data loss, or business information disclosure) caused by the User's use of the Software and Commercial Plugins, even if it has been previously informed of the possibility of such damages.
|
|
44
|
+
|
|
45
|
+
===============
|
|
46
|
+
4. License Type
|
|
47
|
+
===============
|
|
48
|
+
|
|
49
|
+
4.1 The Software uses a dual license type of AGPL-3.0 Open Source License https://www.gnu.org/licenses/agpl-3..en.htm and Commercial License.
|
|
50
|
+
|
|
51
|
+
4.2 The Community Edition uses the AGPL-3.0 Open Source License https://www.gnu.org/licenses/agpl-3.0.en.html.
|
|
52
|
+
|
|
53
|
+
4.3 The Commercial Edition (including Standard, Professional, and Enterprise Editions) uses the Commercial License.
|
|
54
|
+
|
|
55
|
+
4.4 Commercial Plugins use the Commercial Plugin License.
|
|
56
|
+
|
|
57
|
+
================================================
|
|
58
|
+
5. Rights and Obligations of Open Source License
|
|
59
|
+
================================================
|
|
60
|
+
|
|
61
|
+
5.1 The Software can be used for commercial purposes.
|
|
62
|
+
|
|
63
|
+
5.2 The User can sell plugins developed for the Software in the Marketplace.
|
|
64
|
+
|
|
65
|
+
5.3 Outside the Marketplace, changes and plugins to the Software developed by the User or third parties, and third-party applications developed based on the Software must all be open-sourced under the AGPL-3.0 license.
|
|
66
|
+
|
|
67
|
+
5.4 It is not allowed to remove or change the brand, name, link, version number, license, and other information about NocoBase on the Software interface, except for the main LOGO in the upper left corner of the page.
|
|
68
|
+
|
|
69
|
+
5.5 It is not allowed to remove or change all intellectual property statements about NocoBase in the code.
|
|
70
|
+
|
|
71
|
+
5.6 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.
|
|
72
|
+
|
|
73
|
+
5.7 Comply with all requirements of the AGPL-3.0 agreement.
|
|
74
|
+
|
|
75
|
+
===============================
|
|
76
|
+
6. Rights of Commercial License
|
|
77
|
+
===============================
|
|
78
|
+
|
|
79
|
+
6.1 Obtain a permanent commercial license of the Software.
|
|
80
|
+
|
|
81
|
+
6.2 Get 12 months of upgrade and exclusive technical support.
|
|
82
|
+
|
|
83
|
+
6.3 The licensed Software can be used for commercial purposes with no restrictions on the number of applications and users.
|
|
84
|
+
|
|
85
|
+
6.4 Changes and plugins to the Software, and applications integrated with the Software do not need to be open sourced.
|
|
86
|
+
|
|
87
|
+
6.5 Can remove or change the brand, name, link, version number, license, and other information about NocoBase on the Software interface.
|
|
88
|
+
|
|
89
|
+
6.6 Can sell plugins developed for Software in the Marketplace.
|
|
90
|
+
|
|
91
|
+
6.7 The User with a Professional or Enterprise Edition License can sell Upper Layer Application to their clients.
|
|
92
|
+
|
|
93
|
+
6.8 Not restricted by the AGPL-3.0 agreement.
|
|
94
|
+
|
|
95
|
+
6.9 If there are other agreements in the contract for the above rights, the contract agreement shall prevail.
|
|
96
|
+
|
|
97
|
+
====================================
|
|
98
|
+
7. Obligations of Commercial License
|
|
99
|
+
====================================
|
|
100
|
+
|
|
101
|
+
7.1 It is not allowed to remove or change all intellectual property statements about NocoBase in the code.
|
|
102
|
+
|
|
103
|
+
7.2 It is not allowed to sell, transfer, lease, share, or distribute the Commercial License.
|
|
104
|
+
|
|
105
|
+
7.3 It is not allowed to sell, transfer, lease, share, or distribute any form of no-code, zero-code, low-code platform, or developer tools developed based on Software.
|
|
106
|
+
|
|
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
|
+
|
|
109
|
+
7.5 It is not allowed for the User with a Standard Edition license to sell Upper Layer Application to clients without a Commercial license.
|
|
110
|
+
|
|
111
|
+
7.6 It is not allowed to publicly sell plugins developed for Software outside of the Marketplace.
|
|
112
|
+
|
|
113
|
+
7.7 If there is a violation of the above obligations or the terms of this Agreement, the rights owned by the User will be immediately terminated, the paid fees will not be refunded, and the Company reserves the right to pursue the User's legal responsibility.
|
|
114
|
+
|
|
115
|
+
7.8 If there are other agreements in the contract for the above obligations, the contract agreement shall prevail.
|
|
116
|
+
|
|
117
|
+
======================================
|
|
118
|
+
8. Rights of Commercial Plugin License
|
|
119
|
+
======================================
|
|
120
|
+
|
|
121
|
+
8.1 Obtain a permanent Commercial Plugin License for the Commercial Plugin.
|
|
122
|
+
|
|
123
|
+
8.2 Receive 12 months of upgrades and exclusive technical support.
|
|
124
|
+
|
|
125
|
+
8.3 Can be used for commercial purposes without restrictions on the number of applications or users.
|
|
126
|
+
|
|
127
|
+
8.4 The User with a Professional or Enterprise Edition License can use the Commercial Plugin in Upper Layer Applications sold to their customers.
|
|
128
|
+
|
|
129
|
+
8.5 Not restricted by the AGPL-3.0 agreement.
|
|
130
|
+
|
|
131
|
+
8.6 If there are other agreements in the contract regarding the above rights, the contract agreement shall prevail.
|
|
132
|
+
|
|
133
|
+
===========================================
|
|
134
|
+
9. Obligations of Commercial Plugin License
|
|
135
|
+
===========================================
|
|
136
|
+
|
|
137
|
+
9.1 It is not allowed to remove or change any intellectual property statements about NocoBase and the plugin authors in the code.
|
|
138
|
+
|
|
139
|
+
9.2 It is not allowed to sell, transfer, lease, share, or gift the Commercial Plugin.
|
|
140
|
+
|
|
141
|
+
9.3 It is not allowed to use reverse engineering, decompilation, or other methods to attempt to discover the source code of Commercial Plugins without obtaining a source code license.
|
|
142
|
+
|
|
143
|
+
9.4 It is not allowed to disclose the source code of Commercial Plugins to any third party.
|
|
144
|
+
|
|
145
|
+
9.5 If there is any violation of the above obligations or the terms of this Agreement, the rights owned by the User will be immediately terminated, the paid fees will not be refunded, and the Company reserves the right to pursue the User's legal responsibility.
|
|
146
|
+
|
|
147
|
+
9.6 If there are other agreements in the contract regarding the above obligations, the contract agreement shall prevail.
|
|
148
|
+
|
|
149
|
+
=============================================================
|
|
150
|
+
10. Legal Jurisdiction, Interpretation, and Dispute Resolution
|
|
151
|
+
=============================================================
|
|
152
|
+
|
|
153
|
+
10.1 Except for Mainland China, the interpretation, application, and all matters related to this agreement are subject to the jurisdiction of Singapore law.
|
|
154
|
+
|
|
155
|
+
10.2 Any dispute related to this Agreement should first be resolved through friendly negotiation. If the negotiation fails to resolve the dispute, the dispute should be submitted to the International Chamber of Commerce (ICC) for arbitration. The arbitration venue should be Singapore, conducted in English.
|
|
156
|
+
|
|
157
|
+
10.3 All terms and conditions of this Agreement shall be deemed enforceable to the maximum extent permitted by applicable law. If any term of this Agreement is deemed invalid by any applicable law, the invalidity of that term does not affect the validity of any other term of this Agreement, and it should be deemed that the invalid term has been modified as much as possible to make it valid and enforceable, or if the term cannot be modified, it should be deemed to have been deleted from this Agreement.
|
|
158
|
+
|
|
159
|
+
10.4 The arbitration award is final, binding on both parties, and can be enforced in any court with jurisdiction.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @nocobase/plugin-environment-variables
|
package/client.d.ts
ADDED
package/client.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/client/index.js');
|
|
@@ -0,0 +1,12 @@
|
|
|
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 React from 'react';
|
|
10
|
+
declare const EnvAndSecretsContext: React.Context<any>;
|
|
11
|
+
declare const EnvironmentVariablesAndSecretsProvider: React.MemoExoticComponent<import("@formily/react").ReactFC<unknown>>;
|
|
12
|
+
export { EnvAndSecretsContext, EnvironmentVariablesAndSecretsProvider };
|
|
@@ -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
|
+
import React from 'react';
|
|
10
|
+
export default function EnvironmentPage(): React.JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
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 { Plugin } from '@nocobase/client';
|
|
10
|
+
export declare class PluginEnvironmentVariablesClient extends Plugin {
|
|
11
|
+
load(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export default PluginEnvironmentVariablesClient;
|
|
@@ -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("@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"),E=c("721"),w=/^[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?w.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}}),B={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 "}}}},V={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=E.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(T,{schema:V})),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(E.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(E.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(E.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=E.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(E.Alert,{type:"warning",style:{marginBottom:"1.2em",alignItems:"center"},description:d().createElement("div",null,o("Environment variables have been updated. A restart is required for the changes to take effect.")," "),action:d().createElement(E.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(E.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(E.Flex,{justify:"end",style:{marginBottom:16}},d().createElement(E.Space,null,d().createElement(E.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(E.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(E.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(T,{schema:"bulk"===e.key?B:V})),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(E.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("Environment variables"),value:"$env",label:t("Environment variables"),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("Environment variables"),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}()});
|
|
@@ -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 tStr(key: string): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
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 const useGetEnvironmentVariables: () => {
|
|
10
|
+
name: string;
|
|
11
|
+
title: string;
|
|
12
|
+
value: string;
|
|
13
|
+
label: string;
|
|
14
|
+
children: any;
|
|
15
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
"@formily/react": "2.3.0",
|
|
12
|
+
"@nocobase/client": "1.6.0-alpha.10",
|
|
13
|
+
"react": "18.2.0",
|
|
14
|
+
"@nocobase/server": "1.6.0-alpha.10",
|
|
15
|
+
"@ant-design/icons": "5.2.6",
|
|
16
|
+
"@formily/antd-v5": "1.1.9",
|
|
17
|
+
"@formily/core": "2.3.0",
|
|
18
|
+
"antd": "5.12.8",
|
|
19
|
+
"@nocobase/database": "1.6.0-alpha.10"
|
|
20
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -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 * from './server';
|
|
10
|
+
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,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Environment": "环境",
|
|
3
|
+
"Environment variables": "环境变量",
|
|
4
|
+
"Variables": "变量",
|
|
5
|
+
"Secrets": "密钥",
|
|
6
|
+
"Add variable": "添加变量",
|
|
7
|
+
"Bulk import": "批量导入",
|
|
8
|
+
"Name": "名称",
|
|
9
|
+
"Value": "值",
|
|
10
|
+
"Type": "类型",
|
|
11
|
+
"Plain text": "明文",
|
|
12
|
+
"Encrypted": "加密",
|
|
13
|
+
"Delete variable": "删除变量",
|
|
14
|
+
"Restart now": "立即重启",
|
|
15
|
+
"Environment variables have been updated. A restart is required for the changes to take effect.": "检测到环境变量有更新,需重启应用才能生效。"
|
|
16
|
+
}
|
package/dist/re.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
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 const VAR_NAME_RE: RegExp;
|
package/dist/re.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
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 re_exports = {};
|
|
28
|
+
__export(re_exports, {
|
|
29
|
+
VAR_NAME_RE: () => VAR_NAME_RE
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(re_exports);
|
|
32
|
+
const VAR_NAME_RE = /^[A-Za-z][A-Za-z0-9_]*$/;
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
VAR_NAME_RE
|
|
36
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
/// <reference types="node" />
|
|
10
|
+
declare class AesEncryptor {
|
|
11
|
+
private key;
|
|
12
|
+
constructor(key: Buffer);
|
|
13
|
+
encrypt(text: string): Promise<string>;
|
|
14
|
+
decrypt(encryptedText: string): Promise<string>;
|
|
15
|
+
static getOrGenerateKey(keyFilePath: string): Promise<Buffer>;
|
|
16
|
+
}
|
|
17
|
+
export default AesEncryptor;
|
|
@@ -0,0 +1,97 @@
|
|
|
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 AesEncryptor_exports = {};
|
|
38
|
+
__export(AesEncryptor_exports, {
|
|
39
|
+
default: () => AesEncryptor_default
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(AesEncryptor_exports);
|
|
42
|
+
var import_crypto = __toESM(require("crypto"));
|
|
43
|
+
var import_promises = __toESM(require("fs/promises"));
|
|
44
|
+
var import_path = __toESM(require("path"));
|
|
45
|
+
class AesEncryptor {
|
|
46
|
+
key;
|
|
47
|
+
constructor(key) {
|
|
48
|
+
if (key.length !== 32) {
|
|
49
|
+
throw new Error("Key must be 32 bytes for AES-256 encryption.");
|
|
50
|
+
}
|
|
51
|
+
this.key = key;
|
|
52
|
+
}
|
|
53
|
+
async encrypt(text) {
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
try {
|
|
56
|
+
const iv = import_crypto.default.randomBytes(16);
|
|
57
|
+
const cipher = import_crypto.default.createCipheriv("aes-256-cbc", this.key, iv);
|
|
58
|
+
const encrypted = Buffer.concat([cipher.update(Buffer.from(text, "utf8")), cipher.final()]);
|
|
59
|
+
resolve(iv.toString("hex") + encrypted.toString("hex"));
|
|
60
|
+
} catch (error) {
|
|
61
|
+
reject(error);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
async decrypt(encryptedText) {
|
|
66
|
+
return new Promise((resolve, reject) => {
|
|
67
|
+
try {
|
|
68
|
+
const iv = Buffer.from(encryptedText.slice(0, 32), "hex");
|
|
69
|
+
const encrypted = Buffer.from(encryptedText.slice(32), "hex");
|
|
70
|
+
const decipher = import_crypto.default.createDecipheriv("aes-256-cbc", this.key, iv);
|
|
71
|
+
const decrypted = Buffer.concat([decipher.update(encrypted), decipher.final()]);
|
|
72
|
+
resolve(decrypted.toString("utf8"));
|
|
73
|
+
} catch (error) {
|
|
74
|
+
reject(error);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
static async getOrGenerateKey(keyFilePath) {
|
|
79
|
+
try {
|
|
80
|
+
const key = await import_promises.default.readFile(keyFilePath);
|
|
81
|
+
if (key.length !== 32) {
|
|
82
|
+
throw new Error("Invalid key length in file.");
|
|
83
|
+
}
|
|
84
|
+
return key;
|
|
85
|
+
} catch (error) {
|
|
86
|
+
if (error.code === "ENOENT") {
|
|
87
|
+
const key = import_crypto.default.randomBytes(32);
|
|
88
|
+
await import_promises.default.mkdir(import_path.default.dirname(keyFilePath), { recursive: true });
|
|
89
|
+
await import_promises.default.writeFile(keyFilePath, key);
|
|
90
|
+
return key;
|
|
91
|
+
} else {
|
|
92
|
+
throw new Error(`Failed to load key: ${error.message}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
var AesEncryptor_default = AesEncryptor;
|
|
@@ -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
|
+
declare const _default: import("@nocobase/database").CollectionOptions;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,56 @@
|
|
|
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 environmentVariables_exports = {};
|
|
28
|
+
__export(environmentVariables_exports, {
|
|
29
|
+
default: () => environmentVariables_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(environmentVariables_exports);
|
|
32
|
+
var import_database = require("@nocobase/database");
|
|
33
|
+
var import_re = require("../../re");
|
|
34
|
+
var environmentVariables_default = (0, import_database.defineCollection)({
|
|
35
|
+
name: "environmentVariables",
|
|
36
|
+
autoGenId: false,
|
|
37
|
+
migrationRules: ["schema-only"],
|
|
38
|
+
fields: [
|
|
39
|
+
{
|
|
40
|
+
type: "string",
|
|
41
|
+
name: "name",
|
|
42
|
+
primaryKey: true,
|
|
43
|
+
validate: {
|
|
44
|
+
is: import_re.VAR_NAME_RE
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
type: "string",
|
|
49
|
+
name: "type"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
type: "text",
|
|
53
|
+
name: "value"
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
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 { 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,26 @@
|
|
|
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 { Plugin } from '@nocobase/server';
|
|
10
|
+
import AesEncryptor from './AesEncryptor';
|
|
11
|
+
export declare class PluginEnvironmentVariablesServer extends Plugin {
|
|
12
|
+
aesEncryptor: AesEncryptor;
|
|
13
|
+
updated: boolean;
|
|
14
|
+
handleSyncMessage(message: any): Promise<void>;
|
|
15
|
+
load(): Promise<void>;
|
|
16
|
+
createAesEncryptor(): Promise<void>;
|
|
17
|
+
registerACL(): void;
|
|
18
|
+
listEnvironmentVariables(): Promise<any>;
|
|
19
|
+
setEnvironmentVariablesByText(texts: Array<{
|
|
20
|
+
text: string;
|
|
21
|
+
secret: boolean;
|
|
22
|
+
}>): Promise<void>;
|
|
23
|
+
onEnvironmentSaved(): void;
|
|
24
|
+
loadVariables(): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export default PluginEnvironmentVariablesServer;
|
|
@@ -0,0 +1,185 @@
|
|
|
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 plugin_exports = {};
|
|
38
|
+
__export(plugin_exports, {
|
|
39
|
+
PluginEnvironmentVariablesServer: () => PluginEnvironmentVariablesServer,
|
|
40
|
+
default: () => plugin_default
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
43
|
+
var import_server = require("@nocobase/server");
|
|
44
|
+
var import_path = __toESM(require("path"));
|
|
45
|
+
var import_AesEncryptor = __toESM(require("./AesEncryptor"));
|
|
46
|
+
class PluginEnvironmentVariablesServer extends import_server.Plugin {
|
|
47
|
+
aesEncryptor;
|
|
48
|
+
updated = false;
|
|
49
|
+
async handleSyncMessage(message) {
|
|
50
|
+
const { type, name, value } = message;
|
|
51
|
+
if (type === "updated") {
|
|
52
|
+
this.updated = true;
|
|
53
|
+
} else if (type === "setVariable") {
|
|
54
|
+
this.app.environment.setVariable(name, value);
|
|
55
|
+
} else if (type === "removeVariable") {
|
|
56
|
+
this.app.environment.removeVariable(name);
|
|
57
|
+
this.updated = true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async load() {
|
|
61
|
+
this.createAesEncryptor();
|
|
62
|
+
this.registerACL();
|
|
63
|
+
this.onEnvironmentSaved();
|
|
64
|
+
await this.loadVariables();
|
|
65
|
+
}
|
|
66
|
+
async createAesEncryptor() {
|
|
67
|
+
const key = await import_AesEncryptor.default.getOrGenerateKey(
|
|
68
|
+
import_path.default.resolve(process.cwd(), "storage", this.name, this.app.name, "aes_key.dat")
|
|
69
|
+
);
|
|
70
|
+
this.aesEncryptor = new import_AesEncryptor.default(key);
|
|
71
|
+
}
|
|
72
|
+
registerACL() {
|
|
73
|
+
this.app.acl.allow("environmentVariables", "list", "loggedIn");
|
|
74
|
+
this.app.acl.registerSnippet({
|
|
75
|
+
name: `pm.${this.name}`,
|
|
76
|
+
actions: ["environmentVariables:*", "app:refresh"]
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async listEnvironmentVariables() {
|
|
80
|
+
const repository = this.db.getRepository("environmentVariables");
|
|
81
|
+
const items = await repository.find({
|
|
82
|
+
sort: "name"
|
|
83
|
+
});
|
|
84
|
+
return items.map(({ name, type }) => ({ name, type }));
|
|
85
|
+
}
|
|
86
|
+
async setEnvironmentVariablesByText(texts) {
|
|
87
|
+
const repository = this.db.getRepository("environmentVariables");
|
|
88
|
+
for (const { text, secret } of texts) {
|
|
89
|
+
const lines = text.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
90
|
+
for (const line of lines) {
|
|
91
|
+
const equalIndex = line.indexOf("=");
|
|
92
|
+
if (equalIndex === -1) {
|
|
93
|
+
this.app.log.warn(`Invalid environment variable format: ${line}`);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const key = line.slice(0, equalIndex).trim();
|
|
97
|
+
const value = line.slice(equalIndex + 1).trim();
|
|
98
|
+
if (!key || !value) {
|
|
99
|
+
this.app.log.warn(`Empty key or value found: ${line}`);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
await repository.create({
|
|
103
|
+
values: {
|
|
104
|
+
name: key,
|
|
105
|
+
type: secret ? "secret" : "default",
|
|
106
|
+
value
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
onEnvironmentSaved() {
|
|
113
|
+
this.db.on("environmentVariables.afterUpdate", async (model, { transaction }) => {
|
|
114
|
+
this.updated = true;
|
|
115
|
+
this.sendSyncMessage({ type: "updated" }, { transaction });
|
|
116
|
+
});
|
|
117
|
+
this.db.on("environmentVariables.beforeSave", async (model) => {
|
|
118
|
+
if (model.type === "secret" && model.changed("value")) {
|
|
119
|
+
const encrypted = await this.aesEncryptor.encrypt(model.value);
|
|
120
|
+
model.set("value", encrypted);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
this.app.resourceManager.registerActionHandler("environmentVariables:list", async (ctx, next) => {
|
|
124
|
+
const repository = this.db.getRepository("environmentVariables");
|
|
125
|
+
const items = await repository.find({
|
|
126
|
+
sort: "name",
|
|
127
|
+
filter: ctx.action.params.filter
|
|
128
|
+
});
|
|
129
|
+
for (const model of items) {
|
|
130
|
+
if (model.type === "secret") {
|
|
131
|
+
model.set("value", void 0);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
ctx.withoutDataWrapping = true;
|
|
135
|
+
ctx.body = {
|
|
136
|
+
data: items,
|
|
137
|
+
meta: {
|
|
138
|
+
updated: this.updated
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
await next();
|
|
142
|
+
});
|
|
143
|
+
this.db.on("environmentVariables.afterSave", async (model, { transaction }) => {
|
|
144
|
+
if (model.type === "secret") {
|
|
145
|
+
try {
|
|
146
|
+
const decrypted = await this.aesEncryptor.decrypt(model.value);
|
|
147
|
+
model.set("value", decrypted);
|
|
148
|
+
} catch (error) {
|
|
149
|
+
this.app.log.error(error);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
this.app.environment.setVariable(model.name, model.value);
|
|
153
|
+
this.sendSyncMessage({ type: "setVariable", name: model.name, value: model.value }, { transaction });
|
|
154
|
+
});
|
|
155
|
+
this.db.on("environmentVariables.afterDestroy", async (model, { transaction }) => {
|
|
156
|
+
this.app.environment.removeVariable(model.name);
|
|
157
|
+
this.updated = true;
|
|
158
|
+
this.sendSyncMessage({ type: "removeVariable", name: model.name }, { transaction });
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
async loadVariables() {
|
|
162
|
+
const repository = this.db.getRepository("environmentVariables");
|
|
163
|
+
const r = await repository.collection.existsInDb();
|
|
164
|
+
if (!r) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const items = await repository.find();
|
|
168
|
+
for (const model of items) {
|
|
169
|
+
if (model.type === "secret") {
|
|
170
|
+
try {
|
|
171
|
+
const decrypted = await this.aesEncryptor.decrypt(model.value);
|
|
172
|
+
model.set("value", decrypted);
|
|
173
|
+
} catch (error) {
|
|
174
|
+
this.app.log.error(error);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
this.app.environment.setVariable(model.name, model.value);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
var plugin_default = PluginEnvironmentVariablesServer;
|
|
182
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
183
|
+
0 && (module.exports = {
|
|
184
|
+
PluginEnvironmentVariablesServer
|
|
185
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nocobase/plugin-environment-variables",
|
|
3
|
+
"version": "1.6.0-alpha.10",
|
|
4
|
+
"main": "dist/server/index.js",
|
|
5
|
+
"peerDependencies": {
|
|
6
|
+
"@nocobase/client": "1.x",
|
|
7
|
+
"@nocobase/server": "1.x",
|
|
8
|
+
"@nocobase/test": "1.x"
|
|
9
|
+
},
|
|
10
|
+
"displayName": "Environment variables",
|
|
11
|
+
"displayName.zh-CN": "环境变量",
|
|
12
|
+
"description": "Centralized configuration and management of environment variables, used for sensitive data storage, configuration data reuse, multi-environment isolation, and more.",
|
|
13
|
+
"description.zh-CN": "集中配置和管理环境变量,用于敏感数据存储、配置数据重用、多环境隔离等。",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"System management"
|
|
16
|
+
],
|
|
17
|
+
"gitHead": "8ba8204282be7bf6674ef427fdbe31caa65977d5"
|
|
18
|
+
}
|
package/server.d.ts
ADDED
package/server.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/server/index.js');
|