@nocobase/server 0.7.0-alpha.34 → 0.7.0-alpha.57

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 (127) hide show
  1. package/lib/acl/available-action.js +37 -35
  2. package/lib/acl/index.js +45 -21
  3. package/lib/app-manager.js +151 -83
  4. package/lib/application.d.ts +3 -2
  5. package/lib/application.js +291 -162
  6. package/lib/commands/console.d.ts +2 -3
  7. package/lib/commands/console.js +33 -24
  8. package/lib/commands/db-auth.d.ts +2 -4
  9. package/lib/commands/db-auth.js +23 -13
  10. package/lib/commands/db-clean.d.ts +3 -0
  11. package/lib/commands/db-clean.js +27 -0
  12. package/lib/commands/db-sync.d.ts +2 -4
  13. package/lib/commands/db-sync.js +25 -23
  14. package/lib/commands/index.d.ts +1 -2
  15. package/lib/commands/index.js +29 -30
  16. package/lib/commands/install.d.ts +2 -4
  17. package/lib/commands/install.js +64 -42
  18. package/lib/commands/start.d.ts +2 -4
  19. package/lib/commands/start.js +26 -22
  20. package/lib/commands/upgrade.d.ts +6 -0
  21. package/lib/commands/upgrade.js +45 -0
  22. package/lib/helper.js +132 -61
  23. package/lib/index.js +85 -32
  24. package/lib/middlewares/data-wrapping.js +63 -55
  25. package/lib/middlewares/index.js +30 -14
  26. package/lib/middlewares/table2resource.js +89 -52
  27. package/lib/plugin-manager.js +124 -55
  28. package/lib/plugin.js +65 -45
  29. package/lib/read-config.js +159 -64
  30. package/package.json +7 -13
  31. package/esm/acl/available-action.d.ts +0 -5
  32. package/esm/acl/available-action.js +0 -36
  33. package/esm/acl/available-action.js.map +0 -1
  34. package/esm/acl/index.d.ts +0 -2
  35. package/esm/acl/index.js +0 -19
  36. package/esm/acl/index.js.map +0 -1
  37. package/esm/app-manager.d.ts +0 -19
  38. package/esm/app-manager.js +0 -80
  39. package/esm/app-manager.js.map +0 -1
  40. package/esm/application.d.ts +0 -97
  41. package/esm/application.js +0 -165
  42. package/esm/application.js.map +0 -1
  43. package/esm/commands/console.d.ts +0 -4
  44. package/esm/commands/console.js +0 -25
  45. package/esm/commands/console.js.map +0 -1
  46. package/esm/commands/create-plugin/create-plugin.d.ts +0 -2
  47. package/esm/commands/create-plugin/create-plugin.js +0 -29
  48. package/esm/commands/create-plugin/create-plugin.js.map +0 -1
  49. package/esm/commands/create-plugin/index.d.ts +0 -5
  50. package/esm/commands/create-plugin/index.js +0 -6
  51. package/esm/commands/create-plugin/index.js.map +0 -1
  52. package/esm/commands/create-plugin/resources/templates/package-json.d.ts +0 -11
  53. package/esm/commands/create-plugin/resources/templates/package-json.js +0 -11
  54. package/esm/commands/create-plugin/resources/templates/package-json.js.map +0 -1
  55. package/esm/commands/create-plugin/resources/templates/plugin.d.ts +0 -4
  56. package/esm/commands/create-plugin/resources/templates/plugin.js +0 -12
  57. package/esm/commands/create-plugin/resources/templates/plugin.js.map +0 -1
  58. package/esm/commands/db-auth.d.ts +0 -5
  59. package/esm/commands/db-auth.js +0 -14
  60. package/esm/commands/db-auth.js.map +0 -1
  61. package/esm/commands/db-sync.d.ts +0 -5
  62. package/esm/commands/db-sync.js +0 -25
  63. package/esm/commands/db-sync.js.map +0 -1
  64. package/esm/commands/index.d.ts +0 -3
  65. package/esm/commands/index.js +0 -27
  66. package/esm/commands/index.js.map +0 -1
  67. package/esm/commands/install.d.ts +0 -5
  68. package/esm/commands/install.js +0 -46
  69. package/esm/commands/install.js.map +0 -1
  70. package/esm/commands/start.d.ts +0 -5
  71. package/esm/commands/start.js +0 -25
  72. package/esm/commands/start.js.map +0 -1
  73. package/esm/helper.d.ts +0 -7
  74. package/esm/helper.js +0 -59
  75. package/esm/helper.js.map +0 -1
  76. package/esm/index.d.ts +0 -7
  77. package/esm/index.js +0 -9
  78. package/esm/index.js.map +0 -1
  79. package/esm/middlewares/data-wrapping.d.ts +0 -3
  80. package/esm/middlewares/data-wrapping.js +0 -54
  81. package/esm/middlewares/data-wrapping.js.map +0 -1
  82. package/esm/middlewares/index.d.ts +0 -2
  83. package/esm/middlewares/index.js +0 -3
  84. package/esm/middlewares/index.js.map +0 -1
  85. package/esm/middlewares/table2resource.d.ts +0 -6
  86. package/esm/middlewares/table2resource.js +0 -51
  87. package/esm/middlewares/table2resource.js.map +0 -1
  88. package/esm/plugin-manager.d.ts +0 -23
  89. package/esm/plugin-manager.js +0 -57
  90. package/esm/plugin-manager.js.map +0 -1
  91. package/esm/plugin.d.ts +0 -32
  92. package/esm/plugin.js +0 -43
  93. package/esm/plugin.js.map +0 -1
  94. package/esm/read-config.d.ts +0 -8
  95. package/esm/read-config.js +0 -63
  96. package/esm/read-config.js.map +0 -1
  97. package/lib/acl/available-action.js.map +0 -1
  98. package/lib/acl/index.js.map +0 -1
  99. package/lib/app-manager.js.map +0 -1
  100. package/lib/application.js.map +0 -1
  101. package/lib/commands/console.js.map +0 -1
  102. package/lib/commands/create-plugin/create-plugin.d.ts +0 -2
  103. package/lib/commands/create-plugin/create-plugin.js +0 -31
  104. package/lib/commands/create-plugin/create-plugin.js.map +0 -1
  105. package/lib/commands/create-plugin/index.d.ts +0 -5
  106. package/lib/commands/create-plugin/index.js +0 -8
  107. package/lib/commands/create-plugin/index.js.map +0 -1
  108. package/lib/commands/create-plugin/resources/templates/package-json.d.ts +0 -11
  109. package/lib/commands/create-plugin/resources/templates/package-json.js +0 -13
  110. package/lib/commands/create-plugin/resources/templates/package-json.js.map +0 -1
  111. package/lib/commands/create-plugin/resources/templates/plugin.d.ts +0 -4
  112. package/lib/commands/create-plugin/resources/templates/plugin.js +0 -33
  113. package/lib/commands/create-plugin/resources/templates/plugin.js.map +0 -1
  114. package/lib/commands/db-auth.js.map +0 -1
  115. package/lib/commands/db-sync.js.map +0 -1
  116. package/lib/commands/index.js.map +0 -1
  117. package/lib/commands/install.js.map +0 -1
  118. package/lib/commands/start.js.map +0 -1
  119. package/lib/helper.js.map +0 -1
  120. package/lib/index.js.map +0 -1
  121. package/lib/middlewares/data-wrapping.js.map +0 -1
  122. package/lib/middlewares/index.js.map +0 -1
  123. package/lib/middlewares/table2resource.js.map +0 -1
  124. package/lib/plugin-manager.js.map +0 -1
  125. package/lib/plugin.js.map +0 -1
  126. package/lib/read-config.js.map +0 -1
  127. package/tsconfig.build.json +0 -9
