@tulip-systems/core 0.7.0 → 0.8.1

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 (361) hide show
  1. package/dist/auth/server.d.mts +3 -3
  2. package/dist/auth/server.mjs +3 -3
  3. package/dist/components/editor/components/editor.client.d.mts +4 -3
  4. package/dist/components/editor/components/editor.client.d.mts.map +1 -1
  5. package/dist/components/editor/components/editor.client.mjs +5 -2
  6. package/dist/components/editor/components/editor.client.mjs.map +1 -1
  7. package/dist/components/editor/extensions/file-handler/extension.d.mts +4 -4
  8. package/dist/components/editor/extensions/file-handler/extension.d.mts.map +1 -1
  9. package/dist/components/editor/extensions/file-handler/extension.mjs.map +1 -1
  10. package/dist/components/editor/extensions/file-handler/strategy.d.mts +4 -6
  11. package/dist/components/editor/extensions/file-handler/strategy.d.mts.map +1 -1
  12. package/dist/components/editor/extensions/file-handler/strategy.mjs +11 -11
  13. package/dist/components/editor/extensions/file-handler/strategy.mjs.map +1 -1
  14. package/dist/components/editor/extensions/file-handler/utils.mjs +1 -1
  15. package/dist/components/editor/extensions/file-handler/utils.mjs.map +1 -1
  16. package/dist/components/editor/extensions/image/extension.mjs +9 -9
  17. package/dist/components/editor/extensions/image/extension.mjs.map +1 -1
  18. package/dist/components/editor/lib/constants.d.mts +1 -1
  19. package/dist/components/editor/lib/constants.mjs +1 -1
  20. package/dist/components/editor/lib/extensions.d.mts +1 -1
  21. package/dist/components/editor/lib/helpers.d.mts +11 -3
  22. package/dist/components/editor/lib/helpers.d.mts.map +1 -1
  23. package/dist/components/editor/lib/helpers.mjs +27 -13
  24. package/dist/components/editor/lib/helpers.mjs.map +1 -1
  25. package/dist/components/ui/combobox-dropdown.client.mjs +1 -0
  26. package/dist/components/ui/combobox-dropdown.client.mjs.map +1 -1
  27. package/dist/components/ui/combobox.client.mjs +1 -1
  28. package/dist/components/ui/combobox.client.mjs.map +1 -1
  29. package/dist/components.d.mts +2 -2
  30. package/dist/components.mjs +2 -2
  31. package/dist/config/server.d.mts +1 -3
  32. package/dist/config/server.mjs +1 -4
  33. package/dist/config.d.mts +2 -2
  34. package/dist/config.mjs +1 -1
  35. package/dist/data-tables/client.d.mts +2 -1
  36. package/dist/data-tables/client.mjs +2 -1
  37. package/dist/data-tables.d.mts +1 -1
  38. package/dist/database/client.d.mts +1 -0
  39. package/dist/database/client.mjs +1 -0
  40. package/dist/database/server.d.mts +2 -0
  41. package/dist/database/server.mjs +3 -0
  42. package/dist/database.d.mts +3 -0
  43. package/dist/database.mjs +3 -0
  44. package/dist/emails/client.d.mts +1 -0
  45. package/dist/emails/client.mjs +1 -0
  46. package/dist/emails/server.d.mts +2 -0
  47. package/dist/emails/server.mjs +3 -0
  48. package/dist/emails.d.mts +1 -0
  49. package/dist/emails.mjs +1 -0
  50. package/dist/lib/utils/markdown.d.mts +10 -0
  51. package/dist/lib/utils/markdown.d.mts.map +1 -0
  52. package/dist/lib/utils/markdown.mjs +15 -0
  53. package/dist/lib/utils/markdown.mjs.map +1 -0
  54. package/dist/lib/utils/url.mjs +2 -1
  55. package/dist/lib/utils/url.mjs.map +1 -1
  56. package/dist/lib/utils/user-agent.mjs +15 -0
  57. package/dist/lib/utils/user-agent.mjs.map +1 -1
  58. package/dist/lib.d.mts +2 -2
  59. package/dist/lib.mjs +2 -2
  60. package/dist/modules/auth/components/create-first-user-guard.server.d.mts +16 -0
  61. package/dist/modules/auth/components/create-first-user-guard.server.d.mts.map +1 -0
  62. package/dist/modules/auth/components/create-first-user-guard.server.mjs +16 -0
  63. package/dist/modules/auth/components/create-first-user-guard.server.mjs.map +1 -0
  64. package/dist/modules/auth/components/guard.server.d.mts +2 -2
  65. package/dist/modules/auth/components/guard.server.mjs +1 -1
  66. package/dist/modules/auth/components/guard.server.mjs.map +1 -1
  67. package/dist/modules/auth/db/schema.d.mts +1 -1
  68. package/dist/modules/auth/db/schema.mjs +2 -2
  69. package/dist/modules/auth/handler/create-client.client.d.mts +4838 -229
  70. package/dist/modules/auth/handler/create-client.client.d.mts.map +1 -1
  71. package/dist/modules/auth/handler/create-client.client.mjs.map +1 -1
  72. package/dist/modules/auth/handler/proxy.server.mjs +2 -2
  73. package/dist/modules/auth/handler/proxy.server.mjs.map +1 -1
  74. package/dist/modules/auth/handler/route.server.d.mts +2 -2
  75. package/dist/modules/auth/handler/route.server.d.mts.map +1 -1
  76. package/dist/modules/auth/handler/route.server.mjs.map +1 -1
  77. package/dist/modules/auth/handler/{init.d.mts → service.server.d.mts} +322 -90
  78. package/dist/modules/auth/handler/service.server.d.mts.map +1 -0
  79. package/dist/modules/auth/handler/{init.mjs → service.server.mjs} +19 -8
  80. package/dist/modules/auth/handler/service.server.mjs.map +1 -0
  81. package/dist/modules/auth/hooks/use-session.d.mts +9 -4
  82. package/dist/modules/auth/hooks/use-session.d.mts.map +1 -1
  83. package/dist/modules/auth/lib/helpers.server.d.mts +1 -1
  84. package/dist/modules/auth/lib/permissions.d.mts +1 -1
  85. package/dist/modules/auth/lib/validators.mjs +1 -1
  86. package/dist/modules/config/lib/context.d.mts +9 -10
  87. package/dist/modules/config/lib/context.d.mts.map +1 -1
  88. package/dist/modules/config/lib/context.mjs.map +1 -1
  89. package/dist/modules/data-tables/lib/converters/search.d.mts +1 -1
  90. package/dist/modules/data-tables/lib/converters/sorting.d.mts +1 -1
  91. package/dist/modules/data-tables/server/get-data.server.d.mts +3 -3
  92. package/dist/modules/data-tables/server/get-data.server.mjs +1 -1
  93. package/dist/modules/data-tables/server/get-data.server.mjs.map +1 -1
  94. package/dist/modules/data-tables/strategies/infinite/strategy.d.mts +1 -1
  95. package/dist/modules/data-tables/strategies/infinite/strategy.mjs +3 -0
  96. package/dist/modules/data-tables/strategies/infinite/strategy.mjs.map +1 -1
  97. package/dist/modules/data-tables/tables/data-table/components/row.mjs +5 -15
  98. package/dist/modules/data-tables/tables/data-table/components/row.mjs.map +1 -1
  99. package/dist/modules/data-tables/tables/inline-table/components/body.mjs +1 -1
  100. package/dist/modules/data-tables/tables/inline-table/components/body.mjs.map +1 -1
  101. package/dist/modules/data-tables/tables/inline-table/components/row.client.mjs +13 -23
  102. package/dist/modules/data-tables/tables/inline-table/components/row.client.mjs.map +1 -1
  103. package/dist/modules/data-tables/tables/inline-table/components/table.d.mts +1 -0
  104. package/dist/modules/data-tables/tables/inline-table/components/table.d.mts.map +1 -1
  105. package/dist/modules/data-tables/tables/inline-table/components/table.mjs +2 -1
  106. package/dist/modules/data-tables/tables/inline-table/components/table.mjs.map +1 -1
  107. package/dist/modules/data-tables/tables/inline-table/hooks/context.client.d.mts +5 -1
  108. package/dist/modules/data-tables/tables/inline-table/hooks/context.client.d.mts.map +1 -1
  109. package/dist/modules/data-tables/tables/inline-table/hooks/context.client.mjs +2 -1
  110. package/dist/modules/data-tables/tables/inline-table/hooks/context.client.mjs.map +1 -1
  111. package/dist/modules/data-tables/tables/inline-table/hooks/use-hotkeys.client.d.mts +30 -0
  112. package/dist/modules/data-tables/tables/inline-table/hooks/use-hotkeys.client.d.mts.map +1 -0
  113. package/dist/modules/data-tables/tables/inline-table/hooks/use-hotkeys.client.mjs +77 -9
  114. package/dist/modules/data-tables/tables/inline-table/hooks/use-hotkeys.client.mjs.map +1 -1
  115. package/dist/modules/{config/db → database/lib}/helpers.d.mts +2 -2
  116. package/dist/modules/database/lib/helpers.d.mts.map +1 -0
  117. package/dist/modules/{config/db → database/lib}/helpers.mjs +1 -1
  118. package/dist/modules/database/lib/helpers.mjs.map +1 -0
  119. package/dist/modules/database/lib/service.server.d.mts +34 -0
  120. package/dist/modules/database/lib/service.server.d.mts.map +1 -0
  121. package/dist/modules/database/lib/service.server.mjs +24 -0
  122. package/dist/modules/database/lib/service.server.mjs.map +1 -0
  123. package/dist/modules/{config/db → database/lib}/types.d.mts +1 -1
  124. package/dist/modules/database/lib/types.d.mts.map +1 -0
  125. package/dist/modules/emails/lib/service.server.d.mts +29 -0
  126. package/dist/modules/emails/lib/service.server.d.mts.map +1 -0
  127. package/dist/modules/emails/lib/service.server.mjs +21 -0
  128. package/dist/modules/emails/lib/service.server.mjs.map +1 -0
  129. package/dist/modules/inline-edit/components/date-input.client.mjs +1 -1
  130. package/dist/modules/inline-edit/components/date-input.client.mjs.map +1 -1
  131. package/dist/modules/inline-edit/components/date-picker.client.mjs +1 -0
  132. package/dist/modules/inline-edit/components/date-picker.client.mjs.map +1 -1
  133. package/dist/modules/inline-edit/components/date-time.client.mjs +1 -0
  134. package/dist/modules/inline-edit/components/date-time.client.mjs.map +1 -1
  135. package/dist/modules/inline-edit/components/editor.client.mjs +1 -0
  136. package/dist/modules/inline-edit/components/editor.client.mjs.map +1 -1
  137. package/dist/modules/inline-edit/components/input-recipient.client.mjs +1 -0
  138. package/dist/modules/inline-edit/components/input-recipient.client.mjs.map +1 -1
  139. package/dist/modules/inline-edit/components/input-toggle.client.mjs +1 -0
  140. package/dist/modules/inline-edit/components/input-toggle.client.mjs.map +1 -1
  141. package/dist/modules/inline-edit/components/input.client.d.mts.map +1 -1
  142. package/dist/modules/inline-edit/components/input.client.mjs +3 -0
  143. package/dist/modules/inline-edit/components/input.client.mjs.map +1 -1
  144. package/dist/modules/inline-edit/components/select.client.d.mts.map +1 -1
  145. package/dist/modules/inline-edit/components/select.client.mjs +1 -0
  146. package/dist/modules/inline-edit/components/select.client.mjs.map +1 -1
  147. package/dist/modules/inline-edit/components/switch.client.mjs +1 -0
  148. package/dist/modules/inline-edit/components/switch.client.mjs.map +1 -1
  149. package/dist/modules/inline-edit/components/toggle.client.mjs +1 -0
  150. package/dist/modules/inline-edit/components/toggle.client.mjs.map +1 -1
  151. package/dist/modules/router/handler/context.server.d.mts +12 -10
  152. package/dist/modules/router/handler/context.server.d.mts.map +1 -1
  153. package/dist/modules/router/handler/init.server.d.mts +13 -11
  154. package/dist/modules/router/handler/init.server.d.mts.map +1 -1
  155. package/dist/modules/router/handler/init.server.mjs +2 -2
  156. package/dist/modules/router/handler/init.server.mjs.map +1 -1
  157. package/dist/modules/router/handler/route.server.d.mts +1 -1
  158. package/dist/modules/storage/components/dropzone.client.d.mts +2 -2
  159. package/dist/modules/storage/components/dropzone.client.d.mts.map +1 -1
  160. package/dist/modules/storage/components/dropzone.client.mjs.map +1 -1
  161. package/dist/modules/storage/components/image-grid.client.d.mts +3 -3
  162. package/dist/modules/storage/components/image-grid.client.d.mts.map +1 -1
  163. package/dist/modules/storage/components/image-grid.client.mjs +20 -22
  164. package/dist/modules/storage/components/image-grid.client.mjs.map +1 -1
  165. package/dist/modules/storage/components/image.client.d.mts +8 -0
  166. package/dist/modules/storage/components/image.client.d.mts.map +1 -0
  167. package/dist/modules/storage/components/image.client.mjs +17 -0
  168. package/dist/modules/storage/components/image.client.mjs.map +1 -0
  169. package/dist/modules/storage/components/upload-button.client.d.mts +12 -0
  170. package/dist/modules/storage/components/upload-button.client.d.mts.map +1 -0
  171. package/dist/modules/storage/components/upload-button.client.mjs +34 -0
  172. package/dist/modules/storage/components/upload-button.client.mjs.map +1 -0
  173. package/dist/modules/storage/components/upload-zone-context.client.d.mts +5 -5
  174. package/dist/modules/storage/components/upload-zone-context.client.d.mts.map +1 -1
  175. package/dist/modules/storage/components/upload-zone-context.client.mjs +2 -2
  176. package/dist/modules/storage/components/upload-zone-context.client.mjs.map +1 -1
  177. package/dist/modules/storage/components/upload-zone.client.d.mts +4 -4
  178. package/dist/modules/storage/components/upload-zone.client.d.mts.map +1 -1
  179. package/dist/modules/storage/components/upload-zone.client.mjs +16 -9
  180. package/dist/modules/storage/components/upload-zone.client.mjs.map +1 -1
  181. package/dist/modules/storage/lib/constants.d.mts +1 -5
  182. package/dist/modules/storage/lib/constants.d.mts.map +1 -1
  183. package/dist/modules/storage/lib/constants.mjs +1 -13
  184. package/dist/modules/storage/lib/constants.mjs.map +1 -1
  185. package/dist/modules/storage/lib/helpers.d.mts +14 -28
  186. package/dist/modules/storage/lib/helpers.d.mts.map +1 -1
  187. package/dist/modules/storage/lib/helpers.mjs +17 -75
  188. package/dist/modules/storage/lib/helpers.mjs.map +1 -1
  189. package/dist/modules/storage/lib/procedures.server.d.mts +1991 -0
  190. package/dist/modules/{auth/handler/init.d.mts.map → storage/lib/procedures.server.d.mts.map} +1 -1
  191. package/dist/modules/storage/lib/procedures.server.mjs +22 -0
  192. package/dist/modules/storage/lib/procedures.server.mjs.map +1 -0
  193. package/dist/modules/storage/lib/router-handlers.server.d.mts +41 -0
  194. package/dist/modules/storage/lib/router-handlers.server.d.mts.map +1 -0
  195. package/dist/modules/storage/lib/router-handlers.server.mjs +124 -0
  196. package/dist/modules/storage/lib/router-handlers.server.mjs.map +1 -0
  197. package/dist/modules/storage/lib/schema.d.mts +68 -958
  198. package/dist/modules/storage/lib/schema.d.mts.map +1 -1
  199. package/dist/modules/storage/lib/schema.mjs +28 -65
  200. package/dist/modules/storage/lib/schema.mjs.map +1 -1
  201. package/dist/modules/storage/lib/service.server.d.mts +2155 -141
  202. package/dist/modules/storage/lib/service.server.d.mts.map +1 -1
  203. package/dist/modules/storage/lib/service.server.mjs +453 -242
  204. package/dist/modules/storage/lib/service.server.mjs.map +1 -1
  205. package/dist/modules/storage/lib/upload.client.d.mts +58 -0
  206. package/dist/modules/storage/lib/upload.client.d.mts.map +1 -0
  207. package/dist/modules/storage/lib/upload.client.mjs +87 -0
  208. package/dist/modules/storage/lib/upload.client.mjs.map +1 -0
  209. package/dist/modules/storage/lib/validators.d.mts +297 -835
  210. package/dist/modules/storage/lib/validators.d.mts.map +1 -1
  211. package/dist/modules/storage/lib/validators.mjs +32 -76
  212. package/dist/modules/storage/lib/validators.mjs.map +1 -1
  213. package/dist/modules/storage/providers/adapters/s3.server.d.mts +19 -0
  214. package/dist/modules/storage/providers/adapters/s3.server.d.mts.map +1 -0
  215. package/dist/modules/storage/providers/adapters/s3.server.mjs +173 -0
  216. package/dist/modules/storage/providers/adapters/s3.server.mjs.map +1 -0
  217. package/dist/modules/storage/providers/lib/constants.d.mts +6 -0
  218. package/dist/modules/storage/providers/lib/constants.d.mts.map +1 -0
  219. package/dist/modules/storage/providers/lib/constants.mjs +6 -0
  220. package/dist/modules/storage/providers/lib/constants.mjs.map +1 -0
  221. package/dist/modules/storage/providers/lib/errors.d.mts +12 -0
  222. package/dist/modules/storage/providers/lib/errors.d.mts.map +1 -0
  223. package/dist/modules/storage/providers/lib/errors.mjs +13 -0
  224. package/dist/modules/storage/providers/lib/errors.mjs.map +1 -0
  225. package/dist/modules/storage/providers/lib/types.d.mts +21 -0
  226. package/dist/modules/storage/providers/lib/types.d.mts.map +1 -0
  227. package/dist/modules/storage/providers/lib/validators.d.mts +112 -0
  228. package/dist/modules/storage/providers/lib/validators.d.mts.map +1 -0
  229. package/dist/modules/storage/providers/lib/validators.mjs +75 -0
  230. package/dist/modules/storage/providers/lib/validators.mjs.map +1 -0
  231. package/dist/router/server.d.mts +1 -1
  232. package/dist/storage/client.d.mts +4 -2
  233. package/dist/storage/client.mjs +4 -2
  234. package/dist/storage/server.d.mts +5 -4
  235. package/dist/storage/server.mjs +5 -4
  236. package/dist/storage.d.mts +9 -6
  237. package/dist/storage.mjs +8 -6
  238. package/package.json +18 -5
  239. package/src/components/editor/components/editor.client.tsx +9 -1
  240. package/src/components/editor/extensions/file-handler/extension.ts +4 -4
  241. package/src/components/editor/extensions/file-handler/strategy.ts +15 -40
  242. package/src/components/editor/extensions/file-handler/utils.ts +1 -1
  243. package/src/components/editor/extensions/image/extension.ts +10 -10
  244. package/src/components/editor/lib/helpers.ts +28 -11
  245. package/src/components/ui/combobox-dropdown.client.tsx +1 -0
  246. package/src/components/ui/combobox.client.tsx +1 -1
  247. package/src/entry.ts +12 -51
  248. package/src/lib/entry.ts +1 -5
  249. package/src/lib/utils/markdown.ts +10 -0
  250. package/src/lib/utils/url.ts +2 -1
  251. package/src/lib/utils/user-agent.ts +15 -0
  252. package/src/modules/auth/components/{guard-first-user.server.tsx → create-first-user-guard.server.tsx} +8 -8
  253. package/src/modules/auth/components/guard.server.tsx +1 -1
  254. package/src/modules/auth/entry.server.ts +4 -5
  255. package/src/modules/auth/handler/create-client.client.ts +2 -2
  256. package/src/modules/auth/handler/proxy.server.ts +1 -1
  257. package/src/modules/auth/handler/route.server.ts +2 -2
  258. package/src/modules/auth/handler/{init.ts → service.server.ts} +30 -9
  259. package/src/modules/config/entry.server.ts +0 -9
  260. package/src/modules/config/entry.ts +2 -2
  261. package/src/modules/config/lib/context.ts +9 -9
  262. package/src/modules/data-tables/entry.client.ts +1 -0
  263. package/src/modules/data-tables/server/get-data.server.ts +1 -1
  264. package/src/modules/data-tables/strategies/infinite/strategy.ts +4 -1
  265. package/src/modules/data-tables/tables/data-table/components/row.tsx +12 -21
  266. package/src/modules/data-tables/tables/inline-table/components/body.tsx +1 -1
  267. package/src/modules/data-tables/tables/inline-table/components/row.client.tsx +24 -30
  268. package/src/modules/data-tables/tables/inline-table/components/table.tsx +6 -1
  269. package/src/modules/data-tables/tables/inline-table/hooks/context.client.tsx +5 -0
  270. package/src/modules/data-tables/tables/inline-table/hooks/use-hotkeys.client.ts +119 -91
  271. package/src/modules/database/entry.client.ts +0 -0
  272. package/src/modules/database/entry.server.ts +4 -0
  273. package/src/modules/database/entry.ts +5 -0
  274. package/src/modules/database/lib/service.server.ts +33 -0
  275. package/src/modules/emails/entry.client.ts +0 -0
  276. package/src/modules/emails/entry.server.ts +4 -0
  277. package/src/modules/emails/entry.ts +0 -0
  278. package/src/modules/emails/lib/service.server.ts +29 -0
  279. package/src/modules/inline-edit/components/date-input.client.tsx +1 -1
  280. package/src/modules/inline-edit/components/date-picker.client.tsx +1 -0
  281. package/src/modules/inline-edit/components/date-time.client.tsx +1 -0
  282. package/src/modules/inline-edit/components/editor.client.tsx +3 -0
  283. package/src/modules/inline-edit/components/input-recipient.client.tsx +1 -0
  284. package/src/modules/inline-edit/components/input-toggle.client.tsx +1 -0
  285. package/src/modules/inline-edit/components/input.client.tsx +3 -0
  286. package/src/modules/inline-edit/components/select.client.tsx +5 -1
  287. package/src/modules/inline-edit/components/switch.client.tsx +1 -0
  288. package/src/modules/inline-edit/components/toggle.client.tsx +1 -0
  289. package/src/modules/router/handler/init.server.ts +2 -2
  290. package/src/modules/storage/components/dropzone.client.tsx +1 -1
  291. package/src/modules/storage/components/image-grid.client.tsx +23 -20
  292. package/src/modules/storage/components/image.client.tsx +8 -0
  293. package/src/modules/storage/components/upload-zone-context.client.tsx +11 -8
  294. package/src/modules/storage/components/upload-zone.client.tsx +22 -16
  295. package/src/modules/storage/entry.client.ts +3 -1
  296. package/src/modules/storage/entry.server.ts +9 -3
  297. package/src/modules/storage/entry.ts +13 -1
  298. package/src/modules/storage/lib/constants.ts +0 -11
  299. package/src/modules/storage/lib/helpers.ts +18 -65
  300. package/src/modules/storage/lib/procedures.server.ts +60 -0
  301. package/src/modules/storage/lib/router-handlers.server.ts +178 -0
  302. package/src/modules/storage/lib/schema.ts +26 -97
  303. package/src/modules/storage/lib/service.server.ts +636 -374
  304. package/src/modules/storage/lib/upload.client.ts +156 -0
  305. package/src/modules/storage/lib/validators.ts +50 -111
  306. package/src/modules/storage/providers/adapters/s3.server.ts +281 -0
  307. package/src/modules/storage/providers/lib/constants.ts +3 -0
  308. package/src/modules/storage/providers/lib/errors.ts +21 -0
  309. package/src/modules/storage/providers/lib/types.ts +28 -0
  310. package/src/modules/storage/providers/lib/validators.ts +122 -0
  311. package/dist/lib/config/constants.d.mts +0 -5
  312. package/dist/lib/config/constants.d.mts.map +0 -1
  313. package/dist/lib/config/constants.mjs +0 -6
  314. package/dist/lib/config/constants.mjs.map +0 -1
  315. package/dist/modules/auth/components/guard-first-user.server.d.mts +0 -18
  316. package/dist/modules/auth/components/guard-first-user.server.d.mts.map +0 -1
  317. package/dist/modules/auth/components/guard-first-user.server.mjs +0 -16
  318. package/dist/modules/auth/components/guard-first-user.server.mjs.map +0 -1
  319. package/dist/modules/auth/handler/init.mjs.map +0 -1
  320. package/dist/modules/config/db/helpers.d.mts.map +0 -1
  321. package/dist/modules/config/db/helpers.mjs.map +0 -1
  322. package/dist/modules/config/db/init.d.mts +0 -20
  323. package/dist/modules/config/db/init.d.mts.map +0 -1
  324. package/dist/modules/config/db/init.mjs +0 -15
  325. package/dist/modules/config/db/init.mjs.map +0 -1
  326. package/dist/modules/config/db/types.d.mts.map +0 -1
  327. package/dist/modules/config/providers/email.d.mts +0 -12
  328. package/dist/modules/config/providers/email.d.mts.map +0 -1
  329. package/dist/modules/config/providers/email.mjs +0 -11
  330. package/dist/modules/config/providers/email.mjs.map +0 -1
  331. package/dist/modules/storage/config/filters.d.mts +0 -17
  332. package/dist/modules/storage/config/filters.d.mts.map +0 -1
  333. package/dist/modules/storage/config/filters.mjs +0 -17
  334. package/dist/modules/storage/config/filters.mjs.map +0 -1
  335. package/dist/modules/storage/lib/create-client.server.d.mts +0 -11
  336. package/dist/modules/storage/lib/create-client.server.d.mts.map +0 -1
  337. package/dist/modules/storage/lib/create-client.server.mjs +0 -11
  338. package/dist/modules/storage/lib/create-client.server.mjs.map +0 -1
  339. package/dist/modules/storage/lib/create-upload.client.d.mts +0 -56
  340. package/dist/modules/storage/lib/create-upload.client.d.mts.map +0 -1
  341. package/dist/modules/storage/lib/create-upload.client.mjs +0 -98
  342. package/dist/modules/storage/lib/create-upload.client.mjs.map +0 -1
  343. package/dist/modules/storage/lib/proxy.server.d.mts +0 -21
  344. package/dist/modules/storage/lib/proxy.server.d.mts.map +0 -1
  345. package/dist/modules/storage/lib/proxy.server.mjs +0 -46
  346. package/dist/modules/storage/lib/proxy.server.mjs.map +0 -1
  347. package/dist/modules/storage/lib/router.server.d.mts +0 -31002
  348. package/dist/modules/storage/lib/router.server.d.mts.map +0 -1
  349. package/dist/modules/storage/lib/router.server.mjs +0 -86
  350. package/dist/modules/storage/lib/router.server.mjs.map +0 -1
  351. package/src/lib/config/constants.ts +0 -1
  352. package/src/lib/utils/time-picker.ts +0 -139
  353. package/src/modules/config/db/init.ts +0 -21
  354. package/src/modules/config/providers/email.ts +0 -13
  355. package/src/modules/storage/config/filters.ts +0 -12
  356. package/src/modules/storage/lib/create-client.server.ts +0 -14
  357. package/src/modules/storage/lib/create-upload.client.ts +0 -134
  358. package/src/modules/storage/lib/proxy.server.ts +0 -63
  359. package/src/modules/storage/lib/router.server.ts +0 -182
  360. /package/src/modules/{config/db → database/lib}/helpers.ts +0 -0
  361. /package/src/modules/{config/db → database/lib}/types.ts +0 -0
