@tulip-systems/core 0.5.1 → 0.5.3

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 (381) hide show
  1. package/dist/components/common/icons.d.mts +52 -52
  2. package/dist/components/common/icons.d.mts.map +1 -1
  3. package/dist/components/common/status.d.mts +3 -3
  4. package/dist/components/common/status.d.mts.map +1 -1
  5. package/dist/components/editor/components/content.client.d.mts +2 -2
  6. package/dist/components/editor/components/editor.client.d.mts +4 -4
  7. package/dist/components/editor/components/editor.client.mjs +2 -2
  8. package/dist/components/editor/components/editor.client.mjs.map +1 -1
  9. package/dist/components/editor/components/menu.client.d.mts +3 -3
  10. package/dist/components/editor/components/menu.client.mjs +3 -0
  11. package/dist/components/editor/components/menu.client.mjs.map +1 -1
  12. package/dist/components/editor/extensions/file-handler/extension.d.mts +21 -0
  13. package/dist/components/editor/extensions/file-handler/extension.d.mts.map +1 -0
  14. package/dist/components/editor/extensions/file-handler/extension.mjs +40 -0
  15. package/dist/components/editor/extensions/file-handler/extension.mjs.map +1 -0
  16. package/dist/components/editor/extensions/file-handler/strategy.d.mts +29 -0
  17. package/dist/components/editor/extensions/file-handler/strategy.d.mts.map +1 -0
  18. package/dist/components/editor/extensions/file-handler/strategy.mjs +111 -0
  19. package/dist/components/editor/extensions/file-handler/strategy.mjs.map +1 -0
  20. package/dist/components/editor/extensions/file-handler/utils.mjs +50 -0
  21. package/dist/components/editor/extensions/file-handler/utils.mjs.map +1 -0
  22. package/dist/components/editor/extensions/image/extension.d.mts +8 -0
  23. package/dist/components/editor/extensions/image/extension.d.mts.map +1 -0
  24. package/dist/components/editor/extensions/image/extension.mjs +52 -0
  25. package/dist/components/editor/extensions/image/extension.mjs.map +1 -0
  26. package/dist/components/editor/extensions/skeleton/extension.mjs +41 -0
  27. package/dist/components/editor/extensions/skeleton/extension.mjs.map +1 -0
  28. package/dist/components/editor/extensions/skeleton/renderer.mjs +25 -0
  29. package/dist/components/editor/extensions/skeleton/renderer.mjs.map +1 -0
  30. package/dist/components/editor/lib/constants.d.mts +29 -26
  31. package/dist/components/editor/lib/constants.d.mts.map +1 -1
  32. package/dist/components/editor/lib/constants.mjs +14 -2
  33. package/dist/components/editor/lib/constants.mjs.map +1 -1
  34. package/dist/components/editor/lib/extensions.d.mts +5 -1
  35. package/dist/components/editor/lib/extensions.d.mts.map +1 -1
  36. package/dist/components/editor/lib/extensions.mjs.map +1 -1
  37. package/dist/components/editor/lib/variants.mjs +10 -2
  38. package/dist/components/editor/lib/variants.mjs.map +1 -1
  39. package/dist/components/header/back-button.client.d.mts +2 -2
  40. package/dist/components/header/bottom-bar.client.d.mts +3 -3
  41. package/dist/components/header/breadcrumbs.client.d.mts +7 -7
  42. package/dist/components/header/header.client.d.mts +2 -2
  43. package/dist/components/header/mobile-nav-switcher.client.d.mts +2 -2
  44. package/dist/components/header/top-bar.client.d.mts +4 -4
  45. package/dist/components/layouts/admin-content.client.d.mts +2 -2
  46. package/dist/components/layouts/admin-layout.d.mts +2 -2
  47. package/dist/components/layouts/admin-loading.d.mts +2 -2
  48. package/dist/components/layouts/admin-loading.d.mts.map +1 -1
  49. package/dist/components/layouts/empty-page.d.mts +4 -4
  50. package/dist/components/layouts/empty-page.d.mts.map +1 -1
  51. package/dist/components/layouts/list-layout.d.mts +2 -2
  52. package/dist/components/layouts/list-layout.d.mts.map +1 -1
  53. package/dist/components/layouts/not-found-page.d.mts +3 -3
  54. package/dist/components/layouts/not-found-page.d.mts.map +1 -1
  55. package/dist/components/layouts/providers.client.d.mts +2 -2
  56. package/dist/components/layouts/root-layout.server.d.mts +2 -2
  57. package/dist/components/layouts/root-layout.server.d.mts.map +1 -1
  58. package/dist/components/layouts/root-loading.d.mts +2 -2
  59. package/dist/components/layouts/root-loading.d.mts.map +1 -1
  60. package/dist/components/layouts/tab-layout.d.mts +2 -2
  61. package/dist/components/layouts/tab-layout.d.mts.map +1 -1
  62. package/dist/components/lists/data-list.d.mts +5 -5
  63. package/dist/components/lists/data-list.d.mts.map +1 -1
  64. package/dist/components/lists/data-stack.d.mts +8 -8
  65. package/dist/components/navigation/admin-sidebar-paths.client.d.mts +10 -10
  66. package/dist/components/ui/accordion.d.mts +5 -5
  67. package/dist/components/ui/alert-dialog.d.mts +12 -12
  68. package/dist/components/ui/alert.d.mts +6 -6
  69. package/dist/components/ui/aspect-ratio.d.mts +2 -2
  70. package/dist/components/ui/avatar.client.d.mts +4 -4
  71. package/dist/components/ui/badge.d.mts +4 -4
  72. package/dist/components/ui/breadcrumb.d.mts +8 -8
  73. package/dist/components/ui/breadcrumb.d.mts.map +1 -1
  74. package/dist/components/ui/button.d.mts +5 -5
  75. package/dist/components/ui/button.d.mts.map +1 -1
  76. package/dist/components/ui/calendar.d.mts +3 -3
  77. package/dist/components/ui/calendar.d.mts.map +1 -1
  78. package/dist/components/ui/card.d.mts +7 -7
  79. package/dist/components/ui/card.d.mts.map +1 -1
  80. package/dist/components/ui/carousel.d.mts +6 -6
  81. package/dist/components/ui/carousel.d.mts.map +1 -1
  82. package/dist/components/ui/chart.client.d.mts +5 -5
  83. package/dist/components/ui/checkbox.d.mts +2 -2
  84. package/dist/components/ui/checkbox.d.mts.map +1 -1
  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/command.d.mts.map +1 -1
  91. package/dist/components/ui/context-menu.d.mts +16 -16
  92. package/dist/components/ui/date-picker.client.d.mts +2 -2
  93. package/dist/components/ui/dialog.client.d.mts +11 -11
  94. package/dist/components/ui/drawer.client.d.mts +11 -11
  95. package/dist/components/ui/dropdown-menu.d.mts +16 -16
  96. package/dist/components/ui/form.client.d.mts +7 -7
  97. package/dist/components/ui/hover-card.client.d.mts +4 -4
  98. package/dist/components/ui/input-recipient.d.mts +2 -2
  99. package/dist/components/ui/input.d.mts +2 -2
  100. package/dist/components/ui/label.d.mts +2 -2
  101. package/dist/components/ui/navigation-menu.d.mts +11 -11
  102. package/dist/components/ui/pagination.d.mts +8 -8
  103. package/dist/components/ui/popover.d.mts +5 -5
  104. package/dist/components/ui/popover.d.mts.map +1 -1
  105. package/dist/components/ui/progress.client.d.mts +2 -2
  106. package/dist/components/ui/radio-group.d.mts +3 -3
  107. package/dist/components/ui/resizable.client.d.mts +4 -4
  108. package/dist/components/ui/scroll-area.d.mts +3 -3
  109. package/dist/components/ui/select.client.d.mts +11 -11
  110. package/dist/components/ui/separator.d.mts +2 -2
  111. package/dist/components/ui/sheet.client.d.mts +9 -9
  112. package/dist/components/ui/sidebar.client.d.mts +24 -24
  113. package/dist/components/ui/skeleton.d.mts +2 -2
  114. package/dist/components/ui/slider.d.mts +2 -2
  115. package/dist/components/ui/sonner.client.d.mts +2 -2
  116. package/dist/components/ui/switch.d.mts +2 -2
  117. package/dist/components/ui/tabs.d.mts +5 -5
  118. package/dist/components/ui/textarea.d.mts +2 -2
  119. package/dist/components/ui/time-input.client.d.mts +2 -2
  120. package/dist/components/ui/toggle-group.client.d.mts +3 -3
  121. package/dist/components/ui/toggle.d.mts +2 -2
  122. package/dist/components/ui/tooltip.client.d.mts +5 -5
  123. package/dist/components.d.mts +2 -1
  124. package/dist/components.mjs +3 -2
  125. package/dist/data-tables.d.mts +2 -2
  126. package/dist/data-tables.mjs +2 -2
  127. package/dist/inline-edit/client.d.mts +2 -3
  128. package/dist/inline-edit/client.mjs +1 -2
  129. package/dist/lib/client.d.mts +2 -2
  130. package/dist/lib/client.mjs +2 -2
  131. package/dist/lib/hooks/use-action.d.mts +2 -2
  132. package/dist/lib/hooks/use-indicator.d.mts +11 -3
  133. package/dist/lib/hooks/use-indicator.d.mts.map +1 -1
  134. package/dist/lib/hooks/use-indicator.mjs +19 -8
  135. package/dist/lib/hooks/use-indicator.mjs.map +1 -1
  136. package/dist/modules/auth/components/allowed.client.d.mts +2 -2
  137. package/dist/modules/auth/components/allowed.client.d.mts.map +1 -1
  138. package/dist/modules/auth/components/auth-layout.server.d.mts +2 -2
  139. package/dist/modules/auth/components/auth-layout.server.d.mts.map +1 -1
  140. package/dist/modules/auth/components/auth-loading.d.mts +2 -2
  141. package/dist/modules/auth/components/create-first-user-page.client.d.mts +2 -2
  142. package/dist/modules/auth/components/create-first-user-page.client.d.mts.map +1 -1
  143. package/dist/modules/auth/components/forget-password-page.client.d.mts +2 -2
  144. package/dist/modules/auth/components/forget-password-page.client.d.mts.map +1 -1
  145. package/dist/modules/auth/components/guard-first-user.server.d.mts +2 -2
  146. package/dist/modules/auth/components/guard-first-user.server.d.mts.map +1 -1
  147. package/dist/modules/auth/components/guard.server.d.mts +2 -2
  148. package/dist/modules/auth/components/guard.server.d.mts.map +1 -1
  149. package/dist/modules/auth/components/login-page.client.d.mts +2 -2
  150. package/dist/modules/auth/components/login-page.client.d.mts.map +1 -1
  151. package/dist/modules/auth/components/reset-password-page.client.d.mts +2 -2
  152. package/dist/modules/auth/components/reset-password-page.client.d.mts.map +1 -1
  153. package/dist/modules/auth/components/update-password-command.d.mts +2 -2
  154. package/dist/modules/auth/components/update-password-command.d.mts.map +1 -1
  155. package/dist/modules/auth/db/schema.d.mts +73 -73
  156. package/dist/modules/auth/db/schema.d.mts.map +1 -1
  157. package/dist/modules/auth/handler/client.client.d.mts +8 -8
  158. package/dist/modules/auth/hooks/use-permission.d.mts +2 -2
  159. package/dist/modules/auth/hooks/use-session.d.mts +4 -4
  160. package/dist/modules/auth/lib/validators.d.mts +2 -2
  161. package/dist/modules/auth/lib/validators.d.mts.map +1 -1
  162. package/dist/modules/commands/components/alert-dialog-command.client.d.mts +10 -10
  163. package/dist/modules/commands/components/alert-dialog-command.client.d.mts.map +1 -1
  164. package/dist/modules/commands/components/click-command.client.d.mts +2 -2
  165. package/dist/modules/commands/components/click-command.client.d.mts.map +1 -1
  166. package/dist/modules/commands/components/command-trigger.client.d.mts +6 -6
  167. package/dist/modules/commands/components/command-trigger.client.d.mts.map +1 -1
  168. package/dist/modules/commands/components/dialog-command.client.d.mts +8 -8
  169. package/dist/modules/commands/components/dialog-command.client.d.mts.map +1 -1
  170. package/dist/modules/commands/components/dropdown-command.client.d.mts +5 -5
  171. package/dist/modules/commands/components/dropdown-command.client.d.mts.map +1 -1
  172. package/dist/modules/commands/components/empty-command.client.d.mts +2 -2
  173. package/dist/modules/commands/components/empty-command.client.d.mts.map +1 -1
  174. package/dist/modules/commands/components/form-dialog-command.client.d.mts +11 -11
  175. package/dist/modules/commands/components/form-dialog-command.client.d.mts.map +1 -1
  176. package/dist/modules/commands/hooks/use-command-mutation.client.d.mts +2 -2
  177. package/dist/modules/commands/menus/context-menu.client.d.mts +2 -2
  178. package/dist/modules/commands/menus/context-menu.client.d.mts.map +1 -1
  179. package/dist/modules/commands/menus/dropdown-menu.client.d.mts +3 -3
  180. package/dist/modules/commands/menus/dropdown-menu.client.d.mts.map +1 -1
  181. package/dist/modules/commands/menus/inline-menu.client.d.mts +3 -3
  182. package/dist/modules/commands/menus/inline-menu.client.d.mts.map +1 -1
  183. package/dist/modules/commands/menus/responsive-menu.client.d.mts +3 -3
  184. package/dist/modules/commands/menus/responsive-menu.client.d.mts.map +1 -1
  185. package/dist/modules/commands/utils/archive-command.client.d.mts +3 -3
  186. package/dist/modules/commands/utils/archive-command.client.d.mts.map +1 -1
  187. package/dist/modules/commands/utils/delete-command.client.d.mts +3 -3
  188. package/dist/modules/commands/utils/delete-command.client.d.mts.map +1 -1
  189. package/dist/modules/config/db/helpers.d.mts +5 -5
  190. package/dist/modules/config/db/helpers.d.mts.map +1 -1
  191. package/dist/modules/data-tables/components/cell/common.client.d.mts +5 -5
  192. package/dist/modules/data-tables/components/cell/common.client.d.mts.map +1 -1
  193. package/dist/modules/data-tables/components/column-header.d.mts +2 -2
  194. package/dist/modules/data-tables/components/filters/combobox.client.d.mts +2 -2
  195. package/dist/modules/data-tables/components/filters/combobox.client.d.mts.map +1 -1
  196. package/dist/modules/data-tables/components/filters/slider.client.d.mts +2 -2
  197. package/dist/modules/data-tables/components/filters/slider.client.d.mts.map +1 -1
  198. package/dist/modules/data-tables/components/header.d.mts +4 -4
  199. package/dist/modules/data-tables/components/layout.d.mts +2 -2
  200. package/dist/modules/data-tables/components/search-input.client.d.mts +2 -2
  201. package/dist/modules/data-tables/components/search-input.client.d.mts.map +1 -1
  202. package/dist/modules/data-tables/components/skeleton.d.mts +2 -2
  203. package/dist/modules/data-tables/components/table.d.mts +7 -7
  204. package/dist/modules/data-tables/components/toolbar.d.mts +3 -3
  205. package/dist/modules/data-tables/hooks/use-context.client.d.mts +2 -2
  206. package/dist/modules/data-tables/hooks/use-context.client.d.mts.map +1 -1
  207. package/dist/modules/data-tables/lib/filters/parsers.d.mts +6 -1
  208. package/dist/modules/data-tables/lib/filters/parsers.d.mts.map +1 -1
  209. package/dist/modules/data-tables/lib/filters/parsers.mjs +6 -1
  210. package/dist/modules/data-tables/lib/filters/parsers.mjs.map +1 -1
  211. package/dist/modules/data-tables/tables/data-table/components/table.d.mts +2 -2
  212. package/dist/modules/data-tables/tables/data-table/components/table.d.mts.map +1 -1
  213. package/dist/modules/data-tables/tables/inline-table/components/cells/common.d.mts +2 -2
  214. package/dist/modules/data-tables/tables/inline-table/components/cells/common.d.mts.map +1 -1
  215. package/dist/modules/data-tables/tables/inline-table/components/cells/drag-handle.client.d.mts +2 -2
  216. package/dist/modules/data-tables/tables/inline-table/components/cells/drag-handle.client.d.mts.map +1 -1
  217. package/dist/modules/data-tables/tables/inline-table/components/inputs/advanced-select.client.d.mts +2 -2
  218. package/dist/modules/data-tables/tables/inline-table/components/inputs/advanced-select.client.d.mts.map +1 -1
  219. package/dist/modules/data-tables/tables/inline-table/components/inputs/combobox.client.d.mts +2 -2
  220. package/dist/modules/data-tables/tables/inline-table/components/inputs/combobox.client.d.mts.map +1 -1
  221. package/dist/modules/data-tables/tables/inline-table/components/inputs/input.client.d.mts +3 -3
  222. package/dist/modules/data-tables/tables/inline-table/components/inputs/input.client.d.mts.map +1 -1
  223. package/dist/modules/data-tables/tables/inline-table/components/inputs/read-only.d.mts +2 -2
  224. package/dist/modules/data-tables/tables/inline-table/components/inputs/read-only.d.mts.map +1 -1
  225. package/dist/modules/data-tables/tables/inline-table/components/inputs/select.client.d.mts +2 -2
  226. package/dist/modules/data-tables/tables/inline-table/components/inputs/select.client.d.mts.map +1 -1
  227. package/dist/modules/data-tables/tables/inline-table/components/table.d.mts +2 -2
  228. package/dist/modules/data-tables/tables/inline-table/components/table.d.mts.map +1 -1
  229. package/dist/modules/data-tables/tables/inline-table/hooks/context.client.d.mts +2 -2
  230. package/dist/modules/data-tables/tables/inline-table/hooks/context.client.d.mts.map +1 -1
  231. package/dist/modules/inline-edit/components/combobox-dropdown.client.d.mts +6 -4
  232. package/dist/modules/inline-edit/components/combobox-dropdown.client.d.mts.map +1 -1
  233. package/dist/modules/inline-edit/components/combobox-dropdown.client.mjs +11 -6
  234. package/dist/modules/inline-edit/components/combobox-dropdown.client.mjs.map +1 -1
  235. package/dist/modules/inline-edit/components/combobox.client.d.mts +6 -4
  236. package/dist/modules/inline-edit/components/combobox.client.d.mts.map +1 -1
  237. package/dist/modules/inline-edit/components/combobox.client.mjs +7 -5
  238. package/dist/modules/inline-edit/components/combobox.client.mjs.map +1 -1
  239. package/dist/modules/inline-edit/components/date-input.client.d.mts +5 -3
  240. package/dist/modules/inline-edit/components/date-input.client.d.mts.map +1 -1
  241. package/dist/modules/inline-edit/components/date-input.client.mjs +26 -13
  242. package/dist/modules/inline-edit/components/date-input.client.mjs.map +1 -1
  243. package/dist/modules/inline-edit/components/date-picker.client.d.mts +6 -4
  244. package/dist/modules/inline-edit/components/date-picker.client.d.mts.map +1 -1
  245. package/dist/modules/inline-edit/components/date-picker.client.mjs +12 -7
  246. package/dist/modules/inline-edit/components/date-picker.client.mjs.map +1 -1
  247. package/dist/modules/inline-edit/components/editor.client.d.mts +6 -4
  248. package/dist/modules/inline-edit/components/editor.client.d.mts.map +1 -1
  249. package/dist/modules/inline-edit/components/editor.client.mjs +11 -6
  250. package/dist/modules/inline-edit/components/editor.client.mjs.map +1 -1
  251. package/dist/modules/inline-edit/components/input-recipient.client.d.mts +6 -4
  252. package/dist/modules/inline-edit/components/input-recipient.client.d.mts.map +1 -1
  253. package/dist/modules/inline-edit/components/input-recipient.client.mjs +11 -6
  254. package/dist/modules/inline-edit/components/input-recipient.client.mjs.map +1 -1
  255. package/dist/modules/inline-edit/components/input-toggle.client.d.mts +6 -4
  256. package/dist/modules/inline-edit/components/input-toggle.client.d.mts.map +1 -1
  257. package/dist/modules/inline-edit/components/input-toggle.client.mjs +9 -7
  258. package/dist/modules/inline-edit/components/input-toggle.client.mjs.map +1 -1
  259. package/dist/modules/inline-edit/components/input.client.d.mts +13 -10
  260. package/dist/modules/inline-edit/components/input.client.d.mts.map +1 -1
  261. package/dist/modules/inline-edit/components/input.client.mjs +35 -19
  262. package/dist/modules/inline-edit/components/input.client.mjs.map +1 -1
  263. package/dist/modules/inline-edit/components/select.client.d.mts +10 -9
  264. package/dist/modules/inline-edit/components/select.client.d.mts.map +1 -1
  265. package/dist/modules/inline-edit/components/select.client.mjs +14 -7
  266. package/dist/modules/inline-edit/components/select.client.mjs.map +1 -1
  267. package/dist/modules/inline-edit/components/switch.client.d.mts +5 -3
  268. package/dist/modules/inline-edit/components/switch.client.d.mts.map +1 -1
  269. package/dist/modules/inline-edit/components/switch.client.mjs +8 -6
  270. package/dist/modules/inline-edit/components/switch.client.mjs.map +1 -1
  271. package/dist/modules/inline-edit/components/toggle.client.d.mts +6 -4
  272. package/dist/modules/inline-edit/components/toggle.client.d.mts.map +1 -1
  273. package/dist/modules/inline-edit/components/toggle.client.mjs +9 -7
  274. package/dist/modules/inline-edit/components/toggle.client.mjs.map +1 -1
  275. package/dist/modules/inline-edit/hooks/use-inline.client.d.mts +35 -3
  276. package/dist/modules/inline-edit/hooks/use-inline.client.d.mts.map +1 -1
  277. package/dist/modules/inline-edit/hooks/use-inline.client.mjs +71 -9
  278. package/dist/modules/inline-edit/hooks/use-inline.client.mjs.map +1 -1
  279. package/dist/modules/inline-edit/lib/variants.d.mts +1 -0
  280. package/dist/modules/inline-edit/lib/variants.d.mts.map +1 -1
  281. package/dist/modules/inline-edit/lib/variants.mjs +12 -4
  282. package/dist/modules/inline-edit/lib/variants.mjs.map +1 -1
  283. package/dist/modules/router/handler/init.server.d.mts +6 -6
  284. package/dist/modules/router/handler/init.server.d.mts.map +1 -1
  285. package/dist/modules/router/lib/query-client.server.d.mts +2 -2
  286. package/dist/modules/storage/components/dropzone-context.client.d.mts +2 -2
  287. package/dist/modules/storage/components/dropzone-context.client.d.mts.map +1 -1
  288. package/dist/modules/storage/components/dropzone.client.d.mts +5 -5
  289. package/dist/modules/storage/components/dropzone.client.d.mts.map +1 -1
  290. package/dist/modules/storage/components/dropzone.client.mjs +1 -1
  291. package/dist/modules/storage/components/image-grid.client.d.mts +3 -3
  292. package/dist/modules/storage/components/image-grid.client.d.mts.map +1 -1
  293. package/dist/modules/storage/components/image-grid.client.mjs +3 -3
  294. package/dist/modules/storage/components/image-grid.client.mjs.map +1 -1
  295. package/dist/modules/storage/components/upload-zone-context.client.d.mts +3 -11
  296. package/dist/modules/storage/components/upload-zone-context.client.d.mts.map +1 -1
  297. package/dist/modules/storage/components/upload-zone-context.client.mjs.map +1 -1
  298. package/dist/modules/storage/components/upload-zone.client.d.mts +10 -31
  299. package/dist/modules/storage/components/upload-zone.client.d.mts.map +1 -1
  300. package/dist/modules/storage/components/upload-zone.client.mjs +19 -91
  301. package/dist/modules/storage/components/upload-zone.client.mjs.map +1 -1
  302. package/dist/modules/storage/config/filters.d.mts +2 -0
  303. package/dist/modules/storage/config/filters.d.mts.map +1 -1
  304. package/dist/modules/storage/config/filters.mjs +3 -1
  305. package/dist/modules/storage/config/filters.mjs.map +1 -1
  306. package/dist/modules/storage/lib/create-upload.client.d.mts +56 -0
  307. package/dist/modules/storage/lib/create-upload.client.d.mts.map +1 -0
  308. package/dist/modules/storage/lib/create-upload.client.mjs +98 -0
  309. package/dist/modules/storage/lib/create-upload.client.mjs.map +1 -0
  310. package/dist/modules/storage/lib/helpers.d.mts +2 -2
  311. package/dist/modules/storage/lib/helpers.d.mts.map +1 -1
  312. package/dist/modules/storage/lib/helpers.mjs +1 -0
  313. package/dist/modules/storage/lib/helpers.mjs.map +1 -1
  314. package/dist/modules/storage/lib/router.server.d.mts +4181 -2283
  315. package/dist/modules/storage/lib/router.server.d.mts.map +1 -1
  316. package/dist/modules/storage/lib/router.server.mjs +5 -2
  317. package/dist/modules/storage/lib/router.server.mjs.map +1 -1
  318. package/dist/modules/storage/lib/schema.d.mts +156 -88
  319. package/dist/modules/storage/lib/schema.d.mts.map +1 -1
  320. package/dist/modules/storage/lib/schema.mjs +3 -1
  321. package/dist/modules/storage/lib/schema.mjs.map +1 -1
  322. package/dist/modules/storage/lib/service.server.d.mts +54 -38
  323. package/dist/modules/storage/lib/service.server.d.mts.map +1 -1
  324. package/dist/modules/storage/lib/service.server.mjs +11 -5
  325. package/dist/modules/storage/lib/service.server.mjs.map +1 -1
  326. package/dist/modules/storage/lib/validators.d.mts +232 -71
  327. package/dist/modules/storage/lib/validators.d.mts.map +1 -1
  328. package/dist/modules/storage/lib/validators.mjs +16 -25
  329. package/dist/modules/storage/lib/validators.mjs.map +1 -1
  330. package/dist/storage/client.d.mts +2 -1
  331. package/dist/storage/client.mjs +2 -8
  332. package/dist/storage.d.mts +3 -3
  333. package/dist/storage.mjs +3 -3
  334. package/package.json +2 -1
  335. package/src/components/editor/components/editor.client.tsx +7 -2
  336. package/src/components/editor/components/menu.client.tsx +26 -0
  337. package/src/components/editor/extensions/file-handler/extension.ts +69 -0
  338. package/src/components/editor/extensions/file-handler/strategy.ts +167 -0
  339. package/src/components/editor/extensions/file-handler/utils.ts +51 -0
  340. package/src/components/editor/extensions/image/extension.ts +57 -0
  341. package/src/components/editor/extensions/skeleton/extension.ts +35 -0
  342. package/src/components/editor/extensions/skeleton/renderer.tsx +14 -0
  343. package/src/components/editor/lib/constants.ts +16 -2
  344. package/src/components/editor/lib/extensions.ts +4 -1
  345. package/src/components/editor/lib/utils.ts +32 -0
  346. package/src/components/editor/lib/variants.ts +72 -1
  347. package/src/components/entry.ts +2 -1
  348. package/src/lib/hooks/use-indicator.tsx +27 -18
  349. package/src/modules/data-tables/lib/filters/parsers.ts +14 -0
  350. package/src/modules/inline-edit/components/combobox-dropdown.client.tsx +21 -12
  351. package/src/modules/inline-edit/components/combobox.client.tsx +13 -6
  352. package/src/modules/inline-edit/components/date-input.client.tsx +29 -13
  353. package/src/modules/inline-edit/components/date-picker.client.tsx +13 -9
  354. package/src/modules/inline-edit/components/editor.client.tsx +14 -14
  355. package/src/modules/inline-edit/components/input-recipient.client.tsx +15 -8
  356. package/src/modules/inline-edit/components/input-toggle.client.tsx +16 -9
  357. package/src/modules/inline-edit/components/input.client.tsx +38 -24
  358. package/src/modules/inline-edit/components/select.client.tsx +16 -9
  359. package/src/modules/inline-edit/components/switch.client.tsx +10 -6
  360. package/src/modules/inline-edit/components/toggle.client.tsx +13 -9
  361. package/src/modules/inline-edit/entry.client.ts +0 -1
  362. package/src/modules/inline-edit/hooks/use-inline.client copy.tsx +97 -0
  363. package/src/modules/inline-edit/hooks/use-inline.client.tsx +139 -20
  364. package/src/modules/inline-edit/lib/variants.ts +7 -0
  365. package/src/modules/storage/components/image-grid.client.tsx +2 -2
  366. package/src/modules/storage/components/upload-zone-context.client.tsx +3 -4
  367. package/src/modules/storage/components/upload-zone.client.tsx +17 -113
  368. package/src/modules/storage/config/filters.ts +2 -0
  369. package/src/modules/storage/entry.client.ts +2 -1
  370. package/src/modules/storage/lib/create-upload.client.ts +134 -0
  371. package/src/modules/storage/lib/helpers.ts +3 -2
  372. package/src/modules/storage/lib/router.server.ts +1 -0
  373. package/src/modules/storage/lib/schema.ts +2 -0
  374. package/src/modules/storage/lib/service.server.ts +18 -4
  375. package/src/modules/storage/lib/validators.ts +21 -31
  376. package/dist/modules/inline-edit/components/deprecated-editor.client.d.mts +0 -21
  377. package/dist/modules/inline-edit/components/deprecated-editor.client.d.mts.map +0 -1
  378. package/dist/modules/inline-edit/components/deprecated-editor.client.mjs +0 -37
  379. package/dist/modules/inline-edit/components/deprecated-editor.client.mjs.map +0 -1
  380. package/dist/storage/client.mjs.map +0 -1
  381. package/src/modules/inline-edit/components/deprecated-editor.client.tsx +0 -48
