@tulip-systems/core 0.5.2 → 0.5.4

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 (423) hide show
  1. package/dist/auth/client.d.mts +3 -3
  2. package/dist/auth/client.mjs +2 -2
  3. package/dist/components/client.d.mts +2 -2
  4. package/dist/components/common/icons.d.mts +2 -2
  5. package/dist/components/common/icons.d.mts.map +1 -1
  6. package/dist/components/common/status.d.mts +3 -3
  7. package/dist/components/common/status.d.mts.map +1 -1
  8. package/dist/components/editor/components/content.client.d.mts +2 -2
  9. package/dist/components/editor/components/content.client.d.mts.map +1 -1
  10. package/dist/components/editor/components/editor.client.d.mts +6 -6
  11. package/dist/components/editor/components/editor.client.d.mts.map +1 -1
  12. package/dist/components/editor/components/editor.client.mjs +2 -2
  13. package/dist/components/editor/components/editor.client.mjs.map +1 -1
  14. package/dist/components/editor/components/menu.client.d.mts +3 -3
  15. package/dist/components/editor/components/menu.client.d.mts.map +1 -1
  16. package/dist/components/editor/components/menu.client.mjs +3 -0
  17. package/dist/components/editor/components/menu.client.mjs.map +1 -1
  18. package/dist/components/editor/extensions/file-handler/extension.d.mts +21 -0
  19. package/dist/components/editor/extensions/file-handler/extension.d.mts.map +1 -0
  20. package/dist/components/editor/extensions/file-handler/extension.mjs +40 -0
  21. package/dist/components/editor/extensions/file-handler/extension.mjs.map +1 -0
  22. package/dist/components/editor/extensions/file-handler/strategy.d.mts +29 -0
  23. package/dist/components/editor/extensions/file-handler/strategy.d.mts.map +1 -0
  24. package/dist/components/editor/extensions/file-handler/strategy.mjs +111 -0
  25. package/dist/components/editor/extensions/file-handler/strategy.mjs.map +1 -0
  26. package/dist/components/editor/extensions/file-handler/utils.mjs +50 -0
  27. package/dist/components/editor/extensions/file-handler/utils.mjs.map +1 -0
  28. package/dist/components/editor/extensions/image/extension.d.mts +8 -0
  29. package/dist/components/editor/extensions/image/extension.d.mts.map +1 -0
  30. package/dist/components/editor/extensions/image/extension.mjs +51 -0
  31. package/dist/components/editor/extensions/image/extension.mjs.map +1 -0
  32. package/dist/components/editor/extensions/skeleton/extension.mjs +41 -0
  33. package/dist/components/editor/extensions/skeleton/extension.mjs.map +1 -0
  34. package/dist/components/editor/extensions/skeleton/renderer.mjs +25 -0
  35. package/dist/components/editor/extensions/skeleton/renderer.mjs.map +1 -0
  36. package/dist/components/editor/lib/constants.d.mts +31 -28
  37. package/dist/components/editor/lib/constants.d.mts.map +1 -1
  38. package/dist/components/editor/lib/constants.mjs +17 -5
  39. package/dist/components/editor/lib/constants.mjs.map +1 -1
  40. package/dist/components/editor/lib/extensions.d.mts +7 -3
  41. package/dist/components/editor/lib/extensions.d.mts.map +1 -1
  42. package/dist/components/editor/lib/extensions.mjs.map +1 -1
  43. package/dist/components/editor/lib/helpers.d.mts.map +1 -1
  44. package/dist/components/editor/lib/helpers.mjs +38 -3
  45. package/dist/components/editor/lib/helpers.mjs.map +1 -1
  46. package/dist/components/editor/lib/variants.mjs +10 -2
  47. package/dist/components/editor/lib/variants.mjs.map +1 -1
  48. package/dist/components/header/back-button.client.d.mts +2 -2
  49. package/dist/components/header/back-button.client.d.mts.map +1 -1
  50. package/dist/components/header/bottom-bar.client.d.mts +3 -3
  51. package/dist/components/header/bottom-bar.client.d.mts.map +1 -1
  52. package/dist/components/header/breadcrumbs.client.d.mts +7 -7
  53. package/dist/components/header/breadcrumbs.client.d.mts.map +1 -1
  54. package/dist/components/header/header.client.d.mts +2 -2
  55. package/dist/components/header/header.client.d.mts.map +1 -1
  56. package/dist/components/header/mobile-nav-switcher.client.d.mts +2 -2
  57. package/dist/components/header/mobile-nav-switcher.client.d.mts.map +1 -1
  58. package/dist/components/header/top-bar.client.d.mts +4 -4
  59. package/dist/components/header/top-bar.client.d.mts.map +1 -1
  60. package/dist/components/layouts/admin-content.client.d.mts +2 -2
  61. package/dist/components/layouts/admin-content.client.d.mts.map +1 -1
  62. package/dist/components/layouts/admin-layout.d.mts +2 -2
  63. package/dist/components/layouts/admin-layout.d.mts.map +1 -1
  64. package/dist/components/layouts/admin-loading.d.mts +2 -2
  65. package/dist/components/layouts/admin-loading.d.mts.map +1 -1
  66. package/dist/components/layouts/empty-page.d.mts +4 -4
  67. package/dist/components/layouts/empty-page.d.mts.map +1 -1
  68. package/dist/components/layouts/error-page.d.mts +23 -0
  69. package/dist/components/layouts/error-page.d.mts.map +1 -0
  70. package/dist/components/layouts/error-page.mjs +58 -0
  71. package/dist/components/layouts/error-page.mjs.map +1 -0
  72. package/dist/components/layouts/list-layout.d.mts +2 -2
  73. package/dist/components/layouts/list-layout.d.mts.map +1 -1
  74. package/dist/components/layouts/not-allowed-page.d.mts +22 -0
  75. package/dist/components/layouts/not-allowed-page.d.mts.map +1 -0
  76. package/dist/components/layouts/not-allowed-page.mjs +25 -0
  77. package/dist/components/layouts/not-allowed-page.mjs.map +1 -0
  78. package/dist/components/layouts/not-found-page.d.mts +3 -3
  79. package/dist/components/layouts/not-found-page.d.mts.map +1 -1
  80. package/dist/components/layouts/providers.client.d.mts +2 -2
  81. package/dist/components/layouts/providers.client.d.mts.map +1 -1
  82. package/dist/components/layouts/root-layout.server.d.mts +2 -2
  83. package/dist/components/layouts/root-layout.server.d.mts.map +1 -1
  84. package/dist/components/layouts/root-loading.d.mts +2 -2
  85. package/dist/components/layouts/root-loading.d.mts.map +1 -1
  86. package/dist/components/layouts/tab-layout.d.mts +2 -2
  87. package/dist/components/layouts/tab-layout.d.mts.map +1 -1
  88. package/dist/components/lists/data-list.d.mts +5 -5
  89. package/dist/components/lists/data-list.d.mts.map +1 -1
  90. package/dist/components/lists/data-stack.d.mts +8 -8
  91. package/dist/components/lists/data-stack.d.mts.map +1 -1
  92. package/dist/components/navigation/admin-sidebar-paths.client.d.mts +21 -11
  93. package/dist/components/navigation/admin-sidebar-paths.client.d.mts.map +1 -1
  94. package/dist/components/navigation/admin-sidebar-paths.client.mjs +7 -5
  95. package/dist/components/navigation/admin-sidebar-paths.client.mjs.map +1 -1
  96. package/dist/components/ui/accordion.d.mts +5 -5
  97. package/dist/components/ui/accordion.d.mts.map +1 -1
  98. package/dist/components/ui/alert-dialog.d.mts +12 -12
  99. package/dist/components/ui/alert-dialog.d.mts.map +1 -1
  100. package/dist/components/ui/alert.d.mts +6 -6
  101. package/dist/components/ui/alert.d.mts.map +1 -1
  102. package/dist/components/ui/aspect-ratio.d.mts +2 -2
  103. package/dist/components/ui/aspect-ratio.d.mts.map +1 -1
  104. package/dist/components/ui/avatar.client.d.mts +4 -4
  105. package/dist/components/ui/avatar.client.d.mts.map +1 -1
  106. package/dist/components/ui/badge.d.mts +4 -4
  107. package/dist/components/ui/badge.d.mts.map +1 -1
  108. package/dist/components/ui/breadcrumb.d.mts +8 -8
  109. package/dist/components/ui/breadcrumb.d.mts.map +1 -1
  110. package/dist/components/ui/button.d.mts +5 -5
  111. package/dist/components/ui/button.d.mts.map +1 -1
  112. package/dist/components/ui/calendar.d.mts +3 -3
  113. package/dist/components/ui/calendar.d.mts.map +1 -1
  114. package/dist/components/ui/card.d.mts +7 -7
  115. package/dist/components/ui/card.d.mts.map +1 -1
  116. package/dist/components/ui/carousel.d.mts +6 -6
  117. package/dist/components/ui/carousel.d.mts.map +1 -1
  118. package/dist/components/ui/chart.client.d.mts +5 -5
  119. package/dist/components/ui/chart.client.d.mts.map +1 -1
  120. package/dist/components/ui/checkbox.d.mts +2 -2
  121. package/dist/components/ui/checkbox.d.mts.map +1 -1
  122. package/dist/components/ui/collapsible.client.d.mts +4 -4
  123. package/dist/components/ui/collapsible.client.d.mts.map +1 -1
  124. package/dist/components/ui/color-picker.client.d.mts +2 -2
  125. package/dist/components/ui/color-picker.client.d.mts.map +1 -1
  126. package/dist/components/ui/combobox-dropdown.client.d.mts +2 -2
  127. package/dist/components/ui/combobox-dropdown.client.d.mts.map +1 -1
  128. package/dist/components/ui/combobox.client.d.mts +2 -2
  129. package/dist/components/ui/combobox.client.d.mts.map +1 -1
  130. package/dist/components/ui/command.d.mts +10 -10
  131. package/dist/components/ui/command.d.mts.map +1 -1
  132. package/dist/components/ui/context-menu.d.mts +16 -16
  133. package/dist/components/ui/context-menu.d.mts.map +1 -1
  134. package/dist/components/ui/date-picker.client.d.mts +2 -2
  135. package/dist/components/ui/date-picker.client.d.mts.map +1 -1
  136. package/dist/components/ui/dialog.client.d.mts +11 -11
  137. package/dist/components/ui/dialog.client.d.mts.map +1 -1
  138. package/dist/components/ui/drawer.client.d.mts +11 -11
  139. package/dist/components/ui/drawer.client.d.mts.map +1 -1
  140. package/dist/components/ui/dropdown-menu.d.mts +16 -16
  141. package/dist/components/ui/form.client.d.mts +7 -7
  142. package/dist/components/ui/form.client.d.mts.map +1 -1
  143. package/dist/components/ui/hover-card.client.d.mts +4 -4
  144. package/dist/components/ui/hover-card.client.d.mts.map +1 -1
  145. package/dist/components/ui/input-recipient.d.mts +2 -2
  146. package/dist/components/ui/input.d.mts +2 -2
  147. package/dist/components/ui/label.d.mts +2 -2
  148. package/dist/components/ui/navigation-menu.d.mts +11 -11
  149. package/dist/components/ui/pagination.d.mts +8 -8
  150. package/dist/components/ui/popover.d.mts +5 -5
  151. package/dist/components/ui/progress.client.d.mts +2 -2
  152. package/dist/components/ui/progress.client.d.mts.map +1 -1
  153. package/dist/components/ui/radio-group.d.mts +3 -3
  154. package/dist/components/ui/resizable.client.d.mts +4 -4
  155. package/dist/components/ui/resizable.client.d.mts.map +1 -1
  156. package/dist/components/ui/scroll-area.d.mts +3 -3
  157. package/dist/components/ui/select.client.d.mts +11 -11
  158. package/dist/components/ui/select.client.d.mts.map +1 -1
  159. package/dist/components/ui/separator.d.mts +2 -2
  160. package/dist/components/ui/sheet.client.d.mts +9 -9
  161. package/dist/components/ui/sheet.client.d.mts.map +1 -1
  162. package/dist/components/ui/sidebar.client.d.mts +26 -26
  163. package/dist/components/ui/sidebar.client.d.mts.map +1 -1
  164. package/dist/components/ui/skeleton.d.mts +2 -2
  165. package/dist/components/ui/slider.d.mts +2 -2
  166. package/dist/components/ui/sonner.client.d.mts +2 -2
  167. package/dist/components/ui/switch.d.mts +2 -2
  168. package/dist/components/ui/tabs.d.mts +5 -5
  169. package/dist/components/ui/textarea.d.mts +2 -2
  170. package/dist/components/ui/time-input.client.d.mts +2 -2
  171. package/dist/components/ui/toggle-group.client.d.mts +3 -3
  172. package/dist/components/ui/toggle.d.mts +2 -2
  173. package/dist/components/ui/toggle.d.mts.map +1 -1
  174. package/dist/components/ui/tooltip.client.d.mts +5 -5
  175. package/dist/components/ui/tooltip.client.d.mts.map +1 -1
  176. package/dist/components/ui/tooltip.client.mjs +1 -1
  177. package/dist/components/ui/tooltip.client.mjs.map +1 -1
  178. package/dist/components.d.mts +4 -1
  179. package/dist/components.mjs +5 -2
  180. package/dist/data-tables.d.mts +2 -2
  181. package/dist/data-tables.mjs +2 -2
  182. package/dist/inline-edit/client.d.mts +2 -3
  183. package/dist/inline-edit/client.mjs +1 -2
  184. package/dist/lib/client.d.mts +2 -2
  185. package/dist/lib/client.mjs +2 -2
  186. package/dist/lib/hooks/use-action.d.mts +2 -2
  187. package/dist/lib/hooks/use-indicator.d.mts +11 -3
  188. package/dist/lib/hooks/use-indicator.d.mts.map +1 -1
  189. package/dist/lib/hooks/use-indicator.mjs +19 -8
  190. package/dist/lib/hooks/use-indicator.mjs.map +1 -1
  191. package/dist/modules/auth/components/allowed.client.d.mts +21 -7
  192. package/dist/modules/auth/components/allowed.client.d.mts.map +1 -1
  193. package/dist/modules/auth/components/allowed.client.mjs +8 -2
  194. package/dist/modules/auth/components/allowed.client.mjs.map +1 -1
  195. package/dist/modules/auth/components/auth-layout.server.d.mts +2 -2
  196. package/dist/modules/auth/components/auth-layout.server.d.mts.map +1 -1
  197. package/dist/modules/auth/components/auth-loading.d.mts +2 -2
  198. package/dist/modules/auth/components/auth-loading.d.mts.map +1 -1
  199. package/dist/modules/auth/components/create-first-user-page.client.d.mts +2 -2
  200. package/dist/modules/auth/components/create-first-user-page.client.d.mts.map +1 -1
  201. package/dist/modules/auth/components/forget-password-page.client.d.mts +2 -2
  202. package/dist/modules/auth/components/forget-password-page.client.d.mts.map +1 -1
  203. package/dist/modules/auth/components/guard-first-user.server.d.mts +2 -2
  204. package/dist/modules/auth/components/guard-first-user.server.d.mts.map +1 -1
  205. package/dist/modules/auth/components/guard.server.d.mts +2 -2
  206. package/dist/modules/auth/components/guard.server.d.mts.map +1 -1
  207. package/dist/modules/auth/components/login-page.client.d.mts +2 -2
  208. package/dist/modules/auth/components/login-page.client.d.mts.map +1 -1
  209. package/dist/modules/auth/components/reset-password-page.client.d.mts +2 -2
  210. package/dist/modules/auth/components/reset-password-page.client.d.mts.map +1 -1
  211. package/dist/modules/auth/components/update-password-command.d.mts +2 -2
  212. package/dist/modules/auth/components/update-password-command.d.mts.map +1 -1
  213. package/dist/modules/auth/db/schema.d.mts +73 -73
  214. package/dist/modules/auth/db/schema.d.mts.map +1 -1
  215. package/dist/modules/auth/handler/client.client.d.mts +143 -143
  216. package/dist/modules/auth/handler/client.client.d.mts.map +1 -1
  217. package/dist/modules/auth/handler/init.d.mts +131 -131
  218. package/dist/modules/auth/handler/init.d.mts.map +1 -1
  219. package/dist/modules/auth/hooks/use-permission.d.mts +48 -4
  220. package/dist/modules/auth/hooks/use-permission.d.mts.map +1 -1
  221. package/dist/modules/auth/hooks/use-permission.mjs +51 -4
  222. package/dist/modules/auth/hooks/use-permission.mjs.map +1 -1
  223. package/dist/modules/auth/lib/helpers.server.mjs +1 -1
  224. package/dist/modules/auth/lib/validators.d.mts +2 -2
  225. package/dist/modules/auth/lib/validators.d.mts.map +1 -1
  226. package/dist/modules/commands/components/alert-dialog-command.client.d.mts +10 -10
  227. package/dist/modules/commands/components/click-command.client.d.mts +2 -2
  228. package/dist/modules/commands/components/command-trigger.client.d.mts +6 -6
  229. package/dist/modules/commands/components/dialog-command.client.d.mts +8 -8
  230. package/dist/modules/commands/components/dropdown-command.client.d.mts +5 -5
  231. package/dist/modules/commands/components/empty-command.client.d.mts +2 -2
  232. package/dist/modules/commands/components/form-dialog-command.client.d.mts +11 -11
  233. package/dist/modules/commands/hooks/use-command-menu.client.d.mts.map +1 -1
  234. package/dist/modules/commands/hooks/use-command-menu.client.mjs +0 -5
  235. package/dist/modules/commands/hooks/use-command-menu.client.mjs.map +1 -1
  236. package/dist/modules/commands/hooks/use-command-mutation.client.d.mts +2 -2
  237. package/dist/modules/commands/menus/context-menu.client.d.mts +2 -2
  238. package/dist/modules/commands/menus/dropdown-menu.client.d.mts +3 -3
  239. package/dist/modules/commands/menus/inline-menu.client.d.mts +3 -3
  240. package/dist/modules/commands/menus/responsive-menu.client.d.mts +3 -3
  241. package/dist/modules/commands/utils/archive-command.client.d.mts +3 -3
  242. package/dist/modules/commands/utils/delete-command.client.d.mts +3 -3
  243. package/dist/modules/config/db/helpers.d.mts +5 -5
  244. package/dist/modules/config/db/helpers.d.mts.map +1 -1
  245. package/dist/modules/data-tables/components/cell/common.client.d.mts +5 -5
  246. package/dist/modules/data-tables/components/column-header.d.mts +2 -2
  247. package/dist/modules/data-tables/components/filters/combobox.client.d.mts +2 -2
  248. package/dist/modules/data-tables/components/filters/slider.client.d.mts +2 -2
  249. package/dist/modules/data-tables/components/header.d.mts +4 -4
  250. package/dist/modules/data-tables/components/layout.d.mts +2 -2
  251. package/dist/modules/data-tables/components/search-input.client.d.mts +2 -2
  252. package/dist/modules/data-tables/components/skeleton.d.mts +2 -2
  253. package/dist/modules/data-tables/components/table.d.mts +7 -7
  254. package/dist/modules/data-tables/components/toolbar.d.mts +3 -3
  255. package/dist/modules/data-tables/hooks/use-context.client.d.mts +2 -2
  256. package/dist/modules/data-tables/lib/filters/parsers.d.mts +6 -1
  257. package/dist/modules/data-tables/lib/filters/parsers.d.mts.map +1 -1
  258. package/dist/modules/data-tables/lib/filters/parsers.mjs +6 -1
  259. package/dist/modules/data-tables/lib/filters/parsers.mjs.map +1 -1
  260. package/dist/modules/data-tables/tables/data-table/components/table.d.mts +2 -2
  261. package/dist/modules/data-tables/tables/inline-table/components/cells/common.d.mts +2 -2
  262. package/dist/modules/data-tables/tables/inline-table/components/cells/drag-handle.client.d.mts +2 -2
  263. package/dist/modules/data-tables/tables/inline-table/components/inputs/advanced-select.client.d.mts +2 -2
  264. package/dist/modules/data-tables/tables/inline-table/components/inputs/combobox.client.d.mts +2 -2
  265. package/dist/modules/data-tables/tables/inline-table/components/inputs/input.client.d.mts +3 -3
  266. package/dist/modules/data-tables/tables/inline-table/components/inputs/read-only.d.mts +2 -2
  267. package/dist/modules/data-tables/tables/inline-table/components/inputs/select.client.d.mts +2 -2
  268. package/dist/modules/data-tables/tables/inline-table/components/table.d.mts +2 -2
  269. package/dist/modules/data-tables/tables/inline-table/hooks/context.client.d.mts +2 -2
  270. package/dist/modules/inline-edit/components/combobox-dropdown.client.d.mts +6 -4
  271. package/dist/modules/inline-edit/components/combobox-dropdown.client.d.mts.map +1 -1
  272. package/dist/modules/inline-edit/components/combobox-dropdown.client.mjs +11 -6
  273. package/dist/modules/inline-edit/components/combobox-dropdown.client.mjs.map +1 -1
  274. package/dist/modules/inline-edit/components/combobox.client.d.mts +6 -4
  275. package/dist/modules/inline-edit/components/combobox.client.d.mts.map +1 -1
  276. package/dist/modules/inline-edit/components/combobox.client.mjs +7 -5
  277. package/dist/modules/inline-edit/components/combobox.client.mjs.map +1 -1
  278. package/dist/modules/inline-edit/components/date-input.client.d.mts +5 -3
  279. package/dist/modules/inline-edit/components/date-input.client.d.mts.map +1 -1
  280. package/dist/modules/inline-edit/components/date-input.client.mjs +26 -13
  281. package/dist/modules/inline-edit/components/date-input.client.mjs.map +1 -1
  282. package/dist/modules/inline-edit/components/date-picker.client.d.mts +6 -4
  283. package/dist/modules/inline-edit/components/date-picker.client.d.mts.map +1 -1
  284. package/dist/modules/inline-edit/components/date-picker.client.mjs +12 -7
  285. package/dist/modules/inline-edit/components/date-picker.client.mjs.map +1 -1
  286. package/dist/modules/inline-edit/components/editor.client.d.mts +6 -4
  287. package/dist/modules/inline-edit/components/editor.client.d.mts.map +1 -1
  288. package/dist/modules/inline-edit/components/editor.client.mjs +11 -6
  289. package/dist/modules/inline-edit/components/editor.client.mjs.map +1 -1
  290. package/dist/modules/inline-edit/components/input-recipient.client.d.mts +6 -4
  291. package/dist/modules/inline-edit/components/input-recipient.client.d.mts.map +1 -1
  292. package/dist/modules/inline-edit/components/input-recipient.client.mjs +11 -6
  293. package/dist/modules/inline-edit/components/input-recipient.client.mjs.map +1 -1
  294. package/dist/modules/inline-edit/components/input-toggle.client.d.mts +6 -4
  295. package/dist/modules/inline-edit/components/input-toggle.client.d.mts.map +1 -1
  296. package/dist/modules/inline-edit/components/input-toggle.client.mjs +9 -7
  297. package/dist/modules/inline-edit/components/input-toggle.client.mjs.map +1 -1
  298. package/dist/modules/inline-edit/components/input.client.d.mts +13 -10
  299. package/dist/modules/inline-edit/components/input.client.d.mts.map +1 -1
  300. package/dist/modules/inline-edit/components/input.client.mjs +35 -19
  301. package/dist/modules/inline-edit/components/input.client.mjs.map +1 -1
  302. package/dist/modules/inline-edit/components/select.client.d.mts +10 -9
  303. package/dist/modules/inline-edit/components/select.client.d.mts.map +1 -1
  304. package/dist/modules/inline-edit/components/select.client.mjs +14 -7
  305. package/dist/modules/inline-edit/components/select.client.mjs.map +1 -1
  306. package/dist/modules/inline-edit/components/switch.client.d.mts +5 -3
  307. package/dist/modules/inline-edit/components/switch.client.d.mts.map +1 -1
  308. package/dist/modules/inline-edit/components/switch.client.mjs +8 -6
  309. package/dist/modules/inline-edit/components/switch.client.mjs.map +1 -1
  310. package/dist/modules/inline-edit/components/toggle.client.d.mts +6 -4
  311. package/dist/modules/inline-edit/components/toggle.client.d.mts.map +1 -1
  312. package/dist/modules/inline-edit/components/toggle.client.mjs +9 -7
  313. package/dist/modules/inline-edit/components/toggle.client.mjs.map +1 -1
  314. package/dist/modules/inline-edit/hooks/context.client.d.mts +2 -2
  315. package/dist/modules/inline-edit/hooks/use-inline.client.d.mts +35 -3
  316. package/dist/modules/inline-edit/hooks/use-inline.client.d.mts.map +1 -1
  317. package/dist/modules/inline-edit/hooks/use-inline.client.mjs +71 -9
  318. package/dist/modules/inline-edit/hooks/use-inline.client.mjs.map +1 -1
  319. package/dist/modules/inline-edit/lib/variants.d.mts +1 -0
  320. package/dist/modules/inline-edit/lib/variants.d.mts.map +1 -1
  321. package/dist/modules/inline-edit/lib/variants.mjs +12 -4
  322. package/dist/modules/inline-edit/lib/variants.mjs.map +1 -1
  323. package/dist/modules/router/handler/init.server.d.mts +4 -4
  324. package/dist/modules/router/handler/init.server.mjs +1 -1
  325. package/dist/modules/router/lib/query-client.server.d.mts +2 -2
  326. package/dist/modules/storage/components/dropzone-context.client.d.mts +2 -2
  327. package/dist/modules/storage/components/dropzone.client.d.mts +5 -5
  328. package/dist/modules/storage/components/image-grid.client.d.mts +3 -3
  329. package/dist/modules/storage/components/image-grid.client.mjs +2 -2
  330. package/dist/modules/storage/components/image-grid.client.mjs.map +1 -1
  331. package/dist/modules/storage/components/upload-zone-context.client.d.mts +3 -11
  332. package/dist/modules/storage/components/upload-zone-context.client.d.mts.map +1 -1
  333. package/dist/modules/storage/components/upload-zone-context.client.mjs.map +1 -1
  334. package/dist/modules/storage/components/upload-zone.client.d.mts +10 -33
  335. package/dist/modules/storage/components/upload-zone.client.d.mts.map +1 -1
  336. package/dist/modules/storage/components/upload-zone.client.mjs +19 -93
  337. package/dist/modules/storage/components/upload-zone.client.mjs.map +1 -1
  338. package/dist/modules/storage/config/filters.d.mts +1 -0
  339. package/dist/modules/storage/config/filters.d.mts.map +1 -1
  340. package/dist/modules/storage/config/filters.mjs +1 -0
  341. package/dist/modules/storage/config/filters.mjs.map +1 -1
  342. package/dist/modules/storage/lib/create-upload.client.d.mts +56 -0
  343. package/dist/modules/storage/lib/create-upload.client.d.mts.map +1 -0
  344. package/dist/modules/storage/lib/create-upload.client.mjs +98 -0
  345. package/dist/modules/storage/lib/create-upload.client.mjs.map +1 -0
  346. package/dist/modules/storage/lib/helpers.d.mts +1 -1
  347. package/dist/modules/storage/lib/router.server.d.mts +3239 -2319
  348. package/dist/modules/storage/lib/router.server.d.mts.map +1 -1
  349. package/dist/modules/storage/lib/router.server.mjs +5 -2
  350. package/dist/modules/storage/lib/router.server.mjs.map +1 -1
  351. package/dist/modules/storage/lib/schema.d.mts +124 -90
  352. package/dist/modules/storage/lib/schema.d.mts.map +1 -1
  353. package/dist/modules/storage/lib/schema.mjs +2 -1
  354. package/dist/modules/storage/lib/schema.mjs.map +1 -1
  355. package/dist/modules/storage/lib/service.server.d.mts +28 -39
  356. package/dist/modules/storage/lib/service.server.d.mts.map +1 -1
  357. package/dist/modules/storage/lib/service.server.mjs +6 -6
  358. package/dist/modules/storage/lib/service.server.mjs.map +1 -1
  359. package/dist/modules/storage/lib/validators.d.mts +166 -86
  360. package/dist/modules/storage/lib/validators.d.mts.map +1 -1
  361. package/dist/modules/storage/lib/validators.mjs +2 -1
  362. package/dist/modules/storage/lib/validators.mjs.map +1 -1
  363. package/dist/router/server.mjs +1 -1
  364. package/dist/storage/client.d.mts +2 -1
  365. package/dist/storage/client.mjs +2 -8
  366. package/dist/storage.d.mts +2 -2
  367. package/dist/storage.mjs +1 -1
  368. package/package.json +4 -3
  369. package/src/components/editor/components/editor.client.tsx +7 -2
  370. package/src/components/editor/components/menu.client.tsx +26 -0
  371. package/src/components/editor/extensions/file-handler/extension.ts +69 -0
  372. package/src/components/editor/extensions/file-handler/strategy.ts +167 -0
  373. package/src/components/editor/extensions/file-handler/utils.ts +51 -0
  374. package/src/components/editor/extensions/image/extension.ts +55 -0
  375. package/src/components/editor/extensions/skeleton/extension.ts +35 -0
  376. package/src/components/editor/extensions/skeleton/renderer.tsx +14 -0
  377. package/src/components/editor/lib/constants.ts +16 -2
  378. package/src/components/editor/lib/extensions.ts +4 -1
  379. package/src/components/editor/lib/helpers.ts +39 -3
  380. package/src/components/editor/lib/utils.ts +32 -0
  381. package/src/components/editor/lib/variants.ts +72 -1
  382. package/src/components/entry.ts +4 -1
  383. package/src/components/layouts/error-page.tsx +61 -0
  384. package/src/components/layouts/not-allowed-page.tsx +1 -1
  385. package/src/components/navigation/admin-sidebar-paths.client.tsx +18 -2
  386. package/src/components/ui/tooltip.client.tsx +1 -1
  387. package/src/lib/hooks/use-indicator.tsx +27 -18
  388. package/src/modules/auth/components/allowed.client.tsx +35 -7
  389. package/src/modules/auth/hooks/use-permission.ts +88 -2
  390. package/src/modules/commands/hooks/use-command-menu.client.tsx +4 -7
  391. package/src/modules/data-tables/lib/filters/parsers.ts +14 -0
  392. package/src/modules/inline-edit/components/combobox-dropdown.client.tsx +21 -12
  393. package/src/modules/inline-edit/components/combobox.client.tsx +13 -6
  394. package/src/modules/inline-edit/components/date-input.client.tsx +29 -13
  395. package/src/modules/inline-edit/components/date-picker.client.tsx +13 -9
  396. package/src/modules/inline-edit/components/editor.client.tsx +14 -14
  397. package/src/modules/inline-edit/components/input-recipient.client.tsx +15 -8
  398. package/src/modules/inline-edit/components/input-toggle.client.tsx +16 -9
  399. package/src/modules/inline-edit/components/input.client.tsx +38 -24
  400. package/src/modules/inline-edit/components/select.client.tsx +16 -9
  401. package/src/modules/inline-edit/components/switch.client.tsx +10 -6
  402. package/src/modules/inline-edit/components/toggle.client.tsx +13 -9
  403. package/src/modules/inline-edit/entry.client.ts +0 -1
  404. package/src/modules/inline-edit/hooks/use-inline.client.tsx +139 -20
  405. package/src/modules/inline-edit/lib/variants.ts +7 -0
  406. package/src/modules/storage/components/image-grid.client.tsx +2 -2
  407. package/src/modules/storage/components/upload-zone-context.client.tsx +3 -4
  408. package/src/modules/storage/components/upload-zone.client.tsx +17 -116
  409. package/src/modules/storage/config/filters.ts +1 -0
  410. package/src/modules/storage/entry.client.ts +2 -1
  411. package/src/modules/storage/lib/create-upload.client.ts +134 -0
  412. package/src/modules/storage/lib/router.server.ts +1 -0
  413. package/src/modules/storage/lib/schema.ts +1 -0
  414. package/src/modules/storage/lib/service.server.ts +10 -4
  415. package/src/modules/storage/lib/validators.ts +1 -0
  416. package/dist/modules/auth/lib/utils.mjs +0 -21
  417. package/dist/modules/auth/lib/utils.mjs.map +0 -1
  418. package/dist/modules/inline-edit/components/deprecated-editor.client.d.mts +0 -21
  419. package/dist/modules/inline-edit/components/deprecated-editor.client.d.mts.map +0 -1
  420. package/dist/modules/inline-edit/components/deprecated-editor.client.mjs +0 -37
  421. package/dist/modules/inline-edit/components/deprecated-editor.client.mjs.map +0 -1
  422. package/dist/storage/client.mjs.map +0 -1
  423. package/src/modules/inline-edit/components/deprecated-editor.client.tsx +0 -48
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.mts","names":[],"sources":["../../../../src/modules/auth/handler/init.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;cAca,gBAAA;KAER,8BAA8B;MAC7B,eAAe;SACZ;UACC;MACJ,kBAAkB;6BAEF;;AART,iBAYG,QAZa,CAAA,gBAYY,eAZZ,CAAA,CAAA,KAAA,EAYoC,aAZpC,CAYkD,OAZlD,CAAA,CAAA,eAY0D,IAZ1D,CAAA;EAExB,QAAA,EAAA;IAA8B,YAAA,EAAA,MAAA;IACd,QAAA,EAAA;MAAf,UAAA,EAAA,GAAA,GAAA,KAAA;IACG,CAAA;EACC,CAAA;EACc,QAAA,EAAA,CAAA,OAAA,EAMsD,YAAA,CAAA,iBANtD,EAAA,yBAAA,gCAAA;EAAlB,gBAAA,EAAA;IAEgB,OAAA,EAAA,IAAA;EAAI,CAAA;EAIV,IAAA,EAAA;IAAyB,WAAA,EAAA;MAAsC,OAAA,EAAA,IAAA;IAAd,CAAA;IAAa,gBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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
  import { Permission } from "../lib/permissions.mjs";
