vona 1.0.0 → 5.0.7

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 (332) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -1
  3. package/README.zh-CN.md +1 -0
  4. package/dist/app/extend/context.d.ts +4 -0
  5. package/dist/app/extend/context.js +152 -0
  6. package/dist/index.d.ts +11 -0
  7. package/dist/index.js +35 -0
  8. package/dist/lib/base/dbTransaction.d.ts +12 -0
  9. package/dist/lib/base/dbTransaction.js +55 -0
  10. package/dist/lib/base/error.d.ts +18 -0
  11. package/dist/lib/base/error.js +70 -0
  12. package/dist/lib/base/model.d.ts +22 -0
  13. package/dist/lib/base/model.js +253 -0
  14. package/dist/lib/bean/_beanLocal_.d.ts +6 -0
  15. package/dist/lib/bean/_beanLocal_.js +16 -0
  16. package/dist/lib/bean/beanBase.d.ts +11 -0
  17. package/dist/lib/bean/beanBase.js +34 -0
  18. package/dist/lib/bean/beanBaseSimple.d.ts +8 -0
  19. package/dist/lib/bean/beanBaseSimple.js +31 -0
  20. package/dist/lib/bean/beanContainer.d.ts +39 -0
  21. package/dist/lib/bean/beanContainer.js +516 -0
  22. package/dist/lib/bean/beanLocal.d.ts +6 -0
  23. package/dist/lib/bean/beanLocal.js +16 -0
  24. package/dist/lib/bean/beanModuleScopeBase.d.ts +10 -0
  25. package/dist/lib/bean/beanModuleScopeBase.js +28 -0
  26. package/dist/lib/bean/beanScopeBase.d.ts +6 -0
  27. package/dist/lib/bean/beanScopeBase.js +19 -0
  28. package/dist/lib/bean/beanScopeScene.d.ts +12 -0
  29. package/dist/lib/bean/beanScopeScene.js +23 -0
  30. package/dist/lib/bean/beanSimple.d.ts +7 -0
  31. package/dist/lib/bean/beanSimple.js +24 -0
  32. package/dist/lib/bean/index.d.ts +8 -0
  33. package/dist/lib/bean/index.js +24 -0
  34. package/dist/lib/bean/resource/config/broadcast.d.ts +7 -0
  35. package/dist/lib/bean/resource/config/broadcast.js +3 -0
  36. package/dist/lib/bean/resource/config/index.d.ts +2 -0
  37. package/dist/lib/bean/resource/config/index.js +18 -0
  38. package/dist/lib/bean/resource/config/middleware.d.ts +9 -0
  39. package/dist/lib/bean/resource/config/middleware.js +3 -0
  40. package/dist/lib/bean/resource/config/startup.d.ts +9 -0
  41. package/dist/lib/bean/resource/config/startup.js +3 -0
  42. package/dist/lib/bean/resource/config/type.d.ts +43 -0
  43. package/dist/lib/bean/resource/config/type.js +3 -0
  44. package/dist/lib/bean/resource/constant/index.d.ts +2 -0
  45. package/dist/lib/bean/resource/constant/index.js +18 -0
  46. package/dist/lib/bean/resource/constant/type.d.ts +2 -0
  47. package/dist/lib/bean/resource/constant/type.js +3 -0
  48. package/dist/lib/bean/resource/entity/entityBase.d.ts +18 -0
  49. package/dist/lib/bean/resource/entity/entityBase.js +20 -0
  50. package/dist/lib/bean/resource/entity/index.d.ts +2 -0
  51. package/dist/lib/bean/resource/entity/index.js +18 -0
  52. package/dist/lib/bean/resource/entity/type.d.ts +4 -0
  53. package/dist/lib/bean/resource/entity/type.js +3 -0
  54. package/dist/lib/bean/resource/error/beanScopeError.d.ts +11 -0
  55. package/dist/lib/bean/resource/error/beanScopeError.js +34 -0
  56. package/dist/lib/bean/resource/error/beanScopeErrorImpl.d.ts +14 -0
  57. package/dist/lib/bean/resource/error/beanScopeErrorImpl.js +35 -0
  58. package/dist/lib/bean/resource/error/errorClass.d.ts +18 -0
  59. package/dist/lib/bean/resource/error/errorClass.js +78 -0
  60. package/dist/lib/bean/resource/error/errorContext.d.ts +38 -0
  61. package/dist/lib/bean/resource/error/errorContext.js +3 -0
  62. package/dist/lib/bean/resource/error/errorGlobal.d.ts +8 -0
  63. package/dist/lib/bean/resource/error/errorGlobal.js +3 -0
  64. package/dist/lib/bean/resource/error/errorInternal.d.ts +67 -0
  65. package/dist/lib/bean/resource/error/errorInternal.js +70 -0
  66. package/dist/lib/bean/resource/error/errorObject.d.ts +5 -0
  67. package/dist/lib/bean/resource/error/errorObject.js +3 -0
  68. package/dist/lib/bean/resource/error/index.d.ts +9 -0
  69. package/dist/lib/bean/resource/error/index.js +25 -0
  70. package/dist/lib/bean/resource/error/type.d.ts +9 -0
  71. package/dist/lib/bean/resource/error/type.js +3 -0
  72. package/dist/lib/bean/resource/index.d.ts +8 -0
  73. package/dist/lib/bean/resource/index.js +24 -0
  74. package/dist/lib/bean/resource/locale/beanScopeLocale.d.ts +11 -0
  75. package/dist/lib/bean/resource/locale/beanScopeLocale.js +33 -0
  76. package/dist/lib/bean/resource/locale/beanScopeLocaleImpl.d.ts +3 -0
  77. package/dist/lib/bean/resource/locale/beanScopeLocaleImpl.js +14 -0
  78. package/dist/lib/bean/resource/locale/index.d.ts +4 -0
  79. package/dist/lib/bean/resource/locale/index.js +20 -0
  80. package/dist/lib/bean/resource/locale/localeCtx.d.ts +8 -0
  81. package/dist/lib/bean/resource/locale/localeCtx.js +63 -0
  82. package/dist/lib/bean/resource/locale/type.d.ts +19 -0
  83. package/dist/lib/bean/resource/locale/type.js +3 -0
  84. package/dist/lib/bean/resource/model/beanModelBase.d.ts +24 -0
  85. package/dist/lib/bean/resource/model/beanModelBase.js +165 -0
  86. package/dist/lib/bean/resource/model/beanModelBaseInner.d.ts +29 -0
  87. package/dist/lib/bean/resource/model/beanModelBaseInner.js +86 -0
  88. package/dist/lib/bean/resource/model/index.d.ts +2 -0
  89. package/dist/lib/bean/resource/model/index.js +18 -0
  90. package/dist/lib/bean/resource/model/type.d.ts +14 -0
  91. package/dist/lib/bean/resource/model/type.js +3 -0
  92. package/dist/lib/bean/resource/route/index.d.ts +2 -0
  93. package/dist/lib/bean/resource/route/index.js +18 -0
  94. package/dist/lib/bean/resource/route/type.d.ts +60 -0
  95. package/dist/lib/bean/resource/route/type.js +3 -0
  96. package/dist/lib/bean/scope/beanScopeBase.d.ts +19 -0
  97. package/dist/lib/bean/scope/beanScopeBase.js +104 -0
  98. package/dist/lib/bean/scope/beanScopeBean.d.ts +10 -0
  99. package/dist/lib/bean/scope/beanScopeBean.js +34 -0
  100. package/dist/lib/bean/scope/beanScopeError.d.ts +11 -0
  101. package/dist/lib/bean/scope/beanScopeError.js +21 -0
  102. package/dist/lib/bean/scope/beanScopeErrorImpl.d.ts +14 -0
  103. package/dist/lib/bean/scope/beanScopeErrorImpl.js +21 -0
  104. package/dist/lib/bean/scope/beanScopeScene.d.ts +12 -0
  105. package/dist/lib/bean/scope/beanScopeScene.js +42 -0
  106. package/dist/lib/bean/scope/index.d.ts +5 -0
  107. package/dist/lib/bean/scope/index.js +21 -0
  108. package/dist/lib/bean/scope/type.d.ts +21 -0
  109. package/dist/lib/bean/scope/type.js +3 -0
  110. package/dist/lib/bean/type.d.ts +17 -0
  111. package/dist/lib/bean/type.js +4 -0
  112. package/dist/lib/core/index.d.ts +5 -0
  113. package/dist/lib/core/index.js +21 -0
  114. package/dist/lib/core/meta.d.ts +68 -0
  115. package/dist/lib/core/meta.js +345 -0
  116. package/dist/lib/core/metaCtx.d.ts +16 -0
  117. package/dist/lib/core/metaCtx.js +71 -0
  118. package/dist/lib/core/metadata.d.ts +12 -0
  119. package/dist/lib/core/metadata.js +52 -0
  120. package/dist/lib/core/resource.d.ts +29 -0
  121. package/dist/lib/core/resource.js +173 -0
  122. package/dist/lib/decorator/class/aop.d.ts +3 -0
  123. package/dist/lib/decorator/class/aop.js +22 -0
  124. package/dist/lib/decorator/class/atom.d.ts +2 -0
  125. package/dist/lib/decorator/class/atom.js +20 -0
  126. package/dist/lib/decorator/class/bean.d.ts +3 -0
  127. package/dist/lib/decorator/class/bean.js +23 -0
  128. package/dist/lib/decorator/class/controller.d.ts +2 -0
  129. package/dist/lib/decorator/class/controller.js +20 -0
  130. package/dist/lib/decorator/class/entity.d.ts +4 -0
  131. package/dist/lib/decorator/class/entity.js +33 -0
  132. package/dist/lib/decorator/class/index.d.ts +11 -0
  133. package/dist/lib/decorator/class/index.js +27 -0
  134. package/dist/lib/decorator/class/local.d.ts +3 -0
  135. package/dist/lib/decorator/class/local.js +23 -0
  136. package/dist/lib/decorator/class/model.d.ts +3 -0
  137. package/dist/lib/decorator/class/model.js +21 -0
  138. package/dist/lib/decorator/class/scope.d.ts +2 -0
  139. package/dist/lib/decorator/class/scope.js +20 -0
  140. package/dist/lib/decorator/class/service.d.ts +2 -0
  141. package/dist/lib/decorator/class/service.js +20 -0
  142. package/dist/lib/decorator/class/use.d.ts +5 -0
  143. package/dist/lib/decorator/class/use.js +43 -0
  144. package/dist/lib/decorator/class/util.d.ts +3 -0
  145. package/dist/lib/decorator/class/util.js +10 -0
  146. package/dist/lib/decorator/class/virtual.d.ts +3 -0
  147. package/dist/lib/decorator/class/virtual.js +24 -0
  148. package/dist/lib/decorator/index.d.ts +7 -0
  149. package/dist/lib/decorator/index.js +23 -0
  150. package/dist/lib/decorator/interface/beanOptions.d.ts +44 -0
  151. package/dist/lib/decorator/interface/beanOptions.js +8 -0
  152. package/dist/lib/decorator/interface/useOptions.d.ts +14 -0
  153. package/dist/lib/decorator/interface/useOptions.js +3 -0
  154. package/dist/lib/decorator/type/constructable.d.ts +2 -0
  155. package/dist/lib/decorator/type/constructable.js +3 -0
  156. package/dist/lib/decorator/type/containerScope.d.ts +2 -0
  157. package/dist/lib/decorator/type/containerScope.js +3 -0
  158. package/dist/lib/decorator/type/injectionScope.d.ts +2 -0
  159. package/dist/lib/decorator/type/injectionScope.js +3 -0
  160. package/dist/lib/error/error.d.ts +18 -0
  161. package/dist/lib/error/error.js +71 -0
  162. package/dist/lib/error/errorClass.d.ts +18 -0
  163. package/dist/lib/error/errorClass.js +72 -0
  164. package/dist/lib/error/errorContext.d.ts +38 -0
  165. package/dist/lib/error/errorContext.js +3 -0
  166. package/dist/lib/error/errorGlobal.d.ts +8 -0
  167. package/dist/lib/error/errorGlobal.js +3 -0
  168. package/dist/lib/error/errorInternal.d.ts +67 -0
  169. package/dist/lib/error/errorInternal.js +70 -0
  170. package/dist/lib/error/errorObject.d.ts +5 -0
  171. package/dist/lib/error/errorObject.js +3 -0
  172. package/dist/lib/error/index.d.ts +5 -0
  173. package/dist/lib/error/index.js +21 -0
  174. package/dist/lib/framework/bootstrap.d.ts +9 -0
  175. package/dist/lib/framework/bootstrap.js +35 -0
  176. package/dist/lib/framework/framework.d.ts +11 -0
  177. package/dist/lib/framework/framework.js +28 -0
  178. package/dist/lib/framework/loader.d.ts +24 -0
  179. package/dist/lib/framework/loader.js +69 -0
  180. package/dist/lib/framework/meta.d.ts +2 -0
  181. package/dist/lib/framework/meta.js +23 -0
  182. package/dist/lib/framework/metaClass.d.ts +2 -0
  183. package/dist/lib/framework/metaClass.js +26 -0
  184. package/dist/lib/framework/moduleInfo.d.ts +3 -0
  185. package/dist/lib/framework/moduleInfo.js +67 -0
  186. package/dist/lib/framework/util.d.ts +4 -0
  187. package/dist/lib/framework/util.js +15 -0
  188. package/dist/lib/module/asset/errors.d.ts +68 -0
  189. package/dist/lib/module/asset/errors.js +69 -0
  190. package/dist/lib/module/bean/index.d.ts +4 -0
  191. package/dist/lib/module/bean/index.js +24 -0
  192. package/dist/lib/module/broadcast/broadcast.d.ts +3 -0
  193. package/dist/lib/module/broadcast/broadcast.js +49 -0
  194. package/dist/lib/module/broadcast/broadcastClient.d.ts +24 -0
  195. package/dist/lib/module/broadcast/broadcastClient.js +91 -0
  196. package/dist/lib/module/cluster/agent.d.ts +3 -0
  197. package/dist/lib/module/cluster/agent.js +22 -0
  198. package/dist/lib/module/cluster/app.d.ts +3 -0
  199. package/dist/lib/module/cluster/app.js +26 -0
  200. package/dist/lib/module/config.d.ts +3 -0
  201. package/dist/lib/module/config.js +67 -0
  202. package/dist/lib/module/constant.d.ts +3 -0
  203. package/dist/lib/module/constant.js +46 -0
  204. package/dist/lib/module/contextPatch.d.ts +3 -0
  205. package/dist/lib/module/contextPatch.js +16 -0
  206. package/dist/lib/module/errors.d.ts +3 -0
  207. package/dist/lib/module/errors.js +49 -0
  208. package/dist/lib/module/index.d.ts +2 -0
  209. package/dist/lib/module/index.js +3 -0
  210. package/dist/lib/module/loader.d.ts +5 -0
  211. package/dist/lib/module/loader.js +73 -0
  212. package/dist/lib/module/locales.d.ts +3 -0
  213. package/dist/lib/module/locales.js +132 -0
  214. package/dist/lib/module/messenger.d.ts +25 -0
  215. package/dist/lib/module/messenger.js +128 -0
  216. package/dist/lib/module/middleware.d.ts +3 -0
  217. package/dist/lib/module/middleware.js +113 -0
  218. package/dist/lib/module/model.d.ts +3 -0
  219. package/dist/lib/module/model.js +47 -0
  220. package/dist/lib/module/module.d.ts +12 -0
  221. package/dist/lib/module/module.js +135 -0
  222. package/dist/lib/module/moduleMeta.d.ts +3 -0
  223. package/dist/lib/module/moduleMeta.js +23 -0
  224. package/dist/lib/module/queue/queue.d.ts +3 -0
  225. package/dist/lib/module/queue/queue.js +59 -0
  226. package/dist/lib/module/queue/queueClient.d.ts +26 -0
  227. package/dist/lib/module/queue/queueClient.js +262 -0
  228. package/dist/lib/module/redis.d.ts +11 -0
  229. package/dist/lib/module/redis.js +46 -0
  230. package/dist/lib/module/reload/development.d.ts +3 -0
  231. package/dist/lib/module/reload/development.js +98 -0
  232. package/dist/lib/module/reload/reload.d.ts +16 -0
  233. package/dist/lib/module/reload/reload.js +113 -0
  234. package/dist/lib/module/reload.d.ts +7 -0
  235. package/dist/lib/module/reload.js +17 -0
  236. package/dist/lib/module/route.d.ts +10 -0
  237. package/dist/lib/module/route.js +239 -0
  238. package/dist/lib/module/schedule.d.ts +3 -0
  239. package/dist/lib/module/schedule.js +129 -0
  240. package/dist/lib/module/service.d.ts +3 -0
  241. package/dist/lib/module/service.js +35 -0
  242. package/dist/lib/module/socketio.d.ts +5 -0
  243. package/dist/lib/module/socketio.js +47 -0
  244. package/dist/lib/module/startup.d.ts +2 -0
  245. package/dist/lib/module/startup.js +134 -0
  246. package/dist/lib/module/version/clear.d.ts +2 -0
  247. package/dist/lib/module/version/clear.js +42 -0
  248. package/dist/lib/module/version/ready.d.ts +6 -0
  249. package/dist/lib/module/version/ready.js +106 -0
  250. package/dist/lib/resource/error/errorClass.d.ts +18 -0
  251. package/dist/lib/resource/error/errorClass.js +72 -0
  252. package/dist/lib/resource/error/errorContext.d.ts +38 -0
  253. package/dist/lib/resource/error/errorContext.js +3 -0
  254. package/dist/lib/resource/error/errorGlobal.d.ts +8 -0
  255. package/dist/lib/resource/error/errorGlobal.js +3 -0
  256. package/dist/lib/resource/error/errorInternal.d.ts +67 -0
  257. package/dist/lib/resource/error/errorInternal.js +70 -0
  258. package/dist/lib/resource/error/errorObject.d.ts +5 -0
  259. package/dist/lib/resource/error/errorObject.js +3 -0
  260. package/dist/lib/resource/error/index.d.ts +5 -0
  261. package/dist/lib/resource/error/index.js +21 -0
  262. package/dist/lib/utils/index.d.ts +2 -0
  263. package/dist/lib/utils/index.js +18 -0
  264. package/dist/lib/utils/isClass.d.ts +2 -0
  265. package/dist/lib/utils/isClass.js +20 -0
  266. package/dist/lib/utils/mockUtil.d.ts +11 -0
  267. package/dist/lib/utils/mockUtil.js +34 -0
  268. package/dist/lib/utils/mockUtilCtx.d.ts +10 -0
  269. package/dist/lib/utils/mockUtilCtx.js +35 -0
  270. package/dist/lib/utils/performAction.d.ts +19 -0
  271. package/dist/lib/utils/performAction.js +137 -0
  272. package/dist/lib/utils/util.d.ts +63 -0
  273. package/dist/lib/utils/util.js +445 -0
  274. package/dist/lib/utils/utilCtx.d.ts +34 -0
  275. package/dist/lib/utils/utilCtx.js +137 -0
  276. package/dist/types/application/app.d.ts +21 -0
  277. package/dist/types/application/app.js +28 -0
  278. package/dist/types/application/index.d.ts +2 -0
  279. package/dist/types/application/index.js +18 -0
  280. package/dist/types/config/appInfo.d.ts +4 -0
  281. package/dist/types/config/appInfo.js +3 -0
  282. package/dist/types/config/config.d.ts +10 -0
  283. package/dist/types/config/config.js +3 -0
  284. package/dist/types/config/development.d.ts +4 -0
  285. package/dist/types/config/development.js +3 -0
  286. package/dist/types/config/index.d.ts +4 -0
  287. package/dist/types/config/index.js +20 -0
  288. package/dist/types/config/locale.d.ts +10 -0
  289. package/dist/types/config/locale.js +7 -0
  290. package/dist/types/context/contextBase.d.ts +21 -0
  291. package/dist/types/context/contextBase.js +3 -0
  292. package/dist/types/context/contextConfig.d.ts +4 -0
  293. package/dist/types/context/contextConfig.js +3 -0
  294. package/dist/types/context/contextError.d.ts +25 -0
  295. package/dist/types/context/contextError.js +3 -0
  296. package/dist/types/context/contextLocale.d.ts +9 -0
  297. package/dist/types/context/contextLocale.js +3 -0
  298. package/dist/types/context/contextOthers.d.ts +4 -0
  299. package/dist/types/context/contextOthers.js +3 -0
  300. package/dist/types/context/contextState.d.ts +8 -0
  301. package/dist/types/context/contextState.js +3 -0
  302. package/dist/types/context/index.d.ts +18 -0
  303. package/dist/types/context/index.js +18 -0
  304. package/dist/types/enum/appEvent.d.ts +5 -0
  305. package/dist/types/enum/appEvent.js +9 -0
  306. package/dist/types/enum/index.d.ts +2 -0
  307. package/dist/types/enum/index.js +18 -0
  308. package/dist/types/index.d.ts +7 -0
  309. package/dist/types/index.js +23 -0
  310. package/dist/types/interface/broadcast.d.ts +5 -0
  311. package/dist/types/interface/broadcast.js +3 -0
  312. package/dist/types/interface/error.d.ts +8 -0
  313. package/dist/types/interface/error.js +3 -0
  314. package/dist/types/interface/index.d.ts +6 -0
  315. package/dist/types/interface/index.js +22 -0
  316. package/dist/types/interface/module.d.ts +32 -0
  317. package/dist/types/interface/module.js +18 -0
  318. package/dist/types/interface/monkey.d.ts +22 -0
  319. package/dist/types/interface/monkey.js +3 -0
  320. package/dist/types/interface/queue.d.ts +29 -0
  321. package/dist/types/interface/queue.js +3 -0
  322. package/dist/types/interface/schedule.d.ts +11 -0
  323. package/dist/types/interface/schedule.js +3 -0
  324. package/dist/types/utils/cast.d.ts +6 -0
  325. package/dist/types/utils/cast.js +8 -0
  326. package/dist/types/utils/index.d.ts +4 -0
  327. package/dist/types/utils/index.js +20 -0
  328. package/dist/types/utils/powerPartial.d.ts +4 -0
  329. package/dist/types/utils/powerPartial.js +3 -0
  330. package/dist/types/utils/type.d.ts +4 -0
  331. package/dist/types/utils/type.js +3 -0
  332. package/package.json +62 -14
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016-present Vona
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1 +1 @@
1
- # @cabloy/set
1
+ # vona
@@ -0,0 +1 @@
1
+ # vona
@@ -0,0 +1,4 @@
1
+ import { ContextBase } from '../../types/context/contextBase.js';
2
+ declare const context: ContextBase;
3
+ export default context;
4
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1,152 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const raw_body_1 = __importDefault(require("raw-body"));
30
+ const inflation_1 = __importDefault(require("inflation"));
31
+ const ModuleInfo = __importStar(require("@cabloy/module-info"));
32
+ const metaCtx_js_1 = require("../../lib/core/metaCtx.js");
33
+ const cast_js_1 = require("../../types/utils/cast.js");
34
+ const MODULE = Symbol.for('Context#__module');
35
+ const META = Symbol.for('Context#__meta');
36
+ const INNERACCESS = Symbol.for('Context#__inneraccess');
37
+ const SUBDOMAIN = Symbol.for('Context#__subdomain');
38
+ const CTXCALLER = Symbol.for('Context#__ctxcaller');
39
+ const TAILCALLBACKS = Symbol.for('Context#__tailcallbacks');
40
+ const DBLEVEL = Symbol.for('Context#__dblevel');
41
+ const context = {
42
+ get module() {
43
+ const self = (0, cast_js_1.Cast)(this);
44
+ if (this[MODULE] === undefined) {
45
+ const url = self.req.url || '';
46
+ let info;
47
+ if (url.indexOf('/api/static/public/') === 0) {
48
+ info = null;
49
+ }
50
+ else {
51
+ info = ModuleInfo.parseInfo(ModuleInfo.parseName(url));
52
+ }
53
+ if (!info) {
54
+ info = ModuleInfo.parseInfo('a-base');
55
+ }
56
+ if (info) {
57
+ const module = self.app.meta.modules[info.relativeName];
58
+ // should not throw error, because the url maybe not valid
59
+ // if (!module) throw new Error(`module not found: ${info.relativeName}`);
60
+ this[MODULE] = module || null;
61
+ }
62
+ else {
63
+ this[MODULE] = null;
64
+ }
65
+ }
66
+ return this[MODULE];
67
+ },
68
+ get meta() {
69
+ const self = (0, cast_js_1.Cast)(this);
70
+ if (!this[META]) {
71
+ this[META] = self.bean._newBean(metaCtx_js_1.CtxMeta);
72
+ }
73
+ return this[META];
74
+ },
75
+ get innerAccess() {
76
+ return this[INNERACCESS];
77
+ },
78
+ set innerAccess(value) {
79
+ this[INNERACCESS] = value;
80
+ },
81
+ get dbLevel() {
82
+ return this[DBLEVEL] || 0;
83
+ },
84
+ set dbLevel(value) {
85
+ this[DBLEVEL] = value;
86
+ },
87
+ get subdomain() {
88
+ const self = (0, cast_js_1.Cast)(this);
89
+ return typeof this[SUBDOMAIN] === 'undefined' ? self.subdomains.join('.') : this[SUBDOMAIN];
90
+ },
91
+ set subdomain(value) {
92
+ this[SUBDOMAIN] = value;
93
+ },
94
+ get ctxCaller() {
95
+ return this[CTXCALLER];
96
+ },
97
+ set ctxCaller(value) {
98
+ // ctxCaller
99
+ this[CTXCALLER] = value;
100
+ // innerAccess
101
+ this.innerAccess = true;
102
+ // transaction
103
+ (0, cast_js_1.Cast)(this).dbMeta = value.dbMeta;
104
+ // dbLevel
105
+ this.dbLevel = value.dbLevel;
106
+ },
107
+ get cache() {
108
+ const self = (0, cast_js_1.Cast)(this);
109
+ return self.bean._getBean('cache');
110
+ },
111
+ tail(cb) {
112
+ if (!(0, cast_js_1.Cast)(this).dbMeta.master) {
113
+ this.ctxCaller.tail(cb);
114
+ }
115
+ else {
116
+ this.tailCallbacks.push(cb);
117
+ }
118
+ },
119
+ async tailDone() {
120
+ while (true) {
121
+ const cb = this.tailCallbacks.shift();
122
+ if (!cb)
123
+ break;
124
+ await cb();
125
+ // try {
126
+ // await cb();
127
+ // } catch (err) {
128
+ // this.app.logger.error(err);
129
+ // }
130
+ }
131
+ },
132
+ get tailCallbacks() {
133
+ if (!this[TAILCALLBACKS]) {
134
+ this[TAILCALLBACKS] = [];
135
+ }
136
+ return this[TAILCALLBACKS];
137
+ },
138
+ successMore(list, index, size) {
139
+ const self = (0, cast_js_1.Cast)(this);
140
+ self.success({
141
+ list,
142
+ index: index + list.length,
143
+ finished: size === -1 || size === 0 || list.length < size,
144
+ });
145
+ },
146
+ async getPayload(options) {
147
+ const self = (0, cast_js_1.Cast)(this);
148
+ return await (0, raw_body_1.default)((0, inflation_1.default)(self.req), options);
149
+ },
150
+ };
151
+ exports.default = context;
152
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1,11 @@
1
+ import '@cabloy/set';
2
+ import '@cabloy/json5';
3
+ import 'regenerator-runtime';
4
+ export * from './types/index.js';
5
+ export * from './lib/bean/index.js';
6
+ export * from './lib/core/index.js';
7
+ export * from './lib/decorator/index.js';
8
+ export * from './lib/module/index.js';
9
+ export * from './lib/framework/framework.js';
10
+ export * from './lib/utils/index.js';
11
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,35 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ require("@cabloy/set");
21
+ require("@cabloy/json5");
22
+ require("regenerator-runtime");
23
+ const module_alias_1 = __importDefault(require("module-alias"));
24
+ const cluster_reload_1 = __importDefault(require("@cabloy/cluster-reload"));
25
+ const master_js_1 = __importDefault(require("egg-cluster/lib/master.js"));
26
+ module_alias_1.default.addAlias('koa-static-cache', '@cabloy/koa-static-cache');
27
+ master_js_1.default.prototype.onReload = cluster_reload_1.default;
28
+ __exportStar(require("./types/index.js"), exports);
29
+ __exportStar(require("./lib/bean/index.js"), exports);
30
+ __exportStar(require("./lib/core/index.js"), exports);
31
+ __exportStar(require("./lib/decorator/index.js"), exports);
32
+ __exportStar(require("./lib/module/index.js"), exports);
33
+ __exportStar(require("./lib/framework/framework.js"), exports);
34
+ __exportStar(require("./lib/utils/index.js"), exports);
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,12 @@
1
+ import { CabloyContext } from '../../types/index.js';
2
+ export default class DbTransaction {
3
+ _ctx: CabloyContext;
4
+ _transactionCounter: number;
5
+ _connection: any;
6
+ constructor(ctx: any);
7
+ get inTransaction(): boolean;
8
+ get connection(): any;
9
+ set connection(value: any);
10
+ begin(fn: any): Promise<any>;
11
+ }
12
+ //# sourceMappingURL=dbTransaction.d.ts.map
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class DbTransaction {
4
+ constructor(ctx) {
5
+ this._ctx = ctx;
6
+ this._transactionCounter = 0;
7
+ this._connection = null;
8
+ }
9
+ get inTransaction() {
10
+ return this._transactionCounter > 0;
11
+ }
12
+ get connection() {
13
+ return this._connection;
14
+ }
15
+ set connection(value) {
16
+ this._connection = value;
17
+ }
18
+ async begin(fn) {
19
+ let res;
20
+ const db = this._ctx.meta.util.getDbOriginal();
21
+ try {
22
+ if (++this._transactionCounter === 1) {
23
+ this._connection = await db.beginTransaction();
24
+ }
25
+ }
26
+ catch (err) {
27
+ this._transactionCounter--;
28
+ throw err;
29
+ }
30
+ try {
31
+ res = await fn();
32
+ }
33
+ catch (err) {
34
+ if (--this._transactionCounter === 0) {
35
+ await this._connection.rollback();
36
+ this._connection = null;
37
+ }
38
+ throw err;
39
+ }
40
+ try {
41
+ if (--this._transactionCounter === 0) {
42
+ await this._connection.commit();
43
+ this._connection = null;
44
+ }
45
+ }
46
+ catch (err) {
47
+ await this._connection.rollback();
48
+ this._connection = null;
49
+ throw err;
50
+ }
51
+ return res;
52
+ }
53
+ }
54
+ exports.default = DbTransaction;
55
+ //# sourceMappingURL=dbTransaction.js.map
@@ -0,0 +1,18 @@
1
+ import { BeanSimple } from '../bean/beanSimple.js';
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[]): void;
8
+ parseFail(module: any, code: any, ...args: any[]): any;
9
+ parseSuccess(module: any, code: any, ...args: any[]): {
10
+ code: any;
11
+ message: null;
12
+ };
13
+ parseCode(module: any, codeDefault: any, code: any, ...args: any[]): {
14
+ code: any;
15
+ message: null;
16
+ };
17
+ }
18
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorClass = void 0;
4
+ const beanSimple_js_1 = require("../bean/beanSimple.js");
5
+ class ErrorClass extends beanSimple_js_1.BeanSimple {
6
+ constructor(ebErrors) {
7
+ super();
8
+ this.ebErrors = ebErrors;
9
+ }
10
+ // data,code/message,args
11
+ success(module, data, code, ...args) {
12
+ const body = this.parseSuccess(module, code, ...args);
13
+ this.ctx.response.status = 200;
14
+ this.ctx.response.type = 'application/json';
15
+ this.ctx.response.body = { code: 0, message: body.message, data };
16
+ }
17
+ // code/message,args
18
+ fail(module, code, ...args) {
19
+ const body = this.parseFail(module, code, ...args);
20
+ this.ctx.response.status = 200;
21
+ this.ctx.response.type = 'application/json';
22
+ this.ctx.response.body = { code: __combineErrorCode(module, body.code), message: body.message }; // body maybe Error
23
+ }
24
+ // code/message,args
25
+ throw(module, code, ...args) {
26
+ const body = this.parseFail(module, code, ...args);
27
+ const err = new Error();
28
+ err.code = __combineErrorCode(module, body.code);
29
+ err.message = body.message;
30
+ if (body.code < 500)
31
+ err.status = body.code;
32
+ throw err;
33
+ }
34
+ // code/message,args
35
+ parseFail(module, code, ...args) {
36
+ if (typeof code === 'object')
37
+ return code;
38
+ return this.parseCode(module, 1, code, ...args);
39
+ }
40
+ // code/message,args
41
+ parseSuccess(module, code, ...args) {
42
+ return this.parseCode(module, 0, code, ...args);
43
+ }
44
+ // parseCode
45
+ parseCode(module, codeDefault, code, ...args) {
46
+ const ebError = this.ebErrors[module];
47
+ let message = null;
48
+ if (code === undefined || code === null || code === '') {
49
+ code = codeDefault;
50
+ }
51
+ else if (typeof code === 'string') {
52
+ message = this.ctx.text(code, ...args);
53
+ code = codeDefault;
54
+ }
55
+ else {
56
+ message = this.ctx.text(ebError[code], ...args);
57
+ }
58
+ if (!message) {
59
+ message = this.ctx.text(ebError[codeDefault]);
60
+ }
61
+ return { code, message };
62
+ }
63
+ }
64
+ exports.ErrorClass = ErrorClass;
65
+ function __combineErrorCode(module, code) {
66
+ if (code <= 1000)
67
+ return code;
68
+ return module ? `${module}:${code}` : code;
69
+ }
70
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1,22 @@
1
+ import { BeanSimple } from '../bean/beanSimple.js';
2
+ export declare class Model extends BeanSimple {
3
+ table: string;
4
+ options: any;
5
+ constructor({ table, options }: {
6
+ table: any;
7
+ options?: {} | undefined;
8
+ });
9
+ get disableDeleted(): any;
10
+ get disableInstance(): any;
11
+ columns(tableName?: string): Promise<any>;
12
+ columnsClear(tableName: any): any;
13
+ columnsClearAll(): boolean;
14
+ prepareData(item: any): Promise<{}>;
15
+ default(data: any): Promise<any>;
16
+ _coerceTypeOfDefault(column: any): any;
17
+ create(data: any, ...args: any[]): Promise<any>;
18
+ write(data: any, ...args: any[]): Promise<any>;
19
+ _rowCheck(row: any): void;
20
+ _insertRowsCheck(rows: any): void;
21
+ }
22
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1,253 @@
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.Model = void 0;
7
+ const is_type_of_1 = __importDefault(require("is-type-of"));
8
+ const beanSimple_js_1 = require("../bean/beanSimple.js");
9
+ let __columns = {};
10
+ class Model extends beanSimple_js_1.BeanSimple {
11
+ constructor({ table, options = {} }) {
12
+ super();
13
+ this.table = table;
14
+ this.options = options;
15
+ }
16
+ get disableDeleted() {
17
+ return this.options.disableDeleted === undefined
18
+ ? this.app.config.model.disableDeleted
19
+ : this.options.disableDeleted;
20
+ }
21
+ get disableInstance() {
22
+ return this.options.disableInstance === undefined
23
+ ? this.app.config.model.disableInstance
24
+ : this.options.disableInstance;
25
+ }
26
+ async columns(tableName) {
27
+ tableName = tableName || this.table;
28
+ let columns = __columns[tableName];
29
+ if (!columns) {
30
+ const list = await this.ctx.db.query(`show columns from ${this.ctx.db.format('??', tableName)}`);
31
+ columns = __columns[tableName] = {};
32
+ for (const item of list) {
33
+ columns[item.Field] = item;
34
+ }
35
+ }
36
+ return columns;
37
+ }
38
+ columnsClear(tableName) {
39
+ tableName = tableName || this.table;
40
+ const exists = __columns[tableName];
41
+ delete __columns[tableName];
42
+ return exists;
43
+ }
44
+ columnsClearAll() {
45
+ const exists = Object.keys(__columns).length > 0;
46
+ __columns = {};
47
+ return exists;
48
+ }
49
+ async prepareData(item) {
50
+ // columns
51
+ const columns = await this.columns();
52
+ // data
53
+ const data = {};
54
+ for (const columnName in columns) {
55
+ if (item[columnName] !== undefined) {
56
+ data[columnName] = item[columnName];
57
+ }
58
+ }
59
+ return data;
60
+ }
61
+ async default(data) {
62
+ data = data || {};
63
+ // columns
64
+ const columns = await this.columns();
65
+ for (const columnName in columns) {
66
+ const column = columns[columnName];
67
+ data[columnName] = this._coerceTypeOfDefault(column);
68
+ }
69
+ return data;
70
+ }
71
+ _coerceTypeOfDefault(column) {
72
+ // type
73
+ let type = column.Type;
74
+ const pos = type.indexOf('(');
75
+ if (pos > -1)
76
+ type = type.substring(0, pos);
77
+ // default value
78
+ const value = column.Default;
79
+ // coerce
80
+ if (value === null)
81
+ return value;
82
+ if (['timestamp'].includes(type) && value === 'CURRENT_TIMESTAMP')
83
+ return new Date();
84
+ if (['bit', 'bool'].includes(type))
85
+ return Boolean(value);
86
+ if (['float', 'double'].includes(type))
87
+ return Number(value);
88
+ if (['tinyint', 'smallint', 'mediumint', 'int', 'bigint'].includes(type))
89
+ return Number(value);
90
+ // others
91
+ return value;
92
+ }
93
+ async create(data, ...args) {
94
+ const data2 = await this.prepareData(data);
95
+ const res = await this.insert(data2, ...args);
96
+ return res.insertId;
97
+ }
98
+ async write(data, ...args) {
99
+ const data2 = await this.prepareData(data);
100
+ return await this.update(data2, ...args);
101
+ }
102
+ _rowCheck(row) {
103
+ if ((!this.table || !this.disableInstance) && row.iid === undefined) {
104
+ row.iid = this.ctx.instance.id;
105
+ }
106
+ if (this.table && !this.disableDeleted && row.deleted === undefined) {
107
+ row.deleted = 0;
108
+ }
109
+ }
110
+ _insertRowsCheck(rows) {
111
+ if (!Array.isArray(rows))
112
+ return this._rowCheck(rows);
113
+ for (const row of rows) {
114
+ this._rowCheck(row);
115
+ }
116
+ }
117
+ }
118
+ exports.Model = Model;
119
+ [
120
+ 'literals', //
121
+ 'escape',
122
+ 'escapeId',
123
+ 'format',
124
+ '_formatValue',
125
+ '_formatWhere',
126
+ '_where',
127
+ '_orders',
128
+ 'raw',
129
+ 'query',
130
+ 'queryOne',
131
+ '_query',
132
+ '_selectColumns',
133
+ '_limit',
134
+ ].forEach(method => {
135
+ Object.defineProperty(Model.prototype, method, {
136
+ get() {
137
+ if (is_type_of_1.default.function(this.ctx.db[method])) {
138
+ return function (...args) {
139
+ return this.ctx.db[method](...args);
140
+ };
141
+ }
142
+ // property
143
+ return this.ctx.db[method];
144
+ },
145
+ });
146
+ });
147
+ ['insert'].forEach(method => {
148
+ Object.defineProperty(Model.prototype, method, {
149
+ get() {
150
+ return function (...args) {
151
+ if (args.length === 0) {
152
+ args.push({});
153
+ }
154
+ if (this.table) {
155
+ args.unshift(this.table);
156
+ }
157
+ this._insertRowsCheck(args[1]);
158
+ return this.ctx.db[method](...args);
159
+ };
160
+ },
161
+ });
162
+ });
163
+ ['update'].forEach(method => {
164
+ Object.defineProperty(Model.prototype, method, {
165
+ get() {
166
+ return function (...args) {
167
+ const _args = [];
168
+ if (this.table)
169
+ _args.push(this.table);
170
+ for (const arg of args)
171
+ _args.push(arg);
172
+ if (_args[2] && _args[2].where) {
173
+ this._rowCheck(_args[2].where);
174
+ }
175
+ return this.ctx.db[method](..._args);
176
+ };
177
+ },
178
+ });
179
+ });
180
+ ['delete'].forEach(method => {
181
+ Object.defineProperty(Model.prototype, method, {
182
+ get() {
183
+ return function (...args) {
184
+ const _args = [];
185
+ if (this.table)
186
+ _args.push(this.table);
187
+ for (const arg of args)
188
+ _args.push(arg);
189
+ _args[1] = _args[1] || {};
190
+ this._rowCheck(_args[1]);
191
+ if (this.table && !this.disableDeleted) {
192
+ const sql = this.ctx.db.format('UPDATE ?? SET deleted=1 ', [_args[0]]) + this.ctx.db._where(_args[1]);
193
+ return this.ctx.db.query(sql);
194
+ }
195
+ return this.ctx.db[method](..._args);
196
+ };
197
+ },
198
+ });
199
+ });
200
+ ['count'].forEach(method => {
201
+ Object.defineProperty(Model.prototype, method, {
202
+ get() {
203
+ return function (...args) {
204
+ const _args = [];
205
+ if (this.table)
206
+ _args.push(this.table);
207
+ for (const arg of args)
208
+ _args.push(arg);
209
+ _args[1] = _args[1] || {};
210
+ this._rowCheck(_args[1]);
211
+ return this.ctx.db[method](..._args);
212
+ };
213
+ },
214
+ });
215
+ });
216
+ ['get'].forEach(method => {
217
+ Object.defineProperty(Model.prototype, method, {
218
+ get() {
219
+ return function (...args) {
220
+ // console.log(this.constructor.name, arguments);
221
+ const _args = [];
222
+ if (this.table)
223
+ _args.push(this.table);
224
+ for (const arg of args)
225
+ _args.push(arg);
226
+ _args[1] = _args[1] || {};
227
+ // if (_args[1].id) {
228
+ // return this.ctx.db[method].apply(this.ctx.db, _args);
229
+ // }
230
+ this._rowCheck(_args[1]);
231
+ return this.ctx.db[method](..._args);
232
+ };
233
+ },
234
+ });
235
+ });
236
+ ['select'].forEach(method => {
237
+ Object.defineProperty(Model.prototype, method, {
238
+ get() {
239
+ return function (...args) {
240
+ const _args = [];
241
+ if (this.table)
242
+ _args.push(this.table);
243
+ for (const arg of args)
244
+ _args.push(arg);
245
+ _args[1] = _args[1] || {};
246
+ _args[1].where = _args[1].where || {};
247
+ this._rowCheck(_args[1].where);
248
+ return this.ctx.db[method](..._args);
249
+ };
250
+ },
251
+ });
252
+ });
253
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1,6 @@
1
+ import { BeanModuleScopeBase } from './beanModuleScopeBase.js';
2
+ export declare class BeanLocal extends BeanModuleScopeBase {
3
+ protected __get__(prop: any): unknown;
4
+ module(moduleScope: string): typeof this;
5
+ }
6
+ //# sourceMappingURL=_beanLocal_.d.ts.map