@arken/node 1.5.1 → 1.5.3

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 (640) hide show
  1. package/.rush/temp/shrinkwrap-deps.json +39 -82
  2. package/build/api.js.map +1 -0
  3. package/build/array.js.map +1 -0
  4. package/build/browser.js.map +1 -0
  5. package/build/codebase.js.map +1 -0
  6. package/build/config.js.map +1 -0
  7. package/build/db.d.ts +41 -0
  8. package/build/db.js +234 -0
  9. package/build/db.js.map +1 -0
  10. package/build/{util/decoder.js → decoder.js} +3 -3
  11. package/build/decoder.js.map +1 -0
  12. package/build/format.js.map +1 -0
  13. package/build/guid.js.map +1 -0
  14. package/build/index.d.ts +70 -18
  15. package/build/index.js +216 -18
  16. package/build/index.js.map +1 -1
  17. package/build/json.js.map +1 -0
  18. package/build/legacy/data/items.js +1 -1
  19. package/build/legacy/data/items.js.map +1 -1
  20. package/build/log.d.ts +5 -0
  21. package/build/log.js +28 -0
  22. package/build/log.js.map +1 -0
  23. package/build/math.js.map +1 -0
  24. package/build/{util/merkle.js → merkle.js} +1 -1
  25. package/build/merkle.js.map +1 -0
  26. package/build/{util/mongo.js → mongo.js} +1 -1
  27. package/build/mongo.js.map +1 -0
  28. package/build/number.js.map +1 -0
  29. package/build/object.js.map +1 -0
  30. package/build/otp.js.map +1 -0
  31. package/build/package.json +3 -3
  32. package/build/physics.js.map +1 -0
  33. package/build/{util/process.js → process.js} +1 -1
  34. package/build/process.js.map +1 -0
  35. package/build/rpc.js.map +1 -0
  36. package/build/schema.d.ts +42 -51
  37. package/build/seer.js.map +1 -0
  38. package/build/string.js.map +1 -0
  39. package/build/text.js.map +1 -0
  40. package/build/time/date.js.map +1 -0
  41. package/build/time/fancyTimeFormat.js.map +1 -0
  42. package/build/time/index.js.map +1 -0
  43. package/build/time/now.js.map +1 -0
  44. package/build/trpc/socketLink.d.ts +62 -0
  45. package/build/trpc/socketLink.js +261 -0
  46. package/build/trpc/socketLink.js.map +1 -0
  47. package/build/trpc/socketServer.d.ts +15 -0
  48. package/build/trpc/socketServer.js +47 -0
  49. package/build/trpc/socketServer.js.map +1 -0
  50. package/build/tsconfig.tsbuildinfo +1 -1
  51. package/build/util.d.ts +1 -0
  52. package/build/util.js +2 -0
  53. package/build/util.js.map +1 -0
  54. package/build/web3/httpProvider.js.map +1 -0
  55. package/build/{util/web3.js → web3.js} +1 -1
  56. package/build/web3.js.map +1 -0
  57. package/build/{util/websocket.js → websocket.js} +1 -1
  58. package/build/websocket.js.map +1 -0
  59. package/build/zk.js.map +1 -0
  60. package/build/{util/zod.d.ts → zod.d.ts} +2 -0
  61. package/build/{util/zod.js → zod.js} +1 -0
  62. package/build/zod.js.map +1 -0
  63. package/db.ts +76 -1
  64. package/{util/decoder.ts → decoder.ts} +3 -3
  65. package/index.ts +306 -18
  66. package/legacy/data/items.ts +1 -1
  67. package/log.ts +51 -0
  68. package/{util/merkle.ts → merkle.ts} +3 -1
  69. package/{util/mongo.ts → mongo.ts} +1 -1
  70. package/package.json +3 -3
  71. package/{util/process.ts → process.ts} +1 -1
  72. package/trpc/socketLink.ts +2 -2
  73. package/trpc/socketServer.ts +1 -1
  74. package/tsconfig.json +35 -6
  75. package/util.ts +1 -0
  76. package/{util/web3.ts → web3.ts} +2 -1
  77. package/{util/websocket.ts → websocket.ts} +1 -1
  78. package/{util/zod.ts → zod.ts} +2 -0
  79. package/build/modules/area/area.models.d.ts +0 -6
  80. package/build/modules/area/area.models.js +0 -11
  81. package/build/modules/area/area.models.js.map +0 -1
  82. package/build/modules/area/area.router.d.ts +0 -274
  83. package/build/modules/area/area.router.js +0 -59
  84. package/build/modules/area/area.router.js.map +0 -1
  85. package/build/modules/area/area.schema.d.ts +0 -245
  86. package/build/modules/area/area.schema.js +0 -13
  87. package/build/modules/area/area.schema.js.map +0 -1
  88. package/build/modules/area/area.service.d.ts +0 -12
  89. package/build/modules/area/area.service.js +0 -95
  90. package/build/modules/area/area.service.js.map +0 -1
  91. package/build/modules/area/area.types.d.ts +0 -20
  92. package/build/modules/area/area.types.js +0 -2
  93. package/build/modules/area/area.types.js.map +0 -1
  94. package/build/modules/area/index.d.ts +0 -5
  95. package/build/modules/area/index.js +0 -6
  96. package/build/modules/area/index.js.map +0 -1
  97. package/build/modules/asset/asset.models.d.ts +0 -5
  98. package/build/modules/asset/asset.models.js +0 -44
  99. package/build/modules/asset/asset.models.js.map +0 -1
  100. package/build/modules/asset/asset.router.d.ts +0 -189
  101. package/build/modules/asset/asset.router.js +0 -41
  102. package/build/modules/asset/asset.router.js.map +0 -1
  103. package/build/modules/asset/asset.schema.d.ts +0 -207
  104. package/build/modules/asset/asset.schema.js +0 -19
  105. package/build/modules/asset/asset.schema.js.map +0 -1
  106. package/build/modules/asset/asset.service.d.ts +0 -9
  107. package/build/modules/asset/asset.service.js +0 -68
  108. package/build/modules/asset/asset.service.js.map +0 -1
  109. package/build/modules/asset/asset.types.d.ts +0 -17
  110. package/build/modules/asset/asset.types.js +0 -2
  111. package/build/modules/asset/asset.types.js.map +0 -1
  112. package/build/modules/asset/index.d.ts +0 -5
  113. package/build/modules/asset/index.js +0 -6
  114. package/build/modules/asset/index.js.map +0 -1
  115. package/build/modules/chain/chain.models.d.ts +0 -6
  116. package/build/modules/chain/chain.models.js +0 -42
  117. package/build/modules/chain/chain.models.js.map +0 -1
  118. package/build/modules/chain/chain.router.d.ts +0 -364
  119. package/build/modules/chain/chain.router.js +0 -84
  120. package/build/modules/chain/chain.router.js.map +0 -1
  121. package/build/modules/chain/chain.schema.d.ts +0 -323
  122. package/build/modules/chain/chain.schema.js +0 -41
  123. package/build/modules/chain/chain.schema.js.map +0 -1
  124. package/build/modules/chain/chain.service.d.ts +0 -15
  125. package/build/modules/chain/chain.service.js +0 -115
  126. package/build/modules/chain/chain.service.js.map +0 -1
  127. package/build/modules/chain/chain.types.d.ts +0 -20
  128. package/build/modules/chain/chain.types.js +0 -2
  129. package/build/modules/chain/chain.types.js.map +0 -1
  130. package/build/modules/chain/index.d.ts +0 -5
  131. package/build/modules/chain/index.js +0 -6
  132. package/build/modules/chain/index.js.map +0 -1
  133. package/build/modules/character/character.models.d.ts +0 -14
  134. package/build/modules/character/character.models.js +0 -123
  135. package/build/modules/character/character.models.js.map +0 -1
  136. package/build/modules/character/character.router.d.ts +0 -945
  137. package/build/modules/character/character.router.js +0 -246
  138. package/build/modules/character/character.router.js.map +0 -1
  139. package/build/modules/character/character.schema.d.ts +0 -1239
  140. package/build/modules/character/character.schema.js +0 -67
  141. package/build/modules/character/character.schema.js.map +0 -1
  142. package/build/modules/character/character.service.d.ts +0 -73
  143. package/build/modules/character/character.service.js +0 -533
  144. package/build/modules/character/character.service.js.map +0 -1
  145. package/build/modules/character/character.types.d.ts +0 -48
  146. package/build/modules/character/character.types.js +0 -2
  147. package/build/modules/character/character.types.js.map +0 -1
  148. package/build/modules/character/index.d.ts +0 -5
  149. package/build/modules/character/index.js +0 -6
  150. package/build/modules/character/index.js.map +0 -1
  151. package/build/modules/chat/chat.models.d.ts +0 -4
  152. package/build/modules/chat/chat.models.js +0 -35
  153. package/build/modules/chat/chat.models.js.map +0 -1
  154. package/build/modules/chat/chat.router.d.ts +0 -223
  155. package/build/modules/chat/chat.router.js +0 -51
  156. package/build/modules/chat/chat.router.js.map +0 -1
  157. package/build/modules/chat/chat.schema.d.ts +0 -183
  158. package/build/modules/chat/chat.schema.js +0 -29
  159. package/build/modules/chat/chat.schema.js.map +0 -1
  160. package/build/modules/chat/chat.service.d.ts +0 -12
  161. package/build/modules/chat/chat.service.js +0 -85
  162. package/build/modules/chat/chat.service.js.map +0 -1
  163. package/build/modules/chat/chat.types.d.ts +0 -14
  164. package/build/modules/chat/chat.types.js +0 -2
  165. package/build/modules/chat/chat.types.js.map +0 -1
  166. package/build/modules/chat/index.d.ts +0 -5
  167. package/build/modules/chat/index.js +0 -6
  168. package/build/modules/chat/index.js.map +0 -1
  169. package/build/modules/collection/collection.models.d.ts +0 -9
  170. package/build/modules/collection/collection.models.js +0 -69
  171. package/build/modules/collection/collection.models.js.map +0 -1
  172. package/build/modules/collection/collection.router.d.ts +0 -361
  173. package/build/modules/collection/collection.router.js +0 -71
  174. package/build/modules/collection/collection.router.js.map +0 -1
  175. package/build/modules/collection/collection.schema.d.ts +0 -676
  176. package/build/modules/collection/collection.schema.js +0 -70
  177. package/build/modules/collection/collection.schema.js.map +0 -1
  178. package/build/modules/collection/collection.service.d.ts +0 -15
  179. package/build/modules/collection/collection.service.js +0 -117
  180. package/build/modules/collection/collection.service.js.map +0 -1
  181. package/build/modules/collection/collection.types.d.ts +0 -29
  182. package/build/modules/collection/collection.types.js +0 -2
  183. package/build/modules/collection/collection.types.js.map +0 -1
  184. package/build/modules/collection/index.d.ts +0 -5
  185. package/build/modules/collection/index.js +0 -6
  186. package/build/modules/collection/index.js.map +0 -1
  187. package/build/modules/core/core.models.d.ts +0 -123
  188. package/build/modules/core/core.models.js +0 -811
  189. package/build/modules/core/core.models.js.map +0 -1
  190. package/build/modules/core/core.router.d.ts +0 -5297
  191. package/build/modules/core/core.router.js +0 -1372
  192. package/build/modules/core/core.router.js.map +0 -1
  193. package/build/modules/core/core.schema.d.ts +0 -5918
  194. package/build/modules/core/core.schema.js +0 -519
  195. package/build/modules/core/core.schema.js.map +0 -1
  196. package/build/modules/core/core.service.d.ts +0 -270
  197. package/build/modules/core/core.service.js +0 -2515
  198. package/build/modules/core/core.service.js.map +0 -1
  199. package/build/modules/core/core.types.d.ts +0 -251
  200. package/build/modules/core/core.types.js +0 -2
  201. package/build/modules/core/core.types.js.map +0 -1
  202. package/build/modules/core/index.d.ts +0 -5
  203. package/build/modules/core/index.js +0 -6
  204. package/build/modules/core/index.js.map +0 -1
  205. package/build/modules/core/mail/applyPatchesOrMail.d.ts +0 -72
  206. package/build/modules/core/mail/applyPatchesOrMail.js +0 -416
  207. package/build/modules/core/mail/applyPatchesOrMail.js.map +0 -1
  208. package/build/modules/core/mail/mailClaimablePatchesBatch.d.ts +0 -51
  209. package/build/modules/core/mail/mailClaimablePatchesBatch.js +0 -239
  210. package/build/modules/core/mail/mailClaimablePatchesBatch.js.map +0 -1
  211. package/build/modules/game/game.models.d.ts +0 -6
  212. package/build/modules/game/game.models.js +0 -29
  213. package/build/modules/game/game.models.js.map +0 -1
  214. package/build/modules/game/game.router.d.ts +0 -428
  215. package/build/modules/game/game.router.js +0 -90
  216. package/build/modules/game/game.router.js.map +0 -1
  217. package/build/modules/game/game.schema.d.ts +0 -344
  218. package/build/modules/game/game.schema.js +0 -14
  219. package/build/modules/game/game.schema.js.map +0 -1
  220. package/build/modules/game/game.service.d.ts +0 -16
  221. package/build/modules/game/game.service.js +0 -111
  222. package/build/modules/game/game.service.js.map +0 -1
  223. package/build/modules/game/game.types.d.ts +0 -20
  224. package/build/modules/game/game.types.js +0 -2
  225. package/build/modules/game/game.types.js.map +0 -1
  226. package/build/modules/game/index.d.ts +0 -5
  227. package/build/modules/game/index.js +0 -5
  228. package/build/modules/game/index.js.map +0 -1
  229. package/build/modules/interface/index.d.ts +0 -5
  230. package/build/modules/interface/index.js +0 -6
  231. package/build/modules/interface/index.js.map +0 -1
  232. package/build/modules/interface/interface.canonicalize.d.ts +0 -2
  233. package/build/modules/interface/interface.canonicalize.js +0 -241
  234. package/build/modules/interface/interface.canonicalize.js.map +0 -1
  235. package/build/modules/interface/interface.models.d.ts +0 -6
  236. package/build/modules/interface/interface.models.js +0 -30
  237. package/build/modules/interface/interface.models.js.map +0 -1
  238. package/build/modules/interface/interface.router.d.ts +0 -472
  239. package/build/modules/interface/interface.router.js +0 -113
  240. package/build/modules/interface/interface.router.js.map +0 -1
  241. package/build/modules/interface/interface.schema.d.ts +0 -313
  242. package/build/modules/interface/interface.schema.js +0 -36
  243. package/build/modules/interface/interface.schema.js.map +0 -1
  244. package/build/modules/interface/interface.service.d.ts +0 -19
  245. package/build/modules/interface/interface.service.js +0 -168
  246. package/build/modules/interface/interface.service.js.map +0 -1
  247. package/build/modules/interface/interface.types.d.ts +0 -19
  248. package/build/modules/interface/interface.types.js +0 -2
  249. package/build/modules/interface/interface.types.js.map +0 -1
  250. package/build/modules/item/index.d.ts +0 -5
  251. package/build/modules/item/index.js +0 -6
  252. package/build/modules/item/index.js.map +0 -1
  253. package/build/modules/item/item.models.d.ts +0 -16
  254. package/build/modules/item/item.models.js +0 -101
  255. package/build/modules/item/item.models.js.map +0 -1
  256. package/build/modules/item/item.router.d.ts +0 -263
  257. package/build/modules/item/item.router.js +0 -70
  258. package/build/modules/item/item.router.js.map +0 -1
  259. package/build/modules/item/item.schema.d.ts +0 -778
  260. package/build/modules/item/item.schema.js +0 -56
  261. package/build/modules/item/item.schema.js.map +0 -1
  262. package/build/modules/item/item.service.d.ts +0 -13
  263. package/build/modules/item/item.service.js +0 -116
  264. package/build/modules/item/item.service.js.map +0 -1
  265. package/build/modules/item/item.types.d.ts +0 -55
  266. package/build/modules/item/item.types.js +0 -2
  267. package/build/modules/item/item.types.js.map +0 -1
  268. package/build/modules/job/index.d.ts +0 -5
  269. package/build/modules/job/index.js +0 -6
  270. package/build/modules/job/index.js.map +0 -1
  271. package/build/modules/job/job.models.d.ts +0 -3
  272. package/build/modules/job/job.models.js +0 -9
  273. package/build/modules/job/job.models.js.map +0 -1
  274. package/build/modules/job/job.router.d.ts +0 -146
  275. package/build/modules/job/job.router.js +0 -32
  276. package/build/modules/job/job.router.js.map +0 -1
  277. package/build/modules/job/job.schema.d.ts +0 -67
  278. package/build/modules/job/job.schema.js +0 -7
  279. package/build/modules/job/job.schema.js.map +0 -1
  280. package/build/modules/job/job.service.d.ts +0 -7
  281. package/build/modules/job/job.service.js +0 -144
  282. package/build/modules/job/job.service.js.map +0 -1
  283. package/build/modules/job/job.types.d.ts +0 -16
  284. package/build/modules/job/job.types.js +0 -2
  285. package/build/modules/job/job.types.js.map +0 -1
  286. package/build/modules/market/index.d.ts +0 -5
  287. package/build/modules/market/index.js +0 -6
  288. package/build/modules/market/index.js.map +0 -1
  289. package/build/modules/market/market.models.d.ts +0 -14
  290. package/build/modules/market/market.models.js +0 -98
  291. package/build/modules/market/market.models.js.map +0 -1
  292. package/build/modules/market/market.router.d.ts +0 -230
  293. package/build/modules/market/market.router.js +0 -56
  294. package/build/modules/market/market.router.js.map +0 -1
  295. package/build/modules/market/market.schema.d.ts +0 -949
  296. package/build/modules/market/market.schema.js +0 -101
  297. package/build/modules/market/market.schema.js.map +0 -1
  298. package/build/modules/market/market.service.d.ts +0 -12
  299. package/build/modules/market/market.service.js +0 -88
  300. package/build/modules/market/market.service.js.map +0 -1
  301. package/build/modules/market/market.types.d.ts +0 -49
  302. package/build/modules/market/market.types.js +0 -2
  303. package/build/modules/market/market.types.js.map +0 -1
  304. package/build/modules/product/index.d.ts +0 -5
  305. package/build/modules/product/index.js +0 -6
  306. package/build/modules/product/index.js.map +0 -1
  307. package/build/modules/product/product.models.d.ts +0 -4
  308. package/build/modules/product/product.models.js +0 -113
  309. package/build/modules/product/product.models.js.map +0 -1
  310. package/build/modules/product/product.router.d.ts +0 -447
  311. package/build/modules/product/product.router.js +0 -71
  312. package/build/modules/product/product.router.js.map +0 -1
  313. package/build/modules/product/product.schema.d.ts +0 -654
  314. package/build/modules/product/product.schema.js +0 -117
  315. package/build/modules/product/product.schema.js.map +0 -1
  316. package/build/modules/product/product.service.d.ts +0 -15
  317. package/build/modules/product/product.service.js +0 -115
  318. package/build/modules/product/product.service.js.map +0 -1
  319. package/build/modules/product/product.types.d.ts +0 -28
  320. package/build/modules/product/product.types.js +0 -2
  321. package/build/modules/product/product.types.js.map +0 -1
  322. package/build/modules/profile/index.d.ts +0 -5
  323. package/build/modules/profile/index.js +0 -6
  324. package/build/modules/profile/index.js.map +0 -1
  325. package/build/modules/profile/profile.models.d.ts +0 -2
  326. package/build/modules/profile/profile.models.js +0 -165
  327. package/build/modules/profile/profile.models.js.map +0 -1
  328. package/build/modules/profile/profile.router.d.ts +0 -163
  329. package/build/modules/profile/profile.router.js +0 -54
  330. package/build/modules/profile/profile.router.js.map +0 -1
  331. package/build/modules/profile/profile.schema.d.ts +0 -1
  332. package/build/modules/profile/profile.schema.js +0 -138
  333. package/build/modules/profile/profile.schema.js.map +0 -1
  334. package/build/modules/profile/profile.service.d.ts +0 -11
  335. package/build/modules/profile/profile.service.js +0 -120
  336. package/build/modules/profile/profile.service.js.map +0 -1
  337. package/build/modules/profile/profile.types.d.ts +0 -16
  338. package/build/modules/profile/profile.types.js +0 -2
  339. package/build/modules/profile/profile.types.js.map +0 -1
  340. package/build/modules/raffle/index.d.ts +0 -5
  341. package/build/modules/raffle/index.js +0 -6
  342. package/build/modules/raffle/index.js.map +0 -1
  343. package/build/modules/raffle/raffle.models.d.ts +0 -6
  344. package/build/modules/raffle/raffle.models.js +0 -36
  345. package/build/modules/raffle/raffle.models.js.map +0 -1
  346. package/build/modules/raffle/raffle.router.d.ts +0 -299
  347. package/build/modules/raffle/raffle.router.js +0 -71
  348. package/build/modules/raffle/raffle.router.js.map +0 -1
  349. package/build/modules/raffle/raffle.schema.d.ts +0 -265
  350. package/build/modules/raffle/raffle.schema.js +0 -21
  351. package/build/modules/raffle/raffle.schema.js.map +0 -1
  352. package/build/modules/raffle/raffle.service.d.ts +0 -15
  353. package/build/modules/raffle/raffle.service.js +0 -115
  354. package/build/modules/raffle/raffle.service.js.map +0 -1
  355. package/build/modules/raffle/raffle.types.d.ts +0 -25
  356. package/build/modules/raffle/raffle.types.js +0 -2
  357. package/build/modules/raffle/raffle.types.js.map +0 -1
  358. package/build/modules/skill/index.d.ts +0 -5
  359. package/build/modules/skill/index.js +0 -6
  360. package/build/modules/skill/index.js.map +0 -1
  361. package/build/modules/skill/skill.models.d.ts +0 -9
  362. package/build/modules/skill/skill.models.js +0 -9
  363. package/build/modules/skill/skill.models.js.map +0 -1
  364. package/build/modules/skill/skill.router.d.ts +0 -659
  365. package/build/modules/skill/skill.router.js +0 -152
  366. package/build/modules/skill/skill.router.js.map +0 -1
  367. package/build/modules/skill/skill.schema.d.ts +0 -548
  368. package/build/modules/skill/skill.schema.js +0 -26
  369. package/build/modules/skill/skill.schema.js.map +0 -1
  370. package/build/modules/skill/skill.service.d.ts +0 -32
  371. package/build/modules/skill/skill.service.js +0 -279
  372. package/build/modules/skill/skill.service.js.map +0 -1
  373. package/build/modules/skill/skill.types.d.ts +0 -29
  374. package/build/modules/skill/skill.types.js +0 -2
  375. package/build/modules/skill/skill.types.js.map +0 -1
  376. package/build/modules/video/index.d.ts +0 -5
  377. package/build/modules/video/index.js +0 -6
  378. package/build/modules/video/index.js.map +0 -1
  379. package/build/modules/video/video.models.d.ts +0 -7
  380. package/build/modules/video/video.models.js +0 -19
  381. package/build/modules/video/video.models.js.map +0 -1
  382. package/build/modules/video/video.router.d.ts +0 -563
  383. package/build/modules/video/video.router.js +0 -112
  384. package/build/modules/video/video.router.js.map +0 -1
  385. package/build/modules/video/video.schema.d.ts +0 -456
  386. package/build/modules/video/video.schema.js +0 -31
  387. package/build/modules/video/video.schema.js.map +0 -1
  388. package/build/modules/video/video.service.d.ts +0 -23
  389. package/build/modules/video/video.service.js +0 -197
  390. package/build/modules/video/video.service.js.map +0 -1
  391. package/build/modules/video/video.types.d.ts +0 -28
  392. package/build/modules/video/video.types.js +0 -2
  393. package/build/modules/video/video.types.js.map +0 -1
  394. package/build/router.d.ts +0 -10406
  395. package/build/router.js +0 -44
  396. package/build/router.js.map +0 -1
  397. package/build/types.d.ts +0 -164
  398. package/build/types.js +0 -19
  399. package/build/types.js.map +0 -1
  400. package/build/util/api.js.map +0 -1
  401. package/build/util/array.js.map +0 -1
  402. package/build/util/browser.js.map +0 -1
  403. package/build/util/codebase.js.map +0 -1
  404. package/build/util/config.js.map +0 -1
  405. package/build/util/db/index.d.ts +0 -5
  406. package/build/util/db/index.js +0 -7
  407. package/build/util/db/index.js.map +0 -1
  408. package/build/util/db/isPostgresError.d.ts +0 -2
  409. package/build/util/db/isPostgresError.js +0 -8
  410. package/build/util/db/isPostgresError.js.map +0 -1
  411. package/build/util/db/isUniqueConstraintViolation.d.ts +0 -2
  412. package/build/util/db/isUniqueConstraintViolation.js +0 -3
  413. package/build/util/db/isUniqueConstraintViolation.js.map +0 -1
  414. package/build/util/db.d.ts +0 -6
  415. package/build/util/db.js +0 -51
  416. package/build/util/db.js.map +0 -1
  417. package/build/util/decoder.js.map +0 -1
  418. package/build/util/decoder.test.d.ts +0 -1
  419. package/build/util/decoder.test.js +0 -7
  420. package/build/util/decoder.test.js.map +0 -1
  421. package/build/util/format.js.map +0 -1
  422. package/build/util/guid.js.map +0 -1
  423. package/build/util/index.d.ts +0 -74
  424. package/build/util/index.js +0 -239
  425. package/build/util/index.js.map +0 -1
  426. package/build/util/json.js.map +0 -1
  427. package/build/util/log.d.ts +0 -1
  428. package/build/util/log.js +0 -6
  429. package/build/util/log.js.map +0 -1
  430. package/build/util/math.js.map +0 -1
  431. package/build/util/merkle.js.map +0 -1
  432. package/build/util/mongo.js.map +0 -1
  433. package/build/util/number.js.map +0 -1
  434. package/build/util/object.js.map +0 -1
  435. package/build/util/otp.js.map +0 -1
  436. package/build/util/physics.js.map +0 -1
  437. package/build/util/process.js.map +0 -1
  438. package/build/util/rpc.js.map +0 -1
  439. package/build/util/seer.js.map +0 -1
  440. package/build/util/string.js.map +0 -1
  441. package/build/util/text.js.map +0 -1
  442. package/build/util/time/date.js.map +0 -1
  443. package/build/util/time/fancyTimeFormat.js.map +0 -1
  444. package/build/util/time/index.js.map +0 -1
  445. package/build/util/time/now.js.map +0 -1
  446. package/build/util/web3/httpProvider.js.map +0 -1
  447. package/build/util/web3.js.map +0 -1
  448. package/build/util/websocket.js.map +0 -1
  449. package/build/util/zk.js.map +0 -1
  450. package/build/util/zod.js.map +0 -1
  451. package/modules/area/area.models.ts +0 -15
  452. package/modules/area/area.router.ts +0 -74
  453. package/modules/area/area.schema.ts +0 -22
  454. package/modules/area/area.service.ts +0 -124
  455. package/modules/area/area.types.ts +0 -26
  456. package/modules/area/index.ts +0 -5
  457. package/modules/asset/asset.models.ts +0 -59
  458. package/modules/asset/asset.router.ts +0 -55
  459. package/modules/asset/asset.schema.ts +0 -27
  460. package/modules/asset/asset.service.ts +0 -85
  461. package/modules/asset/asset.types.ts +0 -22
  462. package/modules/asset/index.ts +0 -5
  463. package/modules/chain/chain.models.ts +0 -50
  464. package/modules/chain/chain.router.ts +0 -104
  465. package/modules/chain/chain.schema.ts +0 -52
  466. package/modules/chain/chain.service.ts +0 -167
  467. package/modules/chain/chain.types.ts +0 -24
  468. package/modules/chain/index.ts +0 -5
  469. package/modules/character/character.models.ts +0 -174
  470. package/modules/character/character.router.ts +0 -314
  471. package/modules/character/character.schema.ts +0 -147
  472. package/modules/character/character.service.ts +0 -876
  473. package/modules/character/character.types.ts +0 -64
  474. package/modules/character/index.ts +0 -5
  475. package/modules/chat/chat.models.ts +0 -43
  476. package/modules/chat/chat.router.ts +0 -67
  477. package/modules/chat/chat.schema.ts +0 -36
  478. package/modules/chat/chat.service.ts +0 -128
  479. package/modules/chat/chat.types.ts +0 -20
  480. package/modules/chat/index.ts +0 -5
  481. package/modules/collection/collection.models.ts +0 -76
  482. package/modules/collection/collection.router.ts +0 -91
  483. package/modules/collection/collection.schema.ts +0 -90
  484. package/modules/collection/collection.service.ts +0 -192
  485. package/modules/collection/collection.types.ts +0 -36
  486. package/modules/collection/index.ts +0 -5
  487. package/modules/core/core.models.ts +0 -1380
  488. package/modules/core/core.router.ts +0 -1781
  489. package/modules/core/core.schema.ts +0 -847
  490. package/modules/core/core.service.ts +0 -2824
  491. package/modules/core/core.types.ts +0 -340
  492. package/modules/core/index.ts +0 -5
  493. package/modules/core/mail/applyPatchesOrMail.ts +0 -568
  494. package/modules/core/mail/mailClaimablePatchesBatch.ts +0 -381
  495. package/modules/game/game.models.ts +0 -53
  496. package/modules/game/game.router.ts +0 -110
  497. package/modules/game/game.schema.ts +0 -23
  498. package/modules/game/game.service.ts +0 -143
  499. package/modules/game/game.types.ts +0 -28
  500. package/modules/game/index.ts +0 -5
  501. package/modules/interface/index.ts +0 -5
  502. package/modules/interface/interface.canonicalize.ts +0 -279
  503. package/modules/interface/interface.models.ts +0 -40
  504. package/modules/interface/interface.router.ts +0 -175
  505. package/modules/interface/interface.schema.ts +0 -59
  506. package/modules/interface/interface.service.ts +0 -356
  507. package/modules/interface/interface.types.ts +0 -25
  508. package/modules/item/index.ts +0 -5
  509. package/modules/item/item.models.ts +0 -124
  510. package/modules/item/item.router.ts +0 -103
  511. package/modules/item/item.schema.ts +0 -120
  512. package/modules/item/item.service.ts +0 -167
  513. package/modules/item/item.types.ts +0 -74
  514. package/modules/job/index.ts +0 -5
  515. package/modules/job/job.models.ts +0 -14
  516. package/modules/job/job.router.ts +0 -44
  517. package/modules/job/job.schema.ts +0 -9
  518. package/modules/job/job.service.ts +0 -243
  519. package/modules/job/job.types.ts +0 -23
  520. package/modules/market/index.ts +0 -5
  521. package/modules/market/market.models.ts +0 -113
  522. package/modules/market/market.router.ts +0 -73
  523. package/modules/market/market.schema.ts +0 -140
  524. package/modules/market/market.service.ts +0 -122
  525. package/modules/market/market.types.ts +0 -56
  526. package/modules/product/index.ts +0 -5
  527. package/modules/product/product.models.ts +0 -166
  528. package/modules/product/product.router.ts +0 -93
  529. package/modules/product/product.schema.ts +0 -149
  530. package/modules/product/product.service.ts +0 -160
  531. package/modules/product/product.types.ts +0 -33
  532. package/modules/profile/index.ts +0 -5
  533. package/modules/profile/profile.models.ts +0 -214
  534. package/modules/profile/profile.router.ts +0 -72
  535. package/modules/profile/profile.schema.ts +0 -156
  536. package/modules/profile/profile.service.ts +0 -149
  537. package/modules/profile/profile.types.ts +0 -22
  538. package/modules/raffle/index.ts +0 -5
  539. package/modules/raffle/raffle.models.ts +0 -44
  540. package/modules/raffle/raffle.router.ts +0 -90
  541. package/modules/raffle/raffle.schema.ts +0 -32
  542. package/modules/raffle/raffle.service.ts +0 -167
  543. package/modules/raffle/raffle.types.ts +0 -30
  544. package/modules/skill/index.ts +0 -5
  545. package/modules/skill/skill.models.ts +0 -16
  546. package/modules/skill/skill.router.ts +0 -201
  547. package/modules/skill/skill.schema.ts +0 -40
  548. package/modules/skill/skill.service.ts +0 -390
  549. package/modules/skill/skill.types.ts +0 -33
  550. package/modules/video/index.ts +0 -5
  551. package/modules/video/video.models.ts +0 -25
  552. package/modules/video/video.router.ts +0 -143
  553. package/modules/video/video.schema.ts +0 -46
  554. package/modules/video/video.service.ts +0 -274
  555. package/modules/video/video.types.ts +0 -33
  556. package/router.ts +0 -49
  557. package/types.ts +0 -183
  558. package/util/db/index.ts +0 -7
  559. package/util/db/isPostgresError.ts +0 -9
  560. package/util/db/isUniqueConstraintViolation.ts +0 -3
  561. package/util/db.ts +0 -62
  562. package/util/index.ts +0 -351
  563. package/util/log.ts +0 -5
  564. /package/{util/api.ts → api.ts} +0 -0
  565. /package/{util/array.ts → array.ts} +0 -0
  566. /package/{util/browser.ts → browser.ts} +0 -0
  567. /package/build/{util/api.d.ts → api.d.ts} +0 -0
  568. /package/build/{util/api.js → api.js} +0 -0
  569. /package/build/{util/array.d.ts → array.d.ts} +0 -0
  570. /package/build/{util/array.js → array.js} +0 -0
  571. /package/build/{util/browser.d.ts → browser.d.ts} +0 -0
  572. /package/build/{util/browser.js → browser.js} +0 -0
  573. /package/build/{util/codebase.d.ts → codebase.d.ts} +0 -0
  574. /package/build/{util/codebase.js → codebase.js} +0 -0
  575. /package/build/{util/config.d.ts → config.d.ts} +0 -0
  576. /package/build/{util/config.js → config.js} +0 -0
  577. /package/build/{util/decoder.d.ts → decoder.d.ts} +0 -0
  578. /package/build/{util/format.d.ts → format.d.ts} +0 -0
  579. /package/build/{util/format.js → format.js} +0 -0
  580. /package/build/{util/guid.d.ts → guid.d.ts} +0 -0
  581. /package/build/{util/guid.js → guid.js} +0 -0
  582. /package/build/{util/json.d.ts → json.d.ts} +0 -0
  583. /package/build/{util/json.js → json.js} +0 -0
  584. /package/build/{util/math.d.ts → math.d.ts} +0 -0
  585. /package/build/{util/math.js → math.js} +0 -0
  586. /package/build/{util/merkle.d.ts → merkle.d.ts} +0 -0
  587. /package/build/{util/mongo.d.ts → mongo.d.ts} +0 -0
  588. /package/build/{util/number.d.ts → number.d.ts} +0 -0
  589. /package/build/{util/number.js → number.js} +0 -0
  590. /package/build/{util/object.d.ts → object.d.ts} +0 -0
  591. /package/build/{util/object.js → object.js} +0 -0
  592. /package/build/{util/otp.d.ts → otp.d.ts} +0 -0
  593. /package/build/{util/otp.js → otp.js} +0 -0
  594. /package/build/{util/physics.d.ts → physics.d.ts} +0 -0
  595. /package/build/{util/physics.js → physics.js} +0 -0
  596. /package/build/{util/process.d.ts → process.d.ts} +0 -0
  597. /package/build/{util/rpc.d.ts → rpc.d.ts} +0 -0
  598. /package/build/{util/rpc.js → rpc.js} +0 -0
  599. /package/build/{util/seer.d.ts → seer.d.ts} +0 -0
  600. /package/build/{util/seer.js → seer.js} +0 -0
  601. /package/build/{util/string.d.ts → string.d.ts} +0 -0
  602. /package/build/{util/string.js → string.js} +0 -0
  603. /package/build/{util/text.d.ts → text.d.ts} +0 -0
  604. /package/build/{util/text.js → text.js} +0 -0
  605. /package/build/{util/time → time}/date.d.ts +0 -0
  606. /package/build/{util/time → time}/date.js +0 -0
  607. /package/build/{util/time → time}/fancyTimeFormat.d.ts +0 -0
  608. /package/build/{util/time → time}/fancyTimeFormat.js +0 -0
  609. /package/build/{util/time → time}/index.d.ts +0 -0
  610. /package/build/{util/time → time}/index.js +0 -0
  611. /package/build/{util/time → time}/now.d.ts +0 -0
  612. /package/build/{util/time → time}/now.js +0 -0
  613. /package/build/{util/web3 → web3}/httpProvider.d.ts +0 -0
  614. /package/build/{util/web3 → web3}/httpProvider.js +0 -0
  615. /package/build/{util/web3.d.ts → web3.d.ts} +0 -0
  616. /package/build/{util/websocket.d.ts → websocket.d.ts} +0 -0
  617. /package/build/{util/zk.d.ts → zk.d.ts} +0 -0
  618. /package/build/{util/zk.js → zk.js} +0 -0
  619. /package/{util/codebase.ts → codebase.ts} +0 -0
  620. /package/{util/config.ts → config.ts} +0 -0
  621. /package/{util/decoder.test.ts → decoder.test.ts} +0 -0
  622. /package/{util/format.ts → format.ts} +0 -0
  623. /package/{util/guid.ts → guid.ts} +0 -0
  624. /package/{util/json.ts → json.ts} +0 -0
  625. /package/{util/math.ts → math.ts} +0 -0
  626. /package/{util/number.ts → number.ts} +0 -0
  627. /package/{util/object.ts → object.ts} +0 -0
  628. /package/{util/otp.ts → otp.ts} +0 -0
  629. /package/{util/physics.ts → physics.ts} +0 -0
  630. /package/{util/rpc.ts → rpc.ts} +0 -0
  631. /package/{util/seer.ts → seer.ts} +0 -0
  632. /package/{util/string.ts → string.ts} +0 -0
  633. /package/{util/text.ts → text.ts} +0 -0
  634. /package/{util/time → time}/date.ts +0 -0
  635. /package/{util/time → time}/fancyTimeFormat.ts +0 -0
  636. /package/{util/time → time}/index.ts +0 -0
  637. /package/{util/time → time}/now.ts +0 -0
  638. /package/{util/types → types}/mongo.d.ts +0 -0
  639. /package/{util/web3 → web3}/httpProvider.ts +0 -0
  640. /package/{util/zk.ts → zk.ts} +0 -0
