vona 5.0.4 → 5.0.8

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 (328) hide show
  1. package/LICENSE +8 -0
  2. package/README.en-US.md +63 -0
  3. package/README.md +63 -1
  4. package/package.json +6 -76
  5. package/LICENSE.en-US +0 -3
  6. package/README.zh-CN.md +0 -1
  7. package/dist/app/extend/context.d.ts +0 -4
  8. package/dist/app/extend/context.js +0 -152
  9. package/dist/index.d.ts +0 -11
  10. package/dist/index.js +0 -35
  11. package/dist/lib/base/dbTransaction.d.ts +0 -12
  12. package/dist/lib/base/dbTransaction.js +0 -55
  13. package/dist/lib/base/error.d.ts +0 -18
  14. package/dist/lib/base/error.js +0 -70
  15. package/dist/lib/base/model.d.ts +0 -22
  16. package/dist/lib/base/model.js +0 -253
  17. package/dist/lib/bean/_beanLocal_.d.ts +0 -6
  18. package/dist/lib/bean/_beanLocal_.js +0 -16
  19. package/dist/lib/bean/beanBase.d.ts +0 -11
  20. package/dist/lib/bean/beanBase.js +0 -34
  21. package/dist/lib/bean/beanBaseSimple.d.ts +0 -8
  22. package/dist/lib/bean/beanBaseSimple.js +0 -31
  23. package/dist/lib/bean/beanContainer.d.ts +0 -39
  24. package/dist/lib/bean/beanContainer.js +0 -514
  25. package/dist/lib/bean/beanLocal.d.ts +0 -6
  26. package/dist/lib/bean/beanLocal.js +0 -16
  27. package/dist/lib/bean/beanModuleScopeBase.d.ts +0 -10
  28. package/dist/lib/bean/beanModuleScopeBase.js +0 -28
  29. package/dist/lib/bean/beanScopeBase.d.ts +0 -6
  30. package/dist/lib/bean/beanScopeBase.js +0 -19
  31. package/dist/lib/bean/beanScopeScene.d.ts +0 -12
  32. package/dist/lib/bean/beanScopeScene.js +0 -23
  33. package/dist/lib/bean/beanSimple.d.ts +0 -7
  34. package/dist/lib/bean/beanSimple.js +0 -24
  35. package/dist/lib/bean/index.d.ts +0 -8
  36. package/dist/lib/bean/index.js +0 -24
  37. package/dist/lib/bean/resource/config/broadcast.d.ts +0 -7
  38. package/dist/lib/bean/resource/config/broadcast.js +0 -3
  39. package/dist/lib/bean/resource/config/index.d.ts +0 -2
  40. package/dist/lib/bean/resource/config/index.js +0 -18
  41. package/dist/lib/bean/resource/config/middleware.d.ts +0 -9
  42. package/dist/lib/bean/resource/config/middleware.js +0 -3
  43. package/dist/lib/bean/resource/config/startup.d.ts +0 -9
  44. package/dist/lib/bean/resource/config/startup.js +0 -3
  45. package/dist/lib/bean/resource/config/type.d.ts +0 -43
  46. package/dist/lib/bean/resource/config/type.js +0 -3
  47. package/dist/lib/bean/resource/constant/index.d.ts +0 -2
  48. package/dist/lib/bean/resource/constant/index.js +0 -18
  49. package/dist/lib/bean/resource/constant/type.d.ts +0 -2
  50. package/dist/lib/bean/resource/constant/type.js +0 -3
  51. package/dist/lib/bean/resource/entity/entityBase.d.ts +0 -21
  52. package/dist/lib/bean/resource/entity/entityBase.js +0 -20
  53. package/dist/lib/bean/resource/entity/index.d.ts +0 -2
  54. package/dist/lib/bean/resource/entity/index.js +0 -18
  55. package/dist/lib/bean/resource/error/beanScopeError.d.ts +0 -11
  56. package/dist/lib/bean/resource/error/beanScopeError.js +0 -34
  57. package/dist/lib/bean/resource/error/beanScopeErrorImpl.d.ts +0 -14
  58. package/dist/lib/bean/resource/error/beanScopeErrorImpl.js +0 -35
  59. package/dist/lib/bean/resource/error/errorClass.d.ts +0 -18
  60. package/dist/lib/bean/resource/error/errorClass.js +0 -78
  61. package/dist/lib/bean/resource/error/errorContext.d.ts +0 -38
  62. package/dist/lib/bean/resource/error/errorContext.js +0 -3
  63. package/dist/lib/bean/resource/error/errorGlobal.d.ts +0 -8
  64. package/dist/lib/bean/resource/error/errorGlobal.js +0 -3
  65. package/dist/lib/bean/resource/error/errorInternal.d.ts +0 -67
  66. package/dist/lib/bean/resource/error/errorInternal.js +0 -70
  67. package/dist/lib/bean/resource/error/errorObject.d.ts +0 -5
  68. package/dist/lib/bean/resource/error/errorObject.js +0 -3
  69. package/dist/lib/bean/resource/error/index.d.ts +0 -9
  70. package/dist/lib/bean/resource/error/index.js +0 -25
  71. package/dist/lib/bean/resource/error/type.d.ts +0 -9
  72. package/dist/lib/bean/resource/error/type.js +0 -3
  73. package/dist/lib/bean/resource/index.d.ts +0 -8
  74. package/dist/lib/bean/resource/index.js +0 -24
  75. package/dist/lib/bean/resource/locale/beanScopeLocale.d.ts +0 -11
  76. package/dist/lib/bean/resource/locale/beanScopeLocale.js +0 -33
  77. package/dist/lib/bean/resource/locale/beanScopeLocaleImpl.d.ts +0 -3
  78. package/dist/lib/bean/resource/locale/beanScopeLocaleImpl.js +0 -14
  79. package/dist/lib/bean/resource/locale/index.d.ts +0 -4
  80. package/dist/lib/bean/resource/locale/index.js +0 -20
  81. package/dist/lib/bean/resource/locale/localeCtx.d.ts +0 -8
  82. package/dist/lib/bean/resource/locale/localeCtx.js +0 -63
  83. package/dist/lib/bean/resource/locale/type.d.ts +0 -19
  84. package/dist/lib/bean/resource/locale/type.js +0 -3
  85. package/dist/lib/bean/resource/model/beanModelBase.d.ts +0 -24
  86. package/dist/lib/bean/resource/model/beanModelBase.js +0 -165
  87. package/dist/lib/bean/resource/model/beanModelBaseInner.d.ts +0 -29
  88. package/dist/lib/bean/resource/model/beanModelBaseInner.js +0 -86
  89. package/dist/lib/bean/resource/model/index.d.ts +0 -2
  90. package/dist/lib/bean/resource/model/index.js +0 -18
  91. package/dist/lib/bean/resource/model/type.d.ts +0 -12
  92. package/dist/lib/bean/resource/model/type.js +0 -3
  93. package/dist/lib/bean/resource/route/index.d.ts +0 -2
  94. package/dist/lib/bean/resource/route/index.js +0 -18
  95. package/dist/lib/bean/resource/route/type.d.ts +0 -60
  96. package/dist/lib/bean/resource/route/type.js +0 -3
  97. package/dist/lib/bean/scope/beanScopeBase.d.ts +0 -19
  98. package/dist/lib/bean/scope/beanScopeBase.js +0 -104
  99. package/dist/lib/bean/scope/beanScopeBean.d.ts +0 -10
  100. package/dist/lib/bean/scope/beanScopeBean.js +0 -34
  101. package/dist/lib/bean/scope/beanScopeError.d.ts +0 -11
  102. package/dist/lib/bean/scope/beanScopeError.js +0 -21
  103. package/dist/lib/bean/scope/beanScopeErrorImpl.d.ts +0 -14
  104. package/dist/lib/bean/scope/beanScopeErrorImpl.js +0 -21
  105. package/dist/lib/bean/scope/beanScopeScene.d.ts +0 -12
  106. package/dist/lib/bean/scope/beanScopeScene.js +0 -42
  107. package/dist/lib/bean/scope/index.d.ts +0 -5
  108. package/dist/lib/bean/scope/index.js +0 -21
  109. package/dist/lib/bean/scope/type.d.ts +0 -21
  110. package/dist/lib/bean/scope/type.js +0 -3
  111. package/dist/lib/bean/type.d.ts +0 -17
  112. package/dist/lib/bean/type.js +0 -4
  113. package/dist/lib/core/index.d.ts +0 -5
  114. package/dist/lib/core/index.js +0 -21
  115. package/dist/lib/core/meta.d.ts +0 -65
  116. package/dist/lib/core/meta.js +0 -335
  117. package/dist/lib/core/metaCtx.d.ts +0 -16
  118. package/dist/lib/core/metaCtx.js +0 -71
  119. package/dist/lib/core/metadata.d.ts +0 -12
  120. package/dist/lib/core/metadata.js +0 -52
  121. package/dist/lib/core/resource.d.ts +0 -29
  122. package/dist/lib/core/resource.js +0 -172
  123. package/dist/lib/decorator/class/aop.d.ts +0 -3
  124. package/dist/lib/decorator/class/aop.js +0 -23
  125. package/dist/lib/decorator/class/atom.d.ts +0 -3
  126. package/dist/lib/decorator/class/atom.js +0 -22
  127. package/dist/lib/decorator/class/bean.d.ts +0 -3
  128. package/dist/lib/decorator/class/bean.js +0 -23
  129. package/dist/lib/decorator/class/controller.d.ts +0 -3
  130. package/dist/lib/decorator/class/controller.js +0 -22
  131. package/dist/lib/decorator/class/index.d.ts +0 -10
  132. package/dist/lib/decorator/class/index.js +0 -26
  133. package/dist/lib/decorator/class/local.d.ts +0 -3
  134. package/dist/lib/decorator/class/local.js +0 -23
  135. package/dist/lib/decorator/class/model.d.ts +0 -3
  136. package/dist/lib/decorator/class/model.js +0 -28
  137. package/dist/lib/decorator/class/scope.d.ts +0 -2
  138. package/dist/lib/decorator/class/scope.js +0 -20
  139. package/dist/lib/decorator/class/service.d.ts +0 -3
  140. package/dist/lib/decorator/class/service.js +0 -23
  141. package/dist/lib/decorator/class/use.d.ts +0 -5
  142. package/dist/lib/decorator/class/use.js +0 -43
  143. package/dist/lib/decorator/class/util.d.ts +0 -3
  144. package/dist/lib/decorator/class/util.js +0 -10
  145. package/dist/lib/decorator/class/virtual.d.ts +0 -3
  146. package/dist/lib/decorator/class/virtual.js +0 -24
  147. package/dist/lib/decorator/index.d.ts +0 -7
  148. package/dist/lib/decorator/index.js +0 -23
  149. package/dist/lib/decorator/interface/beanOptions.d.ts +0 -55
  150. package/dist/lib/decorator/interface/beanOptions.js +0 -8
  151. package/dist/lib/decorator/interface/useOptions.d.ts +0 -14
  152. package/dist/lib/decorator/interface/useOptions.js +0 -3
  153. package/dist/lib/decorator/type/constructable.d.ts +0 -2
  154. package/dist/lib/decorator/type/constructable.js +0 -3
  155. package/dist/lib/decorator/type/containerScope.d.ts +0 -2
  156. package/dist/lib/decorator/type/containerScope.js +0 -3
  157. package/dist/lib/decorator/type/injectionScope.d.ts +0 -2
  158. package/dist/lib/decorator/type/injectionScope.js +0 -3
  159. package/dist/lib/error/error.d.ts +0 -18
  160. package/dist/lib/error/error.js +0 -71
  161. package/dist/lib/error/errorClass.d.ts +0 -18
  162. package/dist/lib/error/errorClass.js +0 -72
  163. package/dist/lib/error/errorContext.d.ts +0 -38
  164. package/dist/lib/error/errorContext.js +0 -3
  165. package/dist/lib/error/errorGlobal.d.ts +0 -8
  166. package/dist/lib/error/errorGlobal.js +0 -3
  167. package/dist/lib/error/errorInternal.d.ts +0 -67
  168. package/dist/lib/error/errorInternal.js +0 -70
  169. package/dist/lib/error/errorObject.d.ts +0 -5
  170. package/dist/lib/error/errorObject.js +0 -3
  171. package/dist/lib/error/index.d.ts +0 -5
  172. package/dist/lib/error/index.js +0 -21
  173. package/dist/lib/framework/bootstrap.d.ts +0 -9
  174. package/dist/lib/framework/bootstrap.js +0 -35
  175. package/dist/lib/framework/framework.d.ts +0 -11
  176. package/dist/lib/framework/framework.js +0 -28
  177. package/dist/lib/framework/loader.d.ts +0 -21
  178. package/dist/lib/framework/loader.js +0 -57
  179. package/dist/lib/framework/meta.d.ts +0 -2
  180. package/dist/lib/framework/meta.js +0 -23
  181. package/dist/lib/framework/metaClass.d.ts +0 -2
  182. package/dist/lib/framework/metaClass.js +0 -26
  183. package/dist/lib/framework/moduleInfo.d.ts +0 -3
  184. package/dist/lib/framework/moduleInfo.js +0 -67
  185. package/dist/lib/framework/util.d.ts +0 -4
  186. package/dist/lib/framework/util.js +0 -15
  187. package/dist/lib/module/asset/errors.d.ts +0 -68
  188. package/dist/lib/module/asset/errors.js +0 -69
  189. package/dist/lib/module/bean/index.d.ts +0 -4
  190. package/dist/lib/module/bean/index.js +0 -24
  191. package/dist/lib/module/broadcast/broadcast.d.ts +0 -3
  192. package/dist/lib/module/broadcast/broadcast.js +0 -49
  193. package/dist/lib/module/broadcast/broadcastClient.d.ts +0 -24
  194. package/dist/lib/module/broadcast/broadcastClient.js +0 -91
  195. package/dist/lib/module/cluster/agent.d.ts +0 -3
  196. package/dist/lib/module/cluster/agent.js +0 -22
  197. package/dist/lib/module/cluster/app.d.ts +0 -3
  198. package/dist/lib/module/cluster/app.js +0 -26
  199. package/dist/lib/module/config.d.ts +0 -3
  200. package/dist/lib/module/config.js +0 -67
  201. package/dist/lib/module/constant.d.ts +0 -3
  202. package/dist/lib/module/constant.js +0 -46
  203. package/dist/lib/module/contextPatch.d.ts +0 -3
  204. package/dist/lib/module/contextPatch.js +0 -16
  205. package/dist/lib/module/errors.d.ts +0 -3
  206. package/dist/lib/module/errors.js +0 -49
  207. package/dist/lib/module/index.d.ts +0 -2
  208. package/dist/lib/module/index.js +0 -3
  209. package/dist/lib/module/loader.d.ts +0 -5
  210. package/dist/lib/module/loader.js +0 -73
  211. package/dist/lib/module/locales.d.ts +0 -3
  212. package/dist/lib/module/locales.js +0 -132
  213. package/dist/lib/module/messenger.d.ts +0 -25
  214. package/dist/lib/module/messenger.js +0 -128
  215. package/dist/lib/module/middleware.d.ts +0 -3
  216. package/dist/lib/module/middleware.js +0 -113
  217. package/dist/lib/module/model.d.ts +0 -3
  218. package/dist/lib/module/model.js +0 -47
  219. package/dist/lib/module/module.d.ts +0 -12
  220. package/dist/lib/module/module.js +0 -134
  221. package/dist/lib/module/moduleMeta.d.ts +0 -3
  222. package/dist/lib/module/moduleMeta.js +0 -26
  223. package/dist/lib/module/queue/queue.d.ts +0 -3
  224. package/dist/lib/module/queue/queue.js +0 -59
  225. package/dist/lib/module/queue/queueClient.d.ts +0 -26
  226. package/dist/lib/module/queue/queueClient.js +0 -262
  227. package/dist/lib/module/redis.d.ts +0 -11
  228. package/dist/lib/module/redis.js +0 -46
  229. package/dist/lib/module/reload/development.d.ts +0 -3
  230. package/dist/lib/module/reload/development.js +0 -98
  231. package/dist/lib/module/reload/reload.d.ts +0 -16
  232. package/dist/lib/module/reload/reload.js +0 -113
  233. package/dist/lib/module/reload.d.ts +0 -7
  234. package/dist/lib/module/reload.js +0 -17
  235. package/dist/lib/module/route.d.ts +0 -10
  236. package/dist/lib/module/route.js +0 -239
  237. package/dist/lib/module/schedule.d.ts +0 -3
  238. package/dist/lib/module/schedule.js +0 -129
  239. package/dist/lib/module/service.d.ts +0 -3
  240. package/dist/lib/module/service.js +0 -35
  241. package/dist/lib/module/socketio.d.ts +0 -5
  242. package/dist/lib/module/socketio.js +0 -47
  243. package/dist/lib/module/startup.d.ts +0 -2
  244. package/dist/lib/module/startup.js +0 -134
  245. package/dist/lib/module/version/clear.d.ts +0 -2
  246. package/dist/lib/module/version/clear.js +0 -42
  247. package/dist/lib/module/version/ready.d.ts +0 -6
  248. package/dist/lib/module/version/ready.js +0 -106
  249. package/dist/lib/resource/error/errorClass.d.ts +0 -18
  250. package/dist/lib/resource/error/errorClass.js +0 -72
  251. package/dist/lib/resource/error/errorContext.d.ts +0 -38
  252. package/dist/lib/resource/error/errorContext.js +0 -3
  253. package/dist/lib/resource/error/errorGlobal.d.ts +0 -8
  254. package/dist/lib/resource/error/errorGlobal.js +0 -3
  255. package/dist/lib/resource/error/errorInternal.d.ts +0 -67
  256. package/dist/lib/resource/error/errorInternal.js +0 -70
  257. package/dist/lib/resource/error/errorObject.d.ts +0 -5
  258. package/dist/lib/resource/error/errorObject.js +0 -3
  259. package/dist/lib/resource/error/index.d.ts +0 -5
  260. package/dist/lib/resource/error/index.js +0 -21
  261. package/dist/lib/utils/index.d.ts +0 -2
  262. package/dist/lib/utils/index.js +0 -18
  263. package/dist/lib/utils/isClass.d.ts +0 -2
  264. package/dist/lib/utils/isClass.js +0 -20
  265. package/dist/lib/utils/mockUtil.d.ts +0 -11
  266. package/dist/lib/utils/mockUtil.js +0 -34
  267. package/dist/lib/utils/mockUtilCtx.d.ts +0 -10
  268. package/dist/lib/utils/mockUtilCtx.js +0 -35
  269. package/dist/lib/utils/performAction.d.ts +0 -19
  270. package/dist/lib/utils/performAction.js +0 -137
  271. package/dist/lib/utils/util.d.ts +0 -63
  272. package/dist/lib/utils/util.js +0 -445
  273. package/dist/lib/utils/utilCtx.d.ts +0 -34
  274. package/dist/lib/utils/utilCtx.js +0 -137
  275. package/dist/types/application/app.d.ts +0 -19
  276. package/dist/types/application/app.js +0 -28
  277. package/dist/types/application/index.d.ts +0 -2
  278. package/dist/types/application/index.js +0 -18
  279. package/dist/types/config/appInfo.d.ts +0 -4
  280. package/dist/types/config/appInfo.js +0 -3
  281. package/dist/types/config/config.d.ts +0 -10
  282. package/dist/types/config/config.js +0 -3
  283. package/dist/types/config/development.d.ts +0 -4
  284. package/dist/types/config/development.js +0 -3
  285. package/dist/types/config/index.d.ts +0 -4
  286. package/dist/types/config/index.js +0 -20
  287. package/dist/types/config/locale.d.ts +0 -10
  288. package/dist/types/config/locale.js +0 -7
  289. package/dist/types/context/contextBase.d.ts +0 -21
  290. package/dist/types/context/contextBase.js +0 -3
  291. package/dist/types/context/contextConfig.d.ts +0 -4
  292. package/dist/types/context/contextConfig.js +0 -3
  293. package/dist/types/context/contextError.d.ts +0 -25
  294. package/dist/types/context/contextError.js +0 -3
  295. package/dist/types/context/contextLocale.d.ts +0 -9
  296. package/dist/types/context/contextLocale.js +0 -3
  297. package/dist/types/context/contextOthers.d.ts +0 -4
  298. package/dist/types/context/contextOthers.js +0 -3
  299. package/dist/types/context/contextState.d.ts +0 -8
  300. package/dist/types/context/contextState.js +0 -3
  301. package/dist/types/context/index.d.ts +0 -18
  302. package/dist/types/context/index.js +0 -18
  303. package/dist/types/enum/appEvent.d.ts +0 -5
  304. package/dist/types/enum/appEvent.js +0 -9
  305. package/dist/types/enum/index.d.ts +0 -2
  306. package/dist/types/enum/index.js +0 -18
  307. package/dist/types/index.d.ts +0 -7
  308. package/dist/types/index.js +0 -23
  309. package/dist/types/interface/broadcast.d.ts +0 -5
  310. package/dist/types/interface/broadcast.js +0 -3
  311. package/dist/types/interface/error.d.ts +0 -8
  312. package/dist/types/interface/error.js +0 -3
  313. package/dist/types/interface/index.d.ts +0 -6
  314. package/dist/types/interface/index.js +0 -22
  315. package/dist/types/interface/module.d.ts +0 -32
  316. package/dist/types/interface/module.js +0 -18
  317. package/dist/types/interface/monkey.d.ts +0 -25
  318. package/dist/types/interface/monkey.js +0 -3
  319. package/dist/types/interface/queue.d.ts +0 -29
  320. package/dist/types/interface/queue.js +0 -3
  321. package/dist/types/interface/schedule.d.ts +0 -11
  322. package/dist/types/interface/schedule.js +0 -3
  323. package/dist/types/utils/cast.d.ts +0 -6
  324. package/dist/types/utils/cast.js +0 -8
  325. package/dist/types/utils/index.d.ts +0 -3
  326. package/dist/types/utils/index.js +0 -19
  327. package/dist/types/utils/powerPartial.d.ts +0 -4
  328. package/dist/types/utils/powerPartial.js +0 -3