@@ -1 +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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.mjs";
2
3
  import { users } from "../../auth/db/schema.mjs";
3
4
  import { imageDispositions, imageVariants } from "./constants.mjs";
4
- import { nodeSubtypes } from "./helpers.mjs";
5
5
  import { boolean, pgEnum, pgTable, unique } from "drizzle-orm/pg-core";
6
6
  import { relations } from "drizzle-orm";
7
7
 
@@ -21,9 +21,11 @@ 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
+ hidden: boolean().default(false),
24
25
  createdBy: t.uuid().references(() => users.id, { onDelete: "set null" }),
25
26
  isPending: t.boolean().default(false).notNull(),
26
27
  isDeleted: t.boolean().default(false).notNull(),
28
+ orphanedAt: t.timestamp(),
27
29
  parentId: t.uuid().references(() => nodes.id, { onDelete: "cascade" })
28
30
  }));
29
31
  const nodesRelations = relations(nodes, ({ one, many }) => ({
@@ -1 +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":";;;;;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KAAK,EAAE,MAAM,eAAe,CAAC,CAAC,SAAS;CAClD,OAAO,EAAE,SAAS,CAAC,SAAS;CAC7B,EAAE;AAEH,MAAa,wBAAwB,UAAU,eAAe,EAAE,WAAW,EACzE,MAAM,IAAI,OAAO;CACf,QAAQ,CAAC,aAAa,OAAO;CAC7B,YAAY,CAAC,MAAM,GAAG;CACtB,cAAc;CACf,CAAC,EACH,EAAE;;;;AAKH,MAAa,oBAAoB,QAC/B,wBACC,OAAO;CACN,GAAG;CACH,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,QAAQ;CAChC,SAAS,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC,CAAC,SAAS;CAClD,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC,CAAC,SAAS;CAC1D,WAAW,EAAE,WAAW,CAAC,SAAS;CAClC,QAAQ,EACL,MAAM,CACN,SAAS,CACT,iBAAiB,MAAM,IAAI,EAAE,UAAU,WAAW,CAAC;CACtD,WAAW,EAAE,MAAM,CAAC,iBAAiB,aAAa,IAAI,EAAE,UAAU,YAAY,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"}
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 hidden: 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 orphanedAt: t.timestamp(),\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,QAAQ,SAAS,CAAC,QAAQ,MAAM;CAChC,WAAW,EAAE,MAAM,CAAC,iBAAiB,MAAM,IAAI,EAAE,UAAU,YAAY,CAAC;CACxE,WAAW,EAAE,SAAS,CAAC,QAAQ,MAAM,CAAC,SAAS;CAC/C,WAAW,EAAE,SAAS,CAAC,QAAQ,MAAM,CAAC,SAAS;CAC/C,YAAY,EAAE,WAAW;CACzB,UAAU,EAAE,MAAM,CAAC,iBAA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AAE,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"}
@@ -1,9 +1,9 @@
1
+ import { CreateFolderNodeSchema, FileNode, GetFileURLSchema, GetNodesByParentIdInput, Node, PresignFileSchema, PutObjectInput, UpdateNodeSchema, UploadFileSchema } from "./validators.mjs";
2
+ import { BulkActionSchema } from "../../router/lib/validators.mjs";
3
+ import "../../../router.mjs";
1
4
  import { TDatabaseSchema } from "../../config/db/types.mjs";
2
5
  import { DatabaseClient } from "../../config/db/init.mjs";
3
6
  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
7
  import "../../../config.mjs";
8
8
  import * as _aws_sdk_client_s30 from "@aws-sdk/client-s3";
9
9
  import { S3Client, S3ClientConfig } from "@aws-sdk/client-s3";
@@ -36,6 +36,28 @@ declare class StorageService<TSchema extends TDatabaseSchema> {
36
36
  * Get object
37
37
  */
38
38
  getObject(id: string, options?: GetFileURLSchema): Promise<_aws_sdk_client_s30.GetObjectCommandOutput>;
39
+ /**
40
+ * Get node by id
41
+ */
42
+ getNodeById(id: string): Promise<{
43
+ name: string;
44
+ namespace: string;
45
+ type: "file" | "folder" | null;
46
+ mode: "private" | "public" | null;
47
+ subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
48
+ size: number | null;
49
+ contentType: string | null;
50
+ readonly: boolean | null;
51
+ hidden: boolean | null;
52
+ createdBy: string | null;
53
+ isPending: boolean;
54
+ isDeleted: boolean;
55
+ orphanedAt: Date | null;
56
+ parentId: string | null;
57
+ id: string;
58
+ createdAt: Date;
59
+ updatedAt: Date;
60
+ }[]>;
39
61
  /**
40
62
  * Get nodes by parent id
41
63
  */
@@ -51,9 +73,11 @@ declare class StorageService<TSchema extends TDatabaseSchema> {
51
73
  size: number | null;
52
74
  contentType: string | null;
53
75
  readonly: boolean | null;
76
+ hidden: boolean | null;
54
77
  createdBy: string | null;
55
78
  isPending: boolean;
56
79
  isDeleted: boolean;
80
+ orphanedAt: Date | null;
57
81
  parentId: string | null;
58
82
  id: string;
59
83
  createdAt: Date;
@@ -67,20 +91,22 @@ declare class StorageService<TSchema extends TDatabaseSchema> {
67
91
  * Upload file to S3 and add it to the database
68
92
  **/
69
93
  uploadFile(input: UploadFileSchema & Pick<PutObjectInput, "body">): Promise<{
70
- id: string;
71
- createdAt: Date;
72
- updatedAt: Date;
73
94
  name: string;
95
+ namespace: string;
74
96
  type: "file" | "folder" | null;
75
- readonly: boolean | null;
76
97
  mode: "private" | "public" | null;
77
- size: number | null;
78
- namespace: string;
79
98
  subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
99
+ size: number | null;
80
100
  contentType: string | null;
101
+ readonly: boolean | null;
102
+ hidden: boolean | null;
103
+ id: string;
104
+ createdAt: Date;
105
+ updatedAt: Date;
81
106
  createdBy: string | null;
82
107
  isPending: boolean;
83
108
  isDeleted: boolean;
109
+ orphanedAt: Date | null;
84
110
  parentId: string | null;
85
111
  }>;
86
112
  /**
@@ -90,20 +116,22 @@ declare class StorageService<TSchema extends TDatabaseSchema> {
90
116
  id: string;
91
117
  presignedUrl: string;
92
118
  node: {
93
- id: string;
94
- createdAt: Date;
95
- updatedAt: Date;
96
119
  name: string;
120
+ namespace: string;
97
121
  type: "file" | "folder" | null;
98
- readonly: boolean | null;
99
122
  mode: "private" | "public" | null;
100
- size: number | null;
101
- namespace: string;
102
123
  subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
124
+ size: number | null;
103
125
  contentType: string | null;
126
+ readonly: boolean | null;
127
+ hidden: boolean | null;
128
+ id: string;
129
+ createdAt: Date;
130
+ updatedAt: Date;
104
131
  createdBy: string | null;
105
132
  isPending: boolean;
106
133
  isDeleted: boolean;
134
+ orphanedAt: Date | null;
107
135
  parentId: string | null;
108
136
  };
109
137
  }>;
@@ -112,23 +140,7 @@ declare class StorageService<TSchema extends TDatabaseSchema> {
112
140
  */
113
141
  confirmUpload(input: {
114
142
  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
- }>;
143
+ }): Promise<FileNode>;
132
144
  /**
133
145
  * Generate preview version of the file
134
146
  */
@@ -139,20 +151,22 @@ declare class StorageService<TSchema extends TDatabaseSchema> {
139
151
  * Create a new folder
140
152
  */
141
153
  createFolder(input: CreateFolderNodeSchema): Promise<{
142
- id: string;
143
- createdAt: Date;
144
- updatedAt: Date;
145
154
  name: string;
155
+ namespace: string;
146
156
  type: "file" | "folder" | null;
147
- readonly: boolean | null;
148
157
  mode: "private" | "public" | null;
149
- size: number | null;
150
- namespace: string;
151
158
  subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
159
+ size: number | null;
152
160
  contentType: string | null;
161
+ readonly: boolean | null;
162
+ hidden: boolean | null;
163
+ id: string;
164
+ createdAt: Date;
165
+ updatedAt: Date;
153
166
  createdBy: string | null;
154
167
  isPending: boolean;
155
168
  isDeleted: boolean;
169
+ orphanedAt: Date | null;
156
170
  parentId: string | null;
157
171
  }>;
158
172
  /**
@@ -170,9 +184,11 @@ declare class StorageService<TSchema extends TDatabaseSchema> {
170
184
  size: number | null;
171
185
  contentType: string | null;
172
186
  readonly: boolean | null;
187
+ hidden: boolean | null;
173
188
  createdBy: string | null;
174
189
  isPending: boolean;
175
190
  isDeleted: boolean;
191
+ orphanedAt: Date | null;
176
192
  parentId: string | null;
177
193
  id: string;
178
194
  createdAt: Date;
@@ -1 +1 @@
1
- {"version":3,"file":"service.server.d.mts","names":[],"sources":["../../../../src/modules/storage/lib/service.server.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;KAyCY,qCAAqC;MAC3C,eAAe;UACX;AAFV,CAAA;;;;AAEU,cAMG,cANH,CAAA,gBAMkC,eANlC,CAAA,CAAA;EAAc,CAAA,OAAA;EAMX;;;EAUO,WAAA,CAAA;IAAA,EAAA;IAAA;EAAA,CAAA,EAAU,oBAAV,CAA+B,OAA/B,CAAA;EAA+B;;;EA4BZ,IAAA,CAAA,CAAA,EApBjC,QAoBiC;EAA2C;;;EAmChC,SAAA,CAAA,EAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAnCX,gBAmCW,CAAA,EAnCgC,OAmChC,CAnCgC,mBAAA,CAAA,sBAAA,CAmChC;;;;EAuBvB,kBAAA,CAAA;IAAA,OAAA;IAAA,GAAA;EAAA,CAAA,EAvBuB,uBAuBvB,CAAA,EAvB8C,OAuB9C,CAAA;IAAe,IAAA,EAAA,MAAA;IAA2C,SAAA,EAAA,MAAA;IAmE3D,IAAA,EAAA,MAAA,GAAA,QAAA,GAAA,IAAA;IAAwB,IAAA,EAAA,SAAA,GAAA,QAAA,GAAA,IAAA;IAAL,OAAA,EAAA,OAAA,GAAA,UAAA,GAAA,aAAA,GAAA,OAAA,GAAA,OAAA,GAAA,SAAA,GAAA,OAAA;;;IAA4B,QAAA,EAAA,OAAA,GAAA,IAAA;IAyC5C,SAAA,EAAA,MAAA,GAAA,IAAA;;;IAAiB,QAAA,EAAA,MAAA,GAAA,IAAA;;;IAqCH,SAAA,MAAA;EAuBG,CAAA,EAAA,CAAA;EAwDlB;;;EAAsB,YAAA,CAAA,IAAA,EAhOvB,IAgOuB,EAAA,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A,EAAA,OAAA,GAAA,IAAA;IAAL,SAAA,EAAA,MAAA,GAAA,IAAA;;;;IAA4B,QAAA,EAAA,MAAA,GAAA,IAAA;IAyC5C,EAAA,EAAA,MAAA;;;;EAAiB;;;EA4DA,kBAAA,CAAA;IAAA,OAAA;IAAA,GAAA;EAAA,CAAA,EArMI,uBAqMJ,CAAA,EArM2B,OAqM3B,CAAA;IAwDlB,IAAA,EAAA,MAAA;;;;IAAsB,OAAA,EAAA,OAAA,GAAA,UAAA,GAAA,aAAA,GAAA,OAAA,GAAA,OAAA,GAAA,SAAA,GAAA,OAAA;IA0CJ,IAAA,EAAA,MAAA,GAAA,IAAA;;;;IAAkB,SAAA,EAAA,MAAA,GAAA,IAAA;IA4BrC,SAAA,EAAA,OAAA;IAAgB,SAAA,EAAA,OAAA;IAAA,UAAA,MAAA,GAAA,IAAA;;;;;;;;;qBAtShB,gBAAe,mBAA2C;;;;oBAmE3D,mBAAmB,KAAK,0BAAuB;;;;;;;;;;;;;;;;;;;;;;uBAyC5C,oBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAqCH,QAAA;;;;;;MAuBG;;;;sBAwDlB,yBAAsB;;;;;;;;;;;;;;;;;;;;;;;;UA0CJ;MAAkB;;;;;;;;;;;;;;;;;;;;;;qBA4BrC,mBAAgB"}
@@ -1,13 +1,13 @@
1
+ import { getDriveBucketKey, inferNodeSubtype, isFile, isFolder } from "./helpers.mjs";
1
2
  import { generateDefaultUUID } from "../../config/db/helpers.mjs";
2
3
  import { BUCKET_NAME } from "../../../lib/config/constants.mjs";
3
4
  import { ServerError } from "../../router/lib/error.server.mjs";
4
5
  import { convertSearchToQueryParams } from "../../data-tables/lib/converters/search.mjs";
5
6
  import { convertOrderByToQueryParams } from "../../data-tables/lib/converters/sorting.mjs";
6
7
  import { deviceSizes } from "./constants.mjs";
7
- import { getDriveBucketKey, inferNodeSubtype, isFile, isFolder } from "./helpers.mjs";
8
8
  import { nodePresignedUrls, nodeVariants, nodes } from "./schema.mjs";
9
9
  import { getFileURLSchemaDefaults, getObjectSchema, putObjectSchema } from "./validators.mjs";
10
- import { and, asc, eq, inArray, isNull } from "drizzle-orm";
10
+ import { and, asc, eq, inArray, isNotNull, isNull } from "drizzle-orm";
11
11
  import { after } from "next/server";
12
12
  import { addSeconds } from "date-fns";
13
13
  import { DeleteObjectsCommand, GetObjectCommand, PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
@@ -66,8 +66,8 @@ var StorageService = class {
66
66
  Bucket: BUCKET_NAME,
67
67
  Key: getDriveBucketKey(input.id, input.variant),
68
68
  Body: input.body,
69
- ContentType: input.contentType,
70
- ContentLength: input.size,
69
+ ContentType: input.contentType ?? void 0,
70
+ ContentLength: input.size ?? void 0,
71
71
  Metadata: { nodeId: input.id }
72
72
  });
73
73
  }
@@ -79,12 +79,18 @@ var StorageService = class {
79
79
  return await this.#blob.send(putCommand);
80
80
  }
81
81
  /**
82
+ * Get node by id
83
+ */
84
+ async getNodeById(id) {
85
+ return this.#db.select().from(nodes).where(eq(nodes.id, id));
86
+ }
87
+ /**
82
88
  * Get nodes by parent id
83
89
  */
84
90
  async getNodesByParentId({ filters, ...query }) {
85
91
  const orderBy = convertOrderByToQueryParams(query, nodes, asc(nodes.createdAt));
86
92
  const search = convertSearchToQueryParams(query, [nodes.name]);
87
- 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);
93
+ 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.isOrphaned === true ? isNotNull(nodes.orphanedAt) : filters.isOrphaned === false ? isNull(nodes.orphanedAt) : void 0, filters.hidden != null ? eq(nodes.hidden, filters.hidden) : void 0, filters.parentId ? eq(nodes.parentId, filters.parentId) : isNull(nodes.parentId), eq(nodes.namespace, filters.namespace), search)).orderBy(orderBy);
88
94
  }
89
95
  /**
90
96
  * Get file url
@@ -1 +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 },\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 [node] = await this.#db\n .select({ readonly: nodes.readonly })\n .from(nodes)\n .where(eq(nodes.id, input.id));\n\n if (node?.readonly) {\n throw new ServerError(\"BAD_REQUEST\", { message: \"Node is readonly\" });\n }\n\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, readonly: nodes.readonly })\n .from(nodes)\n .where(inArray(nodes.id, input.ids));\n\n // Check if the nodes are readonly\n if (items.some((item) => item.readonly)) {\n throw new ServerError(\"BAD_REQUEST\", { message: \"Nodes are readonly\" });\n }\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;G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AAM,IAAI,MAAM,CAAC;AAEtD,OAAI,cAAe,OAAM,MAAKC,KAAM,KAAK,cAAc;IACvD"}
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, isNotNull, 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 FileNode,\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 ?? undefined,\n ContentLength: input.size ?? undefined,\n Metadata: {\n nodeId: input.id,\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 node by id\n */\n async getNodeById(id: string) {\n return this.#db.select().from(nodes).where(eq(nodes.id, id));\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.isOrphaned === true\n ? isNotNull(nodes.orphanedAt)\n : filters.isOrphaned === false\n ? isNull(nodes.orphanedAt)\n : undefined,\n filters.hidden != null ? eq(nodes.hidden, filters.hidden) : 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 as FileNode;\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 [node] = await this.#db\n .select({ readonly: nodes.readonly })\n .from(nodes)\n .where(eq(nodes.id, input.id));\n\n if (node?.readonly) {\n throw new ServerError(\"BAD_REQUEST\", { message: \"Node is readonly\" });\n }\n\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, readonly: nodes.readonly })\n .from(nodes)\n .where(inArray(nodes.id, input.ids));\n\n // Check if the nodes are readonly\n if (items.some((item) => item.readonly)) {\n throw new ServerError(\"BAD_REQUEST\", { message: \"Nodes are readonly\" });\n }\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":";;;;;;;;;;;;;;;;;;;AAkDA,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,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