@nocobase/server 0.9.0-alpha.2 → 0.9.1-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/app-manager.d.ts +2 -2
- package/lib/app-manager.js +7 -5
- package/lib/application.d.ts +5 -0
- package/lib/application.js +15 -2
- package/lib/helper.js +3 -1
- package/lib/plugin-manager/PluginManagerRepository.js +4 -1
- package/lib/plugin-manager/options/collection.d.ts +2 -0
- package/lib/plugin-manager/options/collection.js +2 -0
- package/package.json +7 -7
package/lib/app-manager.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import http, { IncomingMessage, ServerResponse } from 'http';
|
|
|
4
4
|
import Application, { ApplicationOptions } from './application';
|
|
5
5
|
declare type AppSelector = (req: IncomingMessage) => Application | string | undefined | null;
|
|
6
6
|
export declare class AppManager extends EventEmitter {
|
|
7
|
-
|
|
7
|
+
app: Application;
|
|
8
8
|
applications: Map<string, Application>;
|
|
9
9
|
constructor(app: Application);
|
|
10
10
|
appSelector: AppSelector;
|
|
@@ -12,7 +12,7 @@ export declare class AppManager extends EventEmitter {
|
|
|
12
12
|
removeApplication(name: string): Promise<void>;
|
|
13
13
|
setAppSelector(selector: AppSelector): void;
|
|
14
14
|
listen(...args: any[]): http.Server;
|
|
15
|
-
getApplication(appName: string): Promise<null | Application>;
|
|
15
|
+
getApplication(appName: string, options?: {}): Promise<null | Application>;
|
|
16
16
|
callback(): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
17
17
|
emitAsync: (event: string | symbol, ...args: any[]) => Promise<boolean>;
|
|
18
18
|
}
|
package/lib/app-manager.js
CHANGED
|
@@ -107,13 +107,14 @@ class AppManager extends _events().default {
|
|
|
107
107
|
return server.listen(...args);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
getApplication(appName) {
|
|
110
|
+
getApplication(appName, options = {}) {
|
|
111
111
|
var _this3 = this;
|
|
112
112
|
|
|
113
113
|
return _asyncToGenerator(function* () {
|
|
114
114
|
yield _this3.emitAsync('beforeGetApplication', {
|
|
115
115
|
appManager: _this3,
|
|
116
|
-
name: appName
|
|
116
|
+
name: appName,
|
|
117
|
+
options
|
|
117
118
|
});
|
|
118
119
|
return _this3.applications.get(appName);
|
|
119
120
|
})();
|
|
@@ -124,17 +125,18 @@ class AppManager extends _events().default {
|
|
|
124
125
|
|
|
125
126
|
return /*#__PURE__*/function () {
|
|
126
127
|
var _ref3 = _asyncToGenerator(function* (req, res) {
|
|
127
|
-
|
|
128
|
+
const appManager = _this4.app.appManager;
|
|
129
|
+
let handleApp = appManager.appSelector(req) || appManager.app;
|
|
128
130
|
|
|
129
131
|
if (typeof handleApp === 'string') {
|
|
130
|
-
handleApp = yield
|
|
132
|
+
handleApp = yield appManager.getApplication(handleApp);
|
|
131
133
|
|
|
132
134
|
if (!handleApp) {
|
|
133
135
|
res.statusCode = 404;
|
|
134
136
|
return res.end(JSON.stringify({
|
|
135
137
|
redirectTo: process.env.APP_NOT_FOUND_REDIRECT_TO,
|
|
136
138
|
errors: [{
|
|
137
|
-
message: 'Not Found'
|
|
139
|
+
message: 'Application Not Found'
|
|
138
140
|
}]
|
|
139
141
|
}));
|
|
140
142
|
}
|
package/lib/application.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export interface ApplicationOptions {
|
|
|
30
30
|
acl?: boolean;
|
|
31
31
|
logger?: AppLoggerOptions;
|
|
32
32
|
pmSock?: string;
|
|
33
|
+
name?: string;
|
|
33
34
|
}
|
|
34
35
|
export interface DefaultState extends KoaDefaultState {
|
|
35
36
|
currentUser?: any;
|
|
@@ -100,6 +101,7 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
100
101
|
get appManager(): AppManager;
|
|
101
102
|
get logger(): Logger;
|
|
102
103
|
get log(): Logger;
|
|
104
|
+
get name(): string;
|
|
103
105
|
protected init(): void;
|
|
104
106
|
private createDatabase;
|
|
105
107
|
getVersion(): any;
|
|
@@ -127,5 +129,8 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
127
129
|
install(options?: InstallOptions): Promise<void>;
|
|
128
130
|
upgrade(options?: any): Promise<void>;
|
|
129
131
|
emitAsync: (event: string | symbol, ...args: any[]) => Promise<boolean>;
|
|
132
|
+
toJSON(): {
|
|
133
|
+
appName: string;
|
|
134
|
+
};
|
|
130
135
|
}
|
|
131
136
|
export default Application;
|
package/lib/application.js
CHANGED
|
@@ -148,6 +148,8 @@ class ApplicationVersion {
|
|
|
148
148
|
if (!app.db.hasCollection('applicationVersion')) {
|
|
149
149
|
app.db.collection({
|
|
150
150
|
name: 'applicationVersion',
|
|
151
|
+
namespace: 'core',
|
|
152
|
+
duplicator: 'required',
|
|
151
153
|
timestamps: false,
|
|
152
154
|
fields: [{
|
|
153
155
|
name: 'value',
|
|
@@ -280,6 +282,10 @@ class Application extends _koa().default {
|
|
|
280
282
|
return this._logger;
|
|
281
283
|
}
|
|
282
284
|
|
|
285
|
+
get name() {
|
|
286
|
+
return this.options.name || 'main';
|
|
287
|
+
}
|
|
288
|
+
|
|
283
289
|
init() {
|
|
284
290
|
const options = this.options;
|
|
285
291
|
const logger = (0, _logger().createAppLogger)(options.logger);
|
|
@@ -453,6 +459,7 @@ class Application extends _koa().default {
|
|
|
453
459
|
yield _this7.dbVersionCheck({
|
|
454
460
|
exit: true
|
|
455
461
|
});
|
|
462
|
+
yield _this7.db.prepare();
|
|
456
463
|
|
|
457
464
|
if ((argv === null || argv === void 0 ? void 0 : argv[2]) !== 'upgrade') {
|
|
458
465
|
yield _this7.load({
|
|
@@ -576,8 +583,8 @@ class Application extends _koa().default {
|
|
|
576
583
|
plain: true
|
|
577
584
|
});
|
|
578
585
|
|
|
579
|
-
if ((result === null || result === void 0 ? void 0 : result.Value) === '1') {
|
|
580
|
-
console.log(_chalk().default.
|
|
586
|
+
if ((result === null || result === void 0 ? void 0 : result.Value) === '1' && !_this11.db.options.underscored) {
|
|
587
|
+
console.log(`Your database lower_case_table_names=1, please add ${_chalk().default.yellow('DB_UNDERSCORED=true')} to the .env file`);
|
|
581
588
|
|
|
582
589
|
if (options === null || options === void 0 ? void 0 : options.exit) {
|
|
583
590
|
process.exit();
|
|
@@ -643,6 +650,12 @@ class Application extends _koa().default {
|
|
|
643
650
|
})();
|
|
644
651
|
}
|
|
645
652
|
|
|
653
|
+
toJSON() {
|
|
654
|
+
return {
|
|
655
|
+
appName: this.name
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
|
|
646
659
|
}
|
|
647
660
|
|
|
648
661
|
exports.Application = Application;
|
package/lib/helper.js
CHANGED
|
@@ -93,7 +93,10 @@ class PluginManagerRepository extends _database().Repository {
|
|
|
93
93
|
var _this4 = this;
|
|
94
94
|
|
|
95
95
|
return _asyncToGenerator(function* () {
|
|
96
|
-
|
|
96
|
+
// sort plugins by id
|
|
97
|
+
const items = yield _this4.find({
|
|
98
|
+
sort: 'id'
|
|
99
|
+
});
|
|
97
100
|
|
|
98
101
|
var _iterator = _createForOfIteratorHelper(items),
|
|
99
102
|
_step;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/server",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1-alpha.1",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
"@hapi/topo": "^6.0.0",
|
|
9
9
|
"@koa/cors": "^3.1.0",
|
|
10
10
|
"@koa/router": "^9.4.0",
|
|
11
|
-
"@nocobase/acl": "0.9.
|
|
12
|
-
"@nocobase/actions": "0.9.
|
|
13
|
-
"@nocobase/database": "0.9.
|
|
14
|
-
"@nocobase/logger": "0.9.
|
|
15
|
-
"@nocobase/resourcer": "0.9.
|
|
11
|
+
"@nocobase/acl": "0.9.1-alpha.1",
|
|
12
|
+
"@nocobase/actions": "0.9.1-alpha.1",
|
|
13
|
+
"@nocobase/database": "0.9.1-alpha.1",
|
|
14
|
+
"@nocobase/logger": "0.9.1-alpha.1",
|
|
15
|
+
"@nocobase/resourcer": "0.9.1-alpha.1",
|
|
16
16
|
"chalk": "^4.1.1",
|
|
17
17
|
"commander": "^9.2.0",
|
|
18
18
|
"find-package-json": "^1.2.0",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/semver": "^7.3.9"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "56cb184b00dc383b853015d525bf6e79dea92169"
|
|
31
31
|
}
|