@temboplus/afloat 0.1.77-beta.9 → 0.1.79

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 (415) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +42 -246
  3. package/esm/mod.d.ts +8 -0
  4. package/esm/mod.d.ts.map +1 -0
  5. package/esm/mod.js +7 -0
  6. package/esm/package.json +3 -0
  7. package/{dist/lib/error/error.api.d.ts → esm/src/errors/api_error.d.ts} +1 -0
  8. package/esm/src/errors/api_error.d.ts.map +1 -0
  9. package/esm/src/errors/api_error.js +90 -0
  10. package/esm/src/errors/index.d.ts +3 -0
  11. package/esm/src/errors/index.d.ts.map +1 -0
  12. package/esm/src/errors/index.js +2 -0
  13. package/{dist/lib/error/error.permission.d.ts → esm/src/errors/permission_error.d.ts} +2 -1
  14. package/esm/src/errors/permission_error.d.ts.map +1 -0
  15. package/esm/src/errors/permission_error.js +70 -0
  16. package/{dist/modules/team-member/team-member.contract.d.ts → esm/src/features/admin/contract.d.ts} +158 -233
  17. package/esm/src/features/admin/contract.d.ts.map +1 -0
  18. package/esm/src/features/admin/contract.js +210 -0
  19. package/esm/src/features/admin/index.d.ts +4 -0
  20. package/esm/src/features/admin/index.d.ts.map +1 -0
  21. package/esm/src/features/admin/index.js +3 -0
  22. package/esm/src/features/admin/repository.d.ts +114 -0
  23. package/esm/src/features/admin/repository.d.ts.map +1 -0
  24. package/esm/src/features/admin/repository.js +248 -0
  25. package/esm/src/features/admin/schemas.d.ts +146 -0
  26. package/esm/src/features/admin/schemas.d.ts.map +1 -0
  27. package/esm/src/features/admin/schemas.js +206 -0
  28. package/esm/src/features/auth/access/contract.d.ts +14 -0
  29. package/esm/src/features/auth/access/contract.d.ts.map +1 -0
  30. package/esm/src/features/auth/access/contract.js +14 -0
  31. package/esm/src/features/auth/access/repository.d.ts +11 -0
  32. package/esm/src/features/auth/access/repository.d.ts.map +1 -0
  33. package/esm/src/features/auth/access/repository.js +25 -0
  34. package/{dist/modules/auth/auth.contract.d.ts → esm/src/features/auth/contract.d.ts} +19 -16
  35. package/esm/src/features/auth/contract.d.ts.map +1 -0
  36. package/esm/src/features/auth/contract.js +43 -0
  37. package/esm/src/features/auth/identity/contract.d.ts +23 -0
  38. package/esm/src/features/auth/identity/contract.d.ts.map +1 -0
  39. package/esm/src/features/auth/identity/contract.js +17 -0
  40. package/esm/src/features/auth/identity/repository.d.ts +22 -0
  41. package/esm/src/features/auth/identity/repository.d.ts.map +1 -0
  42. package/esm/src/features/auth/identity/repository.js +30 -0
  43. package/esm/src/features/auth/index.d.ts +6 -0
  44. package/esm/src/features/auth/index.d.ts.map +1 -0
  45. package/esm/src/features/auth/index.js +5 -0
  46. package/esm/src/features/auth/manager.d.ts +105 -0
  47. package/esm/src/features/auth/manager.d.ts.map +1 -0
  48. package/esm/src/features/auth/manager.js +181 -0
  49. package/{dist/modules/profile/profile.api-contract.d.ts → esm/src/features/auth/profile/contract.d.ts} +6 -8
  50. package/esm/src/features/auth/profile/contract.d.ts.map +1 -0
  51. package/esm/src/features/auth/profile/contract.js +14 -0
  52. package/esm/src/features/auth/profile/repository.d.ts +11 -0
  53. package/esm/src/features/auth/profile/repository.d.ts.map +1 -0
  54. package/esm/src/features/auth/profile/repository.js +25 -0
  55. package/esm/src/features/auth/repository.d.ts +30 -0
  56. package/esm/src/features/auth/repository.d.ts.map +1 -0
  57. package/esm/src/features/auth/repository.js +69 -0
  58. package/{dist/modules/auth/storage/client-store.d.ts → esm/src/features/auth/storage/client_store.d.ts} +2 -1
  59. package/esm/src/features/auth/storage/client_store.d.ts.map +1 -0
  60. package/esm/src/features/auth/storage/client_store.js +46 -0
  61. package/{dist/modules/auth/storage/client-token-handler.d.ts → esm/src/features/auth/storage/client_token_handler.d.ts} +1 -0
  62. package/esm/src/features/auth/storage/client_token_handler.d.ts.map +1 -0
  63. package/esm/src/features/auth/storage/client_token_handler.js +36 -0
  64. package/esm/src/features/auth/storage/server_store.d.ts +24 -0
  65. package/esm/src/features/auth/storage/server_store.d.ts.map +1 -0
  66. package/esm/src/features/auth/storage/server_store.js +34 -0
  67. package/esm/src/features/auth/storage/server_token_handler.d.ts +36 -0
  68. package/esm/src/features/auth/storage/server_token_handler.d.ts.map +1 -0
  69. package/esm/src/features/auth/storage/server_token_handler.js +115 -0
  70. package/{dist/modules → esm/src/features}/auth/storage/types.d.ts +2 -1
  71. package/esm/src/features/auth/storage/types.d.ts.map +1 -0
  72. package/esm/src/features/auth/storage/types.js +1 -0
  73. package/{dist/modules/contact/contact.api-contract.d.ts → esm/src/features/contact/contract.d.ts} +55 -88
  74. package/esm/src/features/contact/contract.d.ts.map +1 -0
  75. package/esm/src/features/contact/contract.js +49 -0
  76. package/esm/src/features/contact/index.d.ts +2 -0
  77. package/esm/src/features/contact/index.d.ts.map +1 -0
  78. package/esm/src/features/contact/index.js +1 -0
  79. package/esm/src/features/contact/repository.d.ts +58 -0
  80. package/esm/src/features/contact/repository.d.ts.map +1 -0
  81. package/esm/src/features/contact/repository.js +108 -0
  82. package/{dist/modules/payout/payout.api-contract.d.ts → esm/src/features/payout/contract.d.ts} +197 -340
  83. package/esm/src/features/payout/contract.d.ts.map +1 -0
  84. package/esm/src/features/payout/contract.js +75 -0
  85. package/esm/src/features/payout/index.d.ts +2 -0
  86. package/esm/src/features/payout/index.d.ts.map +1 -0
  87. package/esm/src/features/payout/index.js +1 -0
  88. package/esm/src/features/payout/repository.d.ts +67 -0
  89. package/esm/src/features/payout/repository.d.ts.map +1 -0
  90. package/esm/src/features/payout/repository.js +163 -0
  91. package/{dist/modules/wallet/wallet.contract.d.ts → esm/src/features/wallet/contract.d.ts} +11 -13
  92. package/esm/src/features/wallet/contract.d.ts.map +1 -0
  93. package/esm/src/features/wallet/contract.js +38 -0
  94. package/esm/src/features/wallet/index.d.ts +2 -0
  95. package/esm/src/features/wallet/index.d.ts.map +1 -0
  96. package/esm/src/features/wallet/index.js +1 -0
  97. package/esm/src/features/wallet/repository.d.ts +57 -0
  98. package/esm/src/features/wallet/repository.d.ts.map +1 -0
  99. package/esm/src/features/wallet/repository.js +93 -0
  100. package/esm/src/models/contact/derivatives/contact.d.ts +172 -0
  101. package/esm/src/models/contact/derivatives/contact.d.ts.map +1 -0
  102. package/esm/src/models/contact/derivatives/contact.js +266 -0
  103. package/esm/src/models/contact/derivatives/contact_info.d.ts +188 -0
  104. package/esm/src/models/contact/derivatives/contact_info.d.ts.map +1 -0
  105. package/esm/src/models/contact/derivatives/contact_info.js +255 -0
  106. package/esm/src/models/contact/index.d.ts +5 -0
  107. package/esm/src/models/contact/index.d.ts.map +1 -0
  108. package/esm/src/models/contact/index.js +4 -0
  109. package/esm/src/models/contact/schemas.d.ts +66 -0
  110. package/esm/src/models/contact/schemas.d.ts.map +1 -0
  111. package/esm/src/models/contact/schemas.js +64 -0
  112. package/esm/src/models/contact/validation.d.ts +37 -0
  113. package/esm/src/models/contact/validation.d.ts.map +1 -0
  114. package/esm/src/models/contact/validation.js +146 -0
  115. package/esm/src/models/index.d.ts +7 -0
  116. package/esm/src/models/index.d.ts.map +1 -0
  117. package/esm/src/models/index.js +6 -0
  118. package/esm/src/models/payout/api.d.ts +29 -0
  119. package/esm/src/models/payout/api.d.ts.map +1 -0
  120. package/esm/src/models/payout/api.js +1 -0
  121. package/esm/src/models/payout/channel.d.ts +58 -0
  122. package/esm/src/models/payout/channel.d.ts.map +1 -0
  123. package/esm/src/models/payout/channel.js +53 -0
  124. package/esm/src/models/payout/derivatives/payout.d.ts +158 -0
  125. package/esm/src/models/payout/derivatives/payout.d.ts.map +1 -0
  126. package/esm/src/models/payout/derivatives/payout.js +271 -0
  127. package/esm/src/models/payout/index.d.ts +7 -0
  128. package/esm/src/models/payout/index.d.ts.map +1 -0
  129. package/esm/src/models/payout/index.js +6 -0
  130. package/esm/src/models/payout/narration.d.ts +164 -0
  131. package/esm/src/models/payout/narration.d.ts.map +1 -0
  132. package/esm/src/models/payout/narration.js +308 -0
  133. package/esm/src/models/payout/schemas.d.ts +156 -0
  134. package/esm/src/models/payout/schemas.d.ts.map +1 -0
  135. package/esm/src/models/payout/schemas.js +105 -0
  136. package/esm/src/models/payout/status.d.ts +33 -0
  137. package/esm/src/models/payout/status.d.ts.map +1 -0
  138. package/esm/src/models/payout/status.js +34 -0
  139. package/{dist/modules/login/permission.type.d.ts → esm/src/models/permission.d.ts} +9 -8
  140. package/esm/src/models/permission.d.ts.map +1 -0
  141. package/esm/src/models/permission.js +50 -0
  142. package/esm/src/models/role.d.ts +21 -0
  143. package/esm/src/models/role.d.ts.map +1 -0
  144. package/esm/src/models/role.js +73 -0
  145. package/esm/src/models/user/authenticated-user.d.ts +77 -0
  146. package/esm/src/models/user/authenticated-user.d.ts.map +1 -0
  147. package/esm/src/models/user/authenticated-user.js +226 -0
  148. package/esm/src/models/user/index.d.ts +4 -0
  149. package/esm/src/models/user/index.d.ts.map +1 -0
  150. package/esm/src/models/user/index.js +3 -0
  151. package/esm/src/models/user/managed-user.d.ts +108 -0
  152. package/esm/src/models/user/managed-user.d.ts.map +1 -0
  153. package/esm/src/models/user/managed-user.js +255 -0
  154. package/{dist/modules/profile/profile.model.d.ts → esm/src/models/user/profile.d.ts} +52 -81
  155. package/esm/src/models/user/profile.d.ts.map +1 -0
  156. package/esm/src/models/user/profile.js +334 -0
  157. package/esm/src/models/wallet/index.d.ts +4 -0
  158. package/esm/src/models/wallet/index.d.ts.map +1 -0
  159. package/esm/src/models/wallet/index.js +3 -0
  160. package/esm/src/models/wallet/schemas.d.ts +95 -0
  161. package/esm/src/models/wallet/schemas.d.ts.map +1 -0
  162. package/esm/src/models/wallet/schemas.js +35 -0
  163. package/esm/src/models/wallet/statement_entry.d.ts +160 -0
  164. package/esm/src/models/wallet/statement_entry.d.ts.map +1 -0
  165. package/esm/src/models/wallet/statement_entry.js +255 -0
  166. package/{dist/modules/wallet/wallet.model.d.ts → esm/src/models/wallet/wallet.d.ts} +37 -31
  167. package/esm/src/models/wallet/wallet.d.ts.map +1 -0
  168. package/esm/src/models/wallet/wallet.js +279 -0
  169. package/esm/src/shared/base_repository.d.ts +80 -0
  170. package/esm/src/shared/base_repository.d.ts.map +1 -0
  171. package/esm/src/shared/base_repository.js +153 -0
  172. package/esm/src/shared/common_responses.d.ts +13 -0
  173. package/esm/src/shared/common_responses.d.ts.map +1 -0
  174. package/esm/src/shared/common_responses.js +10 -0
  175. package/esm/src/shared/index.d.ts +3 -0
  176. package/esm/src/shared/index.d.ts.map +1 -0
  177. package/esm/src/shared/index.js +2 -0
  178. package/esm/src/shared/token_required_repository.d.ts +78 -0
  179. package/esm/src/shared/token_required_repository.d.ts.map +1 -0
  180. package/esm/src/shared/token_required_repository.js +128 -0
  181. package/package.json +23 -49
  182. package/script/mod.d.ts +8 -0
  183. package/script/mod.d.ts.map +1 -0
  184. package/script/mod.js +23 -0
  185. package/script/npm/src/mod.d.ts +8 -0
  186. package/script/npm/src/mod.d.ts.map +1 -0
  187. package/script/npm/src/mod.js +23 -0
  188. package/script/npm/src/src/errors/api_error.d.ts +63 -0
  189. package/script/npm/src/src/errors/api_error.d.ts.map +1 -0
  190. package/script/npm/src/src/errors/api_error.js +94 -0
  191. package/script/npm/src/src/errors/index.d.ts +3 -0
  192. package/script/npm/src/src/errors/index.d.ts.map +1 -0
  193. package/script/npm/src/src/errors/index.js +18 -0
  194. package/script/npm/src/src/errors/permission_error.d.ts +48 -0
  195. package/script/npm/src/src/errors/permission_error.d.ts.map +1 -0
  196. package/script/npm/src/src/errors/permission_error.js +74 -0
  197. package/script/npm/src/src/features/admin/contract.d.ts +842 -0
  198. package/script/npm/src/src/features/admin/contract.d.ts.map +1 -0
  199. package/script/npm/src/src/features/admin/contract.js +213 -0
  200. package/script/npm/src/src/features/admin/index.d.ts +4 -0
  201. package/script/npm/src/src/features/admin/index.d.ts.map +1 -0
  202. package/script/npm/src/src/features/admin/index.js +19 -0
  203. package/script/npm/src/src/features/admin/repository.d.ts +114 -0
  204. package/script/npm/src/src/features/admin/repository.d.ts.map +1 -0
  205. package/script/npm/src/src/features/admin/repository.js +252 -0
  206. package/script/npm/src/src/features/admin/schemas.d.ts +146 -0
  207. package/script/npm/src/src/features/admin/schemas.d.ts.map +1 -0
  208. package/script/npm/src/src/features/admin/schemas.js +209 -0
  209. package/script/npm/src/src/features/auth/access/contract.d.ts +14 -0
  210. package/script/npm/src/src/features/auth/access/contract.d.ts.map +1 -0
  211. package/script/npm/src/src/features/auth/access/contract.js +17 -0
  212. package/script/npm/src/src/features/auth/access/repository.d.ts +11 -0
  213. package/script/npm/src/src/features/auth/access/repository.d.ts.map +1 -0
  214. package/script/npm/src/src/features/auth/access/repository.js +29 -0
  215. package/script/npm/src/src/features/auth/contract.d.ts +112 -0
  216. package/script/npm/src/src/features/auth/contract.d.ts.map +1 -0
  217. package/script/npm/src/src/features/auth/contract.js +46 -0
  218. package/script/npm/src/src/features/auth/identity/contract.d.ts +23 -0
  219. package/script/npm/src/src/features/auth/identity/contract.d.ts.map +1 -0
  220. package/script/npm/src/src/features/auth/identity/contract.js +20 -0
  221. package/script/npm/src/src/features/auth/identity/repository.d.ts +22 -0
  222. package/script/npm/src/src/features/auth/identity/repository.d.ts.map +1 -0
  223. package/script/npm/src/src/features/auth/identity/repository.js +34 -0
  224. package/script/npm/src/src/features/auth/index.d.ts +6 -0
  225. package/script/npm/src/src/features/auth/index.d.ts.map +1 -0
  226. package/script/npm/src/src/features/auth/index.js +21 -0
  227. package/script/npm/src/src/features/auth/manager.d.ts +105 -0
  228. package/script/npm/src/src/features/auth/manager.d.ts.map +1 -0
  229. package/script/npm/src/src/features/auth/manager.js +185 -0
  230. package/script/npm/src/src/features/auth/profile/contract.d.ts +37 -0
  231. package/script/npm/src/src/features/auth/profile/contract.d.ts.map +1 -0
  232. package/script/npm/src/src/features/auth/profile/contract.js +17 -0
  233. package/script/npm/src/src/features/auth/profile/repository.d.ts +11 -0
  234. package/script/npm/src/src/features/auth/profile/repository.d.ts.map +1 -0
  235. package/script/npm/src/src/features/auth/profile/repository.js +29 -0
  236. package/script/npm/src/src/features/auth/repository.d.ts +30 -0
  237. package/script/npm/src/src/features/auth/repository.d.ts.map +1 -0
  238. package/script/npm/src/src/features/auth/repository.js +73 -0
  239. package/script/npm/src/src/features/auth/storage/client_store.d.ts +30 -0
  240. package/script/npm/src/src/features/auth/storage/client_store.d.ts.map +1 -0
  241. package/script/npm/src/src/features/auth/storage/client_store.js +51 -0
  242. package/script/npm/src/src/features/auth/storage/client_token_handler.d.ts +32 -0
  243. package/script/npm/src/src/features/auth/storage/client_token_handler.d.ts.map +1 -0
  244. package/script/npm/src/src/features/auth/storage/client_token_handler.js +40 -0
  245. package/script/npm/src/src/features/auth/storage/server_store.d.ts +24 -0
  246. package/script/npm/src/src/features/auth/storage/server_store.d.ts.map +1 -0
  247. package/script/npm/src/src/features/auth/storage/server_store.js +38 -0
  248. package/script/npm/src/src/features/auth/storage/server_token_handler.d.ts +36 -0
  249. package/script/npm/src/src/features/auth/storage/server_token_handler.d.ts.map +1 -0
  250. package/script/npm/src/src/features/auth/storage/server_token_handler.js +119 -0
  251. package/script/npm/src/src/features/auth/storage/types.d.ts +42 -0
  252. package/script/npm/src/src/features/auth/storage/types.d.ts.map +1 -0
  253. package/script/npm/src/src/features/auth/storage/types.js +2 -0
  254. package/script/npm/src/src/features/contact/contract.d.ts +170 -0
  255. package/script/npm/src/src/features/contact/contract.d.ts.map +1 -0
  256. package/script/npm/src/src/features/contact/contract.js +52 -0
  257. package/script/npm/src/src/features/contact/index.d.ts +2 -0
  258. package/script/npm/src/src/features/contact/index.d.ts.map +1 -0
  259. package/script/npm/src/src/features/contact/index.js +17 -0
  260. package/script/npm/src/src/features/contact/repository.d.ts +58 -0
  261. package/script/npm/src/src/features/contact/repository.d.ts.map +1 -0
  262. package/script/npm/src/src/features/contact/repository.js +112 -0
  263. package/script/npm/src/src/features/payout/contract.d.ts +623 -0
  264. package/script/npm/src/src/features/payout/contract.d.ts.map +1 -0
  265. package/script/npm/src/src/features/payout/contract.js +78 -0
  266. package/script/npm/src/src/features/payout/index.d.ts +2 -0
  267. package/script/npm/src/src/features/payout/index.d.ts.map +1 -0
  268. package/script/npm/src/src/features/payout/index.js +17 -0
  269. package/script/npm/src/src/features/payout/repository.d.ts +67 -0
  270. package/script/npm/src/src/features/payout/repository.d.ts.map +1 -0
  271. package/script/npm/src/src/features/payout/repository.js +167 -0
  272. package/script/npm/src/src/features/wallet/contract.d.ts +137 -0
  273. package/script/npm/src/src/features/wallet/contract.d.ts.map +1 -0
  274. package/script/npm/src/src/features/wallet/contract.js +41 -0
  275. package/script/npm/src/src/features/wallet/index.d.ts +2 -0
  276. package/script/npm/src/src/features/wallet/index.d.ts.map +1 -0
  277. package/script/npm/src/src/features/wallet/index.js +17 -0
  278. package/script/npm/src/src/features/wallet/repository.d.ts +57 -0
  279. package/script/npm/src/src/features/wallet/repository.d.ts.map +1 -0
  280. package/script/npm/src/src/features/wallet/repository.js +97 -0
  281. package/script/npm/src/src/models/contact/derivatives/contact.d.ts +172 -0
  282. package/script/npm/src/src/models/contact/derivatives/contact.d.ts.map +1 -0
  283. package/script/npm/src/src/models/contact/derivatives/contact.js +270 -0
  284. package/script/npm/src/src/models/contact/derivatives/contact_info.d.ts +188 -0
  285. package/script/npm/src/src/models/contact/derivatives/contact_info.d.ts.map +1 -0
  286. package/script/npm/src/src/models/contact/derivatives/contact_info.js +260 -0
  287. package/script/npm/src/src/models/contact/index.d.ts +5 -0
  288. package/script/npm/src/src/models/contact/index.d.ts.map +1 -0
  289. package/script/npm/src/src/models/contact/index.js +20 -0
  290. package/script/npm/src/src/models/contact/schemas.d.ts +66 -0
  291. package/script/npm/src/src/models/contact/schemas.d.ts.map +1 -0
  292. package/script/npm/src/src/models/contact/schemas.js +67 -0
  293. package/script/npm/src/src/models/contact/validation.d.ts +37 -0
  294. package/script/npm/src/src/models/contact/validation.d.ts.map +1 -0
  295. package/script/npm/src/src/models/contact/validation.js +153 -0
  296. package/script/npm/src/src/models/index.d.ts +7 -0
  297. package/script/npm/src/src/models/index.d.ts.map +1 -0
  298. package/script/npm/src/src/models/index.js +22 -0
  299. package/script/npm/src/src/models/payout/api.d.ts +29 -0
  300. package/script/npm/src/src/models/payout/api.d.ts.map +1 -0
  301. package/script/npm/src/src/models/payout/api.js +2 -0
  302. package/script/npm/src/src/models/payout/channel.d.ts +58 -0
  303. package/script/npm/src/src/models/payout/channel.d.ts.map +1 -0
  304. package/script/npm/src/src/models/payout/channel.js +56 -0
  305. package/script/npm/src/src/models/payout/derivatives/payout.d.ts +158 -0
  306. package/script/npm/src/src/models/payout/derivatives/payout.d.ts.map +1 -0
  307. package/script/npm/src/src/models/payout/derivatives/payout.js +275 -0
  308. package/script/npm/src/src/models/payout/index.d.ts +7 -0
  309. package/script/npm/src/src/models/payout/index.d.ts.map +1 -0
  310. package/script/npm/src/src/models/payout/index.js +22 -0
  311. package/script/npm/src/src/models/payout/narration.d.ts +164 -0
  312. package/script/npm/src/src/models/payout/narration.d.ts.map +1 -0
  313. package/script/npm/src/src/models/payout/narration.js +312 -0
  314. package/script/npm/src/src/models/payout/schemas.d.ts +156 -0
  315. package/script/npm/src/src/models/payout/schemas.d.ts.map +1 -0
  316. package/script/npm/src/src/models/payout/schemas.js +108 -0
  317. package/script/npm/src/src/models/payout/status.d.ts +33 -0
  318. package/script/npm/src/src/models/payout/status.d.ts.map +1 -0
  319. package/script/npm/src/src/models/payout/status.js +37 -0
  320. package/script/npm/src/src/models/permission.d.ts +55 -0
  321. package/script/npm/src/src/models/permission.d.ts.map +1 -0
  322. package/script/npm/src/src/models/permission.js +53 -0
  323. package/script/npm/src/src/models/role.d.ts +21 -0
  324. package/script/npm/src/src/models/role.d.ts.map +1 -0
  325. package/script/npm/src/src/models/role.js +77 -0
  326. package/script/npm/src/src/models/user/authenticated-user.d.ts +77 -0
  327. package/script/npm/src/src/models/user/authenticated-user.d.ts.map +1 -0
  328. package/script/npm/src/src/models/user/authenticated-user.js +230 -0
  329. package/script/npm/src/src/models/user/index.d.ts +4 -0
  330. package/script/npm/src/src/models/user/index.d.ts.map +1 -0
  331. package/script/npm/src/src/models/user/index.js +19 -0
  332. package/script/npm/src/src/models/user/managed-user.d.ts +108 -0
  333. package/script/npm/src/src/models/user/managed-user.d.ts.map +1 -0
  334. package/script/npm/src/src/models/user/managed-user.js +260 -0
  335. package/script/npm/src/src/models/user/profile.d.ts +161 -0
  336. package/script/npm/src/src/models/user/profile.d.ts.map +1 -0
  337. package/script/npm/src/src/models/user/profile.js +338 -0
  338. package/script/npm/src/src/models/wallet/index.d.ts +4 -0
  339. package/script/npm/src/src/models/wallet/index.d.ts.map +1 -0
  340. package/script/npm/src/src/models/wallet/index.js +19 -0
  341. package/script/npm/src/src/models/wallet/schemas.d.ts +95 -0
  342. package/script/npm/src/src/models/wallet/schemas.d.ts.map +1 -0
  343. package/script/npm/src/src/models/wallet/schemas.js +38 -0
  344. package/script/npm/src/src/models/wallet/statement_entry.d.ts +160 -0
  345. package/script/npm/src/src/models/wallet/statement_entry.d.ts.map +1 -0
  346. package/script/npm/src/src/models/wallet/statement_entry.js +259 -0
  347. package/script/npm/src/src/models/wallet/wallet.d.ts +147 -0
  348. package/script/npm/src/src/models/wallet/wallet.d.ts.map +1 -0
  349. package/script/npm/src/src/models/wallet/wallet.js +283 -0
  350. package/script/npm/src/src/shared/base_repository.d.ts +80 -0
  351. package/script/npm/src/src/shared/base_repository.d.ts.map +1 -0
  352. package/script/npm/src/src/shared/base_repository.js +157 -0
  353. package/script/npm/src/src/shared/common_responses.d.ts +13 -0
  354. package/script/npm/src/src/shared/common_responses.d.ts.map +1 -0
  355. package/script/npm/src/src/shared/common_responses.js +13 -0
  356. package/script/npm/src/src/shared/index.d.ts +3 -0
  357. package/script/npm/src/src/shared/index.d.ts.map +1 -0
  358. package/script/npm/src/src/shared/index.js +18 -0
  359. package/script/npm/src/src/shared/token_required_repository.d.ts +78 -0
  360. package/script/npm/src/src/shared/token_required_repository.d.ts.map +1 -0
  361. package/script/npm/src/src/shared/token_required_repository.js +132 -0
  362. package/script/package.json +3 -0
  363. package/dist/index.cjs.js +0 -2
  364. package/dist/index.cjs.js.map +0 -1
  365. package/dist/index.d.ts +0 -10
  366. package/dist/index.esm.js +0 -2
  367. package/dist/index.esm.js.map +0 -1
  368. package/dist/lib/api/base-repository.d.ts +0 -175
  369. package/dist/lib/api/index.d.ts +0 -1
  370. package/dist/lib/error/error.utils.d.ts +0 -22
  371. package/dist/lib/error/index.d.ts +0 -3
  372. package/dist/lib/query/index.d.ts +0 -4
  373. package/dist/lib/query/pagination/pagination.d.ts +0 -73
  374. package/dist/lib/query/pagination/pagination.schemas.d.ts +0 -83
  375. package/dist/lib/query/query.builder.d.ts +0 -71
  376. package/dist/lib/query/query.types.d.ts +0 -36
  377. package/dist/modules/auth/auth.manager.d.ts +0 -249
  378. package/dist/modules/auth/auth.repository.d.ts +0 -83
  379. package/dist/modules/auth/auth.store.d.ts +0 -139
  380. package/dist/modules/auth/company-membership.model.d.ts +0 -171
  381. package/dist/modules/auth/index.d.ts +0 -4
  382. package/dist/modules/auth/user.model.d.ts +0 -363
  383. package/dist/modules/contact/contact-info.model.d.ts +0 -485
  384. package/dist/modules/contact/contact-input-handler.d.ts +0 -16
  385. package/dist/modules/contact/contact.dtos.d.ts +0 -84
  386. package/dist/modules/contact/contact.model.d.ts +0 -441
  387. package/dist/modules/contact/contact.repository.d.ts +0 -116
  388. package/dist/modules/contact/index.d.ts +0 -4
  389. package/dist/modules/login/index.d.ts +0 -4
  390. package/dist/modules/login/login.api-contract.d.ts +0 -51
  391. package/dist/modules/login/login.dtos.d.ts +0 -85
  392. package/dist/modules/login/login.model.d.ts +0 -168
  393. package/dist/modules/login/login.repository.d.ts +0 -58
  394. package/dist/modules/payout/index.d.ts +0 -5
  395. package/dist/modules/payout/payout-channel-handler.d.ts +0 -82
  396. package/dist/modules/payout/payout.dtos.d.ts +0 -605
  397. package/dist/modules/payout/payout.model.d.ts +0 -379
  398. package/dist/modules/payout/payout.query.d.ts +0 -133
  399. package/dist/modules/payout/payout.repository.d.ts +0 -181
  400. package/dist/modules/profile/index.d.ts +0 -3
  401. package/dist/modules/profile/profile.dtos.d.ts +0 -80
  402. package/dist/modules/profile/profile.repository.d.ts +0 -56
  403. package/dist/modules/team-member/index.d.ts +0 -4
  404. package/dist/modules/team-member/role.model.d.ts +0 -61
  405. package/dist/modules/team-member/team-member.dtos.d.ts +0 -261
  406. package/dist/modules/team-member/team-member.model.d.ts +0 -237
  407. package/dist/modules/team-member/team-member.repository.d.ts +0 -179
  408. package/dist/modules/wallet/index.d.ts +0 -7
  409. package/dist/modules/wallet/narration.model.d.ts +0 -225
  410. package/dist/modules/wallet/statement-entry.model.d.ts +0 -299
  411. package/dist/modules/wallet/wallet-manager.session.d.ts +0 -143
  412. package/dist/modules/wallet/wallet.dtos.d.ts +0 -204
  413. package/dist/modules/wallet/wallet.query.d.ts +0 -95
  414. package/dist/modules/wallet/wallet.repository.d.ts +0 -205
  415. package/dist/modules/wallet/wallet.utils.d.ts +0 -17
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2025 TemboPlus Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # @temboplus/afloat
2
2
 