2
- import * as _tanstack_react_query3 from "@tanstack/react-query";
2
+ import * as _tanstack_react_query4 from "@tanstack/react-query";
3
3
 
4
4
  //#region src/modules/auth/hooks/use-permission.d.ts
5
5
  /**
6
6
  * UsePermission
7
7
  */
8
- declare function usePermission(permission?: Permission): {
8
+ type UsePermissionProps = {
9
+ /**
10
+ * Strategy to use when checking multiple permissions
11
+ * - "all": all permissions must be allowed
12
+ * - "any": at least one permission must be allowed
13
+ * @default "all"
14
+ */
15
+ strategy?: "all";
16
+ /**
17
+ * Permission to check
18
+ * @example { project: ["view", "create"] }
19
+ */
20
+ permission?: Permission;
21
+ } | {
22
+ /**
23
+ * Strategy to use when checking multiple permissions
24
+ * - "all": all permissions must be allowed
25
+ * - "any": at least one permission must be allowed
26
+ * @default "all"
27
+ */
28
+ strategy?: "any";
29
+ /**
30
+ * Permission to check
31
+ * @example [{ project: ["view", "create"] }, { client: ["view"] }, { drive: ["view"] }]
32
+ */
33
+ permission?: Permission[];
34
+ };
35
+ declare function usePermission({
36
+ permission,
37
+ strategy
38
+ }: UsePermissionProps): _tanstack_react_query4.UseSuspenseQueryResult<{
39
+ permission: undefined;
40
+ success: boolean;
41
+ } | {
42
+ permission: Permission | Permission[];
43
+ success: boolean;
44
+ }, Error>;
45
+ /**
46
+ * Check multiple permissions in parallel
47
+ * @param permission
48
+ * @param strategy
49
+ * @returns
50
+ * @deprecated Use `usePermission` with strategy "any" or "all" instead
51
+ */
52
+ declare function usePermissions(permission?: Permission): {
9
53
  data: null;
10
- errors: _tanstack_react_query3.UseSuspenseQueryResult<{
54
+ errors: _tanstack_react_query4.UseSuspenseQueryResult<{
11
55
  permission: Permission;
12
56
  success: boolean;
13
57
  }, Error>[];
@@ -22,5 +66,5 @@ declare function usePermission(permission?: Permission): {
22
66
  errors: null;
23
67
  };
24
68
  //#endregion
25
- export { usePermission };
69
+ export { UsePermissionProps, usePermission, usePermissions };
26
70
  //# sourceMappingURL=use-permission.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-permission.d.mts","names":[],"sources":["../../../../src/modules/auth/hooks/use-permission.ts"],"sourcesContent":[],"mappings":";;;;;;;AAUgB,iBAAA,aAAA,CAAa,UAAA,CAAA,EAAc,UAAd,CAAA,EAAA;EAAc,IAAA,EAAA,IAAA"}
1
+ {"version":3,"file":"use-permission.d.mts","names":[],"sources":["../../../../src/modules/auth/hooks/use-permission.ts"],"sourcesContent":[],"mappings":";;;;;;;AAUY,KAAA,kBAAA,GAAkB;EAgCd;;;;;;;;;AAsDhB;;eAxEmB;;;;;;;;;;;;;eAeA;;iBAGH,aAAA;;;GAAgD,4CAAkB;;;;;;;;;;;;;;iBAsDlE,cAAA,cAA4B"}
@@ -2,13 +2,60 @@
2
2
 
3
3
  import { authClient } from "../handler/client.client.mjs";
4
4
  import { useSession } from "./use-session.mjs";
5
- import { useSuspenseQueries } from "@tanstack/react-query";
5
+ import { useSuspenseQueries, useSuspenseQuery } from "@tanstack/react-query";
6
6
 
7
7
  //#region src/modules/auth/hooks/use-permission.ts
8
+ function usePermission({ permission, strategy = "all" }) {
9
+ const sessionQuery = useSession();
10
+ return useSuspenseQuery({
11
+ queryKey: ["permission", {
12
+ permission,
13
+ strategy
14
+ }],
15
+ queryFn: async () => {
16
+ if (!permission) return {
17
+ permission,
18
+ success: true
19
+ };
20
+ if (!sessionQuery.data) return {
21
+ permission,
22
+ success: false
23
+ };
24
+ const userId = sessionQuery.data?.user.id;
25
+ if (!userId) return {
26
+ permission,
27
+ success: false
28
+ };
29
+ const permissions = Array.isArray(permission) ? permission : [permission];
30
+ const results = await Promise.all(permissions.map((permission$1) => authClient.admin.hasPermission({
31
+ permission: permission$1,
32
+ userId
33
+ })));
34
+ const data = results.map(({ data: data$1 }) => data$1).filter((data$1) => !!data$1);
35
+ const errors = results.filter(({ error }) => !!error).map(({ error }) => error);
36
+ if (errors.length > 0) {
37
+ console.error(...errors);
38
+ return {
39
+ permission,
40
+ success: false
41
+ };
42
+ }
43
+ return {
44
+ permission,
45
+ success: strategy === "all" ? data.every(({ success }) => success) : data.some(({ success }) => success)
46
+ };
47
+ },
48
+ staleTime: 300 * 1e3
49
+ });
50
+ }
8
51
  /**
9
- * UsePermission
52
+ * Check multiple permissions in parallel
53
+ * @param permission
54
+ * @param strategy
55
+ * @returns
56
+ * @deprecated Use `usePermission` with strategy "any" or "all" instead
10
57
  */
11
- function usePermission(permission) {
58
+ function usePermissions(permission) {
12
59
  const sessionQuery = useSession();
13
60
  return useSuspenseQueries({
14
61
  queries: Object.entries(permission ?? {}).flatMap(([resource, permissions]) => permissions.map((permission$1) => ({ [resource]: [permission$1] }))).map((permission$1) => ({
@@ -53,5 +100,5 @@ function usePermission(permission) {
53
100
  }
54
101
 
55
102
  //#endregion
56
- export { usePermission };
103
+ export { usePermission, usePermissions };
57
104
  //# sourceMappingURL=use-permission.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-permission.mjs","names":["permission"],"sources":["../../../../src/modules/auth/hooks/use-permission.ts"],"sourcesContent":["\"use client\";\n\nimport { useSuspenseQueries } from \"@tanstack/react-query\";\nimport { authClient } from \"../handler/client.client\";\nimport { type Permission } from \"../lib/permissions\";\nimport { useSession } from \"./use-session\";\n\n/**\n * UsePermission\n */\nexport function usePermission(permission?: Permission) {\n const sessionQuery = useSession();\n\n const keys = Object.entries(permission ?? {}).flatMap(([resource, permissions]) =>\n permissions.map((permission) => ({ [resource]: [permission] }) as Permission),\n );\n\n return useSuspenseQueries({\n queries: keys.map((permission) => ({\n queryKey: [\"permission\", permission],\n queryFn: async () => {\n const userId = sessionQuery.data?.user.id;\n if (!userId) return { permission, success: false };\n\n const { data, error } = await authClient.admin.hasPermission({ permission, userId });\n if (error) {\n console.error(error);\n throw error;\n }\n\n return {\n permission,\n success: data.success,\n };\n },\n staleTime: 5 * 60 * 1000, // 5 minutes\n })),\n combine: (results) => {\n const errors = results.filter(({ error }) => error);\n if (errors.length) return { data: null, errors };\n\n const values = results.map(({ data }) => data);\n const success = results.every(({ data }) => data?.success);\n\n return { data: { success, values }, errors: null };\n },\n });\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAgB,cAAc,YAAyB;CACrD,MAAM,eAAe,YAAY;AAMjC,QAAO,mBAAmB;EACxB,SALW,OAAO,QAAQ,cAAc,EAAE,CAAC,CAAC,SAAS,CAAC,UAAU,iBAChE,YAAY,KAAK,kBAAgB,GAAG,WAAW,CAACA,aAAW,EAAE,EAAgB,CAC9E,CAGe,KAAK,kBAAgB;GACjC,UAAU,CAAC,cAAcA,aAAW;GACpC,SAAS,YAAY;IACnB,MAAM,SAAS,aAAa,MAAM,KAAK;AACvC,QAAI,CAAC,OAAQ,QAAO;KAAE;KAAY,SAAS;KAAO;IAElD,MAAM,EAAE,MAAM,UAAU,MAAM,WAAW,MAAM,cAAc;KAAE;KAAY;KAAQ,CAAC;AACpF,QAAI,OAAO;AACT,aAAQ,MAAM,MAAM;AACpB,WAAM;;AAGR,WAAO;KACL;KACA,SAAS,KAAK;KACf;;GAEH,WAAW,MAAS;GACrB,EAAE;EACH,UAAU,YAAY;GACpB,MAAM,SAAS,QAAQ,QAAQ,EAAE,YAAY,MAAM;AACnD,OAAI,OAAO,OAAQ,QAAO;IAAE,MAAM;IAAM;IAAQ;GAEhD,MAAM,SAAS,QAAQ,KAAK,EAAE,WAAW,KAAK;AAG9C,UAAO;IAAE,MAAM;KAAE,SAFD,QAAQ,OAAO,EAAE,WAAW,MAAM,QAAQ;KAEhC;KAAQ;IAAE,QAAQ;IAAM;;EAErD,CAAC"}
1
+ {"version":3,"file":"use-permission.mjs","names":["data","permission"],"sources":["../../../../src/modules/auth/hooks/use-permission.ts"],"sourcesContent":["\"use client\";\n\nimport { useSuspenseQueries, useSuspenseQuery } from \"@tanstack/react-query\";\nimport { authClient } from \"../handler/client.client\";\nimport { type Permission } from \"../lib/permissions\";\nimport { useSession } from \"./use-session\";\n\n/**\n * UsePermission\n */\nexport type UsePermissionProps =\n | {\n /**\n * Strategy to use when checking multiple permissions\n * - \"all\": all permissions must be allowed\n * - \"any\": at least one permission must be allowed\n * @default \"all\"\n */\n strategy?: \"all\";\n\n /**\n * Permission to check\n * @example { project: [\"view\", \"create\"] }\n */\n permission?: Permission;\n }\n | {\n /**\n * Strategy to use when checking multiple permissions\n * - \"all\": all permissions must be allowed\n * - \"any\": at least one permission must be allowed\n * @default \"all\"\n */\n strategy?: \"any\";\n\n /**\n * Permission to check\n * @example [{ project: [\"view\", \"create\"] }, { client: [\"view\"] }, { drive: [\"view\"] }]\n */\n permission?: Permission[];\n };\n\nexport function usePermission({ permission, strategy = \"all\" }: UsePermissionProps) {\n const sessionQuery = useSession();\n\n return useSuspenseQuery({\n queryKey: [\"permission\", { permission, strategy }],\n queryFn: async () => {\n // If no permission is provided, allow by default\n if (!permission) return { permission, success: true };\n\n // If no user is logged in, deny by default\n if (!sessionQuery.data) return { permission, success: false };\n const userId = sessionQuery.data?.user.id;\n if (!userId) return { permission, success: false };\n\n // If the strategy is \"any\", check if the user has any of the permissions\n const permissions = Array.isArray(permission) ? permission : [permission];\n\n // Check if the user has the permission\n const results = await Promise.all(\n permissions.map((permission) => authClient.admin.hasPermission({ permission, userId })),\n );\n\n const data = results.map(({ data }) => data).filter((data) => !!data);\n const errors = results.filter(({ error }) => !!error).map(({ error }) => error);\n\n // If there is an error, log it and return false\n if (errors.length > 0) {\n console.error(...errors);\n return { permission, success: false };\n }\n\n // Determine if the user has the permission based on the strategy\n const success =\n strategy === \"all\"\n ? data.every(({ success }) => success)\n : data.some(({ success }) => success);\n\n // Return the result\n return {\n permission,\n success,\n };\n },\n staleTime: 5 * 60 * 1000, // 5 minutes\n });\n}\n\n/**\n * Check multiple permissions in parallel\n * @param permission\n * @param strategy\n * @returns\n * @deprecated Use `usePermission` with strategy \"any\" or \"all\" instead\n */\nexport function usePermissions(permission?: Permission) {\n const sessionQuery = useSession();\n\n const keys = Object.entries(permission ?? {}).flatMap(([resource, permissions]) =>\n permissions.map((permission) => ({ [resource]: [permission] }) as Permission),\n );\n\n return useSuspenseQueries({\n queries: keys.map((permission) => ({\n queryKey: [\"permission\", permission],\n queryFn: async () => {\n const userId = sessionQuery.data?.user.id;\n if (!userId) return { permission, success: false };\n\n const { data, error } = await authClient.admin.hasPermission({ permission, userId });\n if (error) {\n console.error(error);\n throw error;\n }\n\n return {\n permission,\n success: data.success,\n };\n },\n staleTime: 5 * 60 * 1000, // 5 minutes\n })),\n combine: (results) => {\n const errors = results.filter(({ error }) => error);\n if (errors.length) return { data: null, errors };\n\n const values = results.map(({ data }) => data);\n const success = results.every(({ data }) => data?.success);\n\n return { data: { success, values }, errors: null };\n },\n });\n}\n"],"mappings":";;;;;;;AA0CA,SAAgB,cAAc,EAAE,YAAY,WAAW,SAA6B;CAClF,MAAM,eAAe,YAAY;AAEjC,QAAO,iBAAiB;EACtB,UAAU,CAAC,cAAc;GAAE;GAAY;GAAU,CAAC;EAClD,SAAS,YAAY;AAEnB,OAAI,CAAC,WAAY,QAAO;IAAE;IAAY,SAAS;IAAM;AAGrD,OAAI,CAAC,aAAa,KAAM,QAAO;IAAE;IAAY,SAAS;IAAO;GAC7D,MAAM,SAAS,aAAa,MAAM,KAAK;AACvC,OAAI,CAAC,OAAQ,QAAO;IAAE;IAAY,SAAS;IAAO;GAGlD,MAAM,cAAc,MAAM,QAAQ,WAAW,GAAG,aAAa,CAAC,WAAW;GAGzE,MAAM,UAAU,MAAM,QAAQ,IAC5B,YAAY,KAAK,iBAAe,WAAW,MAAM,cAAc;IAAE;IAAY;IAAQ,CAAC,CAAC,CACxF;GAED,MAAM,OAAO,QAAQ,KAAK,EAAE,mBAAWA,OAAK,CAAC,QAAQ,WAAS,CAAC,CAACA,OAAK;GACrE,MAAM,SAAS,QAAQ,QAAQ,EAAE,YAAY,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,YAAY,MAAM;AAG/E,OAAI,OAAO,SAAS,GAAG;AACrB,YAAQ,MAAM,GAAG,OAAO;AACxB,WAAO;KAAE;KAAY,SAAS;KAAO;;AAUvC,UAAO;IACL;IACA,SAPA,aAAa,QACT,KAAK,OAAO,EAAE,cAAc,QAAQ,GACpC,KAAK,MAAM,EAAE,cAAc,QAAQ;IAMxC;;EAEH,WAAW,MAAS;EACrB,CAAC;;;;;;;;;AAUJ,SAAgB,eAAe,YAAyB;CACtD,MAAM,eAAe,YAAY;AAMjC,QAAO,mBAAmB;EACxB,SALW,OAAO,QAAQ,cAAc,EAAE,CAAC,CAAC,SAAS,CAAC,UAAU,iBAChE,YAAY,KAAK,kBAAgB,GAAG,WAAW,CAACC,aAAW,EAAE,EAAgB,CAC9E,CAGe,KAAK,kBAAgB;GACjC,UAAU,CAAC,cAAcA,aAAW;GACpC,SAAS,YAAY;IACnB,MAAM,SAAS,aAAa,MAAM,KAAK;AACvC,QAAI,CAAC,OAAQ,QAAO;KAAE;KAAY,SAAS;KAAO;IAElD,MAAM,EAAE,MAAM,UAAU,MAAM,WAAW,MAAM,cAAc;KAAE;KAAY;KAAQ,CAAC;AACpF,QAAI,OAAO;AACT,aAAQ,MAAM,MAAM;AACpB,WAAM;;AAGR,WAAO;KACL;KACA,SAAS,KAAK;KACf;;GAEH,WAAW,MAAS;GACrB,EAAE;EACH,UAAU,YAAY;GACpB,MAAM,SAAS,QAAQ,QAAQ,EAAE,YAAY,MAAM;AACnD,OAAI,OAAO,OAAQ,QAAO;IAAE,MAAM;IAAM;IAAQ;GAEhD,MAAM,SAAS,QAAQ,KAAK,EAAE,WAAW,KAAK;AAG9C,UAAO;IAAE,MAAM;KAAE,SAFD,QAAQ,OAAO,EAAE,WAAW,MAAM,QAAQ;KAEhC;KAAQ;IAAE,QAAQ;IAAM;;EAErD,CAAC"}
@@ -1,5 +1,5 @@
1
- import { users } from "../db/schema.mjs";
2
1
  import { ServerError } from "../../router/lib/error.server.mjs";
2
+ import { users } from "../db/schema.mjs";
3
3
  import { eq } from "drizzle-orm";
4
4
  import "server-cli-only";
5
5
  import { headers } from "next/headers";
@@ -43,10 +43,10 @@ type CreateUserSchema = z$1.infer<typeof createUserSchema>;
43
43
  * Update user schema
44
44
  */
45
45
  declare const updateUserSchema: z$1.ZodObject<{
46
- firstName: z$1.ZodString;
47
- lastName: z$1.ZodString;
48
46
  email: z$1.ZodString;
49
47
  image: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
48
+ firstName: z$1.ZodString;
49
+ lastName: z$1.ZodString;
50
50
  }, {
51
51
  out: {};
52
52
  in: {};
@@ -1 +1 @@
1
- {"version":3,"file":"validators.d.mts","names":[],"sources":["../../../../src/modules/auth/lib/validators.ts"],"sourcesContent":[],"mappings":";;;;;;;AAQA;AAKa,KALD,IAAA,GAcV,OAdwB,KAAA,CAAM,YAc9B;;;;AATsB,cAAX,WAAW,EAAA,GAAA,CAAA,SAAA,CAAA;EAAA,KAAA,cAAA;EAcX,QAAA,eAAA;;;;;AAAmB,cAAnB,mBAAmB,EAAA,GAAA,CAAA,SAAA,CAAA;EAmBnB,QAAA,eAAA;;;;;AAUb;cAVa,sBAAoB,GAAA,CAAA;;;;;;cAUpB,kBAAgB,GAAA,CAAA;;;;;EAAA,QAAA,eAAA;EAAA,IAAA,eAAA;AAa7B,CAAA,iBAAY,CAAA;AAKC,KALD,gBAAA,GAAmB,GAAA,CAAE,KAU/B,CAAA,OAV4C,gBAU5C,CAAA;;;;cALW,kBAAgB,GAAA,CAAA;;;EAAA,KAAA,eAAA;EAAA,KAAA,iBAAA,gBAAA,cAAA,CAAA,CAAA;AAO7B,CAAA,EAAA;EAKa,GAAA,EAAA,CAAA,CAAA;;;AAAoB,KALrB,gBAAA,GAAmB,GAAA,CAAE,KAKA,CAAA,OALa,gBAKb,CAAA;;AAIjC;;cAJa,sBAAoB,GAAA,CAAA;;;KAIrB,oBAAA,GAAuB,GAAA,CAAE,aAAa"}
1
+ {"version":3,"file":"validators.d.mts","names":[],"sources":["../../../../src/modules/auth/lib/validators.ts"],"sourcesContent":[],"mappings":";;;;;;;AAQA;AAKa,KALD,IAAA,GAcV,OAdwB,KAAA,CAAM,YAc9B;;;;AATsB,cAAX,WAAW,EAAA,GAAA,CAAA,SAAA,CAAA;EAAA,KAAA,cAAA;EAcX,QAAA,eAAA;;;;;AAAmB,cAAnB,mBAAmB,EAAA,GAAA,CAAA,SAAA,CAAA;EAmBnB,QAAA,eAAA;;;;;AAUb;cAVa,sBAAoB,GAAA,CAAA;;;;;;cAUpB,kBAAgB,GAAA,CAAA;;;;;EAAA,QAAA,eAAA;EAAA,IAAA,eAAA;AAa7B,CAAA,iBAAY,CAAA;AAKC,KALD,gBAAA,GAAmB,GAAA,CAAE,KAU/B,CAAA,OAV4C,gBAU5C,CAAA;;;;cALW,kBAAgB,GAAA,CAAA;;;EAAA,SAAA,eAAA;EAAA,QAAA,eAAA;AAO7B,CAAA,EAAA;EAKa,GAAA,EAAA,CAAA,CAAA;;;AAAoB,KALrB,gBAAA,GAAmB,GAAA,CAAE,KAKA,CAAA,OALa,gBAKb,CAAA;;AAIjC;;cAJa,sBAAoB,GAAA,CAAA;;;KAIrB,oBAAA,GAAuB,GAAA,CAAE,aAAa"}
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime214 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime282 from "react/jsx-runtime";
2
2
  import React from "react";
3
3
  import { DefaultError, MutationOptions } from "@tanstack/react-query";
4
4
  import { Keys } from "react-hotkeys-hook";
@@ -11,7 +11,7 @@ import { AlertDialogCancelProps, AlertDialogContentProps, AlertDialogProps } fro
11
11
  declare function CommandAlertDialog({
12
12
  children,
13
13
  ...props
14
- }: AlertDialogProps): react_jsx_runtime214.JSX.Element;
14
+ }: AlertDialogProps): react_jsx_runtime282.JSX.Element;
15
15
  /**
16
16
  * CommandAlertDialogTrigger
17
17
  */
@@ -28,49 +28,49 @@ declare function CommandAlertDialogTrigger({
28
28
  children,
29
29
  disabled,
30
30
  ...props
31
- }: CommandAlertDialogTriggerProps): react_jsx_runtime214.JSX.Element | undefined;
31
+ }: CommandAlertDialogTriggerProps): react_jsx_runtime282.JSX.Element | undefined;
32
32
  /**
33
33
  * CommandAlertDialogContent
34
34
  */
35
35
  declare function CommandAlertDialogContent({
36
36
  children,
37
37
  ...props
38
- }: AlertDialogContentProps): react_jsx_runtime214.JSX.Element;
38
+ }: AlertDialogContentProps): react_jsx_runtime282.JSX.Element;
39
39
  /**
40
40
  * CommandAlertDialogHeader
41
41
  */
42
42
  declare function CommandAlertDialogHeader({
43
43
  children,
44
44
  ...props
45
- }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime214.JSX.Element;
45
+ }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime282.JSX.Element;
46
46
  /**
47
47
  * CommandAlertDialogTitle
48
48
  */
49
49
  declare function CommandAlertDialogTitle({
50
50
  children,
51
51
  ...props
52
- }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime214.JSX.Element;
52
+ }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime282.JSX.Element;
53
53
  /**
54
54
  * CommandAlertDialogDescription
55
55
  */
56
56
  declare function CommandAlertDialogDescription({
57
57
  children,
58
58
  ...props
59
- }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime214.JSX.Element;
59
+ }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime282.JSX.Element;
60
60
  /**
61
61
  * CommandAlertDialogFooter
62
62
  */
63
63
  declare function CommandAlertDialogFooter({
64
64
  children,
65
65
  ...props
66
- }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime214.JSX.Element;
66
+ }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime282.JSX.Element;
67
67
  /**
68
68
  * CommandAlertDialogCancel
69
69
  */
70
70
  declare function CommandAlertDialogCancel({
71
71
  children,
72
72
  ...props
73
- }: AlertDialogCancelProps): react_jsx_runtime214.JSX.Element;
73
+ }: AlertDialogCancelProps): react_jsx_runtime282.JSX.Element;
74
74
  /**
75
75
  * CommandAlertDialogAction
76
76
  */
@@ -87,7 +87,7 @@ declare function CommandAlertDialogAction<TData = unknown, TError = DefaultError
87
87
  children,
88
88
  disabled,
89
89
  ...props
90
- }: CommandAlertDialogActionProps<TData, TError, TVariables, TOnMutateResult>): react_jsx_runtime214.JSX.Element;
90
+ }: CommandAlertDialogActionProps<TData, TError, TVariables, TOnMutateResult>): react_jsx_runtime282.JSX.Element;
91
91
  //#endregion
