@nocobase/plugin-api-keys 0.11.1-alpha.5 → 0.12.0-alpha.2
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.d.ts +2 -2
- package/client.js +1 -1
- package/dist/client/index.js +483 -0
- package/dist/collections/api-keys.js +98 -0
- package/dist/collections/index.d.ts +1 -0
- package/dist/collections/index.js +11 -0
- package/dist/constants.js +5 -0
- package/{lib → dist}/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/locale/en-US.js +6 -0
- package/dist/locale/fr-FR.js +6 -0
- package/dist/locale/zh-CN.js +24 -0
- package/dist/locale.js +9 -0
- package/dist/server/actions/api-keys.js +51 -0
- package/dist/server/index.js +11 -0
- package/dist/server/locale/en-US.js +5 -0
- package/dist/server/locale/fr-FR.js +5 -0
- package/dist/server/locale/index.js +20 -0
- package/dist/server/locale/zh-CN.js +7 -0
- package/dist/server/plugin.js +48 -0
- package/docs/en-US/changelog.md +1 -0
- package/docs/en-US/index.md +9 -0
- package/docs/en-US/tabs.json +14 -0
- package/docs/en-US/usage.md +19 -0
- package/docs/zh-CN/changelog.md +1 -0
- package/docs/zh-CN/index.md +10 -0
- package/docs/zh-CN/tabs.json +14 -0
- package/docs/zh-CN/usage.md +19 -0
- package/package.json +19 -27
- package/server.d.ts +2 -3
- package/server.js +1 -30
- package/lib/client/Configuration/ExpiresSelect.js +0 -130
- package/lib/client/Configuration/index.js +0 -47
- package/lib/client/Configuration/roles.js +0 -20
- package/lib/client/Configuration/schema.js +0 -319
- package/lib/client/index.js +0 -56
- package/lib/client/locale/index.js +0 -32
- package/lib/collections/api-keys.js +0 -87
- package/lib/collections/index.d.ts +0 -1
- package/lib/collections/index.js +0 -13
- package/lib/constants.js +0 -8
- package/lib/index.js +0 -13
- package/lib/locale/en-US.js +0 -9
- package/lib/locale/fr-FR.js +0 -9
- package/lib/locale/zh-CN.js +0 -27
- package/lib/locale.js +0 -10
- package/lib/server/actions/api-keys.js +0 -71
- package/lib/server/index.js +0 -13
- package/lib/server/locale/en-US.js +0 -8
- package/lib/server/locale/fr-FR.js +0 -8
- package/lib/server/locale/index.js +0 -20
- package/lib/server/locale/zh-CN.js +0 -10
- package/lib/server/plugin.js +0 -77
- package/src/client/Configuration/ExpiresSelect.tsx +0 -80
- package/src/client/Configuration/index.tsx +0 -18
- package/src/client/Configuration/roles.ts +0 -9
- package/src/client/Configuration/schema.tsx +0 -264
- package/src/client/index.tsx +0 -35
- package/src/client/locale/index.ts +0 -13
- package/src/collections/api-keys.ts +0 -95
- package/src/collections/index.ts +0 -1
- package/src/constants.ts +0 -1
- package/src/index.ts +0 -1
- package/src/locale/en-US.ts +0 -3
- package/src/locale/fr-FR.ts +0 -3
- package/src/locale/zh-CN.ts +0 -22
- package/src/locale.ts +0 -5
- package/src/server/__tests__/actions.test.ts +0 -181
- package/src/server/actions/api-keys.ts +0 -49
- package/src/server/index.ts +0 -1
- package/src/server/locale/en-US.ts +0 -1
- package/src/server/locale/fr-FR.ts +0 -1
- package/src/server/locale/index.ts +0 -2
- package/src/server/locale/zh-CN.ts +0 -3
- package/src/server/plugin.ts +0 -53
- /package/{lib → dist}/client/Configuration/ExpiresSelect.d.ts +0 -0
- /package/{lib → dist}/client/Configuration/index.d.ts +0 -0
- /package/{lib → dist}/client/Configuration/roles.d.ts +0 -0
- /package/{lib → dist}/client/Configuration/schema.d.ts +0 -0
- /package/{lib → dist}/client/index.d.ts +0 -0
- /package/{lib → dist}/client/locale/index.d.ts +0 -0
- /package/{lib → dist}/collections/api-keys.d.ts +0 -0
- /package/{lib → dist}/constants.d.ts +0 -0
- /package/{lib → dist}/locale/en-US.d.ts +0 -0
- /package/{lib → dist}/locale/fr-FR.d.ts +0 -0
- /package/{lib → dist}/locale/zh-CN.d.ts +0 -0
- /package/{lib → dist}/locale.d.ts +0 -0
- /package/{lib → dist}/server/actions/api-keys.d.ts +0 -0
- /package/{lib → dist}/server/index.d.ts +0 -0
- /package/{lib → dist}/server/locale/en-US.d.ts +0 -0
- /package/{lib → dist}/server/locale/fr-FR.d.ts +0 -0
- /package/{lib → dist}/server/locale/index.d.ts +0 -0
- /package/{lib → dist}/server/locale/zh-CN.d.ts +0 -0
- /package/{lib → dist}/server/plugin.d.ts +0 -0
package/client.d.ts
CHANGED
package/client.js
CHANGED
|
@@ -4,7 +4,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
4
4
|
|
|
5
5
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
6
6
|
|
|
7
|
-
var _index = _interopRequireWildcard(require("./
|
|
7
|
+
var _index = _interopRequireWildcard(require("./dist/client"));
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", {
|
|
10
10
|
value: true
|
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
(function(global, factory) {
|
|
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`
|
|
139
|
+
width: 100%;
|
|
140
|
+
& > .ant-space-item {
|
|
141
|
+
flex: 1;
|
|
142
|
+
}
|
|
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
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var locale = require('../locale');
|
|
4
|
+
|
|
5
|
+
var api_keys_default = {
|
|
6
|
+
namespace: "api-keys",
|
|
7
|
+
duplicator: "optional",
|
|
8
|
+
name: "apiKeys",
|
|
9
|
+
title: '{{t("API keys")}}',
|
|
10
|
+
sortable: "sort",
|
|
11
|
+
model: "ApiKeyModel",
|
|
12
|
+
createdBy: true,
|
|
13
|
+
updatedAt: false,
|
|
14
|
+
updatedBy: false,
|
|
15
|
+
logging: true,
|
|
16
|
+
fields: [
|
|
17
|
+
{
|
|
18
|
+
name: "id",
|
|
19
|
+
type: "bigInt",
|
|
20
|
+
autoIncrement: true,
|
|
21
|
+
primaryKey: true,
|
|
22
|
+
allowNull: false,
|
|
23
|
+
interface: "id"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: "string",
|
|
27
|
+
name: "name",
|
|
28
|
+
interface: "input",
|
|
29
|
+
uiSchema: {
|
|
30
|
+
type: "string",
|
|
31
|
+
title: '{{t("name")}}',
|
|
32
|
+
"x-component": "Input"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
interface: "obo",
|
|
37
|
+
type: "belongsTo",
|
|
38
|
+
name: "role",
|
|
39
|
+
target: "roles",
|
|
40
|
+
foreignKey: "roleName",
|
|
41
|
+
uiSchema: {
|
|
42
|
+
type: "object",
|
|
43
|
+
title: '{{t("Roles")}}',
|
|
44
|
+
"x-component": "Select",
|
|
45
|
+
"x-component-props": {
|
|
46
|
+
fieldNames: {
|
|
47
|
+
label: "title",
|
|
48
|
+
value: "name"
|
|
49
|
+
},
|
|
50
|
+
objectValue: true,
|
|
51
|
+
options: "{{ currentRoles }}"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "expiresIn",
|
|
57
|
+
type: "string",
|
|
58
|
+
uiSchema: {
|
|
59
|
+
type: "string",
|
|
60
|
+
title: locale.generateNTemplate("Expires"),
|
|
61
|
+
"x-component": "ExpiresSelect",
|
|
62
|
+
enum: [
|
|
63
|
+
{
|
|
64
|
+
label: locale.generateNTemplate("1 Day"),
|
|
65
|
+
value: "1d"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
label: locale.generateNTemplate("7 Days"),
|
|
69
|
+
value: "7d"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
label: locale.generateNTemplate("30 Days"),
|
|
73
|
+
value: "30d"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
label: locale.generateNTemplate("90 Days"),
|
|
77
|
+
value: "90d"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
label: locale.generateNTemplate("Custom"),
|
|
81
|
+
value: "custom"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
label: locale.generateNTemplate("Never"),
|
|
85
|
+
value: "never"
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: "token",
|
|
92
|
+
type: "string",
|
|
93
|
+
hidden: true
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
module.exports = api_keys_default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './api-keys';
|
package/{lib → dist}/index.d.ts
RENAMED
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var server = require('./server');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, 'default', {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return server__namespace.default; }
|
|
12
|
+
});
|
|
13
|
+
Object.keys(server).forEach(function (k) {
|
|
14
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return server[k]; }
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const locale = {
|
|
4
|
+
"API key created successfully": "API key \u521B\u5EFA\u6210\u529F",
|
|
5
|
+
"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",
|
|
6
|
+
"Key name": "\u5BC6\u94A5\u540D\u79F0",
|
|
7
|
+
Expiration: "\u8FC7\u671F\u65F6\u95F4",
|
|
8
|
+
"Delete API key": "\u5220\u9664 API key",
|
|
9
|
+
Role: "\u89D2\u8272",
|
|
10
|
+
"Keys manager": "\u5BC6\u94A5\u7BA1\u7406",
|
|
11
|
+
"Created at": "\u521B\u5EFA\u65F6\u95F4",
|
|
12
|
+
"Add API key": "\u6DFB\u52A0 API key",
|
|
13
|
+
Never: "\u6C38\u4E0D",
|
|
14
|
+
Custom: "\u81EA\u5B9A\u4E49",
|
|
15
|
+
"Never expires": "\u6C38\u4E0D\u8FC7\u671F",
|
|
16
|
+
"1 Day": "1 \u5929",
|
|
17
|
+
"7 Days": "7 \u5929",
|
|
18
|
+
"30 Days": "30 \u5929",
|
|
19
|
+
"90 Days": "90 \u5929",
|
|
20
|
+
"Role not found": "\u89D2\u8272\u4E0D\u5B58\u5728"
|
|
21
|
+
};
|
|
22
|
+
var zh_CN_default = locale;
|
|
23
|
+
|
|
24
|
+
module.exports = zh_CN_default;
|