@@ -5,16 +5,16 @@ import { useDropzone } from "react-dropzone";
5
5
  import { toast } from "@/components/ui/sonner.client";
6
6
  import { useAction } from "@/lib/hooks/use-action";
7
7
  import { cn } from "@/lib/utils/cn";
8
- import type { UploadFileRequest, UploadHooks } from "../lib/create-upload.client";
9
- import type { FileNode, Node, UploadFileSchema } from "../lib/validators";
8
+ import type { UploadFileRequest, UploadHooks } from "../lib/upload.client";
9
+ import type { StorageAsset, UploadInput } from "../lib/validators";
10
10
  import { UploadZoneContext, type UploadZoneContextValue } from "./upload-zone-context.client";
11
11
 
12
12
  export type UploadZoneProps = ComponentProps<"div"> &
13
13
  Pick<UploadZoneContextValue, "optimistic" | "uploadClient" | "disabled"> & {
14
- variables: Pick<UploadFileSchema, "namespace" | "parentId" | "mode" | "hidden" | "readonly">;
14
+ variables: Pick<UploadInput, "visibility">;
15
15
  uploadHooks?: UploadHooks;
16
16
 
17
- onUploadCompleted?: (node: Node) => Promise<void> | void;
17
+ onUploadCompleted?: (asset: StorageAsset) => Promise<void> | void;
18
18
  onUploadFailed?: (error: unknown) => Promise<void> | void;
19
19
  };
