@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
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.mts","names":[],"sources":["../../../../src/modules/auth/handler/init.ts"],"mappings":";;;;;;;;;;;;;;cAca,gBAAA;AAAA,KAER,aAAA,iBAA8B,eAAA;EACjC,EAAA,EAAI,cAAA,CAAe,OAAA;EACnB,KAAA,EAAO,WAAA;EACP,MAAA,EAAQ,WAAA;EACR,EAAA,EAAI,UAAA,QAAkB,mBAAA;EACtB,KAAA,sBACoB,MAAA;AAAA;AAAA,iBAIN,QAAA,iBAAyB,eAAA,CAAA,CAAiB,KAAA,EAAO,aAAA,CAAc,OAAA,iBAAQ,IAAA;;;;;;;sBAAT,YAAA,CAAA,iBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8C5C,aAAA,GAAgB,UAAA,QAAkB,uBAAA;AAAA,KAClC,oBAAA,GAAuB,kBAAA,CAAmB,aAAA;AAAA,KAC1C,mBAAA,GAAsB,iBAAA,CAAkB,aAAA"}
@@ -0,0 +1,22 @@
1
+ import { confirmUploadInputSchema, presignUploadInputSchema, presignUploadOutputSchema, selectStorageAssetSchema } from "./validators.mjs";
2
+ import { initRPC } from "../../router/handler/init.server.mjs";
3
+ import { z as z$1 } from "zod";
4
+
5
+ //#region src/modules/storage/lib/procedures.server.ts
6
+ function createStorageProcedures() {
7
+ const { protectedProcedure } = initRPC();
8
+ return {
9
+ presign: protectedProcedure.input(presignUploadInputSchema).output(presignUploadOutputSchema).handler(async ({ context, input }) => context.storage.presignUpload(input)),
10
+ confirm: protectedProcedure.input(confirmUploadInputSchema).output(selectStorageAssetSchema).handler(async ({ context, input }) => context.storage.confirmUpload(input)),
11
+ deleteAsset: protectedProcedure.input(z$1.uuid()).output(selectStorageAssetSchema.nullable()).handler(async ({ context, input }) => context.storage.deleteAsset(input)),
12
+ deleteAssets: protectedProcedure.input(z$1.string().array()).output(z$1.array(selectStorageAssetSchema)).handler(async ({ context, input }) => context.storage.deleteAssets(input)),
13
+ restoreAsset: protectedProcedure.input(z$1.uuid()).output(selectStorageAssetSchema.nullable()).handler(async ({ context, input }) => context.storage.restoreAsset(input)),
14
+ restoreAssets: protectedProcedure.input(z$1.string().array()).output(z$1.array(selectStorageAssetSchema)).handler(async ({ context, input }) => context.storage.restoreAssets(input)),
15
+ purgeAsset: protectedProcedure.input(z$1.uuid()).output(selectStorageAssetSchema.nullable()).handler(async ({ context, input }) => context.storage.purgeAsset(input)),
16
+ purgeAssets: protectedProcedure.input(z$1.string().array()).output(z$1.array(selectStorageAssetSchema)).handler(async ({ context, input }) => context.storage.purgeAssets(input))
17
+ };
18
+ }
19
+
20
+ //#endregion
21
+ export { createStorageProcedures };
22
+ //# sourceMappingURL=procedures.server.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"procedures.server.mjs","names":["z"],"sources":["../../../../src/modules/storage/lib/procedures.server.ts"],"sourcesContent":["import type { InferRouterInputs, InferRouterOutputs } from \"@orpc/server\";\nimport { z } from \"zod\";\nimport type { TDatabaseSchema } from \"@/modules/config/db/types\";\nimport { initRPC } from \"@/modules/router/handler/init.server\";\nimport {\n confirmUploadInputSchema,\n presignUploadInputSchema,\n presignUploadOutputSchema,\n selectStorageAssetSchema,\n} from \"./validators\";\n\nexport function createStorageProcedures<TSchema extends TDatabaseSchema>() {\n const { protectedProcedure } = initRPC<TSchema>();\n\n return {\n presign: protectedProcedure\n .input(presignUploadInputSchema)\n .output(presignUploadOutputSchema)\n .handler(async ({ context, input }) => context.storage.presignUpload(input)),\n\n confirm: protectedProcedure\n .input(confirmUploadInputSchema)\n .output(selectStorageAssetSchema)\n .handler(async ({ context, input }) => context.storage.confirmUpload(input)),\n\n deleteAsset: protectedProcedure\n .input(z.uuid())\n .output(selectStorageAssetSchema.nullable())\n .handler(async ({ context, input }) => context.storage.deleteAsset(input)),\n\n deleteAssets: protectedProcedure\n .input(z.string().array())\n .output(z.array(selectStorageAssetSchema))\n .handler(async ({ context, input }) => context.storage.deleteAssets(input)),\n\n restoreAsset: protectedProcedure\n .input(z.uuid())\n .output(selectStorageAssetSchema.nullable())\n .handler(async ({ context, input }) => context.storage.restoreAsset(input)),\n\n restoreAssets: protectedProcedure\n .input(z.string().array())\n .output(z.array(selectStorageAssetSchema))\n .handler(async ({ context, input }) => context.storage.restoreAssets(input)),\n\n purgeAsset: protectedProcedure\n .input(z.uuid())\n .output(selectStorageAssetSchema.nullable())\n .handler(async ({ context, input }) => context.storage.purgeAsset(input)),\n\n purgeAssets: protectedProcedure\n .input(z.string().array())\n .output(z.array(selectStorageAssetSchema))\n .handler(async ({ context, input }) => context.storage.purgeAssets(input)),\n };\n}\n\nexport type StorageRouter = ReturnType<typeof createStorageProcedures>;\nexport type StorageRouterOutputs = InferRouterOutputs<StorageRouter>;\nexport type StorageRouterInputs = InferRouterInputs<StorageRouter>;\n"],"mappings":";;;;;AAWA,SAAgB,0BAA2D;CACzE,MAAM,EAAE,uBAAuB,SAAkB;AAEjD,QAAO;EACL,SAAS,mBACN,MAAM,yBAAyB,CAC/B,OAAO,0BAA0B,CACjC,QAAQ,OAAO,EAAE,SAAS,YAAY,QAAQ,QAAQ,cAAc,MAAM,CAAC;EAE9E,SAAS,mBACN,MAAM,yBAAyB,CAC/B,OAAO,yBAAyB,CAChC,QAAQ,OAAO,EAAE,SAAS,YAAY,QAAQ,QAAQ,cAAc,MAAM,CAAC;EAE9E,aAAa,mBACV,MAAMA,IAAE,MAAM,CAAC,CACf,OAAO,yBAAyB,UAAU,CAAC,CAC3C,QAAQ,OAAO,EAAE,SAAS,YAAY,QAAQ,QAAQ,YAAY,MAAM,CAAC;EAE5E,cAAc,mBACX,MAAMA,IAAE,QAAQ,CAAC,OAAO,CAAC,CACzB,OAAOA,IAAE,MAAM,yBAAyB,CAAC,CACzC,QAAQ,OAAO,EAAE,SAAS,YAAY,QAAQ,QAAQ,aAAa,MAAM,CAAC;EAE7E,cAAc,mBACX,MAAMA,IAAE,MAAM,CAAC,CACf,OAAO,yBAAyB,UAAU,CAAC,CAC3C,QAAQ,OAAO,EAAE,SAAS,YAAY,QAAQ,QAAQ,aAAa,MAAM,CAAC;EAE7E,eAAe,mBACZ,MAAMA,IAAE,QAAQ,CAAC,OAAO,CAAC,CACzB,OAAOA,IAAE,MAAM,yBAAyB,CAAC,CACzC,QAAQ,OAAO,EAAE,SAAS,YAAY,QAAQ,QAAQ,cAAc,MAAM,CAAC;EAE9E,YAAY,mBACT,MAAMA,IAAE,MAAM,CAAC,CACf,OAAO,yBAAyB,UAAU,CAAC,CAC3C,QAAQ,OAAO,EAAE,SAAS,YAAY,QAAQ,QAAQ,WAAW,MAAM,CAAC;EAE3E,aAAa,mBACV,MAAMA,IAAE,QAAQ,CAAC,OAAO,CAAC,CACzB,OAAOA,IAAE,MAAM,yBAAyB,CAAC,CACzC,QAAQ,OAAO,EAAE,SAAS,YAAY,QAAQ,QAAQ,YAAY,MAAM,CAAC;EAC7E"}
@@ -0,0 +1,41 @@
1
+ import { TulipContext } from "../../config/lib/context.mjs";
2
+ import { NextRequest } from "next/server";
3
+ import { TDatabaseSchema } from "@/modules/config/db/types";
4
+
5
+ //#region src/modules/storage/lib/router-handlers.server.d.ts
6
+ type RouteCtx = {
7
+ params: Promise<{
8
+ rest?: string[];
9
+ }>;
10
+ };
11
+ type CreateStorageRouteHandlerProps<TSchema extends TDatabaseSchema> = {
12
+ context: Pick<TulipContext<TSchema>, "auth" | "storage">;
13
+ };
14
+ /**
15
+ * Creates a catch-all storage route handler for `/api/storage/[[...rest]]`.
16
+ *
17
+ * Current support:
18
+ * - `GET /api/storage/files/:id`:
19
+ * resolves a storage asset, enforces visibility checks, and redirects
20
+ * to a short-lived signed read URL.
21
+ *
22
+ * Reserved for future extension:
23
+ * - `POST /api/storage/assets/presign`
24
+ * - `POST /api/storage/assets/confirm`
25
+ * - additional storage endpoints under the same catch-all route.
26
+ *
27
+ * @param props - Route handler dependencies (application context)
28
+ * @returns Next.js route handlers for GET, POST, PUT, PATCH, and DELETE
29
+ */
30
+ declare function createStorageRouteHandler<TSchema extends TDatabaseSchema>({
31
+ context
32
+ }: CreateStorageRouteHandlerProps<TSchema>): {
33
+ GET: (request: NextRequest, ctx: RouteCtx) => Promise<Response>;
34
+ POST: () => Promise<Response>;
35
+ PUT: () => Promise<Response>;
36
+ PATCH: () => Promise<Response>;
37
+ DELETE: () => Promise<Response>;
38
+ };
39
+ //#endregion
40
+ export { createStorageRouteHandler };
41
+ //# sourceMappingURL=router-handlers.server.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router-handlers.server.d.mts","names":[],"sources":["../../../../src/modules/storage/lib/router-handlers.server.ts"],"mappings":";;;;;KAQK,QAAA;EACH,MAAA,EAAQ,OAAA;IAAU,IAAA;EAAA;AAAA;AAAA,KAGf,8BAAA,iBAA+C,eAAA;EAClD,OAAA,EAAS,IAAA,CAAK,YAAA,CAAa,OAAA;AAAA;;;;AAJL;;;;;;;;;;;;;iBAwBR,yBAAA,iBAA0C,eAAA,CAAA,CAAA;EACxD;AAAA,GACC,8BAAA,CAA+B,OAAA;iBAUJ,WAAA,EAAW,GAAA,EAAO,QAAA,KAAQ,OAAA,CAAA,QAAA"}
@@ -0,0 +1,124 @@
1
+ import { ServerError } from "../../router/lib/error.server.mjs";
2
+ import { getAssetURLSchema } from "./validators.mjs";
3
+ import { getSession } from "../../auth/lib/helpers.server.mjs";
4
+ import z from "zod";
5
+ import { connection } from "next/server";
6
+
7
+ //#region src/modules/storage/lib/router-handlers.server.ts
8
+ /**
9
+ * Creates a catch-all storage route handler for `/api/storage/[[...rest]]`.
10
+ *
11
+ * Current support:
12
+ * - `GET /api/storage/files/:id`:
13
+ * resolves a storage asset, enforces visibility checks, and redirects
14
+ * to a short-lived signed read URL.
15
+ *
16
+ * Reserved for future extension:
17
+ * - `POST /api/storage/assets/presign`
18
+ * - `POST /api/storage/assets/confirm`
19
+ * - additional storage endpoints under the same catch-all route.
20
+ *
21
+ * @param props - Route handler dependencies (application context)
22
+ * @returns Next.js route handlers for GET, POST, PUT, PATCH, and DELETE
23
+ */
24
+ function createStorageRouteHandler({ context }) {
25
+ /**
26
+ * GET /api/storage/[[...rest]]
27
+ *
28
+ * Current route support:
29
+ * - /api/storage/files/:id
30
+ *
31
+ * The file route resolves an asset by id, enforces visibility rules,
32
+ * and redirects to a short-lived signed object URL.
33
+ */
34
+ async function GET(request, ctx) {
35
+ const { rest = [] } = await ctx.params;
36
+ /**
37
+ * Proxy file request
38
+ * GET /api/storage/files/:id
39
+ */
40
+ if (rest[0] === "files") {
41
+ const id = rest[1];
42
+ if (!id) return Response.json({ error: {
43
+ code: "BAD_REQUEST",
44
+ message: "Missing id"
45
+ } }, { status: 400 });
46
+ console.info("Proxying file: ", id);
47
+ try {
48
+ const asset = await context.storage.getAssetById(id);
49
+ if (!asset) return Response.json({ error: {
50
+ code: "NOT_FOUND",
51
+ message: "Asset not found"
52
+ } }, { status: 404 });
53
+ if (asset.visibility === "private") {
54
+ if (!await getSession(context)) return Response.json({ error: {
55
+ code: "UNAUTHORIZED",
56
+ message: "Unauthorized"
57
+ } }, { status: 401 });
58
+ }
59
+ const disposition = request.nextUrl.searchParams.get("disposition") ?? void 0;
60
+ const options = getAssetURLSchema.parse({ disposition });
61
+ const url = await context.storage.getObjectURL(asset.id, options);
62
+ return Response.redirect(url, 307);
63
+ } catch (error) {
64
+ if (error instanceof z.ZodError) return Response.json({ error: {
65
+ code: "BAD_REQUEST",
66
+ message: "Invalid request input"
67
+ } }, { status: 400 });
68
+ if (error instanceof ServerError) {
69
+ const code = error.code;
70
+ if (code === "BAD_REQUEST") return Response.json({ error: {
71
+ code: "BAD_REQUEST",
72
+ message: error.message
73
+ } }, { status: 400 });
74
+ if (code === "NOT_FOUND") return Response.json({ error: {
75
+ code: "NOT_FOUND",
76
+ message: error.message
77
+ } }, { status: 404 });
78
+ if (code === "UNAUTHORIZED") return Response.json({ error: {
79
+ code: "UNAUTHORIZED",
80
+ message: error.message
81
+ } }, { status: 401 });
82
+ }
83
+ if (error instanceof Error && error.message === "Storage asset not found") return Response.json({ error: {
84
+ code: "NOT_FOUND",
85
+ message: "Asset not found"
86
+ } }, { status: 404 });
87
+ console.error("Storage route error", error);
88
+ return Response.json({ error: {
89
+ code: "INTERNAL_SERVER_ERROR",
90
+ message: "Something went wrong"
91
+ } }, { status: 500 });
92
+ }
93
+ }
94
+ return Response.json({ error: {
95
+ code: "NOT_FOUND",
96
+ message: "Route not found"
97
+ } }, { status: 404 });
98
+ }
99
+ /**
100
+ * POST, PUT, PATCH, DELETE /api/storage/[[...rest]]
101
+ *
102
+ * Reserved for future extension, for example:
103
+ * - POST /api/storage/assets/presign
104
+ * - POST /api/storage/assets/confirm
105
+ */
106
+ async function POST() {
107
+ await connection();
108
+ return Response.json({ error: {
109
+ code: "NOT_FOUND",
110
+ message: "Route not found"
111
+ } }, { status: 404 });
112
+ }
113
+ return {
114
+ GET,
115
+ POST,
116
+ PUT: POST,
117
+ PATCH: POST,
118
+ DELETE: POST
119
+ };
120
+ }
121
+
122
+ //#endregion
123
+ export { createStorageRouteHandler };
124
+ //# sourceMappingURL=router-handlers.server.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router-handlers.server.mjs","names":[],"sources":["../../../../src/modules/storage/lib/router-handlers.server.ts"],"sourcesContent":["import { connection, type NextRequest } from \"next/server\";\nimport z from \"zod\";\nimport { getSession } from \"@/modules/auth/lib/helpers.server\";\nimport type { TDatabaseSchema } from \"@/modules/config/db/types\";\nimport type { TulipContext } from \"@/modules/config/lib/context\";\nimport { ServerError } from \"@/modules/router/lib/error.server\";\nimport { getAssetURLSchema } from \"../entry\";\n\ntype RouteCtx = {\n params: Promise<{ rest?: string[] }>;\n};\n\ntype CreateStorageRouteHandlerProps<TSchema extends TDatabaseSchema> = {\n context: Pick<TulipContext<TSchema>, \"auth\" | \"storage\">;\n};\n\n/**\n * Creates a catch-all storage route handler for `/api/storage/[[...rest]]`.\n *\n * Current support:\n * - `GET /api/storage/files/:id`:\n * resolves a storage asset, enforces visibility checks, and redirects\n * to a short-lived signed read URL.\n *\n * Reserved for future extension:\n * - `POST /api/storage/assets/presign`\n * - `POST /api/storage/assets/confirm`\n * - additional storage endpoints under the same catch-all route.\n *\n * @param props - Route handler dependencies (application context)\n * @returns Next.js route handlers for GET, POST, PUT, PATCH, and DELETE\n */\n\nexport function createStorageRouteHandler<TSchema extends TDatabaseSchema>({\n context,\n}: CreateStorageRouteHandlerProps<TSchema>) {\n /**\n * GET /api/storage/[[...rest]]\n *\n * Current route support:\n * - /api/storage/files/:id\n *\n * The file route resolves an asset by id, enforces visibility rules,\n * and redirects to a short-lived signed object URL.\n */\n async function GET(request: NextRequest, ctx: RouteCtx) {\n // Get the params\n const { rest = [] } = await ctx.params;\n const resource = rest[0];\n\n /**\n * Proxy file request\n * GET /api/storage/files/:id\n */\n if (resource === \"files\") {\n const id = rest[1];\n\n // Guard required path segment: /api/storage/files/:id\n if (!id) {\n return Response.json(\n { error: { code: \"BAD_REQUEST\", message: \"Missing id\" } },\n { status: 400 },\n );\n }\n\n console.info(\"Proxying file: \", id);\n\n try {\n // Resolve storage asset record by id\n const asset = await context.storage.getAssetById(id);\n\n if (!asset) {\n return Response.json(\n { error: { code: \"NOT_FOUND\", message: \"Asset not found\" } },\n { status: 404 },\n );\n }\n\n // Enforce private visibility with session auth\n if (asset.visibility === \"private\") {\n const session = await getSession(context);\n if (!session) {\n return Response.json(\n { error: { code: \"UNAUTHORIZED\", message: \"Unauthorized\" } },\n { status: 401 },\n );\n }\n }\n\n // Handle searchParams for disposition\n const searchParams = request.nextUrl.searchParams;\n const disposition = searchParams.get(\"disposition\") ?? undefined;\n\n // Parse the options\n const options = getAssetURLSchema.parse({ disposition });\n\n // Resolve signed read URL and redirect to object storage\n const url = await context.storage.getObjectURL(asset.id, options);\n\n // Return the file\n return Response.redirect(url, 307);\n } catch (error) {\n if (error instanceof z.ZodError) {\n return Response.json(\n { error: { code: \"BAD_REQUEST\", message: \"Invalid request input\" } },\n { status: 400 },\n );\n }\n\n if (error instanceof ServerError) {\n const code = error.code;\n\n if (code === \"BAD_REQUEST\") {\n return Response.json(\n { error: { code: \"BAD_REQUEST\", message: error.message } },\n { status: 400 },\n );\n }\n\n if (code === \"NOT_FOUND\") {\n return Response.json(\n { error: { code: \"NOT_FOUND\", message: error.message } },\n { status: 404 },\n );\n }\n\n if (code === \"UNAUTHORIZED\") {\n return Response.json(\n { error: { code: \"UNAUTHORIZED\", message: error.message } },\n { status: 401 },\n );\n }\n }\n\n if (error instanceof Error && error.message === \"Storage asset not found\") {\n return Response.json(\n { error: { code: \"NOT_FOUND\", message: \"Asset not found\" } },\n { status: 404 },\n );\n }\n\n console.error(\"Storage route error\", error);\n\n return Response.json(\n { error: { code: \"INTERNAL_SERVER_ERROR\", message: \"Something went wrong\" } },\n { status: 500 },\n );\n }\n }\n\n return Response.json(\n { error: { code: \"NOT_FOUND\", message: \"Route not found\" } },\n { status: 404 },\n );\n }\n\n /**\n * POST, PUT, PATCH, DELETE /api/storage/[[...rest]]\n *\n * Reserved for future extension, for example:\n * - POST /api/storage/assets/presign\n * - POST /api/storage/assets/confirm\n */\n async function POST() {\n // Make endpoint dynamic\n await connection();\n\n // future:\n // POST /api/storage/assets/presign\n // POST /api/storage/assets/confirm\n return Response.json(\n { error: { code: \"NOT_FOUND\", message: \"Route not found\" } },\n { status: 404 },\n );\n }\n\n return { GET, POST, PUT: POST, PATCH: POST, DELETE: POST };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAiCA,SAAgB,0BAA2D,EACzE,WAC0C;;;;;;;;;;CAU1C,eAAe,IAAI,SAAsB,KAAe;EAEtD,MAAM,EAAE,OAAO,EAAE,KAAK,MAAM,IAAI;;;;;AAOhC,MANiB,KAAK,OAML,SAAS;GACxB,MAAM,KAAK,KAAK;AAGhB,OAAI,CAAC,GACH,QAAO,SAAS,KACd,EAAE,OAAO;IAAE,MAAM;IAAe,SAAS;IAAc,EAAE,EACzD,EAAE,QAAQ,KAAK,CAChB;AAGH,WAAQ,KAAK,mBAAmB,GAAG;AAEnC,OAAI;IAEF,MAAM,QAAQ,MAAM,Q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