@midwayjs/core 3.0.0-alpha.6 → 3.0.0-beta.11

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 (113) hide show
  1. package/CHANGELOG.md +137 -0
  2. package/README.md +1 -1
  3. package/dist/baseFramework.d.ts +56 -22
  4. package/dist/baseFramework.js +157 -232
  5. package/dist/common/applicationManager.d.ts +12 -0
  6. package/dist/common/applicationManager.js +66 -0
  7. package/dist/{util → common}/fileDetector.d.ts +0 -0
  8. package/dist/{util → common}/fileDetector.js +16 -10
  9. package/dist/common/filterManager.d.ts +19 -0
  10. package/dist/common/filterManager.js +85 -0
  11. package/dist/common/middlewareManager.d.ts +68 -0
  12. package/dist/common/middlewareManager.js +183 -0
  13. package/dist/common/serviceFactory.d.ts +15 -0
  14. package/dist/{util → common}/serviceFactory.js +16 -6
  15. package/dist/{util → common}/triggerCollector.d.ts +0 -0
  16. package/dist/{util → common}/triggerCollector.js +0 -0
  17. package/dist/common/webGenerator.d.ts +16 -0
  18. package/dist/common/webGenerator.js +114 -0
  19. package/dist/{util → common}/webRouterCollector.d.ts +21 -2
  20. package/dist/common/webRouterCollector.js +331 -0
  21. package/dist/config/config.default.d.ts +7 -0
  22. package/dist/config/config.default.js +28 -0
  23. package/dist/context/container.d.ts +73 -43
  24. package/dist/context/container.js +289 -271
  25. package/dist/context/definitionRegistry.d.ts +26 -0
  26. package/dist/context/definitionRegistry.js +124 -0
  27. package/dist/context/managedResolverFactory.d.ts +15 -32
  28. package/dist/context/managedResolverFactory.js +88 -317
  29. package/dist/context/providerWrapper.d.ts +2 -3
  30. package/dist/context/requestContainer.d.ts +0 -2
  31. package/dist/context/requestContainer.js +9 -26
  32. package/dist/definitions/functionDefinition.d.ts +3 -4
  33. package/dist/definitions/functionDefinition.js +0 -6
  34. package/dist/definitions/objectCreator.js +6 -6
  35. package/dist/definitions/objectDefinition.d.ts +4 -6
  36. package/dist/definitions/objectDefinition.js +0 -8
  37. package/dist/definitions/properties.d.ts +2 -15
  38. package/dist/definitions/properties.js +3 -72
  39. package/dist/error/base.d.ts +13 -0
  40. package/dist/error/base.js +19 -0
  41. package/dist/error/code.d.ts +60 -0
  42. package/dist/error/code.js +65 -0
  43. package/dist/error/framework.d.ts +24 -0
  44. package/dist/error/framework.js +58 -0
  45. package/dist/error/http.d.ts +58 -0
  46. package/dist/error/http.js +82 -0
  47. package/dist/error/index.d.ts +4 -0
  48. package/dist/error/index.js +16 -0
  49. package/dist/functional/configuration.d.ts +4 -2
  50. package/dist/functional/configuration.js +12 -2
  51. package/dist/index.d.ts +24 -11
  52. package/dist/index.js +36 -36
  53. package/dist/interface.d.ts +270 -184
  54. package/dist/interface.js +9 -1
  55. package/dist/service/aspectService.d.ts +11 -14
  56. package/dist/service/aspectService.js +116 -172
  57. package/dist/service/configService.d.ts +10 -8
  58. package/dist/service/configService.js +61 -38
  59. package/dist/service/decoratorService.d.ts +23 -0
  60. package/dist/service/decoratorService.js +149 -0
  61. package/dist/service/environmentService.js +15 -4
  62. package/dist/service/frameworkService.d.ts +26 -0
  63. package/dist/service/frameworkService.js +176 -0
  64. package/dist/service/informationService.d.ts +4 -7
  65. package/dist/service/informationService.js +41 -10
  66. package/dist/service/lifeCycleService.d.ts +14 -0
  67. package/dist/service/lifeCycleService.js +130 -0
  68. package/dist/service/loggerService.d.ts +27 -0
  69. package/dist/service/loggerService.js +132 -0
  70. package/dist/service/middlewareService.d.ts +11 -0
  71. package/dist/service/middlewareService.js +127 -0
  72. package/dist/{features/pipeline.d.ts → service/pipelineService.d.ts} +56 -46
  73. package/dist/{features/pipeline.js → service/pipelineService.js} +54 -19
  74. package/dist/setup.d.ts +4 -0
  75. package/dist/setup.js +119 -0
  76. package/dist/util/contextUtil.d.ts +1 -1
  77. package/dist/util/contextUtil.js +2 -2
  78. package/dist/util/index.d.ts +64 -0
  79. package/dist/util/index.js +195 -7
  80. package/dist/util/pathFileUtil.js +2 -2
  81. package/dist/util/pathToRegexp.d.ts +17 -0
  82. package/dist/util/pathToRegexp.js +280 -0
  83. package/dist/util/webRouterParam.d.ts +2 -2
  84. package/dist/util/webRouterParam.js +19 -20
  85. package/package.json +10 -15
  86. package/dist/common/lodashWrap.d.ts +0 -9
  87. package/dist/common/lodashWrap.js +0 -18
  88. package/dist/common/notFoundError.d.ts +0 -8
  89. package/dist/common/notFoundError.js +0 -20
  90. package/dist/common/reflectTool.d.ts +0 -15
  91. package/dist/common/reflectTool.js +0 -83
  92. package/dist/context/applicationContext.d.ts +0 -81
  93. package/dist/context/applicationContext.js +0 -263
  94. package/dist/context/managed.d.ts +0 -45
  95. package/dist/context/managed.js +0 -69
  96. package/dist/context/resolverHandler.d.ts +0 -34
  97. package/dist/context/resolverHandler.js +0 -88
  98. package/dist/definitions/messageSource.d.ts +0 -13
  99. package/dist/definitions/messageSource.js +0 -74
  100. package/dist/definitions/resource.d.ts +0 -27
  101. package/dist/definitions/resource.js +0 -116
  102. package/dist/features/index.d.ts +0 -2
  103. package/dist/features/index.js +0 -3
  104. package/dist/logger.d.ts +0 -4
  105. package/dist/logger.js +0 -20
  106. package/dist/util/containerUtil.d.ts +0 -9
  107. package/dist/util/containerUtil.js +0 -26
  108. package/dist/util/emptyFramework.d.ts +0 -62
  109. package/dist/util/emptyFramework.js +0 -72
  110. package/dist/util/serviceFactory.d.ts +0 -13
  111. package/dist/util/staticConfig.d.ts +0 -10
  112. package/dist/util/staticConfig.js +0 -67
  113. package/dist/util/webRouterCollector.js +0 -348
