@superinterface/server 1.0.18 → 1.0.20

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 (264) 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/files/[fileId]/contents/route.js +1 -1
  9. package/.next/server/app/api/files/[fileId]/contents/route.js.nft.json +1 -1
  10. package/.next/server/app/api/files/route.js +1 -1
  11. package/.next/server/app/api/files/route.js.nft.json +1 -1
  12. package/.next/server/app/api/messages/route.js +3 -3
  13. package/.next/server/app/api/messages/route.js.nft.json +1 -1
  14. package/.next/server/app/index.html +1 -1
  15. package/.next/server/app/index.rsc +1 -1
  16. package/.next/server/chunks/[root-of-the-server]__0c1bc5ed._.js +1 -1
  17. package/.next/server/chunks/[root-of-the-server]__0c1bc5ed._.js.map +1 -1
  18. package/.next/server/chunks/[root-of-the-server]__13c6bd62._.js +1 -1
  19. package/.next/server/chunks/[root-of-the-server]__13c6bd62._.js.map +1 -1
  20. package/.next/server/chunks/[root-of-the-server]__228bff78._.js +2 -2
  21. package/.next/server/chunks/[root-of-the-server]__228bff78._.js.map +1 -1
  22. package/.next/server/chunks/[root-of-the-server]__25ee13bc._.js +1 -1
  23. package/.next/server/chunks/[root-of-the-server]__25ee13bc._.js.map +1 -1
  24. package/.next/server/chunks/[root-of-the-server]__27aadac9._.js +1 -1
  25. package/.next/server/chunks/[root-of-the-server]__27aadac9._.js.map +1 -1
  26. package/.next/server/chunks/[root-of-the-server]__2945c9e9._.js +1 -1
  27. package/.next/server/chunks/[root-of-the-server]__2945c9e9._.js.map +1 -1
  28. package/.next/server/chunks/[root-of-the-server]__29635e8e._.js +1 -1
  29. package/.next/server/chunks/[root-of-the-server]__29635e8e._.js.map +1 -1
  30. package/.next/server/chunks/[root-of-the-server]__29b43490._.js +2 -2
  31. package/.next/server/chunks/[root-of-the-server]__29b43490._.js.map +1 -1
  32. package/.next/server/chunks/[root-of-the-server]__315f084a._.js +1 -1
  33. package/.next/server/chunks/[root-of-the-server]__315f084a._.js.map +1 -1
  34. package/.next/server/chunks/[root-of-the-server]__3307123c._.js +2 -2
  35. package/.next/server/chunks/[root-of-the-server]__3307123c._.js.map +1 -1
  36. package/.next/server/chunks/[root-of-the-server]__441cee00._.js +1 -1
  37. package/.next/server/chunks/[root-of-the-server]__441cee00._.js.map +1 -1
  38. package/.next/server/chunks/[root-of-the-server]__464a4377._.js +1 -1
  39. package/.next/server/chunks/[root-of-the-server]__464a4377._.js.map +1 -1
  40. package/.next/server/chunks/[root-of-the-server]__4e536bc0._.js +1 -1
  41. package/.next/server/chunks/[root-of-the-server]__4e536bc0._.js.map +1 -1
  42. package/.next/server/chunks/[root-of-the-server]__50c5f12c._.js +2 -2
  43. package/.next/server/chunks/[root-of-the-server]__50c5f12c._.js.map +1 -1
  44. package/.next/server/chunks/[root-of-the-server]__51977f30._.js +1 -1
  45. package/.next/server/chunks/[root-of-the-server]__51977f30._.js.map +1 -1
  46. package/.next/server/chunks/[root-of-the-server]__583a7f1c._.js +1 -1
  47. package/.next/server/chunks/[root-of-the-server]__583a7f1c._.js.map +1 -1
  48. package/.next/server/chunks/[root-of-the-server]__5abf1160._.js +1 -1
  49. package/.next/server/chunks/[root-of-the-server]__5abf1160._.js.map +1 -1
  50. package/.next/server/chunks/[root-of-the-server]__5d09614a._.js +1 -1
  51. package/.next/server/chunks/[root-of-the-server]__5d09614a._.js.map +1 -1
  52. package/.next/server/chunks/[root-of-the-server]__62d958e7._.js +1 -1
  53. package/.next/server/chunks/[root-of-the-server]__62d958e7._.js.map +1 -1
  54. package/.next/server/chunks/[root-of-the-server]__6b8ba839._.js +2 -2
  55. package/.next/server/chunks/[root-of-the-server]__6b8ba839._.js.map +1 -1
  56. package/.next/server/chunks/[root-of-the-server]__7f9ca1e3._.js +1 -1
  57. package/.next/server/chunks/[root-of-the-server]__7f9ca1e3._.js.map +1 -1
  58. package/.next/server/chunks/[root-of-the-server]__83461316._.js +1 -1
  59. package/.next/server/chunks/[root-of-the-server]__83461316._.js.map +1 -1
  60. package/.next/server/chunks/[root-of-the-server]__9a611d42._.js +1 -1
  61. package/.next/server/chunks/[root-of-the-server]__9a611d42._.js.map +1 -1
  62. package/.next/server/chunks/[root-of-the-server]__a135e388._.js +1 -1
  63. package/.next/server/chunks/[root-of-the-server]__a135e388._.js.map +1 -1
  64. package/.next/server/chunks/[root-of-the-server]__b10ec83e._.js +1 -1
  65. package/.next/server/chunks/[root-of-the-server]__b10ec83e._.js.map +1 -1
  66. package/.next/server/chunks/[root-of-the-server]__b9a334c3._.js +1 -1
  67. package/.next/server/chunks/[root-of-the-server]__b9a334c3._.js.map +1 -1
  68. package/.next/server/chunks/[root-of-the-server]__c1629392._.js +1 -1
  69. package/.next/server/chunks/[root-of-the-server]__c1629392._.js.map +1 -1
  70. package/.next/server/chunks/[root-of-the-server]__dd176cb5._.js +2 -2
  71. package/.next/server/chunks/[root-of-the-server]__dd176cb5._.js.map +1 -1
  72. package/.next/server/chunks/[root-of-the-server]__e7819e95._.js +2 -2
  73. package/.next/server/chunks/[root-of-the-server]__e7819e95._.js.map +1 -1
  74. package/.next/server/chunks/[root-of-the-server]__eb816e13._.js +1 -1
  75. package/.next/server/chunks/[root-of-the-server]__eb816e13._.js.map +1 -1
  76. package/.next/server/chunks/[root-of-the-server]__ed6cf593._.js +1 -1
  77. package/.next/server/chunks/[root-of-the-server]__ed6cf593._.js.map +1 -1
  78. package/.next/server/chunks/[root-of-the-server]__f0dfab03._.js +2 -2
  79. package/.next/server/chunks/[root-of-the-server]__f0dfab03._.js.map +1 -1
  80. package/.next/server/chunks/{[root-of-the-server]__30845206._.js → [root-of-the-server]__ff90af03._.js} +3 -3
  81. package/.next/server/chunks/{[root-of-the-server]__30845206._.js.map → [root-of-the-server]__ff90af03._.js.map} +1 -1
  82. package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_cb746cf4.js +1 -1
  83. package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_cb746cf4.js.map +1 -1
  84. package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_f952d9ab.js +1 -1
  85. package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_f952d9ab.js.map +1 -1
  86. package/.next/server/chunks/supercorp_superinterface_bebd2c96._.js +2 -2
  87. package/.next/server/chunks/supercorp_superinterface_bebd2c96._.js.map +1 -1
  88. package/.next/server/pages/404.html +1 -1
  89. package/.next/server/pages/500.html +1 -1
  90. package/.next/trace +1 -1
  91. package/bin/index.cjs +2 -0
  92. package/dist/app/api/api-keys/[apiKeyId]/route.d.ts +55 -0
  93. package/dist/app/api/api-keys/[apiKeyId]/route.d.ts.map +1 -1
  94. package/dist/app/api/api-keys/[apiKeyId]/route.js +10 -4
  95. package/dist/app/api/api-keys/route.d.ts +29 -0
  96. package/dist/app/api/api-keys/route.d.ts.map +1 -1
  97. package/dist/app/api/api-keys/route.js +8 -3
  98. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.d.ts +172 -0
  99. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.d.ts.map +1 -1
  100. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.js +11 -4
  101. package/dist/app/api/assistants/[assistantId]/functions/route.d.ts +113 -0
  102. package/dist/app/api/assistants/[assistantId]/functions/route.d.ts.map +1 -1
  103. package/dist/app/api/assistants/[assistantId]/functions/route.js +8 -3
  104. package/dist/app/api/assistants/[assistantId]/initial-messages/route.d.ts +39 -0
  105. package/dist/app/api/assistants/[assistantId]/initial-messages/route.d.ts.map +1 -1
  106. package/dist/app/api/assistants/[assistantId]/initial-messages/route.js +8 -3
  107. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.d.ts +94 -0
  108. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.d.ts.map +1 -1
  109. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.js +10 -4
  110. package/dist/app/api/assistants/[assistantId]/mcp-servers/route.d.ts +61 -0
  111. package/dist/app/api/assistants/[assistantId]/mcp-servers/route.d.ts.map +1 -1
  112. package/dist/app/api/assistants/[assistantId]/mcp-servers/route.js +7 -3
  113. package/dist/app/api/assistants/[assistantId]/route.d.ts +123 -0
  114. package/dist/app/api/assistants/[assistantId]/route.d.ts.map +1 -1
  115. package/dist/app/api/assistants/[assistantId]/route.js +15 -6
  116. package/dist/app/api/assistants/route.d.ts +59 -0
  117. package/dist/app/api/assistants/route.d.ts.map +1 -1
  118. package/dist/app/api/assistants/route.js +8 -4
  119. package/dist/app/api/files/[fileId]/contents/route.d.ts +3 -2
  120. package/dist/app/api/files/[fileId]/contents/route.d.ts.map +1 -1
  121. package/dist/app/api/files/[fileId]/contents/route.js +9 -6
  122. package/dist/app/api/files/route.d.ts +10 -0
  123. package/dist/app/api/files/route.d.ts.map +1 -1
  124. package/dist/app/api/files/route.js +9 -5
  125. package/dist/app/api/messages/route.d.ts +24 -1
  126. package/dist/app/api/messages/route.d.ts.map +1 -1
  127. package/dist/app/api/messages/route.js +38 -13
  128. package/dist/app/api/providers/[modelProviderId]/assistants/route.d.ts +19 -0
  129. package/dist/app/api/providers/[modelProviderId]/assistants/route.d.ts.map +1 -1
  130. package/dist/app/api/providers/[modelProviderId]/assistants/route.js +4 -2
  131. package/dist/app/api/providers/[modelProviderId]/models/route.d.ts +14 -0
  132. package/dist/app/api/providers/[modelProviderId]/models/route.d.ts.map +1 -1
  133. package/dist/app/api/providers/[modelProviderId]/models/route.js +4 -2
  134. package/dist/app/api/providers/[modelProviderId]/route.d.ts +64 -0
  135. package/dist/app/api/providers/[modelProviderId]/route.d.ts.map +1 -1
  136. package/dist/app/api/providers/[modelProviderId]/route.js +12 -6
  137. package/dist/app/api/providers/route.d.ts +35 -0
  138. package/dist/app/api/providers/route.d.ts.map +1 -1
  139. package/dist/app/api/providers/route.js +9 -5
  140. package/dist/app/api/tasks/[taskId]/route.d.ts +61 -0
  141. package/dist/app/api/tasks/[taskId]/route.d.ts.map +1 -1
  142. package/dist/app/api/tasks/[taskId]/route.js +11 -5
  143. package/dist/app/api/tasks/callback/route.d.ts.map +1 -1
  144. package/dist/app/api/tasks/callback/route.js +17 -9
  145. package/dist/app/api/tasks/route.d.ts +33 -0
  146. package/dist/app/api/tasks/route.d.ts.map +1 -1
  147. package/dist/app/api/tasks/route.js +8 -4
  148. package/dist/app/api/threads/runs/submit-client-tool-outputs/route.d.ts +9 -1
  149. package/dist/app/api/threads/runs/submit-client-tool-outputs/route.d.ts.map +1 -1
  150. package/dist/app/api/threads/runs/submit-client-tool-outputs/route.js +5 -3
  151. package/dist/app/api/workspaces/[workspaceId]/route.d.ts +33 -0
  152. package/dist/app/api/workspaces/[workspaceId]/route.d.ts.map +1 -1
  153. package/dist/app/api/workspaces/[workspaceId]/route.js +7 -3
  154. package/dist/app/api/workspaces/route.d.ts +17 -3
  155. package/dist/app/api/workspaces/route.d.ts.map +1 -1
  156. package/dist/app/api/workspaces/route.js +8 -4
  157. package/dist/lib/apiKeys/getApiKey.d.ts +3 -2
  158. package/dist/lib/apiKeys/getApiKey.d.ts.map +1 -1
  159. package/dist/lib/apiKeys/getApiKey.js +1 -2
  160. package/dist/lib/apiKeys/workspaceAccessWhere.d.ts +3 -1
  161. package/dist/lib/apiKeys/workspaceAccessWhere.d.ts.map +1 -1
  162. package/dist/lib/apiKeys/workspaceAccessWhere.js +2 -1
  163. package/dist/lib/assistants/assistantClientAdapter/buildGetOpenaiAssistant.d.ts +3 -2
  164. package/dist/lib/assistants/assistantClientAdapter/buildGetOpenaiAssistant.d.ts.map +1 -1
  165. package/dist/lib/assistants/assistantClientAdapter/buildGetOpenaiAssistant.js +3 -3
  166. package/dist/lib/assistants/assistantClientAdapter/index.d.ts.map +1 -1
  167. package/dist/lib/assistants/assistantClientAdapter/index.js +7 -2
  168. package/dist/lib/computerCalls/handleComputerCall/index.d.ts +3 -2
  169. package/dist/lib/computerCalls/handleComputerCall/index.d.ts.map +1 -1
  170. package/dist/lib/computerCalls/handleComputerCall/index.js +5 -1
  171. package/dist/lib/functions/createFunction.d.ts +2 -1
  172. package/dist/lib/functions/createFunction.d.ts.map +1 -1
  173. package/dist/lib/functions/createFunction.js +2 -2
  174. package/dist/lib/functions/handleFunction/handleAssistant.d.ts +3 -2
  175. package/dist/lib/functions/handleFunction/handleAssistant.d.ts.map +1 -1
  176. package/dist/lib/functions/handleFunction/handleAssistant.js +12 -2
  177. package/dist/lib/functions/handleFunction/handleClientTool.d.ts +3 -2
  178. package/dist/lib/functions/handleFunction/handleClientTool.d.ts.map +1 -1
  179. package/dist/lib/functions/handleFunction/handleClientTool.js +2 -1
  180. package/dist/lib/functions/handleFunction/handleFirecrawl.d.ts +3 -2
  181. package/dist/lib/functions/handleFunction/handleFirecrawl.d.ts.map +1 -1
  182. package/dist/lib/functions/handleFunction/handleFirecrawl.js +7 -1
  183. package/dist/lib/functions/handleFunction/handleReplicate.d.ts +3 -2
  184. package/dist/lib/functions/handleFunction/handleReplicate.d.ts.map +1 -1
  185. package/dist/lib/functions/handleFunction/handleReplicate.js +4 -1
  186. package/dist/lib/functions/handleFunction/handleRequest.d.ts +3 -2
  187. package/dist/lib/functions/handleFunction/handleRequest.d.ts.map +1 -1
  188. package/dist/lib/functions/handleFunction/handleRequest.js +6 -1
  189. package/dist/lib/functions/handleFunction/index.d.ts +3 -2
  190. package/dist/lib/functions/handleFunction/index.d.ts.map +1 -1
  191. package/dist/lib/functions/handleFunction/index.js +25 -1
  192. package/dist/lib/functions/handleFunction/tasks/handleCreateTask.d.ts +3 -2
  193. package/dist/lib/functions/handleFunction/tasks/handleCreateTask.d.ts.map +1 -1
  194. package/dist/lib/functions/handleFunction/tasks/handleCreateTask.js +4 -4
  195. package/dist/lib/functions/handleFunction/tasks/handleDeleteTask.d.ts +3 -2
  196. package/dist/lib/functions/handleFunction/tasks/handleDeleteTask.d.ts.map +1 -1
  197. package/dist/lib/functions/handleFunction/tasks/handleDeleteTask.js +3 -3
  198. package/dist/lib/functions/handleFunction/tasks/handleListTasks.d.ts +3 -2
  199. package/dist/lib/functions/handleFunction/tasks/handleListTasks.d.ts.map +1 -1
  200. package/dist/lib/functions/handleFunction/tasks/handleListTasks.js +3 -3
  201. package/dist/lib/functions/handleFunction/tasks/handleUpdateTask.d.ts +3 -2
  202. package/dist/lib/functions/handleFunction/tasks/handleUpdateTask.d.ts.map +1 -1
  203. package/dist/lib/functions/handleFunction/tasks/handleUpdateTask.js +4 -4
  204. package/dist/lib/functions/updateFunction.d.ts +2 -1
  205. package/dist/lib/functions/updateFunction.d.ts.map +1 -1
  206. package/dist/lib/functions/updateFunction.js +2 -2
  207. package/dist/lib/handlers/handlerPrismaInput.d.ts +3 -1
  208. package/dist/lib/handlers/handlerPrismaInput.d.ts.map +1 -1
  209. package/dist/lib/handlers/handlerPrismaInput.jsx +1 -2
  210. package/dist/lib/initialMessages/updateInitialMessages.d.ts +3 -2
  211. package/dist/lib/initialMessages/updateInitialMessages.d.ts.map +1 -1
  212. package/dist/lib/initialMessages/updateInitialMessages.js +1 -2
  213. package/dist/lib/logs/createLog.d.ts +3 -2
  214. package/dist/lib/logs/createLog.d.ts.map +1 -1
  215. package/dist/lib/logs/createLog.js +1 -2
  216. package/dist/lib/mcpServers/connectMcpServer.d.ts +5 -3
  217. package/dist/lib/mcpServers/connectMcpServer.d.ts.map +1 -1
  218. package/dist/lib/mcpServers/connectMcpServer.js +7 -5
  219. package/dist/lib/mcpServers/getToolCallMcpServer.d.ts +3 -2
  220. package/dist/lib/mcpServers/getToolCallMcpServer.d.ts.map +1 -1
  221. package/dist/lib/mcpServers/getToolCallMcpServer.js +2 -1
  222. package/dist/lib/mcpServers/headers.d.ts +3 -2
  223. package/dist/lib/mcpServers/headers.d.ts.map +1 -1
  224. package/dist/lib/mcpServers/headers.js +2 -1
  225. package/dist/lib/mcpServers/url.d.ts +3 -2
  226. package/dist/lib/mcpServers/url.d.ts.map +1 -1
  227. package/dist/lib/mcpServers/url.js +2 -1
  228. package/dist/lib/metadata/serializeMetadata.d.ts +3 -1
  229. package/dist/lib/metadata/serializeMetadata.d.ts.map +1 -1
  230. package/dist/lib/metadata/serializeMetadata.js +3 -2
  231. package/dist/lib/organizationApiKeys/getOrganizationApiKey.d.ts +3 -2
  232. package/dist/lib/organizationApiKeys/getOrganizationApiKey.d.ts.map +1 -1
  233. package/dist/lib/organizationApiKeys/getOrganizationApiKey.js +1 -2
  234. package/dist/lib/prisma/index.d.ts +2 -0
  235. package/dist/lib/prisma/index.d.ts.map +1 -1
  236. package/dist/lib/prisma/index.js +16 -4
  237. package/dist/lib/runs/createRunOpts.d.ts +3 -2
  238. package/dist/lib/runs/createRunOpts.d.ts.map +1 -1
  239. package/dist/lib/runs/createRunOpts.js +2 -2
  240. package/dist/lib/tasks/getTaskToolKey.d.ts +3 -2
  241. package/dist/lib/tasks/getTaskToolKey.d.ts.map +1 -1
  242. package/dist/lib/tasks/getTaskToolKey.js +2 -1
  243. package/dist/lib/tasks/parseTaskToolArgs.d.ts +3 -2
  244. package/dist/lib/tasks/parseTaskToolArgs.d.ts.map +1 -1
  245. package/dist/lib/tasks/parseTaskToolArgs.js +4 -1
  246. package/dist/lib/tasks/scheduleTask.d.ts +3 -2
  247. package/dist/lib/tasks/scheduleTask.d.ts.map +1 -1
  248. package/dist/lib/tasks/scheduleTask.js +1 -2
  249. package/dist/lib/threads/createThread/index.d.ts.map +1 -1
  250. package/dist/lib/threads/createThread/index.js +1 -0
  251. package/dist/lib/threads/managedOpenaiThreadId.d.ts +3 -2
  252. package/dist/lib/threads/managedOpenaiThreadId.d.ts.map +1 -1
  253. package/dist/lib/threads/managedOpenaiThreadId.js +1 -2
  254. package/dist/lib/toolCalls/handleToolCall.d.ts +3 -2
  255. package/dist/lib/toolCalls/handleToolCall.d.ts.map +1 -1
  256. package/dist/lib/toolCalls/handleToolCall.js +5 -1
  257. package/dist/lib/tools/tools/index.d.ts +3 -2
  258. package/dist/lib/tools/tools/index.d.ts.map +1 -1
  259. package/dist/lib/tools/tools/index.js +9 -6
  260. package/package.json +1 -1
  261. package/scripts/utils/loadPrisma.ts +1 -2
  262. /package/.next/static/{s_BjB5fnRbk2L3A0fMr5L → Ggpv5PXa7pPyxP1NXVbh6}/_buildManifest.js +0 -0
  263. /package/.next/static/{s_BjB5fnRbk2L3A0fMr5L → Ggpv5PXa7pPyxP1NXVbh6}/_clientMiddlewareManifest.json +0 -0
  264. /package/.next/static/{s_BjB5fnRbk2L3A0fMr5L → Ggpv5PXa7pPyxP1NXVbh6}/_ssgManifest.js +0 -0