3
- A foundational JavaScript/TypeScript library for TemboPlus-Afloat projects, providing abstracted server communication, shared utilities, and standardized data models for consistent development.
3
+ **A foundational library for Temboplus-Afloat projects.**
4
+
5
+ This JavaScript/TypeScript package provides a central hub for shared utilities, logic, and data access mechanisms within the Temboplus-Afloat ecosystem.
4
6
 
5
7
  ## Key Features
6
8
 
@@ -20,7 +22,7 @@ A foundational JavaScript/TypeScript library for TemboPlus-Afloat projects, prov
20
22
 
21
23
  * **Cross-Environment Compatibility**
22
24
  * Works seamlessly in both client-side and server-side environments
23
- * Different patterns for client-side authentication management vs server-side token handling
25
+ * Supports both synchronous and asynchronous initialization patterns
24
26
 
25
27
  ## Usage
26
28
 
@@ -28,7 +30,7 @@ A foundational JavaScript/TypeScript library for TemboPlus-Afloat projects, prov
28
30
 
29
31
  #### Client-Side Usage
30
32
 
31
- In client-side applications, use the `AfloatAuth` singleton for authentication management:
33
+ In client-side applications, authentication is initialized synchronously:
32
34
 
33
35
  ```typescript
34
36
  import { AfloatAuth } from "@temboplus/afloat";
@@ -37,67 +39,42 @@ import { AfloatAuth } from "@temboplus/afloat";
37
39
  const auth = AfloatAuth.instance;
38
40
 
39
41
  // Check if user is authenticated
40
- console.log("User authenticated:", auth.isAuthenticated);
42
+ console.log("User authenticated:", !!auth.currentUser);
41
43
 
42
44
  // Access current user
43
45
  const user = auth.currentUser;
44
46
  if (user) {
45
47
  console.log(`Logged in as: ${user.email}`);
46
48
  }
47
-
48
- // Login a user
49
- try {
50
- const user = await auth.logIn("user@example.com", "password123");
51
- console.log("Login successful!");
52
- } catch (error) {
53
- console.error("Login failed:", error.message);
54
- }
55
-
56
- // Check permissions
57
- if (auth.checkPermission(Permission.ViewBalance)) {
58
- console.log("User can view balance");
59
- }
60
-
61
- // React hook for reactive user state
62
- function UserProfile() {
63
- const user = auth.useCurrentUser();
64
-
65
- if (!user) {
66
- return <LoginForm />;
67
- }
68
-
69
- return <div>Hello, {user.name}!</div>;
70
- }
71
49
  ```
