@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
@@ -1,14 +1,10 @@
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
  modelProviderId: string;
8
4
  }>;
9
- }) => Promise<NextResponse<{
5
+ }) => Promise<import("next/server").NextResponse<{
10
6
  error: string;
11
- }> | NextResponse<{
7
+ }> | import("next/server").NextResponse<{
12
8
  storageProviderAssistants: {
13
9
  id: string;
14
10
  model: string;
@@ -18,6 +14,5 @@ export declare const buildGET: ({ prisma: providedPrisma }?: {
18
14
  tools: import("openai/resources/beta/assistants.mjs").AssistantTool[];
19
15
  }[];
20
16
  }>>;
21
- export declare const GET: ReturnType<typeof buildGET>;
22
- export declare const OPTIONS: () => NextResponse<{}>;
17
+ export declare const OPTIONS: () => import("next/server").NextResponse<{}>;
23
18
  //# sourceMappingURL=route.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/providers/[modelProviderId]/assistants/route.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAO5D,eAAO,MAAM,QAAQ,GAClB,6BAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,UAAU,WAAW,EACrB,OAAO;IACL,MAAM,EAAE,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC7C;;;;;;;;;;;GAkDF,CAAA;AAEH,eAAO,MAAM,GAAG,EACU,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAA;AAErD,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/providers/[modelProviderId]/assistants/route.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;GAAuB,CAAA;AAEvC,eAAO,MAAM,OAAO,8CAAiB,CAAA"}
@@ -1,46 +1,4 @@
1
- import { headers } from 'next/headers';
2
- import { ApiKeyType } from '@prisma/client';
3
- import { NextResponse } from 'next/server';
4
- import { cacheHeaders } from '../../../../../lib/cache/cacheHeaders';
5
- import { resolvePrisma } from '../../../../../lib/prisma';
6
- import { getApiKey } from '../../../../../lib/apiKeys/getApiKey';
7
- import { getStorageProviderAssistants } from '../../../../../lib/storageProviders/getStorageProviderAssistants';
8
- import { serializeApiStorageProviderAssistant } from '../../../../../lib/storageProviders/serializeApiStorageProviderAssistant';
9
- export const buildGET = ({ prisma: providedPrisma } = {}) => async (_request, props) => {
10
- const prisma = resolvePrisma(providedPrisma);
11
- const { modelProviderId } = await props.params;
12
- const headersList = await headers();
13
- const authorization = headersList.get('authorization');
14
- if (!authorization) {
15
- return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
16
- }
17
- const privateApiKey = await getApiKey({
18
- type: ApiKeyType.PRIVATE,
19
- authorization,
20
- prisma,
21
- });
22
- if (!privateApiKey) {
23
- return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
24
- }
25
- const provider = await prisma.modelProvider.findUnique({
26
- where: {
27
- id: modelProviderId,
28
- workspaceId: privateApiKey.workspaceId,
29
- },
30
- });
31
- if (!provider) {
32
- return NextResponse.json({ error: 'No provider found' }, { status: 400 });
33
- }
34
- const storageProviderAssistants = await getStorageProviderAssistants({
35
- modelProvider: provider,
36
- });
37
- return NextResponse.json({
38
- storageProviderAssistants: storageProviderAssistants.map((storageProviderAssistant) => serializeApiStorageProviderAssistant({
39
- storageProviderAssistant,
40
- })),
41
- }, { headers: cacheHeaders });
42
- };
43
- export const GET = ((...args) => buildGET()(...args));
44
- export const OPTIONS = () => NextResponse.json({}, {
45
- headers: cacheHeaders,
46
- });
1
+ import { prisma } from '../../../../../lib/prisma';
2
+ import { buildGET, buildOPTIONS } from './buildRoute';
3
+ export const GET = buildGET({ prisma });
4
+ export const OPTIONS = buildOPTIONS();
@@ -0,0 +1,61 @@
1
+ import { type PrismaClient } from '@prisma/client';
2
+ import { NextResponse, type NextRequest } from 'next/server';
3
+ type RouteProps = {
4
+ params: Promise<{
5
+ modelProviderId: string;
6
+ }>;
7
+ };
8
+ export declare const buildGET: ({ prisma }: {
9
+ prisma: PrismaClient;
10
+ }) => (_request: NextRequest, props: RouteProps) => Promise<NextResponse<{
11
+ error: string;
12
+ }> | NextResponse<{
13
+ provider: {
14
+ id: string;
15
+ type: import("@prisma/client").$Enums.ModelProviderType;
16
+ name: string;
17
+ apiKey: string;
18
+ endpoint: string | null;
19
+ apiVersion: string | null;
20
+ workspaceId: string;
21
+ createdAt: string;
22
+ updatedAt: string;
23
+ };
24
+ }>>;
25
+ export declare const buildPATCH: ({ prisma }: {
26
+ prisma: PrismaClient;
27
+ }) => (request: NextRequest, props: RouteProps) => Promise<NextResponse<{
28
+ error: string;
29
+ }> | NextResponse<{
30
+ provider: {
31
+ id: string;
32
+ type: import("@prisma/client").$Enums.ModelProviderType;
33
+ name: string;
34
+ apiKey: string;
35
+ endpoint: string | null;
36
+ apiVersion: string | null;
37
+ workspaceId: string;
38
+ createdAt: string;
39
+ updatedAt: string;
40
+ };
41
+ }>>;
42
+ export declare const buildDELETE: ({ prisma }: {
43
+ prisma: PrismaClient;
44
+ }) => (_request: NextRequest, props: RouteProps) => Promise<NextResponse<{
45
+ error: string;
46
+ }> | NextResponse<{
47
+ provider: {
48
+ id: string;
49
+ type: import("@prisma/client").$Enums.ModelProviderType;
50
+ name: string;
51
+ apiKey: string;
52
+ endpoint: string | null;
53
+ apiVersion: string | null;
54
+ workspaceId: string;
55
+ createdAt: string;
56
+ updatedAt: string;
57
+ };
58
+ }>>;
59
+ export declare const buildOPTIONS: () => () => NextResponse<{}>;
60
+ export {};
61
+ //# sourceMappingURL=buildRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildRoute.d.ts","sourceRoot":"","sources":["../../../../../src/app/api/providers/[modelProviderId]/buildRoute.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAO5D,KAAK,UAAU,GAAG;IAChB,MAAM,EAAE,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC7C,CAAA;AAED,eAAO,MAAM,QAAQ,GAClB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,MAC9B,UAAU,WAAW,EAAE,OAAO,UAAU;;;;;;;;;;;;;;GA8C9C,CAAA;AAEH,eAAO,MAAM,UAAU,GACpB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,MAC9B,SAAS,WAAW,EAAE,OAAO,UAAU;;;;;;;;;;;;;;GAiF7C,CAAA;AAEH,eAAO,MAAM,WAAW,GACrB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,MAC9B,UAAU,WAAW,EAAE,OAAO,UAAU;;;;;;;;;;;;;;GA6D9C,CAAA;AAEH,eAAO,MAAM,YAAY,8BAMtB,CAAA"}
@@ -0,0 +1,134 @@
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
+ import { validate } from 'uuid';
9
+ export const buildGET = ({ prisma }) => async (_request, props) => {
10
+ const { modelProviderId } = await props.params;
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
+ if (!validate(modelProviderId)) {
25
+ return NextResponse.json({ error: 'Invalid provider id' }, { status: 400 });
26
+ }
27
+ const provider = await prisma.modelProvider.findFirst({
28
+ where: {
29
+ id: modelProviderId,
30
+ workspaceId: privateApiKey.workspaceId,
31
+ },
32
+ });
33
+ if (!provider) {
34
+ return NextResponse.json({ error: 'No provider found' }, { status: 400 });
35
+ }
36
+ return NextResponse.json({
37
+ provider: serializeModelProvider({ provider }),
38
+ }, { headers: cacheHeaders });
39
+ };
40
+ export const buildPATCH = ({ prisma }) => async (request, props) => {
41
+ const { modelProviderId } = await props.params;
42
+ const headersList = await headers();
43
+ const authorization = headersList.get('authorization');
44
+ if (!authorization) {
45
+ return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
46
+ }
47
+ const privateApiKey = await getApiKey({
48
+ authorization,
49
+ type: ApiKeyType.PRIVATE,
50
+ prisma,
51
+ });
52
+ if (!privateApiKey) {
53
+ return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
54
+ }
55
+ if (!validate(modelProviderId)) {
56
+ return NextResponse.json({ error: 'Invalid provider id' }, { status: 400 });
57
+ }
58
+ const body = await request.json();
59
+ const schema = z.object({
60
+ type: z.nativeEnum(ModelProviderType).optional(),
61
+ name: z.string().optional(),
62
+ apiKey: z.string().optional(),
63
+ endpoint: z.string().optional().nullable(),
64
+ apiVersion: z.string().optional().nullable(),
65
+ });
66
+ const parsed = schema.safeParse(body);
67
+ if (!parsed.success) {
68
+ return NextResponse.json({ error: 'Invalid payload' }, { status: 400 });
69
+ }
70
+ const { type, apiKey: providerKey, endpoint, apiVersion, name, } = parsed.data;
71
+ const updateData = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (type ? { type } : {})), (name !== undefined ? { name } : {})), (providerKey !== undefined ? { apiKey: providerKey } : {})), (endpoint !== undefined ? { endpoint } : {})), (apiVersion !== undefined ? { apiVersion } : {}));
72
+ const existingProvider = await prisma.modelProvider.findFirst({
73
+ where: {
74
+ id: modelProviderId,
75
+ workspaceId: privateApiKey.workspaceId,
76
+ },
77
+ });
78
+ if (!existingProvider) {
79
+ return NextResponse.json({ error: 'No provider found' }, { status: 400 });
80
+ }
81
+ const provider = await prisma.modelProvider.update({
82
+ where: { id: modelProviderId },
83
+ data: updateData,
84
+ });
85
+ return NextResponse.json({
86
+ provider: serializeModelProvider({ provider }),
87
+ }, { headers: cacheHeaders });
88
+ };
89
+ export const buildDELETE = ({ prisma }) => async (_request, props) => {
90
+ const { modelProviderId } = await props.params;
91
+ const headersList = await headers();
92
+ const authorization = headersList.get('authorization');
93
+ if (!authorization) {
94
+ return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
95
+ }
96
+ const privateApiKey = await getApiKey({
97
+ authorization,
98
+ type: ApiKeyType.PRIVATE,
99
+ prisma,
100
+ });
101
+ if (!privateApiKey) {
102
+ return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
103
+ }
104
+ if (!validate(modelProviderId)) {
105
+ return NextResponse.json({ error: 'Invalid provider id' }, { status: 400 });
106
+ }
107
+ const assistantsUsingProvider = await prisma.assistant.count({
108
+ where: {
109
+ modelProviderId: modelProviderId,
110
+ workspaceId: privateApiKey.workspaceId,
111
+ },
112
+ });
113
+ if (assistantsUsingProvider > 0) {
114
+ return NextResponse.json({ error: 'Provider in use' }, { status: 400 });
115
+ }
116
+ const existingProvider = await prisma.modelProvider.findFirst({
117
+ where: {
118
+ id: modelProviderId,
119
+ workspaceId: privateApiKey.workspaceId,
120
+ },
121
+ });
122
+ if (!existingProvider) {
123
+ return NextResponse.json({ error: 'No provider found' }, { status: 400 });
124
+ }
125
+ const provider = await prisma.modelProvider.delete({
126
+ where: { id: modelProviderId },
127
+ });
128
+ return NextResponse.json({
129
+ provider: serializeModelProvider({ provider }),
130
+ }, { headers: cacheHeaders });
131
+ };
132
+ export const buildOPTIONS = () => () => NextResponse.json({}, {
133
+ headers: cacheHeaders,
134
+ });
@@ -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
+ modelProviderId: string;
6
+ }>;
7
+ };
8
+ export declare const buildGET: ({ prisma }: {
9
+ prisma: PrismaClient;
10
+ }) => (_request: NextRequest, props: RouteProps) => Promise<NextResponse<{
11
+ error: string;
12
+ }> | NextResponse<{
13
+ models: {
14
+ id: string;
15
+ }[];
16
+ }>>;
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/providers/[modelProviderId]/models/buildRoute.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAM5D,KAAK,UAAU,GAAG;IAChB,MAAM,EAAE,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC7C,CAAA;AAED,eAAO,MAAM,QAAQ,GAClB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,MAC9B,UAAU,WAAW,EAAE,OAAO,UAAU;;;;;;GAgD9C,CAAA;AAEH,eAAO,MAAM,YAAY,8BAMtB,CAAA"}
@@ -0,0 +1,43 @@
1
+ import { headers } from 'next/headers';
2
+ import { ApiKeyType } from '@prisma/client';
3
+ import { NextResponse } from 'next/server';
4
+ import { cacheHeaders } from '../../../../../lib/cache/cacheHeaders';
5
+ import { getApiKey } from '../../../../../lib/apiKeys/getApiKey';
6
+ import { getModels } from '../../../../../lib/models/getModels';
7
+ import { serializeApiModel } from '../../../../../lib/models/serializeApiModel';
8
+ export const buildGET = ({ prisma }) => async (_request, props) => {
9
+ const { modelProviderId } = await props.params;
10
+ const headersList = await headers();
11
+ const authorization = headersList.get('authorization');
12
+ if (!authorization) {
13
+ return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
14
+ }
15
+ const privateApiKey = await getApiKey({
16
+ type: ApiKeyType.PRIVATE,
17
+ authorization,
18
+ prisma,
19
+ });
20
+ if (!privateApiKey) {
21
+ return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
22
+ }
23
+ const provider = await prisma.modelProvider.findUnique({
24
+ where: {
25
+ id: modelProviderId,
26
+ workspaceId: privateApiKey.workspaceId,
27
+ },
28
+ });
29
+ if (!provider) {
30
+ return NextResponse.json({ error: 'No provider found' }, { status: 400 });
31
+ }
32
+ const models = await getModels({
33
+ modelProvider: provider,
34
+ });
35
+ return NextResponse.json({
36
+ models: models.map((model) => serializeApiModel({
37
+ model,
38
+ })),
39
+ }, { headers: cacheHeaders });
40
+ };
41
+ export const buildOPTIONS = () => () => NextResponse.json({}, {
42
+ headers: cacheHeaders,
43
+ });
@@ -1,18 +1,13 @@
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
  modelProviderId: string;