92
92
  export { CommandAlertDialog, CommandAlertDialogAction, CommandAlertDialogCancel, CommandAlertDialogContent, CommandAlertDialogDescription, CommandAlertDialogFooter, CommandAlertDialogHeader, CommandAlertDialogTitle, CommandAlertDialogTrigger };
93
93
  //# sourceMappingURL=alert-dialog-command.client.d.mts.map
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime223 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime292 from "react/jsx-runtime";
2
2
  import React from "react";
3
3
  import { DefaultError, MutationOptions } from "@tanstack/react-query";
4
4
  import { Keys } from "react-hotkeys-hook";
@@ -21,7 +21,7 @@ declare function CommandClick<TData = unknown, TError = DefaultError, TVariables
21
21
  hotkey,
22
22
  disabled,
23
23
  ...props
24
- }: CommandClickProps<TData, TError, TVariables, TOnMutateResult>): react_jsx_runtime223.JSX.Element | null;
24
+ }: CommandClickProps<TData, TError, TVariables, TOnMutateResult>): react_jsx_runtime292.JSX.Element | null;
25
25
  //#endregion
26
26
  export { CommandClick, CommandClickProps };
27
27
  //# sourceMappingURL=click-command.client.d.mts.map
@@ -1,5 +1,5 @@
1
- import * as react_jsx_runtime224 from "react/jsx-runtime";
2
- import * as react104 from "react";
1
+ import * as react_jsx_runtime293 from "react/jsx-runtime";
2
+ import * as react105 from "react";
3
3
  import { PropsWithChildren } from "react";