72
50
 
73
51
  #### Server-Side Usage
74
52
 
75
- In server-side environments, **do not use `AfloatAuth`**. Instead, extract the authentication token from requests and pass it directly to repositories:
53
+ In server-side environments, authentication requires asynchronous initialization:
76
54
 
77
55
  ```typescript
78
- import { WalletRepository } from "@temboplus/afloat";
56
+ import { AfloatAuth } from "@temboplus/afloat";
79
57
 
80
- // In a server route handler or API endpoint
58
+ // In a server route handler or similar context
81
59
  async function handleRequest(req, res) {
82
60
  try {
83
- // Extract token from request headers
61
+ // Extract token from request
84
62
  const token = req.headers.authorization?.replace('Bearer ', '');
85
63
 
86
64
  if (!token) {
87
65
  return res.status(401).json({ error: 'Unauthorized' });
88
66
  }
89
67
 
90
- // Create repository with explicit token
91
- const walletRepo = new WalletRepository({ token });
68
+ // Initialize server-side auth
69
+ const auth = await AfloatAuth.initializeServer(token);
92
70
 
93
- // Use repository methods directly
94
- const balance = await walletRepo.getBalance({ wallet });
95
- const wallets = await walletRepo.getWallets();
71
+ // Now you can use auth for permission checks
72
+ const isAdmin = auth.checkPermission(Permissions.Payout.View);
96
73
 
97
- return res.json({ balance, wallets });
74
+ // Continue with your handler logic...
98
75
  } catch (error) {
99
- console.error('Server request error:', error);
100
- return res.status(500).json({ error: 'Internal server error' });
76
+ console.error('Authentication error:', error);
77
+ return res.status(500).json({ error: 'Authentication failed' });
101
78
  }
102
79
  }
103
80
  ```
