@tulip-systems/core 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (602) hide show
  1. package/dist/auth/client.d.mts +2 -2
  2. package/dist/auth/client.mjs +2 -2
  3. package/dist/commands/client.d.mts +3 -3
  4. package/dist/commands/client.mjs +3 -3
  5. package/dist/components/client.d.mts +3 -5
  6. package/dist/components/client.mjs +3 -5
  7. package/dist/components/common/icons.d.mts +52 -52
  8. package/dist/components/common/icons.d.mts.map +1 -1
  9. package/dist/components/common/status.d.mts +3 -3
  10. package/dist/components/common/status.d.mts.map +1 -1
  11. package/dist/components/editor/components/block-dropdown.mjs +28 -14
  12. package/dist/components/editor/components/block-dropdown.mjs.map +1 -1
  13. package/dist/components/editor/components/content.client.d.mts +2 -2
  14. package/dist/components/editor/components/content.client.mjs +1 -1
  15. package/dist/components/editor/components/content.client.mjs.map +1 -1
  16. package/dist/components/editor/components/editor.client.d.mts +48 -0
  17. package/dist/components/editor/components/editor.client.d.mts.map +1 -0
  18. package/dist/components/editor/components/editor.client.mjs +53 -0
  19. package/dist/components/editor/components/editor.client.mjs.map +1 -0
  20. package/dist/components/editor/components/menu-fixed.client.d.mts +7 -0
  21. package/dist/components/editor/components/menu-fixed.client.d.mts.map +1 -0
  22. package/dist/components/editor/components/{fixed-menu.client.mjs → menu-fixed.client.mjs} +21 -27
  23. package/dist/components/editor/components/menu-fixed.client.mjs.map +1 -0
  24. package/dist/components/editor/lib/constants.d.mts +60 -0
  25. package/dist/components/editor/lib/constants.d.mts.map +1 -0
  26. package/dist/components/editor/lib/constants.mjs +90 -0
  27. package/dist/components/editor/lib/constants.mjs.map +1 -0
  28. package/dist/components/editor/lib/extensions.d.mts +62 -0
  29. package/dist/components/editor/lib/extensions.d.mts.map +1 -0
  30. package/dist/components/editor/lib/extensions.mjs +52 -0
  31. package/dist/components/editor/lib/extensions.mjs.map +1 -0
  32. package/dist/components/editor/lib/helpers.mjs +3 -3
  33. package/dist/components/editor/lib/helpers.mjs.map +1 -1
  34. package/dist/components/editor/lib/variants.mjs +8 -0
  35. package/dist/components/editor/lib/variants.mjs.map +1 -0
  36. package/dist/components/header/back-button.client.d.mts +2 -2
  37. package/dist/components/header/bottom-bar.client.d.mts +3 -3
  38. package/dist/components/header/breadcrumbs.client.d.mts +7 -7
  39. package/dist/components/header/header.client.d.mts +2 -2
  40. package/dist/components/header/mobile-nav-switcher.client.d.mts +2 -2
  41. package/dist/components/header/top-bar.client.d.mts +4 -4
  42. package/dist/components/header/top-bar.client.mjs +1 -1
  43. package/dist/components/header/top-bar.client.mjs.map +1 -1
  44. package/dist/components/layouts/admin-content.client.d.mts +2 -2
  45. package/dist/components/layouts/admin-content.client.mjs +1 -1
  46. package/dist/components/layouts/admin-content.client.mjs.map +1 -1
  47. package/dist/components/layouts/admin-layout.d.mts +2 -2
  48. package/dist/components/layouts/admin-layout.d.mts.map +1 -1
  49. package/dist/components/layouts/admin-loading.d.mts +2 -2
  50. package/dist/components/layouts/admin-loading.d.mts.map +1 -1
  51. package/dist/components/layouts/empty-page.d.mts +4 -4
  52. package/dist/components/layouts/empty-page.d.mts.map +1 -1
  53. package/dist/components/layouts/list-layout.d.mts +2 -2
  54. package/dist/components/layouts/list-layout.d.mts.map +1 -1
  55. package/dist/components/layouts/not-found-page.d.mts +3 -3
  56. package/dist/components/layouts/not-found-page.d.mts.map +1 -1
  57. package/dist/components/layouts/providers.client.d.mts +2 -2
  58. package/dist/components/layouts/root-layout.server.d.mts +4 -4
  59. package/dist/components/layouts/root-layout.server.d.mts.map +1 -1
  60. package/dist/components/layouts/root-loading.d.mts +2 -2
  61. package/dist/components/layouts/root-loading.d.mts.map +1 -1
  62. package/dist/components/layouts/tab-layout.d.mts +2 -2
  63. package/dist/components/layouts/tab-layout.d.mts.map +1 -1
  64. package/dist/components/lists/data-list.d.mts +5 -5
  65. package/dist/components/lists/data-list.d.mts.map +1 -1
  66. package/dist/components/lists/data-stack.d.mts +8 -8
  67. package/dist/components/lists/data-stack.d.mts.map +1 -1
  68. package/dist/components/navigation/admin-sidebar-paths.client.d.mts +10 -10
  69. package/dist/components/ui/accordion.d.mts +5 -5
  70. package/dist/components/ui/alert-dialog.d.mts +12 -12
  71. package/dist/components/ui/alert.d.mts +4 -4
  72. package/dist/components/ui/aspect-ratio.d.mts +2 -2
  73. package/dist/components/ui/avatar.client.d.mts +4 -4
  74. package/dist/components/ui/badge.d.mts +2 -2
  75. package/dist/components/ui/breadcrumb.d.mts +8 -8
  76. package/dist/components/ui/button.d.mts +2 -2
  77. package/dist/components/ui/calendar.d.mts +17 -4
  78. package/dist/components/ui/calendar.d.mts.map +1 -1
  79. package/dist/components/ui/calendar.mjs +90 -37
  80. package/dist/components/ui/calendar.mjs.map +1 -1
  81. package/dist/components/ui/card.d.mts +7 -7
  82. package/dist/components/ui/carousel.d.mts +6 -6
  83. package/dist/components/ui/chart.client.d.mts +5 -5
  84. package/dist/components/ui/checkbox.d.mts +2 -2
  85. package/dist/components/ui/collapsible.client.d.mts +4 -4
  86. package/dist/components/ui/color-picker.client.d.mts +2 -2
  87. package/dist/components/ui/combobox-dropdown.client.d.mts +2 -2
  88. package/dist/components/ui/combobox.client.d.mts +2 -2
  89. package/dist/components/ui/command.d.mts +10 -10
  90. package/dist/components/ui/context-menu.d.mts +16 -16
  91. package/dist/components/ui/date-picker.client.d.mts +2 -2
  92. package/dist/components/ui/dialog.client.d.mts +11 -11
  93. package/dist/components/ui/drawer.client.d.mts +11 -11
  94. package/dist/components/ui/dropdown-menu.d.mts +16 -16
  95. package/dist/components/ui/form.client.d.mts +7 -7
  96. package/dist/components/ui/hover-card.client.d.mts +4 -4
  97. package/dist/components/ui/input-recipient.d.mts +5 -3
  98. package/dist/components/ui/input-recipient.d.mts.map +1 -1
  99. package/dist/components/ui/input-recipient.mjs +2 -2
  100. package/dist/components/ui/input-recipient.mjs.map +1 -1
  101. package/dist/components/ui/input.d.mts +2 -2
  102. package/dist/components/ui/label.d.mts +2 -2
  103. package/dist/components/ui/navigation-menu.d.mts +9 -9
  104. package/dist/components/ui/pagination.d.mts +8 -8
  105. package/dist/components/ui/popover.d.mts +5 -5
  106. package/dist/components/ui/progress.client.d.mts +2 -2
  107. package/dist/components/ui/radio-group.d.mts +3 -3
  108. package/dist/components/ui/resizable.client.d.mts +4 -4
  109. package/dist/components/ui/scroll-area.d.mts +3 -3
  110. package/dist/components/ui/select.client.d.mts +11 -11
  111. package/dist/components/ui/separator.d.mts +2 -2
  112. package/dist/components/ui/sheet.client.d.mts +9 -9
  113. package/dist/components/ui/sidebar.client.d.mts +26 -26
  114. package/dist/components/ui/skeleton.d.mts +2 -2
  115. package/dist/components/ui/slider.d.mts +2 -2
  116. package/dist/components/ui/sonner.client.d.mts +2 -2
  117. package/dist/components/ui/switch.d.mts +2 -2
  118. package/dist/components/ui/tabs.d.mts +5 -5
  119. package/dist/components/ui/textarea.d.mts +2 -2
  120. package/dist/components/ui/time-input.client.d.mts +2 -2
  121. package/dist/components/ui/toggle-group.client.d.mts +3 -3
  122. package/dist/components/ui/toggle.d.mts +4 -4
  123. package/dist/components/ui/toggle.d.mts.map +1 -1
  124. package/dist/components/ui/tooltip.client.d.mts +5 -5
  125. package/dist/components/ui/tooltip.client.d.mts.map +1 -1
  126. package/dist/components.d.mts +2 -2
  127. package/dist/components.mjs +2 -2
  128. package/dist/config/server.d.mts +1 -2
  129. package/dist/config/server.mjs +1 -2
  130. package/dist/data-tables.d.mts +6 -5
  131. package/dist/data-tables.mjs +4 -3
  132. package/dist/inline-edit/client.d.mts +4 -4
  133. package/dist/inline-edit/client.mjs +3 -3
  134. package/dist/lib/hooks/use-action.d.mts +2 -2
  135. package/dist/lib/hooks/use-indicator.d.mts +2 -2
  136. package/dist/lib.mjs +1 -1
  137. package/dist/modules/auth/components/allowed.client.d.mts +2 -2
  138. package/dist/modules/auth/components/allowed.client.d.mts.map +1 -1
  139. package/dist/modules/auth/components/auth-layout.server.d.mts +2 -2
  140. package/dist/modules/auth/components/auth-layout.server.d.mts.map +1 -1
  141. package/dist/modules/auth/components/auth-loading.d.mts +2 -2
  142. package/dist/modules/auth/components/auth-loading.d.mts.map +1 -1
  143. package/dist/modules/auth/components/create-first-user-page.client.d.mts +2 -2
  144. package/dist/modules/auth/components/create-first-user-page.client.d.mts.map +1 -1
  145. package/dist/modules/auth/components/forget-password-page.client.d.mts +2 -2
  146. package/dist/modules/auth/components/forget-password-page.client.d.mts.map +1 -1
  147. package/dist/modules/auth/components/guard-first-user.server.d.mts +2 -2
  148. package/dist/modules/auth/components/guard-first-user.server.d.mts.map +1 -1
  149. package/dist/modules/auth/components/guard.server.d.mts +2 -2
  150. package/dist/modules/auth/components/guard.server.d.mts.map +1 -1
  151. package/dist/modules/auth/components/login-page.client.d.mts +2 -2
  152. package/dist/modules/auth/components/login-page.client.d.mts.map +1 -1
  153. package/dist/modules/auth/components/reset-password-page.client.d.mts +2 -2
  154. package/dist/modules/auth/components/reset-password-page.client.d.mts.map +1 -1
  155. package/dist/modules/auth/components/update-password-command.d.mts +2 -2
  156. package/dist/modules/auth/components/update-password-command.d.mts.map +1 -1
  157. package/dist/modules/auth/db/schema.d.mts +247 -230
  158. package/dist/modules/auth/db/schema.d.mts.map +1 -1
  159. package/dist/modules/auth/db/schema.mjs +12 -20
  160. package/dist/modules/auth/db/schema.mjs.map +1 -1
  161. package/dist/modules/auth/handler/client.client.d.mts +129 -129
  162. package/dist/modules/auth/handler/client.client.d.mts.map +1 -1
  163. package/dist/modules/auth/handler/client.client.mjs +10 -6
  164. package/dist/modules/auth/handler/client.client.mjs.map +1 -1
  165. package/dist/modules/auth/handler/init.d.mts +134 -131
  166. package/dist/modules/auth/handler/init.d.mts.map +1 -1
  167. package/dist/modules/auth/handler/init.mjs +5 -2
  168. package/dist/modules/auth/handler/init.mjs.map +1 -1
  169. package/dist/modules/auth/hooks/use-permission.d.mts +2 -2
  170. package/dist/modules/auth/hooks/use-permission.d.mts.map +1 -1
  171. package/dist/modules/auth/hooks/use-permission.mjs +7 -2
  172. package/dist/modules/auth/hooks/use-permission.mjs.map +1 -1
  173. package/dist/modules/auth/hooks/use-session.d.mts +119 -3
  174. package/dist/modules/auth/hooks/use-session.d.mts.map +1 -1
  175. package/dist/modules/auth/hooks/use-session.mjs +15 -10
  176. package/dist/modules/auth/hooks/use-session.mjs.map +1 -1
  177. package/dist/modules/auth/lib/helpers.server.d.mts +5 -5
  178. package/dist/modules/auth/lib/helpers.server.d.mts.map +1 -1
  179. package/dist/modules/auth/lib/validators.d.mts +1 -1
  180. package/dist/modules/auth/lib/validators.d.mts.map +1 -1
  181. package/dist/modules/auth/lib/validators.mjs +1 -1
  182. package/dist/modules/auth/lib/validators.mjs.map +1 -1
  183. package/dist/modules/commands/components/alert-dialog-command.client.d.mts +10 -10
  184. package/dist/modules/commands/components/alert-dialog-command.client.d.mts.map +1 -1
  185. package/dist/modules/commands/components/alert-dialog-command.client.mjs +2 -2
  186. package/dist/modules/commands/components/alert-dialog-command.client.mjs.map +1 -1
  187. package/dist/modules/commands/components/click-command.client.d.mts +2 -2
  188. package/dist/modules/commands/components/click-command.client.d.mts.map +1 -1
  189. package/dist/modules/commands/components/click-command.client.mjs +2 -2
  190. package/dist/modules/commands/components/click-command.client.mjs.map +1 -1
  191. package/dist/modules/commands/components/command-trigger.client.d.mts +6 -6
  192. package/dist/modules/commands/components/command-trigger.client.d.mts.map +1 -1
  193. package/dist/modules/commands/components/dialog-command.client.d.mts +18 -8
  194. package/dist/modules/commands/components/dialog-command.client.d.mts.map +1 -1
  195. package/dist/modules/commands/components/dialog-command.client.mjs +12 -8
  196. package/dist/modules/commands/components/dialog-command.client.mjs.map +1 -1
  197. package/dist/modules/commands/components/dropdown-command.client.d.mts +5 -5
  198. package/dist/modules/commands/components/dropdown-command.client.d.mts.map +1 -1
  199. package/dist/modules/commands/components/dropdown-command.client.mjs +2 -2
  200. package/dist/modules/commands/components/dropdown-command.client.mjs.map +1 -1
  201. package/dist/modules/commands/components/empty-command.client.d.mts +2 -2
  202. package/dist/modules/commands/components/form-dialog-command.client.d.mts +11 -11
  203. package/dist/modules/commands/components/form-dialog-command.client.mjs +2 -2
  204. package/dist/modules/commands/components/form-dialog-command.client.mjs.map +1 -1
  205. package/dist/modules/commands/hooks/use-command-mutation.client.d.mts +17 -0
  206. package/dist/modules/commands/hooks/use-command-mutation.client.d.mts.map +1 -0
  207. package/dist/modules/commands/hooks/use-command-mutation.client.mjs +42 -0
  208. package/dist/modules/commands/hooks/use-command-mutation.client.mjs.map +1 -0
  209. package/dist/modules/commands/menus/context-menu.client.d.mts +2 -2
  210. package/dist/modules/commands/menus/dropdown-menu.client.d.mts +3 -3
  211. package/dist/modules/commands/menus/inline-menu.client.d.mts +3 -3
  212. package/dist/modules/commands/menus/responsive-menu.client.d.mts +3 -3
  213. package/dist/modules/commands/utils/archive-command.client.d.mts +3 -3
  214. package/dist/modules/commands/utils/delete-command.client.d.mts +13 -8
  215. package/dist/modules/commands/utils/delete-command.client.d.mts.map +1 -1
  216. package/dist/modules/commands/utils/delete-command.client.mjs +10 -1
  217. package/dist/modules/commands/utils/delete-command.client.mjs.map +1 -1
  218. package/dist/modules/config/db/helpers.d.mts +5 -5
  219. package/dist/modules/config/db/helpers.d.mts.map +1 -1
  220. package/dist/modules/config/lib/config.d.mts +3 -3
  221. package/dist/modules/config/lib/config.d.mts.map +1 -1
  222. package/dist/modules/config/lib/config.mjs.map +1 -1
  223. package/dist/modules/config/lib/context.d.mts +2 -2
  224. package/dist/modules/config/lib/context.d.mts.map +1 -1
  225. package/dist/modules/config/lib/context.mjs.map +1 -1
  226. package/dist/modules/data-tables/components/cell/common.client.d.mts +5 -5
  227. package/dist/modules/data-tables/components/cell/common.client.d.mts.map +1 -1
  228. package/dist/modules/data-tables/components/column-header.d.mts +2 -2
  229. package/dist/modules/data-tables/components/filters/combobox.client.d.mts +2 -2
  230. package/dist/modules/data-tables/components/filters/combobox.client.d.mts.map +1 -1
  231. package/dist/modules/data-tables/components/filters/combobox.client.mjs +5 -2
  232. package/dist/modules/data-tables/components/filters/combobox.client.mjs.map +1 -1
  233. package/dist/modules/data-tables/components/filters/slider.client.d.mts +2 -2
  234. package/dist/modules/data-tables/components/filters/slider.client.d.mts.map +1 -1
  235. package/dist/modules/data-tables/components/header.d.mts +4 -4
  236. package/dist/modules/data-tables/components/layout.d.mts +2 -2
  237. package/dist/modules/data-tables/components/layout.d.mts.map +1 -1
  238. package/dist/modules/data-tables/components/search-input.client.d.mts +2 -2
  239. package/dist/modules/data-tables/components/search-input.client.d.mts.map +1 -1
  240. package/dist/modules/data-tables/components/skeleton.d.mts +2 -2
  241. package/dist/modules/data-tables/components/skeleton.d.mts.map +1 -1
  242. package/dist/modules/data-tables/components/table.d.mts +7 -7
  243. package/dist/modules/data-tables/components/table.d.mts.map +1 -1
  244. package/dist/modules/data-tables/components/toolbar.d.mts +3 -3
  245. package/dist/modules/data-tables/components/toolbar.d.mts.map +1 -1
  246. package/dist/modules/data-tables/hooks/use-context.client.d.mts +13 -10
  247. package/dist/modules/data-tables/hooks/use-context.client.d.mts.map +1 -1
  248. package/dist/modules/data-tables/hooks/use-context.client.mjs.map +1 -1
  249. package/dist/modules/data-tables/hooks/use-table.client.d.mts +2 -1
  250. package/dist/modules/data-tables/hooks/use-table.client.d.mts.map +1 -1
  251. package/dist/modules/data-tables/hooks/use-table.client.mjs.map +1 -1
  252. package/dist/modules/data-tables/lib/converters/search.d.mts +1 -1
  253. package/dist/modules/data-tables/lib/converters/sorting.d.mts +1 -1
  254. package/dist/modules/data-tables/lib/filters/config.d.mts +4 -1
  255. package/dist/modules/data-tables/lib/filters/config.d.mts.map +1 -1
  256. package/dist/modules/data-tables/lib/filters/config.mjs.map +1 -1
  257. package/dist/modules/data-tables/lib/filters/helpers.d.mts +11 -0
  258. package/dist/modules/data-tables/lib/filters/helpers.d.mts.map +1 -0
  259. package/dist/modules/data-tables/lib/filters/helpers.mjs +17 -0
  260. package/dist/modules/data-tables/lib/filters/helpers.mjs.map +1 -0
  261. package/dist/modules/data-tables/lib/filters/parsers.d.mts +7 -2
  262. package/dist/modules/data-tables/lib/filters/parsers.d.mts.map +1 -1
  263. package/dist/modules/data-tables/lib/filters/parsers.mjs +6 -1
  264. package/dist/modules/data-tables/lib/filters/parsers.mjs.map +1 -1
  265. package/dist/modules/data-tables/lib/filters/resolvers.d.mts +6 -1
  266. package/dist/modules/data-tables/lib/filters/resolvers.d.mts.map +1 -1
  267. package/dist/modules/data-tables/lib/filters/resolvers.mjs +8 -1
  268. package/dist/modules/data-tables/lib/filters/resolvers.mjs.map +1 -1
  269. package/dist/modules/data-tables/lib/types.d.mts +8 -5
  270. package/dist/modules/data-tables/lib/types.d.mts.map +1 -1
  271. package/dist/modules/data-tables/server/get-data.server.d.mts +1 -1
  272. package/dist/modules/data-tables/tables/data-table/components/table.d.mts +2 -2
  273. package/dist/modules/data-tables/tables/data-table/components/table.d.mts.map +1 -1
  274. package/dist/modules/data-tables/tables/inline-table/components/cells/common.d.mts +2 -2
  275. package/dist/modules/data-tables/tables/inline-table/components/cells/common.d.mts.map +1 -1
  276. package/dist/modules/data-tables/tables/inline-table/components/cells/drag-handle.client.d.mts +2 -2
  277. package/dist/modules/data-tables/tables/inline-table/components/cells/drag-handle.client.d.mts.map +1 -1
  278. package/dist/modules/data-tables/tables/inline-table/components/cells/drag-handle.client.mjs +1 -1
  279. package/dist/modules/data-tables/tables/inline-table/components/cells/drag-handle.client.mjs.map +1 -1
  280. package/dist/modules/data-tables/tables/inline-table/components/inputs/advanced-select.client.d.mts +2 -2
  281. package/dist/modules/data-tables/tables/inline-table/components/inputs/advanced-select.client.d.mts.map +1 -1
  282. package/dist/modules/data-tables/tables/inline-table/components/inputs/combobox.client.d.mts +2 -2
  283. package/dist/modules/data-tables/tables/inline-table/components/inputs/combobox.client.d.mts.map +1 -1
  284. package/dist/modules/data-tables/tables/inline-table/components/inputs/input.client.d.mts +3 -3
  285. package/dist/modules/data-tables/tables/inline-table/components/inputs/input.client.d.mts.map +1 -1
  286. package/dist/modules/data-tables/tables/inline-table/components/inputs/read-only.d.mts +2 -2
  287. package/dist/modules/data-tables/tables/inline-table/components/inputs/read-only.d.mts.map +1 -1
  288. package/dist/modules/data-tables/tables/inline-table/components/inputs/select.client.d.mts +2 -2
  289. package/dist/modules/data-tables/tables/inline-table/components/inputs/select.client.d.mts.map +1 -1
  290. package/dist/modules/data-tables/tables/inline-table/components/table.d.mts +2 -2
  291. package/dist/modules/data-tables/tables/inline-table/components/table.d.mts.map +1 -1
  292. package/dist/modules/data-tables/tables/inline-table/hooks/context.client.d.mts +2 -2
  293. package/dist/modules/data-tables/tables/inline-table/hooks/context.client.d.mts.map +1 -1
  294. package/dist/modules/inline-edit/components/combobox-dropdown.client.d.mts +5 -2
  295. package/dist/modules/inline-edit/components/combobox-dropdown.client.d.mts.map +1 -1
  296. package/dist/modules/inline-edit/components/combobox-dropdown.client.mjs +7 -3
  297. package/dist/modules/inline-edit/components/combobox-dropdown.client.mjs.map +1 -1
  298. package/dist/modules/inline-edit/components/combobox.client.d.mts +5 -2
  299. package/dist/modules/inline-edit/components/combobox.client.d.mts.map +1 -1
  300. package/dist/modules/inline-edit/components/combobox.client.mjs +6 -2
  301. package/dist/modules/inline-edit/components/combobox.client.mjs.map +1 -1
  302. package/dist/modules/inline-edit/components/date-input.client.d.mts +6 -3
  303. package/dist/modules/inline-edit/components/date-input.client.d.mts.map +1 -1
  304. package/dist/modules/inline-edit/components/date-input.client.mjs +5 -3
  305. package/dist/modules/inline-edit/components/date-input.client.mjs.map +1 -1
  306. package/dist/modules/inline-edit/components/date-picker.client.d.mts +7 -3
  307. package/dist/modules/inline-edit/components/date-picker.client.d.mts.map +1 -1
  308. package/dist/modules/inline-edit/components/date-picker.client.mjs +5 -3
  309. package/dist/modules/inline-edit/components/date-picker.client.mjs.map +1 -1
  310. package/dist/modules/inline-edit/components/deprecated-editor.client.d.mts +21 -0
  311. package/dist/modules/inline-edit/components/deprecated-editor.client.d.mts.map +1 -0
  312. package/dist/modules/inline-edit/components/deprecated-editor.client.mjs +37 -0
  313. package/dist/modules/inline-edit/components/deprecated-editor.client.mjs.map +1 -0
  314. package/dist/modules/inline-edit/components/editor.client.d.mts +10 -7
  315. package/dist/modules/inline-edit/components/editor.client.d.mts.map +1 -1
  316. package/dist/modules/inline-edit/components/editor.client.mjs +13 -18
  317. package/dist/modules/inline-edit/components/editor.client.mjs.map +1 -1
  318. package/dist/modules/inline-edit/components/input-recipient.client.d.mts +4 -2
  319. package/dist/modules/inline-edit/components/input-recipient.client.d.mts.map +1 -1
  320. package/dist/modules/inline-edit/components/input-recipient.client.mjs +7 -3
  321. package/dist/modules/inline-edit/components/input-recipient.client.mjs.map +1 -1
  322. package/dist/modules/inline-edit/components/input-toggle.client.d.mts +3 -2
  323. package/dist/modules/inline-edit/components/input-toggle.client.d.mts.map +1 -1
  324. package/dist/modules/inline-edit/components/input-toggle.client.mjs +3 -2
  325. package/dist/modules/inline-edit/components/input-toggle.client.mjs.map +1 -1
  326. package/dist/modules/inline-edit/components/input.client.d.mts +18 -4
  327. package/dist/modules/inline-edit/components/input.client.d.mts.map +1 -1
  328. package/dist/modules/inline-edit/components/input.client.mjs +26 -5
  329. package/dist/modules/inline-edit/components/input.client.mjs.map +1 -1
  330. package/dist/modules/inline-edit/components/select.client.d.mts +8 -6
  331. package/dist/modules/inline-edit/components/select.client.d.mts.map +1 -1
  332. package/dist/modules/inline-edit/components/select.client.mjs +3 -2
  333. package/dist/modules/inline-edit/components/select.client.mjs.map +1 -1
  334. package/dist/modules/inline-edit/components/switch.client.d.mts +3 -2
  335. package/dist/modules/inline-edit/components/switch.client.d.mts.map +1 -1
  336. package/dist/modules/inline-edit/components/switch.client.mjs +3 -2
  337. package/dist/modules/inline-edit/components/switch.client.mjs.map +1 -1
  338. package/dist/modules/inline-edit/components/toggle.client.d.mts +3 -2
  339. package/dist/modules/inline-edit/components/toggle.client.d.mts.map +1 -1
  340. package/dist/modules/inline-edit/components/toggle.client.mjs +3 -2
  341. package/dist/modules/inline-edit/components/toggle.client.mjs.map +1 -1
  342. package/dist/modules/inline-edit/hooks/context.client.d.mts +2 -2
  343. package/dist/modules/inline-edit/hooks/context.client.d.mts.map +1 -1
  344. package/dist/modules/inline-edit/hooks/use-inline.client.d.mts +1 -1
  345. package/dist/modules/inline-edit/hooks/use-inline.client.mjs.map +1 -1
  346. package/dist/modules/inline-edit/lib/variants.d.mts +3 -3
  347. package/dist/modules/inline-edit/lib/variants.mjs +1 -1
  348. package/dist/modules/inline-edit/lib/variants.mjs.map +1 -1
  349. package/dist/modules/router/handler/context.server.d.mts +2 -2
  350. package/dist/modules/router/handler/context.server.d.mts.map +1 -1
  351. package/dist/modules/router/handler/init.server.d.mts +7 -7
  352. package/dist/modules/router/lib/query-client.server.d.mts +2 -2
  353. package/dist/modules/router/lib/query-client.server.d.mts.map +1 -1
  354. package/dist/modules/{uploads/components/dropzone/context.d.mts → storage/components/dropzone-context.client.d.mts} +2 -2
  355. package/dist/modules/storage/components/dropzone-context.client.d.mts.map +1 -0
  356. package/dist/modules/{uploads/components/dropzone/context.mjs → storage/components/dropzone-context.client.mjs} +2 -2
  357. package/dist/modules/storage/components/dropzone-context.client.mjs.map +1 -0
  358. package/dist/modules/{uploads/components/dropzone/index.d.mts → storage/components/dropzone.client.d.mts} +7 -7
  359. package/dist/modules/storage/components/dropzone.client.d.mts.map +1 -0
  360. package/dist/modules/{uploads/components/dropzone/index.mjs → storage/components/dropzone.client.mjs} +6 -6
  361. package/dist/modules/storage/components/dropzone.client.mjs.map +1 -0
  362. package/dist/modules/storage/components/image-grid.client.d.mts +26 -0
  363. package/dist/modules/storage/components/image-grid.client.d.mts.map +1 -0
  364. package/dist/modules/storage/components/image-grid.client.mjs +169 -0
  365. package/dist/modules/storage/components/image-grid.client.mjs.map +1 -0
  366. package/dist/modules/storage/components/upload-zone-context.client.d.mts +34 -0
  367. package/dist/modules/storage/components/upload-zone-context.client.d.mts.map +1 -0
  368. package/dist/modules/storage/components/upload-zone-context.client.mjs +21 -0
  369. package/dist/modules/storage/components/upload-zone-context.client.mjs.map +1 -0
  370. package/dist/modules/storage/components/upload-zone.client.d.mts +51 -0
  371. package/dist/modules/storage/components/upload-zone.client.d.mts.map +1 -0
  372. package/dist/modules/storage/components/upload-zone.client.mjs +196 -0
  373. package/dist/modules/storage/components/upload-zone.client.mjs.map +1 -0
  374. package/dist/modules/{uploads/lib → storage/config}/filters.d.mts +2 -2
  375. package/dist/modules/storage/config/filters.d.mts.map +1 -0
  376. package/dist/modules/{uploads/lib → storage/config}/filters.mjs +3 -3
  377. package/dist/modules/storage/config/filters.mjs.map +1 -0
  378. package/dist/modules/storage/lib/constants.d.mts +10 -0
  379. package/dist/modules/storage/lib/constants.d.mts.map +1 -0
  380. package/dist/modules/{uploads → storage}/lib/constants.mjs +3 -2
  381. package/dist/modules/storage/lib/constants.mjs.map +1 -0
  382. package/dist/modules/storage/lib/create-client.server.d.mts +11 -0
  383. package/dist/modules/storage/lib/create-client.server.d.mts.map +1 -0
  384. package/dist/modules/storage/lib/create-client.server.mjs +11 -0
  385. package/dist/modules/storage/lib/create-client.server.mjs.map +1 -0
  386. package/dist/modules/storage/lib/helpers.d.mts +45 -0
  387. package/dist/modules/storage/lib/helpers.d.mts.map +1 -0
  388. package/dist/modules/{uploads → storage}/lib/helpers.mjs +20 -6
  389. package/dist/modules/storage/lib/helpers.mjs.map +1 -0
  390. package/dist/modules/storage/lib/proxy.server.d.mts +21 -0
  391. package/dist/modules/storage/lib/proxy.server.d.mts.map +1 -0
  392. package/dist/modules/storage/lib/proxy.server.mjs +46 -0
  393. package/dist/modules/storage/lib/proxy.server.mjs.map +1 -0
  394. package/dist/modules/storage/lib/router.server.d.mts +29074 -0
  395. package/dist/modules/storage/lib/router.server.d.mts.map +1 -0
  396. package/dist/modules/storage/lib/router.server.mjs +83 -0
  397. package/dist/modules/storage/lib/router.server.mjs.map +1 -0
  398. package/dist/modules/{uploads → storage}/lib/schema.d.mts +414 -150
  399. package/dist/modules/storage/lib/schema.d.mts.map +1 -0
  400. package/dist/modules/{uploads → storage}/lib/schema.mjs +23 -18
  401. package/dist/modules/storage/lib/schema.mjs.map +1 -0
  402. package/dist/modules/storage/lib/service.server.d.mts +188 -0
  403. package/dist/modules/storage/lib/service.server.d.mts.map +1 -0
  404. package/dist/modules/storage/lib/service.server.mjs +297 -0
  405. package/dist/modules/storage/lib/service.server.mjs.map +1 -0
  406. package/dist/modules/{uploads → storage}/lib/validators.d.mts +413 -108
  407. package/dist/modules/storage/lib/validators.d.mts.map +1 -0
  408. package/dist/modules/storage/lib/validators.mjs +106 -0
  409. package/dist/modules/storage/lib/validators.mjs.map +1 -0
  410. package/dist/storage/client.d.mts +6 -0
  411. package/dist/storage/client.mjs +14 -0
  412. package/dist/storage/client.mjs.map +1 -0
  413. package/dist/storage/server.d.mts +4 -0
  414. package/dist/storage/server.mjs +5 -0
  415. package/dist/storage.d.mts +6 -0
  416. package/dist/storage.mjs +7 -0
  417. package/package.json +32 -20
  418. package/src/components/editor/components/block-dropdown.tsx +43 -25
  419. package/src/components/editor/components/content.client.tsx +1 -1
  420. package/src/components/editor/components/editor.client.tsx +95 -0
  421. package/src/components/editor/components/menu-fixed.client.tsx +165 -0
  422. package/src/components/editor/components/spinner.tsx +2 -2
  423. package/src/components/editor/lib/constants.ts +109 -0
  424. package/src/components/editor/lib/extensions.ts +195 -0
  425. package/src/components/editor/lib/helpers.ts +3 -3
  426. package/src/components/editor/lib/variants.ts +5 -0
  427. package/src/components/entry.client.ts +2 -4
  428. package/src/components/header/top-bar.client.tsx +1 -1
  429. package/src/components/layouts/admin-content.client.tsx +1 -1
  430. package/src/components/ui/calendar.tsx +152 -44
  431. package/src/components/ui/input-recipient.tsx +3 -0
  432. package/src/entry.ts +4 -4
  433. package/src/modules/auth/db/schema.ts +13 -21
  434. package/src/modules/auth/handler/client.client.ts +2 -0
  435. package/src/modules/auth/handler/init.ts +4 -1
  436. package/src/modules/auth/hooks/use-permission.ts +3 -2
  437. package/src/modules/auth/hooks/use-session.ts +16 -10
  438. package/src/modules/auth/lib/validators.ts +1 -1
  439. package/src/modules/commands/components/alert-dialog-command.client.tsx +2 -2
  440. package/src/modules/commands/components/click-command.client.tsx +2 -2
  441. package/src/modules/commands/components/dialog-command.client.tsx +20 -8
  442. package/src/modules/commands/components/dropdown-command.client.tsx +2 -2
  443. package/src/modules/commands/components/form-dialog-command.client.tsx +2 -2
  444. package/src/modules/commands/entry.client.ts +1 -1
  445. package/src/modules/commands/hooks/{use-command-action.client.tsx → use-command-mutation.client.tsx} +9 -47
  446. package/src/modules/commands/utils/delete-command.client.tsx +14 -2
  447. package/src/modules/config/db/create-client.ts +11 -4
  448. package/src/modules/config/entry.server.ts +0 -1
  449. package/src/modules/config/lib/config.ts +3 -3
  450. package/src/modules/config/lib/context.ts +2 -2
  451. package/src/modules/data-tables/components/filters/combobox.client.tsx +3 -3
  452. package/src/modules/data-tables/entry.ts +1 -1
  453. package/src/modules/data-tables/hooks/use-context.client.tsx +31 -13
  454. package/src/modules/data-tables/hooks/use-table.client.ts +6 -3
  455. package/src/modules/data-tables/lib/filters/config.ts +1 -0
  456. package/src/modules/data-tables/lib/filters/helpers.ts +19 -0
  457. package/src/modules/data-tables/lib/filters/parsers.ts +14 -1
  458. package/src/modules/data-tables/lib/filters/resolvers.ts +8 -0
  459. package/src/modules/data-tables/lib/types.ts +10 -3
  460. package/src/modules/data-tables/tables/inline-table/components/cells/drag-handle.client.tsx +1 -1
  461. package/src/modules/inline-edit/components/combobox-dropdown.client.tsx +9 -2
  462. package/src/modules/inline-edit/components/combobox.client.tsx +8 -1
  463. package/src/modules/inline-edit/components/date-input.client.tsx +7 -3
  464. package/src/modules/inline-edit/components/date-picker.client.tsx +10 -3
  465. package/src/modules/inline-edit/components/deprecated-editor.client.tsx +48 -0
  466. package/src/modules/inline-edit/components/editor.client.tsx +32 -29
  467. package/src/modules/inline-edit/components/input-recipient.client.tsx +6 -2
  468. package/src/modules/inline-edit/components/input-toggle.client.tsx +2 -0
  469. package/src/modules/inline-edit/components/input.client.tsx +39 -0
  470. package/src/modules/inline-edit/components/select.client.tsx +9 -2
  471. package/src/modules/inline-edit/components/switch.client.tsx +2 -0
  472. package/src/modules/inline-edit/components/toggle.client.tsx +2 -0
  473. package/src/modules/inline-edit/entry.client.ts +1 -1
  474. package/src/modules/inline-edit/hooks/use-inline.client.tsx +2 -2
  475. package/src/modules/inline-edit/lib/variants.ts +1 -1
  476. package/src/modules/{uploads/components/dropzone/index.tsx → storage/components/dropzone.client.tsx} +2 -2
  477. package/src/modules/storage/components/image-grid.client.tsx +225 -0
  478. package/src/modules/{uploads/components/button.client.tsx → storage/components/upload-button.client.tsx} +1 -1
  479. package/src/modules/storage/components/upload-zone-context.client.tsx +32 -0
  480. package/src/modules/storage/components/upload-zone.client.tsx +258 -0
  481. package/src/modules/{uploads/lib → storage/config}/filters.ts +2 -2
  482. package/src/modules/storage/entry.client.ts +12 -0
  483. package/src/modules/storage/entry.server.ts +6 -0
  484. package/src/modules/{uploads → storage}/entry.ts +1 -1
  485. package/src/modules/storage/lib/constants.ts +14 -0
  486. package/src/modules/storage/lib/create-client.server.ts +14 -0
  487. package/src/modules/{uploads → storage}/lib/helpers.ts +23 -9
  488. package/src/modules/storage/lib/proxy.server.ts +63 -0
  489. package/src/modules/storage/lib/router.server.ts +174 -0
  490. package/src/modules/{uploads → storage}/lib/schema.ts +34 -13
  491. package/src/modules/storage/lib/service.server.ts +463 -0
  492. package/src/modules/storage/lib/validators.ts +156 -0
  493. package/dist/components/editor/components/fixed-menu.client.d.mts +0 -7
  494. package/dist/components/editor/components/fixed-menu.client.d.mts.map +0 -1
  495. package/dist/components/editor/components/fixed-menu.client.mjs.map +0 -1
  496. package/dist/components/editor/context.client.d.mts +0 -33
  497. package/dist/components/editor/context.client.d.mts.map +0 -1
  498. package/dist/components/editor/context.client.mjs +0 -45
  499. package/dist/components/editor/context.client.mjs.map +0 -1
  500. package/dist/components/editor/index.client.d.mts +0 -11
  501. package/dist/components/editor/index.client.d.mts.map +0 -1
  502. package/dist/components/editor/index.client.mjs +0 -17
  503. package/dist/components/editor/index.client.mjs.map +0 -1
  504. package/dist/components/editor/preview.client.d.mts +0 -12
  505. package/dist/components/editor/preview.client.d.mts.map +0 -1
  506. package/dist/components/editor/preview.client.mjs +0 -19
  507. package/dist/components/editor/preview.client.mjs.map +0 -1
  508. package/dist/modules/commands/hooks/use-command-action.client.d.mts +0 -22
  509. package/dist/modules/commands/hooks/use-command-action.client.d.mts.map +0 -1
  510. package/dist/modules/commands/hooks/use-command-action.client.mjs +0 -74
  511. package/dist/modules/commands/hooks/use-command-action.client.mjs.map +0 -1
  512. package/dist/modules/config/providers/blob.d.mts +0 -10
  513. package/dist/modules/config/providers/blob.d.mts.map +0 -1
  514. package/dist/modules/config/providers/blob.mjs +0 -11
  515. package/dist/modules/config/providers/blob.mjs.map +0 -1
  516. package/dist/modules/inline-edit/components/richtext.client.d.mts +0 -15
  517. package/dist/modules/inline-edit/components/richtext.client.d.mts.map +0 -1
  518. package/dist/modules/inline-edit/components/richtext.client.mjs +0 -31
  519. package/dist/modules/inline-edit/components/richtext.client.mjs.map +0 -1
  520. package/dist/modules/uploads/components/button.client.d.mts +0 -12
  521. package/dist/modules/uploads/components/button.client.d.mts.map +0 -1
  522. package/dist/modules/uploads/components/button.client.mjs +0 -34
  523. package/dist/modules/uploads/components/button.client.mjs.map +0 -1
  524. package/dist/modules/uploads/components/dropzone/context.d.mts.map +0 -1
  525. package/dist/modules/uploads/components/dropzone/context.mjs.map +0 -1
  526. package/dist/modules/uploads/components/dropzone/index.d.mts.map +0 -1
  527. package/dist/modules/uploads/components/dropzone/index.mjs.map +0 -1
  528. package/dist/modules/uploads/components/images/grid.client.d.mts +0 -11
  529. package/dist/modules/uploads/components/images/grid.client.d.mts.map +0 -1
  530. package/dist/modules/uploads/components/images/grid.client.mjs +0 -119
  531. package/dist/modules/uploads/components/images/grid.client.mjs.map +0 -1
  532. package/dist/modules/uploads/components/images/input.client.d.mts +0 -16
  533. package/dist/modules/uploads/components/images/input.client.d.mts.map +0 -1
  534. package/dist/modules/uploads/components/images/input.client.mjs +0 -28
  535. package/dist/modules/uploads/components/images/input.client.mjs.map +0 -1
  536. package/dist/modules/uploads/components/preview-dialog.client.d.mts +0 -16
  537. package/dist/modules/uploads/components/preview-dialog.client.d.mts.map +0 -1
  538. package/dist/modules/uploads/components/preview-dialog.client.mjs +0 -22
  539. package/dist/modules/uploads/components/preview-dialog.client.mjs.map +0 -1
  540. package/dist/modules/uploads/components/zone.client.d.mts +0 -21
  541. package/dist/modules/uploads/components/zone.client.d.mts.map +0 -1
  542. package/dist/modules/uploads/components/zone.client.mjs +0 -38
  543. package/dist/modules/uploads/components/zone.client.mjs.map +0 -1
  544. package/dist/modules/uploads/hooks/use-upload-image.client.d.mts +0 -34
  545. package/dist/modules/uploads/hooks/use-upload-image.client.d.mts.map +0 -1
  546. package/dist/modules/uploads/hooks/use-upload-image.client.mjs +0 -101
  547. package/dist/modules/uploads/hooks/use-upload-image.client.mjs.map +0 -1
  548. package/dist/modules/uploads/hooks/use-upload-zone.client.d.mts +0 -39
  549. package/dist/modules/uploads/hooks/use-upload-zone.client.d.mts.map +0 -1
  550. package/dist/modules/uploads/hooks/use-upload-zone.client.mjs +0 -20
  551. package/dist/modules/uploads/hooks/use-upload-zone.client.mjs.map +0 -1
  552. package/dist/modules/uploads/lib/constants.d.mts +0 -9
  553. package/dist/modules/uploads/lib/constants.d.mts.map +0 -1
  554. package/dist/modules/uploads/lib/constants.mjs.map +0 -1
  555. package/dist/modules/uploads/lib/filters.d.mts.map +0 -1
  556. package/dist/modules/uploads/lib/filters.mjs.map +0 -1
  557. package/dist/modules/uploads/lib/helpers.d.mts +0 -36
  558. package/dist/modules/uploads/lib/helpers.d.mts.map +0 -1
  559. package/dist/modules/uploads/lib/helpers.mjs.map +0 -1
  560. package/dist/modules/uploads/lib/procedures.server.d.mts +0 -13628
  561. package/dist/modules/uploads/lib/procedures.server.d.mts.map +0 -1
  562. package/dist/modules/uploads/lib/procedures.server.mjs +0 -176
  563. package/dist/modules/uploads/lib/procedures.server.mjs.map +0 -1
  564. package/dist/modules/uploads/lib/proxy.server.d.mts +0 -54
  565. package/dist/modules/uploads/lib/proxy.server.d.mts.map +0 -1
  566. package/dist/modules/uploads/lib/proxy.server.mjs +0 -97
  567. package/dist/modules/uploads/lib/proxy.server.mjs.map +0 -1
  568. package/dist/modules/uploads/lib/route.server.d.mts +0 -43
  569. package/dist/modules/uploads/lib/route.server.d.mts.map +0 -1
  570. package/dist/modules/uploads/lib/route.server.mjs +0 -70
  571. package/dist/modules/uploads/lib/route.server.mjs.map +0 -1
  572. package/dist/modules/uploads/lib/schema.d.mts.map +0 -1
  573. package/dist/modules/uploads/lib/schema.mjs.map +0 -1
  574. package/dist/modules/uploads/lib/validators.d.mts.map +0 -1
  575. package/dist/modules/uploads/lib/validators.mjs +0 -26
  576. package/dist/modules/uploads/lib/validators.mjs.map +0 -1
  577. package/dist/uploads/client.d.mts +0 -10
  578. package/dist/uploads/client.mjs +0 -11
  579. package/dist/uploads/server.d.mts +0 -4
  580. package/dist/uploads/server.mjs +0 -5
  581. package/dist/uploads.d.mts +0 -6
  582. package/dist/uploads.mjs +0 -7
  583. package/src/components/editor/components/fixed-menu.client.tsx +0 -143
  584. package/src/components/editor/context.client.tsx +0 -116
  585. package/src/components/editor/index.client.tsx +0 -13
  586. package/src/components/editor/preview.client.tsx +0 -13
  587. package/src/modules/config/providers/blob.ts +0 -11
  588. package/src/modules/inline-edit/components/richtext.client.tsx +0 -38
  589. package/src/modules/uploads/components/images/grid.client.tsx +0 -162
  590. package/src/modules/uploads/components/images/input.client.tsx +0 -34
  591. package/src/modules/uploads/components/preview-dialog.client.tsx +0 -21
  592. package/src/modules/uploads/components/zone.client.tsx +0 -56
  593. package/src/modules/uploads/entry.client.ts +0 -16
  594. package/src/modules/uploads/entry.server.ts +0 -6
  595. package/src/modules/uploads/hooks/use-upload-image.client.tsx +0 -131
  596. package/src/modules/uploads/hooks/use-upload-zone.client.ts +0 -44
  597. package/src/modules/uploads/lib/constants.ts +0 -10
  598. package/src/modules/uploads/lib/procedures.server.ts +0 -332
  599. package/src/modules/uploads/lib/proxy.server.ts +0 -139
  600. package/src/modules/uploads/lib/route.server.ts +0 -93
  601. package/src/modules/uploads/lib/validators.ts +0 -50
  602. /package/src/modules/{uploads/components/dropzone/context.tsx → storage/components/dropzone-context.client.tsx} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.mts","names":[],"sources":["../../../../src/modules/storage/lib/schema.ts"],"sourcesContent":[],"mappings":";;;;cAOa,cAAuD,uBAAA,CAA3C;cACZ,cAAyD,uBAAA,CAA7C;;;AADzB;AACa,cAKA,KALyD,0BAKpD,kBALO,CAAA;EAKZ,IAAA,EAAA,OAcV;EAAA,MAAA,EAAA,SAAA;;UAAA,uBAAA,CAAA;;;;;;;;;;;;;;;0BAde;IAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA;IAgBL,SAAA,kCAWV,CAAA;MAAA,IAAA,EAAA,WAAA;;;;UAXwB,EAAA,MAAA;MAAA,WAAA,EAAA,MAAA;MAgBd,OAQV,EAAA,IAAA;MAAA,UAAA,EAAA,IAAA;;;;;;;;;IARsB,IAAA,kCAAA,CAAA;MAUZ,IAAA,EAAA,MAAA;MAWA,SAAA,EAAA,OAeZ;MAAA,QAAA,EAAA,QAAA;;;;;;;;;;;;0BAf6B;IAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA;IAiBjB,IAAA,kCAMV,CAAA;MAKG,IAAA,EAOL,MAAA;MAAA,SAAA,EAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MACW,IAAA,EAAW,aAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KACW,WAAA,UAAqB"}
