@nocobase/server 0.9.1-alpha.1 → 0.9.2-alpha.1
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/lib/acl/index.js +3 -18
- package/lib/app-manager.d.ts +9 -9
- package/lib/app-manager.js +58 -89
- package/lib/application.d.ts +1 -0
- package/lib/application.js +35 -170
- package/lib/commands/console.js +0 -7
- package/lib/commands/db-auth.js +0 -5
- package/lib/commands/db-clean.js +0 -5
- package/lib/commands/db-sync.js +0 -4
- package/lib/commands/index.js +2 -12
- package/lib/commands/install.js +0 -14
- package/lib/commands/migrator.js +0 -5
- package/lib/commands/pm.js +3 -10
- package/lib/commands/start.js +0 -5
- package/lib/commands/upgrade.js +0 -8
- package/lib/helper.js +13 -36
- package/lib/index.js +0 -15
- package/lib/middlewares/data-template.d.ts +2 -0
- package/lib/middlewares/data-template.js +147 -0
- package/lib/middlewares/data-wrapping.js +4 -26
- package/lib/middlewares/db2resource.js +7 -25
- package/lib/middlewares/i18n.js +0 -8
- package/lib/middlewares/index.d.ts +1 -0
- package/lib/middlewares/index.js +13 -5
- package/lib/middlewares/parse-variables.d.ts +1 -0
- package/lib/middlewares/parse-variables.js +79 -0
- package/lib/migration.js +0 -7
- package/lib/plugin-manager/index.d.ts +1 -1
- package/lib/plugin-manager/index.js +4 -6
- package/lib/plugin-manager/options/collection.d.ts +1 -15
- package/lib/plugin-manager/options/collection.js +10 -3
- package/lib/plugin-manager/options/resource.js +0 -16
- package/lib/plugin-manager/{PluginManagerRepository.d.ts → plugin-manager-repository.d.ts} +1 -1
- package/lib/plugin-manager/{PluginManagerRepository.js → plugin-manager-repository.js} +49 -32
- package/lib/plugin-manager/{PluginManager.d.ts → plugin-manager.d.ts} +3 -2
- package/lib/plugin-manager/{PluginManager.js → plugin-manager.js} +140 -242
- package/lib/plugin.d.ts +2 -0
- package/lib/plugin.js +6 -20
- package/lib/read-config.js +5 -48
- package/package.json +9 -7
|
@@ -5,69 +5,51 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.dataWrapping = dataWrapping;
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
|
|
9
8
|
function _stream() {
|
|
10
9
|
const data = _interopRequireDefault(require("stream"));
|
|
11
|
-
|
|
12
10
|
_stream = function _stream() {
|
|
13
11
|
return data;
|
|
14
12
|
};
|
|
15
|
-
|
|
16
13
|
return data;
|
|
17
14
|
}
|
|
18
|
-
|
|
19
15
|
const _excluded = ["rows"];
|
|
20
|
-
|
|
21
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
-
|
|
23
17
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
24
|
-
|
|
25
18
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
26
|
-
|
|
27
19
|
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); } }
|
|
28
|
-
|
|
29
20
|
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); }); }; }
|
|
30
|
-
|
|
31
21
|
function dataWrapping() {
|
|
32
22
|
return /*#__PURE__*/function () {
|
|
33
23
|
var _dataWrapping = _asyncToGenerator(function* (ctx, next) {
|
|
34
24
|
yield next();
|
|
35
|
-
|
|
36
25
|
if (ctx.withoutDataWrapping) {
|
|
37
26
|
return;
|
|
38
|
-
}
|
|
27
|
+
}
|
|
28
|
+
// if (!ctx?.action?.params) {
|
|
39
29
|
// return;
|
|
40
30
|
// }
|
|
41
|
-
|
|
42
|
-
|
|
43
31
|
if (ctx.body instanceof _stream().default.Readable) {
|
|
44
32
|
return;
|
|
45
33
|
}
|
|
46
|
-
|
|
47
34
|
if (ctx.body instanceof Buffer) {
|
|
48
35
|
return;
|
|
49
36
|
}
|
|
50
|
-
|
|
51
37
|
if (!ctx.body) {
|
|
52
38
|
var _ctx$action;
|
|
53
|
-
|
|
54
39
|
if (((_ctx$action = ctx.action) === null || _ctx$action === void 0 ? void 0 : _ctx$action.actionName) == 'get') {
|
|
55
40
|
ctx.status = 200;
|
|
56
41
|
}
|
|
57
42
|
}
|
|
58
|
-
|
|
59
43
|
if (Array.isArray(ctx.body)) {
|
|
60
44
|
ctx.body = {
|
|
61
45
|
data: ctx.body
|
|
62
46
|
};
|
|
63
47
|
return;
|
|
64
48
|
}
|
|
65
|
-
|
|
66
49
|
if (ctx.body) {
|
|
67
50
|
const _ctx$body = ctx.body,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
51
|
+
rows = _ctx$body.rows,
|
|
52
|
+
meta = _objectWithoutProperties(_ctx$body, _excluded);
|
|
71
53
|
if (rows) {
|
|
72
54
|
ctx.body = {
|
|
73
55
|
data: rows,
|
|
@@ -77,7 +59,6 @@ function dataWrapping() {
|
|
|
77
59
|
ctx.body = {
|
|
78
60
|
data: ctx.body
|
|
79
61
|
};
|
|
80
|
-
|
|
81
62
|
if (ctx.bodyMeta) {
|
|
82
63
|
ctx.body.meta = ctx.bodyMeta;
|
|
83
64
|
}
|
|
@@ -88,14 +69,11 @@ function dataWrapping() {
|
|
|
88
69
|
};
|
|
89
70
|
}
|
|
90
71
|
});
|
|
91
|
-
|
|
92
72
|
function dataWrapping(_x, _x2) {
|
|
93
73
|
return _dataWrapping.apply(this, arguments);
|
|
94
74
|
}
|
|
95
|
-
|
|
96
75
|
return dataWrapping;
|
|
97
76
|
}();
|
|
98
77
|
}
|
|
99
|
-
|
|
100
78
|
var _default = dataWrapping;
|
|
101
79
|
exports.default = _default;
|
|
@@ -5,29 +5,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.db2resource = db2resource;
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
|
|
9
8
|
function _resourcer() {
|
|
10
9
|
const data = require("@nocobase/resourcer");
|
|
11
|
-
|
|
12
10
|
_resourcer = function _resourcer() {
|
|
13
11
|
return data;
|
|
14
12
|
};
|
|
15
|
-
|
|
16
13
|
return data;
|
|
17
14
|
}
|
|
18
|
-
|
|
19
15
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
20
|
-
|
|
21
16
|
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."); }
|
|
22
|
-
|
|
23
17
|
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); }
|
|
24
|
-
|
|
25
18
|
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; }
|
|
26
|
-
|
|
27
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
28
|
-
|
|
19
|
+
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; } }
|
|
29
20
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
30
|
-
|
|
31
21
|
function db2resource(ctx, next) {
|
|
32
22
|
const resourcer = ctx.resourcer;
|
|
33
23
|
const database = ctx.db;
|
|
@@ -38,41 +28,33 @@ function db2resource(ctx, next) {
|
|
|
38
28
|
prefix: resourcer.options.prefix,
|
|
39
29
|
accessors: resourcer.options.accessors
|
|
40
30
|
});
|
|
41
|
-
|
|
42
31
|
if (!params) {
|
|
43
32
|
return next();
|
|
44
33
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
const resourceName = (0, _resourcer().getNameByParams)(params);
|
|
35
|
+
// 如果资源名称未被定义
|
|
48
36
|
if (resourcer.isDefined(resourceName)) {
|
|
49
37
|
return next();
|
|
50
38
|
}
|
|
51
|
-
|
|
52
39
|
const _resourceName$split = resourceName.split('.'),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
40
|
+
_resourceName$split2 = _slicedToArray(_resourceName$split, 2),
|
|
41
|
+
collectionName = _resourceName$split2[0],
|
|
42
|
+
fieldName = _resourceName$split2[1];
|
|
43
|
+
// 如果经过加载后是已经定义的表
|
|
58
44
|
if (!database.hasCollection(collectionName)) {
|
|
59
45
|
return next();
|
|
60
46
|
}
|
|
61
|
-
|
|
62
47
|
const collection = database.getCollection(collectionName);
|
|
63
48
|
let resourceType = 'single';
|
|
64
|
-
|
|
65
49
|
if (fieldName && collection.hasField(fieldName)) {
|
|
66
50
|
const field = collection.getField(fieldName);
|
|
67
51
|
resourceType = field.type;
|
|
68
52
|
}
|
|
69
|
-
|
|
70
53
|
resourcer.define({
|
|
71
54
|
type: resourceType,
|
|
72
55
|
name: resourceName
|
|
73
56
|
});
|
|
74
57
|
return next();
|
|
75
58
|
}
|
|
76
|
-
|
|
77
59
|
var _default = db2resource;
|
|
78
60
|
exports.default = _default;
|
package/lib/middlewares/i18n.js
CHANGED
|
@@ -4,15 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.i18n = i18n;
|
|
7
|
-
|
|
8
7
|
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); } }
|
|
9
|
-
|
|
10
8
|
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); }); }; }
|
|
11
|
-
|
|
12
9
|
function i18n(_x, _x2) {
|
|
13
10
|
return _i18n.apply(this, arguments);
|
|
14
11
|
}
|
|
15
|
-
|
|
16
12
|
function _i18n() {
|
|
17
13
|
_i18n = _asyncToGenerator(function* (ctx, next) {
|
|
18
14
|
const i18n = ctx.app.i18n.cloneInstance({
|
|
@@ -20,18 +16,14 @@ function _i18n() {
|
|
|
20
16
|
});
|
|
21
17
|
ctx.i18n = i18n;
|
|
22
18
|
ctx.t = i18n.t.bind(i18n);
|
|
23
|
-
|
|
24
19
|
ctx.getCurrentLocale = () => {
|
|
25
20
|
const lng = ctx.get('X-Locale') || ctx.request.query.locale || ctx.app.i18n.language || ctx.acceptsLanguages().shift() || 'en-US';
|
|
26
21
|
return lng;
|
|
27
22
|
};
|
|
28
|
-
|
|
29
23
|
const lng = ctx.getCurrentLocale();
|
|
30
|
-
|
|
31
24
|
if (lng !== '*' && lng) {
|
|
32
25
|
i18n.changeLanguage(lng);
|
|
33
26
|
}
|
|
34
|
-
|
|
35
27
|
yield next();
|
|
36
28
|
});
|
|
37
29
|
return _i18n.apply(this, arguments);
|
package/lib/middlewares/index.js
CHANGED
|
@@ -3,11 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
parseVariables: true
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "parseVariables", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function get() {
|
|
12
|
+
return _parseVariables.parseVariables;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
7
15
|
var _dataWrapping = require("./data-wrapping");
|
|
8
|
-
|
|
9
16
|
Object.keys(_dataWrapping).forEach(function (key) {
|
|
10
17
|
if (key === "default" || key === "__esModule") return;
|
|
18
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
11
19
|
if (key in exports && exports[key] === _dataWrapping[key]) return;
|
|
12
20
|
Object.defineProperty(exports, key, {
|
|
13
21
|
enumerable: true,
|
|
@@ -16,11 +24,10 @@ Object.keys(_dataWrapping).forEach(function (key) {
|
|
|
16
24
|
}
|
|
17
25
|
});
|
|
18
26
|
});
|
|
19
|
-
|
|
20
27
|
var _db2resource = require("./db2resource");
|
|
21
|
-
|
|
22
28
|
Object.keys(_db2resource).forEach(function (key) {
|
|
23
29
|
if (key === "default" || key === "__esModule") return;
|
|
30
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
24
31
|
if (key in exports && exports[key] === _db2resource[key]) return;
|
|
25
32
|
Object.defineProperty(exports, key, {
|
|
26
33
|
enumerable: true,
|
|
@@ -28,4 +35,5 @@ Object.keys(_db2resource).forEach(function (key) {
|
|
|
28
35
|
return _db2resource[key];
|
|
29
36
|
}
|
|
30
37
|
});
|
|
31
|
-
});
|
|
38
|
+
});
|
|
39
|
+
var _parseVariables = require("./parse-variables");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const parseVariables: (ctx: any, next: any) => Promise<any>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.parseVariables = void 0;
|
|
7
|
+
function _utils() {
|
|
8
|
+
const data = require("@nocobase/utils");
|
|
9
|
+
_utils = function _utils() {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
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); } }
|
|
15
|
+
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); }); }; }
|
|
16
|
+
function getUser(ctx) {
|
|
17
|
+
return /*#__PURE__*/function () {
|
|
18
|
+
var _ref = _asyncToGenerator(function* ({
|
|
19
|
+
fields
|
|
20
|
+
}) {
|
|
21
|
+
var _ctx$logger, _ctx$logger2;
|
|
22
|
+
const userFields = fields.filter(f => f && ctx.db.getFieldByPath('users.' + f));
|
|
23
|
+
(_ctx$logger = ctx.logger) === null || _ctx$logger === void 0 ? void 0 : _ctx$logger.info('filter-parse: ', {
|
|
24
|
+
userFields
|
|
25
|
+
});
|
|
26
|
+
if (!ctx.state.currentUser) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (!userFields.length) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const user = yield ctx.db.getRepository('users').findOne({
|
|
33
|
+
filterByTk: ctx.state.currentUser.id,
|
|
34
|
+
fields: userFields
|
|
35
|
+
});
|
|
36
|
+
(_ctx$logger2 = ctx.logger) === null || _ctx$logger2 === void 0 ? void 0 : _ctx$logger2.info('filter-parse: ', {
|
|
37
|
+
$user: user === null || user === void 0 ? void 0 : user.toJSON()
|
|
38
|
+
});
|
|
39
|
+
return user;
|
|
40
|
+
});
|
|
41
|
+
return function (_x) {
|
|
42
|
+
return _ref.apply(this, arguments);
|
|
43
|
+
};
|
|
44
|
+
}();
|
|
45
|
+
}
|
|
46
|
+
function isNumeric(str) {
|
|
47
|
+
if (typeof str === 'number') return true;
|
|
48
|
+
if (typeof str != 'string') return false;
|
|
49
|
+
return !isNaN(str) && !isNaN(parseFloat(str));
|
|
50
|
+
}
|
|
51
|
+
const parseVariables = /*#__PURE__*/function () {
|
|
52
|
+
var _ref2 = _asyncToGenerator(function* (ctx, next) {
|
|
53
|
+
const filter = ctx.action.params.filter;
|
|
54
|
+
if (!filter) {
|
|
55
|
+
return next();
|
|
56
|
+
}
|
|
57
|
+
ctx.action.params.filter = yield (0, _utils().parseFilter)(filter, {
|
|
58
|
+
timezone: ctx.get('x-timezone'),
|
|
59
|
+
now: new Date().toISOString(),
|
|
60
|
+
getField: path => {
|
|
61
|
+
const fieldPath = path.split('.').filter(p => !p.startsWith('$') && !isNumeric(p)).join('.');
|
|
62
|
+
const resourceName = ctx.action.resourceName;
|
|
63
|
+
return ctx.db.getFieldByPath(`${resourceName}.${fieldPath}`);
|
|
64
|
+
},
|
|
65
|
+
vars: {
|
|
66
|
+
$system: {
|
|
67
|
+
now: new Date().toISOString()
|
|
68
|
+
},
|
|
69
|
+
$date: (0, _utils().getDateVars)(),
|
|
70
|
+
$user: getUser(ctx)
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
yield next();
|
|
74
|
+
});
|
|
75
|
+
return function parseVariables(_x2, _x3) {
|
|
76
|
+
return _ref2.apply(this, arguments);
|
|
77
|
+
};
|
|
78
|
+
}();
|
|
79
|
+
exports.parseVariables = parseVariables;
|
package/lib/migration.js
CHANGED
|
@@ -4,26 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Migration = void 0;
|
|
7
|
-
|
|
8
7
|
function _database() {
|
|
9
8
|
const data = require("@nocobase/database");
|
|
10
|
-
|
|
11
9
|
_database = function _database() {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
class Migration extends _database().Migration {
|
|
19
15
|
get app() {
|
|
20
16
|
return this.context.app;
|
|
21
17
|
}
|
|
22
|
-
|
|
23
18
|
get plugin() {
|
|
24
19
|
return this.context.plugin;
|
|
25
20
|
}
|
|
26
|
-
|
|
27
21
|
}
|
|
28
|
-
|
|
29
22
|
exports.Migration = Migration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './plugin-manager';
|
|
@@ -3,16 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Object.keys(_PluginManager).forEach(function (key) {
|
|
6
|
+
var _pluginManager = require("./plugin-manager");
|
|
7
|
+
Object.keys(_pluginManager).forEach(function (key) {
|
|
10
8
|
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] ===
|
|
9
|
+
if (key in exports && exports[key] === _pluginManager[key]) return;
|
|
12
10
|
Object.defineProperty(exports, key, {
|
|
13
11
|
enumerable: true,
|
|
14
12
|
get: function get() {
|
|
15
|
-
return
|
|
13
|
+
return _pluginManager[key];
|
|
16
14
|
}
|
|
17
15
|
});
|
|
18
16
|
});
|
|
@@ -1,16 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
2
|
-
name: string;
|
|
3
|
-
namespace: string;
|
|
4
|
-
duplicator: string;
|
|
5
|
-
repository: string;
|
|
6
|
-
fields: ({
|
|
7
|
-
type: string;
|
|
8
|
-
name: string;
|
|
9
|
-
unique: boolean;
|
|
10
|
-
} | {
|
|
11
|
-
type: string;
|
|
12
|
-
name: string;
|
|
13
|
-
unique?: undefined;
|
|
14
|
-
})[];
|
|
15
|
-
};
|
|
1
|
+
declare const _default: import("@nocobase/database").CollectionOptions;
|
|
16
2
|
export default _default;
|
|
@@ -4,9 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
7
|
+
function _database() {
|
|
8
|
+
const data = require("@nocobase/database");
|
|
9
|
+
_database = function _database() {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
var _default = (0, _database().defineCollection)({
|
|
8
15
|
name: 'applicationPlugins',
|
|
9
|
-
namespace: 'core',
|
|
16
|
+
namespace: 'core.applicationPlugins',
|
|
10
17
|
duplicator: 'required',
|
|
11
18
|
repository: 'PluginManagerRepository',
|
|
12
19
|
fields: [{
|
|
@@ -29,5 +36,5 @@ var _default = {
|
|
|
29
36
|
type: 'json',
|
|
30
37
|
name: 'options'
|
|
31
38
|
}]
|
|
32
|
-
};
|
|
39
|
+
});
|
|
33
40
|
exports.default = _default;
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
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); } }
|
|
9
|
-
|
|
10
8
|
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); }); }; }
|
|
11
|
-
|
|
12
9
|
var _default = {
|
|
13
10
|
name: 'pm',
|
|
14
11
|
actions: {
|
|
@@ -16,69 +13,56 @@ var _default = {
|
|
|
16
13
|
return _asyncToGenerator(function* () {
|
|
17
14
|
const pm = ctx.app.pm;
|
|
18
15
|
const filterByTk = ctx.action.params.filterByTk;
|
|
19
|
-
|
|
20
16
|
if (!filterByTk) {
|
|
21
17
|
ctx.throw(400, 'plugin name invalid');
|
|
22
18
|
}
|
|
23
|
-
|
|
24
19
|
yield pm.add(filterByTk);
|
|
25
20
|
ctx.body = filterByTk;
|
|
26
21
|
yield next();
|
|
27
22
|
})();
|
|
28
23
|
},
|
|
29
|
-
|
|
30
24
|
enable(ctx, next) {
|
|
31
25
|
return _asyncToGenerator(function* () {
|
|
32
26
|
const pm = ctx.app.pm;
|
|
33
27
|
const filterByTk = ctx.action.params.filterByTk;
|
|
34
|
-
|
|
35
28
|
if (!filterByTk) {
|
|
36
29
|
ctx.throw(400, 'plugin name invalid');
|
|
37
30
|
}
|
|
38
|
-
|
|
39
31
|
yield pm.enable(filterByTk);
|
|
40
32
|
ctx.body = filterByTk;
|
|
41
33
|
yield next();
|
|
42
34
|
})();
|
|
43
35
|
},
|
|
44
|
-
|
|
45
36
|
disable(ctx, next) {
|
|
46
37
|
return _asyncToGenerator(function* () {
|
|
47
38
|
const pm = ctx.app.pm;
|
|
48
39
|
const filterByTk = ctx.action.params.filterByTk;
|
|
49
|
-
|
|
50
40
|
if (!filterByTk) {
|
|
51
41
|
ctx.throw(400, 'plugin name invalid');
|
|
52
42
|
}
|
|
53
|
-
|
|
54
43
|
yield pm.disable(filterByTk);
|
|
55
44
|
ctx.body = filterByTk;
|
|
56
45
|
yield next();
|
|
57
46
|
})();
|
|
58
47
|
},
|
|
59
|
-
|
|
60
48
|
upgrade(ctx, next) {
|
|
61
49
|
return _asyncToGenerator(function* () {
|
|
62
50
|
ctx.body = 'ok';
|
|
63
51
|
yield next();
|
|
64
52
|
})();
|
|
65
53
|
},
|
|
66
|
-
|
|
67
54
|
remove(ctx, next) {
|
|
68
55
|
return _asyncToGenerator(function* () {
|
|
69
56
|
const pm = ctx.app.pm;
|
|
70
57
|
const filterByTk = ctx.action.params.filterByTk;
|
|
71
|
-
|
|
72
58
|
if (!filterByTk) {
|
|
73
59
|
ctx.throw(400, 'plugin name invalid');
|
|
74
60
|
}
|
|
75
|
-
|
|
76
61
|
yield pm.remove(filterByTk);
|
|
77
62
|
ctx.body = filterByTk;
|
|
78
63
|
yield next();
|
|
79
64
|
})();
|
|
80
65
|
}
|
|
81
|
-
|
|
82
66
|
}
|
|
83
67
|
};
|
|
84
68
|
exports.default = _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Repository } from '@nocobase/database';
|
|
2
|
-
import { PluginManager } from './
|
|
2
|
+
import { PluginManager } from './plugin-manager';
|
|
3
3
|
export declare class PluginManagerRepository extends Repository {
|
|
4
4
|
pm: PluginManager;
|
|
5
5
|
setPluginManager(pm: PluginManager): void;
|