@midwayjs/core 4.0.0-beta.1 → 4.0.0-beta.11
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/README.md +1 -1
- 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 +4 -4
- package/dist/decorator/faas/serverlessTrigger.js +2 -3
- package/dist/decorator/metadataManager.d.ts +8 -4
- package/dist/decorator/metadataManager.js +49 -63
- 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.d.ts +6 -0
- 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 +25 -1
- package/dist/service/webRouterService.js +20 -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 +2 -2
- package/dist/util/index.js +42 -37
- 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 +5 -5
package/dist/util/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { FunctionMiddleware, IgnoreMatcher } from '../interface';
|
|
3
2
|
import { camelCase, pascalCase } from './camelCase';
|
|
4
3
|
import { randomUUID } from './uuid';
|
|
@@ -26,9 +25,10 @@ export declare const safeRequire: (p: any, enabledCache?: boolean) => any;
|
|
|
26
25
|
*/
|
|
27
26
|
export declare const loadModule: (p: string, options?: {
|
|
28
27
|
enableCache?: boolean;
|
|
29
|
-
loadMode?:
|
|
28
|
+
loadMode?: "commonjs" | "esm";
|
|
30
29
|
safeLoad?: boolean;
|
|
31
30
|
warnOnLoadError?: boolean;
|
|
31
|
+
extraModuleRoot?: string[];
|
|
32
32
|
}) => Promise<any>;
|
|
33
33
|
/**
|
|
34
34
|
* load module sync, and it must be commonjs mode
|
package/dist/util/index.js
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Utils = exports.
|
|
3
|
+
exports.Utils = exports.transformRequestObjectByType = exports.deprecatedOutput = exports.getCurrentDateString = exports.loadModuleSync = exports.loadModule = exports.safeRequire = exports.getCurrentEnvironment = exports.isDevelopmentEnvironment = void 0;
|
|
4
|
+
exports.safelyGet = safelyGet;
|
|
5
|
+
exports.parsePrefix = parsePrefix;
|
|
6
|
+
exports.getUserHome = getUserHome;
|
|
7
|
+
exports.joinURLPath = joinURLPath;
|
|
8
|
+
exports.delegateTargetPrototypeMethod = delegateTargetPrototypeMethod;
|
|
9
|
+
exports.delegateTargetAllPrototypeMethod = delegateTargetAllPrototypeMethod;
|
|
10
|
+
exports.delegateTargetMethod = delegateTargetMethod;
|
|
11
|
+
exports.delegateTargetProperties = delegateTargetProperties;
|
|
12
|
+
exports.toPathMatch = toPathMatch;
|
|
13
|
+
exports.pathMatching = pathMatching;
|
|
14
|
+
exports.wrapMiddleware = wrapMiddleware;
|
|
15
|
+
exports.isIncludeProperty = isIncludeProperty;
|
|
16
|
+
exports.wrapAsync = wrapAsync;
|
|
17
|
+
exports.sleep = sleep;
|
|
18
|
+
exports.getParamNames = getParamNames;
|
|
19
|
+
exports.generateRandomId = generateRandomId;
|
|
20
|
+
exports.merge = merge;
|
|
21
|
+
exports.toAsyncFunction = toAsyncFunction;
|
|
22
|
+
exports.isTypeScriptEnvironment = isTypeScriptEnvironment;
|
|
23
|
+
exports.isConfigurationExport = isConfigurationExport;
|
|
24
|
+
exports.findProjectEntryFile = findProjectEntryFile;
|
|
25
|
+
exports.findProjectEntryFileSync = findProjectEntryFileSync;
|
|
4
26
|
const path_1 = require("path");
|
|
5
27
|
const fs_1 = require("fs");
|
|
6
28
|
const util_1 = require("util");
|
|
@@ -57,7 +79,6 @@ const safeRequire = (p, enabledCache = true) => {
|
|
|
57
79
|
}
|
|
58
80
|
};
|
|
59
81
|
exports.safeRequire = safeRequire;
|
|
60
|
-
const innerLoadModuleCache = {};
|
|
61
82
|
/**
|
|
62
83
|
* load module, and it can be chosen commonjs or esm mode
|
|
63
84
|
* @param p
|
|
@@ -75,23 +96,29 @@ const loadModule = async (p, options = {}) => {
|
|
|
75
96
|
try {
|
|
76
97
|
if (options.enableCache) {
|
|
77
98
|
if (options.loadMode === 'commonjs') {
|
|
78
|
-
|
|
99
|
+
try {
|
|
100
|
+
return require(p);
|
|
101
|
+
}
|
|
102
|
+
catch (_) {
|
|
103
|
+
for (const extraPath of [
|
|
104
|
+
process.cwd(),
|
|
105
|
+
...(options.extraModuleRoot || []),
|
|
106
|
+
]) {
|
|
107
|
+
try {
|
|
108
|
+
return require(require.resolve(p, { paths: [extraPath] }));
|
|
109
|
+
}
|
|
110
|
+
catch (_) {
|
|
111
|
+
// do nothing
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
79
115
|
}
|
|
80
116
|
else {
|
|
81
117
|
// if json file, import need add options
|
|
82
118
|
if (p.endsWith('.json')) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
*/
|
|
87
|
-
if (!innerLoadModuleCache[p]) {
|
|
88
|
-
// return (await import(p, { assert: { type: 'json' } })).default;
|
|
89
|
-
const content = (0, fs_1.readFileSync)(p, {
|
|
90
|
-
encoding: 'utf-8',
|
|
91
|
-
});
|
|
92
|
-
innerLoadModuleCache[p] = JSON.parse(content);
|
|
93
|
-
}
|
|
94
|
-
return innerLoadModuleCache[p];
|
|
119
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
120
|
+
// @ts-ignore
|
|
121
|
+
return (await import(p, { with: { type: 'json' } })).default;
|
|
95
122
|
}
|
|
96
123
|
else {
|
|
97
124
|
return await import((0, url_1.pathToFileURL)(p).href);
|
|
@@ -185,7 +212,6 @@ function safelyGet(list, obj) {
|
|
|
185
212
|
}
|
|
186
213
|
return willReturn;
|
|
187
214
|
}
|
|
188
|
-
exports.safelyGet = safelyGet;
|
|
189
215
|
/**
|
|
190
216
|
* 剔除 @ 符号
|
|
191
217
|
* @param provideId provideId
|
|
@@ -197,11 +223,9 @@ function parsePrefix(provideId) {
|
|
|
197
223
|
}
|
|
198
224
|
return provideId;
|
|
199
225
|
}
|
|
200
|
-
exports.parsePrefix = parsePrefix;
|
|
201
226
|
function getUserHome() {
|
|
202
227
|
return process.env[process.platform === 'win32' ? 'USERPROFILE' : 'HOME'];
|
|
203
228
|
}
|
|
204
|
-
exports.getUserHome = getUserHome;
|
|
205
229
|
function joinURLPath(...strArray) {
|
|
206
230
|
strArray = strArray.filter(item => !!item);
|
|
207
231
|
if (strArray.length === 0) {
|
|
@@ -214,7 +238,6 @@ function joinURLPath(...strArray) {
|
|
|
214
238
|
}
|
|
215
239
|
return p;
|
|
216
240
|
}
|
|
217
|
-
exports.joinURLPath = joinURLPath;
|
|
218
241
|
/**
|
|
219
242
|
* 代理目标所有的原型方法,不包括构造器和内部隐藏方法
|
|
220
243
|
* @param derivedCtor
|
|
@@ -240,7 +263,6 @@ function delegateTargetPrototypeMethod(derivedCtor, constructors, otherMethods)
|
|
|
240
263
|
delegateTargetMethod(derivedCtor, otherMethods);
|
|
241
264
|
}
|
|
242
265
|
}
|
|
243
|
-
exports.delegateTargetPrototypeMethod = delegateTargetPrototypeMethod;
|
|
244
266
|
/**
|
|
245
267
|
* 代理目标所有的原型方法,包括原型链,不包括构造器和内部隐藏方法
|
|
246
268
|
* @param derivedCtor
|
|
@@ -253,7 +275,6 @@ function delegateTargetAllPrototypeMethod(derivedCtor, constructor) {
|
|
|
253
275
|
constructor = Object.getPrototypeOf(constructor);
|
|
254
276
|
} while (constructor);
|
|
255
277
|
}
|
|
256
|
-
exports.delegateTargetAllPrototypeMethod = delegateTargetAllPrototypeMethod;
|
|
257
278
|
/**
|
|
258
279
|
* 代理目标原型上的特定方法
|
|
259
280
|
* @param derivedCtor
|
|
@@ -267,7 +288,6 @@ function delegateTargetMethod(derivedCtor, methods) {
|
|
|
267
288
|
};
|
|
268
289
|
});
|
|
269
290
|
}
|
|
270
|
-
exports.delegateTargetMethod = delegateTargetMethod;
|
|
271
291
|
/**
|
|
272
292
|
* 代理目标原型属性
|
|
273
293
|
* @param derivedCtor
|
|
@@ -283,7 +303,6 @@ function delegateTargetProperties(derivedCtor, properties) {
|
|
|
283
303
|
});
|
|
284
304
|
});
|
|
285
305
|
}
|
|
286
|
-
exports.delegateTargetProperties = delegateTargetProperties;
|
|
287
306
|
/**
|
|
288
307
|
* 获取当前的时间戳
|
|
289
308
|
* @since 2.0.0
|
|
@@ -359,7 +378,6 @@ function toPathMatch(pattern) {
|
|
|
359
378
|
}
|
|
360
379
|
throw new error_1.MidwayCommonError('match/ignore pattern must be RegExp, Array or String, but got ' + pattern);
|
|
361
380
|
}
|
|
362
|
-
exports.toPathMatch = toPathMatch;
|
|
363
381
|
function pathMatching(options) {
|
|
364
382
|
options = options || {};
|
|
365
383
|
if (options.match && options.ignore)
|
|
@@ -397,7 +415,6 @@ function pathMatching(options) {
|
|
|
397
415
|
return options.match ? matched : !matched;
|
|
398
416
|
};
|
|
399
417
|
}
|
|
400
|
-
exports.pathMatching = pathMatching;
|
|
401
418
|
/**
|
|
402
419
|
* wrap function middleware with match and ignore
|
|
403
420
|
* @param mw
|
|
@@ -419,7 +436,6 @@ function wrapMiddleware(mw, options) {
|
|
|
419
436
|
fn._name = mw._name + 'middlewareWrapper';
|
|
420
437
|
return fn;
|
|
421
438
|
}
|
|
422
|
-
exports.wrapMiddleware = wrapMiddleware;
|
|
423
439
|
function isOwnPropertyWritable(obj, prop) {
|
|
424
440
|
if (obj == null)
|
|
425
441
|
return false;
|
|
@@ -436,7 +452,6 @@ function isIncludeProperty(obj, prop) {
|
|
|
436
452
|
}
|
|
437
453
|
return false;
|
|
438
454
|
}
|
|
439
|
-
exports.isIncludeProperty = isIncludeProperty;
|
|
440
455
|
function wrapAsync(handler) {
|
|
441
456
|
return (...args) => {
|
|
442
457
|
if (typeof args[args.length - 1] === 'function') {
|
|
@@ -457,7 +472,6 @@ function wrapAsync(handler) {
|
|
|
457
472
|
}
|
|
458
473
|
};
|
|
459
474
|
}
|
|
460
|
-
exports.wrapAsync = wrapAsync;
|
|
461
475
|
function sleep(sleepTime = 1000, abortController) {
|
|
462
476
|
return new Promise(resolve => {
|
|
463
477
|
const timeoutHandler = setTimeout(() => {
|
|
@@ -470,7 +484,6 @@ function sleep(sleepTime = 1000, abortController) {
|
|
|
470
484
|
}
|
|
471
485
|
});
|
|
472
486
|
}
|
|
473
|
-
exports.sleep = sleep;
|
|
474
487
|
const STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;
|
|
475
488
|
/**
|
|
476
489
|
* get parameter name from function
|
|
@@ -489,7 +502,6 @@ function getParamNames(func) {
|
|
|
489
502
|
}
|
|
490
503
|
return result;
|
|
491
504
|
}
|
|
492
|
-
exports.getParamNames = getParamNames;
|
|
493
505
|
/**
|
|
494
506
|
* generate a lightweight 32 bit random id, enough for ioc container
|
|
495
507
|
*/
|
|
@@ -497,7 +509,6 @@ function generateRandomId() {
|
|
|
497
509
|
// => f9b327e70bbcf42494ccb28b2d98e00e
|
|
498
510
|
return crypto.randomBytes(16).toString('hex');
|
|
499
511
|
}
|
|
500
|
-
exports.generateRandomId = generateRandomId;
|
|
501
512
|
function merge(target, src) {
|
|
502
513
|
if (!target) {
|
|
503
514
|
target = src;
|
|
@@ -514,7 +525,6 @@ function merge(target, src) {
|
|
|
514
525
|
}
|
|
515
526
|
throw new Error('can not merge meta that type of ' + typeof target);
|
|
516
527
|
}
|
|
517
|
-
exports.merge = merge;
|
|
518
528
|
function toAsyncFunction(method) {
|
|
519
529
|
if (types_1.Types.isAsyncFunction(method)) {
|
|
520
530
|
return method;
|
|
@@ -525,7 +535,6 @@ function toAsyncFunction(method) {
|
|
|
525
535
|
};
|
|
526
536
|
}
|
|
527
537
|
}
|
|
528
|
-
exports.toAsyncFunction = toAsyncFunction;
|
|
529
538
|
function isTypeScriptEnvironment() {
|
|
530
539
|
const TS_MODE_PROCESS_FLAG = process.env.MIDWAY_TS_MODE;
|
|
531
540
|
if ('false' === TS_MODE_PROCESS_FLAG) {
|
|
@@ -534,7 +543,6 @@ function isTypeScriptEnvironment() {
|
|
|
534
543
|
// eslint-disable-next-line node/no-deprecated-api
|
|
535
544
|
return TS_MODE_PROCESS_FLAG === 'true' || !!require.extensions['.ts'];
|
|
536
545
|
}
|
|
537
|
-
exports.isTypeScriptEnvironment = isTypeScriptEnvironment;
|
|
538
546
|
function getFileNameWithSuffix(fileName) {
|
|
539
547
|
return isTypeScriptEnvironment() ? `${fileName}.ts` : `${fileName}.js`;
|
|
540
548
|
}
|
|
@@ -544,7 +552,6 @@ function isConfigurationExport(exports) {
|
|
|
544
552
|
(types_1.Types.isObject(exports) &&
|
|
545
553
|
metadataManager_1.MetadataManager.hasOwnMetadata(decorator_1.CONFIGURATION_OBJECT_KEY, exports)));
|
|
546
554
|
}
|
|
547
|
-
exports.isConfigurationExport = isConfigurationExport;
|
|
548
555
|
async function findProjectEntryFile(appDir, baseDir, loadMode) {
|
|
549
556
|
/**
|
|
550
557
|
* 查找常用文件中的 midway 入口,入口文件包括 Configuration 对象或者 defineConfiguration 函数
|
|
@@ -594,7 +601,6 @@ async function findProjectEntryFile(appDir, baseDir, loadMode) {
|
|
|
594
601
|
}
|
|
595
602
|
}
|
|
596
603
|
}
|
|
597
|
-
exports.findProjectEntryFile = findProjectEntryFile;
|
|
598
604
|
function findProjectEntryFileSync(appDir, baseDir) {
|
|
599
605
|
/**
|
|
600
606
|
* 查找常用文件中的 midway 入口,入口文件包括 Configuration 对象或者 defineConfiguration 函数
|
|
@@ -643,7 +649,6 @@ function findProjectEntryFileSync(appDir, baseDir) {
|
|
|
643
649
|
}
|
|
644
650
|
}
|
|
645
651
|
}
|
|
646
|
-
exports.findProjectEntryFileSync = findProjectEntryFileSync;
|
|
647
652
|
exports.Utils = {
|
|
648
653
|
sleep,
|
|
649
654
|
getParamNames,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PathFileUtils =
|
|
3
|
+
exports.PathFileUtils = void 0;
|
|
4
|
+
exports.isPath = isPath;
|
|
5
|
+
exports.isPathEqual = isPathEqual;
|
|
6
|
+
exports.getFileContentSync = getFileContentSync;
|
|
7
|
+
exports.normalizePath = normalizePath;
|
|
8
|
+
exports.getModuleRequirePathList = getModuleRequirePathList;
|
|
4
9
|
const path_1 = require("path");
|
|
5
10
|
const fs_1 = require("fs");
|
|
6
11
|
function isPath(p) {
|
|
@@ -10,7 +15,6 @@ function isPath(p) {
|
|
|
10
15
|
}
|
|
11
16
|
return false;
|
|
12
17
|
}
|
|
13
|
-
exports.isPath = isPath;
|
|
14
18
|
function isPathEqual(one, two) {
|
|
15
19
|
if (!one || !two) {
|
|
16
20
|
return false;
|
|
@@ -18,7 +22,6 @@ function isPathEqual(one, two) {
|
|
|
18
22
|
const ext = (0, path_1.extname)(one);
|
|
19
23
|
return one.replace(ext, '') === two;
|
|
20
24
|
}
|
|
21
|
-
exports.isPathEqual = isPathEqual;
|
|
22
25
|
function getFileContentSync(filePath, encoding) {
|
|
23
26
|
return typeof filePath === 'string'
|
|
24
27
|
? (0, fs_1.readFileSync)(filePath, {
|
|
@@ -26,7 +29,6 @@ function getFileContentSync(filePath, encoding) {
|
|
|
26
29
|
})
|
|
27
30
|
: filePath;
|
|
28
31
|
}
|
|
29
|
-
exports.getFileContentSync = getFileContentSync;
|
|
30
32
|
/**
|
|
31
33
|
* Normalize path, if p is absolute path, return p, otherwise join p with baseDir
|
|
32
34
|
*
|
|
@@ -47,7 +49,6 @@ function normalizePath(baseDir, p) {
|
|
|
47
49
|
return (0, path_1.resolve)(baseDir, p);
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
|
-
exports.normalizePath = normalizePath;
|
|
51
52
|
function getModuleRequirePathList(moduleName) {
|
|
52
53
|
const moduleNameList = [moduleName, moduleName.replace(/\//g, '_')];
|
|
53
54
|
let moduleNameMap = {};
|
|
@@ -74,7 +75,6 @@ function getModuleRequirePathList(moduleName) {
|
|
|
74
75
|
moduleNameMap = undefined;
|
|
75
76
|
return modulePathList;
|
|
76
77
|
}
|
|
77
|
-
exports.getModuleRequirePathList = getModuleRequirePathList;
|
|
78
78
|
exports.PathFileUtils = {
|
|
79
79
|
isPath,
|
|
80
80
|
isPathEqual,
|
package/dist/util/retry.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.retryWithAsync = retryWithAsync;
|
|
4
|
+
exports.retryWith = retryWith;
|
|
4
5
|
const _1 = require(".");
|
|
5
6
|
const error_1 = require("../error");
|
|
6
7
|
/**
|
|
@@ -32,7 +33,6 @@ function retryWithAsync(retryFn, retryTimes = 1, options = {}) {
|
|
|
32
33
|
}
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
|
-
exports.retryWithAsync = retryWithAsync;
|
|
36
36
|
/**
|
|
37
37
|
* wrap sync function with retry
|
|
38
38
|
* @param retryFn
|
|
@@ -59,5 +59,4 @@ function retryWith(retryFn, retryTimes = 1, options = {}) {
|
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
exports.retryWith = retryWith;
|
|
63
62
|
//# sourceMappingURL=retry.js.map
|
package/dist/util/timeout.d.ts
CHANGED
package/dist/util/timeout.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createPromiseTimeoutInvokeChain =
|
|
3
|
+
exports.createPromiseTimeoutInvokeChain = createPromiseTimeoutInvokeChain;
|
|
4
4
|
const error_1 = require("../error");
|
|
5
5
|
/**
|
|
6
6
|
* Create a Promise that resolves after the specified time
|
|
@@ -140,5 +140,4 @@ async function createPromiseTimeoutInvokeChain(options) {
|
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
exports.createPromiseTimeoutInvokeChain = createPromiseTimeoutInvokeChain;
|
|
144
143
|
//# sourceMappingURL=timeout.js.map
|
package/dist/util/types.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export declare function isString(value: any):
|
|
1
|
+
export declare function isString(value: any): value is string;
|
|
2
2
|
export declare function isClass(fn: any): boolean;
|
|
3
3
|
export declare function isAsyncFunction(value: any): boolean;
|
|
4
|
-
export declare function isGeneratorFunction(value: any):
|
|
5
|
-
export declare function isPromise(value: any):
|
|
4
|
+
export declare function isGeneratorFunction(value: any): value is GeneratorFunction;
|
|
5
|
+
export declare function isPromise(value: any): value is Promise<unknown>;
|
|
6
6
|
export declare function isFunction(value: any): boolean;
|
|
7
7
|
export declare function isObject(value: any): boolean;
|
|
8
8
|
export declare function isPlainObject(obj: any): any;
|
|
9
|
-
export declare function isNumber(value: any):
|
|
9
|
+
export declare function isNumber(value: any): value is number;
|
|
10
10
|
export declare function isProxy(value: any): boolean;
|
|
11
|
-
export declare function isMap(value: any):
|
|
12
|
-
export declare function isSet(value: any):
|
|
13
|
-
export declare function isRegExp(value: any):
|
|
11
|
+
export declare function isMap(value: any): value is Map<unknown, unknown>;
|
|
12
|
+
export declare function isSet(value: any): value is Set<unknown>;
|
|
13
|
+
export declare function isRegExp(value: any): value is RegExp;
|
|
14
14
|
export declare function isUndefined(value: any): boolean;
|
|
15
15
|
export declare function isNull(value: any): boolean;
|
|
16
16
|
export declare function isNullOrUndefined(value: any): boolean;
|
package/dist/util/types.js
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Types =
|
|
3
|
+
exports.Types = void 0;
|
|
4
|
+
exports.isString = isString;
|
|
5
|
+
exports.isClass = isClass;
|
|
6
|
+
exports.isAsyncFunction = isAsyncFunction;
|
|
7
|
+
exports.isGeneratorFunction = isGeneratorFunction;
|
|
8
|
+
exports.isPromise = isPromise;
|
|
9
|
+
exports.isFunction = isFunction;
|
|
10
|
+
exports.isObject = isObject;
|
|
11
|
+
exports.isPlainObject = isPlainObject;
|
|
12
|
+
exports.isNumber = isNumber;
|
|
13
|
+
exports.isProxy = isProxy;
|
|
14
|
+
exports.isMap = isMap;
|
|
15
|
+
exports.isSet = isSet;
|
|
16
|
+
exports.isRegExp = isRegExp;
|
|
17
|
+
exports.isUndefined = isUndefined;
|
|
18
|
+
exports.isNull = isNull;
|
|
19
|
+
exports.isNullOrUndefined = isNullOrUndefined;
|
|
4
20
|
const util = require("util");
|
|
5
21
|
const ToString = Function.prototype.toString;
|
|
6
22
|
const hasOwn = Object.prototype.hasOwnProperty;
|
|
@@ -8,7 +24,6 @@ const toStr = Object.prototype.toString;
|
|
|
8
24
|
function isString(value) {
|
|
9
25
|
return typeof value === 'string';
|
|
10
26
|
}
|
|
11
|
-
exports.isString = isString;
|
|
12
27
|
function isClass(fn) {
|
|
13
28
|
if (typeof fn !== 'function') {
|
|
14
29
|
return false;
|
|
@@ -17,27 +32,21 @@ function isClass(fn) {
|
|
|
17
32
|
return true;
|
|
18
33
|
}
|
|
19
34
|
}
|
|
20
|
-
exports.isClass = isClass;
|
|
21
35
|
function isAsyncFunction(value) {
|
|
22
36
|
return util.types.isAsyncFunction(value);
|
|
23
37
|
}
|
|
24
|
-
exports.isAsyncFunction = isAsyncFunction;
|
|
25
38
|
function isGeneratorFunction(value) {
|
|
26
39
|
return util.types.isGeneratorFunction(value);
|
|
27
40
|
}
|
|
28
|
-
exports.isGeneratorFunction = isGeneratorFunction;
|
|
29
41
|
function isPromise(value) {
|
|
30
42
|
return util.types.isPromise(value);
|
|
31
43
|
}
|
|
32
|
-
exports.isPromise = isPromise;
|
|
33
44
|
function isFunction(value) {
|
|
34
45
|
return typeof value === 'function';
|
|
35
46
|
}
|
|
36
|
-
exports.isFunction = isFunction;
|
|
37
47
|
function isObject(value) {
|
|
38
48
|
return value !== null && typeof value === 'object';
|
|
39
49
|
}
|
|
40
|
-
exports.isObject = isObject;
|
|
41
50
|
function isPlainObject(obj) {
|
|
42
51
|
if (!obj || toStr.call(obj) !== '[object Object]') {
|
|
43
52
|
return false;
|
|
@@ -58,39 +67,30 @@ function isPlainObject(obj) {
|
|
|
58
67
|
}
|
|
59
68
|
return typeof key === 'undefined' || hasOwn.call(obj, key);
|
|
60
69
|
}
|
|
61
|
-
exports.isPlainObject = isPlainObject;
|
|
62
70
|
function isNumber(value) {
|
|
63
71
|
return typeof value === 'number';
|
|
64
72
|
}
|
|
65
|
-
exports.isNumber = isNumber;
|
|
66
73
|
function isProxy(value) {
|
|
67
74
|
return util.types.isProxy(value);
|
|
68
75
|
}
|
|
69
|
-
exports.isProxy = isProxy;
|
|
70
76
|
function isMap(value) {
|
|
71
77
|
return util.types.isMap(value);
|
|
72
78
|
}
|
|
73
|
-
exports.isMap = isMap;
|
|
74
79
|
function isSet(value) {
|
|
75
80
|
return util.types.isSet(value);
|
|
76
81
|
}
|
|
77
|
-
exports.isSet = isSet;
|
|
78
82
|
function isRegExp(value) {
|
|
79
83
|
return util.types.isRegExp(value);
|
|
80
84
|
}
|
|
81
|
-
exports.isRegExp = isRegExp;
|
|
82
85
|
function isUndefined(value) {
|
|
83
86
|
return value === undefined;
|
|
84
87
|
}
|
|
85
|
-
exports.isUndefined = isUndefined;
|
|
86
88
|
function isNull(value) {
|
|
87
89
|
return value === null;
|
|
88
90
|
}
|
|
89
|
-
exports.isNull = isNull;
|
|
90
91
|
function isNullOrUndefined(value) {
|
|
91
92
|
return isUndefined(value) || isNull(value);
|
|
92
93
|
}
|
|
93
|
-
exports.isNullOrUndefined = isNullOrUndefined;
|
|
94
94
|
exports.Types = {
|
|
95
95
|
isClass,
|
|
96
96
|
isAsyncFunction,
|
package/dist/util/uuid.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.randomUUID =
|
|
3
|
+
exports.randomUUID = randomUUID;
|
|
4
4
|
const crypto = require("crypto");
|
|
5
5
|
/**
|
|
6
6
|
* code fork from https://github.com/uuidjs/uuid/blob/main/src/stringify.js
|
|
@@ -60,5 +60,4 @@ function randomUUID(force) {
|
|
|
60
60
|
rnds[8] = (rnds[8] & 0x3f) | 0x80;
|
|
61
61
|
return unsafeStringify(rnds);
|
|
62
62
|
}
|
|
63
|
-
exports.randomUUID = randomUUID;
|
|
64
63
|
//# sourceMappingURL=uuid.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/core",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.11",
|
|
4
4
|
"description": "midway core",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
],
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@midwayjs/logger": "^
|
|
25
|
+
"@midwayjs/logger": "^4.0.0",
|
|
26
26
|
"eventsource": "2.0.2",
|
|
27
|
-
"koa": "
|
|
27
|
+
"koa": "3.0.3",
|
|
28
28
|
"mm": "3.4.0",
|
|
29
29
|
"raw-body": "2.5.2",
|
|
30
30
|
"sinon": "17.0.2"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"url": "https://github.com/midwayjs/midway.git"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
|
-
"node": ">=
|
|
43
|
+
"node": ">=20"
|
|
44
44
|
},
|
|
45
45
|
"madge": {
|
|
46
46
|
"detectiveOptions": {
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"types": "./dist/functional/index.d.ts"
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "6ef05719ca6e900f1ec34aff7a5c5a9614358c50"
|
|
65
65
|
}
|