@@ -1,11 +1,11 @@
1
- import { users } from "../../auth/db/schema.mjs";
2
1
  import { baseColumns } from "../../config/db/helpers.mjs";
2
+ import { users } from "../../auth/db/schema.mjs";
3
3
  import { imageDispositions, imageVariants } from "./constants.mjs";
4
4
  import { nodeSubtypes } from "./helpers.mjs";
5
- import { relations } from "drizzle-orm";
6
5
  import { boolean, pgEnum, pgTable, unique } from "drizzle-orm/pg-core";
6
+ import { relations } from "drizzle-orm";
7
7
 
8
- //#region src/modules/uploads/lib/schema.ts
8
+ //#region src/modules/storage/lib/schema.ts
9
9
  const nodeTypeEnum = pgEnum("node_types", ["file", "folder"]);
10
10
  const nodeModeEnum = pgEnum("node_mode", ["private", "public"]);
11
11
  /**
@@ -21,7 +21,7 @@ const nodes = pgTable("nodes", (t) => ({
21
21
  size: t.integer().default(0),
22
22
  contentType: t.varchar({ length: 255 }),
23
23
  readonly: boolean().default(false),
24
- createdBy: t.text().references(() => users.id, { onDelete: "set null" }),
24
+ createdBy: t.uuid().references(() => users.id, { onDelete: "set null" }),
25
25
  isPending: t.boolean().default(false).notNull(),
26
26
  isDeleted: t.boolean().default(false).notNull(),
27
27
  parentId: t.uuid().references(() => nodes.id, { onDelete: "cascade" })
@@ -33,9 +33,24 @@ const nodesRelations = relations(nodes, ({ one, many }) => ({
33
33
  relationName: "parent"
34
34
  }),
35
35
  children: many(nodes, { relationName: "parent" }),
36
- urls: many(nodePresignedUrls)
36
+ urls: many(nodePresignedUrls),
37
+ variants: many(nodeVariants)
37
38
  }));
38
39
  /**
40
+ * Node variants table
41
+ */
42
+ const nodeVariants = pgTable("node_variants", (t) => ({
43
+ ...baseColumns,
44
+ nodeId: t.uuid().notNull().references(() => nodes.id, { onDelete: "cascade" }),
45
+ variant: t.text({ enum: imageVariants }).notNull(),
46
+ width: t.integer().notNull()
47
+ }));
48
+ const nodeVariantsRelations = relations(nodeVariants, ({ one }) => ({ node: one(nodes, {
49
+ fields: [nodeVariants.nodeId],
50
+ references: [nodes.id],
51
+ relationName: "node"
52
+ }) }));
53
+ /**
39
54
  * Node presigned urls table
40
55
  */
