@nocobase/server 0.7.0-alpha.7 → 0.7.0-alpha.72

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 (124) hide show
  1. package/lib/acl/available-action.js +37 -35
  2. package/lib/acl/index.js +45 -21
  3. package/lib/app-manager.d.ts +3 -3
  4. package/lib/app-manager.js +151 -72
  5. package/lib/application.d.ts +3 -2
  6. package/lib/application.js +291 -153
  7. package/lib/commands/console.d.ts +2 -3
  8. package/lib/commands/console.js +33 -24
  9. package/lib/commands/db-auth.d.ts +3 -0
  10. package/lib/commands/db-auth.js +26 -0
  11. package/lib/commands/db-clean.d.ts +3 -0
  12. package/lib/commands/db-clean.js +27 -0
  13. package/lib/commands/db-sync.d.ts +2 -4
  14. package/lib/commands/db-sync.js +25 -23
  15. package/lib/commands/index.d.ts +1 -2
  16. package/lib/commands/index.js +29 -29
  17. package/lib/commands/install.d.ts +2 -4
  18. package/lib/commands/install.js +68 -20
  19. package/lib/commands/start.d.ts +2 -4
  20. package/lib/commands/start.js +28 -22
  21. package/lib/commands/upgrade.d.ts +6 -0
  22. package/lib/commands/upgrade.js +45 -0
  23. package/lib/helper.js +132 -61
  24. package/lib/index.js +85 -32
  25. package/lib/middlewares/data-wrapping.js +65 -55
  26. package/lib/middlewares/index.js +30 -14
  27. package/lib/middlewares/table2resource.js +89 -52
  28. package/lib/plugin-manager.js +124 -55
  29. package/lib/plugin.js +65 -45
  30. package/lib/read-config.js +159 -64
  31. package/package.json +8 -13
  32. package/esm/acl/available-action.d.ts +0 -5
  33. package/esm/acl/available-action.js +0 -36
  34. package/esm/acl/available-action.js.map +0 -1
  35. package/esm/acl/index.d.ts +0 -2
  36. package/esm/acl/index.js +0 -19
  37. package/esm/acl/index.js.map +0 -1
  38. package/esm/app-manager.d.ts +0 -19
  39. package/esm/app-manager.js +0 -69
  40. package/esm/app-manager.js.map +0 -1
  41. package/esm/application.d.ts +0 -97
  42. package/esm/application.js +0 -156
  43. package/esm/application.js.map +0 -1
  44. package/esm/commands/console.d.ts +0 -4
  45. package/esm/commands/console.js +0 -25
  46. package/esm/commands/console.js.map +0 -1
  47. package/esm/commands/create-plugin/create-plugin.d.ts +0 -2
  48. package/esm/commands/create-plugin/create-plugin.js +0 -29
  49. package/esm/commands/create-plugin/create-plugin.js.map +0 -1
  50. package/esm/commands/create-plugin/index.d.ts +0 -5
  51. package/esm/commands/create-plugin/index.js +0 -6
  52. package/esm/commands/create-plugin/index.js.map +0 -1
  53. package/esm/commands/create-plugin/resources/templates/package-json.d.ts +0 -11
  54. package/esm/commands/create-plugin/resources/templates/package-json.js +0 -11
  55. package/esm/commands/create-plugin/resources/templates/package-json.js.map +0 -1
  56. package/esm/commands/create-plugin/resources/templates/plugin.d.ts +0 -4
  57. package/esm/commands/create-plugin/resources/templates/plugin.js +0 -12
  58. package/esm/commands/create-plugin/resources/templates/plugin.js.map +0 -1
  59. package/esm/commands/db-sync.d.ts +0 -5
  60. package/esm/commands/db-sync.js +0 -25
  61. package/esm/commands/db-sync.js.map +0 -1
  62. package/esm/commands/index.d.ts +0 -3
  63. package/esm/commands/index.js +0 -26
  64. package/esm/commands/index.js.map +0 -1
  65. package/esm/commands/install.d.ts +0 -5
  66. package/esm/commands/install.js +0 -23
  67. package/esm/commands/install.js.map +0 -1
  68. package/esm/commands/start.d.ts +0 -5
  69. package/esm/commands/start.js +0 -23
  70. package/esm/commands/start.js.map +0 -1
  71. package/esm/helper.d.ts +0 -7
  72. package/esm/helper.js +0 -59
  73. package/esm/helper.js.map +0 -1
  74. package/esm/index.d.ts +0 -7
  75. package/esm/index.js +0 -9
  76. package/esm/index.js.map +0 -1
  77. package/esm/middlewares/data-wrapping.d.ts +0 -3
  78. package/esm/middlewares/data-wrapping.js +0 -54
  79. package/esm/middlewares/data-wrapping.js.map +0 -1
  80. package/esm/middlewares/index.d.ts +0 -2
  81. package/esm/middlewares/index.js +0 -3
  82. package/esm/middlewares/index.js.map +0 -1
  83. package/esm/middlewares/table2resource.d.ts +0 -6
  84. package/esm/middlewares/table2resource.js +0 -51
  85. package/esm/middlewares/table2resource.js.map +0 -1
  86. package/esm/plugin-manager.d.ts +0 -23
  87. package/esm/plugin-manager.js +0 -57
  88. package/esm/plugin-manager.js.map +0 -1
  89. package/esm/plugin.d.ts +0 -32
  90. package/esm/plugin.js +0 -43
  91. package/esm/plugin.js.map +0 -1
  92. package/esm/read-config.d.ts +0 -8
  93. package/esm/read-config.js +0 -63
  94. package/esm/read-config.js.map +0 -1
  95. package/lib/acl/available-action.js.map +0 -1
  96. package/lib/acl/index.js.map +0 -1
  97. package/lib/app-manager.js.map +0 -1
  98. package/lib/application.js.map +0 -1
  99. package/lib/commands/console.js.map +0 -1
  100. package/lib/commands/create-plugin/create-plugin.d.ts +0 -2
  101. package/lib/commands/create-plugin/create-plugin.js +0 -31
  102. package/lib/commands/create-plugin/create-plugin.js.map +0 -1
  103. package/lib/commands/create-plugin/index.d.ts +0 -5
  104. package/lib/commands/create-plugin/index.js +0 -8
  105. package/lib/commands/create-plugin/index.js.map +0 -1
  106. package/lib/commands/create-plugin/resources/templates/package-json.d.ts +0 -11
  107. package/lib/commands/create-plugin/resources/templates/package-json.js +0 -13
  108. package/lib/commands/create-plugin/resources/templates/package-json.js.map +0 -1
  109. package/lib/commands/create-plugin/resources/templates/plugin.d.ts +0 -4
  110. package/lib/commands/create-plugin/resources/templates/plugin.js +0 -33
  111. package/lib/commands/create-plugin/resources/templates/plugin.js.map +0 -1
  112. package/lib/commands/db-sync.js.map +0 -1
  113. package/lib/commands/index.js.map +0 -1
  114. package/lib/commands/install.js.map +0 -1
  115. package/lib/commands/start.js.map +0 -1
  116. package/lib/helper.js.map +0 -1
  117. package/lib/index.js.map +0 -1
  118. package/lib/middlewares/data-wrapping.js.map +0 -1
  119. package/lib/middlewares/index.js.map +0 -1
  120. package/lib/middlewares/table2resource.js.map +0 -1
  121. package/lib/plugin-manager.js.map +0 -1
  122. package/lib/plugin.js.map +0 -1
  123. package/lib/read-config.js.map +0 -1
  124. package/tsconfig.build.json +0 -9
