@nocobase/plugin-api-keys 1.5.0-alpha.5 → 1.5.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.
@@ -7,4 +7,9 @@
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-i18next"),require("@formily/shared"),require("@nocobase/client"),require("dayjs"),require("ahooks"),require("antd"),require("@formily/react"),require("react")):"function"==typeof define&&define.amd?define("@nocobase/plugin-api-keys",["react-i18next","@formily/shared","@nocobase/client","dayjs","ahooks","antd","@formily/react","react"],t):"object"==typeof exports?exports["@nocobase/plugin-api-keys"]=t(require("react-i18next"),require("@formily/shared"),require("@nocobase/client"),require("dayjs"),require("ahooks"),require("antd"),require("@formily/react"),require("react")):e["@nocobase/plugin-api-keys"]=t(e["react-i18next"],e["@formily/shared"],e["@nocobase/client"],e.dayjs,e.ahooks,e.antd,e["@formily/react"],e.react)}(self,function(e,t,r,n,o,i,a,c){return function(){"use strict";var l,u,s,p={505:function(e){e.exports=a},875:function(e){e.exports=t},772:function(e){e.exports=r},749:function(e){e.exports=o},721:function(e){e.exports=i},760:function(e){e.exports=n},156:function(e){e.exports=c},238:function(t){t.exports=e}},f={};function y(e){var t=f[e];if(void 0!==t)return t.exports;var r=f[e]={exports:{}};return p[e](r,r.exports,y),r.exports}y.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return y.d(t,{a:t}),t},y.d=function(e,t){for(var r in t)y.o(t,r)&&!y.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},y.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},y.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var d={};y.r(d),y.d(d,{PluginAPIKeysClient:function(){return $},default:function(){return W}});var m=y("772"),b=y("505"),v=y("156"),x=y.n(v),h=y("749"),g=y("721"),w=y("760"),O=y.n(w),j=y("238"),S="@nocobase/plugin-api-keys";function k(){return(0,j.useTranslation)([S,"client"],{nsMode:"fallback"})}function A(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 P(){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 P=function(){return r},r}var C=O()().add(1,"days"),T=(0,m.css)(P()),E=(0,b.connect)(function(e){var t,r,n,o,i=e.onChange;var a=(t=(0,h.useBoolean)(),r=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var r,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,c=!1;try{for(o=o.call(e);!(a=(r=o.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){c=!0,n=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(c)throw n}}return i}}(t,2)||function(e,t){if(e){if("string"==typeof e)return A(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return A(e,t)}}(t,r)||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=a[0],l=a[1],u=l.toggle,s=l.setFalse;return x().createElement(g.Space,{className:T},x().createElement(g.Select,(n=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,o,i;n=e,o=t,i=r[t],o in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i})}return e}({},e),o=(o={value:c?"custom":e.value,onChange:function(e){if("custom"===e)return i("1d"),u();s(),i(e)}},o),Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(o)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(o,e))}),n)),c?x().createElement(g.DatePicker,{disabledDate:function(e){return e.isSameOrBefore()},defaultValue:C,onChange:function(e){e=e.millisecond(0).second(0);var t=O()().millisecond(0).second(0);i("".concat(e.diff(t,"d"),"d"))},showToday:!1,allowClear:!1}):null)},(0,b.mapProps)({dataSource:"options"}),(0,b.mapReadPretty)(function(){var e=(0,m.useRecord)(),t=e.expiresIn,r=e.createdAt,n=k().t,o=(0,v.useMemo)(function(){return"never"===t?n("Never expires"):O()(r).add((null==t?void 0:t.replace("d",""))||0,"days").format("YYYY-MM-DD HH:mm:ss")},[r,t]);return x().createElement(g.Typography.Text,null,o)})),I=y("875");function q(e){return"{{t('".concat(e,"', { ns: '").concat(S,"', nsMode: 'fallback' })}}")}var D={dumpRules:{group:"user"},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:q("Expires"),"x-component":"ExpiresSelect",enum:[{label:q("1 Day"),value:"1d"},{label:q("7 Days"),value:"7d"},{label:q("30 Days"),value:"30d"},{label:q("90 Days"),value:"90d"},{label:q("Custom"),value:"custom"},{label:q("Never"),value:"never"}]}},{name:"token",type:"string",hidden:!0}]};function M(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 R(e,t,r,n,o,i,a){try{var c=e[i](a),l=c.value}catch(e){r(e);return}c.done?t(l):Promise.resolve(l).then(n,o)}function F(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){R(i,n,o,a,c,"next",e)}function c(e){R(i,n,o,a,c,"throw",e)}a(void 0)})}}function B(e,t){var r,n,o,i,a={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){return function(i){if(r)throw TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}var V=g.Modal.useModal;var K={type:"object",properties:{configuration:{type:"void","x-decorator":"TableBlockProvider","x-decorator-props":{collection:D,resource:"apiKeys",action:"list",params:{pageSize:20,appends:["role"],sort:["-createdAt"]},rowKey:"name",showIndex:!0},"x-component":"CardItem",properties:(l={actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--nb-spacing)"}},properties:{create:{type:"void","x-action":"create",title:q("Add API key"),"x-component":"Action","x-component-props":{icon:"PlusOutlined",openMode:"drawer",type:"primary"},properties:{drawer:{type:"void",title:q("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:q("Key name"),required:!0,"x-component":"CollectionField","x-decorator":"FormItem"},role:{type:"string",title:q("Role"),required:!0,"x-decorator-props":{tooltip:q("Allow only your own roles to be selected")},"x-collection-field":"apiKeys.role","x-component":"CollectionField","x-decorator":"FormItem"},expiresIn:{type:"string",title:q("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,r=(0,b.useForm)(),n=(0,m.useActionContext)().setVisible,o=(0,m.useBlockRequestContext)(),i=o.resource,a=o.service,c=k().t;var l=(e=V(),t=2,function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,c=!1;try{for(o=o.call(e);!(a=(r=o.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){c=!0,n=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(c)throw n}}return i}}(e,2)||function(e,t){if(e){if("string"==typeof e)return M(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return M(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.")}()),u=l[0];return{run:function(){return F(function(){var e,t,o;return B(this,function(l){switch(l.label){case 0:return[4,r.submit()];case 1:return l.sent(),[4,i.create({values:r.values})];case 2:return o=l.sent(),u.success({title:c("API key created successfully"),onOk:function(){r.reset(),n(!1)},content:x().createElement(g.Space,{direction:"vertical"},x().createElement(g.Alert,{message:c("Make sure to copy your personal access key now as you will not be able to see this again."),type:"warning"}),x().createElement(g.Typography.Text,{copyable:!0},null===(t=o.data)||void 0===t?void 0:null===(e=t.data)||void 0===e?void 0:e.token))}),null==a||a.refresh(),[2]}})})()},element:l[1]}}}}}}}}},"x-align":"right"}}}},u=(0,I.uid)(),s={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:q("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:q("Role"),properties:{role:{type:"object","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:q("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:q("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:q("Delete API key"),content:"{{t('Are you sure you want to delete it?')}}"},useAction:function(){var e=(0,m.useRecord)(),t=(0,m.useBlockRequestContext)(),r=t.resource,n=t.service;return{run:function(){return F(function(){return B(this,function(t){switch(t.label){case 0:return[4,r.destroy({filterByTk:e.id})];case 1:return t.sent(),n.refresh(),[2]}})})()}}}}}}}}}}},u in l?Object.defineProperty(l,u,{value:s,enumerable:!0,configurable:!0,writable:!0}):l[u]=s,l)}}},_=function(){var e=(0,m.useCurrentRoles)();return x().createElement(m.SchemaComponentOptions,{scope:{currentRoles:e},components:{ExpiresSelect:E}},x().createElement(b.RecursionField,{schema:K}))};function Y(e,t,r,n,o,i,a){try{var c=e[i](a),l=c.value}catch(e){r(e);return}c.done?t(l):Promise.resolve(l).then(n,o)}function N(e,t,r){return(N=U()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&G(o,r.prototype),o}).apply(null,arguments)}function H(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)}}function z(e){return(z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function G(e,t){return(G=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function L(e){var t="function"==typeof Map?new Map:void 0;return(L=function(e){var r;if(null===e||(r=e,-1===Function.toString.call(r).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 N(e,arguments,z(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),G(n,e)})(e)}function U(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(U=function(){return!!e})()}var $=function(e){var t,r,n;function o(){var e,t,r;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),e=this,t=o,r=arguments,t=z(t),function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,U()?Reflect.construct(t,r||[],z(e).constructor):t.apply(e,r))}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&G(e,t)}(o,e),t=o,r=[{key:"load",value:function(){var e,t=this;return(e=function(){return function(e,t){var r,n,o,i,a={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){return function(i){if(r)throw TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}(this,function(e){return t.pluginSettingsManager.add("api-keys",{icon:"KeyOutlined",title:t.t("API keys"),Component:_,aclSnippet:"pm.api-keys.configuration"}),[2]})},function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){Y(i,n,o,a,c,"next",e)}function c(e){Y(i,n,o,a,c,"throw",e)}a(void 0)})})()}}],H(t.prototype,r),o}(L(m.Plugin)),W=$;return d}()});
10
+ (function(e,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("@formily/react"),require("ahooks"),require("antd"),require("dayjs"),require("react"),require("react-i18next"),require("@formily/shared")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","@formily/react","ahooks","antd","dayjs","react","react-i18next","@formily/shared"],t):(e=typeof globalThis!="undefined"?globalThis:e||self,t(e["@nocobase/plugin-api-keys"]={},e["@nocobase/client"],e.jsxRuntime,e["@formily/react"],e.ahooks,e.antd,e.dayjs,e.react,e["react-i18next"],e["@formily/shared"]))})(this,function(e,t,o,p,x,s,d,m,i,y){"use strict";var Y=Object.defineProperty,H=Object.defineProperties;var W=Object.getOwnPropertyDescriptors;var P=Object.getOwnPropertySymbols;var $=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var D=(e,t,o)=>t in e?Y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,w=(e,t)=>{for(var o in t||(t={}))$.call(t,o)&&D(e,o,t[o]);if(P)for(var o of P(t))L.call(t,o)&&D(e,o,t[o]);return e},I=(e,t)=>H(e,W(t));var C=(e,t,o)=>new Promise((p,x)=>{var s=i=>{try{m(o.next(i))}catch(y){x(y)}},d=i=>{try{m(o.throw(i))}catch(y){x(y)}},m=i=>i.done?p(i.value):Promise.resolve(i.value).then(s,d);m((o=o.apply(e,t)).next())});const k="@nocobase/plugin-api-keys";function v(){return i.useTranslation([k,"client"],{nsMode:"fallback"})}const M=d().add(1,"days"),q=t.css`
11
+ width: 100%;
12
+ & > .ant-space-item {
13
+ flex: 1;
14
+ }
15
+ `,F=n=>{const{onChange:a}=n,[c,{toggle:u,setFalse:f}]=x.useBoolean(),b=l=>{if(l==="custom")return a("1d"),u();f(),a(l)},h=l=>{l=l.millisecond(0).second(0);const A=d().millisecond(0).second(0),g=`${l.diff(A,"d")}d`;a(g)};return o.jsxs(s.Space,{className:q,children:[o.jsx(s.Select,I(w({},n),{value:c?"custom":n.value,onChange:b})),c?o.jsx(s.DatePicker,{disabledDate:l=>l.isSameOrBefore(),defaultValue:M,onChange:h,showToday:!1,allowClear:!1}):null]})},K=()=>{const{expiresIn:n,createdAt:a}=t.useRecord(),{t:c}=v(),u=m.useMemo(()=>n==="never"?c("Never expires"):d(a).add((n==null?void 0:n.replace("d",""))||0,"days").format("YYYY-MM-DD HH:mm:ss"),[a,n]);return o.jsx(s.Typography.Text,{children:u})},V=p.connect(F,p.mapProps({dataSource:"options"}),p.mapReadPretty(K));function r(n){return`{{t('${n}', { ns: '${k}', nsMode: 'fallback' })}}`}const B={dumpRules:{group:"user"},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:r("Expires"),"x-component":"ExpiresSelect",enum:[{label:r("1 Day"),value:"1d"},{label:r("7 Days"),value:"7d"},{label:r("30 Days"),value:"30d"},{label:r("90 Days"),value:"90d"},{label:r("Custom"),value:"custom"},{label:r("Never"),value:"never"}]}},{name:"token",type:"string",hidden:!0}]},{useModal:j}=s.Modal,O=()=>{const n=p.useForm(),{setVisible:a}=t.useActionContext(),{resource:c,service:u}=t.useBlockRequestContext(),{t:f}=v(),[b,h]=j();return{run(){return C(this,null,function*(){var g,S;yield n.submit();const A=yield c.create({values:n.values});b.success({title:f("API key created successfully"),onOk:()=>{n.reset(),a(!1)},content:o.jsxs(s.Space,{direction:"vertical",children:[o.jsx(s.Alert,{message:f("Make sure to copy your personal access key now as you will not be able to see this again."),type:"warning"}),o.jsx(s.Typography.Text,{copyable:!0,children:(S=(g=A.data)==null?void 0:g.data)==null?void 0:S.token})]})}),u==null||u.refresh()})},element:h}},N=()=>{const n=t.useRecord(),{resource:a,service:c}=t.useBlockRequestContext();return{run(){return C(this,null,function*(){yield a.destroy({filterByTk:n.id}),c.refresh()})}}},R={type:"object",properties:{configuration:{type:"void","x-decorator":"TableBlockProvider","x-decorator-props":{collection:B,resource:"apiKeys",action:"list",params:{pageSize:20,appends:["role"],sort:["-createdAt"]},rowKey:"name",showIndex:!0},"x-component":"CardItem",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--nb-spacing)"}},properties:{create:{type:"void","x-action":"create",title:r("Add API key"),"x-component":"Action","x-component-props":{icon:"PlusOutlined",openMode:"drawer",type:"primary"},properties:{drawer:{type:"void",title:r("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:r("Key name"),required:!0,"x-component":"CollectionField","x-decorator":"FormItem"},role:{type:"string",title:r("Role"),required:!0,"x-decorator-props":{tooltip:r("Allow only your own roles to be selected")},"x-collection-field":"apiKeys.role","x-component":"CollectionField","x-decorator":"FormItem"},expiresIn:{type:"string",title:r("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:O}}}}}}},"x-align":"right"}}},[y.uid()]:{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:r("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:r("Role"),properties:{role:{type:"object","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:r("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:r("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:r("Delete API key"),content:"{{t('Are you sure you want to delete it?')}}"},useAction:N}}}}}}}}}}}},E=()=>{const n=t.useCurrentRoles();return o.jsx(t.SchemaComponentOptions,{scope:{currentRoles:n},components:{ExpiresSelect:V},children:o.jsx(p.RecursionField,{schema:R})})};class T extends t.Plugin{load(){return C(this,null,function*(){this.pluginSettingsManager.add("api-keys",{icon:"KeyOutlined",title:this.t("API keys"),Component:E,aclSnippet:"pm.api-keys.configuration"})})}}e.PluginAPIKeysClient=T,e.default=T,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -8,9 +8,9 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "1.5.0-alpha.5",
12
- "@nocobase/database": "1.5.0-alpha.5",
13
- "@nocobase/server": "1.5.0-alpha.5",
11
+ "@nocobase/client": "1.5.0-beta.2",
12
+ "@nocobase/database": "1.5.0-beta.2",
13
+ "@nocobase/server": "1.5.0-beta.2",
14
14
  "@formily/react": "2.3.0",
15
15
  "ahooks": "3.7.8",
16
16
  "antd": "5.12.8",
@@ -18,5 +18,5 @@ module.exports = {
18
18
  "react": "18.2.0",
19
19
  "@formily/shared": "2.3.2",
20
20
  "react-i18next": "11.18.6",
21
- "@nocobase/actions": "1.5.0-alpha.5"
21
+ "@nocobase/actions": "1.5.0-beta.2"
22
22
  };
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "认证:API 密钥",
5
5
  "description": "Allows users to use API key to access application's HTTP API",
6
6
  "description.zh-CN": "允许用户使用 API 密钥访问应用的 HTTP API",
7
- "version": "1.5.0-alpha.5",
7
+ "version": "1.5.0-beta.2",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/api-keys",
@@ -32,5 +32,5 @@
32
32
  "@nocobase/test": "1.x",
33
33
  "@nocobase/utils": "1.x"
34
34
  },
35
- "gitHead": "8d24e8d2c0f3f57ceaa271438fd93db2b4150011"
35
+ "gitHead": "8a9c29fdac5c6295dcc7abf00c3fa81bd9e01a36"
36
36
  }