@tachybase/plugin-api-keys 0.23.58 → 1.0.18
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 +1 -1
- package/dist/collections/apiKeys.js +1 -1
- package/dist/externalVersion.js +5 -5
- package/dist/server/migrations/20250403220209-token-text-type.d.ts +6 -0
- package/dist/server/migrations/20250403220209-token-text-type.js +39 -0
- package/dist/server/plugin.js +1 -1
- package/package.json +9 -9
package/dist/client/index.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
& > .ant-space-item {
|
|
4
4
|
flex: 1;
|
|
5
5
|
}
|
|
6
|
-
`,F=n=>{const{onChange:s}=n,[l,{toggle:m,setFalse:x}]=h.useBoolean(),
|
|
6
|
+
`,F=n=>{const{onChange:s}=n,[l,{toggle:m,setFalse:x}]=h.useBoolean(),C=p=>{if(p==="custom")return s("1d"),m();x(),s(p)},g=p=>{p=p.millisecond(0).second(0);const A=u().millisecond(0).second(0),f=`${p.diff(A,"d")}d`;s(f)};return o.jsxs(a.Space,{className:M,children:[o.jsx(a.Select,w(D({},n),{value:l?"custom":n.value,onChange:C})),l?o.jsx(a.DatePicker,{disabledDate:p=>p.isSameOrBefore(),defaultValue:I,onChange:g,showToday:!1,allowClear:!1}):null]})},K=()=>{const{expiresIn:n,createdAt:s}=e.useRecord(),{t:l}=k(),m=y.useMemo(()=>n==="never"?l("Never expires"):u(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:m})},V=i.connect(F,i.mapProps({dataSource:"options"}),i.mapReadPretty(K));function r(n){return`{{t('${n}', { ns: '${d}', nsMode: 'fallback' })}}`}const q={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:"text",hidden:!0},{name:"accessToken",type:"string",hidden:!0}]},{useModal:B}=a.Modal,j=()=>{const n=i.useForm(),{setVisible:s}=e.useActionContext(),{resource:l,service:m}=e.useBlockRequestContext(),{t:x}=k(),[C,g]=B();return{run(){return b(this,null,function*(){var f,T;yield n.submit();const A=yield l.create({values:n.values});C.success({title:x("API key created successfully"),onOk:()=>{n.reset(),s(!1)},content:o.jsxs(a.Space,{direction:"vertical",children:[o.jsx(a.Alert,{message:x("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=(f=A.data)==null?void 0:f.data)==null?void 0:T.token})]})}),m==null||m.refresh()})},element:g}},O=()=>{const n=e.useRecord(),{resource:s,service:l}=e.useBlockRequestContext();return{run(){return b(this,null,function*(){yield s.destroy({filterByTk:n.id}),l.refresh()})}}},N={type:"object",properties:{configuration:{type:"void","x-decorator":"TableBlockProvider","x-decorator-props":{collection:q,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(--tb-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:j}}}}}}},"x-align":"right"}}},[i.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:O}}}}}}}}}}}},R=()=>{const n=e.useCurrentRoles();return o.jsx(e.SchemaComponentOptions,{scope:{currentRoles:n},components:{ExpiresSelect:V},children:o.jsx(i.RecursionField,{schema:N})})};class v extends e.Plugin{load(){return b(this,null,function*(){this.userSettingsManager.add(d,{icon:"KeyOutlined",title:this.t("API keys"),Component:R,aclSnippet:"pm.api-keys.configuration"})})}}t.PluginAPIKeysClient=v,t.default=v,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
"@tachybase/client": "0.
|
|
3
|
-
"@tachybase/database": "0.
|
|
4
|
-
"@tachybase/server": "0.
|
|
2
|
+
"@tachybase/client": "1.0.18",
|
|
3
|
+
"@tachybase/database": "1.0.18",
|
|
4
|
+
"@tachybase/server": "1.0.18",
|
|
5
5
|
"react": "18.3.1",
|
|
6
|
-
"@tachybase/schema": "0.
|
|
6
|
+
"@tachybase/schema": "1.0.18",
|
|
7
7
|
"ahooks": "3.8.4",
|
|
8
8
|
"antd": "5.22.5",
|
|
9
9
|
"dayjs": "1.11.13",
|
|
10
10
|
"react-i18next": "15.2.0",
|
|
11
|
-
"@tachybase/actions": "0.
|
|
11
|
+
"@tachybase/actions": "1.0.18"
|
|
12
12
|
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var token_text_type_exports = {};
|
|
19
|
+
__export(token_text_type_exports, {
|
|
20
|
+
default: () => token_text_type_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(token_text_type_exports);
|
|
23
|
+
var import_database = require("@tachybase/database");
|
|
24
|
+
var import_server = require("@tachybase/server");
|
|
25
|
+
class token_text_type_default extends import_server.Migration {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
this.on = "afterLoad";
|
|
29
|
+
// 'beforeLoad' or 'afterLoad'
|
|
30
|
+
this.appVersion = "<1.0.10";
|
|
31
|
+
}
|
|
32
|
+
async up() {
|
|
33
|
+
const queryInterface = this.db.sequelize.getQueryInterface();
|
|
34
|
+
await queryInterface.changeColumn("apiKeys", "token", {
|
|
35
|
+
type: import_database.DataTypes.TEXT
|
|
36
|
+
});
|
|
37
|
+
this.app.logger.info("change apiKeys token form string to text success!");
|
|
38
|
+
}
|
|
39
|
+
}
|
package/dist/server/plugin.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/plugin-api-keys",
|
|
3
3
|
"displayName": "Auth: API keys",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.18",
|
|
5
5
|
"description": "Allows users to use API key to access application's HTTP API",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"Authentication"
|
|
@@ -16,16 +16,16 @@
|
|
|
16
16
|
"react": "^18.3.1",
|
|
17
17
|
"react-dom": "^18.3.1",
|
|
18
18
|
"react-i18next": "^15.2.0",
|
|
19
|
-
"@tachybase/schema": "0.
|
|
19
|
+
"@tachybase/schema": "1.0.18"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"@tachybase/actions": "0.
|
|
23
|
-
"@tachybase/client": "0.
|
|
24
|
-
"@tachybase/
|
|
25
|
-
"@tachybase/server": "0.
|
|
26
|
-
"@tachybase/
|
|
27
|
-
"@tachybase/test": "0.
|
|
28
|
-
"@tachybase/utils": "0.
|
|
22
|
+
"@tachybase/actions": "1.0.18",
|
|
23
|
+
"@tachybase/client": "1.0.18",
|
|
24
|
+
"@tachybase/resourcer": "1.0.18",
|
|
25
|
+
"@tachybase/server": "1.0.18",
|
|
26
|
+
"@tachybase/database": "1.0.18",
|
|
27
|
+
"@tachybase/test": "1.0.18",
|
|
28
|
+
"@tachybase/utils": "1.0.18"
|
|
29
29
|
},
|
|
30
30
|
"description.zh-CN": "允许用户使用 API 密钥访问应用的 HTTP API",
|
|
31
31
|
"displayName.zh-CN": "认证:API 密钥",
|