@@ -109,235 +86,54 @@ Repositories provide a consistent interface for data operations across environme
109
86
  #### Client-Side Repository Usage
110
87
 
111
88
  ```typescript
112
- import { WalletRepository } from "@temboplus/afloat";
113
-
114
- // Option 1: Let repository use service locator (default behavior)
115
- const walletRepo = new WalletRepository();
89
+ import { WalletRepo } from "@temboplus/afloat";
116
90
 
117
- // Option 2: Explicitly pass token from auth manager
118
- const auth = AfloatAuth.instance;
119
- const walletRepo = new WalletRepository({ token: auth.getUserToken() });
91
+ // Create repository - auth is automatically handled
92
+ const walletRepo = new WalletRepo();
120
93
 
121
94
  // Use repository methods
122
95
  async function displayBalance() {
123
96
  try {
124
- const balance = await walletRepo.getBalance({ wallet });
125
- console.log(`Current balance: ${balance.value} ${balance.currency}`);
97
+ const balance = await walletRepo.getBalance();
98
+ console.log(`Current balance: ${balance}`);
126
99
  } catch (error) {
127
100
  console.error('Error fetching balance:', error);
128
101
  }
129
102
  }
130
-
131
- // Get all wallets
132
- const wallets = await walletRepo.getWallets();
133
-
134
- // Get wallet statement
135
- const entries = await walletRepo.getStatement({
136
- wallet,
137
- range: {
138
- startDate: new Date('2024-01-01'),
139
- endDate: new Date('2024-01-31')
140
- }
141
- });
142
103
  ```