4
4
 
5
5
  //#region src/modules/commands/components/command-trigger.client.d.ts
@@ -9,7 +9,7 @@ import { PropsWithChildren } from "react";
9
9
  type CommandTriggerContextValue = {
10
10
  label?: string;
11
11
  };
12
- declare const CommandTriggerContext: react104.Context<CommandTriggerContextValue>;
12
+ declare const CommandTriggerContext: react105.Context<CommandTriggerContextValue>;
13
13
  /**
14
14
  * Command trigger
15
15
  */
@@ -18,17 +18,17 @@ declare function CommandTrigger({
18
18
  children
19
19
  }: PropsWithChildren<{
20
20
  label?: string;
21
- }>): react_jsx_runtime224.JSX.Element;
21
+ }>): react_jsx_runtime293.JSX.Element;
22
22
  /**
23
23
  * Command label
24
24
  */
25
- declare function CommandLabel(): react_jsx_runtime224.JSX.Element | null;
25
+ declare function CommandLabel(): react_jsx_runtime293.JSX.Element | null;
26
26
  /**
27
27
  * Command icon
28
28
  */
29
29
  declare function CommandIcon({
30
30
  children
31
- }: PropsWithChildren): react_jsx_runtime224.JSX.Element;
31
+ }: PropsWithChildren): react_jsx_runtime293.JSX.Element;
32
32
  //#endregion
