@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.
Files changed (94) hide show
  1. package/client.d.ts +2 -2
  2. package/client.js +1 -1
  3. package/dist/client/index.js +483 -0
  4. package/dist/collections/api-keys.js +98 -0
  5. package/dist/collections/index.d.ts +1 -0
  6. package/dist/collections/index.js +11 -0
  7. package/dist/constants.js +5 -0
  8. package/{lib → dist}/index.d.ts +1 -0
  9. package/dist/index.js +18 -0
  10. package/dist/locale/en-US.js +6 -0
  11. package/dist/locale/fr-FR.js +6 -0
  12. package/dist/locale/zh-CN.js +24 -0
  13. package/dist/locale.js +9 -0
  14. package/dist/server/actions/api-keys.js +51 -0
  15. package/dist/server/index.js +11 -0
  16. package/dist/server/locale/en-US.js +5 -0
  17. package/dist/server/locale/fr-FR.js +5 -0
  18. package/dist/server/locale/index.js +20 -0
  19. package/dist/server/locale/zh-CN.js +7 -0
  20. package/dist/server/plugin.js +48 -0
  21. package/docs/en-US/changelog.md +1 -0
  22. package/docs/en-US/index.md +9 -0
  23. package/docs/en-US/tabs.json +14 -0
  24. package/docs/en-US/usage.md +19 -0
  25. package/docs/zh-CN/changelog.md +1 -0
  26. package/docs/zh-CN/index.md +10 -0
  27. package/docs/zh-CN/tabs.json +14 -0
  28. package/docs/zh-CN/usage.md +19 -0
  29. package/package.json +19 -27
  30. package/server.d.ts +2 -3
  31. package/server.js +1 -30
  32. package/lib/client/Configuration/ExpiresSelect.js +0 -130
  33. package/lib/client/Configuration/index.js +0 -47
  34. package/lib/client/Configuration/roles.js +0 -20
  35. package/lib/client/Configuration/schema.js +0 -319
  36. package/lib/client/index.js +0 -56
  37. package/lib/client/locale/index.js +0 -32
  38. package/lib/collections/api-keys.js +0 -87
  39. package/lib/collections/index.d.ts +0 -1
  40. package/lib/collections/index.js +0 -13
  41. package/lib/constants.js +0 -8
  42. package/lib/index.js +0 -13
  43. package/lib/locale/en-US.js +0 -9
  44. package/lib/locale/fr-FR.js +0 -9
  45. package/lib/locale/zh-CN.js +0 -27
  46. package/lib/locale.js +0 -10
  47. package/lib/server/actions/api-keys.js +0 -71
  48. package/lib/server/index.js +0 -13
  49. package/lib/server/locale/en-US.js +0 -8
  50. package/lib/server/locale/fr-FR.js +0 -8
  51. package/lib/server/locale/index.js +0 -20
  52. package/lib/server/locale/zh-CN.js +0 -10
  53. package/lib/server/plugin.js +0 -77
  54. package/src/client/Configuration/ExpiresSelect.tsx +0 -80
  55. package/src/client/Configuration/index.tsx +0 -18
  56. package/src/client/Configuration/roles.ts +0 -9
  57. package/src/client/Configuration/schema.tsx +0 -264
  58. package/src/client/index.tsx +0 -35
  59. package/src/client/locale/index.ts +0 -13
  60. package/src/collections/api-keys.ts +0 -95
  61. package/src/collections/index.ts +0 -1
  62. package/src/constants.ts +0 -1
  63. package/src/index.ts +0 -1
  64. package/src/locale/en-US.ts +0 -3
  65. package/src/locale/fr-FR.ts +0 -3
  66. package/src/locale/zh-CN.ts +0 -22
  67. package/src/locale.ts +0 -5
  68. package/src/server/__tests__/actions.test.ts +0 -181
  69. package/src/server/actions/api-keys.ts +0 -49
  70. package/src/server/index.ts +0 -1
  71. package/src/server/locale/en-US.ts +0 -1
  72. package/src/server/locale/fr-FR.ts +0 -1
  73. package/src/server/locale/index.ts +0 -2
  74. package/src/server/locale/zh-CN.ts +0 -3
  75. package/src/server/plugin.ts +0 -53
  76. /package/{lib → dist}/client/Configuration/ExpiresSelect.d.ts +0 -0
  77. /package/{lib → dist}/client/Configuration/index.d.ts +0 -0
  78. /package/{lib → dist}/client/Configuration/roles.d.ts +0 -0
  79. /package/{lib → dist}/client/Configuration/schema.d.ts +0 -0
  80. /package/{lib → dist}/client/index.d.ts +0 -0
  81. /package/{lib → dist}/client/locale/index.d.ts +0 -0
  82. /package/{lib → dist}/collections/api-keys.d.ts +0 -0
  83. /package/{lib → dist}/constants.d.ts +0 -0
  84. /package/{lib → dist}/locale/en-US.d.ts +0 -0
  85. /package/{lib → dist}/locale/fr-FR.d.ts +0 -0
  86. /package/{lib → dist}/locale/zh-CN.d.ts +0 -0
  87. /package/{lib → dist}/locale.d.ts +0 -0
  88. /package/{lib → dist}/server/actions/api-keys.d.ts +0 -0
  89. /package/{lib → dist}/server/index.d.ts +0 -0
  90. /package/{lib → dist}/server/locale/en-US.d.ts +0 -0
  91. /package/{lib → dist}/server/locale/fr-FR.d.ts +0 -0
  92. /package/{lib → dist}/server/locale/index.d.ts +0 -0
  93. /package/{lib → dist}/server/locale/zh-CN.d.ts +0 -0
  94. /package/{lib → dist}/server/plugin.d.ts +0 -0
