@superinterface/server 1.0.18 → 1.0.19

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 (251) 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]__25ee13bc._.js +1 -1
  21. package/.next/server/chunks/[root-of-the-server]__25ee13bc._.js.map +1 -1
  22. package/.next/server/chunks/[root-of-the-server]__27aadac9._.js +1 -1
  23. package/.next/server/chunks/[root-of-the-server]__27aadac9._.js.map +1 -1
  24. package/.next/server/chunks/[root-of-the-server]__2945c9e9._.js +1 -1
  25. package/.next/server/chunks/[root-of-the-server]__2945c9e9._.js.map +1 -1
  26. package/.next/server/chunks/[root-of-the-server]__29635e8e._.js +1 -1
  27. package/.next/server/chunks/[root-of-the-server]__29635e8e._.js.map +1 -1
  28. package/.next/server/chunks/[root-of-the-server]__29b43490._.js +2 -2
  29. package/.next/server/chunks/[root-of-the-server]__29b43490._.js.map +1 -1
  30. package/.next/server/chunks/[root-of-the-server]__315f084a._.js +1 -1
  31. package/.next/server/chunks/[root-of-the-server]__315f084a._.js.map +1 -1
  32. package/.next/server/chunks/[root-of-the-server]__441cee00._.js +1 -1
  33. package/.next/server/chunks/[root-of-the-server]__441cee00._.js.map +1 -1
  34. package/.next/server/chunks/[root-of-the-server]__464a4377._.js +1 -1
  35. package/.next/server/chunks/[root-of-the-server]__464a4377._.js.map +1 -1
  36. package/.next/server/chunks/[root-of-the-server]__4e536bc0._.js +1 -1
  37. package/.next/server/chunks/[root-of-the-server]__4e536bc0._.js.map +1 -1
  38. package/.next/server/chunks/[root-of-the-server]__51977f30._.js +1 -1
  39. package/.next/server/chunks/[root-of-the-server]__51977f30._.js.map +1 -1
  40. package/.next/server/chunks/[root-of-the-server]__583a7f1c._.js +1 -1
  41. package/.next/server/chunks/[root-of-the-server]__583a7f1c._.js.map +1 -1
  42. package/.next/server/chunks/[root-of-the-server]__5abf1160._.js +1 -1
  43. package/.next/server/chunks/[root-of-the-server]__5abf1160._.js.map +1 -1
  44. package/.next/server/chunks/[root-of-the-server]__5d09614a._.js +1 -1
  45. package/.next/server/chunks/[root-of-the-server]__5d09614a._.js.map +1 -1
  46. package/.next/server/chunks/[root-of-the-server]__62d958e7._.js +1 -1
  47. package/.next/server/chunks/[root-of-the-server]__62d958e7._.js.map +1 -1
  48. package/.next/server/chunks/[root-of-the-server]__7f9ca1e3._.js +1 -1
  49. package/.next/server/chunks/[root-of-the-server]__7f9ca1e3._.js.map +1 -1
  50. package/.next/server/chunks/[root-of-the-server]__83461316._.js +1 -1
  51. package/.next/server/chunks/[root-of-the-server]__83461316._.js.map +1 -1
  52. package/.next/server/chunks/[root-of-the-server]__9a611d42._.js +1 -1
  53. package/.next/server/chunks/[root-of-the-server]__9a611d42._.js.map +1 -1
  54. package/.next/server/chunks/[root-of-the-server]__a135e388._.js +1 -1
  55. package/.next/server/chunks/[root-of-the-server]__a135e388._.js.map +1 -1
  56. package/.next/server/chunks/[root-of-the-server]__b10ec83e._.js +1 -1
  57. package/.next/server/chunks/[root-of-the-server]__b10ec83e._.js.map +1 -1
  58. package/.next/server/chunks/[root-of-the-server]__b9a334c3._.js +1 -1
  59. package/.next/server/chunks/[root-of-the-server]__b9a334c3._.js.map +1 -1
  60. package/.next/server/chunks/[root-of-the-server]__c1629392._.js +1 -1
  61. package/.next/server/chunks/[root-of-the-server]__c1629392._.js.map +1 -1
  62. package/.next/server/chunks/[root-of-the-server]__dd176cb5._.js +2 -2
  63. package/.next/server/chunks/[root-of-the-server]__dd176cb5._.js.map +1 -1
  64. package/.next/server/chunks/[root-of-the-server]__eb816e13._.js +1 -1
  65. package/.next/server/chunks/[root-of-the-server]__eb816e13._.js.map +1 -1
  66. package/.next/server/chunks/[root-of-the-server]__ed6cf593._.js +1 -1
  67. package/.next/server/chunks/[root-of-the-server]__ed6cf593._.js.map +1 -1
  68. package/.next/server/chunks/{[root-of-the-server]__30845206._.js → [root-of-the-server]__ff90af03._.js} +3 -3
  69. package/.next/server/chunks/{[root-of-the-server]__30845206._.js.map → [root-of-the-server]__ff90af03._.js.map} +1 -1
  70. package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_cb746cf4.js +1 -1
  71. package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_cb746cf4.js.map +1 -1
  72. package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_f952d9ab.js +1 -1
  73. package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_f952d9ab.js.map +1 -1
  74. package/.next/server/chunks/supercorp_superinterface_bebd2c96._.js +2 -2
  75. package/.next/server/chunks/supercorp_superinterface_bebd2c96._.js.map +1 -1
  76. package/.next/server/functions-config-manifest.json +2 -2
  77. package/.next/server/pages/404.html +1 -1
  78. package/.next/server/pages/500.html +1 -1
  79. package/.next/trace +1 -1
  80. package/bin/index.cjs +2 -0
  81. package/dist/app/api/api-keys/[apiKeyId]/route.d.ts +55 -0
  82. package/dist/app/api/api-keys/[apiKeyId]/route.d.ts.map +1 -1
  83. package/dist/app/api/api-keys/[apiKeyId]/route.js +10 -4
  84. package/dist/app/api/api-keys/route.d.ts +29 -0
  85. package/dist/app/api/api-keys/route.d.ts.map +1 -1
  86. package/dist/app/api/api-keys/route.js +8 -3
  87. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.d.ts +172 -0
  88. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.d.ts.map +1 -1
  89. package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.js +11 -4
  90. package/dist/app/api/assistants/[assistantId]/functions/route.d.ts +113 -0
  91. package/dist/app/api/assistants/[assistantId]/functions/route.d.ts.map +1 -1
  92. package/dist/app/api/assistants/[assistantId]/functions/route.js +8 -3
  93. package/dist/app/api/assistants/[assistantId]/initial-messages/route.d.ts +39 -0
  94. package/dist/app/api/assistants/[assistantId]/initial-messages/route.d.ts.map +1 -1
  95. package/dist/app/api/assistants/[assistantId]/initial-messages/route.js +8 -3
  96. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.d.ts +94 -0
  97. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.d.ts.map +1 -1
  98. package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.js +10 -4
  99. package/dist/app/api/assistants/[assistantId]/mcp-servers/route.d.ts +61 -0
  100. package/dist/app/api/assistants/[assistantId]/mcp-servers/route.d.ts.map +1 -1
  101. package/dist/app/api/assistants/[assistantId]/mcp-servers/route.js +7 -3
  102. package/dist/app/api/assistants/[assistantId]/route.d.ts +123 -0
  103. package/dist/app/api/assistants/[assistantId]/route.d.ts.map +1 -1
  104. package/dist/app/api/assistants/[assistantId]/route.js +15 -6
  105. package/dist/app/api/assistants/route.d.ts +59 -0
  106. package/dist/app/api/assistants/route.d.ts.map +1 -1
  107. package/dist/app/api/assistants/route.js +8 -4
  108. package/dist/app/api/files/[fileId]/contents/route.d.ts +3 -2
  109. package/dist/app/api/files/[fileId]/contents/route.d.ts.map +1 -1
  110. package/dist/app/api/files/[fileId]/contents/route.js +6 -3
  111. package/dist/app/api/files/route.d.ts +10 -0
  112. package/dist/app/api/files/route.d.ts.map +1 -1
  113. package/dist/app/api/files/route.js +7 -3
  114. package/dist/app/api/messages/route.d.ts +24 -1
  115. package/dist/app/api/messages/route.d.ts.map +1 -1
  116. package/dist/app/api/messages/route.js +27 -6
  117. package/dist/app/api/providers/[modelProviderId]/assistants/route.d.ts +19 -0
  118. package/dist/app/api/providers/[modelProviderId]/assistants/route.d.ts.map +1 -1
  119. package/dist/app/api/providers/[modelProviderId]/assistants/route.js +4 -2
  120. package/dist/app/api/providers/[modelProviderId]/models/route.d.ts +14 -0
  121. package/dist/app/api/providers/[modelProviderId]/models/route.d.ts.map +1 -1
  122. package/dist/app/api/providers/[modelProviderId]/models/route.js +4 -2
  123. package/dist/app/api/providers/[modelProviderId]/route.d.ts +64 -0
  124. package/dist/app/api/providers/[modelProviderId]/route.d.ts.map +1 -1
  125. package/dist/app/api/providers/[modelProviderId]/route.js +12 -6
  126. package/dist/app/api/providers/route.d.ts +35 -0
  127. package/dist/app/api/providers/route.d.ts.map +1 -1
  128. package/dist/app/api/providers/route.js +9 -5
  129. package/dist/app/api/tasks/[taskId]/route.d.ts +61 -0
  130. package/dist/app/api/tasks/[taskId]/route.d.ts.map +1 -1
  131. package/dist/app/api/tasks/[taskId]/route.js +11 -5
  132. package/dist/app/api/tasks/callback/route.d.ts.map +1 -1
  133. package/dist/app/api/tasks/callback/route.js +14 -6
  134. package/dist/app/api/tasks/route.d.ts +33 -0
  135. package/dist/app/api/tasks/route.d.ts.map +1 -1
  136. package/dist/app/api/tasks/route.js +8 -4
  137. package/dist/app/api/threads/runs/submit-client-tool-outputs/route.d.ts +9 -1
  138. package/dist/app/api/threads/runs/submit-client-tool-outputs/route.d.ts.map +1 -1
  139. package/dist/app/api/threads/runs/submit-client-tool-outputs/route.js +5 -3
  140. package/dist/app/api/workspaces/[workspaceId]/route.d.ts +33 -0
  141. package/dist/app/api/workspaces/[workspaceId]/route.d.ts.map +1 -1
  142. package/dist/app/api/workspaces/[workspaceId]/route.js +7 -3
  143. package/dist/app/api/workspaces/route.d.ts +17 -3
  144. package/dist/app/api/workspaces/route.d.ts.map +1 -1
  145. package/dist/app/api/workspaces/route.js +8 -4
  146. package/dist/lib/apiKeys/getApiKey.d.ts +3 -2
  147. package/dist/lib/apiKeys/getApiKey.d.ts.map +1 -1
  148. package/dist/lib/apiKeys/getApiKey.js +1 -2
  149. package/dist/lib/apiKeys/workspaceAccessWhere.d.ts +3 -1
  150. package/dist/lib/apiKeys/workspaceAccessWhere.d.ts.map +1 -1
  151. package/dist/lib/apiKeys/workspaceAccessWhere.js +2 -1
  152. package/dist/lib/assistants/assistantClientAdapter/buildGetOpenaiAssistant.d.ts +3 -2
  153. package/dist/lib/assistants/assistantClientAdapter/buildGetOpenaiAssistant.d.ts.map +1 -1
  154. package/dist/lib/assistants/assistantClientAdapter/buildGetOpenaiAssistant.js +3 -3
  155. package/dist/lib/assistants/assistantClientAdapter/index.d.ts.map +1 -1
  156. package/dist/lib/assistants/assistantClientAdapter/index.js +7 -2
  157. package/dist/lib/computerCalls/handleComputerCall/index.d.ts +3 -2
  158. package/dist/lib/computerCalls/handleComputerCall/index.d.ts.map +1 -1
  159. package/dist/lib/computerCalls/handleComputerCall/index.js +5 -1
  160. package/dist/lib/functions/createFunction.d.ts +2 -1
  161. package/dist/lib/functions/createFunction.d.ts.map +1 -1
  162. package/dist/lib/functions/createFunction.js +2 -2
  163. package/dist/lib/functions/handleFunction/handleAssistant.d.ts +3 -2
  164. package/dist/lib/functions/handleFunction/handleAssistant.d.ts.map +1 -1
  165. package/dist/lib/functions/handleFunction/handleAssistant.js +12 -2
  166. package/dist/lib/functions/handleFunction/handleClientTool.d.ts +3 -2
  167. package/dist/lib/functions/handleFunction/handleClientTool.d.ts.map +1 -1
  168. package/dist/lib/functions/handleFunction/handleClientTool.js +2 -1
  169. package/dist/lib/functions/handleFunction/handleFirecrawl.d.ts +3 -2
  170. package/dist/lib/functions/handleFunction/handleFirecrawl.d.ts.map +1 -1
  171. package/dist/lib/functions/handleFunction/handleFirecrawl.js +7 -1
  172. package/dist/lib/functions/handleFunction/handleReplicate.d.ts +3 -2
  173. package/dist/lib/functions/handleFunction/handleReplicate.d.ts.map +1 -1
  174. package/dist/lib/functions/handleFunction/handleReplicate.js +4 -1
  175. package/dist/lib/functions/handleFunction/handleRequest.d.ts +3 -2
  176. package/dist/lib/functions/handleFunction/handleRequest.d.ts.map +1 -1
  177. package/dist/lib/functions/handleFunction/handleRequest.js +6 -1
  178. package/dist/lib/functions/handleFunction/index.d.ts +3 -2
  179. package/dist/lib/functions/handleFunction/index.d.ts.map +1 -1
  180. package/dist/lib/functions/handleFunction/index.js +25 -1
  181. package/dist/lib/functions/handleFunction/tasks/handleCreateTask.d.ts +3 -2
  182. package/dist/lib/functions/handleFunction/tasks/handleCreateTask.d.ts.map +1 -1
  183. package/dist/lib/functions/handleFunction/tasks/handleCreateTask.js +4 -4
  184. package/dist/lib/functions/handleFunction/tasks/handleDeleteTask.d.ts +3 -2
  185. package/dist/lib/functions/handleFunction/tasks/handleDeleteTask.d.ts.map +1 -1
  186. package/dist/lib/functions/handleFunction/tasks/handleDeleteTask.js +3 -3
  187. package/dist/lib/functions/handleFunction/tasks/handleListTasks.d.ts +3 -2
  188. package/dist/lib/functions/handleFunction/tasks/handleListTasks.d.ts.map +1 -1
  189. package/dist/lib/functions/handleFunction/tasks/handleListTasks.js +3 -3
  190. package/dist/lib/functions/handleFunction/tasks/handleUpdateTask.d.ts +3 -2
  191. package/dist/lib/functions/handleFunction/tasks/handleUpdateTask.d.ts.map +1 -1
  192. package/dist/lib/functions/handleFunction/tasks/handleUpdateTask.js +4 -4
  193. package/dist/lib/functions/updateFunction.d.ts +2 -1
  194. package/dist/lib/functions/updateFunction.d.ts.map +1 -1
  195. package/dist/lib/functions/updateFunction.js +2 -2
  196. package/dist/lib/handlers/handlerPrismaInput.d.ts +3 -1
  197. package/dist/lib/handlers/handlerPrismaInput.d.ts.map +1 -1
  198. package/dist/lib/handlers/handlerPrismaInput.jsx +1 -2
  199. package/dist/lib/initialMessages/updateInitialMessages.d.ts +3 -2
  200. package/dist/lib/initialMessages/updateInitialMessages.d.ts.map +1 -1
  201. package/dist/lib/initialMessages/updateInitialMessages.js +1 -2
  202. package/dist/lib/logs/createLog.d.ts +3 -2
  203. package/dist/lib/logs/createLog.d.ts.map +1 -1
  204. package/dist/lib/logs/createLog.js +1 -2
  205. package/dist/lib/mcpServers/connectMcpServer.d.ts +6 -4
  206. package/dist/lib/mcpServers/connectMcpServer.d.ts.map +1 -1
  207. package/dist/lib/mcpServers/connectMcpServer.js +7 -5
  208. package/dist/lib/mcpServers/getToolCallMcpServer.d.ts +3 -2
  209. package/dist/lib/mcpServers/getToolCallMcpServer.d.ts.map +1 -1
  210. package/dist/lib/mcpServers/getToolCallMcpServer.js +2 -1
  211. package/dist/lib/mcpServers/headers.d.ts +3 -2
  212. package/dist/lib/mcpServers/headers.d.ts.map +1 -1
  213. package/dist/lib/mcpServers/headers.js +2 -1
  214. package/dist/lib/mcpServers/url.d.ts +3 -2
  215. package/dist/lib/mcpServers/url.d.ts.map +1 -1
  216. package/dist/lib/mcpServers/url.js +2 -1
  217. package/dist/lib/metadata/serializeMetadata.d.ts +3 -1
  218. package/dist/lib/metadata/serializeMetadata.d.ts.map +1 -1
  219. package/dist/lib/metadata/serializeMetadata.js +3 -2
  220. package/dist/lib/organizationApiKeys/getOrganizationApiKey.d.ts +3 -2
  221. package/dist/lib/organizationApiKeys/getOrganizationApiKey.d.ts.map +1 -1
  222. package/dist/lib/organizationApiKeys/getOrganizationApiKey.js +1 -2
  223. package/dist/lib/runs/createRunOpts.d.ts +3 -2
  224. package/dist/lib/runs/createRunOpts.d.ts.map +1 -1
  225. package/dist/lib/runs/createRunOpts.js +2 -2
  226. package/dist/lib/tasks/getTaskToolKey.d.ts +3 -2
  227. package/dist/lib/tasks/getTaskToolKey.d.ts.map +1 -1
  228. package/dist/lib/tasks/getTaskToolKey.js +2 -1
  229. package/dist/lib/tasks/parseTaskToolArgs.d.ts +3 -2
  230. package/dist/lib/tasks/parseTaskToolArgs.d.ts.map +1 -1
  231. package/dist/lib/tasks/parseTaskToolArgs.js +4 -1
  232. package/dist/lib/tasks/scheduleTask.d.ts +3 -2
  233. package/dist/lib/tasks/scheduleTask.d.ts.map +1 -1
  234. package/dist/lib/tasks/scheduleTask.js +1 -2
  235. package/dist/lib/threads/createThread/index.d.ts +3 -3
  236. package/dist/lib/threads/createThread/index.d.ts.map +1 -1
  237. package/dist/lib/threads/createThread/index.js +1 -0
  238. package/dist/lib/threads/managedOpenaiThreadId.d.ts +3 -2
  239. package/dist/lib/threads/managedOpenaiThreadId.d.ts.map +1 -1
  240. package/dist/lib/threads/managedOpenaiThreadId.js +1 -2
  241. package/dist/lib/toolCalls/handleToolCall.d.ts +3 -2
  242. package/dist/lib/toolCalls/handleToolCall.d.ts.map +1 -1
  243. package/dist/lib/toolCalls/handleToolCall.js +5 -1
  244. package/dist/lib/tools/tools/index.d.ts +3 -2
  245. package/dist/lib/tools/tools/index.d.ts.map +1 -1
  246. package/dist/lib/tools/tools/index.js +9 -6
  247. package/package.json +1 -1
  248. package/scripts/utils/loadPrisma.ts +1 -2
  249. /package/.next/static/{s_BjB5fnRbk2L3A0fMr5L → rEvucoSBXJWMKfLWTgPF2}/_buildManifest.js +0 -0
  250. /package/.next/static/{s_BjB5fnRbk2L3A0fMr5L → rEvucoSBXJWMKfLWTgPF2}/_clientMiddlewareManifest.json +0 -0
  251. /package/.next/static/{s_BjB5fnRbk2L3A0fMr5L → rEvucoSBXJWMKfLWTgPF2}/_ssgManifest.js +0 -0
