@vitnode/core 1.2.0-canary.10

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 (569) hide show
  1. package/LICENSE.md +21 -0
  2. package/dist/emails/my-email.d.ts +2 -0
  3. package/dist/emails/my-email.d.ts.map +1 -0
  4. package/dist/scripts/get-config.d.ts +3 -0
  5. package/dist/scripts/get-config.d.ts.map +1 -0
  6. package/dist/scripts/plugin.d.ts +4 -0
  7. package/dist/scripts/plugin.d.ts.map +1 -0
  8. package/dist/scripts/prepare-database.d.ts +7 -0
  9. package/dist/scripts/prepare-database.d.ts.map +1 -0
  10. package/dist/scripts/prepare-plugins-files.d.ts +2 -0
  11. package/dist/scripts/prepare-plugins-files.d.ts.map +1 -0
  12. package/dist/scripts/run-interactive-shell-command.d.ts +2 -0
  13. package/dist/scripts/run-interactive-shell-command.d.ts.map +1 -0
  14. package/dist/scripts/scripts.d.ts +3 -0
  15. package/dist/scripts/scripts.d.ts.map +1 -0
  16. package/dist/scripts/scripts.js +21 -0
  17. package/dist/scripts/shared/file-utils.d.ts +14 -0
  18. package/dist/scripts/shared/file-utils.d.ts.map +1 -0
  19. package/dist/src/api/config.d.ts +24 -0
  20. package/dist/src/api/config.d.ts.map +1 -0
  21. package/dist/src/api/config.js +50 -0
  22. package/dist/src/api/lib/check-plugin-id.d.ts +15 -0
  23. package/dist/src/api/lib/check-plugin-id.d.ts.map +1 -0
  24. package/dist/src/api/lib/check-plugin-id.js +15 -0
  25. package/dist/src/api/lib/get-user-ip.d.ts +3 -0
  26. package/dist/src/api/lib/get-user-ip.d.ts.map +1 -0
  27. package/dist/src/api/lib/get-user-ip.js +8 -0
  28. package/dist/src/api/lib/module.d.ts +23 -0
  29. package/dist/src/api/lib/module.d.ts.map +1 -0
  30. package/dist/src/api/lib/module.js +21 -0
  31. package/dist/src/api/lib/plugin.d.ts +11 -0
  32. package/dist/src/api/lib/plugin.d.ts.map +1 -0
  33. package/dist/src/api/lib/plugin.js +14 -0
  34. package/dist/src/api/lib/route.d.ts +26 -0
  35. package/dist/src/api/lib/route.d.ts.map +1 -0
  36. package/dist/src/api/lib/route.js +23 -0
  37. package/dist/src/api/lib/with-pagination.d.ts +72 -0
  38. package/dist/src/api/lib/with-pagination.d.ts.map +1 -0
  39. package/dist/src/api/lib/with-pagination.js +70 -0
  40. package/dist/src/api/middlewares/global/global.d.ts +66 -0
  41. package/dist/src/api/middlewares/global/global.d.ts.map +1 -0
  42. package/dist/src/api/middlewares/global/global.js +47 -0
  43. package/dist/src/api/models/device.d.ts +10 -0
  44. package/dist/src/api/models/device.d.ts.map +1 -0
  45. package/dist/src/api/models/device.js +54 -0
  46. package/dist/src/api/models/email.d.ts +22 -0
  47. package/dist/src/api/models/email.d.ts.map +1 -0
  48. package/dist/src/api/models/email.js +30 -0
  49. package/dist/src/api/models/password.d.ts +5 -0
  50. package/dist/src/api/models/password.d.ts.map +1 -0
  51. package/dist/src/api/models/password.js +21 -0
  52. package/dist/src/api/models/session-admin.d.ts +24 -0
  53. package/dist/src/api/models/session-admin.d.ts.map +1 -0
  54. package/dist/src/api/models/session-admin.js +73 -0
  55. package/dist/src/api/models/session.d.ts +23 -0
  56. package/dist/src/api/models/session.d.ts.map +1 -0
  57. package/dist/src/api/models/session.js +60 -0
  58. package/dist/src/api/models/sso.d.ts +38 -0
  59. package/dist/src/api/models/sso.d.ts.map +1 -0
  60. package/dist/src/api/models/sso.js +120 -0
  61. package/dist/src/api/models/user/get-user-by-id.d.ts +17 -0
  62. package/dist/src/api/models/user/get-user-by-id.d.ts.map +1 -0
  63. package/dist/src/api/models/user/get-user-by-id.js +18 -0
  64. package/dist/src/api/models/user/sign-in-with-passwords.d.ts +10 -0
  65. package/dist/src/api/models/user/sign-in-with-passwords.d.ts.map +1 -0
  66. package/dist/src/api/models/user/sign-in-with-passwords.js +22 -0
  67. package/dist/src/api/models/user/sign-up.d.ts +21 -0
  68. package/dist/src/api/models/user/sign-up.d.ts.map +1 -0
  69. package/dist/src/api/models/user/sign-up.js +75 -0
  70. package/dist/src/api/models/user.d.ts +45 -0
  71. package/dist/src/api/models/user.d.ts.map +1 -0
  72. package/dist/src/api/models/user.js +8 -0
  73. package/dist/src/api/modules/admin/admin.module.d.ts +294 -0
  74. package/dist/src/api/modules/admin/admin.module.d.ts.map +1 -0
  75. package/dist/src/api/modules/admin/admin.module.js +14 -0
  76. package/dist/src/api/modules/admin/routes/session.route.d.ts +108 -0
  77. package/dist/src/api/modules/admin/routes/session.route.d.ts.map +1 -0
  78. package/dist/src/api/modules/admin/routes/session.route.js +51 -0
  79. package/dist/src/api/modules/admin/users/routes/list.route.d.ts +190 -0
  80. package/dist/src/api/modules/admin/users/routes/list.route.d.ts.map +1 -0
  81. package/dist/src/api/modules/admin/users/routes/list.route.js +79 -0
  82. package/dist/src/api/modules/admin/users/routes/users.route.d.ts +193 -0
  83. package/dist/src/api/modules/admin/users/routes/users.route.d.ts.map +1 -0
  84. package/dist/src/api/modules/admin/users/routes/users.route.js +84 -0
  85. package/dist/src/api/modules/admin/users/users.admin.module.d.ts +189 -0
  86. package/dist/src/api/modules/admin/users/users.admin.module.d.ts.map +1 -0
  87. package/dist/src/api/modules/admin/users/users.admin.module.js +10 -0
  88. package/dist/src/api/modules/middleware/middleware.module.d.ts +52 -0
  89. package/dist/src/api/modules/middleware/middleware.module.d.ts.map +1 -0
  90. package/dist/src/api/modules/middleware/middleware.module.js +10 -0
  91. package/dist/src/api/modules/middleware/route.d.ts +53 -0
  92. package/dist/src/api/modules/middleware/route.d.ts.map +1 -0
  93. package/dist/src/api/modules/middleware/route.js +39 -0
  94. package/dist/src/api/modules/users/avatar-color.d.ts +2 -0
  95. package/dist/src/api/modules/users/avatar-color.d.ts.map +1 -0
  96. package/dist/src/api/modules/users/avatar-color.js +43 -0
  97. package/dist/src/api/modules/users/routes/session.route.d.ts +103 -0
  98. package/dist/src/api/modules/users/routes/session.route.d.ts.map +1 -0
  99. package/dist/src/api/modules/users/routes/session.route.js +46 -0
  100. package/dist/src/api/modules/users/routes/sign-in.route.d.ts +88 -0
  101. package/dist/src/api/modules/users/routes/sign-in.route.d.ts.map +1 -0
  102. package/dist/src/api/modules/users/routes/sign-in.route.js +71 -0
  103. package/dist/src/api/modules/users/routes/sign-out.route.d.ts +47 -0
  104. package/dist/src/api/modules/users/routes/sign-out.route.d.ts.map +1 -0
  105. package/dist/src/api/modules/users/routes/sign-out.route.js +43 -0
  106. package/dist/src/api/modules/users/routes/sign-up.route.d.ts +89 -0
  107. package/dist/src/api/modules/users/routes/sign-up.route.d.ts.map +1 -0
  108. package/dist/src/api/modules/users/routes/sign-up.route.js +60 -0
  109. package/dist/src/api/modules/users/routes/test.route.d.ts +31 -0
  110. package/dist/src/api/modules/users/routes/test.route.d.ts.map +1 -0
  111. package/dist/src/api/modules/users/routes/test.route.js +32 -0
  112. package/dist/src/api/modules/users/sso/routes/callback.route.d.ts +78 -0
  113. package/dist/src/api/modules/users/sso/routes/callback.route.d.ts.map +1 -0
  114. package/dist/src/api/modules/users/sso/routes/callback.route.js +49 -0
  115. package/dist/src/api/modules/users/sso/routes/create-url.route.d.ts +51 -0
  116. package/dist/src/api/modules/users/sso/routes/create-url.route.d.ts.map +1 -0
  117. package/dist/src/api/modules/users/sso/routes/create-url.route.js +36 -0
  118. package/dist/src/api/modules/users/sso/sso.module.d.ts +125 -0
  119. package/dist/src/api/modules/users/sso/sso.module.d.ts.map +1 -0
  120. package/dist/src/api/modules/users/sso/sso.module.js +12 -0
  121. package/dist/src/api/modules/users/users.module.d.ts +439 -0
  122. package/dist/src/api/modules/users/users.module.d.ts.map +1 -0
  123. package/dist/src/api/modules/users/users.module.js +22 -0
  124. package/dist/src/api/plugin.d.ts +2 -0
  125. package/dist/src/api/plugin.d.ts.map +1 -0
  126. package/dist/src/api/plugin.js +13 -0
  127. package/dist/src/api/plugins/email/nodemailer.d.ts +10 -0
  128. package/dist/src/api/plugins/email/nodemailer.d.ts.map +1 -0
  129. package/dist/src/api/plugins/email/nodemailer.js +30 -0
  130. package/dist/src/api/plugins/email/resend.d.ts +6 -0
  131. package/dist/src/api/plugins/email/resend.d.ts.map +1 -0
  132. package/dist/src/api/plugins/email/resend.js +21 -0
  133. package/dist/src/api/plugins/sso/discord.d.ts +6 -0
  134. package/dist/src/api/plugins/sso/discord.d.ts.map +1 -0
  135. package/dist/src/api/plugins/sso/discord.js +77 -0
  136. package/dist/src/api/plugins/sso/facebook.d.ts +6 -0
  137. package/dist/src/api/plugins/sso/facebook.d.ts.map +1 -0
  138. package/dist/src/api/plugins/sso/facebook.js +76 -0
  139. package/dist/src/api/plugins/sso/google.d.ts +6 -0
  140. package/dist/src/api/plugins/sso/google.d.ts.map +1 -0
  141. package/dist/src/api/plugins/sso/google.js +87 -0
  142. package/dist/src/app/login/page.d.ts +6 -0
  143. package/dist/src/app/login/page.d.ts.map +1 -0
  144. package/dist/src/app/login/page.js +15 -0
  145. package/dist/src/app/login/sso/[providerId]/page.d.ts +7 -0
  146. package/dist/src/app/login/sso/[providerId]/page.d.ts.map +1 -0
  147. package/dist/src/app/login/sso/[providerId]/page.js +10 -0
  148. package/dist/src/app/register/page.d.ts +6 -0
  149. package/dist/src/app/register/page.d.ts.map +1 -0
  150. package/dist/src/app/register/page.js +15 -0
  151. package/dist/src/app_admin/core/page.d.ts +2 -0
  152. package/dist/src/app_admin/core/page.d.ts.map +1 -0
  153. package/dist/src/app_admin/core/page.js +5 -0
  154. package/dist/src/app_admin/core/test/page.d.ts +2 -0
  155. package/dist/src/app_admin/core/test/page.d.ts.map +1 -0
  156. package/dist/src/app_admin/core/test/page.js +5 -0
  157. package/dist/src/app_admin/core/users/page.d.ts +6 -0
  158. package/dist/src/app_admin/core/users/page.d.ts.map +1 -0
  159. package/dist/src/app_admin/core/users/page.js +35 -0
  160. package/dist/src/components/avatar.d.ts +10 -0
  161. package/dist/src/components/avatar.d.ts.map +1 -0
  162. package/dist/src/components/avatar.js +14 -0
  163. package/dist/src/components/date-format.d.ts +5 -0
  164. package/dist/src/components/date-format.d.ts.map +1 -0
  165. package/dist/src/components/date-format.js +38 -0
  166. package/dist/src/components/form/auto-form.d.ts +12 -0
  167. package/dist/src/components/form/auto-form.d.ts.map +1 -0
  168. package/dist/src/components/form/auto-form.js +57 -0
  169. package/dist/src/components/form/common/desc.d.ts +2 -0
  170. package/dist/src/components/form/common/desc.d.ts.map +1 -0
  171. package/dist/src/components/form/common/desc.js +9 -0
  172. package/dist/src/components/form/common/label.d.ts +3 -0
  173. package/dist/src/components/form/common/label.d.ts.map +1 -0
  174. package/dist/src/components/form/common/label.js +8 -0
  175. package/dist/src/components/form/fields/checkbox.d.ts +8 -0
  176. package/dist/src/components/form/fields/checkbox.d.ts.map +1 -0
  177. package/dist/src/components/form/fields/checkbox.js +35 -0
  178. package/dist/src/components/form/fields/combobox.d.ts +14 -0
  179. package/dist/src/components/form/fields/combobox.d.ts.map +1 -0
  180. package/dist/src/components/form/fields/combobox.js +88 -0
  181. package/dist/src/components/form/fields/input.d.ts +9 -0
  182. package/dist/src/components/form/fields/input.d.ts.map +1 -0
  183. package/dist/src/components/form/fields/input.js +34 -0
  184. package/dist/src/components/form/fields/item.d.ts +14 -0
  185. package/dist/src/components/form/fields/item.d.ts.map +1 -0
  186. package/dist/src/components/form/fields/item.js +22 -0
  187. package/dist/src/components/form/fields/radio-group.d.ts +13 -0
  188. package/dist/src/components/form/fields/radio-group.d.ts.map +1 -0
  189. package/dist/src/components/form/fields/radio-group.js +51 -0
  190. package/dist/src/components/form/fields/select.d.ts +14 -0
  191. package/dist/src/components/form/fields/select.d.ts.map +1 -0
  192. package/dist/src/components/form/fields/select.js +59 -0
  193. package/dist/src/components/form/fields/switch.d.ts +8 -0
  194. package/dist/src/components/form/fields/switch.d.ts.map +1 -0
  195. package/dist/src/components/form/fields/switch.js +35 -0
  196. package/dist/src/components/form/fields/textarea.d.ts +9 -0
  197. package/dist/src/components/form/fields/textarea.d.ts.map +1 -0
  198. package/dist/src/components/form/fields/textarea.js +34 -0
  199. package/dist/src/components/i18n-provider.d.ts +7 -0
  200. package/dist/src/components/i18n-provider.d.ts.map +1 -0
  201. package/dist/src/components/i18n-provider.js +43 -0
  202. package/dist/src/components/logo-vitnode.d.ts +4 -0
  203. package/dist/src/components/logo-vitnode.d.ts.map +1 -0
  204. package/dist/src/components/logo-vitnode.js +113 -0
  205. package/dist/src/components/switchers/theme-switcher.d.ts +2 -0
  206. package/dist/src/components/switchers/theme-switcher.d.ts.map +1 -0
  207. package/dist/src/components/switchers/theme-switcher.js +25 -0
  208. package/dist/src/components/table/content.d.ts +3 -0
  209. package/dist/src/components/table/content.d.ts.map +1 -0
  210. package/dist/src/components/table/content.js +84 -0
  211. package/dist/src/components/table/data-table.d.ts +37 -0
  212. package/dist/src/components/table/data-table.d.ts.map +1 -0
  213. package/dist/src/components/table/data-table.js +69 -0
  214. package/dist/src/components/table/order-table-head.d.ts +7 -0
  215. package/dist/src/components/table/order-table-head.d.ts.map +1 -0
  216. package/dist/src/components/table/order-table-head.js +39 -0
  217. package/dist/src/components/table/pagination.d.ts +11 -0
  218. package/dist/src/components/table/pagination.d.ts.map +1 -0
  219. package/dist/src/components/table/pagination.js +122 -0
  220. package/dist/src/components/ui/accordion.d.ts +8 -0
  221. package/dist/src/components/ui/accordion.d.ts.map +1 -0
  222. package/dist/src/components/ui/accordion.js +47 -0
  223. package/dist/src/components/ui/alert-dialog.d.ts +15 -0
  224. package/dist/src/components/ui/alert-dialog.d.ts.map +1 -0
  225. package/dist/src/components/ui/alert-dialog.js +86 -0
  226. package/dist/src/components/ui/alert.d.ts +10 -0
  227. package/dist/src/components/ui/alert.d.ts.map +1 -0
  228. package/dist/src/components/ui/alert.js +40 -0
  229. package/dist/src/components/ui/badge.d.ts +10 -0
  230. package/dist/src/components/ui/badge.d.ts.map +1 -0
  231. package/dist/src/components/ui/badge.js +29 -0
  232. package/dist/src/components/ui/button.d.ts +13 -0
  233. package/dist/src/components/ui/button.d.ts.map +1 -0
  234. package/dist/src/components/ui/button.js +66 -0
  235. package/dist/src/components/ui/card.d.ts +10 -0
  236. package/dist/src/components/ui/card.d.ts.map +1 -0
  237. package/dist/src/components/ui/card.js +53 -0
  238. package/dist/src/components/ui/checkbox.d.ts +5 -0
  239. package/dist/src/components/ui/checkbox.d.ts.map +1 -0
  240. package/dist/src/components/ui/checkbox.js +21 -0
  241. package/dist/src/components/ui/collapsible.d.ts +6 -0
  242. package/dist/src/components/ui/collapsible.d.ts.map +1 -0
  243. package/dist/src/components/ui/collapsible.js +22 -0
  244. package/dist/src/components/ui/command.d.ts +19 -0
  245. package/dist/src/components/ui/command.d.ts.map +1 -0
  246. package/dist/src/components/ui/command.js +99 -0
  247. package/dist/src/components/ui/context-menu.d.ts +26 -0
  248. package/dist/src/components/ui/context-menu.d.ts.map +1 -0
  249. package/dist/src/components/ui/context-menu.js +141 -0
  250. package/dist/src/components/ui/dialog.d.ts +23 -0
  251. package/dist/src/components/ui/dialog.d.ts.map +1 -0
  252. package/dist/src/components/ui/dialog.js +181 -0
  253. package/dist/src/components/ui/drawer.d.ts +14 -0
  254. package/dist/src/components/ui/drawer.d.ts.map +1 -0
  255. package/dist/src/components/ui/drawer.js +84 -0
  256. package/dist/src/components/ui/dropdown-menu.d.ts +26 -0
  257. package/dist/src/components/ui/dropdown-menu.d.ts.map +1 -0
  258. package/dist/src/components/ui/dropdown-menu.js +142 -0
  259. package/dist/src/components/ui/form.d.ts +33 -0
  260. package/dist/src/components/ui/form.d.ts.map +1 -0
  261. package/dist/src/components/ui/form.js +142 -0
  262. package/dist/src/components/ui/header-content.d.ts +17 -0
  263. package/dist/src/components/ui/header-content.d.ts.map +1 -0
  264. package/dist/src/components/ui/header-content.js +30 -0
  265. package/dist/src/components/ui/hover-card.d.ts +7 -0
  266. package/dist/src/components/ui/hover-card.d.ts.map +1 -0
  267. package/dist/src/components/ui/hover-card.js +30 -0
  268. package/dist/src/components/ui/input-otp.d.ts +12 -0
  269. package/dist/src/components/ui/input-otp.d.ts.map +1 -0
  270. package/dist/src/components/ui/input-otp.js +49 -0
  271. package/dist/src/components/ui/input.d.ts +4 -0
  272. package/dist/src/components/ui/input.d.ts.map +1 -0
  273. package/dist/src/components/ui/input.js +12 -0
  274. package/dist/src/components/ui/label.d.ts +5 -0
  275. package/dist/src/components/ui/label.d.ts.map +1 -0
  276. package/dist/src/components/ui/label.js +13 -0
  277. package/dist/src/components/ui/loader.d.ts +5 -0
  278. package/dist/src/components/ui/loader.d.ts.map +1 -0
  279. package/dist/src/components/ui/loader.js +16 -0
  280. package/dist/src/components/ui/menubar.d.ts +27 -0
  281. package/dist/src/components/ui/menubar.d.ts.map +1 -0
  282. package/dist/src/components/ui/menubar.js +152 -0
  283. package/dist/src/components/ui/navigation-menu.d.ts +15 -0
  284. package/dist/src/components/ui/navigation-menu.d.ts.map +1 -0
  285. package/dist/src/components/ui/navigation-menu.js +83 -0
  286. package/dist/src/components/ui/popover.d.ts +8 -0
  287. package/dist/src/components/ui/popover.d.ts.map +1 -0
  288. package/dist/src/components/ui/popover.js +35 -0
  289. package/dist/src/components/ui/progress.d.ts +5 -0
  290. package/dist/src/components/ui/progress.d.ts.map +1 -0
  291. package/dist/src/components/ui/progress.js +20 -0
  292. package/dist/src/components/ui/radio-group.d.ts +6 -0
  293. package/dist/src/components/ui/radio-group.d.ts.map +1 -0
  294. package/dist/src/components/ui/radio-group.js +28 -0
  295. package/dist/src/components/ui/select.d.ts +16 -0
  296. package/dist/src/components/ui/select.d.ts.map +1 -0
  297. package/dist/src/components/ui/select.js +114 -0
  298. package/dist/src/components/ui/separator.d.ts +5 -0
  299. package/dist/src/components/ui/separator.d.ts.map +1 -0
  300. package/dist/src/components/ui/separator.js +15 -0
  301. package/dist/src/components/ui/sheet.d.ts +14 -0
  302. package/dist/src/components/ui/sheet.d.ts.map +1 -0
  303. package/dist/src/components/ui/sheet.js +93 -0
  304. package/dist/src/components/ui/sidebar.d.ts +70 -0
  305. package/dist/src/components/ui/sidebar.d.ts.map +1 -0
  306. package/dist/src/components/ui/sidebar.js +437 -0
  307. package/dist/src/components/ui/skeleton.d.ts +3 -0
  308. package/dist/src/components/ui/skeleton.d.ts.map +1 -0
  309. package/dist/src/components/ui/skeleton.js +10 -0
  310. package/dist/src/components/ui/slider.d.ts +5 -0
  311. package/dist/src/components/ui/slider.d.ts.map +1 -0
  312. package/dist/src/components/ui/slider.js +42 -0
  313. package/dist/src/components/ui/sonner.d.ts +4 -0
  314. package/dist/src/components/ui/sonner.d.ts.map +1 -0
  315. package/dist/src/components/ui/sonner.js +26 -0
  316. package/dist/src/components/ui/switch.d.ts +5 -0
  317. package/dist/src/components/ui/switch.d.ts.map +1 -0
  318. package/dist/src/components/ui/switch.js +17 -0
  319. package/dist/src/components/ui/table.d.ts +11 -0
  320. package/dist/src/components/ui/table.d.ts.map +1 -0
  321. package/dist/src/components/ui/table.js +64 -0
  322. package/dist/src/components/ui/tabs.d.ts +8 -0
  323. package/dist/src/components/ui/tabs.d.ts.map +1 -0
  324. package/dist/src/components/ui/tabs.js +34 -0
  325. package/dist/src/components/ui/textarea.d.ts +4 -0
  326. package/dist/src/components/ui/textarea.d.ts.map +1 -0
  327. package/dist/src/components/ui/textarea.js +11 -0
  328. package/dist/src/components/ui/toggle-group.d.ts +8 -0
  329. package/dist/src/components/ui/toggle-group.d.ts.map +1 -0
  330. package/dist/src/components/ui/toggle-group.js +41 -0
  331. package/dist/src/components/ui/toggle.d.ts +10 -0
  332. package/dist/src/components/ui/toggle.d.ts.map +1 -0
  333. package/dist/src/components/ui/toggle.js +35 -0
  334. package/dist/src/components/ui/tooltip.d.ts +8 -0
  335. package/dist/src/components/ui/tooltip.d.ts.map +1 -0
  336. package/dist/src/components/ui/tooltip.js +43 -0
  337. package/dist/src/components/ui/unsaved-changes-dialog.d.ts +1 -0
  338. package/dist/src/components/ui/unsaved-changes-dialog.d.ts.map +1 -0
  339. package/dist/src/config.d.ts +5 -0
  340. package/dist/src/config.d.ts.map +1 -0
  341. package/dist/src/config.js +4 -0
  342. package/dist/src/database/admins.d.ts +246 -0
  343. package/dist/src/database/admins.d.ts.map +1 -0
  344. package/dist/src/database/admins.js +74 -0
  345. package/dist/src/database/languages.d.ts +321 -0
  346. package/dist/src/database/languages.d.ts.map +1 -0
  347. package/dist/src/database/languages.js +52 -0
  348. package/dist/src/database/moderators.d.ts +114 -0
  349. package/dist/src/database/moderators.d.ts.map +1 -0
  350. package/dist/src/database/moderators.js +37 -0
  351. package/dist/src/database/roles.d.ts +146 -0
  352. package/dist/src/database/roles.d.ts.map +1 -0
  353. package/dist/src/database/roles.js +13 -0
  354. package/dist/src/database/sessions.d.ts +196 -0
  355. package/dist/src/database/sessions.d.ts.map +1 -0
  356. package/dist/src/database/sessions.js +57 -0
  357. package/dist/src/database/users.d.ts +562 -0
  358. package/dist/src/database/users.d.ts.map +1 -0
  359. package/dist/src/database/users.js +142 -0
  360. package/dist/src/drizzle.config.d.ts +6 -0
  361. package/dist/src/drizzle.config.d.ts.map +1 -0
  362. package/dist/src/drizzle.config.js +37 -0
  363. package/dist/src/hooks/use-before-unload-with-dialog.d.ts +1 -0
  364. package/dist/src/hooks/use-before-unload-with-dialog.d.ts.map +1 -0
  365. package/dist/src/hooks/use-before-unload.d.ts +2 -0
  366. package/dist/src/hooks/use-before-unload.d.ts.map +1 -0
  367. package/dist/src/hooks/use-before-unload.js +30 -0
  368. package/dist/src/hooks/use-mobile.d.ts +2 -0
  369. package/dist/src/hooks/use-mobile.d.ts.map +1 -0
  370. package/dist/src/hooks/use-mobile.js +15 -0
  371. package/dist/src/hooks/use-unsaved-changes.d.ts +1 -0
  372. package/dist/src/hooks/use-unsaved-changes.d.ts.map +1 -0
  373. package/dist/src/lib/api/get-middleware-api.d.ts +8 -0
  374. package/dist/src/lib/api/get-middleware-api.d.ts.map +1 -0
  375. package/dist/src/lib/api/get-middleware-api.js +13 -0
  376. package/dist/src/lib/api/get-session-admin-api.d.ts +16 -0
  377. package/dist/src/lib/api/get-session-admin-api.d.ts.map +1 -0
  378. package/dist/src/lib/api/get-session-admin-api.js +19 -0
  379. package/dist/src/lib/api/get-session-api.d.ts +17 -0
  380. package/dist/src/lib/api/get-session-api.d.ts.map +1 -0
  381. package/dist/src/lib/api/get-session-api.js +14 -0
  382. package/dist/src/lib/colors.d.ts +23 -0
  383. package/dist/src/lib/colors.d.ts.map +1 -0
  384. package/dist/src/lib/colors.js +131 -0
  385. package/dist/src/lib/colors.test.d.ts +2 -0
  386. package/dist/src/lib/colors.test.d.ts.map +1 -0
  387. package/dist/src/lib/colors.test.js +173 -0
  388. package/dist/src/lib/config.d.ts +6 -0
  389. package/dist/src/lib/config.d.ts.map +1 -0
  390. package/dist/src/lib/config.js +15 -0
  391. package/dist/src/lib/fetcher/cookie-from-string-to-object.d.ts +10 -0
  392. package/dist/src/lib/fetcher/cookie-from-string-to-object.d.ts.map +1 -0
  393. package/dist/src/lib/fetcher/cookie-from-string-to-object.js +12 -0
  394. package/dist/src/lib/fetcher/cookie-from-string-to-object.test.d.ts +2 -0
  395. package/dist/src/lib/fetcher/cookie-from-string-to-object.test.d.ts.map +1 -0
  396. package/dist/src/lib/fetcher/cookie-from-string-to-object.test.js +78 -0
  397. package/dist/src/lib/fetcher/fetcher.d.ts +9 -0
  398. package/dist/src/lib/fetcher/fetcher.d.ts.map +1 -0
  399. package/dist/src/lib/fetcher/helpers.d.ts +3 -0
  400. package/dist/src/lib/fetcher/helpers.d.ts.map +1 -0
  401. package/dist/src/lib/fetcher/helpers.js +33 -0
  402. package/dist/src/lib/fetcher/helpers.test.d.ts +2 -0
  403. package/dist/src/lib/fetcher/helpers.test.d.ts.map +1 -0
  404. package/dist/src/lib/fetcher/helpers.test.js +37 -0
  405. package/dist/src/lib/fetcher/index.d.ts +34 -0
  406. package/dist/src/lib/fetcher/index.d.ts.map +1 -0
  407. package/dist/src/lib/fetcher/types.d.ts +120 -0
  408. package/dist/src/lib/fetcher/types.d.ts.map +1 -0
  409. package/dist/src/lib/fetcher/types.js +1 -0
  410. package/dist/src/lib/fetcher.d.ts +9 -0
  411. package/dist/src/lib/fetcher.d.ts.map +1 -0
  412. package/dist/src/lib/fetcher.js +47 -0
  413. package/dist/src/lib/helpers/auto-form.d.ts +10 -0
  414. package/dist/src/lib/helpers/auto-form.d.ts.map +1 -0
  415. package/dist/src/lib/helpers/auto-form.js +82 -0
  416. package/dist/src/lib/helpers/auto-form.test.d.ts +2 -0
  417. package/dist/src/lib/helpers/auto-form.test.d.ts.map +1 -0
  418. package/dist/src/lib/helpers/auto-form.test.js +126 -0
  419. package/dist/src/lib/navigation.d.ts +339 -0
  420. package/dist/src/lib/navigation.d.ts.map +1 -0
  421. package/dist/src/lib/navigation.js +11 -0
  422. package/dist/src/lib/plugin.d.ts +15 -0
  423. package/dist/src/lib/plugin.d.ts.map +1 -0
  424. package/dist/src/lib/plugin.js +3 -0
  425. package/dist/src/lib/special-characters.d.ts +3 -0
  426. package/dist/src/lib/special-characters.d.ts.map +1 -0
  427. package/dist/src/lib/special-characters.js +4 -0
  428. package/dist/src/lib/special-characters.test.d.ts +2 -0
  429. package/dist/src/lib/special-characters.test.d.ts.map +1 -0
  430. package/dist/src/lib/special-characters.test.js +56 -0
  431. package/dist/src/lib/utils.d.ts +3 -0
  432. package/dist/src/lib/utils.d.ts.map +1 -0
  433. package/dist/src/lib/utils.js +5 -0
  434. package/dist/src/tests/setup.d.ts +2 -0
  435. package/dist/src/tests/setup.d.ts.map +1 -0
  436. package/dist/src/tests/setup.js +6 -0
  437. package/dist/src/views/admin/layouts/admin-layout.d.ts +8 -0
  438. package/dist/src/views/admin/layouts/admin-layout.d.ts.map +1 -0
  439. package/dist/src/views/admin/layouts/admin-layout.js +70 -0
  440. package/dist/src/views/admin/layouts/sidebar/nav/item.d.ts +11 -0
  441. package/dist/src/views/admin/layouts/sidebar/nav/item.d.ts.map +1 -0
  442. package/dist/src/views/admin/layouts/sidebar/nav/item.js +70 -0
  443. package/dist/src/views/admin/layouts/sidebar/nav/nav.d.ts +10 -0
  444. package/dist/src/views/admin/layouts/sidebar/nav/nav.d.ts.map +1 -0
  445. package/dist/src/views/admin/layouts/sidebar/nav/nav.js +49 -0
  446. package/dist/src/views/admin/layouts/sidebar/sidebar.d.ts +3 -0
  447. package/dist/src/views/admin/layouts/sidebar/sidebar.d.ts.map +1 -0
  448. package/dist/src/views/admin/layouts/sidebar/sidebar.js +30 -0
  449. package/dist/src/views/admin/layouts/sidebar/sign-out.d.ts +4 -0
  450. package/dist/src/views/admin/layouts/sidebar/sign-out.d.ts.map +1 -0
  451. package/dist/src/views/admin/layouts/sidebar/sign-out.js +14 -0
  452. package/dist/src/views/admin/layouts/user-bar/client.d.ts +7 -0
  453. package/dist/src/views/admin/layouts/user-bar/client.d.ts.map +1 -0
  454. package/dist/src/views/admin/layouts/user-bar/client.js +61 -0
  455. package/dist/src/views/admin/layouts/user-bar/user-bar.d.ts +3 -0
  456. package/dist/src/views/admin/layouts/user-bar/user-bar.d.ts.map +1 -0
  457. package/dist/src/views/admin/layouts/user-bar/user-bar.js +31 -0
  458. package/dist/src/views/admin/sign-in/sign-in-admin-view.d.ts +2 -0
  459. package/dist/src/views/admin/sign-in/sign-in-admin-view.d.ts.map +1 -0
  460. package/dist/src/views/admin/sign-in/sign-in-admin-view.js +26 -0
  461. package/dist/src/views/admin/views/core/dashboard/dashboard-admin-view.d.ts +2 -0
  462. package/dist/src/views/admin/views/core/dashboard/dashboard-admin-view.d.ts.map +1 -0
  463. package/dist/src/views/admin/views/core/dashboard/dashboard-admin-view.js +44 -0
  464. package/dist/src/views/admin/views/core/test.d.ts +2 -0
  465. package/dist/src/views/admin/views/core/test.d.ts.map +1 -0
  466. package/dist/src/views/admin/views/core/test.js +146 -0
  467. package/dist/src/views/admin/views/core/users/users-admin-view.d.ts +4 -0
  468. package/dist/src/views/admin/views/core/users/users-admin-view.d.ts.map +1 -0
  469. package/dist/src/views/admin/views/core/users/users-admin-view.js +90 -0
  470. package/dist/src/views/auth/components/password-input.d.ts +4 -0
  471. package/dist/src/views/auth/components/password-input.d.ts.map +1 -0
  472. package/dist/src/views/auth/components/password-input.js +89 -0
  473. package/dist/src/views/auth/sign-in/form/form.d.ts +4 -0
  474. package/dist/src/views/auth/sign-in/form/form.d.ts.map +1 -0
  475. package/dist/src/views/auth/sign-in/form/form.js +59 -0
  476. package/dist/src/views/auth/sign-in/form/hooks/mutation-api.d.ts +10 -0
  477. package/dist/src/views/auth/sign-in/form/hooks/mutation-api.d.ts.map +1 -0
  478. package/dist/src/views/auth/sign-in/form/hooks/mutation-api.js +33 -0
  479. package/dist/src/views/auth/sign-in/form/hooks/use-form.d.ts +27 -0
  480. package/dist/src/views/auth/sign-in/form/hooks/use-form.d.ts.map +1 -0
  481. package/dist/src/views/auth/sign-in/form/hooks/use-form.js +38 -0
  482. package/dist/src/views/auth/sign-in/sign-in-view.d.ts +2 -0
  483. package/dist/src/views/auth/sign-in/sign-in-view.d.ts.map +1 -0
  484. package/dist/src/views/auth/sign-in/sign-in-view.js +55 -0
  485. package/dist/src/views/auth/sign-up/form/form.d.ts +4 -0
  486. package/dist/src/views/auth/sign-up/form/form.d.ts.map +1 -0
  487. package/dist/src/views/auth/sign-up/form/form.js +88 -0
  488. package/dist/src/views/auth/sign-up/form/hooks/mutation-api.d.ts +6 -0
  489. package/dist/src/views/auth/sign-up/form/hooks/mutation-api.d.ts.map +1 -0
  490. package/dist/src/views/auth/sign-up/form/hooks/mutation-api.js +18 -0
  491. package/dist/src/views/auth/sign-up/form/hooks/use-form.d.ts +61 -0
  492. package/dist/src/views/auth/sign-up/form/hooks/use-form.d.ts.map +1 -0
  493. package/dist/src/views/auth/sign-up/form/hooks/use-form.js +57 -0
  494. package/dist/src/views/auth/sign-up/sign-up-view.d.ts +2 -0
  495. package/dist/src/views/auth/sign-up/sign-up-view.d.ts.map +1 -0
  496. package/dist/src/views/auth/sign-up/sign-up-view.js +61 -0
  497. package/dist/src/views/auth/sso/buttons/client.d.ts +5 -0
  498. package/dist/src/views/auth/sso/buttons/client.d.ts.map +1 -0
  499. package/dist/src/views/auth/sso/buttons/client.js +22 -0
  500. package/dist/src/views/auth/sso/buttons/mutation-api.d.ts +4 -0
  501. package/dist/src/views/auth/sso/buttons/mutation-api.d.ts.map +1 -0
  502. package/dist/src/views/auth/sso/buttons/mutation-api.js +24 -0
  503. package/dist/src/views/auth/sso/buttons/sso-buttons.d.ts +3 -0
  504. package/dist/src/views/auth/sso/buttons/sso-buttons.d.ts.map +1 -0
  505. package/dist/src/views/auth/sso/buttons/sso-buttons.js +51 -0
  506. package/dist/src/views/auth/sso/callback/callback-sso-view.d.ts +5 -0
  507. package/dist/src/views/auth/sso/callback/callback-sso-view.d.ts.map +1 -0
  508. package/dist/src/views/auth/sso/callback/callback-sso-view.js +18 -0
  509. package/dist/src/views/auth/sso/callback/client/client.d.ts +6 -0
  510. package/dist/src/views/auth/sso/callback/client/client.d.ts.map +1 -0
  511. package/dist/src/views/auth/sso/callback/client/client.js +39 -0
  512. package/dist/src/views/auth/sso/callback/client/mutation-api.d.ts +8 -0
  513. package/dist/src/views/auth/sso/callback/client/mutation-api.d.ts.map +1 -0
  514. package/dist/src/views/auth/sso/callback/client/mutation-api.js +27 -0
  515. package/dist/src/views/error/back-button.d.ts +5 -0
  516. package/dist/src/views/error/back-button.d.ts.map +1 -0
  517. package/dist/src/views/error/back-button.js +14 -0
  518. package/dist/src/views/error/error-view.d.ts +5 -0
  519. package/dist/src/views/error/error-view.d.ts.map +1 -0
  520. package/dist/src/views/error/error-view.js +56 -0
  521. package/dist/src/views/error/global-error-view.d.ts +6 -0
  522. package/dist/src/views/error/global-error-view.d.ts.map +1 -0
  523. package/dist/src/views/error/global-error-view.js +57 -0
  524. package/dist/src/views/layouts/provider.d.ts +11 -0
  525. package/dist/src/views/layouts/provider.d.ts.map +1 -0
  526. package/dist/src/views/layouts/provider.js +43 -0
  527. package/dist/src/views/layouts/root-layout.d.ts +16 -0
  528. package/dist/src/views/layouts/root-layout.d.ts.map +1 -0
  529. package/dist/src/views/layouts/root-layout.js +38 -0
  530. package/dist/src/views/layouts/theme/header/header.d.ts +4 -0
  531. package/dist/src/views/layouts/theme/header/header.d.ts.map +1 -0
  532. package/dist/src/views/layouts/theme/header/header.js +32 -0
  533. package/dist/src/views/layouts/theme/header/user/auth/auth.d.ts +2 -0
  534. package/dist/src/views/layouts/theme/header/user/auth/auth.d.ts.map +1 -0
  535. package/dist/src/views/layouts/theme/header/user/auth/auth.js +33 -0
  536. package/dist/src/views/layouts/theme/header/user/auth/client.d.ts +5 -0
  537. package/dist/src/views/layouts/theme/header/user/auth/client.d.ts.map +1 -0
  538. package/dist/src/views/layouts/theme/header/user/auth/client.js +47 -0
  539. package/dist/src/views/layouts/theme/header/user/auth/log-out-mutation-api.d.ts +4 -0
  540. package/dist/src/views/layouts/theme/header/user/auth/log-out-mutation-api.d.ts.map +1 -0
  541. package/dist/src/views/layouts/theme/header/user/auth/log-out-mutation-api.js +27 -0
  542. package/dist/src/views/layouts/theme/header/user/user.d.ts +2 -0
  543. package/dist/src/views/layouts/theme/header/user/user.d.ts.map +1 -0
  544. package/dist/src/views/layouts/theme/header/user/user.js +34 -0
  545. package/dist/src/views/layouts/theme/layout.d.ts +5 -0
  546. package/dist/src/views/layouts/theme/layout.d.ts.map +1 -0
  547. package/dist/src/views/layouts/theme/layout.js +15 -0
  548. package/dist/src/vitnode.config.d.ts +50 -0
  549. package/dist/src/vitnode.config.d.ts.map +1 -0
  550. package/dist/src/vitnode.config.js +39 -0
  551. package/dist/tsconfig.tsbuildinfo +1 -0
  552. package/dist/tsup.config.d.ts +3 -0
  553. package/dist/tsup.config.d.ts.map +1 -0
  554. package/dist/vitest.config.d.ts +3 -0
  555. package/dist/vitest.config.d.ts.map +1 -0
  556. package/package.json +94 -0
  557. package/src/app/login/page.tsx +21 -0
  558. package/src/app/login/sso/[providerId]/page.tsx +19 -0
  559. package/src/app/register/page.tsx +21 -0
  560. package/src/app_admin/core/page.tsx +5 -0
  561. package/src/app_admin/core/test/page.tsx +5 -0
  562. package/src/app_admin/core/users/page.tsx +35 -0
  563. package/src/database/admins.ts +87 -0
  564. package/src/database/languages.ts +54 -0
  565. package/src/database/moderators.ts +42 -0
  566. package/src/database/roles.ts +15 -0
  567. package/src/database/sessions.ts +59 -0
  568. package/src/database/users.ts +142 -0
  569. package/src/locales/en.json +156 -0
