@intlayer/design-system 3.1.0 → 3.2.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 (320) hide show
  1. package/dist/.vite/manifest.json +481 -455
  2. package/dist/TabSelector-BmkzVPXl.js +660 -0
  3. package/dist/TabSelector-BmkzVPXl.js.map +1 -0
  4. package/dist/TabSelector-o_NRBvPQ.cjs +659 -0
  5. package/dist/TabSelector-o_NRBvPQ.cjs.map +1 -0
  6. package/dist/components/Auth/AuthModal/index.cjs +17 -62
  7. package/dist/components/Auth/AuthModal/index.cjs.map +1 -1
  8. package/dist/components/Auth/AuthModal/index.d.ts.map +1 -1
  9. package/dist/components/Auth/AuthModal/index.mjs +17 -62
  10. package/dist/components/Auth/AuthModal/index.mjs.map +1 -1
  11. package/dist/components/Auth/AuthProvider/index.cjs.map +1 -1
  12. package/dist/components/Auth/AuthProvider/index.d.ts +3 -3
  13. package/dist/components/Auth/AuthProvider/index.d.ts.map +1 -1
  14. package/dist/components/Auth/AuthProvider/index.mjs.map +1 -1
  15. package/dist/components/Auth/AuthProvider/useSession.cjs +7 -8
  16. package/dist/components/Auth/AuthProvider/useSession.cjs.map +1 -1
  17. package/dist/components/Auth/AuthProvider/useSession.d.ts.map +1 -1
  18. package/dist/components/Auth/AuthProvider/useSession.mjs +7 -8
  19. package/dist/components/Auth/AuthProvider/useSession.mjs.map +1 -1
  20. package/dist/components/Auth/AuthenticationBarrier/AuthenticationBarrierClient.cjs +2 -2
  21. package/dist/components/Auth/AuthenticationBarrier/AuthenticationBarrierClient.cjs.map +1 -1
  22. package/dist/components/Auth/AuthenticationBarrier/AuthenticationBarrierClient.mjs +1 -1
  23. package/dist/components/Auth/AuthenticationBarrier/AuthenticationBarrierClient.mjs.map +1 -1
  24. package/dist/components/Auth/AuthenticationBarrier/AuthenticationBarrierServer.cjs.map +1 -1
  25. package/dist/components/Auth/AuthenticationBarrier/AuthenticationBarrierServer.d.ts +2 -2
  26. package/dist/components/Auth/AuthenticationBarrier/AuthenticationBarrierServer.d.ts.map +1 -1
  27. package/dist/components/Auth/AuthenticationBarrier/AuthenticationBarrierServer.mjs.map +1 -1
  28. package/dist/components/Auth/AuthenticationBarrier/accessValidation.cjs.map +1 -1
  29. package/dist/components/Auth/AuthenticationBarrier/accessValidation.d.ts +1 -1
  30. package/dist/components/Auth/AuthenticationBarrier/accessValidation.d.ts.map +1 -1
  31. package/dist/components/Auth/AuthenticationBarrier/accessValidation.mjs.map +1 -1
  32. package/dist/components/Auth/AuthenticationBarrier/index.d.ts +3 -3
  33. package/dist/components/Auth/AuthenticationBarrier/index.d.ts.map +1 -1
  34. package/dist/components/Auth/ChangePasswordForm/ChangePasswordForm.cjs +1 -0
  35. package/dist/components/Auth/ChangePasswordForm/ChangePasswordForm.cjs.map +1 -1
  36. package/dist/components/Auth/ChangePasswordForm/ChangePasswordForm.d.ts +1 -1
  37. package/dist/components/Auth/ChangePasswordForm/ChangePasswordForm.d.ts.map +1 -1
  38. package/dist/components/Auth/ChangePasswordForm/ChangePasswordForm.mjs +1 -0
  39. package/dist/components/Auth/ChangePasswordForm/ChangePasswordForm.mjs.map +1 -1
  40. package/dist/components/Auth/ChangePasswordForm/index.content.d.ts +10 -10
  41. package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.cjs +3 -2
  42. package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.cjs.map +1 -1
  43. package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.d.ts.map +1 -1
  44. package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.mjs +3 -2
  45. package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.mjs.map +1 -1
  46. package/dist/components/Auth/ExternalsLoginButtons/externalsLoginButtons.content.d.ts +5 -5
  47. package/dist/components/Auth/ResetPasswordForm/ResetPasswordForm.cjs +1 -0
  48. package/dist/components/Auth/ResetPasswordForm/ResetPasswordForm.cjs.map +1 -1
  49. package/dist/components/Auth/ResetPasswordForm/ResetPasswordForm.d.ts +1 -1
  50. package/dist/components/Auth/ResetPasswordForm/ResetPasswordForm.d.ts.map +1 -1
  51. package/dist/components/Auth/ResetPasswordForm/ResetPasswordForm.mjs +1 -0
  52. package/dist/components/Auth/ResetPasswordForm/ResetPasswordForm.mjs.map +1 -1
  53. package/dist/components/Auth/ResetPasswordForm/index.content.d.ts +7 -7
  54. package/dist/components/Auth/SignInForm/SignInForm.cjs +4 -3
  55. package/dist/components/Auth/SignInForm/SignInForm.cjs.map +1 -1
  56. package/dist/components/Auth/SignInForm/SignInForm.d.ts +1 -1
  57. package/dist/components/Auth/SignInForm/SignInForm.d.ts.map +1 -1
  58. package/dist/components/Auth/SignInForm/SignInForm.mjs +4 -3
  59. package/dist/components/Auth/SignInForm/SignInForm.mjs.map +1 -1
  60. package/dist/components/Auth/SignInForm/index.content.d.ts +13 -13
  61. package/dist/components/Auth/SignUpForm/SignUpForm.cjs +3 -3
  62. package/dist/components/Auth/SignUpForm/SignUpForm.cjs.map +1 -1
  63. package/dist/components/Auth/SignUpForm/SignUpForm.d.ts +1 -1
  64. package/dist/components/Auth/SignUpForm/SignUpForm.d.ts.map +1 -1
  65. package/dist/components/Auth/SignUpForm/SignUpForm.mjs +3 -3
  66. package/dist/components/Auth/SignUpForm/SignUpForm.mjs.map +1 -1
  67. package/dist/components/Auth/SignUpForm/index.content.d.ts +11 -11
  68. package/dist/components/Auth/index.cjs +2 -4
  69. package/dist/components/Auth/index.cjs.map +1 -1
  70. package/dist/components/Auth/index.d.ts +1 -1
  71. package/dist/components/Auth/index.d.ts.map +1 -1
  72. package/dist/components/Auth/index.mjs +1 -3
  73. package/dist/components/Auth/useAuth/index.cjs +39 -0
  74. package/dist/components/Auth/useAuth/index.cjs.map +1 -0
  75. package/dist/components/Auth/useAuth/index.d.ts +24 -0
  76. package/dist/components/Auth/useAuth/index.d.ts.map +1 -0
  77. package/dist/components/Auth/useAuth/index.mjs +39 -0
  78. package/dist/components/Auth/useAuth/index.mjs.map +1 -0
  79. package/dist/components/Auth/useAuth/useCSRF.cjs +22 -0
  80. package/dist/components/Auth/useAuth/useCSRF.cjs.map +1 -0
  81. package/dist/components/Auth/useAuth/useCSRF.d.ts +5 -0
  82. package/dist/components/Auth/useAuth/useCSRF.d.ts.map +1 -0
  83. package/dist/components/Auth/useAuth/useCSRF.mjs +22 -0
  84. package/dist/components/Auth/useAuth/useCSRF.mjs.map +1 -0
  85. package/dist/components/Auth/useAuth/useOAuth2.cjs +26 -0
  86. package/dist/components/Auth/useAuth/useOAuth2.cjs.map +1 -0
  87. package/dist/components/Auth/useAuth/useOAuth2.d.ts +4 -0
  88. package/dist/components/Auth/useAuth/useOAuth2.d.ts.map +1 -0
  89. package/dist/components/Auth/useAuth/useOAuth2.mjs +26 -0
  90. package/dist/components/Auth/useAuth/useOAuth2.mjs.map +1 -0
  91. package/dist/components/Auth/useAuth/useSession.cjs +60 -0
  92. package/dist/components/Auth/useAuth/useSession.cjs.map +1 -0
  93. package/dist/components/Auth/useAuth/useSession.d.ts +8 -0
  94. package/dist/components/Auth/useAuth/useSession.d.ts.map +1 -0
  95. package/dist/components/Auth/useAuth/useSession.mjs +60 -0
  96. package/dist/components/Auth/useAuth/useSession.mjs.map +1 -0
  97. package/dist/components/Auth/useUser/index.cjs +3 -3
  98. package/dist/components/Auth/useUser/index.cjs.map +1 -1
  99. package/dist/components/Auth/useUser/index.d.ts.map +1 -1
  100. package/dist/components/Auth/useUser/index.mjs +3 -3
  101. package/dist/components/Auth/useUser/index.mjs.map +1 -1
  102. package/dist/components/Badge/index.d.ts +1 -1
  103. package/dist/components/Button/Button.cjs.map +1 -1
  104. package/dist/components/Button/Button.d.ts +1 -2
  105. package/dist/components/Button/Button.d.ts.map +1 -1
  106. package/dist/components/Button/Button.mjs.map +1 -1
  107. package/dist/components/Command/index.d.ts +2 -2
  108. package/dist/components/Command/index.d.ts.map +1 -1
  109. package/dist/components/Container/index.cjs +1 -0
  110. package/dist/components/Container/index.cjs.map +1 -1
  111. package/dist/components/Container/index.d.ts +8 -8
  112. package/dist/components/Container/index.d.ts.map +1 -1
  113. package/dist/components/Container/index.mjs +1 -0
  114. package/dist/components/Container/index.mjs.map +1 -1
  115. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs +4 -17
  116. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs.map +1 -1
  117. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.d.ts.map +1 -1
  118. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs +4 -17
  119. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs.map +1 -1
  120. package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.cjs +0 -21
  121. package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.cjs.map +1 -1
  122. package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.d.ts +0 -9
  123. package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.d.ts.map +1 -1
  124. package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.mjs +0 -21
  125. package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.mjs.map +1 -1
  126. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.cjs +3 -2
  127. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.cjs.map +1 -1
  128. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.mjs +3 -2
  129. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.mjs.map +1 -1
  130. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs +7 -24
  131. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs.map +1 -1
  132. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.d.ts.map +1 -1
  133. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +6 -23
  134. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs.map +1 -1
  135. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryCreationForm.content.cjs +0 -42
  136. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryCreationForm.content.cjs.map +1 -1
  137. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryCreationForm.content.d.ts +0 -18
  138. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryCreationForm.content.d.ts.map +1 -1
  139. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryCreationForm.content.mjs +0 -42
  140. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryCreationForm.content.mjs.map +1 -1
  141. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryFormSchema.d.ts +2 -2
  142. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs +4 -36
  143. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs.map +1 -1
  144. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.d.ts.map +1 -1
  145. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +3 -35
  146. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map +1 -1
  147. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsSchema.d.ts +4 -4
  148. package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.cjs +0 -47
  149. package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.cjs.map +1 -1
  150. package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.d.ts +0 -19
  151. package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.d.ts.map +1 -1
  152. package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.mjs +0 -47
  153. package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.mjs.map +1 -1
  154. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs +3 -2
  155. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs.map +1 -1
  156. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +3 -2
  157. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
  158. package/dist/components/DictionaryFieldEditor/EditorView/EditorView.cjs +3 -2
  159. package/dist/components/DictionaryFieldEditor/EditorView/EditorView.cjs.map +1 -1
  160. package/dist/components/DictionaryFieldEditor/EditorView/EditorView.mjs +3 -2
  161. package/dist/components/DictionaryFieldEditor/EditorView/EditorView.mjs.map +1 -1
  162. package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.cjs +2 -2
  163. package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.mjs +2 -2
  164. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs +2 -2
  165. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +2 -2
  166. package/dist/components/DictionaryFieldEditor/NodeTypeSelector.cjs +2 -2
  167. package/dist/components/DictionaryFieldEditor/NodeTypeSelector.mjs +2 -2
  168. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +4 -17
  169. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs.map +1 -1
  170. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts.map +1 -1
  171. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +4 -17
  172. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
  173. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.cjs +0 -21
  174. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.cjs.map +1 -1
  175. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.d.ts +0 -9
  176. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.d.ts.map +1 -1
  177. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.mjs +0 -21
  178. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.mjs.map +1 -1
  179. package/dist/components/Form/FormBase.cjs +4 -1
  180. package/dist/components/Form/FormBase.cjs.map +1 -1
  181. package/dist/components/Form/FormBase.d.ts +1 -1
  182. package/dist/components/Form/FormBase.d.ts.map +1 -1
  183. package/dist/components/Form/FormBase.mjs +4 -1
  184. package/dist/components/Form/FormBase.mjs.map +1 -1
  185. package/dist/components/Input/Checkbox.d.ts +1 -1
  186. package/dist/components/Input/Input.cjs +8 -2
  187. package/dist/components/Input/Input.cjs.map +1 -1
  188. package/dist/components/Input/Input.d.ts +1 -0
  189. package/dist/components/Input/Input.d.ts.map +1 -1
  190. package/dist/components/Input/Input.mjs +8 -2
  191. package/dist/components/Input/Input.mjs.map +1 -1
  192. package/dist/components/Link/Link.d.ts +1 -1
  193. package/dist/components/Modal/Modal.cjs +3 -1
  194. package/dist/components/Modal/Modal.cjs.map +1 -1
  195. package/dist/components/Modal/Modal.mjs +3 -1
  196. package/dist/components/Modal/Modal.mjs.map +1 -1
  197. package/dist/components/Navbar/MobileNavbar.cjs +3 -1
  198. package/dist/components/Navbar/MobileNavbar.cjs.map +1 -1
  199. package/dist/components/Navbar/MobileNavbar.mjs +3 -1
  200. package/dist/components/Navbar/MobileNavbar.mjs.map +1 -1
  201. package/dist/components/Navbar/index.cjs +3 -1
  202. package/dist/components/Navbar/index.cjs.map +1 -1
  203. package/dist/components/Navbar/index.mjs +3 -1
  204. package/dist/components/Navbar/index.mjs.map +1 -1
  205. package/dist/components/Select/Multiselect.d.ts +1 -1
  206. package/dist/components/Select/Multiselect.d.ts.map +1 -1
  207. package/dist/components/SwitchSelector/index.cjs +3 -1
  208. package/dist/components/SwitchSelector/index.cjs.map +1 -1
  209. package/dist/components/SwitchSelector/index.d.ts +1 -1
  210. package/dist/components/SwitchSelector/index.mjs +3 -1
  211. package/dist/components/SwitchSelector/index.mjs.map +1 -1
  212. package/dist/components/TabSelector/TabSelector.cjs +13 -10
  213. package/dist/components/TabSelector/TabSelector.cjs.map +1 -1
  214. package/dist/components/TabSelector/TabSelector.d.ts +1 -1
  215. package/dist/components/TabSelector/TabSelector.d.ts.map +1 -1
  216. package/dist/components/TabSelector/TabSelector.mjs +13 -10
  217. package/dist/components/TabSelector/TabSelector.mjs.map +1 -1
  218. package/dist/components/Tag/index.cjs +79 -0
  219. package/dist/components/Tag/index.cjs.map +1 -0
  220. package/dist/components/Tag/index.d.ts +12 -0
  221. package/dist/components/Tag/index.d.ts.map +1 -0
  222. package/dist/components/Tag/index.mjs +79 -0
  223. package/dist/components/Tag/index.mjs.map +1 -0
  224. package/dist/components/Toaster/Toast.d.ts +1 -1
  225. package/dist/components/index.cjs +4 -4
  226. package/dist/components/index.d.ts +1 -0
  227. package/dist/components/index.d.ts.map +1 -1
  228. package/dist/components/index.mjs +3 -3
  229. package/dist/components/index.mjs.map +1 -1
  230. package/dist/hooks/index.cjs +4 -1
  231. package/dist/hooks/index.cjs.map +1 -1
  232. package/dist/hooks/index.d.ts +1 -0
  233. package/dist/hooks/index.d.ts.map +1 -1
  234. package/dist/hooks/index.mjs +5 -2
  235. package/dist/hooks/index.mjs.map +1 -1
  236. package/dist/hooks/intlayerAPIHooks.cjs +257 -126
  237. package/dist/hooks/intlayerAPIHooks.cjs.map +1 -1
  238. package/dist/hooks/intlayerAPIHooks.d.ts +43 -38
  239. package/dist/hooks/intlayerAPIHooks.d.ts.map +1 -1
  240. package/dist/hooks/intlayerAPIHooks.mjs +258 -127
  241. package/dist/hooks/intlayerAPIHooks.mjs.map +1 -1
  242. package/dist/hooks/useAsync/useAsync.cjs +142 -104
  243. package/dist/hooks/useAsync/useAsync.cjs.map +1 -1
  244. package/dist/hooks/useAsync/useAsync.d.ts +0 -2
  245. package/dist/hooks/useAsync/useAsync.d.ts.map +1 -1
  246. package/dist/hooks/useAsync/useAsync.mjs +143 -105
  247. package/dist/hooks/useAsync/useAsync.mjs.map +1 -1
  248. package/dist/hooks/useAsync/useAsyncStateStore.cjs +50 -112
  249. package/dist/hooks/useAsync/useAsyncStateStore.cjs.map +1 -1
  250. package/dist/hooks/useAsync/useAsyncStateStore.d.ts +3 -9
  251. package/dist/hooks/useAsync/useAsyncStateStore.d.ts.map +1 -1
  252. package/dist/hooks/useAsync/useAsyncStateStore.mjs +50 -112
  253. package/dist/hooks/useAsync/useAsyncStateStore.mjs.map +1 -1
  254. package/dist/hooks/useAsync/useProxyState.d.ts +3 -0
  255. package/dist/hooks/useAsync/useProxyState.d.ts.map +1 -0
  256. package/dist/hooks/useIntlayerAPI.cjs +6 -5
  257. package/dist/hooks/useIntlayerAPI.cjs.map +1 -1
  258. package/dist/hooks/useIntlayerAPI.d.ts +51 -45
  259. package/dist/hooks/useIntlayerAPI.d.ts.map +1 -1
  260. package/dist/hooks/useIntlayerAPI.mjs +5 -4
  261. package/dist/hooks/useIntlayerAPI.mjs.map +1 -1
  262. package/dist/hooks/useItemSelector.cjs +11 -2
  263. package/dist/hooks/useItemSelector.cjs.map +1 -1
  264. package/dist/hooks/useItemSelector.d.ts +3 -2
  265. package/dist/hooks/useItemSelector.d.ts.map +1 -1
  266. package/dist/hooks/useItemSelector.mjs +11 -2
  267. package/dist/hooks/useItemSelector.mjs.map +1 -1
  268. package/dist/hooks/usePersistedStore.cjs +22 -0
  269. package/dist/hooks/usePersistedStore.cjs.map +1 -0
  270. package/dist/hooks/usePersistedStore.d.ts +2 -0
  271. package/dist/hooks/usePersistedStore.d.ts.map +1 -0
  272. package/dist/hooks/usePersistedStore.mjs +22 -0
  273. package/dist/hooks/usePersistedStore.mjs.map +1 -0
  274. package/dist/hooks/usePersistenceStore.cjs +22 -0
  275. package/dist/hooks/usePersistenceStore.cjs.map +1 -0
  276. package/dist/hooks/usePersistenceStore.d.ts +2 -0
  277. package/dist/hooks/usePersistenceStore.d.ts.map +1 -0
  278. package/dist/hooks/usePersistenceStore.mjs +22 -0
  279. package/dist/hooks/usePersistenceStore.mjs.map +1 -0
  280. package/dist/libs/intlayer-api/auth.cjs +14 -2
  281. package/dist/libs/intlayer-api/auth.cjs.map +1 -1
  282. package/dist/libs/intlayer-api/auth.d.ts +7 -3
  283. package/dist/libs/intlayer-api/auth.d.ts.map +1 -1
  284. package/dist/libs/intlayer-api/auth.mjs +14 -2
  285. package/dist/libs/intlayer-api/auth.mjs.map +1 -1
  286. package/dist/libs/intlayer-api/fetcher.cjs +7 -1
  287. package/dist/libs/intlayer-api/fetcher.cjs.map +1 -1
  288. package/dist/libs/intlayer-api/fetcher.d.ts.map +1 -1
  289. package/dist/libs/intlayer-api/fetcher.mjs +7 -1
  290. package/dist/libs/intlayer-api/fetcher.mjs.map +1 -1
  291. package/dist/libs/intlayer-api/index.cjs +3 -1
  292. package/dist/libs/intlayer-api/index.cjs.map +1 -1
  293. package/dist/libs/intlayer-api/index.d.ts +12 -2
  294. package/dist/libs/intlayer-api/index.d.ts.map +1 -1
  295. package/dist/libs/intlayer-api/index.mjs +3 -1
  296. package/dist/libs/intlayer-api/index.mjs.map +1 -1
  297. package/dist/libs/intlayer-api/stripe.cjs +22 -0
  298. package/dist/libs/intlayer-api/stripe.cjs.map +1 -0
  299. package/dist/libs/intlayer-api/stripe.d.ts +6 -0
  300. package/dist/libs/intlayer-api/stripe.d.ts.map +1 -0
  301. package/dist/libs/intlayer-api/stripe.mjs +22 -0
  302. package/dist/libs/intlayer-api/stripe.mjs.map +1 -0
  303. package/dist/stripe-BsI0lJWz.js +22 -0
  304. package/dist/stripe-BsI0lJWz.js.map +1 -0
  305. package/dist/stripe-C-u5RvGh.js +22 -0
  306. package/dist/stripe-C-u5RvGh.js.map +1 -0
  307. package/dist/stripe-CF_E65Vu.js +22 -0
  308. package/dist/stripe-CF_E65Vu.js.map +1 -0
  309. package/dist/stripe-CpGvfq6T.cjs +21 -0
  310. package/dist/stripe-CpGvfq6T.cjs.map +1 -0
  311. package/dist/stripe-DEv4DjAL.cjs +21 -0
  312. package/dist/stripe-DEv4DjAL.cjs.map +1 -0
  313. package/dist/stripe-DuG0uaEn.cjs +21 -0
  314. package/dist/stripe-DuG0uaEn.cjs.map +1 -0
  315. package/dist/tailwind.css +1 -1
  316. package/dist/useProxyState-D5GLrY2y.js +20 -0
  317. package/dist/useProxyState-D5GLrY2y.js.map +1 -0
  318. package/dist/useProxyState-DewdF3no.cjs +19 -0
  319. package/dist/useProxyState-DewdF3no.cjs.map +1 -0
  320. package/package.json +15 -11