8
4
  }>;
9
- }) => Promise<NextResponse<{
5
+ }) => Promise<import("next/server").NextResponse<{
10
6
  error: string;
11
- }> | NextResponse<{
7
+ }> | import("next/server").NextResponse<{
12
8
  models: {
13
9
  id: string;
14
10
  }[];
15
11
  }>>;
16
- export declare const GET: ReturnType<typeof buildGET>;
17
- export declare const OPTIONS: () => NextResponse<{}>;
12
+ export declare const OPTIONS: () => import("next/server").NextResponse<{}>;
18
13
  //# sourceMappingURL=route.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/providers/[modelProviderId]/models/route.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAO5D,eAAO,MAAM,QAAQ,GAClB,6BAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,UAAU,WAAW,EACrB,OAAO;IACL,MAAM,EAAE,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC7C;;;;;;GAkDF,CAAA;AAEH,eAAO,MAAM,GAAG,EACU,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAA;AAErD,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/providers/[modelProviderId]/models/route.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,GAAG;;;;;;;;;;GAAuB,CAAA;AAEvC,eAAO,MAAM,OAAO,8CAAiB,CAAA"}
@@ -1,46 +1,4 @@
1
- import { headers } from 'next/headers';
2
- import { ApiKeyType } from '@prisma/client';
3
- import { NextResponse } from 'next/server';
4
- import { cacheHeaders } from '../../../../../lib/cache/cacheHeaders';
5
- import { resolvePrisma } from '../../../../../lib/prisma';
6
- import { getApiKey } from '../../../../../lib/apiKeys/getApiKey';
7
- import { getModels } from '../../../../../lib/models/getModels';
8
- import { serializeApiModel } from '../../../../../lib/models/serializeApiModel';
9
- export const buildGET = ({ prisma: providedPrisma } = {}) => async (_request, props) => {
10
- const prisma = resolvePrisma(providedPrisma);
11
- const { modelProviderId } = await props.params;
12
- const headersList = await headers();
13
- const authorization = headersList.get('authorization');
14
- if (!authorization) {
15
- return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
16
- }
17
- const privateApiKey = await getApiKey({
18
- type: ApiKeyType.PRIVATE,
19
- authorization,
20
- prisma,
21
- });
22
- if (!privateApiKey) {
23
- return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
24
- }
25
- const provider = await prisma.modelProvider.findUnique({
26
- where: {
27
- id: modelProviderId,
28
- workspaceId: privateApiKey.workspaceId,
29
- },
30
- });
31
- if (!provider) {
32
- return NextResponse.json({ error: 'No provider found' }, { status: 400 });
33
- }
34
- const models = await getModels({
35
- modelProvider: provider,
36
- });
37
- return NextResponse.json({
38
- models: models.map((model) => serializeApiModel({
39
- model,
40
- })),
41
- }, { headers: cacheHeaders });
42
- };
43
- export const GET = ((...args) => buildGET()(...args));
44
- export const OPTIONS = () => NextResponse.json({}, {
45
- headers: cacheHeaders,
46
- });
1
+ import { prisma } from '../../../../../lib/prisma';
2
+ import { buildGET, buildOPTIONS } from './buildRoute';
3
+ export const GET = buildGET({ prisma });
4
+ export const OPTIONS = buildOPTIONS();
@@ -1,14 +1,10 @@
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
  modelProviderId: string;