@@ -1,72 +1,167 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.loadConfiguration = exports.ConfigurationRepository = exports.readConfig = void 0;
16
- const lodash_1 = __importDefault(require("lodash"));
17
- const fs_1 = __importDefault(require("fs"));
18
- const path_1 = __importDefault(require("path"));
19
- function readConfig(dir) {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- const repository = new ConfigurationRepository();
22
- yield loadConfiguration(dir, repository);
23
- return repository.toObject();
24
- });
25
- }
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ConfigurationRepository = void 0;
7
+ exports.loadConfiguration = loadConfiguration;
26
8
  exports.readConfig = readConfig;
9
+
10
+ function _lodash() {
11
+ const data = _interopRequireDefault(require("lodash"));
12
+
13
+ _lodash = function _lodash() {
14
+ return data;
15
+ };
16
+
17
+ return data;
18
+ }
19
+
20
+ function _fs() {
21
+ const data = _interopRequireDefault(require("fs"));
22
+
23
+ _fs = function _fs() {
24
+ return data;
25
+ };
26
+
27
+ return data;
28
+ }
29
+
30
+ function _path() {
31
+ const data = _interopRequireDefault(require("path"));
32
+
33
+ _path = function _path() {
34
+ return data;
35
+ };
36
+
37
+ return data;
38
+ }
39
+
40
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
41
+
42
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
43
+
44
+ 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."); }
45
+
46
+ 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; }
47
+
48
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
49
+
50
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
51
+
52
+ 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); }
53
+
54
+ 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; }
55
+
56
+ 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); } }
57
+
58
+ 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); }); }; }
59
+
60
+ function readConfig(_x) {
61
+ return _readConfig.apply(this, arguments);
62
+ }
63
+
64
+ function _readConfig() {
65
+ _readConfig = _asyncToGenerator(function* (dir) {
66
+ const repository = new ConfigurationRepository();
67
+ yield loadConfiguration(dir, repository);
68
+ return repository.toObject();
69
+ });
70
+ return _readConfig.apply(this, arguments);
71
+ }
72
+
27
73
  class ConfigurationRepository {
28
- constructor() {
29
- this.items = new Map();
30
- }
31
- get(key, defaultValue = undefined) {
32
- if (this.items.has(key)) {
33
- return this.items.get(key);
34
- }
35
- return defaultValue;
74
+ constructor() {
75
+ this.items = new Map();
76
+ }
77
+
78
+ get(key, defaultValue = undefined) {
79
+ if (this.items.has(key)) {
80
+ return this.items.get(key);
36
81
  }
37
- set(key, value) {
38
- return this.items.set(key, value);
39
- }
40
- toObject() {
41
- const result = {};
42
- for (const [key, value] of this.items.entries()) {
43
- lodash_1.default.set(result, key, value);
44
- }
45
- return result;
82
+
83
+ return defaultValue;
84
+ }
85
+
86
+ set(key, value) {
87
+ return this.items.set(key, value);
88
+ }
89
+
90
+ toObject() {
91
+ const result = {};
92
+
93
+ var _iterator = _createForOfIteratorHelper(this.items.entries()),
94
+ _step;
95
+
96
+ try {
97
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
98
+ const _step$value = _slicedToArray(_step.value, 2),
99
+ key = _step$value[0],
100
+ value = _step$value[1];
101
+
102
+ _lodash().default.set(result, key, value);
103
+ }
104
+ } catch (err) {
105
+ _iterator.e(err);
106
+ } finally {
107
+ _iterator.f();
46
108
  }
109
+
110
+ return result;
111
+ }
112
+
47
113
  }
114
+
48
115
  exports.ConfigurationRepository = ConfigurationRepository;
49
- function loadConfiguration(configurationDir, repository) {
50
- return __awaiter(this, void 0, void 0, function* () {
51
- const getConfigurationFiles = (dir, prefix = []) => __awaiter(this, void 0, void 0, function* () {
52
- const files = yield fs_1.default.promises.readdir(dir, { withFileTypes: true });
53
- for (const file of files) {
54
- if (file.isDirectory()) {
55
- yield getConfigurationFiles(path_1.default.join(dir, file.name), [...prefix, file.name]);
56
- }
57
- else {
58
- if (!['ts', 'js'].includes(file.name.split('.').slice(1).join('.'))) {
59
- continue;
60
- }
61
- const filePath = path_1.default.join(dir, file.name);
62
- const keyName = path_1.default.parse(filePath).name;
63
- const configuration = require(filePath).default;
64
- repository.set([...prefix, keyName].join('.'), configuration);
65
- }
66
- }
67
- });
68
- yield getConfigurationFiles(configurationDir);
69
- });
116
+
117
+ function loadConfiguration(_x2, _x3) {
118
+ return _loadConfiguration.apply(this, arguments);
70
119
  }
71
- exports.loadConfiguration = loadConfiguration;
72
- //# sourceMappingURL=read-config.js.map
120
+
121
+ function _loadConfiguration() {
122
+ _loadConfiguration = _asyncToGenerator(function* (configurationDir, repository) {
123
+ const getConfigurationFiles = /*#__PURE__*/function () {
124
+ var _ref = _asyncToGenerator(function* (dir, prefix = []) {
125
+ const files = yield _fs().default.promises.readdir(dir, {
126
+ withFileTypes: true
127
+ });
128
+
129
+ var _iterator2 = _createForOfIteratorHelper(files),
130
+ _step2;
131
+
132
+ try {
133
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
134
+ const file = _step2.value;
135
+
136
+ if (file.isDirectory()) {
137
+ yield getConfigurationFiles(_path().default.join(dir, file.name), [...prefix, file.name]);
138
+ } else {
139
+ if (!['ts', 'js'].includes(file.name.split('.').slice(1).join('.'))) {
140
+ continue;
141
+ }
142
+
143
+ const filePath = _path().default.join(dir, file.name);
144
+
145
+ const keyName = _path().default.parse(filePath).name;
146
+
147
+ const configuration = require(filePath).default;
148
+
149
+ repository.set([...prefix, keyName].join('.'), configuration);
150
+ }
151
+ }
152
+ } catch (err) {
153
+ _iterator2.e(err);
154
+ } finally {
155
+ _iterator2.f();
156
+ }
157
+ });
158
+
159
+ return function getConfigurationFiles(_x4) {
160
+ return _ref.apply(this, arguments);
161
+ };
162
+ }();
163
+
164
+ yield getConfigurationFiles(configurationDir);
165
+ });
166
+ return _loadConfiguration.apply(this, arguments);
167
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/server",
3
- "version": "0.7.0-alpha.7",
3
+ "version": "0.7.0-alpha.72",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "license": "Apache-2.0",
@@ -10,20 +10,15 @@
10
10
  "url": "http://www.apache.org/licenses/LICENSE-2.0"
11
11
  }
12
12
  ],