@@ -1,3 +1,3 @@
1
- module.exports=[18622,(e,t,r)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},20635,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/action-async-storage.external.js",()=>require("next/dist/server/app-render/action-async-storage.external.js"))},93695,(e,t,r)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},30611,e=>{"use strict";e.s(["cacheHeaders",()=>t]);let t={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, OPTIONS","Access-Control-Allow-Headers":"Content-Type"}},88122,e=>{"use strict";e.s(["getApiKey",()=>a]);var t=e.i(55897),r=e.i(24493);let a=async({authorization:e,type:a})=>{if(!e)return null;let[,s]=e.split("Bearer ");return(0,t.validate)(s)?r.prisma.apiKey.findFirst({where:{type:a,value:s}}):null}},14394,e=>{"use strict";e.s(["serializeModelProvider",()=>t]);let t=({provider:e})=>({id:e.id,type:e.type,name:e.name,apiKey:e.apiKey,endpoint:e.endpoint,apiVersion:e.apiVersion,workspaceId:e.workspaceId,createdAt:e.createdAt.toISOString(),updatedAt:e.updatedAt.toISOString()})},66793,e=>{"use strict";e.s([])},12813,e=>{"use strict";e.s(["handler",()=>q,"patchFetch",()=>K,"routeModule",()=>O,"serverHooks",()=>H,"workAsyncStorage",()=>b,"workUnitAsyncStorage",()=>S],12813);var t=e.i(5865),r=e.i(43877),a=e.i(77767),s=e.i(92562),i=e.i(66256),o=e.i(5270),n=e.i(90231),d=e.i(82677),l=e.i(51081),p=e.i(89822),u=e.i(9124),c=e.i(39147),v=e.i(40568),h=e.i(87188),x=e.i(93695);e.i(57132);var R=e.i(80739);e.s(["DELETE",()=>j,"GET",()=>I,"OPTIONS",()=>T,"PATCH",()=>C],68481);var w=e.i(11053),f=e.i(29173),m=e.i(49493),y=e.i(13669),g=e.i(30611),E=e.i(24493),A=e.i(14394),N=e.i(88122),P=e.i(55897);let I=async(e,t)=>{let{modelProviderId:r}=await t.params,a=(await (0,w.headers)()).get("authorization");if(!a)return m.NextResponse.json({error:"No authorization header found"},{status:400});let s=await (0,N.getApiKey)({type:f.ApiKeyType.PRIVATE,authorization:a});if(!s)return m.NextResponse.json({error:"Invalid api key"},{status:400});if(!(0,P.validate)(r))return m.NextResponse.json({error:"Invalid provider id"},{status:400});let i=await E.prisma.modelProvider.findFirst({where:{id:r,workspaceId:s.workspaceId}});return i?m.NextResponse.json({provider:(0,A.serializeModelProvider)({provider:i})},{headers:g.cacheHeaders}):m.NextResponse.json({error:"No provider found"},{status:400})},C=async(e,t)=>{let{modelProviderId:r}=await t.params,a=(await (0,w.headers)()).get("authorization");if(!a)return m.NextResponse.json({error:"No authorization header found"},{status:400});let s=await (0,N.getApiKey)({authorization:a,type:f.ApiKeyType.PRIVATE});if(!s)return m.NextResponse.json({error:"Invalid api key"},{status:400});if(!(0,P.validate)(r))return m.NextResponse.json({error:"Invalid provider id"},{status:400});let i=await e.json(),o=y.z.object({type:y.z.nativeEnum(f.ModelProviderType).optional(),name:y.z.string().optional(),apiKey:y.z.string().optional(),endpoint:y.z.string().optional().nullable(),apiVersion:y.z.string().optional().nullable()}).safeParse(i);if(!o.success)return m.NextResponse.json({error:"Invalid payload"},{status:400});let{type:n,apiKey:d,endpoint:l,apiVersion:p,name:u}=o.data,c={...n?{type:n}:{},...void 0!==u?{name:u}:{},...void 0!==d?{apiKey:d}:{},...void 0!==l?{endpoint:l}:{},...void 0!==p?{apiVersion:p}:{}};if(!await E.prisma.modelProvider.findFirst({where:{id:r,workspaceId:s.workspaceId}}))return m.NextResponse.json({error:"No provider found"},{status:400});let v=await E.prisma.modelProvider.update({where:{id:r},data:c});return m.NextResponse.json({provider:(0,A.serializeModelProvider)({provider:v})},{headers:g.cacheHeaders})},j=async(e,t)=>{let{modelProviderId:r}=await t.params,a=(await (0,w.headers)()).get("authorization");if(!a)return m.NextResponse.json({error:"No authorization header found"},{status:400});let s=await (0,N.getApiKey)({authorization:a,type:f.ApiKeyType.PRIVATE});if(!s)return m.NextResponse.json({error:"Invalid api key"},{status:400});if(!(0,P.validate)(r))return m.NextResponse.json({error:"Invalid provider id"},{status:400});if(await E.prisma.assistant.count({where:{modelProviderId:r,workspaceId:s.workspaceId}})>0)return m.NextResponse.json({error:"Provider in use"},{status:400});if(!await E.prisma.modelProvider.findFirst({where:{id:r,workspaceId:s.workspaceId}}))return m.NextResponse.json({error:"No provider found"},{status:400});let i=await E.prisma.modelProvider.delete({where:{id:r}});return m.NextResponse.json({provider:(0,A.serializeModelProvider)({provider:i})},{headers:g.cacheHeaders})},T=()=>m.NextResponse.json({},{headers:g.cacheHeaders});var k=e.i(68481);let O=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/providers/[modelProviderId]/route",pathname:"/api/providers/[modelProviderId]",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/supercorp/superinterface/packages/server/src/app/api/providers/[modelProviderId]/route.ts",nextConfigOutput:"",userland:k}),{workAsyncStorage:b,workUnitAsyncStorage:S,serverHooks:H}=O;function K(){return(0,a.patchFetch)({workAsyncStorage:b,workUnitAsyncStorage:S})}async function q(e,t,a){var w;let f="/api/providers/[modelProviderId]/route";f=f.replace(/\/index$/,"")||"/";let m=await O.prepare(e,t,{srcPage:f,multiZoneDraftMode:!1});if(!m)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:y,params:g,nextConfig:E,isDraftMode:A,prerenderManifest:N,routerServerContext:P,isOnDemandRevalidate:I,revalidateOnlyGenerated:C,resolvedPathname:j}=m,T=(0,o.normalizeAppPath)(f),k=!!(N.dynamicRoutes[T]||N.routes[j]);if(k&&!A){let e=!!N.routes[j],t=N.dynamicRoutes[T];if(t&&!1===t.fallback&&!e)throw new x.NoFallbackError}let b=null;!k||O.isDev||A||(b="/index"===(b=j)?"/":b);let S=!0===O.isDev||!k,H=k&&!S,K=e.method||"GET",q=(0,i.getTracer)(),M=q.getActiveScopeSpan(),_={params:g,prerenderManifest:N,renderOpts:{experimental:{cacheComponents:!!E.experimental.cacheComponents,authInterrupts:!!E.experimental.authInterrupts},supportsDynamicResponse:S,incrementalCache:(0,s.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:null==(w=E.experimental)?void 0:w.cacheLife,isRevalidate:H,waitUntil:a.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a)=>O.onRequestError(e,t,a,P)},sharedContext:{buildId:y}},z=new n.NodeNextRequest(e),U=new n.NodeNextResponse(t),D=d.NextRequestAdapter.fromNodeNextRequest(z,(0,d.signalFromNodeResponse)(t));try{let o=async r=>O.handle(D,_).finally(()=>{if(!r)return;r.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let a=q.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==l.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let s=a.get("next.route");if(s){let e=`${K} ${s}`;r.setAttributes({"next.route":s,"http.route":s,"next.span_name":e}),r.updateName(e)}else r.updateName(`${K} ${e.url}`)}),n=async i=>{var n,d;let l=async({previousCacheEntry:r})=>{try{if(!(0,s.getRequestMeta)(e,"minimalMode")&&I&&C&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let n=await o(i);e.fetchMetrics=_.renderOpts.fetchMetrics;let d=_.renderOpts.pendingWaitUntil;d&&a.waitUntil&&(a.waitUntil(d),d=void 0);let l=_.renderOpts.collectedTags;if(!k)return await (0,u.sendResponse)(z,U,n,_.renderOpts.pendingWaitUntil),null;{let e=await n.blob(),t=(0,c.toNodeOutgoingHttpHeaders)(n.headers);l&&(t[h.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==_.renderOpts.collectedRevalidate&&!(_.renderOpts.collectedRevalidate>=h.INFINITE_CACHE)&&_.renderOpts.collectedRevalidate,a=void 0===_.renderOpts.collectedExpire||_.renderOpts.collectedExpire>=h.INFINITE_CACHE?void 0:_.renderOpts.collectedExpire;return{value:{kind:R.CachedRouteKind.APP_ROUTE,status:n.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:a}}}}catch(t){throw(null==r?void 0:r.isStale)&&await O.onRequestError(e,t,{routerKind:"App Router",routePath:f,routeType:"route",revalidateReason:(0,p.getRevalidateReason)({isRevalidate:H,isOnDemandRevalidate:I})},P),t}},x=await O.handleResponse({req:e,nextConfig:E,cacheKey:b,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:N,isRoutePPREnabled:!1,isOnDemandRevalidate:I,revalidateOnlyGenerated:C,responseGenerator:l,waitUntil:a.waitUntil});if(!k)return null;if((null==x||null==(n=x.value)?void 0:n.kind)!==R.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==x||null==(d=x.value)?void 0:d.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});(0,s.getRequestMeta)(e,"minimalMode")||t.setHeader("x-nextjs-cache",I?"REVALIDATED":x.isMiss?"MISS":x.isStale?"STALE":"HIT"),A&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let w=(0,c.fromNodeOutgoingHttpHeaders)(x.value.headers);return(0,s.getRequestMeta)(e,"minimalMode")&&k||w.delete(h.NEXT_CACHE_TAGS_HEADER),!x.cacheControl||t.getHeader("Cache-Control")||w.get("Cache-Control")||w.set("Cache-Control",(0,v.getCacheControlHeader)(x.cacheControl)),await (0,u.sendResponse)(z,U,new Response(x.value.body,{headers:w,status:x.value.status||200})),null};M?await n(M):await q.withPropagatedContext(e.headers,()=>q.trace(l.BaseServerSpan.handleRequest,{spanName:`${K} ${e.url}`,kind:i.SpanKind.SERVER,attributes:{"http.method":K,"http.target":e.url}},n))}catch(t){if(t instanceof x.NoFallbackError||await O.onRequestError(e,t,{routerKind:"App Router",routePath:T,routeType:"route",revalidateReason:(0,p.getRevalidateReason)({isRevalidate:H,isOnDemandRevalidate:I})}),k)throw t;return await (0,u.sendResponse)(z,U,new Response(null,{status:500})),null}}}];
1
+ module.exports=[18622,(e,t,r)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},20635,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/action-async-storage.external.js",()=>require("next/dist/server/app-render/action-async-storage.external.js"))},93695,(e,t,r)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},30611,e=>{"use strict";e.s(["cacheHeaders",()=>t]);let t={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, OPTIONS","Access-Control-Allow-Headers":"Content-Type"}},88122,e=>{"use strict";e.s(["getApiKey",()=>r]);var t=e.i(55897);let r=async({authorization:e,type:r,prisma:a})=>{if(!e)return null;let[,s]=e.split("Bearer ");return(0,t.validate)(s)?a.apiKey.findFirst({where:{type:r,value:s}}):null}},14394,e=>{"use strict";e.s(["serializeModelProvider",()=>t]);let t=({provider:e})=>({id:e.id,type:e.type,name:e.name,apiKey:e.apiKey,endpoint:e.endpoint,apiVersion:e.apiVersion,workspaceId:e.workspaceId,createdAt:e.createdAt.toISOString(),updatedAt:e.updatedAt.toISOString()})},66793,e=>{"use strict";e.s([])},12813,e=>{"use strict";e.s(["handler",()=>z,"patchFetch",()=>_,"routeModule",()=>S,"serverHooks",()=>M,"workAsyncStorage",()=>K,"workUnitAsyncStorage",()=>q],12813);var t=e.i(5865),r=e.i(43877),a=e.i(77767),s=e.i(92562),i=e.i(66256),o=e.i(5270),n=e.i(90231),d=e.i(82677),l=e.i(51081),p=e.i(89822),u=e.i(9124),c=e.i(39147),v=e.i(40568),h=e.i(87188),x=e.i(93695);e.i(57132);var R=e.i(80739);e.s(["DELETE",()=>b,"GET",()=>T,"OPTIONS",()=>O,"PATCH",()=>j,"buildDELETE",()=>k,"buildGET",()=>I,"buildPATCH",()=>C],68481);var w=e.i(11053),f=e.i(29173),y=e.i(49493),m=e.i(13669),g=e.i(30611),E=e.i(24493),A=e.i(14394),N=e.i(88122),P=e.i(55897);let I=({prisma:e=E.prisma}={})=>async(t,r)=>{let{modelProviderId:a}=await r.params,s=(await (0,w.headers)()).get("authorization");if(!s)return y.NextResponse.json({error:"No authorization header found"},{status:400});let i=await (0,N.getApiKey)({type:f.ApiKeyType.PRIVATE,authorization:s,prisma:e});if(!i)return y.NextResponse.json({error:"Invalid api key"},{status:400});if(!(0,P.validate)(a))return y.NextResponse.json({error:"Invalid provider id"},{status:400});let o=await e.modelProvider.findFirst({where:{id:a,workspaceId:i.workspaceId}});return o?y.NextResponse.json({provider:(0,A.serializeModelProvider)({provider:o})},{headers:g.cacheHeaders}):y.NextResponse.json({error:"No provider found"},{status:400})},T=I(),C=({prisma:e=E.prisma}={})=>async(t,r)=>{let{modelProviderId:a}=await r.params,s=(await (0,w.headers)()).get("authorization");if(!s)return y.NextResponse.json({error:"No authorization header found"},{status:400});let i=await (0,N.getApiKey)({authorization:s,type:f.ApiKeyType.PRIVATE,prisma:e});if(!i)return y.NextResponse.json({error:"Invalid api key"},{status:400});if(!(0,P.validate)(a))return y.NextResponse.json({error:"Invalid provider id"},{status:400});let o=await t.json(),n=m.z.object({type:m.z.nativeEnum(f.ModelProviderType).optional(),name:m.z.string().optional(),apiKey:m.z.string().optional(),endpoint:m.z.string().optional().nullable(),apiVersion:m.z.string().optional().nullable()}).safeParse(o);if(!n.success)return y.NextResponse.json({error:"Invalid payload"},{status:400});let{type:d,apiKey:l,endpoint:p,apiVersion:u,name:c}=n.data,v={...d?{type:d}:{},...void 0!==c?{name:c}:{},...void 0!==l?{apiKey:l}:{},...void 0!==p?{endpoint:p}:{},...void 0!==u?{apiVersion:u}:{}};if(!await e.modelProvider.findFirst({where:{id:a,workspaceId:i.workspaceId}}))return y.NextResponse.json({error:"No provider found"},{status:400});let h=await e.modelProvider.update({where:{id:a},data:v});return y.NextResponse.json({provider:(0,A.serializeModelProvider)({provider:h})},{headers:g.cacheHeaders})},j=C(),k=({prisma:e=E.prisma}={})=>async(t,r)=>{let{modelProviderId:a}=await r.params,s=(await (0,w.headers)()).get("authorization");if(!s)return y.NextResponse.json({error:"No authorization header found"},{status:400});let i=await (0,N.getApiKey)({authorization:s,type:f.ApiKeyType.PRIVATE,prisma:e});if(!i)return y.NextResponse.json({error:"Invalid api key"},{status:400});if(!(0,P.validate)(a))return y.NextResponse.json({error:"Invalid provider id"},{status:400});if(await e.assistant.count({where:{modelProviderId:a,workspaceId:i.workspaceId}})>0)return y.NextResponse.json({error:"Provider in use"},{status:400});if(!await e.modelProvider.findFirst({where:{id:a,workspaceId:i.workspaceId}}))return y.NextResponse.json({error:"No provider found"},{status:400});let o=await e.modelProvider.delete({where:{id:a}});return y.NextResponse.json({provider:(0,A.serializeModelProvider)({provider:o})},{headers:g.cacheHeaders})},b=k(),O=()=>y.NextResponse.json({},{headers:g.cacheHeaders});var H=e.i(68481);let S=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/providers/[modelProviderId]/route",pathname:"/api/providers/[modelProviderId]",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/supercorp/superinterface/packages/server/src/app/api/providers/[modelProviderId]/route.ts",nextConfigOutput:"",userland:H}),{workAsyncStorage:K,workUnitAsyncStorage:q,serverHooks:M}=S;function _(){return(0,a.patchFetch)({workAsyncStorage:K,workUnitAsyncStorage:q})}async function z(e,t,a){var w;let f="/api/providers/[modelProviderId]/route";f=f.replace(/\/index$/,"")||"/";let y=await S.prepare(e,t,{srcPage:f,multiZoneDraftMode:!1});if(!y)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:m,params:g,nextConfig:E,isDraftMode:A,prerenderManifest:N,routerServerContext:P,isOnDemandRevalidate:I,revalidateOnlyGenerated:T,resolvedPathname:C}=y,j=(0,o.normalizeAppPath)(f),k=!!(N.dynamicRoutes[j]||N.routes[C]);if(k&&!A){let e=!!N.routes[C],t=N.dynamicRoutes[j];if(t&&!1===t.fallback&&!e)throw new x.NoFallbackError}let b=null;!k||S.isDev||A||(b="/index"===(b=C)?"/":b);let O=!0===S.isDev||!k,H=k&&!O,K=e.method||"GET",q=(0,i.getTracer)(),M=q.getActiveScopeSpan(),_={params:g,prerenderManifest:N,renderOpts:{experimental:{cacheComponents:!!E.experimental.cacheComponents,authInterrupts:!!E.experimental.authInterrupts},supportsDynamicResponse:O,incrementalCache:(0,s.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:null==(w=E.experimental)?void 0:w.cacheLife,isRevalidate:H,waitUntil:a.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a)=>S.onRequestError(e,t,a,P)},sharedContext:{buildId:m}},z=new n.NodeNextRequest(e),U=new n.NodeNextResponse(t),D=d.NextRequestAdapter.fromNodeNextRequest(z,(0,d.signalFromNodeResponse)(t));try{let o=async r=>S.handle(D,_).finally(()=>{if(!r)return;r.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let a=q.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==l.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let s=a.get("next.route");if(s){let e=`${K} ${s}`;r.setAttributes({"next.route":s,"http.route":s,"next.span_name":e}),r.updateName(e)}else r.updateName(`${K} ${e.url}`)}),n=async i=>{var n,d;let l=async({previousCacheEntry:r})=>{try{if(!(0,s.getRequestMeta)(e,"minimalMode")&&I&&T&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let n=await o(i);e.fetchMetrics=_.renderOpts.fetchMetrics;let d=_.renderOpts.pendingWaitUntil;d&&a.waitUntil&&(a.waitUntil(d),d=void 0);let l=_.renderOpts.collectedTags;if(!k)return await (0,u.sendResponse)(z,U,n,_.renderOpts.pendingWaitUntil),null;{let e=await n.blob(),t=(0,c.toNodeOutgoingHttpHeaders)(n.headers);l&&(t[h.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==_.renderOpts.collectedRevalidate&&!(_.renderOpts.collectedRevalidate>=h.INFINITE_CACHE)&&_.renderOpts.collectedRevalidate,a=void 0===_.renderOpts.collectedExpire||_.renderOpts.collectedExpire>=h.INFINITE_CACHE?void 0:_.renderOpts.collectedExpire;return{value:{kind:R.CachedRouteKind.APP_ROUTE,status:n.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:a}}}}catch(t){throw(null==r?void 0:r.isStale)&&await S.onRequestError(e,t,{routerKind:"App Router",routePath:f,routeType:"route",revalidateReason:(0,p.getRevalidateReason)({isRevalidate:H,isOnDemandRevalidate:I})},P),t}},x=await S.handleResponse({req:e,nextConfig:E,cacheKey:b,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:N,isRoutePPREnabled:!1,isOnDemandRevalidate:I,revalidateOnlyGenerated:T,responseGenerator:l,waitUntil:a.waitUntil});if(!k)return null;if((null==x||null==(n=x.value)?void 0:n.kind)!==R.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==x||null==(d=x.value)?void 0:d.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});(0,s.getRequestMeta)(e,"minimalMode")||t.setHeader("x-nextjs-cache",I?"REVALIDATED":x.isMiss?"MISS":x.isStale?"STALE":"HIT"),A&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let w=(0,c.fromNodeOutgoingHttpHeaders)(x.value.headers);return(0,s.getRequestMeta)(e,"minimalMode")&&k||w.delete(h.NEXT_CACHE_TAGS_HEADER),!x.cacheControl||t.getHeader("Cache-Control")||w.get("Cache-Control")||w.set("Cache-Control",(0,v.getCacheControlHeader)(x.cacheControl)),await (0,u.sendResponse)(z,U,new Response(x.value.body,{headers:w,status:x.value.status||200})),null};M?await n(M):await q.withPropagatedContext(e.headers,()=>q.trace(l.BaseServerSpan.handleRequest,{spanName:`${K} ${e.url}`,kind:i.SpanKind.SERVER,attributes:{"http.method":K,"http.target":e.url}},n))}catch(t){if(t instanceof x.NoFallbackError||await S.onRequestError(e,t,{routerKind:"App Router",routePath:j,routeType:"route",revalidateReason:(0,p.getRevalidateReason)({isRevalidate:H,isOnDemandRevalidate:I})}),k)throw t;return await (0,u.sendResponse)(z,U,new Response(null,{status:500})),null}}}];
2
2
 
