@nocobase/plugin-api-keys 2.0.22 → 2.1.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.
|
@@ -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
|
+
"use strict";(self.webpackChunk_nocobase_plugin_api_keys=self.webpackChunk_nocobase_plugin_api_keys||[]).push([["100"],{855:function(e,t,r){r.r(t),r.d(t,{Configuration:function(){return D}});var n,o,a,l=r(342),i=r(155),c=r.n(i),u=r(230),s=r(625),p=r(59),m=r(185),y=r.n(m),d=r(953),f="@nocobase/plugin-api-keys";function b(){return(0,d.useTranslation)([f,"client"],{nsMode:"fallback"})}function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function x(){var e,t,r=(e=["\n width: 100%;\n & > .ant-space-item {\n flex: 1;\n }\n"],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return x=function(){return r},r}var g=y()().add(1,"days"),h=(0,l.css)(x()),w=(0,u.connect)(function(e){var t,r,n,o=e.onChange,a=function(e){if(Array.isArray(e))return e}(t=(0,s.useBoolean)())||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],a=!0,l=!1;try{for(n=n.call(e);!(a=(t=n.next()).done)&&(o.push(t.value),2!==o.length);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==n.return||n.return()}finally{if(l)throw r}}return o}}(t)||function(e){if(e){if("string"==typeof e)return v(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return v(e,2)}}(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.")}(),l=a[0],i=a[1],u=i.toggle,m=i.setFalse;return c().createElement(p.Space,{className:h},c().createElement(p.Select,(r=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},e),n=n={value:l?"custom":e.value,onChange:function(e){if("custom"===e)return o("1d"),u();m(),o(e)}},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}),r)),l?c().createElement(p.DatePicker,{disabledDate:function(e){return e.isSameOrBefore()},defaultValue:g,onChange:function(e){e=e.millisecond(0).second(0);var t=y()().millisecond(0).second(0);o("".concat(e.diff(t,"d"),"d"))},showToday:!1,allowClear:!1}):null)},(0,u.mapProps)({dataSource:"options"}),(0,u.mapReadPretty)(function(){var e=(0,l.useRecord)(),t=e.expiresIn,r=e.createdAt,n=b().t,o=(0,i.useMemo)(function(){return"never"===t?n("Never expires"):y()(r).add((null==t?void 0:t.replace("d",""))||0,"days").format("YYYY-MM-DD HH:mm:ss")},[r,t]);return c().createElement(p.Typography.Text,null,o)})),A=r(166);function C(e){return"{{t('".concat(e,"', { ns: '").concat(f,"', nsMode: 'fallback' })}}")}var O={dumpRules:{group:"user"},migrationRules:["schema-only"],shared:!0,name:"apiKeys",sortable:"sort",createdBy:!0,updatedAt:!1,updatedBy:!1,logging:!0,fields:[{name:"id",type:"bigInt",autoIncrement:!0,primaryKey:!0,allowNull:!1,interface:"id"},{type:"string",name:"name",interface:"input",uiSchema:{type:"string",title:'{{t("name")}}',"x-component":"Input"}},{interface:"obo",type:"belongsTo",name:"role",target:"roles",foreignKey:"roleName",uiSchema:{type:"object",title:'{{t("Roles")}}',"x-component":"Select","x-component-props":{fieldNames:{label:"title",value:"name"},objectValue:!0,options:"{{ currentRoles }}"}}},{name:"expiresIn",type:"string",uiSchema:{type:"string",title:C("Expires"),"x-component":"ExpiresSelect",enum:[{label:C("1 Day"),value:"1d"},{label:C("7 Days"),value:"7d"},{label:C("30 Days"),value:"30d"},{label:C("90 Days"),value:"90d"},{label:C("Custom"),value:"custom"},{label:C("Never"),value:"never"}]}},{name:"token",type:"string",hidden:!0}]};function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function S(e,t,r,n,o,a,l){try{var i=e[a](l),c=i.value}catch(e){r(e);return}i.done?t(c):Promise.resolve(c).then(n,o)}function j(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function l(e){S(a,n,o,l,i,"next",e)}function i(e){S(a,n,o,l,i,"throw",e)}l(void 0)})}}function P(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(l,"next",{value:c(0)}),i(l,"throw",{value:c(1)}),i(l,"return",{value:c(2)}),"function"==typeof Symbol&&i(l,Symbol.iterator,{value:function(){return this}}),l;function c(i){return function(c){var u=[i,c];if(r)throw TypeError("Generator is already executing.");for(;l&&(l=0,u[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var I=p.Modal.useModal,T={type:"object",properties:{configuration:{type:"void","x-decorator":"TableBlockProvider","x-decorator-props":{collection:O,resource:"apiKeys",action:"list",params:{pageSize:20,appends:["role"],sort:["-createdAt"]},rowKey:"name",showIndex:!0},"x-component":"CardItem",properties:(n={actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--nb-spacing)"}},properties:{create:{type:"void","x-action":"create",title:C("Add API key"),"x-component":"Action","x-component-props":{icon:"PlusOutlined",openMode:"drawer",type:"primary"},properties:{drawer:{type:"void",title:C("Add API key"),"x-decorator":"Form","x-component":"Action.Modal","x-component-props":{maskClosable:!1,style:{maxWidth:"520px",width:"100%"}},properties:{name:{type:"string",title:C("Key name"),required:!0,"x-component":"CollectionField","x-decorator":"FormItem"},role:{type:"string",title:C("Role"),required:!0,"x-decorator-props":{tooltip:C("Allow only your own roles to be selected")},"x-collection-field":"apiKeys.role","x-component":"CollectionField","x-decorator":"FormItem"},expiresIn:{type:"string",title:C("Expiration"),required:!0,"x-component":"CollectionField","x-decorator":"FormItem",default:"30d"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:function(){var e,t=(0,u.useForm)(),r=(0,l.useActionContext)().setVisible,n=(0,l.useBlockRequestContext)(),o=n.resource,a=n.service,i=b().t,s=function(e){if(Array.isArray(e))return e}(e=I())||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],a=!0,l=!1;try{for(n=n.call(e);!(a=(t=n.next()).done)&&(o.push(t.value),2!==o.length);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==n.return||n.return()}finally{if(l)throw r}}return o}}(e)||function(e){if(e){if("string"==typeof e)return k(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return k(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),m=s[0];return{run:function(){return j(function(){var e,n,l;return P(this,function(u){switch(u.label){case 0:return[4,t.submit()];case 1:return u.sent(),[4,o.create({values:t.values})];case 2:return l=u.sent(),m.success({title:i("API key created successfully"),onOk:function(){t.reset(),r(!1)},content:c().createElement(p.Space,{direction:"vertical"},c().createElement(p.Alert,{message:i("Make sure to copy your personal access key now as you will not be able to see this again."),type:"warning"}),c().createElement(p.Typography.Text,{copyable:!0},null==(n=l.data)||null==(e=n.data)?void 0:e.token))}),null==a||a.refresh(),[2]}})})()},element:s[1]}}}}}}}}},"x-align":"right"}}}},o=(0,A.uid)(),a={type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{column1:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:C("Key name"),properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:C("Role"),properties:{role:{type:"string","x-collection-field":"apiKeys.role","x-component":"CollectionField","x-component-props":{enableLink:!1},"x-read-pretty":!0}}},column3:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:C("Expiration"),properties:{expiresIn:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column4:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:C("Created at"),properties:{createdAt:{type:"date","x-component":"DatePicker","x-component-props":{format:"YYYY-MM-DD HH:mm:ss"},"x-read-pretty":!0}}},actionColumn:{type:"void",title:'{{ t("Actions") }}',"x-action-column":"actions","x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column",properties:{columnActions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:C("Delete API key"),content:"{{t('Are you sure you want to delete it?')}}"},useAction:function(){var e=(0,l.useRecord)(),t=(0,l.useBlockRequestContext)(),r=t.resource,n=t.service;return{run:function(){return j(function(){return P(this,function(t){switch(t.label){case 0:return[4,r.destroy({filterByTk:e.id})];case 1:return t.sent(),n.refresh(),[2]}})})()}}}}}}}}}}},o in n?Object.defineProperty(n,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):n[o]=a,n)}}},D=function(){var e=(0,l.useCurrentRoles)().filter(function(e){return"__union__"!==e.name});return c().createElement(l.SchemaComponentOptions,{scope:{currentRoles:e},components:{ExpiresSelect:w}},c().createElement(l.NocoBaseRecursionField,{schema:T}))}}}]);
|
package/dist/client/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("ahooks"),require("react-i18next"),require("dayjs"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("@formily/react")):"function"==typeof define&&define.amd?define("@nocobase/plugin-api-keys",["ahooks","react-i18next","dayjs","@formily/shared","react","antd","@nocobase/client","@formily/react"],t):"object"==typeof exports?exports["@nocobase/plugin-api-keys"]=t(require("ahooks"),require("react-i18next"),require("dayjs"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("@formily/react")):e["@nocobase/plugin-api-keys"]=t(e.ahooks,e["react-i18next"],e.dayjs,e["@formily/shared"],e.react,e.antd,e["@nocobase/client"],e["@formily/react"])}(self,function(e,t,r,n,o,i,u,c){return function(){var a,s,l,f={631:function(e){e.exports=function(e,t){return"u">typeof __deoptimization_sideEffect__&&__deoptimization_sideEffect__(e,t),t}},230:function(e){"use strict";e.exports=c},166:function(e){"use strict";e.exports=n},342:function(e){"use strict";e.exports=u},625:function(t){"use strict";t.exports=e},59:function(e){"use strict";e.exports=i},185:function(e){"use strict";e.exports=r},155:function(e){"use strict";e.exports=o},953:function(e){"use strict";e.exports=t}},p={};function d(e){var t=p[e];if(void 0!==t)return t.exports;var r=p[e]={exports:{}};return f[e](r,r.exports,d),r.exports}d.m=f,d.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return d.d(t,{a:t}),t},d.d=function(e,t){for(var r in t)d.o(t,r)&&!d.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},d.f={},d.e=function(e){return Promise.all(Object.keys(d.f).reduce(function(t,r){return d.f[r](e,t),t},[]))},d.u=function(e){return"dfc1955b66a68cd1.js"},d.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),d.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},y={},d.l=function(e,t,r,n){if(y[e])return void y[e].push(t);if(void 0!==r)for(var o,i,u=document.getElementsByTagName("script"),c=0;c<u.length;c++){var a=u[c];if(a.getAttribute("src")==e||a.getAttribute("data-rspack")=="@nocobase/plugin-api-keys:"+r){o=a;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,d.nc&&o.setAttribute("nonce",d.nc),o.setAttribute("data-rspack","@nocobase/plugin-api-keys:"+r),o.src=e),y[e]=[t];var s=function(t,r){o.onerror=o.onload=null,clearTimeout(l);var n=y[e];if(delete y[e],o.parentNode&&o.parentNode.removeChild(o),n&&n.forEach(function(e){return e(r)}),t)return t(r)},l=setTimeout(s.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=s.bind(null,o.onerror),o.onload=s.bind(null,o.onload),i&&document.head.appendChild(o)},d.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},d.g.importScripts&&(b=d.g.location+"");var y,b,h=d.g.document;if(!b&&h&&(h.currentScript&&"SCRIPT"===h.currentScript.tagName.toUpperCase()&&(b=h.currentScript.src),!b)){var v=h.getElementsByTagName("script");if(v.length)for(var m=v.length-1;m>-1&&(!b||!/^http(s?):/.test(b));)b=v[m--].src}if(!b)throw Error("Automatic publicPath is not supported in this browser");d.p=b.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a={889:0},d.f.j=function(e,t){var r=d.o(a,e)?a[e]:void 0;if(0!==r)if(r)t.push(r[2]);else{var n=new Promise(function(t,n){r=a[e]=[t,n]});t.push(r[2]=n);var o=d.p+d.u(e),i=Error();d.l(o,function(t){if(d.o(a,e)&&(0!==(r=a[e])&&(a[e]=void 0),r)){var n=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+n+": "+o+")",i.name="ChunkLoadError",i.type=n,i.request=o,r[1](i)}},"chunk-"+e,e)}},s=function(e,t){var r,n,o=t[0],i=t[1],u=t[2],c=0;if(o.some(function(e){return 0!==a[e]})){for(r in i)d.o(i,r)&&(d.m[r]=i[r]);u&&u(d)}for(e&&e(t);c<o.length;c++)n=o[c],d.o(a,n)&&a[n]&&a[n][0](),a[n]=0},(l=self.webpackChunk_nocobase_plugin_api_keys=self.webpackChunk_nocobase_plugin_api_keys||[]).forEach(s.bind(null,0)),l.push=s.bind(null,l.push.bind(l));var g={};return!function(){"use strict";var e=window.__webpack_public_path__||"/";"/"!==e.charAt(e.length-1)&&(e+="/"),d.p=e+"static/plugins/@nocobase/plugin-api-keys/dist/client/"}(),!function(){"use strict";d.r(g),d.d(g,{PluginAPIKeysClient:function(){return s}});var e=d(342),t=d(631);function r(e,t,r,n,o,i,u){try{var c=e[i](u),a=c.value}catch(e){r(e);return}c.done?t(a):Promise.resolve(a).then(n,o)}function n(e,t,r){return(n=c()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&i(o,r.prototype),o}).apply(null,arguments)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e){var t="function"==typeof Map?new Map:void 0;return(u=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return n(e,arguments,o(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),i(r,e)})(e)}function c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(c=function(){return!!e})()}var a=(0,e.lazy)(function(){return t("imported_-138s8db_component",d.e("100").then(d.bind(d,855)))},"Configuration").Configuration,s=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 r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,c()?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&&i(n,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(u,"next",{value:a(0)}),c(u,"throw",{value:a(1)}),c(u,"return",{value:a(2)}),"function"==typeof Symbol&&c(u,Symbol.iterator,{value:function(){return this}}),u;function a(c){return function(a){var s=[c,a];if(r)throw TypeError("Generator is already executing.");for(;u&&(u=0,s[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,n=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}(this,function(e){return this.pluginSettingsManager.add("api-keys",{icon:"KeyOutlined",title:this.t("API keys"),Component:a,aclSnippet:"pm.api-keys.configuration"}),[2]})},function(){var t=this,n=arguments;return new Promise(function(o,i){var u=e.apply(t,n);function c(e){r(u,o,i,c,a,"next",e)}function a(e){r(u,o,i,c,a,"throw",e)}c(void 0)})}).call(this)}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(n.prototype,t),n}(u(e.Plugin));g.default=s}(),g}()});
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "2.0.
|
|
12
|
-
"@nocobase/database": "2.0.
|
|
13
|
-
"@nocobase/server": "2.0.
|
|
11
|
+
"@nocobase/client": "2.1.0-alpha.10",
|
|
12
|
+
"@nocobase/database": "2.1.0-alpha.10",
|
|
13
|
+
"@nocobase/server": "2.1.0-alpha.10",
|
|
14
14
|
"@formily/react": "2.3.7",
|
|
15
15
|
"ahooks": "3.7.8",
|
|
16
16
|
"antd": "5.24.2",
|
|
@@ -18,5 +18,5 @@ module.exports = {
|
|
|
18
18
|
"react": "18.2.0",
|
|
19
19
|
"@formily/shared": "2.3.7",
|
|
20
20
|
"react-i18next": "11.18.6",
|
|
21
|
-
"@nocobase/actions": "2.0.
|
|
21
|
+
"@nocobase/actions": "2.1.0-alpha.10"
|
|
22
22
|
};
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"description": "Allows users to use API key to access application's HTTP API",
|
|
7
7
|
"description.ru-RU": "Позволяет пользователям использовать API ключ для доступа к HTTP API приложения",
|
|
8
8
|
"description.zh-CN": "允许用户使用 API 密钥访问应用的 HTTP API",
|
|
9
|
-
"version": "2.0.
|
|
9
|
+
"version": "2.1.0-alpha.10",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"main": "./dist/server/index.js",
|
|
12
12
|
"homepage": "https://docs.nocobase.com/handbook/api-keys",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"@nocobase/test": "2.x",
|
|
36
36
|
"@nocobase/utils": "2.x"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "ce790d46c0a5768ca9618c7d0d77ab8300de75c8"
|
|
39
39
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
"use strict";(self.webpackChunk_nocobase_plugin_api_keys=self.webpackChunk_nocobase_plugin_api_keys||[]).push([["152"],{764:function(e,t,n){n.r(t),n.d(t,{Configuration:function(){return D}});var r,o,a,l=n(772),i=n(156),c=n.n(i),u=n(505),s=n(749),p=n(721),m=n(760),y=n.n(m),d=n(238),f="@nocobase/plugin-api-keys";function b(){return(0,d.useTranslation)([f,"client"],{nsMode:"fallback"})}function x(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 v(){var e,t,n=(e=["\n width: 100%;\n & > .ant-space-item {\n flex: 1;\n }\n"],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return v=function(){return n},n}var g=y()().add(1,"days"),h=(0,l.css)(v()),w=(0,u.connect)(function(e){var t,n,r,o=e.onChange,a=(t=(0,s.useBoolean)(),function(e){if(Array.isArray(e))return e}(t)||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),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}}(t,2)||function(e,t){if(e){if("string"==typeof e)return x(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 x(e,t)}}(t,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.")}()),l=a[0],i=a[1],u=i.toggle,m=i.setFalse;return c().createElement(p.Space,{className:h},c().createElement(p.Select,(n=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}({},e),r=r={value:l?"custom":e.value,onChange:function(e){if("custom"===e)return o("1d"),u();m(),o(e)}},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n)),l?c().createElement(p.DatePicker,{disabledDate:function(e){return e.isSameOrBefore()},defaultValue:g,onChange:function(e){e=e.millisecond(0).second(0);var t=y()().millisecond(0).second(0);o("".concat(e.diff(t,"d"),"d"))},showToday:!1,allowClear:!1}):null)},(0,u.mapProps)({dataSource:"options"}),(0,u.mapReadPretty)(function(){var e=(0,l.useRecord)(),t=e.expiresIn,n=e.createdAt,r=b().t,o=(0,i.useMemo)(function(){return"never"===t?r("Never expires"):y()(n).add((null==t?void 0:t.replace("d",""))||0,"days").format("YYYY-MM-DD HH:mm:ss")},[n,t]);return c().createElement(p.Typography.Text,null,o)})),A=n(875);function C(e){return"{{t('".concat(e,"', { ns: '").concat(f,"', nsMode: 'fallback' })}}")}var k={dumpRules:{group:"user"},migrationRules:["schema-only"],shared:!0,name:"apiKeys",sortable:"sort",createdBy:!0,updatedAt:!1,updatedBy:!1,logging:!0,fields:[{name:"id",type:"bigInt",autoIncrement:!0,primaryKey:!0,allowNull:!1,interface:"id"},{type:"string",name:"name",interface:"input",uiSchema:{type:"string",title:'{{t("name")}}',"x-component":"Input"}},{interface:"obo",type:"belongsTo",name:"role",target:"roles",foreignKey:"roleName",uiSchema:{type:"object",title:'{{t("Roles")}}',"x-component":"Select","x-component-props":{fieldNames:{label:"title",value:"name"},objectValue:!0,options:"{{ currentRoles }}"}}},{name:"expiresIn",type:"string",uiSchema:{type:"string",title:C("Expires"),"x-component":"ExpiresSelect",enum:[{label:C("1 Day"),value:"1d"},{label:C("7 Days"),value:"7d"},{label:C("30 Days"),value:"30d"},{label:C("90 Days"),value:"90d"},{label:C("Custom"),value:"custom"},{label:C("Never"),value:"never"}]}},{name:"token",type:"string",hidden:!0}]};function O(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 S(e,t,n,r,o,a,l){try{var i=e[a](l),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,o)}function j(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function l(e){S(a,r,o,l,i,"next",e)}function i(e){S(a,r,o,l,i,"throw",e)}l(void 0)})}}function P(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){var c=[a,i];if(n)throw TypeError("Generator is already executing.");for(;l;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var T=p.Modal.useModal,I={type:"object",properties:{configuration:{type:"void","x-decorator":"TableBlockProvider","x-decorator-props":{collection:k,resource:"apiKeys",action:"list",params:{pageSize:20,appends:["role"],sort:["-createdAt"]},rowKey:"name",showIndex:!0},"x-component":"CardItem",properties:(r={actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--nb-spacing)"}},properties:{create:{type:"void","x-action":"create",title:C("Add API key"),"x-component":"Action","x-component-props":{icon:"PlusOutlined",openMode:"drawer",type:"primary"},properties:{drawer:{type:"void",title:C("Add API key"),"x-decorator":"Form","x-component":"Action.Modal","x-component-props":{maskClosable:!1,style:{maxWidth:"520px",width:"100%"}},properties:{name:{type:"string",title:C("Key name"),required:!0,"x-component":"CollectionField","x-decorator":"FormItem"},role:{type:"string",title:C("Role"),required:!0,"x-decorator-props":{tooltip:C("Allow only your own roles to be selected")},"x-collection-field":"apiKeys.role","x-component":"CollectionField","x-decorator":"FormItem"},expiresIn:{type:"string",title:C("Expiration"),required:!0,"x-component":"CollectionField","x-decorator":"FormItem",default:"30d"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:function(){var e,t=(0,u.useForm)(),n=(0,l.useActionContext)().setVisible,r=(0,l.useBlockRequestContext)(),o=r.resource,a=r.service,i=b().t,s=(e=T(),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 a=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(a.push(n.value),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,2)||function(e,t){if(e){if("string"==typeof e)return O(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 O(e,t)}}(e,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.")}()),m=s[0];return{run:function(){return j(function(){var e,r,l;return P(this,function(u){switch(u.label){case 0:return[4,t.submit()];case 1:return u.sent(),[4,o.create({values:t.values})];case 2:return l=u.sent(),m.success({title:i("API key created successfully"),onOk:function(){t.reset(),n(!1)},content:c().createElement(p.Space,{direction:"vertical"},c().createElement(p.Alert,{message:i("Make sure to copy your personal access key now as you will not be able to see this again."),type:"warning"}),c().createElement(p.Typography.Text,{copyable:!0},null==(r=l.data)||null==(e=r.data)?void 0:e.token))}),null==a||a.refresh(),[2]}})})()},element:s[1]}}}}}}}}},"x-align":"right"}}}},o=(0,A.uid)(),a={type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{column1:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:C("Key name"),properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:C("Role"),properties:{role:{type:"string","x-collection-field":"apiKeys.role","x-component":"CollectionField","x-component-props":{enableLink:!1},"x-read-pretty":!0}}},column3:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:C("Expiration"),properties:{expiresIn:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column4:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:C("Created at"),properties:{createdAt:{type:"date","x-component":"DatePicker","x-component-props":{format:"YYYY-MM-DD HH:mm:ss"},"x-read-pretty":!0}}},actionColumn:{type:"void",title:'{{ t("Actions") }}',"x-action-column":"actions","x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column",properties:{columnActions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:C("Delete API key"),content:"{{t('Are you sure you want to delete it?')}}"},useAction:function(){var e=(0,l.useRecord)(),t=(0,l.useBlockRequestContext)(),n=t.resource,r=t.service;return{run:function(){return j(function(){return P(this,function(t){switch(t.label){case 0:return[4,n.destroy({filterByTk:e.id})];case 1:return t.sent(),r.refresh(),[2]}})})()}}}}}}}}}}},o in r?Object.defineProperty(r,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[o]=a,r)}}},D=function(){var e=(0,l.useCurrentRoles)().filter(function(e){return"__union__"!==e.name});return c().createElement(l.SchemaComponentOptions,{scope:{currentRoles:e},components:{ExpiresSelect:w}},c().createElement(l.NocoBaseRecursionField,{schema:I}))}}}]);
|