13
- "scripts": {
14
- "build": "rimraf -rf lib esm dist && npm run build:cjs && npm run build:esm",
15
- "build:cjs": "tsc --project tsconfig.build.json",
16
- "build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir esm"
17
- },
18
13
  "dependencies": {
19
14
  "@koa/cors": "^3.1.0",
20
15
  "@koa/router": "^9.4.0",
21
- "@nocobase/acl": "0.7.0-alpha.7",
22
- "@nocobase/actions": "0.7.0-alpha.7",
23
- "@nocobase/database": "0.7.0-alpha.7",
24
- "@nocobase/resourcer": "0.7.0-alpha.7",
25
- "commander": "^8.1.0",
26
- "dotenv": "^8.2.0",
16
+ "@nocobase/acl": "0.7.0-alpha.72",
17
+ "@nocobase/actions": "0.7.0-alpha.72",
18
+ "@nocobase/database": "0.7.0-alpha.72",
19
+ "@nocobase/resourcer": "0.7.0-alpha.72",
20
+ "chalk": "^4.1.1",
21
+ "commander": "^9.2.0",
27
22
  "find-package-json": "^1.2.0",
28
23
  "i18next": "^21.3.2",
29
24
  "koa": "^2.13.4",
@@ -31,5 +26,5 @@
31
26
  "koa-static": "^5.0.0",
32
27
  "lodash": "^4.17.21"
33
28
  },