3
3
  //# sourceMappingURL=%5Broot-of-the-server%5D__0c1bc5ed._.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["turbopack:///[project]/supercorp/superinterface/packages/server/src/lib/cache/cacheHeaders.ts","turbopack:///[project]/supercorp/superinterface/packages/server/src/lib/apiKeys/getApiKey.ts","turbopack:///[project]/supercorp/superinterface/packages/server/src/lib/modelProviders/serializeModelProvider.ts","turbopack:///[project]/supercorp/superinterface/packages/server/src/app/api/providers/[modelProviderId]/route.ts","turbopack:///[project]/supercorp/superinterface/node_modules/next/dist/esm/build/templates/app-route.js"],"sourcesContent":["export const cacheHeaders = {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',\n 'Access-Control-Allow-Headers': 'Content-Type',\n}\n","import { ApiKeyType, ApiKey } from '@prisma/client'\nimport { validate } from 'uuid'\nimport { prisma } from '@/lib/prisma'\n\nexport const getApiKey = async ({\n authorization,\n type,\n}: {\n authorization: string | null\n type: ApiKeyType\n}): Promise<ApiKey | null> => {\n if (!authorization) {\n return null\n }\n\n const [, apiKeyValue] = authorization.split('Bearer ')\n\n if (!validate(apiKeyValue)) {\n return null\n }\n\n return prisma.apiKey.findFirst({\n where: { type, value: apiKeyValue },\n })\n}\n","import type { ModelProvider } from '@prisma/client'\n\nexport const serializeModelProvider = ({\n provider,\n}: {\n provider: ModelProvider\n}) => ({\n id: provider.id,\n type: provider.type,\n name: provider.name,\n apiKey: provider.apiKey,\n endpoint: provider.endpoint,\n apiVersion: provider.apiVersion,\n workspaceId: provider.workspaceId,\n createdAt: provider.createdAt.toISOString(),\n updatedAt: provider.updatedAt.toISOString(),\n})\n\nexport type SerializedModelProvider = ReturnType<typeof serializeModelProvider>\n","import { headers } from 'next/headers'\nimport { ApiKeyType, ModelProviderType, Prisma } from '@prisma/client'\nimport { NextResponse, type NextRequest } from 'next/server'\nimport { z } from 'zod'\nimport { cacheHeaders } from '@/lib/cache/cacheHeaders'\nimport { prisma } from '@/lib/prisma'\nimport { serializeModelProvider } from '@/lib/modelProviders/serializeModelProvider'\nimport { getApiKey } from '@/lib/apiKeys/getApiKey'\nimport { validate } from 'uuid'\n\nexport const GET = async (\n _request: NextRequest,\n props: { params: Promise<{ modelProviderId: string }> },\n) => {\n const { modelProviderId } = await props.params\n\n const headersList = await headers()\n const authorization = headersList.get('authorization')\n if (!authorization) {\n return NextResponse.json(\n { error: 'No authorization header found' },\n { status: 400 },\n )\n }\n\n const privateApiKey = await getApiKey({\n type: ApiKeyType.PRIVATE,\n authorization,\n })\n\n if (!privateApiKey) {\n return NextResponse.json({ error: 'Invalid api key' }, { status: 400 })\n }\n\n if (!validate(modelProviderId)) {\n return NextResponse.json({ error: 'Invalid provider id' }, { status: 400 })\n }\n\n const provider = await prisma.modelProvider.findFirst({\n where: {\n id: modelProviderId,\n workspaceId: privateApiKey.workspaceId,\n },\n })\n\n if (!provider) {\n return NextResponse.json({ error: 'No provider found' }, { status: 400 })\n }\n\n return NextResponse.json(\n {\n provider: serializeModelProvider({ provider }),\n },\n { headers: cacheHeaders },\n )\n}\n\nexport const PATCH = async (\n request: NextRequest,\n props: { params: Promise<{ modelProviderId: string }> },\n) => {\n const { modelProviderId } = await props.params\n\n const headersList = await headers()\n const authorization = headersList.get('authorization')\n if (!authorization) {\n return NextResponse.json(\n { error: 'No authorization header found' },\n { status: 400 },\n )\n }\n\n const privateApiKey = await getApiKey({\n authorization,\n type: ApiKeyType.PRIVATE,\n })\n\n if (!privateApiKey) {\n return NextResponse.json({ error: 'Invalid api key' }, { status: 400 })\n }\n\n if (!validate(modelProviderId)) {\n return NextResponse.json({ error: 'Invalid provider id' }, { status: 400 })\n }\n\n const body = await request.json()\n const schema = z.object({\n type: z.nativeEnum(ModelProviderType).optional(),\n name: z.string().optional(),\n apiKey: z.string().optional(),\n endpoint: z.string().optional().nullable(),\n apiVersion: z.string().optional().nullable(),\n })\n\n const parsed = schema.safeParse(body)\n\n if (!parsed.success) {\n return NextResponse.json({ error: 'Invalid payload' }, { status: 400 })\n }\n\n const { type, apiKey: providerKey, endpoint, apiVersion, name } = parsed.data\n const updateData: Prisma.ModelProviderUpdateInput = {\n ...(type ? { type } : {}),\n ...(name !== undefined ? { name } : {}),\n ...(providerKey !== undefined ? { apiKey: providerKey } : {}),\n ...(endpoint !== undefined ? { endpoint } : {}),\n ...(apiVersion !== undefined ? { apiVersion } : {}),\n }\n\n const existingProvider = await prisma.modelProvider.findFirst({\n where: {\n id: modelProviderId,\n workspaceId: privateApiKey.workspaceId,\n },\n })\n\n if (!existingProvider) {\n return NextResponse.json({ error: 'No provider found' }, { status: 400 })\n }\n\n const provider = await prisma.modelProvider.update({\n where: { id: modelProviderId },\n data: updateData,\n })\n\n return NextResponse.json(\n {\n provider: serializeModelProvider({ provider }),\n },\n { headers: cacheHeaders },\n )\n}\n\nexport const DELETE = async (\n _request: NextRequest,\n props: { params: Promise<{ modelProviderId: string }> },\n) => {\n const { modelProviderId } = await props.params\n\n const headersList = await headers()\n const authorization = headersList.get('authorization')\n if (!authorization) {\n return NextResponse.json(\n { error: 'No authorization header found' },\n { status: 400 },\n )\n }\n\n const privateApiKey = await getApiKey({\n authorization,\n type: ApiKeyType.PRIVATE,\n })\n\n if (!privateApiKey) {\n return NextResponse.json({ error: 'Invalid api key' }, { status: 400 })\n }\n\n if (!validate(modelProviderId)) {\n return NextResponse.json({ error: 'Invalid provider id' }, { status: 400 })\n }\n\n const assistantsUsingProvider = await prisma.assistant.count({\n where: {\n modelProviderId: modelProviderId,\n workspaceId: privateApiKey.workspaceId,\n },\n })\n\n if (assistantsUsingProvider > 0) {\n return NextResponse.json({ error: 'Provider in use' }, { status: 400 })\n }\n\n const existingProvider = await prisma.modelProvider.findFirst({\n where: {\n id: modelProviderId,\n workspaceId: privateApiKey.workspaceId,\n },\n })\n\n if (!existingProvider) {\n return NextResponse.json({ error: 'No provider found' }, { status: 400 })\n }\n\n const provider = await prisma.modelProvider.delete({\n where: { id: modelProviderId },\n })\n\n return NextResponse.json(\n {\n provider: serializeModelProvider({ provider }),\n },\n { headers: cacheHeaders },\n )\n}\n\nexport const OPTIONS = () =>\n NextResponse.json(\n {},\n {\n headers: cacheHeaders,\n },\n )\n","import { AppRouteRouteModule } from \"next/dist/esm/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/esm/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/esm/server/lib/patch-fetch\";\nimport { getRequestMeta } from \"next/dist/esm/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/esm/server/lib/trace/tracer\";\nimport { normalizeAppPath } from \"next/dist/esm/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/esm/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/esm/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/esm/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/esm/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/esm/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/esm/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/esm/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/esm/lib/constants\";\nimport { NoFallbackError } from \"next/dist/esm/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/esm/server/response-cache\";\nimport * as userland from \"INNER_APP_ROUTE\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/providers/[modelProviderId]/route\",\n pathname: \"/api/providers/[modelProviderId]\",\n filename: \"route\",\n bundlePath: \"\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"[project]/supercorp/superinterface/packages/server/src/app/api/providers/[modelProviderId]/route.ts\",\n nextConfigOutput,\n userland\n});\n// Pull out the exports that we need to expose from the module. This should\n// be eliminated when we've moved the other routes to the new format. These\n// are used to hook into the route.\nconst { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;\nfunction patchFetch() {\n return _patchFetch({\n workAsyncStorage,\n workUnitAsyncStorage\n });\n}\nexport { routeModule, workAsyncStorage, workUnitAsyncStorage, serverHooks, patchFetch, };\nexport async function handler(req, res, ctx) {\n var _nextConfig_experimental;\n let srcPage = \"/api/providers/[modelProviderId]/route\";\n // turbopack doesn't normalize `/index` in the page name\n // so we need to to process dynamic routes properly\n // TODO: fix turbopack providing differing value from webpack\n if (process.env.TURBOPACK) {\n srcPage = srcPage.replace(/\\/index$/, '') || '/';\n } else if (srcPage === '/index') {\n // we always normalize /index specifically\n srcPage = '/';\n }\n const multiZoneDraftMode = process.env.__NEXT_MULTI_ZONE_DRAFT_MODE;\n const prepareResult = await routeModule.prepare(req, res, {\n srcPage,\n multiZoneDraftMode\n });\n if (!prepareResult) {\n res.statusCode = 400;\n res.end('Bad Request');\n ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());\n return null;\n }\n const { buildId, params, nextConfig, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname } = prepareResult;\n const normalizedSrcPage = normalizeAppPath(srcPage);\n let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || prerenderManifest.routes[resolvedPathname]);\n if (isIsr && !isDraftMode) {\n const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]);\n const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];\n if (prerenderInfo) {\n if (prerenderInfo.fallback === false && !isPrerendered) {\n throw new NoFallbackError();\n }\n }\n }\n let cacheKey = null;\n if (isIsr && !routeModule.isDev && !isDraftMode) {\n cacheKey = resolvedPathname;\n // ensure /index and / is normalized to one key\n cacheKey = cacheKey === '/index' ? '/' : cacheKey;\n }\n const supportsDynamicResponse = // If we're in development, we always support dynamic HTML\n routeModule.isDev === true || // If this is not SSG or does not have static paths, then it supports\n // dynamic HTML.\n !isIsr;\n // This is a revalidation request if the request is for a static\n // page and it is not being resumed from a postponed render and\n // it is not a dynamic RSC request then it is a revalidation\n // request.\n const isRevalidate = isIsr && !supportsDynamicResponse;\n const method = req.method || 'GET';\n const tracer = getTracer();\n const activeSpan = tracer.getActiveScopeSpan();\n const context = {\n params,\n prerenderManifest,\n renderOpts: {\n experimental: {\n cacheComponents: Boolean(nextConfig.experimental.cacheComponents),\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n supportsDynamicResponse,\n incrementalCache: getRequestMeta(req, 'incrementalCache'),\n cacheLifeProfiles: (_nextConfig_experimental = nextConfig.experimental) == null ? void 0 : _nextConfig_experimental.cacheLife,\n isRevalidate,\n waitUntil: ctx.waitUntil,\n onClose: (cb)=>{\n res.on('close', cb);\n },\n onAfterTaskError: undefined,\n onInstrumentationRequestError: (error, _request, errorContext)=>routeModule.onRequestError(req, error, errorContext, routerServerContext)\n },\n sharedContext: {\n buildId\n }\n };\n const nodeNextReq = new NodeNextRequest(req);\n const nodeNextRes = new NodeNextResponse(res);\n const nextReq = NextRequestAdapter.fromNodeNextRequest(nodeNextReq, signalFromNodeResponse(res));\n try {\n const invokeRouteModule = async (span)=>{\n return routeModule.handle(nextReq, context).finally(()=>{\n if (!span) return;\n span.setAttributes({\n 'http.status_code': res.statusCode,\n 'next.rsc': false\n });\n const rootSpanAttributes = tracer.getRootSpanAttributes();\n // We were unable to get attributes, probably OTEL is not enabled\n if (!rootSpanAttributes) {\n return;\n }\n if (rootSpanAttributes.get('next.span_type') !== BaseServerSpan.handleRequest) {\n console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);\n return;\n }\n const route = rootSpanAttributes.get('next.route');\n if (route) {\n const name = `${method} ${route}`;\n span.setAttributes({\n 'next.route': route,\n 'http.route': route,\n 'next.span_name': name\n });\n span.updateName(name);\n } else {\n span.updateName(`${method} ${req.url}`);\n }\n });\n };\n const handleResponse = async (currentSpan)=>{\n var _cacheEntry_value;\n const responseGenerator = async ({ previousCacheEntry })=>{\n try {\n if (!getRequestMeta(req, 'minimalMode') && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {\n res.statusCode = 404;\n // on-demand revalidate always sets this header\n res.setHeader('x-nextjs-cache', 'REVALIDATED');\n res.end('This page could not be found');\n return null;\n }\n const response = await invokeRouteModule(currentSpan);\n req.fetchMetrics = context.renderOpts.fetchMetrics;\n let pendingWaitUntil = context.renderOpts.pendingWaitUntil;\n // Attempt using provided waitUntil if available\n // if it's not we fallback to sendResponse's handling\n if (pendingWaitUntil) {\n if (ctx.waitUntil) {\n ctx.waitUntil(pendingWaitUntil);\n pendingWaitUntil = undefined;\n }\n }\n const cacheTags = context.renderOpts.collectedTags;\n // If the request is for a static response, we can cache it so long\n // as it's not edge.\n if (isIsr) {\n const blob = await response.blob();\n // Copy the headers from the response.\n const headers = toNodeOutgoingHttpHeaders(response.headers);\n if (cacheTags) {\n headers[NEXT_CACHE_TAGS_HEADER] = cacheTags;\n }\n if (!headers['content-type'] && blob.type) {\n headers['content-type'] = blob.type;\n }\n const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;\n const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= INFINITE_CACHE ? undefined : context.renderOpts.collectedExpire;\n // Create the cache entry for the response.\n const cacheEntry = {\n value: {\n kind: CachedRouteKind.APP_ROUTE,\n status: response.status,\n body: Buffer.from(await blob.arrayBuffer()),\n headers\n },\n cacheControl: {\n revalidate,\n expire\n }\n };\n return cacheEntry;\n } else {\n // send response without caching if not ISR\n await sendResponse(nodeNextReq, nodeNextRes, response, context.renderOpts.pendingWaitUntil);\n return null;\n }\n } catch (err) {\n // if this is a background revalidate we need to report\n // the request error here as it won't be bubbled\n if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: srcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isRevalidate,\n isOnDemandRevalidate\n })\n }, routerServerContext);\n }\n throw err;\n }\n };\n const cacheEntry = await routeModule.handleResponse({\n req,\n nextConfig,\n cacheKey,\n routeKind: RouteKind.APP_ROUTE,\n isFallback: false,\n prerenderManifest,\n isRoutePPREnabled: false,\n isOnDemandRevalidate,\n revalidateOnlyGenerated,\n responseGenerator,\n waitUntil: ctx.waitUntil\n });\n // we don't create a cacheEntry for ISR\n if (!isIsr) {\n return null;\n }\n if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== CachedRouteKind.APP_ROUTE) {\n var _cacheEntry_value1;\n throw Object.defineProperty(new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`), \"__NEXT_ERROR_CODE\", {\n value: \"E701\",\n enumerable: false,\n configurable: true\n });\n }\n if (!getRequestMeta(req, 'minimalMode')) {\n res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');\n }\n // Draft mode should never be cached\n if (isDraftMode) {\n res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');\n }\n const headers = fromNodeOutgoingHttpHeaders(cacheEntry.value.headers);\n if (!(getRequestMeta(req, 'minimalMode') && isIsr)) {\n headers.delete(NEXT_CACHE_TAGS_HEADER);\n }\n // If cache control is already set on the response we don't\n // override it to allow users to customize it via next.config\n if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {\n headers.set('Cache-Control', getCacheControlHeader(cacheEntry.cacheControl));\n }\n await sendResponse(nodeNextReq, nodeNextRes, new Response(cacheEntry.value.body, {\n headers,\n status: cacheEntry.value.status || 200\n }));\n return null;\n };\n // TODO: activeSpan code path is for when wrapped by\n // next-server can be removed when this is no longer used\n if (activeSpan) {\n await handleResponse(activeSpan);\n } else {\n await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(BaseServerSpan.handleRequest, {\n spanName: `${method} ${req.url}`,\n kind: SpanKind.SERVER,\n attributes: {\n 'http.method': method,\n 'http.target': req.url\n }\n }, handleResponse));\n }\n } catch (err) {\n if (!(err instanceof NoFallbackError)) {\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: normalizedSrcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isRevalidate,\n isOnDemandRevalidate\n })\n });\n }\n // rethrow so that we can handle serving error page\n // If this is during static generation, throw the error again.\n if (isIsr) throw err;\n // Otherwise, send a 500 response.\n await sendResponse(nodeNextReq, nodeNextRes, new Response(null, {\n status: 500\n }));\n return null;\n }\n}\n\n//# sourceMappingURL=app-route.js.map\n"],"names":[],"mappings":"6jCAAO,IAAM,EAAe,CAC1B,8BAA+B,IAC/B,+BAAgC,kCAChC,+BAAgC,cAClC,mDCHA,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OAEO,IAAM,EAAY,MAAO,eAC9B,CAAa,MACb,CAAI,CAIL,IACC,GAAI,CAAC,EACH,OAAO,KAGT,CAJoB,EAId,EAAG,EAAY,CAAG,EAAc,KAAK,CAAC,iBAE5C,AAAK,CAAA,EAAA,CAAD,CAAC,QAAA,AAAQ,EAAC,GAIP,EAAA,MAAM,CAAC,EAJc,IAIR,CAAC,SAAS,CAAC,CAC7B,MAAO,MAAE,EAAM,MAAO,CAAY,CACpC,GALS,IAMX,gECtBO,IAAM,EAAyB,CAAC,CACrC,UAAQ,CAGT,GAAK,AAAC,EACL,GAAI,EAAS,EAAE,CACf,KAAM,EAAS,IAAI,CACnB,KAAM,EAAS,IAAI,CACnB,OAAQ,EAAS,MAAM,CACvB,SAAU,EAAS,QAAQ,CAC3B,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,EAAW,YAAY,EAAK,EAAD,AAAK,SAAS,CAAC,kBAAqB,EAAD,AAAS,GAAG,CAAC,kBAAkB,AAC7F,EAAQ,GAAG,CAAC,gBAAiB,CAAA,EAAA,EAAA,qBAAA,AAAqB,EAAC,EAAW,YAAY,GAE9E,MAAM,CAAA,EAAA,EAAA,YAAA,AAAY,EAAC,EAAa,EAAa,IAAI,SAAS,EAAW,KAAK,CAAC,IAAI,CAAE,SAC7E,EACA,OAAQ,EAAW,KAAK,CAAC,MAAM,EAAI,GACvC,IACO,IACX,EAGI,EACA,MAAM,EAAe,EADT,CAGZ,MAAM,EAAO,qBAAqB,CAAC,EAAI,OAAO,CAAE,IAAI,EAAO,KAAK,CAAC,EAAA,cAAc,CAAC,aAAa,CAAE,CACvF,SAAU,CAAA,EAAG,EAAO,CAAC,EAAE,EAAI,GAAG,CAAA,CAAE,CAChC,KAAM,EAAA,QAAQ,CAAC,MAAM,CACrB,WAAY,CACR,cAAe,EACf,cAAe,EAAI,GAAG,AAC1B,CACJ,EAAG,GAEf,CAAE,MAAO,EAAK,CAcV,GAbI,AAAE,CAAD,YAAgB,EAAA,eAAe,EAChC,CADmC,KAC7B,EAAY,cAAc,CAAC,EAAK,EAAK,CACvC,WAAY,aACZ,UAAW,EACX,UAAW,QACX,iBAAkB,CAAA,EAAA,EAAA,mBAAA,AAAmB,EAAC,cAClC,uBACA,CACJ,EACJ,GAIA,EAAO,MAAM,EAKjB,OAHA,MAAM,CAAA,EAAA,EAAA,YAAA,AAAY,EAAC,EAAa,EAAa,IAAI,SAAS,KAAM,CAC5D,OAAQ,GACZ,IACO,IACX,CACJ,EAEA,qCAAqC","ignoreList":[4]}
