@midwayjs/core 4.0.0-beta.6 → 4.0.0-beta.8
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/baseFramework.d.ts +6 -6
- package/dist/baseFramework.js +19 -6
- package/dist/common/applicationManager.js +1 -3
- package/dist/common/asyncContextManager.js +23 -0
- package/dist/common/dataListener.js +2 -3
- package/dist/common/dataSourceManager.js +10 -8
- package/dist/common/fileDetector.js +2 -4
- package/dist/common/filterManager.js +6 -8
- package/dist/common/loggerFactory.js +1 -3
- package/dist/common/middlewareManager.js +2 -2
- package/dist/common/performanceManager.d.ts +0 -1
- package/dist/common/performanceManager.js +21 -20
- package/dist/common/priorityManager.js +2 -4
- package/dist/common/serviceDiscovery/healthCheck.js +10 -2
- package/dist/common/serviceDiscovery/loadBalancer.js +1 -3
- package/dist/common/serviceDiscovery/serviceDiscovery.js +6 -3
- package/dist/common/serviceFactory.js +6 -6
- package/dist/common/typedResourceManager.js +3 -2
- package/dist/common/webGenerator.js +2 -0
- package/dist/config/config.default.js +4 -4
- package/dist/context/componentLoader.js +3 -2
- package/dist/context/container.d.ts +0 -1
- package/dist/context/container.js +9 -8
- package/dist/context/definitionRegistry.js +3 -6
- package/dist/context/dynamicContainer.js +3 -2
- package/dist/context/managedResolverFactory.js +2 -1
- package/dist/context/providerWrapper.js +1 -2
- package/dist/context/requestContainer.js +5 -2
- package/dist/decorator/common/aspect.js +1 -2
- package/dist/decorator/common/autoload.js +1 -2
- package/dist/decorator/common/configuration.js +1 -2
- package/dist/decorator/common/filter.js +2 -3
- package/dist/decorator/common/framework.js +8 -9
- package/dist/decorator/common/guard.js +2 -3
- package/dist/decorator/common/inject.js +4 -5
- package/dist/decorator/common/middleware.js +1 -2
- package/dist/decorator/common/mock.js +1 -2
- package/dist/decorator/common/objectDef.js +2 -3
- package/dist/decorator/common/pipe.js +1 -2
- package/dist/decorator/common/provide.js +1 -2
- package/dist/decorator/common/scope.js +2 -3
- package/dist/decorator/decoratorManager.js +1 -1
- package/dist/decorator/faas/serverlessTrigger.js +2 -3
- package/dist/decorator/metadataManager.js +11 -11
- package/dist/decorator/microservice/consumer.js +1 -2
- package/dist/decorator/microservice/kafkaListener.js +1 -2
- package/dist/decorator/microservice/provider.js +4 -4
- package/dist/decorator/microservice/rabbitmqListener.js +1 -2
- package/dist/decorator/task/queue.js +1 -2
- package/dist/decorator/task/schedule.js +1 -2
- package/dist/decorator/task/task.js +1 -2
- package/dist/decorator/task/taskLocal.js +1 -2
- package/dist/decorator/web/controller.js +1 -2
- package/dist/decorator/web/response.js +5 -6
- package/dist/decorator/ws/webSocketController.js +1 -2
- package/dist/decorator/ws/webSocketEvent.js +6 -6
- package/dist/definitions/functionDefinition.js +21 -12
- package/dist/definitions/objectCreator.js +2 -1
- package/dist/definitions/objectDefinition.js +19 -17
- package/dist/error/base.js +5 -2
- package/dist/functional/configuration.js +1 -0
- package/dist/functional/hooks.js +10 -11
- package/dist/interface.d.ts +0 -2
- package/dist/legacy/decorator.js +31 -32
- package/dist/response/base.d.ts +3 -5
- package/dist/response/base.js +22 -21
- package/dist/response/http.d.ts +4 -7
- package/dist/response/http.js +12 -12
- package/dist/response/sse.d.ts +0 -1
- package/dist/response/sse.js +4 -1
- package/dist/response/stream.d.ts +0 -1
- package/dist/response/stream.js +3 -1
- package/dist/service/aspectService.js +1 -0
- package/dist/service/configService.js +13 -12
- package/dist/service/decoratorService.js +6 -4
- package/dist/service/environmentService.js +2 -3
- package/dist/service/frameworkService.js +9 -1
- package/dist/service/healthService.js +5 -4
- package/dist/service/informationService.js +3 -0
- package/dist/service/lifeCycleService.js +6 -1
- package/dist/service/loggerService.js +6 -2
- package/dist/service/middlewareService.js +1 -0
- package/dist/service/mockService.js +17 -15
- package/dist/service/slsFunctionService.js +1 -0
- package/dist/service/webRouterService.d.ts +1 -1
- package/dist/service/webRouterService.js +4 -3
- package/dist/setup.js +4 -5
- package/dist/util/camelCase.js +2 -3
- package/dist/util/contextUtil.d.ts +3 -3
- package/dist/util/extend.js +1 -2
- package/dist/util/flatted.js +2 -3
- package/dist/util/fs.js +2 -2
- package/dist/util/httpclient.d.ts +0 -4
- package/dist/util/httpclient.js +3 -2
- package/dist/util/index.d.ts +1 -2
- package/dist/util/index.js +26 -36
- package/dist/util/pathFileUtil.d.ts +0 -1
- package/dist/util/pathFileUtil.js +6 -6
- package/dist/util/retry.js +2 -3
- package/dist/util/timeout.d.ts +0 -1
- package/dist/util/timeout.js +1 -2
- package/dist/util/types.d.ts +7 -7
- package/dist/util/types.js +17 -17
- package/dist/util/uuid.js +1 -2
- package/package.json +2 -2
|
@@ -4,24 +4,26 @@ exports.ObjectDefinition = void 0;
|
|
|
4
4
|
const interface_1 = require("../interface");
|
|
5
5
|
const objectCreator_1 = require("./objectCreator");
|
|
6
6
|
class ObjectDefinition {
|
|
7
|
+
_attrs = new Map();
|
|
8
|
+
_asynchronous = false;
|
|
9
|
+
scope = interface_1.ScopeEnum.Singleton;
|
|
10
|
+
creator = null;
|
|
11
|
+
id = null;
|
|
12
|
+
name = null;
|
|
13
|
+
initMethod = null;
|
|
14
|
+
destroyMethod = null;
|
|
15
|
+
constructMethod = null;
|
|
16
|
+
constructorArgs = [];
|
|
17
|
+
srcPath;
|
|
18
|
+
path = null;
|
|
19
|
+
export = null;
|
|
20
|
+
dependsOn = [];
|
|
21
|
+
properties = new Map();
|
|
22
|
+
namespace = '';
|
|
23
|
+
handlerProps = [];
|
|
24
|
+
createFrom;
|
|
25
|
+
allowDowngrade = false;
|
|
7
26
|
constructor() {
|
|
8
|
-
this._attrs = new Map();
|
|
9
|
-
this._asynchronous = false;
|
|
10
|
-
this.scope = interface_1.ScopeEnum.Singleton;
|
|
11
|
-
this.creator = null;
|
|
12
|
-
this.id = null;
|
|
13
|
-
this.name = null;
|
|
14
|
-
this.initMethod = null;
|
|
15
|
-
this.destroyMethod = null;
|
|
16
|
-
this.constructMethod = null;
|
|
17
|
-
this.constructorArgs = [];
|
|
18
|
-
this.path = null;
|
|
19
|
-
this.export = null;
|
|
20
|
-
this.dependsOn = [];
|
|
21
|
-
this.properties = new Map();
|
|
22
|
-
this.namespace = '';
|
|
23
|
-
this.handlerProps = [];
|
|
24
|
-
this.allowDowngrade = false;
|
|
25
27
|
this.creator = new objectCreator_1.ObjectCreator(this);
|
|
26
28
|
}
|
|
27
29
|
set asynchronous(asynchronous) {
|
package/dist/error/base.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MidwayHttpError = exports.MidwayError =
|
|
3
|
+
exports.MidwayHttpError = exports.MidwayError = void 0;
|
|
4
|
+
exports.registerErrorCode = registerErrorCode;
|
|
4
5
|
const http_1 = require("http");
|
|
5
6
|
const codeGroup = new Set();
|
|
6
7
|
/**
|
|
@@ -25,8 +26,9 @@ function registerErrorCode(errorGroup, errorCodeMapping) {
|
|
|
25
26
|
}
|
|
26
27
|
return newCodeEnum;
|
|
27
28
|
}
|
|
28
|
-
exports.registerErrorCode = registerErrorCode;
|
|
29
29
|
class MidwayError extends Error {
|
|
30
|
+
code;
|
|
31
|
+
cause;
|
|
30
32
|
constructor(message, code, options) {
|
|
31
33
|
super(message);
|
|
32
34
|
if (!code || typeof code === 'object') {
|
|
@@ -40,6 +42,7 @@ class MidwayError extends Error {
|
|
|
40
42
|
}
|
|
41
43
|
exports.MidwayError = MidwayError;
|
|
42
44
|
class MidwayHttpError extends MidwayError {
|
|
45
|
+
status;
|
|
43
46
|
constructor(resOrMessage, status, code, options) {
|
|
44
47
|
super(resOrMessage
|
|
45
48
|
? typeof resOrMessage === 'string'
|
|
@@ -4,6 +4,7 @@ exports.defineConfiguration = exports.FunctionalConfiguration = void 0;
|
|
|
4
4
|
const decorator_1 = require("../decorator");
|
|
5
5
|
const metadataManager_1 = require("../decorator/metadataManager");
|
|
6
6
|
class FunctionalConfiguration {
|
|
7
|
+
options;
|
|
7
8
|
constructor(options) {
|
|
8
9
|
this.options = options;
|
|
9
10
|
}
|
package/dist/functional/hooks.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.useContext = useContext;
|
|
4
|
+
exports.useLogger = useLogger;
|
|
5
|
+
exports.usePlugin = usePlugin;
|
|
6
|
+
exports.useInject = useInject;
|
|
7
|
+
exports.useInjectSync = useInjectSync;
|
|
8
|
+
exports.useConfig = useConfig;
|
|
9
|
+
exports.useApp = useApp;
|
|
10
|
+
exports.useMainApp = useMainApp;
|
|
11
|
+
exports.useInjectClient = useInjectClient;
|
|
12
|
+
exports.useInjectDataSource = useInjectDataSource;
|
|
4
13
|
const contextUtil_1 = require("../util/contextUtil");
|
|
5
14
|
const constants_1 = require("../constants");
|
|
6
15
|
const applicationManager_1 = require("../common/applicationManager");
|
|
@@ -11,7 +20,6 @@ function useContext() {
|
|
|
11
20
|
.getValue(constants_1.ASYNC_CONTEXT_KEY);
|
|
12
21
|
return ctx;
|
|
13
22
|
}
|
|
14
|
-
exports.useContext = useContext;
|
|
15
23
|
function useLogger(loggerName) {
|
|
16
24
|
const ctx = useContext();
|
|
17
25
|
if (ctx) {
|
|
@@ -24,12 +32,10 @@ function useLogger(loggerName) {
|
|
|
24
32
|
return useMainApp().getLogger(loggerName);
|
|
25
33
|
}
|
|
26
34
|
}
|
|
27
|
-
exports.useLogger = useLogger;
|
|
28
35
|
function usePlugin(key) {
|
|
29
36
|
const ctx = useContext();
|
|
30
37
|
return ctx ? ctx.app[key] || ctx[key] : useMainApp()[key];
|
|
31
38
|
}
|
|
32
|
-
exports.usePlugin = usePlugin;
|
|
33
39
|
async function useInject(identifier, args) {
|
|
34
40
|
const ctx = useContext();
|
|
35
41
|
const requestContext = ctx
|
|
@@ -37,7 +43,6 @@ async function useInject(identifier, args) {
|
|
|
37
43
|
: useMainApp().getApplicationContext();
|
|
38
44
|
return requestContext.getAsync(identifier, args);
|
|
39
45
|
}
|
|
40
|
-
exports.useInject = useInject;
|
|
41
46
|
function useInjectSync(identifier, args) {
|
|
42
47
|
``;
|
|
43
48
|
const ctx = useContext();
|
|
@@ -46,33 +51,27 @@ function useInjectSync(identifier, args) {
|
|
|
46
51
|
: useMainApp().getApplicationContext();
|
|
47
52
|
return requestContext.get(identifier, args);
|
|
48
53
|
}
|
|
49
|
-
exports.useInjectSync = useInjectSync;
|
|
50
54
|
function useConfig(key) {
|
|
51
55
|
return useMainApp()
|
|
52
56
|
.getApplicationContext()
|
|
53
57
|
.get(configService_1.MidwayConfigService)
|
|
54
58
|
.getConfiguration(key);
|
|
55
59
|
}
|
|
56
|
-
exports.useConfig = useConfig;
|
|
57
60
|
function useApp(appName) {
|
|
58
61
|
const applicationManager = useMainApp()
|
|
59
62
|
.getApplicationContext()
|
|
60
63
|
.get(applicationManager_1.MidwayApplicationManager);
|
|
61
64
|
return applicationManager.getApplication(appName);
|
|
62
65
|
}
|
|
63
|
-
exports.useApp = useApp;
|
|
64
66
|
function useMainApp() {
|
|
65
67
|
return (0, contextUtil_1.getCurrentMainApp)();
|
|
66
68
|
}
|
|
67
|
-
exports.useMainApp = useMainApp;
|
|
68
69
|
async function useInjectClient(serviceFactoryClz, clientName) {
|
|
69
70
|
const factoryService = await useInject(serviceFactoryClz);
|
|
70
71
|
return factoryService.get(clientName);
|
|
71
72
|
}
|
|
72
|
-
exports.useInjectClient = useInjectClient;
|
|
73
73
|
async function useInjectDataSource(dataSourceManagerClz, dataSourceName) {
|
|
74
74
|
const dataSourceManager = await useInject(dataSourceManagerClz);
|
|
75
75
|
return dataSourceManager.getDataSource(dataSourceName);
|
|
76
76
|
}
|
|
77
|
-
exports.useInjectDataSource = useInjectDataSource;
|
|
78
77
|
//# sourceMappingURL=hooks.js.map
|
package/dist/interface.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
import type { AsyncContextManager } from './common/asyncContextManager';
|
|
4
2
|
import type { LoggerFactory } from './common/loggerFactory';
|
|
5
3
|
import type { ManagedResolverFactory } from './context/managedResolverFactory';
|
package/dist/legacy/decorator.js
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.saveClassMetadata = saveClassMetadata;
|
|
4
|
+
exports.attachClassMetadata = attachClassMetadata;
|
|
5
|
+
exports.getClassExtendedMetadata = getClassExtendedMetadata;
|
|
6
|
+
exports.getClassMetadata = getClassMetadata;
|
|
7
|
+
exports.savePropertyDataToClass = savePropertyDataToClass;
|
|
8
|
+
exports.attachPropertyDataToClass = attachPropertyDataToClass;
|
|
9
|
+
exports.getPropertyDataFromClass = getPropertyDataFromClass;
|
|
10
|
+
exports.listPropertyDataFromClass = listPropertyDataFromClass;
|
|
11
|
+
exports.savePropertyMetadata = savePropertyMetadata;
|
|
12
|
+
exports.attachPropertyMetadata = attachPropertyMetadata;
|
|
13
|
+
exports.getPropertyMetadata = getPropertyMetadata;
|
|
14
|
+
exports.savePreloadModule = savePreloadModule;
|
|
15
|
+
exports.listPreloadModule = listPreloadModule;
|
|
16
|
+
exports.saveModule = saveModule;
|
|
17
|
+
exports.listModule = listModule;
|
|
18
|
+
exports.resetModule = resetModule;
|
|
19
|
+
exports.clearAllModule = clearAllModule;
|
|
20
|
+
exports.saveProviderId = saveProviderId;
|
|
21
|
+
exports.getProviderId = getProviderId;
|
|
22
|
+
exports.getProviderName = getProviderName;
|
|
23
|
+
exports.getProviderUUId = getProviderUUId;
|
|
24
|
+
exports.isProvide = isProvide;
|
|
25
|
+
exports.createCustomPropertyDecorator = createCustomPropertyDecorator;
|
|
26
|
+
exports.createCustomMethodDecorator = createCustomMethodDecorator;
|
|
27
|
+
exports.createCustomParamDecorator = createCustomParamDecorator;
|
|
28
|
+
exports.getPropertyType = getPropertyType;
|
|
29
|
+
exports.getMethodParamTypes = getMethodParamTypes;
|
|
30
|
+
exports.savePropertyInject = savePropertyInject;
|
|
31
|
+
exports.getPropertyInject = getPropertyInject;
|
|
32
|
+
exports.saveObjectDefinition = saveObjectDefinition;
|
|
33
|
+
exports.getObjectDefinition = getObjectDefinition;
|
|
4
34
|
const metadataManager_1 = require("../decorator/metadataManager");
|
|
5
35
|
const decorator_1 = require("../decorator");
|
|
6
36
|
const inject_1 = require("../decorator/common/inject");
|
|
@@ -39,7 +69,6 @@ function saveClassMetadata(decoratorNameKey, data, target, mergeIfExist) {
|
|
|
39
69
|
}
|
|
40
70
|
return metadataManager_1.MetadataManager.defineMetadata(decoratorNameKey, data, target);
|
|
41
71
|
}
|
|
42
|
-
exports.saveClassMetadata = saveClassMetadata;
|
|
43
72
|
/**
|
|
44
73
|
* attach data to class
|
|
45
74
|
* @param decoratorNameKey
|
|
@@ -52,7 +81,6 @@ exports.saveClassMetadata = saveClassMetadata;
|
|
|
52
81
|
function attachClassMetadata(decoratorNameKey, data, target, groupBy) {
|
|
53
82
|
return metadataManager_1.MetadataManager.attachMetadata(decoratorNameKey, data, target, groupBy);
|
|
54
83
|
}
|
|
55
|
-
exports.attachClassMetadata = attachClassMetadata;
|
|
56
84
|
function _getClassExtendedMetadata(decoratorNameKey, target, propertyName, useCache) {
|
|
57
85
|
const ret = metadataManager_1.MetadataManager.getPropertiesWithMetadata(decoratorNameKey, target);
|
|
58
86
|
// array item to object
|
|
@@ -87,7 +115,6 @@ function getClassExtendedMetadata(decoratorNameKey, target, propertyName, useCac
|
|
|
87
115
|
}
|
|
88
116
|
return ret;
|
|
89
117
|
}
|
|
90
|
-
exports.getClassExtendedMetadata = getClassExtendedMetadata;
|
|
91
118
|
/**
|
|
92
119
|
* get data from class
|
|
93
120
|
* @param decoratorNameKey
|
|
@@ -98,7 +125,6 @@ exports.getClassExtendedMetadata = getClassExtendedMetadata;
|
|
|
98
125
|
function getClassMetadata(decoratorNameKey, target) {
|
|
99
126
|
return metadataManager_1.MetadataManager.getOwnMetadata(decoratorNameKey, target);
|
|
100
127
|
}
|
|
101
|
-
exports.getClassMetadata = getClassMetadata;
|
|
102
128
|
/**
|
|
103
129
|
* save property data to class
|
|
104
130
|
* @param decoratorNameKey
|
|
@@ -115,7 +141,6 @@ function savePropertyDataToClass(decoratorNameKey, data, target, propertyName) {
|
|
|
115
141
|
originMap.set(dataKey, data);
|
|
116
142
|
return metadataManager_1.MetadataManager.defineMetadata(legacyListPropertyDataKey, originMap, target);
|
|
117
143
|
}
|
|
118
|
-
exports.savePropertyDataToClass = savePropertyDataToClass;
|
|
119
144
|
/**
|
|
120
145
|
* attach property data to class
|
|
121
146
|
* @param decoratorNameKey
|
|
@@ -139,7 +164,6 @@ function attachPropertyDataToClass(decoratorNameKey, data, target, propertyName)
|
|
|
139
164
|
}
|
|
140
165
|
return metadataManager_1.MetadataManager.defineMetadata(legacyListPropertyDataKey, originMap, target);
|
|
141
166
|
}
|
|
142
|
-
exports.attachPropertyDataToClass = attachPropertyDataToClass;
|
|
143
167
|
/**
|
|
144
168
|
* get property data from class
|
|
145
169
|
* @param decoratorNameKey
|
|
@@ -153,7 +177,6 @@ function getPropertyDataFromClass(decoratorNameKey, target, propertyName) {
|
|
|
153
177
|
const originMap = metadataManager_1.MetadataManager.getOwnMetadata(legacyListPropertyDataKey, target);
|
|
154
178
|
return originMap && originMap.get(dataKey);
|
|
155
179
|
}
|
|
156
|
-
exports.getPropertyDataFromClass = getPropertyDataFromClass;
|
|
157
180
|
/**
|
|
158
181
|
* list property data from class
|
|
159
182
|
* @param decoratorNameKey
|
|
@@ -172,7 +195,6 @@ function listPropertyDataFromClass(decoratorNameKey, target) {
|
|
|
172
195
|
}
|
|
173
196
|
return res;
|
|
174
197
|
}
|
|
175
|
-
exports.listPropertyDataFromClass = listPropertyDataFromClass;
|
|
176
198
|
/**
|
|
177
199
|
* save property data
|
|
178
200
|
* @param decoratorNameKey
|
|
@@ -185,7 +207,6 @@ exports.listPropertyDataFromClass = listPropertyDataFromClass;
|
|
|
185
207
|
function savePropertyMetadata(decoratorNameKey, data, target, propertyName) {
|
|
186
208
|
return metadataManager_1.MetadataManager.defineMetadata(decoratorNameKey, data, target, propertyName);
|
|
187
209
|
}
|
|
188
|
-
exports.savePropertyMetadata = savePropertyMetadata;
|
|
189
210
|
/**
|
|
190
211
|
* attach property data
|
|
191
212
|
* @param decoratorNameKey
|
|
@@ -198,7 +219,6 @@ exports.savePropertyMetadata = savePropertyMetadata;
|
|
|
198
219
|
function attachPropertyMetadata(decoratorNameKey, data, target, propertyName) {
|
|
199
220
|
return metadataManager_1.MetadataManager.attachMetadata(decoratorNameKey, data, target, propertyName);
|
|
200
221
|
}
|
|
201
|
-
exports.attachPropertyMetadata = attachPropertyMetadata;
|
|
202
222
|
/**
|
|
203
223
|
* get property data
|
|
204
224
|
* @param decoratorNameKey
|
|
@@ -210,7 +230,6 @@ exports.attachPropertyMetadata = attachPropertyMetadata;
|
|
|
210
230
|
function getPropertyMetadata(decoratorNameKey, target, propertyName) {
|
|
211
231
|
return metadataManager_1.MetadataManager.getOwnMetadata(decoratorNameKey, target, propertyName);
|
|
212
232
|
}
|
|
213
|
-
exports.getPropertyMetadata = getPropertyMetadata;
|
|
214
233
|
/**
|
|
215
234
|
* save preload module by target
|
|
216
235
|
* @param target
|
|
@@ -220,7 +239,6 @@ exports.getPropertyMetadata = getPropertyMetadata;
|
|
|
220
239
|
function savePreloadModule(target) {
|
|
221
240
|
return decorator_1.DecoratorManager.savePreStartModule(target);
|
|
222
241
|
}
|
|
223
|
-
exports.savePreloadModule = savePreloadModule;
|
|
224
242
|
/**
|
|
225
243
|
* list preload module
|
|
226
244
|
* @since 2.0.0
|
|
@@ -229,7 +247,6 @@ exports.savePreloadModule = savePreloadModule;
|
|
|
229
247
|
function listPreloadModule() {
|
|
230
248
|
return decorator_1.DecoratorManager.listPreStartModule();
|
|
231
249
|
}
|
|
232
|
-
exports.listPreloadModule = listPreloadModule;
|
|
233
250
|
/**
|
|
234
251
|
* save module to inner map
|
|
235
252
|
* @param decoratorNameKey
|
|
@@ -240,7 +257,6 @@ exports.listPreloadModule = listPreloadModule;
|
|
|
240
257
|
function saveModule(decoratorNameKey, target) {
|
|
241
258
|
return decorator_1.DecoratorManager.saveModule(decoratorNameKey, target);
|
|
242
259
|
}
|
|
243
|
-
exports.saveModule = saveModule;
|
|
244
260
|
/**
|
|
245
261
|
* list module from decorator key
|
|
246
262
|
* @param decoratorNameKey
|
|
@@ -251,7 +267,6 @@ exports.saveModule = saveModule;
|
|
|
251
267
|
function listModule(decoratorNameKey, filter) {
|
|
252
268
|
return decorator_1.DecoratorManager.listModule(decoratorNameKey, filter);
|
|
253
269
|
}
|
|
254
|
-
exports.listModule = listModule;
|
|
255
270
|
/**
|
|
256
271
|
* reset module
|
|
257
272
|
* @param decoratorNameKey
|
|
@@ -261,7 +276,6 @@ exports.listModule = listModule;
|
|
|
261
276
|
function resetModule(decoratorNameKey) {
|
|
262
277
|
return decorator_1.DecoratorManager.resetModule(decoratorNameKey);
|
|
263
278
|
}
|
|
264
|
-
exports.resetModule = resetModule;
|
|
265
279
|
/**
|
|
266
280
|
* clear all module
|
|
267
281
|
* @since 3.0.0
|
|
@@ -270,7 +284,6 @@ exports.resetModule = resetModule;
|
|
|
270
284
|
function clearAllModule() {
|
|
271
285
|
return decorator_1.DecoratorManager.clearAllModule();
|
|
272
286
|
}
|
|
273
|
-
exports.clearAllModule = clearAllModule;
|
|
274
287
|
/**
|
|
275
288
|
* class provider id
|
|
276
289
|
* @since 2.3.0
|
|
@@ -279,7 +292,6 @@ exports.clearAllModule = clearAllModule;
|
|
|
279
292
|
function saveProviderId(identifier, target) {
|
|
280
293
|
return decorator_1.DecoratorManager.saveProviderId(identifier, target);
|
|
281
294
|
}
|
|
282
|
-
exports.saveProviderId = saveProviderId;
|
|
283
295
|
/**
|
|
284
296
|
* get provider id from module
|
|
285
297
|
* @since 3.0.0
|
|
@@ -288,7 +300,6 @@ exports.saveProviderId = saveProviderId;
|
|
|
288
300
|
function getProviderId(module) {
|
|
289
301
|
return decorator_1.DecoratorManager.getProviderId(module);
|
|
290
302
|
}
|
|
291
|
-
exports.getProviderId = getProviderId;
|
|
292
303
|
/**
|
|
293
304
|
* @since 3.0.0
|
|
294
305
|
* @deprecated Use DecoratorManager.getProviderName instead
|
|
@@ -296,7 +307,6 @@ exports.getProviderId = getProviderId;
|
|
|
296
307
|
function getProviderName(module) {
|
|
297
308
|
return decorator_1.DecoratorManager.getProviderName(module);
|
|
298
309
|
}
|
|
299
|
-
exports.getProviderName = getProviderName;
|
|
300
310
|
/**
|
|
301
311
|
* get provider uuid from module
|
|
302
312
|
* @since 3.0.0
|
|
@@ -305,7 +315,6 @@ exports.getProviderName = getProviderName;
|
|
|
305
315
|
function getProviderUUId(module) {
|
|
306
316
|
return decorator_1.DecoratorManager.getProviderUUId(module);
|
|
307
317
|
}
|
|
308
|
-
exports.getProviderUUId = getProviderUUId;
|
|
309
318
|
/**
|
|
310
319
|
* use @Provide decorator or not
|
|
311
320
|
* @since 3.0.0
|
|
@@ -314,7 +323,6 @@ exports.getProviderUUId = getProviderUUId;
|
|
|
314
323
|
function isProvide(target) {
|
|
315
324
|
return decorator_1.DecoratorManager.isProvide(target);
|
|
316
325
|
}
|
|
317
|
-
exports.isProvide = isProvide;
|
|
318
326
|
/**
|
|
319
327
|
* Create a custom property inject
|
|
320
328
|
* @param decoratorKey
|
|
@@ -326,7 +334,6 @@ exports.isProvide = isProvide;
|
|
|
326
334
|
function createCustomPropertyDecorator(decoratorKey, metadata, impl = true) {
|
|
327
335
|
return decorator_1.DecoratorManager.createCustomPropertyDecorator(decoratorKey, metadata, impl);
|
|
328
336
|
}
|
|
329
|
-
exports.createCustomPropertyDecorator = createCustomPropertyDecorator;
|
|
330
337
|
/**
|
|
331
338
|
* Create a custom method decorator
|
|
332
339
|
* @param decoratorKey
|
|
@@ -338,7 +345,6 @@ exports.createCustomPropertyDecorator = createCustomPropertyDecorator;
|
|
|
338
345
|
function createCustomMethodDecorator(decoratorKey, metadata, implOrOptions = { impl: true }) {
|
|
339
346
|
return decorator_1.DecoratorManager.createCustomMethodDecorator(decoratorKey, metadata, implOrOptions);
|
|
340
347
|
}
|
|
341
|
-
exports.createCustomMethodDecorator = createCustomMethodDecorator;
|
|
342
348
|
/**
|
|
343
349
|
* Create a custom param decorator
|
|
344
350
|
* @param decoratorKey
|
|
@@ -350,7 +356,6 @@ exports.createCustomMethodDecorator = createCustomMethodDecorator;
|
|
|
350
356
|
function createCustomParamDecorator(decoratorKey, metadata, implOrOptions = { impl: true }) {
|
|
351
357
|
return decorator_1.DecoratorManager.createCustomParamDecorator(decoratorKey, metadata, implOrOptions);
|
|
352
358
|
}
|
|
353
|
-
exports.createCustomParamDecorator = createCustomParamDecorator;
|
|
354
359
|
/**
|
|
355
360
|
* get property(method) type from metadata
|
|
356
361
|
* @param target
|
|
@@ -361,7 +366,6 @@ exports.createCustomParamDecorator = createCustomParamDecorator;
|
|
|
361
366
|
function getPropertyType(target, methodName) {
|
|
362
367
|
return metadataManager_1.MetadataManager.transformTypeFromTSDesign(metadataManager_1.MetadataManager.getPropertyType(target, methodName));
|
|
363
368
|
}
|
|
364
|
-
exports.getPropertyType = getPropertyType;
|
|
365
369
|
/**
|
|
366
370
|
* get parameters type by reflect-metadata
|
|
367
371
|
* @since 3.0.0
|
|
@@ -370,7 +374,6 @@ exports.getPropertyType = getPropertyType;
|
|
|
370
374
|
function getMethodParamTypes(target, methodName) {
|
|
371
375
|
return metadataManager_1.MetadataManager.getMethodParamTypes(target, methodName);
|
|
372
376
|
}
|
|
373
|
-
exports.getMethodParamTypes = getMethodParamTypes;
|
|
374
377
|
/**
|
|
375
378
|
* save property inject args
|
|
376
379
|
* @param opts 参数
|
|
@@ -380,7 +383,6 @@ exports.getMethodParamTypes = getMethodParamTypes;
|
|
|
380
383
|
function savePropertyInject(opts) {
|
|
381
384
|
(0, inject_1.saveInjectMetadata)(opts.identifier, opts.target, opts.targetKey);
|
|
382
385
|
}
|
|
383
|
-
exports.savePropertyInject = savePropertyInject;
|
|
384
386
|
/**
|
|
385
387
|
* get property inject args
|
|
386
388
|
* @param target
|
|
@@ -398,7 +400,6 @@ function getPropertyInject(target, useCache) {
|
|
|
398
400
|
}
|
|
399
401
|
return ret;
|
|
400
402
|
}
|
|
401
|
-
exports.getPropertyInject = getPropertyInject;
|
|
402
403
|
/**
|
|
403
404
|
* save class object definition
|
|
404
405
|
* @param target class
|
|
@@ -410,7 +411,6 @@ function saveObjectDefinition(target, props = {}) {
|
|
|
410
411
|
metadataManager_1.MetadataManager.attachMetadata(constants_1.OBJ_DEF_CLS, props, target, '__fake_object_def_method');
|
|
411
412
|
return target;
|
|
412
413
|
}
|
|
413
|
-
exports.saveObjectDefinition = saveObjectDefinition;
|
|
414
414
|
/**
|
|
415
415
|
* get class object definition from metadata
|
|
416
416
|
* @param target
|
|
@@ -464,5 +464,4 @@ function getObjectDefinition(target) {
|
|
|
464
464
|
return Object.assign(res, scope);
|
|
465
465
|
}
|
|
466
466
|
}
|
|
467
|
-
exports.getObjectDefinition = getObjectDefinition;
|
|
468
467
|
//# sourceMappingURL=decorator.js.map
|
package/dist/response/base.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
import { IMidwayContext } from '../interface';
|
|
4
2
|
export declare class ServerResponse<CTX extends IMidwayContext = IMidwayContext> {
|
|
5
3
|
protected readonly ctx: any;
|
|
6
4
|
protected isSuccess: boolean;
|
|
7
5
|
constructor(ctx: CTX);
|
|
8
|
-
static TEXT_TPL: <CTX_1 extends
|
|
9
|
-
static JSON_TPL: <CTX_1 extends
|
|
10
|
-
static BLOB_TPL: <CTX_1 extends
|
|
6
|
+
static TEXT_TPL: <CTX_1 extends IMidwayContext>(data: string, isSuccess: boolean, ctx: CTX_1) => unknown;
|
|
7
|
+
static JSON_TPL: <CTX_1 extends IMidwayContext>(data: Record<any, any>, isSuccess: boolean, ctx: CTX_1) => unknown;
|
|
8
|
+
static BLOB_TPL: <CTX_1 extends IMidwayContext>(data: Buffer, isSuccess: boolean, ctx: CTX_1) => unknown;
|
|
11
9
|
json(data: Record<any, any>): any;
|
|
12
10
|
text(data: string): any;
|
|
13
11
|
blob(data: Buffer): any;
|
package/dist/response/base.js
CHANGED
|
@@ -2,10 +2,31 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ServerResponse = void 0;
|
|
4
4
|
class ServerResponse {
|
|
5
|
+
ctx;
|
|
6
|
+
isSuccess = true;
|
|
5
7
|
constructor(ctx) {
|
|
6
|
-
this.isSuccess = true;
|
|
7
8
|
this.ctx = ctx;
|
|
8
9
|
}
|
|
10
|
+
static TEXT_TPL = (data, isSuccess, ctx) => {
|
|
11
|
+
return data;
|
|
12
|
+
};
|
|
13
|
+
static JSON_TPL = (data, isSuccess, ctx) => {
|
|
14
|
+
if (isSuccess) {
|
|
15
|
+
return {
|
|
16
|
+
success: 'true',
|
|
17
|
+
data,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
return {
|
|
22
|
+
success: 'false',
|
|
23
|
+
message: data || 'fail',
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
static BLOB_TPL = (data, isSuccess, ctx) => {
|
|
28
|
+
return data;
|
|
29
|
+
};
|
|
9
30
|
json(data) {
|
|
10
31
|
return Object.getPrototypeOf(this).constructor.JSON_TPL(data, this.isSuccess, this.ctx);
|
|
11
32
|
}
|
|
@@ -25,24 +46,4 @@ class ServerResponse {
|
|
|
25
46
|
}
|
|
26
47
|
}
|
|
27
48
|
exports.ServerResponse = ServerResponse;
|
|
28
|
-
ServerResponse.TEXT_TPL = (data, isSuccess, ctx) => {
|
|
29
|
-
return data;
|
|
30
|
-
};
|
|
31
|
-
ServerResponse.JSON_TPL = (data, isSuccess, ctx) => {
|
|
32
|
-
if (isSuccess) {
|
|
33
|
-
return {
|
|
34
|
-
success: 'true',
|
|
35
|
-
data,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
return {
|
|
40
|
-
success: 'false',
|
|
41
|
-
message: data || 'fail',
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
ServerResponse.BLOB_TPL = (data, isSuccess, ctx) => {
|
|
46
|
-
return data;
|
|
47
|
-
};
|
|
48
49
|
//# sourceMappingURL=base.js.map
|
package/dist/response/http.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
1
|
import { IMidwayContext, ServerSendEventMessage, ServerSendEventStreamOptions, ServerStreamOptions } from '../interface';
|
|
5
2
|
import { ServerResponse } from './base';
|
|
6
3
|
import { ServerSendEventStream } from './sse';
|
|
@@ -8,10 +5,10 @@ import { Readable } from 'stream';
|
|
|
8
5
|
import { HttpStreamResponse } from './stream';
|
|
9
6
|
export declare class HttpServerResponse<CTX extends IMidwayContext> extends ServerResponse<CTX> {
|
|
10
7
|
constructor(ctx: CTX);
|
|
11
|
-
static FILE_TPL: <CTX_1 extends
|
|
12
|
-
static SSE_TPL: <CTX_1 extends
|
|
13
|
-
static STREAM_TPL: <CTX_1 extends
|
|
14
|
-
static HTML_TPL: <CTX_1 extends
|
|
8
|
+
static FILE_TPL: <CTX_1 extends IMidwayContext>(data: Readable, isSuccess: boolean, ctx: CTX_1) => Readable;
|
|
9
|
+
static SSE_TPL: <CTX_1 extends IMidwayContext>(data: ServerSendEventMessage, ctx: CTX_1) => ServerSendEventMessage;
|
|
10
|
+
static STREAM_TPL: <CTX_1 extends IMidwayContext>(data: unknown, ctx: CTX_1) => unknown;
|
|
11
|
+
static HTML_TPL: <CTX_1 extends IMidwayContext>(data: string, isSuccess: boolean, ctx: CTX_1) => unknown;
|
|
15
12
|
status(code: number): this;
|
|
16
13
|
header(key: string, value: string): this;
|
|
17
14
|
headers(headers: Record<string, string>): this;
|
package/dist/response/http.js
CHANGED
|
@@ -10,6 +10,18 @@ class HttpServerResponse extends base_1.ServerResponse {
|
|
|
10
10
|
constructor(ctx) {
|
|
11
11
|
super(ctx);
|
|
12
12
|
}
|
|
13
|
+
static FILE_TPL = (data, isSuccess, ctx) => {
|
|
14
|
+
return data;
|
|
15
|
+
};
|
|
16
|
+
static SSE_TPL = (data, ctx) => {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
static STREAM_TPL = (data, ctx) => {
|
|
20
|
+
return data;
|
|
21
|
+
};
|
|
22
|
+
static HTML_TPL = (data, isSuccess, ctx) => {
|
|
23
|
+
return data;
|
|
24
|
+
};
|
|
13
25
|
status(code) {
|
|
14
26
|
this.ctx.res.statusCode = code;
|
|
15
27
|
return this;
|
|
@@ -76,16 +88,4 @@ class HttpServerResponse extends base_1.ServerResponse {
|
|
|
76
88
|
}
|
|
77
89
|
}
|
|
78
90
|
exports.HttpServerResponse = HttpServerResponse;
|
|
79
|
-
HttpServerResponse.FILE_TPL = (data, isSuccess, ctx) => {
|
|
80
|
-
return data;
|
|
81
|
-
};
|
|
82
|
-
HttpServerResponse.SSE_TPL = (data, ctx) => {
|
|
83
|
-
return data;
|
|
84
|
-
};
|
|
85
|
-
HttpServerResponse.STREAM_TPL = (data, ctx) => {
|
|
86
|
-
return data;
|
|
87
|
-
};
|
|
88
|
-
HttpServerResponse.HTML_TPL = (data, isSuccess, ctx) => {
|
|
89
|
-
return data;
|
|
90
|
-
};
|
|
91
91
|
//# sourceMappingURL=http.js.map
|
package/dist/response/sse.d.ts
CHANGED
package/dist/response/sse.js
CHANGED
|
@@ -3,12 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ServerSendEventStream = void 0;
|
|
4
4
|
const stream_1 = require("stream");
|
|
5
5
|
class ServerSendEventStream extends stream_1.Transform {
|
|
6
|
+
ctx;
|
|
7
|
+
isActive = false;
|
|
8
|
+
closeEvent;
|
|
9
|
+
options;
|
|
6
10
|
constructor(ctx, options = {}) {
|
|
7
11
|
super({
|
|
8
12
|
objectMode: true,
|
|
9
13
|
...options,
|
|
10
14
|
});
|
|
11
|
-
this.isActive = false;
|
|
12
15
|
this.ctx = ctx;
|
|
13
16
|
this.closeEvent = options.closeEvent || 'close';
|
|
14
17
|
this.options = options;
|
package/dist/response/stream.js
CHANGED
|
@@ -3,12 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.HttpStreamResponse = void 0;
|
|
4
4
|
const stream_1 = require("stream");
|
|
5
5
|
class HttpStreamResponse extends stream_1.Transform {
|
|
6
|
+
ctx;
|
|
7
|
+
isActive = false;
|
|
8
|
+
options;
|
|
6
9
|
constructor(ctx, options = {}) {
|
|
7
10
|
super({
|
|
8
11
|
objectMode: true,
|
|
9
12
|
...options,
|
|
10
13
|
});
|
|
11
|
-
this.isActive = false;
|
|
12
14
|
this.ctx = ctx;
|
|
13
15
|
this.options = options;
|
|
14
16
|
}
|
|
@@ -16,6 +16,7 @@ const decorator_1 = require("../decorator");
|
|
|
16
16
|
const types_1 = require("../util/types");
|
|
17
17
|
const metadataManager_1 = require("../decorator/metadataManager");
|
|
18
18
|
let MidwayAspectService = class MidwayAspectService {
|
|
19
|
+
applicationContext;
|
|
19
20
|
constructor(applicationContext) {
|
|
20
21
|
this.applicationContext = applicationContext;
|
|
21
22
|
}
|
|
@@ -23,18 +23,19 @@ const decorator_1 = require("../decorator");
|
|
|
23
23
|
const types_1 = require("../util/types");
|
|
24
24
|
const debug = util.debuglog('midway:debug');
|
|
25
25
|
let MidwayConfigService = class MidwayConfigService {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
26
|
+
envDirMap = new Map();
|
|
27
|
+
aliasMap = {
|
|
28
|
+
prod: 'production',
|
|
29
|
+
unittest: 'test',
|
|
30
|
+
};
|
|
31
|
+
configMergeOrder = [];
|
|
32
|
+
configuration = {};
|
|
33
|
+
isReady = false;
|
|
34
|
+
externalObject = [];
|
|
35
|
+
appInfo;
|
|
36
|
+
configFilterList = [];
|
|
37
|
+
environmentService;
|
|
38
|
+
informationService;
|
|
38
39
|
init() {
|
|
39
40
|
this.appInfo = {
|
|
40
41
|
pkg: this.informationService.getPkg(),
|