@@ -1,3 +0,0 @@
1
- import { VonaApplication, IModule } from '../../types/index.js';
2
- export default function (app: VonaApplication, modules: Record<string, IModule>): Promise<void>;
3
- //# sourceMappingURL=moduleMeta.d.ts.map
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- async function default_1(app, modules) {
4
- // all metas
5
- app.meta.metas = {};
6
- // load metas
7
- await loadMetas();
8
- async function loadMetas() {
9
- for (const key in modules) {
10
- const module = modules[key];
11
- // module meta
12
- if (typeof module.resource.meta === 'function') {
13
- module.meta = module.resource.meta(app);
14
- }
15
- else {
16
- module.meta = module.resource.meta;
17
- }
18
- if (module.meta) {
19
- await app.meta.util.monkeyModule(app.meta.appMonkey, app.meta.modulesMonkey, 'metaLoaded', module, module.meta);
20
- }
21
- app.meta.metas[module.info.relativeName] = module.meta;
22
- }
23
- }
24
- }
25
- exports.default = default_1;
26
- //# sourceMappingURL=moduleMeta.js.map
@@ -1,3 +0,0 @@
1
- import { VonaApplication } from '../../../types/index.js';
2
- export default function (app: VonaApplication, modules: any): void;
3
- //# sourceMappingURL=queue.d.ts.map
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const queueClient_js_1 = require("./queueClient.js");
4
- function default_1(app, modules) {
5
- // queue
6
- app.meta.queue = app.bean._newBean(queueClient_js_1.QueueClient);
7
- // all queues
8
- const ebQueues = (app.meta.queues = {});
9
- // load queues
10
- loadQueues();
11
- function loadQueues() {
12
- for (const key in modules) {
13
- const module = modules[key];
14
- const config = app.meta.configs[module.info.relativeName];
15
- if (!config.queues)
16
- continue;
17
- for (const queueName in config.queues) {
18
- const queueConfig = config.queues[queueName];
19
- const fullKey = `${module.info.relativeName}:${queueName}`;
20
- // bean
21
- const beanName = queueConfig.bean;
22
- if (!beanName)
23
- throw new Error(`bean not set for queue: ${fullKey}`);
24
- let bean;
25
- if (typeof beanName === 'string') {
26
- bean = {
27
- module: module.info.relativeName,
28
- name: beanName,
29
- };
30
- }
31
- else {
32
- bean = {
33
- module: beanName.module || module.info.relativeName,
34
- name: beanName.name,
35
- };
36
- }
37
- ebQueues[fullKey] = {
38
- module: module.info.relativeName,
39
- name: queueName,
40
- config: queueConfig,
41
- bean,
42
- };
43
- }
44
- }
45
- }
46
- app.meta._loadQueueWorkers = ({ subdomain }) => {
47
- for (const fullKey in ebQueues) {
48
- const queue = ebQueues[fullKey];
49
- const info = {
50
- subdomain,
51
- module: queue.module,
52
- queueName: queue.name,
53
- };
54
- app.meta.queue._ensureWorker(info);
55
- }
56
- };
57
- }
58
- exports.default = default_1;
59
- //# sourceMappingURL=queue.js.map
@@ -1,26 +0,0 @@
1
- import * as bull from 'bullmq';
2
- import { IQueueCallbacks, IQueueQueue, IQueueQueues, IQueueWork, IQueueWorks } from '../../../types/index.js';
3
- import { BeanSimple } from '../../bean/beanSimple.js';
4
- export declare class QueueClient extends BeanSimple {
5
- _workers: IQueueWorks;
6
- _queues: IQueueQueues;
7
- _queueCallbacks: IQueueCallbacks;
8
- push(info: any): void;
9
- pushAsync(info: any): Promise<unknown>;
10
- _clearWorkers(): Promise<void>;
11
- _createWorker(info: any, queueKey: any): IQueueWork;
12
- _createQueue(info: any, queueKey: any): IQueueQueue;
13
- _ensureWorker(info: any): void;
14
- _ensureQueue(info: any): IQueueQueue;
15
- _getQueue(info: any): bull.Queue<any, any, string>;
16
- _callCallback(jobId: any, failedReason: any, data: any): void;
17
- _queuePush(info: any, isAsync: any): Promise<unknown>;
18
- _combineQueueKey({ subdomain, module, queueName }: {
19
- subdomain: any;
20
- module?: string | undefined;
21
- queueName?: string | undefined;
22
- }): string;
23
- _performTask(job: any): Promise<any>;
24
- _getRepeatKey(name: any, repeat: any): string;
25
- }
26
- //# sourceMappingURL=queueClient.d.ts.map
@@ -1,262 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.QueueClient = void 0;
27
- const bull = __importStar(require("bullmq"));
28
- const uuid = __importStar(require("uuid"));
29
- const beanSimple_js_1 = require("../../bean/beanSimple.js");
30
- class QueueClient extends beanSimple_js_1.BeanSimple {
31
- constructor() {
32
- super(...arguments);
33
- Object.defineProperty(this, "_workers", {
34
- enumerable: true,
35
- configurable: true,
36
- writable: true,
37
- value: {}
38
- });
39
- Object.defineProperty(this, "_queues", {
40
- enumerable: true,
41
- configurable: true,
42
- writable: true,
43
- value: {}
44
- });
45
- Object.defineProperty(this, "_queueCallbacks", {
46
- enumerable: true,
47
- configurable: true,
48
- writable: true,
49
- value: {}
50
- });
51
- }
52
- push(info) {
53
- if (!info.dbLevel)
54
- info.dbLevel = 1;
55
- this._queuePush(info, false);
56
- }
57
- // { locale, subdomain, module, queueName,queueNameSub,data }
58
- pushAsync(info) {
59
- if (!info.dbLevel)
60
- throw new Error('should specify the info.dbLevel');
61
- return this._queuePush(info, true);
62
- }
63
- async _clearWorkers() {
64
- for (const queueKey in this._workers) {
65
- const _worker = this._workers[queueKey];
66
- await _worker.worker.close();
67
- }
68
- this._workers = {};
69
- }
70
- _createWorker(info, queueKey) {
71
- const app = this.app;
72
- // worker
73
- const _worker = {};
74
- // prefix
75
- const prefix = `bull_${app.name}:queue`;
76
- // queue config
77
- const queueConfig = app.meta.queues[`${info.module}:${info.queueName}`].config;
78
- // queueConfig.options: queue/worker/job/redlock
79
- const workerOptions = (queueConfig.options && queueConfig.options.worker) || null;
80
- const redlockOptions = (queueConfig.options && queueConfig.options.redlock) || null;
81
- const _redlockOptions = Object.assign({}, app.config.queue.redlock.options, redlockOptions);
82
- // redlock
83
- if (!queueConfig.concurrency) {
84
- _worker.redlock = app.meta.redlock.create(_redlockOptions);
85
- }
86
- // create work
87
- const connectionWorker = app.redis.get('queue').duplicate();
88
- const _workerOptions = Object.assign({}, app.config.queue.worker, workerOptions, {
89
- prefix,
90
- connection: connectionWorker,
91
- });
92
- _worker.worker = new bull.Worker(queueKey, async (job) => {
93
- // concurrency
94
- if (queueConfig.concurrency) {
95
- return await this._performTask(job);
96
- }
97
- // redlock
98
- const _lockResource = `queue:${queueKey}${job.data.queueNameSub ? '#' + job.data.queueNameSub : ''}`;
99
- return await app.meta.util.lock({
100
- // subdomain: job.data.subdomain, // need not
101
- resource: _lockResource,
102
- options: _redlockOptions,
103
- redlock: _worker.redlock,
104
- fn: async () => {
105
- return await this._performTask(job);
106
- },
107
- });
108
- }, _workerOptions);
109
- _worker.worker.on('failed', (_job, err) => {
110
- app.logger.error(err);
111
- });
112
- _worker.worker.on('error', err => {
113
- if (err.message && err.message.indexOf('Missing lock for job') > -1) {
114
- const workerInner = _worker.worker;
115
- if (!workerInner.running) {
116
- _worker.worker.run().catch(error => {
117
- console.error(error);
118
- });
119
- }
120
- }
121
- });
122
- // ok
123
- return _worker;
124
- }
125
- _createQueue(info, queueKey) {
126
- const app = this.app;
127
- // queue
128
- const _queue = {};
129
- // prefix
130
- const prefix = `bull_${app.name}:queue`;
131
- // queue config
132
- const queueConfig = app.meta.queues[`${info.module}:${info.queueName}`].config;
133
- // queueConfig.options: queue/worker/job/limiter
134
- const queueOptions = (queueConfig.options && queueConfig.options.queue) || null;
135
- // create queue
136
- const connectionQueue = app.redis.get('queue').duplicate();
137
- const _queueOptions = Object.assign({}, queueOptions, { prefix, connection: connectionQueue });
138
- _queue.queue = new bull.Queue(queueKey, _queueOptions);
139
- // create events
140
- const connectionEvents = app.redis.get('queue').duplicate();
141
- _queue.queueEvents = new bull.QueueEvents(queueKey, { prefix, connection: connectionEvents });
142
- _queue.queueEvents.on('completed', ({ jobId, returnvalue }) => {
143
- this._callCallback(jobId, null, returnvalue);
144
- });
145
- _queue.queueEvents.on('failed', ({ jobId, failedReason }) => {
146
- this._callCallback(jobId, failedReason, null);
147
- });
148
- // ok
149
- return _queue;
150
- }
151
- _ensureWorker(info) {
152
- // queueKey
153
- const queueKey = this._combineQueueKey(info);
154
- // worker
155
- if (!this._workers[queueKey]) {
156
- this._workers[queueKey] = this._createWorker(info, queueKey);
157
- }
158
- }
159
- _ensureQueue(info) {
160
- // worker
161
- this._ensureWorker(info);
162
- // queueKey
163
- const queueKey = this._combineQueueKey(info);
164
- // queue
165
- if (!this._queues[queueKey]) {
166
- this._queues[queueKey] = this._createQueue(info, queueKey);
167
- }
168
- // ok
169
- return this._queues[queueKey];
170
- }
171
- _getQueue(info) {
172
- return this._ensureQueue(info).queue;
173
- }
174
- _callCallback(jobId, failedReason, data) {
175
- const _callback = this._queueCallbacks[jobId];
176
- if (_callback) {
177
- delete this._queueCallbacks[jobId];
178
- _callback.callback(failedReason ? new Error(failedReason) : null, data);
179
- }
180
- }
181
- _queuePush(info, isAsync) {
182
- const app = this.app;
183
- // queue config
184
- const fullKey = `${info.module}:${info.queueName}`;
185
- const queueBase = app.meta.queues[fullKey];
186
- if (!queueBase)
187
- throw new Error(`queue config not found: ${fullKey}`);
188
- const queueConfig = queueBase.config;
189
- // queueConfig.options: queue/worker/job/limiter
190
- const jobOptions = (queueConfig.options && queueConfig.options.job) || null;
191
- // queue
192
- const queue = this._getQueue(info);
193
- // job
194
- const jobId = (info.jobOptions && info.jobOptions.jobId) || uuid.v4();
195
- const jobName = info.jobName || jobId;
196
- const _jobOptions = Object.assign({}, jobOptions, info.jobOptions);
197
- // not async
198
- if (!isAsync) {
199
- // add job
200
- return queue.add(jobName, info, _jobOptions);
201
- }
202
- // async
203
- return new Promise((resolve, reject) => {
204
- // jobId
205
- if (!_jobOptions.jobId) {
206
- _jobOptions.jobId = jobId;
207
- }
208
- // callback
209
- this._queueCallbacks[jobId] = {
210
- info,
211
- callback: (err, data) => {
212
- if (err)
213
- return reject(err);
214
- resolve(data);
215
- },
216
- };
217
- // add job
218
- return queue.add(jobName, info, _jobOptions);
219
- });
220
- }
221
- _combineQueueKey({ subdomain, module = '', queueName = '' }) {
222
- const app = this.app;
223
- subdomain = app.meta.util.subdomainDesp(subdomain);
224
- return `${subdomain}||${module}||${queueName}`;
225
- }
226
- async _performTask(job) {
227
- const app = this.app;
228
- let { locale, subdomain, module, queueName, queueNameSub, data, ctxParent, dbLevel } = job.data;
229
- // ctxParent
230
- if (!ctxParent)
231
- ctxParent = {};
232
- ctxParent.dbLevel = dbLevel - 1;
233
- // context
234
- const context = { job, data };
235
- if (queueNameSub) {
236
- context.queueNameSub = queueNameSub;
237
- }
238
- // queue config
239
- const queue = app.meta.queues[`${module}:${queueName}`];
240
- // bean
241
- const bean = queue.bean;
242
- // execute
243
- return await app.meta.util.executeBean({
244
- locale,
245
- subdomain,
246
- context,
247
- beanModule: bean.module,
248
- beanFullName: `${bean.module}.queue.${bean.name}`,
249
- transaction: queue.config.transaction,
250
- ctxParent,
251
- });
252
- }
253
- _getRepeatKey(name, repeat) {
254
- const endDate = repeat.endDate ? new Date(repeat.endDate).getTime() : '';
255
- const tz = repeat.tz || '';
256
- const suffix = (repeat.cron ? repeat.cron : String(repeat.every)) || '';
257
- const jobId = repeat.jobId ? repeat.jobId : '';
258
- return `${name}:${jobId}:${endDate}:${tz}:${suffix}`;
259
- }
260
- }
261
- exports.QueueClient = QueueClient;
262
- //# sourceMappingURL=queueClient.js.map
@@ -1,11 +0,0 @@
1
- import Bottleneck from 'bottleneck';
2
- import { VonaApplication } from '../../types/index.js';
3
- import { BeanSimple } from '../bean/beanSimple.js';
4
- export declare class AppLimiter extends BeanSimple {
5
- create(options: any): Bottleneck;
6
- }
7
- export declare class AppRedlock extends BeanSimple {
8
- create(options: any): any;
9
- }
10
- export default function (app: VonaApplication): void;
11
- //# sourceMappingURL=redis.d.ts.map
@@ -1,46 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AppRedlock = exports.AppLimiter = void 0;
7
- const bottleneck_1 = __importDefault(require("bottleneck"));
8
- const redlock_1 = __importDefault(require("redlock"));
9
- const beanSimple_js_1 = require("../bean/beanSimple.js");
10
- class AppLimiter extends beanSimple_js_1.BeanSimple {
11
- // https://github.com/SGrondin/bottleneck#clustering
12
- create(options) {
13
- options = options || {};
14
- // datastore
15
- options.datastore = 'ioredis';
16
- // connection
17
- if (options.connection === undefined) {
18
- options.connection = new bottleneck_1.default.IORedisConnection({
19
- client: this.app.redis.get('limiter'),
20
- });
21
- }
22
- return new bottleneck_1.default(options);
23
- }
24
- }
25
- exports.AppLimiter = AppLimiter;
26
- class AppRedlock extends beanSimple_js_1.BeanSimple {
27
- // https://github.com/mike-marcacci/node-redlock#configuration
28
- create(options) {
29
- // clients
30
- const clients = [];
31
- for (const clientName of this.app.config.queue.redlock.clients) {
32
- const client = this.app.redis.get(clientName) || this.app.redis.get('limiter');
33
- clients.push(client);
34
- }
35
- return new redlock_1.default(clients, options);
36
- }
37
- }
38
- exports.AppRedlock = AppRedlock;
39
- function default_1(app) {
40
- // limiter
41
- app.meta.limiter = app.bean._newBean(AppLimiter);
42
- // redlock
43
- app.meta.redlock = app.bean._newBean(AppRedlock);
44
- }
45
- exports.default = default_1;
46
- //# sourceMappingURL=redis.js.map
@@ -1,3 +0,0 @@
1
- import { VonaApplication } from '../../../types/application/app.js';
2
- export default function (app: VonaApplication): void;
3
- //# sourceMappingURL=development.d.ts.map
@@ -1,98 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const path_1 = __importDefault(require("path"));
7
- const fs_extra_1 = __importDefault(require("fs-extra"));
8
- const chokidar_1 = __importDefault(require("chokidar"));
9
- const debounce_1 = __importDefault(require("debounce"));
10
- const process_helper_1 = require("@cabloy/process-helper");
11
- const cast_js_1 = require("../../../types/utils/cast.js");
12
- function default_1(app) {
13
- let watcherDevelopment = null;
14
- // only in development
15
- if (app.meta.inAgent && app.meta.isLocal) {
16
- _register();
17
- }
18
- // invoked in agent
19
- function _register() {
20
- // watchDirs
21
- const watchDirs = _collectDevelopmentWatchDirs();
22
- // close
23
- if (watcherDevelopment) {
24
- const _watcher = (0, cast_js_1.Cast)(watcherDevelopment);
25
- if (!_watcher.__eb_closed) {
26
- if (_watcher.__eb_ready) {
27
- _watcher.close();
28
- }
29
- else {
30
- _watcher.__eb_closing = true;
31
- }
32
- }
33
- watcherDevelopment = null;
34
- }
35
- // watcher
36
- const _watcher = chokidar_1.default.watch(watchDirs).on('change', (0, debounce_1.default)(info => {
37
- _developmentChange(info);
38
- }, app.config.development.debounce));
39
- // on ready
40
- const _watcher2 = (0, cast_js_1.Cast)(_watcher);
41
- _watcher.once('ready', function () {
42
- _watcher2.__eb_ready = true;
43
- if (_watcher2.__eb_closing) {
44
- _watcher.close();
45
- _watcher2.__eb_closed = true;
46
- }
47
- });
48
- // ok
49
- watcherDevelopment = _watcher;
50
- }
51
- // invoked in agent
52
- function _collectDevelopmentWatchDirs() {
53
- const __pathes = [
54
- 'src/backend/config',
55
- 'src/backend/demo',
56
- 'src/module',
57
- 'src/module-vendor',
58
- 'src/suite',
59
- 'src/suite-vendor',
60
- 'packages-vona/vona',
61
- ];
62
- const cwd = process.cwd();
63
- const watchDirs = [];
64
- for (const __path of __pathes) {
65
- const pathDir = path_1.default.join(cwd, __path);
66
- if (fs_extra_1.default.existsSync(pathDir)) {
67
- watchDirs.push(pathDir);
68
- }
69
- }
70
- return watchDirs;
71
- // const pathSrc = path.resolve(this.app.config.baseDir, '..');
72
- // let watchDirs = eggBornUtils.tools.globbySync(`${pathSrc}/**/backend/src`, { onlyDirectories: true });
73
- // watchDirs = [path.join(pathSrc, 'backend/config')].concat(watchDirs);
74
- // return watchDirs;
75
- }
76
- // invoked in agent
77
- async function _developmentChange(info) {
78
- info = info.replace(/\\/g, '/');
79
- // extname
80
- const extname = path_1.default.extname(info);
81
- if (!['.ts', '.mts'].includes(extname))
82
- return;
83
- // log
84
- app.logger.warn(`[agent:development] reload worker because ${info} changed`);
85
- // tsc
86
- if (extname !== '.mts') {
87
- const __pathes = ['src/backend/config', 'src/backend/demo', 'packages-vona/vona'];
88
- if (__pathes.some(item => info.indexOf(item) > -1)) {
89
- const processHelper = new process_helper_1.ProcessHelper();
90
- await processHelper.tsc();
91
- }
92
- }
93
- // reload
94
- app.meta.reload.now();
95
- }
96
- }
97
- exports.default = default_1;
98
- //# sourceMappingURL=development.js.map
@@ -1,16 +0,0 @@
1
- import { VonaApplication } from '../../../types/application/app.js';
2
- import { BeanSimple } from '../../bean/beanSimple.js';
3
- export declare class AppReload extends BeanSimple {
4
- _freezeCounter: number;
5
- _needReload: boolean;
6
- _reloadDebounceInAgent: any;
7
- now(): void;
8
- freeze(): void;
9
- unfreeze(): void;
10
- initialize(): void;
11
- _reloadInApp({ action }: any): void;
12
- _reloadInAgent({ action }: any): void;
13
- _reloadImmediateInAgent(): void;
14
- }
15
- export default function (app: VonaApplication): void;
16
- //# sourceMappingURL=reload.d.ts.map
@@ -1,113 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AppReload = void 0;
7
- const debounce_1 = __importDefault(require("debounce"));
8
- const cast_js_1 = require("../../../types/utils/cast.js");
9
- const beanSimple_js_1 = require("../../bean/beanSimple.js");
10
- class AppReload extends beanSimple_js_1.BeanSimple {
11
- constructor() {
12
- super(...arguments);
13
- Object.defineProperty(this, "_freezeCounter", {
14
- enumerable: true,
15
- configurable: true,
16
- writable: true,
17
- value: void 0
18
- });
19
- Object.defineProperty(this, "_needReload", {
20
- enumerable: true,
21
- configurable: true,
22
- writable: true,
23
- value: void 0
24
- });
25
- Object.defineProperty(this, "_reloadDebounceInAgent", {
26
- enumerable: true,
27
- configurable: true,
28
- writable: true,
29
- value: void 0
30
- });
31
- }
32
- now() {
33
- if (this.app.meta.inApp) {
34
- this._reloadInApp({ action: 'now' });
35
- }
36
- else {
37
- this._reloadInAgent({ action: 'now' });
38
- }
39
- }
40
- freeze() {
41
- if (this.app.meta.inApp) {
42
- this._reloadInApp({ action: 'freeze' });
43
- }
44
- else {
45
- this._reloadInAgent({ action: 'freeze' });
46
- }
47
- }
48
- unfreeze() {
49
- if (this.app.meta.inApp) {
50
- this._reloadInApp({ action: 'unfreeze' });
51
- }
52
- else {
53
- this._reloadInAgent({ action: 'unfreeze' });
54
- }
55
- }
56
- initialize() {
57
- if (this.app.meta.inAgent) {
58
- //
59
- this._freezeCounter = 0;
60
- this._needReload = false;
61
- this._reloadDebounceInAgent = (0, debounce_1.default)(() => {
62
- if (this._freezeCounter === 0 && this._needReload) {
63
- this._needReload = false;
64
- this._reloadImmediateInAgent();
65
- }
66
- }, 1000);
67
- //
68
- this.app.meta.messenger.addProvider({
69
- name: 'core:reload',
70
- handler: info => {
71
- this._reloadInAgent(info);
72
- },
73
- });
74
- }
75
- }
76
- // invoked in app
77
- _reloadInApp({ action }) {
78
- this.app.meta.messenger.callAgent({ name: 'core:reload', data: { action } });
79
- }
80
- // invoked in agent
81
- _reloadInAgent({ action }) {
82
- if (action === 'now') {
83
- if (this._freezeCounter > 0) {
84
- this._needReload = true;
85
- }
86
- else {
87
- this._reloadImmediateInAgent();
88
- }
89
- }
90
- else if (action === 'freeze') {
91
- this._freezeCounter++;
92
- }
93
- else if (action === 'unfreeze') {
94
- this._freezeCounter--;
95
- if (this._freezeCounter === 0 && this._needReload) {
96
- this._reloadDebounceInAgent();
97
- }
98
- }
99
- }
100
- // invoked in agent
101
- _reloadImmediateInAgent() {
102
- (0, cast_js_1.Cast)(process).send({
103
- to: 'master',
104
- action: 'reload-worker',
105
- });
106
- }
107
- }
108
- exports.AppReload = AppReload;
109
- function default_1(app) {
110
- app.meta.reload.initialize();
111
- }
112
- exports.default = default_1;
113
- //# sourceMappingURL=reload.js.map
@@ -1,7 +0,0 @@
1
- import { BeanSimple } from '../bean/beanSimple.js';
2
- export declare class AppReload extends BeanSimple {
3
- now(): void;
4
- freeze(): void;
5
- unfreeze(): void;
6
- }
7
- //# sourceMappingURL=reload.d.ts.map