@midwayjs/core 3.0.0-alpha.9 → 3.0.0-beta.4

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 (109) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/baseFramework.d.ts +55 -22
  3. package/dist/baseFramework.js +151 -232
  4. package/dist/{util → common}/fileDetector.d.ts +0 -0
  5. package/dist/{util → common}/fileDetector.js +16 -10
  6. package/dist/common/filterManager.d.ts +19 -0
  7. package/dist/common/filterManager.js +85 -0
  8. package/dist/common/middlewareManager.d.ts +11 -0
  9. package/dist/common/middlewareManager.js +48 -0
  10. package/dist/common/serviceFactory.d.ts +15 -0
  11. package/dist/{util → common}/serviceFactory.js +16 -6
  12. package/dist/{util → common}/triggerCollector.d.ts +0 -0
  13. package/dist/{util → common}/triggerCollector.js +0 -0
  14. package/dist/common/webGenerator.d.ts +27 -0
  15. package/dist/common/webGenerator.js +125 -0
  16. package/dist/{util → common}/webRouterCollector.d.ts +21 -2
  17. package/dist/{util → common}/webRouterCollector.js +115 -138
  18. package/dist/config/config.default.d.ts +7 -0
  19. package/dist/config/config.default.js +28 -0
  20. package/dist/context/container.d.ts +73 -43
  21. package/dist/context/container.js +277 -270
  22. package/dist/context/definitionRegistry.d.ts +26 -0
  23. package/dist/context/definitionRegistry.js +124 -0
  24. package/dist/context/managedResolverFactory.d.ts +15 -32
  25. package/dist/context/managedResolverFactory.js +88 -317
  26. package/dist/context/providerWrapper.d.ts +2 -3
  27. package/dist/context/requestContainer.d.ts +0 -2
  28. package/dist/context/requestContainer.js +9 -26
  29. package/dist/definitions/functionDefinition.d.ts +3 -4
  30. package/dist/definitions/functionDefinition.js +0 -6
  31. package/dist/definitions/objectCreator.js +6 -6
  32. package/dist/definitions/objectDefinition.d.ts +4 -6
  33. package/dist/definitions/objectDefinition.js +0 -8
  34. package/dist/definitions/properties.d.ts +2 -15
  35. package/dist/definitions/properties.js +3 -72
  36. package/dist/error/base.d.ts +13 -0
  37. package/dist/error/base.js +19 -0
  38. package/dist/error/code.d.ts +59 -0
  39. package/dist/error/code.js +64 -0
  40. package/dist/error/framework.d.ts +21 -0
  41. package/dist/error/framework.js +52 -0
  42. package/dist/error/http.d.ts +58 -0
  43. package/dist/error/http.js +82 -0
  44. package/dist/error/index.d.ts +4 -0
  45. package/dist/error/index.js +16 -0
  46. package/dist/functional/configuration.d.ts +4 -2
  47. package/dist/functional/configuration.js +12 -2
  48. package/dist/index.d.ts +23 -10
  49. package/dist/index.js +33 -33
  50. package/dist/interface.d.ts +263 -184
  51. package/dist/interface.js +9 -1
  52. package/dist/service/aspectService.d.ts +11 -14
  53. package/dist/service/aspectService.js +116 -172
  54. package/dist/service/configService.d.ts +10 -8
  55. package/dist/service/configService.js +61 -38
  56. package/dist/service/decoratorService.d.ts +23 -0
  57. package/dist/service/decoratorService.js +149 -0
  58. package/dist/service/environmentService.js +15 -4
  59. package/dist/service/frameworkService.d.ts +25 -0
  60. package/dist/service/frameworkService.js +171 -0
  61. package/dist/service/informationService.d.ts +4 -7
  62. package/dist/service/informationService.js +41 -10
  63. package/dist/service/lifeCycleService.d.ts +14 -0
  64. package/dist/service/lifeCycleService.js +130 -0
  65. package/dist/service/loggerService.d.ts +27 -0
  66. package/dist/service/loggerService.js +132 -0
  67. package/dist/service/middlewareService.d.ts +11 -0
  68. package/dist/service/middlewareService.js +119 -0
  69. package/dist/{features/pipeline.d.ts → service/pipelineService.d.ts} +56 -46
  70. package/dist/{features/pipeline.js → service/pipelineService.js} +54 -19
  71. package/dist/setup.d.ts +4 -0
  72. package/dist/setup.js +113 -0
  73. package/dist/util/contextUtil.d.ts +1 -1
  74. package/dist/util/contextUtil.js +2 -2
  75. package/dist/util/index.d.ts +55 -0
  76. package/dist/util/index.js +137 -7
  77. package/dist/util/pathFileUtil.js +2 -2
  78. package/dist/util/pathToRegexp.d.ts +17 -0
  79. package/dist/util/pathToRegexp.js +280 -0
  80. package/dist/util/webRouterParam.d.ts +2 -2
  81. package/dist/util/webRouterParam.js +19 -20
  82. package/package.json +8 -13
  83. package/dist/common/lodashWrap.d.ts +0 -9
  84. package/dist/common/lodashWrap.js +0 -18
  85. package/dist/common/notFoundError.d.ts +0 -8
  86. package/dist/common/notFoundError.js +0 -20
  87. package/dist/common/reflectTool.d.ts +0 -15
  88. package/dist/common/reflectTool.js +0 -83
  89. package/dist/context/applicationContext.d.ts +0 -81
  90. package/dist/context/applicationContext.js +0 -263
  91. package/dist/context/managed.d.ts +0 -45
  92. package/dist/context/managed.js +0 -69
  93. package/dist/context/resolverHandler.d.ts +0 -34
  94. package/dist/context/resolverHandler.js +0 -88
  95. package/dist/definitions/messageSource.d.ts +0 -13
  96. package/dist/definitions/messageSource.js +0 -74
  97. package/dist/definitions/resource.d.ts +0 -27
  98. package/dist/definitions/resource.js +0 -116
  99. package/dist/features/index.d.ts +0 -2
  100. package/dist/features/index.js +0 -3
  101. package/dist/logger.d.ts +0 -4
  102. package/dist/logger.js +0 -20
  103. package/dist/util/containerUtil.d.ts +0 -11
  104. package/dist/util/containerUtil.js +0 -26
  105. package/dist/util/emptyFramework.d.ts +0 -62
  106. package/dist/util/emptyFramework.js +0 -72
  107. package/dist/util/serviceFactory.d.ts +0 -13
  108. package/dist/util/staticConfig.d.ts +0 -10
  109. package/dist/util/staticConfig.js +0 -67
