@nocobase/plugin-license 2.0.0-alpha.9 → 2.0.0-beta.2

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.
Files changed (46) hide show
  1. package/dist/client/LicenseSettingContext.d.ts +16 -0
  2. package/dist/client/ServiceValidate.d.ts +12 -0
  3. package/dist/client/index.js +1 -1
  4. package/dist/client/locale.d.ts +1 -1
  5. package/dist/client/useSubmitProps.d.ts +12 -0
  6. package/dist/externalVersion.js +9 -3
  7. package/dist/locale/de-DE.json +13 -0
  8. package/dist/locale/en-US.json +33 -9
  9. package/dist/locale/es-ES.json +13 -0
  10. package/dist/locale/fr-FR.json +13 -0
  11. package/dist/locale/hu-HU.json +13 -0
  12. package/dist/locale/id-ID.json +13 -0
  13. package/dist/locale/it-IT.json +13 -0
  14. package/dist/locale/ja-JP.json +13 -0
  15. package/dist/locale/ko-KR.json +13 -0
  16. package/dist/locale/nl-NL.json +13 -1
  17. package/dist/locale/pt-BR.json +13 -0
  18. package/dist/locale/ru-RU.json +13 -0
  19. package/dist/locale/tr-TR.json +13 -0
  20. package/dist/locale/uk-UA.json +13 -0
  21. package/dist/locale/vi-VN.json +13 -0
  22. package/dist/locale/zh-CN.json +32 -8
  23. package/dist/locale/zh-TW.json +13 -0
  24. package/dist/server/index.d.ts +1 -0
  25. package/dist/server/index.js +6 -0
  26. package/dist/server/plugin.js +69 -6
  27. package/dist/server/utils/env.d.ts +16 -0
  28. package/dist/server/utils/env.js +125 -0
  29. package/dist/server/utils/index.d.ts +15 -0
  30. package/dist/server/utils/index.js +42 -0
  31. package/dist/server/{utils.d.ts → utils/instance.d.ts} +0 -1
  32. package/dist/server/{utils.js → utils/instance.js} +5 -12
  33. package/dist/server/utils/interface.d.ts +56 -0
  34. package/dist/server/utils/interface.js +44 -0
  35. package/dist/server/utils/key.d.ts +24 -0
  36. package/dist/server/utils/key.js +211 -0
  37. package/dist/server/utils/license.d.ts +34 -0
  38. package/dist/server/utils/license.js +80 -0
  39. package/dist/server/utils/pkg.d.ts +13 -0
  40. package/dist/server/utils/pkg.js +115 -0
  41. package/dist/server/utils/plugin.d.ts +24 -0
  42. package/dist/server/utils/plugin.js +129 -0
  43. package/package.json +7 -5
  44. package/tsconfig.env.json +17 -0
  45. package/utils/env.js +79 -0
  46. package/utils/interface.js +10 -0