143
104
 
144
105
  #### Server-Side Repository Usage
145
106
 
146
107
  ```typescript
147
- import { WalletRepository } from "@temboplus/afloat";
108
+ import { AfloatAuth, WalletRepo } from "@temboplus/afloat";
148
109
 
149
- async function processServerRequest(token: string) {
150
- // Create repository with explicit token (no auth manager needed)
151
- const walletRepo = new WalletRepository({ token });
110
+ async function processServerRequest(token) {
111
+ // Initialize auth for this request
112
+ const auth = await AfloatAuth.initializeServer(token);
113
+
114
+ // Create repository with explicit auth instance
115
+ const walletRepo = new WalletRepo({ auth });
152
116
 
153
- // Use repository methods directly
154
- const balance = await walletRepo.getBalance({ wallet });
117
+ // Use repository methods
118
+ const balance = await walletRepo.getBalance();
155
119
  const wallets = await walletRepo.getWallets();
156
120
 
157
121
  return { balance, wallets };
158
122
  }
159
-
160
- // In Express.js middleware
161
- app.use('/api/wallet', async (req, res, next) => {
162
- const token = extractTokenFromRequest(req);
163
-
164
- if (!token) {
165
- return res.status(401).json({ error: 'No token provided' });
166
- }
167
-
168
- req.walletRepo = new WalletRepository({ token });
169
- next();
170
- });
171
123
  ```
