@superinterface/server 1.0.25 → 1.0.27

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 (266) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +2 -2
  3. package/.next/cache/.tsbuildinfo +1 -1
  4. package/.next/cache/eslint/.cache_btwyo7 +1 -1
  5. package/.next/fallback-build-manifest.json +2 -2
  6. package/.next/server/app/_not-found.html +1 -1
  7. package/.next/server/app/_not-found.rsc +1 -1
  8. package/.next/server/app/api/api-keys/[apiKeyId]/route.js +1 -1
  9. package/.next/server/app/api/api-keys/[apiKeyId]/route.js.nft.json +1 -1
  10. package/.next/server/app/api/api-keys/route.js +1 -1
  11. package/.next/server/app/api/api-keys/route.js.nft.json +1 -1
  12. package/.next/server/app/api/assistants/[assistantId]/functions/[functionId]/route.js +1 -1
  13. package/.next/server/app/api/assistants/[assistantId]/functions/[functionId]/route.js.nft.json +1 -1
  14. package/.next/server/app/api/assistants/[assistantId]/functions/route.js +1 -1
  15. package/.next/server/app/api/assistants/[assistantId]/functions/route.js.nft.json +1 -1
  16. package/.next/server/app/api/assistants/[assistantId]/initial-messages/route.js +1 -1
  17. package/.next/server/app/api/assistants/[assistantId]/initial-messages/route.js.nft.json +1 -1
  18. package/.next/server/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.js +1 -1
  19. package/.next/server/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.js.nft.json +1 -1
  20. package/.next/server/app/api/assistants/[assistantId]/mcp-servers/route.js +1 -1
  21. package/.next/server/app/api/assistants/[assistantId]/mcp-servers/route.js.nft.json +1 -1
  22. package/.next/server/app/api/assistants/[assistantId]/route.js +1 -1
  23. package/.next/server/app/api/assistants/[assistantId]/route.js.nft.json +1 -1
  24. package/.next/server/app/api/assistants/route.js +1 -1
  25. package/.next/server/app/api/assistants/route.js.nft.json +1 -1
  26. package/.next/server/app/api/files/[fileId]/contents/route.js +1 -1
  27. package/.next/server/app/api/files/[fileId]/contents/route.js.nft.json +1 -1
  28. package/.next/server/app/api/files/route.js +1 -1
  29. package/.next/server/app/api/files/route.js.nft.json +1 -1
  30. package/.next/server/app/api/messages/route.js +1 -1
  31. package/.next/server/app/api/messages/route.js.nft.json +1 -1
  32. package/.next/server/app/api/providers/[modelProviderId]/assistants/route.js +1 -1
  33. package/.next/server/app/api/providers/[modelProviderId]/assistants/route.js.nft.json +1 -1
  34. package/.next/server/app/api/providers/[modelProviderId]/models/route.js +1 -1
  35. package/.next/server/app/api/providers/[modelProviderId]/models/route.js.nft.json +1 -1
  36. package/.next/server/app/api/providers/[modelProviderId]/route.js +1 -1
  37. package/.next/server/app/api/providers/[modelProviderId]/route.js.nft.json +1 -1
  38. package/.next/server/app/api/providers/route.js +1 -1
  39. package/.next/server/app/api/providers/route.js.nft.json +1 -1
  40. package/.next/server/app/api/tasks/[taskId]/route.js +1 -1
  41. package/.next/server/app/api/tasks/[taskId]/route.js.nft.json +1 -1
  42. package/.next/server/app/api/tasks/callback/route.js +1 -1
  43. package/.next/server/app/api/tasks/callback/route.js.nft.json +1 -1
  44. package/.next/server/app/api/tasks/route.js +1 -1
  45. package/.next/server/app/api/tasks/route.js.nft.json +1 -1
  46. package/.next/server/app/api/threads/runs/submit-client-tool-outputs/route.js +1 -1
  47. package/.next/server/app/api/threads/runs/submit-client-tool-outputs/route.js.nft.json +1 -1
  48. package/.next/server/app/api/workspaces/[workspaceId]/route.js +1 -1
  49. package/.next/server/app/api/workspaces/[workspaceId]/route.js.nft.json +1 -1
  50. package/.next/server/app/api/workspaces/route.js +1 -1
  51. package/.next/server/app/api/workspaces/route.js.nft.json +1 -1
  52. package/.next/server/app/index.html +1 -1
  53. package/.next/server/app/index.rsc +1 -1
  54. package/.next/server/chunks/[root-of-the-server]__0c1bc5ed._.js +1 -1
  55. package/.next/server/chunks/[root-of-the-server]__0c1bc5ed._.js.map +1 -1
  56. package/.next/server/chunks/[root-of-the-server]__25ee13bc._.js +1 -1
  57. package/.next/server/chunks/[root-of-the-server]__25ee13bc._.js.map +1 -1
  58. package/.next/server/chunks/[root-of-the-server]__2945c9e9._.js +1 -1
  59. package/.next/server/chunks/[root-of-the-server]__2945c9e9._.js.map +1 -1
  60. package/.next/server/chunks/[root-of-the-server]__29635e8e._.js +1 -1
  61. package/.next/server/chunks/[root-of-the-server]__29635e8e._.js.map +1 -1
  62. package/.next/server/chunks/[root-of-the-server]__315f084a._.js +1 -1
  63. package/.next/server/chunks/[root-of-the-server]__315f084a._.js.map +1 -1
  64. package/.next/server/chunks/[root-of-the-server]__40ab45eb._.js +1 -1
  65. package/.next/server/chunks/[root-of-the-server]__40ab45eb._.js.map +1 -1
  66. package/.next/server/chunks/[root-of-the-server]__441cee00._.js +1 -1
  67. package/.next/server/chunks/[root-of-the-server]__441cee00._.js.map +1 -1
  68. package/.next/server/chunks/[root-of-the-server]__464a4377._.js +1 -1
  69. package/.next/server/chunks/[root-of-the-server]__464a4377._.js.map +1 -1
  70. package/.next/server/chunks/[root-of-the-server]__47b17fad._.js +38 -0
  71. package/.next/server/chunks/[root-of-the-server]__47b17fad._.js.map +1 -0
  72. package/.next/server/chunks/[root-of-the-server]__4e536bc0._.js +1 -1
  73. package/.next/server/chunks/[root-of-the-server]__4e536bc0._.js.map +1 -1
  74. package/.next/server/chunks/[root-of-the-server]__583a7f1c._.js +1 -1
  75. package/.next/server/chunks/[root-of-the-server]__583a7f1c._.js.map +1 -1
  76. package/.next/server/chunks/[root-of-the-server]__5abf1160._.js +1 -1
  77. package/.next/server/chunks/[root-of-the-server]__5abf1160._.js.map +1 -1
  78. package/.next/server/chunks/[root-of-the-server]__5d09614a._.js +1 -1
  79. package/.next/server/chunks/[root-of-the-server]__5d09614a._.js.map +1 -1
  80. package/.next/server/chunks/[root-of-the-server]__62d958e7._.js +1 -1
  81. package/.next/server/chunks/[root-of-the-server]__62d958e7._.js.map +1 -1
  82. package/.next/server/chunks/[root-of-the-server]__676affb1._.js +1 -1
  83. package/.next/server/chunks/[root-of-the-server]__676affb1._.js.map +1 -1
  84. package/.next/server/chunks/[root-of-the-server]__83461316._.js +1 -1
  85. package/.next/server/chunks/[root-of-the-server]__83461316._.js.map +1 -1
  86. package/.next/server/chunks/[root-of-the-server]__9a611d42._.js +1 -1
  87. package/.next/server/chunks/[root-of-the-server]__9a611d42._.js.map +1 -1
  88. package/.next/server/chunks/[root-of-the-server]__a878c913._.js +1 -1
  89. package/.next/server/chunks/[root-of-the-server]__a878c913._.js.map +1 -1
  90. package/.next/server/chunks/[root-of-the-server]__b10ec83e._.js +1 -1
  91. package/.next/server/chunks/[root-of-the-server]__b10ec83e._.js.map +1 -1
  92. package/.next/server/chunks/[root-of-the-server]__c1629392._.js +1 -1
  93. package/.next/server/chunks/[root-of-the-server]__c1629392._.js.map +1 -1
  94. package/.next/server/chunks/[root-of-the-server]__eb816e13._.js +1 -1
  95. package/.next/server/chunks/[root-of-the-server]__eb816e13._.js.map +1 -1
  96. package/.next/server/chunks/[root-of-the-server]__f6f61507._.js +38 -0
  97. package/.next/server/chunks/[root-of-the-server]__f6f61507._.js.map +1 -0
  98. package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_cb746cf4.js +1 -1
  99. package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_cb746cf4.js.map +1 -1
  100. package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_f952d9ab.js +1 -1
  101. package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_f952d9ab.js.map +1 -1
  102. package/.next/server/functions-config-manifest.json +1 -8
  103. package/.next/server/pages/404.html +1 -1
  104. package/.next/server/pages/500.html +1 -1
  105. package/.next/trace +1 -1
  106. package/dist/app/api/api-keys/[apiKeyId]/buildRoute.d.ts +52 -0
  107. package/dist/app/api/api-keys/[apiKeyId]/buildRoute.d.ts.map +1 -0
  108. package/dist/app/api/api-keys/[apiKeyId]/buildRoute.js +121 -0
  109. package/dist/app/api/api-keys/[apiKeyId]/route.d.ts +10 -21
  110. package/dist/app/api/api-keys/[apiKeyId]/route.d.ts.map +1 -1
  111. package/dist/app/api/api-keys/[apiKeyId]/route.js +6 -125
  112. package/dist/app/api/api-keys/buildRoute.d.ts +32 -0
  113. package/dist/app/api/api-keys/buildRoute.d.ts.map +1 -0
  114. package/dist/app/api/api-keys/buildRoute.js +104 -0
  115. package/dist/app/api/api-keys/builders.d.ts +31 -0
  116. package/dist/app/api/api-keys/builders.d.ts.map +1 -0
  117. package/dist/app/api/api-keys/builders.js +109 -0
  118. package/dist/app/api/api-keys/route.d.ts +5 -13
  119. package/dist/app/api/api-keys/route.d.ts.map +1 -1
  120. package/dist/app/api/api-keys/route.js +8 -108
  121. package/dist/app/api/assistants/[assistantId]/buildRoute.d.ts +120 -0
  122. package/dist/app/api/assistants/[assistantId]/buildRoute.d.ts.map +1 -0
  123. package/dist/app/api/assistants/[assistantId]/buildRoute.js +226 -0
  124. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/buildRoute.d.ts +167 -0
  125. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/buildRoute.d.ts.map +1 -0
  126. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/buildRoute.js +184 -0
  127. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.d.ts +10 -21
  128. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.d.ts.map +1 -1
  129. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.js +6 -191
  130. package/dist/app/api/assistants/[assistantId]/functions/buildRoute.d.ts +114 -0
  131. package/dist/app/api/assistants/[assistantId]/functions/buildRoute.d.ts.map +1 -0
  132. package/dist/app/api/assistants/[assistantId]/functions/buildRoute.js +117 -0
  133. package/dist/app/api/assistants/[assistantId]/functions/route.d.ts +7 -15
  134. package/dist/app/api/assistants/[assistantId]/functions/route.d.ts.map +1 -1
  135. package/dist/app/api/assistants/[assistantId]/functions/route.js +5 -122
  136. package/dist/app/api/assistants/[assistantId]/initial-messages/buildRoute.d.ts +40 -0
  137. package/dist/app/api/assistants/[assistantId]/initial-messages/buildRoute.d.ts.map +1 -0
  138. package/dist/app/api/assistants/[assistantId]/initial-messages/buildRoute.js +85 -0
  139. package/dist/app/api/assistants/[assistantId]/initial-messages/route.d.ts +7 -15
  140. package/dist/app/api/assistants/[assistantId]/initial-messages/route.d.ts.map +1 -1
  141. package/dist/app/api/assistants/[assistantId]/initial-messages/route.js +5 -90
  142. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/buildRoute.d.ts +89 -0
  143. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/buildRoute.d.ts.map +1 -0
  144. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/buildRoute.js +167 -0
  145. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.d.ts +10 -21
  146. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.d.ts.map +1 -1
  147. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.js +6 -174
  148. package/dist/app/api/assistants/[assistantId]/mcp-servers/buildRoute.d.ts +62 -0
  149. package/dist/app/api/assistants/[assistantId]/mcp-servers/buildRoute.d.ts.map +1 -0
  150. package/dist/app/api/assistants/[assistantId]/mcp-servers/buildRoute.js +115 -0
  151. package/dist/app/api/assistants/[assistantId]/mcp-servers/route.d.ts +7 -15
  152. package/dist/app/api/assistants/[assistantId]/mcp-servers/route.d.ts.map +1 -1
  153. package/dist/app/api/assistants/[assistantId]/mcp-servers/route.js +5 -120
  154. package/dist/app/api/assistants/[assistantId]/route.d.ts +11 -22
  155. package/dist/app/api/assistants/[assistantId]/route.d.ts.map +1 -1
  156. package/dist/app/api/assistants/[assistantId]/route.js +6 -233
  157. package/dist/app/api/assistants/buildRoute.d.ts +121 -0
  158. package/dist/app/api/assistants/buildRoute.d.ts.map +1 -0
  159. package/dist/app/api/assistants/buildRoute.js +144 -0
  160. package/dist/app/api/assistants/route.d.ts +7 -13
  161. package/dist/app/api/assistants/route.d.ts.map +1 -1
  162. package/dist/app/api/assistants/route.js +6 -148
  163. package/dist/app/api/files/[fileId]/contents/buildRoute.d.ts +18 -0
  164. package/dist/app/api/files/[fileId]/contents/buildRoute.d.ts.map +1 -0
  165. package/dist/app/api/files/[fileId]/contents/buildRoute.js +81 -0
  166. package/dist/app/api/files/[fileId]/contents/route.d.ts +3 -13
  167. package/dist/app/api/files/[fileId]/contents/route.d.ts.map +1 -1
  168. package/dist/app/api/files/[fileId]/contents/route.js +4 -84
  169. package/dist/app/api/files/buildRoute.d.ts +14 -0
  170. package/dist/app/api/files/buildRoute.d.ts.map +1 -0
  171. package/dist/app/api/files/buildRoute.js +88 -0
  172. package/dist/app/api/files/route.d.ts +4 -10
  173. package/dist/app/api/files/route.d.ts.map +1 -1
  174. package/dist/app/api/files/route.js +4 -91
  175. package/dist/app/api/messages/buildRoute.d.ts +34 -0
  176. package/dist/app/api/messages/buildRoute.d.ts.map +1 -0
  177. package/dist/app/api/messages/buildRoute.js +607 -0
  178. package/dist/app/api/messages/lib/initialMessagesResponse.d.ts.map +1 -1
  179. package/dist/app/api/messages/lib/initialMessagesResponse.js +1 -1
  180. package/dist/app/api/messages/route.d.ts +10 -22
  181. package/dist/app/api/messages/route.d.ts.map +1 -1
  182. package/dist/app/api/messages/route.js +6 -612
  183. package/dist/app/api/providers/[modelProviderId]/assistants/buildRoute.d.ts +24 -0
  184. package/dist/app/api/providers/[modelProviderId]/assistants/buildRoute.d.ts.map +1 -0
  185. package/dist/app/api/providers/[modelProviderId]/assistants/buildRoute.js +43 -0
  186. package/dist/app/api/providers/[modelProviderId]/assistants/route.d.ts +4 -9
  187. package/dist/app/api/providers/[modelProviderId]/assistants/route.d.ts.map +1 -1
  188. package/dist/app/api/providers/[modelProviderId]/assistants/route.js +4 -46
  189. package/dist/app/api/providers/[modelProviderId]/buildRoute.d.ts +61 -0
  190. package/dist/app/api/providers/[modelProviderId]/buildRoute.d.ts.map +1 -0
  191. package/dist/app/api/providers/[modelProviderId]/buildRoute.js +134 -0
  192. package/dist/app/api/providers/[modelProviderId]/models/buildRoute.d.ts +19 -0
  193. package/dist/app/api/providers/[modelProviderId]/models/buildRoute.d.ts.map +1 -0
  194. package/dist/app/api/providers/[modelProviderId]/models/buildRoute.js +43 -0
  195. package/dist/app/api/providers/[modelProviderId]/models/route.d.ts +4 -9
  196. package/dist/app/api/providers/[modelProviderId]/models/route.d.ts.map +1 -1
  197. package/dist/app/api/providers/[modelProviderId]/models/route.js +4 -46
  198. package/dist/app/api/providers/[modelProviderId]/route.d.ts +10 -21
  199. package/dist/app/api/providers/[modelProviderId]/route.d.ts.map +1 -1
  200. package/dist/app/api/providers/[modelProviderId]/route.js +6 -141
  201. package/dist/app/api/providers/buildRoute.d.ts +38 -0
  202. package/dist/app/api/providers/buildRoute.d.ts.map +1 -0
  203. package/dist/app/api/providers/buildRoute.js +75 -0
  204. package/dist/app/api/providers/route.d.ts +5 -13
  205. package/dist/app/api/providers/route.d.ts.map +1 -1
  206. package/dist/app/api/providers/route.js +5 -80
  207. package/dist/app/api/tasks/[taskId]/buildRoute.d.ts +19 -0
  208. package/dist/app/api/tasks/[taskId]/buildRoute.d.ts.map +1 -0
  209. package/dist/app/api/tasks/[taskId]/buildRoute.js +125 -0
  210. package/dist/app/api/tasks/[taskId]/route.d.ts +7 -57
  211. package/dist/app/api/tasks/[taskId]/route.d.ts.map +1 -1
  212. package/dist/app/api/tasks/[taskId]/route.js +6 -144
  213. package/dist/app/api/tasks/buildRoute.d.ts +36 -0
  214. package/dist/app/api/tasks/buildRoute.d.ts.map +1 -0
  215. package/dist/app/api/tasks/buildRoute.js +85 -0
  216. package/dist/app/api/tasks/callback/buildRoute.d.ts +6 -0
  217. package/dist/app/api/tasks/callback/buildRoute.d.ts.map +1 -0
  218. package/dist/app/api/tasks/callback/buildRoute.js +244 -0
  219. package/dist/app/api/tasks/callback/route.d.ts +2 -1
  220. package/dist/app/api/tasks/callback/route.d.ts.map +1 -1
  221. package/dist/app/api/tasks/callback/route.js +4 -244
  222. package/dist/app/api/tasks/route.d.ts +5 -13
  223. package/dist/app/api/tasks/route.d.ts.map +1 -1
  224. package/dist/app/api/tasks/route.js +5 -90
  225. package/dist/app/api/threads/runs/submit-client-tool-outputs/buildRoute.d.ts +10 -0
  226. package/dist/app/api/threads/runs/submit-client-tool-outputs/buildRoute.d.ts.map +1 -0
  227. package/dist/app/api/threads/runs/submit-client-tool-outputs/buildRoute.js +36 -0
  228. package/dist/app/api/threads/runs/submit-client-tool-outputs/route.d.ts +2 -7
  229. package/dist/app/api/threads/runs/submit-client-tool-outputs/route.d.ts.map +1 -1
  230. package/dist/app/api/threads/runs/submit-client-tool-outputs/route.js +3 -37
  231. package/dist/app/api/workspaces/[workspaceId]/buildRoute.d.ts +16 -0
  232. package/dist/app/api/workspaces/[workspaceId]/buildRoute.d.ts.map +1 -0
  233. package/dist/app/api/workspaces/[workspaceId]/buildRoute.js +89 -0
  234. package/dist/app/api/workspaces/[workspaceId]/route.d.ts +5 -31
  235. package/dist/app/api/workspaces/[workspaceId]/route.d.ts.map +1 -1
  236. package/dist/app/api/workspaces/[workspaceId]/route.js +5 -89
  237. package/dist/app/api/workspaces/buildRoute.d.ts +42 -0
  238. package/dist/app/api/workspaces/buildRoute.d.ts.map +1 -0
  239. package/dist/app/api/workspaces/buildRoute.js +78 -0
  240. package/dist/app/api/workspaces/route.d.ts +7 -27
  241. package/dist/app/api/workspaces/route.d.ts.map +1 -1
  242. package/dist/app/api/workspaces/route.js +6 -82
  243. package/dist/lib/functions/functionSchema.d.ts +56 -56
  244. package/dist/lib/functions/handleFunction/getFunction.d.ts +4 -4
  245. package/dist/lib/mcpServers/mcpServerSchema.d.ts +20 -20
  246. package/dist/lib/prisma/index.d.ts +1 -9
  247. package/dist/lib/prisma/index.d.ts.map +1 -1
  248. package/dist/lib/prisma/index.js +10 -78
  249. package/package.json +4 -12
  250. package/.next/server/chunks/[root-of-the-server]__228bff78._.js +0 -38
  251. package/.next/server/chunks/[root-of-the-server]__228bff78._.js.map +0 -1
  252. package/.next/server/chunks/[root-of-the-server]__3307123c._.js +0 -38
  253. package/.next/server/chunks/[root-of-the-server]__3307123c._.js.map +0 -1
  254. package/.next/server/chunks/[root-of-the-server]__50c5f12c._.js +0 -38
  255. package/.next/server/chunks/[root-of-the-server]__50c5f12c._.js.map +0 -1
  256. package/.next/server/chunks/[root-of-the-server]__6b8ba839._.js +0 -38
  257. package/.next/server/chunks/[root-of-the-server]__6b8ba839._.js.map +0 -1
  258. package/.next/server/chunks/[root-of-the-server]__e7819e95._.js +0 -38
  259. package/.next/server/chunks/[root-of-the-server]__e7819e95._.js.map +0 -1
  260. package/.next/server/chunks/[root-of-the-server]__f0dfab03._.js +0 -38
  261. package/.next/server/chunks/[root-of-the-server]__f0dfab03._.js.map +0 -1
  262. package/.next/server/chunks/[root-of-the-server]__ff90af03._.js +0 -38
  263. package/.next/server/chunks/[root-of-the-server]__ff90af03._.js.map +0 -1
  264. /package/.next/static/{jt8inwg6nWaLQZ4qpiSJ- → iaWEclnh6aHcuw0CBnWpA}/_buildManifest.js +0 -0
  265. /package/.next/static/{jt8inwg6nWaLQZ4qpiSJ- → iaWEclnh6aHcuw0CBnWpA}/_clientMiddlewareManifest.json +0 -0
  266. /package/.next/static/{jt8inwg6nWaLQZ4qpiSJ- → iaWEclnh6aHcuw0CBnWpA}/_ssgManifest.js +0 -0