1
+ {"version":3,"sources":["turbopack:///[project]/supercorp/superinterface/packages/server/src/lib/cache/cacheHeaders.ts","turbopack:///[project]/supercorp/superinterface/packages/server/src/lib/apiKeys/getApiKey.ts","turbopack:///[project]/supercorp/superinterface/packages/server/src/lib/modelProviders/serializeModelProvider.ts","turbopack:///[project]/supercorp/superinterface/packages/server/src/app/api/providers/[modelProviderId]/route.ts","turbopack:///[project]/supercorp/superinterface/node_modules/next/dist/esm/build/templates/app-route.js"],"sourcesContent":["export const cacheHeaders = {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',\n 'Access-Control-Allow-Headers': 'Content-Type',\n}\n","import { ApiKeyType, ApiKey, type PrismaClient } from '@prisma/client'\nimport { validate } from 'uuid'\n\nexport const getApiKey = async ({\n authorization,\n type,\n prisma,\n}: {\n authorization: string | null\n type: ApiKeyType\n prisma: PrismaClient\n}): Promise<ApiKey | null> => {\n if (!authorization) {\n return null\n }\n\n const [, apiKeyValue] = authorization.split('Bearer ')\n\n if (!validate(apiKeyValue)) {\n return null\n }\n\n return prisma.apiKey.findFirst({\n where: { type, value: apiKeyValue },\n })\n}\n","import type { ModelProvider } from '@prisma/client'\n\nexport const serializeModelProvider = ({\n provider,\n}: {\n provider: ModelProvider\n}) => ({\n id: provider.id,\n type: provider.type,\n name: provider.name,\n apiKey: provider.apiKey,\n endpoint: provider.endpoint,\n apiVersion: provider.apiVersion,\n workspaceId: provider.workspaceId,\n createdAt: provider.createdAt.toISOString(),\n updatedAt: provider.updatedAt.toISOString(),\n})\n\nexport type SerializedModelProvider = ReturnType<typeof serializeModelProvider>\n","import { headers } from 'next/headers'\nimport {\n ApiKeyType,\n ModelProviderType,\n Prisma,\n type PrismaClient,\n} from '@prisma/client'\nimport { NextResponse, type NextRequest } from 'next/server'\nimport { z } from 'zod'\nimport { cacheHeaders } from '@/lib/cache/cacheHeaders'\nimport { prisma as defaultPrisma } from '@/lib/prisma'\nimport { serializeModelProvider } from '@/lib/modelProviders/serializeModelProvider'\nimport { getApiKey } from '@/lib/apiKeys/getApiKey'\nimport { validate } from 'uuid'\n\nexport const buildGET =\n ({ prisma = defaultPrisma }: { prisma?: PrismaClient } = {}) =>\n async (\n _request: NextRequest,\n props: { params: Promise<{ modelProviderId: string }> },\n ) => {\n const { modelProviderId } = await props.params\n\n const headersList = await headers()\n const authorization = headersList.get('authorization')\n if (!authorization) {\n return NextResponse.json(\n { error: 'No authorization header found' },\n { status: 400 },\n )\n }\n\n const privateApiKey = await getApiKey({\n type: ApiKeyType.PRIVATE,\n authorization,\n prisma,\n })\n\n if (!privateApiKey) {\n return NextResponse.json({ error: 'Invalid api key' }, { status: 400 })\n }\n\n if (!validate(modelProviderId)) {\n return NextResponse.json(\n { error: 'Invalid provider id' },\n { status: 400 },\n )\n }\n\n const provider = await prisma.modelProvider.findFirst({\n where: {\n id: modelProviderId,\n workspaceId: privateApiKey.workspaceId,\n },\n })\n\n if (!provider) {\n return NextResponse.json({ error: 'No provider found' }, { status: 400 })\n }\n\n return NextResponse.json(\n {\n provider: serializeModelProvider({ provider }),\n },\n { headers: cacheHeaders },\n )\n }\n\nexport const GET = buildGET()\n\nexport const buildPATCH =\n ({ prisma = defaultPrisma }: { prisma?: PrismaClient } = {}) =>\n async (\n request: NextRequest,\n props: { params: Promise<{ modelProviderId: string }> },\n ) => {\n const { modelProviderId } = await props.params\n\n const headersList = await headers()\n const authorization = headersList.get('authorization')\n if (!authorization) {\n return NextResponse.json(\n { error: 'No authorization header found' },\n { status: 400 },\n )\n }\n\n const privateApiKey = await getApiKey({\n authorization,\n type: ApiKeyType.PRIVATE,\n prisma,\n })\n\n if (!privateApiKey) {\n return NextResponse.json({ error: 'Invalid api key' }, { status: 400 })\n }\n\n if (!validate(modelProviderId)) {\n return NextResponse.json(\n { error: 'Invalid provider id' },\n { status: 400 },\n )\n }\n\n const body = await request.json()\n const schema = z.object({\n type: z.nativeEnum(ModelProviderType).optional(),\n name: z.string().optional(),\n apiKey: z.string().optional(),\n endpoint: z.string().optional().nullable(),\n apiVersion: z.string().optional().nullable(),\n })\n\n const parsed = schema.safeParse(body)\n\n if (!parsed.success) {\n return NextResponse.json({ error: 'Invalid payload' }, { status: 400 })\n }\n\n const {\n type,\n apiKey: providerKey,\n endpoint,\n apiVersion,\n name,\n } = parsed.data\n const updateData: Prisma.ModelProviderUpdateInput = {\n ...(type ? { type } : {}),\n ...(name !== undefined ? { name } : {}),\n ...(providerKey !== undefined ? { apiKey: providerKey } : {}),\n ...(endpoint !== undefined ? { endpoint } : {}),\n ...(apiVersion !== undefined ? { apiVersion } : {}),\n }\n\n const existingProvider = await prisma.modelProvider.findFirst({\n where: {\n id: modelProviderId,\n workspaceId: privateApiKey.workspaceId,\n },\n })\n\n if (!existingProvider) {\n return NextResponse.json({ error: 'No provider found' }, { status: 400 })\n }\n\n const provider = await prisma.modelProvider.update({\n where: { id: modelProviderId },\n data: updateData,\n })\n\n return NextResponse.json(\n {\n provider: serializeModelProvider({ provider }),\n },\n { headers: cacheHeaders },\n )\n }\n\nexport const PATCH = buildPATCH()\n\nexport const buildDELETE =\n ({ prisma = defaultPrisma }: { prisma?: PrismaClient } = {}) =>\n async (\n _request: NextRequest,\n props: { params: Promise<{ modelProviderId: string }> },\n ) => {\n const { modelProviderId } = await props.params\n\n const headersList = await headers()\n const authorization = headersList.get('authorization')\n if (!authorization) {\n return NextResponse.json(\n { error: 'No authorization header found' },\n { status: 400 },\n )\n }\n\n const privateApiKey = await getApiKey({\n authorization,\n type: ApiKeyType.PRIVATE,\n prisma,\n })\n\n if (!privateApiKey) {\n return NextResponse.json({ error: 'Invalid api key' }, { status: 400 })\n }\n\n if (!validate(modelProviderId)) {\n return NextResponse.json(\n { error: 'Invalid provider id' },\n { status: 400 },\n )\n }\n\n const assistantsUsingProvider = await prisma.assistant.count({\n where: {\n modelProviderId: modelProviderId,\n workspaceId: privateApiKey.workspaceId,\n },\n })\n\n if (assistantsUsingProvider > 0) {\n return NextResponse.json({ error: 'Provider in use' }, { status: 400 })\n }\n\n const existingProvider = await prisma.modelProvider.findFirst({\n where: {\n id: modelProviderId,\n workspaceId: privateApiKey.workspaceId,\n },\n })\n\n if (!existingProvider) {\n return NextResponse.json({ error: 'No provider found' }, { status: 400 })\n }\n\n const provider = await prisma.modelProvider.delete({\n where: { id: modelProviderId },\n })\n\n return NextResponse.json(\n {\n provider: serializeModelProvider({ provider }),\n },\n { headers: cacheHeaders },\n )\n }\n\nexport const DELETE = buildDELETE()\n\nexport const OPTIONS = () =>\n NextResponse.json(\n {},\n {\n headers: cacheHeaders,\n },\n )\n","import { AppRouteRouteModule } from \"next/dist/esm/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/esm/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/esm/server/lib/patch-fetch\";\nimport { getRequestMeta } from \"next/dist/esm/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/esm/server/lib/trace/tracer\";\nimport { normalizeAppPath } from \"next/dist/esm/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/esm/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/esm/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/esm/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/esm/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/esm/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/esm/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/esm/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/esm/lib/constants\";\nimport { NoFallbackError } from \"next/dist/esm/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/esm/server/response-cache\";\nimport * as userland from \"INNER_APP_ROUTE\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/providers/[modelProviderId]/route\",\n pathname: \"/api/providers/[modelProviderId]\",\n filename: \"route\",\n bundlePath: \"\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"[project]/supercorp/superinterface/packages/server/src/app/api/providers/[modelProviderId]/route.ts\",\n nextConfigOutput,\n userland\n});\n// Pull out the exports that we need to expose from the module. This should\n// be eliminated when we've moved the other routes to the new format. These\n// are used to hook into the route.\nconst { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;\nfunction patchFetch() {\n return _patchFetch({\n workAsyncStorage,\n workUnitAsyncStorage\n });\n}\nexport { routeModule, workAsyncStorage, workUnitAsyncStorage, serverHooks, patchFetch, };\nexport async function handler(req, res, ctx) {\n var _nextConfig_experimental;\n let srcPage = \"/api/providers/[modelProviderId]/route\";\n // turbopack doesn't normalize `/index` in the page name\n // so we need to to process dynamic routes properly\n // TODO: fix turbopack providing differing value from webpack\n if (process.env.TURBOPACK) {\n srcPage = srcPage.replace(/\\/index$/, '') || '/';\n } else if (srcPage === '/index') {\n // we always normalize /index specifically\n srcPage = '/';\n }\n const multiZoneDraftMode = process.env.__NEXT_MULTI_ZONE_DRAFT_MODE;\n const prepareResult = await routeModule.prepare(req, res, {\n srcPage,\n multiZoneDraftMode\n });\n if (!prepareResult) {\n res.statusCode = 400;\n res.end('Bad Request');\n ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());\n return null;\n }\n const { buildId, params, nextConfig, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname } = prepareResult;\n const normalizedSrcPage = normalizeAppPath(srcPage);\n let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || prerenderManifest.routes[resolvedPathname]);\n if (isIsr && !isDraftMode) {\n const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]);\n const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];\n if (prerenderInfo) {\n if (prerenderInfo.fallback === false && !isPrerendered) {\n throw new NoFallbackError();\n }\n }\n }\n let cacheKey = null;\n if (isIsr && !routeModule.isDev && !isDraftMode) {\n cacheKey = resolvedPathname;\n // ensure /index and / is normalized to one key\n cacheKey = cacheKey === '/index' ? '/' : cacheKey;\n }\n const supportsDynamicResponse = // If we're in development, we always support dynamic HTML\n routeModule.isDev === true || // If this is not SSG or does not have static paths, then it supports\n // dynamic HTML.\n !isIsr;\n // This is a revalidation request if the request is for a static\n // page and it is not being resumed from a postponed render and\n // it is not a dynamic RSC request then it is a revalidation\n // request.\n const isRevalidate = isIsr && !supportsDynamicResponse;\n const method = req.method || 'GET';\n const tracer = getTracer();\n const activeSpan = tracer.getActiveScopeSpan();\n const context = {\n params,\n prerenderManifest,\n renderOpts: {\n experimental: {\n cacheComponents: Boolean(nextConfig.experimental.cacheComponents),\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n supportsDynamicResponse,\n incrementalCache: getRequestMeta(req, 'incrementalCache'),\n cacheLifeProfiles: (_nextConfig_experimental = nextConfig.experimental) == null ? void 0 : _nextConfig_experimental.cacheLife,\n isRevalidate,\n waitUntil: ctx.waitUntil,\n onClose: (cb)=>{\n res.on('close', cb);\n },\n onAfterTaskError: undefined,\n onInstrumentationRequestError: (error, _request, errorContext)=>routeModule.onRequestError(req, error, errorContext, routerServerContext)\n },\n sharedContext: {\n buildId\n }\n };\n const nodeNextReq = new NodeNextRequest(req);\n const nodeNextRes = new NodeNextResponse(res);\n const nextReq = NextRequestAdapter.fromNodeNextRequest(nodeNextReq, signalFromNodeResponse(res));\n try {\n const invokeRouteModule = async (span)=>{\n return routeModule.handle(nextReq, context).finally(()=>{\n if (!span) return;\n span.setAttributes({\n 'http.status_code': res.statusCode,\n 'next.rsc': false\n });\n const rootSpanAttributes = tracer.getRootSpanAttributes();\n // We were unable to get attributes, probably OTEL is not enabled\n if (!rootSpanAttributes) {\n return;\n }\n if (rootSpanAttributes.get('next.span_type') !== BaseServerSpan.handleRequest) {\n console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);\n return;\n }\n const route = rootSpanAttributes.get('next.route');\n if (route) {\n const name = `${method} ${route}`;\n span.setAttributes({\n 'next.route': route,\n 'http.route': route,\n 'next.span_name': name\n });\n span.updateName(name);\n } else {\n span.updateName(`${method} ${req.url}`);\n }\n });\n };\n const handleResponse = async (currentSpan)=>{\n var _cacheEntry_value;\n const responseGenerator = async ({ previousCacheEntry })=>{\n try {\n if (!getRequestMeta(req, 'minimalMode') && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {\n res.statusCode = 404;\n // on-demand revalidate always sets this header\n res.setHeader('x-nextjs-cache', 'REVALIDATED');\n res.end('This page could not be found');\n return null;\n }\n const response = await invokeRouteModule(currentSpan);\n req.fetchMetrics = context.renderOpts.fetchMetrics;\n let pendingWaitUntil = context.renderOpts.pendingWaitUntil;\n // Attempt using provided waitUntil if available\n // if it's not we fallback to sendResponse's handling\n if (pendingWaitUntil) {\n if (ctx.waitUntil) {\n ctx.waitUntil(pendingWaitUntil);\n pendingWaitUntil = undefined;\n }\n }\n const cacheTags = context.renderOpts.collectedTags;\n // If the request is for a static response, we can cache it so long\n // as it's not edge.\n if (isIsr) {\n const blob = await response.blob();\n // Copy the headers from the response.\n const headers = toNodeOutgoingHttpHeaders(response.headers);\n if (cacheTags) {\n headers[NEXT_CACHE_TAGS_HEADER] = cacheTags;\n }\n if (!headers['content-type'] && blob.type) {\n headers['content-type'] = blob.type;\n }\n const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;\n const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= INFINITE_CACHE ? undefined : context.renderOpts.collectedExpire;\n // Create the cache entry for the response.\n const cacheEntry = {\n value: {\n kind: CachedRouteKind.APP_ROUTE,\n status: response.status,\n body: Buffer.from(await blob.arrayBuffer()),\n headers\n },\n cacheControl: {\n revalidate,\n expire\n }\n };\n return cacheEntry;\n } else {\n // send response without caching if not ISR\n await sendResponse(nodeNextReq, nodeNextRes, response, context.renderOpts.pendingWaitUntil);\n return null;\n }\n } catch (err) {\n // if this is a background revalidate we need to report\n // the request error here as it won't be bubbled\n if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: srcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isRevalidate,\n isOnDemandRevalidate\n })\n }, routerServerContext);\n }\n throw err;\n }\n };\n const cacheEntry = await routeModule.handleResponse({\n req,\n nextConfig,\n cacheKey,\n routeKind: RouteKind.APP_ROUTE,\n isFallback: false,\n prerenderManifest,\n isRoutePPREnabled: false,\n isOnDemandRevalidate,\n revalidateOnlyGenerated,\n responseGenerator,\n waitUntil: ctx.waitUntil\n });\n // we don't create a cacheEntry for ISR\n if (!isIsr) {\n return null;\n }\n if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== CachedRouteKind.APP_ROUTE) {\n var _cacheEntry_value1;\n throw Object.defineProperty(new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`), \"__NEXT_ERROR_CODE\", {\n value: \"E701\",\n enumerable: false,\n configurable: true\n });\n }\n if (!getRequestMeta(req, 'minimalMode')) {\n res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');\n }\n // Draft mode should never be cached\n if (isDraftMode) {\n res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');\n }\n const headers = fromNodeOutgoingHttpHeaders(cacheEntry.value.headers);\n if (!(getRequestMeta(req, 'minimalMode') && isIsr)) {\n headers.delete(NEXT_CACHE_TAGS_HEADER);\n }\n // If cache control is already set on the response we don't\n // override it to allow users to customize it via next.config\n if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {\n headers.set('Cache-Control', getCacheControlHeader(cacheEntry.cacheControl));\n }\n await sendResponse(nodeNextReq, nodeNextRes, new Response(cacheEntry.value.body, {\n headers,\n status: cacheEntry.value.status || 200\n }));\n return null;\n };\n // TODO: activeSpan code path is for when wrapped by\n // next-server can be removed when this is no longer used\n if (activeSpan) {\n await handleResponse(activeSpan);\n } else {\n await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(BaseServerSpan.handleRequest, {\n spanName: `${method} ${req.url}`,\n kind: SpanKind.SERVER,\n attributes: {\n 'http.method': method,\n 'http.target': req.url\n }\n }, handleResponse));\n }\n } catch (err) {\n if (!(err instanceof NoFallbackError)) {\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: normalizedSrcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isRevalidate,\n isOnDemandRevalidate\n })\n });\n }\n // rethrow so that we can handle serving error page\n // If this is during static generation, throw the error again.\n if (isIsr) throw err;\n // Otherwise, send a 500 response.\n await sendResponse(nodeNextReq, nodeNextRes, new Response(null, {\n status: 500\n }));\n return null;\n }\n}\n\n//# sourceMappingURL=app-route.js.map\n"],"names":[],"mappings":"6jCAAO,IAAM,EAAe,CAC1B,8BAA+B,IAC/B,+BAAgC,kCAChC,+BAAgC,cAClC,mDCHA,IAAA,EAAA,EAAA,CAAA,CAAA,OAEO,IAAM,EAAY,MAAO,eAC9B,CAAa,MACb,CAAI,QACJ,CAAM,CAKP,IACC,GAAI,CAAC,EACH,OAAO,KAGT,CAJoB,EAId,EAAG,EAAY,CAAG,EAAc,KAAK,CAAC,iBAE5C,AAAK,CAAA,EAAA,CAAD,CAAC,QAAA,AAAQ,EAAC,GAIP,EAAO,MAAM,CAAC,EAJO,OAIE,CAAC,CAC7B,MAAO,MAAE,EAAM,MAAO,CAAY,CACpC,GALS,IAMX,gECvBO,I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AA,EAAA,EAAA,YAAA,AAAY,EAAC,EAAa,EAAa,IAAI,SAAS,KAAM,CAC5D,OAAQ,GACZ,IACO,IACX,CACJ,EAEA,qCAAqC","ignoreList":[4]}
@@ -7,6 +7,6 @@ If you want to disable QStash Verification, you should clear env variables QSTAS
7
7
  > Step Names from the request: ${JSON.stringify(s)}