@@ -1 +1 @@
1
- {"version":3,"file":"useItemSelector.d.ts","sourceRoot":"","sources":["../../src/hooks/useItemSelector.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAEnE,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAKF,eAAO,MAAM,eAAe,gBACb,gBAAgB,CAAC,WAAW,EAAE,CAAC,aAClC,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO;;CA2H1D,CAAC"}
1
+ {"version":3,"file":"useItemSelector.d.ts","sourceRoot":"","sources":["../../src/hooks/useItemSelector.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAEnE,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAKF,eAAO,MAAM,eAAe,gBACb,gBAAgB,CAAC,WAAW,EAAE,CAAC,aAClC,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO;;CAoI1D,CAAC"}
@@ -13,12 +13,21 @@ const useItemSelector = (optionsRefs, selector = selectorDefault, isHoverable =
13
13
  } else {
14
14
  targetElement = optionsRefs.current.find(selector) ?? null;
15
15
  }
16
- if (!targetElement) return;
16
+ if (!targetElement) {
17
+ setChoiceIndicatorPosition((prev) => ({
18
+ left: 0,
19
+ width: 0,
20
+ ...prev,
21
+ opacity: 0
22
+ }));
23
+ return;
24
+ }
17
25
  const left = targetElement.offsetLeft;
18
26
  const width = targetElement.offsetWidth;
19
27
  setChoiceIndicatorPosition({
20
28
  left,
21
- width
29
+ width,
30
+ opacity: 1
22
31
  });
23
32
  };
24
33
  calculatePosition();
@@ -1 +1 @@
1
- {"version":3,"file":"useItemSelector.mjs","sources":["../../src/hooks/useItemSelector.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useState, type MutableRefObject } from 'react';\n\ntype PositionState = {\n left: number;\n width: number;\n};\n\nconst selectorDefault = (option: HTMLElement) =>\n option?.getAttribute('aria-selected') === 'true';\n\nexport const useItemSelector = (\n optionsRefs: MutableRefObject<HTMLElement[]>,\n selector: (option: HTMLElement, index: number) => boolean = selectorDefault,\n isHoverable = false\n) => {\n const [choiceIndicatorPosition, setChoiceIndicatorPosition] =\n useState<PositionState | null>(null);\n\n const [hoveredItem, setHoveredItem] = useState<HTMLElement | null>(null);\n\n const itemsLength = optionsRefs.current.length;\n\n useEffect(() => {\n const calculatePosition = () => {\n let targetElement: HTMLElement | null = null;\n\n if (hoveredItem) {\n targetElement = hoveredItem;\n } else {\n targetElement = optionsRefs.current.find(selector) ?? null;\n }\n\n if (!targetElement) return;\n\n const left = targetElement.offsetLeft;\n const width = targetElement.offsetWidth;\n\n setChoiceIndicatorPosition({\n left,\n width,\n });\n };\n\n calculatePosition();\n\n // Event listeners for window events\n window.addEventListener('resize', calculatePosition);\n window.addEventListener('DOMContentLoaded', calculatePosition);\n\n // MutationObserver to watch for 'aria-selected' changes\n const mutationObservers: MutationObserver[] = [];\n\n optionsRefs.current.forEach((option) => {\n if (option) {\n const observer = new MutationObserver((mutations) => {\n for (const mutation of mutations) {\n if (\n mutation.type === 'attributes' &&\n mutation.attributeName === 'aria-selected'\n ) {\n calculatePosition();\n break;\n }\n }\n });\n\n observer.observe(option, {\n attributes: true,\n attributeFilter: ['aria-selected'],\n });\n\n mutationObservers.push(observer);\n }\n });\n\n // ResizeObserver to watch for size changes\n const resizeObservers: ResizeObserver[] = [];\n\n const observeSize = (element: HTMLElement) => {\n if (!element) return;\n const resizeObserver = new ResizeObserver(() => {\n calculatePosition();\n });\n resizeObserver.observe(element);\n resizeObservers.push(resizeObserver);\n };\n\n // Observe the selected item\n const selectedItem = optionsRefs.current.find(selector) ?? null;\n\n if (selectedItem) {\n observeSize(selectedItem);\n }\n\n // Observe the hovered item\n if (hoveredItem) {\n observeSize(hoveredItem);\n }\n\n // Add hover event listeners\n const handleMouseEnter = (event: Event) => {\n setHoveredItem(event.currentTarget as HTMLElement);\n };\n\n const handleMouseLeave = () => {\n setHoveredItem(null);\n };\n\n if (isHoverable) {\n optionsRefs.current.forEach((option) => {\n option?.addEventListener('mouseenter', handleMouseEnter);\n option?.addEventListener('mouseleave', handleMouseLeave);\n });\n }\n\n return () => {\n // Cleanup window event listeners\n window.removeEventListener('resize', calculatePosition);\n window.removeEventListener('DOMContentLoaded', calculatePosition);\n\n // Disconnect MutationObservers\n mutationObservers.forEach((observer) => observer.disconnect());\n\n // Disconnect ResizeObservers\n resizeObservers.forEach((observer) => observer.disconnect());\n\n // Remove hover event listeners\n optionsRefs.current.forEach((option) => {\n option?.removeEventListener('mouseenter', handleMouseEnter);\n option?.removeEventListener('mouseleave', handleMouseLeave);\n });\n };\n }, [optionsRefs, selector, hoveredItem, itemsLength]);\n\n return { choiceIndicatorPosition };\n};\n"],"names":[],"mappings":";;AASA,MAAM,kBAAkB,CAAC,WACvB,QAAQ,aAAa,eAAe,MAAM;AAErC,MAAM,kBAAkB,CAC7B,aACA,WAA4D,iBAC5D,cAAc,UACX;AACH,QAAM,CAAC,yBAAyB,0BAA0B,IACxD,SAA+B,IAAI;AAErC,QAAM,CAAC,aAAa,cAAc,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C,UAAiB;AACzC,qBAAe,MAAM,aAA4B;AAAA,IAAA;AAGnD,UAAM,mBAAmB,MAAM;AAC7B,qBAAe,IAAI;AAAA,IAAA;AAGrB,QAAI,aAAa;AACH,kBAAA,QAAQ,QAAQ,CAAC,WAAW;AAC9B,gBAAA,iBAAiB,cAAc,gBAAgB;AAC/C,gBAAA,iBAAiB,cAAc,gBAAgB;AAAA,MAAA,CACxD;AAAA,IACH;AAEA,WAAO,MAAM;AAEJ,aAAA,oBAAoB,UAAU,iBAAiB;AAC/C,aAAA,oBAAoB,oBAAoB,iBAAiB;AAGhE,wBAAkB,QAAQ,CAAC,aAAa,SAAS,WAAY,CAAA;AAG7D,sBAAgB,QAAQ,CAAC,aAAa,SAAS,WAAY,CAAA;AAG/C,kBAAA,QAAQ,QAAQ,CAAC,WAAW;AAC9B,gBAAA,oBAAoB,cAAc,gBAAgB;AAClD,gBAAA,oBAAoB,cAAc,gBAAgB;AAAA,MAAA,CAC3D;AAAA,IAAA;AAAA,KAEF,CAAC,aAAa,UAAU,aAAa,WAAW,CAAC;AAEpD,SAAO,EAAE,wBAAwB;AACnC;"}
1
+ {"version":3,"file":"useItemSelector.mjs","sources":["../../src/hooks/useItemSelector.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useState, type MutableRefObject } from 'react';\n\ntype StyleState = {\n left: number;\n width: number;\n opacity: number;\n};\n\nconst selectorDefault = (option: HTMLElement) =>\n option?.getAttribute('aria-selected') === 'true';\n\nexport const useItemSelector = (\n optionsRefs: MutableRefObject<HTMLElement[]>,\n selector: (option: HTMLElement, index: number) => boolean = selectorDefault,\n isHoverable = false\n) => {\n const [choiceIndicatorPosition, setChoiceIndicatorPosition] =\n useState<StyleState | null>(null);\n\n const [hoveredItem, setHoveredItem] = useState<HTMLElement | null>(null);\n\n const itemsLength = optionsRefs.current.length;\n\n useEffect(() => {\n const calculatePosition = () => {\n let targetElement: HTMLElement | null = null;\n\n if (hoveredItem) {\n targetElement = hoveredItem;\n } else {\n targetElement = optionsRefs.current.find(selector) ?? null;\n }\n\n if (!targetElement) {\n setChoiceIndicatorPosition((prev) => ({\n left: 0,\n width: 0,\n ...prev,\n opacity: 0,\n }));\n return;\n }\n\n const left = targetElement.offsetLeft;\n const width = targetElement.offsetWidth;\n\n setChoiceIndicatorPosition({\n left,\n width,\n opacity: 1,\n });\n };\n\n calculatePosition();\n\n // Event listeners for window events\n window.addEventListener('resize', calculatePosition);\n window.addEventListener('DOMContentLoaded', calculatePosition);\n\n // MutationObserver to watch for 'aria-selected' changes\n const mutationObservers: MutationObserver[] = [];\n\n optionsRefs.current.forEach((option) => {\n if (option) {\n const observer = new MutationObserver((mutations) => {\n for (const mutation of mutations) {\n if (\n mutation.type === 'attributes' &&\n mutation.attributeName === 'aria-selected'\n ) {\n calculatePosition();\n break;\n }\n }\n });\n\n observer.observe(option, {\n attributes: true,\n attributeFilter: ['aria-selected'],\n });\n\n mutationObservers.push(observer);\n }\n });\n\n // ResizeObserver to watch for size changes\n const resizeObservers: ResizeObserver[] = [];\n\n const observeSize = (element: HTMLElement) => {\n if (!element) return;\n const resizeObserver = new ResizeObserver(() => {\n calculatePosition();\n });\n resizeObserver.observe(element);\n resizeObservers.push(resizeObserver);\n };\n\n // Observe the selected item\n const selectedItem = optionsRefs.current.find(selector) ?? null;\n\n if (selectedItem) {\n observeSize(selectedItem);\n }\n\n // Observe the hovered item\n if (hoveredItem) {\n observeSize(hoveredItem);\n }\n\n // Add hover event listeners\n const handleMouseEnter = (event: Event) => {\n setHoveredItem(event.currentTarget as HTMLElement);\n };\n\n const handleMouseLeave = () => {\n setHoveredItem(null);\n };\n\n if (isHoverable) {\n optionsRefs.current.forEach((option) => {\n option?.addEventListener('mouseenter', handleMouseEnter);\n option?.addEventListener('mouseleave', handleMouseLeave);\n });\n }\n\n return () => {\n // Cleanup window event listeners\n window.removeEventListener('resize', calculatePosition);\n window.removeEventListener('DOMContentLoaded', calculatePosition);\n\n // Disconnect MutationObservers\n mutationObservers.forEach((observer) => observer.disconnect());\n\n // Disconnect ResizeObservers\n resizeObservers.forEach((observer) => observer.disconnect());\n\n // Remove hover event listeners\n optionsRefs.current.forEach((option) => {\n option?.removeEventListener('mouseenter', handleMouseEnter);\n option?.removeEventListener('mouseleave', handleMouseLeave);\n });\n };\n }, [optionsRefs, selector, hoveredItem, itemsLength]);\n\n return { choiceIndicatorPosition };\n};\n"],"names":[],"mappings":";;AAUA,MAAM,kBAAkB,CAAC,WACvB,QAAQ,aAAa,eAAe,MAAM;AAErC,MAAM,kBAAkB,CAC7B,aACA,WAA4D,iBAC5D,cAAc,UACX;AACH,QAAM,CAAC,yBAAyB,0BAA0B,IACxD,SAA4B,IAAI;AAElC,QAAM,CAAC,aAAa,cAAc,IAAI,SAA6B,IAAI;AAEjE,QAAA,cAAc,YAAY,QAAQ;AAExC,YAAU,MAAM;AACd,UAAM,oBAAoB,MAAM;AAC9B,UAAI,gBAAoC;AAExC,UAAI,aAAa;AACC,wBAAA;AAAA,MAAA,OACX;AACL,wBAAgB,YAAY,QAAQ,KAAK,QAAQ,KAAK;AAAA,MACxD;AAEA,UAAI,CAAC,eAAe;AAClB,mCAA2B,CAAC,UAAU;AAAA,UACpC,MAAM;AAAA,UACN,OAAO;AAAA,UACP,GAAG;AAAA,UACH,SAAS;AAAA,QACT,EAAA;AACF;AAAA,MACF;AAEA,YAAM,OAAO,cAAc;AAC3B,YAAM,QAAQ,cAAc;AAED,iCAAA;AAAA,QACzB;AAAA,QACA;AAAA,QACA,SAAS;AAAA,MAAA,CACV;AAAA,IAAA;AAGe;AAGX,WAAA,iBAAiB,UAAU,iBAAiB;AAC5C,WAAA,iBAAiB,oBAAoB,iBAAiB;AAG7D,UAAM,oBAAwC,CAAA;AAElC,gBAAA,QAAQ,QAAQ,CAAC,WAAW;AACtC,UAAI,QAAQ;AACV,cAAM,WAAW,IAAI,iBAAiB,CAAC,cAAc;AACnD,qBAAW,YAAY,WAAW;AAChC,gBACE,SAAS,SAAS,gBAClB,SAAS,k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Aa,UAAU,aAAa,WAAW,CAAC;AAEpD,SAAO,EAAE,wBAAwB;AACnC;"}
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
+ const require$$0 = require("react");
5
+ const usePersistedStore = (key, initialValue) => {
6
+ const [state, setState] = require$$0.useState(() => {
7
+ const persistedState = sessionStorage.getItem(key);
8
+ if (persistedState) {
9
+ return JSON.parse(persistedState);
10
+ }
11
+ return initialValue;
12
+ });
13
+ require$$0.useEffect(() => {
14
+ const persistedState = sessionStorage.getItem(key);
15
+ if (persistedState) {
16
+ setState(JSON.parse(persistedState));
17
+ }
18
+ }, [key, initialValue]);
19
+ return [state, setState];
20
+ };
21
+ exports.usePersistedStore = usePersistedStore;
22
+ //# sourceMappingURL=usePersistedStore.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePersistedStore.cjs","sources":["../../src/hooks/usePersistedStore.ts"],"sourcesContent":["'use client';\n\nimport { useState, useEffect } from 'react';\n\nexport const usePersistedStore = <T>(key: string, initialValue?: T) => {\n const [state, setState] = useState<T>(() => {\n const persistedState = sessionStorage.getItem(key);\n\n if (persistedState) {\n return JSON.parse(persistedState);\n }\n\n return initialValue as T;\n });\n\n useEffect(() => {\n const persistedState = sessionStorage.getItem(key);\n\n if (persistedState) {\n setState(JSON.parse(persistedState));\n }\n }, [key, initialValue]);\n\n return [state, setState] as const;\n};\n"],"names":["useState","useEffect"],"mappings":";;;;AAIa,MAAA,oBAAoB,CAAI,KAAa,iBAAqB;AACrE,QAAM,CAAC,OAAO,QAAQ,IAAIA,oBAAY,MAAM;AACpC,UAAA,iBAAiB,eAAe,QAAQ,GAAG;AAEjD,QAAI,gBAAgB;AACX,aAAA,KAAK,MAAM,cAAc;AAAA,IAClC;AAEO,WAAA;AAAA,EAAA,CACR;AAEDC,aAAAA,UAAU,MAAM;AACR,UAAA,iBAAiB,eAAe,QAAQ,GAAG;AAEjD,QAAI,gBAAgB;AACT,eAAA,KAAK,MAAM,cAAc,CAAC;AAAA,IACrC;AAAA,EAAA,GACC,CAAC,KAAK,YAAY,CAAC;AAEf,SAAA,CAAC,OAAO,QAAQ;AACzB;;"}
@@ -0,0 +1,2 @@
1
+ export declare const usePersistedStore: <T>(key: string, initialValue?: T) => readonly [T, import('react').Dispatch<import('react').SetStateAction<T>>];
2
+ //# sourceMappingURL=usePersistedStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePersistedStore.d.ts","sourceRoot":"","sources":["../../src/hooks/usePersistedStore.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB,GAAI,CAAC,OAAO,MAAM,iBAAiB,CAAC,8EAoBjE,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { useState, useEffect } from "react";
3
+ const usePersistedStore = (key, initialValue) => {
4
+ const [state, setState] = useState(() => {
5
+ const persistedState = sessionStorage.getItem(key);
6
+ if (persistedState) {
7
+ return JSON.parse(persistedState);
8
+ }
9
+ return initialValue;
10
+ });
11
+ useEffect(() => {
12
+ const persistedState = sessionStorage.getItem(key);
13
+ if (persistedState) {
14
+ setState(JSON.parse(persistedState));
15
+ }
16
+ }, [key, initialValue]);
17
+ return [state, setState];
18
+ };
19
+ export {
20
+ usePersistedStore
21
+ };
22
+ //# sourceMappingURL=usePersistedStore.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePersistedStore.mjs","sources":["../../src/hooks/usePersistedStore.ts"],"sourcesContent":["'use client';\n\nimport { useState, useEffect } from 'react';\n\nexport const usePersistedStore = <T>(key: string, initialValue?: T) => {\n const [state, setState] = useState<T>(() => {\n const persistedState = sessionStorage.getItem(key);\n\n if (persistedState) {\n return JSON.parse(persistedState);\n }\n\n return initialValue as T;\n });\n\n useEffect(() => {\n const persistedState = sessionStorage.getItem(key);\n\n if (persistedState) {\n setState(JSON.parse(persistedState));\n }\n }, [key, initialValue]);\n\n return [state, setState] as const;\n};\n"],"names":[],"mappings":";;AAIa,MAAA,oBAAoB,CAAI,KAAa,iBAAqB;AACrE,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAY,MAAM;AACpC,UAAA,iBAAiB,eAAe,QAAQ,GAAG;AAEjD,QAAI,gBAAgB;AACX,aAAA,KAAK,MAAM,cAAc;AAAA,IAClC;AAEO,WAAA;AAAA,EAAA,CACR;AAED,YAAU,MAAM;AACR,UAAA,iBAAiB,eAAe,QAAQ,GAAG;AAEjD,QAAI,gBAAgB;AACT,eAAA,KAAK,MAAM,cAAc,CAAC;AAAA,IACrC;AAAA,EAAA,GACC,CAAC,KAAK,YAAY,CAAC;AAEf,SAAA,CAAC,OAAO,QAAQ;AACzB;"}
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
+ const require$$0 = require("react");
5
+ const usePersistenceStore = (key, initialValue) => {
6
+ const [state, setState] = require$$0.useState(() => {
7
+ const persistedState = sessionStorage.getItem(key);
8
+ if (persistedState) {
9
+ return JSON.parse(persistedState);
10
+ }
11
+ return initialValue;
12
+ });
13
+ require$$0.useEffect(() => {
14
+ const persistedState = sessionStorage.getItem(key);
15
+ if (persistedState) {
16
+ setState(JSON.parse(persistedState));
17
+ }
18
+ }, [key, initialValue]);
19
+ return [state, setState];
20
+ };
21
+ exports.usePersistenceStore = usePersistenceStore;
22
+ //# sourceMappingURL=usePersistenceStore.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePersistenceStore.cjs","sources":["../../src/hooks/usePersistenceStore.ts"],"sourcesContent":["'use client';\n\nimport { useState, useEffect } from 'react';\n\nexport const usePersistenceStore = <T>(key: string, initialValue?: T) => {\n const [state, setState] = useState<T>(() => {\n const persistedState = sessionStorage.getItem(key);\n\n if (persistedState) {\n return JSON.parse(persistedState);\n }\n\n return initialValue as T;\n });\n\n useEffect(() => {\n const persistedState = sessionStorage.getItem(key);\n\n if (persistedState) {\n setState(JSON.parse(persistedState));\n }\n }, [key, initialValue]);\n\n return [state, setState] as const;\n};\n"],"names":["useState","useEffect"],"mappings":";;;;AAIa,MAAA,sBAAsB,CAAI,KAAa,iBAAqB;AACvE,QAAM,CAAC,OAAO,QAAQ,IAAIA,oBAAY,MAAM;AACpC,UAAA,iBAAiB,eAAe,QAAQ,GAAG;AAEjD,QAAI,gBAAgB;AACX,aAAA,KAAK,MAAM,cAAc;AAAA,IAClC;AAEO,WAAA;AAAA,EAAA,CACR;AAEDC,aAAAA,UAAU,MAAM;AACR,UAAA,iBAAiB,eAAe,QAAQ,GAAG;AAEjD,QAAI,gBAAgB;AACT,eAAA,KAAK,MAAM,cAAc,CAAC;AAAA,IACrC;AAAA,EAAA,GACC,CAAC,KAAK,YAAY,CAAC;AAEf,SAAA,CAAC,OAAO,QAAQ;AACzB;;"}
@@ -0,0 +1,2 @@
1
+ export declare const usePersistenceStore: <T>(key: string, initialValue?: T) => readonly [T, import('react').Dispatch<import('react').SetStateAction<T>>];
2
+ //# sourceMappingURL=usePersistenceStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePersistenceStore.d.ts","sourceRoot":"","sources":["../../src/hooks/usePersistenceStore.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB,GAAI,CAAC,OAAO,MAAM,iBAAiB,CAAC,8EAoBnE,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { useState, useEffect } from "react";
3
+ const usePersistenceStore = (key, initialValue) => {
4
+ const [state, setState] = useState(() => {
5
+ const persistedState = sessionStorage.getItem(key);
6
+ if (persistedState) {
7
+ return JSON.parse(persistedState);
8
+ }
9
+ return initialValue;
10
+ });
11
+ useEffect(() => {
12
+ const persistedState = sessionStorage.getItem(key);
13
+ if (persistedState) {
14
+ setState(JSON.parse(persistedState));
15
+ }
16
+ }, [key, initialValue]);
17
+ return [state, setState];
18
+ };
19
+ export {
20
+ usePersistenceStore
21
+ };
22
+ //# sourceMappingURL=usePersistenceStore.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePersistenceStore.mjs","sources":["../../src/hooks/usePersistenceStore.ts"],"sourcesContent":["'use client';\n\nimport { useState, useEffect } from 'react';\n\nexport const usePersistenceStore = <T>(key: string, initialValue?: T) => {\n const [state, setState] = useState<T>(() => {\n const persistedState = sessionStorage.getItem(key);\n\n if (persistedState) {\n return JSON.parse(persistedState);\n }\n\n return initialValue as T;\n });\n\n useEffect(() => {\n const persistedState = sessionStorage.getItem(key);\n\n if (persistedState) {\n setState(JSON.parse(persistedState));\n }\n }, [key, initialValue]);\n\n return [state, setState] as const;\n};\n"],"names":[],"mappings":";;AAIa,MAAA,sBAAsB,CAAI,KAAa,iBAAqB;AACvE,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAY,MAAM;AACpC,UAAA,iBAAiB,eAAe,QAAQ,GAAG;AAEjD,QAAI,gBAAgB;AACX,aAAA,KAAK,MAAM,cAAc;AAAA,IAClC;AAEO,WAAA;AAAA,EAAA,CACR;AAED,YAAU,MAAM;AACR,UAAA,iBAAiB,eAAe,QAAQ,GAAG;AAEjD,QAAI,gBAAgB;AACT,eAAA,KAAK,MAAM,cAAc,CAAC;AAAA,IACrC;AAAA,EAAA,GACC,CAAC,KAAK,YAAY,CAAC;AAEf,SAAA,CAAC,OAAO,QAAQ;AACzB;"}
@@ -22,13 +22,14 @@ const getAuthAPI = (authAPIOptions = {}) => {
22
22
  const searchParams = new URLSearchParams(params);
23
23
  return `${AUTH_API_ROUTE}/login/google?${searchParams.toString()}`;
24
24
  };
25
- const register = async (user, otherOptions = {}) => await libs_intlayerApi_fetcher.fetcher(
25
+ const register = async (user, query = {}, otherOptions = {}) => await libs_intlayerApi_fetcher.fetcher(
26
26
  `${AUTH_API_ROUTE}/register`,
27
27
  authAPIOptions,
28
28
  otherOptions,
29
29
  {
30
30
  method: "POST",
31
- body: user
31
+ body: user,
32
+ params: query
32
33
  }
33
34
  );
34
35
  const logout = async (otherOptions = {}) => await libs_intlayerApi_fetcher.fetcher(
@@ -63,6 +64,14 @@ const getAuthAPI = (authAPIOptions = {}) => {
63
64
  body: data
64
65
  }
65
66
  );
67
+ const checkIfUserHasPassword = async (otherOptions = {}) => await libs_intlayerApi_fetcher.fetcher(
68
+ `${AUTH_API_ROUTE}/password/has`,
69
+ authAPIOptions,
70
+ otherOptions,
71
+ {
72
+ method: "GET"
73
+ }
74
+ );
66
75
  const verifyEmail = async ({ userId, secret }, otherOptions = {}) => await libs_intlayerApi_fetcher.fetcher(
67
76
  `${AUTH_API_ROUTE}/active/${userId}/${secret}`,
68
77
  authAPIOptions,
@@ -71,6 +80,7 @@ const getAuthAPI = (authAPIOptions = {}) => {
71
80
  method: "PUT"
72
81
  }
73
82
  );
83
+ const getVerifyEmailStatusURL = (userId) => `${AUTH_API_ROUTE}/verify-email-status/${String(userId)}`;
74
84
  const createSession = async (data, otherOptions = {}) => await libs_intlayerApi_fetcher.fetcher(
75
85
  `${AUTH_API_ROUTE}/session`,
76
86
  authAPIOptions,
@@ -115,7 +125,9 @@ const getAuthAPI = (authAPIOptions = {}) => {
115
125
  logout,
116
126
  resetPassword,
117
127
  askResetPassword,
128
+ checkIfUserHasPassword,
118
129
  verifyEmail,
130
+ getVerifyEmailStatusURL,
119
131
  changePassword,
120
132
  createSession,
121
133
  getSession,
@@ -1 +1 @@
1
- {"version":3,"file":"auth.cjs","sources":["../../../src/libs/intlayer-api/auth.ts"],"sourcesContent":["import type {\n AskResetPasswordBody,\n AskResetPasswordResult,\n CreateSessionBody,\n CreateSessionResult,\n GetSessionInformationQuery,\n GithubLoginQueryParams,\n GoogleLoginQueryParams,\n GetSessionInformationResult,\n LoginBody,\n LoginResult,\n RegisterBody,\n RegisterResult,\n ResetPasswordParams,\n ResetPasswordResult,\n UpdatePasswordBody,\n UpdatePasswordResult,\n ValidEmailParams,\n ValidEmailResult,\n SetCSRFTokenResult,\n GetOAuth2TokenBody,\n GetOAuth2TokenResult,\n} from '@intlayer/backend';\nimport { getConfiguration } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } from './fetcher';\n\nconst { backendURL, clientId, clientSecret } = getConfiguration().editor;\nconst AUTH_API_ROUTE = `${backendURL}/api/auth`;\n\nexport const getAuthAPI = (authAPIOptions: FetcherOptions = {}) => {\n /**\n * Logs in a user with the provided credentials.\n * @param user - User credentials.\n */\n const login = async (user: LoginBody, otherOptions: FetcherOptions = {}) =>\n await fetcher<LoginResult>(\n `${AUTH_API_ROUTE}/login`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: user,\n }\n );\n\n /**\n * Gets the login with GitHub URL.\n * @param params - The parameters for the login with GitHub URL.\n * @returns The login with GitHub URL.\n */\n const getLoginWithGitHubURL = (params: GithubLoginQueryParams): string => {\n const searchParams = new URLSearchParams(params);\n\n return `${AUTH_API_ROUTE}/login/github?${searchParams.toString()}`;\n };\n\n /**\n * Gets the login with Google URL.\n * @param params - The parameters for the login with Google URL.\n * @returns The login with Google URL.\n */\n const getLoginWithGoogleURL = (params: GoogleLoginQueryParams): string => {\n const searchParams = new URLSearchParams(params);\n\n return `${AUTH_API_ROUTE}/login/google?${searchParams.toString()}`;\n };\n\n /**\n * Registers a new user with the provided credentials.\n * @param user - User credentials.\n * @returns User object.\n */\n const register = async (\n user: RegisterBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<RegisterResult>(\n `${AUTH_API_ROUTE}/register`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: user,\n }\n );\n\n /**\n * Signs out the user.\n * @returns User object.\n */\n const logout = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<void>(\n `${AUTH_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Ask to resets the password of a user with the provided email address.\n * @param email - Email address of the user.\n * @returns User object.\n */\n const askResetPassword = async (\n email: AskResetPasswordBody['email'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AskResetPasswordResult>(\n `${AUTH_API_ROUTE}/password/reset`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { email },\n }\n );\n\n /**\n * Resets the password of a user with the provided email address.\n * @param email - Email address of the user.\n * @returns User object.\n */\n const resetPassword = async (\n params: ResetPasswordParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ResetPasswordResult>(\n `${AUTH_API_ROUTE}/password/reset`,\n authAPIOptions,\n otherOptions,\n { params, method: 'POST' }\n );\n\n /**\n * Changes the password of a user with the provided data.\n * @param data - New password and confirmation.\n * @returns User object.\n */\n const changePassword = async (\n data: UpdatePasswordBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdatePasswordResult>(\n `${AUTH_API_ROUTE}/password`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: data,\n }\n );\n\n /**\n * Verifies the email address of a user with the provided token.\n * @param params - User ID and secret key.\n * @returns User object.\n */\n const verifyEmail = async (\n { userId, secret }: ValidEmailParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ValidEmailResult>(\n `${AUTH_API_ROUTE}/active/${userId}/${secret}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Creates a session for a user.\n * @param params - User ID and secret key.\n * @returns User object.\n */\n const createSession = async (\n data: CreateSessionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<CreateSessionResult>(\n `${AUTH_API_ROUTE}/session`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: data,\n }\n );\n\n /**\n * Gets a session and user.\n * @param sessionToken - Session token.\n * @param otherOptions - Fetcher options.\n * @returns Session and user information.\n */\n const getSession = async (\n sessionToken?: GetSessionInformationQuery['session_token'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetSessionInformationResult>(\n `${backendURL}/session`,\n authAPIOptions,\n otherOptions,\n { params: { session_token: sessionToken } }\n );\n\n /**\n * Gets the CSRF token.\n * @param otherOptions - Fetcher options.\n * @returns The CSRF token.\n */\n const getCSRFToken = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<SetCSRFTokenResult>(\n `${backendURL}/csrf-token`,\n authAPIOptions,\n otherOptions\n );\n\n /**\n * Gets an oAuth2 accessToken\n * @return The token information\n */\n const getOAuth2AccessToken = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetOAuth2TokenResult>(\n `${backendURL}/oauth2/token`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n body: {\n grant_type: 'client_credentials',\n client_id: clientId!,\n client_secret: clientSecret!,\n } satisfies GetOAuth2TokenBody,\n }\n );\n\n return {\n login,\n getLoginWithGitHubURL,\n getLoginWithGoogleURL,\n register,\n logout,\n resetPassword,\n askResetPassword,\n verifyEmail,\n changePassword,\n createSession,\n getSession,\n getCSRFToken,\n getOAuth2AccessToken,\n };\n};\n\nexport const authAPI = getAuthAPI();\n"],"names":["getConfiguration","fetcher"],"mappings":";;;;AA0BA,MAAM,EAAE,YAAY,UAAU,aAAa,IAAIA,0BAAmB;AAClE,MAAM,iBAAiB,GAAG,UAAU;AAE7B,MAAM,aAAa,CAAC,iBAAiC,OAAO;AAKjE,QAAM,QAAQ,OAAO,MAAiB,eAA+B,CAAA,MACnE,MAAMC,yBAAA;AAAA,IACJ,GAAG,cAAc;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EAAA;AAQE,QAAA,wBAAwB,CAAC,WAA2C;AAClE,UAAA,eAAe,IAAI,gBAAgB,MAAM;AAE/C,WAAO,GAAG,cAAc,iBAAiB,aAAa,SAAU,CAAA;AAAA,EAAA;AAQ5D,QAAA,wBAAwB,CAAC,WAA2C;AAClE,UAAA,eAAe,IAAI,gBAAgB,MAAM;AAE/C,WAAO,GAAG,cAAc,iBAAiB,aAAa,SAAU,CAAA;AAAA,EAAA;AAQlE,QAAM,WAAW,OACf,MAC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EAAA;AASJ,QAAM,aAAa,OACjB,cACA,eAA+B,CAAA,MAE/B,MAAMA,yBAAA;AAAA,IACJ,GAAG,UAAU;AAAA,IACb;AAAA,IACA;AAAA,IACA,EAAE,QAAQ,EAAE,eAAe,eAAe;AAAA,EAAA;AAQ9C,QAAM,eAAe,OAAO,eAA+B,CAAA,MACzD,MAAMA,yBAAA;AAAA,IACJ,GAAG,UAAU;AAAA,IACb;AAAA,IACA;AAAA,EAAA;AAOJ,QAAM,uBAAuB,OAAO,eAA+B,CAAA,MACjE,MAAMA,yBAAA;AAAA,IACJ,GAAG,UAAU;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM;AAAA,QACJ,YAAY;AAAA,QACZ,WAAW;AAAA,QACX,eAAe;AAAA,MACjB;AAAA,IACF;AAAA,EAAA;AAGG,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;AAEO,MAAM,UAAU,WAAW;;;"}
1
+ {"version":3,"file":"auth.cjs","sources":["../../../src/libs/intlayer-api/auth.ts"],"sourcesContent":["import type {\n AskResetPasswordBody,\n AskResetPasswordResult,\n CreateSessionBody,\n CreateSessionResult,\n GetSessionInformationQuery,\n GithubLoginQueryParams,\n GoogleLoginQueryParams,\n GetSessionInformationResult,\n LoginBody,\n LoginResult,\n RegisterBody,\n RegisterQuery,\n RegisterResult,\n ResetPasswordParams,\n ResetPasswordResult,\n UpdatePasswordBody,\n UpdatePasswordResult,\n ValidEmailParams,\n ValidEmailResult,\n SetCSRFTokenResult,\n GetOAuth2TokenBody,\n GetOAuth2TokenResult,\n UserAPI,\n CheckIfUserHasPasswordResult,\n} from '@intlayer/backend';\nimport { getConfiguration } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } from './fetcher';\n\nconst { backendURL, clientId, clientSecret } = getConfiguration().editor;\nconst AUTH_API_ROUTE = `${backendURL}/api/auth`;\n\nexport const getAuthAPI = (authAPIOptions: FetcherOptions = {}) => {\n /**\n * Logs in a user with the provided credentials.\n * @param user - User credentials.\n */\n const login = async (user: LoginBody, otherOptions: FetcherOptions = {}) =>\n await fetcher<LoginResult>(\n `${AUTH_API_ROUTE}/login`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: user,\n }\n );\n\n /**\n * Gets the login with GitHub URL.\n * @param params - The parameters for the login with GitHub URL.\n * @returns The login with GitHub URL.\n */\n const getLoginWithGitHubURL = (params: GithubLoginQueryParams): string => {\n const searchParams = new URLSearchParams(params);\n\n return `${AUTH_API_ROUTE}/login/github?${searchParams.toString()}`;\n };\n\n /**\n * Gets the login with Google URL.\n * @param params - The parameters for the login with Google URL.\n * @returns The login with Google URL.\n */\n const getLoginWithGoogleURL = (params: GoogleLoginQueryParams): string => {\n const searchParams = new URLSearchParams(params);\n\n return `${AUTH_API_ROUTE}/login/google?${searchParams.toString()}`;\n };\n\n /**\n * Registers a new user with the provided credentials.\n * @param user - User credentials.\n * @returns User object.\n */\n const register = async (\n user: RegisterBody,\n query: RegisterQuery = {},\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<RegisterResult>(\n `${AUTH_API_ROUTE}/register`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: user,\n params: query,\n }\n );\n\n /**\n * Signs out the user.\n * @returns User object.\n */\n const logout = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<void>(\n `${AUTH_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Ask to resets the password of a user with the provided email address.\n * @param email - Email address of the user.\n * @returns User object.\n */\n const askResetPassword = async (\n email: AskResetPasswordBody['email'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AskResetPasswordResult>(\n `${AUTH_API_ROUTE}/password/reset`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { email },\n }\n );\n\n /**\n * Resets the password of a user with the provided email address.\n * @param email - Email address of the user.\n * @returns User object.\n */\n const resetPassword = async (\n params: ResetPasswordParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ResetPasswordResult>(\n `${AUTH_API_ROUTE}/password/reset`,\n authAPIOptions,\n otherOptions,\n { params, method: 'POST' }\n );\n\n /**\n * Changes the password of a user with the provided data.\n * @param data - New password and confirmation.\n * @returns User object.\n */\n const changePassword = async (\n data: UpdatePasswordBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdatePasswordResult>(\n `${AUTH_API_ROUTE}/password`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: data,\n }\n );\n\n /**\n * Checks if a user has a password.\n * @param params - User ID.\n * @returns User object.\n */\n const checkIfUserHasPassword = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<CheckIfUserHasPasswordResult>(\n `${AUTH_API_ROUTE}/password/has`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n }\n );\n\n /**\n * Verifies the email address of a user with the provided token.\n * @param params - User ID and secret key.\n * @returns User object.\n */\n const verifyEmail = async (\n { userId, secret }: ValidEmailParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ValidEmailResult>(\n `${AUTH_API_ROUTE}/active/${userId}/${secret}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Gets the verify email status URL to use in the SSE.\n * @param userId - User ID.\n * @returns The verify email status URL.\n */\n const getVerifyEmailStatusURL = (userId: string | UserAPI['_id']) =>\n `${AUTH_API_ROUTE}/verify-email-status/${String(userId)}`;\n\n /**\n * Creates a session for a user.\n * @param params - User ID and secret key.\n * @returns User object.\n */\n const createSession = async (\n data: CreateSessionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<CreateSessionResult>(\n `${AUTH_API_ROUTE}/session`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: data,\n }\n );\n\n /**\n * Gets a session and user.\n * @param sessionToken - Session token.\n * @param otherOptions - Fetcher options.\n * @returns Session and user information.\n */\n const getSession = async (\n sessionToken?: GetSessionInformationQuery['session_token'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetSessionInformationResult>(\n `${backendURL}/session`,\n authAPIOptions,\n otherOptions,\n { params: { session_token: sessionToken } }\n );\n\n /**\n * Gets the CSRF token.\n * @param otherOptions - Fetcher options.\n * @returns The CSRF token.\n */\n const getCSRFToken = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<SetCSRFTokenResult>(\n `${backendURL}/csrf-token`,\n authAPIOptions,\n otherOptions\n );\n\n /**\n * Gets an oAuth2 accessToken\n * @return The token information\n */\n const getOAuth2AccessToken = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetOAuth2TokenResult>(\n `${backendURL}/oauth2/token`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n body: {\n grant_type: 'client_credentials',\n client_id: clientId!,\n client_secret: clientSecret!,\n } satisfies GetOAuth2TokenBody,\n }\n );\n\n return {\n login,\n getLoginWithGitHubURL,\n getLoginWithGoogleURL,\n register,\n logout,\n resetPassword,\n askResetPassword,\n checkIfUserHasPassword,\n verifyEmail,\n getVerifyEmailStatusURL,\n changePassword,\n createSession,\n getSession,\n getCSRFToken,\n getOAuth2AccessToken,\n };\n};\n\nexport const authAPI = getAuthAPI();\n"],"names":["getConfiguration","fetcher"],"mappings":";;;;AA6BA,MAAM,EAAE,YAAY,UAAU,aAAa,IAAIA,0BAAmB;AAClE,MAAM,iBAAiB,GAAG,UAAU;AAE7B,MAAM,aAAa,CAAC,iBAAiC,OAAO;AAKjE,QAAM,QAAQ,OAAO,MAAiB,eAA+B,CAAA,MACnE,MAAMC,yBAAA;AAAA,IACJ,GAAG,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;AAAA,EAAA;AAGG,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;AAEO,MAAM,UAAU,WAAW;;;"}
@@ -1,14 +1,16 @@
1
- import { AskResetPasswordBody, AskResetPasswordResult, CreateSessionBody, CreateSessionResult, GetSessionInformationQuery, GithubLoginQueryParams, GoogleLoginQueryParams, GetSessionInformationResult, LoginBody, LoginResult, RegisterBody, RegisterResult, ResetPasswordParams, ResetPasswordResult, UpdatePasswordBody, UpdatePasswordResult, ValidEmailParams, ValidEmailResult, SetCSRFTokenResult, GetOAuth2TokenResult } from '@intlayer/backend';
1
+ import { AskResetPasswordBody, AskResetPasswordResult, CreateSessionBody, CreateSessionResult, GetSessionInformationQuery, GithubLoginQueryParams, GoogleLoginQueryParams, GetSessionInformationResult, LoginBody, LoginResult, RegisterBody, RegisterQuery, RegisterResult, ResetPasswordParams, ResetPasswordResult, UpdatePasswordBody, UpdatePasswordResult, ValidEmailParams, ValidEmailResult, SetCSRFTokenResult, GetOAuth2TokenResult, UserAPI, CheckIfUserHasPasswordResult } from '@intlayer/backend';
2
2
  import { FetcherOptions } from './fetcher';
3
3
  export declare const getAuthAPI: (authAPIOptions?: FetcherOptions) => {
4
4
  login: (user: LoginBody, otherOptions?: FetcherOptions) => Promise<LoginResult>;
5
5
  getLoginWithGitHubURL: (params: GithubLoginQueryParams) => string;
6
6
  getLoginWithGoogleURL: (params: GoogleLoginQueryParams) => string;
7
- register: (user: RegisterBody, otherOptions?: FetcherOptions) => Promise<RegisterResult>;
7
+ register: (user: RegisterBody, query?: RegisterQuery, otherOptions?: FetcherOptions) => Promise<RegisterResult>;
8
8
  logout: (otherOptions?: FetcherOptions) => Promise<void>;
9
9
  resetPassword: (params: ResetPasswordParams, otherOptions?: FetcherOptions) => Promise<ResetPasswordResult>;
10
10
  askResetPassword: (email: AskResetPasswordBody["email"], otherOptions?: FetcherOptions) => Promise<AskResetPasswordResult>;
11
+ checkIfUserHasPassword: (otherOptions?: FetcherOptions) => Promise<CheckIfUserHasPasswordResult>;
11
12
  verifyEmail: ({ userId, secret }: ValidEmailParams, otherOptions?: FetcherOptions) => Promise<ValidEmailResult>;
13
+ getVerifyEmailStatusURL: (userId: string | UserAPI["_id"]) => string;
12
14
  changePassword: (data: UpdatePasswordBody, otherOptions?: FetcherOptions) => Promise<UpdatePasswordResult>;
13
15
  createSession: (data: CreateSessionBody, otherOptions?: FetcherOptions) => Promise<CreateSessionResult>;
14
16
  getSession: (sessionToken?: GetSessionInformationQuery["session_token"], otherOptions?: FetcherOptions) => Promise<GetSessionInformationResult>;
@@ -19,11 +21,13 @@ export declare const authAPI: {
19
21
  login: (user: LoginBody, otherOptions?: FetcherOptions) => Promise<LoginResult>;
20
22
  getLoginWithGitHubURL: (params: GithubLoginQueryParams) => string;
21
23
  getLoginWithGoogleURL: (params: GoogleLoginQueryParams) => string;
22
- register: (user: RegisterBody, otherOptions?: FetcherOptions) => Promise<RegisterResult>;
24
+ register: (user: RegisterBody, query?: RegisterQuery, otherOptions?: FetcherOptions) => Promise<RegisterResult>;
23
25
  logout: (otherOptions?: FetcherOptions) => Promise<void>;
24
26
  resetPassword: (params: ResetPasswordParams, otherOptions?: FetcherOptions) => Promise<ResetPasswordResult>;
25
27
  askResetPassword: (email: AskResetPasswordBody["email"], otherOptions?: FetcherOptions) => Promise<AskResetPasswordResult>;
28
+ checkIfUserHasPassword: (otherOptions?: FetcherOptions) => Promise<CheckIfUserHasPasswordResult>;
26
29
  verifyEmail: ({ userId, secret }: ValidEmailParams, otherOptions?: FetcherOptions) => Promise<ValidEmailResult>;
30
+ getVerifyEmailStatusURL: (userId: string | UserAPI["_id"]) => string;
27
31
  changePassword: (data: UpdatePasswordBody, otherOptions?: FetcherOptions) => Promise<UpdatePasswordResult>;
28
32
  createSession: (data: CreateSessionBody, otherOptions?: FetcherOptions) => Promise<CreateSessionResult>;
29
33
  getSession: (sessionToken?: GetSessionInformationQuery["session_token"], otherOptions?: FetcherOptions) => Promise<GetSessionInformationResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/libs/intlayer-api/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,sBAAsB,EACtB,sBAAsB,EACtB,2BAA2B,EAC3B,SAAS,EACT,WAAW,EACX,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAElB,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAKzD,eAAO,MAAM,UAAU,oBAAoB,cAAc;kBAK5B,SAAS,iBAAgB,cAAc;oCAgB3B,sBAAsB,KAAG,MAAM;oCAW/B,sBAAsB,KAAG,MAAM;qBAY9D,YAAY,iBACJ,cAAc;4BAgBM,cAAc;4BAmCxC,mBAAmB,iBACb,cAAc;8BApBrB,oBAAoB,CAAC,OAAO,CAAC,iBACtB,cAAc;sCAqDR,gBAAgB,iBACtB,cAAc;2BApBtB,kBAAkB,iBACV,cAAc;0BAoCtB,iBAAiB,iBACT,cAAc;gCAmBb,0BAA0B,CAAC,eAAe,CAAC,iBAC5C,cAAc;kCAcY,cAAc;0CAWN,cAAc;CAiCjE,CAAC;AAEF,eAAO,MAAM,OAAO;kBAjOS,SAAS,iBAAgB,cAAc;oCAgB3B,sBAAsB,KAAG,MAAM;oCAW/B,sBAAsB,KAAG,MAAM;qBAY9D,YAAY,iBACJ,cAAc;4BAgBM,cAAc;4BAmCxC,mBAAmB,iBACb,cAAc;8BApB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MAAM,OAAO;kBA5PS,SAAS,iBAAgB,cAAc;oCAgB3B,sBAAsB,KAAG,MAAM;oCAW/B,sBAAsB,KAAG,MAAM;qBAY9D,YAAY,UACX,aAAa,iBACN,cAAc;4BAiBM,cAAc;4BAmCxC,mBAAmB,iBACb,cAAc;8BApBrB,oBAAoB,CAAC,OAAO,CAAC,iBACtB,cAAc;4CAoDsB,cAAc;sCAgB5C,gBAAgB,iBACtB,cAAc;sCAgBW,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;2BAnDxD,kBAAkB,iBACV,cAAc;0BA2DtB,iBAAiB,iBACT,cAAc;gCAmBb,0BAA0B,CAAC,eAAe,CAAC,iBAC5C,cAAc;kCAcY,cAAc;0CAWN,cAAc;CAqC/B,CAAC"}
@@ -20,13 +20,14 @@ const getAuthAPI = (authAPIOptions = {}) => {
20
20
  const searchParams = new URLSearchParams(params);
21
21
  return `${AUTH_API_ROUTE}/login/google?${searchParams.toString()}`;
22
22
  };
23
- const register = async (user, otherOptions = {}) => await fetcher(
23
+ const register = async (user, query = {}, otherOptions = {}) => await fetcher(
24
24
  `${AUTH_API_ROUTE}/register`,
25
25
  authAPIOptions,
26
26
  otherOptions,
27
27
  {
28
28
  method: "POST",
29
- body: user
29
+ body: user,
30
+ params: query
30
31
  }
31
32
  );
32
33
  const logout = async (otherOptions = {}) => await fetcher(
@@ -61,6 +62,14 @@ const getAuthAPI = (authAPIOptions = {}) => {
61
62
  body: data
62
63
  }
63
64
  );
65
+ const checkIfUserHasPassword = async (otherOptions = {}) => await fetcher(
66
+ `${AUTH_API_ROUTE}/password/has`,
67
+ authAPIOptions,
68
+ otherOptions,
69
+ {
70
+ method: "GET"
71
+ }
72
+ );
64
73
  const verifyEmail = async ({ userId, secret }, otherOptions = {}) => await fetcher(
65
74
  `${AUTH_API_ROUTE}/active/${userId}/${secret}`,
66
75
  authAPIOptions,
@@ -69,6 +78,7 @@ const getAuthAPI = (authAPIOptions = {}) => {
69
78
  method: "PUT"
70
79
  }
71
80
  );
81
+ const getVerifyEmailStatusURL = (userId) => `${AUTH_API_ROUTE}/verify-email-status/${String(userId)}`;
72
82
  const createSession = async (data, otherOptions = {}) => await fetcher(
73
83
  `${AUTH_API_ROUTE}/session`,
74
84
  authAPIOptions,
@@ -113,7 +123,9 @@ const getAuthAPI = (authAPIOptions = {}) => {
113
123
  logout,
114
124
  resetPassword,
115
125
  askResetPassword,
126
+ checkIfUserHasPassword,
116
127
  verifyEmail,
128
+ getVerifyEmailStatusURL,
117
129
  changePassword,
118
130
  createSession,
119
131
  getSession,
@@ -1 +1 @@
1
- {"version":3,"file":"auth.mjs","sources":["../../../src/libs/intlayer-api/auth.ts"],"sourcesContent":["import type {\n AskResetPasswordBody,\n AskResetPasswordResult,\n CreateSessionBody,\n CreateSessionResult,\n GetSessionInformationQuery,\n GithubLoginQueryParams,\n GoogleLoginQueryParams,\n GetSessionInformationResult,\n LoginBody,\n LoginResult,\n RegisterBody,\n RegisterResult,\n ResetPasswordParams,\n ResetPasswordResult,\n UpdatePasswordBody,\n UpdatePasswordResult,\n ValidEmailParams,\n ValidEmailResult,\n SetCSRFTokenResult,\n GetOAuth2TokenBody,\n GetOAuth2TokenResult,\n} from '@intlayer/backend';\nimport { getConfiguration } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } from './fetcher';\n\nconst { backendURL, clientId, clientSecret } = getConfiguration().editor;\nconst AUTH_API_ROUTE = `${backendURL}/api/auth`;\n\nexport const getAuthAPI = (authAPIOptions: FetcherOptions = {}) => {\n /**\n * Logs in a user with the provided credentials.\n * @param user - User credentials.\n */\n const login = async (user: LoginBody, otherOptions: FetcherOptions = {}) =>\n await fetcher<LoginResult>(\n `${AUTH_API_ROUTE}/login`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: user,\n }\n );\n\n /**\n * Gets the login with GitHub URL.\n * @param params - The parameters for the login with GitHub URL.\n * @returns The login with GitHub URL.\n */\n const getLoginWithGitHubURL = (params: GithubLoginQueryParams): string => {\n const searchParams = new URLSearchParams(params);\n\n return `${AUTH_API_ROUTE}/login/github?${searchParams.toString()}`;\n };\n\n /**\n * Gets the login with Google URL.\n * @param params - The parameters for the login with Google URL.\n * @returns The login with Google URL.\n */\n const getLoginWithGoogleURL = (params: GoogleLoginQueryParams): string => {\n const searchParams = new URLSearchParams(params);\n\n return `${AUTH_API_ROUTE}/login/google?${searchParams.toString()}`;\n };\n\n /**\n * Registers a new user with the provided credentials.\n * @param user - User credentials.\n * @returns User object.\n */\n const register = async (\n user: RegisterBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<RegisterResult>(\n `${AUTH_API_ROUTE}/register`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: user,\n }\n );\n\n /**\n * Signs out the user.\n * @returns User object.\n */\n const logout = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<void>(\n `${AUTH_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Ask to resets the password of a user with the provided email address.\n * @param email - Email address of the user.\n * @returns User object.\n */\n const askResetPassword = async (\n email: AskResetPasswordBody['email'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AskResetPasswordResult>(\n `${AUTH_API_ROUTE}/password/reset`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { email },\n }\n );\n\n /**\n * Resets the password of a user with the provided email address.\n * @param email - Email address of the user.\n * @returns User object.\n */\n const resetPassword = async (\n params: ResetPasswordParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ResetPasswordResult>(\n `${AUTH_API_ROUTE}/password/reset`,\n authAPIOptions,\n otherOptions,\n { params, method: 'POST' }\n );\n\n /**\n * Changes the password of a user with the provided data.\n * @param data - New password and confirmation.\n * @returns User object.\n */\n const changePassword = async (\n data: UpdatePasswordBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdatePasswordResult>(\n `${AUTH_API_ROUTE}/password`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: data,\n }\n );\n\n /**\n * Verifies the email address of a user with the provided token.\n * @param params - User ID and secret key.\n * @returns User object.\n */\n const verifyEmail = async (\n { userId, secret }: ValidEmailParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ValidEmailResult>(\n `${AUTH_API_ROUTE}/active/${userId}/${secret}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Creates a session for a user.\n * @param params - User ID and secret key.\n * @returns User object.\n */\n const createSession = async (\n data: CreateSessionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<CreateSessionResult>(\n `${AUTH_API_ROUTE}/session`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: data,\n }\n );\n\n /**\n * Gets a session and user.\n * @param sessionToken - Session token.\n * @param otherOptions - Fetcher options.\n * @returns Session and user information.\n */\n const getSession = async (\n sessionToken?: GetSessionInformationQuery['session_token'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetSessionInformationResult>(\n `${backendURL}/session`,\n authAPIOptions,\n otherOptions,\n { params: { session_token: sessionToken } }\n );\n\n /**\n * Gets the CSRF token.\n * @param otherOptions - Fetcher options.\n * @returns The CSRF token.\n */\n const getCSRFToken = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<SetCSRFTokenResult>(\n `${backendURL}/csrf-token`,\n authAPIOptions,\n otherOptions\n );\n\n /**\n * Gets an oAuth2 accessToken\n * @return The token information\n */\n const getOAuth2AccessToken = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetOAuth2TokenResult>(\n `${backendURL}/oauth2/token`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n body: {\n grant_type: 'client_credentials',\n client_id: clientId!,\n client_secret: clientSecret!,\n } satisfies GetOAuth2TokenBody,\n }\n );\n\n return {\n login,\n getLoginWithGitHubURL,\n getLoginWithGoogleURL,\n register,\n logout,\n resetPassword,\n askResetPassword,\n verifyEmail,\n changePassword,\n createSession,\n getSession,\n getCSRFToken,\n getOAuth2AccessToken,\n };\n};\n\nexport const authAPI = getAuthAPI();\n"],"names":[],"mappings":";;AA0BA,MAAM,EAAE,YAAY,UAAU,aAAa,IAAI,mBAAmB;AAClE,MAAM,iBAAiB,GAAG,UAAU;AAE7B,MAAM,aAAa,CAAC,iBAAiC,OAAO;AAKjE,QAAM,QAAQ,OAAO,MAAiB,eAA+B,CAAA,MACnE,MAAM;AAAA,IACJ,GAAG,cAAc;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EAAA;AAQE,QAAA,wBAAwB,CAAC,WAA2C;AAClE,UAAA,eAAe,IAAI,gBAAgB,MAAM;AAE/C,WAAO,GAAG,cAAc,iBAAiB,aAAa,SAAU,CAAA;AAAA,EAAA;AAQ5D,QAAA,wBAAwB,CAAC,WAA2C;AAClE,UAAA,eAAe,IAAI,gBAAgB,MAAM;AAE/C,WAAO,GAAG,cAAc,iBAAiB,aAAa,SAAU,CAAA;AAAA,EAAA;AAQlE,QAAM,WAAW,OACf,MACA,eAA+B,CAAA,MAE/B,MAAM;AAAA,IACJ,GAAG,cAAc;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EAAA;AAOJ,QAAM,SAAS,OAAO,eAA+B,CAAA,MACnD,MAAM;AAAA,IACJ,GAAG,cAAc;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EAAA;AAQJ,QAAM,mBAAmB,OACvB,OACA,eAA+B,CAAA,MAE/B,MAAM;AAAA,IACJ,GAAG,cAAc;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM,EAAE,MAAM;AAAA,IAChB;AAAA,EAAA;AAQJ,QAA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AAGG,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;AAEO,MAAM,UAAU,WAAW;"}
1
+ {"version":3,"file":"auth.mjs","sources":["../../../src/libs/intlayer-api/auth.ts"],"sourcesContent":["import type {\n AskResetPasswordBody,\n AskResetPasswordResult,\n CreateSessionBody,\n CreateSessionResult,\n GetSessionInformationQuery,\n GithubLoginQueryParams,\n GoogleLoginQueryParams,\n GetSessionInformationResult,\n LoginBody,\n LoginResult,\n RegisterBody,\n RegisterQuery,\n RegisterResult,\n ResetPasswordParams,\n ResetPasswordResult,\n UpdatePasswordBody,\n UpdatePasswordResult,\n ValidEmailParams,\n ValidEmailResult,\n SetCSRFTokenResult,\n GetOAuth2TokenBody,\n GetOAuth2TokenResult,\n UserAPI,\n CheckIfUserHasPasswordResult,\n} from '@intlayer/backend';\nimport { getConfiguration } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } from './fetcher';\n\nconst { backendURL, clientId, clientSecret } = getConfiguration().editor;\nconst AUTH_API_ROUTE = `${backendURL}/api/auth`;\n\nexport const getAuthAPI = (authAPIOptions: FetcherOptions = {}) => {\n /**\n * Logs in a user with the provided credentials.\n * @param user - User credentials.\n */\n const login = async (user: LoginBody, otherOptions: FetcherOptions = {}) =>\n await fetcher<LoginResult>(\n `${AUTH_API_ROUTE}/login`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: user,\n }\n );\n\n /**\n * Gets the login with GitHub URL.\n * @param params - The parameters for the login with GitHub URL.\n * @returns The login with GitHub URL.\n */\n const getLoginWithGitHubURL = (params: GithubLoginQueryParams): string => {\n const searchParams = new URLSearchParams(params);\n\n return `${AUTH_API_ROUTE}/login/github?${searchParams.toString()}`;\n };\n\n /**\n * Gets the login with Google URL.\n * @param params - The parameters for the login with Google URL.\n * @returns The login with Google URL.\n */\n const getLoginWithGoogleURL = (params: GoogleLoginQueryParams): string => {\n const searchParams = new URLSearchParams(params);\n\n return `${AUTH_API_ROUTE}/login/google?${searchParams.toString()}`;\n };\n\n /**\n * Registers a new user with the provided credentials.\n * @param user - User credentials.\n * @returns User object.\n */\n const register = async (\n user: RegisterBody,\n query: RegisterQuery = {},\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<RegisterResult>(\n `${AUTH_API_ROUTE}/register`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: user,\n params: query,\n }\n );\n\n /**\n * Signs out the user.\n * @returns User object.\n */\n const logout = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<void>(\n `${AUTH_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Ask to resets the password of a user with the provided email address.\n * @param email - Email address of the user.\n * @returns User object.\n */\n const askResetPassword = async (\n email: AskResetPasswordBody['email'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AskResetPasswordResult>(\n `${AUTH_API_ROUTE}/password/reset`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: { email },\n }\n );\n\n /**\n * Resets the password of a user with the provided email address.\n * @param email - Email address of the user.\n * @returns User object.\n */\n const resetPassword = async (\n params: ResetPasswordParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ResetPasswordResult>(\n `${AUTH_API_ROUTE}/password/reset`,\n authAPIOptions,\n otherOptions,\n { params, method: 'POST' }\n );\n\n /**\n * Changes the password of a user with the provided data.\n * @param data - New password and confirmation.\n * @returns User object.\n */\n const changePassword = async (\n data: UpdatePasswordBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdatePasswordResult>(\n `${AUTH_API_ROUTE}/password`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: data,\n }\n );\n\n /**\n * Checks if a user has a password.\n * @param params - User ID.\n * @returns User object.\n */\n const checkIfUserHasPassword = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<CheckIfUserHasPasswordResult>(\n `${AUTH_API_ROUTE}/password/has`,\n authAPIOptions,\n otherOptions,\n {\n method: 'GET',\n }\n );\n\n /**\n * Verifies the email address of a user with the provided token.\n * @param params - User ID and secret key.\n * @returns User object.\n */\n const verifyEmail = async (\n { userId, secret }: ValidEmailParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<ValidEmailResult>(\n `${AUTH_API_ROUTE}/active/${userId}/${secret}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Gets the verify email status URL to use in the SSE.\n * @param userId - User ID.\n * @returns The verify email status URL.\n */\n const getVerifyEmailStatusURL = (userId: string | UserAPI['_id']) =>\n `${AUTH_API_ROUTE}/verify-email-status/${String(userId)}`;\n\n /**\n * Creates a session for a user.\n * @param params - User ID and secret key.\n * @returns User object.\n */\n const createSession = async (\n data: CreateSessionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<CreateSessionResult>(\n `${AUTH_API_ROUTE}/session`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: data,\n }\n );\n\n /**\n * Gets a session and user.\n * @param sessionToken - Session token.\n * @param otherOptions - Fetcher options.\n * @returns Session and user information.\n */\n const getSession = async (\n sessionToken?: GetSessionInformationQuery['session_token'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetSessionInformationResult>(\n `${backendURL}/session`,\n authAPIOptions,\n otherOptions,\n { params: { session_token: sessionToken } }\n );\n\n /**\n * Gets the CSRF token.\n * @param otherOptions - Fetcher options.\n * @returns The CSRF token.\n */\n const getCSRFToken = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<SetCSRFTokenResult>(\n `${backendURL}/csrf-token`,\n authAPIOptions,\n otherOptions\n );\n\n /**\n * Gets an oAuth2 accessToken\n * @return The token information\n */\n const getOAuth2AccessToken = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetOAuth2TokenResult>(\n `${backendURL}/oauth2/token`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n body: {\n grant_type: 'client_credentials',\n client_id: clientId!,\n client_secret: clientSecret!,\n } satisfies GetOAuth2TokenBody,\n }\n );\n\n return {\n login,\n getLoginWithGitHubURL,\n getLoginWithGoogleURL,\n register,\n logout,\n resetPassword,\n askResetPassword,\n checkIfUserHasPassword,\n verifyEmail,\n getVerifyEmailStatusURL,\n changePassword,\n createSession,\n getSession,\n getCSRFToken,\n getOAuth2AccessToken,\n };\n};\n\nexport const authAPI = getAuthAPI();\n"],"names":[],"mappings":";;AA6BA,MAAM,EAAE,YAAY,UAAU,aAAa,IAAI,mBAAmB;AAClE,MAAM,iBAAiB,GAAG,UAAU;AAE7B,MAAM,aAAa,CAAC,iBAAiC,OAAO;AAKjE,QAAM,QAAQ,OAAO,MAAiB,eAA+B,CAAA,MACnE,MAAM;AAAA,IACJ,GAAG,cAAc;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EAAA;AAQE,QAAA,wBAAwB,CAAC,WAA2C;AAClE,UAAA,eAAe,IAAI,gBAAgB,MAAM;AAE/C,WAAO,GAAG,cAAc,iBAAiB,aAAa,SAAU,CAAA;AAAA,EAAA;AAQ5D,QAAA,wBAAwB,CAAC,WAA2C;AAClE,UAAA,eAAe,IAAI,gBAAgB,MAAM;AAE/C,WAAO,GAAG,cAAc,iBAAiB,aAAa,SAAU,CAAA;AAAA,EAAA;AAQ5D,QAAA,WAAW,OACf,MACA,QAAuB,CAAA,GACvB,eAA+B,CAAC,MAEhC,MAAM;AAAA,IACJ,GAAG,cAAc;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,QAAQ;AAAA,IACV;AAAA,EAAA;AAOJ,QAAM,SAAS,OAAO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A;AASJ,QAAM,aAAa,OACjB,cACA,eAA+B,CAAA,MAE/B,MAAM;AAAA,IACJ,GAAG,UAAU;AAAA,IACb;AAAA,IACA;AAAA,IACA,EAAE,QAAQ,EAAE,eAAe,eAAe;AAAA,EAAA;AAQ9C,QAAM,eAAe,OAAO,eAA+B,CAAA,MACzD,MAAM;AAAA,IACJ,GAAG,UAAU;AAAA,IACb;AAAA,IACA;AAAA,EAAA;AAOJ,QAAM,uBAAuB,OAAO,eAA+B,CAAA,MACjE,MAAM;AAAA,IACJ,GAAG,UAAU;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM;AAAA,QACJ,YAAY;AAAA,QACZ,WAAW;AAAA,QACX,eAAe;AAAA,MACjB;AAAA,IACF;AAAA,EAAA;AAGG,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;AAEO,MAAM,UAAU,WAAW;"}
@@ -60,7 +60,13 @@ const fetcher = async (url, ...options) => {
60
60
  body: bodyString
61
61
  };
62
62
  const urlResult = `${url}${paramsString}`;
63
- return (await fetch(urlResult, formattedOptions)).json();
63
+ const response = await fetch(urlResult, formattedOptions);
64
+ if (!response.ok) {
65
+ const result = await response.json();
66
+ console.error(result);
67
+ throw new Error(JSON.stringify(result.error) ?? "An error occurred");
68
+ }
69
+ return await response.json();
64
70
  };
65
71
  exports.fetcher = fetcher;
66
72
  exports.fetcherOptions = fetcherOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"fetcher.cjs","sources":["../../../src/libs/intlayer-api/fetcher.ts"],"sourcesContent":["/**\n * Type definition for options used in the fetcher function.\n * Extends the standard RequestInit interface (excluding 'body'),\n * and adds 'body' and 'params' properties for convenience.\n */\nexport type FetcherOptions = Omit<RequestInit, 'body'> & {\n /**\n * Body of the request. Should be a key-value pair object.\n */\n body?: Record<string, unknown>;\n /**\n * Query parameters to be appended to the URL.\n */\n params?:\n | Record<string, string | string[] | undefined>\n | string[]\n | URLSearchParams;\n};\n\n/**\n * Default options for the fetcher function.\n * Sets the default method to 'GET', the 'Content-Type' header to 'application/json',\n * and includes credentials in the request.\n */\nexport const fetcherOptions: FetcherOptions = {\n method: 'GET', // Default HTTP method\n headers: {\n 'Content-Type': 'application/json', // Default content type\n },\n credentials: 'include', // Include cookies in the request\n};\n\n/**\n * Utility function to remove properties with undefined values from an object.\n * This helps prevent sending undefined values in the request options.\n *\n * @param obj - The object to clean.\n * @returns The cleaned object without undefined values.\n */\nconst removeUndefined = (obj: object) => {\n Object.keys(obj).forEach((key) => {\n if (obj[key as keyof typeof obj] === undefined) {\n delete obj[key as keyof typeof obj];\n }\n });\n return obj;\n};\n\n/**\n * Deeply merges an array of objects into a single object.\n * Later objects in the array overwrite properties of earlier ones.\n *\n * @template T - The type of objects being merged.\n * @param objects - An array of objects to merge.\n * @returns The merged object.\n */\nconst deepMerge = <T extends object>(objects: (T | undefined)[]): T =>\n objects.reduce((acc, obj) => {\n const acc1: T = (acc ?? {}) as T;\n const obj1: T = removeUndefined(obj ?? {}) as T;\n\n if (typeof acc1 === 'object' && typeof obj1 === 'object') {\n // Merge the two objects\n return { ...acc1, ...obj1 };\n }\n\n // If one of them is not an object, return the defined one\n return obj1 ?? acc1;\n }, {} as T)!;\n\n/**\n * Fetcher function to make HTTP requests.\n * It merges default options with user-provided options,\n * handles query parameters and request body,\n * and returns the parsed JSON response.\n *\n * @template T - The expected type of the response data.\n * @param url - The endpoint URL.\n * @param options - Additional options to customize the request.\n * @returns A promise that resolves with the response data of type T.\n *\n * @example\n * ```typescript\n * // Making a GET request with query parameters\n * const data = await fetcher<MyResponseType>('https://api.example.com/data', {\n * params: { search: 'query' },\n * });\n *\n * // Making a POST request with a JSON body\n * const result = await fetcher<AnotherResponseType>('https://api.example.com/submit', {\n * method: 'POST',\n * body: { key: 'value' },\n * });\n *\n * // Merge body, headers, and params\n * const result = await fetcher<AnotherResponseType>('https://api.example.com/submit', {\n * method: 'POST',\n * body: { key: 'value' },\n * headers: { 'Content-Type': 'application/json' },\n * params: { search: 'query' },\n * },\n * {\n * headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n * params: { page: 1 },\n * });\n * ```\n *\n * Result:\n * ```typescript\n * {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n * params: { page: 1, search: 'query' },\n * body: { key: 'value' },\n * }\n * ```\n */\nexport const fetcher = async <T>(\n url: string,\n ...options: FetcherOptions[]\n): Promise<T> => {\n // Initialize query parameters string and request body string\n let paramsString = '';\n let bodyString: string | undefined = undefined;\n\n // Extract other options excluding 'body', 'params', and 'headers'\n const otherOptions = options.map(\n ({ body, params, headers, ...otherOptions }) => otherOptions\n );\n\n // Merge default options with user-provided options\n const mergedOptions = deepMerge([fetcherOptions, ...otherOptions]);\n\n // Merge default headers with user-provided headers\n const mergedHeaders = deepMerge([\n fetcherOptions.headers,\n ...options.map((option) => option.headers),\n ]);\n\n // Merge query parameters\n const params = deepMerge(options.map((option) => option.params));\n\n const method = mergedOptions.method;\n\n // If the request method is not 'GET' or 'HEAD', prepare the request body\n if (method !== 'GET' && method !== 'HEAD') {\n // Merge all 'body' options\n const body = deepMerge(options.map((option) => option.body));\n if (\n mergedHeaders?.['Content-Type' as keyof HeadersInit] ===\n 'application/x-www-form-urlencoded'\n ) {\n // If the content type is 'application/x-www-form-urlencoded', encode the body accordingly\n bodyString = new URLSearchParams(\n body as Record<string, string>\n ).toString();\n } else {\n // Otherwise, stringify the body as JSON\n bodyString = JSON.stringify(body);\n }\n }\n\n // If there are query parameters, append them to the URL\n if (Object.entries(params).length > 0) {\n paramsString = `?${new URLSearchParams(\n params as Record<string, string>\n ).toString()}`;\n }\n\n // Prepare the final request options\n const formattedOptions: RequestInit = {\n ...mergedOptions,\n headers: mergedHeaders,\n body: bodyString,\n };\n\n // Construct the full URL with query parameters\n const urlResult = `${url}${paramsString}`;\n\n // Make the HTTP request using fetch\n return (await fetch(urlResult, formattedOptions)).json();\n};\n"],"names":["params","otherOptions"],"mappings":";;AAwBO,MAAM,iBAAiC;AAAA,EAC5C,QAAQ;AAAA;AAAA,EACR,SAAS;AAAA,IACP,gBAAgB;AAAA;AAAA,EAClB;AAAA,EACA,aAAa;AAAA;AACf;AASA,MAAM,kBAAkB,CAAC,QAAgB;AACvC,SAAO,KAAK,GAAG,EAAE,QAAQ,CAAC,QAAQ;AAC5B,QAAA,IAAI,GAAuB,MAAM,QAAW;AAC9C,aAAO,IAAI,GAAuB;AAAA,IACpC;AAAA,EAAA,CACD;AACM,SAAA;AACT;AAUA,MAAM,YAAY,CAAmB,YACnC,QAAQ,OAAO,CAAC,KAAK,QAAQ;AACrB,QAAA,OAAW,OAAO;AACxB,QAAM,OAAU,gBAAgB,OAAO,CAAE,CAAA;AAEzC,MAAI,OAAO,SAAS,YAAY,OAAO,SAAS,UAAU;AAExD,WAAO,EAAE,GAAG,MAAM,GAAG;EACvB;AAGA,SAAO,QAAQ;AACjB,GAAG,CAAO,CAAA;AAiDC,MAAA,UAAU,OACrB,QACG,YACY;AAEf,MAAI,eAAe;AACnB,MAAI,aAAiC;AAGrC,QAAM,eAAe,QAAQ;AAAA,IAC3B,CAAC,EAAE,MAAM,QAAAA,SAAQ,SAAS,GAAGC,oBAAmBA;AAAAA,EAAA;AAIlD,QAAM,gBAAgB,UAAU,CAAC,gBAAgB,GAAG,YAAY,CAAC;AAGjE,QAAM,gBAAgB,UAAU;AAAA,IAC9B,eAAe;AAAA,IACf,GAAG,QAAQ,IAAI,CAAC,WAAW,OAAO,OAAO;AAAA,EAAA,CAC1C;AAGK,QAAA,SAAS,UAAU,QAAQ,IAAI,CAAC,WAAW,OAAO,MAAM,CAAC;AAE/D,QAAM,SAAS,cAAc;AAGzB,MAAA,WAAW,SAAS,WAAW,QAAQ;AAEnC,UAAA,OAAO,UAAU,QAAQ,IAAI,CAAC,WAAW,OAAO,IAAI,CAAC;AAEzD,QAAA,gBAAgB,cAAmC,MACnD,qCACA;AAEA,mBAAa,IAAI;AAAA,QACf;AAAA,QACA,SAAS;AAAA,IAAA,OACN;AAEQ,mBAAA,KAAK,UAAU,IAAI;AAAA,IAClC;AAAA,EACF;AAGA,MAAI,OAAO,QAAQ,MAAM,EAAE,SAAS,GAAG;AACrC,mBAAe,IAAI,IAAI;AAAA,MACrB;AAAA,IAAA,EACA,SAAU,CAAA;AAAA,EACd;AAGA,QAAM,mBAAgC;AAAA,IACpC,GAAG;AAAA,IACH,SAAS;AAAA,IACT,MAAM;AAAA,EAAA;AAIR,QAAM,YAAY,GAAG,GAAG,GAAG,YAAY;AAGvC,UAAQ,MAAM,MAAM,WAAW,gBAAgB,GAAG,KAAK;AACzD;;;"}
1
+ {"version":3,"file":"fetcher.cjs","sources":["../../../src/libs/intlayer-api/fetcher.ts"],"sourcesContent":["/**\n * Type definition for options used in the fetcher function.\n * Extends the standard RequestInit interface (excluding 'body'),\n * and adds 'body' and 'params' properties for convenience.\n */\nexport type FetcherOptions = Omit<RequestInit, 'body'> & {\n /**\n * Body of the request. Should be a key-value pair object.\n */\n body?: Record<string, unknown>;\n /**\n * Query parameters to be appended to the URL.\n */\n params?:\n | Record<string, string | string[] | undefined>\n | string[]\n | URLSearchParams;\n};\n\n/**\n * Default options for the fetcher function.\n * Sets the default method to 'GET', the 'Content-Type' header to 'application/json',\n * and includes credentials in the request.\n */\nexport const fetcherOptions: FetcherOptions = {\n method: 'GET', // Default HTTP method\n headers: {\n 'Content-Type': 'application/json', // Default content type\n },\n credentials: 'include', // Include cookies in the request\n};\n\n/**\n * Utility function to remove properties with undefined values from an object.\n * This helps prevent sending undefined values in the request options.\n *\n * @param obj - The object to clean.\n * @returns The cleaned object without undefined values.\n */\nconst removeUndefined = (obj: object) => {\n Object.keys(obj).forEach((key) => {\n if (obj[key as keyof typeof obj] === undefined) {\n delete obj[key as keyof typeof obj];\n }\n });\n return obj;\n};\n\n/**\n * Deeply merges an array of objects into a single object.\n * Later objects in the array overwrite properties of earlier ones.\n *\n * @template T - The type of objects being merged.\n * @param objects - An array of objects to merge.\n * @returns The merged object.\n */\nconst deepMerge = <T extends object>(objects: (T | undefined)[]): T =>\n objects.reduce((acc, obj) => {\n const acc1: T = (acc ?? {}) as T;\n const obj1: T = removeUndefined(obj ?? {}) as T;\n\n if (typeof acc1 === 'object' && typeof obj1 === 'object') {\n // Merge the two objects\n return { ...acc1, ...obj1 };\n }\n\n // If one of them is not an object, return the defined one\n return obj1 ?? acc1;\n }, {} as T)!;\n\n/**\n * Fetcher function to make HTTP requests.\n * It merges default options with user-provided options,\n * handles query parameters and request body,\n * and returns the parsed JSON response.\n *\n * @template T - The expected type of the response data.\n * @param url - The endpoint URL.\n * @param options - Additional options to customize the request.\n * @returns A promise that resolves with the response data of type T.\n *\n * @example\n * ```typescript\n * // Making a GET request with query parameters\n * const data = await fetcher<MyResponseType>('https://api.example.com/data', {\n * params: { search: 'query' },\n * });\n *\n * // Making a POST request with a JSON body\n * const result = await fetcher<AnotherResponseType>('https://api.example.com/submit', {\n * method: 'POST',\n * body: { key: 'value' },\n * });\n *\n * // Merge body, headers, and params\n * const result = await fetcher<AnotherResponseType>('https://api.example.com/submit', {\n * method: 'POST',\n * body: { key: 'value' },\n * headers: { 'Content-Type': 'application/json' },\n * params: { search: 'query' },\n * },\n * {\n * headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n * params: { page: 1 },\n * });\n * ```\n *\n * Result:\n * ```typescript\n * {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n * params: { page: 1, search: 'query' },\n * body: { key: 'value' },\n * }\n * ```\n */\nexport const fetcher = async <T>(\n url: string,\n ...options: FetcherOptions[]\n): Promise<T> => {\n // Initialize query parameters string and request body string\n let paramsString = '';\n let bodyString: string | undefined = undefined;\n\n // Extract other options excluding 'body', 'params', and 'headers'\n const otherOptions = options.map(\n ({ body, params, headers, ...otherOptions }) => otherOptions\n );\n\n // Merge default options with user-provided options\n const mergedOptions = deepMerge([fetcherOptions, ...otherOptions]);\n\n // Merge default headers with user-provided headers\n const mergedHeaders = deepMerge([\n fetcherOptions.headers,\n ...options.map((option) => option.headers),\n ]);\n\n // Merge query parameters\n const params = deepMerge(options.map((option) => option.params));\n\n const method = mergedOptions.method;\n\n // If the request method is not 'GET' or 'HEAD', prepare the request body\n if (method !== 'GET' && method !== 'HEAD') {\n // Merge all 'body' options\n const body = deepMerge(options.map((option) => option.body));\n if (\n mergedHeaders?.['Content-Type' as keyof HeadersInit] ===\n 'application/x-www-form-urlencoded'\n ) {\n // If the content type is 'application/x-www-form-urlencoded', encode the body accordingly\n bodyString = new URLSearchParams(\n body as Record<string, string>\n ).toString();\n } else {\n // Otherwise, stringify the body as JSON\n bodyString = JSON.stringify(body);\n }\n }\n\n // If there are query parameters, append them to the URL\n if (Object.entries(params).length > 0) {\n paramsString = `?${new URLSearchParams(\n params as Record<string, string>\n ).toString()}`;\n }\n\n // Prepare the final request options\n const formattedOptions: RequestInit = {\n ...mergedOptions,\n headers: mergedHeaders,\n body: bodyString,\n };\n\n // Construct the full URL with query parameters\n const urlResult = `${url}${paramsString}`;\n\n // Make the HTTP request using fetch\n const response = await fetch(urlResult, formattedOptions);\n\n if (!response.ok) {\n const result = await response.json();\n\n console.error(result);\n\n // You can customize the error message or include more details\n throw new Error(JSON.stringify(result.error) ?? 'An error occurred');\n }\n return await response.json();\n};\n"],"names":["params","otherOptions"],"mappings":";;AAwBO,MAAM,iBAAiC;AAAA,EAC5C,QAAQ;AAAA;AAAA,EACR,SAAS;AAAA,IACP,gBAAgB;AAAA;AAAA,EAClB;AAAA,EACA,aAAa;AAAA;AACf;AASA,MAAM,kBAAkB,CAAC,QAAgB;AACvC,SAAO,KAAK,GAAG,EAAE,QAAQ,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EACd;AAGA,QAAM,mBAAgC;AAAA,IACpC,GAAG;AAAA,IACH,SAAS;AAAA,IACT,MAAM;AAAA,EAAA;AAIR,QAAM,YAAY,GAAG,GAAG,GAAG,YAAY;AAGvC,QAAM,WAAW,MAAM,MAAM,WAAW,gBAAgB;AAEpD,MAAA,CAAC,SAAS,IAAI;AACV,UAAA,SAAS,MAAM,SAAS;AAE9B,YAAQ,MAAM,MAAM;AAGpB,UAAM,IAAI,MAAM,KAAK,UAAU,OAAO,KAAK,KAAK,mBAAmB;AAAA,EACrE;AACO,SAAA,MAAM,SAAS;AACxB;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../../../src/libs/intlayer-api/fetcher.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG;IACvD;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B;;OAEG;IACH,MAAM,CAAC,EACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,GAC7C,MAAM,EAAE,GACR,eAAe,CAAC;CACrB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,cAM5B,CAAC;AAwCF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,eAAO,MAAM,OAAO,GAAU,CAAC,OACxB,MAAM,cACC,cAAc,EAAE,KAC3B,OAAO,CAAC,CAAC,CA6DX,CAAC"}
1
+ {"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../../../src/libs/intlayer-api/fetcher.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG;IACvD;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B;;OAEG;IACH,MAAM,CAAC,EACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,GAC7C,MAAM,EAAE,GACR,eAAe,CAAC;CACrB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,cAM5B,CAAC;AAwCF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,eAAO,MAAM,OAAO,GAAU,CAAC,OACxB,MAAM,cACC,cAAc,EAAE,KAC3B,OAAO,CAAC,CAAC,CAuEX,CAAC"}
@@ -58,7 +58,13 @@ const fetcher = async (url, ...options) => {
58
58
  body: bodyString
59
59
  };
60
60
  const urlResult = `${url}${paramsString}`;
61
- return (await fetch(urlResult, formattedOptions)).json();
61
+ const response = await fetch(urlResult, formattedOptions);
62
+ if (!response.ok) {
63
+ const result = await response.json();
64
+ console.error(result);
65
+ throw new Error(JSON.stringify(result.error) ?? "An error occurred");
66
+ }
67
+ return await response.json();
62
68
  };
63
69
  export {
64
70
  fetcher,
@@ -1 +1 @@
1
- {"version":3,"file":"fetcher.mjs","sources":["../../../src/libs/intlayer-api/fetcher.ts"],"sourcesContent":["/**\n * Type definition for options used in the fetcher function.\n * Extends the standard RequestInit interface (excluding 'body'),\n * and adds 'body' and 'params' properties for convenience.\n */\nexport type FetcherOptions = Omit<RequestInit, 'body'> & {\n /**\n * Body of the request. Should be a key-value pair object.\n */\n body?: Record<string, unknown>;\n /**\n * Query parameters to be appended to the URL.\n */\n params?:\n | Record<string, string | string[] | undefined>\n | string[]\n | URLSearchParams;\n};\n\n/**\n * Default options for the fetcher function.\n * Sets the default method to 'GET', the 'Content-Type' header to 'application/json',\n * and includes credentials in the request.\n */\nexport const fetcherOptions: FetcherOptions = {\n method: 'GET', // Default HTTP method\n headers: {\n 'Content-Type': 'application/json', // Default content type\n },\n credentials: 'include', // Include cookies in the request\n};\n\n/**\n * Utility function to remove properties with undefined values from an object.\n * This helps prevent sending undefined values in the request options.\n *\n * @param obj - The object to clean.\n * @returns The cleaned object without undefined values.\n */\nconst removeUndefined = (obj: object) => {\n Object.keys(obj).forEach((key) => {\n if (obj[key as keyof typeof obj] === undefined) {\n delete obj[key as keyof typeof obj];\n }\n });\n return obj;\n};\n\n/**\n * Deeply merges an array of objects into a single object.\n * Later objects in the array overwrite properties of earlier ones.\n *\n * @template T - The type of objects being merged.\n * @param objects - An array of objects to merge.\n * @returns The merged object.\n */\nconst deepMerge = <T extends object>(objects: (T | undefined)[]): T =>\n objects.reduce((acc, obj) => {\n const acc1: T = (acc ?? {}) as T;\n const obj1: T = removeUndefined(obj ?? {}) as T;\n\n if (typeof acc1 === 'object' && typeof obj1 === 'object') {\n // Merge the two objects\n return { ...acc1, ...obj1 };\n }\n\n // If one of them is not an object, return the defined one\n return obj1 ?? acc1;\n }, {} as T)!;\n\n/**\n * Fetcher function to make HTTP requests.\n * It merges default options with user-provided options,\n * handles query parameters and request body,\n * and returns the parsed JSON response.\n *\n * @template T - The expected type of the response data.\n * @param url - The endpoint URL.\n * @param options - Additional options to customize the request.\n * @returns A promise that resolves with the response data of type T.\n *\n * @example\n * ```typescript\n * // Making a GET request with query parameters\n * const data = await fetcher<MyResponseType>('https://api.example.com/data', {\n * params: { search: 'query' },\n * });\n *\n * // Making a POST request with a JSON body\n * const result = await fetcher<AnotherResponseType>('https://api.example.com/submit', {\n * method: 'POST',\n * body: { key: 'value' },\n * });\n *\n * // Merge body, headers, and params\n * const result = await fetcher<AnotherResponseType>('https://api.example.com/submit', {\n * method: 'POST',\n * body: { key: 'value' },\n * headers: { 'Content-Type': 'application/json' },\n * params: { search: 'query' },\n * },\n * {\n * headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n * params: { page: 1 },\n * });\n * ```\n *\n * Result:\n * ```typescript\n * {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n * params: { page: 1, search: 'query' },\n * body: { key: 'value' },\n * }\n * ```\n */\nexport const fetcher = async <T>(\n url: string,\n ...options: FetcherOptions[]\n): Promise<T> => {\n // Initialize query parameters string and request body string\n let paramsString = '';\n let bodyString: string | undefined = undefined;\n\n // Extract other options excluding 'body', 'params', and 'headers'\n const otherOptions = options.map(\n ({ body, params, headers, ...otherOptions }) => otherOptions\n );\n\n // Merge default options with user-provided options\n const mergedOptions = deepMerge([fetcherOptions, ...otherOptions]);\n\n // Merge default headers with user-provided headers\n const mergedHeaders = deepMerge([\n fetcherOptions.headers,\n ...options.map((option) => option.headers),\n ]);\n\n // Merge query parameters\n const params = deepMerge(options.map((option) => option.params));\n\n const method = mergedOptions.method;\n\n // If the request method is not 'GET' or 'HEAD', prepare the request body\n if (method !== 'GET' && method !== 'HEAD') {\n // Merge all 'body' options\n const body = deepMerge(options.map((option) => option.body));\n if (\n mergedHeaders?.['Content-Type' as keyof HeadersInit] ===\n 'application/x-www-form-urlencoded'\n ) {\n // If the content type is 'application/x-www-form-urlencoded', encode the body accordingly\n bodyString = new URLSearchParams(\n body as Record<string, string>\n ).toString();\n } else {\n // Otherwise, stringify the body as JSON\n bodyString = JSON.stringify(body);\n }\n }\n\n // If there are query parameters, append them to the URL\n if (Object.entries(params).length > 0) {\n paramsString = `?${new URLSearchParams(\n params as Record<string, string>\n ).toString()}`;\n }\n\n // Prepare the final request options\n const formattedOptions: RequestInit = {\n ...mergedOptions,\n headers: mergedHeaders,\n body: bodyString,\n };\n\n // Construct the full URL with query parameters\n const urlResult = `${url}${paramsString}`;\n\n // Make the HTTP request using fetch\n return (await fetch(urlResult, formattedOptions)).json();\n};\n"],"names":["params","otherOptions"],"mappings":"AAwBO,MAAM,iBAAiC;AAAA,EAC5C,QAAQ;AAAA;AAAA,EACR,SAAS;AAAA,IACP,gBAAgB;AAAA;AAAA,EAClB;AAAA,EACA,aAAa;AAAA;AACf;AASA,MAAM,kBAAkB,CAAC,QAAgB;AACvC,SAAO,KAAK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A,SAAU,CAAA;AAAA,EACd;AAGA,QAAM,mBAAgC;AAAA,IACpC,GAAG;AAAA,IACH,SAAS;AAAA,IACT,MAAM;AAAA,EAAA;AAIR,QAAM,YAAY,GAAG,GAAG,GAAG,YAAY;AAGvC,UAAQ,MAAM,MAAM,WAAW,gBAAgB,GAAG,KAAK;AACzD;"}
1
+ {"version":3,"file":"fetcher.mjs","sources":["../../../src/libs/intlayer-api/fetcher.ts"],"sourcesContent":["/**\n * Type definition for options used in the fetcher function.\n * Extends the standard RequestInit interface (excluding 'body'),\n * and adds 'body' and 'params' properties for convenience.\n */\nexport type FetcherOptions = Omit<RequestInit, 'body'> & {\n /**\n * Body of the request. Should be a key-value pair object.\n */\n body?: Record<string, unknown>;\n /**\n * Query parameters to be appended to the URL.\n */\n params?:\n | Record<string, string | string[] | undefined>\n | string[]\n | URLSearchParams;\n};\n\n/**\n * Default options for the fetcher function.\n * Sets the default method to 'GET', the 'Content-Type' header to 'application/json',\n * and includes credentials in the request.\n */\nexport const fetcherOptions: FetcherOptions = {\n method: 'GET', // Default HTTP method\n headers: {\n 'Content-Type': 'application/json', // Default content type\n },\n credentials: 'include', // Include cookies in the request\n};\n\n/**\n * Utility function to remove properties with undefined values from an object.\n * This helps prevent sending undefined values in the request options.\n *\n * @param obj - The object to clean.\n * @returns The cleaned object without undefined values.\n */\nconst removeUndefined = (obj: object) => {\n Object.keys(obj).forEach((key) => {\n if (obj[key as keyof typeof obj] === undefined) {\n delete obj[key as keyof typeof obj];\n }\n });\n return obj;\n};\n\n/**\n * Deeply merges an array of objects into a single object.\n * Later objects in the array overwrite properties of earlier ones.\n *\n * @template T - The type of objects being merged.\n * @param objects - An array of objects to merge.\n * @returns The merged object.\n */\nconst deepMerge = <T extends object>(objects: (T | undefined)[]): T =>\n objects.reduce((acc, obj) => {\n const acc1: T = (acc ?? {}) as T;\n const obj1: T = removeUndefined(obj ?? {}) as T;\n\n if (typeof acc1 === 'object' && typeof obj1 === 'object') {\n // Merge the two objects\n return { ...acc1, ...obj1 };\n }\n\n // If one of them is not an object, return the defined one\n return obj1 ?? acc1;\n }, {} as T)!;\n\n/**\n * Fetcher function to make HTTP requests.\n * It merges default options with user-provided options,\n * handles query parameters and request body,\n * and returns the parsed JSON response.\n *\n * @template T - The expected type of the response data.\n * @param url - The endpoint URL.\n * @param options - Additional options to customize the request.\n * @returns A promise that resolves with the response data of type T.\n *\n * @example\n * ```typescript\n * // Making a GET request with query parameters\n * const data = await fetcher<MyResponseType>('https://api.example.com/data', {\n * params: { search: 'query' },\n * });\n *\n * // Making a POST request with a JSON body\n * const result = await fetcher<AnotherResponseType>('https://api.example.com/submit', {\n * method: 'POST',\n * body: { key: 'value' },\n * });\n *\n * // Merge body, headers, and params\n * const result = await fetcher<AnotherResponseType>('https://api.example.com/submit', {\n * method: 'POST',\n * body: { key: 'value' },\n * headers: { 'Content-Type': 'application/json' },\n * params: { search: 'query' },\n * },\n * {\n * headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n * params: { page: 1 },\n * });\n * ```\n *\n * Result:\n * ```typescript\n * {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n * params: { page: 1, search: 'query' },\n * body: { key: 'value' },\n * }\n * ```\n */\nexport const fetcher = async <T>(\n url: string,\n ...options: FetcherOptions[]\n): Promise<T> => {\n // Initialize query parameters string and request body string\n let paramsString = '';\n let bodyString: string | undefined = undefined;\n\n // Extract other options excluding 'body', 'params', and 'headers'\n const otherOptions = options.map(\n ({ body, params, headers, ...otherOptions }) => otherOptions\n );\n\n // Merge default options with user-provided options\n const mergedOptions = deepMerge([fetcherOptions, ...otherOptions]);\n\n // Merge default headers with user-provided headers\n const mergedHeaders = deepMerge([\n fetcherOptions.headers,\n ...options.map((option) => option.headers),\n ]);\n\n // Merge query parameters\n const params = deepMerge(options.map((option) => option.params));\n\n const method = mergedOptions.method;\n\n // If the request method is not 'GET' or 'HEAD', prepare the request body\n if (method !== 'GET' && method !== 'HEAD') {\n // Merge all 'body' options\n const body = deepMerge(options.map((option) => option.body));\n if (\n mergedHeaders?.['Content-Type' as keyof HeadersInit] ===\n 'application/x-www-form-urlencoded'\n ) {\n // If the content type is 'application/x-www-form-urlencoded', encode the body accordingly\n bodyString = new URLSearchParams(\n body as Record<string, string>\n ).toString();\n } else {\n // Otherwise, stringify the body as JSON\n bodyString = JSON.stringify(body);\n }\n }\n\n // If there are query parameters, append them to the URL\n if (Object.entries(params).length > 0) {\n paramsString = `?${new URLSearchParams(\n params as Record<string, string>\n ).toString()}`;\n }\n\n // Prepare the final request options\n const formattedOptions: RequestInit = {\n ...mergedOptions,\n headers: mergedHeaders,\n body: bodyString,\n };\n\n // Construct the full URL with query parameters\n const urlResult = `${url}${paramsString}`;\n\n // Make the HTTP request using fetch\n const response = await fetch(urlResult, formattedOptions);\n\n if (!response.ok) {\n const result = await response.json();\n\n console.error(result);\n\n // You can customize the error message or include more details\n throw new Error(JSON.stringify(result.error) ?? 'An error occurred');\n }\n return await response.json();\n};\n"],"names":["params","otherOptions"],"mappings":"AAwBO,MAAM,iBAAiC;AAAA,EAC5C,QAAQ;AAAA;AAAA,EACR,SAAS;AAAA,IACP,gBAAgB;AAAA;AAAA,EAClB;AAAA,EACA,aAAa;AAAA;AACf;AASA,MAAM,kBAAkB,CAAC,QAAgB;AACvC,SAAO,KAAK,GAAG,EAAE,QAAQ,CAAC,QAAQ;AAC5B,QAAA,IAAI,GAAuB,MAAM,QAAW;AAC9C,aAAO,IAAI,GAAuB;AAAA,IACpC;AAAA,EAAA,CACD;AACM,SAAA;AACT;AAUA,MAAM,YAAY,CAAmB,YACnC,QAAQ,OAAO,CAAC,KAAK,QAAQ;AACrB,QAAA,OAAW,OAAO;AACxB,QAAM,OAAU,gBAAgB,OAAO,CAAE,CAAA;AAEzC,MAAI,OAAO,SAAS,YAAY,OAAO,SAAS,UAAU;AAExD,WAAO,EAAE,GAAG,MAAM,GAAG;EACvB;AAGA,SAAO,QAAQ;AACjB,GAAG,CAAO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4,15 @@ const libs_intlayerApi_auth = require("./auth.cjs");
4
4
  const libs_intlayerApi_dictionary = require("./dictionary.cjs");
5
5
  const libs_intlayerApi_organization = require("./organization.cjs");
6
6
  const libs_intlayerApi_project = require("./project.cjs");
7
+ const libs_intlayerApi_stripe = require("./stripe.cjs");
7
8
  const libs_intlayerApi_user = require("./user.cjs");
8
9
  const getIntlayerAPI = (authAPIOptions = {}) => ({
9
10
  organization: libs_intlayerApi_organization.getOrganizationAPI(authAPIOptions),
10
11
  project: libs_intlayerApi_project.getProjectAPI(authAPIOptions),
11
12
  user: libs_intlayerApi_user.getUserAPI(authAPIOptions),
12
13
  auth: libs_intlayerApi_auth.getAuthAPI(authAPIOptions),
13
- dictionary: libs_intlayerApi_dictionary.getDictionaryAPI(authAPIOptions)
14
+ dictionary: libs_intlayerApi_dictionary.getDictionaryAPI(authAPIOptions),
15
+ stripe: libs_intlayerApi_stripe.getStripeAPI(authAPIOptions)
14
16
  });
15
17
  const intlayerAPI = getIntlayerAPI();
16
18
  exports.getIntlayerAPI = getIntlayerAPI;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../src/libs/intlayer-api/index.ts"],"sourcesContent":["import { getAuthAPI } from './auth';\nimport { getDictionaryAPI } from './dictionary';\nimport type { FetcherOptions } from './fetcher';\nimport { getOrganizationAPI } from './organization';\nimport { getProjectAPI } from './project';\nimport { getUserAPI } from './user';\n\nexport const getIntlayerAPI = (authAPIOptions: FetcherOptions = {}) => ({\n organization: getOrganizationAPI(authAPIOptions),\n project: getProjectAPI(authAPIOptions),\n user: getUserAPI(authAPIOptions),\n auth: getAuthAPI(authAPIOptions),\n dictionary: getDictionaryAPI(authAPIOptions),\n});\n\nexport const intlayerAPI = getIntlayerAPI();\n"],"names":["getOrganizationAPI","getProjectAPI","getUserAPI","getAuthAPI","getDictionaryAPI"],"mappings":";;;;;;;AAOO,MAAM,iBAAiB,CAAC,iBAAiC,QAAQ;AAAA,EACtE,cAAcA,iDAAmB,cAAc;AAAA,EAC/C,SAASC,uCAAc,cAAc;AAAA,EACrC,MAAMC,iCAAW,cAAc;AAAA,EAC/B,MAAMC,iCAAW,cAAc;AAAA,EAC/B,YAAYC,6CAAiB,cAAc;AAC7C;AAEO,MAAM,cAAc,eAAe;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../src/libs/intlayer-api/index.ts"],"sourcesContent":["import { getAuthAPI } from './auth';\nimport { getDictionaryAPI } from './dictionary';\nimport type { FetcherOptions } from './fetcher';\nimport { getOrganizationAPI } from './organization';\nimport { getProjectAPI } from './project';\nimport { getStripeAPI } from './stripe';\nimport { getUserAPI } from './user';\n\nexport const getIntlayerAPI = (authAPIOptions: FetcherOptions = {}) => ({\n organization: getOrganizationAPI(authAPIOptions),\n project: getProjectAPI(authAPIOptions),\n user: getUserAPI(authAPIOptions),\n auth: getAuthAPI(authAPIOptions),\n dictionary: getDictionaryAPI(authAPIOptions),\n stripe: getStripeAPI(authAPIOptions),\n});\n\nexport const intlayerAPI = getIntlayerAPI();\n"],"names":["getOrganizationAPI","getProjectAPI","getUserAPI","getAuthAPI","getDictionaryAPI","getStripeAPI"],"mappings":";;;;;;;;AAQO,MAAM,iBAAiB,CAAC,iBAAiC,QAAQ;AAAA,EACtE,cAAcA,iDAAmB,cAAc;AAAA,EAC/C,SAASC,uCAAc,cAAc;AAAA,EACrC,MAAMC,iCAAW,cAAc;AAAA,EAC/B,MAAMC,iCAAW,cAAc;AAAA,EAC/B,YAAYC,6CAAiB,cAAc;AAAA,EAC3C,QAAQC,qCAAa,cAAc;AACrC;AAEO,MAAM,cAAc,eAAe;;;"}