33
33
  export { CommandIcon, CommandLabel, CommandTrigger, CommandTriggerContext };
34
34
  //# sourceMappingURL=command-trigger.client.d.mts.map
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime227 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime296 from "react/jsx-runtime";
2
2
  import React from "react";
3
3
  import { DialogContentProps, DialogProps } from "@radix-ui/react-dialog";
4
4
  import { Keys } from "react-hotkeys-hook";
@@ -20,7 +20,7 @@ declare function CommandDialog({
20
20
  ...props
21
21
  }: Omit<DialogProps, "open" | "onOpenChange"> & {
22
22
  openState?: CommandDialogOpenState;
23
- }): react_jsx_runtime227.JSX.Element;
23
+ }): react_jsx_runtime296.JSX.Element;
24
24
  /**
25
25
  * CommandDialogTrigger
26
26
  */
@@ -37,42 +37,42 @@ declare function CommandDialogTrigger({
37
37
  children,
38
38
  disabled,
39
39
  ...props
40
- }: CommandDialogTriggerProps): react_jsx_runtime227.JSX.Element | undefined;
40
+ }: CommandDialogTriggerProps): react_jsx_runtime296.JSX.Element | undefined;
41
41
  /**
42
42
  * CommandDialogContent
43
43
  */
44
44
  declare function CommandDialogContent({
45
45
  children,
46
46
  ...props
47
- }: DialogContentProps): react_jsx_runtime227.JSX.Element;
47
+ }: DialogContentProps): react_jsx_runtime296.JSX.Element;
48
48
  /**
49
49
  * CommandDialogHeader
50
50
  */