@@ -0,0 +1,16 @@
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
+ interface LicenseSettingContextType {
11
+ onSaveSuccess: () => void;
12
+ keyExist: boolean;
13
+ refreshToken?: any;
14
+ }
15
+ export declare const LicenseSettingContext: React.Context<LicenseSettingContextType>;
16
+ export {};
@@ -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
+ export declare const ServiceValidate: ({ refreshToken }: {
11
+ refreshToken: number;
12
+ }) => React.JSX.Element;
@@ -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("ahooks"),require("@ant-design/icons"),require("@nocobase/client"),require("antd")):"function"==typeof define&&define.amd?define("@nocobase/plugin-license",["react","ahooks","@ant-design/icons","@nocobase/client","antd"],t):"object"==typeof exports?exports["@nocobase/plugin-license"]=t(require("react"),require("ahooks"),require("@ant-design/icons"),require("@nocobase/client"),require("antd")):e["@nocobase/plugin-license"]=t(e.react,e.ahooks,e["@ant-design/icons"],e["@nocobase/client"],e.antd)}(self,function(e,t,n,r,o){return function(){"use strict";var i={482:function(e){e.exports=n},772:function(e){e.exports=r},749:function(e){e.exports=t},721:function(e){e.exports=o},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 a={};return!function(){c.r(a),c.d(a,{PluginLicenseClient:function(){return C},default:function(){return A}});var e=c(772),t=c(156),n=c.n(t),r=c(721),o=c(749),i=JSON.parse('{"u2":"@nocobase/plugin-license"}');function u(){var t=(0,e.useApp)();return function(e){return t.i18n.t(e,{ns:[i.u2,"client"]})}}var l=c(482);function s(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 f(e,t,n,r,o,i,u){try{var c=e[i](u),a=c.value}catch(e){n(e);return}c.done?t(a):Promise.resolve(a).then(r,o)}function p(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function u(e){f(i,r,o,u,c,"next",e)}function c(e){f(i,r,o,u,c,"throw",e)}u(void 0)})}}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],u=!0,c=!1;try{for(o=o.call(e);!(u=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);u=!0);}catch(e){c=!0,r=e}finally{try{u||null==o.return||o.return()}finally{if(c)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return s(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 s(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){var a=[i,c];if(n)throw TypeError("Generator is already executing.");for(;u;)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 u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=t.call(e,u)}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}}}}var b=function(e){var t=e.text,n=e.onSuccess,r=e.onError;if(!navigator.clipboard){var o=document.createElement("textarea");o.value=t,o.style.top="0",o.style.left="0",o.style.position="fixed",document.body.appendChild(o),o.focus(),o.select();try{document.execCommand("copy"),null==n||n()}catch(e){null==r||r()}document.body.removeChild(o);return}navigator.clipboard.writeText(t).then(function(){null==n||n()}).catch(function(e){console.error(e),null==r||r()})};function v(){var o,i=(0,e.useAPIClient)(),c=y((0,t.useState)(!1),2),a=c[0],s=c[1],f=y((0,t.useState)(""),2);f[0],f[1];var v=u(),h=(o=p(function(){return d(this,function(e){return s(!0),[2,i.request({url:"/license:instance-id",method:"GET"}).then(function(e){var t;return null==e||null==(t=e.data)?void 0:t.data}).finally(function(){s(!1)})]})}),function(){return o.apply(this,arguments)});return n().createElement(r.Button,{onClick:p(function(){return d(this,function(e){switch(e.label){case 0:return[4,h()];case 1:return b({text:e.sent(),onSuccess:function(){r.message.success(v("Copied"))},onError:function(){r.message.error(v("Failed to copy, please open ./storage/.license/instance-id and copy it"))}}),[2]}})}),loading:a,icon:n().createElement(l.CopyOutlined,null),type:"link"},v("Copy"))}var h=function(){var n,o=(0,e.useAPIClient)(),i=y((0,t.useState)(!1),2),c=i[0],a=i[1],l=(0,e.useFormBlockContext)(),s=u(),f=(n=p(function(e){return d(this,function(t){switch(t.label){case 0:a(!0),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,o.request({url:"/license:license-key",method:"POST",data:{licenseKey:e}})];case 2:return t.sent(),a(!1),r.message.success(s("License key saved successfully, please re-run the plugin installation.")),[3,4];case 3:return t.sent(),a(!1),[3,4];case 4:return[2]}})}),function(e){return n.apply(this,arguments)});return{loading:c,onClick:p(function(){var e,t,n;return d(this,function(r){switch(r.label){case 0:return[4,null==(e=l.form)?void 0:e.validate()];case 1:return r.sent(),[4,f(null==(n=l.form)||null==(t=n.values)?void 0:t.licenseKey)];case 2:return r.sent(),[2]}})})}},m=function(i){var c=y((0,t.useState)(!1),2),a=c[0],l=c[1],s=(0,e.useAPIClient)(),f=(0,e.useFormBlockContext)(),b=u();return((0,o.useAsyncEffect)(p(function(){var e,t,n,r;return d(this,function(o){switch(o.label){case 0:return[4,s.request({url:"/license:is-exists",method:"GET"})];case 1:return(null==(n=o.sent())||null==(e=n.data)?void 0:e.data)&&(null==(r=f.form)||r.setFieldState("footer",function(e){e.visible=!1})),l(null==n||null==(t=n.data)?void 0:t.data),[2]}})}),[]),a)?n().createElement(n().Fragment,null,b("License key has been set"),"\xa0",n().createElement(r.Button,{onClick:function(){var e;l(!1),null==(e=f.form)||e.setFieldState("footer",function(e){e.visible=!0})}},b("Change key"))):n().createElement(r.Input.TextArea,function(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;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({rows:4},i))};function g(){var t=u(),o={type:"void","x-decorator":"FormBlockProvider","x-decorator-props":{dataSource:"main",collection:"users"},properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps",properties:{label:{type:"string",title:t("Instance ID"),"x-component":"InstanceId","x-decorator":"FormItem"},licenseKey:{type:"string",title:t("License key"),required:!0,"x-component":"TextArea","x-decorator":"FormItem","x-component-props":{placeholder:t("Enter license key")}},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{submit:{title:'{{t("Submit")}}',"x-component":"Action","x-use-component-props":"useSubmitProps","x-component-props":{type:"primary"}}}}}}}};return n().createElement(r.Card,{bordered:!1},n().createElement(e.SchemaComponent,{scope:{useSubmitProps:h},components:{InstanceId:v,TextArea:m},schema:{type:"void",properties:{form:o}}}))}function x(e,t,n,r,o,i,u){try{var c=e[i](u),a=c.value}catch(e){n(e);return}c.done?t(a):Promise.resolve(a).then(r,o)}function S(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function u(e){x(i,r,o,u,c,"next",e)}function c(e){x(i,r,o,u,c,"throw",e)}u(void 0)})}}function w(e,t,n){return(w=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&&k(o,n.prototype),o}).apply(null,arguments)}function O(e){return(O=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function k(e,t){return(k=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function P(e){var t="function"==typeof Map?new Map:void 0;return(P=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return w(e,arguments,O(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),k(n,e)})(e)}function j(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(j=function(){return!!e})()}function E(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){var a=[i,c];if(n)throw TypeError("Generator is already executing.");for(;u;)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 u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=t.call(e,u)}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}}}}var C=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=O(e),function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,j()?Reflect.construct(e,t||[],O(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&k(n,e),t=[{key:"afterAdd",value:function(){return S(function(){return E(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return S(function(){return E(this,function(e){return[2]})})()}},{key:"load",value:function(){var e=this;return S(function(){return E(this,function(t){return e.app.pluginSettingsManager.add("license-settings",{title:"{{t(".concat(JSON.stringify("License settings"),", { ns: ['").concat(i.u2,"', 'client'], nsMode: 'fallback' })}}"),icon:"SolutionOutlined",Component:g,aclSnippet:"pm.license-settings"}),[2]})})()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(P(e.Plugin)),A=C}(),a}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("ahooks"),require("@formily/react"),require("@nocobase/client"),require("@ant-design/icons"),require("antd")):"function"==typeof define&&define.amd?define("@nocobase/plugin-license",["react","ahooks","@formily/react","@nocobase/client","@ant-design/icons","antd"],t):"object"==typeof exports?exports["@nocobase/plugin-license"]=t(require("react"),require("ahooks"),require("@formily/react"),require("@nocobase/client"),require("@ant-design/icons"),require("antd")):e["@nocobase/plugin-license"]=t(e.react,e.ahooks,e["@formily/react"],e["@nocobase/client"],e["@ant-design/icons"],e.antd)}(self,function(e,t,n,r,o,i){return function(){"use strict";var a={482:function(e){e.exports=o},505:function(e){e.exports=n},772:function(e){e.exports=r},749:function(e){e.exports=t},721:function(e){e.exports=i},156:function(t){t.exports=e}},u={};function l(e){var t=u[e];if(void 0!==t)return t.exports;var n=u[e]={exports:{}};return a[e](n,n.exports,l),n.exports}l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,{a:t}),t},l.d=function(e,t){for(var n in t)l.o(t,n)&&!l.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var c={};return!function(){l.r(c),l.d(c,{PluginLicenseClient:function(){return N},default:function(){return _}});var e=l(772),t=l(156),n=l.n(t),r=l(721),o=l(749),i=JSON.parse('{"u2":"@nocobase/plugin-license"}');function a(){var t=(0,e.useApp)();return function(e,n){return String(t.i18n.t(e,function(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;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({ns:[i.u2,"client"]},n||{})))}}var u=l(482);function s(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}var f=function(o){var i,u=o.refreshToken,l=(0,e.useAPIClient)(),c=(i=(0,t.useState)(null),function(e){if(Array.isArray(e))return e}(i)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,u=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),i.length!==t);a=!0);}catch(e){u=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(u)throw r}}return i}}(i,2)||function(e,t){if(e){if("string"==typeof e)return s(e,2);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 s(e,t)}}(i,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),f=c[0],p=c[1],y=a();return((0,t.useEffect)(function(){p(null),l.request({url:"/license:license-validate",method:"get"}).then(function(e){var t;p(null==e||null==(t=e.data)?void 0:t.data)}).catch(function(e){console.log(e)})},[u]),(null==f?void 0:f.licenseStatus)&&(null==f?void 0:f.licenseStatus)==="active")?(null==f?void 0:f.isServiceConnection)===!1&&(null==f?void 0:f.isPkgLogin)===!1?n().createElement(r.Alert,{message:y("Network error."),description:n().createElement(n().Fragment,null,y("Due to network issues, the license key cannot be updated automatically. Please update it manually if necessary."),n().createElement("br",null),y("Plugins also cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.")),type:"warning",style:{marginBottom:12}}):(null==f?void 0:f.isServiceConnection)===!1?n().createElement(r.Alert,{message:y("Network error."),description:n().createElement(n().Fragment,null,y("Due to network issues, the license key cannot be updated automatically. Please update it manually if necessary.")),type:"warning",style:{marginBottom:12}}):(null==f?void 0:f.isPkgLogin)===!1?n().createElement(r.Alert,{message:y("Network error."),description:n().createElement(n().Fragment,null,y("Due to network issues, plugins cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.")),type:"warning",style:{marginBottom:12}}):null:null},p=l(505),y=n().createContext(null);function d(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 h(e,t,n,r,o,i,a){try{var u=e[i](a),l=u.value}catch(e){n(e);return}u.done?t(l):Promise.resolve(l).then(r,o)}function m(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){h(i,r,o,a,u,"next",e)}function u(e){h(i,r,o,a,u,"throw",e)}a(void 0)})}}function b(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){var l=[i,u];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var v=function(){var o,i,u=(0,e.useAPIClient)(),l=(o=(0,t.useState)(!1),function(e){if(Array.isArray(e))return e}(o)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,u=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),i.length!==t);a=!0);}catch(e){u=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(u)throw r}}return i}}(o,2)||function(e,t){if(e){if("string"==typeof e)return d(e,2);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 d(e,t)}}(o,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),c=l[0],s=l[1],f=(0,p.useForm)(),h=a(),v=n().useContext(y).onSaveSuccess,g=(i=m(function(e){var t,o,i;return b(this,function(a){switch(a.label){case 0:s(!0),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,u.request({url:"/license:license-key",method:"POST",data:{licenseKey:e}})];case 2:if(o=a.sent(),s(!1),"invalid"===(i=(null==o||null==(t=o.data)?void 0:t.data)||{}).keyStatus)return r.Modal.error({title:h("Invalid license key."),content:h("The license key is invalid. Please visit the NocoBase Service to obtain a new license key.")}),[2];if("invalid"===i.licenseStatus)return r.Modal.error({title:h("Invalid license key."),content:h("The current license key has been deprecated. Please visit the NocoBase Service to obtain a new license key.")}),[2];if(!1===i.envMatch)return r.Modal.error({title:h("Environment mismatch."),content:n().createElement(n().Fragment,null,!1===i.dbMatch&&!1===i.sysMatch&&n().createElement(n().Fragment,null,h("The current system and database do not match the licensed environment. Please use the new InstanceID to request a new license key.")),!0===i.dbMatch&&!1===i.sysMatch&&n().createElement(n().Fragment,null,h("The current system does not match the licensed system. Please use the new InstanceID to request a new license key.")),!1===i.dbMatch&&!0===i.sysMatch&&n().createElement(n().Fragment,null,h("The current database does not match the licensed database. Please use the new InstanceID to request a new license key.")))}),[2];if(!1===i.domainMatch)return r.Modal.error({title:h("Domain mismatch."),content:h("The current domain ({{domain}}) does not match the licensed domain. Please use the current domain to request a new license key.",{domain:i.current.domain,interpolation:{escapeValue:!1}})}),[2];if(null==v||v(),!0===i.isExpired)return r.message.success(h("The license key was saved successfully"),5),r.Modal.warning({title:h("The license has exceeded the upgrade validity period."),content:h("Plugins bound to this license can still be used but cannot be upgraded. To upgrade, please renew or repurchase the license.")}),[2];if(!1===i.isPkgLogin)return r.message.success(h("The license key was saved successfully"),5),r.Modal.warning({title:h("Network error."),content:h("Due to network issues, plugins cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.")}),[2];return r.message.success(h("License key saved successfully. Please retry the plugin installation.")),[3,4];case 3:return a.sent(),s(!1),r.message.error(h("Network error. Please try again.")),[3,4];case 4:return[2]}})}),function(e){return i.apply(this,arguments)});return{loading:c,onClick:m(function(){var e;return b(this,function(t){switch(t.label){case 0:return[4,null==f?void 0:f.validate()];case 1:return t.sent(),[4,g(null==(e=f.values)?void 0:e.licenseKey)];case 2:return t.sent(),[2]}})})}};function g(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 w(e,t,n,r,o,i,a){try{var u=e[i](a),l=u.value}catch(e){n(e);return}u.done?t(l):Promise.resolve(l).then(r,o)}function k(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){w(i,r,o,a,u,"next",e)}function u(e){w(i,r,o,a,u,"throw",e)}a(void 0)})}}function S(){return(S=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function x(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,u=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){u=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(u)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return g(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 g(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function P(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){var l=[i,u];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var E=function(e){var t=e.text,n=e.onSuccess,r=e.onError;if(!navigator.clipboard){var o=document.createElement("textarea");o.value=t,o.style.top="0",o.style.left="0",o.style.position="fixed",document.body.appendChild(o),o.focus(),o.select();try{document.execCommand("copy"),null==n||n()}catch(e){null==r||r()}document.body.removeChild(o);return}navigator.clipboard.writeText(t).then(function(){null==n||n()}).catch(function(e){console.error(e),null==r||r()})};function O(){var o,i=(0,e.useAPIClient)(),l=x((0,t.useState)(!1),2),c=l[0],s=l[1],f=x((0,t.useState)(""),2);f[0],f[1];var p=a(),y=(o=k(function(){return P(this,function(e){return s(!0),[2,i.request({url:"/license:instance-id",method:"GET"}).then(function(e){var t;return null==e||null==(t=e.data)?void 0:t.data}).finally(function(){s(!1)})]})}),function(){return o.apply(this,arguments)});return n().createElement(r.Button,{onClick:k(function(){return P(this,function(e){switch(e.label){case 0:return[4,y()];case 1:return E({text:e.sent(),onSuccess:function(){r.message.success(p("Copied"))},onError:function(){r.message.error(p("Failed to copy, please open ./storage/.license/instance-id and copy it"))}}),[2]}})}),loading:c,icon:n().createElement(u.CopyOutlined,null),type:"link"},p("Copy"))}var j=function(e){var i=S({},function(e){if(null==e)throw TypeError("Cannot destructure "+e);return e}(e)),u=x((0,t.useState)(!1),2),l=u[0],c=u[1],s=(0,p.useForm)(),f=a(),d=n().useContext(y).keyExist;return((0,o.useAsyncEffect)(k(function(){return P(this,function(e){return!1===d&&(c(!0),null==s||s.setFieldState("footer",function(e){e.visible=!0})),[2]})}),[d]),l)?n().createElement(r.Input.TextArea,function(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;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({rows:4},i)):d?n().createElement(n().Fragment,null,f("License key has been set"),"\xa0",n().createElement(r.Button,{onClick:function(){c(!0),null==s||s.setFieldState("footer",function(e){e.visible=!0})}},f("Change key"))):null},T=function(){var t=n().useContext(y),r=t.keyExist,o=t.refreshToken;return r?n().createElement(e.SchemaComponent,{key:o,schema:{type:"void",properties:{card:{type:"void","x-component":"LicenseCard"}}}}):null};function A(){var i=a(),u=x((0,t.useState)(0),2),l=u[0],c=u[1],s=x((0,t.useState)(null),2),p=s[0],d=s[1],h=(0,e.useAPIClient)();(0,o.useAsyncEffect)(k(function(){var e,t;return P(this,function(n){switch(n.label){case 0:return[4,h.request({url:"/license:is-exists",method:"GET"})];case 1:return d(null==(t=n.sent())||null==(e=t.data)?void 0:e.data),[2]}})}),[]);var m={type:"void","x-decorator":"Form",properties:{form:{type:"void",properties:{label:{type:"string",title:i("Instance ID"),"x-component":"InstanceId","x-decorator":"FormItem"},licenseKey:{type:"string",title:i("License key"),required:!0,"x-component":"TextArea","x-decorator":"FormItem","x-component-props":{placeholder:i("Enter license key")}},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{submit:{title:'{{t("Submit")}}',"x-component":"Action","x-use-component-props":"useSubmitProps","x-component-props":{type:"primary",style:{marginBottom:16}}}},"x-visible":!1},licenseInfo:{type:"void","x-component":"LicenseCardWarp"}}}}};return n().createElement(r.Card,{bordered:!1},n().createElement(y.Provider,{value:{onSaveSuccess:function(){c(function(e){return e+1}),d(!0)},keyExist:p,refreshToken:l}},n().createElement(f,{refreshToken:l}),n().createElement(e.SchemaComponent,{scope:{useSubmitProps:v},components:{InstanceId:O,TextArea:j,LicenseCardWarp:T},schema:{type:"void",properties:{form:m}}})))}function C(e,t,n,r,o,i,a){try{var u=e[i](a),l=u.value}catch(e){n(e);return}u.done?t(l):Promise.resolve(l).then(r,o)}function I(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){C(i,r,o,a,u,"next",e)}function u(e){C(i,r,o,a,u,"throw",e)}a(void 0)})}}function M(e,t,n){return(M=D()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&F(o,n.prototype),o}).apply(null,arguments)}function q(e){return(q=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function F(e,t){return(F=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function B(e){var t="function"==typeof Map?new Map:void 0;return(B=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return M(e,arguments,q(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),F(n,e)})(e)}function D(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(D=function(){return!!e})()}function L(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){var l=[i,u];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var N=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=q(e),function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,D()?Reflect.construct(e,t||[],q(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&F(n,e),t=[{key:"afterAdd",value:function(){return I(function(){return L(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return I(function(){return L(this,function(e){return[2]})})()}},{key:"load",value:function(){var e=this;return I(function(){return L(this,function(t){return e.app.pluginSettingsManager.add("license-settings",{title:"{{t(".concat(JSON.stringify("License settings"),", { ns: ['").concat(i.u2,"', 'client'], nsMode: 'fallback' })}}"),icon:"SolutionOutlined",Component:A,aclSnippet:"pm.license-settings"}),[2]})})()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(B(e.Plugin)),_=N}(),c}()});
@@ -6,5 +6,5 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
- export declare function useT(): (str: string) => string;
9
+ export declare function useT(): (str: string, options?: any) => string;
10
10
  export declare function tStr(key: string): string;
@@ -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
+ export declare const useSubmitProps: () => {
10
+ loading: boolean;
11
+ onClick: () => Promise<void>;
12
+ };
@@ -9,10 +9,16 @@
9
9
 
10
10
  module.exports = {
11
11
  "react": "18.2.0",
12
- "@nocobase/client": "2.0.0-alpha.9",
12
+ "@nocobase/client": "2.0.0-beta.2",
13
13
  "antd": "5.24.2",
14
14
  "ahooks": "3.7.8",
15
15
  "@ant-design/icons": "5.6.1",
16
- "@nocobase/server": "2.0.0-alpha.9",
17
- "@nocobase/license-kit": "0.2.17"
16
+ "@formily/react": "2.3.7",
17
+ "@nocobase/license-kit": "0.3.5",
18
+ "react-i18next": "11.18.6",
19
+ "@nocobase/server": "2.0.0-beta.2",
20
+ "lodash": "4.17.21",
21
+ "koa": "2.16.0",
22
+ "axios": "1.7.7",
23
+ "@nocobase/logger": "2.0.0-beta.2"
18
24
  };
@@ -0,0 +1,13 @@
1
+ {
2
+ "Change key": "Change key",
3
+ "Copied": "Copied",
4
+ "Copy": "Copy",
5
+ "Enter license key": "Enter license key",
6
+ "Failed to copy, please open ./storage/.license/instance-id and copy it": "Failed to copy, please open ./storage/.license/instance-id and copy it",
7
+ "Instance ID": "Instance ID",
8
+ "Invalid license key": "Invalid license key",
9
+ "License key": "License key",
10
+ "License key has been set": "License key has been set",
11
+ "License key saved successfully, please re-run the plugin installation.": "License key saved successfully, please re-run the plugin installation.",
12
+ "License settings": "License settings"
13
+ }
@@ -1,13 +1,37 @@
1
1
  {
2
- "License key saved successfully, please re-run the plugin installation.": "License key saved successfully, please re-run the plugin installation.",
3
- "License settings": "License settings",
4
- "Instance ID": "Instance ID",
5
- "License key": "License key",
6
- "Enter license key": "Enter license key",
7
- "Invalid license key": "Invalid license key",
8
2
  "Change key": "Change key",
9
- "License key has been set": "License key has been set",
10
3
  "Copied": "Copied",
11
4
  "Copy": "Copy",
12
- "Failed to copy, please open ./storage/.license/instance-id and copy it": "Failed to copy, please open ./storage/.license/instance-id and copy it"
13
- }
5
+ "Enter license key": "Enter license key",
6
+ "Instance ID": "Instance ID",
7
+ "Invalid license key": "Invalid license key",
8
+ "License key": "License key",
9
+ "License key has been set": "License key has been set",
10
+ "License key saved successfully, please re-run the plugin installation.": "License key saved successfully, please re-run the plugin installation.",
11
+ "License settings": "License settings",
12
+ "Failed to copy, please open ./storage/.license/instance-id and copy it": "Failed to copy, please open ./storage/.license/instance-id and copy it",
13
+ "Invalid license key.": "Invalid license key.",
14
+ "The license key is invalid. Please visit the NocoBase Service to obtain a new license key.": "The license key is invalid. Please visit the NocoBase Service to obtain a new license key.",
15
+ "The current license key has been deprecated. Please visit the NocoBase Service to obtain a new license key.": "The current license key has been deprecated. Please visit the NocoBase Service to obtain a new license key.",
16
+ "The license has exceeded the upgrade validity period.": "The license has exceeded the upgrade validity period.",
17
+ "Plugins bound to this license can still be used but cannot be upgraded. To upgrade, please renew or repurchase the license.": "Plugins bound to this license can still be used but cannot be upgraded. To upgrade, please renew or repurchase the license.",
18
+ "Environment mismatch.": "Environment mismatch.",
19
+ "The current system does not match the licensed system. Please use the new InstanceID to request a new license key.": "The current system does not match the licensed system. Please use the new InstanceID to request a new license key.",
20
+ "The current database does not match the licensed database. Please use the new InstanceID to request a new license key.": "The current database does not match the licensed database. Please use the new InstanceID to request a new license key.",
21
+ "The current system and database do not match the licensed environment. Please use the new InstanceID to request a new license key.": "The current system and database do not match the licensed environment. Please use the new InstanceID to request a new license key.",
22
+ "Domain mismatch.": "Domain mismatch.",
23
+ "The current domain ({{domain}}) does not match the licensed domain. Please use the current domain to request a new license key.": "The current domain ({{domain}}) does not match the licensed domain. Please use the current domain to request a new license key.",
24
+ "Plugin not licensed.": "Plugin not licensed.",
25
+ "An unlicensed plugin has been detected. Please visit the NocoBase Service to complete the purchase or obtain a license.": "An unlicensed plugin has been detected. Please visit the NocoBase Service to complete the purchase or obtain a license.",
26
+ "Network error.": "Network error.",
27
+ "Due to network issues, the license key cannot be updated automatically. Please update it manually if necessary.": "Due to network issues, the license key cannot be updated automatically. Please update it manually if necessary.",
28
+ "Due to network issues, plugins cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.": "Due to network issues, plugins cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.",
29
+ "Plugins also cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.": "Plugins also cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.",
30
+ "License key saved successfully. Please retry the plugin installation.": "License key saved successfully. Please retry the plugin installation.",
31
+ "The license key was saved successfully": "The license key was saved successfully",
32
+ "License key not found.": "License key not found.",
33
+ "Please go to the": "Please go to the",
34
+ "License Settings": "License Settings",
35
+ "page to enter the license key.": "page to enter the license key.",
36
+ "License information": "License information"
37
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "Change key": "Change key",
3
+ "Copied": "Copied",
4
+ "Copy": "Copy",
5
+ "Enter license key": "Enter license key",
6
+ "Failed to copy, please open ./storage/.license/instance-id and copy it": "Failed to copy, please open ./storage/.license/instance-id and copy it",
7
+ "Instance ID": "Instance ID",
8
+ "Invalid license key": "Invalid license key",
9
+ "License key": "License key",
10
+ "License key has been set": "License key has been set",
11
+ "License key saved successfully, please re-run the plugin installation.": "License key saved successfully, please re-run the plugin installation.",
12
+ "License settings": "License settings"
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "Change key": "Change key",
3
+ "Copied": "Copied",
4
+ "Copy": "Copy",
5
+ "Enter license key": "Enter license key",
6
+ "Failed to copy, please open ./storage/.license/instance-id and copy it": "Failed to copy, please open ./storage/.license/instance-id and copy it",
7
+ "Instance ID": "Instance ID",
8
+ "Invalid license key": "Invalid license key",
9
+ "License key": "License key",
10
+ "License key has been set": "License key has been set",
11
+ "License key saved successfully, please re-run the plugin installation.": "License key saved successfully, please re-run the plugin installation.",
12
+ "License settings": "License settings"
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "Change key": "Change key",
3
+ "Copied": "Copied",
4
+ "Copy": "Copy",
5
+ "Enter license key": "Enter license key",
6
+ "Failed to copy, please open ./storage/.license/instance-id and copy it": "Failed to copy, please open ./storage/.license/instance-id and copy it",
7
+ "Instance ID": "Instance ID",
8
+ "Invalid license key": "Invalid license key",
9
+ "License key": "License key",
10
+ "License key has been set": "License key has been set",
11
+ "License key saved successfully, please re-run the plugin installation.": "License key saved successfully, please re-run the plugin installation.",
12
+ "License settings": "License settings"
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "Change key": "Change key",
3
+ "Copied": "Copied",
4
+ "Copy": "Copy",
5
+ "Enter license key": "Enter license key",
6
+ "Failed to copy, please open ./storage/.license/instance-id and copy it": "Failed to copy, please open ./storage/.license/instance-id and copy it",
7
+ "Instance ID": "Instance ID",
8
+ "Invalid license key": "Invalid license key",
9
+ "License key": "License key",
10
+ "License key has been set": "License key has been set",
11
+ "License key saved successfully, please re-run the plugin installation.": "License key saved successfully, please re-run the plugin installation.",
12
+ "License settings": "License settings"
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "Change key": "Change key",
3
+ "Copied": "Copied",
4
+ "Copy": "Copy",
5
+ "Enter license key": "Enter license key",
6
+ "Failed to copy, please open ./storage/.license/instance-id and copy it": "Failed to copy, please open ./storage/.license/instance-id and copy it",
7
+ "Instance ID": "Instance ID",
8
+ "Invalid license key": "Invalid license key",
9
+ "License key": "License key",
10
+ "License key has been set": "License key has been set",
11
+ "License key saved successfully, please re-run the plugin installation.": "License key saved successfully, please re-run the plugin installation.",
12
+ "License settings": "License settings"
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "Change key": "Change key",
3
+ "Copied": "Copied",
4
+ "Copy": "Copy",
5
+ "Enter license key": "Enter license key",
6
+ "Failed to copy, please open ./storage/.license/instance-id and copy it": "Failed to copy, please open ./storage/.license/instance-id and copy it",
7
+ "Instance ID": "Instance ID",
8
+ "Invalid license key": "Invalid license key",
9
+ "License key": "License key",
10
+ "License key has been set": "License key has been set",
11
+ "License key saved successfully, please re-run the plugin installation.": "License key saved successfully, please re-run the plugin installation.",
12
+ "License settings": "License settings"
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "Change key": "Change key",
3
+ "Copied": "Copied",
4
+ "Copy": "Copy",
5
+ "Enter license key": "Enter license key",
6
+ "Failed to copy, please open ./storage/.license/instance-id and copy it": "Failed to copy, please open ./storage/.license/instance-id and copy it",
7
+ "Instance ID": "Instance ID",
8
+ "Invalid license key": "Invalid license key",
9
+ "License key": "License key",
10
+ "License key has been set": "License key has been set",
11
+ "License key saved successfully, please re-run the plugin installation.": "License key saved successfully, please re-run the plugin installation.",
12
+ "License settings": "License settings"
13
+ }
@@ -1 +1,13 @@
1
- {}
1
+ {
2
+ "Change key": "Change key",
3
+ "Copied": "Copied",
4
+ "Copy": "Copy",
5
+ "Enter license key": "Enter license key",
6
+ "Failed to copy, please open ./storage/.license/instance-id and copy it": "Failed to copy, please open ./storage/.license/instance-id and copy it",
7
+ "Instance ID": "Instance ID",
8
+ "Invalid license key": "Invalid license key",
9
+ "License key": "License key",
10
+ "License key has been set": "License key has been set",
11
+ "License key saved successfully, please re-run the plugin installation.": "License key saved successfully, please re-run the plugin installation.",
12
+ "License settings": "License settings"
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "Change key": "Change key",
3
+ "Copied": "Copied",
4
+ "Copy": "Copy",
5
+ "Enter license key": "Enter license key",
6
+ "Failed to copy, please open ./storage/.license/instance-id and copy it": "Failed to copy, please open ./storage/.license/instance-id and copy it",
7
+ "Instance ID": "Instance ID",
8
+ "Invalid license key": "Invalid license key",
9
+ "License key": "License key",
10
+ "License key has been set": "License key has been set",
11
+ "License key saved successfully, please re-run the plugin installation.": "License key saved successfully, please re-run the plugin installation.",
12
+ "License settings": "License settings"
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "Change key": "Изменить ключ",
3
+ "Copied": "Скопировано",
4
+ "Copy": "Копировать",
5
+ "Enter license key": "Введите лицензионный ключ",
6
+ "Failed to copy, please open ./storage/.license/instance-id and copy it": "Не удалось скопировать, пожалуйста, откройте ./storage/.license/instance-id и скопируйте его",
7
+ "Instance ID": "ID экземпляра",
8
+ "Invalid license key": "Неверный лицензионный ключ",
9
+ "License key": "Лицензионный ключ",
10
+ "License key has been set": "Лицензионный ключ был установлен",
11
+ "License key saved successfully, please re-run the plugin installation.": "Лицензионный ключ успешно сохранен, пожалуйста, перезапустите установку плагина.",
12
+ "License settings": "Настройки лицензии"
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "Change key": "Change key",
3
+ "Copied": "Copied",
4
+ "Copy": "Copy",
5
+ "Enter license key": "Enter license key",
6
+ "Failed to copy, please open ./storage/.license/instance-id and copy it": "Failed to copy, please open ./storage/.license/instance-id and copy it",
7
+ "Instance ID": "Instance ID",
8
+ "Invalid license key": "Invalid license key",
9
+ "License key": "License key",
10
+ "License key has been set": "License key has been set",
11
+ "License key saved successfully, please re-run the plugin installation.": "License key saved successfully, please re-run the plugin installation.",
12
+ "License settings": "License settings"
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "Change key": "Change key",
3
+ "Copied": "Copied",
4
+ "Copy": "Copy",
5
+ "Enter license key": "Enter license key",
6
+ "Failed to copy, please open ./storage/.license/instance-id and copy it": "Failed to copy, please open ./storage/.license/instance-id and copy it",
7
+ "Instance ID": "Instance ID",
8
+ "Invalid license key": "Invalid license key",
9
+ "License key": "License key",
10
+ "License key has been set": "License key has been set",
11
+ "License key saved successfully, please re-run the plugin installation.": "License key saved successfully, please re-run the plugin installation.",
12
+ "License settings": "License settings"
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "Change key": "Change key",
3
+ "Copied": "Copied",
4
+ "Copy": "Copy",
5
+ "Enter license key": "Enter license key",
6
+ "Failed to copy, please open ./storage/.license/instance-id and copy it": "Failed to copy, please open ./storage/.license/instance-id and copy it",
7
+ "Instance ID": "Instance ID",
8
+ "Invalid license key": "Invalid license key",
9
+ "License key": "License key",
10
+ "License key has been set": "License key has been set",
11
+ "License key saved successfully, please re-run the plugin installation.": "License key saved successfully, please re-run the plugin installation.",
12
+ "License settings": "License settings"
13
+ }
@@ -1,13 +1,37 @@
1
1
  {
2
- "License key saved successfully, please re-run the plugin installation.": "授权密钥保存成功,请重新执行插件安装操作",
3
- "License settings": "授权设置",
4
- "Instance ID": "实例 ID",
5
- "License key": "授权密钥",
6
- "Enter license key": "输入授权密钥",
7
- "Invalid license key": "无效的授权密钥",
8
2
  "Change key": "更改密钥",
9
- "License key has been set": "授权密钥已设置",
10
3
  "Copied": "复制成功",
11
4
  "Copy": "复制",
12
- "Failed to copy, please open ./storage/.license/instance-id and copy it": "复制失败,请打开 ./storage/.license/instance-id 并复制"
5
+ "Enter license key": "输入授权密钥",
6
+ "Instance ID": "实例 ID",
7
+ "Invalid license key": "无效的授权密钥",
8
+ "License key": "授权密钥",
9
+ "License key has been set": "授权密钥已设置",
10
+ "License key saved successfully, please re-run the plugin installation.": "授权密钥保存成功,请重新执行插件安装操作",
11
+ "License settings": "授权设置",
12
+ "Failed to copy, please open ./storage/.license/instance-id and copy it": "复制失败,请打开 ./storage/.license/instance-id 并复制",
13
+ "Invalid license key.": "授权密钥无效",
14
+ "The license key is invalid. Please visit the NocoBase Service to obtain a new license key.": "无效的授权密钥,请前往 NocoBase Service 重新获取授权密钥。",
15
+ "The current license key has been deprecated. Please visit the NocoBase Service to obtain a new license key.": "当前授权密钥已被废弃,请前往 NocoBase Service 重新获取授权密钥。",
16
+ "The license has exceeded the upgrade validity period.": "许可证已过升级有效期",
17
+ "Plugins bound to this license can still be used but cannot be upgraded. To upgrade, please renew or repurchase the license.": "许可证绑定的插件可以继续使用,但无法升级,如需升级请续费或重新购买许可证。",
18
+ "Environment mismatch.": "环境不匹配",
19
+ "The current system does not match the licensed system. Please use the new InstanceID to request a new license key.": "当前系统与许可绑定的系统不一致,请使用新的 InstanceID 重新申请授权密钥。",
20
+ "The current database does not match the licensed database. Please use the new InstanceID to request a new license key.": "当前数据库与许可绑定的数据库不一致,请使用新的 InstanceID 重新申请授权密钥。",
21
+ "The current system and database do not match the licensed environment. Please use the new InstanceID to request a new license key.": "当前系统和数据库与许可绑定的环境不一致,请使用新的 InstanceID 重新申请授权密钥。",
22
+ "Domain mismatch.": "域名不匹配",
23
+ "The current domain ({{domain}}) does not match the licensed domain. Please use the current domain to request a new license key.": "当前域名({{domain}})与许可绑定的域名不一致,请使用当前域名重新申请授权密钥。",
24
+ "Plugin not licensed.": "插件未授权",
25
+ "An unlicensed plugin has been detected. Please visit the NocoBase Service to complete the purchase or obtain a license.": "检测到你正在使用未获得许可的插件,请前往 NocoBase Service 完成购买或授权。",
26
+ "Network error.": "网络异常",
27
+ "Due to network issues, the license key cannot be updated automatically. Please update it manually if necessary.": "由于网络问题,授权密钥无法自动更新,如有需要请手动更新。",
28
+ "Due to network issues, plugins cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.": "由于网络问题,插件无法自动更新(可正常使用),如需要更新插件,请检查网络连接,或参考 NocoBase Service 文档手动上传插件。",
29
+ "Plugins also cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.": "插件也无法自动更新(可正常使用),如需要更新插件,请检查网络连接,或参考 NocoBase Service 文档手动上传插件。",
30
+ "License key saved successfully. Please retry the plugin installation.": "授权密钥保存成功,请重新执行插件安装操作。",
31
+ "The license key was saved successfully": "授权密钥保存成功",
32
+ "License key not found.": "授权密钥未找到",
33
+ "Please go to the": "请前往",
34
+ "License Settings": "授权设置",
35
+ "page to enter the license key.": "页面填写授权密钥。",
36
+ "License information": "授权信息"
13
37
  }
@@ -0,0 +1,13 @@
1
+ {
2
+ "Change key": "Change key",
3
+ "Copied": "Copied",
4
+ "Copy": "Copy",
5
+ "Enter license key": "Enter license key",
6
+ "Failed to copy, please open ./storage/.license/instance-id and copy it": "Failed to copy, please open ./storage/.license/instance-id and copy it",
7
+ "Instance ID": "Instance ID",
8
+ "Invalid license key": "Invalid license key",
9
+ "License key": "License key",
10
+ "License key has been set": "License key has been set",
11
+ "License key saved successfully, please re-run the plugin installation.": "License key saved successfully, please re-run the plugin installation.",
12
+ "License settings": "License settings"
13
+ }
@@ -7,3 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  export { default } from './plugin';
10
+ export * from './utils';
@@ -25,6 +25,7 @@ var __copyProps = (to, from, except, desc) => {
25
25
  }
26
26
  return to;
27
27
  };
28
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
28
29
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
30
  // If the importer is in node compatibility mode or this is not an ESM
30
31
  // file that has been converted to a CommonJS file using a Babel-
@@ -40,3 +41,8 @@ __export(server_exports, {
40
41
  });
41
42
  module.exports = __toCommonJS(server_exports);
42
43
  var import_plugin = __toESM(require("./plugin"));
44
+ __reExport(server_exports, require("./utils"), module.exports);
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ ...require("./utils")
48
+ });
@@ -7,9 +7,11 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
+ var __create = Object.create;
10
11
  var __defProp = Object.defineProperty;