@@ -1,5 +1,5 @@
1
1
  import { IManagedInstance, ObjectIdentifier, ScopeEnum } from '@midwayjs/decorator';
2
- import { IProperties, IObjectCreator, IObjectDefinition, HandlerProp } from '../interface';
2
+ import { IProperties, IObjectCreator, IObjectDefinition } from '../interface';
3
3
  export declare class FunctionDefinition implements IObjectDefinition {
4
4
  constructor();
5
5
  constructMethod: string;
@@ -16,16 +16,15 @@ export declare class FunctionDefinition implements IObjectDefinition {
16
16
  properties: IProperties;
17
17
  namespace: string;
18
18
  asynchronous: boolean;
19
- handlerProps: HandlerProp[];
19
+ handlerProps: any[];
20
+ createFrom: any;
20
21
  protected innerAutowire: boolean;
21
22
  protected innerScope: ScopeEnum;
22
- set autowire(autowire: boolean);
23
23
  getAttr(key: ObjectIdentifier): any;
24
24
  hasAttr(key: ObjectIdentifier): boolean;
25
25
  hasConstructorArgs(): boolean;
26
26
  hasDependsOn(): boolean;
27
27
  isAsync(): boolean;
28
- isAutowire(): boolean;
29
28
  isDirect(): boolean;
30
29
  isExternal(): boolean;
31
30
  set scope(scope: ScopeEnum);
@@ -28,9 +28,6 @@ class FunctionDefinition {
28
28
  this.innerScope = decorator_1.ScopeEnum.Singleton;
29
29
  this.creator = new FunctionWrapperCreator(this);
30
30
  }
31
- set autowire(autowire) {
32
- this.innerAutowire = autowire;
33
- }
34
31
  getAttr(key) { }
35
32
  hasAttr(key) {
36
33
  return false;
@@ -44,9 +41,6 @@ class FunctionDefinition {
44
41
  isAsync() {
45
42
  return this.asynchronous;
46
43
  }
47
- isAutowire() {
48
- return this.innerAutowire;
49
- }
50
44
  isDirect() {
51
45
  return false;
52
46
  }
@@ -64,7 +64,7 @@ class ObjectCreator {
64
64
  let inst;
65
65
  if (this.definition.constructMethod) {
66
66
  const fn = Clzz[this.definition.constructMethod];
67
- if (decorator_1.isAsyncFunction(fn)) {
67
+ if ((0, decorator_1.isAsyncFunction)(fn)) {
68
68
  inst = await fn.apply(Clzz, args);
69
69
  }
70
70
  else {
@@ -85,13 +85,13 @@ class ObjectCreator {
85
85
  const inst = obj;
86
86
  // after properties set then do init
87
87
  if (this.definition.initMethod && inst[this.definition.initMethod]) {
88
- if (decorator_1.isGeneratorFunction(inst[this.definition.initMethod]) ||
89
- decorator_1.isAsyncFunction(inst[this.definition.initMethod])) {
88
+ if ((0, decorator_1.isGeneratorFunction)(inst[this.definition.initMethod]) ||
89
+ (0, decorator_1.isAsyncFunction)(inst[this.definition.initMethod])) {
90
90
  throw new Error(`${this.definition.id} not valid by context.get, Use context.getAsync instead!`);
91
91
  }
92
92
  else {
93
93
  const rt = inst[this.definition.initMethod].call(inst);
94
- if (decorator_1.isPromise(rt)) {
94
+ if ((0, decorator_1.isPromise)(rt)) {
95
95
  throw new Error(`${this.definition.id} not valid by context.get, Use context.getAsync instead!`);
96
96
  }
97
97
  }
@@ -106,7 +106,7 @@ class ObjectCreator {
106
106
  const inst = obj;
107
107
  if (this.definition.initMethod && inst[this.definition.initMethod]) {
108
108
  const initFn = inst[this.definition.initMethod];
109
- if (decorator_1.isAsyncFunction(initFn)) {
109
+ if ((0, decorator_1.isAsyncFunction)(initFn)) {
110
110
  await initFn.call(inst);
111
111
  }
112
112
  else {
@@ -139,7 +139,7 @@ class ObjectCreator {
139
139
  async doDestroyAsync(obj) {
140
140
  if (this.definition.destroyMethod && obj[this.definition.destroyMethod]) {
141
141
  const fn = obj[this.definition.destroyMethod];
142
- if (decorator_1.isAsyncFunction(fn)) {
142
+ if ((0, decorator_1.isAsyncFunction)(fn)) {
143
143
  await fn.call(obj);
144
144
  }
145
145
  else {
@@ -1,10 +1,9 @@
1
- import { IObjectCreator, IObjectDefinition, HandlerProp } from '../interface';
1
+ import { IObjectCreator, IObjectDefinition } from '../interface';
2
2
  import { ScopeEnum, ObjectIdentifier } from '@midwayjs/decorator';
3
3
  import { ObjectProperties } from './properties';
4
4
  export declare class ObjectDefinition implements IObjectDefinition {
5
- protected _attrs: Map<string, any>;
5
+ protected _attrs: Map<ObjectIdentifier, any>;
6
6
  protected _asynchronous: boolean;
7
- protected _autowire: boolean;
8
7
  scope: ScopeEnum;
9
8
  creator: IObjectCreator;
10
9
  id: string;
@@ -19,10 +18,9 @@ export declare class ObjectDefinition implements IObjectDefinition {
19
18
  dependsOn: ObjectIdentifier[];
20
19
  properties: ObjectProperties;
21
20
  namespace: string;
22
- handlerProps: HandlerProp[];
21
+ handlerProps: any[];
22
+ createFrom: any;
23
23
  constructor();
24
- set autowire(autowire: boolean);
25
- isAutowire(): boolean;
26
24
  set asynchronous(asynchronous: boolean);
27
25
  isAsync(): boolean;
28
26
  isSingletonScope(): boolean;
@@ -9,8 +9,6 @@ class ObjectDefinition {
9
9
  constructor() {
10
10
  this._attrs = new Map();
11
11
  this._asynchronous = false;
12
- // 对象定义默认需要自动装配
13
- this._autowire = true;
14
12
  this.scope = decorator_1.ScopeEnum.Singleton;
15
13
  this.creator = null;
16
14
  this.id = null;
@@ -27,12 +25,6 @@ class ObjectDefinition {
27
25
  this.handlerProps = [];
28
26
  this.creator = new objectCreator_1.ObjectCreator(this);
29
27
  }
30
- set autowire(autowire) {
31
- this._autowire = autowire;
32
- }
33
- isAutowire() {
34
- return this._autowire;
35
- }
36
28
  set asynchronous(asynchronous) {
37
29
  this._asynchronous = asynchronous;
38
30
  }
@@ -1,21 +1,8 @@
1
1
  import { ObjectIdentifier } from '@midwayjs/decorator';
2
2
  import { IProperties } from '../interface';
3
- export declare class ObjectProperties implements IProperties {
4
- private innerConfig;
5
- get size(): number;
6
- keys(): ObjectIdentifier[];
7
- get(key: ObjectIdentifier, ...args: any[]): any;
8
- dup(key: ObjectIdentifier): any;
9
- has(key: ObjectIdentifier): boolean;
10
- set(key: ObjectIdentifier, value: any): any;
11
- putAll(props: IProperties): void;
12
- putObject(props: Record<string, unknown>, needClone?: boolean): void;
13
- stringPropertyNames(): ObjectIdentifier[];
3
+ export declare class ObjectProperties extends Map<ObjectIdentifier, any> implements IProperties {
4
+ propertyKeys(): ObjectIdentifier[];
14
5
  getProperty(key: ObjectIdentifier, defaultValue?: any): any;
15
- addProperty(key: ObjectIdentifier, value: any): void;
16
6
  setProperty(key: ObjectIdentifier, value: any): any;
17
- clear(): void;
18
- toJSON(): Record<string, unknown>;
19
- clone(): IProperties;
20
7
  }
21
8
  //# sourceMappingURL=properties.d.ts.map
@@ -1,64 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ObjectProperties = void 0;
4
- const _ = require("../common/lodashWrap");
5
- const util_1 = require("util");
6
- class ObjectProperties {
7
- constructor() {
8
- this.innerConfig = {};
9
- }
10
- get size() {
11
- return this.keys().length;
12
- }
13
- keys() {
14
- return Object.keys(this.innerConfig);
15
- }
16
- get(key, ...args) {
17
- if (args && args.length > 0) {
18
- args.unshift(_.get(this.innerConfig, key));
19
- // eslint-disable-next-line prefer-spread
20
- return util_1.format.apply(null, args);
21
- }
22
- return _.get(this.innerConfig, key);
23
- }
24
- dup(key) {
25
- if (!this.has(key)) {
26
- return null;
27
- }
28
- return JSON.parse(JSON.stringify(_.get(this.innerConfig, key)));
29
- }
30
- has(key) {
31
- return this.innerConfig[key] !== undefined;
32
- }
33
- set(key, value) {
34
- const origin = this.get(key);
35
- _.set(this.innerConfig, key, value);
36
- return origin;
37
- }
38
- putAll(props) {
39
- const keys = props.keys();
40
- for (const key of keys) {
41
- if (typeof this.innerConfig[key] === 'object') {
42
- this.set(key, _.defaultsDeep(props.get(key), this.innerConfig[key]));
43
- }
44
- else {
45
- this.set(key, props.get(key));
46
- }
47
- }
48
- }
49
- putObject(props, needClone = false) {
50
- if (needClone) {
51
- const tmp = _.cloneDeep(props);
52
- _.defaultsDeep(tmp, this.innerConfig);
53
- this.innerConfig = tmp;
54
- }
55
- else {
56
- _.defaultsDeep(props, this.innerConfig);
57
- this.innerConfig = props;
58
- }
59
- }
60
- stringPropertyNames() {
61
- return this.keys();
4
+ class ObjectProperties extends Map {
5
+ propertyKeys() {
6
+ return Array.from(this.keys());
62
7
  }
63
8
  getProperty(key, defaultValue) {
64
9
  if (this.has(key)) {
@@ -66,23 +11,9 @@ class ObjectProperties {
66
11
  }
67
12
  return defaultValue;
68
13
  }
69
- addProperty(key, value) {
70
- this.set(key, value);
71
- }
72
14
  setProperty(key, value) {
73
15
  return this.set(key, value);
74
16
  }
75
- clear() {
76
- this.innerConfig = {};
77
- }
78
- toJSON() {
79
- return JSON.parse(JSON.stringify(this.innerConfig));
80
- }
81
- clone() {
82
- const cfg = new ObjectProperties();
83
- cfg.putObject(this.toJSON());
84
- return cfg;
85
- }
86
17
  }
87
18
  exports.ObjectProperties = ObjectProperties;
88
19
  //# sourceMappingURL=properties.js.map
@@ -0,0 +1,13 @@
1
+ interface ErrorOption {
2
+ cause?: Error;
3
+ status?: number;
4
+ }
5
+ export declare class MidwayError extends Error {
6
+ code: number;
7
+ status: number;
8
+ cause: Error;
9
+ constructor(message: string, options?: ErrorOption);
10
+ constructor(message: string, code: number, options?: ErrorOption);
11
+ }
12
+ export {};
13
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MidwayError = void 0;
4
+ const code_1 = require("./code");
5
+ class MidwayError extends Error {
6
+ constructor(message, code, options) {
7
+ super(message);
8
+ if (typeof code !== 'number') {
9
+ options = code;
10
+ code = code_1.FrameworkErrorEnum.UNKNOWN;
11
+ }
12
+ this.name = this.constructor.name;
13
+ this.code = code;
14
+ this.cause = options === null || options === void 0 ? void 0 : options.cause;
15
+ this.status = options === null || options === void 0 ? void 0 : options.status;
16
+ }
17
+ }
18
+ exports.MidwayError = MidwayError;
19
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1,60 @@
1
+ export declare enum HttpStatus {
2
+ CONTINUE = 100,
3
+ SWITCHING_PROTOCOLS = 101,
4
+ PROCESSING = 102,
5
+ EARLYHINTS = 103,
6
+ OK = 200,
7
+ CREATED = 201,
8
+ ACCEPTED = 202,
9
+ NON_AUTHORITATIVE_INFORMATION = 203,
10
+ NO_CONTENT = 204,
11
+ RESET_CONTENT = 205,
12
+ PARTIAL_CONTENT = 206,
13
+ AMBIGUOUS = 300,
14
+ MOVED_PERMANENTLY = 301,
15
+ FOUND = 302,
16
+ SEE_OTHER = 303,
17
+ NOT_MODIFIED = 304,
18
+ TEMPORARY_REDIRECT = 307,
19
+ PERMANENT_REDIRECT = 308,
20
+ BAD_REQUEST = 400,
21
+ UNAUTHORIZED = 401,
22
+ PAYMENT_REQUIRED = 402,
23
+ FORBIDDEN = 403,
24
+ NOT_FOUND = 404,
25
+ METHOD_NOT_ALLOWED = 405,
26
+ NOT_ACCEPTABLE = 406,
27
+ PROXY_AUTHENTICATION_REQUIRED = 407,
28
+ REQUEST_TIMEOUT = 408,
29
+ CONFLICT = 409,
30
+ GONE = 410,
31
+ LENGTH_REQUIRED = 411,
32
+ PRECONDITION_FAILED = 412,
33
+ PAYLOAD_TOO_LARGE = 413,
34
+ URI_TOO_LONG = 414,
35
+ UNSUPPORTED_MEDIA_TYPE = 415,
36
+ REQUESTED_RANGE_NOT_SATISFIABLE = 416,
37
+ EXPECTATION_FAILED = 417,
38
+ I_AM_A_TEAPOT = 418,
39
+ MISDIRECTED = 421,
40
+ UNPROCESSABLE_ENTITY = 422,
41
+ FAILED_DEPENDENCY = 424,
42
+ PRECONDITION_REQUIRED = 428,
43
+ TOO_MANY_REQUESTS = 429,
44
+ INTERNAL_SERVER_ERROR = 500,
45
+ NOT_IMPLEMENTED = 501,
46
+ BAD_GATEWAY = 502,
47
+ SERVICE_UNAVAILABLE = 503,
48
+ GATEWAY_TIMEOUT = 504,
49
+ HTTP_VERSION_NOT_SUPPORTED = 505
50
+ }
51
+ export declare enum FrameworkErrorEnum {
52
+ UNKNOWN = 10000,
53
+ COMMON = 10001,
54
+ PARAM_TYPE = 10002,
55
+ DEFINITION_NOT_FOUND = 10003,
56
+ FEATURE_NO_LONGER_SUPPORTED = 10004,
57
+ VALIDATE_FAIL = 10005,
58
+ MISSING_CONFIG = 10006
59
+ }
60
+ //# sourceMappingURL=code.d.ts.map
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FrameworkErrorEnum = exports.HttpStatus = void 0;
4
+ var HttpStatus;
5
+ (function (HttpStatus) {
6
+ HttpStatus[HttpStatus["CONTINUE"] = 100] = "CONTINUE";
7
+ HttpStatus[HttpStatus["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
8
+ HttpStatus[HttpStatus["PROCESSING"] = 102] = "PROCESSING";
9
+ HttpStatus[HttpStatus["EARLYHINTS"] = 103] = "EARLYHINTS";
10
+ HttpStatus[HttpStatus["OK"] = 200] = "OK";
11
+ HttpStatus[HttpStatus["CREATED"] = 201] = "CREATED";
12
+ HttpStatus[HttpStatus["ACCEPTED"] = 202] = "ACCEPTED";
13
+ HttpStatus[HttpStatus["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
14
+ HttpStatus[HttpStatus["NO_CONTENT"] = 204] = "NO_CONTENT";
15
+ HttpStatus[HttpStatus["RESET_CONTENT"] = 205] = "RESET_CONTENT";
16
+ HttpStatus[HttpStatus["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
17
+ HttpStatus[HttpStatus["AMBIGUOUS"] = 300] = "AMBIGUOUS";
18
+ HttpStatus[HttpStatus["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
19
+ HttpStatus[HttpStatus["FOUND"] = 302] = "FOUND";
20
+ HttpStatus[HttpStatus["SEE_OTHER"] = 303] = "SEE_OTHER";
21
+ HttpStatus[HttpStatus["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
22
+ HttpStatus[HttpStatus["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
23
+ HttpStatus[HttpStatus["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
24
+ HttpStatus[HttpStatus["BAD_REQUEST"] = 400] = "BAD_REQUEST";
25
+ HttpStatus[HttpStatus["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
26
+ HttpStatus[HttpStatus["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
27
+ HttpStatus[HttpStatus["FORBIDDEN"] = 403] = "FORBIDDEN";
28
+ HttpStatus[HttpStatus["NOT_FOUND"] = 404] = "NOT_FOUND";
29
+ HttpStatus[HttpStatus["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
30
+ HttpStatus[HttpStatus["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
31
+ HttpStatus[HttpStatus["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
32
+ HttpStatus[HttpStatus["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
33
+ HttpStatus[HttpStatus["CONFLICT"] = 409] = "CONFLICT";
34
+ HttpStatus[HttpStatus["GONE"] = 410] = "GONE";
35
+ HttpStatus[HttpStatus["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
36
+ HttpStatus[HttpStatus["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
37
+ HttpStatus[HttpStatus["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
38
+ HttpStatus[HttpStatus["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
39
+ HttpStatus[HttpStatus["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
40
+ HttpStatus[HttpStatus["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
41
+ HttpStatus[HttpStatus["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
42
+ HttpStatus[HttpStatus["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
43
+ HttpStatus[HttpStatus["MISDIRECTED"] = 421] = "MISDIRECTED";
44
+ HttpStatus[HttpStatus["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
45
+ HttpStatus[HttpStatus["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
46
+ HttpStatus[HttpStatus["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
47
+ HttpStatus[HttpStatus["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
48
+ HttpStatus[HttpStatus["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
49
+ HttpStatus[HttpStatus["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
50
+ HttpStatus[HttpStatus["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
51
+ HttpStatus[HttpStatus["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
52
+ HttpStatus[HttpStatus["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
53
+ HttpStatus[HttpStatus["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
54
+ })(HttpStatus = exports.HttpStatus || (exports.HttpStatus = {}));
55
+ var FrameworkErrorEnum;
56
+ (function (FrameworkErrorEnum) {
57
+ FrameworkErrorEnum[FrameworkErrorEnum["UNKNOWN"] = 10000] = "UNKNOWN";
58
+ FrameworkErrorEnum[FrameworkErrorEnum["COMMON"] = 10001] = "COMMON";
59
+ FrameworkErrorEnum[FrameworkErrorEnum["PARAM_TYPE"] = 10002] = "PARAM_TYPE";
60
+ FrameworkErrorEnum[FrameworkErrorEnum["DEFINITION_NOT_FOUND"] = 10003] = "DEFINITION_NOT_FOUND";
61
+ FrameworkErrorEnum[FrameworkErrorEnum["FEATURE_NO_LONGER_SUPPORTED"] = 10004] = "FEATURE_NO_LONGER_SUPPORTED";
62
+ FrameworkErrorEnum[FrameworkErrorEnum["VALIDATE_FAIL"] = 10005] = "VALIDATE_FAIL";
63
+ FrameworkErrorEnum[FrameworkErrorEnum["MISSING_CONFIG"] = 10006] = "MISSING_CONFIG";
64
+ })(FrameworkErrorEnum = exports.FrameworkErrorEnum || (exports.FrameworkErrorEnum = {}));
65
+ //# sourceMappingURL=code.js.map
@@ -0,0 +1,24 @@
1
+ import { MidwayError } from './base';
2
+ import { ObjectIdentifier } from '@midwayjs/decorator';
3
+ export declare class MidwayCommonError extends MidwayError {
4
+ constructor(message: string);
5
+ }
6
+ export declare class MidwayParameterError extends MidwayError {
7
+ constructor(message?: string);
8
+ }
9
+ export declare class MidwayDefinitionNotFoundError extends MidwayError {
10
+ static readonly type: unique symbol;
11
+ static isClosePrototypeOf(ins: MidwayDefinitionNotFoundError): boolean;
12
+ constructor(identifier: ObjectIdentifier);
13
+ updateErrorMsg(className: string): void;
14
+ }
15
+ export declare class MidwayFeatureNoLongerSupportedError extends MidwayError {
16
+ constructor(message?: string);
17
+ }
18
+ export declare class MidwayValidationError extends MidwayError {
19
+ constructor(message: any, status: any, cause: any);
20
+ }
21
+ export declare class MidwayConfigMissingError extends MidwayError {
22
+ constructor(configKey: string);
23
+ }
24
+ //# sourceMappingURL=framework.d.ts.map
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MidwayConfigMissingError = exports.MidwayValidationError = exports.MidwayFeatureNoLongerSupportedError = exports.MidwayDefinitionNotFoundError = exports.MidwayParameterError = exports.MidwayCommonError = void 0;
4
+ const base_1 = require("./base");
5
+ const code_1 = require("./code");
6
+ class MidwayCommonError extends base_1.MidwayError {
7
+ constructor(message) {
8
+ super(message, code_1.FrameworkErrorEnum.COMMON);
9
+ }
10
+ }
11
+ exports.MidwayCommonError = MidwayCommonError;
12
+ class MidwayParameterError extends base_1.MidwayError {
13
+ constructor(message) {
14
+ super(message !== null && message !== void 0 ? message : 'Parameter type not match', code_1.FrameworkErrorEnum.PARAM_TYPE);
15
+ }
16
+ }
17
+ exports.MidwayParameterError = MidwayParameterError;
18
+ class MidwayDefinitionNotFoundError extends base_1.MidwayError {
19
+ constructor(identifier) {
20
+ super(`${identifier} is not valid in current context`, code_1.FrameworkErrorEnum.DEFINITION_NOT_FOUND);
21
+ this[MidwayDefinitionNotFoundError.type] =
22
+ MidwayDefinitionNotFoundError.type;
23
+ }
24
+ static isClosePrototypeOf(ins) {
25
+ return ins
26
+ ? ins[MidwayDefinitionNotFoundError.type] ===
27
+ MidwayDefinitionNotFoundError.type
28
+ : false;
29
+ }
30
+ updateErrorMsg(className) {
31
+ const identifier = this.message.split(' is not valid in current context')[0];
32
+ this.message = `${identifier} in class ${className} is not valid in current context`;
33
+ }
34
+ }
35
+ exports.MidwayDefinitionNotFoundError = MidwayDefinitionNotFoundError;
36
+ MidwayDefinitionNotFoundError.type = Symbol.for('#NotFoundError');
37
+ class MidwayFeatureNoLongerSupportedError extends base_1.MidwayError {
38
+ constructor(message) {
39
+ super('This feature no longer supported \n' + message, code_1.FrameworkErrorEnum.FEATURE_NO_LONGER_SUPPORTED);
40
+ }
41
+ }
42
+ exports.MidwayFeatureNoLongerSupportedError = MidwayFeatureNoLongerSupportedError;
43
+ class MidwayValidationError extends base_1.MidwayError {
44
+ constructor(message, status, cause) {
45
+ super(message, code_1.FrameworkErrorEnum.VALIDATE_FAIL, {
46
+ status,
47
+ cause,
48
+ });
49
+ }
50
+ }
51
+ exports.MidwayValidationError = MidwayValidationError;
52
+ class MidwayConfigMissingError extends base_1.MidwayError {
53
+ constructor(configKey) {
54
+ super(`Can't found config key "${configKey}" in your config, please set it first`, code_1.FrameworkErrorEnum.MISSING_CONFIG);
55
+ }
56
+ }
57
+ exports.MidwayConfigMissingError = MidwayConfigMissingError;
58
+ //# sourceMappingURL=framework.js.map
@@ -0,0 +1,58 @@
1
+ import { MidwayError } from './base';
2
+ export declare class HttpError extends MidwayError {
3
+ status: number;
4
+ constructor(response: any, status: any);
5
+ }
6
+ export declare class BadRequestError extends HttpError {
7
+ constructor(response: any);
8
+ }
9
+ export declare class UnauthorizedError extends HttpError {
10
+ }
11
+ export declare class NotFoundError extends HttpError {
12
+ }
13
+ export declare class ForbiddenError extends HttpError {
14
+ }
15
+ export declare class NotAcceptableError extends HttpError {
16
+ }
17
+ export declare class RequestTimeoutError extends HttpError {
18
+ }
19
+ export declare class ConflictError extends HttpError {
20
+ }
21
+ export declare class GoneError extends HttpError {
22
+ }
23
+ export declare class PayloadTooLargeError extends HttpError {
24
+ }
25
+ export declare class UnsupportedMediaTypeError extends HttpError {
26
+ }
27
+ export declare class UnprocessableError extends HttpError {
28
+ }
29
+ export declare class InternalServerErrorError extends HttpError {
30
+ }
31
+ declare class NotImplementedError extends HttpError {
32
+ }
33
+ export declare class BadGatewayError extends HttpError {
34
+ }
35
+ export declare class ServiceUnavailableError extends HttpError {
36
+ }
37
+ export declare class GatewayTimeoutError extends HttpError {
38
+ }
39
+ export declare const http: {
40
+ BadRequestError: typeof BadRequestError;
41
+ UnauthorizedError: typeof UnauthorizedError;
42
+ NotFoundError: typeof NotFoundError;
43
+ ForbiddenError: typeof ForbiddenError;
44
+ NotAcceptableError: typeof NotAcceptableError;
45
+ RequestTimeoutError: typeof RequestTimeoutError;
46
+ ConflictError: typeof ConflictError;
47
+ GoneError: typeof GoneError;
48
+ PayloadTooLargeError: typeof PayloadTooLargeError;
49
+ UnsupportedMediaTypeError: typeof UnsupportedMediaTypeError;
50
+ UnprocessableError: typeof UnprocessableError;
51
+ InternalServerErrorError: typeof InternalServerErrorError;
52
+ NotImplementedError: typeof NotImplementedError;
53
+ BadGatewayError: typeof BadGatewayError;
54
+ ServiceUnavailableError: typeof ServiceUnavailableError;
55
+ GatewayTimeoutError: typeof GatewayTimeoutError;
56
+ };
57
+ export {};
58
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.http = 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.HttpError = void 0;
4
+ const code_1 = require("./code");
5
+ const base_1 = require("./base");
6
+ class HttpError extends base_1.MidwayError {
7
+ constructor(response, status) {
8
+ super(typeof response === 'string' ? response : response.message);
9
+ this.status = status;
10
+ this.name = this.constructor.name;
11
+ }
12
+ }
13
+ exports.HttpError = HttpError;
14
+ class BadRequestError extends HttpError {
15
+ constructor(response) {
16
+ super(response, code_1.HttpStatus.BAD_REQUEST);
17
+ }
18
+ }
19
+ exports.BadRequestError = BadRequestError;
20
+ class UnauthorizedError extends HttpError {
21
+ }
22
+ exports.UnauthorizedError = UnauthorizedError;
23
+ class NotFoundError extends HttpError {
24
+ }
25
+ exports.NotFoundError = NotFoundError;
26
+ class ForbiddenError extends HttpError {
27
+ }
28
+ exports.ForbiddenError = ForbiddenError;
29
+ class NotAcceptableError extends HttpError {
30
+ }
31
+ exports.NotAcceptableError = NotAcceptableError;
32
+ class RequestTimeoutError extends HttpError {
33
+ }
34
+ exports.RequestTimeoutError = RequestTimeoutError;
35
+ class ConflictError extends HttpError {
36
+ }
37
+ exports.ConflictError = ConflictError;
38
+ class GoneError extends HttpError {
39
+ }
40
+ exports.GoneError = GoneError;
41
+ class PayloadTooLargeError extends HttpError {
42
+ }
43
+ exports.PayloadTooLargeError = PayloadTooLargeError;
44
+ class UnsupportedMediaTypeError extends HttpError {
45
+ }
46
+ exports.UnsupportedMediaTypeError = UnsupportedMediaTypeError;
47
+ class UnprocessableError extends HttpError {
48
+ }
49
+ exports.UnprocessableError = UnprocessableError;
50
+ class InternalServerErrorError extends HttpError {
51
+ }
52
+ exports.InternalServerErrorError = InternalServerErrorError;
53
+ class NotImplementedError extends HttpError {
54
+ }
55
+ class BadGatewayError extends HttpError {
56
+ }
57
+ exports.BadGatewayError = BadGatewayError;
58
+ class ServiceUnavailableError extends HttpError {
59
+ }
60
+ exports.ServiceUnavailableError = ServiceUnavailableError;
61
+ class GatewayTimeoutError extends HttpError {
62
+ }
63
+ exports.GatewayTimeoutError = GatewayTimeoutError;
64
+ exports.http = {
65
+ BadRequestError,
66
+ UnauthorizedError,
67
+ NotFoundError,
68
+ ForbiddenError,
69
+ NotAcceptableError,
70
+ RequestTimeoutError,
71
+ ConflictError,
72
+ GoneError,
73
+ PayloadTooLargeError,
74
+ UnsupportedMediaTypeError,
75
+ UnprocessableError,
76
+ InternalServerErrorError,
77
+ NotImplementedError,
78
+ BadGatewayError,
79
+ ServiceUnavailableError,
80
+ GatewayTimeoutError,
81
+ };
82
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1,4 @@
1
+ export * from './base';
2
+ export * from './http';
3
+ export * from './framework';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./base"), exports);
14
+ __exportStar(require("./http"), exports);
15
+ __exportStar(require("./framework"), exports);
16
+ //# sourceMappingURL=index.js.map