@tulip-systems/core 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (367) 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/badge.d.mts +1 -1
  26. package/dist/components/ui/button-group.d.mts +1 -1
  27. package/dist/components/ui/button.d.mts +2 -2
  28. package/dist/components/ui/combobox-dropdown.client.mjs +1 -0
  29. package/dist/components/ui/combobox-dropdown.client.mjs.map +1 -1
  30. package/dist/components/ui/combobox.client.mjs +1 -1
  31. package/dist/components/ui/combobox.client.mjs.map +1 -1
  32. package/dist/components/ui/field.client.d.mts +1 -1
  33. package/dist/components/ui/item.d.mts +1 -1
  34. package/dist/components.d.mts +2 -2
  35. package/dist/components.mjs +2 -2
  36. package/dist/config/server.d.mts +1 -3
  37. package/dist/config/server.mjs +1 -4
  38. package/dist/config.d.mts +2 -2
  39. package/dist/config.mjs +1 -1
  40. package/dist/data-tables/client.d.mts +2 -1
  41. package/dist/data-tables/client.mjs +2 -1
  42. package/dist/data-tables.d.mts +1 -1
  43. package/dist/database/client.d.mts +1 -0
  44. package/dist/database/client.mjs +1 -0
  45. package/dist/database/server.d.mts +2 -0
  46. package/dist/database/server.mjs +3 -0
  47. package/dist/database.d.mts +3 -0
  48. package/dist/database.mjs +3 -0
  49. package/dist/emails/client.d.mts +1 -0
  50. package/dist/emails/client.mjs +1 -0
  51. package/dist/emails/server.d.mts +2 -0
  52. package/dist/emails/server.mjs +3 -0
  53. package/dist/emails.d.mts +1 -0
  54. package/dist/emails.mjs +1 -0
  55. package/dist/lib/utils/markdown.d.mts +10 -0
  56. package/dist/lib/utils/markdown.d.mts.map +1 -0
  57. package/dist/lib/utils/markdown.mjs +15 -0
  58. package/dist/lib/utils/markdown.mjs.map +1 -0
  59. package/dist/lib/utils/url.mjs +2 -1
  60. package/dist/lib/utils/url.mjs.map +1 -1
  61. package/dist/lib/utils/user-agent.mjs +15 -0
  62. package/dist/lib/utils/user-agent.mjs.map +1 -1
  63. package/dist/lib.d.mts +2 -2
  64. package/dist/lib.mjs +2 -2
  65. package/dist/modules/auth/components/create-first-user-guard.server.d.mts +16 -0
  66. package/dist/modules/auth/components/create-first-user-guard.server.d.mts.map +1 -0
  67. package/dist/modules/auth/components/create-first-user-guard.server.mjs +16 -0
  68. package/dist/modules/auth/components/create-first-user-guard.server.mjs.map +1 -0
  69. package/dist/modules/auth/components/guard.server.d.mts +2 -2
  70. package/dist/modules/auth/components/guard.server.mjs +1 -1
  71. package/dist/modules/auth/components/guard.server.mjs.map +1 -1
  72. package/dist/modules/auth/db/schema.d.mts +1 -1
  73. package/dist/modules/auth/db/schema.mjs +2 -2
  74. package/dist/modules/auth/handler/create-client.client.d.mts +4838 -229
  75. package/dist/modules/auth/handler/create-client.client.d.mts.map +1 -1
  76. package/dist/modules/auth/handler/create-client.client.mjs.map +1 -1
  77. package/dist/modules/auth/handler/proxy.server.mjs +2 -2
  78. package/dist/modules/auth/handler/proxy.server.mjs.map +1 -1
  79. package/dist/modules/auth/handler/route.server.d.mts +2 -2
  80. package/dist/modules/auth/handler/route.server.d.mts.map +1 -1
  81. package/dist/modules/auth/handler/route.server.mjs.map +1 -1
  82. package/dist/modules/auth/handler/{init.d.mts → service.server.d.mts} +322 -90
  83. package/dist/modules/auth/handler/service.server.d.mts.map +1 -0
  84. package/dist/modules/auth/handler/{init.mjs → service.server.mjs} +19 -8
  85. package/dist/modules/auth/handler/service.server.mjs.map +1 -0
  86. package/dist/modules/auth/hooks/use-session.d.mts +9 -4
  87. package/dist/modules/auth/hooks/use-session.d.mts.map +1 -1
  88. package/dist/modules/auth/lib/helpers.server.d.mts +1 -1
  89. package/dist/modules/auth/lib/permissions.d.mts +1 -1
  90. package/dist/modules/auth/lib/validators.mjs +1 -1
  91. package/dist/modules/config/lib/context.d.mts +9 -10
  92. package/dist/modules/config/lib/context.d.mts.map +1 -1
  93. package/dist/modules/config/lib/context.mjs.map +1 -1
  94. package/dist/modules/data-tables/lib/converters/search.d.mts +1 -1
  95. package/dist/modules/data-tables/lib/converters/sorting.d.mts +1 -1
  96. package/dist/modules/data-tables/server/get-data.server.d.mts +3 -3
  97. package/dist/modules/data-tables/server/get-data.server.mjs +1 -1
  98. package/dist/modules/data-tables/server/get-data.server.mjs.map +1 -1
  99. package/dist/modules/data-tables/strategies/infinite/strategy.d.mts +1 -1
  100. package/dist/modules/data-tables/strategies/infinite/strategy.mjs +3 -0
  101. package/dist/modules/data-tables/strategies/infinite/strategy.mjs.map +1 -1
  102. package/dist/modules/data-tables/tables/data-table/components/row.mjs +5 -15
  103. package/dist/modules/data-tables/tables/data-table/components/row.mjs.map +1 -1
  104. package/dist/modules/data-tables/tables/inline-table/components/body.mjs +1 -1
  105. package/dist/modules/data-tables/tables/inline-table/components/body.mjs.map +1 -1
  106. package/dist/modules/data-tables/tables/inline-table/components/row.client.mjs +13 -23
  107. package/dist/modules/data-tables/tables/inline-table/components/row.client.mjs.map +1 -1
  108. package/dist/modules/data-tables/tables/inline-table/components/table.d.mts +1 -0
  109. package/dist/modules/data-tables/tables/inline-table/components/table.d.mts.map +1 -1
  110. package/dist/modules/data-tables/tables/inline-table/components/table.mjs +2 -1
  111. package/dist/modules/data-tables/tables/inline-table/components/table.mjs.map +1 -1
  112. package/dist/modules/data-tables/tables/inline-table/hooks/context.client.d.mts +5 -1
  113. package/dist/modules/data-tables/tables/inline-table/hooks/context.client.d.mts.map +1 -1
  114. package/dist/modules/data-tables/tables/inline-table/hooks/context.client.mjs +2 -1
  115. package/dist/modules/data-tables/tables/inline-table/hooks/context.client.mjs.map +1 -1
  116. package/dist/modules/data-tables/tables/inline-table/hooks/use-hotkeys.client.d.mts +30 -0
  117. package/dist/modules/data-tables/tables/inline-table/hooks/use-hotkeys.client.d.mts.map +1 -0
  118. package/dist/modules/data-tables/tables/inline-table/hooks/use-hotkeys.client.mjs +77 -9
  119. package/dist/modules/data-tables/tables/inline-table/hooks/use-hotkeys.client.mjs.map +1 -1
  120. package/dist/modules/{config/db → database/lib}/helpers.d.mts +2 -2
  121. package/dist/modules/database/lib/helpers.d.mts.map +1 -0
  122. package/dist/modules/{config/db → database/lib}/helpers.mjs +1 -1
  123. package/dist/modules/database/lib/helpers.mjs.map +1 -0
  124. package/dist/modules/database/lib/service.server.d.mts +34 -0
  125. package/dist/modules/database/lib/service.server.d.mts.map +1 -0
  126. package/dist/modules/database/lib/service.server.mjs +24 -0
  127. package/dist/modules/database/lib/service.server.mjs.map +1 -0
  128. package/dist/modules/{config/db → database/lib}/types.d.mts +1 -1
  129. package/dist/modules/database/lib/types.d.mts.map +1 -0
  130. package/dist/modules/emails/lib/service.server.d.mts +29 -0
  131. package/dist/modules/emails/lib/service.server.d.mts.map +1 -0
  132. package/dist/modules/emails/lib/service.server.mjs +21 -0
  133. package/dist/modules/emails/lib/service.server.mjs.map +1 -0
  134. package/dist/modules/inline-edit/components/date-input.client.mjs +1 -1
  135. package/dist/modules/inline-edit/components/date-input.client.mjs.map +1 -1
  136. package/dist/modules/inline-edit/components/date-picker.client.mjs +1 -0
  137. package/dist/modules/inline-edit/components/date-picker.client.mjs.map +1 -1
  138. package/dist/modules/inline-edit/components/date-time.client.mjs +1 -0
  139. package/dist/modules/inline-edit/components/date-time.client.mjs.map +1 -1
  140. package/dist/modules/inline-edit/components/editor.client.mjs +1 -0
  141. package/dist/modules/inline-edit/components/editor.client.mjs.map +1 -1
  142. package/dist/modules/inline-edit/components/input-recipient.client.mjs +1 -0
  143. package/dist/modules/inline-edit/components/input-recipient.client.mjs.map +1 -1
  144. package/dist/modules/inline-edit/components/input-toggle.client.mjs +1 -0
  145. package/dist/modules/inline-edit/components/input-toggle.client.mjs.map +1 -1
  146. package/dist/modules/inline-edit/components/input.client.d.mts.map +1 -1
  147. package/dist/modules/inline-edit/components/input.client.mjs +3 -0
  148. package/dist/modules/inline-edit/components/input.client.mjs.map +1 -1
  149. package/dist/modules/inline-edit/components/select.client.d.mts.map +1 -1
  150. package/dist/modules/inline-edit/components/select.client.mjs +1 -0
  151. package/dist/modules/inline-edit/components/select.client.mjs.map +1 -1
  152. package/dist/modules/inline-edit/components/switch.client.mjs +1 -0
  153. package/dist/modules/inline-edit/components/switch.client.mjs.map +1 -1
  154. package/dist/modules/inline-edit/components/toggle.client.mjs +1 -0
  155. package/dist/modules/inline-edit/components/toggle.client.mjs.map +1 -1
  156. package/dist/modules/inline-edit/lib/variants.d.mts +1 -1
  157. package/dist/modules/router/handler/context.server.d.mts +12 -10
  158. package/dist/modules/router/handler/context.server.d.mts.map +1 -1
  159. package/dist/modules/router/handler/init.server.d.mts +13 -11
  160. package/dist/modules/router/handler/init.server.d.mts.map +1 -1
  161. package/dist/modules/router/handler/init.server.mjs +2 -2
  162. package/dist/modules/router/handler/init.server.mjs.map +1 -1
  163. package/dist/modules/router/handler/route.server.d.mts +1 -1
  164. package/dist/modules/storage/components/dropzone.client.d.mts +2 -2
  165. package/dist/modules/storage/components/dropzone.client.d.mts.map +1 -1
  166. package/dist/modules/storage/components/dropzone.client.mjs.map +1 -1
  167. package/dist/modules/storage/components/image-grid.client.d.mts +3 -3
  168. package/dist/modules/storage/components/image-grid.client.d.mts.map +1 -1
  169. package/dist/modules/storage/components/image-grid.client.mjs +20 -22
  170. package/dist/modules/storage/components/image-grid.client.mjs.map +1 -1
  171. package/dist/modules/storage/components/image.client.d.mts +8 -0
  172. package/dist/modules/storage/components/image.client.d.mts.map +1 -0
  173. package/dist/modules/storage/components/image.client.mjs +17 -0
  174. package/dist/modules/storage/components/image.client.mjs.map +1 -0
  175. package/dist/modules/storage/components/upload-button.client.d.mts +12 -0
  176. package/dist/modules/storage/components/upload-button.client.d.mts.map +1 -0
  177. package/dist/modules/storage/components/upload-button.client.mjs +34 -0
  178. package/dist/modules/storage/components/upload-button.client.mjs.map +1 -0
  179. package/dist/modules/storage/components/upload-zone-context.client.d.mts +5 -5
  180. package/dist/modules/storage/components/upload-zone-context.client.d.mts.map +1 -1
  181. package/dist/modules/storage/components/upload-zone-context.client.mjs +2 -2
  182. package/dist/modules/storage/components/upload-zone-context.client.mjs.map +1 -1
  183. package/dist/modules/storage/components/upload-zone.client.d.mts +4 -4
  184. package/dist/modules/storage/components/upload-zone.client.d.mts.map +1 -1
  185. package/dist/modules/storage/components/upload-zone.client.mjs +16 -9
  186. package/dist/modules/storage/components/upload-zone.client.mjs.map +1 -1
  187. package/dist/modules/storage/lib/constants.d.mts +1 -5
  188. package/dist/modules/storage/lib/constants.d.mts.map +1 -1
  189. package/dist/modules/storage/lib/constants.mjs +1 -13
  190. package/dist/modules/storage/lib/constants.mjs.map +1 -1
  191. package/dist/modules/storage/lib/helpers.d.mts +14 -28
  192. package/dist/modules/storage/lib/helpers.d.mts.map +1 -1
  193. package/dist/modules/storage/lib/helpers.mjs +17 -75
  194. package/dist/modules/storage/lib/helpers.mjs.map +1 -1
  195. package/dist/modules/storage/lib/procedures.server.d.mts +1991 -0
  196. package/dist/modules/{auth/handler/init.d.mts.map → storage/lib/procedures.server.d.mts.map} +1 -1
  197. package/dist/modules/storage/lib/procedures.server.mjs +22 -0
  198. package/dist/modules/storage/lib/procedures.server.mjs.map +1 -0
  199. package/dist/modules/storage/lib/router-handlers.server.d.mts +41 -0
  200. package/dist/modules/storage/lib/router-handlers.server.d.mts.map +1 -0
  201. package/dist/modules/storage/lib/router-handlers.server.mjs +124 -0
  202. package/dist/modules/storage/lib/router-handlers.server.mjs.map +1 -0
  203. package/dist/modules/storage/lib/schema.d.mts +68 -958
  204. package/dist/modules/storage/lib/schema.d.mts.map +1 -1
  205. package/dist/modules/storage/lib/schema.mjs +28 -65
  206. package/dist/modules/storage/lib/schema.mjs.map +1 -1
  207. package/dist/modules/storage/lib/service.server.d.mts +2155 -141
  208. package/dist/modules/storage/lib/service.server.d.mts.map +1 -1
  209. package/dist/modules/storage/lib/service.server.mjs +453 -242
  210. package/dist/modules/storage/lib/service.server.mjs.map +1 -1
  211. package/dist/modules/storage/lib/upload.client.d.mts +58 -0
  212. package/dist/modules/storage/lib/upload.client.d.mts.map +1 -0
  213. package/dist/modules/storage/lib/upload.client.mjs +87 -0
  214. package/dist/modules/storage/lib/upload.client.mjs.map +1 -0
  215. package/dist/modules/storage/lib/validators.d.mts +297 -835
  216. package/dist/modules/storage/lib/validators.d.mts.map +1 -1
  217. package/dist/modules/storage/lib/validators.mjs +32 -76
  218. package/dist/modules/storage/lib/validators.mjs.map +1 -1
  219. package/dist/modules/storage/providers/adapters/s3.server.d.mts +19 -0
  220. package/dist/modules/storage/providers/adapters/s3.server.d.mts.map +1 -0
  221. package/dist/modules/storage/providers/adapters/s3.server.mjs +173 -0
  222. package/dist/modules/storage/providers/adapters/s3.server.mjs.map +1 -0
  223. package/dist/modules/storage/providers/lib/constants.d.mts +6 -0
  224. package/dist/modules/storage/providers/lib/constants.d.mts.map +1 -0
  225. package/dist/modules/storage/providers/lib/constants.mjs +6 -0
  226. package/dist/modules/storage/providers/lib/constants.mjs.map +1 -0
  227. package/dist/modules/storage/providers/lib/errors.d.mts +12 -0
  228. package/dist/modules/storage/providers/lib/errors.d.mts.map +1 -0
  229. package/dist/modules/storage/providers/lib/errors.mjs +13 -0
  230. package/dist/modules/storage/providers/lib/errors.mjs.map +1 -0
  231. package/dist/modules/storage/providers/lib/types.d.mts +21 -0
  232. package/dist/modules/storage/providers/lib/types.d.mts.map +1 -0
  233. package/dist/modules/storage/providers/lib/validators.d.mts +112 -0
  234. package/dist/modules/storage/providers/lib/validators.d.mts.map +1 -0
  235. package/dist/modules/storage/providers/lib/validators.mjs +75 -0
  236. package/dist/modules/storage/providers/lib/validators.mjs.map +1 -0
  237. package/dist/router/server.d.mts +1 -1
  238. package/dist/storage/client.d.mts +4 -2
  239. package/dist/storage/client.mjs +4 -2
  240. package/dist/storage/server.d.mts +5 -4
  241. package/dist/storage/server.mjs +5 -4
  242. package/dist/storage.d.mts +9 -6
  243. package/dist/storage.mjs +8 -6
  244. package/package.json +18 -5
  245. package/src/components/editor/components/editor.client.tsx +9 -1
  246. package/src/components/editor/extensions/file-handler/extension.ts +4 -4
  247. package/src/components/editor/extensions/file-handler/strategy.ts +15 -40
  248. package/src/components/editor/extensions/file-handler/utils.ts +1 -1
  249. package/src/components/editor/extensions/image/extension.ts +10 -10
  250. package/src/components/editor/lib/helpers.ts +28 -11
  251. package/src/components/ui/combobox-dropdown.client.tsx +1 -0
  252. package/src/components/ui/combobox.client.tsx +1 -1
  253. package/src/entry.ts +12 -51
  254. package/src/lib/entry.ts +1 -5
  255. package/src/lib/utils/markdown.ts +10 -0
  256. package/src/lib/utils/url.ts +2 -1
  257. package/src/lib/utils/user-agent.ts +15 -0
  258. package/src/modules/auth/components/{guard-first-user.server.tsx → create-first-user-guard.server.tsx} +8 -8
  259. package/src/modules/auth/components/guard.server.tsx +1 -1
  260. package/src/modules/auth/entry.server.ts +4 -5
  261. package/src/modules/auth/handler/create-client.client.ts +2 -2
  262. package/src/modules/auth/handler/proxy.server.ts +1 -1
  263. package/src/modules/auth/handler/route.server.ts +2 -2
  264. package/src/modules/auth/handler/{init.ts → service.server.ts} +30 -9
  265. package/src/modules/config/entry.server.ts +0 -9
  266. package/src/modules/config/entry.ts +2 -2
  267. package/src/modules/config/lib/context.ts +9 -9
  268. package/src/modules/data-tables/entry.client.ts +1 -0
  269. package/src/modules/data-tables/server/get-data.server.ts +1 -1
  270. package/src/modules/data-tables/strategies/infinite/strategy.ts +4 -1
  271. package/src/modules/data-tables/tables/data-table/components/row.tsx +12 -21
  272. package/src/modules/data-tables/tables/inline-table/components/body.tsx +1 -1
  273. package/src/modules/data-tables/tables/inline-table/components/row.client.tsx +24 -30
  274. package/src/modules/data-tables/tables/inline-table/components/table.tsx +6 -1
  275. package/src/modules/data-tables/tables/inline-table/hooks/context.client.tsx +5 -0
  276. package/src/modules/data-tables/tables/inline-table/hooks/use-hotkeys.client.ts +119 -91
  277. package/src/modules/database/entry.client.ts +0 -0
  278. package/src/modules/database/entry.server.ts +4 -0
  279. package/src/modules/database/entry.ts +5 -0
  280. package/src/modules/database/lib/service.server.ts +33 -0
  281. package/src/modules/emails/entry.client.ts +0 -0
  282. package/src/modules/emails/entry.server.ts +4 -0
  283. package/src/modules/emails/entry.ts +0 -0
  284. package/src/modules/emails/lib/service.server.ts +29 -0
  285. package/src/modules/inline-edit/components/date-input.client.tsx +1 -1
  286. package/src/modules/inline-edit/components/date-picker.client.tsx +1 -0
  287. package/src/modules/inline-edit/components/date-time.client.tsx +1 -0
  288. package/src/modules/inline-edit/components/editor.client.tsx +3 -0
  289. package/src/modules/inline-edit/components/input-recipient.client.tsx +1 -0
  290. package/src/modules/inline-edit/components/input-toggle.client.tsx +1 -0
  291. package/src/modules/inline-edit/components/input.client.tsx +3 -0
  292. package/src/modules/inline-edit/components/select.client.tsx +5 -1
  293. package/src/modules/inline-edit/components/switch.client.tsx +1 -0
  294. package/src/modules/inline-edit/components/toggle.client.tsx +1 -0
  295. package/src/modules/router/handler/init.server.ts +2 -2
  296. package/src/modules/storage/components/dropzone.client.tsx +1 -1
  297. package/src/modules/storage/components/image-grid.client.tsx +23 -20
  298. package/src/modules/storage/components/image.client.tsx +8 -0
  299. package/src/modules/storage/components/upload-zone-context.client.tsx +11 -8
  300. package/src/modules/storage/components/upload-zone.client.tsx +22 -16
  301. package/src/modules/storage/entry.client.ts +3 -1
  302. package/src/modules/storage/entry.server.ts +9 -3
  303. package/src/modules/storage/entry.ts +13 -1
  304. package/src/modules/storage/lib/constants.ts +0 -11
  305. package/src/modules/storage/lib/helpers.ts +18 -65
  306. package/src/modules/storage/lib/procedures.server.ts +60 -0
  307. package/src/modules/storage/lib/router-handlers.server.ts +178 -0
  308. package/src/modules/storage/lib/schema.ts +26 -97
  309. package/src/modules/storage/lib/service.server.ts +636 -374
  310. package/src/modules/storage/lib/upload.client.ts +156 -0
  311. package/src/modules/storage/lib/validators.ts +50 -111
  312. package/src/modules/storage/providers/adapters/s3.server.ts +281 -0
  313. package/src/modules/storage/providers/lib/constants.ts +3 -0
  314. package/src/modules/storage/providers/lib/errors.ts +21 -0
  315. package/src/modules/storage/providers/lib/types.ts +28 -0
  316. package/src/modules/storage/providers/lib/validators.ts +122 -0
  317. package/dist/lib/config/constants.d.mts +0 -5
  318. package/dist/lib/config/constants.d.mts.map +0 -1
  319. package/dist/lib/config/constants.mjs +0 -6
  320. package/dist/lib/config/constants.mjs.map +0 -1
  321. package/dist/modules/auth/components/guard-first-user.server.d.mts +0 -18
  322. package/dist/modules/auth/components/guard-first-user.server.d.mts.map +0 -1
  323. package/dist/modules/auth/components/guard-first-user.server.mjs +0 -16
  324. package/dist/modules/auth/components/guard-first-user.server.mjs.map +0 -1
  325. package/dist/modules/auth/handler/init.mjs.map +0 -1
  326. package/dist/modules/config/db/helpers.d.mts.map +0 -1
  327. package/dist/modules/config/db/helpers.mjs.map +0 -1
  328. package/dist/modules/config/db/init.d.mts +0 -20
  329. package/dist/modules/config/db/init.d.mts.map +0 -1
  330. package/dist/modules/config/db/init.mjs +0 -15
  331. package/dist/modules/config/db/init.mjs.map +0 -1
  332. package/dist/modules/config/db/types.d.mts.map +0 -1
  333. package/dist/modules/config/providers/email.d.mts +0 -12
  334. package/dist/modules/config/providers/email.d.mts.map +0 -1
  335. package/dist/modules/config/providers/email.mjs +0 -11
  336. package/dist/modules/config/providers/email.mjs.map +0 -1
  337. package/dist/modules/storage/config/filters.d.mts +0 -17
  338. package/dist/modules/storage/config/filters.d.mts.map +0 -1
  339. package/dist/modules/storage/config/filters.mjs +0 -17
  340. package/dist/modules/storage/config/filters.mjs.map +0 -1
  341. package/dist/modules/storage/lib/create-client.server.d.mts +0 -11
  342. package/dist/modules/storage/lib/create-client.server.d.mts.map +0 -1
  343. package/dist/modules/storage/lib/create-client.server.mjs +0 -11
  344. package/dist/modules/storage/lib/create-client.server.mjs.map +0 -1
  345. package/dist/modules/storage/lib/create-upload.client.d.mts +0 -56
  346. package/dist/modules/storage/lib/create-upload.client.d.mts.map +0 -1
  347. package/dist/modules/storage/lib/create-upload.client.mjs +0 -98
  348. package/dist/modules/storage/lib/create-upload.client.mjs.map +0 -1
  349. package/dist/modules/storage/lib/proxy.server.d.mts +0 -21
  350. package/dist/modules/storage/lib/proxy.server.d.mts.map +0 -1
  351. package/dist/modules/storage/lib/proxy.server.mjs +0 -46
  352. package/dist/modules/storage/lib/proxy.server.mjs.map +0 -1
  353. package/dist/modules/storage/lib/router.server.d.mts +0 -31002
  354. package/dist/modules/storage/lib/router.server.d.mts.map +0 -1
  355. package/dist/modules/storage/lib/router.server.mjs +0 -86
  356. package/dist/modules/storage/lib/router.server.mjs.map +0 -1
  357. package/src/lib/config/constants.ts +0 -1
  358. package/src/lib/utils/time-picker.ts +0 -139
  359. package/src/modules/config/db/init.ts +0 -21
  360. package/src/modules/config/providers/email.ts +0 -13
  361. package/src/modules/storage/config/filters.ts +0 -12
  362. package/src/modules/storage/lib/create-client.server.ts +0 -14
  363. package/src/modules/storage/lib/create-upload.client.ts +0 -134
  364. package/src/modules/storage/lib/proxy.server.ts +0 -63
  365. package/src/modules/storage/lib/router.server.ts +0 -182
  366. /package/src/modules/{config/db → database/lib}/helpers.ts +0 -0
  367. /package/src/modules/{config/db → database/lib}/types.ts +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"router.server.d.mts","names":[],"sources":["../../../../src/modules/storage/lib/router.server.ts"],"mappings":";;;;;;;;;;;;;iBAsBgB,yBAAA,CAAA;;;;;;;;;cAAyB,oBAAA,CAAA,QAAA"}