@@ -0,0 +1,78 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { cookieFromStringToObject } from "./cookie-from-string-to-object";
3
+ describe('cookieFromStringToObject', ()=>{
4
+ it('should parse a simple cookie string', ()=>{
5
+ const cookies = [
6
+ 'token=abc123; Path=/; HttpOnly'
7
+ ];
8
+ const result = cookieFromStringToObject(cookies);
9
+ expect(result).toEqual([
10
+ {
11
+ token: 'abc123',
12
+ Path: '/',
13
+ HttpOnly: true
14
+ }
15
+ ]);
16
+ });
17
+ it('should parse multiple cookie attributes', ()=>{
18
+ const cookies = [
19
+ 'sessionId=xyz789; Domain=example.com; Path=/; HttpOnly; Secure; SameSite=strict; Expires=Wed, 21 Oct 2025 07:28:00 GMT'
20
+ ];
21
+ const result = cookieFromStringToObject(cookies);
22
+ expect(result).toEqual([
23
+ {
24
+ sessionId: 'xyz789',
25
+ Domain: 'example.com',
26
+ Path: '/',
27
+ HttpOnly: true,
28
+ Secure: true,
29
+ SameSite: 'strict',
30
+ Expires: 'Wed, 21 Oct 2025 07:28:00 GMT'
31
+ }
32
+ ]);
33
+ });
34
+ it('should handle multiple cookies', ()=>{
35
+ const cookies = [
36
+ 'token=abc123; Path=/; HttpOnly',
37
+ 'theme=dark; Path=/; SameSite=lax'
38
+ ];
39
+ const result = cookieFromStringToObject(cookies);
40
+ expect(result).toEqual([
41
+ {
42
+ token: 'abc123',
43
+ Path: '/',
44
+ HttpOnly: true
45
+ },
46
+ {
47
+ theme: 'dark',
48
+ Path: '/',
49
+ SameSite: 'lax'
50
+ }
51
+ ]);
52
+ });
53
+ it('should handle URL encoded values', ()=>{
54
+ const cookies = [
55
+ 'data=hello%20world; Path=/'
56
+ ];
57
+ const result = cookieFromStringToObject(cookies);
58
+ expect(result).toEqual([
59
+ {
60
+ data: 'hello world',
61
+ Path: '/'
62
+ }
63
+ ]);
64
+ });
65
+ it('should handle boolean flags without values', ()=>{
66
+ const cookies = [
67
+ 'token=123; HttpOnly; Secure'
68
+ ];
69
+ const result = cookieFromStringToObject(cookies);
70
+ expect(result).toEqual([
71
+ {
72
+ token: '123',
73
+ HttpOnly: true,
74
+ Secure: true
75
+ }
76
+ ]);
77
+ });
78
+ });
@@ -0,0 +1,9 @@
1
+ import type { BaseBuildModuleReturn, BuildModuleReturn } from '../api/lib/module';
2
+ import type { Route } from '../api/lib/route';
3
+ import type { FetcherParams, GetModulePaths, GetValidPathsForModule, InferResponseType } from './fetcher/types
4
+ export declare function fetcher<M extends string, Routes extends Route[], Modules extends BaseBuildModuleReturn[], ModuleName extends GetModulePaths<M, Modules>, SelectedPath extends GetValidPathsForModule<ModuleName, M, Routes, Modules>>({ pluginId }: BuildModuleReturn<string, M, Routes, Modules>, { path, method, module, args, options, allowSaveCookies, withPagination, }: FetcherParams<M, Routes, Modules, ModuleName, SelectedPath> & {
5
+ allowSaveCookies?: boolean;
6
+ options?: Omit<RequestInit, 'body'>;
7
+ withPagination?: boolean;
8
+ }): Promise<InferResponseType<M, Routes, Modules, ModuleName, SelectedPath>>;
9
+ //# sourceMappingURL=fetcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../../../../src/lib/fetcher/fetcher.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAKjB,wBAAsB,OAAO,CAC3B,CAAC,SAAS,MAAM,EAChB,MAAM,SAAS,KAAK,EAAE,EACtB,OAAO,SAAS,qBAAqB,EAAE,EACvC,UAAU,SAAS,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC,EAC7C,YAAY,SAAS,sBAAsB,CAAC,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAE3E,EAAE,QAAQ,EAAE,EAAE,iBAAiB,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAC3D,EACE,IAAI,EACJ,MAAM,EACN,MAAM,EACN,IAAI,EACJ,OAAO,EACP,gBAAwB,EACxB,cAAsB,GACvB,EAAE,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,CAAC,GAAG;IAC/D,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACpC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,GACA,OAAO,CAAC,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,CA+D1E"}
@@ -0,0 +1,3 @@
1
+ export declare const handleSetCookiesFetcher: (res: Response) => Promise<void>;
2
+ export declare const buildSearchParams: (query: Record<string, string | string[]>) => URLSearchParams;
3
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/lib/fetcher/helpers.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,uBAAuB,GAAU,KAAK,QAAQ,kBAkB1D,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,oBAkBzE,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { cookies } from "next/headers";
2
+ import { cookieFromStringToObject } from "./cookie-from-string-to-object";
3
+ export const handleSetCookiesFetcher = async (res)=>{
4
+ await Promise.all(cookieFromStringToObject(res.headers.getSetCookie()).map(async (cookie)=>{
5
+ const key = Object.keys(cookie)[0];
6
+ const value = Object.values(cookie)[0];
7
+ if (typeof value !== 'string' || typeof key !== 'string') return;
8
+ (await cookies()).set(key, value, {
9
+ domain: cookie.Domain,
10
+ path: cookie.Path,
11
+ expires: new Date(cookie.Expires),
12
+ secure: cookie.Secure,
13
+ httpOnly: cookie.HttpOnly,
14
+ sameSite: cookie.SameSite
15
+ });
16
+ }));
17
+ };
18
+ export const buildSearchParams = (query)=>{
19
+ const searchParams = new URLSearchParams();
20
+ for (const [k, v] of Object.entries(query)){
21
+ if (v === undefined) {
22
+ continue;
23
+ }
24
+ if (Array.isArray(v)) {
25
+ for (const v2 of v){
26
+ searchParams.append(k, v2);
27
+ }
28
+ } else {
29
+ searchParams.set(k, v);
30
+ }
31
+ }
32
+ return searchParams;
33
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=helpers.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.test.d.ts","sourceRoot":"","sources":["../../../../src/lib/fetcher/helpers.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,37 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { buildSearchParams } from "./helpers";
3
+ describe('buildSearchParams', ()=>{
4
+ it('should handle empty query object', ()=>{
5
+ const params = buildSearchParams({});
6
+ expect(params.toString()).toBe('');
7
+ });
8
+ it('should handle single string values', ()=>{
9
+ const params = buildSearchParams({
10
+ key: 'value'
11
+ });
12
+ expect(params.toString()).toBe('key=value');
13
+ });
14
+ it('should handle multiple string values', ()=>{
15
+ const params = buildSearchParams({
16
+ key1: 'value1',
17
+ key2: 'value2'
18
+ });
19
+ expect(params.toString()).toBe('key1=value1&key2=value2');
20
+ });
21
+ it('should handle array values', ()=>{
22
+ const params = buildSearchParams({
23
+ key: [
24
+ 'value1',
25
+ 'value2'
26
+ ]
27
+ });
28
+ expect(params.toString()).toBe('key=value1&key=value2');
29
+ });
30
+ it('should skip undefined values', ()=>{
31
+ const params = buildSearchParams({
32
+ key1: 'value1',
33
+ key2: undefined
34
+ });
35
+ expect(params.toString()).toBe('key1=value1');
36
+ });
37
+ });
@@ -0,0 +1,34 @@
1
+ import type {
2
+ BaseBuildModuleReturn,
3
+ BuildModuleReturn,
4
+ } from '../../api/lib/module';
5
+ import type { Route } from '../../api/lib/route';
6
+ import type {
7
+ FetcherParams,
8
+ GetModulePaths,
9
+ GetValidPathsForModule,
10
+ InferResponseType,
11
+ } from './types';
12
+ export declare function fetcher<
13
+ M extends string,
14
+ Routes extends Route[],
15
+ Modules extends BaseBuildModuleReturn[],
16
+ ModuleName extends GetModulePaths<M, Modules>,
17
+ SelectedPath extends GetValidPathsForModule<ModuleName, M, Routes, Modules>,
18
+ >(
19
+ { pluginId }: BuildModuleReturn<string, M, Routes, Modules>,
20
+ {
21
+ path,
22
+ method,
23
+ module,
24
+ args,
25
+ options,
26
+ allowSaveCookies,
27
+ withPagination,
28
+ }: FetcherParams<M, Routes, Modules, ModuleName, SelectedPath> & {
29
+ allowSaveCookies?: boolean;
30
+ options?: Omit<RequestInit, 'body'>;
31
+ withPagination?: boolean;
32
+ },
33
+ ): Promise<InferResponseType<M, Routes, Modules, ModuleName, SelectedPath>>;
34
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/fetcher/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAK1B,wBAAsB,OAAO,CAC3B,CAAC,SAAS,MAAM,EAChB,MAAM,SAAS,KAAK,EAAE,EACtB,OAAO,SAAS,qBAAqB,EAAE,EACvC,UAAU,SAAS,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC,EAC7C,YAAY,SAAS,sBAAsB,CAAC,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAE3E,EAAE,QAAQ,EAAE,EAAE,iBAAiB,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAC3D,EACE,IAAI,EACJ,MAAM,EACN,MAAM,EACN,IAAI,EACJ,OAAO,EACP,gBAAwB,EACxB,cAAsB,GACvB,EAAE,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,CAAC,GAAG;IAC/D,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACpC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,GACA,OAAO,CAAC,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,CA+D1E"}
@@ -0,0 +1,120 @@
1
+ import type { RouteConfig } from '@hono/zod-openapi';
2
+ import type { ResponseFormat } from 'hono/types';
3
+ import type { StatusCode, SuccessStatusCode } from 'hono/utils/http-status';
4
+ import type { z } from 'zod';
5
+ import type { BaseBuildModuleReturn } from '../../api/lib/module';
6
+ import type { Route } from '../../api/lib/route';
7
+ interface ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = ResponseFormat> extends globalThis.Response {
8
+ arrayBuffer: () => Promise<ArrayBuffer>;
9
+ blob: () => Promise<Blob>;
10
+ readonly body: null | ReadableStream;
11
+ readonly bodyUsed: boolean;
12
+ clone: () => Response;
13
+ formData: () => Promise<FormData>;
14
+ headers: Headers;
15
+ json: () => F extends 'text/html' | 'text/plain' ? Promise<never> : F extends 'application/json' ? Promise<T> : Promise<unknown>;
16
+ ok: U extends SuccessStatusCode ? true : U extends Exclude<StatusCode, SuccessStatusCode> ? false : boolean;
17
+ redirect: (url: string, status: number) => Response;
18
+ status: U;
19
+ statusText: string;
20
+ text: () => F extends 'text/html' | 'text/plain' ? T extends string ? Promise<T> : Promise<never> : Promise<string>;
21
+ url: string;
22
+ }
23
+ interface RouteShape {
24
+ readonly route: {
25
+ readonly method: string;
26
+ readonly path: string;
27
+ };
28
+ }
29
+ interface ModuleSpec {
30
+ readonly modules?: readonly ModuleSpec[];
31
+ readonly name: string;
32
+ readonly routes: readonly RouteShape[];
33
+ }
34
+ type SplitPath<S extends string> = S extends `${infer First}/${infer Rest}` ? [First, ...SplitPath<Rest>] : S extends '' ? [] : [S];
35
+ type FindModuleNested<M extends {
36
+ modules?: readonly ModuleSpec[];
37
+ }, Path extends string[]> = Path extends [infer First extends string, ...infer Rest extends string[]] ? Extract<M['modules'], readonly ModuleSpec[]>[number] extends infer SubModule ? SubModule extends ModuleSpec & {
38
+ name: First;
39
+ } ? Rest['length'] extends 0 ? SubModule : FindModuleNested<SubModule, Rest> : never : never : M;
40
+ export type GetModulePaths<MainModule extends string, Modules extends readonly ModuleSpec[]> = `${MainModule}/${Modules[number]['name']}/${Extract<Modules[number]['modules'], readonly ModuleSpec[]>[number]['name']}` | `${MainModule}/${Modules[number]['name']}` | MainModule;
41
+ type GetTargetModule<ModulePath extends string, MainModuleName extends string, MainRoutes extends readonly RouteShape[], SubModules extends readonly ModuleSpec[]> = ModulePath extends MainModuleName ? {
42
+ modules: SubModules;
43
+ name: MainModuleName;
44
+ routes: MainRoutes;
45
+ } : ModulePath extends `${MainModuleName}/${infer Rest}` ? SplitPath<Rest> extends infer PathArray extends string[] ? PathArray['length'] extends 0 ? never : FindModuleNested<{
46
+ modules: SubModules;
47
+ }, PathArray> : never : never;
48
+ type ExtractPaths<M extends {
49
+ routes: readonly RouteShape[];
50
+ }> = M['routes'][number]['route']['path'];
51
+ type ExtractMethodForPath<M extends {
52
+ routes: readonly RouteShape[];
53
+ }, P extends string> = Extract<M['routes'][number], {
54
+ route: {
55
+ path: P;
56
+ };
57
+ }>['route']['method'];
58
+ type ExtractZodType<T> = T extends z.ZodType ? z.infer<T> : never;
59
+ type InferInputType<RouteCfg extends RouteConfig, Part extends 'body' | 'params' | 'query'> = Part extends 'body' ? RouteCfg extends {
60
+ request: {
61
+ body: {
62
+ content: {
63
+ 'application/json': {
64
+ schema: infer S;
65
+ };
66
+ };
67
+ };
68
+ };
69
+ } ? ExtractZodType<S> : RouteCfg extends {
70
+ request: {
71
+ body: {
72
+ schema?: infer S;
73
+ };
74
+ };
75
+ } ? ExtractZodType<S> : undefined : Part extends 'query' ? RouteCfg extends {
76
+ request: {
77
+ query: infer S;
78
+ };
79
+ } ? ExtractZodType<S> : undefined : Part extends 'params' ? RouteCfg extends {
80
+ request: {
81
+ params: infer S;
82
+ };
83
+ } ? ExtractZodType<S> : undefined : never;
84
+ type FindRouteConfig<M extends {
85
+ routes: readonly Route[];
86
+ }, P extends string, Method extends string> = Extract<M['routes'][number], {
87
+ route: {
88
+ method: Method;
89
+ path: P;
90
+ };
91
+ }>['route'];
92
+ type BuildArgsType<RouteCfg extends RouteConfig> = {
93
+ [K in 'body' | 'params' | 'query' as InferInputType<RouteCfg, K> extends undefined ? never : K]: InferInputType<RouteCfg, K>;
94
+ };
95
+ export type GetValidPathsForModule<ModulePath extends string, MainModuleName extends string, MainRoutes extends readonly RouteShape[], SubModules extends readonly ModuleSpec[]> = ExtractPaths<GetTargetModule<ModulePath, MainModuleName, MainRoutes, SubModules>>;
96
+ export type GetValidMethodForPath<ModulePath extends string, Path extends string, MainModuleName extends string, MainRoutes extends readonly RouteShape[], SubModules extends readonly ModuleSpec[]> = Lowercase<Extract<ExtractMethodForPath<GetTargetModule<ModulePath, MainModuleName, MainRoutes, SubModules>, Path>, string>>;
97
+ interface BaseFetcherParams<M extends string, Routes extends Route[], Modules extends BaseBuildModuleReturn[], ModuleName extends GetModulePaths<M, Modules>, SelectedPath extends GetValidPathsForModule<ModuleName, M, Routes, Modules>, Method extends string> {
98
+ method: Method;
99
+ module: ModuleName;
100
+ path: SelectedPath;
101
+ }
102
+ export type FetcherParams<M extends string, Routes extends Route[], Modules extends BaseBuildModuleReturn[], ModuleName extends GetModulePaths<M, Modules>, SelectedPath extends GetValidPathsForModule<ModuleName, M, Routes, Modules>, Method extends GetValidMethodForPath<ModuleName, SelectedPath, M, Routes, Modules> = GetValidMethodForPath<ModuleName, SelectedPath, M, Routes, Modules>, RouteConfig extends FindRouteConfig<GetTargetModule<ModuleName, M, Routes, Modules>, SelectedPath, Method> = FindRouteConfig<GetTargetModule<ModuleName, M, Routes, Modules>, SelectedPath, Method>, ArgsType extends BuildArgsType<RouteConfig> = BuildArgsType<RouteConfig>> = BaseFetcherParams<M, Routes, Modules, ModuleName, SelectedPath, Method> & (keyof ArgsType extends never ? {
103
+ args?: undefined;
104
+ } : {
105
+ args: ArgsType;
106
+ });
107
+ type InferStatusCode<K> = K extends `${infer N extends number}` ? N : K extends number ? K : never;
108
+ export type InferResponseType<M extends string, Routes extends Route[], Modules extends BaseBuildModuleReturn[], ModuleName extends GetModulePaths<M, Modules>, SelectedPath extends GetValidPathsForModule<ModuleName, M, Routes, Modules>, Method extends GetValidMethodForPath<ModuleName, SelectedPath, M, Routes, Modules> = GetValidMethodForPath<ModuleName, SelectedPath, M, Routes, Modules>, RouteConfig extends FindRouteConfig<GetTargetModule<ModuleName, M, Routes, Modules>, SelectedPath, Method> = FindRouteConfig<GetTargetModule<ModuleName, M, Routes, Modules>, SelectedPath, Method>> = RouteConfig extends {
109
+ responses: infer S;
110
+ } ? {
111
+ [K in keyof S]: S[K] extends infer Response ? Response extends {
112
+ content: infer C;
113
+ } ? {
114
+ [Fmt in keyof C]: ClientResponse<C[Fmt] extends {
115
+ schema: infer S;
116
+ } ? ExtractZodType<S> : never, InferStatusCode<K>, Fmt extends string ? Fmt : string>;
117
+ }[keyof C] : ClientResponse<object, InferStatusCode<K>> : never;
118
+ }[keyof S] : never;
119
+ export {};
120
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/fetcher/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7C,UAAU,cAAc,CACtB,CAAC,EACD,CAAC,SAAS,MAAM,GAAG,UAAU,EAC7B,CAAC,SAAS,cAAc,GAAG,cAAc,CACzC,SAAQ,UAAU,CAAC,QAAQ;IAC3B,WAAW,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IACxC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,cAAc,CAAC;IACrC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,KAAK,EAAE,MAAM,QAAQ,CAAC;IACtB,QAAQ,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC,SAAS,WAAW,GAAG,YAAY,GAC5C,OAAO,CAAC,KAAK,CAAC,GACd,CAAC,SAAS,kBAAkB,GAC1B,OAAO,CAAC,CAAC,CAAC,GACV,OAAO,CAAC,OAAO,CAAC,CAAC;IACvB,EAAE,EAAE,CAAC,SAAS,iBAAiB,GAC3B,IAAI,GACJ,CAAC,SAA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MAAM,EAAE,MAAM,CAAC,CAAA;SAAE,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,KAAK,EAC9D,eAAe,CAAC,CAAC,CAAC,EAClB,GAAG,SAAS,MAAM,GAAG,GAAG,GAAG,MAAM,CAClC;KACF,CAAC,MAAM,CAAC,CAAC,GACV,cAAc,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,GAC5C,KAAK;CACV,CAAC,MAAM,CAAC,CAAC,GACV,KAAK,CAAC"}
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,9 @@
1
+ import type { BaseBuildModuleReturn, BuildModuleReturn } from '../api/lib/module';
2
+ import type { Route } from '../api/lib/route';
3
+ import type { FetcherParams, GetModulePaths, GetValidMethodForPath, GetValidPathsForModule, InferResponseType } from './fetcher/types';
4
+ export declare function fetcher<M extends string, Routes extends Route[], Modules extends BaseBuildModuleReturn[], ModuleName extends GetModulePaths<M, Modules>, SelectedPath extends GetValidPathsForModule<ModuleName, M, Routes, Modules>, Method extends GetValidMethodForPath<ModuleName, SelectedPath, M, Routes, Modules> = GetValidMethodForPath<ModuleName, SelectedPath, M, Routes, Modules>>({ pluginId }: BuildModuleReturn<string, M, Routes, Modules>, { path, method, module, args, options, allowSaveCookies, withPagination, }: FetcherParams<M, Routes, Modules, ModuleName, SelectedPath, Method> & {
5
+ allowSaveCookies?: boolean;
6
+ options?: Omit<RequestInit, 'body'>;
7
+ withPagination?: boolean;
8
+ }): Promise<InferResponseType<M, Routes, Modules, ModuleName, SelectedPath, Method>>;
9
+ //# sourceMappingURL=fetcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../../../src/lib/fetcher.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AAKzB,wBAAsB,OAAO,CAC3B,CAAC,SAAS,MAAM,EAChB,MAAM,SAAS,KAAK,EAAE,EACtB,OAAO,SAAS,qBAAqB,EAAE,EACvC,UAAU,SAAS,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC,EAC7C,YAAY,SAAS,sBAAsB,CAAC,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAC3E,MAAM,SAAS,qBAAqB,CAClC,UAAU,EACV,YAAY,EACZ,CAAC,EACD,MAAM,EACN,OAAO,CACR,GAAG,qBAAqB,CAAC,UAAU,EAAE,YAAY,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAEvE,EAAE,QAAQ,EAAE,EAAE,iBAAiB,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAC3D,EACE,IAAI,EACJ,MAAM,EACN,MAAM,EACN,IAAI,EACJ,OAAO,EACP,gBAAwB,EACxB,cAAsB,GACvB,EAAE,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,CAAC,GAAG;IACvE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACpC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,GACA,OAAO,CACR,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,CAAC,CACxE,CA+DA"}
@@ -0,0 +1,47 @@
1
+ import { cookies, headers } from "next/headers";
2
+ import { CONFIG } from "./config";
3
+ import { buildSearchParams, handleSetCookiesFetcher } from "./fetcher/helpers";
4
+ export async function fetcher({ pluginId }, { path, method, module, args, options, allowSaveCookies = false, withPagination = false }) {
5
+ let currentPath = path;
6
+ // Replace path parameters
7
+ if (args && 'params' in args && args.params) {
8
+ for (const [key, value] of Object.entries(args.params)){
9
+ currentPath = currentPath.replaceAll(`{${key}}`, String(value));
10
+ }
11
+ }
12
+ // Ensure path starts with a slash
13
+ const formattedPath = currentPath.startsWith('/') ? currentPath : `/${currentPath}`;
14
+ // Construct the base URL
15
+ const url = new URL(`/api/${pluginId}/${module}${formattedPath}`, CONFIG.backend.origin);
16
+ // Add query parameters if they exist
17
+ if (args && 'query' in args && args.query) {
18
+ const queryParams = args.query;
19
+ const searchParams = buildSearchParams({
20
+ ...args.query,
21
+ ...withPagination && {
22
+ first: !queryParams.last ? queryParams.first ?? '10' : undefined,
23
+ search: queryParams.search ?? ''
24
+ }
25
+ });
26
+ url.search = searchParams.toString();
27
+ }
28
+ const [nextInternalHeaders, cookie] = await Promise.all([
29
+ headers(),
30
+ cookies()
31
+ ]);
32
+ const response = await fetch(url, {
33
+ method: method.toUpperCase(),
34
+ headers: new Headers({
35
+ 'Content-Type': 'application/json',
36
+ Cookie: cookie.toString(),
37
+ ['user-agent']: nextInternalHeaders.get('user-agent') ?? 'node',
38
+ ['x-forwarded-for']: nextInternalHeaders.get('x-forwarded-for') ?? '0.0.0.0'
39
+ }),
40
+ body: args && 'body' in args ? JSON.stringify(args.body) : undefined,
41
+ ...options
42
+ });
43
+ if (response.status >= 200 && response.status < 300 && allowSaveCookies) {
44
+ await handleSetCookiesFetcher(response);
45
+ }
46
+ return response;
47
+ }
@@ -0,0 +1,10 @@
1
+ import type { DefaultValues } from 'react-hook-form';
2
+ import { z } from 'zod';
3
+ export declare const getShapeFromSchema: (schema: z.ZodEffects<z.ZodObject<z.ZodRawShape>> | z.ZodObject<z.ZodRawShape>, id: string) => null | z.ZodAny;
4
+ export type ZodObjectOrWrapped = z.Schema<any, any>;
5
+ export declare function getObjectFormSchema(schema: ZodObjectOrWrapped): z.ZodObject<any, any>;
6
+ export declare function getBaseSchema<T extends z.ZodTypeAny>(schema: T | z.ZodEffects<T>, isArray?: boolean): null | T;
7
+ export declare const getBaseType: (schema: z.ZodTypeAny) => string;
8
+ export declare function getDefaultValueInZodStack(schema: z.ZodTypeAny): unknown;
9
+ export declare function getDefaultValues<Schema extends z.ZodObject<any, any>>(schema: Schema): DefaultValues<Partial<z.TypeOf<Schema>>>;
10
+ //# sourceMappingURL=auto-form.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-form.d.ts","sourceRoot":"","sources":["../../../../src/lib/helpers/auto-form.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,EAC7E,IAAI,MAAM,KACT,IAAI,GAAG,CAAC,CAAC,MAMX,CAAC;AAGF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAEpD,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,kBAAkB,GAEzB,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAUvB;AAMD,wBAAgB,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,EAClD,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAC3B,OAAO,CAAC,EAAE,OAAO,GAChB,IAAI,GAAG,CAAC,CAYV;AAMD,eAAO,MAAM,WAAW,GAAI,QAAQ,CAAC,CAAC,UAAU,KAAG,MAIlD,CAAC;AAKF,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,GAAG,OAAO,CAevE;AAMD,wBAAgB,gBAAgB,CAAC,MAAM,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,EACnE,MAAM,EAAE,MAAM,GACb,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAmC1C"}
@@ -0,0 +1,82 @@
1
+ import { z } from "zod";
2
+ export const getShapeFromSchema = (schema, id)=>{
3
+ if (schema._def.typeName === z.ZodFirstPartyTypeKind.ZodEffects) {
4
+ return schema._def.schema.shape[id];
5
+ }
6
+ return schema.shape[id];
7
+ };
8
+ export function getObjectFormSchema(schema) {
9
+ if (schema._def.typeName === 'ZodEffects') {
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ const typedSchema = schema;
12
+ return getObjectFormSchema(typedSchema._def.schema);
13
+ }
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ return schema;
16
+ }
17
+ /**
18
+ * Get the lowest level Zod type.
19
+ * This will unpack optionals, refinements, etc.
20
+ */ export function getBaseSchema(schema, isArray) {
21
+ if ('innerType' in schema._def) {
22
+ return getBaseSchema(schema._def.innerType, isArray);
23
+ }
24
+ if ('schema' in schema._def) {
25
+ return getBaseSchema(schema._def.schema, isArray);
26
+ }
27
+ if ('type' in schema._def && isArray) {
28
+ return getBaseSchema(schema._def.type, isArray);
29
+ }
30
+ return schema;
31
+ }
32
+ /**
33
+ * Get the type name of the lowest level Zod type.
34
+ * This will unpack optionals, refinements, etc.
35
+ */ export const getBaseType = (schema)=>{
36
+ const baseSchema = getBaseSchema(schema);
37
+ return baseSchema ? baseSchema._def.typeName : '';
38
+ };
39
+ /**
40
+ * Search for a "ZodDefult" in the Zod stack and return its value.
41
+ */ export function getDefaultValueInZodStack(schema) {
42
+ if (schema._def.typeName === z.ZodFirstPartyTypeKind.ZodDefault) {
43
+ return schema._def.defaultValue();
44
+ }
45
+ if ('innerType' in schema._def) {
46
+ return getDefaultValueInZodStack(schema._def.innerType);
47
+ }
48
+ if ('schema' in schema._def) {
49
+ return getDefaultValueInZodStack(schema._def.schema);
50
+ }
51
+ return undefined;
52
+ }
53
+ /**
54
+ * Get all default values from a Zod schema.
55
+ */ // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
+ export function getDefaultValues(schema) {
57
+ const { shape } = schema;
58
+ const defaultValues = {};
59
+ if (!shape) return defaultValues;
60
+ for (const key of Object.keys(shape)){
61
+ const item = shape[key];
62
+ if (getBaseType(item) === 'ZodObject') {
63
+ const baseSchema = getBaseSchema(item);
64
+ if (baseSchema && 'shape' in baseSchema._def) {
65
+ const defaultItems = getDefaultValues(baseSchema);
66
+ if (defaultItems !== null) {
67
+ const obj = {};
68
+ for (const defaultItemKey of Object.keys(defaultItems)){
69
+ obj[defaultItemKey] = defaultItems[defaultItemKey];
70
+ defaultValues[key] = obj;
71
+ }
72
+ }
73
+ }
74
+ } else {
75
+ const defaultValue = getDefaultValueInZodStack(item);
76
+ if (defaultValue !== undefined) {
77
+ defaultValues[key] = defaultValue;
78
+ }
79
+ }
80
+ }
81
+ return defaultValues;
82
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=auto-form.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-form.test.d.ts","sourceRoot":"","sources":["../../../../src/lib/helpers/auto-form.test.ts"],"names":[],"mappings":""}