51
51
  declare function CommandDialogHeader({
52
52
  children,
53
53
  ...props
54
- }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime227.JSX.Element;
54
+ }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime296.JSX.Element;
55
55
  /**
56
56
  * CommandDialogTitle
57
57
  */
58
58
  declare function CommandDialogTitle({
59
59
  children,
60
60
  ...props
61
- }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime227.JSX.Element;
61
+ }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime296.JSX.Element;
62
62
  /**
63
63
  * CommandDialogDescription
64
64
  */
65
65
  declare function CommandDialogDescription({
66
66
  children,
67
67
  ...props
68
- }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime227.JSX.Element;
68
+ }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime296.JSX.Element;
69
69
  /**
70
70
  * CommandDialogFooter
71
71
  */
72
72
  declare function CommandDialogFooter({
73
73
  children,
74
74
  ...props
75
- }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime227.JSX.Element;
75
+ }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime296.JSX.Element;
76
76
  //#endregion
77
77
  export { CommandDialog, CommandDialogContent, CommandDialogDescription, CommandDialogFooter, CommandDialogHeader, CommandDialogTitle, CommandDialogTrigger };
78
78
  //# sourceMappingURL=dialog-command.client.d.mts.map
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime234 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime303 from "react/jsx-runtime";
2
2
  import React from "react";
3
3
  import { DefaultError, MutationOptions } from "@tanstack/react-query";
4
4
 
@@ -13,7 +13,7 @@ type CommandDropdownProps = {
13
13
  declare function CommandDropdown({
14
14
  children,
15
15
  ...props
16
- }: CommandDropdownProps): react_jsx_runtime234.JSX.Element | null;
16
+ }: CommandDropdownProps): react_jsx_runtime303.JSX.Element | null;
17
17
  /**
18
18
  * CommandDropdownContent
19
19
  */
@@ -24,7 +24,7 @@ type CommandDropdownContentProps = {
24
24
  declare function CommandDropdownContent({
25
25
  children,
26
26
  ...props
27
- }: CommandDropdownContentProps): react_jsx_runtime234.JSX.Element | null;
27
+ }: CommandDropdownContentProps): react_jsx_runtime303.JSX.Element | null;
28
28
  /**
29
29
  * CommandDropdownTrigger
30
30
  */
@@ -39,7 +39,7 @@ declare function CommandDropdownTrigger({
39
39
  disabled,
40
40
  children,
41
41
  ...props
42
- }: CommandDropdownTriggerProps): react_jsx_runtime234.JSX.Element | null;
42
+ }: CommandDropdownTriggerProps): react_jsx_runtime303.JSX.Element | null;
43
43
  /**
44
44
  * CommandDropdownItem
45
45
  */
@@ -54,7 +54,7 @@ declare function CommandDropdownItem<TData = unknown, TError = DefaultError, TVa
54
54
  mutation,
55
55
  children,
56
56
  ...props
57
- }: CommandDropdownItemProps<TData, TError, TVariables, TOnMutateResult>): react_jsx_runtime234.JSX.Element | null;
57
+ }: CommandDropdownItemProps<TData, TError, TVariables, TOnMutateResult>): react_jsx_runtime303.JSX.Element | null;
58
58
  //#endregion
59
59
  export { CommandDropdown, CommandDropdownContent, CommandDropdownItem, CommandDropdownProps, CommandDropdownTrigger };
60
60
  //# sourceMappingURL=dropdown-command.client.d.mts.map
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime238 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime307 from "react/jsx-runtime";
2
2
  import React from "react";
3
3
 
4
4
  //#region src/modules/commands/components/empty-command.client.d.ts
@@ -13,7 +13,7 @@ declare function CommandEmpty({
13
13
  children,
14
14
  disabled,
15
15
  ...props
16
- }: CommandEmptyProps): react_jsx_runtime238.JSX.Element | null;
16
+ }: CommandEmptyProps): react_jsx_runtime307.JSX.Element | null;
17
17
  //#endregion
18
18
  export { CommandEmpty, CommandEmptyProps };
19
19
  //# sourceMappingURL=empty-command.client.d.mts.map
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime239 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime308 from "react/jsx-runtime";
2
2
  import React, { ComponentProps } from "react";
3
3
  import { DefaultError, MutationOptions } from "@tanstack/react-query";
4
4
  import { FieldValues, Form } from "react-hook-form";
@@ -12,7 +12,7 @@ import { Keys } from "react-hotkeys-hook";
12
12
  declare function CommandFormDialog({
13
13
  children,
14
14
  ...props
15
- }: DialogProps): react_jsx_runtime239.JSX.Element;
15
+ }: DialogProps): react_jsx_runtime308.JSX.Element;
16
16
  /**
17
17
  * CommandFormDialogTrigger
18
18
  */
@@ -29,28 +29,28 @@ declare function CommandFormDialogTrigger({
29
29
  children,
30
30
  disabled,
31
31
  ...props
32
- }: CommandFormDialogTriggerProps): react_jsx_runtime239.JSX.Element | undefined;
32
+ }: CommandFormDialogTriggerProps): react_jsx_runtime308.JSX.Element | undefined;
33
33
  /**
34
34
  * CommandFormDialogHeader
35
35
  */
36
36
  declare function CommandFormDialogHeader({
37
37
  children,
38
38
  ...props
39
- }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime239.JSX.Element;
39
+ }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime308.JSX.Element;
40
40
  /**
41
41
  * CommandFormDialogTitle
42
42
  */