@@ -0,0 +1,38 @@
1
+ import { type PrismaClient } from '@prisma/client';
2
+ import { NextResponse, type NextRequest } from 'next/server';
3
+ export declare const buildGET: ({ prisma }: {
4
+ prisma: PrismaClient;
5
+ }) => () => Promise<NextResponse<{
6
+ error: string;
7
+ }> | NextResponse<{
8
+ providers: {
9
+ id: string;
10
+ type: import("@prisma/client").$Enums.ModelProviderType;
11
+ name: string;
12
+ apiKey: string;
13
+ endpoint: string | null;
14
+ apiVersion: string | null;
15
+ workspaceId: string;
16
+ createdAt: string;
17
+ updatedAt: string;
18
+ }[];
19
+ }>>;
20
+ export declare const buildPOST: ({ prisma }: {
21
+ prisma: PrismaClient;
22
+ }) => (request: NextRequest) => Promise<NextResponse<{
23
+ error: string;
24
+ }> | NextResponse<{
25
+ provider: {
26
+ id: string;
27
+ type: import("@prisma/client").$Enums.ModelProviderType;
28
+ name: string;
29
+ apiKey: string;
30
+ endpoint: string | null;
31
+ apiVersion: string | null;
32
+ workspaceId: string;
33
+ createdAt: string;
34
+ updatedAt: string;
35
+ };
36
+ }>>;
37
+ export declare const buildOPTIONS: () => () => NextResponse<{}>;
38
+ //# sourceMappingURL=buildRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildRoute.d.ts","sourceRoot":"","sources":["../../../../src/app/api/providers/buildRoute.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAM5D,eAAO,MAAM,QAAQ,GAClB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE;;;;;;;;;;;;;;GAmCpC,CAAA;AAEH,eAAO,MAAM,SAAS,GACnB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,MAC9B,SAAS,WAAW;;;;;;;;;;;;;;GA6D1B,CAAA;AAEH,eAAO,MAAM,YAAY,8BAMtB,CAAA"}
@@ -0,0 +1,75 @@
1
+ import { headers } from 'next/headers';
2
+ import { ApiKeyType, ModelProviderType, } from '@prisma/client';
3
+ import { NextResponse } from 'next/server';
4
+ import { z } from 'zod';
5
+ import { cacheHeaders } from '../../../lib/cache/cacheHeaders';
6
+ import { serializeModelProvider } from '../../../lib/modelProviders/serializeModelProvider';
7
+ import { getApiKey } from '../../../lib/apiKeys/getApiKey';
8
+ export const buildGET = ({ prisma }) => async () => {
9
+ const headersList = await headers();
10
+ const authorization = headersList.get('authorization');
11
+ if (!authorization) {
12
+ return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
13
+ }
14
+ const privateApiKey = await getApiKey({
15
+ type: ApiKeyType.PRIVATE,
16
+ authorization,
17
+ prisma,
18
+ });
19
+ if (!privateApiKey) {
20
+ return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
21
+ }
22
+ const providers = await prisma.modelProvider.findMany({
23
+ where: {
24
+ workspaceId: privateApiKey.workspaceId,
25
+ },
26
+ });
27
+ return NextResponse.json({
28
+ providers: providers.map((p) => serializeModelProvider({ provider: p })),
29
+ }, { headers: cacheHeaders });
30
+ };
31
+ export const buildPOST = ({ prisma }) => async (request) => {
32
+ const headersList = await headers();
33
+ const authorization = headersList.get('authorization');
34
+ if (!authorization) {
35
+ return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
36
+ }
37
+ const privateApiKey = await getApiKey({
38
+ authorization,
39
+ type: ApiKeyType.PRIVATE,
40
+ prisma,
41
+ });
42
+ if (!privateApiKey) {
43
+ return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
44
+ }
45
+ const body = await request.json();
46
+ const schema = z.object({
47
+ type: z.nativeEnum(ModelProviderType),
48
+ name: z.string().optional(),
49
+ apiKey: z.string().optional(),
50
+ endpoint: z.string().optional().nullable(),
51
+ apiVersion: z.string().optional().nullable(),
52
+ });
53
+ const parsed = schema.safeParse(body);
54
+ if (!parsed.success) {
55
+ return NextResponse.json({ error: 'Invalid payload' }, { status: 400 });
56
+ }
57
+ const { type, name, apiKey: providerKey, endpoint, apiVersion, } = parsed.data;
58
+ const workspaceId = privateApiKey.workspaceId;
59
+ const provider = await prisma.modelProvider.create({
60
+ data: {
61
+ type: type,
62
+ name: name !== null && name !== void 0 ? name : '',
63
+ apiKey: providerKey !== null && providerKey !== void 0 ? providerKey : '',
64
+ endpoint: endpoint !== null && endpoint !== void 0 ? endpoint : null,
65
+ apiVersion: apiVersion !== null && apiVersion !== void 0 ? apiVersion : null,
66
+ workspaceId,
67
+ },
68
+ });
69
+ return NextResponse.json({
70
+ provider: serializeModelProvider({ provider }),
71
+ }, { headers: cacheHeaders });
72
+ };
73
+ export const buildOPTIONS = () => () => NextResponse.json({}, {
74
+ headers: cacheHeaders,
75
+ });
@@ -1,10 +1,6 @@
1
- import { type PrismaClient } from '@prisma/client';
2
- import { NextResponse, type NextRequest } from 'next/server';
3
- export declare const buildGET: ({ prisma: providedPrisma }?: {
4
- prisma?: PrismaClient;
5
- }) => () => Promise<NextResponse<{
1
+ export declare const GET: () => Promise<import("next/server").NextResponse<{
6
2
  error: string;
7
- }> | NextResponse<{
3
+ }> | import("next/server").NextResponse<{
8
4
  providers: {
9
5
  id: string;
10
6
  type: import("@prisma/client").$Enums.ModelProviderType;
@@ -17,12 +13,9 @@ export declare const buildGET: ({ prisma: providedPrisma }?: {
17
13
  updatedAt: string;
18
14
  }[];
19
15
  }>>;
20
- export declare const GET: ReturnType<typeof buildGET>;
21
- export declare const buildPOST: ({ prisma: providedPrisma }?: {
22
- prisma?: PrismaClient;
23
- }) => (request: NextRequest) => Promise<NextResponse<{
16
+ export declare const POST: (request: import("next/server").NextRequest) => Promise<import("next/server").NextResponse<{
24
17
  error: string;
25
- }> | NextResponse<{
18
+ }> | import("next/server").NextResponse<{
26
19
  provider: {
27
20
  id: string;
28
21
  type: import("@prisma/client").$Enums.ModelProviderType;
@@ -35,6 +28,5 @@ export declare const buildPOST: ({ prisma: providedPrisma }?: {
35
28
  updatedAt: string;
36
29
  };
37
30
  }>>;
38
- export declare const POST: ReturnType<typeof buildPOST>;
39
- export declare const OPTIONS: () => NextResponse<{}>;
31
+ export declare const OPTIONS: () => import("next/server").NextResponse<{}>;
40
32
  //# sourceMappingURL=route.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/app/api/providers/route.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAO5D,eAAO,MAAM,QAAQ,GAClB,6BAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO;;;;;;;;;;;;;;GAoC1D,CAAA;AAEH,eAAO,MAAM,GAAG,EACU,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAA;AAErD,eAAO,MAAM,SAAS,GACnB,6BAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MACpD,SAAS,WAAW;;;;;;;;;;;;;;GA8D1B,CAAA;AAEH,eAAO,MAAM,IAAI,EACU,UAAU,CAAC,OAAO,SAAS,CAAC,CAAA;AAEvD,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/app/api/providers/route.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,GAAG;;;;;;;;;;;;;;GAAuB,CAAA;AAEvC,eAAO,MAAM,IAAI;;;;;;;;;;;;;;GAAwB,CAAA;AAEzC,eAAO,MAAM,OAAO,8CAAiB,CAAA"}
@@ -1,80 +1,5 @@
1
- import { headers } from 'next/headers';
2
- import { ApiKeyType, ModelProviderType, } from '@prisma/client';
3
- import { NextResponse } from 'next/server';
4
- import { z } from 'zod';
5
- import { cacheHeaders } from '../../../lib/cache/cacheHeaders';
6
- import { resolvePrisma } from '../../../lib/prisma';
7
- import { serializeModelProvider } from '../../../lib/modelProviders/serializeModelProvider';
8
- import { getApiKey } from '../../../lib/apiKeys/getApiKey';
9
- export const buildGET = ({ prisma: providedPrisma } = {}) => async () => {
10
- const prisma = resolvePrisma(providedPrisma);
11
- const headersList = await headers();
12
- const authorization = headersList.get('authorization');
13
- if (!authorization) {
14
- return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
15
- }
16
- const privateApiKey = await getApiKey({
17
- type: ApiKeyType.PRIVATE,
18
- authorization,
19
- prisma,
20
- });
21
- if (!privateApiKey) {
22
- return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
23
- }
24
- const providers = await prisma.modelProvider.findMany({
25
- where: {
26
- workspaceId: privateApiKey.workspaceId,
27
- },
28
- });
29
- return NextResponse.json({
30
- providers: providers.map((p) => serializeModelProvider({ provider: p })),
31
- }, { headers: cacheHeaders });
32
- };
33
- export const GET = ((...args) => buildGET()(...args));
34
- export const buildPOST = ({ prisma: providedPrisma } = {}) => async (request) => {
35
- const prisma = resolvePrisma(providedPrisma);
36
- const headersList = await headers();
37
- const authorization = headersList.get('authorization');
38
- if (!authorization) {
39
- return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
40
- }
41
- const privateApiKey = await getApiKey({
42
- authorization,
43
- type: ApiKeyType.PRIVATE,
44
- prisma,
45
- });
46
- if (!privateApiKey) {
47
- return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
48
- }
49
- const body = await request.json();
50
- const schema = z.object({
51
- type: z.nativeEnum(ModelProviderType),
52
- name: z.string().optional(),
53
- apiKey: z.string().optional(),
54
- endpoint: z.string().optional().nullable(),
55
- apiVersion: z.string().optional().nullable(),
56
- });
57
- const parsed = schema.safeParse(body);
58
- if (!parsed.success) {
59
- return NextResponse.json({ error: 'Invalid payload' }, { status: 400 });
60
- }
61
- const { type, name, apiKey: providerKey, endpoint, apiVersion, } = parsed.data;
62
- const workspaceId = privateApiKey.workspaceId;
63
- const provider = await prisma.modelProvider.create({
64
- data: {
65
- type: type,
66
- name: name !== null && name !== void 0 ? name : '',
67
- apiKey: providerKey !== null && providerKey !== void 0 ? providerKey : '',
68
- endpoint: endpoint !== null && endpoint !== void 0 ? endpoint : null,
69
- apiVersion: apiVersion !== null && apiVersion !== void 0 ? apiVersion : null,
70
- workspaceId,
71
- },
72
- });
73
- return NextResponse.json({
74
- provider: serializeModelProvider({ provider }),
75
- }, { headers: cacheHeaders });
76
- };
77
- export const POST = ((...args) => buildPOST()(...args));
78
- export const OPTIONS = () => NextResponse.json({}, {
79
- headers: cacheHeaders,
80
- });
1
+ import { prisma } from '../../../lib/prisma';
2
+ import { buildGET, buildOPTIONS, buildPOST } from './buildRoute';
3
+ export const GET = buildGET({ prisma });
4
+ export const POST = buildPOST({ prisma });
5
+ export const OPTIONS = buildOPTIONS();
@@ -0,0 +1,19 @@
1
+ import { type PrismaClient } from '@prisma/client';
2
+ import { NextResponse, type NextRequest } from 'next/server';
3
+ type RouteProps = {
4
+ params: Promise<{
5
+ taskId: string;
6
+ }>;
7
+ };
8
+ export declare const buildGET: ({ prisma }: {
9
+ prisma: PrismaClient;
10
+ }) => (_request: NextRequest, props: RouteProps) => Promise<NextResponse<unknown>>;
11
+ export declare const buildPATCH: ({ prisma }: {
12
+ prisma: PrismaClient;
13
+ }) => (request: NextRequest, props: RouteProps) => Promise<NextResponse<unknown>>;
14
+ export declare const buildDELETE: ({ prisma }: {
15
+ prisma: PrismaClient;
16
+ }) => (_request: NextRequest, props: RouteProps) => Promise<NextResponse<unknown>>;
17
+ export declare const buildOPTIONS: () => () => NextResponse<{}>;
18
+ export {};
19
+ //# sourceMappingURL=buildRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildRoute.d.ts","sourceRoot":"","sources":["../../../../../src/app/api/tasks/[taskId]/buildRoute.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAiB5D,KAAK,UAAU,GAAG;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAA;AA4CzD,eAAO,MAAM,QAAQ,GAClB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,MAC9B,UAAU,WAAW,EAAE,OAAO,UAAU,mCAyB9C,CAAA;AAEH,eAAO,MAAM,UAAU,GACpB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,MAC9B,SAAS,WAAW,EAAE,OAAO,UAAU,mCAwD7C,CAAA;AAEH,eAAO,MAAM,WAAW,GACrB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,MAC9B,UAAU,WAAW,EAAE,OAAO,UAAU,mCA6B9C,CAAA;AAEH,eAAO,MAAM,YAAY,8BAMtB,CAAA"}
@@ -0,0 +1,125 @@
1
+ import { headers } from 'next/headers';
2
+ import { ApiKeyType } from '@prisma/client';
3
+ import { NextResponse } from 'next/server';
4
+ import { z } from 'zod';
5
+ import { validate } from 'uuid';
6
+ import { cacheHeaders } from '../../../../lib/cache/cacheHeaders';
7
+ import { serializeTask } from '../../../../lib/tasks/serializeTask';
8
+ import { validateSchedule } from '../../../../lib/tasks/validateSchedule';
9
+ import { getApiKey } from '../../../../lib/apiKeys/getApiKey';
10
+ import { scheduleTask } from '../../../../lib/tasks/scheduleTask';
11
+ import { cancelScheduledTask } from '../../../../lib/tasks/cancelScheduledTask';
12
+ const updateTaskSchema = z.object({
13
+ title: z.string().optional(),
14
+ message: z.string().optional(),
15
+ schedule: z.any().optional(),
16
+ key: z.string().optional(),
17
+ });
18
+ const ensureValidTaskId = (taskId) => {
19
+ if (!taskId) {
20
+ return NextResponse.json({ error: 'No task id found' }, { status: 400 });
21
+ }
22
+ if (!validate(taskId)) {
23
+ return NextResponse.json({ error: 'Invalid task id' }, { status: 400 });
24
+ }
25
+ return null;
26
+ };
27
+ const authorize = async ({ prisma, }) => {
28
+ const headersList = await headers();
29
+ const authorization = headersList.get('authorization');
30
+ if (!authorization) {
31
+ return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
32
+ }
33
+ const privateApiKey = await getApiKey({
34
+ authorization,
35
+ type: ApiKeyType.PRIVATE,
36
+ prisma,
37
+ });
38
+ if (!privateApiKey) {
39
+ return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
40
+ }
41
+ return { privateApiKey };
42
+ };
43
+ export const buildGET = ({ prisma }) => async (_request, props) => {
44
+ const { taskId } = await props.params;
45
+ const authorized = await authorize({ prisma });
46
+ if (authorized instanceof NextResponse)
47
+ return authorized;
48
+ const { privateApiKey } = authorized;
49
+ const validationError = ensureValidTaskId(taskId);
50
+ if (validationError)
51
+ return validationError;
52
+ const task = await prisma.task.findFirst({
53
+ where: {
54
+ id: taskId,
55
+ thread: { assistant: { workspaceId: privateApiKey.workspaceId } },
56
+ },
57
+ });
58
+ if (!task) {
59
+ return NextResponse.json({ error: 'No task found' }, { status: 400 });
60
+ }
61
+ return NextResponse.json({ task: serializeTask({ task }) }, { headers: cacheHeaders });
62
+ };
63
+ export const buildPATCH = ({ prisma }) => async (request, props) => {
64
+ const { taskId } = await props.params;
65
+ const authorized = await authorize({ prisma });
66
+ if (authorized instanceof NextResponse)
67
+ return authorized;
68
+ const { privateApiKey } = authorized;
69
+ const validationError = ensureValidTaskId(taskId);
70
+ if (validationError)
71
+ return validationError;
72
+ const parsed = updateTaskSchema.safeParse(await request.json());
73
+ if (!parsed.success) {
74
+ return NextResponse.json({ error: 'Invalid payload' }, { status: 400 });
75
+ }
76
+ if (parsed.data.schedule !== undefined &&
77
+ !validateSchedule(parsed.data.schedule)) {
78
+ return NextResponse.json({ error: 'Invalid schedule' }, { status: 400 });
79
+ }
80
+ const existingTask = await prisma.task.findFirst({
81
+ where: {
82
+ id: taskId,
83
+ thread: { assistant: { workspaceId: privateApiKey.workspaceId } },
84
+ },
85
+ });
86
+ if (!existingTask) {
87
+ return NextResponse.json({ error: 'No task found' }, { status: 400 });
88
+ }
89
+ const updateData = Object.assign(Object.assign(Object.assign(Object.assign({}, (parsed.data.title !== undefined ? { title: parsed.data.title } : {})), (parsed.data.message !== undefined
90
+ ? { message: parsed.data.message }
91
+ : {})), (parsed.data.schedule !== undefined
92
+ ? { schedule: parsed.data.schedule }
93
+ : {})), (parsed.data.key !== undefined ? { key: parsed.data.key } : {}));
94
+ const task = await prisma.task.update({
95
+ where: { id: existingTask.id },
96
+ data: updateData,
97
+ });
98
+ await scheduleTask({ task, prisma });
99
+ return NextResponse.json({ task: serializeTask({ task }) }, { headers: cacheHeaders });
100
+ };
101
+ export const buildDELETE = ({ prisma }) => async (_request, props) => {
102
+ const { taskId } = await props.params;
103
+ const authorized = await authorize({ prisma });
104
+ if (authorized instanceof NextResponse)
105
+ return authorized;
106
+ const { privateApiKey } = authorized;
107
+ const validationError = ensureValidTaskId(taskId);
108
+ if (validationError)
109
+ return validationError;
110
+ const existingTask = await prisma.task.findFirst({
111
+ where: {
112
+ id: taskId,
113
+ thread: { assistant: { workspaceId: privateApiKey.workspaceId } },
114
+ },
115
+ });
116
+ if (!existingTask) {
117
+ return NextResponse.json({ error: 'No task found' }, { status: 400 });
118
+ }
119
+ await cancelScheduledTask({ task: existingTask });
120
+ const task = await prisma.task.delete({ where: { id: existingTask.id } });
121
+ return NextResponse.json({ task: serializeTask({ task }) }, { headers: cacheHeaders });
122
+ };
123
+ export const buildOPTIONS = () => () => NextResponse.json({}, {
124
+ headers: cacheHeaders,
125
+ });
@@ -1,67 +1,17 @@
1
- import { type PrismaClient } from '@prisma/client';
2
- import { NextResponse, type NextRequest } from 'next/server';
3
- export declare const buildGET: ({ prisma: providedPrisma }?: {
4
- prisma?: PrismaClient;
5
- }) => (_request: NextRequest, props: {
1
+ export declare const GET: (_request: import("next/server").NextRequest, props: {
6
2
  params: Promise<{
7
3
  taskId: string;
8
4
  }>;
9
- }) => Promise<NextResponse<{
10
- error: string;
11
- }> | NextResponse<{
12
- task: {
13
- id: string;
14
- title: string;
15
- message: string;
16
- schedule: PrismaJson.TaskSchedule;
17
- threadId: string;
18
- key: string;
19
- createdAt: string;
20
- updatedAt: string;
21
- };
22
- }>>;
23
- export declare const GET: ReturnType<typeof buildGET>;
24
- export declare const buildPATCH: ({ prisma: providedPrisma }?: {
25
- prisma?: PrismaClient;
26
- }) => (request: NextRequest, props: {
5
+ }) => Promise<import("next/server").NextResponse<unknown>>;
6
+ export declare const PATCH: (request: import("next/server").NextRequest, props: {
27
7
  params: Promise<{
28
8
  taskId: string;
29
9
  }>;
30
- }) => Promise<NextResponse<{
31
- error: string;
32
- }> | NextResponse<{
33
- task: {
34
- id: string;
35
- title: string;
36
- message: string;
37
- schedule: PrismaJson.TaskSchedule;
38
- threadId: string;
39
- key: string;
40
- createdAt: string;
41
- updatedAt: string;
42
- };
43
- }>>;
44
- export declare const PATCH: ReturnType<typeof buildPATCH>;
45
- export declare const buildDELETE: ({ prisma: providedPrisma }?: {
46
- prisma?: PrismaClient;
47
- }) => (_request: NextRequest, props: {
10
+ }) => Promise<import("next/server").NextResponse<unknown>>;
11
+ export declare const DELETE: (_request: import("next/server").NextRequest, props: {
48
12
  params: Promise<{
49
13
  taskId: string;
50
14
  }>;
51
- }) => Promise<NextResponse<{
52
- error: string;
53
- }> | NextResponse<{
54
- task: {
55
- id: string;
56
- title: string;
57
- message: string;
58
- schedule: PrismaJson.TaskSchedule;
59
- threadId: string;
60
- key: string;
61
- createdAt: string;
62
- updatedAt: string;
63
- };
64
- }>>;
65
- export declare const DELETE: ReturnType<typeof buildDELETE>;
66
- export declare const OPTIONS: () => NextResponse<{}>;
15
+ }) => Promise<import("next/server").NextResponse<unknown>>;
16
+ export declare const OPTIONS: () => import("next/server").NextResponse<{}>;
67
17
  //# sourceMappingURL=route.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../src/app/api/tasks/[taskId]/route.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAkB5D,eAAO,MAAM,QAAQ,GAClB,6BAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,UAAU,WAAW,EACrB,OAAO;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;;;;;GA+C/C,CAAA;AAEH,eAAO,MAAM,GAAG,EACU,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAA;AAErD,eAAO,MAAM,UAAU,GACpB,6BAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,SAAS,WAAW,EACpB,OAAO;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;;;;;GAkF/C,CAAA;AAEH,eAAO,MAAM,KAAK,EACU,UAAU,CAAC,OAAO,UAAU,CAAC,CAAA;AAEzD,eAAO,MAAM,WAAW,GACrB,6BAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,UAAU,WAAW,EACrB,OAAO;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;;;;;GAmD/C,CAAA;AAEH,eAAO,MAAM,MAAM,EACU,UAAU,CAAC,OAAO,WAAW,CAAC,CAAA;AAE3D,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../src/app/api/tasks/[taskId]/route.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,GAAG;;;;0DAAuB,CAAA;AAEvC,eAAO,MAAM,KAAK;;;;0DAAyB,CAAA;AAE3C,eAAO,MAAM,MAAM;;;;0DAA0B,CAAA;AAE7C,eAAO,MAAM,OAAO,8CAAiB,CAAA"}
@@ -1,144 +1,6 @@
1
- import { headers } from 'next/headers';
2
- import { ApiKeyType } from '@prisma/client';
3
- import { NextResponse } from 'next/server';
4
- import { z } from 'zod';
5
- import { validate } from 'uuid';
6
- import { cacheHeaders } from '../../../../lib/cache/cacheHeaders';
7
- import { resolvePrisma } from '../../../../lib/prisma';
8
- import { serializeTask } from '../../../../lib/tasks/serializeTask';
9
- import { validateSchedule } from '../../../../lib/tasks/validateSchedule';
10
- import { getApiKey } from '../../../../lib/apiKeys/getApiKey';
11
- import { scheduleTask } from '../../../../lib/tasks/scheduleTask';
12
- import { cancelScheduledTask } from '../../../../lib/tasks/cancelScheduledTask';
13
- const updateTaskSchema = z.object({
14
- title: z.string().optional(),
15
- message: z.string().optional(),
16
- schedule: z.any().optional(),
17
- key: z.string().optional(),
18
- });
19
- export const buildGET = ({ prisma: providedPrisma } = {}) => async (_request, props) => {
20
- const prisma = resolvePrisma(providedPrisma);
21
- const { taskId } = await props.params;
22
- const headersList = await headers();
23
- const authorization = headersList.get('authorization');
24
- if (!authorization) {
25
- return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
26
- }
27
- const privateApiKey = await getApiKey({
28
- authorization,
29
- type: ApiKeyType.PRIVATE,
30
- prisma,
31
- });
32
- if (!privateApiKey) {
33
- return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
34
- }
35
- if (!taskId) {
36
- return NextResponse.json({ error: 'No task id found' }, { status: 400 });
37
- }
38
- if (!validate(taskId)) {
39
- return NextResponse.json({ error: 'Invalid task id' }, { status: 400 });
40
- }
41
- const task = await prisma.task.findFirst({
42
- where: {
43
- id: taskId,
44
- thread: { assistant: { workspaceId: privateApiKey.workspaceId } },
45
- },
46
- });
47
- if (!task) {
48
- return NextResponse.json({ error: 'No task found' }, { status: 400 });
49
- }
50
- return NextResponse.json({ task: serializeTask({ task }) }, { headers: cacheHeaders });
51
- };
52
- export const GET = ((...args) => buildGET()(...args));
53
- export const buildPATCH = ({ prisma: providedPrisma } = {}) => async (request, props) => {
54
- const prisma = resolvePrisma(providedPrisma);
55
- const { taskId } = await props.params;
56
- const headersList = await headers();
57
- const authorization = headersList.get('authorization');
58
- if (!authorization) {
59
- return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
60
- }
61
- const privateApiKey = await getApiKey({
62
- authorization,
63
- type: ApiKeyType.PRIVATE,
64
- prisma,
65
- });
66
- if (!privateApiKey) {
67
- return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
68
- }
69
- if (!taskId) {
70
- return NextResponse.json({ error: 'No task id found' }, { status: 400 });
71
- }
72
- if (!validate(taskId)) {
73
- return NextResponse.json({ error: 'Invalid task id' }, { status: 400 });
74
- }
75
- const parsed = updateTaskSchema.safeParse(await request.json());
76
- if (!parsed.success) {
77
- return NextResponse.json({ error: 'Invalid payload' }, { status: 400 });
78
- }
79
- const updateData = Object.assign(Object.assign(Object.assign(Object.assign({}, (parsed.data.title !== undefined ? { title: parsed.data.title } : {})), (parsed.data.message !== undefined
80
- ? { message: parsed.data.message }
81
- : {})), (parsed.data.schedule !== undefined
82
- ? Object.assign({}, (validateSchedule(parsed.data.schedule)
83
- ? { schedule: parsed.data.schedule }
84
- : {})) : {})), (parsed.data.key !== undefined ? { key: parsed.data.key } : {}));
85
- if (parsed.data.schedule !== undefined &&
86
- !validateSchedule(parsed.data.schedule)) {
87
- return NextResponse.json({ error: 'Invalid schedule' }, { status: 400 });
88
- }
89
- const existingTask = await prisma.task.findFirst({
90
- where: {
91
- id: taskId,
92
- thread: { assistant: { workspaceId: privateApiKey.workspaceId } },
93
- },
94
- });
95
- if (!existingTask) {
96
- return NextResponse.json({ error: 'No task found' }, { status: 400 });
97
- }
98
- const task = await prisma.task.update({
99
- where: { id: existingTask.id },
100
- data: updateData,
101
- });
102
- await scheduleTask({ task, prisma });
103
- return NextResponse.json({ task: serializeTask({ task }) }, { headers: cacheHeaders });
104
- };
105
- export const PATCH = ((...args) => buildPATCH()(...args));
106
- export const buildDELETE = ({ prisma: providedPrisma } = {}) => async (_request, props) => {
107
- const prisma = resolvePrisma(providedPrisma);
108
- const { taskId } = await props.params;
109
- const headersList = await headers();
110
- const authorization = headersList.get('authorization');
111
- if (!authorization) {
112
- return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
113
- }
114
- const privateApiKey = await getApiKey({
115
- authorization,
116
- type: ApiKeyType.PRIVATE,
117
- prisma,
118
- });
119
- if (!privateApiKey) {
120
- return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
121
- }
122
- if (!taskId) {
123
- return NextResponse.json({ error: 'No task id found' }, { status: 400 });
124
- }
125
- if (!validate(taskId)) {
126
- return NextResponse.json({ error: 'Invalid task id' }, { status: 400 });
127
- }
128
- const existingTask = await prisma.task.findFirst({
129
- where: {
130
- id: taskId,
131
- thread: { assistant: { workspaceId: privateApiKey.workspaceId } },
132
- },
133
- });
134
- if (!existingTask) {
135
- return NextResponse.json({ error: 'No task found' }, { status: 400 });
136
- }
137
- await cancelScheduledTask({ task: existingTask });
138
- const task = await prisma.task.delete({ where: { id: existingTask.id } });
139
- return NextResponse.json({ task: serializeTask({ task }) }, { headers: cacheHeaders });
140
- };
141
- export const DELETE = ((...args) => buildDELETE()(...args));
142
- export const OPTIONS = () => NextResponse.json({}, {
143
- headers: cacheHeaders,
144
- });
1
+ import { prisma } from '../../../../lib/prisma';
2
+ import { buildDELETE, buildGET, buildOPTIONS, buildPATCH, } from './buildRoute';
3
+ export const GET = buildGET({ prisma });
4
+ export const PATCH = buildPATCH({ prisma });
5
+ export const DELETE = buildDELETE({ prisma });
6
+ export const OPTIONS = buildOPTIONS();
@@ -0,0 +1,36 @@
1
+ import { type PrismaClient } from '@prisma/client';
2
+ import { NextResponse, type NextRequest } from 'next/server';
3
+ export declare const buildGET: ({ prisma }: {
4
+ prisma: PrismaClient;
5
+ }) => (request: NextRequest) => Promise<NextResponse<{
6
+ error: string;
7
+ }> | NextResponse<{
8
+ tasks: {
9
+ id: string;
10
+ title: string;
11
+ message: string;
12
+ schedule: PrismaJson.TaskSchedule;
13
+ threadId: string;
14
+ key: string;
15
+ createdAt: string;
16
+ updatedAt: string;
17
+ }[];
18
+ }>>;
19
+ export declare const buildPOST: ({ prisma }: {
20
+ prisma: PrismaClient;
21
+ }) => (request: NextRequest) => Promise<NextResponse<{
22
+ error: string;
23
+ }> | NextResponse<{
24
+ task: {
25
+ id: string;
26
+ title: string;
27
+ message: string;
28
+ schedule: PrismaJson.TaskSchedule;
29
+ threadId: string;
30
+ key: string;
31
+ createdAt: string;
32
+ updatedAt: string;
33
+ };
34
+ }>>;
35
+ export declare const buildOPTIONS: () => () => NextResponse<{}>;
36
+ //# sourceMappingURL=buildRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildRoute.d.ts","sourceRoot":"","sources":["../../../../src/app/api/tasks/buildRoute.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAQ5D,eAAO,MAAM,QAAQ,GAClB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,MAC9B,SAAS,WAAW;;;;;;;;;;;;;GAoC1B,CAAA;AAEH,eAAO,MAAM,SAAS,GACnB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,MAC9B,SAAS,WAAW;;;;;;;;;;;;;GAiE1B,CAAA;AAEH,eAAO,MAAM,YAAY,8BAMtB,CAAA"}