@nocobase/plugin-api-keys 0.14.0-alpha.8 → 0.15.0-alpha.1
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/dist/client/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(t,e){typeof exports=="object"&&typeof module!="undefined"?e(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"],e):(t=typeof globalThis!="undefined"?globalThis:t||self,e(t["@nocobase/plugin-api-keys"]={},t["@nocobase/client"],t.jsxRuntime,t["@formily/react"],t.ahooks,t.antd,t.dayjs,t.react,t["react-i18next"],t["@formily/shared"]))})(this,function(t,e,o,p,x,a,d,m,i,y){"use strict";var R=Object.defineProperty,H=Object.defineProperties;var W=Object.getOwnPropertyDescriptors;var S=Object.getOwnPropertySymbols;var $=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var P=(t,e,o)=>e in t?R(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,D=(t,e)=>{for(var o in e||(e={}))$.call(e,o)&&P(t,o,e[o]);if(S)for(var o of S(e))L.call(e,o)&&P(t,o,e[o]);return t},w=(t,e)=>H(t,W(e));var g=(t,e,o)=>new Promise((p,x)=>{var a=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(a,d);m((o=o.apply(t,e)).next())});const b="api-keys";function r(n){return`{{t('${n}', { ns: '${b}', nsMode: 'fallback' })}}`}const M={namespace:"api-keys",duplicator:"optional",name:"apiKeys",title:'{{t("API keys", {"ns": "api-keys"})}}',sortable:"sort",model:"ApiKeyModel",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}]};function v(){return i.useTranslation([b,"client"],{nsMode:"fallback"})}const I=d().add(1,"days"),K=e.css`
|
|
2
2
|
width: 100%;
|
|
3
3
|
& > .ant-space-item {
|
|
4
4
|
flex: 1;
|
|
5
5
|
}
|
|
6
|
-
`,
|
|
6
|
+
`,q=n=>{const{onChange:s}=n,[c,{toggle:u,setFalse:f}]=x.useBoolean(),h=l=>{if(l==="custom")return s("1d"),u();f(),s(l)},A=l=>{l=l.millisecond(0).second(0);const k=d().millisecond(0).second(0),C=`${l.diff(k,"d")}d`;s(C)};return o.jsxs(a.Space,{className:K,children:[o.jsx(a.Select,w(D({},n),{value:c?"custom":n.value,onChange:h})),c?o.jsx(a.DatePicker,{disabledDate:l=>l.isSameOrBefore(),defaultValue:I,onChange:A,showToday:!1,allowClear:!1}):null]})},F=()=>{const{expiresIn:n,createdAt:s}=e.useRecord(),{t:c}=v(),u=m.useMemo(()=>n==="never"?c("Never expires"):d(s).add((n==null?void 0:n.replace("d",""))||0,"days").format("YYYY-MM-DD HH:mm:ss"),[s,n]);return o.jsx(a.Typography.Text,{children:u})},V=p.connect(q,p.mapProps({dataSource:"options"}),p.mapReadPretty(F)),{useModal:B}=a.Modal,j=()=>{const n=p.useForm(),{setVisible:s}=e.useActionContext(),{resource:c,service:u}=e.useBlockRequestContext(),{t:f}=v(),[h,A]=B();return{run(){return g(this,null,function*(){var C,T;yield n.submit();const k=yield c.create({values:n.values});h.success({title:f("API key created successfully"),onOk:()=>{n.reset(),s(!1)},content:o.jsxs(a.Space,{direction:"vertical",children:[o.jsx(a.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(a.Typography.Text,{copyable:!0,children:(T=(C=k.data)==null?void 0:C.data)==null?void 0:T.token})]})}),u==null||u.refresh()})},element:A}},N=()=>{const n=e.useRecord(),{resource:s,service:c}=e.useBlockRequestContext();return{run(){return g(this,null,function*(){yield s.destroy({filterByTk:n.id}),c.refresh()})}}},O={type:"object",properties:{configuration:{type:"void","x-decorator":"TableBlockProvider","x-decorator-props":{collection:"apiKeys",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":{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:j}}}}}}},"x-align":"right"}}},[y.uid()]:{type:"array","x-component":"TableV2","x-component-props":{rowKey:"id",useProps:"{{ useTableBlockProps }}"},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=e.useCurrentRoles();return o.jsx(e.CollectionManagerProvider,{collections:[M],children:o.jsx(e.SchemaComponentOptions,{scope:{currentRoles:n},components:{ExpiresSelect:V},children:o.jsx(p.RecursionField,{schema:O})})})};class Y extends e.Plugin{load(){return g(this,null,function*(){this.app.pluginSettingsManager.add(b,{icon:"KeyOutlined",title:'{{t("API keys", {"ns": "api-keys"})}}',Component:E,aclSnippet:"pm.api-keys.configuration"})})}}t.default=Y,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
"@nocobase/client": "0.
|
|
3
|
-
"
|
|
4
|
-
"@nocobase/
|
|
5
|
-
"@nocobase/server": "0.14.0-alpha.8",
|
|
2
|
+
"@nocobase/client": "0.15.0-alpha.1",
|
|
3
|
+
"@nocobase/database": "0.15.0-alpha.1",
|
|
4
|
+
"@nocobase/server": "0.15.0-alpha.1",
|
|
6
5
|
"@formily/react": "2.2.27",
|
|
7
6
|
"ahooks": "3.7.8",
|
|
8
7
|
"antd": "5.8.6",
|
|
9
8
|
"dayjs": "1.11.9",
|
|
9
|
+
"react": "18.2.0",
|
|
10
10
|
"@formily/shared": "2.2.27",
|
|
11
11
|
"react-i18next": "11.18.6",
|
|
12
|
-
"@nocobase/actions": "0.
|
|
12
|
+
"@nocobase/actions": "0.15.0-alpha.1"
|
|
13
13
|
};
|
package/dist/locale/zh-CN.d.ts
CHANGED
package/dist/locale/zh-CN.js
CHANGED
|
@@ -21,15 +21,16 @@ __export(zh_CN_exports, {
|
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(zh_CN_exports);
|
|
23
23
|
const locale = {
|
|
24
|
-
"API
|
|
24
|
+
"API keys": "API \u5BC6\u94A5",
|
|
25
|
+
"API key created successfully": "API \u5BC6\u94A5\u521B\u5EFA\u6210\u529F",
|
|
25
26
|
"Make sure to copy your personal access key now as you will not be able to see this again.": "\u8BF7\u786E\u4FDD\u73B0\u5728\u590D\u5236\u4F60\u7684\u4E2A\u4EBA\u8BBF\u95EE\u5BC6\u94A5\uFF0C\u56E0\u4E3A\u4F60\u5C06\u65E0\u6CD5\u518D\u6B21\u770B\u5230\u8FD9\u4E2A\u5BC6\u94A5\u3002",
|
|
26
27
|
"Key name": "\u5BC6\u94A5\u540D\u79F0",
|
|
27
28
|
Expiration: "\u8FC7\u671F\u65F6\u95F4",
|
|
28
|
-
"Delete API key": "\u5220\u9664 API
|
|
29
|
+
"Delete API key": "\u5220\u9664 API \u5BC6\u94A5",
|
|
29
30
|
Role: "\u89D2\u8272",
|
|
30
31
|
"Keys manager": "\u5BC6\u94A5\u7BA1\u7406",
|
|
31
32
|
"Created at": "\u521B\u5EFA\u65F6\u95F4",
|
|
32
|
-
"Add API key": "\u6DFB\u52A0 API
|
|
33
|
+
"Add API key": "\u6DFB\u52A0 API \u5BC6\u94A5",
|
|
33
34
|
Never: "\u6C38\u4E0D",
|
|
34
35
|
Custom: "\u81EA\u5B9A\u4E49",
|
|
35
36
|
"Never expires": "\u6C38\u4E0D\u8FC7\u671F",
|
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 NocoBase HTTP API",
|
|
6
6
|
"description.zh-CN": "允许用户使用 API 密钥访问 NocoBase HTTP API",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.15.0-alpha.1",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"devDependencies": {
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"@nocobase/test": "0.x",
|
|
28
28
|
"@nocobase/utils": "0.x"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "8bbeab858a818fbe0a1f954ecf1f61337d06c065"
|
|
31
31
|
}
|