@midwayjs/core 3.0.0-beta.15 → 3.0.0-beta.16

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2013 - Now midwayjs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -47,7 +47,7 @@ class DirectoryFileDetector extends AbstractFileDetector {
47
47
  continue;
48
48
  }
49
49
  }
50
- else if ((0, decorator_1.isRegExp)(resolveFilter.pattern)) {
50
+ else if (decorator_1.TYPES.isRegExp(resolveFilter.pattern)) {
51
51
  if (resolveFilter.pattern.test(file)) {
52
52
  const exports = resolveFilter.ignoreRequire
53
53
  ? undefined
@@ -232,7 +232,7 @@ class WebRouterCollector {
232
232
  return urlMatchList
233
233
  .map(item => {
234
234
  const urlString = item.url.toString();
235
- const weightArr = (0, decorator_1.isRegExp)(item.url)
235
+ const weightArr = decorator_1.TYPES.isRegExp(item.url)
236
236
  ? urlString.split('\\/')
237
237
  : urlString.split('/');
238
238
  let weight = 0;
@@ -144,16 +144,16 @@ class ContainerConfiguration {
144
144
  }
145
145
  getConfigurationExport(exports) {
146
146
  const mods = [];
147
- if ((0, decorator_1.isClass)(exports) ||
148
- (0, decorator_1.isFunction)(exports) ||
147
+ if (decorator_1.TYPES.isClass(exports) ||
148
+ decorator_1.TYPES.isFunction(exports) ||
149
149
  exports instanceof configuration_1.FunctionalConfiguration) {
150
150
  mods.push(exports);
151
151
  }
152
152
  else {
153
153
  for (const m in exports) {
154
154
  const module = exports[m];
155
- if ((0, decorator_1.isClass)(module) ||
156
- (0, decorator_1.isFunction)(module) ||
155
+ if (decorator_1.TYPES.isClass(module) ||
156
+ decorator_1.TYPES.isFunction(module) ||
157
157
  module instanceof configuration_1.FunctionalConfiguration) {
158
158
  mods.push(module);
159
159
  }
@@ -240,13 +240,13 @@ class MidwayContainer {
240
240
  (_a = this.fileDetector) === null || _a === void 0 ? void 0 : _a.run(this);
241
241
  }
242
242
  bindClass(exports, options) {
243
- if ((0, decorator_1.isClass)(exports) || (0, decorator_1.isFunction)(exports)) {
243
+ if (decorator_1.TYPES.isClass(exports) || decorator_1.TYPES.isFunction(exports)) {
244
244
  this.bindModule(exports, options);
245
245
  }
246
246
  else {
247
247
  for (const m in exports) {
248
248
  const module = exports[m];
249
- if ((0, decorator_1.isClass)(module) || (0, decorator_1.isFunction)(module)) {
249
+ if (decorator_1.TYPES.isClass(module) || decorator_1.TYPES.isFunction(module)) {
250
250
  this.bindModule(module, options);
251
251
  }
252
252
  }
@@ -254,7 +254,7 @@ class MidwayContainer {
254
254
  }
255
255
  bind(identifier, target, options) {
256
256
  var _a;
257
- if ((0, decorator_1.isClass)(identifier) || (0, decorator_1.isFunction)(identifier)) {
257
+ if (decorator_1.TYPES.isClass(identifier) || decorator_1.TYPES.isFunction(identifier)) {
258
258
  return this.bindModule(identifier, target);
259
259
  }
260
260
  if (this.registry.hasDefinition(identifier)) {
@@ -262,13 +262,13 @@ class MidwayContainer {
262
262
  return;
263
263
  }
264
264
  let definition;
265
- if ((0, decorator_1.isClass)(target)) {
265
+ if (decorator_1.TYPES.isClass(target)) {
266
266
  definition = new objectDefinition_1.ObjectDefinition();
267
267
  definition.name = (0, decorator_1.getProviderName)(target);
268
268
  }
269
269
  else {
270
270
  definition = new functionDefinition_1.FunctionDefinition();
271
- if (!(0, decorator_1.isAsyncFunction)(target)) {
271
+ if (!decorator_1.TYPES.isAsyncFunction(target)) {
272
272
  definition.asynchronous = false;
273
273
  }
274
274
  definition.name = definition.id;
@@ -327,7 +327,7 @@ class MidwayContainer {
327
327
  }
328
328
  }
329
329
  bindModule(module, options) {
330
- if ((0, decorator_1.isClass)(module)) {
330
+ if (decorator_1.TYPES.isClass(module)) {
331
331
  const providerId = (0, decorator_1.getProviderUUId)(module);
332
332
  if (providerId) {
333
333
  this.identifierMapping.saveClassRelation(module, options === null || options === void 0 ? void 0 : options.namespace);
@@ -65,7 +65,7 @@ class ObjectCreator {
65
65
  let inst;
66
66
  if (this.definition.constructMethod) {
67
67
  const fn = Clzz[this.definition.constructMethod];
68
- if ((0, decorator_1.isAsyncFunction)(fn)) {
68
+ if (decorator_1.TYPES.isAsyncFunction(fn)) {
69
69
  inst = await fn.apply(Clzz, args);
70
70
  }
71
71
  else {
@@ -86,13 +86,13 @@ class ObjectCreator {
86
86
  const inst = obj;
87
87
  // after properties set then do init
88
88
  if (this.definition.initMethod && inst[this.definition.initMethod]) {
89
- if ((0, decorator_1.isGeneratorFunction)(inst[this.definition.initMethod]) ||
90
- (0, decorator_1.isAsyncFunction)(inst[this.definition.initMethod])) {
89
+ if (decorator_1.TYPES.isGeneratorFunction(inst[this.definition.initMethod]) ||
90
+ decorator_1.TYPES.isAsyncFunction(inst[this.definition.initMethod])) {
91
91
  throw new error_1.MidwayUseWrongMethodError('context.get', 'context.getAsync', this.definition.id);
92
92
  }
93
93
  else {
94
94
  const rt = inst[this.definition.initMethod].call(inst);
95
- if ((0, decorator_1.isPromise)(rt)) {
95
+ if (decorator_1.TYPES.isPromise(rt)) {
96
96
  throw new error_1.MidwayUseWrongMethodError('context.get', 'context.getAsync', this.definition.id);
97
97
  }
98
98
  }
@@ -107,7 +107,7 @@ class ObjectCreator {
107
107
  const inst = obj;
108
108
  if (this.definition.initMethod && inst[this.definition.initMethod]) {
109
109
  const initFn = inst[this.definition.initMethod];
110
- if ((0, decorator_1.isAsyncFunction)(initFn)) {
110
+ if (decorator_1.TYPES.isAsyncFunction(initFn)) {
111
111
  await initFn.call(inst);
112
112
  }
113
113
  else {
@@ -140,7 +140,7 @@ class ObjectCreator {
140
140
  async doDestroyAsync(obj) {
141
141
  if (this.definition.destroyMethod && obj[this.definition.destroyMethod]) {
142
142
  const fn = obj[this.definition.destroyMethod];
143
- if ((0, decorator_1.isAsyncFunction)(fn)) {
143
+ if (decorator_1.TYPES.isAsyncFunction(fn)) {
144
144
  await fn.call(obj);
145
145
  }
146
146
  else {
@@ -64,7 +64,7 @@ let MidwayAspectService = class MidwayAspectService {
64
64
  */
65
65
  interceptPrototypeMethod(Clz, methodName, aspectObject) {
66
66
  const originMethod = Clz.prototype[methodName];
67
- if ((0, decorator_1.isAsyncFunction)(Clz.prototype[methodName])) {
67
+ if (decorator_1.TYPES.isAsyncFunction(Clz.prototype[methodName])) {
68
68
  Clz.prototype[methodName] = async function (...args) {
69
69
  var _a, _b, _c;
70
70
  let error, result;
@@ -107,7 +107,7 @@ let MidwayConfigService = class MidwayConfigService {
107
107
  const target = {};
108
108
  for (const filename of [...defaultSet, ...currentEnvSet]) {
109
109
  let config = await this.loadConfig(filename);
110
- if ((0, decorator_1.isFunction)(config)) {
110
+ if (decorator_1.TYPES.isFunction(config)) {
111
111
  // eslint-disable-next-line prefer-spread
112
112
  config = config.apply(null, [this.appInfo, target]);
113
113
  }
@@ -7,7 +7,7 @@ export declare class MidwayLoggerService extends ServiceFactory<ILogger> {
7
7
  configService: MidwayConfigService;
8
8
  constructor(applicationContext: IMidwayContainer);
9
9
  protected init(): Promise<void>;
10
- transformEggConfig(): {
10
+ protected transformEggConfig(): {
11
11
  midwayLogger: {
12
12
  default: {};
13
13
  clients: {};
@@ -23,7 +23,7 @@ let MidwayMiddlewareService = class MidwayMiddlewareService {
23
23
  }
24
24
  const newMiddlewareArr = [];
25
25
  for (let fn of middleware) {
26
- if ((0, decorator_1.isClass)(fn) || typeof fn === 'string') {
26
+ if (decorator_1.TYPES.isClass(fn) || typeof fn === 'string') {
27
27
  if (typeof fn === 'string' &&
28
28
  !this.applicationContext.hasDefinition(fn)) {
29
29
  throw new error_1.MidwayCommonError('Middleware definition not found in midway container');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/core",
3
- "version": "3.0.0-beta.15",
3
+ "version": "3.0.0-beta.16",
4
4
  "description": "midway core",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index.d.ts",
@@ -21,7 +21,7 @@
21
21
  ],
22
22
  "license": "MIT",
23
23
  "devDependencies": {
24
- "@midwayjs/decorator": "^3.0.0-beta.15",
24
+ "@midwayjs/decorator": "^3.0.0-beta.16",
25
25
  "koa": "2.13.4",
26
26
  "midway-test-component": "*",
27
27
  "mm": "3.2.0",
@@ -45,5 +45,5 @@
45
45
  "engines": {
46
46
  "node": ">=12"
47
47
  },
48
- "gitHead": "6b9778557289d9e8b562c7ce6127736db1248973"
48
+ "gitHead": "43a32745ac45164dfef1494cba979f9652a6692b"
49
49
  }