@@ -1,172 +1,301 @@
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());
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.Application = void 0;
7
+
8
+ function _actions() {
9
+ const data = require("@nocobase/actions");
10
+
11
+ _actions = function _actions() {
12
+ return data;
13
+ };
14
+
15
+ return data;
16
+ }
17
+
18
+ function _utils() {
19
+ const data = require("@nocobase/utils");
20
+
21
+ _utils = function _utils() {
22
+ return data;
23
+ };
24
+
25
+ return data;
26
+ }
27
+
28
+ function _commander() {
29
+ const data = require("commander");
30
+
31
+ _commander = function _commander() {
32
+ return data;
33
+ };
34
+
35
+ return data;
36
+ }
37
+
38
+ function _koa() {
39
+ const data = _interopRequireDefault(require("koa"));
40
+
41
+ _koa = function _koa() {
42
+ return data;
43
+ };
44
+
45
+ return data;
46
+ }
47
+
48
+ function _lodash() {
49
+ const data = require("lodash");
50
+
51
+ _lodash = function _lodash() {
52
+ return data;
53
+ };
54
+
55
+ return data;
56
+ }
57
+
58
+ var _acl = require("./acl");
59
+
60
+ var _appManager = require("./app-manager");
61
+
62
+ var _commands = require("./commands");
63
+
64
+ var _helper = require("./helper");
65
+
66
+ var _pluginManager = require("./plugin-manager");
67
+
68
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
69
+
70
+ 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); } }
71
+
72
+ 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); }); }; }
73
+
74
+ 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(_e) { throw _e; }, 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(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
75
+
76
+ 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); }
77
+
78
+ 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; }
79
+
80
+ const packageJson = require('../package.json');
81
+
82
+ class Application extends _koa().default {
83
+ constructor(options) {
84
+ super();
85
+ this.options = void 0;
86
+ this.db = void 0;
87
+ this.resourcer = void 0;
88
+ this.cli = void 0;
89
+ this.i18n = void 0;
90
+ this.pm = void 0;
91
+ this.acl = void 0;
92
+ this.appManager = void 0;
93
+ this.plugins = new Map();
94
+ this.listenServer = void 0;
95
+ this.options = options;
96
+ this.acl = (0, _acl.createACL)();
97
+ this.db = (0, _helper.createDatabase)(options);
98
+ this.resourcer = (0, _helper.createResourcer)(options);
99
+ this.cli = new (_commander().Command)('nocobase').usage('[command] [options]');
100
+ this.i18n = (0, _helper.createI18n)(options);
101
+ this.pm = new _pluginManager.PluginManager({
102
+ app: this
9
103
  });
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.Application = void 0;
16
- const actions_1 = require("@nocobase/actions");
17
- const utils_1 = require("@nocobase/utils");
18
- const koa_1 = __importDefault(require("koa"));
19
- const lodash_1 = require("lodash");
20
- const acl_1 = require("./acl");
21
- const app_manager_1 = require("./app-manager");
22
- const commands_1 = require("./commands");
23
- const helper_1 = require("./helper");
24
- const plugin_manager_1 = require("./plugin-manager");
25
- class Application extends koa_1.default {
26
- constructor(options) {
27
- super();
28
- this.options = options;
29
- this.plugins = new Map();
30
- this.acl = (0, acl_1.createACL)();
31
- this.db = (0, helper_1.createDatabase)(options);
32
- this.resourcer = (0, helper_1.createResourcer)(options);
33
- this.cli = (0, commands_1.createCli)(this);
34
- this.i18n = (0, helper_1.createI18n)(options);
35
- this.pm = new plugin_manager_1.PluginManager({
36
- app: this,
37
- });
38
- this.appManager = new app_manager_1.AppManager(this);
39
- (0, helper_1.registerMiddlewares)(this, options);
40
- if (options.registerActions !== false) {
41
- (0, actions_1.registerActions)(this);
42
- }
43
- this.loadPluginConfig(options.plugins || []);
104
+ this.appManager = new _appManager.AppManager(this);
105
+ (0, _helper.registerMiddlewares)(this, options);
106
+
107
+ if (options.registerActions !== false) {
108
+ (0, _actions().registerActions)(this);
44
109
  }
45
- plugin(pluginClass, options) {
46
- return this.pm.add(pluginClass, options);
47
- }
48
- loadPluginConfig(pluginsConfigurations) {
49
- for (let pluginConfiguration of pluginsConfigurations) {
50
- if (typeof pluginConfiguration == 'string') {
51
- pluginConfiguration = [pluginConfiguration, {}];
52
- }
53
- const plugin = plugin_manager_1.PluginManager.resolvePlugin(pluginConfiguration[0]);
54
- const pluginOptions = pluginConfiguration[1];
55
- this.plugin(plugin, pluginOptions);
110
+
111
+ this.loadPluginConfig(options.plugins || []);
112
+ (0, _commands.registerCli)(this);
113
+ }
114
+
115
+ getVersion() {
116
+ return packageJson.version;
117
+ }
118
+
119
+ plugin(pluginClass, options) {
120
+ return this.pm.add(pluginClass, options);
121
+ }
122
+
123
+ loadPluginConfig(pluginsConfigurations) {
124
+ var _iterator = _createForOfIteratorHelper(pluginsConfigurations),
125
+ _step;
126
+
127
+ try {
128
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
129
+ let pluginConfiguration = _step.value;
130
+
131
+ if (typeof pluginConfiguration == 'string') {
132
+ pluginConfiguration = [pluginConfiguration, {}];
56
133
  }
134
+
135
+ const plugin = _pluginManager.PluginManager.resolvePlugin(pluginConfiguration[0]);
136
+
137
+ const pluginOptions = pluginConfiguration[1];
138
+ this.plugin(plugin, pluginOptions);
139
+ }
140
+ } catch (err) {
141
+ _iterator.e(err);
142
+ } finally {
143
+ _iterator.f();
57
144
  }
58
- use(middleware, options) {
59
- // @ts-ignore
60
- return super.use(middleware);
61
- }
62
- collection(options) {
63
- return this.db.collection(options);
64
- }
65
- resource(options) {
66
- return this.resourcer.define(options);
67
- }
68
- actions(handlers, options) {
69
- return this.resourcer.registerActions(handlers);
70
- }
71
- command(name, desc, opts) {
72
- return this.cli.command(name, desc, opts);
73
- }
74
- findCommand(name) {
75
- return this.cli._findCommand(name);
76
- }
77
- load() {
78
- return __awaiter(this, void 0, void 0, function* () {
79
- yield this.pm.load();
145
+ }
146
+
147
+ use(middleware, options) {
148
+ // @ts-ignore
149
+ return super.use(middleware);
150
+ }
151
+
152
+ collection(options) {
153
+ return this.db.collection(options);
154
+ }
155
+
156
+ resource(options) {
157
+ return this.resourcer.define(options);
158
+ }
159
+
160
+ actions(handlers, options) {
161
+ return this.resourcer.registerActions(handlers);
162
+ }
163
+
164
+ command(name, desc, opts) {
165
+ return this.cli.command(name, desc, opts).allowUnknownOption();
166
+ }
167
+
168
+ findCommand(name) {
169
+ return this.cli._findCommand(name);
170
+ }
171
+
172
+ load() {
173
+ var _this = this;
174
+
175
+ return _asyncToGenerator(function* () {
176
+ yield _this.pm.load();
177
+ })();
178
+ }
179
+
180
+ getPlugin(name) {
181
+ return this.pm.get(name);
182
+ }
183
+
184
+ parse(argv = process.argv) {
185
+ var _this2 = this;
186
+
187
+ return _asyncToGenerator(function* () {
188
+ yield _this2.load();
189
+ return _this2.cli.parseAsync(argv);
190
+ })();
191
+ }
192
+
193
+ start(options = {}) {
194
+ var _this3 = this;
195
+
196
+ return _asyncToGenerator(function* () {
197
+ var _options$listen;
198
+
199
+ // reconnect database
200
+ if (_this3.db.closed()) {
201
+ yield _this3.db.reconnect();
202
+ }
203
+
204
+ yield _this3.emitAsync('beforeStart', _this3, options);
205
+
206
+ if (options === null || options === void 0 ? void 0 : (_options$listen = options.listen) === null || _options$listen === void 0 ? void 0 : _options$listen.port) {
207
+ const listen = () => new Promise((resolve, reject) => {
208
+ const Server = _this3.listen(options === null || options === void 0 ? void 0 : options.listen, () => {
209
+ resolve(Server);
210
+ });
211
+
212
+ Server.on('error', err => {
213
+ reject(err);
214
+ });
80
215
  });
81
- }
82
- getPlugin(name) {
83
- return this.pm.get(name);
84
- }
85
- parse(argv = process.argv) {
86
- return __awaiter(this, void 0, void 0, function* () {
87
- yield this.load();
88
- return this.cli.parseAsync(argv);
89
- });
90
- }
91
- start(options = {}) {
92
- var _a;
93
- return __awaiter(this, void 0, void 0, function* () {
94
- // reconnect database
95
- if (this.db.closed()) {
96
- yield this.db.reconnect();
97
- }
98
- yield this.emitAsync('beforeStart', this, options);
99
- if ((_a = options === null || options === void 0 ? void 0 : options.listen) === null || _a === void 0 ? void 0 : _a.port) {
100
- const listen = () => new Promise((resolve, reject) => {
101
- const Server = this.listen(options === null || options === void 0 ? void 0 : options.listen, () => {
102
- resolve(Server);
103
- });
104
- Server.on('error', (err) => {
105
- reject(err);
106
- });
107
- });
108
- try {
109
- //@ts-ignore
110
- this.listenServer = yield listen();
111
- }
112
- catch (e) {
113
- console.error(e);
114
- process.exit(1);
115
- }
116
- }
117
- yield this.emitAsync('afterStart', this, options);
118
- });
119
- }
120
- listen(...args) {
121
- return this.appManager.listen(...args);
122
- }
123
- stop(options = {}) {
124
- return __awaiter(this, void 0, void 0, function* () {
125
- yield this.emitAsync('beforeStop', this, options);
126
- try {
127
- // close database connection
128
- // silent if database already closed
129
- yield this.db.close();
130
- }
131
- catch (e) {
132
- console.log(e);
133
- }
134
- // close http server
135
- if (this.listenServer) {
136
- const closeServer = () => new Promise((resolve, reject) => {
137
- this.listenServer.close((err) => {
138
- if (err) {
139
- return reject(err);
140
- }
141
- this.listenServer = null;
142
- resolve(true);
143
- });
144
- });
145
- yield closeServer();
146
- }
147
- yield this.emitAsync('afterStop', this, options);
148
- });
149
- }
150
- destroy(options = {}) {
151
- return __awaiter(this, void 0, void 0, function* () {
152
- yield this.emitAsync('beforeDestroy', this, options);
153
- yield this.stop(options);
154
- yield this.emitAsync('afterDestroy', this, options);
155
- });
156
- }
157
- install(options = {}) {
158
- return __awaiter(this, void 0, void 0, function* () {
159
- yield this.emitAsync('beforeInstall', this, options);
160
- if (options === null || options === void 0 ? void 0 : options.clean) {
161
- yield this.db.clean((0, lodash_1.isBoolean)(options.clean) ? { drop: options.clean } : options.clean);
216
+
217
+ try {
218
+ //@ts-ignore
219
+ _this3.listenServer = yield listen();
220
+ } catch (e) {
221
+ console.error(e);
222
+ process.exit(1);
223
+ }
224
+ }
225
+
226
+ yield _this3.emitAsync('afterStart', _this3, options);
227
+ })();
228
+ }
229
+
230
+ listen(...args) {
231
+ return this.appManager.listen(...args);
232
+ }
233
+
234
+ stop(options = {}) {
235
+ var _this4 = this;
236
+
237
+ return _asyncToGenerator(function* () {
238
+ yield _this4.emitAsync('beforeStop', _this4, options);
239
+
240
+ try {
241
+ // close database connection
242
+ // silent if database already closed
243
+ yield _this4.db.close();
244
+ } catch (e) {
245
+ console.log(e);
246
+ } // close http server
247
+
248
+
249
+ if (_this4.listenServer) {
250
+ const closeServer = () => new Promise((resolve, reject) => {
251
+ _this4.listenServer.close(err => {
252
+ if (err) {
253
+ return reject(err);
162
254
  }
163
- yield this.db.sync(options === null || options === void 0 ? void 0 : options.sync);
164
- yield this.pm.install(options);
165
- yield this.emitAsync('afterInstall', this, options);
255
+
256
+ _this4.listenServer = null;
257
+ resolve(true);
258
+ });
166
259
  });
167
- }
260
+
261
+ yield closeServer();
262
+ }
263
+
264
+ yield _this4.emitAsync('afterStop', _this4, options);
265
+ })();
266
+ }
267
+
268
+ destroy(options = {}) {
269
+ var _this5 = this;
270
+
271
+ return _asyncToGenerator(function* () {
272
+ yield _this5.emitAsync('beforeDestroy', _this5, options);
273
+ yield _this5.stop(options);
274
+ yield _this5.emitAsync('afterDestroy', _this5, options);
275
+ })();
276
+ }
277
+
278
+ install(options = {}) {
279
+ var _this6 = this;
280
+
281
+ return _asyncToGenerator(function* () {
282
+ yield _this6.emitAsync('beforeInstall', _this6, options);
283
+
284
+ if (options === null || options === void 0 ? void 0 : options.clean) {
285
+ yield _this6.db.clean((0, _lodash().isBoolean)(options.clean) ? {
286
+ drop: options.clean
287
+ } : options.clean);
288
+ }
289
+
290
+ yield _this6.db.sync(options === null || options === void 0 ? void 0 : options.sync);
291
+ yield _this6.pm.install(options);
292
+ yield _this6.emitAsync('afterInstall', _this6, options);
293
+ })();
294
+ }
295
+
168
296
  }
297
+
169
298
  exports.Application = Application;
170
- (0, utils_1.applyMixins)(Application, [utils_1.AsyncEmitter]);
171
- exports.default = Application;
172
- //# sourceMappingURL=application.js.map
299
+ (0, _utils().applyMixins)(Application, [_utils().AsyncEmitter]);
300
+ var _default = Application;
301
+ exports.default = _default;
@@ -1,4 +1,3 @@
1
- declare const _default: ({ app }: {
2
- app: any;
3
- }) => Promise<void>;
1
+ import Application from '../application';
2
+ declare const _default: (app: Application) => void;
4
3
  export default _default;
@@ -1,27 +1,36 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ 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
+ 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
12
  const REPL = require('repl');
13
- exports.default = ({ app }) => __awaiter(void 0, void 0, void 0, function* () {
13
+
14
+ var _default = app => {
15
+ app.command('console').action( /*#__PURE__*/_asyncToGenerator(function* () {
14
16
  yield app.start();
15
- const repl = (REPL.start('nocobase > ').context.app = app);
16
- repl.on('exit', function (err) {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- if (err) {
19
- console.log(err);
20
- process.exit(1);
21
- }
22
- yield app.stop();
23
- process.exit(0);
24
- });
25
- });
26
- });
27
- //# sourceMappingURL=console.js.map
17
+ const repl = REPL.start('nocobase > ').context.app = app;
18
+ repl.on('exit', /*#__PURE__*/function () {
19
+ var _ref2 = _asyncToGenerator(function* (err) {
20
+ if (err) {
21
+ console.log(err);
22
+ process.exit(1);
23
+ }
24
+
25
+ yield app.stop();
26
+ process.exit(0);
27
+ });
28
+
29
+ return function (_x) {
30
+ return _ref2.apply(this, arguments);
31
+ };
32
+ }());
33
+ }));
34
+ };
35
+
36
+ exports.default = _default;
@@ -1,5 +1,3 @@
1
- declare const _default: ({ app, cliArgs }: {
2
- app: any;
3
- cliArgs: any;
4
- }) => Promise<void>;
1
+ import Application from '../application';
2
+ declare const _default: (app: Application) => void;
5
3
  export default _default;
@@ -1,16 +1,26 @@
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());
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ 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
+ 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
+ var _default = app => {
13
+ app.command('db:auth').option('-r, --repeat [repeat]').action( /*#__PURE__*/function () {
14
+ var _ref = _asyncToGenerator(function* (opts) {
15
+ yield app.db.auth({
16
+ repeat: opts.repeat || 10
17
+ });
9
18
  });
19
+
20
+ return function (_x) {
21
+ return _ref.apply(this, arguments);
22
+ };
23
+ }());
10
24
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.default = ({ app, cliArgs }) => __awaiter(void 0, void 0, void 0, function* () {
13
- const [opts] = cliArgs;
14
- yield app.db.auth({ repeat: opts.repeat || 10 });
15
- });
16
- //# sourceMappingURL=db-auth.js.map
25
+
26
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import Application from '../application';
2
+ declare const _default: (app: Application) => void;
3
+ export default _default;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ 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
+ 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
+ var _default = app => {
13
+ app.command('db:clean').option('-y, --yes').action( /*#__PURE__*/function () {
14
+ var _ref = _asyncToGenerator(function* (opts) {
15
+ console.log('Clearing database');
16
+ yield app.db.clean({
17
+ drop: opts.yes
18
+ });
19
+ });
20
+
21
+ return function (_x) {
22
+ return _ref.apply(this, arguments);
23
+ };
24
+ }());
25
+ };
26
+
27
+ exports.default = _default;
@@ -1,5 +1,3 @@
1
- declare const _default: ({ app, cliArgs }: {
2
- app: any;
3
- cliArgs: any;
4
- }) => Promise<void>;
1
+ import Application from '../application';
2
+ declare const _default: (app: Application) => void;
5
3
  export default _default;