@temboplus/afloat 0.1.0

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 (335) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +21 -0
  3. package/esm/_dnt.test_shims.d.ts.map +1 -0
  4. package/esm/deps/jsr.io/@std/assert/1.0.10/almost_equals.d.ts.map +1 -0
  5. package/esm/deps/jsr.io/@std/assert/1.0.10/array_includes.d.ts.map +1 -0
  6. package/esm/deps/jsr.io/@std/assert/1.0.10/assert.d.ts.map +1 -0
  7. package/esm/deps/jsr.io/@std/assert/1.0.10/assertion_error.d.ts.map +1 -0
  8. package/esm/deps/jsr.io/@std/assert/1.0.10/equal.d.ts.map +1 -0
  9. package/esm/deps/jsr.io/@std/assert/1.0.10/equals.d.ts.map +1 -0
  10. package/esm/deps/jsr.io/@std/assert/1.0.10/exists.d.ts.map +1 -0
  11. package/esm/deps/jsr.io/@std/assert/1.0.10/fail.d.ts.map +1 -0
  12. package/esm/deps/jsr.io/@std/assert/1.0.10/false.d.ts.map +1 -0
  13. package/esm/deps/jsr.io/@std/assert/1.0.10/greater.d.ts.map +1 -0
  14. package/esm/deps/jsr.io/@std/assert/1.0.10/greater_or_equal.d.ts.map +1 -0
  15. package/esm/deps/jsr.io/@std/assert/1.0.10/instance_of.d.ts.map +1 -0
  16. package/esm/deps/jsr.io/@std/assert/1.0.10/is_error.d.ts.map +1 -0
  17. package/esm/deps/jsr.io/@std/assert/1.0.10/less.d.ts.map +1 -0
  18. package/esm/deps/jsr.io/@std/assert/1.0.10/less_or_equal.d.ts.map +1 -0
  19. package/esm/deps/jsr.io/@std/assert/1.0.10/match.d.ts.map +1 -0
  20. package/esm/deps/jsr.io/@std/assert/1.0.10/mod.d.ts.map +1 -0
  21. package/esm/deps/jsr.io/@std/assert/1.0.10/not_equals.d.ts.map +1 -0
  22. package/esm/deps/jsr.io/@std/assert/1.0.10/not_instance_of.d.ts.map +1 -0
  23. package/esm/deps/jsr.io/@std/assert/1.0.10/not_match.d.ts.map +1 -0
  24. package/esm/deps/jsr.io/@std/assert/1.0.10/not_strict_equals.d.ts.map +1 -0
  25. package/esm/deps/jsr.io/@std/assert/1.0.10/object_match.d.ts.map +1 -0
  26. package/esm/deps/jsr.io/@std/assert/1.0.10/rejects.d.ts.map +1 -0
  27. package/esm/deps/jsr.io/@std/assert/1.0.10/strict_equals.d.ts.map +1 -0
  28. package/esm/deps/jsr.io/@std/assert/1.0.10/string_includes.d.ts.map +1 -0
  29. package/esm/deps/jsr.io/@std/assert/1.0.10/throws.d.ts.map +1 -0
  30. package/esm/deps/jsr.io/@std/assert/1.0.10/unimplemented.d.ts.map +1 -0
  31. package/esm/deps/jsr.io/@std/assert/1.0.10/unreachable.d.ts.map +1 -0
  32. package/esm/deps/jsr.io/@std/internal/1.0.5/build_message.d.ts.map +1 -0
  33. package/esm/deps/jsr.io/@std/internal/1.0.5/diff.d.ts.map +1 -0
  34. package/esm/deps/jsr.io/@std/internal/1.0.5/diff_str.d.ts.map +1 -0
  35. package/esm/deps/jsr.io/@std/internal/1.0.5/format.d.ts.map +1 -0
  36. package/esm/deps/jsr.io/@std/internal/1.0.5/styles.d.ts.map +1 -0
  37. package/esm/deps/jsr.io/@std/internal/1.0.5/types.d.ts.map +1 -0
  38. package/esm/mod.d.ts +7 -0
  39. package/esm/mod.d.ts.map +1 -0
  40. package/esm/mod.js +6 -0
  41. package/esm/package.json +3 -0
  42. package/esm/src/errors/api_error.d.ts +63 -0
  43. package/esm/src/errors/api_error.d.ts.map +1 -0
  44. package/esm/src/errors/api_error.js +90 -0
  45. package/esm/src/errors/index.d.ts +3 -0
  46. package/esm/src/errors/index.d.ts.map +1 -0
  47. package/esm/src/errors/index.js +2 -0
  48. package/esm/src/errors/permission_error.d.ts +48 -0
  49. package/esm/src/errors/permission_error.d.ts.map +1 -0
  50. package/esm/src/errors/permission_error.js +70 -0
  51. package/esm/src/features/auth/contract.d.ts +123 -0
  52. package/esm/src/features/auth/contract.d.ts.map +1 -0
  53. package/esm/src/features/auth/contract.js +50 -0
  54. package/esm/src/features/auth/index.d.ts +2 -0
  55. package/esm/src/features/auth/index.d.ts.map +1 -0
  56. package/esm/src/features/auth/index.js +1 -0
  57. package/esm/src/features/auth/manager.d.ts +71 -0
  58. package/esm/src/features/auth/manager.d.ts.map +1 -0
  59. package/esm/src/features/auth/manager.js +118 -0
  60. package/esm/src/features/auth/repository.d.ts +30 -0
  61. package/esm/src/features/auth/repository.d.ts.map +1 -0
  62. package/esm/src/features/auth/repository.js +94 -0
  63. package/esm/src/features/contact/contract.d.ts +170 -0
  64. package/esm/src/features/contact/contract.d.ts.map +1 -0
  65. package/esm/src/features/contact/contract.js +49 -0
  66. package/esm/src/features/contact/index.d.ts +2 -0
  67. package/esm/src/features/contact/index.d.ts.map +1 -0
  68. package/esm/src/features/contact/index.js +1 -0
  69. package/esm/src/features/contact/repository.d.ts +47 -0
  70. package/esm/src/features/contact/repository.d.ts.map +1 -0
  71. package/esm/src/features/contact/repository.js +94 -0
  72. package/esm/src/features/files-gen/contract.d.ts +67 -0
  73. package/esm/src/features/files-gen/contract.d.ts.map +1 -0
  74. package/esm/src/features/files-gen/contract.js +40 -0
  75. package/esm/src/features/files-gen/repository.d.ts +47 -0
  76. package/esm/src/features/files-gen/repository.d.ts.map +1 -0
  77. package/esm/src/features/files-gen/repository.js +48 -0
  78. package/esm/src/features/payout/contract.d.ts +623 -0
  79. package/esm/src/features/payout/contract.d.ts.map +1 -0
  80. package/esm/src/features/payout/contract.js +75 -0
  81. package/esm/src/features/payout/index.d.ts +2 -0
  82. package/esm/src/features/payout/index.d.ts.map +1 -0
  83. package/esm/src/features/payout/index.js +1 -0
  84. package/esm/src/features/payout/repository.d.ts +62 -0
  85. package/esm/src/features/payout/repository.d.ts.map +1 -0
  86. package/esm/src/features/payout/repository.js +158 -0
  87. package/esm/src/features/wallet/contract.d.ts +103 -0
  88. package/esm/src/features/wallet/contract.d.ts.map +1 -0
  89. package/esm/src/features/wallet/contract.js +35 -0
  90. package/esm/src/features/wallet/index.d.ts +2 -0
  91. package/esm/src/features/wallet/index.d.ts.map +1 -0
  92. package/esm/src/features/wallet/index.js +1 -0
  93. package/esm/src/features/wallet/repository.d.ts +74 -0
  94. package/esm/src/features/wallet/repository.d.ts.map +1 -0
  95. package/esm/src/features/wallet/repository.js +132 -0
  96. package/esm/src/models/contact/derivatives/contact.d.ts +168 -0
  97. package/esm/src/models/contact/derivatives/contact.d.ts.map +1 -0
  98. package/esm/src/models/contact/derivatives/contact.js +260 -0
  99. package/esm/src/models/contact/derivatives/contact.test.d.ts.map +1 -0
  100. package/esm/src/models/contact/derivatives/contact_info.d.ts +188 -0
  101. package/esm/src/models/contact/derivatives/contact_info.d.ts.map +1 -0
  102. package/esm/src/models/contact/derivatives/contact_info.js +255 -0
  103. package/esm/src/models/contact/derivatives/contact_info.test.d.ts.map +1 -0
  104. package/esm/src/models/contact/index.d.ts +5 -0
  105. package/esm/src/models/contact/index.d.ts.map +1 -0
  106. package/esm/src/models/contact/index.js +4 -0
  107. package/esm/src/models/contact/schemas.d.ts +66 -0
  108. package/esm/src/models/contact/schemas.d.ts.map +1 -0
  109. package/esm/src/models/contact/schemas.js +64 -0
  110. package/esm/src/models/contact/validation.d.ts +37 -0
  111. package/esm/src/models/contact/validation.d.ts.map +1 -0
  112. package/esm/src/models/contact/validation.js +139 -0
  113. package/esm/src/models/contact/validation.test.d.ts.map +1 -0
  114. package/esm/src/models/index.d.ts +6 -0
  115. package/esm/src/models/index.d.ts.map +1 -0
  116. package/esm/src/models/index.js +5 -0
  117. package/esm/src/models/payout/api.d.ts +29 -0
  118. package/esm/src/models/payout/api.d.ts.map +1 -0
  119. package/esm/src/models/payout/api.js +1 -0
  120. package/esm/src/models/payout/channel.d.ts +58 -0
  121. package/esm/src/models/payout/channel.d.ts.map +1 -0
  122. package/esm/src/models/payout/channel.js +46 -0
  123. package/esm/src/models/payout/derivatives/payout.d.ts +156 -0
  124. package/esm/src/models/payout/derivatives/payout.d.ts.map +1 -0
  125. package/esm/src/models/payout/derivatives/payout.js +261 -0
  126. package/esm/src/models/payout/derivatives/payout.test.d.ts.map +1 -0
  127. package/esm/src/models/payout/index.d.ts +6 -0
  128. package/esm/src/models/payout/index.d.ts.map +1 -0
  129. package/esm/src/models/payout/index.js +5 -0
  130. package/esm/src/models/payout/schemas.d.ts +154 -0
  131. package/esm/src/models/payout/schemas.d.ts.map +1 -0
  132. package/esm/src/models/payout/schemas.js +103 -0
  133. package/esm/src/models/payout/status.d.ts +31 -0
  134. package/esm/src/models/payout/status.d.ts.map +1 -0
  135. package/esm/src/models/payout/status.js +32 -0
  136. package/esm/src/models/permission.d.ts +42 -0
  137. package/esm/src/models/permission.d.ts.map +1 -0
  138. package/esm/src/models/permission.js +37 -0
  139. package/esm/src/models/user/index.d.ts +3 -0
  140. package/esm/src/models/user/index.d.ts.map +1 -0
  141. package/esm/src/models/user/index.js +2 -0
  142. package/esm/src/models/user/profile.d.ts +38 -0
  143. package/esm/src/models/user/profile.d.ts.map +1 -0
  144. package/esm/src/models/user/profile.js +25 -0
  145. package/esm/src/models/user/user.d.ts +80 -0
  146. package/esm/src/models/user/user.d.ts.map +1 -0
  147. package/esm/src/models/user/user.js +149 -0
  148. package/esm/src/models/wallet/guards.d.ts +11 -0
  149. package/esm/src/models/wallet/guards.d.ts.map +1 -0
  150. package/esm/src/models/wallet/guards.js +14 -0
  151. package/esm/src/models/wallet/index.d.ts +4 -0
  152. package/esm/src/models/wallet/index.d.ts.map +1 -0
  153. package/esm/src/models/wallet/index.js +3 -0
  154. package/esm/src/models/wallet/schemas.d.ts +50 -0
  155. package/esm/src/models/wallet/schemas.d.ts.map +1 -0
  156. package/esm/src/models/wallet/schemas.js +64 -0
  157. package/esm/src/models/wallet/statement.d.ts +27 -0
  158. package/esm/src/models/wallet/statement.d.ts.map +1 -0
  159. package/esm/src/models/wallet/statement.js +13 -0
  160. package/esm/src/shared/base_repository.d.ts +56 -0
  161. package/esm/src/shared/base_repository.d.ts.map +1 -0
  162. package/esm/src/shared/base_repository.js +95 -0
  163. package/esm/src/shared/common_responses.d.ts +13 -0
  164. package/esm/src/shared/common_responses.d.ts.map +1 -0
  165. package/esm/src/shared/common_responses.js +10 -0
  166. package/esm/src/shared/index.d.ts +3 -0
  167. package/esm/src/shared/index.d.ts.map +1 -0
  168. package/esm/src/shared/index.js +2 -0
  169. package/package.json +40 -0
  170. package/script/_dnt.test_shims.d.ts.map +1 -0
  171. package/script/deps/jsr.io/@std/assert/1.0.10/almost_equals.d.ts.map +1 -0
  172. package/script/deps/jsr.io/@std/assert/1.0.10/array_includes.d.ts.map +1 -0
  173. package/script/deps/jsr.io/@std/assert/1.0.10/assert.d.ts.map +1 -0
  174. package/script/deps/jsr.io/@std/assert/1.0.10/assertion_error.d.ts.map +1 -0
  175. package/script/deps/jsr.io/@std/assert/1.0.10/equal.d.ts.map +1 -0
  176. package/script/deps/jsr.io/@std/assert/1.0.10/equals.d.ts.map +1 -0
  177. package/script/deps/jsr.io/@std/assert/1.0.10/exists.d.ts.map +1 -0
  178. package/script/deps/jsr.io/@std/assert/1.0.10/fail.d.ts.map +1 -0
  179. package/script/deps/jsr.io/@std/assert/1.0.10/false.d.ts.map +1 -0
  180. package/script/deps/jsr.io/@std/assert/1.0.10/greater.d.ts.map +1 -0
  181. package/script/deps/jsr.io/@std/assert/1.0.10/greater_or_equal.d.ts.map +1 -0
  182. package/script/deps/jsr.io/@std/assert/1.0.10/instance_of.d.ts.map +1 -0
  183. package/script/deps/jsr.io/@std/assert/1.0.10/is_error.d.ts.map +1 -0
  184. package/script/deps/jsr.io/@std/assert/1.0.10/less.d.ts.map +1 -0
  185. package/script/deps/jsr.io/@std/assert/1.0.10/less_or_equal.d.ts.map +1 -0
  186. package/script/deps/jsr.io/@std/assert/1.0.10/match.d.ts.map +1 -0
  187. package/script/deps/jsr.io/@std/assert/1.0.10/mod.d.ts.map +1 -0
  188. package/script/deps/jsr.io/@std/assert/1.0.10/not_equals.d.ts.map +1 -0
  189. package/script/deps/jsr.io/@std/assert/1.0.10/not_instance_of.d.ts.map +1 -0
  190. package/script/deps/jsr.io/@std/assert/1.0.10/not_match.d.ts.map +1 -0
  191. package/script/deps/jsr.io/@std/assert/1.0.10/not_strict_equals.d.ts.map +1 -0
  192. package/script/deps/jsr.io/@std/assert/1.0.10/object_match.d.ts.map +1 -0
  193. package/script/deps/jsr.io/@std/assert/1.0.10/rejects.d.ts.map +1 -0
  194. package/script/deps/jsr.io/@std/assert/1.0.10/strict_equals.d.ts.map +1 -0
  195. package/script/deps/jsr.io/@std/assert/1.0.10/string_includes.d.ts.map +1 -0
  196. package/script/deps/jsr.io/@std/assert/1.0.10/throws.d.ts.map +1 -0
  197. package/script/deps/jsr.io/@std/assert/1.0.10/unimplemented.d.ts.map +1 -0
  198. package/script/deps/jsr.io/@std/assert/1.0.10/unreachable.d.ts.map +1 -0
  199. package/script/deps/jsr.io/@std/internal/1.0.5/build_message.d.ts.map +1 -0
  200. package/script/deps/jsr.io/@std/internal/1.0.5/diff.d.ts.map +1 -0
  201. package/script/deps/jsr.io/@std/internal/1.0.5/diff_str.d.ts.map +1 -0
  202. package/script/deps/jsr.io/@std/internal/1.0.5/format.d.ts.map +1 -0
  203. package/script/deps/jsr.io/@std/internal/1.0.5/styles.d.ts.map +1 -0
  204. package/script/deps/jsr.io/@std/internal/1.0.5/types.d.ts.map +1 -0
  205. package/script/mod.d.ts +7 -0
  206. package/script/mod.d.ts.map +1 -0
  207. package/script/mod.js +22 -0
  208. package/script/package.json +3 -0
  209. package/script/src/errors/api_error.d.ts +63 -0
  210. package/script/src/errors/api_error.d.ts.map +1 -0
  211. package/script/src/errors/api_error.js +94 -0
  212. package/script/src/errors/index.d.ts +3 -0
  213. package/script/src/errors/index.d.ts.map +1 -0
  214. package/script/src/errors/index.js +18 -0
  215. package/script/src/errors/permission_error.d.ts +48 -0
  216. package/script/src/errors/permission_error.d.ts.map +1 -0
  217. package/script/src/errors/permission_error.js +74 -0
  218. package/script/src/features/auth/contract.d.ts +123 -0
  219. package/script/src/features/auth/contract.d.ts.map +1 -0
  220. package/script/src/features/auth/contract.js +53 -0
  221. package/script/src/features/auth/index.d.ts +2 -0
  222. package/script/src/features/auth/index.d.ts.map +1 -0
  223. package/script/src/features/auth/index.js +17 -0
  224. package/script/src/features/auth/manager.d.ts +71 -0
  225. package/script/src/features/auth/manager.d.ts.map +1 -0
  226. package/script/src/features/auth/manager.js +122 -0
  227. package/script/src/features/auth/repository.d.ts +30 -0
  228. package/script/src/features/auth/repository.d.ts.map +1 -0
  229. package/script/src/features/auth/repository.js +98 -0
  230. package/script/src/features/contact/contract.d.ts +170 -0
  231. package/script/src/features/contact/contract.d.ts.map +1 -0
  232. package/script/src/features/contact/contract.js +52 -0
  233. package/script/src/features/contact/index.d.ts +2 -0
  234. package/script/src/features/contact/index.d.ts.map +1 -0
  235. package/script/src/features/contact/index.js +17 -0
  236. package/script/src/features/contact/repository.d.ts +47 -0
  237. package/script/src/features/contact/repository.d.ts.map +1 -0
  238. package/script/src/features/contact/repository.js +98 -0
  239. package/script/src/features/files-gen/contract.d.ts +67 -0
  240. package/script/src/features/files-gen/contract.d.ts.map +1 -0
  241. package/script/src/features/files-gen/contract.js +43 -0
  242. package/script/src/features/files-gen/repository.d.ts +47 -0
  243. package/script/src/features/files-gen/repository.d.ts.map +1 -0
  244. package/script/src/features/files-gen/repository.js +52 -0
  245. package/script/src/features/payout/contract.d.ts +623 -0
  246. package/script/src/features/payout/contract.d.ts.map +1 -0
  247. package/script/src/features/payout/contract.js +78 -0
  248. package/script/src/features/payout/index.d.ts +2 -0
  249. package/script/src/features/payout/index.d.ts.map +1 -0
  250. package/script/src/features/payout/index.js +17 -0
  251. package/script/src/features/payout/repository.d.ts +62 -0
  252. package/script/src/features/payout/repository.d.ts.map +1 -0
  253. package/script/src/features/payout/repository.js +162 -0
  254. package/script/src/features/wallet/contract.d.ts +103 -0
  255. package/script/src/features/wallet/contract.d.ts.map +1 -0
  256. package/script/src/features/wallet/contract.js +38 -0
  257. package/script/src/features/wallet/index.d.ts +2 -0
  258. package/script/src/features/wallet/index.d.ts.map +1 -0
  259. package/script/src/features/wallet/index.js +17 -0
  260. package/script/src/features/wallet/repository.d.ts +74 -0
  261. package/script/src/features/wallet/repository.d.ts.map +1 -0
  262. package/script/src/features/wallet/repository.js +136 -0
  263. package/script/src/models/contact/derivatives/contact.d.ts +168 -0
  264. package/script/src/models/contact/derivatives/contact.d.ts.map +1 -0
  265. package/script/src/models/contact/derivatives/contact.js +264 -0
  266. package/script/src/models/contact/derivatives/contact.test.d.ts.map +1 -0
  267. package/script/src/models/contact/derivatives/contact_info.d.ts +188 -0
  268. package/script/src/models/contact/derivatives/contact_info.d.ts.map +1 -0
  269. package/script/src/models/contact/derivatives/contact_info.js +260 -0
  270. package/script/src/models/contact/derivatives/contact_info.test.d.ts.map +1 -0
  271. package/script/src/models/contact/index.d.ts +5 -0
  272. package/script/src/models/contact/index.d.ts.map +1 -0
  273. package/script/src/models/contact/index.js +20 -0
  274. package/script/src/models/contact/schemas.d.ts +66 -0
  275. package/script/src/models/contact/schemas.d.ts.map +1 -0
  276. package/script/src/models/contact/schemas.js +67 -0
  277. package/script/src/models/contact/validation.d.ts +37 -0
  278. package/script/src/models/contact/validation.d.ts.map +1 -0
  279. package/script/src/models/contact/validation.js +146 -0
  280. package/script/src/models/contact/validation.test.d.ts.map +1 -0
  281. package/script/src/models/index.d.ts +6 -0
  282. package/script/src/models/index.d.ts.map +1 -0
  283. package/script/src/models/index.js +21 -0
  284. package/script/src/models/payout/api.d.ts +29 -0
  285. package/script/src/models/payout/api.d.ts.map +1 -0
  286. package/script/src/models/payout/api.js +2 -0
  287. package/script/src/models/payout/channel.d.ts +58 -0
  288. package/script/src/models/payout/channel.d.ts.map +1 -0
  289. package/script/src/models/payout/channel.js +49 -0
  290. package/script/src/models/payout/derivatives/payout.d.ts +156 -0
  291. package/script/src/models/payout/derivatives/payout.d.ts.map +1 -0
  292. package/script/src/models/payout/derivatives/payout.js +265 -0
  293. package/script/src/models/payout/derivatives/payout.test.d.ts.map +1 -0
  294. package/script/src/models/payout/index.d.ts +6 -0
  295. package/script/src/models/payout/index.d.ts.map +1 -0
  296. package/script/src/models/payout/index.js +21 -0
  297. package/script/src/models/payout/schemas.d.ts +154 -0
  298. package/script/src/models/payout/schemas.d.ts.map +1 -0
  299. package/script/src/models/payout/schemas.js +106 -0
  300. package/script/src/models/payout/status.d.ts +31 -0
  301. package/script/src/models/payout/status.d.ts.map +1 -0
  302. package/script/src/models/payout/status.js +35 -0
  303. package/script/src/models/permission.d.ts +42 -0
  304. package/script/src/models/permission.d.ts.map +1 -0
  305. package/script/src/models/permission.js +40 -0
  306. package/script/src/models/user/index.d.ts +3 -0
  307. package/script/src/models/user/index.d.ts.map +1 -0
  308. package/script/src/models/user/index.js +18 -0
  309. package/script/src/models/user/profile.d.ts +38 -0
  310. package/script/src/models/user/profile.d.ts.map +1 -0
  311. package/script/src/models/user/profile.js +28 -0
  312. package/script/src/models/user/user.d.ts +80 -0
  313. package/script/src/models/user/user.d.ts.map +1 -0
  314. package/script/src/models/user/user.js +153 -0
  315. package/script/src/models/wallet/guards.d.ts +11 -0
  316. package/script/src/models/wallet/guards.d.ts.map +1 -0
  317. package/script/src/models/wallet/guards.js +17 -0
  318. package/script/src/models/wallet/index.d.ts +4 -0
  319. package/script/src/models/wallet/index.d.ts.map +1 -0
  320. package/script/src/models/wallet/index.js +19 -0
  321. package/script/src/models/wallet/schemas.d.ts +50 -0
  322. package/script/src/models/wallet/schemas.d.ts.map +1 -0
  323. package/script/src/models/wallet/schemas.js +67 -0
  324. package/script/src/models/wallet/statement.d.ts +27 -0
  325. package/script/src/models/wallet/statement.d.ts.map +1 -0
  326. package/script/src/models/wallet/statement.js +16 -0
  327. package/script/src/shared/base_repository.d.ts +56 -0
  328. package/script/src/shared/base_repository.d.ts.map +1 -0
  329. package/script/src/shared/base_repository.js +99 -0
  330. package/script/src/shared/common_responses.d.ts +13 -0
  331. package/script/src/shared/common_responses.d.ts.map +1 -0
  332. package/script/src/shared/common_responses.js +13 -0
  333. package/script/src/shared/index.d.ts +3 -0
  334. package/script/src/shared/index.d.ts.map +1 -0
  335. package/script/src/shared/index.js +18 -0
