@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,90 +1,5 @@
1
- import { headers } from 'next/headers';
2
- import { ApiKeyType } from '@prisma/client';
3
- import { NextResponse } from 'next/server';
4
- import { createTaskSchema } from '../../../lib/tasks/schemas';
5
- import { cacheHeaders } from '../../../lib/cache/cacheHeaders';
6
- import { resolvePrisma } from '../../../lib/prisma';
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
- export const buildGET = ({ prisma: providedPrisma } = {}) => async (request) => {
12
- const prisma = resolvePrisma(providedPrisma);
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
- authorization,
20
- type: ApiKeyType.PRIVATE,
21
- prisma,
22
- });
23
- if (!privateApiKey) {
24
- return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
25
- }
26
- const key = request.nextUrl.searchParams.get('key');
27
- const tasks = await prisma.task.findMany({
28
- where: Object.assign(Object.assign({}, (key ? { key } : {})), { thread: { assistant: { workspaceId: privateApiKey.workspaceId } } }),
29
- orderBy: { createdAt: 'desc' },
30
- });
31
- return NextResponse.json({
32
- tasks: tasks.map((t) => serializeTask({ task: t })),
33
- }, { headers: cacheHeaders });
34
- };
35
- export const GET = ((...args) => buildGET()(...args));
36
- export const buildPOST = ({ prisma: providedPrisma } = {}) => async (request) => {
37
- var _a;
38
- const prisma = resolvePrisma(providedPrisma);
39
- const headersList = await headers();
40
- const authorization = headersList.get('authorization');
41
- if (!authorization) {
42
- return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
43
- }
44
- const privateApiKey = await getApiKey({
45
- authorization,
46
- type: ApiKeyType.PRIVATE,
47
- prisma,
48
- });
49
- if (!privateApiKey) {
50
- return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
51
- }
52
- const parsed = createTaskSchema.safeParse(await request.json());
53
- if (!parsed.success) {
54
- return NextResponse.json({ error: 'Invalid payload' }, { status: 400 });
55
- }
56
- const { title, message, schedule, threadId } = parsed.data;
57
- if (!validateSchedule(schedule)) {
58
- return NextResponse.json({ error: 'Invalid schedule' }, { status: 400 });
59
- }
60
- const thread = await prisma.thread.findFirst({
61
- where: {
62
- id: threadId,
63
- assistant: {
64
- workspaceId: privateApiKey.workspaceId,
65
- },
66
- },
67
- });
68
- if (!thread) {
69
- return NextResponse.json({ error: 'Thread not found' }, { status: 400 });
70
- }
71
- const task = await prisma.task.create({
72
- data: {
73
- title,
74
- message,
75
- schedule,
76
- thread: {
77
- connect: { id: thread.id },
78
- },
79
- key: (_a = parsed.data.key) !== null && _a !== void 0 ? _a : '',
80
- },
81
- });
82
- await scheduleTask({ task, prisma });
83
- return NextResponse.json({
84
- task: serializeTask({ task }),
85
- }, { headers: cacheHeaders });
86
- };
87
- export const POST = ((...args) => buildPOST()(...args));
88
- export const OPTIONS = () => NextResponse.json({}, {
89
- headers: cacheHeaders,
90
- });
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,10 @@
1
+ import { NextRequest, NextResponse } from 'next/server';
2
+ import { type PrismaClient } from '@prisma/client';
3
+ export declare const buildPOST: ({ prisma }: {
4
+ prisma: PrismaClient;
5
+ }) => (request: NextRequest) => Promise<NextResponse<{
6
+ error: string;
7
+ }> | NextResponse<{
8
+ status: string;
9
+ }>>;
10
+ //# sourceMappingURL=buildRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildRoute.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/threads/runs/submit-client-tool-outputs/buildRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEvD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAGlD,eAAO,MAAM,SAAS,GACnB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,MAC9B,SAAS,WAAW;;;;GAqD1B,CAAA"}
@@ -0,0 +1,36 @@
1
+ import { NextResponse } from 'next/server';
2
+ import { redis } from '../../../../../lib/redis';
3
+ import { workspaceAccessWhere as getWorkspaceAccessWhere } from '../../../../../lib/apiKeys/workspaceAccessWhere';
4
+ export const buildPOST = ({ prisma }) => async (request) => {
5
+ const body = await request.json();
6
+ const { assistantId, publicApiKey, toolOutputs } = body;
7
+ const workspaceAccessWhere = await getWorkspaceAccessWhere({
8
+ publicApiKey,
9
+ prisma,
10
+ });
11
+ if (!workspaceAccessWhere) {
12
+ return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
13
+ }
14
+ if (!assistantId) {
15
+ return NextResponse.json({ error: 'No assistant id found' }, { status: 400 });
16
+ }
17
+ const assistant = await prisma.assistant.findFirst({
18
+ where: {
19
+ id: assistantId,
20
+ workspace: workspaceAccessWhere,
21
+ },
22
+ });
23
+ if (!assistant) {
24
+ return NextResponse.json({ error: 'No assistant found' }, { status: 400 });
25
+ }
26
+ if (!Array.isArray(toolOutputs)) {
27
+ return NextResponse.json({ error: 'Invalid tool outputs' }, { status: 400 });
28
+ }
29
+ await Promise.all(toolOutputs.map(async (toolOutput) => {
30
+ const isPending = await redis.get(`submit-client-tool-outputs:pending:${toolOutput.toolCallId}`);
31
+ if (isPending) {
32
+ await redis.set(`submit-client-tool-outputs:output:${toolOutput.toolCallId}`, JSON.stringify(toolOutput.output), { ex: 60 * 60 * 24 * 7 });
33
+ }
34
+ }));
35
+ return NextResponse.json({ status: 'success' });
36
+ };
@@ -1,11 +1,6 @@
1
- import { NextRequest, NextResponse } from 'next/server';
2
- import { type PrismaClient } from '@prisma/client';
3
- export declare const buildPOST: ({ prisma: providedPrisma }?: {
4
- prisma?: PrismaClient;
5
- }) => (request: NextRequest) => Promise<NextResponse<{
1
+ export declare const POST: (request: import("next/server").NextRequest) => Promise<import("next/server").NextResponse<{
6
2
  error: string;
7
- }> | NextResponse<{
3
+ }> | import("next/server").NextResponse<{
8
4
  status: string;
9
5
  }>>;
10
- export declare const POST: ReturnType<typeof buildPOST>;
11
6
  //# sourceMappingURL=route.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/threads/runs/submit-client-tool-outputs/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAGvD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAGlD,eAAO,MAAM,SAAS,GACnB,6BAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MACpD,SAAS,WAAW;;;;GAiD1B,CAAA;AAEH,eAAO,MAAM,IAAI,EACU,UAAU,CAAC,OAAO,SAAS,CAAC,CAAA"}
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/threads/runs/submit-client-tool-outputs/route.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,IAAI;;;;GAAwB,CAAA"}
@@ -1,37 +1,3 @@
1
- import { NextResponse } from 'next/server';
2
- import { redis } from '../../../../../lib/redis';
3
- import { resolvePrisma } from '../../../../../lib/prisma';
4
- import { workspaceAccessWhere as getWorkspaceAccessWhere } from '../../../../../lib/apiKeys/workspaceAccessWhere';
5
- export const buildPOST = ({ prisma: providedPrisma } = {}) => async (request) => {
6
- const prisma = resolvePrisma(providedPrisma);
7
- const body = await request.json();
8
- const { assistantId, publicApiKey, toolOutputs } = body;
9
- const workspaceAccessWhere = await getWorkspaceAccessWhere({
10
- publicApiKey,
11
- prisma,
12
- });
13
- if (!workspaceAccessWhere) {
14
- return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
15
- }
16
- if (!assistantId) {
17
- return NextResponse.json({ error: 'No assistant id found' }, { status: 400 });
18
- }
19
- const assistant = await prisma.assistant.findFirst({
20
- where: {
21
- id: assistantId,
22
- workspace: workspaceAccessWhere,
23
- },
24
- });
25
- if (!assistant) {
26
- return NextResponse.json({ error: 'No assistant found' }, { status: 400 });
27
- }
28
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
- await Promise.all(toolOutputs.map(async (toolOutput) => {
30
- const isPending = await redis.get(`submit-client-tool-outputs:pending:${toolOutput.toolCallId}`);
31
- if (isPending) {
32
- await redis.set(`submit-client-tool-outputs:output:${toolOutput.toolCallId}`, JSON.stringify(toolOutput.output), { ex: 60 * 60 * 24 * 7 });
33
- }
34
- }));
35
- return NextResponse.json({ status: 'success' });
36
- };
37
- export const POST = ((...args) => buildPOST()(...args));
1
+ import { prisma } from '../../../../../lib/prisma';
2
+ import { buildPOST } from './buildRoute';
3
+ export const POST = buildPOST({ prisma });
@@ -0,0 +1,16 @@
1
+ import { type PrismaClient } from '@prisma/client';
2
+ import { NextResponse, type NextRequest } from 'next/server';
3
+ type RouteProps = {
4
+ params: Promise<{
5
+ workspaceId: 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 buildOPTIONS: () => () => NextResponse<{}>;
15
+ export {};
16
+ //# sourceMappingURL=buildRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildRoute.d.ts","sourceRoot":"","sources":["../../../../../src/app/api/workspaces/[workspaceId]/buildRoute.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAO5D,KAAK,UAAU,GAAG;IAChB,MAAM,EAAE,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACzC,CAAA;AA8CD,eAAO,MAAM,QAAQ,GAClB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,MAC9B,UAAU,WAAW,EAAE,OAAO,UAAU,mCA2B9C,CAAA;AAEH,eAAO,MAAM,UAAU,GACpB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,MAC9B,SAAS,WAAW,EAAE,OAAO,UAAU,mCAgD7C,CAAA;AAEH,eAAO,MAAM,YAAY,8BAMtB,CAAA"}
@@ -0,0 +1,89 @@
1
+ import { headers } from 'next/headers';
2
+ import { NextResponse } from 'next/server';
3
+ import { z } from 'zod';
4
+ import { cacheHeaders } from '../../../../lib/cache/cacheHeaders';
5
+ import { validate } from 'uuid';
6
+ import { getOrganizationApiKey } from '../../../../lib/organizationApiKeys/getOrganizationApiKey';
7
+ import { serializeApiWorkspace } from '../../../../lib/workspaces/serializeApiWorkspace';
8
+ const ensureValidWorkspaceId = (workspaceId) => {
9
+ if (!validate(workspaceId)) {
10
+ return NextResponse.json({ error: 'Invalid workspace id' }, { status: 400 });
11
+ }
12
+ return null;
13
+ };
14
+ const authorize = async ({ prisma, }) => {
15
+ const headersList = await headers();
16
+ const authorization = headersList.get('authorization');
17
+ if (!authorization) {
18
+ return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
19
+ }
20
+ const organizationApiKey = await getOrganizationApiKey({
21
+ authorization,
22
+ prisma,
23
+ });
24
+ if (!organizationApiKey) {
25
+ return NextResponse.json({ error: 'Invalid organization api key' }, { status: 400 });
26
+ }
27
+ return { organizationApiKey };
28
+ };
29
+ export const buildGET = ({ prisma }) => async (_request, props) => {
30
+ const { workspaceId } = await props.params;
31
+ const authorized = await authorize({ prisma });
32
+ if (authorized instanceof NextResponse)
33
+ return authorized;
34
+ const { organizationApiKey } = authorized;
35
+ const validationError = ensureValidWorkspaceId(workspaceId);
36
+ if (validationError)
37
+ return validationError;
38
+ const workspace = await prisma.workspace.findFirst({
39
+ where: {
40
+ id: workspaceId,
41
+ organizationId: organizationApiKey.organizationId,
42
+ },
43
+ });
44
+ if (!workspace) {
45
+ return NextResponse.json({ error: 'No workspace found' }, { status: 400 });
46
+ }
47
+ return NextResponse.json({
48
+ workspace: serializeApiWorkspace({ workspace }),
49
+ }, { headers: cacheHeaders });
50
+ };
51
+ export const buildPATCH = ({ prisma }) => async (request, props) => {
52
+ const { workspaceId } = await props.params;
53
+ const authorized = await authorize({ prisma });
54
+ if (authorized instanceof NextResponse)
55
+ return authorized;
56
+ const { organizationApiKey } = authorized;
57
+ const validationError = ensureValidWorkspaceId(workspaceId);
58
+ if (validationError)
59
+ return validationError;
60
+ const body = await request.json();
61
+ const schema = z.object({
62
+ name: z.string().optional(),
63
+ });
64
+ const parsed = schema.safeParse(body);
65
+ if (!parsed.success) {
66
+ return NextResponse.json({ error: 'Invalid payload' }, { status: 400 });
67
+ }
68
+ const { name } = parsed.data;
69
+ const updateData = Object.assign({}, (name !== undefined ? { name } : {}));
70
+ const existingWorkspace = await prisma.workspace.findFirst({
71
+ where: {
72
+ id: workspaceId,
73
+ organizationId: organizationApiKey.organizationId,
74
+ },
75
+ });
76
+ if (!existingWorkspace) {
77
+ return NextResponse.json({ error: 'No workspace found' }, { status: 400 });
78
+ }
79
+ const workspace = await prisma.workspace.update({
80
+ where: { id: workspaceId },
81
+ data: updateData,
82
+ });
83
+ return NextResponse.json({
84
+ workspace: serializeApiWorkspace({ workspace }),
85
+ }, { headers: cacheHeaders });
86
+ };
87
+ export const buildOPTIONS = () => () => NextResponse.json({}, {
88
+ headers: cacheHeaders,
89
+ });
@@ -1,38 +1,12 @@
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
  workspaceId: string;
8
4
  }>;
9
- }) => Promise<NextResponse<{
10
- error: string;
11
- }> | NextResponse<{
12
- workspace: {
13
- id: string;
14
- name: string;
15
- createdAt: string;
16
- updatedAt: string;
17
- };
18
- }>>;
19
- export declare const GET: ReturnType<typeof buildGET>;
20
- export declare const buildPATCH: ({ prisma: providedPrisma }?: {
21
- prisma?: PrismaClient;
22
- }) => (request: NextRequest, props: {
5
+ }) => Promise<import("next/server").NextResponse<unknown>>;
6
+ export declare const PATCH: (request: import("next/server").NextRequest, props: {
23
7
  params: Promise<{
24
8
  workspaceId: string;
25
9
  }>;
26
- }) => Promise<NextResponse<{
27
- error: string;
28
- }> | NextResponse<{
29
- workspace: {
30
- id: string;
31
- name: string;
32
- createdAt: string;
33
- updatedAt: string;
34
- };
35
- }>>;
36
- export declare const PATCH: ReturnType<typeof buildPATCH>;
37
- export declare const OPTIONS: () => NextResponse<{}>;
10
+ }) => Promise<import("next/server").NextResponse<unknown>>;
11
+ export declare const OPTIONS: () => import("next/server").NextResponse<{}>;
38
12
  //# sourceMappingURL=route.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../src/app/api/workspaces/[workspaceId]/route.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC1D,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,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACzC;;;;;;;;;GAmDF,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,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACzC;;;;;;;;;GAuEF,CAAA;AAEH,eAAO,MAAM,KAAK,EACU,UAAU,CAAC,OAAO,UAAU,CAAC,CAAA;AAEzD,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../src/app/api/workspaces/[workspaceId]/route.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,GAAG;;;;0DAAuB,CAAA;AAEvC,eAAO,MAAM,KAAK;;;;0DAAyB,CAAA;AAE3C,eAAO,MAAM,OAAO,8CAAiB,CAAA"}
