vona-core 1.0.0 → 5.0.9

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 (233) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.d.ts +4 -0
  3. package/dist/index.js +4 -0
  4. package/dist/lib/bean/beanAopBase.d.ts +3 -0
  5. package/dist/lib/bean/beanAopBase.js +3 -0
  6. package/dist/lib/bean/beanAopMethodBase.d.ts +3 -0
  7. package/dist/lib/bean/beanAopMethodBase.js +3 -0
  8. package/dist/lib/bean/beanBase.d.ts +19 -0
  9. package/dist/lib/bean/beanBase.js +36 -0
  10. package/dist/lib/bean/beanBaseSimple.d.ts +14 -0
  11. package/dist/lib/bean/beanBaseSimple.js +27 -0
  12. package/dist/lib/bean/beanContainer.d.ts +40 -0
  13. package/dist/lib/bean/beanContainer.js +578 -0
  14. package/dist/lib/bean/beanSimple.d.ts +7 -0
  15. package/dist/lib/bean/beanSimple.js +9 -0
  16. package/dist/lib/bean/index.d.ts +9 -0
  17. package/dist/lib/bean/index.js +9 -0
  18. package/dist/lib/bean/resource/config/index.d.ts +1 -0
  19. package/dist/lib/bean/resource/config/index.js +1 -0
  20. package/dist/lib/bean/resource/config/type.d.ts +2 -0
  21. package/dist/lib/bean/resource/config/type.js +1 -0
  22. package/dist/lib/bean/resource/constant/index.d.ts +1 -0
  23. package/dist/lib/bean/resource/constant/index.js +1 -0
  24. package/dist/lib/bean/resource/constant/type.d.ts +1 -0
  25. package/dist/lib/bean/resource/constant/type.js +1 -0
  26. package/dist/lib/bean/resource/error/_errorInternal.d.ts +66 -0
  27. package/dist/lib/bean/resource/error/_errorInternal.js +66 -0
  28. package/dist/lib/bean/resource/error/beanScopeError.d.ts +10 -0
  29. package/dist/lib/bean/resource/error/beanScopeError.js +17 -0
  30. package/dist/lib/bean/resource/error/beanScopeErrorImpl.d.ts +13 -0
  31. package/dist/lib/bean/resource/error/beanScopeErrorImpl.js +18 -0
  32. package/dist/lib/bean/resource/error/errorApplication.d.ts +32 -0
  33. package/dist/lib/bean/resource/error/errorApplication.js +1 -0
  34. package/dist/lib/bean/resource/error/errorClass.d.ts +17 -0
  35. package/dist/lib/bean/resource/error/errorClass.js +71 -0
  36. package/dist/lib/bean/resource/error/errorGlobal.d.ts +7 -0
  37. package/dist/lib/bean/resource/error/errorGlobal.js +1 -0
  38. package/dist/lib/bean/resource/error/errorObject.d.ts +4 -0
  39. package/dist/lib/bean/resource/error/errorObject.js +1 -0
  40. package/dist/lib/bean/resource/error/index.d.ts +7 -0
  41. package/dist/lib/bean/resource/error/index.js +7 -0
  42. package/dist/lib/bean/resource/error/type.d.ts +8 -0
  43. package/dist/lib/bean/resource/error/type.js +1 -0
  44. package/dist/lib/bean/resource/index.d.ts +4 -0
  45. package/dist/lib/bean/resource/index.js +4 -0
  46. package/dist/lib/bean/resource/locale/appLocale.d.ts +7 -0
  47. package/dist/lib/bean/resource/locale/appLocale.js +45 -0
  48. package/dist/lib/bean/resource/locale/beanScopeLocale.d.ts +10 -0
  49. package/dist/lib/bean/resource/locale/beanScopeLocale.js +16 -0
  50. package/dist/lib/bean/resource/locale/index.d.ts +3 -0
  51. package/dist/lib/bean/resource/locale/index.js +3 -0
  52. package/dist/lib/bean/resource/locale/type.d.ts +19 -0
  53. package/dist/lib/bean/resource/locale/type.js +1 -0
  54. package/dist/lib/bean/scope/beanScopeBase.d.ts +19 -0
  55. package/dist/lib/bean/scope/beanScopeBase.js +88 -0
  56. package/dist/lib/bean/scope/beanScopeContainer.d.ts +7 -0
  57. package/dist/lib/bean/scope/beanScopeContainer.js +15 -0
  58. package/dist/lib/bean/scope/beanScopeScene.d.ts +11 -0
  59. package/dist/lib/bean/scope/beanScopeScene.js +20 -0
  60. package/dist/lib/bean/scope/beanScopeUtil.d.ts +10 -0
  61. package/dist/lib/bean/scope/beanScopeUtil.js +18 -0
  62. package/dist/lib/bean/scope/index.d.ts +4 -0
  63. package/dist/lib/bean/scope/index.js +4 -0
  64. package/dist/lib/bean/type.d.ts +21 -0
  65. package/dist/lib/bean/type.js +2 -0
  66. package/dist/lib/core/application.d.ts +25 -0
  67. package/dist/lib/core/application.js +78 -0
  68. package/dist/lib/core/asyncLocalStorage.d.ts +8 -0
  69. package/dist/lib/core/asyncLocalStorage.js +23 -0
  70. package/dist/lib/core/config.d.ts +12 -0
  71. package/dist/lib/core/config.js +120 -0
  72. package/dist/lib/core/context.d.ts +2 -0
  73. package/dist/lib/core/context.js +104 -0
  74. package/dist/lib/core/ctxCounter.d.ts +7 -0
  75. package/dist/lib/core/ctxCounter.js +20 -0
  76. package/dist/lib/core/index.d.ts +6 -0
  77. package/dist/lib/core/index.js +6 -0
  78. package/dist/lib/core/locales.d.ts +137 -0
  79. package/dist/lib/core/locales.js +6 -0
  80. package/dist/lib/core/logger.d.ts +22 -0
  81. package/dist/lib/core/logger.js +147 -0
  82. package/dist/lib/core/loggerDefault.d.ts +3 -0
  83. package/dist/lib/core/loggerDefault.js +44 -0
  84. package/dist/lib/core/meta.d.ts +42 -0
  85. package/dist/lib/core/meta.js +123 -0
  86. package/dist/lib/core/metadata.d.ts +15 -0
  87. package/dist/lib/core/metadata.js +80 -0
  88. package/dist/lib/core/resource.d.ts +33 -0
  89. package/dist/lib/core/resource.js +146 -0
  90. package/dist/lib/decorator/class/beanInfo.d.ts +2 -0
  91. package/dist/lib/decorator/class/beanInfo.js +8 -0
  92. package/dist/lib/decorator/class/createBeanDecorator.d.ts +3 -0
  93. package/dist/lib/decorator/class/createBeanDecorator.js +23 -0
  94. package/dist/lib/decorator/class/index.d.ts +4 -0
  95. package/dist/lib/decorator/class/index.js +4 -0
  96. package/dist/lib/decorator/class/proxyDisable.d.ts +1 -0
  97. package/dist/lib/decorator/class/proxyDisable.js +8 -0
  98. package/dist/lib/decorator/class/use.d.ts +7 -0
  99. package/dist/lib/decorator/class/use.js +69 -0
  100. package/dist/lib/decorator/class/util.d.ts +3 -0
  101. package/dist/lib/decorator/class/util.js +9 -0
  102. package/dist/lib/decorator/index.d.ts +3 -0
  103. package/dist/lib/decorator/index.js +3 -0
  104. package/dist/lib/decorator/interface/beanOptions.d.ts +21 -0
  105. package/dist/lib/decorator/interface/beanOptions.js +1 -0
  106. package/dist/lib/decorator/interface/index.d.ts +2 -0
  107. package/dist/lib/decorator/interface/index.js +2 -0
  108. package/dist/lib/decorator/interface/useOptions.d.ts +29 -0
  109. package/dist/lib/decorator/interface/useOptions.js +1 -0
  110. package/dist/lib/decorator/type/constructable.d.ts +1 -0
  111. package/dist/lib/decorator/type/constructable.js +1 -0
  112. package/dist/lib/decorator/type/containerScope.d.ts +1 -0
  113. package/dist/lib/decorator/type/containerScope.js +1 -0
  114. package/dist/lib/decorator/type/function.d.ts +6 -0
  115. package/dist/lib/decorator/type/function.js +1 -0
  116. package/dist/lib/decorator/type/index.d.ts +4 -0
  117. package/dist/lib/decorator/type/index.js +4 -0
  118. package/dist/lib/decorator/type/injectionScope.d.ts +1 -0
  119. package/dist/lib/decorator/type/injectionScope.js +1 -0
  120. package/dist/lib/framework/bootstrap.d.ts +3 -0
  121. package/dist/lib/framework/bootstrap.js +13 -0
  122. package/dist/lib/framework/cluster.d.ts +2 -0
  123. package/dist/lib/framework/cluster.js +32 -0
  124. package/dist/lib/framework/createApp.d.ts +2 -0
  125. package/dist/lib/framework/createApp.js +71 -0
  126. package/dist/lib/framework/index.d.ts +4 -0
  127. package/dist/lib/framework/index.js +4 -0
  128. package/dist/lib/framework/process.d.ts +2 -0
  129. package/dist/lib/framework/process.js +36 -0
  130. package/dist/lib/framework/start.d.ts +10 -0
  131. package/dist/lib/framework/start.js +51 -0
  132. package/dist/lib/framework/useApp.d.ts +4 -0
  133. package/dist/lib/framework/useApp.js +49 -0
  134. package/dist/lib/index.d.ts +6 -0
  135. package/dist/lib/index.js +6 -0
  136. package/dist/lib/locale/en-us.d.ts +68 -0
  137. package/dist/lib/locale/en-us.js +68 -0
  138. package/dist/lib/locale/zh-cn.d.ts +68 -0
  139. package/dist/lib/locale/zh-cn.js +68 -0
  140. package/dist/lib/mappedClass/index.d.ts +3 -0
  141. package/dist/lib/mappedClass/index.js +3 -0
  142. package/dist/lib/mappedClass/mappedClass.d.ts +10 -0
  143. package/dist/lib/mappedClass/mappedClass.js +10 -0
  144. package/dist/lib/mappedClass/mixinClass.d.ts +8 -0
  145. package/dist/lib/mappedClass/mixinClass.js +8 -0
  146. package/dist/lib/mappedClass/omitClass.d.ts +2 -0
  147. package/dist/lib/mappedClass/omitClass.js +14 -0
  148. package/dist/lib/mappedClass/partialClass.d.ts +3 -0
  149. package/dist/lib/mappedClass/partialClass.js +15 -0
  150. package/dist/lib/mappedClass/pickClass.d.ts +2 -0
  151. package/dist/lib/mappedClass/pickClass.js +14 -0
  152. package/dist/lib/mappedClass/type.d.ts +6 -0
  153. package/dist/lib/mappedClass/type.js +1 -0
  154. package/dist/lib/mappedClass/utils.d.ts +8 -0
  155. package/dist/lib/mappedClass/utils.js +76 -0
  156. package/dist/lib/module/config.d.ts +3 -0
  157. package/dist/lib/module/config.js +17 -0
  158. package/dist/lib/module/constant.d.ts +3 -0
  159. package/dist/lib/module/constant.js +16 -0
  160. package/dist/lib/module/errors.d.ts +3 -0
  161. package/dist/lib/module/errors.js +29 -0
  162. package/dist/lib/module/loader.d.ts +4 -0
  163. package/dist/lib/module/loader.js +25 -0
  164. package/dist/lib/module/locales.d.ts +3 -0
  165. package/dist/lib/module/locales.js +48 -0
  166. package/dist/lib/module/module.d.ts +7 -0
  167. package/dist/lib/module/module.js +32 -0
  168. package/dist/lib/utils/index.d.ts +4 -0
  169. package/dist/lib/utils/index.js +4 -0
  170. package/dist/lib/utils/isClass.d.ts +2 -0
  171. package/dist/lib/utils/isClass.js +18 -0
  172. package/dist/lib/utils/retry.d.ts +4 -0
  173. package/dist/lib/utils/retry.js +16 -0
  174. package/dist/lib/utils/util.d.ts +59 -0
  175. package/dist/lib/utils/util.js +298 -0
  176. package/dist/lib/utils/zod-openapi.d.ts +1 -0
  177. package/dist/lib/utils/zod-openapi.js +3 -0
  178. package/dist/types/application/app.d.ts +36 -0
  179. package/dist/types/application/app.js +1 -0
  180. package/dist/types/application/index.d.ts +1 -0
  181. package/dist/types/application/index.js +1 -0
  182. package/dist/types/config/config.d.ts +36 -0
  183. package/dist/types/config/config.js +1 -0
  184. package/dist/types/config/index.d.ts +3 -0
  185. package/dist/types/config/index.js +3 -0
  186. package/dist/types/config/instance.d.ts +7 -0
  187. package/dist/types/config/instance.js +1 -0
  188. package/dist/types/config/locale.d.ts +10 -0
  189. package/dist/types/config/locale.js +3 -0
  190. package/dist/types/context/contextBase.d.ts +24 -0
  191. package/dist/types/context/contextBase.js +1 -0
  192. package/dist/types/context/contextConfig.d.ts +3 -0
  193. package/dist/types/context/contextConfig.js +1 -0
  194. package/dist/types/context/contextOthers.d.ts +4 -0
  195. package/dist/types/context/contextOthers.js +1 -0
  196. package/dist/types/context/contextState.d.ts +7 -0
  197. package/dist/types/context/contextState.js +1 -0
  198. package/dist/types/context/index.d.ts +10 -0
  199. package/dist/types/context/index.js +1 -0
  200. package/dist/types/enum/appEvent.d.ts +4 -0
  201. package/dist/types/enum/appEvent.js +5 -0
  202. package/dist/types/enum/httpStatus.d.ts +68 -0
  203. package/dist/types/enum/httpStatus.js +69 -0
  204. package/dist/types/enum/index.d.ts +2 -0
  205. package/dist/types/enum/index.js +2 -0
  206. package/dist/types/index.d.ts +6 -0
  207. package/dist/types/index.js +6 -0
  208. package/dist/types/interface/bootstrap.d.ts +10 -0
  209. package/dist/types/interface/bootstrap.js +1 -0
  210. package/dist/types/interface/index.d.ts +4 -0
  211. package/dist/types/interface/index.js +4 -0
  212. package/dist/types/interface/logger.d.ts +22 -0
  213. package/dist/types/interface/logger.js +1 -0
  214. package/dist/types/interface/module.d.ts +24 -0
  215. package/dist/types/interface/module.js +1 -0
  216. package/dist/types/interface/monkey.d.ts +31 -0
  217. package/dist/types/interface/monkey.js +1 -0
  218. package/dist/types/utils/cast.d.ts +5 -0
  219. package/dist/types/utils/cast.js +3 -0
  220. package/dist/types/utils/demo.d.ts +4 -0
  221. package/dist/types/utils/demo.js +1 -0
  222. package/dist/types/utils/env.d.ts +25 -0
  223. package/dist/types/utils/env.js +1 -0
  224. package/dist/types/utils/index.d.ts +6 -0
  225. package/dist/types/utils/index.js +6 -0
  226. package/dist/types/utils/omitNever.d.ts +9 -0
  227. package/dist/types/utils/omitNever.js +1 -0
  228. package/dist/types/utils/powerPartial.d.ts +3 -0
  229. package/dist/types/utils/powerPartial.js +1 -0
  230. package/dist/types/utils/type.d.ts +3 -0
  231. package/dist/types/utils/type.js +1 -0
  232. package/package.json +37 -18
  233. package/README.md +0 -1