8
4
  }>;
9
- }) => Promise<NextResponse<{
5
+ }) => Promise<import("next/server").NextResponse<{
10
6
  error: string;
11
- }> | NextResponse<{
7
+ }> | import("next/server").NextResponse<{
12
8
  provider: {
13
9
  id: string;
14
10
  type: import("@prisma/client").$Enums.ModelProviderType;
@@ -21,16 +17,13 @@ export declare const buildGET: ({ prisma: providedPrisma }?: {
21
17
  updatedAt: string;
22
18
  };
23
19
  }>>;
24
- export declare const GET: ReturnType<typeof buildGET>;
25
- export declare const buildPATCH: ({ prisma: providedPrisma }?: {
26
- prisma?: PrismaClient;
27
- }) => (request: NextRequest, props: {
20
+ export declare const PATCH: (request: import("next/server").NextRequest, props: {
28
21
  params: Promise<{
29
22
  modelProviderId: string;
30
23
  }>;
31
- }) => Promise<NextResponse<{
24
+ }) => Promise<import("next/server").NextResponse<{
32
25
  error: string;
33
- }> | NextResponse<{
26
+ }> | import("next/server").NextResponse<{
34
27
  provider: {
35
28
  id: string;
36
29
  type: import("@prisma/client").$Enums.ModelProviderType;
@@ -43,16 +36,13 @@ export declare const buildPATCH: ({ prisma: providedPrisma }?: {
43
36
  updatedAt: string;
44
37
  };
45
38
  }>>;
46
- export declare const PATCH: ReturnType<typeof buildPATCH>;
47
- export declare const buildDELETE: ({ prisma: providedPrisma }?: {
48
- prisma?: PrismaClient;
49
- }) => (_request: NextRequest, props: {
39
+ export declare const DELETE: (_request: import("next/server").NextRequest, props: {
50
40
  params: Promise<{
51
41
  modelProviderId: string;
52
42
  }>;
53
- }) => Promise<NextResponse<{
43
+ }) => Promise<import("next/server").NextResponse<{
54
44
  error: string;
55
- }> | NextResponse<{
45
+ }> | import("next/server").NextResponse<{
56
46
  provider: {
57
47
  id: string;
58
48
  type: import("@prisma/client").$Enums.ModelProviderType;
@@ -65,6 +55,5 @@ export declare const buildDELETE: ({ prisma: providedPrisma }?: {
65
55
  updatedAt: string;
66
56
  };
67
57
  }>>;
68
- export declare const DELETE: ReturnType<typeof buildDELETE>;
69
- export declare const OPTIONS: () => NextResponse<{}>;
58
+ export declare const OPTIONS: () => import("next/server").NextResponse<{}>;
70
59
  //# sourceMappingURL=route.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../src/app/api/providers/[modelProviderId]/route.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAQ5D,eAAO,MAAM,QAAQ,GAClB,6BAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,UAAU,WAAW,EACrB,OAAO;IACL,MAAM,EAAE,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC7C;;;;;;;;;;;;;;GAgDF,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;IACL,MAAM,EAAE,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC7C;;;;;;;;;;;;;;GAmFF,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;IACL,MAAM,EAAE,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC7C;;;;;;;;;;;;;;GA+DF,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/providers/[modelProviderId]/route.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;GAAuB,CAAA;AAEvC,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;GAAyB,CAAA;AAE3C,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;GAA0B,CAAA;AAE7C,eAAO,MAAM,OAAO,8CAAiB,CAAA"}
@@ -1,141 +1,6 @@
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
- import { validate } from 'uuid';
10
- export const buildGET = ({ prisma: providedPrisma } = {}) => async (_request, props) => {
11
- const prisma = resolvePrisma(providedPrisma);
12
- const { modelProviderId } = await props.params;
13
- const headersList = await headers();
14
- const authorization = headersList.get('authorization');
15
- if (!authorization) {
16
- return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
17
- }
18
- const privateApiKey = await getApiKey({
19
- type: ApiKeyType.PRIVATE,
20
- authorization,
21
- prisma,
22
- });
23
- if (!privateApiKey) {
24
- return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
25
- }
26
- if (!validate(modelProviderId)) {
27
- return NextResponse.json({ error: 'Invalid provider id' }, { status: 400 });
28
- }
29
- const provider = await prisma.modelProvider.findFirst({
30
- where: {
31
- id: modelProviderId,
32
- workspaceId: privateApiKey.workspaceId,
33
- },
34
- });
35
- if (!provider) {
36
- return NextResponse.json({ error: 'No provider found' }, { status: 400 });
37
- }
38
- return NextResponse.json({
39
- provider: serializeModelProvider({ provider }),
40
- }, { headers: cacheHeaders });
41
- };
42
- export const GET = ((...args) => buildGET()(...args));
43
- export const buildPATCH = ({ prisma: providedPrisma } = {}) => async (request, props) => {
44
- const prisma = resolvePrisma(providedPrisma);
45
- const { modelProviderId } = await props.params;
46
- const headersList = await headers();
47
- const authorization = headersList.get('authorization');
48
- if (!authorization) {
49
- return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
50
- }
51
- const privateApiKey = await getApiKey({
52
- authorization,
53
- type: ApiKeyType.PRIVATE,
54
- prisma,
55
- });
56
- if (!privateApiKey) {
57
- return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
58
- }
59
- if (!validate(modelProviderId)) {
60
- return NextResponse.json({ error: 'Invalid provider id' }, { status: 400 });
61
- }
62
- const body = await request.json();
63
- const schema = z.object({
64
- type: z.nativeEnum(ModelProviderType).optional(),
65
- name: z.string().optional(),
66
- apiKey: z.string().optional(),
67
- endpoint: z.string().optional().nullable(),
68
- apiVersion: z.string().optional().nullable(),
69
- });
70
- const parsed = schema.safeParse(body);
71
- if (!parsed.success) {
72
- return NextResponse.json({ error: 'Invalid payload' }, { status: 400 });
73
- }
74
- const { type, apiKey: providerKey, endpoint, apiVersion, name, } = parsed.data;
75
- const updateData = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (type ? { type } : {})), (name !== undefined ? { name } : {})), (providerKey !== undefined ? { apiKey: providerKey } : {})), (endpoint !== undefined ? { endpoint } : {})), (apiVersion !== undefined ? { apiVersion } : {}));
76
- const existingProvider = await prisma.modelProvider.findFirst({
77
- where: {
78
- id: modelProviderId,
79
- workspaceId: privateApiKey.workspaceId,
80
- },
81
- });
82
- if (!existingProvider) {
83
- return NextResponse.json({ error: 'No provider found' }, { status: 400 });
84
- }
85
- const provider = await prisma.modelProvider.update({
86
- where: { id: modelProviderId },
87
- data: updateData,
88
- });
89
- return NextResponse.json({
90
- provider: serializeModelProvider({ provider }),
91
- }, { headers: cacheHeaders });
92
- };
93
- export const PATCH = ((...args) => buildPATCH()(...args));
94
- export const buildDELETE = ({ prisma: providedPrisma } = {}) => async (_request, props) => {
95
- const prisma = resolvePrisma(providedPrisma);
96
- const { modelProviderId } = await props.params;
97
- const headersList = await headers();
98
- const authorization = headersList.get('authorization');
99
- if (!authorization) {
100
- return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
101
- }
102
- const privateApiKey = await getApiKey({
103
- authorization,
104
- type: ApiKeyType.PRIVATE,
105
- prisma,
106
- });
107
- if (!privateApiKey) {
108
- return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
109
- }
110
- if (!validate(modelProviderId)) {
111
- return NextResponse.json({ error: 'Invalid provider id' }, { status: 400 });
112
- }
113
- const assistantsUsingProvider = await prisma.assistant.count({
114
- where: {
115
- modelProviderId: modelProviderId,
116
- workspaceId: privateApiKey.workspaceId,
117
- },
118
- });
119
- if (assistantsUsingProvider > 0) {
120
- return NextResponse.json({ error: 'Provider in use' }, { status: 400 });
121
- }
122
- const existingProvider = await prisma.modelProvider.findFirst({
123
- where: {
124
- id: modelProviderId,
125
- workspaceId: privateApiKey.workspaceId,
126
- },
127
- });
128
- if (!existingProvider) {
129
- return NextResponse.json({ error: 'No provider found' }, { status: 400 });
130
- }
131
- const provider = await prisma.modelProvider.delete({
132
- where: { id: modelProviderId },
133
- });
134
- return NextResponse.json({
135
- provider: serializeModelProvider({ provider }),
136
- }, { headers: cacheHeaders });
137
- };
138
- export const DELETE = ((...args) => buildDELETE()(...args));
139
- export const OPTIONS = () => NextResponse.json({}, {
140
- headers: cacheHeaders,
141
- });
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();