@nocobase/plugin-api-keys 0.12.0-alpha.5 → 0.13.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 -479
- package/dist/collections/api-keys.js +30 -13
- package/dist/collections/index.js +33 -11
- package/dist/constants.js +26 -4
- package/dist/index.js +37 -16
- package/dist/locale/en-US.js +22 -4
- package/dist/locale/fr-FR.js +22 -4
- package/dist/locale/zh-CN.d.ts +1 -0
- package/dist/locale/zh-CN.js +24 -5
- package/dist/locale.js +28 -7
- package/dist/server/actions/api-keys.js +41 -13
- package/dist/server/index.js +33 -11
- package/dist/server/locale/en-US.js +22 -4
- package/dist/server/locale/fr-FR.js +22 -4
- package/dist/server/locale/index.js +38 -18
- package/dist/server/locale/zh-CN.js +22 -4
- package/dist/server/plugin.js +33 -16
- package/dist/swagger/index.d.ts +106 -0
- package/dist/swagger/index.js +130 -0
- package/package.json +2 -2
package/dist/client/index.js
CHANGED
|
@@ -1,483 +1,6 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("@nocobase/client"), require("@formily/react"), require("dayjs"), require("ahooks"), require("antd"), require("react-i18next"), require("@formily/shared")) : typeof define === "function" && define.amd ? define(["exports", "react", "@nocobase/client", "@formily/react", "dayjs", "ahooks", "antd", "react-i18next", "@formily/shared"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["@nocobase/plugin-api-keys"] = {}, global.react, global["@nocobase/client"], global["@formily/react"], global.dayjs, global.ahooks, global.antd, global["react-i18next"], global["@formily/shared"]));
|
|
3
|
-
})(this, function(exports2, require$$0, client, react, dayjs, ahooks, antd, reactI18next, shared) {
|
|
4
|
-
"use strict";
|
|
5
|
-
var jsxRuntime = { exports: {} };
|
|
6
|
-
var reactJsxRuntime_production_min = {};
|
|
7
|
-
/**
|
|
8
|
-
* @license React
|
|
9
|
-
* react-jsx-runtime.production.min.js
|
|
10
|
-
*
|
|
11
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
12
|
-
*
|
|
13
|
-
* This source code is licensed under the MIT license found in the
|
|
14
|
-
* LICENSE file in the root directory of this source tree.
|
|
15
|
-
*/
|
|
16
|
-
var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
|
|
17
|
-
function q(c, a, g) {
|
|
18
|
-
var b, d = {}, e = null, h = null;
|
|
19
|
-
void 0 !== g && (e = "" + g);
|
|
20
|
-
void 0 !== a.key && (e = "" + a.key);
|
|
21
|
-
void 0 !== a.ref && (h = a.ref);
|
|
22
|
-
for (b in a)
|
|
23
|
-
m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
|
|
24
|
-
if (c && c.defaultProps)
|
|
25
|
-
for (b in a = c.defaultProps, a)
|
|
26
|
-
void 0 === d[b] && (d[b] = a[b]);
|
|
27
|
-
return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
|
|
28
|
-
}
|
|
29
|
-
reactJsxRuntime_production_min.Fragment = l;
|
|
30
|
-
reactJsxRuntime_production_min.jsx = q;
|
|
31
|
-
reactJsxRuntime_production_min.jsxs = q;
|
|
32
|
-
{
|
|
33
|
-
jsxRuntime.exports = reactJsxRuntime_production_min;
|
|
34
|
-
}
|
|
35
|
-
var jsxRuntimeExports = jsxRuntime.exports;
|
|
36
|
-
const NAMESPACE = "api-keys";
|
|
37
|
-
function generateNTemplate(key) {
|
|
38
|
-
return `{{t('${key}', { ns: '${NAMESPACE}', nsMode: 'fallback' })}}`;
|
|
39
|
-
}
|
|
40
|
-
const apiKeysCollection = {
|
|
41
|
-
namespace: "api-keys",
|
|
42
|
-
duplicator: "optional",
|
|
43
|
-
name: "apiKeys",
|
|
44
|
-
title: '{{t("API keys")}}',
|
|
45
|
-
sortable: "sort",
|
|
46
|
-
model: "ApiKeyModel",
|
|
47
|
-
createdBy: true,
|
|
48
|
-
updatedAt: false,
|
|
49
|
-
updatedBy: false,
|
|
50
|
-
logging: true,
|
|
51
|
-
fields: [
|
|
52
|
-
{
|
|
53
|
-
name: "id",
|
|
54
|
-
type: "bigInt",
|
|
55
|
-
autoIncrement: true,
|
|
56
|
-
primaryKey: true,
|
|
57
|
-
allowNull: false,
|
|
58
|
-
interface: "id"
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
type: "string",
|
|
62
|
-
name: "name",
|
|
63
|
-
interface: "input",
|
|
64
|
-
uiSchema: {
|
|
65
|
-
type: "string",
|
|
66
|
-
title: '{{t("name")}}',
|
|
67
|
-
"x-component": "Input"
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
interface: "obo",
|
|
72
|
-
type: "belongsTo",
|
|
73
|
-
name: "role",
|
|
74
|
-
target: "roles",
|
|
75
|
-
foreignKey: "roleName",
|
|
76
|
-
uiSchema: {
|
|
77
|
-
type: "object",
|
|
78
|
-
title: '{{t("Roles")}}',
|
|
79
|
-
"x-component": "Select",
|
|
80
|
-
"x-component-props": {
|
|
81
|
-
fieldNames: {
|
|
82
|
-
label: "title",
|
|
83
|
-
value: "name"
|
|
84
|
-
},
|
|
85
|
-
objectValue: true,
|
|
86
|
-
options: "{{ currentRoles }}"
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
name: "expiresIn",
|
|
92
|
-
type: "string",
|
|
93
|
-
uiSchema: {
|
|
94
|
-
type: "string",
|
|
95
|
-
title: generateNTemplate("Expires"),
|
|
96
|
-
"x-component": "ExpiresSelect",
|
|
97
|
-
enum: [
|
|
98
|
-
{
|
|
99
|
-
label: generateNTemplate("1 Day"),
|
|
100
|
-
value: "1d"
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
label: generateNTemplate("7 Days"),
|
|
104
|
-
value: "7d"
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
label: generateNTemplate("30 Days"),
|
|
108
|
-
value: "30d"
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
label: generateNTemplate("90 Days"),
|
|
112
|
-
value: "90d"
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
label: generateNTemplate("Custom"),
|
|
116
|
-
value: "custom"
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
label: generateNTemplate("Never"),
|
|
120
|
-
value: "never"
|
|
121
|
-
}
|
|
122
|
-
]
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
name: "token",
|
|
127
|
-
type: "string",
|
|
128
|
-
hidden: true
|
|
129
|
-
}
|
|
130
|
-
]
|
|
131
|
-
};
|
|
132
|
-
function useTranslation() {
|
|
133
|
-
return reactI18next.useTranslation([NAMESPACE, "client"], {
|
|
134
|
-
nsMode: "fallback"
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
const TOMORROW = dayjs().add(1, "days");
|
|
138
|
-
const spaceCSS = client.css`
|
|
1
|
+
(function(o,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("react/jsx-runtime"),require("@nocobase/client"),require("react"),require("@formily/react"),require("dayjs"),require("ahooks"),require("antd"),require("react-i18next"),require("@formily/shared")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@nocobase/client","react","@formily/react","dayjs","ahooks","antd","react-i18next","@formily/shared"],e):(o=typeof globalThis!="undefined"?globalThis:o||self,e(o["@nocobase/plugin-api-keys"]={},o.jsxRuntime,o["@nocobase/client"],o.react,o["@formily/react"],o.dayjs,o.ahooks,o.antd,o["react-i18next"],o["@formily/shared"]))})(this,function(o,e,t,y,c,u,C,a,i,m){"use strict";var R=Object.defineProperty,W=Object.defineProperties;var $=Object.getOwnPropertyDescriptors;var S=Object.getOwnPropertySymbols;var L=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;var D=(o,e,t)=>e in o?R(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,w=(o,e)=>{for(var t in e||(e={}))L.call(e,t)&&D(o,t,e[t]);if(S)for(var t of S(e))_.call(e,t)&&D(o,t,e[t]);return o},I=(o,e)=>W(o,$(e));var h=(o,e,t)=>new Promise((y,c)=>{var u=i=>{try{a(t.next(i))}catch(m){c(m)}},C=i=>{try{a(t.throw(i))}catch(m){c(m)}},a=i=>i.done?y(i.value):Promise.resolve(i.value).then(u,C);a((t=t.apply(o,e)).next())});const k="api-keys";function r(n){return`{{t('${n}', { ns: '${k}', nsMode: 'fallback' })}}`}const M={namespace:"api-keys",duplicator:"optional",name:"apiKeys",title:'{{t("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 b(){return i.useTranslation([k,"client"],{nsMode:"fallback"})}const K=u().add(1,"days"),q=t.css`
|
|
139
2
|
width: 100%;
|
|
140
3
|
& > .ant-space-item {
|
|
141
4
|
flex: 1;
|
|
142
5
|
}
|
|
143
|
-
`;
|
|
144
|
-
const InternalExpiresSelect = (props) => {
|
|
145
|
-
const { onChange } = props;
|
|
146
|
-
const [isCustom, { toggle: toggleShowDatePicker, setFalse }] = ahooks.useBoolean();
|
|
147
|
-
const onSelectChange = (v) => {
|
|
148
|
-
if (v === "custom") {
|
|
149
|
-
onChange("1d");
|
|
150
|
-
return toggleShowDatePicker();
|
|
151
|
-
} else {
|
|
152
|
-
setFalse();
|
|
153
|
-
onChange(v);
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
const onDatePickerChange = (v) => {
|
|
157
|
-
v = v.millisecond(0).second(0);
|
|
158
|
-
const NOW = dayjs().millisecond(0).second(0);
|
|
159
|
-
const value = `${v.diff(NOW, "d")}d`;
|
|
160
|
-
onChange(value);
|
|
161
|
-
};
|
|
162
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs(antd.Space, { className: spaceCSS, children: [
|
|
163
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(antd.Select, { ...props, value: isCustom ? "custom" : props.value, onChange: onSelectChange }),
|
|
164
|
-
isCustom ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
165
|
-
antd.DatePicker,
|
|
166
|
-
{
|
|
167
|
-
disabledDate: (date) => {
|
|
168
|
-
return date.isSameOrBefore();
|
|
169
|
-
},
|
|
170
|
-
defaultValue: TOMORROW,
|
|
171
|
-
onChange: onDatePickerChange,
|
|
172
|
-
showToday: false,
|
|
173
|
-
allowClear: false
|
|
174
|
-
}
|
|
175
|
-
) : null
|
|
176
|
-
] });
|
|
177
|
-
};
|
|
178
|
-
const ReadPretty = () => {
|
|
179
|
-
const { expiresIn, createdAt } = client.useRecord();
|
|
180
|
-
const { t } = useTranslation();
|
|
181
|
-
const expiresDate = require$$0.useMemo(() => {
|
|
182
|
-
if (expiresIn === "never")
|
|
183
|
-
return t("Never expires");
|
|
184
|
-
return dayjs(createdAt).add((expiresIn == null ? void 0 : expiresIn.replace("d", "")) || 0, "days").format("YYYY-MM-DD HH:mm:ss");
|
|
185
|
-
}, [createdAt, expiresIn]);
|
|
186
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Typography.Text, { children: expiresDate });
|
|
187
|
-
};
|
|
188
|
-
const ExpiresSelect = react.connect(
|
|
189
|
-
InternalExpiresSelect,
|
|
190
|
-
react.mapProps({
|
|
191
|
-
dataSource: "options"
|
|
192
|
-
}),
|
|
193
|
-
react.mapReadPretty(ReadPretty)
|
|
194
|
-
);
|
|
195
|
-
const { useModal } = antd.Modal;
|
|
196
|
-
const useCreateAction = () => {
|
|
197
|
-
const form = react.useForm();
|
|
198
|
-
const { setVisible } = client.useActionContext();
|
|
199
|
-
const { resource, service } = client.useBlockRequestContext();
|
|
200
|
-
const { t } = useTranslation();
|
|
201
|
-
const [modalIns, element] = useModal();
|
|
202
|
-
return {
|
|
203
|
-
async run() {
|
|
204
|
-
var _a, _b;
|
|
205
|
-
await form.submit();
|
|
206
|
-
const response = await resource.create({
|
|
207
|
-
values: form.values
|
|
208
|
-
});
|
|
209
|
-
modalIns.success({
|
|
210
|
-
title: t("API key created successfully"),
|
|
211
|
-
onOk: () => {
|
|
212
|
-
form.reset();
|
|
213
|
-
setVisible(false);
|
|
214
|
-
},
|
|
215
|
-
content: /* @__PURE__ */ jsxRuntimeExports.jsxs(antd.Space, { direction: "vertical", children: [
|
|
216
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
217
|
-
antd.Alert,
|
|
218
|
-
{
|
|
219
|
-
message: t("Make sure to copy your personal access key now as you will not be able to see this again."),
|
|
220
|
-
type: "warning"
|
|
221
|
-
}
|
|
222
|
-
),
|
|
223
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(antd.Typography.Text, { copyable: true, children: (_b = (_a = response.data) == null ? void 0 : _a.data) == null ? void 0 : _b.token })
|
|
224
|
-
] })
|
|
225
|
-
});
|
|
226
|
-
service == null ? void 0 : service.refresh();
|
|
227
|
-
},
|
|
228
|
-
element
|
|
229
|
-
};
|
|
230
|
-
};
|
|
231
|
-
const useDestroyAction = () => {
|
|
232
|
-
const record = client.useRecord();
|
|
233
|
-
const { resource, service } = client.useBlockRequestContext();
|
|
234
|
-
return {
|
|
235
|
-
async run() {
|
|
236
|
-
await resource.destroy({
|
|
237
|
-
filterByTk: record.id
|
|
238
|
-
});
|
|
239
|
-
service.refresh();
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
};
|
|
243
|
-
const configurationSchema = {
|
|
244
|
-
type: "object",
|
|
245
|
-
properties: {
|
|
246
|
-
configuration: {
|
|
247
|
-
type: "void",
|
|
248
|
-
"x-decorator": "TableBlockProvider",
|
|
249
|
-
"x-decorator-props": {
|
|
250
|
-
collection: "apiKeys",
|
|
251
|
-
resource: "apiKeys",
|
|
252
|
-
action: "list",
|
|
253
|
-
params: {
|
|
254
|
-
pageSize: 20,
|
|
255
|
-
appends: ["role"],
|
|
256
|
-
sort: ["-createdAt"]
|
|
257
|
-
},
|
|
258
|
-
rowKey: "name",
|
|
259
|
-
showIndex: true
|
|
260
|
-
},
|
|
261
|
-
"x-component": "CardItem",
|
|
262
|
-
properties: {
|
|
263
|
-
actions: {
|
|
264
|
-
type: "void",
|
|
265
|
-
"x-component": "ActionBar",
|
|
266
|
-
"x-component-props": {
|
|
267
|
-
style: {
|
|
268
|
-
marginBottom: "var(--nb-spacing)"
|
|
269
|
-
}
|
|
270
|
-
},
|
|
271
|
-
properties: {
|
|
272
|
-
create: {
|
|
273
|
-
type: "void",
|
|
274
|
-
"x-action": "create",
|
|
275
|
-
title: generateNTemplate("Add API key"),
|
|
276
|
-
"x-component": "Action",
|
|
277
|
-
"x-component-props": {
|
|
278
|
-
openMode: "drawer",
|
|
279
|
-
type: "primary"
|
|
280
|
-
},
|
|
281
|
-
properties: {
|
|
282
|
-
drawer: {
|
|
283
|
-
type: "void",
|
|
284
|
-
title: generateNTemplate("Add API key"),
|
|
285
|
-
"x-decorator": "Form",
|
|
286
|
-
"x-component": "Action.Modal",
|
|
287
|
-
"x-component-props": {
|
|
288
|
-
maskClosable: false,
|
|
289
|
-
style: {
|
|
290
|
-
maxWidth: "520px",
|
|
291
|
-
width: "100%"
|
|
292
|
-
}
|
|
293
|
-
},
|
|
294
|
-
properties: {
|
|
295
|
-
name: {
|
|
296
|
-
type: "string",
|
|
297
|
-
title: generateNTemplate("Key name"),
|
|
298
|
-
required: true,
|
|
299
|
-
"x-component": "CollectionField",
|
|
300
|
-
"x-decorator": "FormItem"
|
|
301
|
-
},
|
|
302
|
-
role: {
|
|
303
|
-
type: "string",
|
|
304
|
-
title: generateNTemplate("Role"),
|
|
305
|
-
required: true,
|
|
306
|
-
"x-collection-field": "apiKeys.role",
|
|
307
|
-
"x-component": "CollectionField",
|
|
308
|
-
"x-decorator": "FormItem"
|
|
309
|
-
},
|
|
310
|
-
expiresIn: {
|
|
311
|
-
type: "string",
|
|
312
|
-
title: generateNTemplate("Expiration"),
|
|
313
|
-
required: true,
|
|
314
|
-
"x-component": "CollectionField",
|
|
315
|
-
"x-decorator": "FormItem",
|
|
316
|
-
default: "30d"
|
|
317
|
-
},
|
|
318
|
-
footer: {
|
|
319
|
-
type: "void",
|
|
320
|
-
"x-component": "Action.Modal.Footer",
|
|
321
|
-
properties: {
|
|
322
|
-
cancel: {
|
|
323
|
-
title: '{{t("Cancel")}}',
|
|
324
|
-
"x-component": "Action",
|
|
325
|
-
"x-component-props": {
|
|
326
|
-
useAction: "{{ cm.useCancelAction }}"
|
|
327
|
-
}
|
|
328
|
-
},
|
|
329
|
-
submit: {
|
|
330
|
-
title: '{{t("Submit")}}',
|
|
331
|
-
"x-component": "Action",
|
|
332
|
-
"x-component-props": {
|
|
333
|
-
type: "primary",
|
|
334
|
-
useAction: useCreateAction
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
},
|
|
342
|
-
"x-align": "right"
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
},
|
|
346
|
-
[shared.uid()]: {
|
|
347
|
-
type: "array",
|
|
348
|
-
"x-component": "TableV2",
|
|
349
|
-
"x-component-props": {
|
|
350
|
-
rowKey: "id",
|
|
351
|
-
useProps: "{{ useTableBlockProps }}"
|
|
352
|
-
},
|
|
353
|
-
properties: {
|
|
354
|
-
column1: {
|
|
355
|
-
type: "void",
|
|
356
|
-
"x-decorator": "TableV2.Column.Decorator",
|
|
357
|
-
"x-component": "TableV2.Column",
|
|
358
|
-
title: generateNTemplate("Key name"),
|
|
359
|
-
properties: {
|
|
360
|
-
name: {
|
|
361
|
-
type: "string",
|
|
362
|
-
"x-component": "CollectionField",
|
|
363
|
-
"x-read-pretty": true
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
},
|
|
367
|
-
column2: {
|
|
368
|
-
type: "void",
|
|
369
|
-
"x-decorator": "TableV2.Column.Decorator",
|
|
370
|
-
"x-component": "TableV2.Column",
|
|
371
|
-
title: generateNTemplate("Role"),
|
|
372
|
-
properties: {
|
|
373
|
-
role: {
|
|
374
|
-
type: "object",
|
|
375
|
-
"x-collection-field": "apiKeys.role",
|
|
376
|
-
"x-component": "CollectionField",
|
|
377
|
-
"x-component-props": {
|
|
378
|
-
enableLink: false
|
|
379
|
-
},
|
|
380
|
-
"x-read-pretty": true
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
},
|
|
384
|
-
column3: {
|
|
385
|
-
type: "void",
|
|
386
|
-
"x-decorator": "TableV2.Column.Decorator",
|
|
387
|
-
"x-component": "TableV2.Column",
|
|
388
|
-
title: generateNTemplate("Expiration"),
|
|
389
|
-
properties: {
|
|
390
|
-
expiresIn: {
|
|
391
|
-
type: "string",
|
|
392
|
-
"x-component": "CollectionField",
|
|
393
|
-
"x-read-pretty": true
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
},
|
|
397
|
-
column4: {
|
|
398
|
-
type: "void",
|
|
399
|
-
"x-decorator": "TableV2.Column.Decorator",
|
|
400
|
-
"x-component": "TableV2.Column",
|
|
401
|
-
title: generateNTemplate("Created at"),
|
|
402
|
-
properties: {
|
|
403
|
-
createdAt: {
|
|
404
|
-
type: "date",
|
|
405
|
-
// 'x-component': 'CollectionField',
|
|
406
|
-
"x-component": "DatePicker",
|
|
407
|
-
"x-component-props": {
|
|
408
|
-
format: "YYYY-MM-DD HH:mm:ss"
|
|
409
|
-
},
|
|
410
|
-
"x-read-pretty": true
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
},
|
|
414
|
-
actionColumn: {
|
|
415
|
-
type: "void",
|
|
416
|
-
title: '{{ t("Actions") }}',
|
|
417
|
-
"x-action-column": "actions",
|
|
418
|
-
"x-decorator": "TableV2.Column.ActionBar",
|
|
419
|
-
"x-component": "TableV2.Column",
|
|
420
|
-
properties: {
|
|
421
|
-
columnActions: {
|
|
422
|
-
type: "void",
|
|
423
|
-
"x-component": "Space",
|
|
424
|
-
"x-component-props": {
|
|
425
|
-
split: "|"
|
|
426
|
-
},
|
|
427
|
-
properties: {
|
|
428
|
-
delete: {
|
|
429
|
-
type: "void",
|
|
430
|
-
title: '{{ t("Delete") }}',
|
|
431
|
-
"x-component": "Action.Link",
|
|
432
|
-
"x-component-props": {
|
|
433
|
-
confirm: {
|
|
434
|
-
title: generateNTemplate("Delete API key"),
|
|
435
|
-
content: "{{t('Are you sure you want to delete it?')}}"
|
|
436
|
-
},
|
|
437
|
-
useAction: useDestroyAction
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
};
|
|
450
|
-
const Configuration = () => {
|
|
451
|
-
const currentRoles = client.useCurrentRoles();
|
|
452
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(client.CollectionManagerProvider, { collections: [apiKeysCollection], children: /* @__PURE__ */ jsxRuntimeExports.jsx(client.SchemaComponentOptions, { scope: { currentRoles }, components: { ExpiresSelect }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(react.RecursionField, { schema: configurationSchema }) }) });
|
|
453
|
-
};
|
|
454
|
-
const ApiKeysProvider = require$$0.memo((props) => {
|
|
455
|
-
const { t } = useTranslation();
|
|
456
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
457
|
-
client.SettingsCenterProvider,
|
|
458
|
-
{
|
|
459
|
-
settings: {
|
|
460
|
-
["api-keys"]: {
|
|
461
|
-
title: t("API keys"),
|
|
462
|
-
icon: "EnvironmentOutlined",
|
|
463
|
-
tabs: {
|
|
464
|
-
configuration: {
|
|
465
|
-
title: t("Keys manager"),
|
|
466
|
-
component: Configuration
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
},
|
|
471
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(client.SchemaComponentOptions, { components: {}, children: props.children })
|
|
472
|
-
}
|
|
473
|
-
);
|
|
474
|
-
});
|
|
475
|
-
ApiKeysProvider.displayName = "ApiKeysProvider";
|
|
476
|
-
class APIKeysPlugin extends client.Plugin {
|
|
477
|
-
async load() {
|
|
478
|
-
this.app.addProvider(ApiKeysProvider);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
exports2.default = APIKeysPlugin;
|
|
482
|
-
Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
483
|
-
});
|
|
6
|
+
`,F=n=>{const{onChange:s}=n,[l,{toggle:d,setFalse:x}]=C.useBoolean(),g=p=>{if(p==="custom")return s("1d"),d();x(),s(p)},A=p=>{p=p.millisecond(0).second(0);const v=u().millisecond(0).second(0),f=`${p.diff(v,"d")}d`;s(f)};return e.jsxs(a.Space,{className:q,children:[e.jsx(a.Select,I(w({},n),{value:l?"custom":n.value,onChange:g})),l?e.jsx(a.DatePicker,{disabledDate:p=>p.isSameOrBefore(),defaultValue:K,onChange:A,showToday:!1,allowClear:!1}):null]})},V=()=>{const{expiresIn:n,createdAt:s}=t.useRecord(),{t:l}=b(),d=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 e.jsx(a.Typography.Text,{children:d})},B=c.connect(F,c.mapProps({dataSource:"options"}),c.mapReadPretty(V)),{useModal:j}=a.Modal,N=()=>{const n=c.useForm(),{setVisible:s}=t.useActionContext(),{resource:l,service:d}=t.useBlockRequestContext(),{t:x}=b(),[g,A]=j();return{run(){return h(this,null,function*(){var f,P;yield n.submit();const v=yield l.create({values:n.values});g.success({title:x("API key created successfully"),onOk:()=>{n.reset(),s(!1)},content:e.jsxs(a.Space,{direction:"vertical",children:[e.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"}),e.jsx(a.Typography.Text,{copyable:!0,children:(P=(f=v.data)==null?void 0:f.data)==null?void 0:P.token})]})}),d==null||d.refresh()})},element:A}},O=()=>{const n=t.useRecord(),{resource:s,service:l}=t.useBlockRequestContext();return{run(){return h(this,null,function*(){yield s.destroy({filterByTk:n.id}),l.refresh()})}}},E={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:N}}}}}}},"x-align":"right"}}},[m.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:O}}}}}}}}}}}},Y=()=>{const n=t.useCurrentRoles();return e.jsx(t.CollectionManagerProvider,{collections:[M],children:e.jsx(t.SchemaComponentOptions,{scope:{currentRoles:n},components:{ExpiresSelect:B},children:e.jsx(c.RecursionField,{schema:E})})})},T=y.memo(n=>{const{t:s}=b();return e.jsx(t.SettingsCenterProvider,{settings:{"api-keys":{title:s("API keys"),icon:"EnvironmentOutlined",tabs:{configuration:{title:s("Keys manager"),component:Y}}}},children:e.jsx(t.SchemaComponentOptions,{components:{},children:n.children})})});T.displayName="ApiKeysProvider";class H extends t.Plugin{load(){return h(this,null,function*(){this.app.addProvider(T)})}}o.default=H,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -1,7 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
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 api_keys_exports = {};
|
|
19
|
+
__export(api_keys_exports, {
|
|
20
|
+
default: () => api_keys_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(api_keys_exports);
|
|
23
|
+
var import_locale = require("../locale");
|
|
5
24
|
var api_keys_default = {
|
|
6
25
|
namespace: "api-keys",
|
|
7
26
|
duplicator: "optional",
|
|
@@ -57,31 +76,31 @@ var api_keys_default = {
|
|
|
57
76
|
type: "string",
|
|
58
77
|
uiSchema: {
|
|
59
78
|
type: "string",
|
|
60
|
-
title:
|
|
79
|
+
title: (0, import_locale.generateNTemplate)("Expires"),
|
|
61
80
|
"x-component": "ExpiresSelect",
|
|
62
81
|
enum: [
|
|
63
82
|
{
|
|
64
|
-
label:
|
|
83
|
+
label: (0, import_locale.generateNTemplate)("1 Day"),
|
|
65
84
|
value: "1d"
|
|
66
85
|
},
|
|
67
86
|
{
|
|
68
|
-
label:
|
|
87
|
+
label: (0, import_locale.generateNTemplate)("7 Days"),
|
|
69
88
|
value: "7d"
|
|
70
89
|
},
|
|
71
90
|
{
|
|
72
|
-
label:
|
|
91
|
+
label: (0, import_locale.generateNTemplate)("30 Days"),
|
|
73
92
|
value: "30d"
|
|
74
93
|
},
|
|
75
94
|
{
|
|
76
|
-
label:
|
|
95
|
+
label: (0, import_locale.generateNTemplate)("90 Days"),
|
|
77
96
|
value: "90d"
|
|
78
97
|
},
|
|
79
98
|
{
|
|
80
|
-
label:
|
|
99
|
+
label: (0, import_locale.generateNTemplate)("Custom"),
|
|
81
100
|
value: "custom"
|
|
82
101
|
},
|
|
83
102
|
{
|
|
84
|
-
label:
|
|
103
|
+
label: (0, import_locale.generateNTemplate)("Never"),
|
|
85
104
|
value: "never"
|
|
86
105
|
}
|
|
87
106
|
]
|
|
@@ -94,5 +113,3 @@ var api_keys_default = {
|
|
|
94
113
|
}
|
|
95
114
|
]
|
|
96
115
|
};
|
|
97
|
-
|
|
98
|
-
module.exports = api_keys_default;
|
|
@@ -1,11 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var collections_exports = {};
|
|
29
|
+
__export(collections_exports, {
|
|
30
|
+
default: () => import_api_keys.default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(collections_exports);
|
|
33
|
+
var import_api_keys = __toESM(require("./api-keys"));
|
package/dist/constants.js
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 constants_exports = {};
|
|
19
|
+
__export(constants_exports, {
|
|
20
|
+
NAMESPACE: () => NAMESPACE
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(constants_exports);
|
|
3
23
|
const NAMESPACE = "api-keys";
|
|
4
|
-
|
|
5
|
-
exports
|
|
24
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
25
|
+
0 && (module.exports = {
|
|
26
|
+
NAMESPACE
|
|
27
|
+
});
|