172
124
 
173
- ## Architecture Overview
174
-
175
- ### Client-Side Pattern
176
- - **Authentication Management**: Use `AfloatAuth.instance` singleton
177
- - **Repository Creation**: Can use service locator or explicit token passing
178
- - **State Management**: Reactive updates through React hooks
179
- - **Permission Checking**: Built into the auth manager
180
-
181
- ### Server-Side Pattern
182
- - **No Auth Manager**: Extract tokens directly from requests
183
- - **Repository Creation**: Always pass token explicitly
184
- - **Stateless**: Each request creates fresh repository instances
185
- - **Permission Checking**: Handle at route/middleware level
186
-
187
125
  ## Best Practices
188
126
 
189
- ### Client-Side Applications
190
-
191
- 1. **Initialize Early**: Set up `AfloatAuth.instance` early in your application lifecycle
192
- 2. **Use React Hooks**: Leverage `auth.useCurrentUser()` for reactive UI updates
193
- 3. **Handle Permissions**: Check permissions before attempting restricted operations
194
- 4. **Error Handling**: Implement proper error handling for authentication failures
195
-
196
- ```typescript
197
- // Good: Initialize auth early
198
- const auth = AfloatAuth.instance;
199
-
200
- // Good: Use reactive hooks in components
201
- function Dashboard() {
202
- const user = auth.useCurrentUser();
203
-
204
- if (!user) return <LoginPrompt />;
205
-
206
- return <UserDashboard user={user} />;
207
- }
208
-
209
- // Good: Check permissions before operations
210
- if (auth.checkPermission(Permission.ViewBalance)) {
211
- const repo = new WalletRepository();
212
- const balance = await repo.getBalance({ wallet });
213
- }
214
- ```
215
-
216
- ### Server-Side Applications
217
-
218
- 1. **Token Extraction**: Always extract and validate tokens from requests
219
- 2. **Explicit Dependencies**: Pass tokens explicitly to repositories
220
- 3. **Error Handling**: Implement proper middleware for authentication errors
221
- 4. **Stateless Design**: Create fresh repository instances per request
222
-
223
- ```typescript
224
- // Good: Extract token from request
225
- const token = req.headers.authorization?.replace('Bearer ', '');
226
-
227
- // Good: Explicit token passing
228
- const repo = new WalletRepository({ token });
229
-
230
- // Good: Middleware pattern
231
- const authMiddleware = (req, res, next) => {
232
- const token = extractToken(req);
233
-
234
- if (!token) {
235
- return res.status(401).json({ error: 'Unauthorized' });
236
- }
237
-
238
- req.authToken = token;
239
- next();
240
- };
241
-
242
- // Good: Use in route handlers
243
- app.get('/api/balance', authMiddleware, async (req, res) => {
244
- const repo = new WalletRepository({ token: req.authToken });
245
- const balance = await repo.getBalance({ wallet });
246
- res.json({ balance });
247
- });
248
- ```
249
-
250
- ### Testing
251
-
252
- 1. **Client-Side**: Mock the `AfloatAuth` singleton or use dependency injection
253
- 2. **Server-Side**: Mock repositories with test tokens
254
- 3. **Integration**: Test both authentication flows and repository operations
255
-
256
- ```typescript
257
- // Client-side testing
258
- const mockAuth = {
259
- currentUser: testUser,
260
- getUserToken: () => 'test-token',
261
- checkPermission: () => true
262
- };
263
-
264
- // Server-side testing
265
- const testRepo = new WalletRepository({ token: 'test-token' });
266
- ```
267
-
268
- ## Troubleshooting
269
-
270
- ### Common Issues
271
-
272
- #### `"Cannot find package 'react'" in Node.js`
273
-
274
- This error occurs when using Zustand v5. Ensure you're using Zustand v4:
275
- ```bash
276
- npm install zustand@^4.5.7
277
- ```
278
-
279
- Remove any existing v5 installation:
280
- ```bash
281
- npm uninstall zustand@5.x.x
282
- ```
283
-
284
- #### Authentication Errors in Server Environment
285
-
286
- **Problem**: Trying to use `AfloatAuth.instance` in server-side code
287
- **Solution**: Extract tokens from requests and pass directly to repositories
288
-
289
- ```typescript
290
- // ❌ Don't do this in server code
291
- const auth = AfloatAuth.instance; // This is client-side only!
292
-
293
- // ✅ Do this instead
294
- const token = req.headers.authorization?.replace('Bearer ', '');
295
- const repo = new WalletRepository({ token });
296
- ```
297
-
298
- #### Repository Token Issues
299
-
300
- **Problem**: Repository calls failing with authentication errors
301
- **Solution**: Ensure tokens are properly extracted and passed
302
-
303
- ```typescript
304
- // ❌ Missing token
305
- const repo = new WalletRepository(); // May fail in server context
306
-
307
- // ✅ Explicit token
308
- const repo = new WalletRepository({ token: extractedToken });
309
- ```
310
-
311
- ### Debug Information
312
-
313
- Use the auth manager's debug utilities for troubleshooting:
314
-
315
- ```typescript
316
- // Client-side debugging
317
- const debugInfo = AfloatAuth.instance.getDebugInfo();
318
- console.log('Auth Debug Info:', debugInfo);
319
- ```
320
-
321
- ## API Reference
322
-
323
- ### AfloatAuth (Client-Side Only)
324
-
325
- - `AfloatAuth.instance` - Singleton instance for client-side usage
326
- - `currentUser` - Get current authenticated user
327
- - `isAuthenticated` - Check authentication status
328
- - `getUserToken()` - Get current auth token
329
- - `useCurrentUser()` - React hook for reactive user state
330
- - `checkPermission(perm)` - Check user permissions
331
- - `logIn(email, password)` - Authenticate user
332
- - `logOut()` - Clear authentication state
333
- - `resetPassword(current, new)` - Update user password
334
-
335
- ### Repository Pattern
127
+ 1. **Client-Side Applications**
128
+ - Initialize `AfloatAuth.instance` early in your application lifecycle
129
+ - Create repositories without explicit auth parameters
130
+ - Handle permission errors appropriately in your UI
336
131
 