20
20
 
@@ -34,7 +34,9 @@ export function UploadZone({
34
34
  * Delete mutation
35
35
  */
36
36
  const deleteMutation = useAction({
37
- mutationFn: async (ids: string[]) => uploadClient.deleteFiles(ids),
37
+ mutationFn: async (ids: string[]) => {
38
+ await uploadClient.deleteAssets(ids);
39
+ },
38
40
  onMutate: async (ids) => {
39
41
  await optimistic?.cancel?.();
40
42
  await optimistic?.remove?.(ids);
@@ -54,30 +56,34 @@ export function UploadZone({
54
56
  const uploadMutation = useAction({
55
57
  mutationFn: async (params: UploadFileRequest) => uploadClient.upload(params, uploadHooks),
56
58
  onMutate: async (variables) => {
57
- // Generate a new node
58
- const newNode = {
59
+ await optimistic?.cancel?.();
60
+
61
+ const newAsset = {
59
62
  ...variables,
60
- type: "file",
61
- isPending: true,
62
- } as FileNode;
63
+ visibility: variables.visibility ?? "private",
64
+ status: "pending",
65
+ name: variables.file.name,
66
+ size: variables.file.size,
67
+ contentType: variables.file.type || "application/octet-stream",
68
+ etag: null,
69
+ metadata: null,
70
+ uploadedAt: new Date(),
71
+ deletedAt: null,
72
+ } as Omit<StorageAsset, "id" | "key" | "bucket" | "provider" | "createdAt" | "updatedAt">;
63
73
 
64
- await optimistic?.cancel?.();
65
- await optimistic?.add?.(newNode);
74
+ await optimistic?.add?.(newAsset);
66
75
  },
67
76
  onSuccess: async (data) => {
68
77
  await onUploadCompleted?.(data);
69
78
  toast.success(`Succesvol geupload: ${data.name}`);
70
79
  },
71
- onError: async (error, variables) => {
80
+ onError: async (error) => {
72
81
  await onUploadFailed?.(error);
73
82
 
74
83
  console.error("Upload error: ", error);
75
84
  toast.error("Bestand uploaden mislukt", {
76
85
  description: error instanceof Error ? error.message : undefined,
77
86
  });
78
-
79
- console.info("Deleting failed upload");
80
- await deleteMutation.mutateAsync([variables.id]);
81
87
  },
82
88
  onSettled: () => {
83
89
  optimistic?.invalidate?.();
@@ -4,11 +4,13 @@
4
4
 
5
5
  export * from "./components/dropzone.client";
6
6
  export * from "./components/dropzone-context.client";
7
+ export * from "./components/image.client";
7
8
  export * from "./components/image-grid.client";
9
+ export * from "./components/upload-button.client";
8
10
  export * from "./components/upload-zone.client";
9
11
  export * from "./components/upload-zone-context.client";
10
12
 
11
13
  /**
12
14
  * Lib
13
15
  */
14
- export * from "./lib/create-upload.client";
16
+ export * from "./lib/upload.client";
@@ -1,6 +1,12 @@
1
1
  /**
2
2
  * Lib
3
3
  */
4
- export * from "./lib/create-client.server";
5
- export * from "./lib/proxy.server";
6
- export * from "./lib/router.server";
4
+
5
+ export * from "./lib/procedures.server";
6
+ export * from "./lib/router-handlers.server";
7
+ export * from "./lib/service.server";
8
+
9
+ /**
10
+ * Providers
11
+ */
12
+ export * from "./providers/adapters/s3.server";
@@ -1,5 +1,17 @@
1
- export * from "./config/filters";
1
+ /**
2
+ * Lib
3
+ */
4
+
2
5
  export * from "./lib/constants";
3
6
  export * from "./lib/helpers";
4
7
  export * from "./lib/schema";
5
8
  export * from "./lib/validators";
9
+ export * from "./lib/validators";
10
+
11
+ /**
12
+ * Providers
13
+ */
14
+ export * from "./providers/lib/constants";
15
+ export * from "./providers/lib/errors";
16
+ export * from "./providers/lib/types";
17
+ export * from "./providers/lib/validators";
@@ -1,14 +1,3 @@
1
- // Device sizes
2
- export const deviceSizes = [640, 750, 828, 1080, 1200, 1920, 2048, 3840];
3
- export const imageSizes = deviceSizes;
4
-
5
- // Image variants
6
- export const imageVariants = [
7
- "main",
8
- ...deviceSizes.map((size) => `preview-${size}` as const),
9
- ] as const;
10
- export type ImageVariant = (typeof imageVariants)[number];
11
-
12
1
  // Image dispositions
13
2
  export const imageDispositions = ["inline", "attachment"] as const;
14
3
  export type ImageDisposition = (typeof imageDispositions)[number];
@@ -1,85 +1,38 @@
1
1
  import type { ImageLoaderProps } from "next/image";
2
- import type { ImageVariant } from "./constants";
3
- import type { CreateNodeSchema, GetFileURLSchema, Node } from "./validators";
2
+ import type { GetAssetURLInput } from "../lib/validators";
4
3
 
5
4
  /**
6
- * Check if the node is a file
5
+ * Builds the public API route URL for a storage file proxy request.
6
+ *
7
+ * Use this helper when you need a stable file URL in the client/UI
8
+ * without manually composing the route path.
9
+ *
10
+ * @param id - Storage asset id
11
+ * @returns File proxy URL for the storage route handler
12
+ * @example
13
+ * const url = getAssetURL("019d0051-2c0d-741e-9e3c-e5a5bc4d16a2", { disposition: "attachment" });
14
+ * // /api/storage/files/019d0051-2c0d-741e-9e3c-e5a5bc4d16a2?disposition=attachment
7
15
  */
8
- export function isFile(node: Pick<Node, "type">): node is Node {
9
- return node.type === "file";
10
- }
11
-
12
- /**
13
- * Check if the node is a folder
14
- */
15
- export function isFolder(node: Pick<Node, "type">): node is Node {
16
- return node.type === "folder";
17
- }
18
16
 
19
- /**
20
- * Get file url
21
- */
22
- export function getFileUrl(id: string, options: Partial<GetFileURLSchema> = {}) {
17
+ export function getAssetURL(id: string, options: Partial<GetAssetURLInput> = {}) {
23
18
  const searchParams = new URLSearchParams();
24
- searchParams.set("id", id);
25
- if (options?.variant) searchParams.set("variant", options.variant);
26
19
  if (options?.disposition) searchParams.set("disposition", options.disposition);
27
20
 
28
- return `/api/storage/files?${searchParams.toString()}`;
21
+ const queryString = searchParams.toString();
22
+
23
+ return `/api/storage/files/${id}${queryString ? `?${queryString}` : ""}`;
29
24
  }
30
25
 
31
26
  /**
32
27
  * Image loader
33
28
  */
34
- export function imageLoader({ src, width }: ImageLoaderProps) {
29
+ export function imageLoader({ src }: ImageLoaderProps) {
30
+ if (typeof window === "undefined") return src;
31
+
35
32
  const url = new URL(src, window.location.origin);
36
- url.searchParams.set("variant", `preview-${width}`);
37
33
  return url.toString();
38
34
  }
39
35
 
40
- /**
41
- * Generate object key
42
- */
43
- export function getDriveBucketKey(id: string, variant: ImageVariant) {
44
- return `storage/${id}/${variant}`;
45
- }
46
-
47
- /**
48
- * Node subtype
49
- */
50
- export const nodeSubtypes = [
51
- "image",
52
- "document",
53
- "spreadsheet",
54
- "video",
55
- "audio",
56
- "archive",
57
- "other",
58
- ] as const;
59
-
60
- export type NodeSubtype = (typeof nodeSubtypes)[number];
61
-
62
- export function inferNodeSubtype({
63
- name,
64
- contentType,
65
- }: Pick<CreateNodeSchema, "name" | "contentType">): NodeSubtype {
66
- if (!contentType) return "other";
67
- if (contentType?.startsWith("image/")) return "image";
68
- if (contentType === "application/pdf") return "document";
69
- if (contentType?.includes("spreadsheet")) return "spreadsheet";
70
- if (contentType?.startsWith("video/")) return "video";
71
- if (contentType?.startsWith("audio/")) return "audio";
72
- if (contentType?.includes("zip") || contentType?.includes("archive")) return "archive";
73
-
74
- const ext = name.split(".").pop()?.toLowerCase();
75
- if (["jpg", "jpeg", "png", "gif", "bmp", "webp"].includes(ext ?? "")) return "image";
76
- if (["pdf", "doc", "docx", "txt"].includes(ext ?? "")) return "document";
77
- if (["xls", "xlsx", "ods"].includes(ext ?? "")) return "spreadsheet";
78
- if (["zip", "rar", "7z"].includes(ext ?? "")) return "archive";
79
-
80
- return "other";
81
- }
82
-
83
36
  /**
84
37
  * Render bytes
85
38
  */
@@ -0,0 +1,60 @@
1
+ import type { InferRouterInputs, InferRouterOutputs } from "@orpc/server";
2
+ import { z } from "zod";
3
+ import type { TDatabaseSchema } from "@/modules/config/db/types";
4
+ import { initRPC } from "@/modules/router/handler/init.server";
5
+ import {
6
+ confirmUploadInputSchema,
7
+ presignUploadInputSchema,
8
+ presignUploadOutputSchema,
9
+ selectStorageAssetSchema,
10
+ } from "./validators";
11
+
12
+ export function createStorageProcedures<TSchema extends TDatabaseSchema>() {
13
+ const { protectedProcedure } = initRPC<TSchema>();
14
+
15
+ return {
16
+ presign: protectedProcedure
17
+ .input(presignUploadInputSchema)
18
+ .output(presignUploadOutputSchema)
19
+ .handler(async ({ context, input }) => context.storage.presignUpload(input)),
20
+
21
+ confirm: protectedProcedure
22
+ .input(confirmUploadInputSchema)
23
+ .output(selectStorageAssetSchema)
24
+ .handler(async ({ context, input }) => context.storage.confirmUpload(input)),
25
+
26
+ deleteAsset: protectedProcedure
27
+ .input(z.uuid())
28
+ .output(selectStorageAssetSchema.nullable())
29
+ .handler(async ({ context, input }) => context.storage.deleteAsset(input)),
30
+
31
+ deleteAssets: protectedProcedure
32
+ .input(z.string().array())
33
+ .output(z.array(selectStorageAssetSchema))
34
+ .handler(async ({ context, input }) => context.storage.deleteAssets(input)),
35
+
36
+ restoreAsset: protectedProcedure
37
+ .input(z.uuid())
38
+ .output(selectStorageAssetSchema.nullable())
39
+ .handler(async ({ context, input }) => context.storage.restoreAsset(input)),
40
+
41
+ restoreAssets: protectedProcedure
42
+ .input(z.string().array())
43
+ .output(z.array(selectStorageAssetSchema))
44
+ .handler(async ({ context, input }) => context.storage.restoreAssets(input)),
45
+
46
+ purgeAsset: protectedProcedure
47
+ .input(z.uuid())
48
+ .output(selectStorageAssetSchema.nullable())
49
+ .handler(async ({ context, input }) => context.storage.purgeAsset(input)),
50
+
51
+ purgeAssets: protectedProcedure
52
+ .input(z.string().array())
53
+ .output(z.array(selectStorageAssetSchema))
54
+ .handler(async ({ context, input }) => context.storage.purgeAssets(input)),
55
+ };
56
+ }
57
+
58
+ export type StorageRouter = ReturnType<typeof createStorageProcedures>;
59
+ export type StorageRouterOutputs = InferRouterOutputs<StorageRouter>;
60
+ export type StorageRouterInputs = InferRouterInputs<StorageRouter>;
@@ -0,0 +1,178 @@
1
+ import { connection, type NextRequest } from "next/server";
2
+ import z from "zod";
3
+ import { getSession } from "@/modules/auth/lib/helpers.server";
4
+ import type { TDatabaseSchema } from "@/modules/config/db/types";
5
+ import type { TulipContext } from "@/modules/config/lib/context";
6
+ import { ServerError } from "@/modules/router/lib/error.server";
7
+ import { getAssetURLSchema } from "../entry";
8
+
9
+ type RouteCtx = {
10
+ params: Promise<{ rest?: string[] }>;
11
+ };
12
+
13
+ type CreateStorageRouteHandlerProps<TSchema extends TDatabaseSchema> = {
14
+ context: Pick<TulipContext<TSchema>, "auth" | "storage">;
15
+ };
16
+
17
+ /**
18
+ * Creates a catch-all storage route handler for `/api/storage/[[...rest]]`.
19
+ *
20
+ * Current support:
21
+ * - `GET /api/storage/files/:id`:
22
+ * resolves a storage asset, enforces visibility checks, and redirects
23
+ * to a short-lived signed read URL.
24
+ *
25
+ * Reserved for future extension:
26
+ * - `POST /api/storage/assets/presign`
27
+ * - `POST /api/storage/assets/confirm`
28
+ * - additional storage endpoints under the same catch-all route.
29
+ *
30
+ * @param props - Route handler dependencies (application context)
31
+ * @returns Next.js route handlers for GET, POST, PUT, PATCH, and DELETE
32
+ */
33
+
34
+ export function createStorageRouteHandler<TSchema extends TDatabaseSchema>({
35
+ context,
36
+ }: CreateStorageRouteHandlerProps<TSchema>) {
37
+ /**
38
+ * GET /api/storage/[[...rest]]
39
+ *
40
+ * Current route support:
41
+ * - /api/storage/files/:id
42
+ *
43
+ * The file route resolves an asset by id, enforces visibility rules,
44
+ * and redirects to a short-lived signed object URL.
45
+ */
46
+ async function GET(request: NextRequest, ctx: RouteCtx) {
47
+ // Get the params
48
+ const { rest = [] } = await ctx.params;
49
+ const resource = rest[0];
50
+
51
+ /**
52
+ * Proxy file request
53
+ * GET /api/storage/files/:id
54
+ */
55
+ if (resource === "files") {
56
+ const id = rest[1];
57
+
58
+ // Guard required path segment: /api/storage/files/:id
59
+ if (!id) {
60
+ return Response.json(
61
+ { error: { code: "BAD_REQUEST", message: "Missing id" } },
62
+ { status: 400 },
63
+ );
64
+ }
65
+
66
+ console.info("Proxying file: ", id);
67
+
68
+ try {
69
+ // Resolve storage asset record by id
70
+ const asset = await context.storage.getAssetById(id);
71
+
72
+ if (!asset) {
73
+ return Response.json(
74
+ { error: { code: "NOT_FOUND", message: "Asset not found" } },
75
+ { status: 404 },
76
+ );
77
+ }
78
+
79
+ // Enforce private visibility with session auth
80
+ if (asset.visibility === "private") {
81
+ const session = await getSession(context);
82
+ if (!session) {
83
+ return Response.json(
84
+ { error: { code: "UNAUTHORIZED", message: "Unauthorized" } },
85
+ { status: 401 },
86
+ );
87
+ }
88
+ }
89
+
90
+ // Handle searchParams for disposition
91
+ const searchParams = request.nextUrl.searchParams;
92
+ const disposition = searchParams.get("disposition") ?? undefined;
93
+
94
+ // Parse the options
95
+ const options = getAssetURLSchema.parse({ disposition });
96
+
97
+ // Resolve signed read URL and redirect to object storage
98
+ const url = await context.storage.getObjectURL(asset.id, options);
99
+
100
+ // Return the file
101
+ return Response.redirect(url, 307);
102
+ } catch (error) {
103
+ if (error instanceof z.ZodError) {
104
+ return Response.json(
105
+ { error: { code: "BAD_REQUEST", message: "Invalid request input" } },
106
+ { status: 400 },
107
+ );
108
+ }
109
+
110
+ if (error instanceof ServerError) {
111
+ const code = error.code;
112
+
113
+ if (code === "BAD_REQUEST") {
114
+ return Response.json(
115
+ { error: { code: "BAD_REQUEST", message: error.message } },
116
+ { status: 400 },
117
+ );
118
+ }
119
+
120
+ if (code === "NOT_FOUND") {
121
+ return Response.json(
122
+ { error: { code: "NOT_FOUND", message: error.message } },
123
+ { status: 404 },
124
+ );
125
+ }
126
+
127
+ if (code === "UNAUTHORIZED") {
128
+ return Response.json(
129
+ { error: { code: "UNAUTHORIZED", message: error.message } },
130
+ { status: 401 },
131
+ );
132
+ }
133
+ }
134
+
135
+ if (error instanceof Error && error.message === "Storage asset not found") {
136
+ return Response.json(
137
+ { error: { code: "NOT_FOUND", message: "Asset not found" } },
138
+ { status: 404 },
139
+ );
140
+ }
141
+
142
+ console.error("Storage route error", error);
143
+
144
+ return Response.json(
145
+ { error: { code: "INTERNAL_SERVER_ERROR", message: "Something went wrong" } },
146
+ { status: 500 },
147
+ );
148
+ }
149
+ }
150
+
151
+ return Response.json(
152
+ { error: { code: "NOT_FOUND", message: "Route not found" } },
153
+ { status: 404 },
154
+ );
155
+ }
156
+
157
+ /**
158
+ * POST, PUT, PATCH, DELETE /api/storage/[[...rest]]
159
+ *
160
+ * Reserved for future extension, for example:
161
+ * - POST /api/storage/assets/presign
162
+ * - POST /api/storage/assets/confirm
163
+ */
164
+ async function POST() {
165
+ // Make endpoint dynamic
166
+ await connection();
167
+
168
+ // future:
169
+ // POST /api/storage/assets/presign
170
+ // POST /api/storage/assets/confirm
171
+ return Response.json(
172
+ { error: { code: "NOT_FOUND", message: "Route not found" } },
173
+ { status: 404 },
174
+ );
175
+ }
176
+
177
+ return { GET, POST, PUT: POST, PATCH: POST, DELETE: POST };
178
+ }
@@ -1,105 +1,34 @@
1
- import { relations } from "drizzle-orm";
2
- import { type AnyPgColumn, boolean, pgEnum, pgTable, unique } from "drizzle-orm/pg-core";
3
- import { users } from "@/modules/auth/db/schema";
4
- import { baseColumns } from "@/modules/config/db/helpers";
5
- import { imageDispositions, imageVariants } from "./constants";
6
- import { nodeSubtypes } from "./helpers";
1
+ import { index, pgEnum, pgTable, unique } from "drizzle-orm/pg-core";
2
+ import { baseColumns } from "@/modules/database/lib/helpers";
3
+ import { storageProviders } from "../providers/lib/constants";
7
4
 
8
- export const nodeTypeEnum = pgEnum("node_types", ["file", "folder"]);
9
- export const nodeModeEnum = pgEnum("node_mode", ["private", "public"]);
5
+ export const storageAssetStatusEnum = pgEnum("storage_asset_status", ["pending", "ready", "error"]);
6
+ export const storageAssetVisibilityEnum = pgEnum("storage_asset_visibility", ["private", "public"]);
10
7
 
11
8
  /**
12
- * Node table
9
+ * Storage objects table
13
10
  */
14
- export const nodes = pgTable("nodes", (t) => ({
15
- ...baseColumns,
16
- name: t.text().notNull(),
17
- namespace: t.text().notNull().default("global"),
18
- type: nodeTypeEnum(),
19
- mode: nodeModeEnum().default("private"),
20
- subtype: t.text({ enum: nodeSubtypes }).notNull().default("other"),
21
- size: t.integer().default(0),
22
- contentType: t.varchar({ length: 255 }),
23
- readonly: boolean().default(false),
24
- hidden: boolean().default(false),
25
- createdBy: t.uuid().references(() => users.id, { onDelete: "set null" }),
26
- isPending: t.boolean().default(false).notNull(),
27
- isDeleted: t.boolean().default(false).notNull(),
28
- orphanedAt: t.timestamp(),
29
- parentId: t.uuid().references((): AnyPgColumn => nodes.id, { onDelete: "cascade" }),
30
- }));
31
-
32
- export const nodesRelations = relations(nodes, ({ one, many }) => ({
33
- parent: one(nodes, {
34
- fields: [nodes.parentId],
35
- references: [nodes.id],
36
- relationName: "parent",
37
- }),
38
- children: many(nodes, {
39
- relationName: "parent",
40
- }),
41
- urls: many(nodePresignedUrls),
42
- variants: many(nodeVariants),
43
- }));
44
-
45
- /**
46
- * Node variants table
47
- */
48
- export const nodeVariants = pgTable("node_variants", (t) => ({
49
- ...baseColumns,
50
- nodeId: t
51
- .uuid()
52
- .notNull()
53
- .references(() => nodes.id, { onDelete: "cascade" }),
54
- variant: t.text({ enum: imageVariants }).notNull(),
55
- width: t.integer().notNull(),
56
- }));
57
-
58
- export const nodeVariantsRelations = relations(nodeVariants, ({ one }) => ({
59
- node: one(nodes, {
60
- fields: [nodeVariants.nodeId],
61
- references: [nodes.id],
62
- relationName: "node",
63
- }),
64
- }));
65
-
66
- /**
67
- * Node presigned urls table
68
- */
69
- export const nodePresignedUrls = pgTable(
70
- "node_presigned_urls",
11
+ export const storageAssets = pgTable(
12
+ "storage_assets",
71
13
  (t) => ({
72
14
  ...baseColumns,
73
- url: t.text().notNull().unique(),
74
- variant: t.text({ enum: imageVariants }).notNull(),
75
- disposition: t.text({ enum: imageDispositions }).notNull(),
76
- expiresAt: t.timestamp().notNull(),
77
- nodeId: t
78
- .uuid()
79
- .notNull()
80
- .references(() => nodes.id, { onDelete: "cascade" }),
81
- variantId: t.uuid().references(() => nodeVariants.id, { onDelete: "set null" }),
15
+ provider: t.text({ enum: storageProviders }).notNull(),
16
+ bucket: t.text().notNull(),
17
+ key: t.text().notNull(),
18
+ status: storageAssetStatusEnum().notNull(),
19
+ visibility: storageAssetVisibilityEnum().notNull().default("private"),
20
+ size: t.integer().default(0),
21
+ contentType: t.varchar({ length: 255 }),
22
+ uploadId: t.uuid().notNull().defaultRandom(),
23
+ name: t.text(),
24
+ metadata: t.jsonb(),
25
+ etag: t.text(),
26
+ uploadedAt: t.timestamp().defaultNow().notNull(),
27
+ deletedAt: t.timestamp(),
82
28
  }),
83
- (t) => [unique("node_presigned_url_unique").on(t.nodeId, t.variant, t.disposition)],
29
+ (t) => [
30
+ unique("storage_assets_provider_bucket_key_unique").on(t.provider, t.bucket, t.key),
31
+ index("storage_assets_status_idx").on(t.status),
32
+ index("storage_assets_bucket_key_idx").on(t.bucket, t.key),
33
+ ],
84
34
  );
85
-
86
- export const nodePresignedUrlsRelations = relations(nodePresignedUrls, ({ one }) => ({
87
- node: one(nodes, {
88
- fields: [nodePresignedUrls.nodeId],
89
- references: [nodes.id],
90
- relationName: "node",
91
- }),
92
- }));
93
-
94
- /**
95
- * Drive schema
96
- **/
97
- const driveSchema = {
98
- nodes,
99
- nodesRelations,
100
- nodeVariants,
101
- nodeVariantsRelations,
102
- nodePresignedUrls,
103
- nodePresignedUrlsRelations,
104
- };
105
- export type DriveSchema = typeof driveSchema;