@tulip-systems/core 0.5.13 → 0.5.15

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 (229) hide show
  1. package/dist/auth/client.d.mts +5 -4
  2. package/dist/auth/client.mjs +6 -5
  3. package/dist/auth.mjs +2 -2
  4. package/dist/components/client.mjs +2 -2
  5. package/dist/components/common/icons.d.mts +52 -52
  6. package/dist/components/common/status.d.mts +3 -3
  7. package/dist/components/editor/components/content.client.d.mts +2 -2
  8. package/dist/components/editor/components/editor.client.d.mts +6 -6
  9. package/dist/components/editor/components/editor.client.d.mts.map +1 -1
  10. package/dist/components/editor/components/menu.client.d.mts +3 -3
  11. package/dist/components/header/back-button.client.d.mts +2 -2
  12. package/dist/components/header/bottom-bar.client.d.mts +3 -3
  13. package/dist/components/header/breadcrumbs.client.d.mts +7 -7
  14. package/dist/components/header/header.client.d.mts +2 -2
  15. package/dist/components/header/mobile-nav-switcher.client.d.mts +2 -2
  16. package/dist/components/header/top-bar.client.d.mts +4 -4
  17. package/dist/components/layouts/admin-content.client.d.mts +2 -2
  18. package/dist/components/layouts/admin-error-pages.d.mts +4 -4
  19. package/dist/components/layouts/admin-layout.d.mts +2 -2
  20. package/dist/components/layouts/admin-layout.mjs +1 -1
  21. package/dist/components/layouts/admin-layout.mjs.map +1 -1
  22. package/dist/components/layouts/admin-loading.d.mts +2 -2
  23. package/dist/components/layouts/empty-page.d.mts +4 -4
  24. package/dist/components/layouts/error-page.d.mts +9 -9
  25. package/dist/components/layouts/error-sections.d.mts +5 -5
  26. package/dist/components/layouts/list-layout.d.mts +2 -2
  27. package/dist/components/layouts/providers.client.d.mts +2 -2
  28. package/dist/components/layouts/root-error-pages.d.mts +2 -2
  29. package/dist/components/layouts/root-layout.server.d.mts +4 -4
  30. package/dist/components/layouts/root-layout.server.d.mts.map +1 -1
  31. package/dist/components/layouts/root-loading.d.mts +2 -2
  32. package/dist/components/layouts/tab-layout.d.mts +2 -2
  33. package/dist/components/lists/data-list.d.mts +5 -5
  34. package/dist/components/lists/data-stack.d.mts +8 -8
  35. package/dist/components/navigation/admin-sidebar-header.client.mjs +3 -2
  36. package/dist/components/navigation/admin-sidebar-header.client.mjs.map +1 -1
  37. package/dist/components/navigation/admin-sidebar-paths.client.d.mts +10 -10
  38. package/dist/components/ui/accordion.d.mts +5 -5
  39. package/dist/components/ui/alert-dialog.d.mts +12 -12
  40. package/dist/components/ui/alert.d.mts +6 -6
  41. package/dist/components/ui/aspect-ratio.d.mts +2 -2
  42. package/dist/components/ui/avatar.client.d.mts +4 -4
  43. package/dist/components/ui/badge.d.mts +4 -4
  44. package/dist/components/ui/breadcrumb.d.mts +8 -8
  45. package/dist/components/ui/button.d.mts +4 -4
  46. package/dist/components/ui/calendar.d.mts +3 -3
  47. package/dist/components/ui/card.d.mts +7 -7
  48. package/dist/components/ui/carousel.d.mts +6 -6
  49. package/dist/components/ui/chart.client.d.mts +5 -5
  50. package/dist/components/ui/checkbox.d.mts +2 -2
  51. package/dist/components/ui/collapsible.client.d.mts +4 -4
  52. package/dist/components/ui/color-picker.client.d.mts +2 -2
  53. package/dist/components/ui/combobox-dropdown.client.d.mts +2 -2
  54. package/dist/components/ui/combobox.client.d.mts +2 -2
  55. package/dist/components/ui/command.d.mts +10 -10
  56. package/dist/components/ui/context-menu.d.mts +16 -16
  57. package/dist/components/ui/date-picker.client.d.mts +2 -2
  58. package/dist/components/ui/dialog.client.d.mts +11 -11
  59. package/dist/components/ui/drawer.client.d.mts +11 -11
  60. package/dist/components/ui/dropdown-menu.d.mts +16 -16
  61. package/dist/components/ui/form.client.d.mts +7 -7
  62. package/dist/components/ui/hover-card.client.d.mts +4 -4
  63. package/dist/components/ui/input-recipient.d.mts +2 -2
  64. package/dist/components/ui/input.d.mts +2 -2
  65. package/dist/components/ui/label.d.mts +2 -2
  66. package/dist/components/ui/navigation-menu.d.mts +11 -11
  67. package/dist/components/ui/pagination.d.mts +8 -8
  68. package/dist/components/ui/popover.d.mts +5 -5
  69. package/dist/components/ui/progress.client.d.mts +2 -2
  70. package/dist/components/ui/radio-group.d.mts +3 -3
  71. package/dist/components/ui/resizable.client.d.mts +4 -4
  72. package/dist/components/ui/scroll-area.d.mts +3 -3
  73. package/dist/components/ui/select.client.d.mts +11 -11
  74. package/dist/components/ui/separator.d.mts +2 -2
  75. package/dist/components/ui/sheet.client.d.mts +9 -9
  76. package/dist/components/ui/sidebar.client.d.mts +26 -26
  77. package/dist/components/ui/skeleton.d.mts +2 -2
  78. package/dist/components/ui/slider.d.mts +2 -2
  79. package/dist/components/ui/sonner.client.d.mts +2 -2
  80. package/dist/components/ui/sonner.client.mjs +1 -1
  81. package/dist/components/ui/switch.d.mts +2 -2
  82. package/dist/components/ui/tabs.d.mts +5 -5
  83. package/dist/components/ui/textarea.d.mts +2 -2
  84. package/dist/components/ui/time-input.client.d.mts +2 -2
  85. package/dist/components/ui/toggle-group.client.d.mts +3 -3
  86. package/dist/components/ui/toggle.d.mts +4 -4
  87. package/dist/components/ui/toggle.d.mts.map +1 -1
  88. package/dist/components/ui/tooltip.client.d.mts +5 -5
  89. package/dist/components.mjs +2 -2
  90. package/dist/lib/client.mjs +1 -1
  91. package/dist/lib/hooks/use-action.d.mts +2 -2
  92. package/dist/lib/hooks/use-indicator.d.mts +2 -2
  93. package/dist/modules/auth/components/allowed.client.d.mts +2 -2
  94. package/dist/modules/auth/components/allowed.client.mjs +2 -3
  95. package/dist/modules/auth/components/allowed.client.mjs.map +1 -1
  96. package/dist/modules/auth/components/auth-layout.server.d.mts +2 -2
  97. package/dist/modules/auth/components/auth-layout.server.d.mts.map +1 -1
  98. package/dist/modules/auth/components/auth-loading.d.mts +2 -2
  99. package/dist/modules/auth/components/create-first-user-page.client.d.mts +2 -2
  100. package/dist/modules/auth/components/create-first-user-page.client.mjs +4 -3
  101. package/dist/modules/auth/components/create-first-user-page.client.mjs.map +1 -1
  102. package/dist/modules/auth/components/forget-password-page.client.d.mts +2 -2
  103. package/dist/modules/auth/components/forget-password-page.client.mjs +4 -3
  104. package/dist/modules/auth/components/forget-password-page.client.mjs.map +1 -1
  105. package/dist/modules/auth/components/guard-first-user.server.d.mts +2 -2
  106. package/dist/modules/auth/components/guard-first-user.server.d.mts.map +1 -1
  107. package/dist/modules/auth/components/guard.server.d.mts +3 -2
  108. package/dist/modules/auth/components/guard.server.d.mts.map +1 -1
  109. package/dist/modules/auth/components/guard.server.mjs +1 -0
  110. package/dist/modules/auth/components/guard.server.mjs.map +1 -1
  111. package/dist/modules/auth/components/login-page.client.d.mts +2 -2
  112. package/dist/modules/auth/components/login-page.client.mjs +4 -3
  113. package/dist/modules/auth/components/login-page.client.mjs.map +1 -1
  114. package/dist/modules/auth/components/reset-password-page.client.d.mts +2 -2
  115. package/dist/modules/auth/components/reset-password-page.client.mjs +4 -3
  116. package/dist/modules/auth/components/reset-password-page.client.mjs.map +1 -1
  117. package/dist/modules/auth/components/update-password-command.d.mts +2 -2
  118. package/dist/modules/auth/components/update-password-command.mjs +1 -1
  119. package/dist/modules/auth/handler/{client.client.d.mts → create-client.client.d.mts} +288 -168
  120. package/dist/modules/auth/handler/create-client.client.d.mts.map +1 -0
  121. package/dist/modules/auth/handler/create-client.client.mjs +26 -0
  122. package/dist/modules/auth/handler/create-client.client.mjs.map +1 -0
  123. package/dist/modules/auth/handler/init.d.mts +133 -133
  124. package/dist/modules/auth/handler/init.d.mts.map +1 -1
  125. package/dist/modules/auth/hooks/use-auth-client.d.mts +24 -0
  126. package/dist/modules/auth/hooks/use-auth-client.d.mts.map +1 -0
  127. package/dist/modules/auth/hooks/use-auth-client.mjs +31 -0
  128. package/dist/modules/auth/hooks/use-auth-client.mjs.map +1 -0
  129. package/dist/modules/auth/hooks/use-permission.d.mts +8 -35
  130. package/dist/modules/auth/hooks/use-permission.d.mts.map +1 -1
  131. package/dist/modules/auth/hooks/use-permission.mjs +47 -93
  132. package/dist/modules/auth/hooks/use-permission.mjs.map +1 -1
  133. package/dist/modules/auth/hooks/use-session.d.mts +5 -119
  134. package/dist/modules/auth/hooks/use-session.d.mts.map +1 -1
  135. package/dist/modules/auth/hooks/use-session.mjs +15 -17
  136. package/dist/modules/auth/hooks/use-session.mjs.map +1 -1
  137. package/dist/modules/auth/lib/helpers.server.mjs +1 -1
  138. package/dist/modules/auth/lib/validators.d.mts +2 -2
  139. package/dist/modules/auth/lib/validators.d.mts.map +1 -1
  140. package/dist/modules/commands/components/alert-dialog-command.client.d.mts +11 -11
  141. package/dist/modules/commands/components/click-command.client.d.mts +2 -2
  142. package/dist/modules/commands/components/command-trigger.client.d.mts +4 -4
  143. package/dist/modules/commands/components/dialog-command.client.d.mts +8 -8
  144. package/dist/modules/commands/components/dropdown-command.client.d.mts +5 -5
  145. package/dist/modules/commands/components/empty-command.client.d.mts +2 -2
  146. package/dist/modules/commands/components/form-dialog-command.client.d.mts +12 -12
  147. package/dist/modules/commands/hooks/use-command-menu.client.mjs.map +1 -1
  148. package/dist/modules/commands/hooks/use-command-mutation.client.mjs +1 -1
  149. package/dist/modules/commands/menus/context-menu.client.d.mts +2 -2
  150. package/dist/modules/commands/menus/dropdown-menu.client.d.mts +3 -3
  151. package/dist/modules/commands/menus/inline-menu.client.d.mts +3 -3
  152. package/dist/modules/commands/menus/responsive-menu.client.d.mts +3 -3
  153. package/dist/modules/commands/utils/archive-command.client.d.mts +3 -3
  154. package/dist/modules/commands/utils/delete-command.client.d.mts +3 -3
  155. package/dist/modules/config/db/helpers.d.mts +5 -5
  156. package/dist/modules/config/db/helpers.d.mts.map +1 -1
  157. package/dist/modules/config/lib/config.d.mts +1 -1
  158. package/dist/modules/config/lib/config.mjs.map +1 -1
  159. package/dist/modules/data-tables/components/cell/common.client.d.mts +5 -5
  160. package/dist/modules/data-tables/components/filters/combobox.client.d.mts +2 -2
  161. package/dist/modules/data-tables/components/filters/slider.client.d.mts +2 -2
  162. package/dist/modules/data-tables/components/search-input.client.d.mts +2 -2
  163. package/dist/modules/data-tables/hooks/use-context.client.d.mts +2 -2
  164. package/dist/modules/data-tables/strategies/helpers/sorting.mjs +1 -1
  165. package/dist/modules/data-tables/tables/data-table/components/table.d.mts +2 -2
  166. package/dist/modules/data-tables/tables/inline-table/components/cells/common.d.mts +2 -2
  167. package/dist/modules/data-tables/tables/inline-table/components/cells/drag-handle.client.d.mts +2 -2
  168. package/dist/modules/data-tables/tables/inline-table/components/cells/read-only.d.mts +2 -2
  169. package/dist/modules/data-tables/tables/inline-table/components/table.d.mts +2 -2
  170. package/dist/modules/data-tables/tables/inline-table/hooks/context.client.d.mts +2 -2
  171. package/dist/modules/inline-edit/components/combobox-dropdown.client.d.mts +2 -2
  172. package/dist/modules/inline-edit/components/combobox-dropdown.client.d.mts.map +1 -1
  173. package/dist/modules/inline-edit/components/combobox.client.d.mts +2 -2
  174. package/dist/modules/inline-edit/components/combobox.client.d.mts.map +1 -1
  175. package/dist/modules/inline-edit/components/date-input.client.d.mts +2 -2
  176. package/dist/modules/inline-edit/components/date-input.client.d.mts.map +1 -1
  177. package/dist/modules/inline-edit/components/date-picker.client.d.mts +2 -2
  178. package/dist/modules/inline-edit/components/date-picker.client.d.mts.map +1 -1
  179. package/dist/modules/inline-edit/components/editor.client.d.mts +2 -2
  180. package/dist/modules/inline-edit/components/input-recipient.client.d.mts +2 -2
  181. package/dist/modules/inline-edit/components/input-toggle.client.d.mts +2 -2
  182. package/dist/modules/inline-edit/components/input.client.d.mts +4 -4
  183. package/dist/modules/inline-edit/components/select.client.d.mts +6 -6
  184. package/dist/modules/inline-edit/components/switch.client.d.mts +2 -2
  185. package/dist/modules/inline-edit/components/toggle.client.d.mts +2 -2
  186. package/dist/modules/inline-edit/hooks/context.client.d.mts +2 -2
  187. package/dist/modules/inline-edit/hooks/context.client.d.mts.map +1 -1
  188. package/dist/modules/inline-edit/hooks/use-inline.client.mjs +2 -6
  189. package/dist/modules/inline-edit/hooks/use-inline.client.mjs.map +1 -1
  190. package/dist/modules/storage/components/dropzone.client.d.mts +4 -4
  191. package/dist/modules/storage/components/image-grid.client.d.mts +3 -3
  192. package/dist/modules/storage/components/image-grid.client.mjs +1 -1
  193. package/dist/modules/storage/components/upload-zone.client.d.mts +2 -2
  194. package/dist/modules/storage/components/upload-zone.client.mjs +1 -2
  195. package/dist/modules/storage/components/upload-zone.client.mjs.map +1 -1
  196. package/dist/modules/storage/lib/create-upload.client.d.mts.map +1 -1
  197. package/dist/modules/storage/lib/proxy.server.mjs +1 -1
  198. package/dist/modules/storage/lib/router.server.d.mts +2354 -2324
  199. package/dist/modules/storage/lib/router.server.d.mts.map +1 -1
  200. package/dist/modules/storage/lib/router.server.mjs +2 -3
  201. package/dist/modules/storage/lib/router.server.mjs.map +1 -1
  202. package/dist/modules/storage/lib/service.server.d.mts +18 -18
  203. package/dist/modules/storage/lib/validators.d.mts +90 -90
  204. package/dist/modules/storage/lib/validators.d.mts.map +1 -1
  205. package/package.json +1 -1
  206. package/src/components/layouts/admin-layout.tsx +1 -3
  207. package/src/components/navigation/admin-sidebar-header.client.tsx +3 -20
  208. package/src/modules/auth/components/allowed.client.tsx +2 -2
  209. package/src/modules/auth/components/create-first-user-page.client.tsx +3 -2
  210. package/src/modules/auth/components/forget-password-page.client.tsx +2 -1
  211. package/src/modules/auth/components/guard.server.tsx +2 -0
  212. package/src/modules/auth/components/login-page.client.tsx +2 -1
  213. package/src/modules/auth/components/reset-password-page.client.tsx +3 -1
  214. package/src/modules/auth/entry.client.ts +13 -1
  215. package/src/modules/auth/entry.ts +11 -0
  216. package/src/modules/auth/handler/create-client.client.ts +53 -0
  217. package/src/modules/auth/hooks/use-auth-client.tsx +38 -0
  218. package/src/modules/auth/hooks/use-permission.ts +49 -94
  219. package/src/modules/auth/hooks/use-session.ts +16 -16
  220. package/src/modules/commands/hooks/use-command-menu.client.tsx +0 -6
  221. package/src/modules/config/lib/config.ts +3 -2
  222. package/src/modules/inline-edit/hooks/use-inline.client.tsx +1 -1
  223. package/src/modules/storage/components/upload-zone.client.tsx +0 -2
  224. package/src/modules/storage/lib/router.server.ts +5 -4
  225. package/dist/modules/auth/handler/client.client.d.mts.map +0 -1
  226. package/dist/modules/auth/handler/client.client.mjs +0 -21
  227. package/dist/modules/auth/handler/client.client.mjs.map +0 -1
  228. package/src/modules/auth/components/guard.client.tsx +0 -12
  229. package/src/modules/auth/handler/client.client.ts +0 -16