@@ -0,0 +1,66 @@
1
+ export declare const errorsInternal: {
2
+ 0: string;
3
+ 1: string;
4
+ 100: string;
5
+ 101: string;
6
+ 102: string;
7
+ 200: string;
8
+ 201: string;
9
+ 202: string;
10
+ 203: string;
11
+ 204: string;
12
+ 205: string;
13
+ 206: string;
14
+ 207: string;
15
+ 208: string;
16
+ 226: string;
17
+ 300: string;
18
+ 301: string;
19
+ 302: string;
20
+ 303: string;
21
+ 304: string;
22
+ 305: string;
23
+ 307: string;
24
+ 308: string;
25
+ 400: string;
26
+ 401: string;
27
+ 402: string;
28
+ 403: string;
29
+ 404: string;
30
+ 405: string;
31
+ 406: string;
32
+ 407: string;
33
+ 408: string;
34
+ 409: string;
35
+ 410: string;
36
+ 411: string;
37
+ 412: string;
38
+ 413: string;
39
+ 414: string;
40
+ 415: string;
41
+ 416: string;
42
+ 417: string;
43
+ 418: string;
44
+ 421: string;
45
+ 422: string;
46
+ 423: string;
47
+ 424: string;
48
+ 425: string;
49
+ 426: string;
50
+ 428: string;
51
+ 429: string;
52
+ 431: string;
53
+ 451: string;
54
+ 500: string;
55
+ 501: string;
56
+ 502: string;
57
+ 503: string;
58
+ 504: string;
59
+ 505: string;
60
+ 506: string;
61
+ 507: string;
62
+ 508: string;
63
+ 509: string;
64
+ 510: string;
65
+ 511: string;
66
+ };
@@ -0,0 +1,66 @@
1
+ export const errorsInternal = {
2
+ 0: 'Success',
3
+ 1: 'Unknown Error',
4
+ 100: 'Continue',
5
+ 101: 'Switching Protocols',
6
+ 102: 'Processing',
7
+ 200: 'OK',
8
+ 201: 'Created',
9
+ 202: 'Accepted',
10
+ 203: 'Non-Authoritative Information',
11
+ 204: 'No Content',
12
+ 205: 'Reset Content',
13
+ 206: 'Partial Content',
14
+ 207: 'Multi-Status',
15
+ 208: 'Already Reported',
16
+ 226: 'IM Used',
17
+ 300: 'Multiple Choices',
18
+ 301: 'Moved Permanently',
19
+ 302: 'Found',
20
+ 303: 'See Other',
21
+ 304: 'Not Modified',
22
+ 305: 'Use Proxy',
23
+ 307: 'Temporary Redirect',
24
+ 308: 'Permanent Redirect',
25
+ 400: 'Bad Request',
26
+ 401: 'Unauthorized',
27
+ 402: 'Payment Required',
28
+ 403: 'Forbidden',
29
+ 404: 'Not Found',
30
+ 405: 'Method Not Allowed',
31
+ 406: 'Not Acceptable',
32
+ 407: 'Proxy Authentication Required',
33
+ 408: 'Request Timeout',
34
+ 409: 'Conflict',
35
+ 410: 'Gone',
36
+ 411: 'Length Required',
37
+ 412: 'Precondition Failed',
38
+ 413: 'Payload Too Large',
39
+ 414: 'URI Too Long',
40
+ 415: 'Unsupported Media Type',
41
+ 416: 'Range Not Satisfiable',
42
+ 417: 'Expectation Failed',
43
+ 418: "I'm a teapot",
44
+ 421: 'Misdirected Request',
45
+ 422: 'Unprocessable Entity',
46
+ 423: 'Locked',
47
+ 424: 'Failed Dependency',
48
+ 425: 'Unordered Collection',
49
+ 426: 'Upgrade Required',
50
+ 428: 'Precondition Required',
51
+ 429: 'Too Many Requests',
52
+ 431: 'Request Header Fields Too Large',
53
+ 451: 'Unavailable For Legal Reasons',
54
+ 500: 'Internal Server Error',
55
+ 501: 'Not Implemented',
56
+ 502: 'Bad Gateway',
57
+ 503: 'Service Unavailable',
58
+ 504: 'Gateway Timeout',
59
+ 505: 'HTTP Version Not Supported',
60
+ 506: 'Variant Also Negotiates',
61
+ 507: 'Insufficient Storage',
62
+ 508: 'Loop Detected',
63
+ 509: 'Bandwidth Limit Exceeded',
64
+ 510: 'Not Extended',
65
+ 511: 'Network Authentication Required',
66
+ };
@@ -0,0 +1,10 @@
1
+ import type { IModuleError } from './type.ts';
2
+ import { BeanSimple } from '../../beanSimple.ts';
3
+ declare const BeanModuleScope: unique symbol;
4
+ export declare class BeanScopeError extends BeanSimple {
5
+ private [BeanModuleScope];
6
+ private __instances;
7
+ constructor(moduleScope: any);
8
+ protected __get__(prop: string): IModuleError;
9
+ }
10
+ export {};
@@ -0,0 +1,17 @@
1
+ import { BeanSimple } from "../../beanSimple.js";
2
+ import { BeanScopeErrorImpl } from "./beanScopeErrorImpl.js";
3
+ const BeanModuleScope = Symbol('BeanScopeError#ModuleScope');
4
+ export class BeanScopeError extends BeanSimple {
5
+ [BeanModuleScope];
6
+ __instances = {};
7
+ constructor(moduleScope) {
8
+ super();
9
+ this[BeanModuleScope] = moduleScope;
10
+ }
11
+ __get__(prop) {
12
+ if (!this.__instances[prop]) {
13
+ this.__instances[prop] = this.bean._newBean(BeanScopeErrorImpl, this[BeanModuleScope], prop);
14
+ }
15
+ return this.__instances[prop];
16
+ }
17
+ }
@@ -0,0 +1,13 @@
1
+ import type { IErrorObject } from './errorObject.ts';
2
+ import type { IModuleError } from './type.ts';
3
+ import { BeanSimple } from '../../beanSimple.ts';
4
+ declare const BeanModuleScope: unique symbol;
5
+ declare const BeanErrorCode: unique symbol;
6
+ export declare class BeanScopeErrorImpl extends BeanSimple implements IModuleError {
7
+ private [BeanModuleScope];
8
+ private [BeanErrorCode];
9
+ constructor(moduleScope: any, errorCode: any);
10
+ throw(...args: any[]): never;
11
+ parseFail(...args: any[]): IErrorObject;
12
+ }
13
+ export {};
@@ -0,0 +1,18 @@
1
+ import { BeanSimple } from "../../beanSimple.js";
2
+ const BeanModuleScope = Symbol('BeanScopeError#ModuleScope');
3
+ const BeanErrorCode = Symbol('BeanScopeError#BeanErrorCode');
4
+ export class BeanScopeErrorImpl extends BeanSimple {
5
+ [BeanModuleScope];
6
+ [BeanErrorCode];
7
+ constructor(moduleScope, errorCode) {
8
+ super();
9
+ this[BeanModuleScope] = moduleScope;
10
+ this[BeanErrorCode] = errorCode;
11
+ }
12
+ throw(...args) {
13
+ return this.app.meta.error.throw(this[BeanModuleScope], this[BeanErrorCode], ...args);
14
+ }
15
+ parseFail(...args) {
16
+ return this.app.meta.error.parseFail(this[BeanModuleScope], this[BeanErrorCode], ...args);
17
+ }
18
+ }
@@ -0,0 +1,32 @@
1
+ import type { HttpStatus } from '../../../../types/index.ts';
2
+ import type { IErrorObject } from './errorObject.ts';
3
+ type TypeErrorMethodNames = 'parseFail' | 'parseSuccess';
4
+ interface TypeErrorMethodCommon {
5
+ (code: number | string, ...args: any[]): IErrorObject;
6
+ }
7
+ interface TypeErrorMethodFail {
8
+ (code: number | string, ...args: any[]): void;
9
+ }
10
+ interface TypeErrorMethodThrow {
11
+ (code: HttpStatus | number | string, ...args: any[]): never;
12
+ }
13
+ interface TypeErrorMethodSuccess {
14
+ (data?: any, ...args: any[]): void;
15
+ }
16
+ interface TypeErrorMethodParseCode {
17
+ (codeDefault: number, code: number | string, ...args: any[]): IErrorObject;
18
+ }
19
+ type TypeErrorMethods = {
20
+ success: TypeErrorMethodSuccess;
21
+ } & {
22
+ throw: TypeErrorMethodThrow;
23
+ } & {
24
+ fail: TypeErrorMethodFail;
25
+ } & {
26
+ [property in TypeErrorMethodNames]: TypeErrorMethodCommon;
27
+ } & {
28
+ parseCode: TypeErrorMethodParseCode;
29
+ };
30
+ export interface ApplicationError extends TypeErrorMethods {
31
+ }
32
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ import { BeanSimple } from '../../beanSimple.ts';
2
+ export declare class ErrorClass extends BeanSimple {
3
+ ebErrors: any;
4
+ constructor(ebErrors: any);
5
+ success(module: any, data: any, code: any, ...args: any[]): void;
6
+ fail(module: any, code: any, ...args: any[]): void;
7
+ throw(module: any, code: any, ...args: any[]): never;
8
+ parseFail(module: any, code: any, ...args: any[]): any;
9
+ parseSuccess(module: any, code: any, ...args: any[]): {
10
+ code: any;
11
+ message: string;
12
+ };
13
+ parseCode(module: any, codeDefault: any, code: any, ...args: any[]): {
14
+ code: any;
15
+ message: string;
16
+ };
17
+ }
@@ -0,0 +1,71 @@
1
+ import { HttpStatus } from "../../../../types/enum/httpStatus.js";
2
+ import { BeanSimple } from "../../beanSimple.js";
3
+ export class ErrorClass extends BeanSimple {
4
+ ebErrors;
5
+ constructor(ebErrors) {
6
+ super();
7
+ this.ebErrors = ebErrors;
8
+ }
9
+ // data,code/message,args
10
+ success(module, data, code, ...args) {
11
+ const body = this.parseSuccess(module, code, ...args);
12
+ this.ctx.response.status = 200;
13
+ this.ctx.response.type = 'application/json';
14
+ this.ctx.response.body = { code: 0, message: body.message, data };
15
+ }
16
+ // code/message,args
17
+ fail(module, code, ...args) {
18
+ const body = this.parseFail(module, code, ...args);
19
+ this.ctx.response.status = __calcStatus(body.code);
20
+ this.ctx.response.type = 'application/json';
21
+ this.ctx.response.body = { code: body.code, message: body.message }; // body maybe Error
22
+ }
23
+ // code/message,args
24
+ throw(module, code, ...args) {
25
+ const body = this.parseFail(module, code, ...args);
26
+ const err = new Error();
27
+ err.code = body.code;
28
+ err.message = body.message;
29
+ err.status = __calcStatus(body.code);
30
+ throw err;
31
+ }
32
+ // code/message,args
33
+ parseFail(module, code, ...args) {
34
+ if (typeof code === 'object')
35
+ return code;
36
+ return this.parseCode(module, 500, code, ...args);
37
+ }
38
+ // code/message,args
39
+ parseSuccess(module, code, ...args) {
40
+ return this.parseCode(module, 0, code, ...args);
41
+ }
42
+ // parseCode
43
+ parseCode(module, codeDefault, code, ...args) {
44
+ const ebError = this.ebErrors[module];
45
+ // convert from enum
46
+ if (ebError && code && typeof code === 'string') {
47
+ code = ebError[code];
48
+ }
49
+ if (code === undefined || code === null || code === '') {
50
+ code = codeDefault;
51
+ }
52
+ let message;
53
+ if (typeof code === 'number' && code <= 1000) {
54
+ const httpStatusMessageKey = `HTTPSTATUS_${HttpStatus[code]}`;
55
+ message = this.app.meta.locale.getText(true, undefined, undefined, httpStatusMessageKey, ...args);
56
+ }
57
+ else {
58
+ message = this.app.meta.locale.getText(false, module, undefined, ebError ? ebError[code] : code, ...args);
59
+ }
60
+ code = __combineErrorCode(module, code);
61
+ return { code, message };
62
+ }
63
+ }
64
+ function __combineErrorCode(module, code) {
65
+ if (typeof code !== 'number' || code <= 1000)
66
+ return code;
67
+ return module ? `${module}:${code}` : code;
68
+ }
69
+ function __calcStatus(code) {
70
+ return typeof code !== 'string' && code < 1000 ? code : 500;
71
+ }
@@ -0,0 +1,7 @@
1
+ declare global {
2
+ export interface Error {
3
+ code?: number | string | undefined;
4
+ status?: number | undefined;
5
+ }
6
+ }
7
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export interface IErrorObject {
2
+ code: number | string;
3
+ message: string;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ export * from './beanScopeError.ts';
2
+ export * from './beanScopeErrorImpl.ts';
3
+ export * from './errorApplication.ts';
4
+ export * from './errorClass.ts';
5
+ export * from './errorGlobal.ts';
6
+ export * from './errorObject.ts';
7
+ export * from './type.ts';
@@ -0,0 +1,7 @@
1
+ export * from "./beanScopeError.js";
2
+ export * from "./beanScopeErrorImpl.js";
3
+ export * from "./errorApplication.js";
4
+ export * from "./errorClass.js";
5
+ export * from "./errorGlobal.js";
6
+ export * from "./errorObject.js";
7
+ export * from "./type.js";
@@ -0,0 +1,8 @@
1
+ import type { IErrorObject } from './errorObject.ts';
2
+ export interface IModuleError {
3
+ throw: (...args: any[]) => never;
4
+ parseFail: (...args: any[]) => IErrorObject;
5
+ }
6
+ export type TypeModuleErrors<T> = {
7
+ [prop in string & keyof T]: IModuleError;
8
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export * from './config/index.ts';
2
+ export * from './constant/index.ts';
3
+ export * from './error/index.ts';
4
+ export * from './locale/index.ts';
@@ -0,0 +1,4 @@
1
+ export * from "./config/index.js";
2
+ export * from "./constant/index.js";
3
+ export * from "./error/index.js";
4
+ export * from "./locale/index.js";
@@ -0,0 +1,7 @@
1
+ import type { ILocaleInfos } from './type.ts';
2
+ import { BeanSimple } from '../../beanSimple.ts';
3
+ export declare class AppLocale extends BeanSimple {
4
+ get locale(): keyof ILocaleInfos;
5
+ set locale(value: keyof ILocaleInfos);
6
+ getText<T extends keyof ILocaleInfos>(supportCustomMessage: boolean, moduleScope: string | undefined, locale: T | undefined, key: string, ...args: any[]): string;
7
+ }
@@ -0,0 +1,45 @@
1
+ import * as localeutil from '@cabloy/localeutil';
2
+ import { BeanSimple } from "../../beanSimple.js";
3
+ import { LocaleModuleNameSeparator } from "./type.js";
4
+ export class AppLocale extends BeanSimple {
5
+ get locale() {
6
+ return this.ctx.locale;
7
+ }
8
+ set locale(value) {
9
+ this.ctx.locale = value;
10
+ }
11
+ /** @internal */
12
+ createLocaleText(moduleScope) {
13
+ const self = this;
14
+ const getText = function (text, ...args) {
15
+ return self.getText(false, moduleScope, undefined, text, ...args);
16
+ };
17
+ getText.locale = function (locale, text, ...args) {
18
+ return self.getText(false, moduleScope, locale, text, ...args);
19
+ };
20
+ return getText;
21
+ }
22
+ /** @internal */
23
+ createScopeLocaleText(moduleScope, text) {
24
+ const self = this;
25
+ const getText = function (...args) {
26
+ return self.getText(false, moduleScope, undefined, text, ...args);
27
+ };
28
+ getText.locale = function (locale, ...args) {
29
+ return self.getText(false, moduleScope, locale, text, ...args);
30
+ };
31
+ return getText;
32
+ }
33
+ getText(supportCustomMessage, moduleScope, locale, key, ...args) {
34
+ if (!key)
35
+ return key;
36
+ if (typeof key !== 'string')
37
+ throw new Error(`${key} should be string`);
38
+ const pos = key.indexOf(LocaleModuleNameSeparator);
39
+ if (pos > -1) {
40
+ moduleScope = key.substring(0, pos);
41
+ key = key.substring(pos + LocaleModuleNameSeparator.length);
42
+ }
43
+ return localeutil.getLocaleText(supportCustomMessage, moduleScope ? this.app.meta.localeModules[moduleScope] : undefined, this.app.meta.locales, locale || this.locale, key, ...args);
44
+ }
45
+ }
@@ -0,0 +1,10 @@
1
+ import type { IModuleLocale } from './type.ts';
2
+ import { BeanSimple } from '../../beanSimple.ts';
3
+ declare const BeanModuleScope: unique symbol;
4
+ export declare class BeanScopeLocale extends BeanSimple {
5
+ private [BeanModuleScope];
6
+ private __instances;
7
+ constructor(moduleScope: any);
8
+ protected __get__(prop: string): IModuleLocale;
9
+ }
10
+ export {};
@@ -0,0 +1,16 @@
1
+ import { BeanSimple } from "../../beanSimple.js";
2
+ const BeanModuleScope = Symbol('BeanScopeLocale#ModuleScope');
3
+ export class BeanScopeLocale extends BeanSimple {
4
+ [BeanModuleScope];
5
+ __instances = {};
6
+ constructor(moduleScope) {
7
+ super();
8
+ this[BeanModuleScope] = moduleScope;
9
+ }
10
+ __get__(prop) {
11
+ if (!this.__instances[prop]) {
12
+ this.__instances[prop] = this.app.meta.locale.createScopeLocaleText(this[BeanModuleScope], prop);
13
+ }
14
+ return this.__instances[prop];
15
+ }
16
+ }
@@ -0,0 +1,3 @@
1
+ export * from './appLocale.ts';
2
+ export * from './beanScopeLocale.ts';
3
+ export * from './type.ts';
@@ -0,0 +1,3 @@
1
+ export * from "./appLocale.js";
2
+ export * from "./beanScopeLocale.js";
3
+ export * from "./type.js";
@@ -0,0 +1,19 @@
1
+ export declare const LocaleModuleNameSeparator = "::";
2
+ export interface IModuleLocale {
3
+ (...args: any[]): string;
4
+ locale: <T extends keyof ILocaleInfos>(locale: T, ...args: any[]) => string;
5
+ }
6
+ export interface IModuleLocaleText {
7
+ (text: string, ...args: any[]): string;
8
+ locale: <T extends keyof ILocaleInfos>(locale: T, text: string, ...args: any[]) => string;
9
+ }
10
+ export type TypeModuleLocales<T> = {
11
+ [prop in keyof T]: IModuleLocale;
12
+ };
13
+ export type TypeLocaleBase = 'en-us';
14
+ export interface ILocaleInfo {
15
+ }
16
+ export interface ILocaleInfos {
17
+ 'en-us': ILocaleInfo;
18
+ 'zh-cn': ILocaleInfo;
19
+ }
@@ -0,0 +1 @@
1
+ export const LocaleModuleNameSeparator = '::';
@@ -0,0 +1,19 @@
1
+ import type { IModule } from '@cabloy/module-info';
2
+ import { BeanBaseSimple } from '../beanBaseSimple.ts';
3
+ declare const BeanModuleError: unique symbol;
4
+ declare const BeanModuleLocale: unique symbol;
5
+ declare const BeanModuleUtil: unique symbol;
6
+ declare const BeanModuleModel: unique symbol;
7
+ export declare class BeanScopeBase extends BeanBaseSimple {
8
+ private [BeanModuleError];
9
+ private [BeanModuleLocale];
10
+ private [BeanModuleUtil];
11
+ private [BeanModuleModel];
12
+ private __onionMetaNames;
13
+ private __scenes;
14
+ private __metas;
15
+ get module(): IModule;
16
+ private get onionMetaNames();
17
+ protected __get__(prop: string): any;
18
+ }
19
+ export {};
@@ -0,0 +1,88 @@
1
+ import { getOnionMetasMeta } from '@cabloy/module-info';
2
+ import { BeanBaseSimple, SymbolModuleBelong } from "../beanBaseSimple.js";
3
+ import { BeanScopeError } from "../resource/error/beanScopeError.js";
4
+ import { BeanScopeLocale } from "../resource/locale/beanScopeLocale.js";
5
+ import { BeanScopeScene } from "./beanScopeScene.js";
6
+ import { BeanScopeUtil } from "./beanScopeUtil.js";
7
+ const BeanModuleError = Symbol('BeanScopeBase#BeanModuleError');
8
+ const BeanModuleLocale = Symbol('BeanScopeBase#BeanModuleLocale');
9
+ const BeanModuleUtil = Symbol('BeanScopeBase#BeanModuleUtil');
10
+ const BeanModuleModel = Symbol('BeanScopeBase#BeanModuleModel');
11
+ export class BeanScopeBase extends BeanBaseSimple {
12
+ [BeanModuleError];
13
+ [BeanModuleLocale];
14
+ [BeanModuleUtil];
15
+ [BeanModuleModel];
16
+ __onionMetaNames;
17
+ __scenes = {};
18
+ __metas = {};
19
+ get module() {
20
+ return this.app.meta.modules[this[SymbolModuleBelong]];
21
+ }
22
+ get onionMetaNames() {
23
+ if (!this.__onionMetaNames) {
24
+ this.__onionMetaNames = {};
25
+ const onionMetasMeta = getOnionMetasMeta(this.app.meta.modules);
26
+ for (const metaName in onionMetasMeta) {
27
+ const onionMetaMeta = onionMetasMeta[metaName];
28
+ if (onionMetaMeta.scopeResource) {
29
+ this.__onionMetaNames[metaName] = true;
30
+ }
31
+ }
32
+ }
33
+ return this.__onionMetaNames;
34
+ }
35
+ __get__(prop) {
36
+ const moduleBelong = this[SymbolModuleBelong];
37
+ // error
38
+ if (prop === 'error') {
39
+ if (!this[BeanModuleError]) {
40
+ this[BeanModuleError] = this.bean._newBean(BeanScopeError, moduleBelong);
41
+ }
42
+ return this[BeanModuleError];
43
+ }
44
+ // locale
45
+ if (prop === 'locale') {
46
+ if (!this[BeanModuleLocale]) {
47
+ this[BeanModuleLocale] = this.bean._newBean(BeanScopeLocale, moduleBelong);
48
+ }
49
+ return this[BeanModuleLocale];
50
+ }
51
+ // config
52
+ if (prop === 'config') {
53
+ // app or ctx
54
+ const config = this.ctx ? this.ctx.config : this.app.config;
55
+ return config.modules[moduleBelong];
56
+ }
57
+ // constant
58
+ if (prop === 'constant') {
59
+ return this.app.meta.constants[moduleBelong];
60
+ }
61
+ // util
62
+ if (prop === 'util') {
63
+ if (!this[BeanModuleUtil]) {
64
+ this[BeanModuleUtil] = this.bean._newBean(BeanScopeUtil, moduleBelong);
65
+ }
66
+ return this[BeanModuleUtil];
67
+ }
68
+ // model
69
+ if (prop === 'model') {
70
+ if (!this[BeanModuleModel]) {
71
+ this[BeanModuleModel] = this.bean._newBean('a-database.service.modelResolver', moduleBelong);
72
+ }
73
+ return this[BeanModuleModel];
74
+ }
75
+ // meta
76
+ if (this.onionMetaNames[prop]) {
77
+ if (!this.__metas[prop]) {
78
+ this.__metas[prop] = this.bean._getBean(`${moduleBelong}.meta.${prop}`);
79
+ }
80
+ return this.__metas[prop];
81
+ }
82
+ // scene
83
+ if (!this.__scenes[prop]) {
84
+ this.__scenes[prop] = this.bean._newBean(BeanScopeScene, moduleBelong, prop);
85
+ }
86
+ return this.__scenes[prop];
87
+ }
88
+ }
@@ -0,0 +1,7 @@
1
+ import { BeanSimple } from '../beanSimple.ts';
2
+ export interface IBeanScopeContainer {
3
+ }
4
+ export declare class BeanScopeContainer extends BeanSimple {
5
+ private __instances;
6
+ protected __get__(prop: string): any;
7
+ }
@@ -0,0 +1,15 @@
1
+ import { splitWords } from '@cabloy/word-utils';
2
+ import { BeanSimple } from "../beanSimple.js";
3
+ export class BeanScopeContainer extends BeanSimple {
4
+ __instances = {};
5
+ __get__(prop) {
6
+ if (!this.__instances[prop]) {
7
+ let moduleName = splitWords(prop, true, '-');
8
+ if (!moduleName?.includes('-')) {
9
+ moduleName = `a-${moduleName}`;
10
+ }
11
+ this.__instances[prop] = this.bean.scope(moduleName);
12
+ }
13
+ return this.__instances[prop];
14
+ }
15
+ }
@@ -0,0 +1,11 @@
1
+ import { BeanSimple } from '../beanSimple.ts';
2
+ declare const BeanModuleScope: unique symbol;
3
+ declare const BeanModuleScene: unique symbol;
4
+ export declare class BeanScopeScene extends BeanSimple {
5
+ private [BeanModuleScope];
6
+ private [BeanModuleScene];
7
+ private __instances;
8
+ constructor(moduleScope: any, scene: any);
9
+ protected __get__(prop: string): any;
10
+ }
11
+ export {};