@midwayjs/decorator 3.4.11 → 3.7.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 (79) hide show
  1. package/dist/index.d.ts +3 -7
  2. package/dist/index.js +14 -12
  3. package/package.json +3 -3
  4. package/dist/constant.d.ts +0 -54
  5. package/dist/constant.js +0 -85
  6. package/dist/decorator/common/aspect.d.ts +0 -20
  7. package/dist/decorator/common/aspect.js +0 -22
  8. package/dist/decorator/common/autoload.d.ts +0 -2
  9. package/dist/decorator/common/autoload.js +0 -13
  10. package/dist/decorator/common/configuration.d.ts +0 -24
  11. package/dist/decorator/common/configuration.js +0 -11
  12. package/dist/decorator/common/filter.d.ts +0 -6
  13. package/dist/decorator/common/filter.js +0 -31
  14. package/dist/decorator/common/framework.d.ts +0 -2
  15. package/dist/decorator/common/framework.js +0 -13
  16. package/dist/decorator/common/index.d.ts +0 -11
  17. package/dist/decorator/common/index.js +0 -27
  18. package/dist/decorator/common/inject.d.ts +0 -3
  19. package/dist/decorator/common/inject.js +0 -11
  20. package/dist/decorator/common/middleware.d.ts +0 -2
  21. package/dist/decorator/common/middleware.js +0 -12
  22. package/dist/decorator/common/objectDef.d.ts +0 -7
  23. package/dist/decorator/common/objectDef.js +0 -25
  24. package/dist/decorator/common/pipeline.d.ts +0 -3
  25. package/dist/decorator/common/pipeline.js +0 -11
  26. package/dist/decorator/common/provide.d.ts +0 -3
  27. package/dist/decorator/common/provide.js +0 -11
  28. package/dist/decorator/faas/serverlessTrigger.d.ts +0 -13
  29. package/dist/decorator/faas/serverlessTrigger.js +0 -29
  30. package/dist/decorator/framework/index.d.ts +0 -7
  31. package/dist/decorator/framework/index.js +0 -33
  32. package/dist/decorator/framework/schedule.d.ts +0 -21
  33. package/dist/decorator/framework/schedule.js +0 -15
  34. package/dist/decorator/index.d.ts +0 -19
  35. package/dist/decorator/index.js +0 -43
  36. package/dist/decorator/microservice/consumer.d.ts +0 -5
  37. package/dist/decorator/microservice/consumer.js +0 -18
  38. package/dist/decorator/microservice/kafkaListener.d.ts +0 -24
  39. package/dist/decorator/microservice/kafkaListener.js +0 -13
  40. package/dist/decorator/microservice/provider.d.ts +0 -16
  41. package/dist/decorator/microservice/provider.js +0 -48
  42. package/dist/decorator/microservice/rabbitmqListener.d.ts +0 -50
  43. package/dist/decorator/microservice/rabbitmqListener.js +0 -13
  44. package/dist/decorator/rpc/hsf.d.ts +0 -12
  45. package/dist/decorator/rpc/hsf.js +0 -19
  46. package/dist/decorator/task/queue.d.ts +0 -2
  47. package/dist/decorator/task/queue.js +0 -17
  48. package/dist/decorator/task/task.d.ts +0 -2
  49. package/dist/decorator/task/task.js +0 -18
  50. package/dist/decorator/task/taskLocal.d.ts +0 -2
  51. package/dist/decorator/task/taskLocal.js +0 -17
  52. package/dist/decorator/web/controller.d.ts +0 -20
  53. package/dist/decorator/web/controller.js +0 -19
  54. package/dist/decorator/web/paramMapping.d.ts +0 -31
  55. package/dist/decorator/web/paramMapping.js +0 -50
  56. package/dist/decorator/web/requestMapping.d.ts +0 -129
  57. package/dist/decorator/web/requestMapping.js +0 -83
  58. package/dist/decorator/web/response.d.ts +0 -9
  59. package/dist/decorator/web/response.js +0 -65
  60. package/dist/decorator/ws/webSocketController.d.ts +0 -10
  61. package/dist/decorator/ws/webSocketController.js +0 -21
  62. package/dist/decorator/ws/webSocketEvent.d.ts +0 -60
  63. package/dist/decorator/ws/webSocketEvent.js +0 -87
  64. package/dist/decoratorManager.d.ts +0 -301
  65. package/dist/decoratorManager.js +0 -708
  66. package/dist/interface.d.ts +0 -238
  67. package/dist/interface.js +0 -67
  68. package/dist/util/camelCase.d.ts +0 -3
  69. package/dist/util/camelCase.js +0 -88
  70. package/dist/util/flatted.d.ts +0 -7
  71. package/dist/util/flatted.js +0 -91
  72. package/dist/util/format.d.ts +0 -25
  73. package/dist/util/format.js +0 -38
  74. package/dist/util/fs.d.ts +0 -5
  75. package/dist/util/fs.js +0 -15
  76. package/dist/util/index.d.ts +0 -62
  77. package/dist/util/index.js +0 -200
  78. package/dist/util/uuid.d.ts +0 -5
  79. package/dist/util/uuid.js +0 -64