@@ -1,86 +0,0 @@
1
- import { ServerError } from "../../router/lib/error.server.mjs";
2
- import { isFolder } from "./helpers.mjs";
3
- import { bulkActionSchema } from "../../router/lib/validators.mjs";
4
- import { initRPC } from "../../router/handler/init.server.mjs";
5
- import { nodes } from "./schema.mjs";
6
- import { createFolderNodeSchema, getFileURLSchema, getNodesByParentIdSchema, presignFileSchema, selectNodeSchema, selectNodeWithChildrenSchema, updateNodeSchema } from "./validators.mjs";
7
- import { and, eq, sql } from "drizzle-orm";
8
- import { z as z$1 } from "zod";
9
-
10
- //#region src/modules/storage/lib/router.server.ts
11
- /**
12
- * Create Drive base procedures
13
- */
14
- function createDriveBaseProcedures() {
15
- const { protectedProcedure } = initRPC();
16
- return {
17
- getNodeById: protectedProcedure.input(z$1.object({
18
- id: z$1.string(),
19
- namespace: z$1.string()
20
- })).output(selectNodeWithChildrenSchema.optional()).handler(async ({ context, input }) => context.db.query.nodes.findFirst({
21
- where: and(eq(nodes.id, input.id), eq(nodes.namespace, input.namespace)),
22
- with: { children: true }
23
- })),
24
- getNodesByParentId: protectedProcedure.input(getNodesByParentIdSchema).output(z$1.array(selectNodeSchema)).handler(async ({ context, input }) => context.storage.getNodesByParentId(input)),
25
- getFolderParents: protectedProcedure.input(z$1.object({
26
- id: z$1.string().nullable(),
27
- namespace: z$1.string()
28
- })).handler(async ({ context, input }) => {
29
- if (!input.id) return [];
30
- const startNodeQuery = context.db.select({
31
- id: nodes.id,
32
- name: nodes.name,
33
- parentId: nodes.parentId,
34
- depth: sql`0`.as("depth")
35
- }).from(nodes).where(and(eq(nodes.id, input.id), eq(nodes.namespace, input.namespace)));
36
- const alias = "parent_nodes";
37
- const parentNodesQueryAlias = startNodeQuery.as(alias);
38
- const recursiveQueryName = sql.raw(`"${alias}"`);
39
- const recursiveQuery = startNodeQuery.unionAll(context.db.select({
40
- id: nodes.id,
41
- name: nodes.name,
42
- parentId: nodes.parentId,
43
- depth: sql`${parentNodesQueryAlias.depth} + 1`
44
- }).from(nodes).innerJoin(recursiveQueryName, eq(nodes.id, parentNodesQueryAlias.parentId)));
45
- return (await context.db.execute(sql`WITH RECURSIVE ${recursiveQueryName} AS ${recursiveQuery} SELECT * FROM ${recursiveQueryName}`))?.rows?.toSorted((a, b) => Number(b.depth) - Number(a.depth)) ?? [];
46
- }),
47
- getSignedURL: protectedProcedure.input(getFileURLSchema.extend({ id: z$1.string() })).output(z$1.string().nullable()).handler(async ({ context, input: { id, ...options } }) => {
48
- const [node] = await context.db.select().from(nodes).where(eq(nodes.id, id));
49
- if (!node) return null;
50
- return await context.storage.getSignedURL(node, options);
51
- }),
52
- presign: protectedProcedure.input(presignFileSchema).output(z$1.object({
53
- id: z$1.string(),
54
- presignedUrl: z$1.string()
55
- })).handler(async ({ context, input }) => context.storage.presignUpload(input)),
56
- confirm: protectedProcedure.input(z$1.object({ id: z$1.string() })).output(selectNodeSchema).handler(async ({ context, input }) => context.storage.confirmUpload(input)),
57
- createFolder: protectedProcedure.input(createFolderNodeSchema).output(selectNodeSchema).handler(async ({ context, input }) => context.storage.createFolder(input)),
58
- updateNode: protectedProcedure.input(z$1.object({
59
- id: z$1.string(),
60
- data: updateNodeSchema
61
- })).output(selectNodeSchema).handler(async ({ context, input }) => context.storage.updateNode(input)),
62
- changeParent: protectedProcedure.input(z$1.object({
63
- id: z$1.string(),
64
- parentId: z$1.string().nullish()
65
- })).handler(async ({ context, input }) => {
66
- const [parent, node] = await Promise.all([input.parentId && await context.db.query.nodes.findFirst({ where: eq(nodes.id, input.parentId) }), context.db.query.nodes.findFirst({ where: eq(nodes.id, input.id) })]);
67
- /**
68
- * Validate
69
- */
70
- if (node?.readonly) throw new ServerError("BAD_REQUEST", { message: "Deze node is alleen leesbaar en kan niet worden gewijzigd" });
71
- if (input.parentId && !parent) throw new ServerError("BAD_REQUEST", { message: "Parent not found" });
72
- if (!node) throw new ServerError("BAD_REQUEST", { message: "Node not found" });
73
- if (parent && !isFolder(parent)) throw new ServerError("BAD_REQUEST", { message: "Parent is not a folder" });
74
- if (parent && parent.namespace !== node.namespace) throw new ServerError("BAD_REQUEST", { message: "Parent is not in the same namespace" });
75
- /**
76
- * Update the parent
77
- */
78
- await context.db.update(nodes).set({ parentId: input.parentId }).where(eq(nodes.id, input.id));
79
- }),
80
- deleteNodes: protectedProcedure.input(bulkActionSchema).output(z$1.void()).handler(async ({ context, input }) => context.storage.deleteNodes(input))
81
- };
82
- }
83
-
84
- //#endregion
85
- export { createDriveBaseProcedures };
86
- //# sourceMappingURL=router.server.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"router.server.mjs","names":["z"],"sources":["../../../../src/modules/storage/lib/router.server.ts"],"sourcesContent":["import { and, eq, sql } from \"drizzle-orm\";\nimport type { QueryResult } from \"pg\";\nimport { z } from \"zod\";\nimport { bulkActionSchema } from \"@/modules/router/entry\";\nimport { ServerError } from \"@/modules/router/entry.server\";\nimport { initRPC } from \"@/modules/router/handler/init.server\";\nimport { isFolder } from \"./helpers\";\nimport { type DriveSchema, nodes } from \"./schema\";\nimport {\n createFolderNodeSchema,\n getFileURLSchema,\n getNodesByParentIdSchema,\n type Node,\n presignFileSchema,\n selectNodeSchema,\n selectNodeWithChildrenSchema,\n updateNodeSchema,\n} from \"./validators\";\n\n/**\n * Create Drive base procedures\n */\nexport function createDriveBaseProcedures() {\n const { protectedProcedure } = initRPC<DriveSchema>();\n\n return {\n /**\n * Get node and its children\n */\n getNodeById: protectedProcedure\n .input(z.object({ id: z.string(), namespace: z.string() }))\n .output(selectNodeWithChildrenSchema.optional())\n .handler(async ({ context, input }) =>\n context.db.query.nodes.findFirst({\n where: and(eq(nodes.id, input.id), eq(nodes.namespace, input.namespace)),\n with: { children: true },\n }),\n ),\n /**\n * Get folders by parent id\n */\n getNodesByParentId: protectedProcedure\n .input(getNodesByParentIdSchema)\n .output(z.array(selectNodeSchema))\n .handler(async ({ context, input }) => context.storage.getNodesByParentId(input)),\n /**\n * Get parents of a folder\n */\n getFolderParents: protectedProcedure\n .input(z.object({ id: z.string().nullable(), namespace: z.string() }))\n .handler(async ({ context, input }) => {\n if (!input.id) return [];\n\n const startNodeQuery = context.db\n .select({\n id: nodes.id,\n name: nodes.name,\n parentId: nodes.parentId,\n depth: sql<number>`0`.as(\"depth\"),\n })\n .from(nodes)\n .where(and(eq(nodes.id, input.id), eq(nodes.namespace, input.namespace)));\n\n const alias = \"parent_nodes\";\n const parentNodesQueryAlias = startNodeQuery.as(alias);\n const recursiveQueryName = sql.raw(`\"${alias}\"`);\n\n const recursiveQuery = startNodeQuery.unionAll(\n context.db\n .select({\n id: nodes.id,\n name: nodes.name,\n parentId: nodes.parentId,\n depth: sql<number>`${parentNodesQueryAlias.depth} + 1`,\n })\n .from(nodes)\n .innerJoin(recursiveQueryName, eq(nodes.id, parentNodesQueryAlias.parentId)),\n );\n\n const result = (await context.db.execute(\n sql`WITH RECURSIVE ${recursiveQueryName} AS ${recursiveQuery} SELECT * FROM ${recursiveQueryName}`,\n )) as QueryResult<Pick<Node, \"id\" | \"name\" | \"parentId\"> & { depth: number }>;\n\n return result?.rows?.toSorted((a, b) => Number(b.depth) - Number(a.depth)) ?? [];\n }),\n /**\n * Get presigned url for opening a file\n */\n getSignedURL: protectedProcedure\n .input(getFileURLSchema.extend({ id: z.string() }))\n .output(z.string().nullable())\n .handler(async ({ context, input: { id, ...options } }) => {\n const [node] = await context.db.select().from(nodes).where(eq(nodes.id, id));\n if (!node) return null;\n\n return await context.storage.getSignedURL(node, options);\n }),\n\n /**\n * Get presigned url for uploading a file\n */\n presign: protectedProcedure\n .input(presignFileSchema)\n .output(z.object({ id: z.string(), presignedUrl: z.string() }))\n .handler(async ({ context, input }) => context.storage.presignUpload(input)),\n /**\n * Confirm the upload\n */\n confirm: protectedProcedure\n .input(z.object({ id: z.string() }))\n .output(selectNodeSchema)\n .handler(async ({ context, input }) => context.storage.confirmUpload(input)),\n /**\n * Create a folder\n */\n createFolder: protectedProcedure\n .input(createFolderNodeSchema)\n .output(selectNodeSchema)\n .handler(async ({ context, input }) => context.storage.createFolder(input)),\n /**\n * Update node\n */\n updateNode: protectedProcedure\n .input(z.object({ id: z.string(), data: updateNodeSchema }))\n .output(selectNodeSchema)\n .handler(async ({ context, input }) => context.storage.updateNode(input)),\n /**\n * Change node parent\n */\n changeParent: protectedProcedure\n .input(z.object({ id: z.string(), parentId: z.string().nullish() }))\n .handler(async ({ context, input }) => {\n const [parent, node] = await Promise.all([\n input.parentId &&\n (await context.db.query.nodes.findFirst({\n where: eq(nodes.id, input.parentId),\n })),\n context.db.query.nodes.findFirst({\n where: eq(nodes.id, input.id),\n }),\n ]);\n\n /**\n * Validate\n */\n if (node?.readonly) {\n throw new ServerError(\"BAD_REQUEST\", {\n message: \"Deze node is alleen leesbaar en kan niet worden gewijzigd\",\n });\n }\n\n if (input.parentId && !parent)\n throw new ServerError(\"BAD_REQUEST\", { message: \"Parent not found\" });\n if (!node) throw new ServerError(\"BAD_REQUEST\", { message: \"Node not found\" });\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 !== node.namespace) {\n throw new ServerError(\"BAD_REQUEST\", {\n message: \"Parent is not in the same namespace\",\n });\n }\n\n /**\n * Update the parent\n */\n await context.db\n .update(nodes)\n .set({ parentId: input.parentId })\n .where(eq(nodes.id, input.id));\n }),\n /**\n * Delete nodes\n */\n deleteNodes: protectedProcedure\n .input(bulkActionSchema)\n .output(z.void())\n .handler(async ({ context, input }) => context.storage.deleteNodes(input)),\n };\n}\n"],"mappings":"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"}
@@ -1 +0,0 @@
1
- export const BUCKET_NAME = process.env.S3_BUCKET ?? "";
@@ -1,139 +0,0 @@
1
- /**
2
- * regular expression to check for valid hour format (01-23)
3
- */
4
- export function isValidHour(value: string) {
5
- return /^(0[0-9]|1[0-9]|2[0-3])$/.test(value);
6
- }
7
-
8
- /**
9
- * regular expression to check for valid 12 hour format (01-12)
10
- */
11
- export function isValid12Hour(value: string) {
12
- return /^(0[1-9]|1[0-2])$/.test(value);
13
- }
14
-
15
- /**
16
- * regular expression to check for valid minute format (00-59)
17
- */
18
- export function isValidMinuteOrSecond(value: string) {
19
- return /^[0-5][0-9]$/.test(value);
20
- }
21
-
22
- type GetValidNumberConfig = { max: number; min?: number; loop?: boolean };
23
-
24
- export function getValidNumber(
25
- value: string,
26
- { max, min = 0, loop = false }: GetValidNumberConfig,
27
- ) {
28
- let numericValue = parseInt(value, 10);
29
-
30
- if (!Number.isNaN(numericValue)) {
31
- if (!loop) {
32
- if (numericValue > max) numericValue = max;
33
- if (numericValue < min) numericValue = min;
34
- } else {
35
- if (numericValue > max) numericValue = min;
36
- if (numericValue < min) numericValue = max;
37
- }
38
- return numericValue.toString().padStart(2, "0");
39
- }
40
-
41
- return "00";
42
- }
43
-
44
- export function getValidHour(value: string) {
45
- if (isValidHour(value)) return value;
46
- return getValidNumber(value, { max: 23 });
47
- }
48
-
49
- export function getValid12Hour(value: string) {
50
- if (isValid12Hour(value)) return value;
51
- return getValidNumber(value, { max: 12 });
52
- }
53
-
54
- export function getValidMinuteOrSecond(value: string) {
55
- if (isValidMinuteOrSecond(value)) return value;
56
- return getValidNumber(value, { max: 59 });
57
- }
58
-
59
- type GetValidArrowNumberConfig = {
60
- min: number;
61
- max: number;
62
- step: number;
63
- };
64
-
65
- export function getValidArrowNumber(value: string, { min, max, step }: GetValidArrowNumberConfig) {
66
- let numericValue = parseInt(value, 10);
67
- if (!Number.isNaN(numericValue)) {
68
- numericValue += step;
69
- return getValidNumber(String(numericValue), { min, max, loop: true });
70
- }
71
- return "00";
72
- }
73
-
74
- export function getValidArrowHour(value: string, step: number) {
75
- return getValidArrowNumber(value, { min: 0, max: 23, step });
76
- }
77
-
78
- export function getValidArrowMinuteOrSecond(value: string, step: number) {
79
- return getValidArrowNumber(value, { min: 0, max: 59, step });
80
- }
81
-
82
- export function setMinutes(date: Date, value: string) {
83
- const minutes = getValidMinuteOrSecond(value);
84
- date.setMinutes(parseInt(minutes, 10));
85
- return date;
86
- }
87
-
88
- export function setSeconds(date: Date, value: string) {
89
- const seconds = getValidMinuteOrSecond(value);
90
- date.setSeconds(parseInt(seconds, 10));
91
- return date;
92
- }
93
-
94
- export function setHours(date: Date, value: string) {
95
- const hours = getValidHour(value);
96
- date.setHours(parseInt(hours, 10));
97
- return date;
98
- }
99
-
100
- export type TimePickerType = "minutes" | "seconds" | "hours"; // | "12hours";
101
-
102
- export function setDateByType(date: Date, value: string, type: TimePickerType) {
103
- switch (type) {
104
- case "minutes":
105
- return setMinutes(date, value);
106
- case "seconds":
107
- return setSeconds(date, value);
108
- case "hours":
109
- return setHours(date, value);
110
- default:
111
- return date;
112
- }
113
- }
114
-
115
- export function getDateByType(date: Date, type: TimePickerType) {
116
- switch (type) {
117
- case "minutes":
118
- return getValidMinuteOrSecond(String(date.getMinutes()));
119
- case "seconds":
120
- return getValidMinuteOrSecond(String(date.getSeconds()));
121
- case "hours":
122
- return getValidHour(String(date.getHours()));
123
- default:
124
- return "00";
125
- }
126
- }
127
-
128
- export function getArrowByType(value: string, step: number, type: TimePickerType) {
129
- switch (type) {
130
- case "minutes":
131
- return getValidArrowMinuteOrSecond(value, step);
132
- case "seconds":
133
- return getValidArrowMinuteOrSecond(value, step);
134
- case "hours":
135
- return getValidArrowHour(value, step);
136
- default:
137
- return "00";
138
- }
139
- }
@@ -1,21 +0,0 @@
1
- import "server-cli-only";
2
-
3
- import { drizzle } from "drizzle-orm/node-postgres";
4
- import type { Pool } from "pg";
5
- import type { TDatabaseSchema } from "./types";
6
-
7
- type InitDatabaseProps<TSchema extends TDatabaseSchema> = {
8
- schema: TSchema;
9
- pool: Pool;
10
- };
11
-
12
- export function initDatabase<TSchema extends TDatabaseSchema>({
13
- schema,
14
- pool,
15
- }: InitDatabaseProps<TSchema>) {
16
- return drizzle({ client: pool, schema, casing: "snake_case" });
17
- }
18
-
19
- export type DatabaseClient<TSchema extends TDatabaseSchema> = ReturnType<
20
- typeof initDatabase<TSchema>
21
- >;
@@ -1,13 +0,0 @@
1
- import "server-cli-only";
2
-
3
- import { Resend } from "resend";
4
-
5
- type InitEmailProviderProps = {
6
- key: string;
7
- };
8
-
9
- export function initEmailProvider(props: InitEmailProviderProps) {
10
- return new Resend(props.key);
11
- }
12
-
13
- export type EmailClient = ReturnType<typeof initEmailProvider>;
@@ -1,12 +0,0 @@
1
- import z from "zod";
2
- import { createTableFilters } from "@/modules/data-tables/lib/filters/config";
3
- import { parseFilterArray, parseFilterBoolean } from "@/modules/data-tables/lib/filters/parsers";
4
- import { nodeTypeEnum } from "../lib/schema";
5
-
6
- export const nodesTableFilters = createTableFilters({
7
- types: parseFilterArray(z.array(z.enum(nodeTypeEnum.enumValues))),
8
- nodeIds: parseFilterArray(z.array(z.string())),
9
- isDeleted: parseFilterBoolean(z.boolean()),
10
- isOrphaned: parseFilterBoolean(z.boolean()),
11
- hidden: parseFilterBoolean(z.boolean()),
12
- });
@@ -1,14 +0,0 @@
1
- import "server-cli-only";
2
-
3
- import type { TDatabaseSchema } from "@/modules/config/entry";
4
- import { StorageService, type StorageServiceConfig } from "./service.server";
5
-
6
- export function createStorageClient<TSchema extends TDatabaseSchema>(
7
- props: StorageServiceConfig<TSchema>,
8
- ) {
9
- return new StorageService(props);
10
- }
11
-
12
- export type StorageClient<TSchema extends TDatabaseSchema> = ReturnType<
13
- typeof createStorageClient<TSchema>
14
- >;
@@ -1,134 +0,0 @@
1
- import { generateDefaultUUID } from "@/modules/config/entry";
2
- import type { BulkActionSchema } from "@/modules/router/entry";
3
- import type { PresignFileSchema, SelectNodeSchema, UpdateNodeSchema } from "./validators";
4
-
5
- /**
6
- * Upload request
7
- */
8
- export type PrepareUploadInput = Omit<UploadFileRequest, "id" | "name" | "size" | "contentType">;
9
- export type UploadFileRequest = PresignFileSchema & { file: File };
10
- export type UploadHooks = {
11
- beforePresign?: (input: UploadFileRequest) => Promise<void> | void;
12
- afterPresign?: (presignResult: { id: string; presignedUrl: string }) => Promise<void> | void;
13
- beforeConfirm?: (presignResult: { id: string; presignedUrl: string }) => Promise<void> | void;
14
- afterConfirm?: (node: SelectNodeSchema) => Promise<void> | void;
15
- };
16
-
17
- /**
18
- * Upload client
19
- */
20
- export type UploadClient = {
21
- prepareUpload: (input: PrepareUploadInput) => UploadFileRequest;
22
- upload: (input: UploadFileRequest, hooks?: UploadHooks) => Promise<SelectNodeSchema>;
23
- deleteFiles: (ids: string[]) => Promise<void>;
24
- updateNode: (id: string, data: UpdateNodeSchema) => Promise<SelectNodeSchema>;
25
- };
26
-
27
- /**
28
- * Create upload client
29
- */
30
- type CreateUploadClientProps = {
31
- endpoints: {
32
- presign: (input: PresignFileSchema) => Promise<{ id: string; presignedUrl: string }>;
33
- confirm: (input: { id: string }) => Promise<SelectNodeSchema>;
34
- deleteNodes: (input: BulkActionSchema) => Promise<void>;
35
- updateNode: (input: { id: string; data: UpdateNodeSchema }) => Promise<SelectNodeSchema>;
36
- };
37
- };
38
-
39
- export function createUploadClient(props: CreateUploadClientProps): UploadClient {
40
- /**
41
- * Create input schema for the upload method
42
- * @param {PrepareUploadInput} input
43
- * @returns {UploadFileRequest}
44
- */
45
- function prepareUpload(input: PrepareUploadInput): UploadFileRequest {
46
- return {
47
- ...input,
48
- id: generateDefaultUUID(),
49
- name: input.file.name,
50
- size: input.file.size,
51
- contentType: input.file.type,
52
- };
53
- }
54
-
55
- /**
56
- * Upload file to the server
57
- * @param {UploadFileRequest} input
58
- * @returns {Promise<SelectNodeSchema>}
59
- */
60
- async function upload(input: UploadFileRequest, hooks?: UploadHooks): Promise<SelectNodeSchema> {
61
- try {
62
- /**
63
- * Presign
64
- */
65
- await hooks?.beforePresign?.(input);
66
- const presignResult = await props.endpoints.presign(input);
67
- await hooks?.afterPresign?.(presignResult);
68
- /**
69
- * Upload the file
70
- */
71
- const uploadResponse = await fetch(presignResult.presignedUrl, {
72
- method: "PUT",
73
- headers: { "Content-Type": input.file.type },
74
- body: input.file,
75
- });
76
-
77
- if (!uploadResponse.ok) {
78
- const message = await uploadResponse.text();
79
- throw new Error(`Upload failed: ${message}`);
80
- }
81
-
82
- /**
83
- * Confirm
84
- */
85
- await hooks?.beforeConfirm?.(presignResult);
86
- const node = await props.endpoints.confirm({ id: presignResult.id });
87
- await hooks?.afterConfirm?.(node);
88
- /**
89
- * Return
90
- */
91
- return node;
92
- } catch (err) {
93
- console.error("Upload error: ", err);
94
-
95
- /**
96
- * Delete if upload failed
97
- * */
98
- try {
99
- await deleteFiles([input.id]);
100
- } catch (cleanupErr) {
101
- console.error("Cleanup delete failed:", cleanupErr);
102
- }
103
-
104
- throw err;
105
- }
106
- }
107
-
108
- /**
109
- * Delete files
110
- * @param {string[]} ids
111
- */
112
- async function deleteFiles(ids: string[]) {
113
- await props.endpoints.deleteNodes({ ids });
114
- }
115
-
116
- /**
117
- * Update node
118
- * @param {string} id
119
- * @param {UpdateNodeSchema} data
120
- */
121
- async function updateNode(id: string, data: UpdateNodeSchema) {
122
- return props.endpoints.updateNode({ id, data });
123
- }
124
-
125
- /**
126
- * Upload client
127
- */
128
- return {
129
- prepareUpload,
130
- upload,
131
- deleteFiles,
132
- updateNode,
133
- };
134
- }
@@ -1,63 +0,0 @@
1
- import "server-cli-only";
2
-
3
- import { eq } from "drizzle-orm";
4
- import { connection, type NextRequest } from "next/server";
5
- import { getSession } from "@/modules/auth/entry.server";
6
- import type { TulipContext } from "@/modules/config/entry";
7
- import { type DriveSchema, nodes } from "./schema";
8
- import { getFileURLSchema } from "./validators";
9
-
10
- type CreateDriveProxyRouteProps<TSchema extends DriveSchema> = {
11
- context: TulipContext<TSchema>;
12
- };
13
-
14
- /**
15
- * Create drive proxy route
16
- */
17
- export function createDriveProxyRoute<TSchema extends DriveSchema>({
18
- context,
19
- }: CreateDriveProxyRouteProps<TSchema>) {
20
- /**
21
- * GET: Drive node proxy
22
- */
23
- async function GET(request: NextRequest) {
24
- // Make endpoint dynamic
25
- await connection();
26
-
27
- try {
28
- // Get the params
29
- const searchParams = request.nextUrl.searchParams;
30
- const id = searchParams.get("id");
31
- if (!id) return Response.json("Missing id", { status: 400 });
32
-
33
- console.info("Proxying file: ", id);
34
-
35
- // Get the node
36
- const [node] = await context.db.select().from(nodes).where(eq(nodes.id, id));
37
- if (!node) return Response.json("Bestand kon niet worden gevonden", { status: 404 });
38
-
39
- // If the node is private check if the user is authenticated
40
- if (node.mode === "private") {
41
- const session = await getSession(context);
42
- if (!session) return Response.json("Unauthorized", { status: 401 });
43
- }
44
-
45
- const variant = searchParams.get("variant") ?? undefined;
46
- const disposition = searchParams.get("disposition") ?? undefined;
47
-
48
- // Parse the options
49
- const options = getFileURLSchema.parse({ variant, disposition });
50
-
51
- // Get the file url
52
- const url = await context.storage.getSignedURL(node, options);
53
-
54
- // Return the file
55
- return Response.redirect(url, 307);
56
- } catch (error) {
57
- console.error("error", error);
58
- return Response.json("Error", { status: 500 });
59
- }
60
- }
61
-
62
- return { GET };
63
- }