8
8
  Step Types from the request: ${JSON.stringify(o)}
9
9
  > Step Names expected: ${JSON.stringify(a)}
10
- Step Types expected: ${JSON.stringify(i)}`)}throw r}},e6=e=>[...e].sort((e,t)=>(e=>e.targetStep??e.stepId)(e)-(e=>e.targetStep??e.stepId)(t)),e7=class{stepName;constructor(e){this.stepName=e}},e3=class extends e7{stepFunction;stepType="Run";constructor(e,t){super(e),this.stepFunction=t}getPlanStep(e,t){return{stepId:0,stepName:this.stepName,stepType:this.stepType,concurrent:e,targetStep:t}}async getResultStep(e,t){let r=this.stepFunction();return r instanceof Promise&&(r=await r),{stepId:t,stepName:this.stepName,stepType:this.stepType,out:r,concurrent:e}}},e9=class extends e7{sleep;stepType="SleepFor";constructor(e,t){super(e),this.sleep=t}getPlanStep(e,t){return{stepId:0,stepName:this.stepName,stepType:this.stepType,sleepFor:this.sleep,concurrent:e,targetStep:t}}async getResultStep(e,t){return await Promise.resolve({stepId:t,stepName:this.stepName,stepType:this.stepType,sleepFor:this.sleep,concurrent:e})}},te=class extends e7{sleepUntil;stepType="SleepUntil";constructor(e,t){super(e),this.sleepUntil=t}getPlanStep(e,t){return{stepId:0,stepName:this.stepName,stepType:this.stepType,sleepUntil:this.sleepUntil,concurrent:e,targetStep:t}}async getResultStep(e,t){return await Promise.resolve({stepId:t,stepName:this.stepName,stepType:this.stepType,sleepUntil:this.sleepUntil,concurrent:e})}},tt=class extends e7{url;method;body;headers;stepType="Call";constructor(e,t,r,a,i){super(e),this.url=t,this.method=r,this.body=a,this.headers=i}getPlanStep(e,t){return{stepId:0,stepName:this.stepName,stepType:this.stepType,concurrent:e,targetStep:t}}async getResultStep(e,t){return await Promise.resolve({stepId:t,stepName:this.stepName,stepType:this.stepType,concurrent:e,callUrl:this.url,callMethod:this.method,callBody:this.body,callHeaders:this.headers})}},tr=class{executor;steps;qstashClient;workflowRunId;url;failureUrl;requestPayload;headers;rawInitialPayload;env;retries;constructor({qstashClient:e,workflowRunId:t,headers:r,steps:a,url:i,failureUrl:s,debug:o,initialPayload:n,rawInitialPayload:c,env:f,retries:d}){this.qstashClient=e,this.workflowRunId=t,this.steps=a,this.url=i,this.failureUrl=s,this.headers=r,this.requestPayload=n,this.rawInitialPayload=c??JSON.stringify(this.requestPayload),this.env=f??{},this.retries=d??3,this.executor=new e4(this,this.steps,o)}async run(e,t){let r=()=>this.executor.wrapStep(e,t);return this.addStep(new e3(e,r))}async sleep(e,t){await this.addStep(new e9(e,t))}async sleepUntil(e,t){let r;r="number"==typeof t?t:Math.round((t="string"==typeof t?new Date(t):t).getTime()/1e3),await this.addStep(new te(e,r))}async call(e,t,r,a,i){let s=await this.addStep(new tt(e,t,r,a,i??{}));try{return JSON.parse(s)}catch{return s}}async addStep(e){return await this.executor.addStep(e)}},ta=class e extends tr{static disabledMessage="disabled-qstash-worklfow-run";async addStep(t){throw new ev(e.disabledMessage)}static async tryAuthentication(t,r){let a=new e({qstashClient:new ej({baseUrl:"disabled-client",token:"disabled-client"}),workflowRunId:r.workflowRunId,headers:r.headers,steps:[],url:r.url,failureUrl:r.failureUrl,initialPayload:r.requestPayload,rawInitialPayload:r.rawInitialPayload,env:r.env,retries:r.retries});try{await t(a)}catch(e){if(e instanceof ev&&e.stepName===this.disabledMessage)return ec("step-found");return ef(e)}return ec("run-ended")}},ti=["DEBUG","INFO","SUBMIT","WARN","ERROR"],ts=class e{logs=[];options;workflowRunId=void 0;constructor(e){this.options=e}async log(e,t,r){if(this.shouldLog(e)){let a={timestamp:Date.now(),workflowRunId:this.workflowRunId??"",logLevel:e,eventType:t,details:r};this.logs.push(a),"console"===this.options.logOutput&&this.writeToConsole(a),await new Promise(e=>setTimeout(e,100))}}setWorkflowRunId(e){this.workflowRunId=e}writeToConsole(e){console.log(JSON.stringify(e,void 0,2))}shouldLog(e){return ti.indexOf(e)>=ti.indexOf(this.options.logLevel)}static getLogger(t){return"object"==typeof t?t:t?new e({logLevel:"INFO",logOutput:"console"}):void 0}},to=async e=>{try{return await e.text()}catch{return}},tn=async(e,t)=>{if(e.length<2)return!1;let r=e.at(-1),a=r.stepId,i=r.targetStep;for(let r=0;r<e.length-1;r++){let s=e[r];if(s.stepId===a&&s.targetStep===i){let e=`Upstash Workflow: The step '${s.stepName}' with id '${s.stepId}' has run twice during workflow execution. Rest of the workflow will continue running as usual.`;return await t?.log("WARN","RESPONSE_DEFAULT",e),console.warn(e),!0}}return!1},tc=async(e,t,r)=>{if(t)return{rawInitialPayload:e??"",steps:[],isLastDuplicate:!1};{if(!e)throw new ew("Only first call can have an empty body");let{rawInitialPayload:t,steps:a}=(e=>{let[t,...r]=JSON.parse(e),a=eJ(t.body),i=[{stepId:0,stepName:"init",stepType:"Initial",out:a,concurrent:1},...r.filter(e=>"step"===e.callType).map(e=>JSON.parse(eJ(e.body)))];return{rawInitialPayload:a,steps:i}})(e),i=await tn(a,r);return{rawInitialPayload:t,steps:(e=>{let t=[],r=[],a=[];for(let i of e)0===i.stepId?t.includes(i.targetStep??0)||(a.push(i),t.push(i.targetStep??0)):r.includes(i.stepId)||(a.push(i),r.push(i.stepId));return a})(a),isLastDuplicate:i}}},tf=async(e,t,r,a,i,s)=>{if("true"!==e.headers.get(eF))return ec("not-failure-callback");if(!i)return ef(new ew("Workflow endpoint is called to handle a failure, but a failureFunction is not provided in serve options. Either provide a failureUrl or a failureFunction."));try{let{status:e,header:o,body:n,url:c,sourceHeader:f,sourceBody:d,workflowRunId:l}=JSON.parse(t),x=n?eJ(n):"{}",h=JSON.parse(x),{rawInitialPayload:u,steps:p,isLastDuplicate:b}=await tc(eJ(d),!1,s),y=new tr({qstashClient:r,workflowRunId:l,initialPayload:a(u),rawInitialPayload:u,headers:eZ(new Headers(f)),steps:p,url:c,failureUrl:c,debug:s});await i(y,e,h.message,o)}catch(e){return ef(e)}return ec("is-failure-callback")},td=(e,t)=>{let{qstashClient:r,onStepFinish:a,initialPayloadParser:i,url:s,verbose:o,receiver:n,failureUrl:c,failureFunction:f,baseUrl:d,env:l,retries:x}=(e=>{let t=e?.env??("undefined"==typeof process?{}:process.env),r=!!(t.QSTASH_CURRENT_SIGNING_KEY&&t.QSTASH_NEXT_SIGNING_KEY);return{qstashClient:new ej({baseUrl:t.QSTASH_URL,token:t.QSTASH_TOKEN}),onStepFinish:(e,t)=>new Response(JSON.stringify({workflowRunId:e}),{status:200}),initialPayloadParser:e=>{if(e)try{return JSON.parse(e)}catch(t){if(t instanceof SyntaxError)return e;throw t}},receiver:r?new eh({currentSigningKey:t.QSTASH_CURRENT_SIGNING_KEY,nextSigningKey:t.QSTASH_NEXT_SIGNING_KEY}):void 0,baseUrl:t.UPSTASH_WORKFLOW_URL,env:t,retries:3,...e}})(t),h=ts.getLogger(o),u=async t=>{let o=s??t.url,u=d?o.replace(/^(https?:\/\/[^/]+)(\/.*)?$/,(e,t,r)=>d+(r||"")):o;u!==o&&await h?.log("WARN","ENDPOINT_START",{warning:`Upstash Workflow: replacing the base of the url with "${d}" and using it as workflow endpoint.`,originalURL:o,updatedURL:u});let p=f?u:c,b=await to(t)??"";await e2(b,t.headers.get("upstash-signature"),n),await h?.log("INFO","ENDPOINT_START");let y=await tf(t,b,r,i,f);if(y.isErr())throw y.error;if("is-failure-callback"===y.value)return await h?.log("WARN","RESPONSE_DEFAULT","failureFunction executed"),a("no-workflow-id","failure-callback");let{isFirstInvocation:m,workflowRunId:w}=(e=>{let t=e.headers.get(eG),r=!t;if(!r&&"1"!==t)throw new ew(`Incompatible workflow sdk protocol version. Expected 1, got ${t} from the request.`);let a=r?`wfr_${[...crypto.getRandomValues(new Uint8Array(21))].map(e=>ez[e%ez.length]).join("")}`:e.headers.get(eK)??"";if(0===a.length)throw new ew("Couldn't get workflow id from header");return{isFirstInvocation:r,workflowRunId:a}})(t);h?.setWorkflowRunId(w);let{rawInitialPayload:v,steps:g,isLastDuplicate:S}=await tc(b,m,h);if(S)return a("no-workflow-id","duplicate-step");let _=new tr({qstashClient:r,workflowRunId:w,initialPayload:i(v),rawInitialPayload:v,headers:eZ(t.headers),steps:g,url:u,failureUrl:p,debug:h,env:l}),k=await ta.tryAuthentication(e,_);if(k.isErr())throw await h?.log("ERROR","ERROR",{error:k.error.message}),k.error;if("run-ended"===k.value)return a("no-workflow-id","auth-fail");let E=await e0(t,v,r,u,p,x,h);if(E.isErr())throw await h?.log("ERROR","SUBMIT_THIRD_PARTY_RESULT",{error:E.error.message}),E.error;if("continue-workflow"===E.value){let t=m?await eY(_,x,h):await eX({onStep:async()=>e(_),onCleanup:async()=>{await eV(_,h)}});if(t.isErr())throw await h?.log("ERROR","ERROR",{error:t.error.message}),t.error;return await h?.log("INFO","RESPONSE_WORKFLOW"),a(_.workflowRunId,"success")}return await h?.log("INFO","RESPONSE_DEFAULT"),a("no-workflow-id","fromCallback")};return async e=>{try{return await u(e)}catch(e){return console.error(e),new Response(JSON.stringify(eg(e)),{status:500})}}},tl=class{http;constructor(e){this.http=e}async cancel(e){return await this.http.request({path:["v2","workflows","runs",`${e}?cancel=true`],method:"DELETE",parseResponseAsJson:!1})??!0}};let tx=new ej({token:process.env.QSTASH_TOKEN})},772,e=>{"use strict";e.s(["getNextOccurrence",()=>o]);var t=e.i(56512),r=e.i(57855),a=e.i(55348);t.default.extend(r.default),t.default.extend(a.default);let i={secondly:"second",minutely:"minute",hourly:"hour",daily:"day",weekly:"week",monthly:"month",yearly:"year"},s=(e,t)=>(!t.byMonth||t.byMonth.includes(e.month()+1))&&(!t.byDay||t.byDay.includes(e.format("dd").toUpperCase()))&&(!t.byHour||t.byHour.includes(e.hour()))&&(!t.byMinute||t.byMinute.includes(e.minute()))&&(!t.bySecond||t.bySecond.includes(e.second())),o=({schedule:e,now:r=new Date})=>{if(!e||"object"!=typeof e)return null;let{start:a,timeZone:o="UTC",recurrenceRules:n=[]}=e;if("string"!=typeof a||!(0,t.default)(a).isValid())return null;let c=/([+-]\d\d:\d\d|Z)$/i.test(a)?(0,t.default)(a).tz(o):t.default.tz(a,o),f=t.default.tz(r,o).add(1,"second");if(0===n.length)return c.isAfter(f)?c.toISOString():null;let d=null;for(let e of n){let r=i[e.frequency];if(!r)continue;let a=Math.max(1,e.interval??1),n=c;if(n.isBefore(f)){let e=Math.floor(f.diff(c,r)/a);for(n=c.add(e*a,r);n.isBefore(f);)n=n.add(a,r)}let l=0;for(;!s(n,e)&&l<5e3;)n=n.add(a,r),l++;!(e.until&&n.isAfter(t.default.tz(e.until,o)))&&!(e.count&&c.add(a*e.count,r).isBefore(n))&&(!d||n.isBefore(d))&&(d=n)}return d?d.toISOString():null}},60172,e=>{"use strict";e.s(["scheduleTask",()=>n]);var t=e.i(56512),r=e.i(57855),a=e.i(55348),i=e.i(30021),s=e.i(24493),o=e.i(772);t.default.extend(r.default),t.default.extend(a.default);let n=async({task:e})=>{if(!e.schedule||"object"!=typeof e.schedule)return;let r=(0,o.getNextOccurrence)({schedule:e.schedule});if(!r)return;let a=t.default.utc(r);if(!a.isValid())return;let n=Math.max(0,a.diff(t.default.utc(),"second")),{messageId:c}=await i.qstash.publishJSON({url:`${process.env.NEXT_PUBLIC_SUPERINTERFACE_BASE_URL}/api/cloud/tasks/callback`,body:{taskId:e.id},delay:n});if(!c)throw Error("Failed to schedule task: missing QStash ID");await s.prisma.task.update({where:{id:e.id},data:{qstashMessageId:c}})}},7179,83675,e=>{"use strict";e.s(["serializeTask",()=>t],7179);let t=({task:e})=>({id:e.id,title:e.title,message:e.message,schedule:e.schedule,threadId:e.threadId,key:e.key,createdAt:e.createdAt.toISOString(),updatedAt:e.updatedAt.toISOString()});e.s(["scheduleSchema",()=>s],83675);var r=e.i(13669);let a=/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?)(Z|[+-]\d{2}:\d{2})?$/,i=r.z.object({frequency:r.z.enum(["yearly","monthly","weekly","daily","hourly","minutely","secondly"]),interval:r.z.number().int().min(1).optional(),byDay:r.z.array(r.z.string()).optional(),byMonth:r.z.array(r.z.number()).optional(),byHour:r.z.array(r.z.number()).optional(),byMinute:r.z.array(r.z.number()).optional(),bySecond:r.z.array(r.z.number()).optional(),until:r.z.string().regex(a).optional(),count:r.z.number().int().optional()}).passthrough(),s=r.z.object({start:r.z.string().regex(a),due:r.z.string().regex(a).optional(),recurrenceRules:r.z.array(i).optional()}).passthrough()},79100,e=>{"use strict";e.s(["validateSchedule",()=>a]);var t=e.i(83675),r=e.i(772);let a=e=>{if(!t.scheduleSchema.safeParse(e).success)return!1;try{let t=(0,r.getNextOccurrence)({schedule:e});if(Array.isArray(e.recurrenceRules)&&e.recurrenceRules.length)return null!==t;return!0}catch{return!1}}}];
10
+ Step Types expected: ${JSON.stringify(i)}`)}throw r}},e6=e=>[...e].sort((e,t)=>(e=>e.targetStep??e.stepId)(e)-(e=>e.targetStep??e.stepId)(t)),e7=class{stepName;constructor(e){this.stepName=e}},e3=class extends e7{stepFunction;stepType="Run";constructor(e,t){super(e),this.stepFunction=t}getPlanStep(e,t){return{stepId:0,stepName:this.stepName,stepType:this.stepType,concurrent:e,targetStep:t}}async getResultStep(e,t){let r=this.stepFunction();return r instanceof Promise&&(r=await r),{stepId:t,stepName:this.stepName,stepType:this.stepType,out:r,concurrent:e}}},e9=class extends e7{sleep;stepType="SleepFor";constructor(e,t){super(e),this.sleep=t}getPlanStep(e,t){return{stepId:0,stepName:this.stepName,stepType:this.stepType,sleepFor:this.sleep,concurrent:e,targetStep:t}}async getResultStep(e,t){return await Promise.resolve({stepId:t,stepName:this.stepName,stepType:this.stepType,sleepFor:this.sleep,concurrent:e})}},te=class extends e7{sleepUntil;stepType="SleepUntil";constructor(e,t){super(e),this.sleepUntil=t}getPlanStep(e,t){return{stepId:0,stepName:this.stepName,stepType:this.stepType,sleepUntil:this.sleepUntil,concurrent:e,targetStep:t}}async getResultStep(e,t){return await Promise.resolve({stepId:t,stepName:this.stepName,stepType:this.stepType,sleepUntil:this.sleepUntil,concurrent:e})}},tt=class extends e7{url;method;body;headers;stepType="Call";constructor(e,t,r,a,i){super(e),this.url=t,this.method=r,this.body=a,this.headers=i}getPlanStep(e,t){return{stepId:0,stepName:this.stepName,stepType:this.stepType,concurrent:e,targetStep:t}}async getResultStep(e,t){return await Promise.resolve({stepId:t,stepName:this.stepName,stepType:this.stepType,concurrent:e,callUrl:this.url,callMethod:this.method,callBody:this.body,callHeaders:this.headers})}},tr=class{executor;steps;qstashClient;workflowRunId;url;failureUrl;requestPayload;headers;rawInitialPayload;env;retries;constructor({qstashClient:e,workflowRunId:t,headers:r,steps:a,url:i,failureUrl:s,debug:o,initialPayload:n,rawInitialPayload:c,env:f,retries:d}){this.qstashClient=e,this.workflowRunId=t,this.steps=a,this.url=i,this.failureUrl=s,this.headers=r,this.requestPayload=n,this.rawInitialPayload=c??JSON.stringify(this.requestPayload),this.env=f??{},this.retries=d??3,this.executor=new e4(this,this.steps,o)}async run(e,t){let r=()=>this.executor.wrapStep(e,t);return this.addStep(new e3(e,r))}async sleep(e,t){await this.addStep(new e9(e,t))}async sleepUntil(e,t){let r;r="number"==typeof t?t:Math.round((t="string"==typeof t?new Date(t):t).getTime()/1e3),await this.addStep(new te(e,r))}async call(e,t,r,a,i){let s=await this.addStep(new tt(e,t,r,a,i??{}));try{return JSON.parse(s)}catch{return s}}async addStep(e){return await this.executor.addStep(e)}},ta=class e extends tr{static disabledMessage="disabled-qstash-worklfow-run";async addStep(t){throw new ev(e.disabledMessage)}static async tryAuthentication(t,r){let a=new e({qstashClient:new ej({baseUrl:"disabled-client",token:"disabled-client"}),workflowRunId:r.workflowRunId,headers:r.headers,steps:[],url:r.url,failureUrl:r.failureUrl,initialPayload:r.requestPayload,rawInitialPayload:r.rawInitialPayload,env:r.env,retries:r.retries});try{await t(a)}catch(e){if(e instanceof ev&&e.stepName===this.disabledMessage)return ec("step-found");return ef(e)}return ec("run-ended")}},ti=["DEBUG","INFO","SUBMIT","WARN","ERROR"],ts=class e{logs=[];options;workflowRunId=void 0;constructor(e){this.options=e}async log(e,t,r){if(this.shouldLog(e)){let a={timestamp:Date.now(),workflowRunId:this.workflowRunId??"",logLevel:e,eventType:t,details:r};this.logs.push(a),"console"===this.options.logOutput&&this.writeToConsole(a),await new Promise(e=>setTimeout(e,100))}}setWorkflowRunId(e){this.workflowRunId=e}writeToConsole(e){console.log(JSON.stringify(e,void 0,2))}shouldLog(e){return ti.indexOf(e)>=ti.indexOf(this.options.logLevel)}static getLogger(t){return"object"==typeof t?t:t?new e({logLevel:"INFO",logOutput:"console"}):void 0}},to=async e=>{try{return await e.text()}catch{return}},tn=async(e,t)=>{if(e.length<2)return!1;let r=e.at(-1),a=r.stepId,i=r.targetStep;for(let r=0;r<e.length-1;r++){let s=e[r];if(s.stepId===a&&s.targetStep===i){let e=`Upstash Workflow: The step '${s.stepName}' with id '${s.stepId}' has run twice during workflow execution. Rest of the workflow will continue running as usual.`;return await t?.log("WARN","RESPONSE_DEFAULT",e),console.warn(e),!0}}return!1},tc=async(e,t,r)=>{if(t)return{rawInitialPayload:e??"",steps:[],isLastDuplicate:!1};{if(!e)throw new ew("Only first call can have an empty body");let{rawInitialPayload:t,steps:a}=(e=>{let[t,...r]=JSON.parse(e),a=eJ(t.body),i=[{stepId:0,stepName:"init",stepType:"Initial",out:a,concurrent:1},...r.filter(e=>"step"===e.callType).map(e=>JSON.parse(eJ(e.body)))];return{rawInitialPayload:a,steps:i}})(e),i=await tn(a,r);return{rawInitialPayload:t,steps:(e=>{let t=[],r=[],a=[];for(let i of e)0===i.stepId?t.includes(i.targetStep??0)||(a.push(i),t.push(i.targetStep??0)):r.includes(i.stepId)||(a.push(i),r.push(i.stepId));return a})(a),isLastDuplicate:i}}},tf=async(e,t,r,a,i,s)=>{if("true"!==e.headers.get(eF))return ec("not-failure-callback");if(!i)return ef(new ew("Workflow endpoint is called to handle a failure, but a failureFunction is not provided in serve options. Either provide a failureUrl or a failureFunction."));try{let{status:e,header:o,body:n,url:c,sourceHeader:f,sourceBody:d,workflowRunId:l}=JSON.parse(t),x=n?eJ(n):"{}",h=JSON.parse(x),{rawInitialPayload:u,steps:p,isLastDuplicate:b}=await tc(eJ(d),!1,s),y=new tr({qstashClient:r,workflowRunId:l,initialPayload:a(u),rawInitialPayload:u,headers:eZ(new Headers(f)),steps:p,url:c,failureUrl:c,debug:s});await i(y,e,h.message,o)}catch(e){return ef(e)}return ec("is-failure-callback")},td=(e,t)=>{let{qstashClient:r,onStepFinish:a,initialPayloadParser:i,url:s,verbose:o,receiver:n,failureUrl:c,failureFunction:f,baseUrl:d,env:l,retries:x}=(e=>{let t=e?.env??("undefined"==typeof process?{}:process.env),r=!!(t.QSTASH_CURRENT_SIGNING_KEY&&t.QSTASH_NEXT_SIGNING_KEY);return{qstashClient:new ej({baseUrl:t.QSTASH_URL,token:t.QSTASH_TOKEN}),onStepFinish:(e,t)=>new Response(JSON.stringify({workflowRunId:e}),{status:200}),initialPayloadParser:e=>{if(e)try{return JSON.parse(e)}catch(t){if(t instanceof SyntaxError)return e;throw t}},receiver:r?new eh({currentSigningKey:t.QSTASH_CURRENT_SIGNING_KEY,nextSigningKey:t.QSTASH_NEXT_SIGNING_KEY}):void 0,baseUrl:t.UPSTASH_WORKFLOW_URL,env:t,retries:3,...e}})(t),h=ts.getLogger(o),u=async t=>{let o=s??t.url,u=d?o.replace(/^(https?:\/\/[^/]+)(\/.*)?$/,(e,t,r)=>d+(r||"")):o;u!==o&&await h?.log("WARN","ENDPOINT_START",{warning:`Upstash Workflow: replacing the base of the url with "${d}" and using it as workflow endpoint.`,originalURL:o,updatedURL:u});let p=f?u:c,b=await to(t)??"";await e2(b,t.headers.get("upstash-signature"),n),await h?.log("INFO","ENDPOINT_START");let y=await tf(t,b,r,i,f);if(y.isErr())throw y.error;if("is-failure-callback"===y.value)return await h?.log("WARN","RESPONSE_DEFAULT","failureFunction executed"),a("no-workflow-id","failure-callback");let{isFirstInvocation:m,workflowRunId:w}=(e=>{let t=e.headers.get(eG),r=!t;if(!r&&"1"!==t)throw new ew(`Incompatible workflow sdk protocol version. Expected 1, got ${t} from the request.`);let a=r?`wfr_${[...crypto.getRandomValues(new Uint8Array(21))].map(e=>ez[e%ez.length]).join("")}`:e.headers.get(eK)??"";if(0===a.length)throw new ew("Couldn't get workflow id from header");return{isFirstInvocation:r,workflowRunId:a}})(t);h?.setWorkflowRunId(w);let{rawInitialPayload:v,steps:g,isLastDuplicate:S}=await tc(b,m,h);if(S)return a("no-workflow-id","duplicate-step");let _=new tr({qstashClient:r,workflowRunId:w,initialPayload:i(v),rawInitialPayload:v,headers:eZ(t.headers),steps:g,url:u,failureUrl:p,debug:h,env:l}),k=await ta.tryAuthentication(e,_);if(k.isErr())throw await h?.log("ERROR","ERROR",{error:k.error.message}),k.error;if("run-ended"===k.value)return a("no-workflow-id","auth-fail");let E=await e0(t,v,r,u,p,x,h);if(E.isErr())throw await h?.log("ERROR","SUBMIT_THIRD_PARTY_RESULT",{error:E.error.message}),E.error;if("continue-workflow"===E.value){let t=m?await eY(_,x,h):await eX({onStep:async()=>e(_),onCleanup:async()=>{await eV(_,h)}});if(t.isErr())throw await h?.log("ERROR","ERROR",{error:t.error.message}),t.error;return await h?.log("INFO","RESPONSE_WORKFLOW"),a(_.workflowRunId,"success")}return await h?.log("INFO","RESPONSE_DEFAULT"),a("no-workflow-id","fromCallback")};return async e=>{try{return await u(e)}catch(e){return console.error(e),new Response(JSON.stringify(eg(e)),{status:500})}}},tl=class{http;constructor(e){this.http=e}async cancel(e){return await this.http.request({path:["v2","workflows","runs",`${e}?cancel=true`],method:"DELETE",parseResponseAsJson:!1})??!0}};let tx=new ej({token:process.env.QSTASH_TOKEN})},772,e=>{"use strict";e.s(["getNextOccurrence",()=>o]);var t=e.i(56512),r=e.i(57855),a=e.i(55348);t.default.extend(r.default),t.default.extend(a.default);let i={secondly:"second",minutely:"minute",hourly:"hour",daily:"day",weekly:"week",monthly:"month",yearly:"year"},s=(e,t)=>(!t.byMonth||t.byMonth.includes(e.month()+1))&&(!t.byDay||t.byDay.includes(e.format("dd").toUpperCase()))&&(!t.byHour||t.byHour.includes(e.hour()))&&(!t.byMinute||t.byMinute.includes(e.minute()))&&(!t.bySecond||t.bySecond.includes(e.second())),o=({schedule:e,now:r=new Date})=>{if(!e||"object"!=typeof e)return null;let{start:a,timeZone:o="UTC",recurrenceRules:n=[]}=e;if("string"!=typeof a||!(0,t.default)(a).isValid())return null;let c=/([+-]\d\d:\d\d|Z)$/i.test(a)?(0,t.default)(a).tz(o):t.default.tz(a,o),f=t.default.tz(r,o).add(1,"second");if(0===n.length)return c.isAfter(f)?c.toISOString():null;let d=null;for(let e of n){let r=i[e.frequency];if(!r)continue;let a=Math.max(1,e.interval??1),n=c;if(n.isBefore(f)){let e=Math.floor(f.diff(c,r)/a);for(n=c.add(e*a,r);n.isBefore(f);)n=n.add(a,r)}let l=0;for(;!s(n,e)&&l<5e3;)n=n.add(a,r),l++;!(e.until&&n.isAfter(t.default.tz(e.until,o)))&&!(e.count&&c.add(a*e.count,r).isBefore(n))&&(!d||n.isBefore(d))&&(d=n)}return d?d.toISOString():null}},60172,e=>{"use strict";e.s(["scheduleTask",()=>o]);var t=e.i(56512),r=e.i(57855),a=e.i(55348),i=e.i(30021),s=e.i(772);t.default.extend(r.default),t.default.extend(a.default);let o=async({task:e,prisma:r})=>{if(!e.schedule||"object"!=typeof e.schedule)return;let a=(0,s.getNextOccurrence)({schedule:e.schedule});if(!a)return;let o=t.default.utc(a);if(!o.isValid())return;let n=Math.max(0,o.diff(t.default.utc(),"second")),{messageId:c}=await i.qstash.publishJSON({url:`${process.env.NEXT_PUBLIC_SUPERINTERFACE_BASE_URL}/api/cloud/tasks/callback`,body:{taskId:e.id},delay:n});if(!c)throw Error("Failed to schedule task: missing QStash ID");await r.task.update({where:{id:e.id},data:{qstashMessageId:c}})}},7179,83675,e=>{"use strict";e.s(["serializeTask",()=>t],7179);let t=({task:e})=>({id:e.id,title:e.title,message:e.message,schedule:e.schedule,threadId:e.threadId,key:e.key,createdAt:e.createdAt.toISOString(),updatedAt:e.updatedAt.toISOString()});e.s(["scheduleSchema",()=>s],83675);var r=e.i(13669);let a=/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?)(Z|[+-]\d{2}:\d{2})?$/,i=r.z.object({frequency:r.z.enum(["yearly","monthly","weekly","daily","hourly","minutely","secondly"]),interval:r.z.number().int().min(1).optional(),byDay:r.z.array(r.z.string()).optional(),byMonth:r.z.array(r.z.number()).optional(),byHour:r.z.array(r.z.number()).optional(),byMinute:r.z.array(r.z.number()).optional(),bySecond:r.z.array(r.z.number()).optional(),until:r.z.string().regex(a).optional(),count:r.z.number().int().optional()}).passthrough(),s=r.z.object({start:r.z.string().regex(a),due:r.z.string().regex(a).optional(),recurrenceRules:r.z.array(i).optional()}).passthrough()},79100,e=>{"use strict";e.s(["validateSchedule",()=>a]);var t=e.i(83675),r=e.i(772);let a=e=>{if(!t.scheduleSchema.safeParse(e).success)return!1;try{let t=(0,r.getNextOccurrence)({schedule:e});if(Array.isArray(e.recurrenceRules)&&e.recurrenceRules.length)return null!==t;return!0}catch{return!1}}}];
11
11
 
12
12
  //# sourceMappingURL=%5Broot-of-the-server%5D__13c6bd62._.js.map