@@ -1,200 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Utils = exports.Types = exports.toAsyncFunction = exports.merge = exports.generateRandomId = exports.getParamNames = exports.sleep = 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 crypto = require("crypto");
6
- const camelCase_1 = require("./camelCase");
7
- const uuid_1 = require("./uuid");
8
- const flatted_1 = require("./flatted");
9
- const ToString = Function.prototype.toString;
10
- const hasOwn = Object.prototype.hasOwnProperty;
11
- const toStr = Object.prototype.toString;
12
- function fnBody(fn) {
13
- return ToString.call(fn)
14
- .replace(/^[^{]*{\s*/, '')
15
- .replace(/\s*}[^}]*$/, '');
16
- }
17
- function isString(value) {
18
- return typeof value === 'string';
19
- }
20
- exports.isString = isString;
21
- function isClass(fn) {
22
- if (typeof fn !== 'function') {
23
- return false;
24
- }
25
- if (/^class[\s{]/.test(ToString.call(fn))) {
26
- return true;
27
- }
28
- // babel.js classCallCheck() & inlined
29
- const body = fnBody(fn);
30
- return (/classCallCheck\(/.test(body) ||
31
- /TypeError\("Cannot call a class as a function"\)/.test(body));
32
- }
33
- exports.isClass = isClass;
34
- function isAsyncFunction(value) {
35
- return util.types.isAsyncFunction(value);
36
- }
37
- exports.isAsyncFunction = isAsyncFunction;
38
- function isGeneratorFunction(value) {
39
- return util.types.isGeneratorFunction(value);
40
- }
41
- exports.isGeneratorFunction = isGeneratorFunction;
42
- function isPromise(value) {
43
- return util.types.isPromise(value);
44
- }
45
- exports.isPromise = isPromise;
46
- function isFunction(value) {
47
- return typeof value === 'function';
48
- }
49
- exports.isFunction = isFunction;
50
- function isObject(value) {
51
- return value !== null && typeof value === 'object';
52
- }
53
- exports.isObject = isObject;
54
- function isPlainObject(obj) {
55
- if (!obj || toStr.call(obj) !== '[object Object]') {
56
- return false;
57
- }
58
- const hasOwnConstructor = hasOwn.call(obj, 'constructor');
59
- const hasIsPrototypeOf = obj.constructor &&
60
- obj.constructor.prototype &&
61
- hasOwn.call(obj.constructor.prototype, 'isPrototypeOf');
62
- // Not own constructor property must be Object
63
- if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
64
- return false;
65
- }
66
- // Own properties are enumerated firstly, so to speed up,
67
- // if last one is own, then all properties are own.
68
- let key;
69
- for (key in obj) {
70
- /**/
71
- }
72
- return typeof key === 'undefined' || hasOwn.call(obj, key);
73
- }
74
- exports.isPlainObject = isPlainObject;
75
- function isNumber(value) {
76
- return typeof value === 'number';
77
- }
78
- exports.isNumber = isNumber;
79
- function isProxy(value) {
80
- return util.types.isProxy(value);
81
- }
82
- exports.isProxy = isProxy;
83
- function isMap(value) {
84
- return util.types.isMap(value);
85
- }
86
- exports.isMap = isMap;
87
- function isSet(value) {
88
- return util.types.isSet(value);
89
- }
90
- exports.isSet = isSet;
91
- function isRegExp(value) {
92
- return util.types.isRegExp(value);
93
- }
94
- exports.isRegExp = isRegExp;
95
- function isUndefined(value) {
96
- return value === undefined;
97
- }
98
- exports.isUndefined = isUndefined;
99
- function isNull(value) {
100
- return value === null;
101
- }
102
- exports.isNull = isNull;
103
- function isNullOrUndefined(value) {
104
- return isUndefined(value) || isNull(value);
105
- }
106
- exports.isNullOrUndefined = isNullOrUndefined;
107
- function sleep(sleepTime = 1000) {
108
- return new Promise(resolve => {
109
- setTimeout(() => {
110
- resolve();
111
- }, sleepTime);
112
- });
113
- }
114
- exports.sleep = sleep;
115
- const STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;
116
- /**
117
- * get parameter name from function
118
- * @param func
119
- */
120
- function getParamNames(func) {
121
- const fnStr = func.toString().replace(STRIP_COMMENTS, '');
122
- let result = fnStr
123
- .slice(fnStr.indexOf('(') + 1, fnStr.indexOf(')'))
124
- .split(',')
125
- .map(content => {
126
- return content.trim().replace(/\s?=.*$/, '');
127
- });
128
- if (result.length === 1 && result[0] === '') {
129
- result = [];
130
- }
131
- return result;
132
- }
133
- exports.getParamNames = getParamNames;
134
- /**
135
- * generate a lightweight 32 bit random id, enough for ioc container
136
- */
137
- function generateRandomId() {
138
- // => f9b327e70bbcf42494ccb28b2d98e00e
139
- return crypto.randomBytes(16).toString('hex');
140
- }
141
- exports.generateRandomId = generateRandomId;
142
- function merge(target, src) {
143
- if (!target) {
144
- target = src;
145
- src = null;
146
- }
147
- if (!target) {
148
- return null;
149
- }
150
- if (Array.isArray(target)) {
151
- return target.concat(src || []);
152
- }
153
- if (typeof target === 'object') {
154
- return Object.assign({}, target, src);
155
- }
156
- throw new Error('can not merge meta that type of ' + typeof target);
157
- }
158
- exports.merge = merge;
159
- function toAsyncFunction(method) {
160
- if (isAsyncFunction(method)) {
161
- return method;
162
- }
163
- else {
164
- return async function (...args) {
165
- return Promise.resolve(method.call(this, ...args));
166
- };
167
- }
168
- }
169
- exports.toAsyncFunction = toAsyncFunction;
170
- exports.Types = {
171
- isClass,
172
- isAsyncFunction,
173
- isGeneratorFunction,
174
- isString,
175
- isPromise,
176
- isFunction,
177
- isObject,
178
- isPlainObject,
179
- isNumber,
180
- isProxy,
181
- isMap,
182
- isSet,
183
- isRegExp,
184
- isUndefined,
185
- isNull,
186
- isNullOrUndefined,
187
- };
188
- exports.Utils = {
189
- sleep,
190
- getParamNames,
191
- generateRandomId,
192
- merge,
193
- camelCase: camelCase_1.camelCase,
194
- pascalCase: camelCase_1.pascalCase,
195
- randomUUID: uuid_1.randomUUID,
196
- toAsyncFunction,
197
- safeStringify: flatted_1.safeStringify,
198
- safeParse: flatted_1.safeParse,
199
- };
200
- //# sourceMappingURL=index.js.map
@@ -1,5 +0,0 @@
1
- /**
2
- * a easy uuid v4 generator
3
- */
4
- export declare function randomUUID(): string;
5
- //# sourceMappingURL=uuid.d.ts.map
package/dist/util/uuid.js DELETED
@@ -1,64 +0,0 @@
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() {
53
- // node > v14.17
54
- if (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