@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
@@ -0,0 +1,122 @@
1
+ import { Readable } from "node:stream";
2
+ import { z } from "zod";
3
+
4
+ /**
5
+ * Object body schema
6
+ */
7
+ export const objectBodyInputSchema = z.union([
8
+ z.string(),
9
+ z.instanceof(Uint8Array),
10
+ z.instanceof(Buffer),
11
+ z.instanceof(Readable),
12
+ ]);
13
+
14
+ export type ObjectBodyInput = z.infer<typeof objectBodyInputSchema>;
15
+
16
+ /**
17
+ * Object body output schema (normalized)
18
+ */
19
+ export const objectBodyOutputSchema = z.instanceof(Readable);
20
+
21
+ export type ObjectBodyOutput = z.infer<typeof objectBodyOutputSchema>;
22
+
23
+ /**
24
+ * Object schema
25
+ */
26
+ export const objectSchema = z.object({
27
+ contentType: z.string().nullable().optional(),
28
+ size: z.number().nullable().optional(),
29
+ metadata: z.record(z.string(), z.string()).optional(),
30
+ });
31
+
32
+ export type ObjectSchema = z.infer<typeof objectSchema>;
33
+
34
+ /**
35
+ * Get object input
36
+ */
37
+ export const getObjectInputSchema = z.string();
38
+ export type GetObjectInput = z.input<typeof getObjectInputSchema>;
39
+
40
+ /**
41
+ * Get object options schema
42
+ */
43
+ export const getObjectOptionsDefaults = { disposition: "inline" } as const;
44
+
45
+ export const getObjectOptionsSchema = z.object({
46
+ disposition: z.string().optional().default(getObjectOptionsDefaults.disposition),
47
+ });
48
+
49
+ export type GetObjectOptions = z.input<typeof getObjectOptionsSchema>;
50
+
51
+ /**
52
+ * Get object URL input
53
+ */
54
+ export const getObjectURLOptionsSchema = getObjectOptionsSchema.extend({
55
+ expiresIn: z
56
+ .number()
57
+ .optional()
58
+ .default(3600 * 24),
59
+ });
60
+
61
+ export type GetObjectURLOptions = z.input<typeof getObjectURLOptionsSchema>;
62
+
63
+ /**
64
+ * Get object output
65
+ */
66
+ export const getObjectOutputSchema = objectSchema.extend({
67
+ body: objectBodyOutputSchema,
68
+ });
69
+
70
+ export type GetObjectOutput = z.infer<typeof getObjectOutputSchema>;
71
+
72
+ /**
73
+ * Get object head input
74
+ */
75
+ export const headObjectInputSchema = z.object({
76
+ key: z.string(),
77
+ });
78
+
79
+ export type HeadObjectInput = z.input<typeof headObjectInputSchema>;
80
+
81
+ /**
82
+ * Head object output
83
+ */
84
+ export const headObjectOutputSchema = objectSchema;
85
+
86
+ export type HeadObjectOutput = z.infer<typeof headObjectOutputSchema>;
87
+
88
+ /**
89
+ * Put object URL input
90
+ */
91
+ export const putObjectURLInputSchema = z.object({
92
+ key: z.string(),
93
+ contentType: z.string().nullable().optional(),
94
+ size: z.number().nullable().optional(),
95
+ metadata: z.record(z.string(), z.string()).optional(),
96
+ });
97
+
98
+ export type PutObjectURLInput = z.input<typeof putObjectURLInputSchema>;
99
+
100
+ /**
101
+ * Put object URL input
102
+ */
103
+ export const putObjectURLOptionsSchema = z.object({
104
+ expiresIn: z.number().optional().default(3600),
105
+ });
106
+
107
+ export type PutObjectURLOptions = z.input<typeof putObjectURLOptionsSchema>;
108
+
109
+ /**
110
+ * Put object input
111
+ */
112
+ export const putObjectInputSchema = putObjectURLInputSchema.extend({
113
+ body: objectBodyInputSchema,
114
+ });
115
+
116
+ export type PutObjectInput = z.input<typeof putObjectInputSchema>;
117
+
118
+ /**
119
+ * Put object schema
120
+ */
121
+ export const putObjectOutputSchema = objectSchema;
122
+ export type PutObjectOutput = z.infer<typeof putObjectOutputSchema>;
@@ -1,5 +0,0 @@
1
- //#region src/lib/config/constants.d.ts
2
- declare const BUCKET_NAME: string;
3
- //#endregion
4
- export { BUCKET_NAME };
5
- //# sourceMappingURL=constants.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.mts","names":[],"sources":["../../../src/lib/config/constants.ts"],"mappings":";cAAa,WAAA"}
@@ -1,6 +0,0 @@
1
- //#region src/lib/config/constants.ts
2
- const BUCKET_NAME = process.env.S3_BUCKET ?? "";
3
-
4
- //#endregion
5
- export { BUCKET_NAME };
6
- //# sourceMappingURL=constants.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.mjs","names":[],"sources":["../../../src/lib/config/constants.ts"],"sourcesContent":["export const BUCKET_NAME = process.env.S3_BUCKET ?? \"\";\n"],"mappings":";AAAA,MAAa,cAAc,QAAQ,IAAI,aAAa"}
@@ -1,18 +0,0 @@
1
- import { TDatabaseSchema } from "../../config/db/types.mjs";
2
- import { TulipContext } from "../../config/lib/context.mjs";
3
- import "../../../config.mjs";
4
- import * as react_jsx_runtime0 from "react/jsx-runtime";
5
- import { PropsWithChildren } from "react";
6
-
7
- //#region src/modules/auth/components/guard-first-user.server.d.ts
8
- type AuthGuardFirstUserProps<TSchema extends TDatabaseSchema> = PropsWithChildren<Pick<TulipContext<TSchema>, "db"> & {
9
- login?: boolean;
10
- }>;
11
- declare function AuthGuardFirstUser<TSchema extends TDatabaseSchema>({
12
- children,
13
- db,
14
- login
15
- }: AuthGuardFirstUserProps<TSchema>): Promise<react_jsx_runtime0.JSX.Element>;
16
- //#endregion
17
- export { AuthGuardFirstUser };
18
- //# sourceMappingURL=guard-first-user.server.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"guard-first-user.server.d.mts","names":[],"sources":["../../../../src/modules/auth/components/guard-first-user.server.tsx"],"mappings":";;;;;;;KAKK,uBAAA,iBAAwC,eAAA,IAAmB,iBAAA,CAC9D,IAAA,CAAK,YAAA,CAAa,OAAA;EAAoB,KAAA;AAAA;AAAA,iBAGlB,kBAAA,iBAAmC,eAAA,CAAA,CAAA;EACvD,QAAA;EACA,EAAA;EACA;AAAA,GACC,uBAAA,CAAwB,OAAA,IAAQ,OAAA,CAAA,kBAAA,CAAA,GAAA,CAAA,OAAA"}
@@ -1,16 +0,0 @@
1
- import { users } from "../db/schema.mjs";
2
- import { Fragment, jsx } from "react/jsx-runtime";
3
- import { redirect } from "next/navigation";
4
-
5
- //#region src/modules/auth/components/guard-first-user.server.tsx
6
- async function AuthGuardFirstUser({ children, db, login = false }) {
7
- const usersExist = (await db.select().from(users).limit(1)).length > 0;
8
- if (login) {
9
- if (!usersExist) redirect("/auth/create-first-user");
10
- } else if (usersExist) redirect("/auth/login");
11
- return /* @__PURE__ */ jsx(Fragment, { children });
12
- }
13
-
14
- //#endregion
15
- export { AuthGuardFirstUser };
16
- //# sourceMappingURL=guard-first-user.server.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"guard-first-user.server.mjs","names":[],"sources":["../../../../src/modules/auth/components/guard-first-user.server.tsx"],"sourcesContent":["import { redirect } from \"next/navigation\";\nimport type { PropsWithChildren } from \"react\";\nimport type { TDatabaseSchema, TulipContext } from \"@/modules/config/entry\";\nimport { users } from \"../db/schema\";\n\ntype AuthGuardFirstUserProps<TSchema extends TDatabaseSchema> = PropsWithChildren<\n Pick<TulipContext<TSchema>, \"db\"> & { login?: boolean }\n>;\n\nexport async function AuthGuardFirstUser<TSchema extends TDatabaseSchema>({\n children,\n db,\n login = false,\n}: AuthGuardFirstUserProps<TSchema>) {\n const allUsers = await db.select().from(users).limit(1);\n const usersExist = allUsers.length > 0;\n\n if (login) {\n if (!usersExist) redirect(\"/auth/create-first-user\");\n } else {\n if (usersExist) redirect(\"/auth/login\");\n }\n\n return <>{children}</>;\n}\n"],"mappings":";;;;;AASA,eAAsB,mBAAoD,EACxE,UACA,IACA,QAAQ,SAC2B;CAEnC,MAAM,cADW,MAAM,GAAG,QAAQ,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,EAC3B,SAAS;AAErC,KAAI,OACF;MAAI,CAAC,WAAY,UAAS,0BAA0B;YAEhD,WAAY,UAAS,cAAc;AAGzC,QAAO,gCAAG,WAAY"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"init.mjs","names":[],"sources":["../../../../src/modules/auth/handler/init.ts"],"sourcesContent":["import { passkey } from \"@better-auth/passkey\";\nimport { drizzleAdapter } from \"better-auth/adapters/drizzle\";\nimport { betterAuth } from \"better-auth/minimal\";\nimport { nextCookies } from \"better-auth/next-js\";\nimport { admin, createAuthMiddleware, emailOTP } from \"better-auth/plugins\";\nimport { eq } from \"drizzle-orm\";\nimport ForgetPasswordEmail from \"@/components/emails/forget-password-email\";\nimport { url } from \"@/lib/utils/url\";\nimport type { TDatabaseSchema } from \"@/modules/config/entry\";\nimport type { DatabaseClient, EmailClient } from \"@/modules/config/entry.server\";\nimport type { TulipConfig } from \"@/modules/config/lib/config\";\nimport { users } from \"../entry\";\nimport type { createAccessControl, Role } from \"../lib/permissions\";\n\nexport const authCookiePrefix = \"tulip\";\n\ntype InitAuthProps<TSchema extends TDatabaseSchema> = {\n db: DatabaseClient<TSchema>;\n email: EmailClient;\n config: TulipConfig;\n ac: ReturnType<typeof createAccessControl>;\n roles: {\n [key in string]?: Role;\n };\n};\n\nexport function initAuth<TSchema extends TDatabaseSchema>(props: InitAuthProps<TSchema>) {\n return betterAuth({\n advanced: {\n cookiePrefix: authCookiePrefix,\n database: {\n generateId: () => false,\n },\n },\n database: drizzleAdapter(props.db, {\n provider: \"pg\",\n usePlural: true,\n // schema: props.schema,\n }),\n emailAndPassword: {\n enabled: true,\n },\n user: {\n changeEmail: {\n enabled: true,\n },\n additionalFields: {\n firstName: {\n type: \"string\",\n required: true,\n input: true,\n },\n lastName: {\n type: \"string\",\n required: true,\n input: true,\n },\n },\n },\n hooks: {\n after: createAuthMiddleware(async (ctx) => {\n if (!ctx.path.startsWith(\"/sign-up\")) return;\n\n const session = ctx.context.newSession;\n if (!session) return;\n\n const existingUsers = await props.db.select().from(users);\n\n if (existingUsers.length === 1) {\n await props.db\n .update(users)\n .set({ role: \"developer\" })\n .where(eq(users.id, session.user.id));\n }\n }),\n },\n plugins: [\n nextCookies(),\n passkey(),\n admin({\n roles: props.roles,\n ac: props.ac,\n adminRoles: [\"admin\", \"developer\"],\n }),\n emailOTP({\n sendVerificationOTP: async ({ email, otp, type }) => {\n /**\n * Send a forget password mail\n */\n if (type === \"forget-password\") {\n const searchParams = new URLSearchParams();\n searchParams.set(\"email\", email);\n searchParams.set(\"otp\", otp);\n\n const resetPasswordHref = url(`/auth/reset-password?${searchParams.toString()}`);\n\n const result = await props.email.emails.send({\n from: props.config.email.defaultFrom,\n to: email,\n subject: \"Wachtwoord herstellen\",\n react: ForgetPasswordEmail({ resetPasswordHref }),\n });\n if (result.error) throw new Error(result.error.message);\n }\n },\n }),\n ],\n });\n}\n\nexport type AuthClient = ReturnType<typeof initAuth>;\n"],"mappings":";;;;;;;;;;;AAcA,MAAa,mBAAmB;AAYhC,SAAgB,SAA0C,OAA+B;AACvF,QAAO,WAAW;EAChB,UAAU;GACR,cAAc;GACd,UAAU,EACR,kBAAkB,OACnB;GACF;EACD,UAAU,eAAe,MAAM,IAAI;GACjC,UAAU;GACV,WAAW;GAEZ,CAAC;EACF,kBAAkB,EAChB,SAAS,MACV;EACD,MAAM;GACJ,aAAa,EACX,SAAS,MACV;GACD,kBAAkB;IAChB,WAAW;KACT,MAAM;KACN,UAAU;KACV,OAAO;KACR;IACD,UAAU;KACR,MAAM;KACN,UAAU;KACV,OAAO;KACR;IACF;GACF;EACD,OAAO,EACL,OAAO,qBAAqB,OAAO,QAAQ;AACzC,OAAI,CAAC,IAAI,KAAK,WAAW,WAAW,CAAE;GAEtC,MAAM,UAAU,IAAI,QAAQ;AAC5B,OAAI,CAAC,QAAS;AAId,QAFsB,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,MAAM,EAEvC,WAAW,EAC3B,OAAM,MAAM,GACT,OAAO,MAAM,CACb,IAAI,EAAE,MAAM,aAAa,CAAC,CAC1B,MAAM,GAAG,MAAM,IAAI,QAAQ,KAAK,GAAG,CAAC;IAEzC,EACH;EACD,SAAS;GACP,aAAa;GACb,SAAS;GACT,MAAM;IACJ,OAAO,MAAM;IACb,IAAI,MAAM;IACV,YAAY,CAAC,SAAS,YAAY;IACnC,CAAC;GACF,SAAS,EACP,qBAAqB,OAAO,EAAE,OAAO,KAAK,WAAW;;;;AAInD,QAAI,SAAS,mBAAmB;KAC9B,MAAM,eAAe,IAAI,iBAAiB;AAC1C,kBAAa,IAAI,SAAS,MAAM;AAChC,kBAAa,IAAI,OAAO,IAAI;KAE5B,MAAM,oBAAoB,IAAI,wBAAwB,aAAa,UAAU,GAAG;KAEhF,MAAM,SAAS,MAAM,MAAM,MAAM,OAAO,KAAK;MAC3C,MAAM,MAAM,OAAO,MAAM;MACzB,IAAI;MACJ,SAAS;MACT,OAAO,oBAAoB,EAAE,mBAAmB,CAAC;MAClD,CAAC;AACF,SAAI,OAAO,MAAO,OAAM,IAAI,MAAM,OAAO,MAAM,QAAQ;;MAG5D,CAAC;GACH;EACF,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.d.mts","names":[],"sources":["../../../../src/modules/config/db/helpers.ts"],"mappings":";;;;cAGa,mBAAA;;;;cAKA,WAAA;4GAWZ,oBAAA,CAAA,oBAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.mjs","names":["uuidv7"],"sources":["../../../../src/modules/config/db/helpers.ts"],"sourcesContent":["import { timestamp, uuid } from \"drizzle-orm/pg-core\";\nimport { v7 as uuidv7 } from \"uuid\";\n\nexport const generateDefaultUUID = () => uuidv7();\n\n/**\n * Base columns4\n */\nexport const baseColumns = {\n // Primary key\n id: uuid()\n .primaryKey()\n .$defaultFn(() => generateDefaultUUID()),\n // Timestamps\n createdAt: timestamp().defaultNow().notNull(),\n updatedAt: timestamp()\n .defaultNow()\n .notNull()\n .$onUpdate(() => new Date()),\n};\n"],"mappings":";;;;AAGA,MAAa,4BAA4BA,IAAQ;;;;AAKjD,MAAa,cAAc;CAEzB,IAAI,MAAM,CACP,YAAY,CACZ,iBAAiB,qBAAqB,CAAC;CAE1C,WAAW,WAAW,CAAC,YAAY,CAAC,SAAS;CAC7C,WAAW,WAAW,CACnB,YAAY,CACZ,SAAS,CACT,gCAAgB,IAAI,MAAM,CAAC;CAC/B"}
@@ -1,20 +0,0 @@
1
- import { TDatabaseSchema } from "./types.mjs";
2
- import "server-cli-only";
3
- import * as drizzle_orm_node_postgres0 from "drizzle-orm/node-postgres";
4
- import { Pool } from "pg";
5
-
6
- //#region src/modules/config/db/init.d.ts
7
- type InitDatabaseProps<TSchema extends TDatabaseSchema> = {
8
- schema: TSchema;
9
- pool: Pool;
10
- };
11
- declare function initDatabase<TSchema extends TDatabaseSchema>({
12
- schema,
13
- pool
14
- }: InitDatabaseProps<TSchema>): drizzle_orm_node_postgres0.NodePgDatabase<TSchema> & {
15
- $client: Pool;
16
- };
17
- type DatabaseClient<TSchema extends TDatabaseSchema> = ReturnType<typeof initDatabase<TSchema>>;
18
- //#endregion
19
- export { DatabaseClient, initDatabase };
20
- //# sourceMappingURL=init.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"init.d.mts","names":[],"sources":["../../../../src/modules/config/db/init.ts"],"mappings":";;;;;;KAMK,iBAAA,iBAAkC,eAAA;EACrC,MAAA,EAAQ,OAAA;EACR,IAAA,EAAM,IAAA;AAAA;AAAA,iBAGQ,YAAA,iBAA6B,eAAA,CAAA,CAAA;EAC3C,MAAA;EACA;AAAA,GACC,iBAAA,CAAkB,OAAA,IAAQ,0BAAA,CAAA,cAAA,CAAA,OAAA;;;KAIjB,cAAA,iBAA+B,eAAA,IAAmB,UAAA,QACrD,YAAA,CAAa,OAAA"}
@@ -1,15 +0,0 @@
1
- import "server-cli-only";
2
- import { drizzle } from "drizzle-orm/node-postgres";
3
-
4
- //#region src/modules/config/db/init.ts
5
- function initDatabase({ schema, pool }) {
6
- return drizzle({
7
- client: pool,
8
- schema,
9
- casing: "snake_case"
10
- });
11
- }
12
-
13
- //#endregion
14
- export { initDatabase };
15
- //# sourceMappingURL=init.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"init.mjs","names":[],"sources":["../../../../src/modules/config/db/init.ts"],"sourcesContent":["import \"server-cli-only\";\n\nimport { drizzle } from \"drizzle-orm/node-postgres\";\nimport type { Pool } from \"pg\";\nimport type { TDatabaseSchema } from \"./types\";\n\ntype InitDatabaseProps<TSchema extends TDatabaseSchema> = {\n schema: TSchema;\n pool: Pool;\n};\n\nexport function initDatabase<TSchema extends TDatabaseSchema>({\n schema,\n pool,\n}: InitDatabaseProps<TSchema>) {\n return drizzle({ client: pool, schema, casing: \"snake_case\" });\n}\n\nexport type DatabaseClient<TSchema extends TDatabaseSchema> = ReturnType<\n typeof initDatabase<TSchema>\n>;\n"],"mappings":";;;;AAWA,SAAgB,aAA8C,EAC5D,QACA,QAC6B;AAC7B,QAAO,QAAQ;EAAE,QAAQ;EAAM;EAAQ,QAAQ;EAAc,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../../../../src/modules/config/db/types.ts"],"mappings":";KAAY,eAAA,GAAkB,MAAA"}
@@ -1,12 +0,0 @@
1
- import "server-cli-only";
2
- import { Resend } from "resend";
3
-
4
- //#region src/modules/config/providers/email.d.ts
5
- type InitEmailProviderProps = {
6
- key: string;
7
- };
8
- declare function initEmailProvider(props: InitEmailProviderProps): Resend;
9
- type EmailClient = ReturnType<typeof initEmailProvider>;
10
- //#endregion
11
- export { EmailClient, initEmailProvider };
12
- //# sourceMappingURL=email.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"email.d.mts","names":[],"sources":["../../../../src/modules/config/providers/email.ts"],"mappings":";;;;KAIK,sBAAA;EACH,GAAA;AAAA;AAAA,iBAGc,iBAAA,CAAkB,KAAA,EAAO,sBAAA,GAAsB,MAAA;AAAA,KAInD,WAAA,GAAc,UAAA,QAAkB,iBAAA"}
@@ -1,11 +0,0 @@
1
- import "server-cli-only";
2
- import { Resend } from "resend";
3
-
4
- //#region src/modules/config/providers/email.ts
5
- function initEmailProvider(props) {
6
- return new Resend(props.key);
7
- }
8
-
9
- //#endregion
10
- export { initEmailProvider };
11
- //# sourceMappingURL=email.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"email.mjs","names":[],"sources":["../../../../src/modules/config/providers/email.ts"],"sourcesContent":["import \"server-cli-only\";\n\nimport { Resend } from \"resend\";\n\ntype InitEmailProviderProps = {\n key: string;\n};\n\nexport function initEmailProvider(props: InitEmailProviderProps) {\n return new Resend(props.key);\n}\n\nexport type EmailClient = ReturnType<typeof initEmailProvider>;\n"],"mappings":";;;;AAQA,SAAgB,kBAAkB,OAA+B;AAC/D,QAAO,IAAI,OAAO,MAAM,IAAI"}
@@ -1,17 +0,0 @@
1
- import { ParseFilter } from "../../data-tables/lib/filters/parsers.mjs";
2
- import z from "zod";
3
-
4
- //#region src/modules/storage/config/filters.d.ts
5
- declare const nodesTableFilters: {
6
- types: ParseFilter<z.ZodArray<z.ZodEnum<{
7
- file: "file";
8
- folder: "folder";
9
- }>>>;
10
- nodeIds: ParseFilter<z.ZodArray<z.ZodString>>;
11
- isDeleted: ParseFilter<z.ZodBoolean>;
12
- isOrphaned: ParseFilter<z.ZodBoolean>;
13
- hidden: ParseFilter<z.ZodBoolean>;
14
- };
15
- //#endregion
16
- export { nodesTableFilters };
17
- //# sourceMappingURL=filters.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"filters.d.mts","names":[],"sources":["../../../../src/modules/storage/config/filters.ts"],"mappings":";;;;cAKa,iBAAA"}
@@ -1,17 +0,0 @@
1
- import { createTableFilters } from "../../data-tables/lib/filters/config.mjs";
2
- import { parseFilterArray, parseFilterBoolean } from "../../data-tables/lib/filters/parsers.mjs";
3
- import { nodeTypeEnum } from "../lib/schema.mjs";
4
- import z from "zod";
5
-
6
- //#region src/modules/storage/config/filters.ts
7
- const nodesTableFilters = createTableFilters({
8
- types: parseFilterArray(z.array(z.enum(nodeTypeEnum.enumValues))),
9
- nodeIds: parseFilterArray(z.array(z.string())),
10
- isDeleted: parseFilterBoolean(z.boolean()),
11
- isOrphaned: parseFilterBoolean(z.boolean()),
12
- hidden: parseFilterBoolean(z.boolean())
13
- });
14
-
15
- //#endregion
16
- export { nodesTableFilters };
17
- //# sourceMappingURL=filters.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"filters.mjs","names":[],"sources":["../../../../src/modules/storage/config/filters.ts"],"sourcesContent":["import z from \"zod\";\nimport { createTableFilters } from \"@/modules/data-tables/lib/filters/config\";\nimport { parseFilterArray, parseFilterBoolean } from \"@/modules/data-tables/lib/filters/parsers\";\nimport { nodeTypeEnum } from \"../lib/schema\";\n\nexport const nodesTableFilters = createTableFilters({\n types: parseFilterArray(z.array(z.enum(nodeTypeEnum.enumValues))),\n nodeIds: parseFilterArray(z.array(z.string())),\n isDeleted: parseFilterBoolean(z.boolean()),\n isOrphaned: parseFilterBoolean(z.boolean()),\n hidden: parseFilterBoolean(z.boolean()),\n});\n"],"mappings":";;;;;;AAKA,MAAa,oBAAoB,mBAAmB;CAClD,OAAO,iBAAiB,EAAE,MAAM,EAAE,KAAK,aAAa,WAAW,CAAC,CAAC;CACjE,SAAS,iBAAiB,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;CAC9C,WAAW,mBAAmB,EAAE,SAAS,CAAC;CAC1C,YAAY,mBAAmB,EAAE,SAAS,CAAC;CAC3C,QAAQ,mBAAmB,EAAE,SAAS,CAAC;CACxC,CAAC"}
@@ -1,11 +0,0 @@
1
- import { TDatabaseSchema } from "../../config/db/types.mjs";
2
- import { StorageService, StorageServiceConfig } from "./service.server.mjs";
3
- import "../../../config.mjs";
4
- import "server-cli-only";
5
-
6
- //#region src/modules/storage/lib/create-client.server.d.ts
7
- declare function createStorageClient<TSchema extends TDatabaseSchema>(props: StorageServiceConfig<TSchema>): StorageService<TSchema>;
8
- type StorageClient<TSchema extends TDatabaseSchema> = ReturnType<typeof createStorageClient<TSchema>>;
9
- //#endregion
10
- export { StorageClient, createStorageClient };
11
- //# sourceMappingURL=create-client.server.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-client.server.d.mts","names":[],"sources":["../../../../src/modules/storage/lib/create-client.server.ts"],"mappings":";;;;;;iBAKgB,mBAAA,iBAAoC,eAAA,CAAA,CAClD,KAAA,EAAO,oBAAA,CAAqB,OAAA,IAAQ,cAAA,CAAA,OAAA;AAAA,KAK1B,aAAA,iBAA8B,eAAA,IAAmB,UAAA,QACpD,mBAAA,CAAoB,OAAA"}
@@ -1,11 +0,0 @@
1
- import { StorageService } from "./service.server.mjs";
2
- import "server-cli-only";
3
-
4
- //#region src/modules/storage/lib/create-client.server.ts
5
- function createStorageClient(props) {
6
- return new StorageService(props);
7
- }
8
-
9
- //#endregion
10
- export { createStorageClient };
11
- //# sourceMappingURL=create-client.server.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-client.server.mjs","names":[],"sources":["../../../../src/modules/storage/lib/create-client.server.ts"],"sourcesContent":["import \"server-cli-only\";\n\nimport type { TDatabaseSchema } from \"@/modules/config/entry\";\nimport { StorageService, type StorageServiceConfig } from \"./service.server\";\n\nexport function createStorageClient<TSchema extends TDatabaseSchema>(\n props: StorageServiceConfig<TSchema>,\n) {\n return new StorageService(props);\n}\n\nexport type StorageClient<TSchema extends TDatabaseSchema> = ReturnType<\n typeof createStorageClient<TSchema>\n>;\n"],"mappings":";;;;AAKA,SAAgB,oBACd,OACA;AACA,QAAO,IAAI,eAAe,MAAM"}
@@ -1,56 +0,0 @@
1
- import { PresignFileSchema, SelectNodeSchema, UpdateNodeSchema } from "./validators.mjs";
2
- import { BulkActionSchema } from "../../router/lib/validators.mjs";
3
- import "../../../router.mjs";
4
-
5
- //#region src/modules/storage/lib/create-upload.client.d.ts
6
- /**
7
- * Upload request
8
- */
9
- type PrepareUploadInput = Omit<UploadFileRequest, "id" | "name" | "size" | "contentType">;
10
- type UploadFileRequest = PresignFileSchema & {
11
- file: File;
12
- };
13
- type UploadHooks = {
14
- beforePresign?: (input: UploadFileRequest) => Promise<void> | void;
15
- afterPresign?: (presignResult: {
16
- id: string;
17
- presignedUrl: string;
18
- }) => Promise<void> | void;
19
- beforeConfirm?: (presignResult: {
20
- id: string;
21
- presignedUrl: string;
22
- }) => Promise<void> | void;
23
- afterConfirm?: (node: SelectNodeSchema) => Promise<void> | void;
24
- };
25
- /**
26
- * Upload client
27
- */
28
- type UploadClient = {
29
- prepareUpload: (input: PrepareUploadInput) => UploadFileRequest;
30
- upload: (input: UploadFileRequest, hooks?: UploadHooks) => Promise<SelectNodeSchema>;
31
- deleteFiles: (ids: string[]) => Promise<void>;
32
- updateNode: (id: string, data: UpdateNodeSchema) => Promise<SelectNodeSchema>;
33
- };
34
- /**
35
- * Create upload client
36
- */
37
- type CreateUploadClientProps = {
38
- endpoints: {
39
- presign: (input: PresignFileSchema) => Promise<{
40
- id: string;
41
- presignedUrl: string;
42
- }>;
43
- confirm: (input: {
44
- id: string;
45
- }) => Promise<SelectNodeSchema>;
46
- deleteNodes: (input: BulkActionSchema) => Promise<void>;
47
- updateNode: (input: {
48
- id: string;
49
- data: UpdateNodeSchema;
50
- }) => Promise<SelectNodeSchema>;
51
- };
52
- };
53
- declare function createUploadClient(props: CreateUploadClientProps): UploadClient;
54
- //#endregion
55
- export { PrepareUploadInput, UploadClient, UploadFileRequest, UploadHooks, createUploadClient };
56
- //# sourceMappingURL=create-upload.client.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-upload.client.d.mts","names":[],"sources":["../../../../src/modules/storage/lib/create-upload.client.ts"],"mappings":";;;;;;;;KAOY,kBAAA,GAAqB,IAAA,CAAK,iBAAA;AAAA,KAC1B,iBAAA,GAAoB,iBAAA;EAAsB,IAAA,EAAM,IAAA;AAAA;AAAA,KAChD,WAAA;EACV,aAAA,IAAiB,KAAA,EAAO,iBAAA,KAAsB,OAAA;EAC9C,YAAA,IAAgB,aAAA;IAAiB,EAAA;IAAY,YAAA;EAAA,MAA2B,OAAA;EACxE,aAAA,IAAiB,aAAA;IAAiB,EAAA;IAAY,YAAA;EAAA,MAA2B,OAAA;EACzE,YAAA,IAAgB,IAAA,EAAM,gBAAA,KAAqB,OAAA;AAAA;;;;KAMjC,YAAA;EACV,aAAA,GAAgB,KAAA,EAAO,kBAAA,KAAuB,iBAAA;EAC9C,MAAA,GAAS,KAAA,EAAO,iBAAA,EAAmB,KAAA,GAAQ,WAAA,KAAgB,OAAA,CAAQ,gBAAA;EACnE,WAAA,GAAc,GAAA,eAAkB,OAAA;EAChC,UAAA,GAAa,EAAA,UAAY,IAAA,EAAM,gBAAA,KAAqB,OAAA,CAAQ,gBAAA;AAAA;;;;KAMzD,uBAAA;EACH,SAAA;IACE,OAAA,GAAU,KAAA,EAAO,iBAAA,KAAsB,OAAA;MAAU,EAAA;MAAY,YAAA;IAAA;IAC7D,OAAA,GAAU,KAAA;MAAS,EAAA;IAAA,MAAiB,OAAA,CAAQ,gBAAA;IAC5C,WAAA,GAAc,KAAA,EAAO,gBAAA,KAAqB,OAAA;IAC1C,UAAA,GAAa,KAAA;MAAS,EAAA;MAAY,IAAA,EAAM,gBAAA;IAAA,MAAuB,OAAA,CAAQ,gBAAA;EAAA;AAAA;AAAA,iBAI3D,kBAAA,CAAmB,KAAA,EAAO,uBAAA,GAA0B,YAAA"}
@@ -1,98 +0,0 @@
1
- import { generateDefaultUUID } from "../../config/db/helpers.mjs";
2
-
3
- //#region src/modules/storage/lib/create-upload.client.ts
4
- function createUploadClient(props) {
5
- /**
6
- * Create input schema for the upload method
7
- * @param {PrepareUploadInput} input
8
- * @returns {UploadFileRequest}
9
- */
10
- function prepareUpload(input) {
11
- return {
12
- ...input,
13
- id: generateDefaultUUID(),
14
- name: input.file.name,
15
- size: input.file.size,
16
- contentType: input.file.type
17
- };
18
- }
19
- /**
20
- * Upload file to the server
21
- * @param {UploadFileRequest} input
22
- * @returns {Promise<SelectNodeSchema>}
23
- */
24
- async function upload(input, hooks) {
25
- try {
26
- /**
27
- * Presign
28
- */
29
- await hooks?.beforePresign?.(input);
30
- const presignResult = await props.endpoints.presign(input);
31
- await hooks?.afterPresign?.(presignResult);
32
- /**
33
- * Upload the file
34
- */
35
- const uploadResponse = await fetch(presignResult.presignedUrl, {
36
- method: "PUT",
37
- headers: { "Content-Type": input.file.type },
38
- body: input.file
39
- });
40
- if (!uploadResponse.ok) {
41
- const message = await uploadResponse.text();
42
- throw new Error(`Upload failed: ${message}`);
43
- }
44
- /**
45
- * Confirm
46
- */
47
- await hooks?.beforeConfirm?.(presignResult);
48
- const node = await props.endpoints.confirm({ id: presignResult.id });
49
- await hooks?.afterConfirm?.(node);
50
- /**
51
- * Return
52
- */
53
- return node;
54
- } catch (err) {
55
- console.error("Upload error: ", err);
56
- /**
57
- * Delete if upload failed
58
- * */
59
- try {
60
- await deleteFiles([input.id]);
61
- } catch (cleanupErr) {
62
- console.error("Cleanup delete failed:", cleanupErr);
63
- }
64
- throw err;
65
- }
66
- }
67
- /**
68
- * Delete files
69
- * @param {string[]} ids
70
- */
71
- async function deleteFiles(ids) {
72
- await props.endpoints.deleteNodes({ ids });
73
- }
74
- /**
75
- * Update node
76
- * @param {string} id
77
- * @param {UpdateNodeSchema} data
78
- */
79
- async function updateNode(id, data) {
80
- return props.endpoints.updateNode({
81
- id,
82
- data
83
- });
84
- }
85
- /**
86
- * Upload client
87
- */
88
- return {
89
- prepareUpload,
90
- upload,
91
- deleteFiles,
92
- updateNode
93
- };
94
- }
95
-
96
- //#endregion
97
- export { createUploadClient };
98
- //# sourceMappingURL=create-upload.client.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-upload.client.mjs","names":[],"sources":["../../../../src/modules/storage/lib/create-upload.client.ts"],"sourcesContent":["import { generateDefaultUUID } from \"@/modules/config/entry\";\nimport type { BulkActionSchema } from \"@/modules/router/entry\";\nimport type { PresignFileSchema, SelectNodeSchema, UpdateNodeSchema } from \"./validators\";\n\n/**\n * Upload request\n */\nexport type PrepareUploadInput = Omit<UploadFileRequest, \"id\" | \"name\" | \"size\" | \"contentType\">;\nexport type UploadFileRequest = PresignFileSchema & { file: File };\nexport type UploadHooks = {\n beforePresign?: (input: UploadFileRequest) => Promise<void> | void;\n afterPresign?: (presignResult: { id: string; presignedUrl: string }) => Promise<void> | void;\n beforeConfirm?: (presignResult: { id: string; presignedUrl: string }) => Promise<void> | void;\n afterConfirm?: (node: SelectNodeSchema) => Promise<void> | void;\n};\n\n/**\n * Upload client\n */\nexport type UploadClient = {\n prepareUpload: (input: PrepareUploadInput) => UploadFileRequest;\n upload: (input: UploadFileRequest, hooks?: UploadHooks) => Promise<SelectNodeSchema>;\n deleteFiles: (ids: string[]) => Promise<void>;\n updateNode: (id: string, data: UpdateNodeSchema) => Promise<SelectNodeSchema>;\n};\n\n/**\n * Create upload client\n */\ntype CreateUploadClientProps = {\n endpoints: {\n presign: (input: PresignFileSchema) => Promise<{ id: string; presignedUrl: string }>;\n confirm: (input: { id: string }) => Promise<SelectNodeSchema>;\n deleteNodes: (input: BulkActionSchema) => Promise<void>;\n updateNode: (input: { id: string; data: UpdateNodeSchema }) => Promise<SelectNodeSchema>;\n };\n};\n\nexport function createUploadClient(props: CreateUploadClientProps): UploadClient {\n /**\n * Create input schema for the upload method\n * @param {PrepareUploadInput} input\n * @returns {UploadFileRequest}\n */\n function prepareUpload(input: PrepareUploadInput): UploadFileRequest {\n return {\n ...input,\n id: generateDefaultUUID(),\n name: input.file.name,\n size: input.file.size,\n contentType: input.file.type,\n };\n }\n\n /**\n * Upload file to the server\n * @param {UploadFileRequest} input\n * @returns {Promise<SelectNodeSchema>}\n */\n async function upload(input: UploadFileRequest, hooks?: UploadHooks): Promise<SelectNodeSchema> {\n try {\n /**\n * Presign\n */\n await hooks?.beforePresign?.(input);\n const presignResult = await props.endpoints.presign(input);\n await hooks?.afterPresign?.(presignResult);\n /**\n * Upload the file\n */\n const uploadResponse = await fetch(presignResult.presignedUrl, {\n method: \"PUT\",\n headers: { \"Content-Type\": input.file.type },\n body: input.file,\n });\n\n if (!uploadResponse.ok) {\n const message = await uploadResponse.text();\n throw new Error(`Upload failed: ${message}`);\n }\n\n /**\n * Confirm\n */\n await hooks?.beforeConfirm?.(presignResult);\n const node = await props.endpoints.confirm({ id: presignResult.id });\n await hooks?.afterConfirm?.(node);\n /**\n * Return\n */\n return node;\n } catch (err) {\n console.error(\"Upload error: \", err);\n\n /**\n * Delete if upload failed\n * */\n try {\n await deleteFiles([input.id]);\n } catch (cleanupErr) {\n console.error(\"Cleanup delete failed:\", cleanupErr);\n }\n\n throw err;\n }\n }\n\n /**\n * Delete files\n * @param {string[]} ids\n */\n async function deleteFiles(ids: string[]) {\n await props.endpoints.deleteNodes({ ids });\n }\n\n /**\n * Update node\n * @param {string} id\n * @param {UpdateNodeSchema} data\n */\n async function updateNode(id: string, data: UpdateNodeSchema) {\n return props.endpoints.updateNode({ id, data });\n }\n\n /**\n * Upload client\n */\n return {\n prepareUpload,\n upload,\n deleteFiles,\n updateNode,\n };\n}\n"],"mappings":";;;AAsCA,SAAgB,mBAAmB,OAA8C;;;;;;CAM/E,SAAS,cAAc,OAA8C;AACnE,SAAO;GACL,GAAG;GACH,IAAI,qBAAqB;GACzB,MAAM,MAAM,KAAK;GACjB,MAAM,MAAM,KAAK;GACjB,aAAa,MAAM,KAAK;GACzB;;;;;;;CAQH,eAAe,OAAO,OAA0B,OAAgD;AAC9F,MAAI;;;;AAIF,SAAM,OAAO,gBAAgB,MAAM;GACnC,MAAM,gBAAgB,MAAM,MAAM,UAAU,QAAQ,MAAM;AAC1D,SAAM,OAAO,eAAe,cAAc;;;;GAI1C,MAAM,iBAAiB,MAAM,MAAM,cAAc,cAAc;IAC7D,QAAQ;IACR,SAAS,EAAE,gBAAgB,MAAM,KAAK,MAAM;IAC5C,MAAM,MAAM;IACb,CAAC;AAEF,OAAI,CAAC,eAAe,IAAI;IACtB,MAAM,UAAU,MAAM,eAAe,MAAM;AAC3C,UAAM,IAAI,MAAM,kBAAkB,UAAU;;;;;AAM9C,SAAM,OAAO,gBAAgB,cAAc;GAC3C,MAAM,OAAO,MAAM,MAAM,UAAU,QAAQ,EAAE,IAAI,cAAc,IAAI,CAAC;AACpE,SAAM,OAAO,eAAe,KAAK;;;;AAIjC,UAAO;WACA,KAAK;AACZ,WAAQ,MAAM,kBAAkB,IAAI;;;;AAKpC,OAAI;AACF,UAAM,YAAY,CAAC,MAAM,GAAG,CAAC;YACtB,YAAY;AACnB,YAAQ,MAAM,0BAA0B,WAAW;;AAGrD,SAAM;;;;;;;CAQV,eAAe,YAAY,KAAe;AACxC,QAAM,MAAM,UAAU,YAAY,EAAE,KAAK,CAAC;;;;;;;CAQ5C,eAAe,WAAW,IAAY,MAAwB;AAC5D,SAAO,MAAM,UAAU,WAAW;GAAE;GAAI;GAAM,CAAC;;;;;AAMjD,QAAO;EACL;EACA;EACA;EACA;EACD"}
@@ -1,21 +0,0 @@
1
- import { DriveSchema } from "./schema.mjs";
2
- import { TulipContext } from "../../config/lib/context.mjs";
3
- import "../../../config.mjs";
4
- import "server-cli-only";
5
- import { NextRequest } from "next/server";
6
-
7
- //#region src/modules/storage/lib/proxy.server.d.ts
8
- type CreateDriveProxyRouteProps<TSchema extends DriveSchema> = {
9
- context: TulipContext<TSchema>;
10
- };
11
- /**
12
- * Create drive proxy route
13
- */
14
- declare function createDriveProxyRoute<TSchema extends DriveSchema>({
15
- context
16
- }: CreateDriveProxyRouteProps<TSchema>): {
17
- GET: (request: NextRequest) => Promise<Response>;
18
- };
19
- //#endregion
20
- export { createDriveProxyRoute };
21
- //# sourceMappingURL=proxy.server.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"proxy.server.d.mts","names":[],"sources":["../../../../src/modules/storage/lib/proxy.server.ts"],"mappings":";;;;;;;KASK,0BAAA,iBAA2C,WAAA;EAC9C,OAAA,EAAS,YAAA,CAAa,OAAA;AAAA;AAJ2B;;;AAAA,iBAUnC,qBAAA,iBAAsC,WAAA,CAAA,CAAA;EACpD;AAAA,GACC,0BAAA,CAA2B,OAAA;iBAIA,WAAA,KAAW,OAAA,CAAA,QAAA;AAAA"}
@@ -1,46 +0,0 @@
1
- import { getSession } from "../../auth/lib/helpers.server.mjs";
2
- import { nodes } from "./schema.mjs";
3
- import { getFileURLSchema } from "./validators.mjs";
4
- import "server-cli-only";
5
- import { eq } from "drizzle-orm";
6
- import { connection } from "next/server";
7
-
8
- //#region src/modules/storage/lib/proxy.server.ts
9
- /**
10
- * Create drive proxy route
11
- */
12
- function createDriveProxyRoute({ context }) {
13
- /**
14
- * GET: Drive node proxy
15
- */
16
- async function GET(request) {
17
- await connection();
18
- try {
19
- const searchParams = request.nextUrl.searchParams;
20
- const id = searchParams.get("id");
21
- if (!id) return Response.json("Missing id", { status: 400 });
22
- console.info("Proxying file: ", id);
23
- const [node] = await context.db.select().from(nodes).where(eq(nodes.id, id));
24
- if (!node) return Response.json("Bestand kon niet worden gevonden", { status: 404 });
25
- if (node.mode === "private") {
26
- if (!await getSession(context)) return Response.json("Unauthorized", { status: 401 });
27
- }
28
- const variant = searchParams.get("variant") ?? void 0;
29
- const disposition = searchParams.get("disposition") ?? void 0;
30
- const options = getFileURLSchema.parse({
31
- variant,
32
- disposition
33
- });
34
- const url = await context.storage.getSignedURL(node, options);
35
- return Response.redirect(url, 307);
36
- } catch (error) {
37
- console.error("error", error);
38
- return Response.json("Error", { status: 500 });
39
- }
40
- }
41
- return { GET };
42
- }
43
-
44
- //#endregion
45
- export { createDriveProxyRoute };
46
- //# sourceMappingURL=proxy.server.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"proxy.server.mjs","names":[],"sources":["../../../../src/modules/storage/lib/proxy.server.ts"],"sourcesContent":["import \"server-cli-only\";\n\nimport { eq } from \"drizzle-orm\";\nimport { connection, type NextRequest } from \"next/server\";\nimport { getSession } from \"@/modules/auth/entry.server\";\nimport type { TulipContext } from \"@/modules/config/entry\";\nimport { type DriveSchema, nodes } from \"./schema\";\nimport { getFileURLSchema } from \"./validators\";\n\ntype CreateDriveProxyRouteProps<TSchema extends DriveSchema> = {\n context: TulipContext<TSchema>;\n};\n\n/**\n * Create drive proxy route\n */\nexport function createDriveProxyRoute<TSchema extends DriveSchema>({\n context,\n}: CreateDriveProxyRouteProps<TSchema>) {\n /**\n * GET: Drive node proxy\n */\n async function GET(request: NextRequest) {\n // Make endpoint dynamic\n await connection();\n\n try {\n // Get the params\n const searchParams = request.nextUrl.searchParams;\n const id = searchParams.get(\"id\");\n if (!id) return Response.json(\"Missing id\", { status: 400 });\n\n console.info(\"Proxying file: \", id);\n\n // Get the node\n const [node] = await context.db.select().from(nodes).where(eq(nodes.id, id));\n if (!node) return Response.json(\"Bestand kon niet worden gevonden\", { status: 404 });\n\n // If the node is private check if the user is authenticated\n if (node.mode === \"private\") {\n const session = await getSession(context);\n if (!session) return Response.json(\"Unauthorized\", { status: 401 });\n }\n\n const variant = searchParams.get(\"variant\") ?? undefined;\n const disposition = searchParams.get(\"disposition\") ?? undefined;\n\n // Parse the options\n const options = getFileURLSchema.parse({ variant, disposition });\n\n // Get the file url\n const url = await context.storage.getSignedURL(node, options);\n\n // Return the file\n return Response.redirect(url, 307);\n } catch (error) {\n console.error(\"error\", error);\n return Response.json(\"Error\", { status: 500 });\n }\n }\n\n return { GET };\n}\n"],"mappings":";;;;;;;;;;;AAgBA,SAAgB,sBAAmD,EACjE,WACsC;;;;CAItC,eAAe,IAAI,SAAsB;AAEvC,QAAM,YAAY;AAElB,MAAI;GAEF,MAAM,eAAe,QAAQ,QAAQ;GACrC,MAAM,KAAK,aAAa,IAAI,KAAK;AACjC,OAAI,CAAC,GAAI,QAAO,SAAS,KAAK,cAAc,EAAE,QAAQ,KAAK,CAAC;AAE5D,WAAQ,KAAK,mBAAmB,GAAG;GAGnC,MAAM,CAAC,QAAQ,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,MAAM,CAAC,MAAM,GAAG,MAAM,IAAI,GAAG,CAAC;AAC5E,OAAI,CAAC,KAAM,QAAO,SAAS,KAAK,oCAAoC,EAAE,QAAQ,KAAK,CAAC;AAGpF,OAAI,KAAK,SAAS,WAEhB;QAAI,CADY,MAAM,WAAW,QAAQ,CAC3B,QAAO,SAAS,KAAK,gBAAgB,EAAE,QAAQ,KAAK,CAAC;;GAGrE,MAAM,UAAU,aAAa,IAAI,UAAU,IAAI;GAC/C,MAAM,cAAc,aAAa,IAAI,cAAc,IAAI;GAGvD,MAAM,UAAU,iBAAiB,MAAM;IAAE;IAAS;IAAa,CAAC;GAGhE,MAAM,MAAM,MAAM,QAAQ,QAAQ,aAAa,MAAM,QAAQ;AAG7D,UAAO,SAAS,SAAS,KAAK,IAAI;WAC3B,OAAO;AACd,WAAQ,MAAM,SAAS,MAAM;AAC7B,UAAO,SAAS,KAAK,SAAS,EAAE,QAAQ,KAAK,CAAC;;;AAIlD,QAAO,EAAE,KAAK"}