@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.
Files changed (145) hide show
  1. package/LICENSE +21 -0
  2. package/dist/baseFramework.d.ts +7 -2
  3. package/dist/baseFramework.js +27 -9
  4. package/dist/common/applicationManager.d.ts +1 -1
  5. package/dist/common/applicationManager.js +1 -1
  6. package/dist/common/dataListener.js +1 -1
  7. package/dist/common/dataSourceManager.js +7 -7
  8. package/dist/common/fileDetector.js +6 -5
  9. package/dist/common/filterManager.js +1 -1
  10. package/dist/common/guardManager.d.ts +6 -0
  11. package/dist/common/guardManager.js +49 -0
  12. package/dist/common/middlewareManager.d.ts +2 -2
  13. package/dist/common/webGenerator.d.ts +2 -1
  14. package/dist/common/webGenerator.js +12 -3
  15. package/dist/config/config.default.d.ts +2 -11
  16. package/dist/config/config.default.js +2 -2
  17. package/dist/{common/constants.d.ts → constants.d.ts} +10 -1
  18. package/dist/{common/constants.js → constants.js} +18 -2
  19. package/dist/context/container.d.ts +1 -1
  20. package/dist/context/container.js +16 -14
  21. package/dist/context/definitionRegistry.d.ts +1 -1
  22. package/dist/context/definitionRegistry.js +1 -1
  23. package/dist/context/managedResolverFactory.d.ts +1 -4
  24. package/dist/context/managedResolverFactory.js +6 -6
  25. package/dist/context/providerWrapper.d.ts +1 -1
  26. package/dist/context/providerWrapper.js +1 -1
  27. package/dist/context/requestContainer.js +3 -3
  28. package/dist/decorator/common/aspect.d.ts +20 -0
  29. package/dist/decorator/common/aspect.js +22 -0
  30. package/dist/decorator/common/autoload.d.ts +2 -0
  31. package/dist/decorator/common/autoload.js +13 -0
  32. package/dist/decorator/common/configuration.d.ts +24 -0
  33. package/dist/decorator/common/configuration.js +11 -0
  34. package/dist/decorator/common/filter.d.ts +6 -0
  35. package/dist/decorator/common/filter.js +31 -0
  36. package/dist/decorator/common/framework.d.ts +8 -0
  37. package/dist/decorator/common/framework.js +41 -0
  38. package/dist/decorator/common/guard.d.ts +4 -0
  39. package/dist/decorator/common/guard.js +30 -0
  40. package/dist/decorator/common/inject.d.ts +3 -0
  41. package/dist/decorator/common/inject.js +11 -0
  42. package/dist/decorator/common/middleware.d.ts +2 -0
  43. package/dist/decorator/common/middleware.js +12 -0
  44. package/dist/decorator/common/objectDef.d.ts +7 -0
  45. package/dist/decorator/common/objectDef.js +25 -0
  46. package/dist/decorator/common/pipeline.d.ts +3 -0
  47. package/dist/decorator/common/pipeline.js +12 -0
  48. package/dist/decorator/common/provide.d.ts +3 -0
  49. package/dist/decorator/common/provide.js +11 -0
  50. package/dist/decorator/constant.d.ts +55 -0
  51. package/dist/decorator/constant.js +86 -0
  52. package/dist/decorator/decoratorManager.d.ts +301 -0
  53. package/dist/decorator/decoratorManager.js +709 -0
  54. package/dist/decorator/faas/serverlessTrigger.d.ts +13 -0
  55. package/dist/decorator/faas/serverlessTrigger.js +29 -0
  56. package/dist/decorator/index.d.ts +31 -0
  57. package/dist/decorator/index.js +55 -0
  58. package/dist/decorator/interface.d.ts +238 -0
  59. package/dist/decorator/interface.js +67 -0
  60. package/dist/decorator/microservice/consumer.d.ts +5 -0
  61. package/dist/decorator/microservice/consumer.js +17 -0
  62. package/dist/decorator/microservice/kafkaListener.d.ts +24 -0
  63. package/dist/decorator/microservice/kafkaListener.js +13 -0
  64. package/dist/decorator/microservice/provider.d.ts +16 -0
  65. package/dist/decorator/microservice/provider.js +47 -0
  66. package/dist/decorator/microservice/rabbitmqListener.d.ts +50 -0
  67. package/dist/decorator/microservice/rabbitmqListener.js +13 -0
  68. package/dist/decorator/rpc/hsf.d.ts +12 -0
  69. package/dist/decorator/rpc/hsf.js +18 -0
  70. package/dist/decorator/task/queue.d.ts +2 -0
  71. package/dist/decorator/task/queue.js +17 -0
  72. package/dist/decorator/task/schedule.d.ts +21 -0
  73. package/dist/decorator/task/schedule.js +14 -0
  74. package/dist/decorator/task/task.d.ts +2 -0
  75. package/dist/decorator/task/task.js +18 -0
  76. package/dist/decorator/task/taskLocal.d.ts +2 -0
  77. package/dist/decorator/task/taskLocal.js +17 -0
  78. package/dist/decorator/web/controller.d.ts +20 -0
  79. package/dist/decorator/web/controller.js +18 -0
  80. package/dist/decorator/web/paramMapping.d.ts +31 -0
  81. package/dist/decorator/web/paramMapping.js +50 -0
  82. package/dist/decorator/web/requestMapping.d.ts +132 -0
  83. package/dist/decorator/web/requestMapping.js +83 -0
  84. package/dist/decorator/web/response.d.ts +9 -0
  85. package/dist/decorator/web/response.js +65 -0
  86. package/dist/decorator/ws/webSocketController.d.ts +10 -0
  87. package/dist/decorator/ws/webSocketController.js +20 -0
  88. package/dist/decorator/ws/webSocketEvent.d.ts +60 -0
  89. package/dist/decorator/ws/webSocketEvent.js +87 -0
  90. package/dist/definitions/functionDefinition.d.ts +1 -1
  91. package/dist/definitions/functionDefinition.js +1 -1
  92. package/dist/definitions/objectCreator.d.ts +1 -1
  93. package/dist/definitions/objectCreator.js +7 -7
  94. package/dist/definitions/objectDefinition.d.ts +1 -1
  95. package/dist/definitions/objectDefinition.js +1 -1
  96. package/dist/definitions/properties.d.ts +1 -1
  97. package/dist/error/framework.d.ts +5 -1
  98. package/dist/error/framework.js +9 -2
  99. package/dist/functional/configuration.d.ts +1 -1
  100. package/dist/index.d.ts +18 -15
  101. package/dist/index.js +40 -27
  102. package/dist/interface.d.ts +52 -18
  103. package/dist/interface.js +1 -17
  104. package/dist/service/aspectService.d.ts +1 -1
  105. package/dist/service/aspectService.js +3 -2
  106. package/dist/service/configService.js +3 -2
  107. package/dist/service/decoratorService.js +1 -1
  108. package/dist/service/environmentService.js +1 -1
  109. package/dist/service/frameworkService.d.ts +1 -1
  110. package/dist/service/frameworkService.js +3 -3
  111. package/dist/service/informationService.js +1 -1
  112. package/dist/service/lifeCycleService.js +1 -1
  113. package/dist/service/loggerService.js +1 -1
  114. package/dist/service/middlewareService.js +3 -2
  115. package/dist/service/mockService.js +1 -1
  116. package/dist/service/pipelineService.d.ts +1 -1
  117. package/dist/service/pipelineService.js +1 -1
  118. package/dist/service/slsFunctionService.d.ts +1 -1
  119. package/dist/service/slsFunctionService.js +1 -1
  120. package/dist/service/webRouterService.d.ts +9 -1
  121. package/dist/service/webRouterService.js +6 -3
  122. package/dist/setup.d.ts +3 -3
  123. package/dist/setup.js +1 -1
  124. package/dist/util/camelCase.d.ts +3 -0
  125. package/dist/util/camelCase.js +88 -0
  126. package/dist/util/contextUtil.js +2 -2
  127. package/dist/util/extend.js +3 -3
  128. package/dist/util/flatted.d.ts +7 -0
  129. package/dist/util/flatted.js +91 -0
  130. package/dist/util/format.d.ts +25 -0
  131. package/dist/util/format.js +38 -0
  132. package/dist/util/fs.d.ts +5 -0
  133. package/dist/util/fs.js +15 -0
  134. package/dist/util/httpclient.d.ts +1 -0
  135. package/dist/util/index.d.ts +26 -0
  136. package/dist/util/index.js +80 -1
  137. package/dist/util/pathFileUtil.d.ts +6 -3
  138. package/dist/util/pathFileUtil.js +28 -22
  139. package/dist/util/retry.js +2 -2
  140. package/dist/util/types.d.ts +35 -0
  141. package/dist/util/types.js +121 -0
  142. package/dist/util/uuid.d.ts +5 -0
  143. package/dist/util/uuid.js +64 -0
  144. package/dist/util/webRouterParam.js +1 -1
  145. package/package.json +8 -11