@@ -1,319 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.configurationSchema = void 0;
7
- function _react() {
8
- const data = require("@formily/react");
9
- _react = function _react() {
10
- return data;
11
- };
12
- return data;
13
- }
14
- function _shared() {
15
- const data = require("@formily/shared");
16
- _shared = function _shared() {
17
- return data;
18
- };
19
- return data;
20
- }
21
- function _client() {
22
- const data = require("@nocobase/client");
23
- _client = function _client() {
24
- return data;
25
- };
26
- return data;
27
- }
28
- function _antd() {
29
- const data = require("antd");
30
- _antd = function _antd() {
31
- return data;
32
- };
33
- return data;
34
- }
35
- function _react2() {
36
- const data = _interopRequireDefault(require("react"));
37
- _react2 = function _react2() {
38
- return data;
39
- };
40
- return data;
41
- }
42
- var _locale = require("../../locale");
43
- var _locale2 = require("../locale");
44
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
45
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
46
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
47
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
48
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
49
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
50
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
51
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
52
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
53
- const useModal = _antd().Modal.useModal;
54
- const useCreateAction = () => {
55
- const form = (0, _react().useForm)();
56
- const _useActionContext = (0, _client().useActionContext)(),
57
- setVisible = _useActionContext.setVisible;
58
- const _useBlockRequestConte = (0, _client().useBlockRequestContext)(),
59
- resource = _useBlockRequestConte.resource,
60
- service = _useBlockRequestConte.service;
61
- const _useTranslation = (0, _locale2.useTranslation)(),
62
- t = _useTranslation.t;
63
- const _useModal = useModal(),
64
- _useModal2 = _slicedToArray(_useModal, 2),
65
- modalIns = _useModal2[0],
66
- element = _useModal2[1];
67
- return {
68
- run() {
69
- return _asyncToGenerator(function* () {
70
- var _response$data, _response$data$data;
71
- yield form.submit();
72
- const response = yield resource.create({
73
- values: form.values
74
- });
75
- modalIns.success({
76
- title: t('API key created successfully'),
77
- onOk: () => {
78
- form.reset();
79
- setVisible(false);
80
- },
81
- content: _react2().default.createElement(_antd().Space, {
82
- direction: "vertical"
83
- }, _react2().default.createElement(_antd().Alert, {
84
- message: t('Make sure to copy your personal access key now as you will not be able to see this again.'),
85
- type: "warning"
86
- }), _react2().default.createElement(_antd().Typography.Text, {
87
- copyable: true
88
- }, (_response$data = response.data) === null || _response$data === void 0 ? void 0 : (_response$data$data = _response$data.data) === null || _response$data$data === void 0 ? void 0 : _response$data$data.token))
89
- });
90
- service === null || service === void 0 ? void 0 : service.refresh();
91
- })();
92
- },
93
- element
94
- };
95
- };
96
- const useDestroyAction = () => {
97
- const record = (0, _client().useRecord)();
98
- const _useBlockRequestConte2 = (0, _client().useBlockRequestContext)(),
99
- resource = _useBlockRequestConte2.resource,
100
- service = _useBlockRequestConte2.service;
101
- return {
102
- run() {
103
- return _asyncToGenerator(function* () {
104
- yield resource.destroy({
105
- filterByTk: record.id
106
- });
107
- service.refresh();
108
- })();
109
- }
110
- };
111
- };
112
- const configurationSchema = {
113
- type: 'object',
114
- properties: {
115
- configuration: {
116
- type: 'void',
117
- 'x-decorator': 'TableBlockProvider',
118
- 'x-decorator-props': {
119
- collection: 'apiKeys',
120
- resource: 'apiKeys',
121
- action: 'list',
122
- params: {
123
- pageSize: 20,
124
- appends: ['role'],
125
- sort: ['-createdAt']
126
- },
127
- rowKey: 'name',
128
- showIndex: true
129
- },
130
- 'x-component': 'CardItem',
131
- properties: {
132
- actions: {
133
- type: 'void',
134
- 'x-component': 'ActionBar',
135
- 'x-component-props': {
136
- style: {
137
- marginBottom: 'var(--nb-spacing)'
138
- }
139
- },
140
- properties: {
141
- create: {
142
- type: 'void',
143
- 'x-action': 'create',
144
- title: (0, _locale.generateNTemplate)('Add API key'),
145
- 'x-component': 'Action',
146
- 'x-component-props': {
147
- openMode: 'drawer',
148
- type: 'primary'
149
- },
150
- properties: {
151
- drawer: {
152
- type: 'void',
153
- title: (0, _locale.generateNTemplate)('Add API key'),
154
- 'x-decorator': 'Form',
155
- 'x-component': 'Action.Modal',
156
- 'x-component-props': {
157
- maskClosable: false,
158
- style: {
159
- maxWidth: '520px',
160
- width: '100%'
161
- }
162
- },
163
- properties: {
164
- name: {
165
- type: 'string',
166
- title: (0, _locale.generateNTemplate)('Key name'),
167
- required: true,
168
- 'x-component': 'CollectionField',
169
- 'x-decorator': 'FormItem'
170
- },
171
- role: {
172
- type: 'string',
173
- title: (0, _locale.generateNTemplate)('Role'),
174
- required: true,
175
- 'x-collection-field': 'apiKeys.role',
176
- 'x-component': 'CollectionField',
177
- 'x-decorator': 'FormItem'
178
- },
179
- expiresIn: {
180
- type: 'string',
181
- title: (0, _locale.generateNTemplate)('Expiration'),
182
- required: true,
183
- 'x-component': 'CollectionField',
184
- 'x-decorator': 'FormItem',
185
- default: '30d'
186
- },
187
- footer: {
188
- type: 'void',
189
- 'x-component': 'Action.Modal.Footer',
190
- properties: {
191
- cancel: {
192
- title: '{{t("Cancel")}}',
193
- 'x-component': 'Action',
194
- 'x-component-props': {
195
- useAction: '{{ cm.useCancelAction }}'
196
- }
197
- },
198
- submit: {
199
- title: '{{t("Submit")}}',
200
- 'x-component': 'Action',
201
- 'x-component-props': {
202
- type: 'primary',
203
- useAction: useCreateAction
204
- }
205
- }
206
- }
207
- }
208
- }
209
- }
210
- },
211
- 'x-align': 'right'
212
- }
213
- }
214
- },
215
- [(0, _shared().uid)()]: {
216
- type: 'array',
217
- 'x-component': 'TableV2',
218
- 'x-component-props': {
219
- rowKey: 'id',
220
- useProps: '{{ useTableBlockProps }}'
221
- },
222
- properties: {
223
- column1: {
224
- type: 'void',
225
- 'x-decorator': 'TableV2.Column.Decorator',
226
- 'x-component': 'TableV2.Column',
227
- title: (0, _locale.generateNTemplate)('Key name'),
228
- properties: {
229
- name: {
230
- type: 'string',
231
- 'x-component': 'CollectionField',
232
- 'x-read-pretty': true
233
- }
234
- }
235
- },
236
- column2: {
237
- type: 'void',
238
- 'x-decorator': 'TableV2.Column.Decorator',
239
- 'x-component': 'TableV2.Column',
240
- title: (0, _locale.generateNTemplate)('Role'),
241
- properties: {
242
- role: {
243
- type: 'object',
244
- 'x-collection-field': 'apiKeys.role',
245
- 'x-component': 'CollectionField',
246
- 'x-component-props': {
247
- enableLink: false
248
- },
249
- 'x-read-pretty': true
250
- }
251
- }
252
- },
253
- column3: {
254
- type: 'void',
255
- 'x-decorator': 'TableV2.Column.Decorator',
256
- 'x-component': 'TableV2.Column',
257
- title: (0, _locale.generateNTemplate)('Expiration'),
258
- properties: {
259
- expiresIn: {
260
- type: 'string',
261
- 'x-component': 'CollectionField',
262
- 'x-read-pretty': true
263
- }
264
- }
265
- },
266
- column4: {
267
- type: 'void',
268
- 'x-decorator': 'TableV2.Column.Decorator',
269
- 'x-component': 'TableV2.Column',
270
- title: (0, _locale.generateNTemplate)('Created at'),
271
- properties: {
272
- createdAt: {
273
- type: 'date',
274
- // 'x-component': 'CollectionField',
275
- 'x-component': 'DatePicker',
276
- 'x-component-props': {
277
- format: 'YYYY-MM-DD HH:mm:ss'
278
- },
279
- 'x-read-pretty': true
280
- }
281
- }
282
- },
283
- actionColumn: {
284
- type: 'void',
285
- title: '{{ t("Actions") }}',
286
- 'x-action-column': 'actions',
287
- 'x-decorator': 'TableV2.Column.ActionBar',
288
- 'x-component': 'TableV2.Column',
289
- properties: {
290
- columnActions: {
291
- type: 'void',
292
- 'x-component': 'Space',
293
- 'x-component-props': {
294
- split: '|'
295
- },
296
- properties: {
297
- delete: {
298
- type: 'void',
299
- title: '{{ t("Delete") }}',
300
- 'x-component': 'Action.Link',
301
- 'x-component-props': {
302
- confirm: {
303
- title: (0, _locale.generateNTemplate)('Delete API key'),
304
- content: "{{t('Are you sure you want to delete it?')}}"
305
- },
306
- useAction: useDestroyAction
307
- }
308
- }
309
- }
310
- }
311
- }
312
- }
313
- }
314
- }
315
- }
316
- }
317
- }
318
- };
319
- exports.configurationSchema = configurationSchema;
@@ -1,56 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- function _client() {
8
- const data = require("@nocobase/client");
9
- _client = function _client() {
10
- return data;
11
- };
12
- return data;
13
- }
14
- function _react() {
15
- const data = _interopRequireDefault(require("react"));
16
- _react = function _react() {
17
- return data;
18
- };
19
- return data;
20
- }
21
- var _Configuration = require("./Configuration");
22
- var _locale = require("./locale");
23
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
25
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
26
- const ApiKeysProvider = _react().default.memo(props => {
27
- const _useTranslation = (0, _locale.useTranslation)(),
28
- t = _useTranslation.t;
29
- return _react().default.createElement(_client().SettingsCenterProvider, {
30
- settings: {
31
- ['api-keys']: {
32
- title: t('API keys'),
33
- icon: 'EnvironmentOutlined',
34
- tabs: {
35
- configuration: {
36
- title: t('Keys manager'),
37
- component: _Configuration.Configuration
38
- }
39
- }
40
- }
41
- }
42
- }, _react().default.createElement(_client().SchemaComponentOptions, {
43
- components: {}
44
- }, props.children));
45
- });
46
- ApiKeysProvider.displayName = 'ApiKeysProvider';
47
- class APIKeysPlugin extends _client().Plugin {
48
- load() {
49
- var _this = this;
50
- return _asyncToGenerator(function* () {
51
- _this.app.addProvider(ApiKeysProvider);
52
- })();
53
- }
54
- }
55
- var _default = APIKeysPlugin;
56
- exports.default = _default;
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.lang = lang;
7
- exports.useTranslation = useTranslation;
8
- function _client() {
9
- const data = require("@nocobase/client");
10
- _client = function _client() {
11
- return data;
12
- };
13
- return data;
14
- }
15
- function _reactI18next() {
16
- const data = require("react-i18next");
17
- _reactI18next = function _reactI18next() {
18
- return data;
19
- };
20
- return data;
21
- }
22
- var _constants = require("../../constants");
23
- function lang(key) {
24
- return _client().i18n.t(key, {
25
- ns: _constants.NAMESPACE
26
- });
27
- }
28
- function useTranslation() {
29
- return (0, _reactI18next().useTranslation)([_constants.NAMESPACE, 'client'], {
30
- nsMode: 'fallback'
31
- });
32
- }
@@ -1,87 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _locale = require("../locale");
8
- var _default = {
9
- namespace: 'api-keys',
10
- duplicator: 'optional',
11
- name: 'apiKeys',
12
- title: '{{t("API keys")}}',
13
- sortable: 'sort',
14
- model: 'ApiKeyModel',
15
- createdBy: true,
16
- updatedAt: false,
17
- updatedBy: false,
18
- logging: true,
19
- fields: [{
20
- name: 'id',
21
- type: 'bigInt',
22
- autoIncrement: true,
23
- primaryKey: true,
24
- allowNull: false,
25
- interface: 'id'
26
- }, {
27
- type: 'string',
28
- name: 'name',
29
- interface: 'input',
30
- uiSchema: {
31
- type: 'string',
32
- title: '{{t("name")}}',
33
- 'x-component': 'Input'
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
- name: 'expiresIn',
56
- type: 'string',
57
- uiSchema: {
58
- type: 'string',
59
- title: (0, _locale.generateNTemplate)('Expires'),
60
- 'x-component': 'ExpiresSelect',
61
- enum: [{
62
- label: (0, _locale.generateNTemplate)('1 Day'),
63
- value: '1d'
64
- }, {
65
- label: (0, _locale.generateNTemplate)('7 Days'),
66
- value: '7d'
67
- }, {
68
- label: (0, _locale.generateNTemplate)('30 Days'),
69
- value: '30d'
70
- }, {
71
- label: (0, _locale.generateNTemplate)('90 Days'),
72
- value: '90d'
73
- }, {
74
- label: (0, _locale.generateNTemplate)('Custom'),
75
- value: 'custom'
76
- }, {
77
- label: (0, _locale.generateNTemplate)('Never'),
78
- value: 'never'
79
- }]
80
- }
81
- }, {
82
- name: 'token',
83
- type: 'string',
84
- hidden: true
85
- }]
86
- };
87
- exports.default = _default;
@@ -1 +0,0 @@
1
- export { default as apiKeysCollection } from './api-keys';
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "apiKeysCollection", {
7
- enumerable: true,
8
- get: function get() {
9
- return _apiKeys.default;
10
- }
11
- });
12
- var _apiKeys = _interopRequireDefault(require("./api-keys"));
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
package/lib/constants.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.NAMESPACE = void 0;
7
- const NAMESPACE = 'api-keys';
8
- exports.NAMESPACE = NAMESPACE;
package/lib/index.js DELETED
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "default", {
7
- enumerable: true,
8
- get: function get() {
9
- return _server.default;
10
- }
11
- });
12
- var _server = _interopRequireDefault(require("./server"));
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1,9 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- const locale = {};
8
- var _default = locale;
9
- exports.default = _default;
@@ -1,9 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- const locale = {};
8
- var _default = locale;
9
- exports.default = _default;
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- const locale = {
8
- 'API key created successfully': 'API key 创建成功',
9
- 'Make sure to copy your personal access key now as you will not be able to see this again.': '请确保现在复制你的个人访问密钥,因为你将无法再次看到这个密钥。',
10
- 'Key name': '密钥名称',
11
- Expiration: '过期时间',
12
- 'Delete API key': '删除 API key',
13
- Role: '角色',
14
- 'Keys manager': '密钥管理',
15
- 'Created at': '创建时间',
16
- 'Add API key': '添加 API key',
17
- Never: '永不',
18
- Custom: '自定义',
19
- 'Never expires': '永不过期',
20
- '1 Day': '1 天',
21
- '7 Days': '7 天',
22
- '30 Days': '30 天',
23
- '90 Days': '90 天',
24
- 'Role not found': '角色不存在'
25
- };
26
- var _default = locale;
27
- exports.default = _default;
package/lib/locale.js DELETED
@@ -1,10 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.generateNTemplate = generateNTemplate;
7
- var _constants = require("./constants");
8
- function generateNTemplate(key) {
9
- return `{{t('${key}', { ns: '${_constants.NAMESPACE}', nsMode: 'fallback' })}}`;
10
- }
@@ -1,71 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.create = create;
7
- exports.destroy = destroy;
8
- function _actions() {
9
- const data = _interopRequireDefault(require("@nocobase/actions"));
10
- _actions = function _actions() {
11
- return data;
12
- };
13
- return data;
14
- }
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
17
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
18
- function create(_x, _x2) {
19
- return _create.apply(this, arguments);
20
- }
21
- function _create() {
22
- _create = _asyncToGenerator(function* (ctx, next) {
23
- const values = ctx.action.params.values;
24
- if (!values.role) {
25
- return;
26
- }
27
- const repository = ctx.db.getRepository('users.roles', ctx.auth.user.id);
28
- const role = yield repository.findOne({
29
- filter: {
30
- name: values.role.name
31
- }
32
- });
33
- if (!role) {
34
- throw ctx.throw(400, ctx.t('Role not found'));
35
- }
36
- const token = ctx.app.authManager.jwt.sign({
37
- userId: ctx.auth.user.id,
38
- roleName: role.name
39
- }, {
40
- expiresIn: values.expiresIn
41
- });
42
- ctx.action.mergeParams({
43
- values: {
44
- token
45
- }
46
- });
47
- return _actions().default.create(ctx, /*#__PURE__*/_asyncToGenerator(function* () {
48
- ctx.body = {
49
- token
50
- };
51
- yield next();
52
- }));
53
- });
54
- return _create.apply(this, arguments);
55
- }
56
- function destroy(_x3, _x4) {
57
- return _destroy.apply(this, arguments);
58
- }
59
- function _destroy() {
60
- _destroy = _asyncToGenerator(function* (ctx, next) {
61
- const repo = ctx.db.getRepository(ctx.action.resourceName);
62
- const filterByTk = ctx.action.params.filterByTk;
63
- const data = yield repo.findById(filterByTk);
64
- const token = data === null || data === void 0 ? void 0 : data.get('token');
65
- if (token) {
66
- yield ctx.app.authManager.jwt.block(token);
67
- }
68
- return _actions().default.destroy(ctx, next);
69
- });
70
- return _destroy.apply(this, arguments);
71
- }
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "default", {
7
- enumerable: true,
8
- get: function get() {
9
- return _plugin.default;
10
- }
11
- });
12
- var _plugin = _interopRequireDefault(require("./plugin"));
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }