@nocobase/plugin-api-keys 0.18.0-alpha.9 → 0.19.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.
- package/dist/client/index.js +2 -2
- package/dist/collections/{api-keys.js → apiKeys.js} +9 -9
- package/dist/externalVersion.js +5 -5
- package/dist/locale/ko_KR.json +21 -0
- package/dist/server/collections/apiKeys.d.ts +2 -0
- package/dist/{collections/index.js → server/collections/apiKeys.js} +6 -5
- package/dist/server/plugin.js +1 -3
- package/package.json +11 -6
- package/dist/collections/index.d.ts +0 -1
- /package/dist/collections/{api-keys.d.ts → apiKeys.d.ts} +0 -0
package/dist/client/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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,
|
|
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,s,d,m,i,y){"use strict";var Y=Object.defineProperty,H=Object.defineProperties;var W=Object.getOwnPropertyDescriptors;var S=Object.getOwnPropertySymbols;var $=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var D=(t,e,o)=>e in t?Y(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,P=(t,e)=>{for(var o in e||(e={}))$.call(e,o)&&D(t,o,e[o]);if(S)for(var o of S(e))L.call(e,o)&&D(t,o,e[o]);return t},w=(t,e)=>H(t,W(e));var C=(t,e,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(t,e)).next())});const h="api-keys";function r(n){return`{{t('${n}', { ns: '${h}', nsMode: 'fallback' })}}`}const M={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}]};function v(){return i.useTranslation([h,"client"],{nsMode:"fallback"})}const I=d().add(1,"days"),q=e.css`
|
|
2
2
|
width: 100%;
|
|
3
3
|
& > .ant-space-item {
|
|
4
4
|
flex: 1;
|
|
5
5
|
}
|
|
6
|
-
`,
|
|
6
|
+
`,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)},A=l=>{l=l.millisecond(0).second(0);const k=d().millisecond(0).second(0),g=`${l.diff(k,"d")}d`;a(g)};return o.jsxs(s.Space,{className:q,children:[o.jsx(s.Select,w(P({},n),{value:c?"custom":n.value,onChange:b})),c?o.jsx(s.DatePicker,{disabledDate:l=>l.isSameOrBefore(),defaultValue:I,onChange:A,showToday:!1,allowClear:!1}):null]})},K=()=>{const{expiresIn:n,createdAt:a}=e.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)),{useModal:B}=s.Modal,j=()=>{const n=p.useForm(),{setVisible:a}=e.useActionContext(),{resource:c,service:u}=e.useBlockRequestContext(),{t:f}=v(),[b,A]=B();return{run(){return C(this,null,function*(){var g,T;yield n.submit();const k=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:(T=(g=k.data)==null?void 0:g.data)==null?void 0:T.token})]})}),u==null||u.refresh()})},element:A}},N=()=>{const n=e.useRecord(),{resource:a,service:c}=e.useBlockRequestContext();return{run(){return C(this,null,function*(){yield a.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 R extends e.Plugin{load(){return C(this,null,function*(){this.app.pluginSettingsManager.add(h,{icon:"KeyOutlined",title:'{{t("API keys", {"ns": "api-keys"})}}',Component:E,aclSnippet:"pm.api-keys.configuration"})})}}t.default=R,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -15,19 +15,19 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var
|
|
19
|
-
__export(
|
|
20
|
-
default: () =>
|
|
18
|
+
var apiKeys_exports = {};
|
|
19
|
+
__export(apiKeys_exports, {
|
|
20
|
+
default: () => apiKeys_default
|
|
21
21
|
});
|
|
22
|
-
module.exports = __toCommonJS(
|
|
22
|
+
module.exports = __toCommonJS(apiKeys_exports);
|
|
23
23
|
var import_locale = require("../locale");
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
var apiKeys_default = {
|
|
25
|
+
dumpRules: {
|
|
26
|
+
group: "user"
|
|
27
|
+
},
|
|
28
|
+
shared: true,
|
|
27
29
|
name: "apiKeys",
|
|
28
|
-
title: '{{t("API keys", {"ns": "api-keys"})}}',
|
|
29
30
|
sortable: "sort",
|
|
30
|
-
model: "ApiKeyModel",
|
|
31
31
|
createdBy: true,
|
|
32
32
|
updatedAt: false,
|
|
33
33
|
updatedBy: false,
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
"@nocobase/client": "0.
|
|
3
|
-
"@nocobase/database": "0.
|
|
4
|
-
"@nocobase/server": "0.
|
|
2
|
+
"@nocobase/client": "0.19.0-alpha.10",
|
|
3
|
+
"@nocobase/database": "0.19.0-alpha.10",
|
|
4
|
+
"@nocobase/server": "0.19.0-alpha.10",
|
|
5
5
|
"@formily/react": "2.3.0",
|
|
6
6
|
"ahooks": "3.7.8",
|
|
7
|
-
"antd": "5.12.
|
|
7
|
+
"antd": "5.12.8",
|
|
8
8
|
"dayjs": "1.11.10",
|
|
9
9
|
"react": "18.2.0",
|
|
10
10
|
"@formily/shared": "2.3.0",
|
|
11
11
|
"react-i18next": "11.18.6",
|
|
12
|
-
"@nocobase/actions": "0.
|
|
12
|
+
"@nocobase/actions": "0.19.0-alpha.10"
|
|
13
13
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"API keys": "API 키",
|
|
3
|
+
"API key created successfully": "API 키가 성공적으로 생성되었습니다",
|
|
4
|
+
"Make sure to copy your personal access key now as you will not be able to see this again.": "이제 개인 액세스 키를 복사해두십시오. 이후에는 다시 확인할 수 없습니다.",
|
|
5
|
+
"Key name": "키 이름",
|
|
6
|
+
"Expiration": "만료",
|
|
7
|
+
"Delete API key": "API 키 삭제",
|
|
8
|
+
"Role": "역할",
|
|
9
|
+
"Keys manager": "키 관리자",
|
|
10
|
+
"Created at": "생성일",
|
|
11
|
+
"Add API key": "API 키 추가",
|
|
12
|
+
"Never": "영원히",
|
|
13
|
+
"Custom": "사용자 설정",
|
|
14
|
+
"Never expires": "만료되지 않음",
|
|
15
|
+
"1 Day": "1 일",
|
|
16
|
+
"7 Days": "7 일",
|
|
17
|
+
"30 Days": "30 일",
|
|
18
|
+
"90 Days": "90 일",
|
|
19
|
+
"Role not found": "역할을 찾을 수 없음",
|
|
20
|
+
"Allow only your own roles to be selected": "자신의 역할만 선택할 수 있도록 허용"
|
|
21
|
+
}
|
|
@@ -25,9 +25,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
mod
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var
|
|
29
|
-
__export(
|
|
30
|
-
default: () =>
|
|
28
|
+
var apiKeys_exports = {};
|
|
29
|
+
__export(apiKeys_exports, {
|
|
30
|
+
default: () => apiKeys_default
|
|
31
31
|
});
|
|
32
|
-
module.exports = __toCommonJS(
|
|
33
|
-
var
|
|
32
|
+
module.exports = __toCommonJS(apiKeys_exports);
|
|
33
|
+
var import_apiKeys = __toESM(require("../../collections/apiKeys"));
|
|
34
|
+
var apiKeys_default = import_apiKeys.default;
|
package/dist/server/plugin.js
CHANGED
|
@@ -47,9 +47,7 @@ class ApiKeysPlugin extends import_server.Plugin {
|
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
async load() {
|
|
50
|
-
await this.
|
|
51
|
-
directory: (0, import_path.resolve)(__dirname, "../collections")
|
|
52
|
-
});
|
|
50
|
+
await this.importCollections((0, import_path.resolve)(__dirname, "../collections"));
|
|
53
51
|
this.app.resourcer.use(async (ctx, next) => {
|
|
54
52
|
const { resourceName, actionName } = ctx.action.params;
|
|
55
53
|
if (resourceName == this.resourceName && ["list", "destroy"].includes(actionName)) {
|
package/package.json
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-api-keys",
|
|
3
|
-
"displayName": "API keys",
|
|
4
|
-
"displayName.zh-CN": "API 密钥",
|
|
5
|
-
"description": "Allows users to use API key to access
|
|
6
|
-
"description.zh-CN": "允许用户使用 API
|
|
7
|
-
"version": "0.
|
|
3
|
+
"displayName": "Auth: API keys",
|
|
4
|
+
"displayName.zh-CN": "认证:API 密钥",
|
|
5
|
+
"description": "Allows users to use API key to access application's HTTP API",
|
|
6
|
+
"description.zh-CN": "允许用户使用 API 密钥访问应用的 HTTP API",
|
|
7
|
+
"version": "0.19.0-alpha.10",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
|
+
"homepage": "https://docs.nocobase.com/plugins/api-keys",
|
|
11
|
+
"homepage.zh-CN": "https://docs-cn.nocobase.com/plugins/api-keys",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"Authentication"
|
|
14
|
+
],
|
|
10
15
|
"devDependencies": {
|
|
11
16
|
"@formily/react": "2.x",
|
|
12
17
|
"@formily/shared": "2.x",
|
|
@@ -27,5 +32,5 @@
|
|
|
27
32
|
"@nocobase/test": "0.x",
|
|
28
33
|
"@nocobase/utils": "0.x"
|
|
29
34
|
},
|
|
30
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "d09d81eba67339da36bcec27939a85b35d180770"
|
|
31
36
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './api-keys';
|
|
File without changes
|