11
12
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
13
  var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
13
15
  var __hasOwnProp = Object.prototype.hasOwnProperty;
14
16
  var __export = (target, all) => {
15
17
  for (var name in all)
@@ -23,6 +25,14 @@ var __copyProps = (to, from, except, desc) => {
23
25
  }
24
26
  return to;
25
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
+ ));
26
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
37
  var plugin_exports = {};
28
38
  __export(plugin_exports, {
@@ -32,7 +42,7 @@ __export(plugin_exports, {
32
42
  module.exports = __toCommonJS(plugin_exports);
33
43
  var import_server = require("@nocobase/server");
34
44
  var import_utils = require("./utils");
35
- var import_license_kit = require("@nocobase/license-kit");
45
+ var import_pick = __toESM(require("lodash/pick"));
36
46
  class PluginLicenseServer extends import_server.Plugin {
37
47
  async afterAdd() {
38
48
  }
@@ -48,17 +58,70 @@ class PluginLicenseServer extends import_server.Plugin {
48
58
  },
49
59
  "license-key": async (ctx, next) => {
50
60
  const { licenseKey } = ctx.request.body;
51
- try {
52
- (0, import_license_kit.keyDecrypt)(licenseKey);
53
- } catch (e) {
54
- return ctx.throw(500, ctx.t("Invalid license key", { ns: "@nocobase/plugin-license" }));
61
+ const licenseValidate = await (0, import_utils.getLicenseValidate)({ key: licenseKey, ctx });
62
+ const licenseStatus = await (0, import_utils.getLicenseStatus)(licenseValidate.keyData);
63
+ ctx.body = {
64
+ ...licenseValidate,
65
+ licenseStatus
66
+ };
67
+ if (ctx.body.envMatch && ctx.body.domainMatch && ctx.body.licenseStatus === "active") {
68
+ await (0, import_utils.saveLicenseKey)(licenseKey, ctx);
55
69
  }
56
- await (0, import_utils.saveLicenseKey)(licenseKey);
57
70
  await next();
58
71
  },
59
72
  "is-exists": async (ctx, next) => {
60
73
  ctx.body = await (0, import_utils.isLicenseKeyExists)();
61
74
  await next();
75
+ },
76
+ "license-validate": async (ctx, next) => {
77
+ const isExist = await (0, import_utils.isLicenseKeyExists)();
78
+ if (!isExist) {
79
+ ctx.body = {
80
+ keyExist: false
81
+ };
82
+ await next();
83
+ return;
84
+ }
85
+ const licenseValidate = await (0, import_utils.getLicenseValidate)({ ctx });
86
+ ctx.body = {
87
+ keyExist: true,
88
+ ...licenseValidate,
89
+ keyData: (0, import_pick.default)(licenseValidate.keyData, ["service"])
90
+ };
91
+ await next();
92
+ },
93
+ "service-validate": async (ctx, next) => {
94
+ const keyExist = await (0, import_utils.isLicenseKeyExists)();
95
+ if (!keyExist) {
96
+ ctx.body = {
97
+ keyExist
98
+ };
99
+ await next();
100
+ return;
101
+ }
102
+ let isPkgConnection = false;
103
+ try {
104
+ isPkgConnection = await (0, import_utils.testPkgConnection)();
105
+ } catch (e) {
106
+ isPkgConnection = false;
107
+ }
108
+ let isPkgLogin = false;
109
+ let isServiceConnection = false;
110
+ try {
111
+ const keyData = await (0, import_utils.getLocalKeyData)();
112
+ isPkgLogin = await (0, import_utils.testPkgLogin)(keyData);
113
+ isServiceConnection = await (0, import_utils.testServiceConnection)(keyData);
114
+ } catch (e) {
115
+ isPkgLogin = false;
116
+ isServiceConnection = false;
117
+ }
118
+ ctx.body = {
119
+ keyExist,
120
+ isPkgConnection,
121
+ isPkgLogin,
122
+ isServiceConnection
123
+ };
124
+ await next();
62
125
  }
63
126
  }
64
127
  });