337
- All repositories accept optional configuration:
338
- - `token` - Authentication token for API calls
339
- - `root` - Custom API root URL
132
+ 2. **Server-Side Applications**
133
+ - Always use `await AfloatAuth.initializeServer(token)` for each request
134
+ - Pass the auth instance explicitly to repositories
135
+ - Implement proper error handling for authentication failures
340
136
 
341
- Example repositories:
342
- - `WalletRepository` - Wallet operations and balance management
343
- - `AuthRepository` - Authentication operations
137
+ 3. **Testing**
138
+ - Use the `AuthContext` to inject mock auth instances during testing
139
+ - Reset `AuthContext.current` after each test to prevent test pollution
package/esm/mod.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ export * from "./src/features/auth/index.js";
2
+ export * from "./src/features/contact/index.js";
3
+ export * from "./src/features/wallet/index.js";
4
+ export * from "./src/features/payout/index.js";
5
+ export * from "./src/features/admin/index.js";
6
+ export * from "./src/errors/index.js";
7
+ export * from "./src/models/index.js";
8
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAE9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
package/esm/mod.js ADDED
@@ -0,0 +1,7 @@
1
+ export * from "./src/features/auth/index.js";
2
+ export * from "./src/features/contact/index.js";
3
+ export * from "./src/features/wallet/index.js";
4
+ export * from "./src/features/payout/index.js";
5
+ export * from "./src/features/admin/index.js";
6
+ export * from "./src/errors/index.js";
7
+ export * from "./src/models/index.js";
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -60,3 +60,4 @@ export declare class APIError extends Error {
60
60
  details: z.ZodOptional<z.AnyZodObject>;
61
61
  }>;
62
62
  }
