@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,149 @@
1
+ import { Permissions } from "../permission.js";
2
+ /**
3
+ * Represents a user in Afloat
4
+ *
5
+ * This class centralizes user-related logic, simplifying interaction
6
+ * with user-related data and ensuring consistent permission checks across the application.
7
+ */
8
+ export class User {
9
+ /**
10
+ * Creates a new instance of the `User` class.
11
+ *
12
+ * @param userData - An object of type `CoreUser` containing the user's profile, token,
13
+ * permissions (access list), and the `resetPassword` flag.
14
+ */
15
+ constructor(data) {
16
+ /**
17
+ * Logged-in user name
18
+ */
19
+ Object.defineProperty(this, "name", {
20
+ enumerable: true,
21
+ configurable: true,
22
+ writable: true,
23
+ value: void 0
24
+ });
25
+ /**
26
+ * Logged-in identity: phone-number or email address
27
+ */
28
+ Object.defineProperty(this, "identity", {
29
+ enumerable: true,
30
+ configurable: true,
31
+ writable: true,
32
+ value: void 0
33
+ });
34
+ /**
35
+ * The user's Afloat profile, containing personal information such as name, contact details, and account information.
36
+ */
37
+ Object.defineProperty(this, "profile", {
38
+ enumerable: true,
39
+ configurable: true,
40
+ writable: true,
41
+ value: void 0
42
+ });
43
+ /**
44
+ * The user's authentication token. This token must be passed in the request headers
45
+ * for all authenticated API endpoints.
46
+ */
47
+ Object.defineProperty(this, "token", {
48
+ enumerable: true,
49
+ configurable: true,
50
+ writable: true,
51
+ value: void 0
52
+ });
53
+ /**
54
+ * Indicates whether the user is required to change their default password.
55
+ *
56
+ * Afloat users are initially provided with a default username and password. After the first
57
+ * successful login, `resetPassword` will be set to `true` to prompt the user to set a new password.
58
+ */
59
+ Object.defineProperty(this, "resetPassword", {
60
+ enumerable: true,
61
+ configurable: true,
62
+ writable: true,
63
+ value: void 0
64
+ });
65
+ /**
66
+ * A map of permission keys to boolean values, indicating whether the user has access
67
+ * to specific actions or features in the system.
68
+ */
69
+ Object.defineProperty(this, "permissionsMap", {
70
+ enumerable: true,
71
+ configurable: true,
72
+ writable: true,
73
+ value: void 0
74
+ });
75
+ const { profile, token, access, resetPassword } = data;
76
+ this.profile = profile;
77
+ this.token = token;
78
+ this.resetPassword = resetPassword;
79
+ this.name = data.loginCredentials.name;
80
+ this.identity = data.loginCredentials.identity;
81
+ // Initialize the permissions map
82
+ this.permissionsMap = {};
83
+ for (const permission of Object.values(Permissions)) {
84
+ if (typeof permission === "object") {
85
+ Object.values(permission).forEach((perm) => {
86
+ this.permissionsMap[perm] = access.includes(perm);
87
+ });
88
+ }
89
+ }
90
+ }
91
+ /**
92
+ * Checks if the user has a specific permission.
93
+ *
94
+ * @param permission - The permission key to check.
95
+ * @returns `true` if the user has the specified permission, otherwise `false`.
96
+ */
97
+ can(permission) {
98
+ return this.permissionsMap[permission] ?? false;
99
+ }
100
+ /**
101
+ * Serializes the `User` instance to a JSON string.
102
+ *
103
+ * @returns A JSON string representation of the `User` instance, including:
104
+ * - `profile`: The user's profile information.
105
+ * - `token`: The user's authentication token.
106
+ * - `resetPassword`: Indicates whether the user must reset their password.
107
+ * - `permissions`: An array of permission keys the user has.
108
+ */
109
+ toJSON() {
110
+ return JSON.stringify({
111
+ profile: this.profile,
112
+ token: this.token,
113
+ resetPassword: this.resetPassword,
114
+ name: this.name,
115
+ identity: this.identity,
116
+ permissions: Object.keys(this.permissionsMap).filter((key) => this.permissionsMap[key]),
117
+ });
118
+ }
119
+ /**
120
+ * Creates a new `User` instance from a JSON string.
121
+ *
122
+ * @param jsonString - A JSON string containing user data.
123
+ * @returns A `User` instance reconstructed from the JSON data.
124
+ * @throws Will throw an error if the JSON data is invalid or incomplete.
125
+ */
126
+ static fromJSON(jsonString) {
127
+ const data = JSON.parse(jsonString);
128
+ if (!data.profile ||
129
+ !data.token ||
130
+ !data.name ||
131
+ !data.identity ||
132
+ !Array.isArray(data.permissions) ||
133
+ typeof data.resetPassword !== "boolean") {
134
+ throw new Error("Invalid JSON data for User");
135
+ }
136
+ // Reconstruct the CoreUser structure
137
+ const args = {
138
+ profile: data.profile,
139
+ token: data.token,
140
+ access: data.permissions,
141
+ resetPassword: data.resetPassword,
142
+ loginCredentials: {
143
+ name: data.name,
144
+ identity: data.identity,
145
+ },
146
+ };
147
+ return new User(args);
148
+ }
149
+ }
@@ -0,0 +1,11 @@
1
+ import { type WalletStatementItem } from "./schemas.js";
2
+ /**
3
+ * Type guard function that checks if the provided data is an array of valid wallet statement items.
4
+ * Uses Zod schema validation to ensure each item in the array matches the WalletStatementItem schema.
5
+ *
6
+ * @param {unknown} data - The data to be type checked. Can be any value.
7
+ * @returns {boolean} Returns true if the data is an array of valid WalletStatementItem objects,
8
+ * false otherwise
9
+ */
10
+ export declare function isWalletStatementItemArray(data: unknown): data is WalletStatementItem[];
11
+ //# sourceMappingURL=guards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../../../../src/src/models/wallet/guards.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,cAAc,CAAC;AAEtB;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,OAAO,GACZ,IAAI,IAAI,mBAAmB,EAAE,CAG/B"}
@@ -0,0 +1,14 @@
1
+ import { z } from "zod";
2
+ import { WalletSchemas, } from "./schemas.js";
3
+ /**
4
+ * Type guard function that checks if the provided data is an array of valid wallet statement items.
5
+ * Uses Zod schema validation to ensure each item in the array matches the WalletStatementItem schema.
6
+ *
7
+ * @param {unknown} data - The data to be type checked. Can be any value.
8
+ * @returns {boolean} Returns true if the data is an array of valid WalletStatementItem objects,
9
+ * false otherwise
10
+ */
11
+ export function isWalletStatementItemArray(data) {
12
+ const result = z.array(WalletSchemas.statementEntry).safeParse(data);
13
+ return result.success;
14
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./guards.js";
2
+ export * from "./schemas.js";
3
+ export * from "./statement.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/models/wallet/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./guards.js";
2
+ export * from "./schemas.js";
3
+ export * from "./statement.js";
@@ -0,0 +1,50 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Type definition for statement entry schema using Zod.
4
+ * This is used as a TypeScript type helper for the actual schema implementation.
5
+ */
6
+ type _StatementEntryType = z.ZodObject<{
7
+ accountNo: z.ZodEffects<z.ZodOptional<z.ZodString>>;
8
+ cbaRefNo: z.ZodEffects<z.ZodOptional<z.ZodString>>;
9
+ debitOrCredit: z.ZodString;
10
+ tranRefNo: z.ZodString;
11
+ narration: z.ZodString;
12
+ txnDate: z.ZodDate;
13
+ valueDate: z.ZodDate;
14
+ amountCredited: z.ZodNumber;
15
+ amountDebited: z.ZodNumber;
16
+ balance: z.ZodNumber;
17
+ }>;
18
+ /**
19
+ * Type definition for wallet schema using Zod.
20
+ * This is used as a TypeScript type helper for the actual schema implementation.
21
+ */
22
+ type _WalletType = z.ZodObject<{
23
+ id: z.ZodString;
24
+ profileId: z.ZodString;
25
+ accountNo: z.ZodString;
26
+ accountName: z.ZodString;
27
+ channel: z.ZodString;
28
+ createdAt: z.ZodString;
29
+ updatedAt: z.ZodString;
30
+ }>;
31
+ /**
32
+ * Collection of wallet-related schemas for export.
33
+ * Provides access to both wallet and statement entry validation schemas.
34
+ */
35
+ export declare const WalletSchemas: {
36
+ wallet: _WalletType;
37
+ statementEntry: _StatementEntryType;
38
+ };
39
+ /**
40
+ * TypeScript type for a validated wallet object.
41
+ * Use this type for wallet instances that have been validated against the schema.
42
+ */
43
+ export type Wallet = z.infer<typeof WalletSchemas.wallet>;
44
+ /**
45
+ * TypeScript type for a validated statement entry object.
46
+ * Use this type for statement entries that have been validated against the schema.
47
+ */
48
+ export type WalletStatementItem = z.infer<typeof WalletSchemas.statementEntry>;
49
+ export {};
50
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/src/models/wallet/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB;;;GAGG;AACH,KAAK,mBAAmB,GAAG,CAAC,CAAC,SAAS,CAAC;IACrC,SAAS,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IACpD,QAAQ,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IACnD,aAAa,EAAE,CAAC,CAAC,SAAS,CAAC;IAC3B,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC;IACvB,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC;IACvB,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC;IACnB,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC;IACrB,cAAc,EAAE,CAAC,CAAC,SAAS,CAAC;IAC5B,aAAa,EAAE,CAAC,CAAC,SAAS,CAAC;IAC3B,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC;CACtB,CAAC,CAAC;AA8BH;;;GAGG;AACH,KAAK,WAAW,GAAG,CAAC,CAAC,SAAS,CAAC;IAC7B,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC;IAChB,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC;IACvB,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC;IACvB,WAAW,EAAE,CAAC,CAAC,SAAS,CAAC;IACzB,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC;IACrB,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC;IACvB,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC;CACxB,CAAC,CAAC;AAwBH;;;GAGG;AACH,eAAO,MAAM,aAAa;;;CAGzB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC;AAE1D;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,cAAc,CAAC,CAAC"}
@@ -0,0 +1,64 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Helper function to make a field optional with undefined
4
+ * Transforms null values to undefined for consistency
5
+ * @param schema - The Zod schema to make optional
6
+ * @returns A schema that only allows string or undefined (no null)
7
+ */
8
+ const makeOptional = (schema) => schema.optional().transform((val) => val ?? undefined);
9
+ /**
10
+ * Schema definition for a statement entry.
11
+ * Represents a single transaction in a wallet's statement history.
12
+ *
13
+ * @property {string} accountNo - The account number associated with the transaction (optional)
14
+ * @property {string} cbaRefNo - Core banking system reference number (optional)
15
+ * @property {string} debitOrCredit - Indicator if transaction is debit or credit
16
+ * @property {string} tranRefNo - Transaction reference number
17
+ * @property {string} narration - Description of the transaction
18
+ * @property {Date} txnDate - Date when transaction was initiated
19
+ * @property {Date} valueDate - Date when transaction value was applied
20
+ * @property {number} amountCredited - Amount credited in transaction (if credit)
21
+ * @property {number} amountDebited - Amount debited in transaction (if debit)
22
+ * @property {number} balance - Running balance after transaction
23
+ */
24
+ const statementEntrySchema = z.object({
25
+ accountNo: makeOptional(z.string()),
26
+ cbaRefNo: makeOptional(z.string()),
27
+ debitOrCredit: z.string().min(1, "Transaction type is required"),
28
+ tranRefNo: z.string().min(1, "Transaction reference is required"),
29
+ narration: z.string().min(1, "Transaction description is required"),
30
+ txnDate: z.coerce.date(),
31
+ valueDate: z.coerce.date(),
32
+ amountCredited: z.number().min(0, "Credited amount must be non-negative"),
33
+ amountDebited: z.number().min(0, "Debited amount must be non-negative"),
34
+ balance: z.number(),
35
+ });
36
+ /**
37
+ * Schema definition for a wallet.
38
+ * Represents a digital wallet that can hold funds and process transactions.
39
+ *
40
+ * @property {string} id - Unique identifier for the wallet
41
+ * @property {string} profileId - ID of the profile that owns this wallet
42
+ * @property {string} accountNo - Account number associated with the wallet
43
+ * @property {string} accountName - Name of the account holder
44
+ * @property {string} channel - Payment channel or provider (e.g., "MPESA", "BANK")
45
+ * @property {string} createdAt - ISO datetime string of wallet creation
46
+ * @property {string} updatedAt - ISO datetime string of last wallet update
47
+ */
48
+ const walletSchema = z.object({
49
+ id: z.string().uuid("Invalid wallet ID format"),
50
+ profileId: z.string().min(1, "Profile ID is required"),
51
+ accountNo: z.string().min(1, "Account number is required"),
52
+ accountName: z.string().min(1, "Account name is required"),
53
+ channel: z.string().min(1, "Channel is required"),
54
+ createdAt: z.string().datetime("Invalid creation timestamp"),
55
+ updatedAt: z.string().datetime("Invalid update timestamp"),
56
+ });
57
+ /**
58
+ * Collection of wallet-related schemas for export.
59
+ * Provides access to both wallet and statement entry validation schemas.
60
+ */
61
+ export const WalletSchemas = {
62
+ wallet: walletSchema,
63
+ statementEntry: statementEntrySchema,
64
+ };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Enum representing the supported output formats for statement generation.
3
+ * Used to specify the desired file format when requesting statement downloads.
4
+ *
5
+ * @enum {string}
6
+ */
7
+ export declare enum STATEMENT_OUTPUT_TYPE {
8
+ /** Generate statement as a PDF document */
9
+ PDF = "PDF",
10
+ /** Generate statement as an Excel spreadsheet */
11
+ EXCEL = "EXCEL"
12
+ }
13
+ /**
14
+ * Interface defining the structure of a generated statement file.
15
+ * Contains metadata about the file and its content type.
16
+ *
17
+ * @interface StatementFile
18
+ * @property {string} file - Base64 encoded string of the file content or file path
19
+ * @property {string} file_extension - File extension (e.g., "pdf", "xlsx") without the dot
20
+ * @property {string} mime_type - MIME type of the file (e.g., "application/pdf", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
21
+ */
22
+ export interface StatementFile {
23
+ file: string;
24
+ file_extension: string;
25
+ mime_type: string;
26
+ }
27
+ //# sourceMappingURL=statement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statement.d.ts","sourceRoot":"","sources":["../../../../src/src/models/wallet/statement.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,oBAAY,qBAAqB;IAC/B,2CAA2C;IAC3C,GAAG,QAAQ;IACX,iDAAiD;IACjD,KAAK,UAAU;CAChB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Enum representing the supported output formats for statement generation.
3
+ * Used to specify the desired file format when requesting statement downloads.
4
+ *
5
+ * @enum {string}
6
+ */
7
+ export var STATEMENT_OUTPUT_TYPE;
8
+ (function (STATEMENT_OUTPUT_TYPE) {
9
+ /** Generate statement as a PDF document */
10
+ STATEMENT_OUTPUT_TYPE["PDF"] = "PDF";
11
+ /** Generate statement as an Excel spreadsheet */
12
+ STATEMENT_OUTPUT_TYPE["EXCEL"] = "EXCEL";
13
+ })(STATEMENT_OUTPUT_TYPE || (STATEMENT_OUTPUT_TYPE = {}));
@@ -0,0 +1,56 @@
1
+ import { type AppRouter } from "@ts-rest/core";
2
+ import type { InitClientArgs } from "@ts-rest/core";
3
+ /**
4
+ * BaseRepository
5
+ *
6
+ * A generic base class to build repositories for interacting with the Afloat API.
7
+ * This class initializes a "ts-rest" client using a specified "ts-rest" contract and provides
8
+ * helper methods to handle API responses consistently.
9
+ *
10
+ * @template TContract - The API contract extending `AppRouter` from `@npm/ts_rest.ts`.
11
+ */
12
+ export declare class BaseRepository<TContract extends AppRouter> {
13
+ /**
14
+ * A "ts-rest" contract
15
+ *
16
+ * @protected
17
+ */
18
+ protected contract: TContract;
19
+ /**
20
+ * An API endpoint
21
+ *
22
+ * @protected
23
+ */
24
+ protected endpoint: string;
25
+ /**
26
+ * An API Root URL
27
+ *
28
+ * @protected
29
+ */
30
+ protected root: string | undefined;
31
+ /**
32
+ * Constructs a new instance of `BaseRepository`.
33
+ *
34
+ * @param contract - The "ts-rest" contract
35
+ * @param endpoint - API endpoint
36
+ */
37
+ constructor(endpoint: string, contract: TContract, args?: {
38
+ root?: string;
39
+ });
40
+ get client(): { [TKey in keyof TContract]: TContract[TKey] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey], InitClientArgs>> : TContract[TKey] extends AppRouter ? TContract[TKey] extends infer T extends AppRouter ? { [TKey_1 in keyof T]: TContract[TKey][TKey_1] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1], InitClientArgs>> : TContract[TKey][TKey_1] extends AppRouter ? TContract[TKey][TKey_1] extends infer T_1 extends AppRouter ? { [TKey_2 in keyof T_1]: TContract[TKey][TKey_1][TKey_2] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2] extends AppRouter ? TContract[TKey][TKey_1][TKey_2] extends infer T_2 extends AppRouter ? { [TKey_3 in keyof T_2]: TContract[TKey][TKey_1][TKey_2][TKey_3] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2][TKey_3], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2][TKey_3], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2][TKey_3] extends AppRouter ? TContract[TKey][TKey_1][TKey_2][TKey_3] extends infer T_3 extends AppRouter ? { [TKey_4 in keyof T_3]: TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4] extends AppRouter ? TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4] extends infer T_4 extends AppRouter ? { [TKey_5 in keyof T_4]: TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5] extends AppRouter ? TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5] extends infer T_5 extends AppRouter ? { [TKey_6 in keyof T_5]: TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6] extends AppRouter ? TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6] extends infer T_6 extends AppRouter ? { [TKey_7 in keyof T_6]: TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7] extends AppRouter ? TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7] extends infer T_7 extends AppRouter ? { [TKey_8 in keyof T_7]: TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8] extends AppRouter ? TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8] extends infer T_8 extends AppRouter ? { [TKey_9 in keyof T_8]: TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9] extends AppRouter ? TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9] extends infer T_9 extends AppRouter ? { [TKey_10 in keyof T_9]: TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9][TKey_10] extends import("@ts-rest/core").AppRoute ? import("@ts-rest/core").AppRouteFunction<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9][TKey_10], InitClientArgs, import("@ts-rest/core").PartialClientInferRequest<TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9][TKey_10], InitClientArgs>> : TContract[TKey][TKey_1][TKey_2][TKey_3][TKey_4][TKey_5][TKey_6][TKey_7][TKey_8][TKey_9][TKey_10] extends AppRouter ? any : never; } : never : never; } : never : never; } : never : never; } : never : never; } : never : never; } : never : never; } : never : never; } : never : never; } : never : never; } : never : never; };
41
+ /**
42
+ * Handles the API response by checking the HTTP status code and returning the response body
43
+ * for successful requests or throwing an `APIError` for errors.
44
+ *
45
+ * @template T - The expected type of the successful response body.
46
+ * @param result - The API response object containing the status code and response body.
47
+ * @param successStatusCode - The expected HTTP status code indicating success (e.g., 200, 201).
48
+ * @returns The response body typed as `T` if the status code matches the success criteria.
49
+ * @throws `APIError` - If the status code indicates a failure.
50
+ */
51
+ handleResponse<T>(result: {
52
+ status: number;
53
+ body: unknown;
54
+ }, successStatusCode: number): T;
55
+ }
56
+ //# sourceMappingURL=base_repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base_repository.d.ts","sourceRoot":"","sources":["../../../src/src/shared/base_repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAc,MAAM,eAAe,CAAC;AAG3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAIpD;;;;;;;;GAQG;AACH,qBAAa,cAAc,CAAC,SAAS,SAAS,SAAS;IACrD;;;;OAIG;IACH,SAAS,CAAC,QAAQ,EAAE,SAAS,CAAC;IAE9B;;;;OAIG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE3B;;;;OAIG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAEnC;;;;;OAKG;gBACS,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE;IAM3E,IAAI,MAAM,k0LAcT;IAED;;;;;;;;;OASG;IACH,cAAc,CAAC,CAAC,EACd,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,EACzC,iBAAiB,EAAE,MAAM,GACxB,CAAC;CAgBL"}
@@ -0,0 +1,95 @@
1
+ import { initClient } from "@ts-rest/core";
2
+ import { APIError } from "../errors/api_error.js";
3
+ import { v4 as uuidv4 } from "uuid";
4
+ import { AfloatAuth } from "../features/auth/index.js";
5
+ /**
6
+ * BaseRepository
7
+ *
8
+ * A generic base class to build repositories for interacting with the Afloat API.
9
+ * This class initializes a "ts-rest" client using a specified "ts-rest" contract and provides
10
+ * helper methods to handle API responses consistently.
11
+ *
12
+ * @template TContract - The API contract extending `AppRouter` from `@npm/ts_rest.ts`.
13
+ */
14
+ export class BaseRepository {
15
+ /**
16
+ * Constructs a new instance of `BaseRepository`.
17
+ *
18
+ * @param contract - The "ts-rest" contract
19
+ * @param endpoint - API endpoint
20
+ */
21
+ constructor(endpoint, contract, args) {
22
+ /**
23
+ * A "ts-rest" contract
24
+ *
25
+ * @protected
26
+ */
27
+ Object.defineProperty(this, "contract", {
28
+ enumerable: true,
29
+ configurable: true,
30
+ writable: true,
31
+ value: void 0
32
+ });
33
+ /**
34
+ * An API endpoint
35
+ *
36
+ * @protected
37
+ */
38
+ Object.defineProperty(this, "endpoint", {
39
+ enumerable: true,
40
+ configurable: true,
41
+ writable: true,
42
+ value: void 0
43
+ });
44
+ /**
45
+ * An API Root URL
46
+ *
47
+ * @protected
48
+ */
49
+ Object.defineProperty(this, "root", {
50
+ enumerable: true,
51
+ configurable: true,
52
+ writable: true,
53
+ value: void 0
54
+ });
55
+ this.contract = contract;
56
+ this.endpoint = endpoint;
57
+ this.root = args?.root;
58
+ }
59
+ get client() {
60
+ const baseUrl = this.root
61
+ ? `${this.root}/${this.endpoint}`
62
+ : `https://api.afloat.money/v1/${this.endpoint}`;
63
+ const args = {
64
+ baseUrl,
65
+ baseHeaders: {
66
+ "token": AfloatAuth.instance.getUserToken() ?? "",
67
+ "x-request-id": uuidv4(),
68
+ },
69
+ };
70
+ return initClient(this.contract, args);
71
+ }
72
+ /**
73
+ * Handles the API response by checking the HTTP status code and returning the response body
74
+ * for successful requests or throwing an `APIError` for errors.
75
+ *
76
+ * @template T - The expected type of the successful response body.
77
+ * @param result - The API response object containing the status code and response body.
78
+ * @param successStatusCode - The expected HTTP status code indicating success (e.g., 200, 201).
79
+ * @returns The response body typed as `T` if the status code matches the success criteria.
80
+ * @throws `APIError` - If the status code indicates a failure.
81
+ */
82
+ handleResponse(result, successStatusCode) {
83
+ if (successStatusCode === result.status) {
84
+ return result.body;
85
+ }
86
+ if (result.status === 400) {
87
+ throw new APIError(result.body);
88
+ }
89
+ throw new APIError({
90
+ message: "We encountered an error trying to process your request. Please try again later",
91
+ statusCode: 520,
92
+ error: "UNKNOWN ERROR",
93
+ });
94
+ }
95
+ }
@@ -0,0 +1,13 @@
1
+ import type { AppRouteResponse } from "@ts-rest/core";
2
+ import { z } from "zod";
3
+ type ApiErrorResponseSchemaType = z.ZodObject<{
4
+ statusCode: z.ZodNumber;
5
+ message: z.ZodString;
6
+ error: z.ZodString;
7
+ details: z.ZodOptional<z.ZodRecord>;
8
+ }>;
9
+ export declare const common400ResponseSchema: ApiErrorResponseSchemaType;
10
+ export type Common400APIResponse = z.infer<typeof common400ResponseSchema>;
11
+ export declare const commonAPIResponses: Record<number, AppRouteResponse>;
12
+ export {};
13
+ //# sourceMappingURL=common_responses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common_responses.d.ts","sourceRoot":"","sources":["../../../src/src/shared/common_responses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,KAAK,0BAA0B,GAAG,CAAC,CAAC,SAAS,CAAC;IAC5C,UAAU,EAAE,CAAC,CAAC,SAAS,CAAC;IACxB,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC;IACrB,KAAK,EAAE,CAAC,CAAC,SAAS,CAAC;IACnB,OAAO,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;CACrC,CAAC,CAAC;AACH,eAAO,MAAM,uBAAuB,EAAE,0BAKpC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE3E,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAE/D,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { z } from "zod";
2
+ export const common400ResponseSchema = z.object({
3
+ statusCode: z.number(),
4
+ message: z.string(),
5
+ error: z.string(),
6
+ details: z.record(z.string()).optional(),
7
+ });
8
+ export const commonAPIResponses = {
9
+ 400: common400ResponseSchema,
10
+ };
@@ -0,0 +1,3 @@
1
+ export * from "./common_responses.js";
2
+ export * from "./base_repository.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/shared/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./common_responses.js";
2
+ export * from "./base_repository.js";
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@temboplus/afloat",
3
+ "version": "0.1.0",
4
+ "description": "A JavaScript/TypeScript package providing common utilities and logic shared across all Temboplus-Afloat Projects",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/TemboPlus-Frontend/afloat-js"
8
+ },
9
+ "license": "MIT",
10
+ "bugs": {
11
+ "url": "https://github.com/TemboPlus-Frontend/afloat-js/issues"
12
+ },
13
+ "main": "./script/mod.js",
14
+ "module": "./esm/mod.js",
15
+ "exports": {
16
+ ".": {
17
+ "import": "./esm/mod.js",
18
+ "require": "./script/mod.js"
19
+ }
20
+ },
21
+ "scripts": {
22
+ "test": "node test_runner.js"
23
+ },
24
+ "private": false,
25
+ "dependencies": {
26
+ "@temboplus/frontend-core": "^0.1.0",
27
+ "@ts-rest/core": "^3.51.0",
28
+ "antd": "^5.22.7",
29
+ "uuid": "^11.0.3",
30
+ "zod": "^3.24.1",
31
+ "zustand": "^5.0.2"
32
+ },
33
+ "devDependencies": {
34
+ "@types/node": "^20.9.0",
35
+ "picocolors": "^1.0.0",
36
+ "@faker-js/faker": "9.3.0",
37
+ "@deno/shim-deno": "~0.18.0"
38
+ },
39
+ "_generatedBy": "dnt@dev"
40
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_dnt.test_shims.d.ts","sourceRoot":"","sources":["../src/_dnt.test_shims.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAKvC,eAAO,MAAM,aAAa;;CAA2C,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"almost_equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/almost_equals.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM,EAClB,GAAG,CAAC,EAAE,MAAM,QAmBb"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array_includes.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/array_includes.ts"],"names":[],"mappings":"AAMA,0FAA0F;AAC1F,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,EACvB,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,EACzB,GAAG,CAAC,EAAE,MAAM,QAwBb"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/assert.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,SAAK,GAAG,OAAO,CAAC,IAAI,CAI5D"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertion_error.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/assertion_error.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC;;;;OAIG;gBACS,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAIpD"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"equal.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/equal.ts"],"names":[],"mappings":"AA2FA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAuGrD"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/equals.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,MAAM,EAAE,CAAC,EACT,QAAQ,EAAE,CAAC,EACX,GAAG,CAAC,EAAE,MAAM,QAkBb"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exists.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/exists.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,MAAM,EAAE,CAAC,EACT,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,CAOlC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fail.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.10/fail.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,wBAAgB,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,CAGxC"}