@@ -1,2515 +0,0 @@
1
- import { ARXError } from '../../util/rpc';
2
- import { getFilter } from '../../util/api';
3
- import { log } from '../../util';
4
- import { deepMerge } from '../../util/object';
5
- import { isValidRequest } from '../../util/web3';
6
- import { claimMailMessage } from './mail/applyPatchesOrMail';
7
- import { mailClaimablePatchesBatch } from './mail/mailClaimablePatchesBatch';
8
- export class Service {
9
- async claimConversationMessage(input, ctx) {
10
- if (!ctx.client?.profile)
11
- throw new Error('Unauthorized');
12
- const profileId = ctx.client.profile.id;
13
- const messageId = String(input.messageId);
14
- const characterId = input?.characterId ? String(input.characterId) : null;
15
- const Conversation = ctx.app.model.Conversation;
16
- const ConversationMessage = ctx.app.model.ConversationMessage;
17
- const Profile = ctx.app.model.Profile;
18
- const msg = await ctx.app.model.ConversationMessage.findById(messageId).lean().exec();
19
- if (!msg)
20
- throw new Error('Message not found');
21
- const convo = await Conversation.findOne({
22
- _id: msg.conversationId,
23
- $or: [{ profileId }, { 'participants.profileId': profileId }],
24
- })
25
- .lean()
26
- .exec();
27
- if (!convo)
28
- throw new Error('Not authorized for this message');
29
- const profile = await Profile.findById(profileId).populate('characters').exec();
30
- if (!profile)
31
- throw new Error('Profile not found');
32
- let character = null;
33
- const chars = profile.characters || [];
34
- if (characterId) {
35
- character = chars.find((c) => String(c._id) === characterId) ?? null;
36
- }
37
- else {
38
- character = chars?.[0] ?? null;
39
- }
40
- await claimMailMessage({
41
- ctx,
42
- profile,
43
- character: character ?? undefined,
44
- messageId,
45
- });
46
- return { ok: true, messageId };
47
- }
48
- async distributeSantaChristmasTicket(input, ctx) {
49
- if (!input)
50
- throw new ARXError('NO_INPUT');
51
- if (!ctx.client?.roles?.includes('admin'))
52
- throw new Error('Not authorized');
53
- const year = 2025;
54
- const dedupeKey = input?.dedupeKey || `broadcast:santa-christmas-ticket:${year}`;
55
- const patches = [
56
- {
57
- entityType: 'profile.meta',
58
- entityId: 'broadcast',
59
- claimable: true,
60
- ops: [{ op: 'inc', key: `rewards.tokens.christmas${year}`, value: 1 }],
61
- },
62
- ];
63
- const result = await mailClaimablePatchesBatch({
64
- ctx,
65
- streamAllProfiles: true,
66
- kind: 'mail',
67
- conversationKey: 'system',
68
- source: 'core.broadcastSantaChristmasTicket',
69
- title: `Holiday Gift 🎁`,
70
- body: `You received a Santa Christmas Ticket (${year}). Claim it to add it to your account.`,
71
- dedupeKey,
72
- claimablePatches: patches,
73
- payloadUi: {
74
- rewards: [{ type: 'token', id: `christmas${year}`, quantity: 1 }],
75
- },
76
- batchSize: input?.batchSize ?? 1000,
77
- });
78
- return {
79
- ok: true,
80
- year,
81
- dedupeKey,
82
- ...result,
83
- };
84
- }
85
- async getConversationMessages(input, ctx) {
86
- if (!input)
87
- throw new ARXError('NO_INPUT');
88
- if (!ctx.client?.profile)
89
- throw new Error('Unauthorized');
90
- const profileId = String(ctx.client.profile.id);
91
- const baseFilter = getFilter(input);
92
- const limit = Math.min(200, Number(input.limit ?? 50));
93
- const skip = Math.max(0, Number(input.skip ?? 0));
94
- const cursor = input.cursor ? String(input.cursor) : null;
95
- const Conversation = ctx.app.model.Conversation;
96
- const ConversationMessage = ctx.app.model.ConversationMessage;
97
- const requestedConversationId = baseFilter?.conversationId;
98
- if (requestedConversationId && typeof requestedConversationId !== 'object') {
99
- const convo = await Conversation.findOne({
100
- _id: requestedConversationId,
101
- $or: [{ profileId }, { 'participants.profileId': profileId }],
102
- })
103
- .select({ _id: 1 })
104
- .lean()
105
- .exec();
106
- if (!convo)
107
- throw new Error('Not authorized for this conversation');
108
- const msgFilter = {
109
- ...baseFilter,
110
- conversationId: requestedConversationId,
111
- };
112
- if (cursor)
113
- msgFilter._id = { $lt: cursor };
114
- const items = await ctx.app.model.ConversationMessage.findJSON(msgFilter, null, {
115
- sort: { _id: -1 },
116
- skip,
117
- limit,
118
- });
119
- const total = await ctx.app.model.ConversationMessage.countDocumentsFiltered(msgFilter);
120
- return {
121
- items,
122
- total,
123
- nextCursor: items.length ? String(items[items.length - 1]._id) : null,
124
- };
125
- }
126
- const convos = await Conversation.find({
127
- $or: [{ profileId }, { 'participants.profileId': profileId }],
128
- })
129
- .select({ _id: 1 })
130
- .lean()
131
- .exec();
132
- const convoIds = convos.map((c) => c._id);
133
- if (!convoIds.length)
134
- return { items: [], total: 0, nextCursor: null };
135
- const msgFilter = {
136
- ...baseFilter,
137
- conversationId: { $in: convoIds },
138
- };
139
- if (requestedConversationId && typeof requestedConversationId === 'object' && requestedConversationId.$in) {
140
- const wanted = (requestedConversationId.$in || []).map((x) => String(x));
141
- const allowed = convoIds.map((x) => String(x));
142
- const intersection = wanted.filter((id) => allowed.includes(id));
143
- msgFilter.conversationId = { $in: intersection };
144
- if (!intersection.length)
145
- return { items: [], total: 0, nextCursor: null };
146
- }
147
- if (cursor)
148
- msgFilter._id = { $lt: cursor };
149
- const items = await ctx.app.model.ConversationMessage.findJSON(msgFilter, null, {
150
- sort: { _id: -1 },
151
- skip,
152
- limit,
153
- });
154
- const total = await ctx.app.model.ConversationMessage.countDocumentsFiltered(msgFilter);
155
- return {
156
- items,
157
- total,
158
- nextCursor: items.length ? String(items[items.length - 1].id) : null,
159
- };
160
- }
161
- async setConversationMessageStar(input, ctx) {
162
- if (!ctx.client?.profile)
163
- throw new Error('Unauthorized');
164
- const profileId = String(ctx.client.profile.id);
165
- const messageId = String(input.messageId);
166
- const isStarred = !!input.isStarred;
167
- const Conversation = ctx.app.model.Conversation;
168
- const ConversationMessage = ctx.app.model.ConversationMessage;
169
- const msg = await ConversationMessage.findById(messageId).lean().exec();
170
- if (!msg)
171
- throw new Error('Message not found');
172
- const convo = await Conversation.findOne({
173
- _id: msg.conversationId,
174
- $or: [{ profileId }, { 'participants.profileId': profileId }],
175
- })
176
- .select({ _id: 1 })
177
- .lean()
178
- .exec();
179
- if (!convo)
180
- throw new Error('Not authorized for this message');
181
- await ConversationMessage.updateOne({ _id: messageId }, { $set: { isStarred } }).exec();
182
- return { ok: true, messageId, isStarred };
183
- }
184
- async distributeSantaChristmasTicketToProfile(input, ctx) {
185
- if (!input?.profileId)
186
- throw new ARXError('NO_INPUT');
187
- if (!ctx.client?.roles?.includes('admin'))
188
- throw new Error('Not authorized');
189
- const year = 2025;
190
- const dedupeKey = input?.dedupeKey || `broadcast:santa-christmas-ticket:${year}`;
191
- const patches = [
192
- {
193
- entityType: 'profile.meta',
194
- entityId: 'broadcast',
195
- claimable: true,
196
- ops: [{ op: 'inc', key: `rewards.tokens.christmas${year}`, value: 1 }],
197
- },
198
- ];
199
- const result = await mailClaimablePatchesBatch({
200
- ctx,
201
- profileIds: [input.profileId],
202
- kind: 'mail',
203
- conversationKey: 'system',
204
- source: 'core.broadcastSantaChristmasTicket',
205
- title: `Holiday Gift 🎁`,
206
- body: `You received a Santa Christmas Ticket (${year}). Claim it to add it to your account.`,
207
- dedupeKey,
208
- claimablePatches: patches,
209
- payloadUi: {
210
- rewards: [{ type: 'token', id: `christmas${year}`, quantity: 1 }],
211
- },
212
- batchSize: 1,
213
- });
214
- return {
215
- ok: true,
216
- year,
217
- dedupeKey,
218
- profileId: input.profileId,
219
- ...result,
220
- };
221
- }
222
- async readAndClaimLatestMail(input, ctx) {
223
- if (!input?.conversationId)
224
- throw new ARXError('NO_INPUT');
225
- if (!ctx.client?.profile)
226
- throw new Error('Unauthorized');
227
- const profileId = String(ctx.client.profile.id);
228
- const conversationId = String(input.conversationId);
229
- const limit = Math.max(1, Math.min(200, Number(input.limit ?? 50)));
230
- const characterId = input?.characterId ? String(input.characterId) : null;
231
- const Conversation = ctx.app.model.Conversation;
232
- const ConversationMessage = ctx.app.model.ConversationMessage;
233
- const Profile = ctx.app.model.Profile;
234
- const convo = await Conversation.findOne({
235
- _id: conversationId,
236
- $or: [{ profileId }, { 'participants.profileId': profileId }],
237
- })
238
- .lean()
239
- .exec();
240
- if (!convo)
241
- throw new Error('Not authorized');
242
- const msgs = await ConversationMessage.find({
243
- conversationId,
244
- status: { $ne: 'Archived' },
245
- })
246
- .sort({ _id: -1 })
247
- .limit(limit)
248
- .lean()
249
- .exec();
250
- const now = new Date();
251
- await Conversation.updateOne({ _id: conversationId }, {
252
- $set: {
253
- 'participants.$[p].lastReadDate': now,
254
- 'participants.$[p].unreadCount': 0,
255
- },
256
- }, {
257
- arrayFilters: [
258
- {
259
- 'p.profileId': ctx.app.db?.mongoose?.Types?.ObjectId?.isValid?.(profileId)
260
- ? ctx.app.db.mongoose.Types.ObjectId(profileId)
261
- : profileId,
262
- },
263
- ],
264
- })
265
- .exec()
266
- .catch(async () => {
267
- await Conversation.updateOne({ _id: conversationId, 'participants.profileId': profileId }, { $set: { 'participants.$.lastReadDate': now, 'participants.$.unreadCount': 0 } }).exec();
268
- });
269
- const profile = await Profile.findById(profileId).populate('characters').exec();
270
- if (!profile)
271
- throw new Error('Profile not found');
272
- let character = null;
273
- const chars = profile.characters || [];
274
- if (characterId)
275
- character = chars.find((c) => String(c._id) === characterId) ?? null;
276
- else
277
- character = chars?.[0] ?? null;
278
- let claimedCount = 0;
279
- for (const m of msgs) {
280
- const claimable = !!m?.claim?.isClaimable && !m?.claim?.claimedDate;
281
- if (!claimable)
282
- continue;
283
- try {
284
- await claimMailMessage({
285
- ctx,
286
- profile,
287
- character: character ?? undefined,
288
- messageId: String(m._id),
289
- });
290
- claimedCount += 1;
291
- }
292
- catch {
293
- }
294
- }
295
- return { ok: true, conversationId, readCount: msgs.length, claimedCount };
296
- }
297
- async archiveReadConversations(input, ctx) {
298
- if (!input?.conversationId)
299
- throw new ARXError('NO_INPUT');
300
- if (!ctx.client?.profile)
301
- throw new Error('Unauthorized');
302
- const profileId = String(ctx.client.profile.id);
303
- const conversationId = String(input.conversationId);
304
- const Conversation = ctx.app.model.Conversation;
305
- const ConversationMessage = ctx.app.model.ConversationMessage;
306
- const convo = await Conversation.findOne({
307
- _id: conversationId,
308
- $or: [{ profileId }, { 'participants.profileId': profileId }],
309
- })
310
- .lean()
311
- .exec();
312
- if (!convo)
313
- throw new Error('Not authorized');
314
- const participant = Array.isArray(convo.participants)
315
- ? convo.participants.find((p) => String(p.profileId) === profileId)
316
- : null;
317
- const lastReadDate = participant?.lastReadDate ? new Date(participant.lastReadDate) : new Date(0);
318
- const res = await ConversationMessage.updateMany({
319
- conversationId,
320
- status: { $ne: 'Archived' },
321
- isStarred: { $ne: true },
322
- createdDate: { $lte: lastReadDate },
323
- }, { $set: { status: 'Archived' } }).exec();
324
- const archivedCount = Number(res?.modifiedCount ?? res?.nModified ?? 0);
325
- return { ok: true, conversationId, archivedCount };
326
- }
327
- async markConversationRead(input, ctx) {
328
- if (!ctx.client?.profile)
329
- throw new Error('Unauthorized');
330
- const profileId = String(ctx.client.profile.id);
331
- const Conversation = ctx.app.model.Conversation;
332
- const ConversationMessage = ctx.app.model.ConversationMessage;
333
- const messageIds = Array.isArray(input?.messageIds)
334
- ? input.messageIds.map((x) => String(x)).filter(Boolean)
335
- : [];
336
- const conversationId = input?.conversationId ? String(input.conversationId) : null;
337
- const limit = Math.min(200, Number(input?.limit ?? 50));
338
- let targetIds = messageIds;
339
- if (!targetIds.length) {
340
- if (!conversationId) {
341
- return { ok: true, updatedCount: 0 };
342
- }
343
- const convo = await Conversation.findOne({
344
- _id: conversationId,
345
- $or: [{ profileId }, { 'participants.profileId': profileId }],
346
- })
347
- .lean()
348
- .exec();
349
- if (!convo)
350
- throw new Error('Not authorized for this conversation');
351
- const docs = await ConversationMessage.find({ conversationId })
352
- .sort({ _id: -1 })
353
- .limit(limit)
354
- .select({ _id: 1 })
355
- .lean()
356
- .exec();
357
- targetIds = docs.map((d) => String(d._id));
358
- if (!targetIds.length)
359
- return { ok: true, updatedCount: 0 };
360
- }
361
- else {
362
- const msgs = await ConversationMessage.find({ _id: { $in: targetIds } })
363
- .select({ _id: 1, conversationId: 1 })
364
- .lean()
365
- .exec();
366
- if (!msgs.length)
367
- return { ok: true, updatedCount: 0 };
368
- const convoIds = Array.from(new Set(msgs.map((m) => String(m.conversationId))));
369
- const allowed = await Conversation.find({
370
- _id: { $in: convoIds },
371
- $or: [{ profileId }, { 'participants.profileId': profileId }],
372
- })
373
- .select({ _id: 1 })
374
- .lean()
375
- .exec();
376
- const allowedSet = new Set(allowed.map((c) => String(c._id)));
377
- targetIds = msgs.filter((m) => allowedSet.has(String(m.conversationId))).map((m) => String(m._id));
378
- if (!targetIds.length)
379
- throw new Error('Not authorized for these messages');
380
- }
381
- const res = await ConversationMessage.updateMany({ _id: { $in: targetIds } }, {
382
- $set: {
383
- status: 'Read',
384
- readDate: new Date(),
385
- },
386
- }).exec();
387
- const updatedCount = Number(res?.modifiedCount ?? res?.nModified ?? 0);
388
- return { ok: true, updatedCount, messageIds: targetIds };
389
- }
390
- async getConversations(input, ctx) {
391
- if (!input)
392
- throw new ARXError('NO_INPUT');
393
- const filter = getFilter(input);
394
- const limit = input.limit ?? 50;
395
- const skip = input.skip ?? 0;
396
- const [items, total] = await Promise.all([
397
- ctx.app.model.Conversation.findJSON(filter, null, { skip, limit }),
398
- ctx.app.model.Conversation.find(filter).countDocuments().exec(),
399
- ]);
400
- return { items, total };
401
- }
402
- async getConversation(input, ctx) {
403
- if (!input)
404
- throw new ARXError('NO_INPUT');
405
- log('Core.Service.getConversation', input);
406
- const AUTO_CREATE_KEYS = new Set(['system', 'battles', 'reports', 'guild']);
407
- function titleCase(s) {
408
- if (!s)
409
- return s;
410
- return s.charAt(0).toUpperCase() + s.slice(1);
411
- }
412
- function defaultsForKey(key) {
413
- if (key === 'system') {
414
- return {
415
- name: 'System',
416
- category: 'system',
417
- kind: 'mail',
418
- isLocked: true,
419
- allowUserSend: false,
420
- importance: 0,
421
- };
422
- }
423
- return {
424
- name: titleCase(key),
425
- category: key,
426
- kind: 'mail',
427
- isLocked: false,
428
- allowUserSend: false,
429
- importance: 0,
430
- };
431
- }
432
- if (!ctx.client?.profile?.id)
433
- throw new Error('Unauthorized');
434
- input.where = input.where || {};
435
- input.where.profileId = { equals: ctx.client.profile.id };
436
- const where = input.where || {};
437
- const requestedKey = typeof where?.key === 'string' ? where.key : typeof where?.key?.equals === 'string' ? where.key.equals : null;
438
- let conversation = await ctx.app.model.Conversation.findOneJSON(getFilter(input));
439
- if (conversation)
440
- return conversation;
441
- if (!requestedKey || !AUTO_CREATE_KEYS.has(requestedKey)) {
442
- throw new Error('Conversation not found');
443
- }
444
- const profileId = String(ctx.client.profile.id);
445
- const createDoc = {
446
- key: requestedKey,
447
- profileId,
448
- ...defaultsForKey(requestedKey),
449
- participants: [
450
- {
451
- profileId,
452
- role: 'user',
453
- lastReadAt: new Date(0),
454
- unreadCount: 0,
455
- isMuted: false,
456
- isPinned: false,
457
- isArchived: false,
458
- isDeleted: false,
459
- },
460
- ],
461
- messages: [],
462
- messageCount: 0,
463
- lastMessageDate: null,
464
- lastMessagePreview: '',
465
- meta: {},
466
- data: {},
467
- status: 'Active',
468
- };
469
- try {
470
- await ctx.app.model.Conversation.create(createDoc);
471
- }
472
- catch (err) {
473
- log('getConversation auto-create race/err', err?.message || err);
474
- }
475
- conversation = await ctx.app.model.Conversation.findOneJSON(getFilter(input));
476
- if (!conversation)
477
- throw new Error('Conversation not found');
478
- return conversation;
479
- }
480
- async createConversation(input, ctx) {
481
- if (!input)
482
- throw new ARXError('NO_INPUT');
483
- log('Core.Service.createConversation', input);
484
- const conversation = await ctx.app.model.Conversation.create(input.data);
485
- return conversation;
486
- }
487
- async updateConversation(input, ctx) {
488
- if (!input)
489
- throw new ARXError('NO_INPUT');
490
- const filters = getFilter(input);
491
- if (!filters._id)
492
- throw new ARXError('BAD_REQUEST');
493
- log('Core.Service.updateConversation', input);
494
- const updatedConversation = await ctx.app.model.Conversation.findByIdAndUpdate(filters._id, input.data, {
495
- new: true,
496
- })
497
- .lean()
498
- .exec();
499
- if (!updatedConversation)
500
- throw new Error('Conversation update failed');
501
- return updatedConversation;
502
- }
503
- async getConversationMessage(input, ctx) {
504
- if (!input)
505
- throw new ARXError('NO_INPUT');
506
- log('Core.Service.getConversationMessage', input);
507
- const conversationMessage = await ctx.app.model.ConversationMessage.findOneJSON(getFilter(input));
508
- if (!conversationMessage)
509
- throw new Error('ConversationMessage not found');
510
- return conversationMessage;
511
- }
512
- async createConversationMessage(input, ctx) {
513
- if (!input)
514
- throw new ARXError('NO_INPUT');
515
- log('Core.Service.createConversationMessage', input);
516
- const conversationMessage = await ctx.app.model.ConversationMessage.create(input.data);
517
- return conversationMessage;
518
- }
519
- async updateConversationMessage(input, ctx) {
520
- if (!input)
521
- throw new ARXError('NO_INPUT');
522
- log('Core.Service.updateConversationMessage', input);
523
- const updatedConversationMessage = await ctx.app.model.ConversationMessage.findByIdAndUpdate(input.where.id.equals, input.data, { new: true })
524
- .lean()
525
- .exec();
526
- if (!updatedConversationMessage)
527
- throw new Error('ConversationMessage update failed');
528
- return updatedConversationMessage;
529
- }
530
- async updateSettings(input, ctx) {
531
- if (!ctx.client.profile)
532
- return;
533
- const validKeys = ['warp', 'designer'];
534
- const incoming = input;
535
- for (const key of Object.keys(incoming)) {
536
- if (!validKeys.includes(key))
537
- continue;
538
- const prev = ctx.client.profile.settings[key] || {};
539
- ctx.client.profile.settings[key] = deepMerge(prev, incoming[key]);
540
- }
541
- ctx.client.profile.markModified('settings');
542
- await ctx.client.profile.save();
543
- return ctx.client.profile.settings;
544
- }
545
- async ask(input, ctx) {
546
- if (!input)
547
- throw new ARXError('NO_INPUT');
548
- log('Core.Service.ask', input);
549
- const { conversationId, messages } = input.data;
550
- if (!conversationId) {
551
- throw new Error('NO_CONVERSATION_ID');
552
- }
553
- if (!Array.isArray(messages) || messages.length === 0) {
554
- throw new Error('NO_MESSAGES');
555
- }
556
- const lastMessage = messages[messages.length - 1];
557
- if (!lastMessage?.content) {
558
- throw new Error('NO_MESSAGE_CONTENT');
559
- }
560
- const userRole = lastMessage.role || 'user';
561
- await ctx.app.model.ConversationMessage.create({
562
- conversationId,
563
- role: userRole,
564
- content: lastMessage.content,
565
- });
566
- const assistantReply = {
567
- content: 'Request success.',
568
- role: 'assistant',
569
- };
570
- await ctx.app.model.ConversationMessage.create({
571
- conversationId,
572
- role: assistantReply.role,
573
- content: assistantReply.content,
574
- });
575
- return assistantReply;
576
- }
577
- async authorize(input, ctx) {
578
- if (!input)
579
- throw new ARXError('NO_INPUT');
580
- log('Core.Service.authorize', input);
581
- const isValid = await isValidRequest(ctx.app.web3.bsc, {
582
- signature: {
583
- address: input.address,
584
- hash: input.token,
585
- data: input.data || 'evolution',
586
- },
587
- });
588
- if (!isValid)
589
- throw new Error(`Invalid signature: ${input.address} ${input.token}`);
590
- ctx.client.profile = await ctx.app.model.Profile.findOne({
591
- address: input.address,
592
- });
593
- if (!ctx.client.profile)
594
- throw new Error('Profile not found: ' + input.address);
595
- const roles = ['guest'];
596
- if (input.address.toLowerCase() === '0xDfA8f768d82D719DC68E12B199090bDc3691fFc7'.toLowerCase() ||
597
- input.address.toLowerCase() === '0x81F8C054667046171C0EAdC73063Da557a828d6f'.toLowerCase() ||
598
- input.address.toLowerCase() === '0x954246b18fee13712C48E5a7Da5b78D88e8891d5'.toLowerCase()) {
599
- roles.push('mod');
600
- roles.push('admin');
601
- }
602
- roles.push('user');
603
- ctx.client.roles = roles;
604
- const permissions = {
605
- 'character.create': roles.includes('mod'),
606
- 'character.view': roles.includes('mod'),
607
- 'character.remove': roles.includes('mod'),
608
- 'character.update': roles.includes('mod'),
609
- 'rewards.distribute': roles.includes('admin'),
610
- 'character.data.write': roles.includes('mod'),
611
- 'character.inventory.write': roles.includes('mod'),
612
- 'profile.meta.write': roles.includes('mod'),
613
- 'character.data.write:evolution.quest.*': roles.includes('mod'),
614
- };
615
- ctx.client.permissions = permissions;
616
- return {
617
- token: input.token,
618
- };
619
- }
620
- async syncGetPayloadsSince(input, ctx) {
621
- if (!input)
622
- throw new ARXError('NO_INPUT');
623
- log('Core.Service.syncGetPayloadsSince', input);
624
- const sinceDate = new Date(input.since);
625
- const payloads = await ctx.app.model.SeerPayload.find({
626
- createdDate: { $gt: sinceDate },
627
- })
628
- .lean()
629
- .exec();
630
- return { payloads };
631
- }
632
- async getAccount(input, ctx) {
633
- if (!input)
634
- throw new ARXError('NO_INPUT');
635
- log('Core.Service.getAccount', input);
636
- const account = await ctx.app.model.Account.findOne(getFilter(input)).exec();
637
- if (!account)
638
- throw new Error('Account not found');
639
- return account;
640
- }
641
- async getAccounts(ctx) {
642
- log('Core.Service.getAccounts');
643
- const accounts = await ctx.app.model.Account.find().exec();
644
- return accounts;
645
- }
646
- async createAccount(input, ctx) {
647
- if (!input)
648
- throw new ARXError('NO_INPUT');
649
- log('Core.Service.createAccount', input);
650
- const account = await ctx.app.model.Account.create(input);
651
- return account;
652
- }
653
- async updateAccount(input, ctx) {
654
- if (!input)
655
- throw new ARXError('NO_INPUT');
656
- log('Core.Service.updateAccount', input);
657
- const updatedAccount = await ctx.app.model.Account.findByIdAndUpdate(input.where.id.equals, input.data, {
658
- new: true,
659
- })
660
- .lean()
661
- .exec();
662
- if (!updatedAccount)
663
- throw new Error('Account update failed');
664
- return updatedAccount;
665
- }
666
- async getAchievement(input, ctx) {
667
- if (!input)
668
- throw new ARXError('NO_INPUT');
669
- log('Core.Service.getAchievement', input);
670
- const achievement = await ctx.app.model.Achievement.findOne(getFilter(input)).exec();
671
- if (!achievement)
672
- throw new Error('Achievement not found');
673
- return achievement;
674
- }
675
- async getAchievements(ctx) {
676
- log('Core.Service.getAchievements');
677
- const achievements = await ctx.app.model.Achievement.find().exec();
678
- return achievements;
679
- }
680
- async createAchievement(input, ctx) {
681
- if (!input)
682
- throw new ARXError('NO_INPUT');
683
- log('Core.Service.createAchievement', input);
684
- const achievement = await ctx.app.model.Achievement.create(input);
685
- return achievement;
686
- }
687
- async updateAchievement(input, ctx) {
688
- if (!input)
689
- throw new ARXError('NO_INPUT');
690
- log('Core.Service.updateAchievement', input);
691
- const updatedAchievement = await ctx.app.model.Achievement.findByIdAndUpdate(input.where.id.equals, input.data, {
692
- new: true,
693
- })
694
- .lean()
695
- .exec();
696
- if (!updatedAchievement)
697
- throw new Error('Achievement update failed');
698
- return updatedAchievement;
699
- }
700
- async info(input, ctx) {
701
- return { version: '1.1.1' };
702
- }
703
- async stats(input, ctx) {
704
- if (!input)
705
- throw new ARXError('NO_INPUT');
706
- log('Core.Service.stats');
707
- const stats = await ctx.app.model.Stat.find().sort({ number: -1 }).limit(1).exec();
708
- return stats.map((stat) => stat.toObject());
709
- }
710
- async getAct(input, ctx) {
711
- if (!input)
712
- throw new ARXError('NO_INPUT');
713
- log('Core.Service.getAct', input);
714
- const act = await ctx.app.model.Act.findOne(getFilter(input)).exec();
715
- if (!act)
716
- throw new Error('Act not found');
717
- return act;
718
- }
719
- async getActs(input, ctx) {
720
- if (!input)
721
- throw new ARXError('NO_INPUT');
722
- const filter = getFilter(input);
723
- const limit = input.limit ?? 50;
724
- const skip = input.skip ?? 0;
725
- const [items, total] = await Promise.all([
726
- ctx.app.model.Act.find(filter).skip(skip).limit(limit).lean().exec(),
727
- ctx.app.model.Act.find(filter).countDocuments().exec(),
728
- ]);
729
- return { items, total };
730
- }
731
- async createAct(input, ctx) {
732
- if (!input)
733
- throw new ARXError('NO_INPUT');
734
- log('Core.Service.createAct', input);
735
- const act = await ctx.app.model.Act.create(input);
736
- return act;
737
- }
738
- async updateAct(input, ctx) {
739
- if (!input)
740
- throw new ARXError('NO_INPUT');
741
- log('Core.Service.updateAct', input);
742
- const updatedAct = await ctx.app.model.Act.findByIdAndUpdate(input.where.id.equals, input.data, { new: true })
743
- .lean()
744
- .exec();
745
- if (!updatedAct)
746
- throw new Error('Act update failed');
747
- return updatedAct;
748
- }
749
- async getAgent(input, ctx) {
750
- if (!input)
751
- throw new ARXError('NO_INPUT');
752
- log('Core.Service.getAgent', input);
753
- const agent = await ctx.app.model.Agent.findOne(getFilter(input)).exec();
754
- if (!agent)
755
- throw new Error('Agent not found');
756
- return agent;
757
- }
758
- async createAgent(input, ctx) {
759
- if (!input)
760
- throw new ARXError('NO_INPUT');
761
- log('Core.Service.createAgent', input);
762
- const agent = await ctx.app.model.Agent.create(input);
763
- return agent;
764
- }
765
- async updateAgent(input, ctx) {
766
- if (!input)
767
- throw new ARXError('NO_INPUT');
768
- log('Core.Service.updateAgent', input);
769
- const updatedAgent = await ctx.app.model.Agent.findByIdAndUpdate(input.where.id.equals, input.data, { new: true })
770
- .lean()
771
- .exec();
772
- if (!updatedAgent)
773
- throw new Error('Agent update failed');
774
- return updatedAgent;
775
- }
776
- async getApplication(input, ctx) {
777
- if (!input)
778
- throw new ARXError('NO_INPUT');
779
- log('Core.Service.getApplication', input);
780
- const application = await ctx.app.model.Application.findOne(getFilter(input)).exec();
781
- if (!application)
782
- throw new Error('Application not found');
783
- return application;
784
- }
785
- async createApplication(input, ctx) {
786
- if (!input)
787
- throw new ARXError('NO_INPUT');
788
- log('Core.Service.createApplication', input);
789
- const application = await ctx.app.model.Application.create(input);
790
- return application;
791
- }
792
- async updateApplication(input, ctx) {
793
- if (!input)
794
- throw new ARXError('NO_INPUT');
795
- log('Core.Service.updateApplication', input);
796
- const updatedApplication = await ctx.app.model.Application.findByIdAndUpdate(input.where.id.equals, input.data, {
797
- new: true,
798
- })
799
- .lean()
800
- .exec();
801
- if (!updatedApplication)
802
- throw new Error('Application update failed');
803
- return updatedApplication;
804
- }
805
- async getBadge(input, ctx) {
806
- if (!input)
807
- throw new ARXError('NO_INPUT');
808
- log('Core.Service.getBadge', input);
809
- const badge = await ctx.app.model.Badge.findOne(getFilter(input)).exec();
810
- if (!badge)
811
- throw new Error('Badge not found');
812
- return badge;
813
- }
814
- async createBadge(input, ctx) {
815
- if (!input)
816
- throw new ARXError('NO_INPUT');
817
- log('Core.Service.createBadge', input);
818
- const badge = await ctx.app.model.Badge.create(input);
819
- return badge;
820
- }
821
- async updateBadge(input, ctx) {
822
- if (!input)
823
- throw new ARXError('NO_INPUT');
824
- log('Core.Service.updateBadge', input);
825
- const updatedBadge = await ctx.app.model.Badge.findByIdAndUpdate(input.where.id.equals, input.data, { new: true })
826
- .lean()
827
- .exec();
828
- if (!updatedBadge)
829
- throw new Error('Badge update failed');
830
- return updatedBadge;
831
- }
832
- async getBattlePass(input, ctx) {
833
- if (!input)
834
- throw new ARXError('NO_INPUT');
835
- log('Core.Service.getBattlePass', input);
836
- const battlePass = await ctx.app.model.BattlePass.findOne(getFilter(input)).exec();
837
- if (!battlePass)
838
- throw new Error('BattlePass not found');
839
- return battlePass;
840
- }
841
- async createBattlePass(input, ctx) {
842
- if (!input)
843
- throw new ARXError('NO_INPUT');
844
- log('Core.Service.createBattlePass', input);
845
- const battlePass = await ctx.app.model.BattlePass.create(input);
846
- return battlePass;
847
- }
848
- async updateBattlePass(input, ctx) {
849
- if (!input)
850
- throw new ARXError('NO_INPUT');
851
- log('Core.Service.updateBattlePass', input);
852
- const updatedBattlePass = await ctx.app.model.BattlePass.findByIdAndUpdate(input.where.id.equals, input.data, {
853
- new: true,
854
- })
855
- .lean()
856
- .exec();
857
- if (!updatedBattlePass)
858
- throw new Error('BattlePass update failed');
859
- return updatedBattlePass;
860
- }
861
- async getBiome(input, ctx) {
862
- if (!input)
863
- throw new ARXError('NO_INPUT');
864
- log('Core.Service.getBiome', input);
865
- const biome = await ctx.app.model.Biome.findOne(getFilter(input)).exec();
866
- if (!biome)
867
- throw new Error('Biome not found');
868
- return biome;
869
- }
870
- async createBiome(input, ctx) {
871
- if (!input)
872
- throw new ARXError('NO_INPUT');
873
- log('Core.Service.createBiome', input);
874
- const biome = await ctx.app.model.Biome.create(input);
875
- return biome;
876
- }
877
- async updateBiome(input, ctx) {
878
- if (!input)
879
- throw new ARXError('NO_INPUT');
880
- log('Core.Service.updateBiome', input);
881
- const updatedBiome = await ctx.app.model.Biome.findByIdAndUpdate(input.where.id.equals, input.data, { new: true })
882
- .lean()
883
- .exec();
884
- if (!updatedBiome)
885
- throw new Error('Biome update failed');
886
- return updatedBiome;
887
- }
888
- async getBiomeFeature(input, ctx) {
889
- if (!input)
890
- throw new ARXError('NO_INPUT');
891
- log('Core.Service.getBiomeFeature', input);
892
- const biomeFeature = await ctx.app.model.BiomeFeature.findOne(getFilter(input)).exec();
893
- if (!biomeFeature)
894
- throw new Error('BiomeFeature not found');
895
- return biomeFeature;
896
- }
897
- async createBiomeFeature(input, ctx) {
898
- if (!input)
899
- throw new ARXError('NO_INPUT');
900
- log('Core.Service.createBiomeFeature', input);
901
- const biomeFeature = await ctx.app.model.BiomeFeature.create(input);
902
- return biomeFeature;
903
- }
904
- async updateBiomeFeature(input, ctx) {
905
- if (!input)
906
- throw new ARXError('NO_INPUT');
907
- log('Core.Service.updateBiomeFeature', input);
908
- const updatedBiomeFeature = await ctx.app.model.BiomeFeature.findByIdAndUpdate(input.where.id.equals, input.data, {
909
- new: true,
910
- })
911
- .lean()
912
- .exec();
913
- if (!updatedBiomeFeature)
914
- throw new Error('BiomeFeature update failed');
915
- return updatedBiomeFeature;
916
- }
917
- async getCollection(input, ctx) {
918
- if (!input)
919
- throw new ARXError('NO_INPUT');
920
- log('Core.Service.getCollection', input);
921
- const collection = await ctx.app.model.Collection.findOne(getFilter(input)).exec();
922
- if (!collection)
923
- throw new Error('Collection not found');
924
- return collection;
925
- }
926
- async createCollection(input, ctx) {
927
- if (!input)
928
- throw new ARXError('NO_INPUT');
929
- log('Core.Service.createCollection', input);
930
- const collection = await ctx.app.model.Collection.create(input);
931
- return collection;
932
- }
933
- async updateCollection(input, ctx) {
934
- if (!input)
935
- throw new ARXError('NO_INPUT');
936
- log('Core.Service.updateCollection', input);
937
- const updatedCollection = await ctx.app.model.Collection.findByIdAndUpdate(input.where.id.equals, input.data, {
938
- new: true,
939
- })
940
- .lean()
941
- .exec();
942
- if (!updatedCollection)
943
- throw new Error('Collection update failed');
944
- return updatedCollection;
945
- }
946
- async getComment(input, ctx) {
947
- if (!input)
948
- throw new ARXError('NO_INPUT');
949
- log('Core.Service.getComment', input);
950
- const comment = await ctx.app.model.Comment.findOne(getFilter(input)).exec();
951
- if (!comment)
952
- throw new Error('Comment not found');
953
- return comment;
954
- }
955
- async createComment(input, ctx) {
956
- if (!input)
957
- throw new ARXError('NO_INPUT');
958
- log('Core.Service.createComment', input);
959
- const comment = await ctx.app.model.Comment.create(input);
960
- return comment;
961
- }
962
- async updateComment(input, ctx) {
963
- if (!input)
964
- throw new ARXError('NO_INPUT');
965
- log('Core.Service.updateComment', input);
966
- const updatedComment = await ctx.app.model.Comment.findByIdAndUpdate(input.where.id.equals, input.data, {
967
- new: true,
968
- })
969
- .lean()
970
- .exec();
971
- if (!updatedComment)
972
- throw new Error('Comment update failed');
973
- return updatedComment;
974
- }
975
- async getCommunity(input, ctx) {
976
- if (!input)
977
- throw new ARXError('NO_INPUT');
978
- log('Core.Service.getCommunity', input);
979
- const community = await ctx.app.model.Community.findOne(getFilter(input)).exec();
980
- if (!community)
981
- throw new Error('Community not found');
982
- return community;
983
- }
984
- async createCommunity(input, ctx) {
985
- if (!input)
986
- throw new ARXError('NO_INPUT');
987
- log('Core.Service.createCommunity', input);
988
- const community = await ctx.app.model.Community.create(input);
989
- return community;
990
- }
991
- async updateCommunity(input, ctx) {
992
- if (!input)
993
- throw new ARXError('NO_INPUT');
994
- log('Core.Service.updateCommunity', input);
995
- const updatedCommunity = await ctx.app.model.Community.findByIdAndUpdate(input.where.id.equals, input.data, {
996
- new: true,
997
- })
998
- .lean()
999
- .exec();
1000
- if (!updatedCommunity)
1001
- throw new Error('Community update failed');
1002
- return updatedCommunity;
1003
- }
1004
- async getCompany(input, ctx) {
1005
- if (!input)
1006
- throw new ARXError('NO_INPUT');
1007
- log('Core.Service.getCompany', input);
1008
- const company = await ctx.app.model.Company.findOne(getFilter(input)).exec();
1009
- if (!company)
1010
- throw new Error('Company not found');
1011
- return company;
1012
- }
1013
- async createCompany(input, ctx) {
1014
- if (!input)
1015
- throw new ARXError('NO_INPUT');
1016
- log('Core.Service.createCompany', input);
1017
- const company = await ctx.app.model.Company.create(input);
1018
- return company;
1019
- }
1020
- async updateCompany(input, ctx) {
1021
- if (!input)
1022
- throw new ARXError('NO_INPUT');
1023
- log('Core.Service.updateCompany', input.where.id.equals, input.data);
1024
- const updatedCompany = await ctx.app.model.Company.findByIdAndUpdate(input.where.id.equals, input.data, {
1025
- new: true,
1026
- })
1027
- .lean()
1028
- .exec();
1029
- if (!updatedCompany)
1030
- throw new Error('Company update failed');
1031
- return updatedCompany;
1032
- }
1033
- async getData(input, ctx) {
1034
- if (!input)
1035
- throw new ARXError('NO_INPUT');
1036
- log('Core.Service.getData', input.where.id.equals);
1037
- const data = await ctx.app.model.Data.findOne(getFilter(input)).exec();
1038
- if (!data)
1039
- throw new Error('Data not found');
1040
- return data;
1041
- }
1042
- async createData(input, ctx) {
1043
- if (!input)
1044
- throw new ARXError('NO_INPUT');
1045
- log('Core.Service.createData', input);
1046
- const data = await ctx.app.model.Data.create(input);
1047
- return data;
1048
- }
1049
- async updateData(input, ctx) {
1050
- if (!input)
1051
- throw new ARXError('NO_INPUT');
1052
- log('Core.Service.updateData', input.where.id.equals, input.data);
1053
- const updatedData = await ctx.app.model.Data.findByIdAndUpdate(input.where.id.equals, input.data, { new: true })
1054
- .lean()
1055
- .exec();
1056
- if (!updatedData)
1057
- throw new Error('Data update failed');
1058
- return updatedData;
1059
- }
1060
- async getDiscussion(input, ctx) {
1061
- if (!input)
1062
- throw new ARXError('NO_INPUT');
1063
- log('Core.Service.getDiscussion', input.where.id.equals);
1064
- const discussion = await ctx.app.model.Discussion.findOne(getFilter(input)).exec();
1065
- if (!discussion)
1066
- throw new Error('Discussion not found');
1067
- return discussion;
1068
- }
1069
- async createDiscussion(input, ctx) {
1070
- if (!input)
1071
- throw new ARXError('NO_INPUT');
1072
- log('Core.Service.createDiscussion', input);
1073
- const discussion = await ctx.app.model.Discussion.create(input);
1074
- return discussion;
1075
- }
1076
- async updateDiscussion(input, ctx) {
1077
- if (!input)
1078
- throw new ARXError('NO_INPUT');
1079
- log('Core.Service.updateDiscussion', input);
1080
- const updatedDiscussion = await ctx.app.model.Discussion.findByIdAndUpdate(input.where.id.equals, input.data, {
1081
- new: true,
1082
- })
1083
- .lean()
1084
- .exec();
1085
- if (!updatedDiscussion)
1086
- throw new Error('Discussion update failed');
1087
- return updatedDiscussion;
1088
- }
1089
- async getEnergy(input, ctx) {
1090
- if (!input)
1091
- throw new ARXError('NO_INPUT');
1092
- log('Core.Service.getEnergy', input);
1093
- const energy = await ctx.app.model.Energy.findOne(getFilter(input)).exec();
1094
- if (!energy)
1095
- throw new Error('Energy not found');
1096
- return energy;
1097
- }
1098
- async getEnergies(input, ctx) {
1099
- if (!input)
1100
- throw new ARXError('NO_INPUT');
1101
- log('Core.Service.getEnergies', input);
1102
- const filter = getFilter(input);
1103
- const limit = input.limit ?? 50;
1104
- const skip = input.skip ?? 0;
1105
- const [items, total] = await Promise.all([
1106
- ctx.app.model.Energy.find(filter).skip(skip).limit(limit).lean().exec(),
1107
- ctx.app.model.Energy.find(filter).countDocuments().exec(),
1108
- ]);
1109
- return { items, total };
1110
- }
1111
- async createEnergy(input, ctx) {
1112
- if (!input)
1113
- throw new ARXError('NO_INPUT');
1114
- log('Core.Service.createEnergy', input);
1115
- const energy = await ctx.app.model.Energy.create(input);
1116
- return energy;
1117
- }
1118
- async updateEnergy(input, ctx) {
1119
- if (!input)
1120
- throw new ARXError('NO_INPUT');
1121
- log('Core.Service.updateEnergy', input);
1122
- const updatedEnergy = await ctx.app.model.Energy.findByIdAndUpdate(input.where.id.equals, { new: true })
1123
- .lean()
1124
- .exec();
1125
- if (!updatedEnergy)
1126
- throw new Error('Energy update failed');
1127
- return updatedEnergy;
1128
- }
1129
- async getEvent(input, ctx) {
1130
- if (!input)
1131
- throw new ARXError('NO_INPUT');
1132
- log('Core.Service.getEvent', input);
1133
- const event = await ctx.app.model.Event.findOne(getFilter(input)).exec();
1134
- if (!event)
1135
- throw new Error('Event not found');
1136
- return event;
1137
- }
1138
- async createEvent(input, ctx) {
1139
- if (!input)
1140
- throw new ARXError('NO_INPUT');
1141
- log('Core.Service.createEvent', input);
1142
- const event = await ctx.app.model.Event.create(input);
1143
- return event;
1144
- }
1145
- async updateEvent(input, ctx) {
1146
- if (!input)
1147
- throw new ARXError('NO_INPUT');
1148
- log('Core.Service.updateEvent', input);
1149
- const updatedEvent = await ctx.app.model.Event.findByIdAndUpdate(input.where.id.equals, input.data, { new: true })
1150
- .lean()
1151
- .exec();
1152
- if (!updatedEvent)
1153
- throw new Error('Event update failed');
1154
- return updatedEvent;
1155
- }
1156
- async getFile(input, ctx) {
1157
- if (!input)
1158
- throw new ARXError('NO_INPUT');
1159
- log('Core.Service.getFile', input);
1160
- const file = await ctx.app.model.File.findOne(getFilter(input)).exec();
1161
- if (!file)
1162
- throw new Error('File not found');
1163
- return file;
1164
- }
1165
- async createFile(input, ctx) {
1166
- if (!input)
1167
- throw new ARXError('NO_INPUT');
1168
- log('Core.Service.createFile', input);
1169
- const file = await ctx.app.model.File.create(input);
1170
- return file;
1171
- }
1172
- async updateFile(input, ctx) {
1173
- if (!input)
1174
- throw new ARXError('NO_INPUT');
1175
- log('Core.Service.updateFile', input);
1176
- const updatedFile = await ctx.app.model.File.findByIdAndUpdate(input.where.id.equals, input.data, { new: true })
1177
- .lean()
1178
- .exec();
1179
- if (!updatedFile)
1180
- throw new Error('File update failed');
1181
- return updatedFile;
1182
- }
1183
- async getGalaxy(input, ctx) {
1184
- if (!input)
1185
- throw new ARXError('NO_INPUT');
1186
- log('Core.Service.getGalaxy', input);
1187
- const galaxy = await ctx.app.model.Galaxy.findOne(getFilter(input)).exec();
1188
- if (!galaxy)
1189
- throw new Error('Galaxy not found');
1190
- return galaxy;
1191
- }
1192
- async createGalaxy(input, ctx) {
1193
- if (!input)
1194
- throw new ARXError('NO_INPUT');
1195
- log('Core.Service.createGalaxy', input);
1196
- const galaxy = await ctx.app.model.Galaxy.create(input);
1197
- return galaxy;
1198
- }
1199
- async updateGalaxy(input, ctx) {
1200
- if (!input)
1201
- throw new ARXError('NO_INPUT');
1202
- log('Core.Service.updateGalaxy', input);
1203
- const updatedGalaxy = await ctx.app.model.Galaxy.findByIdAndUpdate(input.where.id.equals, { new: true })
1204
- .lean()
1205
- .exec();
1206
- if (!updatedGalaxy)
1207
- throw new Error('Galaxy update failed');
1208
- return updatedGalaxy;
1209
- }
1210
- async getGuide(input, ctx) {
1211
- if (!input)
1212
- throw new ARXError('NO_INPUT');
1213
- log('Core.Service.getGuide', input);
1214
- const guide = await ctx.app.model.Guide.findOne(getFilter(input)).exec();
1215
- if (!guide)
1216
- throw new Error('Guide not found');
1217
- return guide;
1218
- }
1219
- async createGuide(input, ctx) {
1220
- if (!input)
1221
- throw new ARXError('NO_INPUT');
1222
- log('Core.Service.createGuide', input);
1223
- const guide = await ctx.app.model.Guide.create(input);
1224
- return guide;
1225
- }
1226
- async updateGuide(input, ctx) {
1227
- if (!input)
1228
- throw new ARXError('NO_INPUT');
1229
- log('Core.Service.updateGuide', input);
1230
- const updatedGuide = await ctx.app.model.Guide.findByIdAndUpdate(input.where.id.equals, { new: true })
1231
- .lean()
1232
- .exec();
1233
- if (!updatedGuide)
1234
- throw new Error('Guide update failed');
1235
- return updatedGuide;
1236
- }
1237
- async getIdea(input, ctx) {
1238
- if (!input)
1239
- throw new ARXError('NO_INPUT');
1240
- log('Core.Service.getIdea', input);
1241
- const idea = await ctx.app.model.Idea.findOne(getFilter(input)).exec();
1242
- if (!idea)
1243
- throw new Error('Idea not found');
1244
- return idea;
1245
- }
1246
- async createIdea(input, ctx) {
1247
- if (!input)
1248
- throw new ARXError('NO_INPUT');
1249
- log('Core.Service.createIdea', input);
1250
- const idea = await ctx.app.model.Idea.create(input);
1251
- return idea;
1252
- }
1253
- async updateIdea(input, ctx) {
1254
- if (!input)
1255
- throw new ARXError('NO_INPUT');
1256
- log('Core.Service.updateIdea', input);
1257
- const updatedIdea = await ctx.app.model.Idea.findByIdAndUpdate(input.where.id.equals, { new: true }).exec();
1258
- if (!updatedIdea)
1259
- throw new Error('Idea update failed');
1260
- return updatedIdea;
1261
- }
1262
- async getLeaderboard(input, ctx) {
1263
- if (!input)
1264
- throw new ARXError('NO_INPUT');
1265
- log('Core.Service.getLeaderboard', input);
1266
- const leaderboard = await ctx.app.model.Leaderboard.findOne(getFilter(input)).exec();
1267
- if (!leaderboard)
1268
- throw new Error('Leaderboard not found');
1269
- return leaderboard;
1270
- }
1271
- async createLeaderboard(input, ctx) {
1272
- if (!input)
1273
- throw new ARXError('NO_INPUT');
1274
- log('Core.Service.createLeaderboard', input);
1275
- const leaderboard = await ctx.app.model.Leaderboard.create(input);
1276
- return leaderboard;
1277
- }
1278
- async updateLeaderboard(input, ctx) {
1279
- if (!input)
1280
- throw new ARXError('NO_INPUT');
1281
- log('Core.Service.updateLeaderboard', input);
1282
- const updatedLeaderboard = await ctx.app.model.Leaderboard.findByIdAndUpdate(input.where.id.equals, {
1283
- new: true,
1284
- })
1285
- .lean()
1286
- .exec();
1287
- if (!updatedLeaderboard)
1288
- throw new Error('Leaderboard update failed');
1289
- return updatedLeaderboard;
1290
- }
1291
- async getLog(input, ctx) {
1292
- if (!input)
1293
- throw new ARXError('NO_INPUT');
1294
- log('Core.Service.getLog', input);
1295
- const item = await ctx.app.model.Log.findOne(getFilter(input)).exec();
1296
- if (!item)
1297
- throw new Error('Log not found');
1298
- return item;
1299
- }
1300
- async createLog(input, ctx) {
1301
- if (!input)
1302
- throw new ARXError('NO_INPUT');
1303
- log('Core.Service.createLog', input);
1304
- const item = await ctx.app.model.Log.create(input);
1305
- return item;
1306
- }
1307
- async updateLog(input, ctx) {
1308
- if (!input)
1309
- throw new ARXError('NO_INPUT');
1310
- log('Core.Service.updateLog', input);
1311
- const item = await ctx.app.model.Log.findByIdAndUpdate(input.where.id.equals, { new: true }).exec();
1312
- if (!item)
1313
- throw new Error('Log update failed');
1314
- return item;
1315
- }
1316
- async getLore(input, ctx) {
1317
- if (!input)
1318
- throw new ARXError('NO_INPUT');
1319
- log('Core.Service.getLore', input);
1320
- const lore = await ctx.app.model.Lore.findOne(getFilter(input)).exec();
1321
- if (!lore)
1322
- throw new Error('Lore not found');
1323
- return lore;
1324
- }
1325
- async createLore(input, ctx) {
1326
- if (!input)
1327
- throw new ARXError('NO_INPUT');
1328
- log('Core.Service.createLore', input);
1329
- const lore = await ctx.app.model.Lore.create(input);
1330
- return lore;
1331
- }
1332
- async updateLore(input, ctx) {
1333
- if (!input)
1334
- throw new ARXError('NO_INPUT');
1335
- log('Core.Service.updateLore', input);
1336
- const updatedLore = await ctx.app.model.Lore.findByIdAndUpdate(input.where.id.equals, { new: true }).exec();
1337
- if (!updatedLore)
1338
- throw new Error('Lore update failed');
1339
- return updatedLore;
1340
- }
1341
- async getMemory(input, ctx) {
1342
- if (!input)
1343
- throw new ARXError('NO_INPUT');
1344
- log('Core.Service.getMemory', input);
1345
- const memory = await ctx.app.model.Memory.findOne(getFilter(input)).exec();
1346
- if (!memory)
1347
- throw new Error('Memory not found');
1348
- return memory;
1349
- }
1350
- async createMemory(input, ctx) {
1351
- if (!input)
1352
- throw new ARXError('NO_INPUT');
1353
- log('Core.Service.createMemory', input);
1354
- const memory = await ctx.app.model.Memory.create(input);
1355
- return memory;
1356
- }
1357
- async updateMemory(input, ctx) {
1358
- if (!input)
1359
- throw new ARXError('NO_INPUT');
1360
- log('Core.Service.updateMemory', input);
1361
- const updatedMemory = await ctx.app.model.Memory.findByIdAndUpdate(input.where.id.equals, { new: true })
1362
- .lean()
1363
- .exec();
1364
- if (!updatedMemory)
1365
- throw new Error('Memory update failed');
1366
- return updatedMemory;
1367
- }
1368
- async getMessage(input, ctx) {
1369
- if (!input)
1370
- throw new ARXError('NO_INPUT');
1371
- log('Core.Service.getMessage', input);
1372
- const message = await ctx.app.model.Message.findOne(getFilter(input)).exec();
1373
- if (!message)
1374
- throw new Error('Message not found');
1375
- return message;
1376
- }
1377
- async createMessage(input, ctx) {
1378
- if (!input)
1379
- throw new ARXError('NO_INPUT');
1380
- log('Core.Service.createMessage', input);
1381
- const message = await ctx.app.model.Message.create(input);
1382
- return message;
1383
- }
1384
- async updateMessage(input, ctx) {
1385
- if (!input)
1386
- throw new ARXError('NO_INPUT');
1387
- log('Core.Service.updateMessage', input);
1388
- const updatedMessage = await ctx.app.model.Message.findByIdAndUpdate(input.where.id.equals, { new: true })
1389
- .lean()
1390
- .exec();
1391
- if (!updatedMessage)
1392
- throw new Error('Message update failed');
1393
- return updatedMessage;
1394
- }
1395
- async getMetaverse(input, ctx) {
1396
- if (!input)
1397
- throw new ARXError('NO_INPUT');
1398
- log('Core.Service.getMetaverse', input);
1399
- const metaverse = await ctx.app.model.Metaverse.findOne(getFilter(input)).exec();
1400
- if (!metaverse)
1401
- throw new Error('Metaverse not found');
1402
- return metaverse;
1403
- }
1404
- async createMetaverse(input, ctx) {
1405
- if (!input)
1406
- throw new ARXError('NO_INPUT');
1407
- log('Core.Service.createMetaverse', input);
1408
- const metaverse = await ctx.app.model.Metaverse.create(input);
1409
- return metaverse;
1410
- }
1411
- async updateMetaverse(input, ctx) {
1412
- if (!input)
1413
- throw new ARXError('NO_INPUT');
1414
- log('Core.Service.updateMetaverse', input);
1415
- const updatedMetaverse = await ctx.app.model.Metaverse.findByIdAndUpdate(input.where.id.equals, {
1416
- new: true,
1417
- })
1418
- .lean()
1419
- .exec();
1420
- if (!updatedMetaverse)
1421
- throw new Error('Metaverse update failed');
1422
- return updatedMetaverse;
1423
- }
1424
- async getNewsArticle(input, ctx) {
1425
- if (!input)
1426
- throw new ARXError('NO_INPUT');
1427
- log('Core.Service.getNewsArticle', input);
1428
- const newsArticle = await ctx.app.model.NewsArticle.findOne(getFilter(input)).exec();
1429
- if (!newsArticle)
1430
- throw new Error('NewsArticle not found');
1431
- return newsArticle;
1432
- }
1433
- async createNewsArticle(input, ctx) {
1434
- if (!input)
1435
- throw new ARXError('NO_INPUT');
1436
- log('Core.Service.createNewsArticle', input);
1437
- const newsArticle = await ctx.app.model.NewsArticle.create(input);
1438
- return newsArticle;
1439
- }
1440
- async updateNewsArticle(input, ctx) {
1441
- if (!input)
1442
- throw new ARXError('NO_INPUT');
1443
- log('Core.Service.updateNewsArticle', input);
1444
- const updatedNewsArticle = await ctx.app.model.NewsArticle.findByIdAndUpdate(input.where.id.equals, {
1445
- new: true,
1446
- })
1447
- .lean()
1448
- .exec();
1449
- if (!updatedNewsArticle)
1450
- throw new Error('NewsArticle update failed');
1451
- return updatedNewsArticle;
1452
- }
1453
- async getNpc(input, ctx) {
1454
- if (!input)
1455
- throw new ARXError('NO_INPUT');
1456
- log('Core.Service.getNpc', input);
1457
- const npc = await ctx.app.model.Npc.findOne(getFilter(input)).exec();
1458
- if (!npc)
1459
- throw new Error('Npc not found');
1460
- return npc;
1461
- }
1462
- async createNpc(input, ctx) {
1463
- if (!input)
1464
- throw new ARXError('NO_INPUT');
1465
- log('Core.Service.createNpc', input);
1466
- const npc = await ctx.app.model.Npc.create(input);
1467
- return npc;
1468
- }
1469
- async updateNpc(input, ctx) {
1470
- if (!input)
1471
- throw new ARXError('NO_INPUT');
1472
- log('Core.Service.updateNpc', input);
1473
- const updatedNpc = await ctx.app.model.Npc.findByIdAndUpdate(input.where.id.equals, { new: true }).exec();
1474
- if (!updatedNpc)
1475
- throw new Error('Npc update failed');
1476
- return updatedNpc;
1477
- }
1478
- async getOffer(input, ctx) {
1479
- if (!input)
1480
- throw new ARXError('NO_INPUT');
1481
- log('Core.Service.getOffer', input);
1482
- const offer = await ctx.app.model.Offer.findOne(getFilter(input)).exec();
1483
- if (!offer)
1484
- throw new Error('Offer not found');
1485
- return offer;
1486
- }
1487
- async createOffer(input, ctx) {
1488
- if (!input)
1489
- throw new ARXError('NO_INPUT');
1490
- log('Core.Service.createOffer', input);
1491
- const offer = await ctx.app.model.Offer.create(input);
1492
- return offer;
1493
- }
1494
- async updateOffer(input, ctx) {
1495
- if (!input)
1496
- throw new ARXError('NO_INPUT');
1497
- log('Core.Service.updateOffer', input);
1498
- const updatedOffer = await ctx.app.model.Offer.findByIdAndUpdate(input.where.id.equals, { new: true })
1499
- .lean()
1500
- .exec();
1501
- if (!updatedOffer)
1502
- throw new Error('Offer update failed');
1503
- return updatedOffer;
1504
- }
1505
- async getOmniverse(input, ctx) {
1506
- if (!input)
1507
- throw new ARXError('NO_INPUT');
1508
- log('Core.Service.getOmniverse', input);
1509
- const omniverse = await ctx.app.model.Omniverse.findOne(getFilter(input)).exec();
1510
- if (!omniverse)
1511
- throw new Error('Omniverse not found');
1512
- return omniverse;
1513
- }
1514
- async createOmniverse(input, ctx) {
1515
- if (!input)
1516
- throw new ARXError('NO_INPUT');
1517
- log('Core.Service.createOmniverse', input);
1518
- const omniverse = await ctx.app.model.Omniverse.create(input);
1519
- return omniverse;
1520
- }
1521
- async updateOmniverse(input, ctx) {
1522
- if (!input)
1523
- throw new ARXError('NO_INPUT');
1524
- log('Core.Service.updateOmniverse', input);
1525
- const updatedOmniverse = await ctx.app.model.Omniverse.findByIdAndUpdate(input.where.id.equals, {
1526
- new: true,
1527
- })
1528
- .lean()
1529
- .exec();
1530
- if (!updatedOmniverse)
1531
- throw new Error('Omniverse update failed');
1532
- return updatedOmniverse;
1533
- }
1534
- async getOrder(input, ctx) {
1535
- if (!input)
1536
- throw new ARXError('NO_INPUT');
1537
- log('Core.Service.getOrder', input);
1538
- const order = await ctx.app.model.Order.findOne(getFilter(input)).exec();
1539
- if (!order)
1540
- throw new Error('Order not found');
1541
- return order;
1542
- }
1543
- async createOrder(input, ctx) {
1544
- if (!input)
1545
- throw new ARXError('NO_INPUT');
1546
- log('Core.Service.createOrder', input);
1547
- const order = await ctx.app.model.Order.create(input);
1548
- return order;
1549
- }
1550
- async updateOrder(input, ctx) {
1551
- if (!input)
1552
- throw new ARXError('NO_INPUT');
1553
- log('Core.Service.updateOrder', input);
1554
- const updatedOrder = await ctx.app.model.Order.findByIdAndUpdate(input.where.id.equals, { new: true })
1555
- .lean()
1556
- .exec();
1557
- if (!updatedOrder)
1558
- throw new Error('Order update failed');
1559
- return updatedOrder;
1560
- }
1561
- async getPayment(input, ctx) {
1562
- if (!input)
1563
- throw new ARXError('NO_INPUT');
1564
- log('Core.Service.getPayment', input);
1565
- const payment = await ctx.app.model.Payment.findOne(getFilter(input)).exec();
1566
- if (!payment)
1567
- throw new Error('Payment not found');
1568
- return payment;
1569
- }
1570
- async createPayment(input, ctx) {
1571
- if (!input)
1572
- throw new ARXError('NO_INPUT');
1573
- log('Core.Service.createPayment', input);
1574
- const payment = await ctx.app.model.Payment.create(input);
1575
- return payment;
1576
- }
1577
- async updatePayment(input, ctx) {
1578
- if (!input)
1579
- throw new ARXError('NO_INPUT');
1580
- log('Core.Service.updatePayment', input);
1581
- const updatedPayment = await ctx.app.model.Payment.findByIdAndUpdate(input.where.id.equals, { new: true })
1582
- .lean()
1583
- .exec();
1584
- if (!updatedPayment)
1585
- throw new Error('Payment update failed');
1586
- return updatedPayment;
1587
- }
1588
- async getPermission(input, ctx) {
1589
- if (!input)
1590
- throw new ARXError('NO_INPUT');
1591
- log('Core.Service.getPermission', input);
1592
- const permission = await ctx.app.model.Permission.findOne(getFilter(input)).exec();
1593
- if (!permission)
1594
- throw new Error('Permission not found');
1595
- return permission;
1596
- }
1597
- async createPermission(input, ctx) {
1598
- if (!input)
1599
- throw new ARXError('NO_INPUT');
1600
- log('Core.Service.createPermission', input);
1601
- const permission = await ctx.app.model.Permission.create(input);
1602
- return permission;
1603
- }
1604
- async updatePermission(input, ctx) {
1605
- if (!input)
1606
- throw new ARXError('NO_INPUT');
1607
- log('Core.Service.updatePermission', input);
1608
- const updatedPermission = await ctx.app.model.Permission.findByIdAndUpdate(input.where.id.equals, {
1609
- new: true,
1610
- })
1611
- .lean()
1612
- .exec();
1613
- if (!updatedPermission)
1614
- throw new Error('Permission update failed');
1615
- return updatedPermission;
1616
- }
1617
- async getPerson(input, ctx) {
1618
- if (!input)
1619
- throw new ARXError('NO_INPUT');
1620
- log('Core.Service.getPerson', input);
1621
- const person = await ctx.app.model.Person.findOne(getFilter(input)).exec();
1622
- if (!person)
1623
- throw new Error('Person not found');
1624
- return person;
1625
- }
1626
- async createPerson(input, ctx) {
1627
- if (!input)
1628
- throw new ARXError('NO_INPUT');
1629
- log('Core.Service.createPerson', input);
1630
- const person = await ctx.app.model.Person.create(input);
1631
- return person;
1632
- }
1633
- async updatePerson(input, ctx) {
1634
- if (!input)
1635
- throw new ARXError('NO_INPUT');
1636
- log('Core.Service.updatePerson', input);
1637
- const updatedPerson = await ctx.app.model.Person.findByIdAndUpdate(input.where.id.equals, { new: true })
1638
- .lean()
1639
- .exec();
1640
- if (!updatedPerson)
1641
- throw new Error('Person update failed');
1642
- return updatedPerson;
1643
- }
1644
- async getPlanet(input, ctx) {
1645
- if (!input)
1646
- throw new ARXError('NO_INPUT');
1647
- log('Core.Service.getPlanet', input);
1648
- const planet = await ctx.app.model.Planet.findOne(getFilter(input)).exec();
1649
- if (!planet)
1650
- throw new Error('Planet not found');
1651
- return planet;
1652
- }
1653
- async createPlanet(input, ctx) {
1654
- if (!input)
1655
- throw new ARXError('NO_INPUT');
1656
- log('Core.Service.createPlanet', input);
1657
- const planet = await ctx.app.model.Planet.create(input);
1658
- return planet;
1659
- }
1660
- async updatePlanet(input, ctx) {
1661
- if (!input)
1662
- throw new ARXError('NO_INPUT');
1663
- log('Core.Service.updatePlanet', input);
1664
- const updatedPlanet = await ctx.app.model.Planet.findByIdAndUpdate(input.where.id.equals, { new: true })
1665
- .lean()
1666
- .exec();
1667
- if (!updatedPlanet)
1668
- throw new Error('Planet update failed');
1669
- return updatedPlanet;
1670
- }
1671
- async getPoll(input, ctx) {
1672
- if (!input)
1673
- throw new ARXError('NO_INPUT');
1674
- log('Core.Service.getPoll', input);
1675
- const poll = await ctx.app.model.Poll.findOne(getFilter(input)).exec();
1676
- if (!poll)
1677
- throw new Error('Poll not found');
1678
- return poll;
1679
- }
1680
- async createPoll(input, ctx) {
1681
- if (!input)
1682
- throw new ARXError('NO_INPUT');
1683
- log('Core.Service.createPoll', input);
1684
- const poll = await ctx.app.model.Poll.create(input);
1685
- return poll;
1686
- }
1687
- async updatePoll(input, ctx) {
1688
- if (!input)
1689
- throw new ARXError('NO_INPUT');
1690
- log('Core.Service.updatePoll', input);
1691
- const updatedPoll = await ctx.app.model.Poll.findByIdAndUpdate(input.where.id.equals, { new: true }).exec();
1692
- if (!updatedPoll)
1693
- throw new Error('Poll update failed');
1694
- return updatedPoll;
1695
- }
1696
- async getProject(input, ctx) {
1697
- if (!input)
1698
- throw new ARXError('NO_INPUT');
1699
- log('Core.Service.getProject', input);
1700
- const project = await ctx.app.model.Project.findOne(getFilter(input)).exec();
1701
- if (!project)
1702
- throw new Error('Project not found');
1703
- return project;
1704
- }
1705
- async createProject(input, ctx) {
1706
- if (!input)
1707
- throw new ARXError('NO_INPUT');
1708
- log('Core.Service.createProject', input);
1709
- const project = await ctx.app.model.Project.create(input);
1710
- return project;
1711
- }
1712
- async updateProject(input, ctx) {
1713
- if (!input)
1714
- throw new ARXError('NO_INPUT');
1715
- log('Core.Service.updateProject', input);
1716
- const updatedProject = await ctx.app.model.Project.findByIdAndUpdate(input.where.id.equals, { new: true })
1717
- .lean()
1718
- .exec();
1719
- if (!updatedProject)
1720
- throw new Error('Project update failed');
1721
- return updatedProject;
1722
- }
1723
- async getProposal(input, ctx) {
1724
- if (!input)
1725
- throw new ARXError('NO_INPUT');
1726
- log('Core.Service.getProposal', input);
1727
- const proposal = await ctx.app.model.Proposal.findOne(getFilter(input)).exec();
1728
- if (!proposal)
1729
- throw new Error('Proposal not found');
1730
- return proposal;
1731
- }
1732
- async createProposal(input, ctx) {
1733
- if (!input)
1734
- throw new ARXError('NO_INPUT');
1735
- log('Core.Service.createProposal', input);
1736
- const proposal = await ctx.app.model.Proposal.create(input);
1737
- return proposal;
1738
- }
1739
- async updateProposal(input, ctx) {
1740
- if (!input)
1741
- throw new ARXError('NO_INPUT');
1742
- log('Core.Service.updateProposal', input);
1743
- const updatedProposal = await ctx.app.model.Proposal.findByIdAndUpdate(input.where.id.equals, { new: true })
1744
- .lean()
1745
- .exec();
1746
- if (!updatedProposal)
1747
- throw new Error('Proposal update failed');
1748
- return updatedProposal;
1749
- }
1750
- async getQuest(input, ctx) {
1751
- if (!input)
1752
- throw new ARXError('NO_INPUT');
1753
- log('Core.Service.getQuest', input);
1754
- const quest = await ctx.app.model.Quest.findOne(getFilter(input)).exec();
1755
- if (!quest)
1756
- throw new Error('Quest not found');
1757
- return quest;
1758
- }
1759
- async createQuest(input, ctx) {
1760
- if (!input)
1761
- throw new ARXError('NO_INPUT');
1762
- log('Core.Service.createQuest', input);
1763
- const quest = await ctx.app.model.Quest.create(input);
1764
- return quest;
1765
- }
1766
- async updateQuest(input, ctx) {
1767
- if (!input)
1768
- throw new ARXError('NO_INPUT');
1769
- log('Core.Service.updateQuest', input);
1770
- const updatedQuest = await ctx.app.model.Quest.findByIdAndUpdate(input.where.id.equals, { new: true })
1771
- .lean()
1772
- .exec();
1773
- if (!updatedQuest)
1774
- throw new Error('Quest update failed');
1775
- return updatedQuest;
1776
- }
1777
- async getRating(input, ctx) {
1778
- if (!input)
1779
- throw new ARXError('NO_INPUT');
1780
- log('Core.Service.getRating', input);
1781
- const rating = await ctx.app.model.Rating.findOne(getFilter(input)).exec();
1782
- if (!rating)
1783
- throw new Error('Rating not found');
1784
- return rating;
1785
- }
1786
- async createRating(input, ctx) {
1787
- if (!input)
1788
- throw new ARXError('NO_INPUT');
1789
- log('Core.Service.createRating', input);
1790
- const rating = await ctx.app.model.Rating.create(input);
1791
- return rating;
1792
- }
1793
- async updateRating(input, ctx) {
1794
- if (!input)
1795
- throw new ARXError('NO_INPUT');
1796
- log('Core.Service.updateRating', input);
1797
- const updatedRating = await ctx.app.model.Rating.findByIdAndUpdate(input.where.id.equals, { new: true })
1798
- .lean()
1799
- .exec();
1800
- if (!updatedRating)
1801
- throw new Error('Rating update failed');
1802
- return updatedRating;
1803
- }
1804
- async getRealm(input, ctx) {
1805
- if (!input)
1806
- throw new ARXError('NO_INPUT');
1807
- log('Core.Service.getRealm', input);
1808
- const realm = await ctx.app.model.Realm.findOne(getFilter(input)).exec();
1809
- if (!realm)
1810
- throw new Error('Realm not found');
1811
- return realm;
1812
- }
1813
- async getRealms(input, ctx) {
1814
- log('Core.Service.getRealms', input);
1815
- const filter = getFilter(input);
1816
- filter.status = 'Online';
1817
- let realms = await ctx.app.model.Realm.find(filter).exec();
1818
- console.log('getRealms', realms);
1819
- realms = [
1820
- {
1821
- status: 'Online',
1822
- clientCount: 1,
1823
- regionCode: 'EU',
1824
- endpoint: 'evolution-realm-1.arken.gg',
1825
- gameId: '673996aec43266df5f966da6',
1826
- realmShards: [
1827
- {
1828
- status: 'Online',
1829
- clientCount: 1,
1830
- endpoint: 'evolution-realm-shard-1.arken.gg',
1831
- },
1832
- ],
1833
- },
1834
- ];
1835
- return realms;
1836
- }
1837
- async createRealm(input, ctx) {
1838
- if (!input)
1839
- throw new ARXError('NO_INPUT');
1840
- log('Core.Service.createRealm', input);
1841
- const realm = await ctx.app.model.Realm.create(input);
1842
- return realm;
1843
- }
1844
- async updateRealm(input, ctx) {
1845
- if (!input)
1846
- throw new ARXError('NO_INPUT');
1847
- log('Core.Service.updateRealm', input);
1848
- const updatedRealm = await ctx.app.model.Realm.findByIdAndUpdate(input.where.id.equals, { new: true })
1849
- .lean()
1850
- .exec();
1851
- if (!updatedRealm)
1852
- throw new Error('Realm update failed');
1853
- return updatedRealm;
1854
- }
1855
- async getRealmEvent(input, ctx) {
1856
- if (!input)
1857
- throw new ARXError('NO_INPUT');
1858
- log('Core.Service.getRealmEvent', input);
1859
- const realmEvent = await ctx.app.model.RealmEvent.findOne(getFilter(input)).exec();
1860
- if (!realmEvent)
1861
- throw new Error('RealmEvent not found');
1862
- return realmEvent;
1863
- }
1864
- async getRealmEvents(input, ctx) {
1865
- log('Core.Service.getRealmEvents', input);
1866
- const filter = getFilter(input);
1867
- filter.status = 'Online';
1868
- let realmEvents = await ctx.app.model.RealmEvent.find(filter).exec();
1869
- console.log('getRealmEvents', realmEvents);
1870
- return realmEvents;
1871
- }
1872
- async createRealmEvent(input, ctx) {
1873
- if (!input)
1874
- throw new ARXError('NO_INPUT');
1875
- log('Core.Service.createRealmEvent', input);
1876
- const realmEvent = await ctx.app.model.RealmEvent.create(input);
1877
- return realmEvent;
1878
- }
1879
- async updateRealmEvent(input, ctx) {
1880
- if (!input)
1881
- throw new ARXError('NO_INPUT');
1882
- log('Core.Service.updateRealmEvent', input);
1883
- const updatedRealmEvent = await ctx.app.model.RealmEvent.findByIdAndUpdate(input.where.id.equals, { new: true })
1884
- .lean()
1885
- .exec();
1886
- if (!updatedRealmEvent)
1887
- throw new Error('RealmEvent update failed');
1888
- return updatedRealmEvent;
1889
- }
1890
- async getRevision(input, ctx) {
1891
- if (!input)
1892
- throw new ARXError('NO_INPUT');
1893
- log('Core.Service.getRevision', input);
1894
- const revision = await ctx.app.model.Revision.findOne(getFilter(input)).exec();
1895
- if (!revision)
1896
- throw new Error('Revision not found');
1897
- return revision;
1898
- }
1899
- async createRevision(input, ctx) {
1900
- if (!input)
1901
- throw new ARXError('NO_INPUT');
1902
- log('Core.Service.createRevision', input);
1903
- const revision = await ctx.app.model.Revision.create(input);
1904
- return revision;
1905
- }
1906
- async updateRevision(input, ctx) {
1907
- if (!input)
1908
- throw new ARXError('NO_INPUT');
1909
- log('Core.Service.updateRevision', input);
1910
- const updatedRevision = await ctx.app.model.Revision.findByIdAndUpdate(input.where.id.equals, {
1911
- new: true,
1912
- })
1913
- .lean()
1914
- .exec();
1915
- if (!updatedRevision)
1916
- throw new Error('Revision update failed');
1917
- return updatedRevision;
1918
- }
1919
- async getReferral(input, ctx) {
1920
- if (!input)
1921
- throw new ARXError('NO_INPUT');
1922
- log('Core.Service.getReferral', input);
1923
- const referral = await ctx.app.model.Referral.findOne(getFilter(input)).exec();
1924
- if (!referral)
1925
- throw new Error('Referral not found');
1926
- return referral;
1927
- }
1928
- async createReferral(input, ctx) {
1929
- if (!input)
1930
- throw new ARXError('NO_INPUT');
1931
- log('Core.Service.createReferral', input);
1932
- const referral = await ctx.app.model.Referral.create(input);
1933
- return referral;
1934
- }
1935
- async updateReferral(input, ctx) {
1936
- if (!input)
1937
- throw new ARXError('NO_INPUT');
1938
- log('Core.Service.updateReferral', input);
1939
- const updatedReferral = await ctx.app.model.Referral.findByIdAndUpdate(input.where.id.equals, { new: true })
1940
- .lean()
1941
- .exec();
1942
- if (!updatedReferral)
1943
- throw new Error('Referral update failed');
1944
- return updatedReferral;
1945
- }
1946
- async getReview(input, ctx) {
1947
- if (!input)
1948
- throw new ARXError('NO_INPUT');
1949
- log('Core.Service.getReview', input);
1950
- const review = await ctx.app.model.Review.findOne(getFilter(input)).exec();
1951
- if (!review)
1952
- throw new Error('Review not found');
1953
- return review;
1954
- }
1955
- async createReview(input, ctx) {
1956
- if (!input)
1957
- throw new ARXError('NO_INPUT');
1958
- log('Core.Service.createReview', input);
1959
- const review = await ctx.app.model.Review.create(input);
1960
- return review;
1961
- }
1962
- async updateReview(input, ctx) {
1963
- if (!input)
1964
- throw new ARXError('NO_INPUT');
1965
- log('Core.Service.updateReview', input);
1966
- const updatedReview = await ctx.app.model.Review.findByIdAndUpdate(input.where.id.equals, { new: true })
1967
- .lean()
1968
- .exec();
1969
- if (!updatedReview)
1970
- throw new Error('Review update failed');
1971
- return updatedReview;
1972
- }
1973
- async getRole(input, ctx) {
1974
- if (!input)
1975
- throw new ARXError('NO_INPUT');
1976
- log('Core.Service.getRole', input);
1977
- const role = await ctx.app.model.Role.findOne(getFilter(input)).exec();
1978
- if (!role)
1979
- throw new Error('Role not found');
1980
- return role;
1981
- }
1982
- async createRole(input, ctx) {
1983
- if (!input)
1984
- throw new ARXError('NO_INPUT');
1985
- log('Core.Service.createRole', input);
1986
- const role = await ctx.app.model.Role.create(input);
1987
- return role;
1988
- }
1989
- async updateRole(input, ctx) {
1990
- if (!input)
1991
- throw new ARXError('NO_INPUT');
1992
- log('Core.Service.updateRole', input);
1993
- const updatedRole = await ctx.app.model.Role.findByIdAndUpdate(input.where.id.equals, { new: true }).exec();
1994
- if (!updatedRole)
1995
- throw new Error('Role update failed');
1996
- return updatedRole;
1997
- }
1998
- async getSeason(input, ctx) {
1999
- if (!input)
2000
- throw new ARXError('NO_INPUT');
2001
- log('Core.Service.getSeason', input);
2002
- const season = await ctx.app.model.Season.findOne(getFilter(input)).exec();
2003
- if (!season)
2004
- throw new Error('Season not found');
2005
- return season;
2006
- }
2007
- async createSeason(input, ctx) {
2008
- if (!input)
2009
- throw new ARXError('NO_INPUT');
2010
- log('Core.Service.createSeason', input);
2011
- const season = await ctx.app.model.Season.create(input);
2012
- return season;
2013
- }
2014
- async updateSeason(input, ctx) {
2015
- if (!input)
2016
- throw new ARXError('NO_INPUT');
2017
- log('Core.Service.updateSeason', input);
2018
- const updatedSeason = await ctx.app.model.Season.findByIdAndUpdate(input.where.id.equals, { new: true })
2019
- .lean()
2020
- .exec();
2021
- if (!updatedSeason)
2022
- throw new Error('Season update failed');
2023
- return updatedSeason;
2024
- }
2025
- async getRealmShard(input, ctx) {
2026
- if (!input)
2027
- throw new ARXError('NO_INPUT');
2028
- log('Core.Service.getRealmShard', input);
2029
- const server = await ctx.app.model.RealmShard.findOne(getFilter(input)).exec();
2030
- if (!server)
2031
- throw new Error('RealmShard not found');
2032
- return server;
2033
- }
2034
- async getRealmShards(input, ctx) {
2035
- log('Core.Service.getRealmShards', input);
2036
- const filter = getFilter(input);
2037
- filter.status = 'Active';
2038
- const servers = await ctx.app.model.RealmShard.find(filter).exec();
2039
- return servers;
2040
- }
2041
- async createRealmShard(input, ctx) {
2042
- if (!input)
2043
- throw new ARXError('NO_INPUT');
2044
- log('Core.Service.createRealmShard', input);
2045
- const server = await ctx.app.model.RealmShard.create(input);
2046
- return server;
2047
- }
2048
- async updateRealmShard(input, ctx) {
2049
- if (!input)
2050
- throw new ARXError('NO_INPUT');
2051
- log('Core.Service.updateRealmShard', input);
2052
- const updatedRealmShard = await ctx.app.model.RealmShard.findByIdAndUpdate(input.where.id.equals, { new: true })
2053
- .lean()
2054
- .exec();
2055
- if (!updatedRealmShard)
2056
- throw new Error('RealmShard update failed');
2057
- return updatedRealmShard;
2058
- }
2059
- async getSession(input, ctx) {
2060
- if (!input)
2061
- throw new ARXError('NO_INPUT');
2062
- log('Core.Service.getSession', input);
2063
- const session = await ctx.app.model.Session.findOne(getFilter(input)).exec();
2064
- if (!session)
2065
- throw new Error('Session not found');
2066
- return session;
2067
- }
2068
- async createSession(input, ctx) {
2069
- if (!input)
2070
- throw new ARXError('NO_INPUT');
2071
- log('Core.Service.createSession', input);
2072
- const session = await ctx.app.model.Session.create(input);
2073
- return session;
2074
- }
2075
- async updateSession(input, ctx) {
2076
- if (!input)
2077
- throw new ARXError('NO_INPUT');
2078
- log('Core.Service.updateSession', input);
2079
- const updatedSession = await ctx.app.model.Session.findByIdAndUpdate(input.where.id.equals, { new: true })
2080
- .lean()
2081
- .exec();
2082
- if (!updatedSession)
2083
- throw new Error('Session update failed');
2084
- return updatedSession;
2085
- }
2086
- async getSolarSystem(input, ctx) {
2087
- if (!input)
2088
- throw new ARXError('NO_INPUT');
2089
- log('Core.Service.getSolarSystem', input);
2090
- const solarSystem = await ctx.app.model.SolarSystem.findOne(getFilter(input)).exec();
2091
- if (!solarSystem)
2092
- throw new Error('SolarSystem not found');
2093
- return solarSystem;
2094
- }
2095
- async createSolarSystem(input, ctx) {
2096
- if (!input)
2097
- throw new ARXError('NO_INPUT');
2098
- log('Core.Service.createSolarSystem', input);
2099
- const solarSystem = await ctx.app.model.SolarSystem.create(input);
2100
- return solarSystem;
2101
- }
2102
- async updateSolarSystem(input, ctx) {
2103
- if (!input)
2104
- throw new ARXError('NO_INPUT');
2105
- log('Core.Service.updateSolarSystem', input);
2106
- const updatedSolarSystem = await ctx.app.model.SolarSystem.findByIdAndUpdate(input.where.id.equals, {
2107
- new: true,
2108
- })
2109
- .lean()
2110
- .exec();
2111
- if (!updatedSolarSystem)
2112
- throw new Error('SolarSystem update failed');
2113
- return updatedSolarSystem;
2114
- }
2115
- async getStar(input, ctx) {
2116
- if (!input)
2117
- throw new ARXError('NO_INPUT');
2118
- log('Core.Service.getStar', input);
2119
- const star = await ctx.app.model.Star.findOne(getFilter(input)).exec();
2120
- if (!star)
2121
- throw new Error('Star not found');
2122
- return star;
2123
- }
2124
- async createStar(input, ctx) {
2125
- if (!input)
2126
- throw new ARXError('NO_INPUT');
2127
- log('Core.Service.createStar', input);
2128
- const star = await ctx.app.model.Star.create(input);
2129
- return star;
2130
- }
2131
- async updateStar(input, ctx) {
2132
- if (!input)
2133
- throw new ARXError('NO_INPUT');
2134
- log('Core.Service.updateStar', input);
2135
- const updatedStar = await ctx.app.model.Star.findByIdAndUpdate(input.where.id.equals, { new: true }).exec();
2136
- if (!updatedStar)
2137
- throw new Error('Star update failed');
2138
- return updatedStar;
2139
- }
2140
- async getStash(input, ctx) {
2141
- if (!input)
2142
- throw new ARXError('NO_INPUT');
2143
- log('Core.Service.getStash', input);
2144
- const stash = await ctx.app.model.Stash.findOne(getFilter(input)).exec();
2145
- if (!stash)
2146
- throw new Error('Stash not found');
2147
- return stash;
2148
- }
2149
- async createStash(input, ctx) {
2150
- if (!input)
2151
- throw new ARXError('NO_INPUT');
2152
- log('Core.Service.createStash', input);
2153
- const stash = await ctx.app.model.Stash.create(input);
2154
- return stash;
2155
- }
2156
- async updateStash(input, ctx) {
2157
- if (!input)
2158
- throw new ARXError('NO_INPUT');
2159
- log('Core.Service.updateStash', input);
2160
- const updatedStash = await ctx.app.model.Stash.findByIdAndUpdate(input.where.id.equals, { new: true })
2161
- .lean()
2162
- .exec();
2163
- if (!updatedStash)
2164
- throw new Error('Stash update failed');
2165
- return updatedStash;
2166
- }
2167
- async getStock(input, ctx) {
2168
- if (!input)
2169
- throw new ARXError('NO_INPUT');
2170
- log('Core.Service.getStock', input);
2171
- const stock = await ctx.app.model.Stock.findOne(getFilter(input)).exec();
2172
- if (!stock)
2173
- throw new Error('Stock not found');
2174
- return stock;
2175
- }
2176
- async createStock(input, ctx) {
2177
- if (!input)
2178
- throw new ARXError('NO_INPUT');
2179
- log('Core.Service.createStock', input);
2180
- const stock = await ctx.app.model.Stock.create(input);
2181
- return stock;
2182
- }
2183
- async updateStock(input, ctx) {
2184
- if (!input)
2185
- throw new ARXError('NO_INPUT');
2186
- log('Core.Service.updateStock', input);
2187
- const updatedStock = await ctx.app.model.Stock.findByIdAndUpdate(input.where.id.equals, { new: true })
2188
- .lean()
2189
- .exec();
2190
- if (!updatedStock)
2191
- throw new Error('Stock update failed');
2192
- return updatedStock;
2193
- }
2194
- async getSuggestion(input, ctx) {
2195
- if (!input)
2196
- throw new ARXError('NO_INPUT');
2197
- log('Core.Service.getSuggestion', input);
2198
- const suggestion = await ctx.app.model.Suggestion.findOne(getFilter(input)).exec();
2199
- if (!suggestion)
2200
- throw new Error('Suggestion not found');
2201
- return suggestion;
2202
- }
2203
- async createSuggestion(input, ctx) {
2204
- if (!input)
2205
- throw new ARXError('NO_INPUT');
2206
- log('Core.Service.createSuggestion', input);
2207
- const suggestion = await ctx.app.model.Suggestion.create(input);
2208
- return suggestion;
2209
- }
2210
- async updateSuggestion(input, ctx) {
2211
- if (!input)
2212
- throw new ARXError('NO_INPUT');
2213
- log('Core.Service.updateSuggestion', input);
2214
- const updatedSuggestion = await ctx.app.model.Suggestion.findByIdAndUpdate(input.where.id.equals, {
2215
- new: true,
2216
- })
2217
- .lean()
2218
- .exec();
2219
- if (!updatedSuggestion)
2220
- throw new Error('Suggestion update failed');
2221
- return updatedSuggestion;
2222
- }
2223
- async getTag(input, ctx) {
2224
- if (!input)
2225
- throw new ARXError('NO_INPUT');
2226
- log('Core.Service.getTag', input);
2227
- const tag = await ctx.app.model.Tag.findOne(getFilter(input)).exec();
2228
- if (!tag)
2229
- throw new Error('Tag not found');
2230
- return tag;
2231
- }
2232
- async createTag(input, ctx) {
2233
- if (!input)
2234
- throw new ARXError('NO_INPUT');
2235
- log('Core.Service.createTag', input);
2236
- const tag = await ctx.app.model.Tag.create(input);
2237
- return tag;
2238
- }
2239
- async updateTag(input, ctx) {
2240
- if (!input)
2241
- throw new ARXError('NO_INPUT');
2242
- log('Core.Service.updateTag', input);
2243
- const updatedTag = await ctx.app.model.Tag.findByIdAndUpdate(input.where.id.equals, { new: true }).exec();
2244
- if (!updatedTag)
2245
- throw new Error('Tag update failed');
2246
- return updatedTag;
2247
- }
2248
- async getTeam(input, ctx) {
2249
- if (!input)
2250
- throw new ARXError('NO_INPUT');
2251
- log('Core.Service.getTeam', input);
2252
- const filter = getFilter(input);
2253
- const team = await ctx.app.model.Team.findOne(filter).exec();
2254
- if (!team)
2255
- throw new Error('Team not found');
2256
- return team;
2257
- }
2258
- async getTeams(input, ctx) {
2259
- if (!input)
2260
- throw new ARXError('NO_INPUT');
2261
- log('Core.Service.getTeams', input);
2262
- const filter = getFilter(input);
2263
- const teams = await ctx.app.model.Team.find(filter)
2264
- .skip(input.skip || 0)
2265
- .limit(input.limit || 10)
2266
- .exec();
2267
- return teams;
2268
- }
2269
- async createTeam(input, ctx) {
2270
- if (!input)
2271
- throw new ARXError('NO_INPUT');
2272
- log('Core.Service.createTeam', input);
2273
- const team = await ctx.app.model.Team.create(input);
2274
- return team;
2275
- }
2276
- async updateTeam(input, ctx) {
2277
- if (!input)
2278
- throw new ARXError('NO_INPUT');
2279
- log('Core.Service.updateTeam', input);
2280
- const updatedTeam = await ctx.app.model.Team.findByIdAndUpdate(input.where.id.equals, { new: true }).exec();
2281
- if (!updatedTeam)
2282
- throw new Error('Team update failed');
2283
- return updatedTeam;
2284
- }
2285
- async getTournament(input, ctx) {
2286
- if (!input)
2287
- throw new ARXError('NO_INPUT');
2288
- log('Core.Service.getTournament', input);
2289
- const tournament = await ctx.app.model.Tournament.findOne(getFilter(input)).exec();
2290
- if (!tournament)
2291
- throw new Error('Tournament not found');
2292
- return tournament;
2293
- }
2294
- async createTournament(input, ctx) {
2295
- if (!input)
2296
- throw new ARXError('NO_INPUT');
2297
- log('Core.Service.createTournament', input);
2298
- const tournament = await ctx.app.model.Tournament.create(input);
2299
- return tournament;
2300
- }
2301
- async updateTournament(input, ctx) {
2302
- if (!input)
2303
- throw new ARXError('NO_INPUT');
2304
- log('Core.Service.updateTournament', input);
2305
- const updatedTournament = await ctx.app.model.Tournament.findByIdAndUpdate(input.where.id.equals, {
2306
- new: true,
2307
- })
2308
- .lean()
2309
- .exec();
2310
- if (!updatedTournament)
2311
- throw new Error('Tournament update failed');
2312
- return updatedTournament;
2313
- }
2314
- async getTrade(input, ctx) {
2315
- if (!input)
2316
- throw new ARXError('NO_INPUT');
2317
- log('Core.Service.getTrade', input);
2318
- const trade = await ctx.app.model.Trade.findOne(getFilter(input)).exec();
2319
- if (!trade)
2320
- throw new Error('Trade not found');
2321
- return trade;
2322
- }
2323
- async getTrades(input, ctx) {
2324
- if (!input)
2325
- throw new ARXError('NO_INPUT');
2326
- log('Core.Service.getTrades', input);
2327
- const trade = await ctx.app.model.Trade.find().limit(10).exec();
2328
- return trade;
2329
- }
2330
- async createTrade(input, ctx) {
2331
- if (!input)
2332
- throw new ARXError('NO_INPUT');
2333
- log('Core.Service.createTrade', input);
2334
- const trade = await ctx.app.model.Trade.create(input);
2335
- return trade;
2336
- }
2337
- async updateTrade(input, ctx) {
2338
- if (!input)
2339
- throw new ARXError('NO_INPUT');
2340
- log('Core.Service.updateTrade', input);
2341
- const updatedTrade = await ctx.app.model.Trade.findByIdAndUpdate(input.where.id.equals, { new: true })
2342
- .lean()
2343
- .exec();
2344
- if (!updatedTrade)
2345
- throw new Error('Trade update failed');
2346
- return updatedTrade;
2347
- }
2348
- async getUniverse(input, ctx) {
2349
- if (!input)
2350
- throw new ARXError('NO_INPUT');
2351
- log('Core.Service.getUniverse', input);
2352
- const universe = await ctx.app.model.Universe.findOne(getFilter(input)).exec();
2353
- if (!universe)
2354
- throw new Error('Universe not found');
2355
- return universe;
2356
- }
2357
- async createUniverse(input, ctx) {
2358
- if (!input)
2359
- throw new ARXError('NO_INPUT');
2360
- log('Core.Service.createUniverse', input);
2361
- const universe = await ctx.app.model.Universe.create(input);
2362
- return universe;
2363
- }
2364
- async updateUniverse(input, ctx) {
2365
- if (!input)
2366
- throw new ARXError('NO_INPUT');
2367
- log('Core.Service.updateUniverse', input);
2368
- const updatedUniverse = await ctx.app.model.Universe.findByIdAndUpdate(input.where.id.equals, { new: true })
2369
- .lean()
2370
- .exec();
2371
- if (!updatedUniverse)
2372
- throw new Error('Universe update failed');
2373
- return updatedUniverse;
2374
- }
2375
- async getValidator(input, ctx) {
2376
- if (!input)
2377
- throw new ARXError('NO_INPUT');
2378
- log('Core.Service.getValidator', input);
2379
- const validator = await ctx.app.model.Validator.findOne(getFilter(input)).exec();
2380
- if (!validator)
2381
- throw new Error('Validator not found');
2382
- return validator;
2383
- }
2384
- async createValidator(input, ctx) {
2385
- if (!input)
2386
- throw new ARXError('NO_INPUT');
2387
- log('Core.Service.createValidator', input);
2388
- const validator = await ctx.app.model.Validator.create(input);
2389
- return validator;
2390
- }
2391
- async updateValidator(input, ctx) {
2392
- if (!input)
2393
- throw new ARXError('NO_INPUT');
2394
- log('Core.Service.updateValidator', input);
2395
- const updatedValidator = await ctx.app.model.Validator.findByIdAndUpdate(input.where.id.equals, {
2396
- new: true,
2397
- })
2398
- .lean()
2399
- .exec();
2400
- if (!updatedValidator)
2401
- throw new Error('Validator update failed');
2402
- return updatedValidator;
2403
- }
2404
- async getVote(input, ctx) {
2405
- if (!input)
2406
- throw new ARXError('NO_INPUT');
2407
- log('Core.Service.getVote', input);
2408
- const vote = await ctx.app.model.Vote.findOne(getFilter(input)).exec();
2409
- if (!vote)
2410
- throw new Error('Vote not found');
2411
- return vote;
2412
- }
2413
- async createVote(input, ctx) {
2414
- if (!input)
2415
- throw new ARXError('NO_INPUT');
2416
- log('Core.Service.createVote', input);
2417
- const vote = await ctx.app.model.Vote.create(input);
2418
- return vote;
2419
- }
2420
- async updateVote(input, ctx) {
2421
- if (!input)
2422
- throw new ARXError('NO_INPUT');
2423
- log('Core.Service.updateVote', input);
2424
- const updatedVote = await ctx.app.model.Vote.findByIdAndUpdate(input.where.id.equals, { new: true }).exec();
2425
- if (!updatedVote)
2426
- throw new Error('Vote update failed');
2427
- return updatedVote;
2428
- }
2429
- async getWorldEvent(input, ctx) {
2430
- if (!input)
2431
- throw new ARXError('NO_INPUT');
2432
- log('Core.Service.getWorldEvent', input);
2433
- const worldEvent = await ctx.app.model.WorldEvent.findOne(getFilter(input)).exec();
2434
- if (!worldEvent)
2435
- throw new Error('WorldEvent not found');
2436
- return worldEvent;
2437
- }
2438
- async createWorldEvent(input, ctx) {
2439
- if (!input)
2440
- throw new ARXError('NO_INPUT');
2441
- log('Core.Service.createWorldEvent', input);
2442
- const worldEvent = await ctx.app.model.WorldEvent.create(input);
2443
- return worldEvent;
2444
- }
2445
- async updateWorldEvent(input, ctx) {
2446
- if (!input)
2447
- throw new ARXError('NO_INPUT');
2448
- log('Core.Service.updateWorldEvent', input);
2449
- const updatedWorldEvent = await ctx.app.model.WorldEvent.findByIdAndUpdate(input.where.id.equals, {
2450
- new: true,
2451
- })
2452
- .lean()
2453
- .exec();
2454
- if (!updatedWorldEvent)
2455
- throw new Error('WorldEvent update failed');
2456
- return updatedWorldEvent;
2457
- }
2458
- async getWorldRecord(input, ctx) {
2459
- if (!input)
2460
- throw new ARXError('NO_INPUT');
2461
- log('Core.Service.getWorldRecord', input);
2462
- const worldRecord = await ctx.app.model.WorldRecord.findOne(getFilter(input)).exec();
2463
- if (!worldRecord)
2464
- throw new Error('WorldRecord not found');
2465
- return worldRecord;
2466
- }
2467
- async createWorldRecord(input, ctx) {
2468
- if (!input)
2469
- throw new ARXError('NO_INPUT');
2470
- log('Core.Service.createWorldRecord', input);
2471
- const worldRecord = await ctx.app.model.WorldRecord.create(input);
2472
- return worldRecord;
2473
- }
2474
- async updateWorldRecord(input, ctx) {
2475
- if (!input)
2476
- throw new ARXError('NO_INPUT');
2477
- log('Core.Service.updateWorldRecord', input);
2478
- const updatedWorldRecord = await ctx.app.model.WorldRecord.findByIdAndUpdate(input.where.id.equals, {
2479
- new: true,
2480
- })
2481
- .lean()
2482
- .exec();
2483
- if (!updatedWorldRecord)
2484
- throw new Error('WorldRecord update failed');
2485
- return updatedWorldRecord;
2486
- }
2487
- async getBounty(input, ctx) {
2488
- if (!input)
2489
- throw new ARXError('NO_INPUT');
2490
- log('Core.Service.getBounty', input);
2491
- const bounty = await ctx.app.model.Bounty.findOne(getFilter(input)).exec();
2492
- if (!bounty)
2493
- throw new Error('Bounty not found');
2494
- return bounty;
2495
- }
2496
- async createBounty(input, ctx) {
2497
- if (!input)
2498
- throw new ARXError('NO_INPUT');
2499
- log('Core.Service.createBounty', input);
2500
- const bounty = await ctx.app.model.Bounty.create(input);
2501
- return bounty;
2502
- }
2503
- async updateBounty(input, ctx) {
2504
- if (!input)
2505
- throw new ARXError('NO_INPUT');
2506
- log('Core.Service.updateBounty', input);
2507
- const updatedBounty = await ctx.app.model.Bounty.findByIdAndUpdate(input.where.id.equals, { new: true })
2508
- .lean()
2509
- .exec();
2510
- if (!updatedBounty)
2511
- throw new Error('Bounty update failed');
2512
- return updatedBounty;
2513
- }
2514
- }
2515
- //# sourceMappingURL=core.service.js.map