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

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/CHANGELOG.md CHANGED
@@ -3,6 +3,23 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [3.0.0-beta.15](https://github.com/midwayjs/midway/compare/v3.0.0-beta.14...v3.0.0-beta.15) (2022-01-07)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * serverless app run ([#1523](https://github.com/midwayjs/midway/issues/1523)) ([5a25eb7](https://github.com/midwayjs/midway/commit/5a25eb7ebb17bf9b0e2ba4feee5bc1649f70d56f))
12
+
13
+
14
+ ### Features
15
+
16
+ * add data listener ([#1525](https://github.com/midwayjs/midway/issues/1525)) ([0bd0db8](https://github.com/midwayjs/midway/commit/0bd0db8c7f3338c754ae852619bbbb4f2336cc16))
17
+ * add secret filter ([#1531](https://github.com/midwayjs/midway/issues/1531)) ([ce77e48](https://github.com/midwayjs/midway/commit/ce77e4804aaffc18a0a091d3726e36d7ec1514b2))
18
+
19
+
20
+
21
+
22
+
6
23
  # [3.0.0-beta.14](https://github.com/midwayjs/midway/compare/v3.0.0-beta.13...v3.0.0-beta.14) (2022-01-04)
7
24
 
8
25
 
@@ -0,0 +1,11 @@
1
+ export declare abstract class DataListener<T> {
2
+ private innerData;
3
+ protected init(): Promise<void>;
4
+ abstract initData(): T;
5
+ abstract onData(callback: (data: T) => void): any;
6
+ protected setData(data: T): void;
7
+ getData(): T;
8
+ stop(): Promise<void>;
9
+ protected destroyListener(): Promise<void>;
10
+ }
11
+ //# sourceMappingURL=dataListener.d.ts.map
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.DataListener = void 0;
13
+ const decorator_1 = require("@midwayjs/decorator");
14
+ class DataListener {
15
+ async init() {
16
+ this.innerData = await this.initData();
17
+ await this.onData(this.setData.bind(this));
18
+ }
19
+ setData(data) {
20
+ this.innerData = data;
21
+ }
22
+ getData() {
23
+ return this.innerData;
24
+ }
25
+ async stop() {
26
+ await this.destroyListener();
27
+ }
28
+ async destroyListener() { }
29
+ }
30
+ __decorate([
31
+ (0, decorator_1.Init)(),
32
+ __metadata("design:type", Function),
33
+ __metadata("design:paramtypes", []),
34
+ __metadata("design:returntype", Promise)
35
+ ], DataListener.prototype, "init", null);
36
+ __decorate([
37
+ (0, decorator_1.Destroy)(),
38
+ __metadata("design:type", Function),
39
+ __metadata("design:paramtypes", []),
40
+ __metadata("design:returntype", Promise)
41
+ ], DataListener.prototype, "stop", null);
42
+ exports.DataListener = DataListener;
43
+ //# sourceMappingURL=dataListener.js.map
@@ -109,7 +109,7 @@ export declare class PayloadTooLargeError extends MidwayHttpError {
109
109
  export declare class UnsupportedMediaTypeError extends MidwayHttpError {
110
110
  constructor(resOrMessage?: ResOrMessage);
111
111
  }
112
- export declare class UnprocessableError extends MidwayHttpError {
112
+ export declare class UnprocessableEntityError extends MidwayHttpError {
113
113
  constructor(resOrMessage?: ResOrMessage);
114
114
  }
115
115
  /**
@@ -121,7 +121,7 @@ export declare class InternalServerErrorError extends MidwayHttpError {
121
121
  /**
122
122
  * 501 http error, Means that the server doesn't recognize the request method or it lacks the ability to fulfill the request.
123
123
  */
124
- declare class NotImplementedError extends MidwayHttpError {
124
+ export declare class NotImplementedError extends MidwayHttpError {
125
125
  constructor(resOrMessage?: ResOrMessage);
126
126
  }
127
127
  /**
@@ -153,12 +153,11 @@ export declare const httpError: {
153
153
  GoneError: typeof GoneError;
154
154
  PayloadTooLargeError: typeof PayloadTooLargeError;
155
155
  UnsupportedMediaTypeError: typeof UnsupportedMediaTypeError;
156
- UnprocessableError: typeof UnprocessableError;
156
+ UnprocessableEntityError: typeof UnprocessableEntityError;
157
157
  InternalServerErrorError: typeof InternalServerErrorError;
158
158
  NotImplementedError: typeof NotImplementedError;
159
159
  BadGatewayError: typeof BadGatewayError;
160
160
  ServiceUnavailableError: typeof ServiceUnavailableError;
161
161
  GatewayTimeoutError: typeof GatewayTimeoutError;
162
162
  };
163
- export {};
164
163
  //# sourceMappingURL=http.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.httpError = exports.GatewayTimeoutError = exports.ServiceUnavailableError = exports.BadGatewayError = exports.InternalServerErrorError = exports.UnprocessableError = exports.UnsupportedMediaTypeError = exports.PayloadTooLargeError = exports.GoneError = exports.ConflictError = exports.RequestTimeoutError = exports.NotAcceptableError = exports.ForbiddenError = exports.NotFoundError = exports.UnauthorizedError = exports.BadRequestError = exports.HttpStatus = void 0;
3
+ exports.httpError = exports.GatewayTimeoutError = exports.ServiceUnavailableError = exports.BadGatewayError = exports.NotImplementedError = exports.InternalServerErrorError = exports.UnprocessableEntityError = exports.UnsupportedMediaTypeError = exports.PayloadTooLargeError = exports.GoneError = exports.ConflictError = exports.RequestTimeoutError = exports.NotAcceptableError = exports.ForbiddenError = exports.NotFoundError = exports.UnauthorizedError = exports.BadRequestError = exports.HttpStatus = void 0;
4
4
  const base_1 = require("./base");
5
5
  var HttpStatus;
6
6
  (function (HttpStatus) {
@@ -143,12 +143,12 @@ class UnsupportedMediaTypeError extends base_1.MidwayHttpError {
143
143
  }
144
144
  }
145
145
  exports.UnsupportedMediaTypeError = UnsupportedMediaTypeError;
146
- class UnprocessableError extends base_1.MidwayHttpError {
146
+ class UnprocessableEntityError extends base_1.MidwayHttpError {
147
147
  constructor(resOrMessage = 'Unprocessable Entity') {
148
148
  super(resOrMessage, HttpStatus.UNPROCESSABLE_ENTITY);
149
149
  }
150
150
  }
151
- exports.UnprocessableError = UnprocessableError;
151
+ exports.UnprocessableEntityError = UnprocessableEntityError;
152
152
  /**
153
153
  * 500 http error, Is a generic error and users receive this error message when there is no more suitable specific message.
154
154
  */
@@ -166,6 +166,7 @@ class NotImplementedError extends base_1.MidwayHttpError {
166
166
  super(resOrMessage, HttpStatus.NOT_IMPLEMENTED);
167
167
  }
168
168
  }
169
+ exports.NotImplementedError = NotImplementedError;
169
170
  /**
170
171
  * 502 http error, Means that the server was acting as a gateway or proxy and it received an invalid answer from the upstream server.
171
172
  */
@@ -204,7 +205,7 @@ exports.httpError = {
204
205
  GoneError,
205
206
  PayloadTooLargeError,
206
207
  UnsupportedMediaTypeError,
207
- UnprocessableError,
208
+ UnprocessableEntityError,
208
209
  InternalServerErrorError,
209
210
  NotImplementedError,
210
211
  BadGatewayError,
@@ -1,4 +1,4 @@
1
1
  export * from './base';
2
- export * from './http';
2
+ export { HttpStatus, httpError } from './http';
3
3
  export * from './framework';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -10,7 +10,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.httpError = exports.HttpStatus = void 0;
13
14
  __exportStar(require("./base"), exports);
14
- __exportStar(require("./http"), exports);
15
+ var http_1 = require("./http");
16
+ Object.defineProperty(exports, "HttpStatus", { enumerable: true, get: function () { return http_1.HttpStatus; } });
17
+ Object.defineProperty(exports, "httpError", { enumerable: true, get: function () { return http_1.httpError; } });
15
18
  __exportStar(require("./framework"), exports);
16
19
  //# sourceMappingURL=index.js.map
@@ -4,10 +4,12 @@ export declare class FunctionalConfiguration {
4
4
  private readyHandler;
5
5
  private stopHandler;
6
6
  private configLoadHandler;
7
+ private serverReadyHandler;
7
8
  private options;
8
9
  constructor(options: InjectionConfigurationOptions);
9
10
  onConfigLoad(configLoadHandler: ((container: IMidwayContainer, app: IMidwayApplication) => any) | IMidwayContainer, app?: IMidwayApplication): any;
10
11
  onReady(readyHandler: ((container: IMidwayContainer, app: IMidwayApplication) => void) | IMidwayContainer, app?: IMidwayApplication): any;
12
+ onServerReady(serverReadyHandler: ((container: IMidwayContainer, app: IMidwayApplication) => void) | IMidwayContainer, app?: IMidwayApplication): any;
11
13
  onStop(stopHandler: ((container: IMidwayContainer, app: IMidwayApplication) => void) | IMidwayContainer, app?: IMidwayApplication): any;
12
14
  getConfigurationOptions(): InjectionConfigurationOptions;
13
15
  }
@@ -7,6 +7,7 @@ class FunctionalConfiguration {
7
7
  this.readyHandler = () => { };
8
8
  this.stopHandler = () => { };
9
9
  this.configLoadHandler = () => { };
10
+ this.serverReadyHandler = () => { };
10
11
  }
11
12
  onConfigLoad(configLoadHandler, app) {
12
13
  if (typeof configLoadHandler === 'function') {
@@ -26,6 +27,15 @@ class FunctionalConfiguration {
26
27
  }
27
28
  return this;
28
29
  }
30
+ onServerReady(serverReadyHandler, app) {
31
+ if (typeof serverReadyHandler === 'function') {
32
+ this.serverReadyHandler = serverReadyHandler;
33
+ }
34
+ else {
35
+ return this.serverReadyHandler(serverReadyHandler, app);
36
+ }
37
+ return this;
38
+ }
29
39
  onStop(stopHandler, app) {
30
40
  if (typeof stopHandler === 'function') {
31
41
  this.stopHandler = stopHandler;
package/dist/index.d.ts CHANGED
@@ -22,6 +22,7 @@ export { MidwayDecoratorService } from './service/decoratorService';
22
22
  export * from './service/pipelineService';
23
23
  export * from './util/contextUtil';
24
24
  export * from './common/serviceFactory';
25
+ export * from './common/dataListener';
25
26
  export * from './common/fileDetector';
26
27
  export * from './common/webGenerator';
27
28
  export * from './common/middlewareManager';
package/dist/index.js CHANGED
@@ -56,6 +56,7 @@ Object.defineProperty(exports, "MidwayDecoratorService", { enumerable: true, get
56
56
  __exportStar(require("./service/pipelineService"), exports);
57
57
  __exportStar(require("./util/contextUtil"), exports);
58
58
  __exportStar(require("./common/serviceFactory"), exports);
59
+ __exportStar(require("./common/dataListener"), exports);
59
60
  __exportStar(require("./common/fileDetector"), exports);
60
61
  __exportStar(require("./common/webGenerator"), exports);
61
62
  __exportStar(require("./common/middlewareManager"), exports);
@@ -468,10 +468,5 @@ export interface MidwayAppInfo {
468
468
  export interface MidwayConfig extends FileConfigOption<typeof _default> {
469
469
  [customConfigKey: string]: unknown;
470
470
  }
471
- export interface TranslateOptions {
472
- lang?: string;
473
- group?: string;
474
- args?: any;
475
- }
476
471
  export {};
477
472
  //# sourceMappingURL=interface.d.ts.map
@@ -1,4 +1,4 @@
1
- import { IConfigService } from '../interface';
1
+ import { IConfigService, MidwayAppInfo } from '../interface';
2
2
  import { MidwayEnvironmentService } from './environmentService';
3
3
  import { MidwayInformationService } from './informationService';
4
4
  export declare class MidwayConfigService implements IConfigService {
@@ -7,8 +7,10 @@ export declare class MidwayConfigService implements IConfigService {
7
7
  protected configuration: any;
8
8
  protected isReady: boolean;
9
9
  protected externalObject: Record<string, unknown>[];
10
+ protected appInfo: MidwayAppInfo;
10
11
  protected environmentService: MidwayEnvironmentService;
11
12
  protected informationService: MidwayInformationService;
13
+ protected init(): Promise<void>;
12
14
  add(configFilePaths: any[]): void;
13
15
  addObject(obj: Record<string, unknown>): void;
14
16
  private getEnvSet;
@@ -29,6 +29,17 @@ let MidwayConfigService = class MidwayConfigService {
29
29
  this.isReady = false;
30
30
  this.externalObject = [];
31
31
  }
32
+ async init() {
33
+ this.appInfo = {
34
+ pkg: this.informationService.getPkg(),
35
+ name: this.informationService.getProjectName(),
36
+ baseDir: this.informationService.getBaseDir(),
37
+ appDir: this.informationService.getAppDir(),
38
+ HOME: this.informationService.getHome(),
39
+ root: this.informationService.getRoot(),
40
+ env: this.environmentService.getCurrentEnvironment(),
41
+ };
42
+ }
32
43
  add(configFilePaths) {
33
44
  for (const dir of configFilePaths) {
34
45
  if (typeof dir === 'string') {
@@ -98,18 +109,7 @@ let MidwayConfigService = class MidwayConfigService {
98
109
  let config = await this.loadConfig(filename);
99
110
  if ((0, decorator_1.isFunction)(config)) {
100
111
  // eslint-disable-next-line prefer-spread
101
- config = config.apply(null, [
102
- {
103
- pkg: this.informationService.getPkg(),
104
- name: this.informationService.getProjectName(),
105
- baseDir: this.informationService.getBaseDir(),
106
- appDir: this.informationService.getAppDir(),
107
- HOME: this.informationService.getHome(),
108
- root: this.informationService.getRoot(),
109
- env: this.environmentService.getCurrentEnvironment(),
110
- },
111
- target,
112
- ]);
112
+ config = config.apply(null, [this.appInfo, target]);
113
113
  }
114
114
  if (!config) {
115
115
  continue;
@@ -160,6 +160,12 @@ __decorate([
160
160
  (0, decorator_1.Inject)(),
161
161
  __metadata("design:type", informationService_1.MidwayInformationService)
162
162
  ], MidwayConfigService.prototype, "informationService", void 0);
163
+ __decorate([
164
+ (0, decorator_1.Init)(),
165
+ __metadata("design:type", Function),
166
+ __metadata("design:paramtypes", []),
167
+ __metadata("design:returntype", Promise)
168
+ ], MidwayConfigService.prototype, "init", null);
163
169
  MidwayConfigService = __decorate([
164
170
  (0, decorator_1.Provide)(),
165
171
  (0, decorator_1.Scope)(decorator_1.ScopeEnum.Singleton)
@@ -1,6 +1,6 @@
1
1
  import { IEnvironmentService } from '../interface';
2
2
  export declare class MidwayEnvironmentService implements IEnvironmentService {
3
- environment: string;
3
+ protected environment: string;
4
4
  getCurrentEnvironment(): string;
5
5
  setCurrentEnvironment(environment: string): void;
6
6
  isDevelopmentEnvironment(): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/core",
3
- "version": "3.0.0-beta.14",
3
+ "version": "3.0.0-beta.15",
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.14",
24
+ "@midwayjs/decorator": "^3.0.0-beta.15",
25
25
  "koa": "2.13.4",
26
26
  "midway-test-component": "*",
27
27
  "mm": "3.2.0",
@@ -35,7 +35,7 @@
35
35
  "@midwayjs/logger": "2.14.0",
36
36
  "class-transformer": "^0.5.1",
37
37
  "extend2": "^1.0.0",
38
- "picomatch": "^2.3.0"
38
+ "picomatch": "2.3.1"
39
39
  },
40
40
  "author": "Harry Chen <czy88840616@gmail.com>",
41
41
  "repository": {
@@ -45,5 +45,5 @@
45
45
  "engines": {
46
46
  "node": ">=12"
47
47
  },
48
- "gitHead": "95695ada36190cf376e93a1a8866b3fb6dde06bc"
48
+ "gitHead": "6b9778557289d9e8b562c7ce6127736db1248973"
49
49
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
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.