@@ -0,0 +1,280 @@
1
+ "use strict";
2
+ /**
3
+ * this file fork from path-to-regexp package v1.8.0
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.pathToRegexp = void 0;
7
+ /**
8
+ * The main path matching regexp utility.
9
+ *
10
+ * @type {RegExp}
11
+ */
12
+ const PATH_REGEXP = new RegExp([
13
+ // Match escaped characters that would otherwise appear in future matches.
14
+ // This allows the user to escape special characters that won't transform.
15
+ '(\\\\.)',
16
+ // Match Express-style parameters and un-named parameters with a prefix
17
+ // and optional suffixes. Matches appear as:
18
+ //
19
+ // "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?", undefined]
20
+ // "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined, undefined]
21
+ // "/*" => ["/", undefined, undefined, undefined, undefined, "*"]
22
+ '([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))',
23
+ ].join('|'), 'g');
24
+ /**
25
+ * Parse a string for the raw tokens.
26
+ *
27
+ * @param {string} str
28
+ * @param {Object=} options
29
+ * @return {!Array}
30
+ */
31
+ function parse(str, options) {
32
+ const tokens = [];
33
+ let key = 0;
34
+ let index = 0;
35
+ let path = '';
36
+ const defaultDelimiter = (options && options.delimiter) || '/';
37
+ let res;
38
+ while ((res = PATH_REGEXP.exec(str)) != null) {
39
+ const m = res[0];
40
+ const escaped = res[1];
41
+ const offset = res.index;
42
+ path += str.slice(index, offset);
43
+ index = offset + m.length;
44
+ // Ignore already escaped sequences.
45
+ if (escaped) {
46
+ path += escaped[1];
47
+ continue;
48
+ }
49
+ const next = str[index];
50
+ const prefix = res[2];
51
+ const name = res[3];
52
+ const capture = res[4];
53
+ const group = res[5];
54
+ const modifier = res[6];
55
+ const asterisk = res[7];
56
+ // Push the current path onto the tokens.
57
+ if (path) {
58
+ tokens.push(path);
59
+ path = '';
60
+ }
61
+ const partial = prefix != null && next != null && next !== prefix;
62
+ const repeat = modifier === '+' || modifier === '*';
63
+ const optional = modifier === '?' || modifier === '*';
64
+ const delimiter = res[2] || defaultDelimiter;
65
+ const pattern = capture || group;
66
+ tokens.push({
67
+ name: name || key++,
68
+ prefix: prefix || '',
69
+ delimiter: delimiter,
70
+ optional: optional,
71
+ repeat: repeat,
72
+ partial: partial,
73
+ asterisk: !!asterisk,
74
+ pattern: pattern
75
+ ? escapeGroup(pattern)
76
+ : asterisk
77
+ ? '.*'
78
+ : '[^' + escapeString(delimiter) + ']+?',
79
+ });
80
+ }
81
+ // Match any characters still remaining.
82
+ if (index < str.length) {
83
+ path += str.substr(index);
84
+ }
85
+ // If the path exists, push it onto the end.
86
+ if (path) {
87
+ tokens.push(path);
88
+ }
89
+ return tokens;
90
+ }
91
+ /**
92
+ * Escape a regular expression string.
93
+ *
94
+ * @param {string} str
95
+ * @return {string}
96
+ */
97
+ function escapeString(str) {
98
+ return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, '\\$1');
99
+ }
100
+ /**
101
+ * Escape the capturing group by escaping special characters and meaning.
102
+ *
103
+ * @param {string} group
104
+ * @return {string}
105
+ */
106
+ function escapeGroup(group) {
107
+ return group.replace(/([=!:$/()])/g, '\\$1');
108
+ }
109
+ /**
110
+ * Attach the keys as a property of the regexp.
111
+ *
112
+ * @param {!RegExp} re
113
+ * @param {Array} keys
114
+ * @return {!RegExp}
115
+ */
116
+ function attachKeys(re, keys) {
117
+ re.keys = keys;
118
+ return re;
119
+ }
120
+ /**
121
+ * Get the flags for a regexp from the options.
122
+ *
123
+ * @param {Object} options
124
+ * @return {string}
125
+ */
126
+ function flags(options) {
127
+ return options && options.sensitive ? '' : 'i';
128
+ }
129
+ /**
130
+ * Pull out keys from a regexp.
131
+ *
132
+ * @param {!RegExp} path
133
+ * @param {!Array} keys
134
+ * @return {!RegExp}
135
+ */
136
+ function regexpToRegexp(path, keys) {
137
+ // Use a negative lookahead to match only capturing groups.
138
+ const groups = path.source.match(/\((?!\?)/g);
139
+ if (groups) {
140
+ for (let i = 0; i < groups.length; i++) {
141
+ keys.push({
142
+ name: i,
143
+ prefix: null,
144
+ delimiter: null,
145
+ optional: false,
146
+ repeat: false,
147
+ partial: false,
148
+ asterisk: false,
149
+ pattern: null,
150
+ });
151
+ }
152
+ }
153
+ return attachKeys(path, keys);
154
+ }
155
+ /**
156
+ * Transform an array into a regexp.
157
+ *
158
+ * @param {!Array} path
159
+ * @param {Array} keys
160
+ * @param {!Object} options
161
+ * @return {!RegExp}
162
+ */
163
+ function arrayToRegexp(path, keys, options) {
164
+ const parts = [];
165
+ for (let i = 0; i < path.length; i++) {
166
+ parts.push(pathToRegexp(path[i], keys, options).source);
167
+ }
168
+ const regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options));
169
+ return attachKeys(regexp, keys);
170
+ }
171
+ /**
172
+ * Create a path regexp from string input.
173
+ *
174
+ * @param {string} path
175
+ * @param {!Array} keys
176
+ * @param {!Object} options
177
+ * @return {!RegExp}
178
+ */
179
+ function stringToRegexp(path, keys, options) {
180
+ return tokensToRegExp(parse(path, options), keys, options);
181
+ }
182
+ /**
183
+ * Expose a function for taking tokens and returning a RegExp.
184
+ *
185
+ * @param {!Array} tokens
186
+ * @param {(Array|Object)=} keys
187
+ * @param {Object=} options
188
+ * @return {!RegExp}
189
+ */
190
+ function tokensToRegExp(tokens, keys, options) {
191
+ if (!Array.isArray(keys)) {
192
+ options = /** @type {!Object} */ keys || options;
193
+ keys = [];
194
+ }
195
+ options = options || {};
196
+ const strict = options.strict;
197
+ const end = options.end !== false;
198
+ let route = '';
199
+ // Iterate over the tokens and create our regexp string.
200
+ for (let i = 0; i < tokens.length; i++) {
201
+ const token = tokens[i];
202
+ if (typeof token === 'string') {
203
+ route += escapeString(token);
204
+ }
205
+ else {
206
+ const prefix = escapeString(token.prefix);
207
+ let capture = '(?:' + token.pattern + ')';
208
+ keys.push(token);
209
+ if (token.repeat) {
210
+ capture += '(?:' + prefix + capture + ')*';
211
+ }
212
+ if (token.optional) {
213
+ if (!token.partial) {
214
+ capture = '(?:' + prefix + '(' + capture + '))?';
215
+ }
216
+ else {
217
+ capture = prefix + '(' + capture + ')?';
218
+ }
219
+ }
220
+ else {
221
+ capture = prefix + '(' + capture + ')';
222
+ }
223
+ route += capture;
224
+ }
225
+ }
226
+ const delimiter = escapeString(options.delimiter || '/');
227
+ const endsWithDelimiter = route.slice(-delimiter.length) === delimiter;
228
+ // In non-strict mode we allow a slash at the end of match. If the path to
229
+ // match already ends with a slash, we remove it for consistency. The slash
230
+ // is valid at the end of a path match, not in the middle. This is important
231
+ // in non-ending mode, where "/test/" shouldn't match "/test//route".
232
+ if (!strict) {
233
+ route =
234
+ (endsWithDelimiter ? route.slice(0, -delimiter.length) : route) +
235
+ '(?:' +
236
+ delimiter +
237
+ '(?=$))?';
238
+ }
239
+ if (end) {
240
+ route += '$';
241
+ }
242
+ else {
243
+ // In non-ending mode, we need the capturing groups to match as much as
244
+ // possible by using a positive lookahead to the end or next path segment.
245
+ route += strict && endsWithDelimiter ? '' : '(?=' + delimiter + '|$)';
246
+ }
247
+ return attachKeys(new RegExp('^' + route, flags(options)), keys);
248
+ }
249
+ /**
250
+ * Normalize the given path string, returning a regular expression.
251
+ *
252
+ * An empty array can be passed in for the keys, which will hold the
253
+ * placeholder key descriptions. For example, using `/user/:id`, `keys` will
254
+ * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
255
+ *
256
+ * @param {(string|RegExp|Array)} path
257
+ * @param {(Array|Object)=} keys
258
+ * @param {Object=} options
259
+ * @return {!RegExp}
260
+ */
261
+ function pathToRegexp(path, keys, options) {
262
+ if (!Array.isArray(keys)) {
263
+ options = /** @type {!Object} */ keys || options;
264
+ keys = [];
265
+ }
266
+ options = options || {};
267
+ if (path instanceof RegExp) {
268
+ return regexpToRegexp(path, /** @type {!Array} */ keys);
269
+ }
270
+ if (Array.isArray(path)) {
271
+ return arrayToRegexp(
272
+ /** @type {!Array} */ path,
273
+ /** @type {!Array} */ keys, options);
274
+ }
275
+ return stringToRegexp(
276
+ /** @type {string} */ path,
277
+ /** @type {!Array} */ keys, options);
278
+ }
279
+ exports.pathToRegexp = pathToRegexp;
280
+ //# sourceMappingURL=pathToRegexp.js.map
@@ -1,3 +1,3 @@
1
- export declare const extractKoaLikeValue: (key: any, data: any) => (ctx: any, next: any) => Promise<any>;
2
- export declare const extractExpressLikeValue: (key: any, data: any) => (req: any, res: any, next: any) => Promise<any>;
1
+ export declare const extractKoaLikeValue: (key: any, data: any, paramType?: any) => (ctx: any, next: any) => any;
2
+ export declare const extractExpressLikeValue: (key: any, data: any, paramType?: any) => (req: any, res: any, next: any) => any;
3
3
  //# sourceMappingURL=webRouterParam.d.ts.map