@@ -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(p: any): boolean;
4
- isPathEqual(one: string, two: string): boolean;
5
- getFileContentSync(filePath: any, encoding?: BufferEncoding): any;
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
- exports.PathFileUtil = {
7
- isPath(p) {
8
- // eslint-disable-next-line no-useless-escape
9
- if (/(^[\.\/])|:|\\/.test(p)) {
10
- return true;
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
- isPathEqual(one, two) {
15
- if (!one || !two) {
16
- return false;
17
- }
18
- const ext = (0, path_1.extname)(one);
19
- return one.replace(ext, '') === two;
20
- },
21
- getFileContentSync(filePath, encoding) {
22
- return typeof filePath === 'string'
23
- ? (0, fs_1.readFileSync)(filePath, {
24
- encoding,
25
- })
26
- : filePath;
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
@@ -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, decorator_1.sleep)(options.retryInterval);
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,5 @@
1
+ /**
2
+ * a easy uuid v4 generator
3
+ */
4
+ export declare function randomUUID(force?: boolean): string;
5
+ //# sourceMappingURL=uuid.d.ts.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.5.4-beta.2",
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.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": "^0.5.1",
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": "a603d2348d6141f8f723901498f03a162a037708"
46
+ "gitHead": "22643b0e8519766bb7c68b975930199fc136336e"
50
47
  }