43
43
  declare function CommandFormDialogTitle({
44
44
  children,
45
45
  ...props
46
- }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime239.JSX.Element;
46
+ }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime308.JSX.Element;
47
47
  /**
48
48
  * CommandFormDialogDescription
49
49
  */
50
50
  declare function CommandFormDialogDescription({
51
51
  children,
52
52
  ...props
53
- }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime239.JSX.Element;
53
+ }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime308.JSX.Element;
54
54
  declare const CommandFormDialogContentProvider: typeof Form;
55
55
  /**
56
56
  * CommandFormDialogContent
@@ -65,7 +65,7 @@ declare function CommandFormDialogContent<TValues extends FieldValues, TData = u
65
65
  mutation,
66
66
  children,
67
67
  ...props
68
- }: CommandFormDialogContentProps<TValues, TData, TError, TVariables, TOnMutateResult>): react_jsx_runtime239.JSX.Element;
68
+ }: CommandFormDialogContentProps<TValues, TData, TError, TVariables, TOnMutateResult>): react_jsx_runtime308.JSX.Element;
69
69
  /**
70
70
  * FormDialogFields
71
71
  */
@@ -73,28 +73,28 @@ declare function CommandFormDialogFields({
73
73
  children,
74
74
  className,
75
75
  ...props
76
- }: ComponentProps<"div">): react_jsx_runtime239.JSX.Element;
76
+ }: ComponentProps<"div">): react_jsx_runtime308.JSX.Element;
77
77
  /**
78
78
  * CommandFormDialogFooter
79
79
  */
80
80
  declare function CommandFormDialogFooter({
81
81
  children,
82
82
  ...props
83
- }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime239.JSX.Element;
83
+ }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime308.JSX.Element;
84
84
  /**
85
85
  * CommandFormDialogCancel
86
86
  */
87
87
  declare function CommandFormDialogCancel({
88
88
  children,
89
89
  ...props
90
- }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime239.JSX.Element;
90
+ }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime308.JSX.Element;
91
91
  /**
92
92
  * CommandFormDialogSubmit
93
93
  */
94
94
  declare function CommandFormDialogSubmit({
95
95
  children,
96
96
  ...props
97
- }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime239.JSX.Element;
97
+ }: React.HTMLAttributes<HTMLElement>): react_jsx_runtime308.JSX.Element;
98
98
  //#endregion
99
99
  export { CommandFormDialog, CommandFormDialogCancel, CommandFormDialogContent, CommandFormDialogContentProps, CommandFormDialogContentProvider, CommandFormDialogDescription, CommandFormDialogFields, CommandFormDialogFooter, CommandFormDialogHeader, CommandFormDialogSubmit, CommandFormDialogTitle, CommandFormDialogTrigger };
100
100
  //# sourceMappingURL=form-dialog-command.client.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-command-menu.client.d.mts","names":[],"sources":["../../../../src/modules/commands/hooks/use-command-menu.client.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;KAcY;EAAA,IAAA,EACJ,KADI;EACJ,QAAA,EACI,UADJ,CACe,KADf,EACsB,KADtB,CAAA,EAAA;EACe,IAAA,CAAA,EACd,KADc;CAAO"}