63
+ //# sourceMappingURL=api_error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api_error.d.ts","sourceRoot":"","sources":["../../../src/src/errors/api_error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC;;;OAGG;IACH,SAAgB,UAAU,EAAE,MAAM,CAAC;IAEnC;;;OAGG;IACH,SAAgB,KAAK,CAAC,EAAE,MAAM,CAAC;IAE/B;;;OAGG;IACH,SAAgB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAElD;;;;;;;OAOG;gBACS,IAAI,EAAE;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACnC;IASD;;;;;;;;;;;;;;;;;OAiBG;WACW,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ;WAKrC,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,QAAQ;IAOjD,WAAkB,MAAM,IAAI,CAAC,CAAC,SAAS,CAAC;QACtC,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC;QACrB,UAAU,EAAE,CAAC,CAAC,SAAS,CAAC;QACxB,KAAK,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAClC,OAAO,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;KACxC,CAAC,CAOD;CACF"}
@@ -0,0 +1,90 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Custom error class representing API-related errors.
4
+ * Extends the built-in `Error` class to include additional properties such as `statusCode`, `error`, and `details`.
5
+ */
6
+ export class APIError extends Error {
7
+ /**
8
+ * Creates a new `APIError` instance.
9
+ * @param {Object} args - The arguments to initialize the error.
10
+ * @param {string} args.message - The error message.
11
+ * @param {number} args.statusCode - The HTTP status code associated with the error.
12
+ * @param {string} [args.error] - An optional error identifier or code.
13
+ * @param {Record<string, unknown>} [args.details] - Additional details about the error.
14
+ */
15
+ constructor(args) {
16
+ super(args.message);
17
+ /**
18
+ * The HTTP status code associated with the error.
19
+ * @type {number}
20
+ */
21
+ Object.defineProperty(this, "statusCode", {
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true,
25
+ value: void 0
26
+ });
27
+ /**
28
+ * An optional error identifier or code.
29
+ * @type {string | undefined}
30
+ */
31
+ Object.defineProperty(this, "error", {
32
+ enumerable: true,
33
+ configurable: true,
34
+ writable: true,
35
+ value: void 0
36
+ });
37
+ /**
38
+ * Additional details about the error, often used for debugging purposes.
39
+ * @type {Record<string, unknown> | undefined}
40
+ */
41
+ Object.defineProperty(this, "details", {
42
+ enumerable: true,
43
+ configurable: true,
44
+ writable: true,
45
+ value: void 0
46
+ });
47
+ this.name = "ApiError";
48
+ this.statusCode = args.statusCode;
49
+ if (this.error)
50
+ this.error = args.error;
51
+ if (args.details)
52
+ this.details = args.details;
53
+ }
54
+ /**
55
+ * Validates whether an unknown value conforms to the APIError schema.
56
+ * This is more thorough than an instanceof check as it verifies all required properties
57
+ * and their types using the defined schema.
58
+ *
59
+ * @param {unknown} error - Any value to be validated
60
+ * @returns {error is APIError} Type predicate indicating if the value is a valid APIError
61
+ *
62
+ * @example
63
+ * try {
64
+ * throw new Error('Network failed');
65
+ * } catch (err) {
66
+ * if (APIError.is(err)) {
67
+ * // err is typed as APIError here
68
+ * console.log(err.statusCode);
69
+ * }
70
+ * }
71
+ */
72
+ static is(error) {
73
+ const result = APIError.schema.safeParse(error);
74
+ return result.success;
75
+ }
76
+ static unknown(message) {
77
+ return new APIError({
78
+ message: message ?? "An unknown error occurred",
79
+ statusCode: 502,
80
+ });
81
+ }
82
+ static get schema() {
83
+ return z.object({
84
+ message: z.string(),
85
+ statusCode: z.number().int(),
86
+ error: z.string().optional(),
87
+ details: z.object({}).optional(),
88
+ });
89
+ }
90
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./api_error.js";
2
+ export * from "./permission_error.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/errors/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./api_error.js";
2
+ export * from "./permission_error.js";
@@ -1,4 +1,4 @@
1
- import { Permission } from "@/modules/login/permission.type.js";
1
+ import { type Permission } from "../models/permission.js";
2
2
  /**
3
3
  * Custom error class representing an error caused by missing required permissions.
4
4
  * Extends the built-in {@link Error} class to include the `requiredPermissions` property.
@@ -45,3 +45,4 @@ export declare class PermissionError extends Error {
45
45
  */
46
46
  static is(error: unknown): error is PermissionError;
47
47
  }
48
+ //# sourceMappingURL=permission_error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission_error.d.ts","sourceRoot":"","sources":["../../../src/src/errors/permission_error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAe,MAAM,yBAAyB,CAAC;AAGvE;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC;;;OAGG;IACH,SAAgB,mBAAmB,EAAE,UAAU,EAAE,CAAC;IAElD;;;;;OAKG;gBACS,IAAI,EAAE;QAChB,mBAAmB,EAAE,UAAU,EAAE,CAAC;QAClC,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB;IASD;;;;;;;;;;;;;;;;;;;;;;;OAuBG;WACW,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe;CAkB3D"}
@@ -0,0 +1,70 @@
1
+ import { Permissions } from "../models/permission.js";
2
+ import { z } from "zod";
3
+ /**
4
+ * Custom error class representing an error caused by missing required permissions.
5
+ * Extends the built-in {@link Error} class to include the `requiredPermissions` property.
6
+ */
7
+ export class PermissionError extends Error {
8
+ /**
9
+ * Creates a new `PermissionError` instance.
10
+ * @param {Object} args - The constructor arguments.
11
+ * @param {Permission[]} args.requiredPermissions - An array of permissions required for the operation.
12
+ * @param {string} [args.message] - An optional custom error message. Defaults to listing the missing permissions.
13
+ */
14
+ constructor(args) {
15
+ super(args.message ??
16
+ `Missing required permissions: ${args.requiredPermissions.join(", ")}`);
17
+ /**
18
+ * The permissions that are required but were not present, causing the error.
19
+ * @type {Permission[]}
20
+ */
21
+ Object.defineProperty(this, "requiredPermissions", {
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true,
25
+ value: void 0
26
+ });
27
+ this.name = "PermissionError";
28
+ this.requiredPermissions = args.requiredPermissions;
29
+ }
30
+ /**
31
+ * Validates if an unknown value is a valid PermissionError instance.
32
+ * Performs structural validation of the error object and its properties.
33
+ *
34
+ * @param {unknown} error - The value to validate.
35
+ * @returns {error is PermissionError} Type predicate indicating if the value is a valid PermissionError.
36
+ *
37
+ * @example
38
+ * try {
39
+ * throw new Error('Access denied');
40
+ * } catch (error) {
41
+ * if (PermissionError.is(error)) {
42
+ * // error is typed as PermissionError with properly typed requiredPermissions
43
+ * console.log(error.requiredPermissions);
44
+ * }
45
+ * }
46
+ *
47
+ * @remarks
48
+ * Validates the following:
49
+ * - Has all required Error properties
50
+ * - Has correct error name
51
+ * - Contains properly structured requiredPermissions array
52
+ * - Maintains proper prototype chain
53
+ */
54
+ static is(error) {
55
+ const permissionSchema = z.union([
56
+ z.enum(Object.values(Permissions.Profile)),
57
+ z.enum(Object.values(Permissions.Contact)),
58
+ z.enum(Object.values(Permissions.Payment)),
59
+ z.enum(Object.values(Permissions.Payout)),
60
+ z.enum(Object.values(Permissions.Transfer)),
61
+ z.enum(Object.values(Permissions.Wallet)),
62
+ ]);
63
+ const errorSchema = z.object({
64
+ name: z.literal("PermissionError"),
65
+ message: z.string(),
66
+ requiredPermissions: z.array(permissionSchema),
67
+ });
68
+ return errorSchema.safeParse(error).success;
69
+ }
70
+ }