@@ -1,4 +1,25 @@
1
+ import { type PrismaClient } from '@prisma/client';
1
2
  import { NextResponse, type NextRequest } from 'next/server';
3
+ export declare const buildGET: ({ prisma }?: {
4
+ prisma?: PrismaClient;
5
+ }) => (_request: NextRequest, props: {
6
+ params: Promise<{
7
+ taskId: string;
8
+ }>;
9
+ }) => Promise<NextResponse<{
10
+ error: string;
11
+ }> | NextResponse<{
12
+ task: {
13
+ id: string;
14
+ title: string;
15
+ message: string;
16
+ schedule: PrismaJson.TaskSchedule;
17
+ threadId: string;
18
+ key: string;
19
+ createdAt: string;
20
+ updatedAt: string;
21
+ };
22
+ }>>;
2
23
  export declare const GET: (_request: NextRequest, props: {
3
24
  params: Promise<{
4
25
  taskId: string;
@@ -17,6 +38,26 @@ export declare const GET: (_request: NextRequest, props: {
17
38
  updatedAt: string;
18
39
  };
19
40
  }>>;
41
+ export declare const buildPATCH: ({ prisma }?: {
42
+ prisma?: PrismaClient;
43
+ }) => (request: NextRequest, props: {
44
+ params: Promise<{
45
+ taskId: string;
46
+ }>;
47
+ }) => Promise<NextResponse<{
48
+ error: string;
49
+ }> | NextResponse<{
50
+ task: {
51
+ id: string;
52
+ title: string;
53
+ message: string;
54
+ schedule: PrismaJson.TaskSchedule;
55
+ threadId: string;
56
+ key: string;
57
+ createdAt: string;
58
+ updatedAt: string;
59
+ };
60
+ }>>;
20
61
  export declare const PATCH: (request: NextRequest, props: {
21
62
  params: Promise<{
22
63
  taskId: string;
@@ -35,6 +76,26 @@ export declare const PATCH: (request: NextRequest, props: {
35
76
  updatedAt: string;
36
77
  };
37
78
  }>>;
79
+ export declare const buildDELETE: ({ prisma }?: {
80
+ prisma?: PrismaClient;
81
+ }) => (_request: NextRequest, props: {
82
+ params: Promise<{
83
+ taskId: string;
84
+ }>;
85
+ }) => Promise<NextResponse<{
86
+ error: string;
87
+ }> | NextResponse<{
88
+ task: {
89
+ id: string;
90
+ title: string;
91
+ message: string;
92
+ schedule: PrismaJson.TaskSchedule;
93
+ threadId: string;
94
+ key: string;
95
+ createdAt: string;
96
+ updatedAt: string;
97
+ };
98
+ }>>;
38
99
  export declare const DELETE: (_request: NextRequest, props: {
39
100
  params: Promise<{
40
101
  taskId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../src/app/api/tasks/[taskId]/route.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAkB5D,eAAO,MAAM,GAAG,GACd,UAAU,WAAW,EACrB,OAAO;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;;;;;GA6C/C,CAAA;AAED,eAAO,MAAM,KAAK,GAChB,SAAS,WAAW,EACpB,OAAO;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;;;;;GAgF/C,CAAA;AAED,eAAO,MAAM,MAAM,GACjB,UAAU,WAAW,EACrB,OAAO;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,MAAM,EAA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EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;;;;;GAkD/C,CAAA;AAEH,eAAO,MAAM,MAAM,aArDL,WAAW,SACd;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;;;;;GAoDf,CAAA;AAEnC,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
@@ -4,7 +4,7 @@ import { NextResponse } from 'next/server';
4
4
  import { z } from 'zod';
5
5
  import { validate } from 'uuid';
6
6
  import { cacheHeaders } from '../../../../lib/cache/cacheHeaders';
7
- import { prisma } from '../../../../lib/prisma';
7
+ import { getPrisma } from '../../../../lib/prisma';
8
8
  import { serializeTask } from '../../../../lib/tasks/serializeTask';
9
9
  import { validateSchedule } from '../../../../lib/tasks/validateSchedule';
10
10
  import { getApiKey } from '../../../../lib/apiKeys/getApiKey';
@@ -16,7 +16,7 @@ const updateTaskSchema = z.object({
16
16
  schedule: z.any().optional(),
17
17
  key: z.string().optional(),
18
18
  });
19
- export const GET = async (_request, props) => {
19
+ export const buildGET = ({ prisma = getPrisma() } = {}) => async (_request, props) => {
20
20
  const { taskId } = await props.params;
21
21
  const headersList = await headers();
22
22
  const authorization = headersList.get('authorization');
@@ -26,6 +26,7 @@ export const GET = async (_request, props) => {
26
26
  const privateApiKey = await getApiKey({
27
27
  authorization,
28
28
  type: ApiKeyType.PRIVATE,
29
+ prisma,
29
30
  });
30
31
  if (!privateApiKey) {
31
32
  return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
@@ -47,7 +48,8 @@ export const GET = async (_request, props) => {
47
48
  }
48
49
  return NextResponse.json({ task: serializeTask({ task }) }, { headers: cacheHeaders });
49
50
  };
50
- export const PATCH = async (request, props) => {
51
+ export const GET = buildGET();
52
+ export const buildPATCH = ({ prisma = getPrisma() } = {}) => async (request, props) => {
51
53
  const { taskId } = await props.params;
52
54
  const headersList = await headers();
53
55
  const authorization = headersList.get('authorization');
@@ -57,6 +59,7 @@ export const PATCH = async (request, props) => {
57
59
  const privateApiKey = await getApiKey({
58
60
  authorization,
59
61
  type: ApiKeyType.PRIVATE,
62
+ prisma,
60
63
  });
61
64
  if (!privateApiKey) {
62
65
  return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
@@ -94,10 +97,11 @@ export const PATCH = async (request, props) => {
94
97
  where: { id: existingTask.id },
95
98
  data: updateData,
96
99
  });
97
- await scheduleTask({ task });
100
+ await scheduleTask({ task, prisma });
98
101
  return NextResponse.json({ task: serializeTask({ task }) }, { headers: cacheHeaders });
99
102
  };
100
- export const DELETE = async (_request, props) => {
103
+ export const PATCH = buildPATCH();
104
+ export const buildDELETE = ({ prisma = getPrisma() } = {}) => async (_request, props) => {
101
105
  const { taskId } = await props.params;
102
106
  const headersList = await headers();
103
107
  const authorization = headersList.get('authorization');
@@ -107,6 +111,7 @@ export const DELETE = async (_request, props) => {
107
111
  const privateApiKey = await getApiKey({
108
112
  authorization,
109
113
  type: ApiKeyType.PRIVATE,
114
+ prisma,
110
115
  });
111
116
  if (!privateApiKey) {
112
117
  return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
@@ -130,6 +135,7 @@ export const DELETE = async (_request, props) => {
130
135
  const task = await prisma.task.delete({ where: { id: existingTask.id } });
131
136
  return NextResponse.json({ task: serializeTask({ task }) }, { headers: cacheHeaders });
132
137
  };
138
+ export const DELETE = buildDELETE();
133
139
  export const OPTIONS = () => NextResponse.json({}, {
134
140
  headers: cacheHeaders,
135
141
  });
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../src/app/api/tasks/callback/route.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,WAAW,MAAM,CAAA;AAmQ9B,eAAO,MAAM,IAAI,2FAG0B,CAAA"}
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../src/app/api/tasks/callback/route.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,WAAW,MAAM,CAAA;AA8Q9B,eAAO,MAAM,IAAI,2FAG0B,CAAA"}
@@ -1,8 +1,8 @@
1
1
  import { NextResponse } from 'next/server';
2
2
  import { verifySignatureAppRouter } from '@upstash/qstash/nextjs';
3
3
  import { createMessageResponse } from '@superinterface/react/server';
4
- import { LogRequestMethod, LogRequestRoute, LogLevel } from '@prisma/client';
5
- import { prisma } from '../../../../lib/prisma';
4
+ import { LogRequestMethod, LogRequestRoute, LogLevel, } from '@prisma/client';
5
+ import { getPrisma } from '../../../../lib/prisma';
6
6
  import { assistantClientAdapter } from '../../../../lib/assistants/assistantClientAdapter';
7
7
  import { createRunOpts } from '../../../../lib/runs/createRunOpts';
8
8
  import { scheduleTask } from '../../../../lib/tasks/scheduleTask';
@@ -15,7 +15,7 @@ import { isOpenaiAssistantsStorageProvider } from '../../../../lib/storageProvid
15
15
  import { managedOpenaiThreadId } from '../../../../lib/threads/managedOpenaiThreadId';
16
16
  import { serializeMetadata } from '../../../../lib/metadata/serializeMetadata';
17
17
  export const maxDuration = 800;
18
- const postHandler = async (request) => {
18
+ const buildPostHandler = ({ prisma = getPrisma() } = {}) => async (request) => {
19
19
  var _a, _b;
20
20
  const { taskId } = await request.json();
21
21
  const task = await prisma.task.findUnique({
@@ -81,7 +81,7 @@ const postHandler = async (request) => {
81
81
  }
82
82
  const assistant = task.thread.assistant;
83
83
  const thread = task.thread;
84
- const client = assistantClientAdapter({ assistant, prisma });
84
+ const assistantClient = assistantClientAdapter({ assistant, prisma });
85
85
  let storageThreadId;
86
86
  try {
87
87
  storageThreadId = getStorageThreadId({
@@ -101,6 +101,7 @@ const postHandler = async (request) => {
101
101
  assistantId: assistant.id,
102
102
  threadId: thread.id,
103
103
  },
104
+ prisma,
104
105
  });
105
106
  return NextResponse.json({ error: 'Failed to get storage thread id.' }, { status: 500 });
106
107
  }
@@ -112,6 +113,7 @@ const postHandler = async (request) => {
112
113
  storageThreadId = await managedOpenaiThreadId({
113
114
  assistant,
114
115
  threadId: thread.id,
116
+ prisma,
115
117
  });
116
118
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
117
119
  }
@@ -127,6 +129,7 @@ const postHandler = async (request) => {
127
129
  assistantId: assistant.id,
128
130
  threadId: thread.id,
129
131
  },
132
+ prisma,
130
133
  });
131
134
  return NextResponse.json({ error: 'Failed to get managed openai thread id.' }, { status: 500 });
132
135
  }
@@ -143,11 +146,12 @@ const postHandler = async (request) => {
143
146
  assistantId: assistant.id,
144
147
  threadId: thread.id,
145
148
  },
149
+ prisma,
146
150
  });
147
151
  return NextResponse.json({ error: 'Invalid thread configuration.' }, { status: 500 });
148
152
  }
149
153
  try {
150
- await client.beta.threads.messages.create(storageThreadId, {
154
+ await assistantClient.beta.threads.messages.create(storageThreadId, {
151
155
  role: 'user',
152
156
  content: task.message,
153
157
  metadata: serializeMetadata({
@@ -156,6 +160,7 @@ const postHandler = async (request) => {
156
160
  superinterfaceCreatedById: task.id,
157
161
  },
158
162
  workspaceId: assistant.workspaceId,
163
+ prisma,
159
164
  }),
160
165
  });
161
166
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -173,12 +178,13 @@ const postHandler = async (request) => {
173
178
  assistantId: assistant.id,
174
179
  threadId: thread.id,
175
180
  },
181
+ prisma,
176
182
  });
177
183
  return NextResponse.json({ error: 'Failed to create message' }, { status: 500 });
178
184
  }
179
185
  let createRunStream;
180
186
  try {
181
- createRunStream = await client.beta.threads.runs.create(storageThreadId, await createRunOpts({ assistant, thread }));
187
+ createRunStream = await assistantClient.beta.threads.runs.create(storageThreadId, await createRunOpts({ assistant, thread, prisma }));
182
188
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
183
189
  }
184
190
  catch (error) {
@@ -194,13 +200,14 @@ const postHandler = async (request) => {
194
200
  assistantId: assistant.id,
195
201
  threadId: thread.id,
196
202
  },
203
+ prisma,
197
204
  });
198
205
  return NextResponse.json({ error: 'Failed to create run stream' }, { status: 500 });
199
206
  }
200
207
  const messageResponse = createMessageResponse({
201
- client,
208
+ client: assistantClient,
202
209
  createRunStream,
203
- handleToolCall: handleToolCall({ assistant, thread }),
210
+ handleToolCall: handleToolCall({ assistant, thread, prisma }),
204
211
  });
205
212
  const decoder = new TextDecoder();
206
213
  const reader = messageResponse.getReader();
@@ -228,9 +235,10 @@ const postHandler = async (request) => {
228
235
  });
229
236
  }
230
237
  }
231
- await scheduleTask({ task });
238
+ await scheduleTask({ task, prisma });
232
239
  return NextResponse.json({ ok: true });
233
240
  };
241
+ const postHandler = buildPostHandler();
234
242
  export const POST = process.env.NODE_ENV === 'test' || !process.env.QSTASH_CURRENT_SIGNING_KEY
235
243
  ? postHandler
236
244
  : verifySignatureAppRouter(postHandler);
@@ -1,4 +1,21 @@
1
+ import { type PrismaClient } from '@prisma/client';
1
2
  import { NextResponse, type NextRequest } from 'next/server';
3
+ export declare const buildGET: ({ prisma }?: {
4
+ prisma?: PrismaClient;
5
+ }) => (request: NextRequest) => Promise<NextResponse<{
6
+ error: string;
7
+ }> | NextResponse<{
8
+ tasks: {
9
+ id: string;
10
+ title: string;
11
+ message: string;
12
+ schedule: PrismaJson.TaskSchedule;
13
+ threadId: string;
14
+ key: string;
15
+ createdAt: string;
16
+ updatedAt: string;
17
+ }[];
18
+ }>>;
2
19
  export declare const GET: (request: NextRequest) => Promise<NextResponse<{
3
20
  error: string;
4
21
  }> | NextResponse<{
@@ -13,6 +30,22 @@ export declare const GET: (request: NextRequest) => Promise<NextResponse<{
13
30
  updatedAt: string;
14
31
  }[];
15
32
  }>>;
33
+ export declare const buildPOST: ({ prisma }?: {
34
+ prisma?: PrismaClient;
35
+ }) => (request: NextRequest) => Promise<NextResponse<{
36
+ error: string;
37
+ }> | NextResponse<{
38
+ task: {
39
+ id: string;
40
+ title: string;
41
+ message: string;
42
+ schedule: PrismaJson.TaskSchedule;
43
+ threadId: string;
44
+ key: string;
45
+ createdAt: string;
46
+ updatedAt: string;
47
+ };
48
+ }>>;
16
49
  export declare const POST: (request: NextRequest) => Promise<NextResponse<{
17
50
  error: string;
18
51
  }> | NextResponse<{
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/app/api/tasks/route.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAS5D,eAAO,MAAM,GAAG,GAAU,SAAS,WAAW;;;;;;;;;;;;;GAmC7C,CAAA;AAED,eAAO,MAAM,IAAI,GAAU,SAAS,WAAW;;;;;;;;;;;;;GAgE9C,CAAA;AAED,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/app/api/tasks/route.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAS5D,eAAO,MAAM,QAAQ,GAClB,aAA0B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAClD,SAAS,WAAW;;;;;;;;;;;;;GAoC1B,CAAA;AAEH,eAAO,MAAM,GAAG,YAtCE,WAAW;;;;;;;;;;;;;GAsCA,CAAA;AAE7B,eAAO,MAAM,SAAS,GACnB,aAA0B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAClD,SAAS,WAAW;;;;;;;;;;;;;GAiE1B,CAAA;AAEH,eAAO,MAAM,IAAI,YAnEC,WAAW;;;;;;;;;;;;;GAmEE,CAAA;AAE/B,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
@@ -3,12 +3,12 @@ import { ApiKeyType } from '@prisma/client';
3
3
  import { NextResponse } from 'next/server';
4
4
  import { createTaskSchema } from '../../../lib/tasks/schemas';
5
5
  import { cacheHeaders } from '../../../lib/cache/cacheHeaders';
6
- import { prisma } from '../../../lib/prisma';
6
+ import { getPrisma } from '../../../lib/prisma';
7
7
  import { serializeTask } from '../../../lib/tasks/serializeTask';
8
8
  import { validateSchedule } from '../../../lib/tasks/validateSchedule';
9
9
  import { getApiKey } from '../../../lib/apiKeys/getApiKey';
10
10
  import { scheduleTask } from '../../../lib/tasks/scheduleTask';
11
- export const GET = async (request) => {
11
+ export const buildGET = ({ prisma = getPrisma() } = {}) => async (request) => {
12
12
  const headersList = await headers();
13
13
  const authorization = headersList.get('authorization');
14
14
  if (!authorization) {
@@ -17,6 +17,7 @@ export const GET = async (request) => {
17
17
  const privateApiKey = await getApiKey({
18
18
  authorization,
19
19
  type: ApiKeyType.PRIVATE,
20
+ prisma,
20
21
  });
21
22
  if (!privateApiKey) {
22
23
  return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
@@ -30,7 +31,8 @@ export const GET = async (request) => {
30
31
  tasks: tasks.map((t) => serializeTask({ task: t })),
31
32
  }, { headers: cacheHeaders });
32
33
  };
33
- export const POST = async (request) => {
34
+ export const GET = buildGET();
35
+ export const buildPOST = ({ prisma = getPrisma() } = {}) => async (request) => {
34
36
  var _a;
35
37
  const headersList = await headers();
36
38
  const authorization = headersList.get('authorization');
@@ -40,6 +42,7 @@ export const POST = async (request) => {
40
42
  const privateApiKey = await getApiKey({
41
43
  authorization,
42
44
  type: ApiKeyType.PRIVATE,
45
+ prisma,
43
46
  });
44
47
  if (!privateApiKey) {
45
48
  return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
@@ -74,11 +77,12 @@ export const POST = async (request) => {
74
77
  key: (_a = parsed.data.key) !== null && _a !== void 0 ? _a : '',
75
78
  },
76
79
  });
77
- await scheduleTask({ task });
80
+ await scheduleTask({ task, prisma });
78
81
  return NextResponse.json({
79
82
  task: serializeTask({ task }),
80
83
  }, { headers: cacheHeaders });
81
84
  };
85
+ export const POST = buildPOST();
82
86
  export const OPTIONS = () => NextResponse.json({}, {
83
87
  headers: cacheHeaders,
84
88
  });
@@ -1,5 +1,13 @@
1
1
  import { NextRequest, NextResponse } from 'next/server';
2
- export declare function POST(request: NextRequest): Promise<NextResponse<{
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
+ export declare const POST: (request: NextRequest) => Promise<NextResponse<{
3
11
  error: string;
4
12
  }> | NextResponse<{
5
13
  status: string;
@@ -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;AAMvD,wBAAsB,IAAI,CAAC,OAAO,EAAE,WAAW;;;;IA+C9C"}
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;AAIvD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAGlD,eAAO,MAAM,SAAS,GACnB,aAA0B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAClD,SAAS,WAAW;;;;GAgD1B,CAAA;AAEH,eAAO,MAAM,IAAI,YAlDC,WAAW;;;;GAkDE,CAAA"}
@@ -1,13 +1,14 @@
1
1
  import { NextResponse } from 'next/server';
2
2
  import { map } from 'p-iteration';
3
3
  import { redis } from '../../../../../lib/redis';
4
- import { prisma } from '../../../../../lib/prisma';
4
+ import { getPrisma } from '../../../../../lib/prisma';
5
5
  import { workspaceAccessWhere as getWorkspaceAccessWhere } from '../../../../../lib/apiKeys/workspaceAccessWhere';
6
- export async function POST(request) {
6
+ export const buildPOST = ({ prisma = getPrisma() } = {}) => async (request) => {
7
7
  const body = await request.json();
8
8
  const { assistantId, publicApiKey, toolOutputs } = body;
9
9
  const workspaceAccessWhere = await getWorkspaceAccessWhere({
10
10
  publicApiKey,
11
+ prisma,
11
12
  });
12
13
  if (!workspaceAccessWhere) {
13
14
  return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
@@ -32,4 +33,5 @@ export async function POST(request) {
32
33
  }
33
34
  });
34
35
  return NextResponse.json({ status: 'success' });
35
- }
36
+ };
37
+ export const POST = buildPOST();
@@ -1,4 +1,21 @@
1
+ import { type PrismaClient } from '@prisma/client';
1
2
  import { NextResponse, type NextRequest } from 'next/server';
3
+ export declare const buildGET: ({ prisma }?: {
4
+ prisma?: PrismaClient;
5
+ }) => (_request: NextRequest, props: {
6
+ params: Promise<{
7
+ workspaceId: string;
8
+ }>;
9
+ }) => Promise<NextResponse<{
10
+ error: string;
11
+ }> | NextResponse<{
12
+ workspace: {
13
+ id: string;
14
+ name: string;
15
+ createdAt: string;
16
+ updatedAt: string;
17
+ };
18
+ }>>;
2
19
  export declare const GET: (_request: NextRequest, props: {
3
20
  params: Promise<{
4
21
  workspaceId: string;
@@ -13,6 +30,22 @@ export declare const GET: (_request: NextRequest, props: {
13
30
  updatedAt: string;
14
31
  };
15
32
  }>>;
33
+ export declare const buildPATCH: ({ prisma }?: {
34
+ prisma?: PrismaClient;
35
+ }) => (request: NextRequest, props: {
36
+ params: Promise<{
37
+ workspaceId: string;
38
+ }>;
39
+ }) => Promise<NextResponse<{
40
+ error: string;
41
+ }> | NextResponse<{
42
+ workspace: {
43
+ id: string;
44
+ name: string;
45
+ createdAt: string;
46
+ updatedAt: string;
47
+ };
48
+ }>>;
16
49
  export declare const PATCH: (request: NextRequest, props: {
17
50
  params: Promise<{
18
51
  workspaceId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../src/app/api/workspaces/[workspaceId]/route.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAQ5D,eAAO,MAAM,G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MAAM,CAAA;KAAE,CAAC,CAAA;CACzC;;;;;;;;;GAwE4B,CAAA;AAEjC,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
@@ -2,11 +2,11 @@ import { headers } from 'next/headers';
2
2
  import { NextResponse } from 'next/server';
3
3
  import { z } from 'zod';
4
4
  import { cacheHeaders } from '../../../../lib/cache/cacheHeaders';
5
- import { prisma } from '../../../../lib/prisma';
5
+ import { getPrisma } from '../../../../lib/prisma';
6
6
  import { validate } from 'uuid';
7
7
  import { getOrganizationApiKey } from '../../../../lib/organizationApiKeys/getOrganizationApiKey';
8
8
  import { serializeApiWorkspace } from '../../../../lib/workspaces/serializeApiWorkspace';
9
- export const GET = async (_request, props) => {
9
+ export const buildGET = ({ prisma = getPrisma() } = {}) => async (_request, props) => {
10
10
  const { workspaceId } = await props.params;
11
11
  const headersList = await headers();
12
12
  const authorization = headersList.get('authorization');
@@ -15,6 +15,7 @@ export const GET = async (_request, props) => {
15
15
  }
16
16
  const organizationApiKey = await getOrganizationApiKey({
17
17
  authorization,
18
+ prisma,
18
19
  });
19
20
  if (!organizationApiKey) {
20
21
  return NextResponse.json({ error: 'Invalid organization api key' }, { status: 400 });
@@ -35,7 +36,8 @@ export const GET = async (_request, props) => {
35
36
  workspace: serializeApiWorkspace({ workspace }),
36
37
  }, { headers: cacheHeaders });
37
38
  };
38
- export const PATCH = async (request, props) => {
39
+ export const GET = buildGET();
40
+ export const buildPATCH = ({ prisma = getPrisma() } = {}) => async (request, props) => {
39
41
  const { workspaceId } = await props.params;
40
42
  const headersList = await headers();
41
43
  const authorization = headersList.get('authorization');
@@ -44,6 +46,7 @@ export const PATCH = async (request, props) => {
44
46
  }
45
47
  const organizationApiKey = await getOrganizationApiKey({
46
48
  authorization,
49
+ prisma,
47
50
  });
48
51
  if (!organizationApiKey) {
49
52
  return NextResponse.json({ error: 'Invalid organization api key' }, { status: 400 });
@@ -78,6 +81,7 @@ export const PATCH = async (request, props) => {
78
81
  workspace: serializeApiWorkspace({ workspace }),
79
82
  }, { headers: cacheHeaders });
80
83
  };
84
+ export const PATCH = buildPATCH();
81
85
  export const OPTIONS = () => NextResponse.json({}, {
82
86
  headers: cacheHeaders,
83
87
  });
@@ -1,4 +1,4 @@
1
- import type { Organization, Workspace } from '@prisma/client';
1
+ import type { Organization, Workspace, PrismaClient } from '@prisma/client';
2
2
  import { NextResponse, type NextRequest } from 'next/server';
3
3
  import { z } from 'zod';
4
4
  declare const createWorkspaceSchema: z.ZodObject<{
@@ -8,6 +8,18 @@ declare const createWorkspaceSchema: z.ZodObject<{
8
8
  }, {
9
9
  name?: string | undefined;
10
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
+ }>>;
11
23
  export declare const GET: () => Promise<NextResponse<{
12
24
  error: string;
13
25
  }> | NextResponse<{
@@ -18,10 +30,12 @@ export declare const GET: () => Promise<NextResponse<{
18
30
  updatedAt: string;
19
31
  }[];
20
32
  }>>;
21
- export declare const buildPOST: ({ createWorkspace, }: {
22
- createWorkspace?: ({ parsedData, organization, }: {
33
+ export declare const buildPOST: ({ prisma, createWorkspace, }?: {
34
+ prisma?: PrismaClient;
35
+ createWorkspace?: ({ parsedData, organization, prisma, }: {
23
36
  parsedData: z.infer<typeof createWorkspaceSchema>;
24
37
  organization: Organization;
38
+ prisma: PrismaClient;
25
39
  }) => Promise<Workspace>;
26
40
  }) => (request: NextRequest) => Promise<NextResponse<{
27
41
  error: string;
@@ -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,MAAM,gBAAgB,CAAA;AAE7D,OAAO,EAAE,YAAY,EAAE,KAAK,WA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BAAqB,CAAC,CAAA;QACjD,YAAY,EAAE,YAAY,CAAA;QAC1B,MAAM,EAAE,YAAY,CAAA;KACrB,KAAK,OAAO,CAAC,SAAS,CAAC,CAAA;CACpB,MACC,SAAS,WAAW;;;;;;;;;GAuD1B,CAAA;AAEH,eAAO,MAAM,IAAI,YAzDC,WAAW;;;;;;;;;GAyDI,CAAA;AAEjC,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
@@ -2,13 +2,13 @@ import { headers } from 'next/headers';
2
2
  import { NextResponse } from 'next/server';
3
3
  import { z } from 'zod';
4
4
  import { cacheHeaders } from '../../../lib/cache/cacheHeaders';
5
- import { prisma } from '../../../lib/prisma';
5
+ import { getPrisma } from '../../../lib/prisma';
6
6
  import { serializeApiWorkspace } from '../../../lib/workspaces/serializeApiWorkspace';
7
7
  import { getOrganizationApiKey } from '../../../lib/organizationApiKeys/getOrganizationApiKey';
8
8
  const createWorkspaceSchema = z.object({
9
9
  name: z.string().optional(),
10
10
  });
11
- export const GET = async () => {
11
+ export const buildGET = ({ prisma = getPrisma() } = {}) => async () => {
12
12
  const headersList = await headers();
13
13
  const authorization = headersList.get('authorization');
14
14
  if (!authorization) {
@@ -16,6 +16,7 @@ export const GET = async () => {
16
16
  }
17
17
  const organizationApiKey = await getOrganizationApiKey({
18
18
  authorization,
19
+ prisma,
19
20
  });
20
21
  if (!organizationApiKey) {
21
22
  return NextResponse.json({ error: 'Invalid organization api key' }, { status: 400 });
@@ -29,7 +30,8 @@ export const GET = async () => {
29
30
  workspaces: workspaces.map((workspace) => serializeApiWorkspace({ workspace })),
30
31
  }, { headers: cacheHeaders });
31
32
  };
32
- export const buildPOST = ({ createWorkspace = ({ parsedData, organization, }) => {
33
+ export const GET = buildGET();
34
+ export const buildPOST = ({ prisma = getPrisma(), createWorkspace = ({ parsedData, organization, prisma, }) => {
33
35
  var _a;
34
36
  return prisma.workspace.create({
35
37
  data: {
@@ -37,7 +39,7 @@ export const buildPOST = ({ createWorkspace = ({ parsedData, organization, }) =>
37
39
  organizationId: organization.id,
38
40
  },
39
41
  });
40
- }, }) => async (request) => {
42
+ }, } = {}) => async (request) => {
41
43
  const headersList = await headers();
42
44
  const authorization = headersList.get('authorization');
43
45
  if (!authorization) {
@@ -45,6 +47,7 @@ export const buildPOST = ({ createWorkspace = ({ parsedData, organization, }) =>
45
47
  }
46
48
  const organizationApiKey = await getOrganizationApiKey({
47
49
  authorization,
50
+ prisma,
48
51
  });
49
52
  if (!organizationApiKey) {
50
53
  return NextResponse.json({ error: 'Invalid organization api key' }, { status: 400 });
@@ -65,6 +68,7 @@ export const buildPOST = ({ createWorkspace = ({ parsedData, organization, }) =>
65
68
  const workspace = await createWorkspace({
66
69
  parsedData: parsed.data,
67
70
  organization,
71
+ prisma,
68
72
  });
69
73
  return NextResponse.json({
70
74
  workspace: serializeApiWorkspace({ workspace }),
@@ -1,6 +1,7 @@
1
- import { ApiKeyType, ApiKey } from '@prisma/client';
2
- export declare const getApiKey: ({ authorization, type, }: {
1
+ import { ApiKeyType, ApiKey, type PrismaClient } from '@prisma/client';
2
+ export declare const getApiKey: ({ authorization, type, prisma, }: {
3
3
  authorization: string | null;
4
4
  type: ApiKeyType;
5
+ prisma: PrismaClient;
5
6
  }) => Promise<ApiKey | null>;
6
7
  //# sourceMappingURL=getApiKey.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getApiKey.d.ts","sourceRoot":"","sources":["../../../src/lib/apiKeys/getApiKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAInD,eAAO,MAAM,SAAS,GAAU,0BAG7B;IACD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,IAAI,EAAE,UAAU,CAAA;CACjB,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAcxB,CAAA"}
1
+ {"version":3,"file":"getApiKey.d.ts","sourceRoot":"","sources":["../../../src/lib/apiKeys/getApiKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAGtE,eAAO,MAAM,SAAS,GAAU,kCAI7B;IACD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,IAAI,EAAE,UAAU,CAAA;IAChB,MAAM,EAAE,YAAY,CAAA;CACrB,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAcxB,CAAA"}