34
- "gitHead": "58b599aaec7ac28a536e6ba29b9990b05164a20b"
29
+ "gitHead": "db24b85879b0f911458914b49ea9644fd7eb7562"
35
30
  }
@@ -1,5 +0,0 @@
1
- import { AvailableActionOptions } from '@nocobase/acl';
2
- declare const availableActions: {
3
- [key: string]: AvailableActionOptions;
4
- };
5
- export { availableActions };
@@ -1,36 +0,0 @@
1
- const availableActions = {
2
- create: {
3
- displayName: '{{t("Add new")}}',
4
- type: 'new-data',
5
- onNewRecord: true,
6
- allowConfigureFields: true,
7
- },
8
- // import: {
9
- // displayName: '{{t("Import")}}',
10
- // type: 'new-data',
11
- // scope: false,
12
- // },
13
- export: {
14
- displayName: '{{t("Export")}}',
15
- type: 'old-data',
16
- allowConfigureFields: true,
17
- },
18
- view: {
19
- displayName: '{{t("View")}}',
20
- type: 'old-data',
21
- aliases: ['get', 'list'],
22
- allowConfigureFields: true,
23
- },
24
- update: {
25
- displayName: '{{t("Edit")}}',
26
- type: 'old-data',
27
- aliases: ['update', 'move'],
28
- allowConfigureFields: true,
29
- },
30
- destroy: {
31
- displayName: '{{t("Delete")}}',
32
- type: 'old-data',
33
- },
34
- };
35
- export { availableActions };
36
- //# sourceMappingURL=available-action.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"available-action.js","sourceRoot":"","sources":["../../src/acl/available-action.ts"],"names":[],"mappings":"AAEA,MAAM,gBAAgB,GAElB;IACF,MAAM,EAAE;QACN,WAAW,EAAE,kBAAkB;QAC/B,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,IAAI;QACjB,oBAAoB,EAAE,IAAI;KAC3B;IACD,YAAY;IACZ,oCAAoC;IACpC,sBAAsB;IACtB,kBAAkB;IAClB,KAAK;IACL,MAAM,EAAE;QACN,WAAW,EAAE,iBAAiB;QAC9B,IAAI,EAAE,UAAU;QAChB,oBAAoB,EAAE,IAAI;KAC3B;IACD,IAAI,EAAE;QACJ,WAAW,EAAE,eAAe;QAC5B,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;QACxB,oBAAoB,EAAE,IAAI;KAC3B;IACD,MAAM,EAAE;QACN,WAAW,EAAE,eAAe;QAC5B,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC3B,oBAAoB,EAAE,IAAI;KAC3B;IACD,OAAO,EAAE;QACP,WAAW,EAAE,iBAAiB;QAC9B,IAAI,EAAE,UAAU;KACjB;CACF,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["import { AvailableActionOptions } from '@nocobase/acl';\n\nconst availableActions: {\n [key: string]: AvailableActionOptions;\n} = {\n create: {\n displayName: '{{t(\"Add new\")}}',\n type: 'new-data',\n onNewRecord: true,\n allowConfigureFields: true,\n },\n // import: {\n // displayName: '{{t(\"Import\")}}',\n // type: 'new-data',\n // scope: false,\n // },\n export: {\n displayName: '{{t(\"Export\")}}',\n type: 'old-data',\n allowConfigureFields: true,\n },\n view: {\n displayName: '{{t(\"View\")}}',\n type: 'old-data',\n aliases: ['get', 'list'],\n allowConfigureFields: true,\n },\n update: {\n displayName: '{{t(\"Edit\")}}',\n type: 'old-data',\n aliases: ['update', 'move'],\n allowConfigureFields: true,\n },\n destroy: {\n displayName: '{{t(\"Delete\")}}',\n type: 'old-data',\n },\n};\n\nexport { availableActions };\n"]}
@@ -1,2 +0,0 @@
1
- import { ACL } from '@nocobase/acl';
2
- export declare function createACL(): ACL;
package/esm/acl/index.js DELETED
@@ -1,19 +0,0 @@
1
- import { ACL } from '@nocobase/acl';
2
- import { availableActions } from './available-action';
3
- const configureResources = [
4
- 'roles',
5
- 'collections',
6
- 'roles.collections',
7
- 'roles.resources',
8
- 'rolesResourcesScopes',
9
- 'availableActions',
10
- ];
11
- export function createACL() {
12
- const acl = new ACL();
13
- for (const [actionName, actionParams] of Object.entries(availableActions)) {
14
- acl.setAvailableAction(actionName, actionParams);
15
- }
16
- acl.registerConfigResources(configureResources);
17
- return acl;
18
- }
19
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/acl/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,kBAAkB,GAAG;IACzB,OAAO;IACP,aAAa;IACb,mBAAmB;IACnB,iBAAiB;IACjB,sBAAsB;IACtB,kBAAkB;CACnB,CAAC;AAEF,MAAM,UAAU,SAAS;IACvB,MAAM,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;IAEtB,KAAK,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE;QACzE,GAAG,CAAC,kBAAkB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;KAClD;IAED,GAAG,CAAC,uBAAuB,CAAC,kBAAkB,CAAC,CAAC;IAEhD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { ACL } from '@nocobase/acl';\nimport { availableActions } from './available-action';\n\nconst configureResources = [\n 'roles',\n 'collections',\n 'roles.collections',\n 'roles.resources',\n 'rolesResourcesScopes',\n 'availableActions',\n];\n\nexport function createACL() {\n const acl = new ACL();\n\n for (const [actionName, actionParams] of Object.entries(availableActions)) {\n acl.setAvailableAction(actionName, actionParams);\n }\n\n acl.registerConfigResources(configureResources);\n\n return acl;\n}\n"]}
@@ -1,19 +0,0 @@
1
- /// <reference types="node" />
2
- import Application, { ApplicationOptions } from './application';
3
- import http, { IncomingMessage } from 'http';
4
- import EventEmitter from 'events';
5
- declare type AppSelector = (req: IncomingMessage) => Application | string | undefined | null;
6
- export declare class AppManager extends EventEmitter {
7
- private app;
8
- applications: Map<string, Application>;
9
- constructor(app: Application);
10
- appSelector: AppSelector;
11
- createApplication(name: string, options: ApplicationOptions): Application;
12
- removeApplication(name: string): Promise<void>;
13
- setAppSelector(selector: AppSelector): void;
14
- listen(...args: any[]): http.Server;
15
- getApplication(appName: string): Promise<null | Application>;
16
- callback(): (req: any, res: any) => Promise<void>;
17
- emitAsync: (event: string | symbol, ...args: any[]) => Promise<boolean>;
18
- }
19
- export {};
@@ -1,69 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import Application from './application';
11
- import http from 'http';
12
- import EventEmitter from 'events';
13
- import { applyMixins, AsyncEmitter } from '@nocobase/utils';
14
- export class AppManager extends EventEmitter {
15
- constructor(app) {
16
- super();
17
- this.app = app;
18
- this.applications = new Map();
19
- this.appSelector = (req) => this.app;
20
- app.on('beforeStop', (mainApp, options) => __awaiter(this, void 0, void 0, function* () {
21
- return yield Promise.all([...this.applications.values()].map((application) => application.stop(options)));
22
- }));
23
- app.on('afterDestroy', (mainApp, options) => __awaiter(this, void 0, void 0, function* () {
24
- return yield Promise.all([...this.applications.values()].map((application) => application.destroy(options)));
25
- }));
26
- }
27
- createApplication(name, options) {
28
- const application = new Application(options);
29
- this.applications.set(name, application);
30
- return application;
31
- }
32
- removeApplication(name) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- const application = this.applications.get(name);
35
- if (!application) {
36
- return;
37
- }
38
- yield application.destroy();
39
- this.applications.delete(name);
40
- });
41
- }
42
- setAppSelector(selector) {
43
- this.appSelector = selector;
44
- }
45
- listen(...args) {
46
- const server = http.createServer(this.callback());
47
- return server.listen(...args);
48
- }
49
- getApplication(appName) {
50
- return __awaiter(this, void 0, void 0, function* () {
51
- yield this.emitAsync('beforeGetApplication', {
52
- appManager: this,
53
- name: appName,
54
- });
55
- return this.applications.get(appName);
56
- });
57
- }
58
- callback() {
59
- return (req, res) => __awaiter(this, void 0, void 0, function* () {
60
- let handleApp = this.appSelector(req) || this.app;
61
- if (typeof handleApp === 'string') {
62
- handleApp = (yield this.getApplication(handleApp)) || this.app;
63
- }
64
- handleApp.callback()(req, res);
65
- });
66
- }
67
- }
68
- applyMixins(AppManager, [AsyncEmitter]);
69
- //# sourceMappingURL=app-manager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"app-manager.js","sourceRoot":"","sources":["../src/app-manager.ts"],"names":[],"mappings":"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","sourcesContent":["import Application, { ApplicationOptions } from './application';\nimport http, { IncomingMessage } from 'http';\nimport EventEmitter from 'events';\nimport { applyMixins, AsyncEmitter } from '@nocobase/utils';\n\ntype AppSelector = (req: IncomingMessage) => Application | string | undefined | null;\n\nexport class AppManager extends EventEmitter {\n public applications: Map<string, Application> = new Map<string, Application>();\n\n constructor(private app: Application) {\n super();\n\n app.on('beforeStop', async (mainApp, options) => {\n return await Promise.all(\n [...this.applications.values()].map((application: Application) => application.stop(options)),\n );\n });\n\n app.on('afterDestroy', async (mainApp, options) => {\n return await Promise.all(\n [...this.applications.values()].map((application: Application) => application.destroy(options)),\n );\n });\n }\n\n appSelector: AppSelector = (req: IncomingMessage) => this.app;\n\n createApplication(name: string, options: ApplicationOptions): Application {\n const application = new Application(options);\n this.applications.set(name, application);\n return application;\n }\n\n async removeApplication(name: string) {\n const application = this.applications.get(name);\n if (!application) {\n return;\n }\n\n await application.destroy();\n\n this.applications.delete(name);\n }\n\n setAppSelector(selector: AppSelector) {\n this.appSelector = selector;\n }\n\n listen(...args) {\n const server = http.createServer(this.callback());\n return server.listen(...args);\n }\n\n async getApplication(appName: string): Promise<null | Application> {\n await this.emitAsync('beforeGetApplication', {\n appManager: this,\n name: appName,\n });\n\n return this.applications.get(appName);\n }\n\n callback() {\n return async (req, res) => {\n let handleApp = this.appSelector(req) || this.app;\n\n if (typeof handleApp === 'string') {\n handleApp = (await this.getApplication(handleApp)) || this.app;\n }\n\n handleApp.callback()(req, res);\n };\n }\n\n emitAsync: (event: string | symbol, ...args: any[]) => Promise<boolean>;\n}\n\napplyMixins(AppManager, [AsyncEmitter]);\n"]}
@@ -1,97 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="koa-bodyparser" />
3
- import { ACL } from '@nocobase/acl';
4
- import Database, { CollectionOptions, IDatabaseOptions } from '@nocobase/database';
5
- import Resourcer, { ResourceOptions } from '@nocobase/resourcer';
6
- import { AsyncEmitter } from '@nocobase/utils';
7
- import { Command, CommandOptions } from 'commander';
8
- import { Server } from 'http';
9
- import { i18n, InitOptions } from 'i18next';
10
- import Koa from 'koa';
11
- import { AppManager } from './app-manager';
12
- import { Plugin } from './plugin';
13
- import { InstallOptions, PluginManager } from './plugin-manager';
14
- export declare type PluginConfiguration = string | [string, any];
15
- export declare type PluginsConfigurations = Array<PluginConfiguration>;
16
- export interface ResourcerOptions {
17
- prefix?: string;
18
- }
19
- export interface ApplicationOptions {
20
- database?: IDatabaseOptions | Database;
21
- resourcer?: ResourcerOptions;
22
- bodyParser?: any;
23
- cors?: any;
24
- dataWrapping?: boolean;
25
- registerActions?: boolean;
26
- i18n?: i18n | InitOptions;
27
- plugins?: PluginsConfigurations;
28
- }
29
- interface DefaultState {
30
- currentUser?: any;
31
- [key: string]: any;
32
- }
33
- interface DefaultContext {
34
- db: Database;
35
- resourcer: Resourcer;
36
- [key: string]: any;
37
- }
38
- interface MiddlewareOptions {
39
- name?: string;
40
- resourceName?: string;
41
- resourceNames?: string[];
42
- insertBefore?: string;
43
- insertAfter?: string;
44
- }
45
- interface ActionsOptions {
46
- resourceName?: string;
47
- resourceNames?: string[];
48
- }
49
- interface ListenOptions {
50
- port?: number | undefined;
51
- host?: string | undefined;
52
- backlog?: number | undefined;
53
- path?: string | undefined;
54
- exclusive?: boolean | undefined;
55
- readableAll?: boolean | undefined;
56
- writableAll?: boolean | undefined;
57
- /**
58
- * @default false
59
- */
60
- ipv6Only?: boolean | undefined;
61
- signal?: AbortSignal | undefined;
62
- }
63
- interface StartOptions {
64
- cliArgs?: any[];
65
- listen?: ListenOptions;
66
- }
67
- export declare class Application<StateT = DefaultState, ContextT = DefaultContext> extends Koa implements AsyncEmitter {
68
- options: ApplicationOptions;
69
- readonly db: Database;
70
- readonly resourcer: Resourcer;
71
- readonly cli: Command;
72
- readonly i18n: i18n;
73
- readonly pm: PluginManager;
74
- readonly acl: ACL;
75
- readonly appManager: AppManager;
76
- protected plugins: Map<string, Plugin<any>>;
77
- listenServer: Server;
78
- constructor(options: ApplicationOptions);
79
- plugin<O = any>(pluginClass: any, options?: O): Plugin<O>;
80
- loadPluginConfig(pluginsConfigurations: PluginsConfigurations): void;
81
- use<NewStateT = {}, NewContextT = {}>(middleware: Koa.Middleware<StateT & NewStateT, ContextT & NewContextT>, options?: MiddlewareOptions): Koa<Koa.DefaultState & StateT & NewStateT, Koa.DefaultContext & ContextT & NewContextT>;
82
- collection(options: CollectionOptions): import("@nocobase/database").Collection<any, any>;
83
- resource(options: ResourceOptions): import("@nocobase/resourcer").Resource;
84
- actions(handlers: any, options?: ActionsOptions): void;
85
- command(name: string, desc?: string, opts?: CommandOptions): Command;
86
- findCommand(name: string): Command;
87
- load(): Promise<void>;
88
- getPlugin<P extends Plugin>(name: string): P;
89
- parse(argv?: string[]): Promise<Command>;
90
- start(options?: StartOptions): Promise<void>;
91
- listen(...args: any[]): Server;
92
- stop(options?: any): Promise<void>;
93
- destroy(options?: any): Promise<void>;
94
- install(options?: InstallOptions): Promise<void>;
95
- emitAsync: (event: string | symbol, ...args: any[]) => Promise<boolean>;
96
- }
97
- export default Application;