@midwayjs/core 3.1.0 → 3.1.5
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/dist/common/serviceFactory.d.ts +1 -0
- package/dist/common/serviceFactory.js +3 -0
- package/dist/config/config.default.js +1 -2
- package/dist/context/container.js +4 -4
- package/dist/error/index.js +5 -1
- package/dist/index.js +5 -1
- package/dist/service/frameworkService.js +0 -6
- package/dist/service/loggerService.d.ts +2 -2
- package/dist/setup.js +14 -4
- package/dist/util/index.d.ts +1 -0
- package/dist/util/index.js +1 -0
- package/package.json +2 -2
|
@@ -6,6 +6,7 @@ export declare abstract class ServiceFactory<T> {
|
|
|
6
6
|
protected options: {};
|
|
7
7
|
protected initClients(options?: any): Promise<void>;
|
|
8
8
|
get<U = T>(id?: string): U;
|
|
9
|
+
has(id: string): boolean;
|
|
9
10
|
createInstance(config: any, clientName?: any): Promise<T | void>;
|
|
10
11
|
abstract getName(): string;
|
|
11
12
|
protected abstract createClient(config: any, clientName: any): Promise<T | void> | (T | void);
|
|
@@ -28,6 +28,9 @@ class ServiceFactory {
|
|
|
28
28
|
get(id = 'default') {
|
|
29
29
|
return this.clients.get(id);
|
|
30
30
|
}
|
|
31
|
+
has(id) {
|
|
32
|
+
return this.clients.has(id);
|
|
33
|
+
}
|
|
31
34
|
async createInstance(config, clientName) {
|
|
32
35
|
// options.default will be merge in to options.clients[id]
|
|
33
36
|
config = Object.assign({}, this.options['default'], config);
|
|
@@ -13,8 +13,7 @@ exports.default = (appInfo) => {
|
|
|
13
13
|
dir: (0, path_1.join)(logRoot, 'logs', appInfo.name),
|
|
14
14
|
level: isDevelopment ? 'info' : 'warn',
|
|
15
15
|
consoleLevel: isDevelopment ? 'info' : 'warn',
|
|
16
|
-
auditFileDir:
|
|
17
|
-
errorDir: (0, path_1.join)(logRoot, 'logs', appInfo.name),
|
|
16
|
+
auditFileDir: '.audit',
|
|
18
17
|
},
|
|
19
18
|
clients: {
|
|
20
19
|
coreLogger: {
|
|
@@ -79,7 +79,7 @@ class ContainerConfiguration {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
addImports(imports = []) {
|
|
82
|
-
var _a
|
|
82
|
+
var _a;
|
|
83
83
|
// 处理 imports
|
|
84
84
|
for (let importPackage of imports) {
|
|
85
85
|
if (!importPackage)
|
|
@@ -92,8 +92,8 @@ class ContainerConfiguration {
|
|
|
92
92
|
this.load(importPackage);
|
|
93
93
|
}
|
|
94
94
|
else if ('component' in importPackage) {
|
|
95
|
-
if (
|
|
96
|
-
if ((
|
|
95
|
+
if (importPackage === null || importPackage === void 0 ? void 0 : importPackage.enabledEnvironment) {
|
|
96
|
+
if ((_a = importPackage === null || importPackage === void 0 ? void 0 : importPackage.enabledEnvironment) === null || _a === void 0 ? void 0 : _a.includes(this.container
|
|
97
97
|
.get(environmentService_1.MidwayEnvironmentService)
|
|
98
98
|
.getCurrentEnvironment())) {
|
|
99
99
|
this.load(importPackage.component);
|
|
@@ -228,7 +228,6 @@ class MidwayContainer {
|
|
|
228
228
|
}
|
|
229
229
|
load(module) {
|
|
230
230
|
var _a;
|
|
231
|
-
this.isLoad = true;
|
|
232
231
|
if (module) {
|
|
233
232
|
// load configuration
|
|
234
233
|
const configuration = new ContainerConfiguration(this);
|
|
@@ -242,6 +241,7 @@ class MidwayContainer {
|
|
|
242
241
|
(0, extend_1.extend)(true, detectorOptionsMerged, detectorOptions);
|
|
243
242
|
}
|
|
244
243
|
(_a = this.fileDetector) === null || _a === void 0 ? void 0 : _a.setExtraDetectorOptions(detectorOptionsMerged);
|
|
244
|
+
this.isLoad = true;
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
loadDefinitions() {
|
package/dist/error/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -94,12 +94,6 @@ let MidwayFrameworkService = class MidwayFrameworkService {
|
|
|
94
94
|
}
|
|
95
95
|
// init aspect module
|
|
96
96
|
await this.aspectService.loadAspect();
|
|
97
|
-
// some preload module init
|
|
98
|
-
const modules = (0, decorator_1.listPreloadModule)();
|
|
99
|
-
for (const module of modules) {
|
|
100
|
-
// preload init context
|
|
101
|
-
await this.applicationContext.getAsync(module);
|
|
102
|
-
}
|
|
103
97
|
}
|
|
104
98
|
getMainApp() {
|
|
105
99
|
var _a;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { MidwayConfigService } from './configService';
|
|
2
2
|
import { ServiceFactory } from '../common/serviceFactory';
|
|
3
|
-
import { ILogger } from '@midwayjs/logger';
|
|
3
|
+
import { ILogger, LoggerOptions } from '@midwayjs/logger';
|
|
4
4
|
import { IMidwayContainer } from '../interface';
|
|
5
5
|
export declare class MidwayLoggerService extends ServiceFactory<ILogger> {
|
|
6
6
|
readonly applicationContext: IMidwayContainer;
|
|
7
7
|
configService: MidwayConfigService;
|
|
8
8
|
constructor(applicationContext: IMidwayContainer);
|
|
9
9
|
protected init(): void;
|
|
10
|
-
protected createClient(config:
|
|
10
|
+
protected createClient(config: LoggerOptions, name?: string): void;
|
|
11
11
|
getName(): string;
|
|
12
12
|
createLogger(name: any, config: any): ILogger;
|
|
13
13
|
getLogger(name: string): ILogger;
|
package/dist/setup.js
CHANGED
|
@@ -72,7 +72,9 @@ async function initializeGlobalApplicationContext(globalOptions) {
|
|
|
72
72
|
.concat(globalOptions.imports)
|
|
73
73
|
.concat(globalOptions.configurationModule)) {
|
|
74
74
|
// load configuration and component
|
|
75
|
-
|
|
75
|
+
if (configurationModule) {
|
|
76
|
+
applicationContext.load(configurationModule);
|
|
77
|
+
}
|
|
76
78
|
}
|
|
77
79
|
// bind user code module
|
|
78
80
|
applicationContext.ready();
|
|
@@ -92,9 +94,11 @@ async function initializeGlobalApplicationContext(globalOptions) {
|
|
|
92
94
|
// it will be delay framework initialize in egg cluster mode
|
|
93
95
|
if (!globalOptions.lazyInitializeFramework) {
|
|
94
96
|
// init logger
|
|
95
|
-
await applicationContext.getAsync(_1.MidwayLoggerService, [
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
const loggerService = await applicationContext.getAsync(_1.MidwayLoggerService, [applicationContext]);
|
|
98
|
+
if (loggerService.getLogger('appLogger')) {
|
|
99
|
+
// register global logger
|
|
100
|
+
applicationContext.registerObject('logger', loggerService.getLogger('appLogger'));
|
|
101
|
+
}
|
|
98
102
|
// framework/config/plugin/logger/app decorator support
|
|
99
103
|
await applicationContext.getAsync(_1.MidwayFrameworkService, [
|
|
100
104
|
applicationContext,
|
|
@@ -104,6 +108,12 @@ async function initializeGlobalApplicationContext(globalOptions) {
|
|
|
104
108
|
await applicationContext.getAsync(_1.MidwayLifeCycleService, [
|
|
105
109
|
applicationContext,
|
|
106
110
|
]);
|
|
111
|
+
// some preload module init
|
|
112
|
+
const modules = (0, decorator_1.listPreloadModule)();
|
|
113
|
+
for (const module of modules) {
|
|
114
|
+
// preload init context
|
|
115
|
+
await applicationContext.getAsync(module);
|
|
116
|
+
}
|
|
107
117
|
}
|
|
108
118
|
return applicationContext;
|
|
109
119
|
}
|
package/dist/util/index.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export declare function joinURLPath(...strArray: any[]): string;
|
|
|
36
36
|
* 代理目标所有的原型方法,不包括构造器和内部隐藏方法
|
|
37
37
|
* @param derivedCtor
|
|
38
38
|
* @param constructors
|
|
39
|
+
* @param otherMethods
|
|
39
40
|
* @since 2.0.0
|
|
40
41
|
*/
|
|
41
42
|
export declare function delegateTargetPrototypeMethod(derivedCtor: any, constructors: any[], otherMethods?: string[]): void;
|
package/dist/util/index.js
CHANGED
|
@@ -112,6 +112,7 @@ exports.joinURLPath = joinURLPath;
|
|
|
112
112
|
* 代理目标所有的原型方法,不包括构造器和内部隐藏方法
|
|
113
113
|
* @param derivedCtor
|
|
114
114
|
* @param constructors
|
|
115
|
+
* @param otherMethods
|
|
115
116
|
* @since 2.0.0
|
|
116
117
|
*/
|
|
117
118
|
function delegateTargetPrototypeMethod(derivedCtor, constructors, otherMethods) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/core",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.5",
|
|
4
4
|
"description": "midway core",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"engines": {
|
|
46
46
|
"node": ">=12"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "46a7851ad3ce6fc675bd7e1b7c9dff2c70009104"
|
|
49
49
|
}
|