@@ -1,89 +1,5 @@
1
- import { headers } from 'next/headers';
2
- import { NextResponse } from 'next/server';
3
- import { z } from 'zod';
4
- import { cacheHeaders } from '../../../../lib/cache/cacheHeaders';
5
- import { resolvePrisma } from '../../../../lib/prisma';
6
- import { validate } from 'uuid';
7
- import { getOrganizationApiKey } from '../../../../lib/organizationApiKeys/getOrganizationApiKey';
8
- import { serializeApiWorkspace } from '../../../../lib/workspaces/serializeApiWorkspace';
9
- export const buildGET = ({ prisma: providedPrisma } = {}) => async (_request, props) => {
10
- const prisma = resolvePrisma(providedPrisma);
11
- const { workspaceId } = 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 organizationApiKey = await getOrganizationApiKey({
18
- authorization,
19
- prisma,
20
- });
21
- if (!organizationApiKey) {
22
- return NextResponse.json({ error: 'Invalid organization api key' }, { status: 400 });
23
- }
24
- if (!validate(workspaceId)) {
25
- return NextResponse.json({ error: 'Invalid workspace id' }, { status: 400 });
26
- }
27
- const workspace = await prisma.workspace.findFirst({
28
- where: {
29
- id: workspaceId,
30
- organizationId: organizationApiKey.organizationId,
31
- },
32
- });
33
- if (!workspace) {
34
- return NextResponse.json({ error: 'No workspace found' }, { status: 400 });
35
- }
36
- return NextResponse.json({
37
- workspace: serializeApiWorkspace({ workspace }),
38
- }, { headers: cacheHeaders });
39
- };
40
- export const GET = ((...args) => buildGET()(...args));
41
- export const buildPATCH = ({ prisma: providedPrisma } = {}) => async (request, props) => {
42
- const prisma = resolvePrisma(providedPrisma);
43
- const { workspaceId } = await props.params;
44
- const headersList = await headers();
45
- const authorization = headersList.get('authorization');
46
- if (!authorization) {
47
- return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
48
- }
49
- const organizationApiKey = await getOrganizationApiKey({
50
- authorization,
51
- prisma,
52
- });
53
- if (!organizationApiKey) {
54
- return NextResponse.json({ error: 'Invalid organization api key' }, { status: 400 });
55
- }
56
- if (!validate(workspaceId)) {
57
- return NextResponse.json({ error: 'Invalid workspace id' }, { status: 400 });
58
- }
59
- const body = await request.json();
60
- const schema = z.object({
61
- name: z.string().optional(),
62
- });
63
- const parsed = schema.safeParse(body);
64
- if (!parsed.success) {
65
- return NextResponse.json({ error: 'Invalid payload' }, { status: 400 });
66
- }
67
- const { name } = parsed.data;
68
- const updateData = Object.assign({}, (name !== undefined ? { name } : {}));
69
- const existingWorkspace = await prisma.workspace.findFirst({
70
- where: {
71
- id: workspaceId,
72
- organizationId: organizationApiKey.organizationId,
73
- },
74
- });
75
- if (!existingWorkspace) {
76
- return NextResponse.json({ error: 'No workspace found' }, { status: 400 });
77
- }
78
- const workspace = await prisma.workspace.update({
79
- where: { id: workspaceId },
80
- data: updateData,
81
- });
82
- return NextResponse.json({
83
- workspace: serializeApiWorkspace({ workspace }),
84
- }, { headers: cacheHeaders });
85
- };
86
- export const PATCH = ((...args) => buildPATCH()(...args));
87
- export const OPTIONS = () => NextResponse.json({}, {
88
- headers: cacheHeaders,
89
- });
1
+ import { prisma } from '../../../../lib/prisma';
2
+ import { buildGET, buildOPTIONS, buildPATCH, } from './buildRoute';
3
+ export const GET = buildGET({ prisma });
4
+ export const PATCH = buildPATCH({ prisma });
5
+ export const OPTIONS = buildOPTIONS();
@@ -0,0 +1,42 @@
1
+ import type { Organization, Workspace, PrismaClient } from '@prisma/client';
2
+ import { NextResponse, type NextRequest } from 'next/server';
3
+ import { z } from 'zod';
4
+ declare const createWorkspaceSchema: z.ZodObject<{
5
+ name: z.ZodOptional<z.ZodString>;
6
+ }, "strip", z.ZodTypeAny, {
7
+ name?: string | undefined;
8
+ }, {
9
+ name?: string | undefined;
10
+ }>;
11
+ export declare const buildGET: ({ prisma }: {
12
+ prisma: PrismaClient;
13
+ }) => () => Promise<NextResponse<{
14
+ error: string;
15
+ }> | NextResponse<{
16
+ workspaces: {
17
+ id: string;
18
+ name: string;
19
+ createdAt: string;
20
+ updatedAt: string;
21
+ }[];
22
+ }>>;
23
+ export declare const buildPOST: ({ prisma, createWorkspace, }: {
24
+ prisma: PrismaClient;
25
+ createWorkspace?: ({ parsedData, organization, prisma, }: {
26
+ parsedData: z.infer<typeof createWorkspaceSchema>;
27
+ organization: Organization;
28
+ prisma: PrismaClient;
29
+ }) => Promise<Workspace>;
30
+ }) => (request: NextRequest) => Promise<NextResponse<{
31
+ error: string;
32
+ }> | NextResponse<{
33
+ workspace: {
34
+ id: string;
35
+ name: string;
36
+ createdAt: string;
37
+ updatedAt: string;
38
+ };
39
+ }>>;
40
+ export declare const buildOPTIONS: () => () => NextResponse<{}>;
41
+ export { createWorkspaceSchema };
42
+ //# sourceMappingURL=buildRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildRoute.d.ts","sourceRoot":"","sources":["../../../../src/app/api/workspaces/buildRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE3E,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAKvB,QAAA,MAAM,qBAAqB;;;;;;EAEzB,CAAA;AAEF,eAAO,MAAM,QAAQ,GAClB,YAAY;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE;;;;;;;;;GAsCpC,CAAA;AAEH,eAAO,MAAM,SAAS,GACnB,8BAiBE;IACD,MAAM,EAAE,YAAY,CAAA;IACpB,eAAe,CAAC,EAAE,CAAC,EACjB,UAAU,EACV,YAAY,EACZ,MAAM,GACP,EAAE;QACD,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;QACjD,YAAY,EAAE,YAAY,CAAA;QAC1B,MAAM,EAAE,YAAY,CAAA;KACrB,KAAK,OAAO,CAAC,SAAS,CAAC,CAAA;CACzB,MACM,SAAS,WAAW;;;;;;;;;GAuD1B,CAAA;AAEH,eAAO,MAAM,YAAY,8BAMtB,CAAA;AAEH,OAAO,EAAE,qBAAqB,EAAE,CAAA"}
@@ -0,0 +1,78 @@
1
+ import { headers } from 'next/headers';
2
+ import { NextResponse } from 'next/server';
3
+ import { z } from 'zod';
4
+ import { cacheHeaders } from '../../../lib/cache/cacheHeaders';
5
+ import { serializeApiWorkspace } from '../../../lib/workspaces/serializeApiWorkspace';
6
+ import { getOrganizationApiKey } from '../../../lib/organizationApiKeys/getOrganizationApiKey';
7
+ const createWorkspaceSchema = z.object({
8
+ name: z.string().optional(),
9
+ });
10
+ export const buildGET = ({ prisma }) => async () => {
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 organizationApiKey = await getOrganizationApiKey({
17
+ authorization,
18
+ prisma,
19
+ });
20
+ if (!organizationApiKey) {
21
+ return NextResponse.json({ error: 'Invalid organization api key' }, { status: 400 });
22
+ }
23
+ const workspaces = await prisma.workspace.findMany({
24
+ where: {
25
+ organizationId: organizationApiKey.organizationId,
26
+ },
27
+ });
28
+ return NextResponse.json({
29
+ workspaces: workspaces.map((workspace) => serializeApiWorkspace({ workspace })),
30
+ }, { headers: cacheHeaders });
31
+ };
32
+ export const buildPOST = ({ prisma, createWorkspace = ({ parsedData, organization, prisma, }) => {
33
+ var _a;
34
+ return prisma.workspace.create({
35
+ data: {
36
+ name: (_a = parsedData.name) !== null && _a !== void 0 ? _a : '',
37
+ organizationId: organization.id,
38
+ },
39
+ });
40
+ }, }) => async (request) => {
41
+ const headersList = await headers();
42
+ const authorization = headersList.get('authorization');
43
+ if (!authorization) {
44
+ return NextResponse.json({ error: 'No authorization header found' }, { status: 400 });
45
+ }
46
+ const organizationApiKey = await getOrganizationApiKey({
47
+ authorization,
48
+ prisma,
49
+ });
50
+ if (!organizationApiKey) {
51
+ return NextResponse.json({ error: 'Invalid organization api key' }, { status: 400 });
52
+ }
53
+ const body = await request.json();
54
+ const parsed = createWorkspaceSchema.safeParse(body);
55
+ if (!parsed.success) {
56
+ return NextResponse.json({ error: 'Invalid payload' }, { status: 400 });
57
+ }
58
+ const organization = await prisma.organization.findUnique({
59
+ where: {
60
+ id: organizationApiKey.organizationId,
61
+ },
62
+ });
63
+ if (!organization) {
64
+ return NextResponse.json({ error: 'Organization not found' }, { status: 404 });
65
+ }
66
+ const workspace = await createWorkspace({
67
+ parsedData: parsed.data,
68
+ organization,
69
+ prisma,
70
+ });
71
+ return NextResponse.json({
72
+ workspace: serializeApiWorkspace({ workspace }),
73
+ }, { headers: cacheHeaders });
74
+ };
75
+ export const buildOPTIONS = () => () => NextResponse.json({}, {
76
+ headers: cacheHeaders,
77
+ });
78
+ export { createWorkspaceSchema };
@@ -1,18 +1,8 @@
1
- import type { Organization, Workspace, PrismaClient } from '@prisma/client';
2
- import { NextResponse, type NextRequest } from 'next/server';
3
- import { z } from 'zod';
4
- declare const createWorkspaceSchema: z.ZodObject<{
5
- name: z.ZodOptional<z.ZodString>;
6
- }, "strip", z.ZodTypeAny, {
7
- name?: string | undefined;
8
- }, {
9
- name?: string | undefined;
10
- }>;
11
- export declare const buildGET: ({ prisma: providedPrisma }?: {
12
- prisma?: PrismaClient;
13
- }) => () => Promise<NextResponse<{
1
+ import { createWorkspaceSchema } from './buildRoute';
2
+ export { createWorkspaceSchema };
3
+ export declare const GET: () => Promise<import("next/server").NextResponse<{
14
4
  error: string;
15
- }> | NextResponse<{
5
+ }> | import("next/server").NextResponse<{
16
6
  workspaces: {
17
7
  id: string;
18
8
  name: string;
@@ -20,17 +10,9 @@ export declare const buildGET: ({ prisma: providedPrisma }?: {
20
10
  updatedAt: string;
21
11
  }[];
22
12
  }>>;
23
- export declare const GET: ReturnType<typeof buildGET>;
24
- export declare const buildPOST: ({ prisma: providedPrisma, createWorkspace, }?: {
25
- prisma?: PrismaClient;
26
- createWorkspace?: ({ parsedData, organization, prisma, }: {
27
- parsedData: z.infer<typeof createWorkspaceSchema>;
28
- organization: Organization;
29
- prisma: PrismaClient;
30
- }) => Promise<Workspace>;
31
- }) => (request: NextRequest) => Promise<NextResponse<{
13
+ export declare const POST: (request: import("next/server").NextRequest) => Promise<import("next/server").NextResponse<{
32
14
  error: string;
33
- }> | NextResponse<{
15
+ }> | import("next/server").NextResponse<{
34
16
  workspace: {
35
17
  id: string;
36
18
  name: string;
@@ -38,7 +20,5 @@ export declare const buildPOST: ({ prisma: providedPrisma, createWorkspace, }?:
38
20
  updatedAt: string;
39
21
  };
40
22
  }>>;
41
- export declare const POST: ReturnType<typeof buildPOST>;
42
- export declare const OPTIONS: () => NextResponse<{}>;
43
- export {};
23
+ export declare const OPTIONS: () => import("next/server").NextResponse<{}>;
44
24
  //# sourceMappingURL=route.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/app/api/workspaces/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE3E,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,QAAA,MAAM,qBAAqB;;;;;;EAEzB,CAAA;AAEF,eAAO,MAAM,QAAQ,GAClB,6BAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO;;;;;;;;;GAuC1D,CAAA;AAEH,eAAO,MAAM,GAAG,EACU,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAA;AAErD,eAAO,MAAM,SAAS,GACnB,+CAiBE;IACD,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,eAAe,CAAC,EAAE,CAAC,EACjB,UAAU,EACV,YAAY,EACZ,MAAM,GACP,EAAE;QACD,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;QACjD,YAAY,EAAE,YAAY,CAAA;QAC1B,MAAM,EAAE,YAAY,CAAA;KACrB,KAAK,OAAO,CAAC,SAAS,CAAC,CAAA;CACpB,MACC,SAAS,WAAW;;;;;;;;;GAwD1B,CAAA;AAEH,eAAO,MAAM,IAAI,EACY,UAAU,CAAC,OAAO,SAAS,CAAC,CAAA;AAEzD,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/app/api/workspaces/route.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,qBAAqB,EACtB,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,qBAAqB,EAAE,CAAA;AAEhC,eAAO,MAAM,GAAG;;;;;;;;;GAAuB,CAAA;AAEvC,eAAO,MAAM,IAAI;;;;;;;;;GAAwB,CAAA;AAEzC,eAAO,MAAM,OAAO,8CAAiB,CAAA"}