@@ -2,26 +2,25 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extractExpressLikeValue = exports.extractKoaLikeValue = void 0;
4
4
  const decorator_1 = require("@midwayjs/decorator");
5
- const extractKoaLikeValue = (key, data) => {
5
+ const index_1 = require("./index");
6
+ const extractKoaLikeValue = (key, data, paramType) => {
6
7
  if (decorator_1.ALL === data) {
7
8
  data = undefined;
8
9
  }
9
- return async function (ctx, next) {
10
+ return function (ctx, next) {
10
11
  switch (key) {
11
12
  case decorator_1.RouteParamTypes.NEXT:
12
13
  return next;
13
14
  case decorator_1.RouteParamTypes.BODY:
14
- return data && ctx.request.body
15
- ? ctx.request.body[data]
16
- : ctx.request.body;
15
+ return (0, index_1.transformRequestObjectByType)(data && ctx.request.body ? ctx.request.body[data] : ctx.request.body, paramType);
17
16
  case decorator_1.RouteParamTypes.PARAM:
18
- return data ? ctx.params[data] : ctx.params;
17
+ return (0, index_1.transformRequestObjectByType)(data ? ctx.params[data] : ctx.params, paramType);
19
18
  case decorator_1.RouteParamTypes.QUERY:
20
- return data ? ctx.query[data] : ctx.query;
19
+ return (0, index_1.transformRequestObjectByType)(data ? ctx.query[data] : ctx.query, paramType);
21
20
  case decorator_1.RouteParamTypes.HEADERS:
22
- return data ? ctx.get(data) : ctx.headers;
21
+ return (0, index_1.transformRequestObjectByType)(data ? ctx.get(data) : ctx.headers, paramType);
23
22
  case decorator_1.RouteParamTypes.SESSION:
24
- return data ? ctx.session[data] : ctx.session;
23
+ return (0, index_1.transformRequestObjectByType)(data ? ctx.session[data] : ctx.session, paramType);
25
24
  case decorator_1.RouteParamTypes.FILESTREAM:
26
25
  return ctx.getFileStream && ctx.getFileStream(data);
27
26
  case decorator_1.RouteParamTypes.FILESSTREAM:
@@ -32,10 +31,10 @@ const extractKoaLikeValue = (key, data) => {
32
31
  return ctx['ip'];
33
32
  case decorator_1.RouteParamTypes.QUERIES:
34
33
  if (ctx.queries) {
35
- return data ? ctx.queries[data] : ctx.queries;
34
+ return (0, index_1.transformRequestObjectByType)(data ? ctx.queries[data] : ctx.queries, paramType);
36
35
  }
37
36
  else {
38
- return data ? ctx.query[data] : ctx.query;
37
+ return (0, index_1.transformRequestObjectByType)(data ? ctx.query[data] : ctx.query, paramType);
39
38
  }
40
39
  default:
41
40
  return null;
@@ -43,24 +42,24 @@ const extractKoaLikeValue = (key, data) => {
43
42
  };
44
43
  };
45
44
  exports.extractKoaLikeValue = extractKoaLikeValue;
46
- const extractExpressLikeValue = (key, data) => {
45
+ const extractExpressLikeValue = (key, data, paramType) => {
47
46
  if (decorator_1.ALL === data) {
48
47
  data = undefined;
49
48
  }
50
- return async function (req, res, next) {
49
+ return function (req, res, next) {
51
50
  switch (key) {
52
51
  case decorator_1.RouteParamTypes.NEXT:
53
52
  return next;
54
53
  case decorator_1.RouteParamTypes.BODY:
55
- return data && req.body ? req.body[data] : req.body;
54
+ return (0, index_1.transformRequestObjectByType)(data && req.body ? req.body[data] : req.body, paramType);
56
55
  case decorator_1.RouteParamTypes.PARAM:
57
- return data ? req.params[data] : req.params;
56
+ return (0, index_1.transformRequestObjectByType)(data ? req.params[data] : req.params, paramType);
58
57
  case decorator_1.RouteParamTypes.QUERY:
59
- return data ? req.query[data] : req.query;
58
+ return (0, index_1.transformRequestObjectByType)(data ? req.query[data] : req.query, paramType);
60
59
  case decorator_1.RouteParamTypes.HEADERS:
61
- return data ? req.get(data) : req.headers;
60
+ return (0, index_1.transformRequestObjectByType)(data ? req.get(data) : req.headers, paramType);
62
61
  case decorator_1.RouteParamTypes.SESSION:
63
- return data ? req.session[data] : req.session;
62
+ return (0, index_1.transformRequestObjectByType)(data ? req.session[data] : req.session, paramType);
64
63
  case decorator_1.RouteParamTypes.FILESTREAM:
65
64
  return req.getFileStream && req.getFileStream(data);
66
65
  case decorator_1.RouteParamTypes.FILESSTREAM:
@@ -71,10 +70,10 @@ const extractExpressLikeValue = (key, data) => {
71
70
  return req['ip'];
72
71
  case decorator_1.RouteParamTypes.QUERIES:
73
72
  if (req.queries) {
74
- return data ? req.queries[data] : req.queries;
73
+ return (0, index_1.transformRequestObjectByType)(data ? req.queries[data] : req.queries, paramType);
75
74
  }
76
75
  else {
77
- return data ? req.query[data] : req.query;
76
+ return (0, index_1.transformRequestObjectByType)(data ? req.query[data] : req.query, paramType);
78
77
  }
79
78
  default:
80
79
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/core",
3
- "version": "3.0.0-alpha.9+d5acc750",
3
+ "version": "3.0.0-beta.4",
4
4
  "description": "midway core",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index.d.ts",
@@ -21,24 +21,19 @@
21
21
  ],
22
22
  "license": "MIT",
23
23
  "devDependencies": {
24
- "@midwayjs/decorator": "^3.0.0-alpha.2",
25
- "chai": "^4.2.0",
24
+ "@midwayjs/decorator": "^3.0.0-beta.4",
25
+ "midway-test-component": "*",
26
26
  "mm": "3",
27
27
  "sinon": "^7.2.2"
28
28
  },
29
29
  "peerDependencies": {
30
- "@midwayjs/decorator": "^2.10.12"
30
+ "@midwayjs/decorator": "*"
31
31
  },
32
32
  "dependencies": {
33
33
  "@midwayjs/glob": "^1.0.2",
34
- "@midwayjs/logger": "^2.11.3",
35
- "class-transformer": "^0.3.1",
34
+ "@midwayjs/logger": "^3.0.0-beta.4",
35
+ "class-transformer": "^0.4.0",
36
36
  "extend2": "^1.0.0",
37
- "lodash.clonedeep": "^4.5.0",
38
- "lodash.defaultsdeep": "^4.6.0",
39
- "lodash.get": "^4.4.2",
40
- "lodash.set": "^4.3.2",
41
- "lodash.template": "^4.4.0",
42
37
  "picomatch": "^2.2.2",
43
38
  "reflect-metadata": "^0.1.13"
44
39
  },
@@ -48,7 +43,7 @@
48
43
  "url": "http://github.com/midwayjs/midway.git"
49
44
  },
50
45
  "engines": {
51
- "node": ">= 10.0.0"
46
+ "node": ">=12"
52
47
  },
53
- "gitHead": "d5acc7505275ea9d566edd38e5e0377141e0abc1"
48
+ "gitHead": "02e2144e302f807770b512b0d89da3145b1cbf2e"
54
49
  }
@@ -1,9 +0,0 @@
1
- import * as get from 'lodash.get';
2
- import * as set from 'lodash.set';
3
- import * as template from 'lodash.template';
4
- import * as cloneDeep from 'lodash.clonedeep';
5
- import * as defaultsDeep from 'lodash.defaultsdeep';
6
- import * as assign from 'extend2';
7
- declare const isArray: (arg: any) => arg is any[];
8
- export { assign, set, get, isArray, template, cloneDeep, defaultsDeep };
9
- //# sourceMappingURL=lodashWrap.d.ts.map
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultsDeep = exports.cloneDeep = exports.template = exports.isArray = exports.get = exports.set = exports.assign = void 0;
4
- const get = require("lodash.get");
5
- exports.get = get;
6
- const set = require("lodash.set");
7
- exports.set = set;
8
- const template = require("lodash.template");
9
- exports.template = template;
10
- const cloneDeep = require("lodash.clonedeep");
11
- exports.cloneDeep = cloneDeep;
12
- const defaultsDeep = require("lodash.defaultsdeep");
13
- exports.defaultsDeep = defaultsDeep;
14
- const assign = require("extend2");
15
- exports.assign = assign;
16
- const isArray = Array.isArray;
17
- exports.isArray = isArray;
18
- //# sourceMappingURL=lodashWrap.js.map
@@ -1,8 +0,0 @@
1
- import { ObjectIdentifier } from '@midwayjs/decorator';
2
- export declare class NotFoundError extends Error {
3
- static readonly type: unique symbol;
4
- static isClosePrototypeOf(ins: NotFoundError): boolean;
5
- constructor(identifier: ObjectIdentifier);
6
- updateErrorMsg(className: string): void;
7
- }
8
- //# sourceMappingURL=notFoundError.d.ts.map
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NotFoundError = void 0;
4
- class NotFoundError extends Error {
5
- constructor(identifier) {
6
- super(`${identifier} is not valid in current context`);
7
- this[NotFoundError.type] = NotFoundError.type;
8
- }
9
- static isClosePrototypeOf(ins) {
10
- return ins ? ins[NotFoundError.type] === NotFoundError.type : false;
11
- }
12
- updateErrorMsg(className) {
13
- const identifier = this.message.split(' is not valid in current context')[0];
14
- const msg = `${identifier} in class ${className} is not valid in current context`;
15
- this.message = msg;
16
- }
17
- }
18
- exports.NotFoundError = NotFoundError;
19
- NotFoundError.type = Symbol.for('#NotFoundError');
20
- //# sourceMappingURL=notFoundError.js.map
@@ -1,15 +0,0 @@
1
- import 'reflect-metadata';
2
- import { ReflectResult } from '@midwayjs/decorator';
3
- /**
4
- * 以数组形式返回对象所有 property, 数组第一个元素是距离 o 最近的原型
5
- * @param target 对象,class 或者 function
6
- */
7
- export declare function recursiveGetPrototypeOf(target: any): any[];
8
- export declare function getOwnMetadata(metadataKey: any, target: any, propertyKey?: string | symbol): ReflectResult;
9
- /**
10
- * get metadata value of a metadata key on the prototype chain of an object and property
11
- * @param metadataKey metadata's key
12
- * @param target the target of metadataKey
13
- */
14
- export declare function recursiveGetMetadata(metadataKey: any, target: any, propertyKey?: string | symbol): ReflectResult[];
15
- //# sourceMappingURL=reflectTool.d.ts.map
@@ -1,83 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.recursiveGetMetadata = exports.getOwnMetadata = exports.recursiveGetPrototypeOf = void 0;
4
- require("reflect-metadata");
5
- const functionPrototype = Object.getPrototypeOf(Function);
6
- // get property of an object
7
- // https://tc39.github.io/ecma262/#sec-ordinarygetprototypeof
8
- function ordinaryGetPrototypeOf(O) {
9
- const proto = Object.getPrototypeOf(O);
10
- if (typeof O !== 'function' || O === functionPrototype) {
11
- return proto;
12
- }
13
- // TypeScript doesn't set __proto__ in ES5, as it's non-standard.
14
- // Try to determine the superclass constructor. Compatible implementations
15
- // must either set __proto__ on a subclass constructor to the superclass constructor,
16
- // or ensure each class has a valid `constructor` property on its prototype that
17
- // points back to the constructor.
18
- // If this is not the same as Function.[[Prototype]], then this is definately inherited.
19
- // This is the case when in ES6 or when using __proto__ in a compatible browser.
20
- if (proto !== functionPrototype) {
21
- return proto;
22
- }
23
- // If the super prototype is Object.prototype, null, or undefined, then we cannot determine the heritage.
24
- const prototype = O.prototype;
25
- const prototypeProto = prototype && Object.getPrototypeOf(prototype);
26
- if (prototypeProto == null || prototypeProto === Object.prototype) {
27
- return proto;
28
- }
29
- // If the constructor was not a function, then we cannot determine the heritage.
30
- const constructor = prototypeProto.constructor;
31
- if (typeof constructor !== 'function') {
32
- return proto;
33
- }
34
- // If we have some kind of self-reference, then we cannot determine the heritage.
35
- if (constructor === O) {
36
- return proto;
37
- }
38
- // we have a pretty good guess at the heritage.
39
- return constructor;
40
- }
41
- /**
42
- * 以数组形式返回对象所有 property, 数组第一个元素是距离 o 最近的原型
43
- * @param target 对象,class 或者 function
44
- */
45
- function recursiveGetPrototypeOf(target) {
46
- const properties = [];
47
- let parent = ordinaryGetPrototypeOf(target);
48
- while (parent !== null) {
49
- properties.push(parent);
50
- parent = ordinaryGetPrototypeOf(parent);
51
- }
52
- return properties;
53
- }
54
- exports.recursiveGetPrototypeOf = recursiveGetPrototypeOf;
55
- function getOwnMetadata(metadataKey, target, propertyKey) {
56
- return Reflect.getOwnMetadata(metadataKey, target, propertyKey);
57
- }
58
- exports.getOwnMetadata = getOwnMetadata;
59
- /**
60
- * get metadata value of a metadata key on the prototype chain of an object and property
61
- * @param metadataKey metadata's key
62
- * @param target the target of metadataKey
63
- */
64
- function recursiveGetMetadata(metadataKey, target, propertyKey) {
65
- const metadatas = [];
66
- // get metadata value of a metadata key on the prototype
67
- let metadata = Reflect.getOwnMetadata(metadataKey, target, propertyKey);
68
- if (metadata) {
69
- metadatas.push(metadata);
70
- }
71
- // get metadata value of a metadata key on the prototype chain
72
- let parent = ordinaryGetPrototypeOf(target);
73
- while (parent !== null) {
74
- metadata = Reflect.getOwnMetadata(metadataKey, parent, propertyKey);
75
- if (metadata) {
76
- metadatas.push(metadata);
77
- }
78
- parent = ordinaryGetPrototypeOf(parent);
79
- }
80
- return metadatas;
81
- }
82
- exports.recursiveGetMetadata = recursiveGetMetadata;
83
- //# sourceMappingURL=reflectTool.js.map
@@ -1,81 +0,0 @@
1
- /**
2
- * 基础的ObjectFactory和ApplicationContext实现
3
- */
4
- import { ObjectIdentifier } from '@midwayjs/decorator';
5
- import { IApplicationContext, IObjectDefinition, IObjectDefinitionRegistry, IObjectFactory, ObjectDependencyTree } from '../interface';
6
- import { ObjectProperties } from '../definitions/properties';
7
- import { ManagedResolverFactory } from './managedResolverFactory';
8
- export declare class ObjectDefinitionRegistry extends Map implements IObjectDefinitionRegistry {
9
- private singletonIds;
10
- get identifiers(): any[];
11
- get count(): number;
12
- getSingletonDefinitionIds(): ObjectIdentifier[];
13
- getDefinitionByName(name: string): IObjectDefinition[];
14
- registerDefinition(identifier: ObjectIdentifier, definition: IObjectDefinition): void;
15
- getDefinition(identifier: ObjectIdentifier): IObjectDefinition;
16
- getDefinitionByPath(path: string): IObjectDefinition;
17
- removeDefinition(identifier: ObjectIdentifier): void;
18
- hasDefinition(identifier: ObjectIdentifier): boolean;
19
- clearAll(): void;
20
- hasObject(identifier: ObjectIdentifier): boolean;
21
- registerObject(identifier: ObjectIdentifier, target: any): void;
22
- getObject(identifier: ObjectIdentifier): any;
23
- }
24
- export declare class BaseApplicationContext implements IApplicationContext, IObjectFactory {
25
- protected readied: boolean;
26
- protected midwayIdentifiers: string[];
27
- private _resolverFactory;
28
- private _registry;
29
- private _props;
30
- private _dependencyMap;
31
- baseDir: string;
32
- parent: IApplicationContext;
33
- disableConflictCheck: boolean;
34
- constructor(baseDir?: string, parent?: IApplicationContext);
35
- get dependencyMap(): Map<string, ObjectDependencyTree>;
36
- get props(): ObjectProperties;
37
- get registry(): IObjectDefinitionRegistry;
38
- set registry(registry: IObjectDefinitionRegistry);
39
- protected getManagedResolverFactory(): ManagedResolverFactory;
40
- /**
41
- * 继承实现时需要调用super
42
- */
43
- protected init(): void;
44
- stop(): Promise<void>;
45
- ready(): void;
46
- protected loadDefinitions(): void;
47
- isAsync(identifier: ObjectIdentifier): boolean;
48
- get<T>(identifier: {
49
- new (...args: any[]): T;
50
- }, args?: any): T;
51
- get<T>(identifier: ObjectIdentifier, args?: any): T;
52
- getAsync<T>(identifier: {
53
- new (...args: any[]): T;
54
- }, args?: any): Promise<T>;
55
- getAsync<T>(identifier: ObjectIdentifier, args?: any): Promise<T>;
56
- get isReady(): boolean;
57
- /**
58
- * proxy registry.registerDefinition
59
- * @param {ObjectIdentifier} identifier
60
- * @param {IObjectDefinition} definition
61
- */
62
- registerDefinition(identifier: ObjectIdentifier, definition: IObjectDefinition): void;
63
- /**
64
- * proxy registry.registerObject
65
- * @param {ObjectIdentifier} identifier
66
- * @param target
67
- */
68
- registerObject(identifier: ObjectIdentifier, target: any): void;
69
- /**
70
- * register handler after instance create
71
- * @param fn
72
- */
73
- afterEachCreated(fn: (ins: any, context: IApplicationContext, definition?: IObjectDefinition) => void): void;
74
- /**
75
- * register handler before instance create
76
- * @param fn
77
- */
78
- beforeEachCreated(fn: (Clzz: any, constructorArgs: any[], context: IApplicationContext) => void): void;
79
- protected createObjectDependencyTree(identifier: any, definition: any): void;
80
- }
81
- //# sourceMappingURL=applicationContext.d.ts.map