41
56
  const nodePresignedUrls = pgTable("node_presigned_urls", (t) => ({
@@ -44,25 +59,15 @@ const nodePresignedUrls = pgTable("node_presigned_urls", (t) => ({
44
59
  variant: t.text({ enum: imageVariants }).notNull(),
45
60
  disposition: t.text({ enum: imageDispositions }).notNull(),
46
61
  expiresAt: t.timestamp().notNull(),
47
- nodeId: t.uuid().notNull().references(() => nodes.id, { onDelete: "cascade" })
62
+ nodeId: t.uuid().notNull().references(() => nodes.id, { onDelete: "cascade" }),
63
+ variantId: t.uuid().references(() => nodeVariants.id, { onDelete: "set null" })
48
64
  }), (t) => [unique("node_presigned_url_unique").on(t.nodeId, t.variant, t.disposition)]);
49
65
  const nodePresignedUrlsRelations = relations(nodePresignedUrls, ({ one }) => ({ node: one(nodes, {
50
66
  fields: [nodePresignedUrls.nodeId],
51
67
  references: [nodes.id],
52
68
  relationName: "node"
53
69
  }) }));
54
- /**
55
- * @deprecated
56
- */
57
- const assets = pgTable("assets", (t) => ({
58
- ...baseColumns,
59
- name: t.text().notNull(),
60
- pathname: t.text().notNull(),
61
- url: t.text().notNull().unique(),
62
- size: t.integer().default(0),
63
- contentType: t.varchar({ length: 255 })
64
- }));
65
70
 
66
71
  //#endregion
67
- export { assets, nodeModeEnum, nodePresignedUrls, nodePresignedUrlsRelations, nodeTypeEnum, nodes, nodesRelations };
72
+ export { nodeModeEnum, nodePresignedUrls, nodePresignedUrlsRelations, nodeTypeEnum, nodeVariants, nodeVariantsRelations, nodes, nodesRelations };
68
73
  //# sourceMappingURL=schema.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.mjs","names":[],"sources":["../../../../src/modules/storage/lib/schema.ts"],"sourcesContent":["import { users } from \"@/modules/auth/db/schema\";\nimport { baseColumns } from \"@/modules/config/db/helpers\";\nimport { relations } from \"drizzle-orm\";\nimport { AnyPgColumn, boolean, pgEnum, pgTable, unique } from \"drizzle-orm/pg-core\";\nimport { imageDispositions, imageVariants } from \"./constants\";\nimport { nodeSubtypes } from \"./helpers\";\n\nexport const nodeTypeEnum = pgEnum(\"node_types\", [\"file\", \"folder\"]);\nexport const nodeModeEnum = pgEnum(\"node_mode\", [\"private\", \"public\"]);\n\n/**\n * Node table\n */\nexport const nodes = pgTable(\"nodes\", (t) => ({\n ...baseColumns,\n name: t.text().notNull(),\n namespace: t.text().notNull().default(\"global\"),\n type: nodeTypeEnum(),\n mode: nodeModeEnum().default(\"private\"),\n subtype: t.text({ enum: nodeSubtypes }).notNull().default(\"other\"),\n size: t.integer().default(0),\n contentType: t.varchar({ length: 255 }),\n readonly: boolean().default(false),\n createdBy: t.uuid().references(() => users.id, { onDelete: \"set null\" }),\n isPending: t.boolean().default(false).notNull(),\n isDeleted: t.boolean().default(false).notNull(),\n parentId: t.uuid().references((): AnyPgColumn => nodes.id, { onDelete: \"cascade\" }),\n}));\n\nexport const nodesRelations = relations(nodes, ({ one, many }) => ({\n parent: one(nodes, {\n fields: [nodes.parentId],\n references: [nodes.id],\n relationName: \"parent\",\n }),\n children: many(nodes, {\n relationName: \"parent\",\n }),\n urls: many(nodePresignedUrls),\n variants: many(nodeVariants),\n}));\n\n/**\n * Node variants table\n */\nexport const nodeVariants = pgTable(\"node_variants\", (t) => ({\n ...baseColumns,\n nodeId: t\n .uuid()\n .notNull()\n .references(() => nodes.id, { onDelete: \"cascade\" }),\n variant: t.text({ enum: imageVariants }).notNull(),\n width: t.integer().notNull(),\n}));\n\nexport const nodeVariantsRelations = relations(nodeVariants, ({ one }) => ({\n node: one(nodes, {\n fields: [nodeVariants.nodeId],\n references: [nodes.id],\n relationName: \"node\",\n }),\n}));\n\n/**\n * Node presigned urls table\n */\nexport const nodePresignedUrls = pgTable(\n \"node_presigned_urls\",\n (t) => ({\n ...baseColumns,\n url: t.text().notNull().unique(),\n variant: t.text({ enum: imageVariants }).notNull(),\n disposition: t.text({ enum: imageDispositions }).notNull(),\n expiresAt: t.timestamp().notNull(),\n nodeId: t\n .uuid()\n .notNull()\n .references(() => nodes.id, { onDelete: \"cascade\" }),\n variantId: t.uuid().references(() => nodeVariants.id, { onDelete: \"set null\" }),\n }),\n (t) => [unique(\"node_presigned_url_unique\").on(t.nodeId, t.variant, t.disposition)],\n);\n\nexport const nodePresignedUrlsRelations = relations(nodePresignedUrls, ({ one }) => ({\n node: one(nodes, {\n fields: [nodePresignedUrls.nodeId],\n references: [nodes.id],\n relationName: \"node\",\n }),\n}));\n\n/**\n * Drive schema\n **/\nconst driveSchema = {\n nodes,\n nodesRelations,\n nodeVariants,\n nodeVariantsRelations,\n nodePresignedUrls,\n nodePresignedUrlsRelations,\n};\nexport type DriveSchema = typeof driveSchema;\n"],"mappings":";;;;;;;;AAOA,MAAa,eAAe,OAAO,cAAc,CAAC,QAAQ,SAAS,CAAC;AACpE,MAAa,eAAe,OAAO,aAAa,CAAC,WAAW,SAAS,CAAC;;;;AAKtE,MAAa,QAAQ,QAAQ,UAAU,OAAO;CAC5C,GAAG;CACH,MAAM,EAAE,MAAM,CAAC,SAAS;CACxB,WAAW,EAAE,MAAM,CAAC,SAAS,CAAC,QAAQ,SAAS;CAC/C,MAAM,cAAc;CACpB,MAAM,cAAc,CAAC,QAAQ,UAAU;CACvC,SAAS,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC,CAAC,SAAS,CAAC,QAAQ,QAAQ;CAClE,MAAM,EAAE,SAAS,CAAC,QAAQ,EAAE;CAC5B,aAAa,EAAE,QAAQ,EAAE,QAAQ,KAAK,CAAC;CACvC,UAAU,SAAS,CAAC,QAAQ,MAAM;CAClC,WAAW,EAAE,MAAM,CAAC,iBAAiB,MAAM,IAAI,EAAE,UAAU,YAAY,CAAC;CACxE,WAAW,EAAE,SAAS,CAAC,QAAQ,MAAM,CAAC,SAAS;CAC/C,WAA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CAAC;CAChF,IACA,MAAM,CAAC,OAAO,4BAA4B,CAAC,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,CAAC,CACpF;AAED,MAAa,6BAA6B,UAAU,oBAAoB,EAAE,WAAW,EACnF,MAAM,IAAI,OAAO;CACf,QAAQ,CAAC,kBAAkB,OAAO;CAClC,YAAY,CAAC,MAAM,GAAG;CACtB,cAAc;CACf,CAAC,EACH,EAAE"}
@@ -0,0 +1,188 @@
1
+ import { TDatabaseSchema } from "../../config/db/types.mjs";
2
+ import { DatabaseClient } from "../../config/db/init.mjs";
3
+ import "../../../config/server.mjs";
4
+ import { BulkActionSchema } from "../../router/lib/validators.mjs";
5
+ import "../../../router.mjs";
6
+ import { CreateFolderNodeSchema, GetFileURLSchema, GetNodesByParentIdInput, Node, PresignFileSchema, PutObjectInput, UpdateNodeSchema, UploadFileSchema } from "./validators.mjs";
7
+ import "../../../config.mjs";
8
+ import * as _aws_sdk_client_s30 from "@aws-sdk/client-s3";
9
+ import { S3Client, S3ClientConfig } from "@aws-sdk/client-s3";
10
+
11
+ //#region src/modules/storage/lib/service.server.d.ts
12
+ /**
13
+ * Storage Service Config
14
+ */
15
+ type StorageServiceConfig<TSchema extends TDatabaseSchema> = {
16
+ db: DatabaseClient<TSchema>;
17
+ config: S3ClientConfig;
18
+ };
19
+ /**
20
+ * Storage Service
21
+ */
22
+ declare class StorageService<TSchema extends TDatabaseSchema> {
23
+ #private;
24
+ /**
25
+ * Constructor
26
+ */
27
+ constructor({
28
+ db,
29
+ config
30
+ }: StorageServiceConfig<TSchema>);
31
+ /**
32
+ * Get Blob
33
+ */
34
+ blob(): S3Client;
35
+ /**
36
+ * Get object
37
+ */
38
+ getObject(id: string, options?: GetFileURLSchema): Promise<_aws_sdk_client_s30.GetObjectCommandOutput>;
39
+ /**
40
+ * Get nodes by parent id
41
+ */
42
+ getNodesByParentId({
43
+ filters,
44
+ ...query
45
+ }: GetNodesByParentIdInput): Promise<{
46
+ name: string;
47
+ namespace: string;
48
+ type: "file" | "folder" | null;
49
+ mode: "private" | "public" | null;
50
+ subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
51
+ size: number | null;
52
+ contentType: string | null;
53
+ readonly: boolean | null;
54
+ createdBy: string | null;
55
+ isPending: boolean;
56
+ isDeleted: boolean;
57
+ parentId: string | null;
58
+ id: string;
59
+ createdAt: Date;
60
+ updatedAt: Date;
61
+ }[]>;
62
+ /**
63
+ * Get file url
64
+ */
65
+ getSignedURL(node: Node, options?: GetFileURLSchema): Promise<string>;
66
+ /**
67
+ * Upload file to S3 and add it to the database
68
+ **/
69
+ uploadFile(input: UploadFileSchema & Pick<PutObjectInput, "body">): Promise<{
70
+ isPending: boolean;
71
+ id: string;
72
+ readonly: boolean | null;
73
+ type: "file" | "folder" | null;
74
+ name: string;
75
+ namespace: string;
76
+ mode: "private" | "public" | null;
77
+ subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
78
+ size: number | null;
79
+ contentType: string | null;
80
+ createdAt: Date;
81
+ updatedAt: Date;
82
+ createdBy: string | null;
83
+ isDeleted: boolean;
84
+ parentId: string | null;
85
+ }>;
86
+ /**
87
+ * Presign a new upload
88
+ */
89
+ presignUpload(input: PresignFileSchema): Promise<{
90
+ id: string;
91
+ presignedUrl: string;
92
+ node: {
93
+ isPending: boolean;
94
+ id: string;
95
+ readonly: boolean | null;
96
+ type: "file" | "folder" | null;
97
+ name: string;
98
+ namespace: string;
99
+ mode: "private" | "public" | null;
100
+ subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
101
+ size: number | null;
102
+ contentType: string | null;
103
+ createdAt: Date;
104
+ updatedAt: Date;
105
+ createdBy: string | null;
106
+ isDeleted: boolean;
107
+ parentId: string | null;
108
+ };
109
+ }>;
110
+ /**
111
+ * Confirm a new upload
112
+ */
113
+ confirmUpload(input: {
114
+ id: string;
115
+ }): Promise<{
116
+ name: string;
117
+ namespace: string;
118
+ type: "file" | "folder" | null;
119
+ mode: "private" | "public" | null;
120
+ subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
121
+ size: number | null;
122
+ contentType: string | null;
123
+ readonly: boolean | null;
124
+ createdBy: string | null;
125
+ isPending: boolean;
126
+ isDeleted: boolean;
127
+ parentId: string | null;
128
+ id: string;
129
+ createdAt: Date;
130
+ updatedAt: Date;
131
+ }>;
132
+ /**
133
+ * Generate preview version of the file
134
+ */
135
+ generatePreviews(input: {
136
+ id: string;
137
+ }): Promise<void>;
138
+ /**
139
+ * Create a new folder
140
+ */
141
+ createFolder(input: CreateFolderNodeSchema): Promise<{
142
+ isPending: boolean;
143
+ id: string;
144
+ readonly: boolean | null;
145
+ type: "file" | "folder" | null;
146
+ name: string;
147
+ namespace: string;
148
+ mode: "private" | "public" | null;
149
+ subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
150
+ size: number | null;
151
+ contentType: string | null;
152
+ createdAt: Date;
153
+ updatedAt: Date;
154
+ createdBy: string | null;
155
+ isDeleted: boolean;
156
+ parentId: string | null;
157
+ }>;
158
+ /**
159
+ * Update a node
160
+ */
161
+ updateNode(input: {
162
+ id: string;
163
+ data: UpdateNodeSchema;
164
+ }): Promise<{
165
+ name: string;
166
+ namespace: string;
167
+ type: "file" | "folder" | null;
168
+ mode: "private" | "public" | null;
169
+ subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
170
+ size: number | null;
171
+ contentType: string | null;
172
+ readonly: boolean | null;
173
+ createdBy: string | null;
174
+ isPending: boolean;
175
+ isDeleted: boolean;
176
+ parentId: string | null;
177
+ id: string;
178
+ createdAt: Date;
179
+ updatedAt: Date;
180
+ }>;
181
+ /**
182
+ * Delete nodes
183
+ */
184
+ deleteNodes(input: BulkActionSchema): Promise<void>;
185
+ }
186
+ //#endregion
187
+ export { StorageService, StorageServiceConfig };
188
+ //# sourceMappingURL=service.server.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.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EAvMS,OAuMT,CAAA;IAmBrC,SAAA,EAAA,OAAA;IAAgB,EAAA,EAAA,MAAA;IAAA,QAAA,EAAA,OAAA,GAAA,IAAA;;;;;;;;;;;;;;;;;uBAjLd,oBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;MAqCH;;;;;;;;;;;;;;;;;;;;;;MAuBG;;;;sBAwDlB,yBAAsB;;;;;;;;;;;;;;;;;;;;;;UA0CJ;MAAkB;;;;;;;;;;;;;;;;;;;;qBAmBrC,mBAAgB"}
@@ -0,0 +1,297 @@
1
+ import { generateDefaultUUID } from "../../config/db/helpers.mjs";
2
+ import { BUCKET_NAME } from "../../../lib/config/constants.mjs";
3
+ import { ServerError } from "../../router/lib/error.server.mjs";
4
+ import { convertSearchToQueryParams } from "../../data-tables/lib/converters/search.mjs";
5
+ import { convertOrderByToQueryParams } from "../../data-tables/lib/converters/sorting.mjs";
6
+ import { deviceSizes } from "./constants.mjs";
7
+ import { getDriveBucketKey, inferNodeSubtype, isFile, isFolder } from "./helpers.mjs";
8
+ import { nodePresignedUrls, nodeVariants, nodes } from "./schema.mjs";
9
+ import { getFileURLSchemaDefaults, getObjectSchema, putObjectSchema } from "./validators.mjs";
10
+ import { and, asc, eq, inArray, isNull } from "drizzle-orm";
11
+ import { after } from "next/server";
12
+ import { addSeconds } from "date-fns";
13
+ import { DeleteObjectsCommand, GetObjectCommand, PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
14
+ import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
15
+
16
+ //#region src/modules/storage/lib/service.server.ts
17
+ /**
18
+ * Storage Service
19
+ */
20
+ var StorageService = class {
21
+ /**
22
+ * S3 Client
23
+ */
24
+ #blob;
25
+ #db;
26
+ /**
27
+ * Constructor
28
+ */
29
+ constructor({ db, config }) {
30
+ this.#db = db;
31
+ this.#blob = new S3Client(config);
32
+ }
33
+ /**
34
+ * Get Blob
35
+ */
36
+ blob() {
37
+ return this.#blob;
38
+ }
39
+ /**
40
+ * Create get command
41
+ */
42
+ #createGetCommand(props) {
43
+ const input = getObjectSchema.parse(props);
44
+ return new GetObjectCommand({
45
+ Bucket: BUCKET_NAME,
46
+ Key: getDriveBucketKey(input.id, input.variant),
47
+ ResponseContentDisposition: input.disposition
48
+ });
49
+ }
50
+ /**
51
+ * Get object
52
+ */
53
+ async getObject(id, options = getFileURLSchemaDefaults) {
54
+ const getCommand = this.#createGetCommand({
55
+ ...options,
56
+ id
57
+ });
58
+ return await this.#blob.send(getCommand);
59
+ }
60
+ /**
61
+ * Create put command
62
+ */
63
+ #createPutCommand(props) {
64
+ const input = putObjectSchema.parse(props);
65
+ return new PutObjectCommand({
66
+ Bucket: BUCKET_NAME,
67
+ Key: getDriveBucketKey(input.id, input.variant),
68
+ Body: input.body,
69
+ ContentType: input.contentType,
70
+ ContentLength: input.size,
71
+ Metadata: {
72
+ nodeId: input.id,
73
+ filename: input.name
74
+ }
75
+ });
76
+ }
77
+ /**
78
+ * Put object
79
+ */
80
+ async #putObject(props) {
81
+ const putCommand = this.#createPutCommand(props);
82
+ return await this.#blob.send(putCommand);
83
+ }
84
+ /**
85
+ * Get nodes by parent id
86
+ */
87
+ async getNodesByParentId({ filters, ...query }) {
88
+ const orderBy = convertOrderByToQueryParams(query, nodes, asc(nodes.createdAt));
89
+ const search = convertSearchToQueryParams(query, [nodes.name]);
90
+ return this.#db.select().from(nodes).where(and(filters.nodeIds != null ? inArray(nodes.id, filters.nodeIds) : void 0, filters.types != null ? inArray(nodes.type, filters.types) : void 0, filters.isDeleted != null ? eq(nodes.isDeleted, filters.isDeleted) : void 0, filters.parentId ? eq(nodes.parentId, filters.parentId) : isNull(nodes.parentId), eq(nodes.namespace, filters.namespace), search)).orderBy(orderBy);
91
+ }
92
+ /**
93
+ * Get file url
94
+ */
95
+ async getSignedURL(node, options = getFileURLSchemaDefaults) {
96
+ const [presignedUrl] = await this.#db.select({
97
+ url: nodePresignedUrls.url,
98
+ expiresAt: nodePresignedUrls.expiresAt
99
+ }).from(nodePresignedUrls).where(and(eq(nodePresignedUrls.nodeId, node.id), eq(nodePresignedUrls.variant, options.variant), eq(nodePresignedUrls.disposition, options.disposition)));
100
+ if (presignedUrl && presignedUrl.expiresAt > /* @__PURE__ */ new Date()) return presignedUrl.url;
101
+ const expiresIn = 3600 * 24;
102
+ const variant = (await this.#db.select().from(nodeVariants).where(eq(nodeVariants.nodeId, node.id))).find((v) => v.variant === options.variant) ? options.variant : "main";
103
+ console.info(`Generating new signed url for file: ${node.id} with variant: ${variant} and disposition: ${options.disposition}`);
104
+ const getCommand = this.#createGetCommand({
105
+ id: node.id,
106
+ variant,
107
+ disposition: `${options.disposition}; filename="${node.name}"`
108
+ });
109
+ const url = await getSignedUrl(this.#blob, getCommand, { expiresIn });
110
+ after(async () => {
111
+ await this.#db.insert(nodePresignedUrls).values({
112
+ nodeId: node.id,
113
+ url,
114
+ variant,
115
+ disposition: options.disposition,
116
+ expiresAt: addSeconds(/* @__PURE__ */ new Date(), expiresIn)
117
+ }).onConflictDoUpdate({
118
+ target: [
119
+ nodePresignedUrls.nodeId,
120
+ nodePresignedUrls.variant,
121
+ nodePresignedUrls.disposition
122
+ ],
123
+ set: {
124
+ url,
125
+ expiresAt: addSeconds(/* @__PURE__ */ new Date(), expiresIn)
126
+ }
127
+ });
128
+ });
129
+ return url;
130
+ }
131
+ /**
132
+ * Upload file to S3 and add it to the database
133
+ **/
134
+ async uploadFile(input) {
135
+ const id = generateDefaultUUID();
136
+ return await this.#db.transaction(async (tx) => {
137
+ const [result] = await tx.insert(nodes).values({
138
+ id,
139
+ type: "file",
140
+ name: input.name,
141
+ namespace: input.namespace,
142
+ parentId: input.parentId,
143
+ size: input.size,
144
+ contentType: input.contentType,
145
+ mode: input.mode,
146
+ subtype: inferNodeSubtype(input)
147
+ }).returning();
148
+ if (!result) throw new ServerError("INTERNAL_SERVER_ERROR", { message: "Oep! Er is iets fout gegaan" });
149
+ await this.#putObject({
150
+ id,
151
+ body: input.body,
152
+ variant: "main",
153
+ name: input.name,
154
+ contentType: input.contentType,
155
+ size: input.size
156
+ });
157
+ return result;
158
+ });
159
+ }
160
+ /**
161
+ * Presign a new upload
162
+ */
163
+ async presignUpload(input) {
164
+ const putCommand = this.#createPutCommand({
165
+ id: input.id,
166
+ name: input.name,
167
+ variant: "main",
168
+ contentType: input.contentType,
169
+ size: input.size
170
+ });
171
+ const presignedUrl = await getSignedUrl(this.#blob, putCommand, { expiresIn: 3600 });
172
+ const [node] = await this.#db.insert(nodes).values({
173
+ ...input,
174
+ subtype: inferNodeSubtype(input),
175
+ isPending: true,
176
+ type: "file",
177
+ id: input.id
178
+ }).returning();
179
+ if (!node) throw new ServerError("INTERNAL_SERVER_ERROR", { message: "Oep! Er is iets fout gegaan" });
180
+ return {
181
+ id: input.id,
182
+ presignedUrl,
183
+ node
184
+ };
185
+ }
186
+ /**
187
+ * Confirm a new upload
188
+ */
189
+ async confirmUpload(input) {
190
+ const [result] = await this.#db.update(nodes).set({ isPending: false }).where(eq(nodes.id, input.id)).returning();
191
+ if (!result) throw new ServerError("NOT_FOUND", { message: "File not found" });
192
+ /**
193
+ * Generate the preview version of the file
194
+ */
195
+ await this.generatePreviews(input);
196
+ return result;
197
+ }
198
+ /**
199
+ * Generate preview version of the file
200
+ */
201
+ async generatePreviews(input) {
202
+ /**
203
+ * Get the main version of the file
204
+ */
205
+ const getCommand = this.#createGetCommand({
206
+ id: input.id,
207
+ variant: "main"
208
+ });
209
+ const response = await this.#blob.send(getCommand);
210
+ const contentType = response.ContentType;
211
+ if (!response.Body) throw new ServerError("INTERNAL_SERVER_ERROR", { message: "Oep! Er is iets fout gegaan" });
212
+ /**
213
+ * Transform the main version of the file to a buffer
214
+ */
215
+ const byteArray = await response.Body.transformToByteArray();
216
+ const buffer = Buffer.from(byteArray);
217
+ /**
218
+ * Generate the preview versions for images
219
+ */
220
+ if (contentType?.startsWith("image/")) {
221
+ const sharp = await import("sharp");
222
+ await Promise.allSettled(deviceSizes.flatMap(async (width) => {
223
+ const preview = await sharp.default(buffer).resize({ width }).webp().toBuffer();
224
+ return this.#db.transaction(async (tx) => {
225
+ await this.#putObject({
226
+ id: input.id,
227
+ body: preview,
228
+ variant: `preview-${width}`,
229
+ contentType: "image/webp",
230
+ size: preview.byteLength
231
+ });
232
+ await tx.insert(nodeVariants).values({
233
+ nodeId: input.id,
234
+ variant: `preview-${width}`,
235
+ width
236
+ });
237
+ });
238
+ }));
239
+ }
240
+ }
241
+ /**
242
+ * Create a new folder
243
+ */
244
+ async createFolder(input) {
245
+ const [parent] = input.parentId ? await this.#db.select().from(nodes).where(eq(nodes.id, input.parentId)) : [];
246
+ /**
247
+ * Validate
248
+ */
249
+ if (input.parentId && !parent) throw new ServerError("BAD_REQUEST", { message: "Parent not found" });
250
+ if (parent && !isFolder(parent)) throw new ServerError("BAD_REQUEST", { message: "Parent is not a folder" });
251
+ if (parent && parent.namespace !== input.namespace) throw new ServerError("BAD_REQUEST", { message: "Parent is not in the same namespace" });
252
+ /**
253
+ * Create the folder
254
+ */
255
+ const [result] = await this.#db.insert(nodes).values({
256
+ ...input,
257
+ type: "folder"
258
+ }).returning();
259
+ if (!result) throw new ServerError("INTERNAL_SERVER_ERROR", { message: "Folder kon niet worden aangemaakt" });
260
+ return result;
261
+ }
262
+ /**
263
+ * Update a node
264
+ */
265
+ async updateNode(input) {
266
+ const [result] = await this.#db.update(nodes).set(input.data).where(eq(nodes.id, input.id)).returning();
267
+ if (!result) throw new ServerError("INTERNAL_SERVER_ERROR", { message: "Node kon niet worden gewijzigd" });
268
+ return result;
269
+ }
270
+ /**
271
+ * Delete nodes
272
+ */
273
+ async deleteNodes(input) {
274
+ const items = await this.#db.select({
275
+ id: nodes.id,
276
+ type: nodes.type
277
+ }).from(nodes).where(inArray(nodes.id, input.ids));
278
+ const folders = items.filter(isFolder).map((folder) => folder.id);
279
+ const files = items.filter(isFile).map((file) => file.id);
280
+ const deleteCommand = files.length > 0 ? new DeleteObjectsCommand({
281
+ Bucket: BUCKET_NAME,
282
+ Delete: { Objects: files.map((id) => ({ Key: id })) }
283
+ }) : void 0;
284
+ /**
285
+ * Delete files and folders in a transaction
286
+ */
287
+ await this.#db.transaction(async (tx) => {
288
+ await tx.delete(nodes).where(inArray(nodes.id, folders));
289
+ await tx.delete(nodes).where(inArray(nodes.id, files));
290
+ if (deleteCommand) await this.#blob.send(deleteCommand);
291
+ });
292
+ }
293
+ };
294
+
295
+ //#endregion
296
+ export { StorageService };
297
+ //# sourceMappingURL=service.server.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.server.mjs","names":["#db","#blob","#createGetCommand","#putObject","#createPutCommand"],"sources":["../../../../src/modules/storage/lib/service.server.ts"],"sourcesContent":["import { BUCKET_NAME } from \"@/lib/config/constants\";\nimport { generateDefaultUUID, TDatabaseSchema } from \"@/modules/config/entry\";\nimport { DatabaseClient } from \"@/modules/config/entry.server\";\nimport {\n convertOrderByToQueryParams,\n convertSearchToQueryParams,\n} from \"@/modules/data-tables/entry.server\";\nimport { BulkActionSchema } from \"@/modules/router/entry\";\nimport { ServerError } from \"@/modules/router/lib/error.server\";\nimport {\n DeleteObjectsCommand,\n GetObjectCommand,\n PutObjectCommand,\n S3Client,\n S3ClientConfig,\n} from \"@aws-sdk/client-s3\";\nimport { getSignedUrl } from \"@aws-sdk/s3-request-presigner\";\nimport { addSeconds } from \"date-fns\";\nimport { and, asc, eq, inArray, isNull, SQL } from \"drizzle-orm\";\nimport { after } from \"next/server\";\nimport { deviceSizes } from \"./constants\";\nimport { getDriveBucketKey, inferNodeSubtype, isFile, isFolder } from \"./helpers\";\nimport { nodePresignedUrls, nodes, nodeVariants } from \"./schema\";\nimport {\n CreateFolderNodeSchema,\n GetFileURLSchema,\n getFileURLSchemaDefaults,\n GetNodesByParentIdInput,\n GetObjectInput,\n getObjectSchema,\n Node,\n PresignFileSchema,\n PutObjectInput,\n putObjectSchema,\n UpdateNodeSchema,\n UploadFileSchema,\n} from \"./validators\";\n\n/**\n * Storage Service Config\n */\nexport type StorageServiceConfig<TSchema extends TDatabaseSchema> = {\n db: DatabaseClient<TSchema>;\n config: S3ClientConfig;\n};\n\n/**\n * Storage Service\n */\nexport class StorageService<TSchema extends TDatabaseSchema> {\n /**\n * S3 Client\n */\n #blob: S3Client;\n #db: DatabaseClient<TSchema>;\n\n /**\n * Constructor\n */\n constructor({ db, config }: StorageServiceConfig<TSchema>) {\n this.#db = db;\n this.#blob = new S3Client(config);\n }\n\n /**\n * Get Blob\n */\n blob() {\n return this.#blob;\n }\n\n /**\n * Create get command\n */\n #createGetCommand(props: GetObjectInput) {\n const input = getObjectSchema.parse(props);\n\n return new GetObjectCommand({\n Bucket: BUCKET_NAME,\n Key: getDriveBucketKey(input.id, input.variant),\n ResponseContentDisposition: input.disposition,\n });\n }\n\n /**\n * Get object\n */\n async getObject(id: string, options: GetFileURLSchema = getFileURLSchemaDefaults) {\n const getCommand = this.#createGetCommand({ ...options, id });\n\n return await this.#blob.send(getCommand);\n }\n\n /**\n * Create put command\n */\n #createPutCommand(props: PutObjectInput) {\n const input = putObjectSchema.parse(props);\n\n return new PutObjectCommand({\n Bucket: BUCKET_NAME,\n Key: getDriveBucketKey(input.id, input.variant),\n Body: input.body,\n ContentType: input.contentType,\n ContentLength: input.size,\n Metadata: {\n nodeId: input.id,\n filename: input.name,\n },\n });\n }\n\n /**\n * Put object\n */\n async #putObject(props: PutObjectInput) {\n const putCommand = this.#createPutCommand(props);\n return await this.#blob.send(putCommand);\n }\n\n /**\n * Get nodes by parent id\n */\n async getNodesByParentId({ filters, ...query }: GetNodesByParentIdInput) {\n const orderBy = convertOrderByToQueryParams(query, nodes, asc(nodes.createdAt));\n const search = convertSearchToQueryParams(query, [nodes.name]);\n\n return this.#db\n .select()\n .from(nodes)\n .where(\n and(\n filters.nodeIds != null ? inArray(nodes.id, filters.nodeIds) : undefined,\n filters.types != null ? inArray(nodes.type, filters.types) : undefined,\n filters.isDeleted != null ? eq(nodes.isDeleted, filters.isDeleted) : undefined,\n filters.parentId ? eq(nodes.parentId, filters.parentId) : isNull(nodes.parentId),\n eq(nodes.namespace, filters.namespace),\n search,\n ),\n )\n .orderBy(orderBy as SQL);\n }\n\n /**\n * Get file url\n */\n async getSignedURL(node: Node, options: GetFileURLSchema = getFileURLSchemaDefaults) {\n const [presignedUrl] = await this.#db\n .select({ url: nodePresignedUrls.url, expiresAt: nodePresignedUrls.expiresAt })\n .from(nodePresignedUrls)\n .where(\n and(\n eq(nodePresignedUrls.nodeId, node.id),\n eq(nodePresignedUrls.variant, options.variant),\n eq(nodePresignedUrls.disposition, options.disposition),\n ),\n );\n\n if (presignedUrl && presignedUrl.expiresAt > new Date()) return presignedUrl.url;\n\n const expiresIn = 3600 * 24;\n\n // Get the variants\n const variants = await this.#db\n .select()\n .from(nodeVariants)\n .where(eq(nodeVariants.nodeId, node.id));\n\n // If the requested variant does not exist, fallback to main\n const variantExists = variants.find((v) => v.variant === options.variant);\n const variant = variantExists ? options.variant : \"main\";\n\n console.info(\n `Generating new signed url for file: ${node.id} with variant: ${variant} and disposition: ${options.disposition}`,\n );\n\n // Generate the get command\n const getCommand = this.#createGetCommand({\n id: node.id,\n variant,\n disposition: `${options.disposition}; filename=\"${node.name}\"`,\n });\n\n // Generate the presigned url that expires in 24 hours\n const url = await getSignedUrl(this.#blob, getCommand, { expiresIn });\n\n // Add the presigned url to the database\n after(async () => {\n await this.#db\n .insert(nodePresignedUrls)\n .values({\n nodeId: node.id,\n url,\n variant,\n disposition: options.disposition,\n expiresAt: addSeconds(new Date(), expiresIn),\n })\n .onConflictDoUpdate({\n target: [\n nodePresignedUrls.nodeId,\n nodePresignedUrls.variant,\n nodePresignedUrls.disposition,\n ],\n set: { url, expiresAt: addSeconds(new Date(), expiresIn) },\n });\n });\n\n return url;\n }\n\n /**\n * Upload file to S3 and add it to the database\n **/\n async uploadFile(input: UploadFileSchema & Pick<PutObjectInput, \"body\">) {\n const id = generateDefaultUUID();\n\n return await this.#db.transaction(async (tx) => {\n const [result] = await tx\n .insert(nodes)\n .values({\n id,\n type: \"file\",\n name: input.name,\n namespace: input.namespace,\n parentId: input.parentId,\n size: input.size,\n contentType: input.contentType,\n mode: input.mode,\n subtype: inferNodeSubtype(input),\n })\n .returning();\n\n if (!result) {\n throw new ServerError(\"INTERNAL_SERVER_ERROR\", {\n message: \"Oep! Er is iets fout gegaan\",\n });\n }\n\n await this.#putObject({\n id,\n body: input.body,\n variant: \"main\",\n name: input.name,\n contentType: input.contentType,\n size: input.size,\n });\n\n return result;\n });\n }\n\n /**\n * Presign a new upload\n */\n async presignUpload(input: PresignFileSchema) {\n // Generate the put command\n const putCommand = this.#createPutCommand({\n id: input.id,\n name: input.name,\n variant: \"main\",\n contentType: input.contentType,\n size: input.size,\n });\n\n // Generate the presigned url\n const presignedUrl = await getSignedUrl(this.#blob, putCommand, { expiresIn: 3600 });\n\n const [node] = await this.#db\n .insert(nodes)\n .values({\n ...input,\n subtype: inferNodeSubtype(input),\n isPending: true,\n type: \"file\",\n id: input.id,\n })\n .returning();\n\n if (!node) {\n throw new ServerError(\"INTERNAL_SERVER_ERROR\", {\n message: \"Oep! Er is iets fout gegaan\",\n });\n }\n\n // Return the result\n return { id: input.id, presignedUrl, node };\n }\n\n /**\n * Confirm a new upload\n */\n async confirmUpload(input: { id: string }) {\n const [result] = await this.#db\n .update(nodes)\n .set({ isPending: false })\n .where(eq(nodes.id, input.id))\n .returning();\n\n if (!result) {\n throw new ServerError(\"NOT_FOUND\", { message: \"File not found\" });\n }\n\n /**\n * Generate the preview version of the file\n */\n // after(async () => {});\n await this.generatePreviews(input);\n\n return result;\n }\n\n /**\n * Generate preview version of the file\n */\n async generatePreviews(input: { id: string }) {\n /**\n * Get the main version of the file\n */\n const getCommand = this.#createGetCommand({ id: input.id, variant: \"main\" });\n\n const response = await this.#blob.send(getCommand);\n const contentType = response.ContentType;\n if (!response.Body) {\n throw new ServerError(\"INTERNAL_SERVER_ERROR\", {\n message: \"Oep! Er is iets fout gegaan\",\n });\n }\n\n /**\n * Transform the main version of the file to a buffer\n */\n const byteArray = await response.Body.transformToByteArray();\n const buffer = Buffer.from(byteArray);\n\n /**\n * Generate the preview versions for images\n */\n if (contentType?.startsWith(\"image/\")) {\n const sharp = await import(\"sharp\");\n\n // Generate the preview versions\n await Promise.allSettled(\n deviceSizes.flatMap(async (width) => {\n // Generate the preview\n const preview = await sharp.default(buffer).resize({ width }).webp().toBuffer();\n\n // Upload the preview and add the variant to the database\n return this.#db.transaction(async (tx) => {\n await this.#putObject({\n id: input.id,\n body: preview,\n variant: `preview-${width}`,\n contentType: \"image/webp\",\n size: preview.byteLength,\n });\n\n await tx.insert(nodeVariants).values({\n nodeId: input.id,\n variant: `preview-${width}`,\n width,\n });\n });\n }),\n );\n }\n }\n\n /**\n * Create a new folder\n */\n async createFolder(input: CreateFolderNodeSchema) {\n const [parent] = input.parentId\n ? await this.#db.select().from(nodes).where(eq(nodes.id, input.parentId))\n : [];\n\n /**\n * Validate\n */\n if (input.parentId && !parent) {\n throw new ServerError(\"BAD_REQUEST\", { message: \"Parent not found\" });\n }\n\n if (parent && !isFolder(parent)) {\n throw new ServerError(\"BAD_REQUEST\", { message: \"Parent is not a folder\" });\n }\n\n if (parent && parent.namespace !== input.namespace) {\n throw new ServerError(\"BAD_REQUEST\", {\n message: \"Parent is not in the same namespace\",\n });\n }\n\n /**\n * Create the folder\n */\n const [result] = await this.#db\n .insert(nodes)\n .values({ ...input, type: \"folder\" })\n .returning();\n\n if (!result) {\n throw new ServerError(\"INTERNAL_SERVER_ERROR\", {\n message: \"Folder kon niet worden aangemaakt\",\n });\n }\n\n return result;\n }\n\n /**\n * Update a node\n */\n async updateNode(input: { id: string; data: UpdateNodeSchema }) {\n const [result] = await this.#db\n .update(nodes)\n .set(input.data)\n .where(eq(nodes.id, input.id))\n .returning();\n\n if (!result) {\n throw new ServerError(\"INTERNAL_SERVER_ERROR\", {\n message: \"Node kon niet worden gewijzigd\",\n });\n }\n\n return result;\n }\n\n /**\n * Delete nodes\n */\n async deleteNodes(input: BulkActionSchema) {\n const items = await this.#db\n .select({ id: nodes.id, type: nodes.type })\n .from(nodes)\n .where(inArray(nodes.id, input.ids));\n\n // Split the nodes into folders and files\n const folders = items.filter(isFolder).map((folder) => folder.id);\n const files = items.filter(isFile).map((file) => file.id);\n\n // Delete command for S3\n const deleteCommand =\n files.length > 0\n ? new DeleteObjectsCommand({\n Bucket: BUCKET_NAME,\n Delete: {\n Objects: files.map((id) => ({ Key: id })),\n },\n })\n : undefined;\n\n /**\n * Delete files and folders in a transaction\n */\n await this.#db.transaction(async (tx) => {\n await tx.delete(nodes).where(inArray(nodes.id, folders));\n await tx.delete(nodes).where(inArray(nodes.id, files));\n\n if (deleteCommand) await this.#blob.send(deleteCommand);\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiDA,IAAa,iBAAb,MAA6D;;;;CAI3D;CACA;;;;CAKA,YAAY,EAAE,IAAI,UAAyC;AACzD,QAAKA,KAAM;AACX,QAAKC,OAAQ,IAAI,SAAS,OAAO;;;;;CAMnC,OAAO;AACL,SAAO,MAAKA;;;;;CAMd,kBAAkB,OAAuB;EACvC,MAAM,QAAQ,gBAAgB,MAAM,MAAM;AAE1C,SAAO,IAAI,iBAAiB;GAC1B,QAAQ;GACR,KAAK,kBAAkB,MAAM,IAAI,MAAM,QAAQ;GAC/C,4BAA4B,MAAM;GACnC,CAAC;;;;;CAMJ,MAAM,UAAU,IAAY,UAA4B,0BAA0B;EAChF,MAAM,aAAa,MAAKC,iBAAkB;GAAE,GAAG;GAAS;GAAI,CAAC;AAE7D,SAAO,MAAM,MAAKD,KAAM,KAAK,WAAW;;;;;CAM1C,kBAAkB,OAAuB;EACvC,MAAM,QAAQ,gBAAgB,MAAM,MAAM;AAE1C,SAAO,IAAI,iBAAiB;GAC1B,QAAQ;GACR,KAAK,kBAAkB,MAAM,IAAI,MAAM,QAAQ;GAC/C,MAAM,MAAM;GACZ,aAAa,MAAM;GACnB,eAAe,MAAM;GACrB,UAA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