@@ -0,0 +1,75 @@
1
+ import { PayoutSchemas } from "../../models/payout/index.js";
2
+ import { APIError } from "../../errors/api_error.js";
3
+ import { initContract } from "@ts-rest/core";
4
+ import { z } from "zod";
5
+ /** Default eager loading settings for payout API */
6
+ export const DEFAULT_PAYOUT_API_EAGER = "[createdBy,actionedBy]";
7
+ /** Default sort order for payout listings */
8
+ export const DEFAULT_ORDER_BY_DESC = "createdAt";
9
+ /**
10
+ * Payout management API contract
11
+ * Defines endpoints for creating and managing payouts
12
+ *
13
+ * @property {Object} getPayouts - List payouts with filtering (GET /)
14
+ * @property {Object} getPayoutsByApprovalStatus - List payouts by approval status (GET /)
15
+ * @property {Object} postPayout - Create new payout (POST /)
16
+ * @property {Object} approve - Approve/reject payout (POST /:id/approve)
17
+ */
18
+ export const contract = initContract().router({
19
+ getPayouts: {
20
+ method: "GET",
21
+ path: "",
22
+ query: z.object({
23
+ rangeStart: z.number(),
24
+ rangeEnd: z.number(),
25
+ eager: z.string(),
26
+ approvalStatus: PayoutSchemas.payoutApprovalStatus.nullable().optional(),
27
+ orderByDesc: z.string(),
28
+ }),
29
+ responses: {
30
+ 200: z.object({
31
+ results: z.array(PayoutSchemas.payoutData),
32
+ total: z.number(),
33
+ }),
34
+ },
35
+ },
36
+ getPayoutsByApprovalStatus: {
37
+ method: "GET",
38
+ path: "",
39
+ query: z.object({
40
+ rangeStart: z.number(),
41
+ rangeEnd: z.number(),
42
+ eager: z.string(),
43
+ approvalStatus: PayoutSchemas.payoutApprovalStatus,
44
+ orderByDesc: z.string(),
45
+ }),
46
+ responses: {
47
+ 200: z.object({
48
+ results: z.array(PayoutSchemas.payoutData),
49
+ total: z.number(),
50
+ }),
51
+ },
52
+ },
53
+ postPayout: {
54
+ method: "POST",
55
+ path: "",
56
+ body: PayoutSchemas.payoutInput,
57
+ responses: {
58
+ 201: PayoutSchemas.payoutData,
59
+ 400: APIError.schema,
60
+ },
61
+ },
62
+ approve: {
63
+ method: "POST",
64
+ path: "/:id/approve",
65
+ body: z.object({
66
+ action: z.enum(["Approve", "Reject"]),
67
+ notes: z.string().optional(),
68
+ }),
69
+ responses: {
70
+ 201: PayoutSchemas.payoutData,
71
+ 404: z.object({}),
72
+ 409: z.object({}),
73
+ },
74
+ },
75
+ });
@@ -0,0 +1,2 @@
1
+ export * from "./repository.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/features/payout/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./repository.js";
@@ -0,0 +1,62 @@
1
+ import { BaseRepository } from "../../shared/index.js";
2
+ import { type PayoutAPI } from "./contract.js";
3
+ import { type GetPayoutsAPIArgs, type PayoutInput } from "../../models/payout/index.js";
4
+ import { Payout } from "../../models/payout/derivatives/payout.js";
5
+ /**
6
+ * Repository class for managing payout operations including creation, approval,
7
+ * rejection, and retrieval of payouts.
8
+ * @extends {BaseRepository<PayoutAPI>}
9
+ */
10
+ export declare class PayoutRepository extends BaseRepository<PayoutAPI> {
11
+ /**
12
+ * Creates an instance of PayoutRepository initialized with the payout contract.
13
+ */
14
+ constructor();
15
+ /**
16
+ * Retrieves a paginated list of payouts with optional filtering for pending status.
17
+ * @param {GetPayoutsAPIArgs} [args] - Optional arguments for filtering and pagination
18
+ * @param {number} [args.rangeStart=0] - Starting index for pagination
19
+ * @param {number} [args.rangeEnd=10] - Ending index for pagination
20
+ * @param {boolean} [args.pending] - Filter for pending payouts only
21
+ * @throws {PermissionError} If user lacks the Payout.List permission
22
+ * @throws {APIError} If range is invalid or if the fetch operation fails
23
+ * @returns {Promise<{results: Payout[]; total: number}>} Paginated payout results and total count
24
+ */
25
+ getAll(args?: GetPayoutsAPIArgs): Promise<{
26
+ results: Payout[];
27
+ total: number;
28
+ }>;
29
+ /**
30
+ * Creates a new payout with the provided input data.
31
+ * @param {PayoutInput} input - The payout creation data
32
+ * @throws {PermissionError} If user lacks the Payout.Create permission
33
+ * @throws {APIError} If the input is invalid or if the creation operation fails
34
+ * @returns {Promise<Payout>} The created payout
35
+ */
36
+ pay(input: PayoutInput): Promise<Payout>;
37
+ /**
38
+ * Approves a payout with optional notes.
39
+ * @param {string} id - The ID of the payout to approve
40
+ * @param {Object} [args] - Optional arguments
41
+ * @param {string} [args.notes] - Optional notes for the approval
42
+ * @throws {PermissionError} If user lacks the Payout.Approve permission
43
+ * @throws {APIError} If payout is not found, already approved, or if the operation fails
44
+ * @returns {Promise<Payout>} The approved payout
45
+ */
46
+ approve(id: string, args?: {
47
+ notes?: string;
48
+ }): Promise<Payout>;
49
+ /**
50
+ * Rejects a payout with optional notes.
51
+ * @param {string} id - The ID of the payout to reject
52
+ * @param {Object} [args] - Optional arguments
53
+ * @param {string} [args.notes] - Optional notes for the rejection
54
+ * @throws {PermissionError} If user lacks the Payout.Approve permission
55
+ * @throws {APIError} If payout is not found, already rejected, or if the operation fails
56
+ * @returns {Promise<Payout>} The rejected payout
57
+ */
58
+ reject(id: string, args?: {
59
+ notes?: string;
60
+ }): Promise<Payout>;
61
+ }
62
+ //# sourceMappingURL=repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../../src/src/features/payout/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,WAAW,EACjB,MAAM,8BAA8B,CAAC;AAItC,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAEnE;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,cAAc,CAAC,SAAS,CAAC;IAC7D;;OAEG;;IAKH;;;;;;;;;OASG;IACG,MAAM,CAAC,IAAI,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC;QAC9C,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IA2CF;;;;;;OAMG;IACG,GAAG,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAkB9C;;;;;;;;OAQG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IA8BrE;;;;;;;;OAQG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;CA6BrE"}
@@ -0,0 +1,158 @@
1
+ import { BaseRepository } from "../../shared/index.js";
2
+ import { contract } from "./contract.js";
3
+ import { PAYOUT_APPROVAL_STATUS, } from "../../models/payout/index.js";
4
+ import { AfloatAuth } from "../auth/manager.js";
5
+ import { Permissions } from "../../models/permission.js";
6
+ import { APIError, PermissionError } from "../../errors/index.js";
7
+ import { Payout } from "../../models/payout/derivatives/payout.js";
8
+ /**
9
+ * Repository class for managing payout operations including creation, approval,
10
+ * rejection, and retrieval of payouts.
11
+ * @extends {BaseRepository<PayoutAPI>}
12
+ */
13
+ export class PayoutRepository extends BaseRepository {
14
+ /**
15
+ * Creates an instance of PayoutRepository initialized with the payout contract.
16
+ */
17
+ constructor() {
18
+ super("payout", contract);
19
+ }
20
+ /**
21
+ * Retrieves a paginated list of payouts with optional filtering for pending status.
22
+ * @param {GetPayoutsAPIArgs} [args] - Optional arguments for filtering and pagination
23
+ * @param {number} [args.rangeStart=0] - Starting index for pagination
24
+ * @param {number} [args.rangeEnd=10] - Ending index for pagination
25
+ * @param {boolean} [args.pending] - Filter for pending payouts only
26
+ * @throws {PermissionError} If user lacks the Payout.List permission
27
+ * @throws {APIError} If range is invalid or if the fetch operation fails
28
+ * @returns {Promise<{results: Payout[]; total: number}>} Paginated payout results and total count
29
+ */
30
+ async getAll(args) {
31
+ const requiredPerm = Permissions.Payout.List;
32
+ if (!AfloatAuth.instance.checkPermission(requiredPerm)) {
33
+ throw new PermissionError({
34
+ message: "You are not authorized to view payouts.",
35
+ requiredPermissions: [requiredPerm],
36
+ });
37
+ }
38
+ const rangeStart = args?.rangeStart ?? 0;
39
+ const rangeEnd = args?.rangeEnd ?? 10;
40
+ const pendingStatus = PAYOUT_APPROVAL_STATUS.PENDING;
41
+ const query = {
42
+ rangeStart,
43
+ rangeEnd,
44
+ eager: "[createdBy,actionedBy]",
45
+ orderByDesc: "createdAt",
46
+ };
47
+ if (args?.pending) {
48
+ Object.assign(query, { approvalStatus: pendingStatus });
49
+ }
50
+ if (rangeEnd <= rangeStart) {
51
+ throw new APIError({
52
+ message: "Invalid range: end-date must be greater than start-date",
53
+ statusCode: 400,
54
+ });
55
+ }
56
+ const result = await this.client.getPayouts({ query: query });
57
+ if (result.status === 200) {
58
+ return {
59
+ results: Payout.createMany(result.body.results),
60
+ total: result.body.total,
61
+ };
62
+ }
63
+ throw APIError.unknown("An error occured while fetching payouts");
64
+ }
65
+ /**
66
+ * Creates a new payout with the provided input data.
67
+ * @param {PayoutInput} input - The payout creation data
68
+ * @throws {PermissionError} If user lacks the Payout.Create permission
69
+ * @throws {APIError} If the input is invalid or if the creation operation fails
70
+ * @returns {Promise<Payout>} The created payout
71
+ */
72
+ async pay(input) {
73
+ const requiredPerm = Permissions.Payout.Create;
74
+ if (!AfloatAuth.instance.checkPermission(Permissions.Payout.Create)) {
75
+ throw new PermissionError({
76
+ message: "You are not authorized to create payouts.",
77
+ requiredPermissions: [requiredPerm],
78
+ });
79
+ }
80
+ const result = await this.client.postPayout({ body: input });
81
+ if (result.status === 201)
82
+ return Payout.create(result.body);
83
+ if (result.status === 400) {
84
+ throw new APIError(result.body);
85
+ }
86
+ throw APIError.unknown();
87
+ }
88
+ /**
89
+ * Approves a payout with optional notes.
90
+ * @param {string} id - The ID of the payout to approve
91
+ * @param {Object} [args] - Optional arguments
92
+ * @param {string} [args.notes] - Optional notes for the approval
93
+ * @throws {PermissionError} If user lacks the Payout.Approve permission
94
+ * @throws {APIError} If payout is not found, already approved, or if the operation fails
95
+ * @returns {Promise<Payout>} The approved payout
96
+ */
97
+ async approve(id, args) {
98
+ const requiredPerm = Permissions.Payout.Approve;
99
+ if (!AfloatAuth.instance.checkPermission(requiredPerm)) {
100
+ throw new PermissionError({
101
+ message: "You are not authorized to approve or reject payouts.",
102
+ requiredPermissions: [requiredPerm],
103
+ });
104
+ }
105
+ const result = await this.client.approve({
106
+ params: { id },
107
+ body: { action: "Approve", notes: args?.notes },
108
+ });
109
+ if (result.status === 201) {
110
+ return Payout.create(result.body);
111
+ }
112
+ if (result.status === 404) {
113
+ throw new APIError({ message: "Payout not found", statusCode: 404 });
114
+ }
115
+ if (result.status === 409) {
116
+ throw new APIError({
117
+ message: "Payout already approved",
118
+ statusCode: 409,
119
+ });
120
+ }
121
+ throw APIError.unknown();
122
+ }
123
+ /**
124
+ * Rejects a payout with optional notes.
125
+ * @param {string} id - The ID of the payout to reject
126
+ * @param {Object} [args] - Optional arguments
127
+ * @param {string} [args.notes] - Optional notes for the rejection
128
+ * @throws {PermissionError} If user lacks the Payout.Approve permission
129
+ * @throws {APIError} If payout is not found, already rejected, or if the operation fails
130
+ * @returns {Promise<Payout>} The rejected payout
131
+ */
132
+ async reject(id, args) {
133
+ const requiredPerm = Permissions.Payout.Approve;
134
+ if (!AfloatAuth.instance.checkPermission(requiredPerm)) {
135
+ throw new PermissionError({
136
+ message: "You are not authorized to approve or reject payouts.",
137
+ requiredPermissions: [requiredPerm],
138
+ });
139
+ }
140
+ const result = await this.client.approve({
141
+ params: { id },
142
+ body: { action: "Reject", notes: args?.notes },
143
+ });
144
+ if (result.status === 201) {
145
+ return Payout.create(result.body);
146
+ }
147
+ if (result.status === 404) {
148
+ throw new APIError({ message: "Payout not found", statusCode: 404 });
149
+ }
150
+ if (result.status === 409) {
151
+ throw new APIError({
152
+ message: "Payout already rejected",
153
+ statusCode: 409,
154
+ });
155
+ }
156
+ throw APIError.unknown();
157
+ }
158
+ }
@@ -0,0 +1,103 @@
1
+ import { z } from "zod";
2
+ export declare const contract: {
3
+ getWallets: {
4
+ method: "GET";
5
+ path: "/";
6
+ responses: {
7
+ 200: z.ZodArray<z.ZodObject<{
8
+ id: z.ZodString;
9
+ profileId: z.ZodString;
10
+ accountNo: z.ZodString;
11
+ accountName: z.ZodString;
12
+ channel: z.ZodString;
13
+ createdAt: z.ZodString;
14
+ updatedAt: z.ZodString;
15
+ }, z.UnknownKeysParam, z.ZodTypeAny, {
16
+ id: string;
17
+ accountNo: string;
18
+ channel: string;
19
+ profileId: string;
20
+ createdAt: string;
21
+ updatedAt: string;
22
+ accountName: string;
23
+ }, {
24
+ id: string;
25
+ accountNo: string;
26
+ channel: string;
27
+ profileId: string;
28
+ createdAt: string;
29
+ updatedAt: string;
30
+ accountName: string;
31
+ }>, "many">;
32
+ };
33
+ };
34
+ getBalance: {
35
+ method: "POST";
36
+ body: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
37
+ path: "/balance";
38
+ responses: {
39
+ 201: z.ZodObject<{
40
+ availableBalance: z.ZodNumber;
41
+ }, "strip", z.ZodTypeAny, {
42
+ availableBalance: number;
43
+ }, {
44
+ availableBalance: number;
45
+ }>;
46
+ };
47
+ };
48
+ getStatement: {
49
+ summary: "Get Wallet Statement";
50
+ method: "POST";
51
+ body: z.ZodObject<{
52
+ endDate: z.ZodDate;
53
+ startDate: z.ZodDate;
54
+ accountNo: z.ZodOptional<z.ZodString>;
55
+ }, "strip", z.ZodTypeAny, {
56
+ endDate: Date;
57
+ startDate: Date;
58
+ accountNo?: string | undefined;
59
+ }, {
60
+ endDate: Date;
61
+ startDate: Date;
62
+ accountNo?: string | undefined;
63
+ }>;
64
+ path: "/statement";
65
+ responses: {
66
+ 201: z.ZodArray<z.ZodObject<{
67
+ accountNo: z.ZodEffects<z.ZodOptional<z.ZodString>>;
68
+ cbaRefNo: z.ZodEffects<z.ZodOptional<z.ZodString>>;
69
+ debitOrCredit: z.ZodString;
70
+ tranRefNo: z.ZodString;
71
+ narration: z.ZodString;
72
+ txnDate: z.ZodDate;
73
+ valueDate: z.ZodDate;
74
+ amountCredited: z.ZodNumber;
75
+ amountDebited: z.ZodNumber;
76
+ balance: z.ZodNumber;
77
+ }, z.UnknownKeysParam, z.ZodTypeAny, {
78
+ debitOrCredit: string;
79
+ tranRefNo: string;
80
+ narration: string;
81
+ txnDate: Date;
82
+ valueDate: Date;
83
+ amountCredited: number;
84
+ amountDebited: number;
85
+ balance: number;
86
+ accountNo?: string | undefined;
87
+ cbaRefNo?: string | undefined;
88
+ }, {
89
+ debitOrCredit: string;
90
+ tranRefNo: string;
91
+ narration: string;
92
+ txnDate: Date;
93
+ valueDate: Date;
94
+ amountCredited: number;
95
+ amountDebited: number;
96
+ balance: number;
97
+ accountNo?: string | undefined;
98
+ cbaRefNo?: string | undefined;
99
+ }>, "many">;
100
+ };
101
+ };
102
+ };
103
+ //# sourceMappingURL=contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../../../src/src/features/wallet/contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BnB,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { z } from "zod";
2
+ import { initContract } from "@ts-rest/core";
3
+ import { WalletSchemas } from "../../models/wallet/index.js";
4
+ export const contract = initContract().router({
5
+ getWallets: {
6
+ method: "GET",
7
+ path: "/",
8
+ responses: {
9
+ 200: z.array(WalletSchemas.wallet),
10
+ },
11
+ },
12
+ getBalance: {
13
+ method: "POST",
14
+ path: "/balance",
15
+ body: z.object({}),
16
+ responses: {
17
+ 201: z.object({
18
+ availableBalance: z.number(),
19
+ }),
20
+ },
21
+ },
22
+ getStatement: {
23
+ method: "POST",
24
+ path: "/statement",
25
+ summary: "Get Wallet Statement",
26
+ body: z.object({
27
+ endDate: z.date(),
28
+ startDate: z.date(),
29
+ accountNo: z.string().optional(),
30
+ }),
31
+ responses: {
32
+ 201: z.array(WalletSchemas.statementEntry),
33
+ },
34
+ },
35
+ });
@@ -0,0 +1,2 @@
1
+ export * from "./repository.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/features/wallet/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./repository.js";
@@ -0,0 +1,74 @@
1
+ import { BaseRepository } from "../../shared/base_repository.js";
2
+ import { contract } from "./contract.js";
3
+ import type { STATEMENT_OUTPUT_TYPE, StatementFile, Wallet, WalletStatementItem } from "../../models/wallet/index.js";
4
+ /**
5
+ * Repository class for managing wallet operations including balance checking,
6
+ * statement generation, and wallet information retrieval.
7
+ * @extends {BaseRepository<typeof contract>}
8
+ */
9
+ export declare class WalletRepo extends BaseRepository<typeof contract> {
10
+ /**
11
+ * Creates an instance of WalletRepo initialized with the wallet contract.
12
+ */
13
+ constructor();
14
+ /**
15
+ * Gets an instance of the file generation repository.
16
+ * @private
17
+ * @returns {AfloatFilesRepo} A new instance of AfloatFilesRepo
18
+ */
19
+ private get fileGenRepo();
20
+ /**
21
+ * Retrieves the current available balance for the wallet.
22
+ * @throws {PermissionError} If user lacks the ViewBalance permission
23
+ * @throws {Error} If the balance fetch operation fails
24
+ * @returns {Promise<number>} The available balance amount
25
+ */
26
+ getBalance(): Promise<number>;
27
+ /**
28
+ * Retrieves all wallets associated with the current context.
29
+ * @throws {Error} If the wallet fetch operation fails
30
+ * @returns {Promise<Wallet[]>} Array of wallet objects
31
+ */
32
+ getWallets(): Promise<Wallet[]>;
33
+ /**
34
+ * Retrieves wallet statement items for a specified date range and account.
35
+ * If no range is provided, defaults to the current month (1st to 30th).
36
+ * @param {Object} props - The statement request properties
37
+ * @param {Object} [props.range] - Optional date range for the statement
38
+ * @param {Date} props.range.startDate - Start date for the statement period
39
+ * @param {Date} props.range.endDate - End date for the statement period
40
+ * @param {string} [props.accountNo] - Optional account number to fetch statement for
41
+ * @throws {PermissionError} If user lacks the ViewStatement permission
42
+ * @throws {Error} If the statement fetch operation fails
43
+ * @returns {Promise<WalletStatementItem[]>} Array of statement items for the specified period
44
+ */
45
+ getStatement(props: {
46
+ range?: {
47
+ startDate: Date;
48
+ endDate: Date;
49
+ };
50
+ accountNo?: string;
51
+ }): Promise<WalletStatementItem[]>;
52
+ /**
53
+ * Generates a statement file for the specified period and account.
54
+ * @param {STATEMENT_OUTPUT_TYPE} fileType - The desired output format type for the statement
55
+ * @param {Object} props - The statement generation properties
56
+ * @param {Date} props.startDate - Start date for the statement period
57
+ * @param {Date} props.endDate - End date for the statement period
58
+ * @param {string} [props.accountNo] - Optional account number to generate statement for
59
+ * @throws {PermissionError} If user lacks the ViewStatement permission
60
+ * @returns {Promise<StatementFile>} The generated statement file
61
+ */
62
+ genStatement(fileType: STATEMENT_OUTPUT_TYPE, props: {
63
+ startDate: Date;
64
+ endDate: Date;
65
+ accountNo?: string;
66
+ }): Promise<StatementFile>;
67
+ /**
68
+ * Generates a PDF containing detailed wallet account information.
69
+ * @throws {PermissionError} If user lacks the ViewBalance permission
70
+ * @returns {Promise<StatementFile>} The generated PDF file containing wallet details
71
+ */
72
+ genWalletDetailsPDF(): Promise<StatementFile>;
73
+ }
74
+ //# sourceMappingURL=repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../../src/src/features/wallet/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EACV,qBAAqB,EACrB,aAAa,EACb,MAAM,EACN,mBAAmB,EACpB,MAAM,8BAA8B,CAAC;AAMtC;;;;GAIG;AACH,qBAAa,UAAW,SAAQ,cAAc,CAAC,OAAO,QAAQ,CAAC;IAC7D;;OAEG;;IAKH;;;;OAIG;IACH,OAAO,KAAK,WAAW,GAEtB;IAED;;;;;OAKG;IACG,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAkBnC;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAUrC;;;;;;;;;;;OAWG;IACG,YAAY,CAChB,KAAK,EAAE;QACL,KAAK,CAAC,EAAE;YAAE,SAAS,EAAE,IAAI,CAAC;YAAC,OAAO,EAAE,IAAI,CAAA;SAAE,CAAC;QAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GACA,OAAO,CAAC,mBAAmB,EAAE,CAAC;IA0BjC;;;;;;;;;OASG;IACG,YAAY,CAChB,QAAQ,EAAE,qBAAqB,EAC/B,KAAK,EAAE;QACL,SAAS,EAAE,IAAI,CAAC;QAChB,OAAO,EAAE,IAAI,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GACA,OAAO,CAAC,aAAa,CAAC;IAiBzB;;;;OAIG;IACG,mBAAmB,IAAI,OAAO,CAAC,aAAa,CAAC;CAWpD"}
@@ -0,0 +1,132 @@
1
+ import { BaseRepository } from "../../shared/base_repository.js";
2
+ import { contract } from "./contract.js";
3
+ import { AfloatFilesRepo } from "../files-gen/repository.js";
4
+ import { AfloatAuth } from "../auth/manager.js";
5
+ import { Permissions } from "../../models/permission.js";
6
+ import { PermissionError } from "../../errors/index.js";
7
+ /**
8
+ * Repository class for managing wallet operations including balance checking,
9
+ * statement generation, and wallet information retrieval.
10
+ * @extends {BaseRepository<typeof contract>}
11
+ */
12
+ export class WalletRepo extends BaseRepository {
13
+ /**
14
+ * Creates an instance of WalletRepo initialized with the wallet contract.
15
+ */
16
+ constructor() {
17
+ super("wallet", contract);
18
+ }
19
+ /**
20
+ * Gets an instance of the file generation repository.
21
+ * @private
22
+ * @returns {AfloatFilesRepo} A new instance of AfloatFilesRepo
23
+ */
24
+ get fileGenRepo() {
25
+ return new AfloatFilesRepo();
26
+ }
27
+ /**
28
+ * Retrieves the current available balance for the wallet.
29
+ * @throws {PermissionError} If user lacks the ViewBalance permission
30
+ * @throws {Error} If the balance fetch operation fails
31
+ * @returns {Promise<number>} The available balance amount
32
+ */
33
+ async getBalance() {
34
+ const requirePerm = Permissions.Wallet.ViewBalance;
35
+ if (!AfloatAuth.instance.checkPermission(requirePerm)) {
36
+ throw new PermissionError({
37
+ message: "You are not authorized to view the account balance.",
38
+ requiredPermissions: [requirePerm],
39
+ });
40
+ }
41
+ const result = await this.client.getBalance();
42
+ if (result.status === 201) {
43
+ return result.body.availableBalance;
44
+ }
45
+ throw new Error("An error occured while fetching balance");
46
+ }
47
+ /**
48
+ * Retrieves all wallets associated with the current context.
49
+ * @throws {Error} If the wallet fetch operation fails
50
+ * @returns {Promise<Wallet[]>} Array of wallet objects
51
+ */
52
+ async getWallets() {
53
+ const result = await this.client.getWallets();
54
+ if (result.status === 200) {
55
+ return result.body;
56
+ }
57
+ throw new Error("An error occured while fetching wallets");
58
+ }
59
+ /**
60
+ * Retrieves wallet statement items for a specified date range and account.
61
+ * If no range is provided, defaults to the current month (1st to 30th).
62
+ * @param {Object} props - The statement request properties
63
+ * @param {Object} [props.range] - Optional date range for the statement
64
+ * @param {Date} props.range.startDate - Start date for the statement period
65
+ * @param {Date} props.range.endDate - End date for the statement period
66
+ * @param {string} [props.accountNo] - Optional account number to fetch statement for
67
+ * @throws {PermissionError} If user lacks the ViewStatement permission
68
+ * @throws {Error} If the statement fetch operation fails
69
+ * @returns {Promise<WalletStatementItem[]>} Array of statement items for the specified period
70
+ */
71
+ async getStatement(props) {
72
+ const requirePerm = Permissions.Wallet.ViewStatement;
73
+ if (!AfloatAuth.instance.checkPermission(requirePerm)) {
74
+ throw new PermissionError({
75
+ message: "You are not authorized to view the statement.",
76
+ requiredPermissions: [requirePerm],
77
+ });
78
+ }
79
+ const now = new Date();
80
+ const monthStart = new Date(now.getFullYear(), now.getMonth(), 1);
81
+ const monthEnd = new Date(now.getFullYear(), now.getMonth(), 30);
82
+ const range = props.range !== undefined
83
+ ? { startDate: props.range.startDate, endDate: props.range.endDate }
84
+ : { startDate: monthStart, endDate: monthEnd };
85
+ const body = { ...range, accountNo: props.accountNo };
86
+ const result = await this.client.getStatement({ body });
87
+ if (result.status === 201) {
88
+ return result.body;
89
+ }
90
+ throw new Error("An error occured while fetching statement");
91
+ }
92
+ /**
93
+ * Generates a statement file for the specified period and account.
94
+ * @param {STATEMENT_OUTPUT_TYPE} fileType - The desired output format type for the statement
95
+ * @param {Object} props - The statement generation properties
96
+ * @param {Date} props.startDate - Start date for the statement period
97
+ * @param {Date} props.endDate - End date for the statement period
98
+ * @param {string} [props.accountNo] - Optional account number to generate statement for
99
+ * @throws {PermissionError} If user lacks the ViewStatement permission
100
+ * @returns {Promise<StatementFile>} The generated statement file
101
+ */
102
+ async genStatement(fileType, props) {
103
+ const requirePerm = Permissions.Wallet.ViewStatement;
104
+ if (!AfloatAuth.instance.checkPermission(requirePerm)) {
105
+ throw new PermissionError({
106
+ message: "You are not authorized to view the statement.",
107
+ requiredPermissions: [requirePerm],
108
+ });
109
+ }
110
+ return await this.fileGenRepo.downloadStatement({
111
+ start_date: props.startDate,
112
+ end_date: props.endDate,
113
+ return_file_type: fileType,
114
+ account_no: props.accountNo,
115
+ });
116
+ }
117
+ /**
118
+ * Generates a PDF containing detailed wallet account information.
119
+ * @throws {PermissionError} If user lacks the ViewBalance permission
120
+ * @returns {Promise<StatementFile>} The generated PDF file containing wallet details
121
+ */
122
+ async genWalletDetailsPDF() {
123
+ const requirePerm = Permissions.Wallet.ViewBalance;
124
+ if (!AfloatAuth.instance.checkPermission(requirePerm)) {
125
+ throw new PermissionError({
126
+ message: "You are not authorized to view the account details.",
127
+ requiredPermissions: [requirePerm],
128
+ });
129
+ }
130
+ return await this.fileGenRepo.genAccountDetailsPDF();
131
+ }
132
+ }