@@ -1 +1 @@
1
- {"version":3,"file":"validators.d.mts","names":[],"sources":["../../../../src/modules/storage/lib/validators.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;KAYY,IAAA,UAAc,KAAA,CAAM;AAApB,KACA,QAAA,GADc,OACI,KAAA,CAAM,YADQ,GAAA;EAChC,IAAA,EAAA,MAAQ;AACpB,CAAA;AAKa,KALD,UAAA,GAKiD,OAL7B,KAAA,CAAM,YAKX,GAAA;EACf,IAAA,EAAA,QAAQ;AAKpB,CAAA;;;;cANa,gBAAc,GAAA,CAAA;;;;KACf,QAAA,GAAW,GAAA,CAAE,aAAa;;;;cAKzB,+BAAgB;QAE3B,uBAAA,CAAA;;;;;;;;;gBAF2B,EAAA,KAAA;IAAA,eAAA,EAAA,KAAA;IAIjB,iBAAe,EAAA,KAAA;IACf,UAAA,EAAA,CAAA,MAAgB,EAAA,GAAA,MAAkB,EAAA,CAAA;IAKjC,UAAA,EAAA,KAA4C;IAAA,QAAA,EAAA,SAAA;;;;;;;;;;;;;;;;;;;;wCAA5B,CAAA;IAAA,IAAA,EAAA,MAAA;IAEjB,SAAA,EAAA,OAAe;IACf,QAAA,EAAA,QAAgB;IAKf,UAAA,EAAA,cAA4C;IAAA,IAAA,EAAA,MAAA,GAAA,QAAA;;;;;;;;;;;;;;;;;;;;cAA5B,EAAA,IAAA;IAAA,YAAA,EAAA,KAAA;IAChB,eAAA,EAAA,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAA4B,UAAA,EAAA,KAAA;IAAA,YAAA,EAAA,KAAA;IAI7B,eAAgB,EAAA,KAAA;IAChB,iBAAA,EAAA,KAA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E,aAAa;;;;cAK7C,yBAAuB,GAAA,CAAA,QAAA,GAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAaxB,iBAAA,GAAoB,GAAA,CAAE,aAAa;;;;cAKlC,wBAAsB,GAAA,CAAA;;;;;;;;;;;;;;;;;;;;;KAOvB,sBAAA,GAAyB,GAAA,CAAE,aAAa;;;;cAKvC,kBAAgB,GAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAEjB,gBAAA,GAAmB,GAAA,CAAE,aAAa;;;;cAKjC,mBAAiB,GAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAElB,iBAAA,GAAoB,GAAA,CAAE,aAAa;;;;cAKlC;;;;cAEA,kBAAgB,GAAA,CAAA;;;;;;;;;;KAKjB,eAAA,GAAkB,GAAA,CAAE,aAAa;KACjC,gBAAA,GAAmB,GAAA,CAAE,aAAa;;;;cAKjC,0BAAwB,GAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAIzB,uBAAA,GAA0B,GAAA,CAAE,aAAa;;;;cAKxC,iBAAe,GAAA,CAAA;;;;;;;;KAMhB,cAAA,GAAiB,GAAA,CAAE,aAAa;KAChC,eAAA,GAAkB,GAAA,CAAE,aAAa;;;;cAKhC,iBAAe,GAAA,CAAA;;;;;;;;;;;KAShB,cAAA,GAAiB,GAAA,CAAE,aAAa;SACnC;;KAGG,eAAA,GAAkB,GAAA,CAAE,aAAa"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tulip-systems/core",
3
- "version": "0.5.13",
3
+ "version": "0.5.15",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",
@@ -3,8 +3,6 @@ import { SidebarProvider } from "../ui/sidebar.client";
3
3
 
4
4
  export function AdminLayout(props: PropsWithChildren) {
5
5
  return (
6
- <SidebarProvider className="max-h-[100dvh] overflow-hidden border">
7
- {props.children}
8
- </SidebarProvider>
6
+ <SidebarProvider className="max-h-dvh overflow-hidden border">{props.children}</SidebarProvider>
9
7
  );
10
8
  }
@@ -13,7 +13,7 @@ import {
13
13
  DropdownMenuTrigger,
14
14
  } from "@/components/ui/dropdown-menu";
15
15
  import { cn } from "@/lib/utils/cn";
16
- import { authClient } from "@/modules/auth/handler/client.client";
16
+ import { useAuthClient } from "@/modules/auth/hooks/use-auth-client";
17
17
  import { useSession } from "@/modules/auth/hooks/use-session";
18
18
  import {
19
19
  ChevronsUpDownIcon,
@@ -32,13 +32,14 @@ import { SidebarHeader, useSidebar } from "../ui/sidebar.client";
32
32
 
33
33
  export function AdminSidebarHeader() {
34
34
  const router = useRouter();
35
+ const authClient = useAuthClient();
35
36
  const { theme, setTheme } = useTheme();
36
37
 
37
38
  const [open, setOpen] = React.useState(false);
38
39
 
39
40
  const { setOpenMobile } = useSidebar();
40
41
 
41
- const sessionQuery = useSession();
42
+ const sessionQuery = useSession(authClient);
42
43
 
43
44
  return (
44
45
  <SidebarHeader>
@@ -105,24 +106,6 @@ export function AdminSidebarHeader() {
105
106
  </DropdownMenuSubContent>
106
107
  </DropdownMenuSub>
107
108
 
108
- {/*
109
- <DropdownMenuItem
110
- onClick={() => {
111
- setOpenMobile(false);
112
- setOpen(false);
113
- authClient.passkey.addPasskey({
114
- fetchOptions: {
115
- onSuccess: () => {
116
- toast.success("Passkey succesvol toegevoegd");
117
- },
118
- },
119
- });
120
- }}
121
- >
122
- <Icons.add className="mr-2 h-4 w-4" />
123
- <span>Passkey</span>
124
- </DropdownMenuItem> */}
125
-
126
109
  <DropdownMenuItem
127
110
  onClick={() => {
128
111
  setOpenMobile(false);
@@ -42,9 +42,9 @@ export type AllowedProps = UsePermissionProps & {
42
42
  * Allowed
43
43
  */
44
44
  export function Allowed({ permission, strategy, fallback, children }: AllowedProps) {
45
- const { data } = usePermission({ permission, strategy } as UsePermissionProps);
45
+ const data = usePermission({ permission, strategy } as UsePermissionProps);
46
46
 
47
- if (data?.success) return <>{children}</>;
47
+ if (data.success) return <>{children}</>;
48
48
 
49
49
  return <>{fallback}</>;
50
50
  }
@@ -22,10 +22,11 @@ import { Eye, EyeOff } from "lucide-react";
22
22
  import { useRouter } from "next/navigation";
23
23
  import { useState } from "react";
24
24
  import { useForm } from "react-hook-form";
25
- import { authClient } from "../handler/client.client";
25
+ import { useAuthClient } from "../hooks/use-auth-client";
26
26
 
27
27
  export function CreateFirstUserPage() {
28
28
  const router = useRouter();
29
+ const authClient = useAuthClient();
29
30
  const [callbackURL] = useQueryState("callbackURL", parseAsString);
30
31
  const [showPassword, setShowPassword] = useState(false);
31
32
 
@@ -62,7 +63,7 @@ export function CreateFirstUserPage() {
62
63
  disabled,
63
64
  });
64
65
 
65
- if(Object.keys(form.formState.errors).length > 0) {
66
+ if (Object.keys(form.formState.errors).length > 0) {
66
67
  console.error(form.formState.errors);
67
68
  }
68
69
 
@@ -9,10 +9,11 @@ import React from "react";
9
9
  import { useForm } from "react-hook-form";
10
10
  import { toast } from "sonner";
11
11
  import * as z from "zod";
12
- import { authClient } from "../handler/client.client";
12
+ import { useAuthClient } from "../hooks/use-auth-client";
13
13
  import { forgotPasswordSchema } from "../lib/validators";
14
14
 
15
15
  export function ForgetPasswordPage() {
16
+ const authClient = useAuthClient();
16
17
  const [isPending, startTransition] = React.useTransition();
17
18
 
18
19
  const form = useForm<z.infer<typeof forgotPasswordSchema>>({
@@ -1,3 +1,5 @@
1
+ import "server-only";
2
+
1
3
  import { TDatabaseSchema, TulipContext } from "@/modules/config/entry";
2
4
  import { getQueryClient } from "@/modules/router/lib/query-client";
3
5
  import { HydrateClient } from "@/modules/router/lib/query-client.server";
@@ -14,7 +14,7 @@ import { useState } from "react";
14
14
  import { useForm } from "react-hook-form";
15
15
  import { toast } from "sonner";
16
16
  import * as z from "zod";
17
- import { authClient } from "../handler/client.client";
17
+ import { useAuthClient } from "../hooks/use-auth-client";
18
18
  import { loginSchema } from "../lib/validators";
19
19
 
20
20
  type LoginPageProps = {
@@ -25,6 +25,7 @@ type LoginPageProps = {
25
25
 
26
26
  export function LoginPage(props: LoginPageProps) {
27
27
  const router = useRouter();
28
+ const authClient = useAuthClient();
28
29
  const [callbackURL] = useQueryState("callbackURL", parseAsString);
29
30
  const [showPassword, setShowPassword] = useState(false);
30
31
 
@@ -18,7 +18,7 @@ import React, { use, useState } from "react";
18
18
  import { useForm } from "react-hook-form";
19
19
  import { toast } from "sonner";
20
20
  import * as z from "zod";
21
- import { authClient } from "../handler/client.client";
21
+ import { useAuthClient } from "../hooks/use-auth-client";
22
22
  import { resetPasswordSchema } from "../lib/validators";
23
23
 
24
24
  export function ResetPasswordPage(params: {
@@ -27,6 +27,8 @@ export function ResetPasswordPage(params: {
27
27
  const { email, otp } = use(params.searchParams);
28
28
 
29
29
  const router = useRouter();
30
+ const authClient = useAuthClient();
31
+
30
32
  const [showPassword, setShowPassword] = useState(false);
31
33
  const [showPasswordConfirm, setShowPasswordConfirm] = useState(false);
32
34
 
@@ -1,9 +1,21 @@
1
+ /**
2
+ * Components
3
+ */
1
4
  export * from "./components/allowed.client";
2
5
  export * from "./components/create-first-user-page.client";
3
6
  export * from "./components/forget-password-page.client";
4
7
  export * from "./components/login-page.client";
5
8
  export * from "./components/reset-password-page.client";
6
9
  export * from "./components/update-password-command";
7
- export * from "./handler/client.client";
10
+
11
+ /**
12
+ * Handlers
13
+ */
14
+ export * from "./handler/create-client.client";
15
+
16
+ /**
17
+ * Hooks
18
+ */
19
+ export * from "./hooks/use-auth-client";
8
20
  export * from "./hooks/use-permission";
9
21
  export * from "./hooks/use-session";
@@ -1,4 +1,15 @@
1
+ /**
2
+ * Components
3
+ */
1
4
  export * from "./components/auth-loading";
5
+
6
+ /**
7
+ * DB
8
+ */
2
9
  export * from "./db/schema";
10
+
11
+ /**
12
+ * Lib
13
+ */
3
14
  export * from "./lib/permissions";
4
15
  export * from "./lib/validators";
@@ -0,0 +1,53 @@
1
+ import "client-only";
2
+
3
+ import { url } from "@/lib/utils/url";
4
+ import { passkeyClient } from "@better-auth/passkey/client";
5
+ import { adminClient, emailOTPClient, inferAdditionalFields } from "better-auth/client/plugins";
6
+ import { AccessControl, Role } from "better-auth/plugins";
7
+ import { createAuthClient as createBetterAuthClient } from "better-auth/react";
8
+ import { AuthClient } from "./init";
9
+
10
+ /**
11
+ * Create auth client
12
+ */
13
+ export type CreateAuthClientProps<
14
+ TAccessControl extends AccessControl,
15
+ TRoles extends { [key in string]: Role },
16
+ > = {
17
+ /**
18
+ * Base URL for the auth client
19
+ */
20
+ baseURL?: string;
21
+ /**
22
+ * Access control instance
23
+ */
24
+ ac: TAccessControl;
25
+ roles: TRoles;
26
+ };
27
+
28
+ export function createAuthClient<
29
+ TAccessControl extends AccessControl,
30
+ TRoles extends { [key in string]: Role },
31
+ >(props: CreateAuthClientProps<TAccessControl, TRoles>) {
32
+ const { ac, roles } = props;
33
+
34
+ const baseURL = props.baseURL ?? url();
35
+
36
+ return createBetterAuthClient({
37
+ baseURL,
38
+ plugins: [
39
+ emailOTPClient(),
40
+ passkeyClient(),
41
+ adminClient({ ac, roles }),
42
+ inferAdditionalFields<AuthClient>(),
43
+ ],
44
+ });
45
+ }
46
+
47
+ /**
48
+ * Client auth type
49
+ */
50
+ export type ClientAuth<
51
+ TAccessControl extends AccessControl,
52
+ TRoles extends { [key in string]: Role },
53
+ > = ReturnType<typeof createAuthClient<TAccessControl, TRoles>>;
@@ -0,0 +1,38 @@
1
+ "use client";
2
+
3
+ import { AccessControl, Role } from "better-auth/plugins";
4
+ import { createContext, PropsWithChildren, use } from "react";
5
+ import { ClientAuth } from "../handler/create-client.client";
6
+
7
+ /**
8
+ * Auth client context
9
+ */
10
+
11
+ export const AuthClientContext = createContext(null as unknown as ClientAuth<never, never>);
12
+
13
+ /**
14
+ * Use auth client
15
+ */
16
+ export function useAuthClient<
17
+ TAccessControl extends AccessControl = never,
18
+ TRoles extends { [key in string]: Role } = never,
19
+ >() {
20
+ const context = use(AuthClientContext);
21
+ if (!context) throw new Error("Auth client is not provided");
22
+
23
+ return context as ClientAuth<TAccessControl, TRoles>;
24
+ }
25
+
26
+ /**
27
+ * Auth client provider
28
+ */
29
+ export function AuthProvider<
30
+ TAccessControl extends AccessControl,
31
+ TRoles extends { [key in string]: Role },
32
+ >(props: PropsWithChildren<{ authClient: ClientAuth<TAccessControl, TRoles> }>) {
33
+ return (
34
+ <AuthClientContext value={props.authClient as ClientAuth<never, never>}>
35
+ {props.children}
36
+ </AuthClientContext>
37
+ );
38
+ }
@@ -1,13 +1,9 @@
1
1
  "use client";
2
2
 
3
- import { useSuspenseQueries, useSuspenseQuery } from "@tanstack/react-query";
4
- import { authClient } from "../handler/client.client";
5
3
  import { type Permission } from "../lib/permissions";
4
+ import { useAuthClient } from "./use-auth-client";
6
5
  import { useSession } from "./use-session";
7
6
 
8
- /**
9
- * UsePermission
10
- */
11
7
  export type UsePermissionProps =
12
8
  | {
13
9
  /**
@@ -40,95 +36,54 @@ export type UsePermissionProps =
40
36
  permission?: Permission[];
41
37
  };
42
38
 
43
- export function usePermission({ permission, strategy = "all" }: UsePermissionProps) {
44
- const sessionQuery = useSession();
45
-
46
- return useSuspenseQuery({
47
- queryKey: ["permission", { permission, strategy }],
48
- queryFn: async () => {
49
- // If no permission is provided, allow by default
50
- if (!permission) return { permission, success: true };
51
-
52
- // If no user is logged in, deny by default
53
- if (!sessionQuery.data) return { permission, success: false };
54
- const userId = sessionQuery.data?.user.id;
55
- if (!userId) return { permission, success: false };
56
-
57
- // If the strategy is "any", check if the user has any of the permissions
58
- const permissions = Array.isArray(permission) ? permission : [permission];
59
-
60
- // Check if the user has the permission
61
- const results = await Promise.all(
62
- permissions.map((permission) => authClient.admin.hasPermission({ permission, userId })),
63
- );
64
-
65
- const data = results.map(({ data }) => data).filter((data) => !!data);
66
- const errors = results.filter(({ error }) => !!error).map(({ error }) => error);
67
-
68
- // If there is an error, log it and return false
69
- if (errors.length > 0) {
70
- console.error(...errors);
71
- return { permission, success: false };
72
- }
73
-
74
- // Determine if the user has the permission based on the strategy
75
- const success =
76
- strategy === "all"
77
- ? data.every(({ success }) => success)
78
- : data.some(({ success }) => success);
79
-
80
- // Return the result
81
- return {
82
- permission,
83
- success,
84
- };
85
- },
86
- staleTime: 5 * 60 * 1000, // 5 minutes
87
- });
88
- }
89
-
90
39
  /**
91
- * Check multiple permissions in parallel
92
- * @param permission
93
- * @param strategy
94
- * @returns
95
- * @deprecated Use `usePermission` with strategy "any" or "all" instead
40
+ * UsePermission
96
41
  */
97
- export function usePermissions(permission?: Permission) {
98
- const sessionQuery = useSession();
99
-
100
- const keys = Object.entries(permission ?? {}).flatMap(([resource, permissions]) =>
101
- permissions.map((permission) => ({ [resource]: [permission] }) as Permission),
102
- );
103
-
104
- return useSuspenseQueries({
105
- queries: keys.map((permission) => ({
106
- queryKey: ["permission", permission],
107
- queryFn: async () => {
108
- const userId = sessionQuery.data?.user.id;
109
- if (!userId) return { permission, success: false };
110
-
111
- const { data, error } = await authClient.admin.hasPermission({ permission, userId });
112
- if (error) {
113
- console.error(error);
114
- throw error;
115
- }
116
-
117
- return {
118
- permission,
119
- success: data.success,
120
- };
121
- },
122
- staleTime: 5 * 60 * 1000, // 5 minutes
123
- })),
124
- combine: (results) => {
125
- const errors = results.filter(({ error }) => error);
126
- if (errors.length) return { data: null, errors };
127
-
128
- const values = results.map(({ data }) => data);
129
- const success = results.every(({ data }) => data?.success);
130
-
131
- return { data: { success, values }, errors: null };
132
- },
133
- });
42
+ export function usePermission({ strategy = "all", permission }: UsePermissionProps) {
43
+ const authClient = useAuthClient();
44
+ const sessionQuery = useSession(authClient);
45
+
46
+ /**
47
+ * If no role is found in the session, deny by default
48
+ */
49
+ const role = sessionQuery.data?.user.role;
50
+ if (!role) return { permission, success: false };
51
+
52
+ /**
53
+ * If no permission is provided, allow by default
54
+ */
55
+ if (!permission) return { permission, success: true };
56
+
57
+ /**
58
+ * If the strategy is "any", check if the user has any of the permissions
59
+ */
60
+ if (strategy === "any" && Array.isArray(permission)) {
61
+ const permissions = Array.isArray(permission) ? permission : [permission];
62
+
63
+ const success = permissions.some((permission) =>
64
+ authClient.admin.checkRolePermission({
65
+ role,
66
+ permissions: permission,
67
+ }),
68
+ );
69
+
70
+ return { permission, success };
71
+ }
72
+
73
+ /**
74
+ * If the strategy is "all", check if the user has all of the permissions
75
+ */
76
+ if (strategy === "all" && !Array.isArray(permission)) {
77
+ const success = authClient.admin.checkRolePermission({
78
+ role,
79
+ permissions: permission,
80
+ });
81
+
82
+ return { permission, success };
83
+ }
84
+
85
+ /**
86
+ * If the strategy is not recognized, deny by default
87
+ */
88
+ return { permission, success: false };
134
89
  }
@@ -1,24 +1,24 @@
1
1
  "use client";
2
2
 
3
- import { queryOptions, useSuspenseQuery } from "@tanstack/react-query";
4
- import { authClient } from "../entry.client";
3
+ import { useSuspenseQuery } from "@tanstack/react-query";
4
+ import { ClientAuth } from "../entry.client";
5
5
 
6
- export const sessionQueryOptions = queryOptions({
7
- queryKey: ["session"],
8
- queryFn: async () => {
9
- const session = await authClient.getSession();
6
+ export function useSession(authClient: ClientAuth<never, never>) {
7
+ const session = useSuspenseQuery({
8
+ queryKey: ["session"],
9
+ queryFn: async () => {
10
+ const session = await authClient.getSession();
11
+
10
12
 
11
- if (session.error) {
12
- console.error(session.error);
13
- return null;
14
- }
13
+ if (session.error) {
14
+ console.error(session.error);
15
+ return null;
16
+ }
15
17
 
16
- return session.data;
17
- },
18
- staleTime: 1000 * 60 * 60,
19
- });
18
+ return session.data;
19
+ },
20
+ staleTime: 1000 * 60 * 60,
21
+ });
20
22
 
21
- export function useSession() {
22
- const session = useSuspenseQuery(sessionQueryOptions);
23
23
  return session;
24
24
  }
@@ -112,9 +112,6 @@ export function useSingleCommandMenu<TData, TMeta>({
112
112
  commands,
113
113
  meta,
114
114
  }: SingleCommandMenuProps<TData, TMeta> & { data: TData }) {
115
- // const permissions = commands.map((command) => command.permission).filter(Boolean) as Permission[];
116
- // usePermission(mergePermissions(permissions));
117
-
118
115
  // filter out commands that don't have valid conditions
119
116
  const validCommands = commands.filter((command) =>
120
117
  command.mode === "single"
@@ -139,9 +136,6 @@ export function useBulkCommandMenu<TData, TMeta>({
139
136
  commands,
140
137
  meta,
141
138
  }: BulkCommandMenuProps<TData, TMeta>) {
142
- // const permissions = commands.map((command) => command.permission).filter(Boolean) as Permission[];
143
- // usePermission(mergePermissions(permissions));
144
-
145
139
  /**
146
140
  * Filter out commands that don't have valid conditions
147
141
  */
@@ -1,4 +1,4 @@
1
- export type TulipConfig<TValues> = {
1
+ export type TulipConfig<TValues = object> = {
2
2
  general: {
3
3
  name: string;
4
4
  shortName: string;
@@ -12,4 +12,5 @@ export type TulipConfig<TValues> = {
12
12
  * Build the Tulip config
13
13
  */
14
14
 
15
- export const defineTulipConfig = <TValues>(config: TulipConfig<TValues>): TulipConfig<TValues> => config;
15
+ export const defineTulipConfig = <TValues>(config: TulipConfig<TValues>): TulipConfig<TValues> =>
16
+ config;
@@ -86,7 +86,7 @@ export function useInlineEdit<
86
86
  /**
87
87
  * Permission guard
88
88
  */
89
- const { data } = usePermission(props.permission ?? context.permission ?? {});
89
+ const data = usePermission(props.permission ?? context.permission ?? {});
90
90
  const isAllowed = data?.success;
91
91
 
92
92
  /**
@@ -108,8 +108,6 @@ export function UploadZone({
108
108
 
109
109
  const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop, noClick: true });
110
110
 
111
- console.log("isDragActive", isDragActive);
112
-
113
111
  return (
114
112
  <div {...props} {...getRootProps()} className={cn("relative z-0", className)}>
115
113
  <input {...getInputProps()} />
@@ -2,6 +2,7 @@ import { bulkActionSchema } from "@/modules/router/entry";
2
2
  import { ServerError } from "@/modules/router/entry.server";
3
3
  import { initRPC } from "@/modules/router/handler/init.server";
4
4
  import { and, eq, sql } from "drizzle-orm";
5
+ import { QueryResult } from "pg";
5
6
  import { z } from "zod";
6
7
  import { isFolder } from "./helpers";
7
8
  import { DriveSchema, nodes } from "./schema";
@@ -9,6 +10,7 @@ import {
9
10
  createFolderNodeSchema,
10
11
  getFileURLSchema,
11
12
  getNodesByParentIdSchema,
13
+ Node,
12
14
  presignFileSchema,
13
15
  selectNodeSchema,
14
16
  selectNodeWithChildrenSchema,
@@ -76,11 +78,10 @@ export function createDriveBaseProcedures() {
76
78
  );
77
79
 
78
80
  const result = (await context.db.execute(
79
- sql`WITH RECURSIVE ${recursiveQueryName} AS ${recursiveQuery}
80
- SELECT * FROM ${recursiveQueryName}`,
81
- )) as Awaited<ReturnType<(typeof recursiveQuery)["execute"]>>;
81
+ sql`WITH RECURSIVE ${recursiveQueryName} AS ${recursiveQuery} SELECT * FROM ${recursiveQueryName}`,
82
+ )) as QueryResult<Pick<Node, "id" | "name" | "parentId"> & { depth: number }>;
82
83
 
83
- return result.toSorted((a, b) => Number(b.depth) - Number(a.depth));
84
+ return result?.rows?.toSorted((a, b) => Number(b.depth) - Number(a.depth)) ?? [];
84
85
  }),
85
86
  /**
86
87
  * Get presigned url for opening a file
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.client.d.mts","names":[],"sources":["../../../../src/modules/auth/handler/client.client.ts"],"sourcesContent":[],"mappings":";;;;;;;cAQa;;UAGX,qBAAA,CAAA,OAAA;;;;yBAAA;MAHW,KAGX,CAAA,eAK6pI,kBAL7pI;IAAA,CAAA,GAAA,SAAA,EAAA,UAAA,CAAA,IAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;eAA+U;kBAA+C;;;WAAwG;eAAwC;;qBAAqF;cAAyC;;0BAAA,kBAAA,CAA+E,oBAAA;;;;;qBAAA,kBAAA,CAAA;;;;;;;;;;;;;;;;;;;;+BAA27B,YAAA;;cAAA,kBAAA,CAAmG,gBAAA,UAAA,cAAA;kBAAA,kBAAA,CAAmG,gBAAA;;;;;uBAAuM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAH9hM,UAAA,UAAoB;KAEpB,aAAA,UAAuB,UAAA,CAAW,MAAA,CAAO"}
@@ -1,21 +0,0 @@
1
- "use client";
2
-
3
- import { url } from "../../../lib/utils/url.mjs";
4
- import { passkeyClient } from "@better-auth/passkey/client";
5
- import { adminClient, emailOTPClient, inferAdditionalFields } from "better-auth/client/plugins";
6
- import { createAuthClient } from "better-auth/react";
7
-
8
- //#region src/modules/auth/handler/client.client.ts
9
- const authClient = createAuthClient({
10
- baseURL: url(),
11
- plugins: [
12
- emailOTPClient(),
13
- passkeyClient(),
14
- adminClient(),
15
- inferAdditionalFields()
16
- ]
17
- });
18
-
19
- //#endregion
20
- export { authClient };
21
- //# sourceMappingURL=client.client.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.client.mjs","names":[],"sources":["../../../../src/modules/auth/handler/client.client.ts"],"sourcesContent":["\"use client\";\n\nimport { passkeyClient } from \"@better-auth/passkey/client\";\nimport { adminClient, emailOTPClient, inferAdditionalFields } from \"better-auth/client/plugins\";\nimport { createAuthClient } from \"better-auth/react\";\nimport { AuthClient } from \"./init\";\nimport { url } from \"@/lib/utils/url\";\n\nexport const authClient = createAuthClient({\n baseURL: url(),\n plugins: [emailOTPClient(), passkeyClient(), adminClient(), inferAdditionalFields<AuthClient>()],\n});\n\nexport type ClientAuth = typeof authClient;\n\nexport type ClientSession = typeof authClient.$Infer.Session;\n"],"mappings":";;;;;;;;AAQA,MAAa,aAAa,iBAAiB;CACzC,SAAS,KAAK;CACd,SAAS;EAAC,gBAAgB;EAAE,eAAe;EAAE,aAAa;EAAE,uBAAmC;EAAC;CACjG,CAAC"}
@@ -1,12 +0,0 @@
1
- "use client";
2
-
3
- import { redirect } from "next/navigation";
4
- import { PropsWithChildren } from "react";
5
- import { useSession } from "../hooks/use-session";
6
-
7
- export function AuthGuard({ children }: PropsWithChildren) {
8
- const session = useSession();
9
- if (!session.data) redirect("/auth/login");
10
-
11
- return <>{children}</>;
12
- }