1
+ {"version":3,"file":"use-command-menu.client.d.mts","names":[],"sources":["../../../../src/modules/commands/hooks/use-command-menu.client.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;KAWY;QACJ;EADI,QAAA,EAEA,UAFA,CAEW,KAFW,EAEJ,KAFI,CAAA,EAAA;EAC1B,IAAA,CAAA,EAEC,KAFD;CACe"}
@@ -1,8 +1,5 @@
1
1
  "use client";
2
2
 
3
- import { mergePermissions } from "../../auth/lib/utils.mjs";
4
- import { usePermission } from "../../auth/hooks/use-permission.mjs";
5
-
6
3
  //#region src/modules/commands/hooks/use-command-menu.client.tsx
7
4
  /**
8
5
  * Check if a command has an id field in the data
@@ -37,7 +34,6 @@ function renderBulkCommand({ data, command, meta }) {
37
34
  * useSingleCommandMenu
38
35
  */
39
36
  function useSingleCommandMenu({ data, commands, meta }) {
40
- usePermission(mergePermissions(commands.map((command) => command.permission).filter(Boolean)));
41
37
  const validCommands = commands.filter((command) => command.mode === "single" ? validateSingleCommand({
42
38
  data,
43
39
  command
@@ -62,7 +58,6 @@ function useSingleCommandMenu({ data, commands, meta }) {
62
58
  * useBulkCommandMenu
63
59
  */
64
60
  function useBulkCommandMenu({ data, commands, meta }) {
65
- usePermission(mergePermissions(commands.map((command) => command.permission).filter(Boolean)));
66
61
  /**
67
62
  * Filter out commands that don't have valid conditions
68
63
  */
@@ -1 +1 @@
1
- {"version":3,"file":"use-command-menu.client.mjs","names":["data"],"sources":["../../../../src/modules/commands/hooks/use-command-menu.client.tsx"],"sourcesContent":["\"use client\";\n\nimport { Permission } from \"@/modules/auth/entry\";\nimport { usePermission } from \"@/modules/auth/hooks/use-permission\";\nimport { mergePermissions } from \"@/modules/auth/lib/utils\";\nimport {\n type BulkCommandDefRenderParams,\n type CommandDef,\n type SingleCommandDefRenderParams,\n} from \"../lib/definitions\";\n\n/**\n * Command menu props\n */\nexport type SingleCommandMenuProps<TData, TMeta> = {\n data: TData;\n commands: CommandDef<TData, TMeta>[];\n meta?: TMeta;\n};\n\nexport type BulkCommandMenuProps<TData, TMeta> = {\n data: TData[];\n commands: CommandDef<TData, TMeta>[];\n meta?: TMeta;\n};\n\n/**\n * Check if a command has an id field in the data\n */\nfunction dataHasId<TData>(data: TData) {\n return data && typeof data === \"object\" && \"id\" in data && typeof data.id === \"string\";\n}\n\n/**\n * Single command validation\n */\ntype ValidateSingleCommandParams<TData, TMeta> = {\n data: TData;\n command: CommandDef<TData, TMeta> & { mode: \"single\" };\n};\n\nfunction validateSingleCommand<TData, TMeta>({\n data,\n command,\n}: ValidateSingleCommandParams<TData, TMeta>) {\n const valid = command.conditions?.({ data });\n return Array.isArray(valid) ? valid.every(Boolean) : (valid ?? true);\n}\n\n/**\n * Single command rendering\n */\ntype RenderSingleCommandParams<TData, TMeta> = {\n data: TData;\n meta?: TMeta;\n command: CommandDef<TData, TMeta> & { mode: \"single\" };\n};\n\nfunction renderSingleCommand<TData, TMeta>({\n data,\n command,\n meta,\n}: RenderSingleCommandParams<TData, TMeta>) {\n return command.render({\n data,\n meta: meta ?? ({} as TMeta),\n ...(dataHasId(data) ? { id: (data as TData & { id: string }).id } : {}),\n } as SingleCommandDefRenderParams<TData, TMeta>);\n}\n\n/**\n * Bulk command validation\n */\ntype ValidateBulkCommandParams<TData, TMeta> = {\n data: TData[];\n command: CommandDef<TData, TMeta> & { mode: \"bulk\" };\n};\n\nfunction validateBulkCommand<TData, TMeta>({\n data,\n command,\n}: ValidateBulkCommandParams<TData, TMeta>) {\n const valid = command.conditions?.({ data });\n return Array.isArray(valid) ? valid.every(Boolean) : (valid ?? true);\n}\n\n/**\n * Bulk command rendering\n */\ntype RenderBulkCommandParams<TData, TMeta> = {\n data: TData[];\n command: CommandDef<TData, TMeta> & { mode: \"bulk\" };\n meta?: TMeta;\n};\n\nfunction renderBulkCommand<TData, TMeta>({\n data,\n command,\n meta,\n}: RenderBulkCommandParams<TData, TMeta>) {\n const ids = data.filter(dataHasId).map((data) => (data as TData & { id: string }).id);\n\n return command.render({\n data,\n meta: meta ?? ({} as TMeta),\n ...(ids.length > 0 ? { ids } : {}),\n } as BulkCommandDefRenderParams<TData, TMeta>);\n}\n\n/**\n * useSingleCommandMenu\n */\nexport function useSingleCommandMenu<TData, TMeta>({\n data,\n commands,\n meta,\n}: SingleCommandMenuProps<TData, TMeta> & { data: TData }) {\n const permissions = commands.map((command) => command.permission).filter(Boolean) as Permission[];\n usePermission(mergePermissions(permissions));\n\n // filter out commands that don't have valid conditions\n const validCommands = commands.filter((command) =>\n command.mode === \"single\"\n ? validateSingleCommand({ data, command })\n : validateBulkCommand({ data: [data], command }),\n );\n\n function renderCommand(command: (typeof validCommands)[number]) {\n return command.mode === \"single\"\n ? renderSingleCommand({ command, data, meta })\n : renderBulkCommand({ command, data: [data], meta });\n }\n\n return [validCommands, renderCommand] as const;\n}\n\n/**\n * useBulkCommandMenu\n */\nexport function useBulkCommandMenu<TData, TMeta>({\n data,\n commands,\n meta,\n}: BulkCommandMenuProps<TData, TMeta>) {\n const permissions = commands.map((command) => command.permission).filter(Boolean) as Permission[];\n usePermission(mergePermissions(permissions));\n\n /**\n * Filter out commands that don't have valid conditions\n */\n const validCommands = commands\n // filter out commands that have mode \"bulk\"\n .filter((command) => command.mode === \"bulk\")\n // filter out commands that don't have valid conditions\n .filter((command) => command.mode === \"bulk\" && validateBulkCommand({ data, command }));\n\n /**\n * Render command\n */\n function renderCommand(command: (typeof commands)[number]) {\n if (command.mode === \"single\") return null;\n\n return renderBulkCommand({ command, data, meta });\n }\n\n return [validCommands, renderCommand] as const;\n}\n\n// export function useBulkCommandMenu<TData, TMeta>({\n// data,\n// commands,\n// meta,\n// }: BulkCommandMenuProps<TData, TMeta>) {\n// /**\n// * Filter out commands that don't have valid conditions\n// */\n// const validCommands = useSuspenseQueries({\n// queries: commands.flatMap((command) => ({\n// queryKey: [\"command\", command],\n// queryFn: async () => {\n// const { mode, permission } = command;\n\n// // filter out commands that have mode \"bulk\"\n// if (mode !== \"bulk\") return null;\n\n// // filter out commands that don't have valid conditions\n// if (!validateBulkCommand({ data, command })) return null;\n\n// // filter out commands that don't have a permissions defined\n// if (!permission) return command;\n\n// // filter out commands that don't have valid permissions\n// const session = await authClient.getSession();\n// const userId = session.data?.user.id;\n// const hasPermission = await authClient.admin.hasPermission({ permission, userId });\n// if (!hasPermission.data?.success) return null;\n\n// return command;\n// },\n// })),\n// combine: (items) =>\n// items.filter(({ data }) => data).map(({ data }) => data as NonNullable<typeof data>),\n// });\n\n// /**\n// * Render command\n// */\n// const renderCommand = (command: (typeof validCommands)[number]) =>\n// renderBulkCommand({ command, data, meta });\n\n// return [validCommands, renderCommand] as const;\n// }\n\n// */\n// export function useSingleCommandMenu<TData, TMeta>({\n// data,\n// commands,\n// meta,\n// }: SingleCommandMenuProps<TData, TMeta> & { data: TData }) {\n// /**\n// * Filter out commands that don't have valid conditions\n// */\n// const validCommands = useSuspenseQueries({\n// queries: commands.flatMap((command) => ({\n// queryKey: [\"command\", command],\n// queryFn: async () => {\n// const { mode, permission } = command;\n\n// // filter out commands that don't have valid conditions\n// if (mode === \"single\" && !validateSingleCommand({ data, command })) return null;\n// if (mode === \"bulk\" && !validateBulkCommand({ data: [data], command })) return null;\n\n// // filter out commands that don't have a permissions defined\n// if (!permission) return command;\n\n// // filter out commands that don't have valid permissions\n// const session = await authClient.getSession();\n// const userId = session.data?.user.id;\n// const hasPermission = await authClient.admin.hasPermission({ permission, userId });\n// if (!hasPermission.data?.success) return null;\n\n// return command;\n// },\n// })),\n// combine: (items) =>\n// items.filter(({ data }) => data).map(({ data }) => data as NonNullable<typeof data>),\n// });\n\n// /**\n// * Render command\n// */\n// function renderCommand(command: (typeof validCommands)[number]) {\n// return command.mode === \"single\"\n// ? renderSingleCommand({ command, data, meta })\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AAC9D,SAAO,QAAQ,SAAS,WACpB,oBAAoB;GAAE;GAAS;GAAM;GAAM,CAAC,GAC5C,kBAAkB;GAAE;GAAS,MAAM,CAAC,KAAK;GAAE;GAAM,CAAC;;AAGxD,QAAO,CAAC,eAAe,cAAc;;;;;AAMvC,SAAgB,mBAAiC,EAC/C,MACA,UACA,QACqC;AAErC,eAAc,iBADM,SAAS,KAAK,YAAY,QAAQ,WAAW,CAAC,OAAO,QAAQ,CACtC,CAAC;;;;CAK5C,MAAM,gBAAgB,SAEnB,QAAQ,YAAY,QAAQ,SAAS,OAAO,CAE5C,QAAQ,YAAY,QAAQ,SAAS,UAAU,oBAAoB;EAAE;EAAM;EAAS,CAAC,CAAC;;;;CAKzF,SAAS,cAAc,SAAoC;AACzD,MAAI,QAAQ,SAAS,SAAU,QAAO;AAEtC,SAAO,kBAAkB;GAAE;GAAS;GAAM;GAAM,CAAC;;AAGnD,QAAO,CAAC,eAAe,cAAc"}
1
+ {"version":3,"file":"use-command-menu.client.mjs","names":["data"],"sources":["../../../../src/modules/commands/hooks/use-command-menu.client.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type BulkCommandDefRenderParams,\n type CommandDef,\n type SingleCommandDefRenderParams,\n} from \"../lib/definitions\";\n\n/**\n * Command menu props\n */\nexport type SingleCommandMenuProps<TData, TMeta> = {\n data: TData;\n commands: CommandDef<TData, TMeta>[];\n meta?: TMeta;\n};\n\nexport type BulkCommandMenuProps<TData, TMeta> = {\n data: TData[];\n commands: CommandDef<TData, TMeta>[];\n meta?: TMeta;\n};\n\n/**\n * Check if a command has an id field in the data\n */\nfunction dataHasId<TData>(data: TData) {\n return data && typeof data === \"object\" && \"id\" in data && typeof data.id === \"string\";\n}\n\n/**\n * Single command validation\n */\ntype ValidateSingleCommandParams<TData, TMeta> = {\n data: TData;\n command: CommandDef<TData, TMeta> & { mode: \"single\" };\n};\n\nfunction validateSingleCommand<TData, TMeta>({\n data,\n command,\n}: ValidateSingleCommandParams<TData, TMeta>) {\n const valid = command.conditions?.({ data });\n return Array.isArray(valid) ? valid.every(Boolean) : (valid ?? true);\n}\n\n/**\n * Single command rendering\n */\ntype RenderSingleCommandParams<TData, TMeta> = {\n data: TData;\n meta?: TMeta;\n command: CommandDef<TData, TMeta> & { mode: \"single\" };\n};\n\nfunction renderSingleCommand<TData, TMeta>({\n data,\n command,\n meta,\n}: RenderSingleCommandParams<TData, TMeta>) {\n return command.render({\n data,\n meta: meta ?? ({} as TMeta),\n ...(dataHasId(data) ? { id: (data as TData & { id: string }).id } : {}),\n } as SingleCommandDefRenderParams<TData, TMeta>);\n}\n\n/**\n * Bulk command validation\n */\ntype ValidateBulkCommandParams<TData, TMeta> = {\n data: TData[];\n command: CommandDef<TData, TMeta> & { mode: \"bulk\" };\n};\n\nfunction validateBulkCommand<TData, TMeta>({\n data,\n command,\n}: ValidateBulkCommandParams<TData, TMeta>) {\n const valid = command.conditions?.({ data });\n return Array.isArray(valid) ? valid.every(Boolean) : (valid ?? true);\n}\n\n/**\n * Bulk command rendering\n */\ntype RenderBulkCommandParams<TData, TMeta> = {\n data: TData[];\n command: CommandDef<TData, TMeta> & { mode: \"bulk\" };\n meta?: TMeta;\n};\n\nfunction renderBulkCommand<TData, TMeta>({\n data,\n command,\n meta,\n}: RenderBulkCommandParams<TData, TMeta>) {\n const ids = data.filter(dataHasId).map((data) => (data as TData & { id: string }).id);\n\n return command.render({\n data,\n meta: meta ?? ({} as TMeta),\n ...(ids.length > 0 ? { ids } : {}),\n } as BulkCommandDefRenderParams<TData, TMeta>);\n}\n\n/**\n * useSingleCommandMenu\n */\nexport function useSingleCommandMenu<TData, TMeta>({\n data,\n commands,\n meta,\n}: SingleCommandMenuProps<TData, TMeta> & { data: TData }) {\n // const permissions = commands.map((command) => command.permission).filter(Boolean) as Permission[];\n // usePermission(mergePermissions(permissions));\n\n // filter out commands that don't have valid conditions\n const validCommands = commands.filter((command) =>\n command.mode === \"single\"\n ? validateSingleCommand({ data, command })\n : validateBulkCommand({ data: [data], command }),\n );\n\n function renderCommand(command: (typeof validCommands)[number]) {\n return command.mode === \"single\"\n ? renderSingleCommand({ command, data, meta })\n : renderBulkCommand({ command, data: [data], meta });\n }\n\n return [validCommands, renderCommand] as const;\n}\n\n/**\n * useBulkCommandMenu\n */\nexport function useBulkCommandMenu<TData, TMeta>({\n data,\n commands,\n meta,\n}: BulkCommandMenuProps<TData, TMeta>) {\n // const permissions = commands.map((command) => command.permission).filter(Boolean) as Permission[];\n // usePermission(mergePermissions(permissions));\n\n /**\n * Filter out commands that don't have valid conditions\n */\n const validCommands = commands\n // filter out commands that have mode \"bulk\"\n .filter((command) => command.mode === \"bulk\")\n // filter out commands that don't have valid conditions\n .filter((command) => command.mode === \"bulk\" && validateBulkCommand({ data, command }));\n\n /**\n * Render command\n */\n function renderCommand(command: (typeof commands)[number]) {\n if (command.mode === \"single\") return null;\n\n return renderBulkCommand({ command, data, meta });\n }\n\n return [validCommands, renderCommand] as const;\n}\n\n// export function useBulkCommandMenu<TData, TMeta>({\n// data,\n// commands,\n// meta,\n// }: BulkCommandMenuProps<TData, TMeta>) {\n// /**\n// * Filter out commands that don't have valid conditions\n// */\n// const validCommands = useSuspenseQueries({\n// queries: commands.flatMap((command) => ({\n// queryKey: [\"command\", command],\n// queryFn: async () => {\n// const { mode, permission } = command;\n\n// // filter out commands that have mode \"bulk\"\n// if (mode !== \"bulk\") return null;\n\n// // filter out commands that don't have valid conditions\n// if (!validateBulkCommand({ data, command })) return null;\n\n// // filter out commands that don't have a permissions defined\n// if (!permission) return command;\n\n// // filter out commands that don't have valid permissions\n// const session = await authClient.getSession();\n// const userId = session.data?.user.id;\n// const hasPermission = await authClient.admin.hasPermission({ permission, userId });\n// if (!hasPermission.data?.success) return null;\n\n// return command;\n// },\n// })),\n// combine: (items) =>\n// items.filter(({ data }) => data).map(({ data }) => data as NonNullable<typeof data>),\n// });\n\n// /**\n// * Render command\n// */\n// const renderCommand = (command: (typeof validCommands)[number]) =>\n// renderBulkCommand({ command, data, meta });\n\n// return [validCommands, renderCommand] as const;\n// }\n\n// */\n// export function useSingleCommandMenu<TData, TMeta>({\n// data,\n// commands,\n// meta,\n// }: SingleCommandMenuProps<TData, TMeta> & { data: TData }) {\n// /**\n// * Filter out commands that don't have valid conditions\n// */\n// const validCommands = useSuspenseQueries({\n// queries: commands.flatMap((command) => ({\n// queryKey: [\"command\", command],\n// queryFn: async () => {\n// const { mode, permission } = command;\n\n// // filter out commands that don't have valid conditions\n// if (mode === \"single\" && !validateSingleCommand({ data, command })) return null;\n// if (mode === \"bulk\" && !validateBulkCommand({ data: [data], command })) return null;\n\n// // filter out commands that don't have a permissions defined\n// if (!permission) return command;\n\n// // filter out commands that don't have valid permissions\n// const session = await authClient.getSession();\n// const userId = session.data?.user.id;\n// const hasPermission = await authClient.admin.hasPermission({ permission, userId });\n// if (!hasPermission.data?.success) return null;\n\n// return command;\n// },\n// })),\n// combine: (items) =>\n// items.filter(({ data }) => data).map(({ data }) => data as NonNullable<typeof data>),\n// });\n\n// /**\n// * Render command\n// */\n// function renderCommand(command: (typeof validCommands)[number]) {\n// return command.mode === \"single\"\n// ? renderSingleCommand({ command, data, meta })\n// : renderBulkCommand({ command, data: [data], meta });\n// }\n\n// return [validCommands, renderCommand] as const;\n// }\n"],"mappings":";;;;;;AA0BA,SAAS,UAAiB,MAAa;AACrC,QAAO,QAAQ,OAAO,SAAS,YAAY,QAAQ,QAAQ,OAAO,KAAK,OAAO;;AAWhF,SAAS,sBAAoC,EAC3C,MACA,WAC4C;CAC5C,MAAM,QAAQ,QAAQ,aAAa,EAAE,MAAM,CAAC;AAC5C,QAAO,MAAM,QAAQ,MAAM,GAAG,MAAM,MAAM,QAAQ,GAAI,SAAS;;AAYjE,SAAS,oBAAkC,EACzC,MACA,SACA,QAC0C;AAC1C,QAAO,QAAQ,OAAO;EACpB;EACA,MAAM,QAAS,EAAE;EACjB,GAAI,UAAU,KAAK,GAAG,EAAE,IAAK,KAAgC,IAAI,GAAG,EAAE;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