@midwayjs/core 3.5.4-beta.2 → 3.6.0
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/LICENSE +21 -0
- package/dist/baseFramework.d.ts +7 -2
- package/dist/baseFramework.js +27 -9
- package/dist/common/applicationManager.d.ts +1 -1
- package/dist/common/applicationManager.js +1 -1
- package/dist/common/dataListener.js +1 -1
- package/dist/common/dataSourceManager.js +7 -7
- package/dist/common/fileDetector.js +6 -5
- package/dist/common/filterManager.js +1 -1
- package/dist/common/guardManager.d.ts +6 -0
- package/dist/common/guardManager.js +49 -0
- package/dist/common/middlewareManager.d.ts +2 -2
- package/dist/common/webGenerator.d.ts +2 -1
- package/dist/common/webGenerator.js +12 -3
- package/dist/config/config.default.d.ts +2 -11
- package/dist/config/config.default.js +2 -2
- package/dist/{common/constants.d.ts → constants.d.ts} +10 -1
- package/dist/{common/constants.js → constants.js} +18 -2
- package/dist/context/container.d.ts +1 -1
- package/dist/context/container.js +16 -14
- package/dist/context/definitionRegistry.d.ts +1 -1
- package/dist/context/definitionRegistry.js +1 -1
- package/dist/context/managedResolverFactory.d.ts +1 -4
- package/dist/context/managedResolverFactory.js +6 -6
- package/dist/context/providerWrapper.d.ts +1 -1
- package/dist/context/providerWrapper.js +1 -1
- package/dist/context/requestContainer.js +3 -3
- package/dist/decorator/common/aspect.d.ts +20 -0
- package/dist/decorator/common/aspect.js +22 -0
- package/dist/decorator/common/autoload.d.ts +2 -0
- package/dist/decorator/common/autoload.js +13 -0
- package/dist/decorator/common/configuration.d.ts +24 -0
- package/dist/decorator/common/configuration.js +11 -0
- package/dist/decorator/common/filter.d.ts +6 -0
- package/dist/decorator/common/filter.js +31 -0
- package/dist/decorator/common/framework.d.ts +8 -0
- package/dist/decorator/common/framework.js +41 -0
- package/dist/decorator/common/guard.d.ts +4 -0
- package/dist/decorator/common/guard.js +30 -0
- package/dist/decorator/common/inject.d.ts +3 -0
- package/dist/decorator/common/inject.js +11 -0
- package/dist/decorator/common/middleware.d.ts +2 -0
- package/dist/decorator/common/middleware.js +12 -0
- package/dist/decorator/common/objectDef.d.ts +7 -0
- package/dist/decorator/common/objectDef.js +25 -0
- package/dist/decorator/common/pipeline.d.ts +3 -0
- package/dist/decorator/common/pipeline.js +12 -0
- package/dist/decorator/common/provide.d.ts +3 -0
- package/dist/decorator/common/provide.js +11 -0
- package/dist/decorator/constant.d.ts +55 -0
- package/dist/decorator/constant.js +86 -0
- package/dist/decorator/decoratorManager.d.ts +301 -0
- package/dist/decorator/decoratorManager.js +709 -0
- package/dist/decorator/faas/serverlessTrigger.d.ts +13 -0
- package/dist/decorator/faas/serverlessTrigger.js +29 -0
- package/dist/decorator/index.d.ts +31 -0
- package/dist/decorator/index.js +55 -0
- package/dist/decorator/interface.d.ts +238 -0
- package/dist/decorator/interface.js +67 -0
- package/dist/decorator/microservice/consumer.d.ts +5 -0
- package/dist/decorator/microservice/consumer.js +17 -0
- package/dist/decorator/microservice/kafkaListener.d.ts +24 -0
- package/dist/decorator/microservice/kafkaListener.js +13 -0
- package/dist/decorator/microservice/provider.d.ts +16 -0
- package/dist/decorator/microservice/provider.js +47 -0
- package/dist/decorator/microservice/rabbitmqListener.d.ts +50 -0
- package/dist/decorator/microservice/rabbitmqListener.js +13 -0
- package/dist/decorator/rpc/hsf.d.ts +12 -0
- package/dist/decorator/rpc/hsf.js +18 -0
- package/dist/decorator/task/queue.d.ts +2 -0
- package/dist/decorator/task/queue.js +17 -0
- package/dist/decorator/task/schedule.d.ts +21 -0
- package/dist/decorator/task/schedule.js +14 -0
- package/dist/decorator/task/task.d.ts +2 -0
- package/dist/decorator/task/task.js +18 -0
- package/dist/decorator/task/taskLocal.d.ts +2 -0
- package/dist/decorator/task/taskLocal.js +17 -0
- package/dist/decorator/web/controller.d.ts +20 -0
- package/dist/decorator/web/controller.js +18 -0
- package/dist/decorator/web/paramMapping.d.ts +31 -0
- package/dist/decorator/web/paramMapping.js +50 -0
- package/dist/decorator/web/requestMapping.d.ts +132 -0
- package/dist/decorator/web/requestMapping.js +83 -0
- package/dist/decorator/web/response.d.ts +9 -0
- package/dist/decorator/web/response.js +65 -0
- package/dist/decorator/ws/webSocketController.d.ts +10 -0
- package/dist/decorator/ws/webSocketController.js +20 -0
- package/dist/decorator/ws/webSocketEvent.d.ts +60 -0
- package/dist/decorator/ws/webSocketEvent.js +87 -0
- package/dist/definitions/functionDefinition.d.ts +1 -1
- package/dist/definitions/functionDefinition.js +1 -1
- package/dist/definitions/objectCreator.d.ts +1 -1
- package/dist/definitions/objectCreator.js +7 -7
- package/dist/definitions/objectDefinition.d.ts +1 -1
- package/dist/definitions/objectDefinition.js +1 -1
- package/dist/definitions/properties.d.ts +1 -1
- package/dist/error/framework.d.ts +5 -1
- package/dist/error/framework.js +9 -2
- package/dist/functional/configuration.d.ts +1 -1
- package/dist/index.d.ts +18 -15
- package/dist/index.js +40 -27
- package/dist/interface.d.ts +52 -18
- package/dist/interface.js +1 -17
- package/dist/service/aspectService.d.ts +1 -1
- package/dist/service/aspectService.js +3 -2
- package/dist/service/configService.js +3 -2
- package/dist/service/decoratorService.js +1 -1
- package/dist/service/environmentService.js +1 -1
- package/dist/service/frameworkService.d.ts +1 -1
- package/dist/service/frameworkService.js +3 -3
- package/dist/service/informationService.js +1 -1
- package/dist/service/lifeCycleService.js +1 -1
- package/dist/service/loggerService.js +1 -1
- package/dist/service/middlewareService.js +3 -2
- package/dist/service/mockService.js +1 -1
- package/dist/service/pipelineService.d.ts +1 -1
- package/dist/service/pipelineService.js +1 -1
- package/dist/service/slsFunctionService.d.ts +1 -1
- package/dist/service/slsFunctionService.js +1 -1
- package/dist/service/webRouterService.d.ts +9 -1
- package/dist/service/webRouterService.js +6 -3
- package/dist/setup.d.ts +3 -3
- package/dist/setup.js +1 -1
- package/dist/util/camelCase.d.ts +3 -0
- package/dist/util/camelCase.js +88 -0
- package/dist/util/contextUtil.js +2 -2
- package/dist/util/extend.js +3 -3
- package/dist/util/flatted.d.ts +7 -0
- package/dist/util/flatted.js +91 -0
- package/dist/util/format.d.ts +25 -0
- package/dist/util/format.js +38 -0
- package/dist/util/fs.d.ts +5 -0
- package/dist/util/fs.js +15 -0
- package/dist/util/httpclient.d.ts +1 -0
- package/dist/util/index.d.ts +26 -0
- package/dist/util/index.js +80 -1
- package/dist/util/pathFileUtil.d.ts +6 -3
- package/dist/util/pathFileUtil.js +28 -22
- package/dist/util/retry.js +2 -2
- package/dist/util/types.d.ts +35 -0
- package/dist/util/types.js +121 -0
- package/dist/util/uuid.d.ts +5 -0
- package/dist/util/uuid.js +64 -0
- package/dist/util/webRouterParam.js +1 -1
- package/package.json +8 -11
package/dist/util/index.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wrapAsync = exports.isIncludeProperty = exports.wrapMiddleware = exports.pathMatching = exports.toPathMatch = exports.transformRequestObjectByType = exports.deprecatedOutput = exports.getCurrentDateString = exports.delegateTargetProperties = exports.delegateTargetMethod = exports.delegateTargetAllPrototypeMethod = exports.delegateTargetPrototypeMethod = exports.joinURLPath = exports.getUserHome = exports.parsePrefix = exports.safelyGet = exports.safeRequire = exports.getCurrentEnvironment = exports.isDevelopmentEnvironment = void 0;
|
|
3
|
+
exports.Utils = exports.toAsyncFunction = exports.merge = exports.generateRandomId = exports.getParamNames = exports.sleep = exports.wrapAsync = exports.isIncludeProperty = exports.wrapMiddleware = exports.pathMatching = exports.toPathMatch = exports.transformRequestObjectByType = exports.deprecatedOutput = exports.getCurrentDateString = exports.delegateTargetProperties = exports.delegateTargetMethod = exports.delegateTargetAllPrototypeMethod = exports.delegateTargetPrototypeMethod = exports.joinURLPath = exports.getUserHome = exports.parsePrefix = exports.safelyGet = exports.safeRequire = exports.getCurrentEnvironment = exports.isDevelopmentEnvironment = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
6
|
const util_1 = require("util");
|
|
7
7
|
const transformer = require("class-transformer");
|
|
8
8
|
const pathToRegexp_1 = require("./pathToRegexp");
|
|
9
9
|
const error_1 = require("../error");
|
|
10
|
+
const camelCase_1 = require("./camelCase");
|
|
11
|
+
const uuid_1 = require("./uuid");
|
|
12
|
+
const flatted_1 = require("./flatted");
|
|
13
|
+
const crypto = require("crypto");
|
|
14
|
+
const types_1 = require("./types");
|
|
10
15
|
const debug = (0, util_1.debuglog)('midway:container:util');
|
|
11
16
|
/**
|
|
12
17
|
* @since 2.0.0
|
|
@@ -334,4 +339,78 @@ function wrapAsync(handler) {
|
|
|
334
339
|
};
|
|
335
340
|
}
|
|
336
341
|
exports.wrapAsync = wrapAsync;
|
|
342
|
+
function sleep(sleepTime = 1000) {
|
|
343
|
+
return new Promise(resolve => {
|
|
344
|
+
setTimeout(() => {
|
|
345
|
+
resolve();
|
|
346
|
+
}, sleepTime);
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
exports.sleep = sleep;
|
|
350
|
+
const STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;
|
|
351
|
+
/**
|
|
352
|
+
* get parameter name from function
|
|
353
|
+
* @param func
|
|
354
|
+
*/
|
|
355
|
+
function getParamNames(func) {
|
|
356
|
+
const fnStr = func.toString().replace(STRIP_COMMENTS, '');
|
|
357
|
+
let result = fnStr
|
|
358
|
+
.slice(fnStr.indexOf('(') + 1, fnStr.indexOf(')'))
|
|
359
|
+
.split(',')
|
|
360
|
+
.map(content => {
|
|
361
|
+
return content.trim().replace(/\s?=.*$/, '');
|
|
362
|
+
});
|
|
363
|
+
if (result.length === 1 && result[0] === '') {
|
|
364
|
+
result = [];
|
|
365
|
+
}
|
|
366
|
+
return result;
|
|
367
|
+
}
|
|
368
|
+
exports.getParamNames = getParamNames;
|
|
369
|
+
/**
|
|
370
|
+
* generate a lightweight 32 bit random id, enough for ioc container
|
|
371
|
+
*/
|
|
372
|
+
function generateRandomId() {
|
|
373
|
+
// => f9b327e70bbcf42494ccb28b2d98e00e
|
|
374
|
+
return crypto.randomBytes(16).toString('hex');
|
|
375
|
+
}
|
|
376
|
+
exports.generateRandomId = generateRandomId;
|
|
377
|
+
function merge(target, src) {
|
|
378
|
+
if (!target) {
|
|
379
|
+
target = src;
|
|
380
|
+
src = null;
|
|
381
|
+
}
|
|
382
|
+
if (!target) {
|
|
383
|
+
return null;
|
|
384
|
+
}
|
|
385
|
+
if (Array.isArray(target)) {
|
|
386
|
+
return target.concat(src || []);
|
|
387
|
+
}
|
|
388
|
+
if (typeof target === 'object') {
|
|
389
|
+
return Object.assign({}, target, src);
|
|
390
|
+
}
|
|
391
|
+
throw new Error('can not merge meta that type of ' + typeof target);
|
|
392
|
+
}
|
|
393
|
+
exports.merge = merge;
|
|
394
|
+
function toAsyncFunction(method) {
|
|
395
|
+
if (types_1.Types.isAsyncFunction(method)) {
|
|
396
|
+
return method;
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
return async function (...args) {
|
|
400
|
+
return Promise.resolve(method.call(this, ...args));
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
exports.toAsyncFunction = toAsyncFunction;
|
|
405
|
+
exports.Utils = {
|
|
406
|
+
sleep,
|
|
407
|
+
getParamNames,
|
|
408
|
+
camelCase: camelCase_1.camelCase,
|
|
409
|
+
pascalCase: camelCase_1.pascalCase,
|
|
410
|
+
randomUUID: uuid_1.randomUUID,
|
|
411
|
+
generateRandomId,
|
|
412
|
+
toAsyncFunction,
|
|
413
|
+
safeStringify: flatted_1.safeStringify,
|
|
414
|
+
safeParse: flatted_1.safeParse,
|
|
415
|
+
};
|
|
337
416
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
export declare function isPath(p: any): boolean;
|
|
3
|
+
export declare function isPathEqual(one: string, two: string): boolean;
|
|
4
|
+
export declare function getFileContentSync(filePath: any, encoding?: BufferEncoding): any;
|
|
2
5
|
export declare const PathFileUtil: {
|
|
3
|
-
isPath
|
|
4
|
-
isPathEqual
|
|
5
|
-
getFileContentSync
|
|
6
|
+
isPath: typeof isPath;
|
|
7
|
+
isPathEqual: typeof isPathEqual;
|
|
8
|
+
getFileContentSync: typeof getFileContentSync;
|
|
6
9
|
};
|
|
7
10
|
//# sourceMappingURL=pathFileUtil.d.ts.map
|
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PathFileUtil = void 0;
|
|
3
|
+
exports.PathFileUtil = exports.getFileContentSync = exports.isPathEqual = exports.isPath = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
function isPath(p) {
|
|
7
|
+
// eslint-disable-next-line no-useless-escape
|
|
8
|
+
if (/(^[\.\/])|:|\\/.test(p)) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
exports.isPath = isPath;
|
|
14
|
+
function isPathEqual(one, two) {
|
|
15
|
+
if (!one || !two) {
|
|
12
16
|
return false;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
}
|
|
18
|
+
const ext = (0, path_1.extname)(one);
|
|
19
|
+
return one.replace(ext, '') === two;
|
|
20
|
+
}
|
|
21
|
+
exports.isPathEqual = isPathEqual;
|
|
22
|
+
function getFileContentSync(filePath, encoding) {
|
|
23
|
+
return typeof filePath === 'string'
|
|
24
|
+
? (0, fs_1.readFileSync)(filePath, {
|
|
25
|
+
encoding,
|
|
26
|
+
})
|
|
27
|
+
: filePath;
|
|
28
|
+
}
|
|
29
|
+
exports.getFileContentSync = getFileContentSync;
|
|
30
|
+
exports.PathFileUtil = {
|
|
31
|
+
isPath,
|
|
32
|
+
isPathEqual,
|
|
33
|
+
getFileContentSync,
|
|
28
34
|
};
|
|
29
35
|
//# sourceMappingURL=pathFileUtil.js.map
|
package/dist/util/retry.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.retryWith = exports.retryWithAsync = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
4
5
|
const error_1 = require("../error");
|
|
5
|
-
const decorator_1 = require("@midwayjs/decorator");
|
|
6
6
|
/**
|
|
7
7
|
* wrap async function with retry
|
|
8
8
|
* @param retryFn
|
|
@@ -21,7 +21,7 @@ function retryWithAsync(retryFn, retryTimes = 1, options = {}) {
|
|
|
21
21
|
error = err;
|
|
22
22
|
}
|
|
23
23
|
if (options.retryInterval >= 0) {
|
|
24
|
-
await (0,
|
|
24
|
+
await (0, _1.sleep)(options.retryInterval);
|
|
25
25
|
}
|
|
26
26
|
} while (defaultRetry-- > 0);
|
|
27
27
|
if (options.throwOriginError) {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare function isString(value: any): boolean;
|
|
2
|
+
export declare function isClass(fn: any): boolean;
|
|
3
|
+
export declare function isAsyncFunction(value: any): boolean;
|
|
4
|
+
export declare function isGeneratorFunction(value: any): boolean;
|
|
5
|
+
export declare function isPromise(value: any): boolean;
|
|
6
|
+
export declare function isFunction(value: any): boolean;
|
|
7
|
+
export declare function isObject(value: any): boolean;
|
|
8
|
+
export declare function isPlainObject(obj: any): any;
|
|
9
|
+
export declare function isNumber(value: any): boolean;
|
|
10
|
+
export declare function isProxy(value: any): boolean;
|
|
11
|
+
export declare function isMap(value: any): boolean;
|
|
12
|
+
export declare function isSet(value: any): boolean;
|
|
13
|
+
export declare function isRegExp(value: any): boolean;
|
|
14
|
+
export declare function isUndefined(value: any): boolean;
|
|
15
|
+
export declare function isNull(value: any): boolean;
|
|
16
|
+
export declare function isNullOrUndefined(value: any): boolean;
|
|
17
|
+
export declare const Types: {
|
|
18
|
+
isClass: typeof isClass;
|
|
19
|
+
isAsyncFunction: typeof isAsyncFunction;
|
|
20
|
+
isGeneratorFunction: typeof isGeneratorFunction;
|
|
21
|
+
isString: typeof isString;
|
|
22
|
+
isPromise: typeof isPromise;
|
|
23
|
+
isFunction: typeof isFunction;
|
|
24
|
+
isObject: typeof isObject;
|
|
25
|
+
isPlainObject: typeof isPlainObject;
|
|
26
|
+
isNumber: typeof isNumber;
|
|
27
|
+
isProxy: typeof isProxy;
|
|
28
|
+
isMap: typeof isMap;
|
|
29
|
+
isSet: typeof isSet;
|
|
30
|
+
isRegExp: typeof isRegExp;
|
|
31
|
+
isUndefined: typeof isUndefined;
|
|
32
|
+
isNull: typeof isNull;
|
|
33
|
+
isNullOrUndefined: typeof isNullOrUndefined;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Types = exports.isNullOrUndefined = exports.isNull = exports.isUndefined = exports.isRegExp = exports.isSet = exports.isMap = exports.isProxy = exports.isNumber = exports.isPlainObject = exports.isObject = exports.isFunction = exports.isPromise = exports.isGeneratorFunction = exports.isAsyncFunction = exports.isClass = exports.isString = void 0;
|
|
4
|
+
const util = require("util");
|
|
5
|
+
const ToString = Function.prototype.toString;
|
|
6
|
+
const hasOwn = Object.prototype.hasOwnProperty;
|
|
7
|
+
const toStr = Object.prototype.toString;
|
|
8
|
+
function fnBody(fn) {
|
|
9
|
+
return ToString.call(fn)
|
|
10
|
+
.replace(/^[^{]*{\s*/, '')
|
|
11
|
+
.replace(/\s*}[^}]*$/, '');
|
|
12
|
+
}
|
|
13
|
+
function isString(value) {
|
|
14
|
+
return typeof value === 'string';
|
|
15
|
+
}
|
|
16
|
+
exports.isString = isString;
|
|
17
|
+
function isClass(fn) {
|
|
18
|
+
if (typeof fn !== 'function') {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
if (/^class[\s{]/.test(ToString.call(fn))) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
// babel.js classCallCheck() & inlined
|
|
25
|
+
const body = fnBody(fn);
|
|
26
|
+
return (/classCallCheck\(/.test(body) ||
|
|
27
|
+
/TypeError\("Cannot call a class as a function"\)/.test(body));
|
|
28
|
+
}
|
|
29
|
+
exports.isClass = isClass;
|
|
30
|
+
function isAsyncFunction(value) {
|
|
31
|
+
return util.types.isAsyncFunction(value);
|
|
32
|
+
}
|
|
33
|
+
exports.isAsyncFunction = isAsyncFunction;
|
|
34
|
+
function isGeneratorFunction(value) {
|
|
35
|
+
return util.types.isGeneratorFunction(value);
|
|
36
|
+
}
|
|
37
|
+
exports.isGeneratorFunction = isGeneratorFunction;
|
|
38
|
+
function isPromise(value) {
|
|
39
|
+
return util.types.isPromise(value);
|
|
40
|
+
}
|
|
41
|
+
exports.isPromise = isPromise;
|
|
42
|
+
function isFunction(value) {
|
|
43
|
+
return typeof value === 'function';
|
|
44
|
+
}
|
|
45
|
+
exports.isFunction = isFunction;
|
|
46
|
+
function isObject(value) {
|
|
47
|
+
return value !== null && typeof value === 'object';
|
|
48
|
+
}
|
|
49
|
+
exports.isObject = isObject;
|
|
50
|
+
function isPlainObject(obj) {
|
|
51
|
+
if (!obj || toStr.call(obj) !== '[object Object]') {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
const hasOwnConstructor = hasOwn.call(obj, 'constructor');
|
|
55
|
+
const hasIsPrototypeOf = obj.constructor &&
|
|
56
|
+
obj.constructor.prototype &&
|
|
57
|
+
hasOwn.call(obj.constructor.prototype, 'isPrototypeOf');
|
|
58
|
+
// Not own constructor property must be Object
|
|
59
|
+
if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
// Own properties are enumerated firstly, so to speed up,
|
|
63
|
+
// if last one is own, then all properties are own.
|
|
64
|
+
let key;
|
|
65
|
+
for (key in obj) {
|
|
66
|
+
/**/
|
|
67
|
+
}
|
|
68
|
+
return typeof key === 'undefined' || hasOwn.call(obj, key);
|
|
69
|
+
}
|
|
70
|
+
exports.isPlainObject = isPlainObject;
|
|
71
|
+
function isNumber(value) {
|
|
72
|
+
return typeof value === 'number';
|
|
73
|
+
}
|
|
74
|
+
exports.isNumber = isNumber;
|
|
75
|
+
function isProxy(value) {
|
|
76
|
+
return util.types.isProxy(value);
|
|
77
|
+
}
|
|
78
|
+
exports.isProxy = isProxy;
|
|
79
|
+
function isMap(value) {
|
|
80
|
+
return util.types.isMap(value);
|
|
81
|
+
}
|
|
82
|
+
exports.isMap = isMap;
|
|
83
|
+
function isSet(value) {
|
|
84
|
+
return util.types.isSet(value);
|
|
85
|
+
}
|
|
86
|
+
exports.isSet = isSet;
|
|
87
|
+
function isRegExp(value) {
|
|
88
|
+
return util.types.isRegExp(value);
|
|
89
|
+
}
|
|
90
|
+
exports.isRegExp = isRegExp;
|
|
91
|
+
function isUndefined(value) {
|
|
92
|
+
return value === undefined;
|
|
93
|
+
}
|
|
94
|
+
exports.isUndefined = isUndefined;
|
|
95
|
+
function isNull(value) {
|
|
96
|
+
return value === null;
|
|
97
|
+
}
|
|
98
|
+
exports.isNull = isNull;
|
|
99
|
+
function isNullOrUndefined(value) {
|
|
100
|
+
return isUndefined(value) || isNull(value);
|
|
101
|
+
}
|
|
102
|
+
exports.isNullOrUndefined = isNullOrUndefined;
|
|
103
|
+
exports.Types = {
|
|
104
|
+
isClass,
|
|
105
|
+
isAsyncFunction,
|
|
106
|
+
isGeneratorFunction,
|
|
107
|
+
isString,
|
|
108
|
+
isPromise,
|
|
109
|
+
isFunction,
|
|
110
|
+
isObject,
|
|
111
|
+
isPlainObject,
|
|
112
|
+
isNumber,
|
|
113
|
+
isProxy,
|
|
114
|
+
isMap,
|
|
115
|
+
isSet,
|
|
116
|
+
isRegExp,
|
|
117
|
+
isUndefined,
|
|
118
|
+
isNull,
|
|
119
|
+
isNullOrUndefined,
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.randomUUID = void 0;
|
|
4
|
+
const crypto = require("crypto");
|
|
5
|
+
/**
|
|
6
|
+
* code fork from https://github.com/uuidjs/uuid/blob/main/src/stringify.js
|
|
7
|
+
*/
|
|
8
|
+
const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate
|
|
9
|
+
let poolPtr = rnds8Pool.length;
|
|
10
|
+
function rng() {
|
|
11
|
+
if (poolPtr > rnds8Pool.length - 16) {
|
|
12
|
+
crypto.randomFillSync(rnds8Pool);
|
|
13
|
+
poolPtr = 0;
|
|
14
|
+
}
|
|
15
|
+
return rnds8Pool.slice(poolPtr, (poolPtr += 16));
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
19
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
20
|
+
*/
|
|
21
|
+
const byteToHex = [];
|
|
22
|
+
for (let i = 0; i < 256; ++i) {
|
|
23
|
+
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
24
|
+
}
|
|
25
|
+
function unsafeStringify(arr, offset = 0) {
|
|
26
|
+
// Note: Be careful editing this code! It's been tuned for performance
|
|
27
|
+
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
28
|
+
return (byteToHex[arr[offset + 0]] +
|
|
29
|
+
byteToHex[arr[offset + 1]] +
|
|
30
|
+
byteToHex[arr[offset + 2]] +
|
|
31
|
+
byteToHex[arr[offset + 3]] +
|
|
32
|
+
'-' +
|
|
33
|
+
byteToHex[arr[offset + 4]] +
|
|
34
|
+
byteToHex[arr[offset + 5]] +
|
|
35
|
+
'-' +
|
|
36
|
+
byteToHex[arr[offset + 6]] +
|
|
37
|
+
byteToHex[arr[offset + 7]] +
|
|
38
|
+
'-' +
|
|
39
|
+
byteToHex[arr[offset + 8]] +
|
|
40
|
+
byteToHex[arr[offset + 9]] +
|
|
41
|
+
'-' +
|
|
42
|
+
byteToHex[arr[offset + 10]] +
|
|
43
|
+
byteToHex[arr[offset + 11]] +
|
|
44
|
+
byteToHex[arr[offset + 12]] +
|
|
45
|
+
byteToHex[arr[offset + 13]] +
|
|
46
|
+
byteToHex[arr[offset + 14]] +
|
|
47
|
+
byteToHex[arr[offset + 15]]).toLowerCase();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* a easy uuid v4 generator
|
|
51
|
+
*/
|
|
52
|
+
function randomUUID(force) {
|
|
53
|
+
// node > v14.17
|
|
54
|
+
if (!force && crypto['randomUUID']) {
|
|
55
|
+
return crypto['randomUUID']();
|
|
56
|
+
}
|
|
57
|
+
const rnds = rng();
|
|
58
|
+
// Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
59
|
+
rnds[6] = (rnds[6] & 0x0f) | 0x40;
|
|
60
|
+
rnds[8] = (rnds[8] & 0x3f) | 0x80;
|
|
61
|
+
return unsafeStringify(rnds);
|
|
62
|
+
}
|
|
63
|
+
exports.randomUUID = randomUUID;
|
|
64
|
+
//# sourceMappingURL=uuid.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extractExpressLikeValue = exports.extractKoaLikeValue = void 0;
|
|
4
|
-
const decorator_1 = require("@midwayjs/decorator");
|
|
5
4
|
const index_1 = require("./index");
|
|
5
|
+
const decorator_1 = require("../decorator");
|
|
6
6
|
const extractKoaLikeValue = (key, data, paramType) => {
|
|
7
7
|
if (decorator_1.ALL === data) {
|
|
8
8
|
data = undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "midway core",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"build": "tsc",
|
|
9
9
|
"test": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand",
|
|
10
10
|
"cov": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand --coverage --forceExit",
|
|
11
|
-
"link": "npm link"
|
|
11
|
+
"link": "npm link",
|
|
12
|
+
"madge": "madge --circular --extensions ts,tsx --exclude 'node_modules|test|dist' src"
|
|
12
13
|
},
|
|
13
14
|
"keywords": [
|
|
14
15
|
"midway",
|
|
@@ -21,22 +22,18 @@
|
|
|
21
22
|
],
|
|
22
23
|
"license": "MIT",
|
|
23
24
|
"devDependencies": {
|
|
24
|
-
"@midwayjs/decorator": "^3.4.11",
|
|
25
25
|
"koa": "2.13.4",
|
|
26
|
-
"midway-test-component": "*",
|
|
27
26
|
"mm": "3.2.0",
|
|
28
27
|
"pg": "8.8.0",
|
|
29
28
|
"raw-body": "2.5.1",
|
|
30
|
-
"sinon": "14.0.
|
|
31
|
-
},
|
|
32
|
-
"peerDependencies": {
|
|
33
|
-
"@midwayjs/decorator": "*"
|
|
29
|
+
"sinon": "14.0.1"
|
|
34
30
|
},
|
|
35
31
|
"dependencies": {
|
|
36
32
|
"@midwayjs/glob": "^1.0.2",
|
|
37
33
|
"@midwayjs/logger": "^2.15.0",
|
|
38
|
-
"class-transformer": "
|
|
39
|
-
"picomatch": "2.3.1"
|
|
34
|
+
"class-transformer": "0.5.1",
|
|
35
|
+
"picomatch": "2.3.1",
|
|
36
|
+
"reflect-metadata": "0.1.13"
|
|
40
37
|
},
|
|
41
38
|
"author": "Harry Chen <czy88840616@gmail.com>",
|
|
42
39
|
"repository": {
|
|
@@ -46,5 +43,5 @@
|
|
|
46
43
|
"engines": {
|
|
47
44
|
"node": ">=12"
|
|
48
45
|
},
|
|
49
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "22643b0e8519766bb7c68b975930199fc136336e"
|
|
50
47
|
}
|