@nocobase/plugin-api-keys 2.1.0-beta.34 → 2.1.0-beta.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client-v2.d.ts +2 -0
- package/client-v2.js +1 -0
- package/dist/client-v2/849.3f8b976beb7f19c9.js +10 -0
- package/dist/client-v2/index.d.ts +9 -0
- package/dist/client-v2/index.js +10 -0
- package/dist/client-v2/locale.d.ts +10 -0
- package/dist/client-v2/pages/ApiKeysPage.d.ts +59 -0
- package/dist/client-v2/pages/ExpiresField.d.ts +30 -0
- package/dist/client-v2/plugin.d.ts +14 -0
- package/dist/externalVersion.js +7 -4
- package/package.json +4 -2
package/client-v2.d.ts
ADDED
package/client-v2.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/client-v2/index.js');
|
|
@@ -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
|
+
(self.webpackChunk_nocobase_plugin_api_keys_client_v2=self.webpackChunk_nocobase_plugin_api_keys_client_v2||[]).push([["849"],{153:function(e){e.exports=function(e,t){t.prototype.isSameOrBefore=function(e,t){return this.isSame(e,t)||this.isBefore(e,t)}}},648:function(e,t,n){"use strict";n.r(t),n.d(t,{submitApiKeyForm:function(){return k},default:function(){return S},deleteApiKey:function(){return A}});var r=n(375),l=n(485),a=n(694),o=n(625),u=n(59),i=n(185),c=n.n(i),s=n(155),f=n.n(s);function d(){var e=(0,a.useFlowEngine)();return function(t,n){return e.context.t(t,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:["@nocobase/plugin-api-keys","client"]},n))}}var m=n(153),p=n.n(m);function y(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(e){var t,n=e.value,r=e.onChange,l=e.options,a=function(e){if(Array.isArray(e))return e}(t=(0,o.useBoolean)(!1))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var l=[],a=!0,o=!1;try{for(r=r.call(e);!(a=(t=r.next()).done)&&(l.push(t.value),2!==l.length);a=!0);}catch(e){o=!0,n=e}finally{try{a||null==r.return||r.return()}finally{if(o)throw n}}return l}}(t)||function(e){if(e){if("string"==typeof e)return y(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 y(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.")}(),i=a[0],s=a[1],d=s.toggle,m=s.setFalse;return f().createElement(u.Space,{style:{width:"100%"},styles:{item:{flex:1}}},f().createElement(u.Select,{style:{width:"100%"},options:l,value:i?"custom":n,onChange:function(e){if("custom"===e){null==r||r("1d"),d();return}m(),null==r||r(e)}}),i?f().createElement(u.DatePicker,{style:{width:"100%"},disabledDate:function(e){return e.isSameOrBefore(c()())},defaultValue:c()().add(1,"days"),onChange:function(e){e&&(null==r||r(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:c()(),n=e.millisecond(0).second(0),r=t.millisecond(0).second(0);return"".concat(n.diff(r,"d"),"d")}(e)))},allowClear:!1}):null)}function b(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,l,a,o){try{var u=e[a](o),i=u.value}catch(e){n(e);return}u.done?t(i):Promise.resolve(i).then(r,l)}function g(e){return function(){var t=this,n=arguments;return new Promise(function(r,l){var a=e.apply(t,n);function o(e){h(a,r,l,o,u,"next",e)}function u(e){h(a,r,l,o,u,"throw",e)}o(void 0)})}}function w(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,l=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=l){var a=[],o=!0,u=!1;try{for(l=l.call(e);!(o=(n=l.next()).done)&&(a.push(n.value),!t||a.length!==t);o=!0);}catch(e){u=!0,r=e}finally{try{o||null==l.return||l.return()}finally{if(u)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return b(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 b(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 E(e,t){var n,r,l,a={label:0,sent:function(){if(1&l[0])throw l[1];return l[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(o,"next",{value:i(0)}),u(o,"throw",{value:i(1)}),u(o,"return",{value:i(2)}),"function"==typeof Symbol&&u(o,Symbol.iterator,{value:function(){return this}}),o;function i(u){return function(i){var c=[u,i];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(l=2&c[0]?r.return:c[0]?r.throw||((l=r.return)&&l.call(r),0):r.next)&&!(l=l.call(r,c[1])).done)return l;switch(r=0,l&&(c=[2&c[0],l.value]),c[0]){case 0:case 1:l=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(l=(l=a.trys).length>0&&l[l.length-1])&&(6===c[0]||2===c[0])){a=0;continue}if(3===c[0]&&(!l||c[1]>l[0]&&c[1]<l[3])){a.label=c[1];break}if(6===c[0]&&a.label<l[1]){a.label=l[1],l=c;break}if(l&&a.label<l[2]){a.label=l[2],a.ops.push(c);break}l[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],r=0}finally{n=l=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function k(e){return g(function(){var t,n,r;return E(this,function(l){switch(l.label){case 0:return[4,e.resource.create({values:e.values})];case 1:return r=l.sent(),e.onCreated(null==r||null==(n=r.data)||null==(t=n.data)?void 0:t.token),[2]}})})()}function A(e){return g(function(){return E(this,function(t){switch(t.label){case 0:return[4,e.resource.destroy({filterByTk:e.filterByTk})];case 1:return t.sent(),e.onDeleted(),[2]}})})()}function x(e){var t,n=e.onCreated,r=d(),o=(0,a.useFlowContext)(),i=(0,a.useFlowView)(),c=[{label:(t=d())("1 Day"),value:"1d"},{label:t("7 Days"),value:"7d"},{label:t("30 Days"),value:"30d"},{label:t("90 Days"),value:"90d"},{label:t("Custom"),value:"custom"},{label:t("Never"),value:"never"}],m=(0,l.useCurrentRoles)(),p=w(u.Form.useForm(),1)[0],y=w((0,s.useState)(!1),2),b=y[0],h=y[1],A=(0,s.useMemo)(function(){return o.api.resource("apiKeys")},[o.api]),x=(0,s.useCallback)(function(){return g(function(){var e;return E(this,function(t){switch(t.label){case 0:return[4,p.validateFields()];case 1:e=t.sent(),h(!0),t.label=2;case 2:return t.trys.push([2,,5,6]),[4,k({values:{name:e.name,role:e.role?{name:e.role}:void 0,expiresIn:e.expiresIn},resource:A,onCreated:function(e){p.resetFields(),n(e)}})];case 3:return t.sent(),[4,i.close()];case 4:return t.sent(),[3,6];case 5:return h(!1),[7];case 6:return[2]}})})()},[p,n,A,i]);return f().createElement(f().Fragment,null,f().createElement(u.Form,{form:p,layout:"vertical",initialValues:{expiresIn:"30d"}},f().createElement(u.Form.Item,{name:"name",label:r("Key name"),rules:[{required:!0,message:r("The field value is required")}]},f().createElement(u.Input,null)),f().createElement(u.Form.Item,{name:"role",label:r("Role"),tooltip:r("Allow only your own roles to be selected"),rules:[{required:!0,message:r("The field value is required")}]},f().createElement(u.Select,{fieldNames:{label:"title",value:"name"},options:m})),f().createElement(u.Form.Item,{name:"expiresIn",label:r("Expiration"),rules:[{required:!0,message:r("The field value is required")}]},f().createElement(v,{options:c}))),i.Footer?f().createElement(i.Footer,null,f().createElement(u.Space,null,f().createElement(u.Button,{onClick:function(){return g(function(){return E(this,function(e){return[2,i.close()]})})()}},r("Cancel")),f().createElement(u.Button,{type:"primary",loading:b,onClick:x},r("Submit")))):null)}c().extend(p());var S=function(){var e=d(),t=(0,a.useFlowContext)(),n=(0,a.useFlowEngine)(),i=u.theme.useToken().token,m=u.App.useApp().modal,p=(0,s.useMemo)(function(){return t.api.resource("apiKeys")},[t.api]),y=(0,o.useRequest)(function(){return g(function(){var e,n;return E(this,function(r){switch(r.label){case 0:return[4,t.api.request({url:"apiKeys:list",method:"get",params:{pageSize:20,appends:["role"],sort:["-createdAt"]},skipNotify:!0})];case 1:return[2,null!=(e=null==(n=r.sent())?void 0:n.data)?e:{data:[]}]}})})()}),v=y.data,b=y.loading,h=(0,s.useMemo)(function(){var e=null==v?void 0:v.data;return Array.isArray(e)?e:[]},[v]),w=(0,s.useMemo)(function(){var e,t,n,r=null==v?void 0:v.meta;return!!r&&{total:null!=(e=r.count)?e:h.length,pageSize:null!=(t=r.pageSize)?t:20,current:null!=(n=r.page)?n:1}},[v,h.length]),k=(0,s.useCallback)(function(t){m.confirm({title:e("Delete API key"),content:e("Are you sure you want to delete it?"),onOk:function(){return g(function(){return E(this,function(e){switch(e.label){case 0:return[4,A({resource:p,filterByTk:t.id,onDeleted:function(){return y.refresh()}})];case 1:return e.sent(),[2]}})})()}})},[y,m,p,e]),S=(0,s.useCallback)(function(){t.viewer.dialog({title:e("Add API key"),width:520,maskClosable:!1,closable:!0,content:function(){return f().createElement(x,{onCreated:function(t){y.refresh(),m.success({title:e("API key created successfully"),content:f().createElement(u.Space,{direction:"vertical",style:{width:"100%"}},f().createElement(u.Alert,{type:"warning",message:e("Make sure to copy your personal access key now as you will not be able to see this again.")}),f().createElement(u.Typography.Text,{copyable:!0},t))})}})}})},[t.viewer,y,m,e]),C=e("Never expires"),I=(0,s.useMemo)(function(){return[{title:e("Key name"),dataIndex:"name",ellipsis:!0},{title:e("Role"),dataIndex:["role","title"],render:function(e,t){var r,l,a=null==(l=t.role)?void 0:l.title;return a?f().createElement(u.Tag,null,n.context.t(a)):null!=(r=t.roleName)?r:"-"}},{title:e("Expiration"),render:function(e,t){var n={expiresIn:t.expiresIn,createdAt:t.createdAt};if("never"===n.expiresIn)return C;var r,l=parseInt(String(null!=(r=n.expiresIn)?r:"").replace("d",""),10)||0;return n.createdAt?c()(n.createdAt).add(l,"days").format("YYYY-MM-DD HH:mm:ss"):""}},{title:e("Created at"),dataIndex:"createdAt",render:function(e){return e?c()(e).format("YYYY-MM-DD HH:mm:ss"):"-"}},{title:e("Actions"),width:160,render:function(t,n){return f().createElement("a",{onClick:function(){return k(n)}},e("Delete"))}}]},[n,k,C,e]);return f().createElement(u.Card,null,f().createElement(u.Flex,{justify:"flex-end",style:{marginBottom:i.marginMD}},f().createElement(u.Space,null,f().createElement(u.Button,{icon:f().createElement(r.ReloadOutlined,null),onClick:function(){return y.refresh()}},e("Refresh")),f().createElement(u.Button,{type:"primary",icon:f().createElement(r.PlusOutlined,null),onClick:S},e("Add API key")))),f().createElement(l.Table,{rowKey:"id",loading:b,dataSource:h,columns:I,pagination:w}))}}}]);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export { default } from './plugin';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("ahooks"),require("@nocobase/client-v2"),require("dayjs"),require("react"),require("antd"),require("@ant-design/icons"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@nocobase/plugin-api-keys/client-v2",["ahooks","@nocobase/client-v2","dayjs","react","antd","@ant-design/icons","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@nocobase/plugin-api-keys/client-v2"]=t(require("ahooks"),require("@nocobase/client-v2"),require("dayjs"),require("react"),require("antd"),require("@ant-design/icons"),require("@nocobase/flow-engine")):e["@nocobase/plugin-api-keys/client-v2"]=t(e.ahooks,e["@nocobase/client-v2"],e.dayjs,e.react,e.antd,e["@ant-design/icons"],e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o,i,a){return function(){"use strict";var u,c,l,s={375:function(e){e.exports=i},485:function(e){e.exports=t},694:function(e){e.exports=a},625:function(t){t.exports=e},59:function(e){e.exports=o},185:function(e){e.exports=n},155:function(e){e.exports=r}},p={};function f(e){var t=p[e];if(void 0!==t)return t.exports;var n=p[e]={exports:{}};return s[e].call(n.exports,n,n.exports,f),n.exports}f.m=s,f.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(t,{a:t}),t},f.d=function(e,t){for(var n in t)f.o(t,n)&&!f.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},f.f={},f.e=function(e){return Promise.all(Object.keys(f.f).reduce(function(t,n){return f.f[n](e,t),t},[]))},f.u=function(e){return""+e+".3f8b976beb7f19c9.js"},f.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),f.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},d={},f.l=function(e,t,n,r){if(d[e])return void d[e].push(t);if(void 0!==n)for(var o,i,a=document.getElementsByTagName("script"),u=0;u<a.length;u++){var c=a[u];if(c.getAttribute("src")==e||c.getAttribute("data-rspack")=="@nocobase/plugin-api-keys/client-v2:"+n){o=c;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,f.nc&&o.setAttribute("nonce",f.nc),o.setAttribute("data-rspack","@nocobase/plugin-api-keys/client-v2:"+n),o.src=e),d[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(s);var r=d[e];if(delete d[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),i&&document.head.appendChild(o)},f.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.g.importScripts&&(b=f.g.location+"");var d,b,y=f.g.document;if(!b&&y&&(y.currentScript&&"SCRIPT"===y.currentScript.tagName.toUpperCase()&&(b=y.currentScript.src),!b)){var v=y.getElementsByTagName("script");if(v.length)for(var h=v.length-1;h>-1&&(!b||!/^http(s?):/.test(b));)b=v[h--].src}if(!b)throw Error("Automatic publicPath is not supported in this browser");f.p=b.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),u={889:0},f.f.j=function(e,t){var n=f.o(u,e)?u[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=u[e]=[t,r]});t.push(n[2]=r);var o=f.p+f.u(e),i=Error();f.l(o,function(t){if(f.o(u,e)&&(0!==(n=u[e])&&(u[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},c=function(e,t){var n,r,o=t[0],i=t[1],a=t[2],c=0;if(o.some(function(e){return 0!==u[e]})){for(n in i)f.o(i,n)&&(f.m[n]=i[n]);a&&a(f)}for(e&&e(t);c<o.length;c++)r=o[c],f.o(u,r)&&u[r]&&u[r][0](),u[r]=0},(l=self.webpackChunk_nocobase_plugin_api_keys_client_v2=self.webpackChunk_nocobase_plugin_api_keys_client_v2||[]).forEach(c.bind(null,0)),l.push=c.bind(null,l.push.bind(l));var g={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var n=window.__webpack_public_path__||"";n&&("/"!==n.charAt(n.length-1)&&(n+="/"),e=n+"static/plugins/@nocobase/plugin-api-keys/dist/client-v2/")}if(!e){if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var r=window.location.pathname||"/",o=r.indexOf("/v2/");e=o>=0?r.slice(0,o+1):"/"}e&&(e=e.replace(/\/v2\/?$/,"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-api-keys/dist/client-v2/"}f.p=e}(),!function(){f.r(g),f.d(g,{default:function(){return u}});var e=f(485);function t(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function n(e,t,r){return(n=a()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&o(i,n.prototype),i}).apply(null,arguments)}function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e){var t="function"==typeof Map?new Map:void 0;return(i=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,i)}function i(){return n(e,arguments,r(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),o(i,e)})(e)}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(a=function(){return!!e})()}var u=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function i(){var e,t;if(!(this instanceof i))throw TypeError("Cannot call a class as a function");return e=i,t=arguments,e=r(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">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,a()?Reflect.construct(e,t||[],r(this).constructor):e.apply(this,t))}return i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&o(i,e),n=[{key:"load",value:function(){var e;return(e=function(){var e;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var l=[u,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)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 i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}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}}}}(this,function(t){return e=this.t("API keys"),this.pluginSettingsManager.addMenuItem({key:"api-keys",title:e,icon:"KeyOutlined",aclSnippet:"pm.api-keys.configuration"}),this.pluginSettingsManager.addPageTabItem({menuKey:"api-keys",key:"index",title:e,componentLoader:function(){return f.e("849").then(f.bind(f,648))}}),[2]})},function(){var n=this,r=arguments;return new Promise(function(o,i){var a=e.apply(n,r);function u(e){t(a,o,i,u,c,"next",e)}function c(e){t(a,o,i,u,c,"throw",e)}u(void 0)})}).call(this)}}],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)}}(i.prototype,n),i}(i(e.Plugin))}(),g}()});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useT(): (key: string, options?: Record<string, any>) => string;
|
|
10
|
+
export declare function tExpr(key: string): string;
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
type Role = {
|
|
11
|
+
name: string;
|
|
12
|
+
title?: string;
|
|
13
|
+
};
|
|
14
|
+
export type ApiKeyFormValues = {
|
|
15
|
+
name: string;
|
|
16
|
+
role?: Role;
|
|
17
|
+
expiresIn: string;
|
|
18
|
+
};
|
|
19
|
+
export type ApiKeyRecord = {
|
|
20
|
+
id: number;
|
|
21
|
+
name: string;
|
|
22
|
+
role?: Role;
|
|
23
|
+
roleName?: string;
|
|
24
|
+
expiresIn: string;
|
|
25
|
+
createdAt?: string;
|
|
26
|
+
};
|
|
27
|
+
type CreateResponse = {
|
|
28
|
+
data?: {
|
|
29
|
+
data?: {
|
|
30
|
+
token?: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export type ApiKeyResource = {
|
|
35
|
+
create: (params: {
|
|
36
|
+
values: ApiKeyFormValues;
|
|
37
|
+
}) => Promise<CreateResponse>;
|
|
38
|
+
destroy: (params: {
|
|
39
|
+
filterByTk: number | number[];
|
|
40
|
+
}) => Promise<unknown>;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Pure submit pipeline so tests can pin the resource call shape (create →
|
|
44
|
+
* extract token → onCreated) and a future refactor cannot silently skip the
|
|
45
|
+
* POST while still closing the drawer. Mirrors the prevention rule documented
|
|
46
|
+
* in references/settings-page-crud.md (`No silent fallthrough on submit branches`).
|
|
47
|
+
*/
|
|
48
|
+
export declare function submitApiKeyForm(args: {
|
|
49
|
+
values: ApiKeyFormValues;
|
|
50
|
+
resource: ApiKeyResource;
|
|
51
|
+
onCreated: (token: string | undefined) => void;
|
|
52
|
+
}): Promise<void>;
|
|
53
|
+
export declare function deleteApiKey(args: {
|
|
54
|
+
resource: ApiKeyResource;
|
|
55
|
+
filterByTk: number;
|
|
56
|
+
onDeleted: () => void;
|
|
57
|
+
}): Promise<void>;
|
|
58
|
+
declare const ApiKeysPage: React.FC;
|
|
59
|
+
export default ApiKeysPage;
|
|
@@ -0,0 +1,30 @@
|
|
|
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 dayjs from 'dayjs';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
export type ExpiresOption = {
|
|
12
|
+
label: string;
|
|
13
|
+
value: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Convert a future `dayjs` date into the `Xd` shape persisted by the apiKeys
|
|
17
|
+
* collection. Mirrors the v1 ExpiresSelect: zero out seconds/milliseconds on
|
|
18
|
+
* both ends and report the day difference.
|
|
19
|
+
*/
|
|
20
|
+
export declare function diffToExpiresIn(target: dayjs.Dayjs, now?: dayjs.Dayjs): string;
|
|
21
|
+
export declare function formatExpiresReadOnly(record: {
|
|
22
|
+
expiresIn?: string;
|
|
23
|
+
createdAt?: string;
|
|
24
|
+
}, neverLabel: string): string;
|
|
25
|
+
export declare function ExpiresEditor(props: {
|
|
26
|
+
value?: string;
|
|
27
|
+
onChange?: (next: string) => void;
|
|
28
|
+
options: ExpiresOption[];
|
|
29
|
+
}): React.JSX.Element;
|
|
30
|
+
export declare function useExpiresOptions(): ExpiresOption[];
|
|
@@ -0,0 +1,14 @@
|
|
|
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 type { Application } from '@nocobase/client-v2';
|
|
10
|
+
import { Plugin } from '@nocobase/client-v2';
|
|
11
|
+
export declare class PluginAPIKeysClientV2 extends Plugin<Record<string, never>, Application> {
|
|
12
|
+
load(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export default PluginAPIKeysClientV2;
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,9 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "2.1.0-beta.
|
|
12
|
-
"@nocobase/
|
|
13
|
-
"@nocobase/
|
|
11
|
+
"@nocobase/client": "2.1.0-beta.36",
|
|
12
|
+
"@nocobase/flow-engine": "2.1.0-beta.36",
|
|
13
|
+
"@nocobase/client-v2": "2.1.0-beta.36",
|
|
14
|
+
"@nocobase/database": "2.1.0-beta.36",
|
|
15
|
+
"@nocobase/server": "2.1.0-beta.36",
|
|
14
16
|
"@formily/react": "2.3.7",
|
|
15
17
|
"ahooks": "3.7.8",
|
|
16
18
|
"antd": "5.24.2",
|
|
@@ -18,5 +20,6 @@ module.exports = {
|
|
|
18
20
|
"react": "18.2.0",
|
|
19
21
|
"@formily/shared": "2.3.7",
|
|
20
22
|
"react-i18next": "11.18.6",
|
|
21
|
-
"@
|
|
23
|
+
"@ant-design/icons": "5.6.1",
|
|
24
|
+
"@nocobase/actions": "2.1.0-beta.36"
|
|
22
25
|
};
|
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.1.0-beta.
|
|
9
|
+
"version": "2.1.0-beta.36",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"main": "./dist/server/index.js",
|
|
12
12
|
"homepage": "https://docs.nocobase.com/handbook/api-keys",
|
|
@@ -29,11 +29,13 @@
|
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@nocobase/actions": "2.x",
|
|
31
31
|
"@nocobase/client": "2.x",
|
|
32
|
+
"@nocobase/client-v2": "2.x",
|
|
32
33
|
"@nocobase/database": "2.x",
|
|
34
|
+
"@nocobase/flow-engine": "2.x",
|
|
33
35
|
"@nocobase/resourcer": "2.x",
|
|
34
36
|
"@nocobase/server": "2.x",
|
|
35
37
|
"@nocobase/test": "2.x",
|
|
36
38
|
"@nocobase/utils": "2.x"
|
|
37
39
|
},
|
|
38
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "397d45c744f6eb48b3a0cd785c87cbf1257c3513"
|
|
39
41
|
}
|