@farm.js/core 0.1.0-beta.6 → 0.1.0-beta.8

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 (447) hide show
  1. package/dist/after.cjs +227 -0
  2. package/dist/after.cjs.map +1 -0
  3. package/dist/after.d.mts +25 -0
  4. package/dist/after.d.ts +25 -0
  5. package/dist/after.mjs +14 -0
  6. package/dist/after.mjs.map +1 -0
  7. package/dist/agent-runtime.cjs +2379 -0
  8. package/dist/agent-runtime.cjs.map +1 -0
  9. package/dist/agent-runtime.d.mts +94 -0
  10. package/dist/agent-runtime.d.ts +94 -0
  11. package/dist/agent-runtime.mjs +479 -0
  12. package/dist/agent-runtime.mjs.map +1 -0
  13. package/dist/api/route-manager.d.mts +66 -0
  14. package/dist/api/route-manager.d.ts +66 -0
  15. package/dist/api/runtime.d.mts +3 -0
  16. package/dist/api/runtime.d.ts +3 -0
  17. package/dist/api.cjs +4100 -0
  18. package/dist/api.cjs.map +1 -0
  19. package/dist/api.d.mts +48 -0
  20. package/dist/api.d.ts +48 -0
  21. package/dist/api.mjs +93 -0
  22. package/dist/api.mjs.map +1 -0
  23. package/dist/app-BWtqQu3R.d.mts +302 -0
  24. package/dist/app-markdown.cjs +244 -0
  25. package/dist/app-markdown.cjs.map +1 -0
  26. package/dist/app-markdown.d.mts +22 -0
  27. package/dist/app-markdown.d.ts +22 -0
  28. package/dist/app-markdown.mjs +27 -0
  29. package/dist/app-markdown.mjs.map +1 -0
  30. package/dist/app-xltejvLY.d.ts +302 -0
  31. package/dist/cache.cjs +945 -0
  32. package/dist/cache.cjs.map +1 -0
  33. package/dist/cache.d.mts +192 -0
  34. package/dist/cache.d.ts +192 -0
  35. package/dist/cache.mjs +46 -0
  36. package/dist/cache.mjs.map +1 -0
  37. package/dist/chunk-2ED5Q2GH.mjs +422 -0
  38. package/dist/chunk-2ED5Q2GH.mjs.map +1 -0
  39. package/dist/chunk-32W4QEJP.mjs +158 -0
  40. package/dist/chunk-32W4QEJP.mjs.map +1 -0
  41. package/dist/chunk-3XNTL3FQ.mjs +452 -0
  42. package/dist/chunk-3XNTL3FQ.mjs.map +1 -0
  43. package/dist/chunk-44ZCFSKE.mjs +84 -0
  44. package/dist/chunk-44ZCFSKE.mjs.map +1 -0
  45. package/dist/chunk-4MGVSBRP.mjs +7787 -0
  46. package/dist/chunk-4MGVSBRP.mjs.map +1 -0
  47. package/dist/chunk-4S3ORGFA.mjs +44 -0
  48. package/dist/chunk-4S3ORGFA.mjs.map +1 -0
  49. package/dist/chunk-5BY76U2M.mjs +1 -0
  50. package/dist/chunk-5BY76U2M.mjs.map +1 -0
  51. package/dist/chunk-5ZGPRGWV.mjs +136 -0
  52. package/dist/chunk-5ZGPRGWV.mjs.map +1 -0
  53. package/dist/chunk-65A7QIKI.mjs +142 -0
  54. package/dist/chunk-65A7QIKI.mjs.map +1 -0
  55. package/dist/chunk-74YTBPTY.mjs +450 -0
  56. package/dist/chunk-74YTBPTY.mjs.map +1 -0
  57. package/dist/chunk-7FBJLMQH.mjs +338 -0
  58. package/dist/chunk-7FBJLMQH.mjs.map +1 -0
  59. package/dist/chunk-7HO6AEOP.mjs +74 -0
  60. package/dist/chunk-7HO6AEOP.mjs.map +1 -0
  61. package/dist/chunk-7MABZJIM.mjs +29 -0
  62. package/dist/chunk-7MABZJIM.mjs.map +1 -0
  63. package/dist/chunk-7N62DNSO.mjs +41 -0
  64. package/dist/chunk-7N62DNSO.mjs.map +1 -0
  65. package/dist/chunk-7ZY5AIJO.mjs +161 -0
  66. package/dist/chunk-7ZY5AIJO.mjs.map +1 -0
  67. package/dist/chunk-ALCLXXTY.mjs +187 -0
  68. package/dist/chunk-ALCLXXTY.mjs.map +1 -0
  69. package/dist/chunk-AZ7YUVNR.mjs +65 -0
  70. package/dist/chunk-AZ7YUVNR.mjs.map +1 -0
  71. package/dist/chunk-B232I2GP.mjs +163 -0
  72. package/dist/chunk-B232I2GP.mjs.map +1 -0
  73. package/dist/chunk-B4W3BNTL.mjs +483 -0
  74. package/dist/chunk-B4W3BNTL.mjs.map +1 -0
  75. package/dist/chunk-C2ROET2V.mjs +718 -0
  76. package/dist/chunk-C2ROET2V.mjs.map +1 -0
  77. package/dist/chunk-CGILA3WO.mjs +14 -0
  78. package/dist/chunk-CGILA3WO.mjs.map +1 -0
  79. package/dist/chunk-CGIXMLSY.mjs +184 -0
  80. package/dist/chunk-CGIXMLSY.mjs.map +1 -0
  81. package/dist/chunk-DJSGLHCN.mjs +597 -0
  82. package/dist/chunk-DJSGLHCN.mjs.map +1 -0
  83. package/dist/chunk-E2MPIBRE.mjs +149 -0
  84. package/dist/chunk-E2MPIBRE.mjs.map +1 -0
  85. package/dist/chunk-E6EPN5BT.mjs +203 -0
  86. package/dist/chunk-E6EPN5BT.mjs.map +1 -0
  87. package/dist/chunk-EI43C4RA.mjs +6277 -0
  88. package/dist/chunk-EI43C4RA.mjs.map +1 -0
  89. package/dist/chunk-EJ7T4TPB.mjs +622 -0
  90. package/dist/chunk-EJ7T4TPB.mjs.map +1 -0
  91. package/dist/chunk-FQYDHKKU.mjs +128 -0
  92. package/dist/chunk-FQYDHKKU.mjs.map +1 -0
  93. package/dist/chunk-FRPWCMMG.mjs +299 -0
  94. package/dist/chunk-FRPWCMMG.mjs.map +1 -0
  95. package/dist/chunk-GN72QAIH.mjs +146 -0
  96. package/dist/chunk-GN72QAIH.mjs.map +1 -0
  97. package/dist/chunk-GQVGIUSN.mjs +149 -0
  98. package/dist/chunk-GQVGIUSN.mjs.map +1 -0
  99. package/dist/chunk-GS6K5OCM.mjs +407 -0
  100. package/dist/chunk-GS6K5OCM.mjs.map +1 -0
  101. package/dist/chunk-GXASWWJU.mjs +364 -0
  102. package/dist/chunk-GXASWWJU.mjs.map +1 -0
  103. package/dist/chunk-GY2STC2S.mjs +180 -0
  104. package/dist/chunk-GY2STC2S.mjs.map +1 -0
  105. package/dist/chunk-H2FA2SBS.mjs +51 -0
  106. package/dist/chunk-H2FA2SBS.mjs.map +1 -0
  107. package/dist/chunk-I4CUBGVF.mjs +93 -0
  108. package/dist/chunk-I4CUBGVF.mjs.map +1 -0
  109. package/dist/chunk-ITN462YM.mjs +98 -0
  110. package/dist/chunk-ITN462YM.mjs.map +1 -0
  111. package/dist/chunk-J23HNLFY.mjs +72 -0
  112. package/dist/chunk-J23HNLFY.mjs.map +1 -0
  113. package/dist/chunk-J4FNJ5IU.mjs +179 -0
  114. package/dist/chunk-J4FNJ5IU.mjs.map +1 -0
  115. package/dist/chunk-J5YWQVI5.mjs +211 -0
  116. package/dist/chunk-J5YWQVI5.mjs.map +1 -0
  117. package/dist/chunk-JDEOUK5V.mjs +427 -0
  118. package/dist/chunk-JDEOUK5V.mjs.map +1 -0
  119. package/dist/chunk-JK25YEN6.mjs +219 -0
  120. package/dist/chunk-JK25YEN6.mjs.map +1 -0
  121. package/dist/chunk-K4667E2Q.mjs +1916 -0
  122. package/dist/chunk-K4667E2Q.mjs.map +1 -0
  123. package/dist/chunk-LGHEOHBU.mjs +218 -0
  124. package/dist/chunk-LGHEOHBU.mjs.map +1 -0
  125. package/dist/chunk-LM2YNO4U.mjs +24 -0
  126. package/dist/chunk-LM2YNO4U.mjs.map +1 -0
  127. package/dist/chunk-ME4MO2RJ.mjs +3540 -0
  128. package/dist/chunk-ME4MO2RJ.mjs.map +1 -0
  129. package/dist/chunk-MIUW47JX.mjs +639 -0
  130. package/dist/chunk-MIUW47JX.mjs.map +1 -0
  131. package/dist/chunk-NNLCAVB6.mjs +391 -0
  132. package/dist/chunk-NNLCAVB6.mjs.map +1 -0
  133. package/dist/chunk-P7QDS5AT.mjs +191 -0
  134. package/dist/chunk-P7QDS5AT.mjs.map +1 -0
  135. package/dist/chunk-PFE6GMNE.mjs +603 -0
  136. package/dist/chunk-PFE6GMNE.mjs.map +1 -0
  137. package/dist/chunk-QGOHVJ6J.mjs +63 -0
  138. package/dist/chunk-QGOHVJ6J.mjs.map +1 -0
  139. package/dist/chunk-QKVUNGAH.mjs +39 -0
  140. package/dist/chunk-QKVUNGAH.mjs.map +1 -0
  141. package/dist/chunk-QM746KUO.mjs +56 -0
  142. package/dist/chunk-QM746KUO.mjs.map +1 -0
  143. package/dist/chunk-QTZZ2ISQ.mjs +753 -0
  144. package/dist/chunk-QTZZ2ISQ.mjs.map +1 -0
  145. package/dist/chunk-RBRLLZL5.mjs +81 -0
  146. package/dist/chunk-RBRLLZL5.mjs.map +1 -0
  147. package/dist/chunk-RHIFZZUI.mjs +69 -0
  148. package/dist/chunk-RHIFZZUI.mjs.map +1 -0
  149. package/dist/chunk-RQ633A5I.mjs +187 -0
  150. package/dist/chunk-RQ633A5I.mjs.map +1 -0
  151. package/dist/chunk-SCFX4UTD.mjs +28 -0
  152. package/dist/chunk-SCFX4UTD.mjs.map +1 -0
  153. package/dist/chunk-SL6HTIOK.mjs +66 -0
  154. package/dist/chunk-SL6HTIOK.mjs.map +1 -0
  155. package/dist/chunk-SPBBQLXI.mjs +207 -0
  156. package/dist/chunk-SPBBQLXI.mjs.map +1 -0
  157. package/dist/chunk-SSA7THPX.mjs +10 -0
  158. package/dist/chunk-SSA7THPX.mjs.map +1 -0
  159. package/dist/chunk-T4QJQK76.mjs +459 -0
  160. package/dist/chunk-T4QJQK76.mjs.map +1 -0
  161. package/dist/chunk-TQAEEJB4.mjs +157 -0
  162. package/dist/chunk-TQAEEJB4.mjs.map +1 -0
  163. package/dist/chunk-UB5UOSHB.mjs +458 -0
  164. package/dist/chunk-UB5UOSHB.mjs.map +1 -0
  165. package/dist/chunk-USWZZUEH.mjs +25 -0
  166. package/dist/chunk-USWZZUEH.mjs.map +1 -0
  167. package/dist/chunk-UVCIEUJC.mjs +16 -0
  168. package/dist/chunk-UVCIEUJC.mjs.map +1 -0
  169. package/dist/chunk-UXUAWNO5.mjs +396 -0
  170. package/dist/chunk-UXUAWNO5.mjs.map +1 -0
  171. package/dist/chunk-V3XURYJO.mjs +756 -0
  172. package/dist/chunk-V3XURYJO.mjs.map +1 -0
  173. package/dist/chunk-V6WE6JSZ.mjs +352 -0
  174. package/dist/chunk-V6WE6JSZ.mjs.map +1 -0
  175. package/dist/chunk-V7RBCSDJ.mjs +170 -0
  176. package/dist/chunk-V7RBCSDJ.mjs.map +1 -0
  177. package/dist/chunk-VCANOYFI.mjs +588 -0
  178. package/dist/chunk-VCANOYFI.mjs.map +1 -0
  179. package/dist/chunk-VY2UYN5R.mjs +224 -0
  180. package/dist/chunk-VY2UYN5R.mjs.map +1 -0
  181. package/dist/chunk-W2CRQFF6.mjs +1352 -0
  182. package/dist/chunk-W2CRQFF6.mjs.map +1 -0
  183. package/dist/chunk-WDU6QXNK.mjs +872 -0
  184. package/dist/chunk-WDU6QXNK.mjs.map +1 -0
  185. package/dist/chunk-WZ5QFROO.mjs +23 -0
  186. package/dist/chunk-WZ5QFROO.mjs.map +1 -0
  187. package/dist/chunk-XIVV5IWN.mjs +541 -0
  188. package/dist/chunk-XIVV5IWN.mjs.map +1 -0
  189. package/dist/chunk-YW7OBE6Q.mjs +119 -0
  190. package/dist/chunk-YW7OBE6Q.mjs.map +1 -0
  191. package/dist/chunk-Z5CQMP54.mjs +365 -0
  192. package/dist/chunk-Z5CQMP54.mjs.map +1 -0
  193. package/dist/chunk-ZBE6MLHL.mjs +230 -0
  194. package/dist/chunk-ZBE6MLHL.mjs.map +1 -0
  195. package/dist/chunk-ZVWA4ZQ3.mjs +189 -0
  196. package/dist/chunk-ZVWA4ZQ3.mjs.map +1 -0
  197. package/dist/chunk-ZZ57EH5Z.mjs +173 -0
  198. package/dist/chunk-ZZ57EH5Z.mjs.map +1 -0
  199. package/dist/client-BT1mFQas.d.mts +447 -0
  200. package/dist/client-Nn0q4eO4.d.ts +447 -0
  201. package/dist/client-cache-CIlyBlmx.d.ts +6 -0
  202. package/dist/client-cache-D-EZ7XVW.d.mts +6 -0
  203. package/dist/client-plugins-BI2R6Eae.d.mts +1926 -0
  204. package/dist/client-plugins-DU9oMspX.d.ts +1926 -0
  205. package/dist/client-plugins.cjs +415 -0
  206. package/dist/client-plugins.cjs.map +1 -0
  207. package/dist/client-plugins.d.mts +22 -0
  208. package/dist/client-plugins.d.ts +22 -0
  209. package/dist/client-plugins.mjs +10 -0
  210. package/dist/client-plugins.mjs.map +1 -0
  211. package/dist/client.cjs +5402 -0
  212. package/dist/client.cjs.map +1 -0
  213. package/dist/client.d.mts +447 -0
  214. package/dist/client.d.ts +447 -0
  215. package/dist/client.mjs +110 -0
  216. package/dist/client.mjs.map +1 -0
  217. package/dist/config.cjs +38 -0
  218. package/dist/config.cjs.map +1 -0
  219. package/dist/config.d.mts +29 -0
  220. package/dist/config.d.ts +29 -0
  221. package/dist/config.mjs +10 -0
  222. package/dist/config.mjs.map +1 -0
  223. package/dist/cron.cjs +406 -0
  224. package/dist/cron.cjs.map +1 -0
  225. package/dist/cron.d.mts +78 -0
  226. package/dist/cron.d.ts +78 -0
  227. package/dist/cron.mjs +30 -0
  228. package/dist/cron.mjs.map +1 -0
  229. package/dist/deferred.cjs +438 -0
  230. package/dist/deferred.cjs.map +1 -0
  231. package/dist/deferred.d.mts +42 -0
  232. package/dist/deferred.d.ts +42 -0
  233. package/dist/deferred.mjs +28 -0
  234. package/dist/deferred.mjs.map +1 -0
  235. package/dist/deployment.cjs +199 -0
  236. package/dist/deployment.cjs.map +1 -0
  237. package/dist/deployment.d.mts +34 -0
  238. package/dist/deployment.d.ts +34 -0
  239. package/dist/deployment.mjs +38 -0
  240. package/dist/deployment.mjs.map +1 -0
  241. package/dist/devtools-REQTS3I7.mjs +371 -0
  242. package/dist/devtools-REQTS3I7.mjs.map +1 -0
  243. package/dist/devtools-client-3XRTBND5.mjs +216 -0
  244. package/dist/devtools-client-3XRTBND5.mjs.map +1 -0
  245. package/dist/devtools-ui-NJKFORTG.mjs +1349 -0
  246. package/dist/devtools-ui-NJKFORTG.mjs.map +1 -0
  247. package/dist/docs.cjs +5548 -0
  248. package/dist/docs.cjs.map +1 -0
  249. package/dist/docs.d.mts +69 -0
  250. package/dist/docs.d.ts +69 -0
  251. package/dist/docs.mjs +47 -0
  252. package/dist/docs.mjs.map +1 -0
  253. package/dist/env-types.cjs +232 -0
  254. package/dist/env-types.cjs.map +1 -0
  255. package/dist/env-types.d.mts +12 -0
  256. package/dist/env-types.d.ts +12 -0
  257. package/dist/env-types.mjs +11 -0
  258. package/dist/env-types.mjs.map +1 -0
  259. package/dist/env.cjs +215 -0
  260. package/dist/env.cjs.map +1 -0
  261. package/dist/env.d.mts +45 -0
  262. package/dist/env.d.ts +45 -0
  263. package/dist/env.mjs +22 -0
  264. package/dist/env.mjs.map +1 -0
  265. package/dist/environment/vite.d.mts +22 -0
  266. package/dist/environment/vite.d.ts +22 -0
  267. package/dist/environment.cjs +96 -0
  268. package/dist/environment.cjs.map +1 -0
  269. package/dist/environment.d.mts +18 -0
  270. package/dist/environment.d.ts +18 -0
  271. package/dist/environment.mjs +14 -0
  272. package/dist/environment.mjs.map +1 -0
  273. package/dist/headers.cjs +126 -0
  274. package/dist/headers.cjs.map +1 -0
  275. package/dist/headers.d.mts +22 -0
  276. package/dist/headers.d.ts +22 -0
  277. package/dist/headers.mjs +12 -0
  278. package/dist/headers.mjs.map +1 -0
  279. package/dist/i18n/client.d.mts +32 -0
  280. package/dist/i18n/client.d.ts +32 -0
  281. package/dist/i18n/index.d.mts +20 -0
  282. package/dist/i18n/index.d.ts +20 -0
  283. package/dist/i18n/server.d.mts +30 -0
  284. package/dist/i18n/server.d.ts +30 -0
  285. package/dist/image/server.d.mts +37 -0
  286. package/dist/image/server.d.ts +37 -0
  287. package/dist/image/sharp.d.mts +7 -0
  288. package/dist/image/sharp.d.ts +7 -0
  289. package/dist/image-config-Duob7wER.d.mts +50 -0
  290. package/dist/image-config-Duob7wER.d.ts +50 -0
  291. package/dist/image.cjs +209 -0
  292. package/dist/image.cjs.map +1 -0
  293. package/dist/image.d.mts +39 -0
  294. package/dist/image.d.ts +39 -0
  295. package/dist/image.mjs +165 -0
  296. package/dist/image.mjs.map +1 -0
  297. package/dist/index.cjs +42186 -0
  298. package/dist/index.cjs.map +1 -0
  299. package/dist/index.d.mts +454 -0
  300. package/dist/index.d.ts +454 -0
  301. package/dist/index.mjs +980 -0
  302. package/dist/index.mjs.map +1 -0
  303. package/dist/integration-api-CHT2OKAf.d.mts +93 -0
  304. package/dist/integration-api-CHT2OKAf.d.ts +93 -0
  305. package/dist/integration-orm-GQLGU66X.mjs +13 -0
  306. package/dist/integration-orm-GQLGU66X.mjs.map +1 -0
  307. package/dist/integrations.cjs +2820 -0
  308. package/dist/integrations.cjs.map +1 -0
  309. package/dist/integrations.d.mts +22 -0
  310. package/dist/integrations.d.ts +22 -0
  311. package/dist/integrations.mjs +51 -0
  312. package/dist/integrations.mjs.map +1 -0
  313. package/dist/internal/build-runtime.cjs +643 -322
  314. package/dist/internal/build-runtime.cjs.map +1 -1
  315. package/dist/internal/build-runtime.d.mts +39 -0
  316. package/dist/internal/build-runtime.d.ts +39 -0
  317. package/dist/internal/build-runtime.mjs +11 -10
  318. package/dist/internal/client-runtime.d.mts +2 -0
  319. package/dist/internal/client-runtime.d.ts +2 -0
  320. package/dist/internal/config-runtime.cjs +135 -39
  321. package/dist/internal/config-runtime.cjs.map +1 -1
  322. package/dist/internal/config-runtime.d.mts +39 -0
  323. package/dist/internal/config-runtime.d.ts +39 -0
  324. package/dist/internal/config-runtime.mjs +5 -4
  325. package/dist/internal/production-node-env.d.mts +12 -0
  326. package/dist/internal/production-node-env.d.ts +12 -0
  327. package/dist/internal/production-runtime.d.mts +39 -0
  328. package/dist/internal/production-runtime.d.ts +39 -0
  329. package/dist/layers-VWVDTPUZ.mjs +16 -0
  330. package/dist/layers-VWVDTPUZ.mjs.map +1 -0
  331. package/dist/manager-THKFTOFE.mjs +10 -0
  332. package/dist/manager-THKFTOFE.mjs.map +1 -0
  333. package/dist/markdown.cjs +364 -0
  334. package/dist/markdown.cjs.map +1 -0
  335. package/dist/markdown.d.mts +60 -0
  336. package/dist/markdown.d.ts +60 -0
  337. package/dist/markdown.mjs +18 -0
  338. package/dist/markdown.mjs.map +1 -0
  339. package/dist/metadata-Cm9ujH4I.d.ts +22 -0
  340. package/dist/metadata-DacXbnLA.d.mts +22 -0
  341. package/dist/middleware.cjs +2148 -0
  342. package/dist/middleware.cjs.map +1 -0
  343. package/dist/middleware.d.mts +164 -0
  344. package/dist/middleware.d.ts +164 -0
  345. package/dist/middleware.mjs +49 -0
  346. package/dist/middleware.mjs.map +1 -0
  347. package/dist/navigation-errors-Dvwpzaer.d.mts +13 -0
  348. package/dist/navigation-errors-Dvwpzaer.d.ts +13 -0
  349. package/dist/navigation.cjs +1329 -0
  350. package/dist/navigation.cjs.map +1 -0
  351. package/dist/navigation.d.mts +14 -0
  352. package/dist/navigation.d.ts +14 -0
  353. package/dist/navigation.mjs +33 -0
  354. package/dist/navigation.mjs.map +1 -0
  355. package/dist/nitro-QO5LV6QK.mjs +689 -0
  356. package/dist/nitro-QO5LV6QK.mjs.map +1 -0
  357. package/dist/observability.cjs +186 -0
  358. package/dist/observability.cjs.map +1 -0
  359. package/dist/observability.d.mts +335 -0
  360. package/dist/observability.d.ts +335 -0
  361. package/dist/observability.mjs +16 -0
  362. package/dist/observability.mjs.map +1 -0
  363. package/dist/params-BALtrRim.d.ts +15 -0
  364. package/dist/params-ry-lxqmy.d.mts +15 -0
  365. package/dist/plugin-BJDf43dc.d.mts +165 -0
  366. package/dist/plugin-BJDf43dc.d.ts +165 -0
  367. package/dist/plugin.cjs +23470 -0
  368. package/dist/plugin.cjs.map +1 -1
  369. package/dist/plugin.d.mts +22 -0
  370. package/dist/plugin.d.ts +22 -0
  371. package/dist/plugin.mjs +8 -7
  372. package/dist/production-runtime-4KKq1AVC.d.mts +79 -0
  373. package/dist/production-runtime-C_B79w2P.d.mts +28 -0
  374. package/dist/production-runtime-DDEM1D2q.d.ts +28 -0
  375. package/dist/production-runtime-DRsWDN2x.d.ts +79 -0
  376. package/dist/query/client.d.mts +61 -0
  377. package/dist/query/client.d.ts +61 -0
  378. package/dist/query/index.d.mts +90 -0
  379. package/dist/query/index.d.ts +90 -0
  380. package/dist/query/parsers.d.mts +25 -0
  381. package/dist/query/parsers.d.ts +25 -0
  382. package/dist/query/server.d.mts +55 -0
  383. package/dist/query/server.d.ts +55 -0
  384. package/dist/request-Dsq4kGW0.d.mts +6 -0
  385. package/dist/request-udtobOLv.d.ts +6 -0
  386. package/dist/request.d.mts +2 -0
  387. package/dist/request.d.ts +2 -0
  388. package/dist/resolver-DJqjLMg_.d.mts +14 -0
  389. package/dist/resolver-IH4RmPEl.d.ts +14 -0
  390. package/dist/route-runtime-DoOHzCAD.d.mts +38 -0
  391. package/dist/route-runtime-DoOHzCAD.d.ts +38 -0
  392. package/dist/router.d.mts +36 -0
  393. package/dist/router.d.ts +36 -0
  394. package/dist/routes.d.mts +224 -0
  395. package/dist/routes.d.ts +224 -0
  396. package/dist/runtime-9nQjVM7X.d.mts +206 -0
  397. package/dist/runtime-Cxpq6xZN.d.mts +27 -0
  398. package/dist/runtime-DgeS2skB.d.ts +206 -0
  399. package/dist/runtime-bv63eUiO.d.ts +27 -0
  400. package/dist/server-action-security.d.mts +43 -0
  401. package/dist/server-action-security.d.ts +43 -0
  402. package/dist/server-fn-client.d.mts +32 -0
  403. package/dist/server-fn-client.d.ts +32 -0
  404. package/dist/server-fn.d.mts +93 -0
  405. package/dist/server-fn.d.ts +93 -0
  406. package/dist/server-plugins.d.mts +55 -0
  407. package/dist/server-plugins.d.ts +55 -0
  408. package/dist/server-query-client.d.mts +50 -0
  409. package/dist/server-query-client.d.ts +50 -0
  410. package/dist/server-query.d.mts +36 -0
  411. package/dist/server-query.d.ts +36 -0
  412. package/dist/server.cjs +731 -447
  413. package/dist/server.cjs.map +1 -1
  414. package/dist/server.d.mts +48 -0
  415. package/dist/server.d.ts +48 -0
  416. package/dist/server.mjs +9 -8
  417. package/dist/server.mjs.map +1 -1
  418. package/dist/storage.d.mts +52 -0
  419. package/dist/storage.d.ts +52 -0
  420. package/dist/testing.d.mts +101 -0
  421. package/dist/testing.d.ts +101 -0
  422. package/dist/transport-BmbGTXA5.d.mts +49 -0
  423. package/dist/transport-BmbGTXA5.d.ts +49 -0
  424. package/dist/types-BMxWr97v.d.mts +81 -0
  425. package/dist/types-BMxWr97v.d.ts +81 -0
  426. package/dist/types-C9N-nk5R.d.mts +53 -0
  427. package/dist/types-C9N-nk5R.d.ts +53 -0
  428. package/dist/types-D1A6-XvH.d.mts +73 -0
  429. package/dist/types-D1A6-XvH.d.ts +73 -0
  430. package/dist/utils-B-cUHwoK.d.ts +23 -0
  431. package/dist/utils-Cm41AefV.d.mts +23 -0
  432. package/dist/version.cjs +1 -1
  433. package/dist/version.cjs.map +1 -1
  434. package/dist/version.d.mts +3 -0
  435. package/dist/version.d.ts +3 -0
  436. package/dist/version.mjs +1 -1
  437. package/dist/vite.cjs +682 -437
  438. package/dist/vite.cjs.map +1 -1
  439. package/dist/vite.d.mts +22 -0
  440. package/dist/vite.d.ts +22 -0
  441. package/dist/vite.mjs +6 -5
  442. package/dist/workflows.d.mts +110 -0
  443. package/dist/workflows.d.ts +110 -0
  444. package/package.json +3 -2
  445. package/types/client.d.ts +1 -1
  446. package/types/image.d.ts +4 -0
  447. package/types/images.d.ts +59 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/request-context.ts","../src/integrations.ts"],"sourcesContent":["type RequestContextCarrier = object;\n\nexport interface SetRequestContextOptions {\n exposeToPage?: boolean;\n}\n\nexport interface RequestContextSnapshotOptions {\n exposedOnly?: boolean;\n}\n\ninterface RequestContextBucket {\n privateData: Map<string, any>;\n exposedData: Map<string, any>;\n}\n\nconst REQUEST_CONTEXT_STORE_KEY = Symbol.for(\"farm.requestContextStore\");\n\ntype GlobalWithRequestContextStore = typeof globalThis & {\n [REQUEST_CONTEXT_STORE_KEY]?: WeakMap<RequestContextCarrier, RequestContextBucket>;\n};\n\nfunction getRequestContextStore() {\n const globalState = globalThis as GlobalWithRequestContextStore;\n if (!globalState[REQUEST_CONTEXT_STORE_KEY]) {\n globalState[REQUEST_CONTEXT_STORE_KEY] = new WeakMap<\n RequestContextCarrier,\n RequestContextBucket\n >();\n }\n\n return globalState[REQUEST_CONTEXT_STORE_KEY]!;\n}\n\nfunction getBucket(target: RequestContextCarrier): RequestContextBucket {\n const requestContextStore = getRequestContextStore();\n let bucket = requestContextStore.get(target);\n if (!bucket) {\n bucket = {\n privateData: new Map<string, any>(),\n exposedData: new Map<string, any>(),\n };\n requestContextStore.set(target, bucket);\n }\n return bucket;\n}\n\nexport function setRequestContext(\n target: RequestContextCarrier,\n key: string,\n value: any,\n options: SetRequestContextOptions = {},\n): void {\n const bucket = getBucket(target);\n bucket.privateData.set(key, value);\n if (options.exposeToPage) {\n bucket.exposedData.set(key, value);\n }\n}\n\nexport function getRequestContext<T = any>(\n target: RequestContextCarrier,\n key: string,\n): T | undefined {\n const requestContextStore = getRequestContextStore();\n const bucket = requestContextStore.get(target);\n return bucket?.privateData.get(key) as T | undefined;\n}\n\nexport function hasRequestContext(target: RequestContextCarrier, key: string): boolean {\n const requestContextStore = getRequestContextStore();\n const bucket = requestContextStore.get(target);\n return bucket?.privateData.has(key) ?? false;\n}\n\nexport function deleteRequestContext(target: RequestContextCarrier, key: string): boolean {\n const requestContextStore = getRequestContextStore();\n const bucket = requestContextStore.get(target);\n if (!bucket) return false;\n const removedPrivate = bucket.privateData.delete(key);\n bucket.exposedData.delete(key);\n return removedPrivate;\n}\n\nexport function clearRequestContext(target: RequestContextCarrier): void {\n const requestContextStore = getRequestContextStore();\n const bucket = requestContextStore.get(target);\n if (!bucket) return;\n bucket.privateData.clear();\n bucket.exposedData.clear();\n}\n\nexport function getRequestContextSnapshot(\n target: RequestContextCarrier,\n options: RequestContextSnapshotOptions = {},\n): Map<string, any> {\n const requestContextStore = getRequestContextStore();\n const bucket = requestContextStore.get(target);\n if (!bucket) return new Map<string, any>();\n if (options.exposedOnly) {\n return new Map(bucket.exposedData);\n }\n return new Map(bucket.privateData);\n}\n","import type { ComponentType, ReactNode } from \"react\";\nimport { api as integrationApi, defineIntegrationAPIOperation } from \"./integration-api\";\nimport type {\n FarmIntegrationAPI,\n FarmIntegrationAPIBodyFormat,\n FarmIntegrationAPIMethod,\n FarmIntegrationAPIOperation,\n FarmIntegrationAPIResponseFormat,\n FarmIntegrationRouteOperationCarrier,\n InferIntegrationAPIFromRoutes,\n} from \"./integration-api\";\nimport type { InferFarmIntegrationOrmClient } from \"./integration-orm\";\nimport type { FarmPlugin, FarmPluginContext, FarmRequestStore } from \"./plugin\";\nimport {\n clearRequestContext,\n deleteRequestContext,\n getRequestContext,\n getRequestContextSnapshot,\n hasRequestContext,\n setRequestContext,\n} from \"./request-context\";\nimport { sendWebResponse } from \"./server/response\";\nimport type { FarmRequest } from \"./types\";\n\nexport { api, defineIntegrationAPI, defineIntegrationAPIOperation } from \"./integration-api\";\nexport type {\n FarmIntegrationAPI,\n FarmIntegrationAPIBodyFormat,\n FarmIntegrationAPIMethod,\n FarmIntegrationAPIOperation,\n FarmIntegrationAPIResponseFormat,\n} from \"./integration-api\";\n\nexport type FarmIntegrationCategory = \"auth\" | \"payment\" | \"monitoring\" | \"logging\" | (string & {});\n\n/** @deprecated Use FarmIntegrationCategory instead. */\nexport type FarmIntegrationSlot = FarmIntegrationCategory;\n\nexport type FarmIntegrationRouteParamValue = string | string[];\nexport type FarmIntegrationRouteParams = Record<string, FarmIntegrationRouteParamValue>;\nexport type FarmIntegrationRouteMethod =\n | FarmIntegrationAPIMethod\n | Lowercase<FarmIntegrationAPIMethod>\n | \"ALL\"\n | \"all\";\nexport type FarmIntegrationRouteInputSource = \"body\" | \"query\";\n\ntype MaybePromise<T> = T | Promise<T>;\n\nexport type FarmIntegrationValidationPathSegment =\n | PropertyKey\n | {\n readonly key: PropertyKey;\n };\n\nexport interface FarmIntegrationRouteInput<TBody = unknown, TQuery = unknown> {\n body?: TBody;\n query?: TQuery;\n}\n\nexport interface FarmIntegrationValidationIssue {\n source: FarmIntegrationRouteInputSource;\n path?: readonly (string | number)[];\n code?: string;\n message: string;\n}\n\nexport interface FarmIntegrationValidationErrorLike {\n issues?: readonly {\n path?: readonly FarmIntegrationValidationPathSegment[];\n code?: string;\n message?: string;\n }[];\n message?: string;\n}\n\nexport type FarmIntegrationValidationResult<TValue> =\n | {\n success: true;\n data: TValue;\n }\n | {\n success: false;\n error: FarmIntegrationValidationErrorLike;\n };\n\nexport type FarmIntegrationStandardValidationResult<TValue> =\n | {\n value: TValue;\n }\n | {\n issues: readonly {\n path?: readonly FarmIntegrationValidationPathSegment[];\n code?: string;\n message: string;\n }[];\n };\n\nexport interface FarmIntegrationInputSchema<TValue = unknown> {\n _output?: TValue;\n parse?(value: unknown): MaybePromise<TValue>;\n safeParse?(value: unknown): MaybePromise<FarmIntegrationValidationResult<TValue>>;\n safeParseAsync?(value: unknown): Promise<FarmIntegrationValidationResult<TValue>>;\n \"~standard\"?: {\n validate(value: unknown): MaybePromise<FarmIntegrationStandardValidationResult<TValue>>;\n types?: {\n output: TValue;\n };\n };\n}\n\nexport interface FarmIntegrationRouteInputSchemas<TBody = unknown, TQuery = unknown> {\n body?: FarmIntegrationInputSchema<TBody>;\n query?: FarmIntegrationInputSchema<TQuery>;\n}\n\n/** @deprecated Use `FarmRequestStore` and access it through `ctx.req`. */\nexport type FarmIntegrationRequestContextStore = FarmRequestStore;\n\nexport const FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY = \"farm.integration.internalDispatch\";\n\nexport type FarmIntegrationRouteDb<TSchema extends FarmIntegrationSchema | undefined> =\n InferFarmIntegrationOrmClient<TSchema>;\n\nexport interface FarmIntegrationRouteStorageArgs<\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n> {\n getClient(): Promise<unknown | undefined>;\n getOrm(): Promise<FarmIntegrationRouteDb<TSchema>>;\n}\n\nexport interface FarmIntegrationRouteArgs<\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n> {\n db: FarmIntegrationRouteDb<TSchema>;\n getDb(): Promise<FarmIntegrationRouteDb<TSchema>>;\n storage: FarmIntegrationRouteStorageArgs<TSchema>;\n}\n\nexport interface FarmIntegrationConfigContext<\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n> {\n key: string;\n integration: FarmIntegration<TSchema, any>;\n appConfig: FarmPluginContext[\"config\"];\n /** Alias for appConfig. */\n config: FarmPluginContext[\"config\"];\n args: FarmIntegrationRouteArgs<TSchema>;\n env: Record<string, string | undefined>;\n isDev: boolean;\n isProd: boolean;\n}\n\nexport interface FarmIntegrationConfigDefinition<\n TConfig = unknown,\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n> {\n schema?: FarmIntegrationInputSchema<TConfig>;\n env?: Record<string, string | readonly string[]>;\n defaults?:\n | Partial<TConfig>\n | ((context: FarmIntegrationConfigContext<TSchema>) => MaybePromise<Partial<TConfig>>);\n input?:\n | Partial<TConfig>\n | ((context: FarmIntegrationConfigContext<TSchema>) => MaybePromise<Partial<TConfig>>);\n resolve?(\n context: FarmIntegrationConfigContext<TSchema>,\n ): MaybePromise<TConfig | Partial<TConfig> | undefined>;\n}\n\nexport type FarmIntegrationConfigInput<\n TConfig = unknown,\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n> = FarmIntegrationInputSchema<TConfig> | FarmIntegrationConfigDefinition<TConfig, TSchema>;\n\nexport type FarmIntegrationLifecycleLogLevel = \"info\" | \"warn\" | \"error\";\n\nexport interface FarmIntegrationLifecycleLogger {\n info(message: string, meta?: Record<string, unknown>): void;\n warn(message: string, meta?: Record<string, unknown>): void;\n error(message: string, meta?: Record<string, unknown>): void;\n}\n\nexport interface FarmIntegrationLifecycleContext<\n TConfig = unknown,\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n> extends FarmIntegrationConfigContext<TSchema> {\n integration: FarmIntegration<TSchema, TConfig>;\n integrationConfig: TConfig;\n log: FarmIntegrationLifecycleLogger;\n reason?: string;\n cleanup(callback?: () => MaybePromise<void>): Promise<void>;\n}\n\nexport type FarmIntegrationLifecycleHook<\n TConfig = unknown,\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n> = (context: FarmIntegrationLifecycleContext<TConfig, TSchema>) => MaybePromise<void>;\n\n/**\n * Small per-call integration metadata. Values received over HTTP are\n * client-controlled and should be validated before authorization decisions.\n */\nexport type FarmIntegrationData = Record<string, unknown>;\n\nexport interface FarmIntegrationHandlerContext<\n TBody = unknown,\n TQuery = unknown,\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n> {\n request: Request;\n requestId: string;\n url: URL;\n pathname: string;\n method: string;\n params: FarmIntegrationRouteParams;\n input: FarmIntegrationRouteInput<TBody, TQuery>;\n args: FarmIntegrationRouteArgs<TSchema>;\n data: FarmIntegrationData;\n integration: {\n category: FarmIntegrationCategory;\n /** @deprecated Use category instead. */\n slot: FarmIntegrationCategory;\n type: string;\n instance: unknown;\n };\n route: {\n kind: \"route\" | \"middleware\";\n path: string;\n methods: readonly string[];\n };\n req: FarmRequestStore;\n /** @deprecated Use `req` instead. */\n requestContext: FarmRequestStore;\n config: FarmPluginContext[\"config\"];\n isDev: boolean;\n isProd: boolean;\n}\n\nexport interface FarmIntegrationRouteHookContext<\n TBody = unknown,\n TQuery = unknown,\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n> extends FarmIntegrationHandlerContext<TBody, TQuery, TSchema> {\n response?: Response;\n}\n\nexport type FarmIntegrationRouteHook<\n TBody = unknown,\n TQuery = unknown,\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n> = {\n bivarianceHack(\n request: Request,\n context: FarmIntegrationRouteHookContext<TBody, TQuery, TSchema>,\n ): Promise<Response | void> | Response | void;\n}[\"bivarianceHack\"];\n\nexport interface FarmIntegrationRoute<\n TBody = unknown,\n TQuery = unknown,\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n> {\n path: string;\n method?: FarmIntegrationRouteMethod;\n methods?: readonly FarmIntegrationRouteMethod[];\n middleware?: readonly FarmIntegrationRouteMiddleware<TSchema>[];\n before?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];\n after?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];\n rawBody?: boolean;\n bodyFormat?: FarmIntegrationAPIBodyFormat;\n body?: FarmIntegrationInputSchema<TBody>;\n query?: FarmIntegrationInputSchema<TQuery>;\n input?: FarmIntegrationRouteInputSchemas<TBody, TQuery>;\n handler(\n request: Request,\n context: FarmIntegrationHandlerContext<TBody, TQuery, TSchema>,\n ): Promise<Response> | Response;\n}\n\nexport interface FarmTypedIntegrationRoute<\n TPath extends string = string,\n TBody = never,\n TQuery = never,\n TResponse = unknown,\n TServer extends boolean = false,\n TMethod extends FarmIntegrationAPIMethod = FarmIntegrationAPIMethod,\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n> extends FarmIntegrationRoute<TBody, TQuery, TSchema> {\n path: TPath;\n method: TMethod;\n __operation: FarmIntegrationAPIOperation<TBody, TQuery, TResponse, TServer, TMethod>;\n}\n\nexport interface FarmIntegrationRouteMiddleware<\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n> {\n handler(\n request: Request,\n context: FarmIntegrationHandlerContext<unknown, unknown, TSchema>,\n ): Promise<Response | void> | Response | void;\n}\n\nexport interface FarmIntegrationMiddleware<\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n> {\n matcher?: string | string[];\n handler(\n request: Request,\n context: FarmIntegrationHandlerContext<unknown, unknown, TSchema>,\n ): Promise<Response | void> | Response | void;\n}\n\nexport interface FarmIntegrationProviderProps {\n children: ReactNode;\n}\n\nexport interface FarmIntegrationProvider {\n name: string;\n type: string;\n props?: Record<string, unknown>;\n component?: ComponentType<FarmIntegrationProviderProps>;\n}\n\nexport interface FarmIntegrationDocumentNavigation {\n matcher: string | readonly string[];\n}\n\nexport type FarmIntegrationSchemaFieldType =\n | \"id\"\n | \"uuid\"\n | \"string\"\n | \"text\"\n | \"boolean\"\n | \"integer\"\n | \"number\"\n | \"datetime\"\n | \"json\"\n | \"enum\";\n\nexport interface FarmIntegrationSchemaReference {\n model: string;\n field: string;\n relation?: \"belongsTo\" | \"hasOne\" | \"hasMany\";\n onDelete?: \"cascade\" | \"restrict\" | \"setNull\" | \"noAction\";\n enforced?: \"db\" | \"app\" | \"none\";\n}\n\nexport interface FarmIntegrationSchemaField {\n type: FarmIntegrationSchemaFieldType;\n name?: string;\n description?: string;\n required?: boolean;\n nullable?: boolean;\n primaryKey?: boolean;\n unique?: boolean;\n index?: boolean;\n list?: boolean;\n default?: unknown;\n values?: readonly string[];\n reference?: FarmIntegrationSchemaReference;\n meta?: Record<string, unknown>;\n}\n\nexport interface FarmIntegrationSchemaConstraint {\n type: \"unique\" | \"index\";\n fields: readonly string[];\n name?: string;\n meta?: Record<string, unknown>;\n}\n\nexport interface FarmIntegrationSchemaModel {\n name?: string;\n description?: string;\n fields: Record<string, FarmIntegrationSchemaField>;\n constraints?: readonly FarmIntegrationSchemaConstraint[];\n meta?: Record<string, unknown>;\n}\n\nexport interface FarmIntegrationSchemaModelExtension {\n name?: string;\n description?: string;\n fields?: Record<string, FarmIntegrationSchemaField>;\n constraints?: readonly FarmIntegrationSchemaConstraint[];\n meta?: Record<string, unknown>;\n}\n\nexport interface FarmIntegrationSchemaModelOverride {\n name?: string;\n description?: string;\n fields?: Record<string, Partial<FarmIntegrationSchemaField>>;\n constraints?: readonly FarmIntegrationSchemaConstraint[];\n meta?: Record<string, unknown>;\n}\n\nexport interface FarmIntegrationSchema {\n models: Record<string, FarmIntegrationSchemaModel>;\n meta?: Record<string, unknown>;\n extend?: Record<string, FarmIntegrationSchemaModelExtension>;\n override?: Record<string, FarmIntegrationSchemaModelOverride>;\n}\n\nexport function defineIntegrationSchema<TSchema extends FarmIntegrationSchema>(\n schema: TSchema,\n): TSchema {\n return schema;\n}\n\nexport type FarmIntegrationLogPhase =\n | \"registered\"\n | \"validate\"\n | \"setup\"\n | \"ready\"\n | \"dispose\"\n | \"request:start\"\n | \"request:end\"\n | \"request:error\";\n\nexport interface FarmIntegrationLogEvent {\n category: FarmIntegrationCategory;\n /** @deprecated Use category instead. */\n slot: FarmIntegrationCategory;\n type: string;\n phase: FarmIntegrationLogPhase;\n route?: {\n kind: \"route\" | \"middleware\";\n path: string;\n methods: readonly string[];\n };\n requestId?: string;\n request?: Request;\n response?: Response;\n error?: unknown;\n durationMs?: number;\n level?: FarmIntegrationLifecycleLogLevel;\n message?: string;\n meta?: Record<string, unknown>;\n context: Map<string, unknown>;\n}\n\nexport type FarmIntegrationLogger = (event: FarmIntegrationLogEvent) => void | Promise<void>;\n\nexport interface FarmIntegration<\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n TConfig = unknown,\n> {\n readonly kind: \"farm-integration\";\n category: FarmIntegrationCategory;\n /** @deprecated Use category instead. */\n slot?: FarmIntegrationCategory;\n type: string;\n instance: unknown;\n /** Set to false when a platform adapter owns this integration's production routes. */\n serverRuntime?: boolean;\n api?: FarmIntegrationAPI;\n schema?: TSchema;\n config?: FarmIntegrationConfigInput<TConfig, TSchema>;\n validate?: FarmIntegrationLifecycleHook<TConfig, TSchema>;\n setup?: FarmIntegrationLifecycleHook<TConfig, TSchema>;\n ready?: FarmIntegrationLifecycleHook<TConfig, TSchema>;\n dispose?: FarmIntegrationLifecycleHook<TConfig, TSchema>;\n log?: FarmIntegrationLogger;\n routes?: readonly FarmIntegrationRoute<any, any, TSchema>[];\n endpoints?: FarmIntegrationEndpoints<TSchema>;\n middleware?: readonly FarmIntegrationMiddleware<TSchema>[];\n providers?: readonly FarmIntegrationProvider[];\n documentNavigations?: readonly FarmIntegrationDocumentNavigation[];\n plugins?: readonly FarmPlugin[];\n}\n\nexport type FarmIntegrationsUserConfig = Record<string, FarmIntegration<any, any> | undefined>;\n\nconst FARM_INTEGRATION_PLUGIN_SERVER_RUNTIME = Symbol.for(\n \"@farm.js/core/integration-plugin-server-runtime\",\n);\n\n/** @internal Identifies lifecycle plugins owned by platform-managed integrations. */\nexport function getFarmIntegrationPluginServerRuntime(plugin: FarmPlugin): boolean | undefined {\n const value = (plugin as FarmPlugin & Record<symbol, unknown>)[\n FARM_INTEGRATION_PLUGIN_SERVER_RUNTIME\n ];\n return typeof value === \"boolean\" ? value : undefined;\n}\n\ntype IntegrationRouteBuilderOptions<\n TBody,\n TQuery,\n TServer extends boolean,\n TSchema extends FarmIntegrationSchema | undefined,\n> = {\n middleware?: readonly FarmIntegrationRouteMiddleware<TSchema>[];\n before?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];\n after?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];\n rawBody?: boolean;\n headers?: Record<string, string>;\n credentials?: RequestCredentials;\n bodyFormat?: FarmIntegrationAPIBodyFormat;\n responseFormat?: FarmIntegrationAPIResponseFormat;\n isServer?: TServer;\n body?: FarmIntegrationInputSchema<TBody>;\n query?: FarmIntegrationInputSchema<TQuery>;\n input?: FarmIntegrationRouteInputSchemas<TBody, TQuery>;\n handler(\n request: Request,\n context: FarmIntegrationHandlerContext<TBody, TQuery, TSchema>,\n ): Promise<Response> | Response;\n};\n\nfunction defineTypedIntegrationRoute<\n TPath extends string,\n TBody,\n TQuery,\n TResponse,\n TServer extends boolean,\n TMethod extends FarmIntegrationAPIMethod,\n TSchema extends FarmIntegrationSchema | undefined,\n>(\n method: TMethod,\n path: TPath,\n input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>,\n): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, TMethod, TSchema> {\n return {\n path,\n method,\n middleware: input.middleware,\n before: input.before,\n after: input.after,\n rawBody: input.rawBody,\n bodyFormat: input.bodyFormat,\n input: normalizeIntegrationRouteInputSchemas(input),\n handler: input.handler,\n __operation: defineIntegrationAPIOperation<TBody, TQuery, TResponse, TServer, TMethod>({\n path,\n method,\n bodyFormat: input.bodyFormat,\n responseFormat: input.responseFormat,\n headers: input.headers,\n credentials: input.credentials,\n isServer: input.isServer,\n }),\n };\n}\n\nexport interface FarmIntegrationRouteFactory<\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n> {\n get<TPath extends string, TResponse = unknown, TQuery = never, TServer extends boolean = false>(\n path: TPath,\n input: Omit<IntegrationRouteBuilderOptions<never, TQuery, TServer, TSchema>, \"bodyFormat\">,\n ): FarmTypedIntegrationRoute<TPath, never, TQuery, TResponse, TServer, \"GET\", TSchema>;\n post<\n TPath extends string,\n TBody = never,\n TResponse = unknown,\n TQuery = never,\n TServer extends boolean = false,\n >(\n path: TPath,\n input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>,\n ): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, \"POST\", TSchema>;\n put<\n TPath extends string,\n TBody = never,\n TResponse = unknown,\n TQuery = never,\n TServer extends boolean = false,\n >(\n path: TPath,\n input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>,\n ): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, \"PUT\", TSchema>;\n patch<\n TPath extends string,\n TBody = never,\n TResponse = unknown,\n TQuery = never,\n TServer extends boolean = false,\n >(\n path: TPath,\n input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>,\n ): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, \"PATCH\", TSchema>;\n delete<\n TPath extends string,\n TBody = never,\n TResponse = unknown,\n TQuery = never,\n TServer extends boolean = false,\n >(\n path: TPath,\n input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>,\n ): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, \"DELETE\", TSchema>;\n options<\n TPath extends string,\n TResponse = unknown,\n TQuery = never,\n TServer extends boolean = false,\n >(\n path: TPath,\n input: Omit<IntegrationRouteBuilderOptions<never, TQuery, TServer, TSchema>, \"bodyFormat\">,\n ): FarmTypedIntegrationRoute<TPath, never, TQuery, TResponse, TServer, \"OPTIONS\", TSchema>;\n head<TPath extends string, TResponse = unknown, TQuery = never, TServer extends boolean = false>(\n path: TPath,\n input: Omit<IntegrationRouteBuilderOptions<never, TQuery, TServer, TSchema>, \"bodyFormat\">,\n ): FarmTypedIntegrationRoute<TPath, never, TQuery, TResponse, TServer, \"HEAD\", TSchema>;\n}\n\nexport interface FarmIntegrationRoutesFactoryContext<\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n> {\n route: FarmIntegrationRouteFactory<TSchema>;\n integrationRoute: FarmIntegrationRouteFactory<TSchema>;\n}\n\nexport type FarmIntegrationRoutesFactory<\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n> = (\n context: FarmIntegrationRoutesFactoryContext<TSchema>,\n) => readonly FarmIntegrationRoute<any, any, TSchema>[];\n\nexport type FarmIntegrationEndpointValue<\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n> =\n | FarmIntegrationRoute<any, any, TSchema>\n | readonly FarmIntegrationEndpointValue<TSchema>[]\n | {\n readonly [key: string]: FarmIntegrationEndpointValue<TSchema> | undefined;\n };\n\nexport type FarmIntegrationEndpoints<\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n> = {\n readonly [key: string]: FarmIntegrationEndpointValue<TSchema> | undefined;\n};\n\nexport interface FarmIntegrationEndpointsFactoryContext<\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n> extends FarmIntegrationRoutesFactoryContext<TSchema> {\n endpoint: FarmIntegrationRouteFactory<TSchema>;\n}\n\nexport type FarmIntegrationEndpointsFactory<\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n> = (context: FarmIntegrationEndpointsFactoryContext<TSchema>) => FarmIntegrationEndpoints<TSchema>;\n\nfunction createIntegrationRouteFactory<\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n>(): FarmIntegrationRouteFactory<TSchema> {\n return {\n get<TPath extends string, TResponse = unknown, TQuery = never, TServer extends boolean = false>(\n path: TPath,\n input: Omit<IntegrationRouteBuilderOptions<never, TQuery, TServer, TSchema>, \"bodyFormat\">,\n ) {\n return defineTypedIntegrationRoute<TPath, never, TQuery, TResponse, TServer, \"GET\", TSchema>(\n \"GET\",\n path,\n input,\n );\n },\n post<\n TPath extends string,\n TBody = never,\n TResponse = unknown,\n TQuery = never,\n TServer extends boolean = false,\n >(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>) {\n return defineTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, \"POST\", TSchema>(\n \"POST\",\n path,\n {\n bodyFormat: \"json\",\n ...input,\n },\n );\n },\n put<\n TPath extends string,\n TBody = never,\n TResponse = unknown,\n TQuery = never,\n TServer extends boolean = false,\n >(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>) {\n return defineTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, \"PUT\", TSchema>(\n \"PUT\",\n path,\n {\n bodyFormat: \"json\",\n ...input,\n },\n );\n },\n patch<\n TPath extends string,\n TBody = never,\n TResponse = unknown,\n TQuery = never,\n TServer extends boolean = false,\n >(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>) {\n return defineTypedIntegrationRoute<\n TPath,\n TBody,\n TQuery,\n TResponse,\n TServer,\n \"PATCH\",\n TSchema\n >(\"PATCH\", path, {\n bodyFormat: \"json\",\n ...input,\n });\n },\n delete<\n TPath extends string,\n TBody = never,\n TResponse = unknown,\n TQuery = never,\n TServer extends boolean = false,\n >(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>) {\n return defineTypedIntegrationRoute<\n TPath,\n TBody,\n TQuery,\n TResponse,\n TServer,\n \"DELETE\",\n TSchema\n >(\"DELETE\", path, {\n bodyFormat: \"json\",\n ...input,\n });\n },\n options<\n TPath extends string,\n TResponse = unknown,\n TQuery = never,\n TServer extends boolean = false,\n >(\n path: TPath,\n input: Omit<IntegrationRouteBuilderOptions<never, TQuery, TServer, TSchema>, \"bodyFormat\">,\n ) {\n return defineTypedIntegrationRoute<\n TPath,\n never,\n TQuery,\n TResponse,\n TServer,\n \"OPTIONS\",\n TSchema\n >(\"OPTIONS\", path, input);\n },\n head<\n TPath extends string,\n TResponse = unknown,\n TQuery = never,\n TServer extends boolean = false,\n >(\n path: TPath,\n input: Omit<IntegrationRouteBuilderOptions<never, TQuery, TServer, TSchema>, \"bodyFormat\">,\n ) {\n return defineTypedIntegrationRoute<TPath, never, TQuery, TResponse, TServer, \"HEAD\", TSchema>(\n \"HEAD\",\n path,\n input,\n );\n },\n };\n}\n\nexport function createIntegrationRoute<\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n>(_schema?: TSchema): FarmIntegrationRouteFactory<TSchema> {\n return createIntegrationRouteFactory<TSchema>();\n}\n\nexport const integrationRoute = createIntegrationRouteFactory<undefined>();\n\ntype RegisteredIntegrationRuntime = {\n integration: FarmIntegration;\n config: FarmPluginContext[\"config\"];\n isDev: boolean;\n isProd: boolean;\n};\n\nconst INTEGRATION_RUNTIME_REGISTRY_KEY = Symbol.for(\"farm.integrationRuntimeRegistry\");\nconst INTEGRATION_REQUEST_DISPATCHER_KEY = Symbol.for(\"farm.integrationRequestDispatcher\");\n\ntype IntegrationRequestDispatcher = (\n runtime: RegisteredIntegrationRuntime,\n request: Request,\n options?: { currentRequest?: Request },\n) => Promise<Response | null>;\n\ntype GlobalWithIntegrationRuntimeRegistry = typeof globalThis & {\n [INTEGRATION_RUNTIME_REGISTRY_KEY]?: Map<string, RegisteredIntegrationRuntime>;\n [INTEGRATION_REQUEST_DISPATCHER_KEY]?: IntegrationRequestDispatcher;\n};\n\nfunction getIntegrationRuntimeRegistry() {\n const globalState = globalThis as GlobalWithIntegrationRuntimeRegistry;\n if (!globalState[INTEGRATION_RUNTIME_REGISTRY_KEY]) {\n globalState[INTEGRATION_RUNTIME_REGISTRY_KEY] = new Map<string, RegisteredIntegrationRuntime>();\n }\n\n return globalState[INTEGRATION_RUNTIME_REGISTRY_KEY]!;\n}\n\ntype FarmIntegrationRoutesInput<\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n> = readonly FarmIntegrationRoute<any, any, TSchema>[] | FarmIntegrationRoutesFactory<TSchema>;\n\ntype FarmIntegrationEndpointsInput<\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n> = FarmIntegrationEndpoints<TSchema> | FarmIntegrationEndpointsFactory<TSchema>;\n\ntype FarmIntegrationInput<\n TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined,\n TConfig = unknown,\n> = Omit<\n FarmIntegration<TSchema, TConfig>,\n \"kind\" | \"category\" | \"slot\" | \"config\" | \"routes\" | \"endpoints\"\n> & {\n config?: FarmIntegrationConfigInput<TConfig, TSchema>;\n routes?: FarmIntegrationRoutesInput<TSchema>;\n endpoints?: FarmIntegrationEndpointsInput<TSchema>;\n} & (\n | {\n category: FarmIntegrationCategory;\n slot?: FarmIntegrationCategory;\n }\n | {\n category?: FarmIntegrationCategory;\n slot: FarmIntegrationCategory;\n }\n );\n\ntype FarmIntegrationCategoryInput =\n | {\n category: FarmIntegrationCategory;\n slot?: FarmIntegrationCategory;\n }\n | {\n category?: FarmIntegrationCategory;\n slot: FarmIntegrationCategory;\n };\n\ntype FarmIntegrationShapeForInference = FarmIntegrationCategoryInput & {\n api?: FarmIntegrationAPI;\n schema?: FarmIntegrationSchema;\n config?: unknown;\n routes?: unknown;\n endpoints?: unknown;\n};\n\ntype ExtractIntegrationSchema<TIntegration> = TIntegration extends {\n schema: infer TSchema extends FarmIntegrationSchema;\n}\n ? TSchema\n : undefined;\n\ntype ResolveIntegrationRoutesInput<TRoutes, TSchema extends FarmIntegrationSchema | undefined> =\n TRoutes extends FarmIntegrationRoutesFactory<TSchema> ? ReturnType<TRoutes> : TRoutes;\n\ntype ResolveIntegrationEndpointsInput<\n TEndpoints,\n TSchema extends FarmIntegrationSchema | undefined,\n> =\n TEndpoints extends FarmIntegrationEndpointsFactory<TSchema> ? ReturnType<TEndpoints> : TEndpoints;\n\ntype ExtractIntegrationRoutesFromRoutesInput<\n TRoutes,\n TSchema extends FarmIntegrationSchema | undefined,\n> =\n ResolveIntegrationRoutesInput<TRoutes, TSchema> extends readonly (infer TRoute)[]\n ? TRoute\n : never;\n\ntype ExtractIntegrationRoutesFromEndpointValue<TValue> =\n TValue extends FarmIntegrationRouteOperationCarrier<string, any>\n ? TValue\n : TValue extends readonly (infer TItem)[]\n ? ExtractIntegrationRoutesFromEndpointValue<TItem>\n : TValue extends object\n ? ExtractIntegrationRoutesFromEndpointValue<TValue[keyof TValue]>\n : never;\n\ntype ExtractIntegrationRoutesFromEndpointsInput<\n TEndpoints,\n TSchema extends FarmIntegrationSchema | undefined,\n> = ExtractIntegrationRoutesFromEndpointValue<\n ResolveIntegrationEndpointsInput<TEndpoints, TSchema>\n>;\n\ntype ExtractIntegrationRouteUnion<TIntegration, TSchema extends FarmIntegrationSchema | undefined> =\n | (TIntegration extends { routes: infer TRoutes }\n ? ExtractIntegrationRoutesFromRoutesInput<TRoutes, TSchema>\n : never)\n | (TIntegration extends { endpoints: infer TEndpoints }\n ? ExtractIntegrationRoutesFromEndpointsInput<TEndpoints, TSchema>\n : never);\n\ntype ExtractDefinedIntegrationRoutes<\n TIntegration,\n TSchema extends FarmIntegrationSchema | undefined,\n> = [ExtractIntegrationRouteUnion<TIntegration, TSchema>] extends [never]\n ? undefined\n : readonly ExtractIntegrationRouteUnion<TIntegration, TSchema>[];\n\ntype ExtractDefinedIntegrationEndpoints<\n TIntegration,\n TSchema extends FarmIntegrationSchema | undefined,\n> = TIntegration extends { endpoints: infer TEndpoints }\n ? ResolveIntegrationEndpointsInput<TEndpoints, TSchema>\n : undefined;\n\ntype ExtractIntegrationAPIRoutes<\n TIntegration,\n TSchema extends FarmIntegrationSchema | undefined,\n> = Extract<\n ExtractIntegrationRouteUnion<TIntegration, TSchema>,\n FarmIntegrationRouteOperationCarrier<string, any>\n>;\n\ntype ExtractIntegrationCategory<TIntegration extends FarmIntegrationCategoryInput> =\n TIntegration extends {\n category: infer TCategory extends FarmIntegrationCategory;\n }\n ? TCategory\n : TIntegration extends { slot: infer TSlot extends FarmIntegrationCategory }\n ? TSlot\n : FarmIntegrationCategory;\n\ntype ExtractDerivedIntegrationAPI<\n TIntegration extends FarmIntegrationShapeForInference,\n TSchema extends FarmIntegrationSchema | undefined = ExtractIntegrationSchema<TIntegration>,\n> = TIntegration extends { api: infer TAPI extends FarmIntegrationAPI }\n ? TAPI\n : [ExtractIntegrationAPIRoutes<TIntegration, TSchema>] extends [never]\n ? FarmIntegrationAPI | undefined\n : InferIntegrationAPIFromRoutes<readonly ExtractIntegrationAPIRoutes<TIntegration, TSchema>[]>;\n\nexport type DefinedIntegration<\n TIntegration extends FarmIntegrationShapeForInference,\n TSchema extends FarmIntegrationSchema | undefined = ExtractIntegrationSchema<TIntegration>,\n> = Omit<TIntegration, \"kind\" | \"category\" | \"slot\" | \"api\" | \"routes\" | \"endpoints\"> & {\n readonly kind: \"farm-integration\";\n category: ExtractIntegrationCategory<TIntegration>;\n slot: ExtractIntegrationCategory<TIntegration>;\n routes: ExtractDefinedIntegrationRoutes<TIntegration, TSchema>;\n endpoints: ExtractDefinedIntegrationEndpoints<TIntegration, TSchema>;\n api: ExtractDerivedIntegrationAPI<TIntegration, TSchema>;\n};\n\nfunction isIntegrationEndpointRoute(value: unknown): value is FarmIntegrationRoute {\n return (\n !!value &&\n typeof value === \"object\" &&\n typeof (value as { path?: unknown }).path === \"string\" &&\n typeof (value as { handler?: unknown }).handler === \"function\"\n );\n}\n\nfunction flattenIntegrationEndpoints(\n endpoints: FarmIntegrationEndpointValue | FarmIntegrationEndpoints | undefined,\n): FarmIntegrationRoute[] {\n if (!endpoints) {\n return [];\n }\n\n if (Array.isArray(endpoints)) {\n return endpoints.flatMap((endpoint) => flattenIntegrationEndpoints(endpoint));\n }\n\n if (isIntegrationEndpointRoute(endpoints)) {\n return [endpoints];\n }\n\n if (typeof endpoints === \"object\") {\n return Object.values(endpoints).flatMap((endpoint) => flattenIntegrationEndpoints(endpoint));\n }\n\n return [];\n}\n\nexport function defineIntegration<\n const TSchema extends FarmIntegrationSchema | undefined,\n const TConfig,\n TIntegration extends FarmIntegrationInput<TSchema, TConfig>,\n>(\n integration: TIntegration & FarmIntegrationInput<TSchema, TConfig>,\n): DefinedIntegration<TIntegration, TSchema>;\nexport function defineIntegration<\n const TSchema extends FarmIntegrationSchema | undefined,\n const TConfig,\n TIntegration extends FarmIntegrationInput<TSchema, TConfig>,\n>(\n integration: TIntegration & FarmIntegrationInput<TSchema, TConfig>,\n): DefinedIntegration<TIntegration, TSchema> {\n const category = integration.category ?? integration.slot;\n\n if (!category) {\n throw new Error(\"Integration category is required.\");\n }\n\n if (integration.category && integration.slot && integration.category !== integration.slot) {\n throw new Error(\"Integration category and slot must match when both are provided.\");\n }\n\n const routeFactory = createIntegrationRoute(integration.schema);\n const routes =\n typeof integration.routes === \"function\"\n ? integration.routes({\n route: routeFactory,\n integrationRoute: routeFactory,\n })\n : integration.routes;\n const endpoints =\n typeof integration.endpoints === \"function\"\n ? integration.endpoints({\n endpoint: routeFactory,\n route: routeFactory,\n integrationRoute: routeFactory,\n })\n : integration.endpoints;\n const endpointRoutes = flattenIntegrationEndpoints(endpoints);\n const allRoutes =\n routes?.length || endpointRoutes.length\n ? ([...(routes || []), ...endpointRoutes] as readonly FarmIntegrationRoute[])\n : undefined;\n\n const derivedApi =\n integration.api ||\n (allRoutes?.length\n ? integrationApi.fromRoutes(\n allRoutes as unknown as ReadonlyArray<{\n path: string;\n __operation: FarmIntegrationAPIOperation<any, any, any, any, any>;\n }>,\n )\n : undefined);\n\n return {\n kind: \"farm-integration\",\n ...integration,\n endpoints,\n routes: allRoutes,\n api: derivedApi,\n category,\n slot: category,\n } as unknown as DefinedIntegration<TIntegration, TSchema>;\n}\n\nexport function isFarmIntegration(value: unknown): value is FarmIntegration {\n return (\n !!value && typeof value === \"object\" && (value as FarmIntegration).kind === \"farm-integration\"\n );\n}\n\nexport function resolveIntegrationPlugins(\n integrations: FarmIntegrationsUserConfig | undefined,\n): FarmPlugin[] {\n if (!integrations) {\n return [];\n }\n\n const plugins: FarmPlugin[] = [];\n for (const [key, integration] of Object.entries(integrations)) {\n if (!integration || !isFarmIntegration(integration)) {\n continue;\n }\n\n plugins.push(createIntegrationPlugin(key, integration));\n\n if (integration.plugins?.length) {\n plugins.push(...integration.plugins);\n }\n }\n\n return plugins;\n}\n\nexport function getIntegrationProviders(\n integrations: FarmIntegrationsUserConfig | undefined,\n): Array<Pick<FarmIntegrationProvider, \"name\" | \"type\" | \"props\">> {\n if (!integrations) {\n return [];\n }\n\n const providers: Array<Pick<FarmIntegrationProvider, \"name\" | \"type\" | \"props\">> = [];\n for (const integration of Object.values(integrations)) {\n if (!integration || !isFarmIntegration(integration) || !integration.providers?.length) {\n continue;\n }\n\n for (const provider of integration.providers) {\n providers.push({\n name: provider.name,\n type: provider.type,\n props: provider.props,\n });\n }\n }\n\n return providers;\n}\n\nexport function getIntegrationDocumentNavigationMatchers(\n integrations: FarmIntegrationsUserConfig | undefined,\n): string[] {\n if (!integrations) {\n return [];\n }\n\n const matchers: string[] = [];\n for (const integration of Object.values(integrations)) {\n if (\n !integration ||\n !isFarmIntegration(integration) ||\n !integration.documentNavigations?.length\n ) {\n continue;\n }\n\n for (const navigation of integration.documentNavigations) {\n const items = Array.isArray(navigation.matcher) ? navigation.matcher : [navigation.matcher];\n\n for (const item of items) {\n matchers.push(item);\n }\n }\n }\n\n return matchers;\n}\n\nexport function getIntegrationSchemas(\n integrations: FarmIntegrationsUserConfig | undefined,\n): Record<string, FarmIntegrationSchema> {\n if (!integrations) {\n return {};\n }\n\n const schemaEntries = Object.entries(integrations)\n .map(([key, integration]) => {\n const schema = integration && isFarmIntegration(integration) ? integration.schema : undefined;\n return schema ? ([key, schema] as const) : null;\n })\n .filter((value): value is readonly [string, FarmIntegrationSchema] => value !== null);\n\n return Object.fromEntries(schemaEntries);\n}\n\nexport function getRegisteredIntegrationRuntime(\n key: string,\n): RegisteredIntegrationRuntime | undefined {\n return getIntegrationRuntimeRegistry().get(key);\n}\n\nexport function getRegisteredIntegrations(): Record<string, FarmIntegration> {\n return Object.fromEntries(\n Array.from(getIntegrationRuntimeRegistry().entries()).map(([key, runtime]) => [\n key,\n runtime.integration,\n ]),\n );\n}\n\nexport function getRegisteredIntegrationSchemas(): Record<string, FarmIntegrationSchema> {\n return getIntegrationSchemas(getRegisteredIntegrations());\n}\n\nexport function matchIntegrationRoute(\n integrations: FarmIntegrationsUserConfig | undefined,\n input: {\n pathname: string;\n method?: string;\n },\n): {\n key: string;\n integration: FarmIntegration;\n route: {\n path: string;\n methods: readonly string[];\n };\n params: FarmIntegrationRouteParams;\n} | null {\n if (!integrations) {\n return null;\n }\n\n for (const [key, integration] of Object.entries(integrations)) {\n if (!integration || !isFarmIntegration(integration)) {\n continue;\n }\n\n const routes = normalizeIntegrationRoutes(integration.routes || []);\n\n for (const route of routes) {\n if (!matchesMethod(route.methods, input.method)) {\n continue;\n }\n\n const params = extractPathParams(route.path, input.pathname);\n if (!params) {\n continue;\n }\n\n return {\n key,\n integration,\n route: {\n path: route.path,\n methods: route.methods,\n },\n params,\n };\n }\n }\n\n return null;\n}\n\nexport function matchRegisteredIntegrationRoute(input: { pathname: string; method?: string }): {\n key: string;\n integration: FarmIntegration;\n route: {\n path: string;\n methods: readonly string[];\n };\n params: FarmIntegrationRouteParams;\n} | null {\n return matchIntegrationRoute(getRegisteredIntegrations(), input);\n}\n\nfunction createClientSafeIntegrationAPI(\n api: FarmIntegrationAPI | undefined,\n): FarmIntegrationAPI | undefined {\n if (!api) {\n return undefined;\n }\n\n const entries = Object.entries(api as Record<string, unknown>).map(([key, value]) => {\n if (\n value &&\n typeof value === \"object\" &&\n (value as FarmIntegrationAPIOperation<any, any, any, any, any>).kind ===\n \"farm-integration-api-operation\"\n ) {\n const operation = value as FarmIntegrationAPIOperation<any, any, any, any, any>;\n return [\n key,\n defineIntegrationAPIOperation({\n path: operation.path,\n method: operation.method,\n bodyFormat: operation.bodyFormat,\n responseFormat: operation.responseFormat,\n credentials: operation.credentials,\n isServer: operation.isServer,\n }),\n ];\n }\n\n if (value && typeof value === \"object\") {\n return [key, createClientSafeIntegrationAPI(value as FarmIntegrationAPI)];\n }\n\n return [key, value];\n });\n\n return Object.fromEntries(entries) as FarmIntegrationAPI;\n}\n\nexport function getRegisteredIntegrationAPIManifest(): Record<string, FarmIntegrationAPI> {\n const manifestEntries = Object.entries(getRegisteredIntegrations())\n .map(([key, integration]) => {\n const api = createClientSafeIntegrationAPI(integration.api);\n return api ? ([key, api] as const) : null;\n })\n .filter((value): value is readonly [string, FarmIntegrationAPI] => value !== null);\n\n return Object.fromEntries(manifestEntries);\n}\n\ntype IntegrationLifecycleCleanup = () => MaybePromise<void>;\n\nfunction getIntegrationRuntimeEnv(): Record<string, string | undefined> {\n return typeof process !== \"undefined\" ? process.env : {};\n}\n\nfunction isIntegrationConfigDefinition(\n value: unknown,\n): value is FarmIntegrationConfigDefinition<unknown> {\n return (\n !!value &&\n typeof value === \"object\" &&\n (\"schema\" in value ||\n \"env\" in value ||\n \"defaults\" in value ||\n \"input\" in value ||\n \"resolve\" in value)\n );\n}\n\nfunction mergeIntegrationConfigValue(current: unknown, next: unknown): unknown {\n if (next === undefined) {\n return current;\n }\n\n if (isPlainIntegrationConfigObject(current) && isPlainIntegrationConfigObject(next)) {\n return {\n ...current,\n ...next,\n };\n }\n\n return next;\n}\n\nfunction isPlainIntegrationConfigObject(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === \"object\" && !Array.isArray(value);\n}\n\nasync function resolveIntegrationConfigPart<TValue>(\n value: TValue | ((context: FarmIntegrationConfigContext) => MaybePromise<TValue>) | undefined,\n context: FarmIntegrationConfigContext,\n): Promise<TValue | undefined> {\n if (typeof value === \"function\") {\n return (value as (context: FarmIntegrationConfigContext) => MaybePromise<TValue>)(context);\n }\n\n return value;\n}\n\nfunction resolveIntegrationEnvConfig(\n env: Record<string, string | readonly string[]> | undefined,\n): Record<string, string> | undefined {\n if (!env) {\n return undefined;\n }\n\n const runtimeEnv = getIntegrationRuntimeEnv();\n const config: Record<string, string> = {};\n\n for (const [key, names] of Object.entries(env)) {\n const envNames = Array.isArray(names) ? names : [names];\n const value = envNames.map((name) => runtimeEnv[name]).find((entry) => entry !== undefined);\n if (value !== undefined) {\n config[key] = value;\n }\n }\n\n return config;\n}\n\nasync function parseIntegrationConfigSchema<TConfig>(\n integration: FarmIntegration<any, any>,\n schema: FarmIntegrationInputSchema<TConfig>,\n value: unknown,\n): Promise<TConfig> {\n const parser = schema.safeParseAsync || schema.safeParse;\n if (parser) {\n const result = await parser.call(schema, value);\n if (result.success) {\n return result.data;\n }\n\n throw createIntegrationConfigValidationError(integration, result.error);\n }\n\n if (schema[\"~standard\"]?.validate) {\n const result = await schema[\"~standard\"].validate(value);\n if (\"value\" in result) {\n return result.value;\n }\n\n throw createIntegrationConfigValidationError(integration, {\n issues: result.issues,\n });\n }\n\n if (schema.parse) {\n try {\n return await schema.parse(value);\n } catch (error) {\n throw createIntegrationConfigValidationError(\n integration,\n normalizeIntegrationValidationError(error),\n );\n }\n }\n\n throw new Error(\n `Integration \"${integration.type}\" config schema must expose safeParse, safeParseAsync, parse, or ~standard.validate.`,\n );\n}\n\nfunction createIntegrationConfigValidationError(\n integration: FarmIntegration<any, any>,\n error: FarmIntegrationValidationErrorLike,\n) {\n const issues =\n Array.isArray(error.issues) && error.issues.length > 0\n ? error.issues\n .map((issue) => {\n const normalizedPath = normalizeIntegrationValidationPath(issue.path);\n const path = normalizedPath.length ? `${normalizedPath.join(\".\")}: ` : \"\";\n return `${path}${issue.message || \"Invalid config\"}`;\n })\n .join(\"; \")\n : error.message || \"Invalid config\";\n\n return new Error(`Integration \"${integration.type}\" config validation failed: ${issues}`);\n}\n\nasync function resolveIntegrationConfig<TConfig>(\n integration: FarmIntegration<any, TConfig>,\n context: FarmIntegrationConfigContext,\n): Promise<TConfig> {\n const config = integration.config;\n if (!config) {\n return undefined as TConfig;\n }\n\n if (!isIntegrationConfigDefinition(config)) {\n return parseIntegrationConfigSchema(integration, config, {});\n }\n\n let value: unknown = {};\n value = mergeIntegrationConfigValue(\n value,\n await resolveIntegrationConfigPart(config.defaults, context),\n );\n value = mergeIntegrationConfigValue(value, resolveIntegrationEnvConfig(config.env));\n value = mergeIntegrationConfigValue(\n value,\n await resolveIntegrationConfigPart(config.input, context),\n );\n value = mergeIntegrationConfigValue(value, await config.resolve?.(context));\n\n return config.schema\n ? parseIntegrationConfigSchema(integration, config.schema, value)\n : (value as TConfig);\n}\n\nfunction createIntegrationLifecycleLogger(\n integration: FarmIntegration<any, any>,\n phase: FarmIntegrationLogPhase,\n): FarmIntegrationLifecycleLogger {\n const write = (\n level: FarmIntegrationLifecycleLogLevel,\n message: string,\n meta?: Record<string, unknown>,\n ) => {\n if (!integration.log) {\n return;\n }\n\n void Promise.resolve(\n integration.log({\n category: integration.category,\n slot: integration.category,\n type: integration.type,\n phase,\n level,\n message,\n meta,\n context: new Map(),\n }),\n ).catch(() => {});\n };\n\n return {\n info(message, meta) {\n write(\"info\", message, meta);\n },\n warn(message, meta) {\n write(\"warn\", message, meta);\n },\n error(message, meta) {\n write(\"error\", message, meta);\n },\n };\n}\n\nconst INTEGRATION_DATA_HEADER = \"x-farm-integration-data\";\nconst INTEGRATION_DATA_HEADER_MAX_LENGTH = 16 * 1024;\nconst BLOCKED_INTEGRATION_DATA_KEYS = new Set([\"__proto__\", \"constructor\", \"prototype\"]);\n\nfunction isFarmIntegrationData(value: unknown): value is FarmIntegrationData {\n return !!value && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction isPlainIntegrationDataObject(value: unknown): value is Record<string, unknown> {\n if (!isFarmIntegrationData(value)) {\n return false;\n }\n\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n\nfunction sanitizeIntegrationDataValue(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map((item) => sanitizeIntegrationDataValue(item));\n }\n\n if (!isPlainIntegrationDataObject(value)) {\n return value;\n }\n\n const sanitized: Record<string, unknown> = {};\n for (const [key, item] of Object.entries(value)) {\n if (BLOCKED_INTEGRATION_DATA_KEYS.has(key)) {\n continue;\n }\n\n sanitized[key] = sanitizeIntegrationDataValue(item);\n }\n\n return sanitized;\n}\n\nfunction normalizeIntegrationData(value: FarmIntegrationData | undefined): FarmIntegrationData {\n if (!isFarmIntegrationData(value)) {\n return {};\n }\n\n const sanitized = sanitizeIntegrationDataValue(value);\n return isFarmIntegrationData(sanitized) ? sanitized : {};\n}\n\nfunction getIntegrationDataHeaderByteLength(value: string): number {\n return new TextEncoder().encode(value).byteLength;\n}\n\nfunction parseIntegrationDataHeader(request: Request): FarmIntegrationData {\n const raw = request.headers.get(INTEGRATION_DATA_HEADER);\n if (!raw) {\n return {};\n }\n\n if (getIntegrationDataHeaderByteLength(raw) > INTEGRATION_DATA_HEADER_MAX_LENGTH) {\n return {};\n }\n\n try {\n const value = JSON.parse(raw);\n return normalizeIntegrationData(value);\n } catch {\n return {};\n }\n}\n\nfunction resolveIntegrationData(request: Request, data?: FarmIntegrationData): FarmIntegrationData {\n return {\n ...parseIntegrationDataHeader(request),\n ...normalizeIntegrationData(data),\n };\n}\n\nfunction createIntegrationPlugin(integrationKey: string, integration: FarmIntegration): FarmPlugin {\n const routes = normalizeIntegrationRoutes(integration.routes || []);\n const middleware = [...(integration.middleware || [])];\n const cleanupCallbacks: IntegrationLifecycleCleanup[] = [];\n let integrationConfigPromise: Promise<unknown> | undefined;\n\n const runCleanup = async () => {\n const callbacks = cleanupCallbacks.splice(0).reverse();\n for (const callback of callbacks) {\n await callback();\n }\n };\n\n const createLifecycleContext = async (\n context: FarmPluginContext,\n phase: FarmIntegrationLogPhase,\n options: { reason?: string } = {},\n ): Promise<FarmIntegrationLifecycleContext> => {\n const args = createIntegrationRouteArgs({\n integration,\n config: context.config,\n });\n const configContext: FarmIntegrationConfigContext = {\n key: integrationKey,\n integration,\n appConfig: context.config,\n config: context.config,\n args,\n env: getIntegrationRuntimeEnv(),\n isDev: context.isDev,\n isProd: context.isProd,\n };\n integrationConfigPromise ??= resolveIntegrationConfig(integration, configContext);\n\n return {\n ...configContext,\n integrationConfig: await integrationConfigPromise,\n log: createIntegrationLifecycleLogger(integration, phase),\n reason: options.reason,\n async cleanup(callback) {\n if (callback) {\n cleanupCallbacks.push(callback);\n return;\n }\n\n await runCleanup();\n },\n };\n };\n\n const plugin: FarmPlugin = {\n name: `farm:integration:${integration.category}:${integration.type}`,\n enforce: \"pre\",\n\n async init(context) {\n getIntegrationRuntimeRegistry().set(integrationKey, {\n integration,\n config: context.config,\n isDev: context.isDev,\n isProd: context.isProd,\n });\n\n await createLifecycleContext(context, \"validate\");\n\n if (integration.validate) {\n await integration.validate(await createLifecycleContext(context, \"validate\"));\n }\n\n if (integration.setup) {\n await integration.setup(await createLifecycleContext(context, \"setup\"));\n }\n\n if (!integration.log) {\n return;\n }\n\n for (const route of routes) {\n await integration.log({\n category: integration.category,\n slot: integration.category,\n type: integration.type,\n phase: \"registered\",\n route: {\n kind: \"route\",\n path: route.path,\n methods: route.methods,\n },\n context: new Map(),\n });\n }\n\n for (const entry of middleware) {\n await integration.log({\n category: integration.category,\n slot: integration.category,\n type: integration.type,\n phase: \"registered\",\n route: {\n kind: \"middleware\",\n path: normalizeMatcher(entry.matcher),\n methods: [\"ALL\"],\n },\n context: new Map(),\n });\n }\n },\n\n async ready(context) {\n if (integration.ready) {\n await integration.ready(await createLifecycleContext(context, \"ready\"));\n }\n },\n\n async shutdown(payload, context) {\n try {\n if (integration.dispose) {\n await integration.dispose(\n await createLifecycleContext(context, \"dispose\", {\n reason: payload.reason,\n }),\n );\n }\n } finally {\n await runCleanup();\n }\n },\n\n async beforeRequest(req, res, context) {\n const fullUrl = `http://${req.headers.host || \"localhost\"}${req.url || \"/\"}`;\n const url = new URL(fullUrl);\n const pathname = url.pathname;\n const requestId = getRequestId(req);\n let bodyLoaded = false;\n let requestBody: Buffer | undefined;\n\n const getRequestBody = async () => {\n if (!bodyLoaded) {\n bodyLoaded = true;\n if (req.method && req.method !== \"GET\" && req.method !== \"HEAD\") {\n requestBody = await readRequestBody(req);\n }\n }\n\n return requestBody;\n };\n\n const createHandlerRequest = async () => {\n return createWebRequest(req, fullUrl, await getRequestBody());\n };\n\n for (const entry of middleware) {\n const params = resolveMatcherParams(entry.matcher, pathname);\n if (!params) {\n continue;\n }\n\n const request = await createHandlerRequest();\n const handlerContext = createIntegrationHandlerContext({\n integration,\n route: {\n kind: \"middleware\",\n path: normalizeMatcher(entry.matcher),\n methods: [\"ALL\"],\n },\n request,\n rawRequest: req,\n params,\n pathname,\n requestId,\n pluginContext: context,\n });\n const startedAt = Date.now();\n await integration.log?.({\n category: integration.category,\n slot: integration.category,\n type: integration.type,\n phase: \"request:start\",\n route: {\n kind: \"middleware\",\n path: normalizeMatcher(entry.matcher),\n methods: [\"ALL\"],\n },\n request,\n requestId,\n context: handlerContext.req.snapshot(),\n });\n\n try {\n const response = await entry.handler(request, handlerContext);\n if (response) {\n await sendWebResponse(res, response);\n await integration.log?.({\n category: integration.category,\n slot: integration.category,\n type: integration.type,\n phase: \"request:end\",\n route: {\n kind: \"middleware\",\n path: normalizeMatcher(entry.matcher),\n methods: [\"ALL\"],\n },\n request,\n response,\n requestId,\n durationMs: Date.now() - startedAt,\n context: handlerContext.req.snapshot(),\n });\n return;\n }\n\n await integration.log?.({\n category: integration.category,\n slot: integration.category,\n type: integration.type,\n phase: \"request:end\",\n route: {\n kind: \"middleware\",\n path: normalizeMatcher(entry.matcher),\n methods: [\"ALL\"],\n },\n request,\n requestId,\n durationMs: Date.now() - startedAt,\n context: handlerContext.req.snapshot(),\n });\n } catch (error) {\n await integration.log?.({\n category: integration.category,\n slot: integration.category,\n type: integration.type,\n phase: \"request:error\",\n route: {\n kind: \"middleware\",\n path: normalizeMatcher(entry.matcher),\n methods: [\"ALL\"],\n },\n request,\n requestId,\n durationMs: Date.now() - startedAt,\n error,\n context: handlerContext.req.snapshot(),\n });\n throw error;\n }\n }\n\n for (const route of routes) {\n const params = matchesMethod(route.methods, req.method)\n ? extractPathParams(route.path, pathname)\n : null;\n if (!params) {\n continue;\n }\n\n const request = await createHandlerRequest();\n const handlerContext = createIntegrationHandlerContext({\n integration,\n route: {\n kind: \"route\",\n path: route.path,\n methods: route.methods,\n },\n request,\n rawRequest: req,\n params,\n pathname,\n requestId,\n pluginContext: context,\n });\n const startedAt = Date.now();\n await integration.log?.({\n category: integration.category,\n slot: integration.category,\n type: integration.type,\n phase: \"request:start\",\n route: {\n kind: \"route\",\n path: route.path,\n methods: route.methods,\n },\n request,\n requestId,\n context: handlerContext.req.snapshot(),\n });\n\n try {\n const validation = await validateIntegrationRouteInput(route, request, url);\n if (!validation.success) {\n await sendWebResponse(res, validation.response);\n await integration.log?.({\n category: integration.category,\n slot: integration.category,\n type: integration.type,\n phase: \"request:end\",\n route: {\n kind: \"route\",\n path: route.path,\n methods: route.methods,\n },\n request,\n response: validation.response,\n requestId,\n durationMs: Date.now() - startedAt,\n context: handlerContext.req.snapshot(),\n });\n return;\n }\n handlerContext.input = validation.input;\n\n for (const middlewareEntry of route.middleware || []) {\n const middlewareResponse = await middlewareEntry.handler(request, handlerContext);\n if (middlewareResponse) {\n await sendWebResponse(res, middlewareResponse);\n await integration.log?.({\n category: integration.category,\n slot: integration.category,\n type: integration.type,\n phase: \"request:end\",\n route: {\n kind: \"route\",\n path: route.path,\n methods: route.methods,\n },\n request,\n response: middlewareResponse,\n requestId,\n durationMs: Date.now() - startedAt,\n context: handlerContext.req.snapshot(),\n });\n return;\n }\n }\n\n const beforeResponse = await runIntegrationRouteBeforeHooks(\n route,\n request,\n handlerContext,\n );\n if (beforeResponse) {\n const response = await runIntegrationRouteAfterHooks(\n route,\n request,\n handlerContext,\n beforeResponse,\n );\n await sendWebResponse(res, response);\n await integration.log?.({\n category: integration.category,\n slot: integration.category,\n type: integration.type,\n phase: \"request:end\",\n route: {\n kind: \"route\",\n path: route.path,\n methods: route.methods,\n },\n request,\n response,\n requestId,\n durationMs: Date.now() - startedAt,\n context: handlerContext.req.snapshot(),\n });\n return;\n }\n\n const handlerResponse = await route.handler(request, handlerContext);\n const response = await runIntegrationRouteAfterHooks(\n route,\n request,\n handlerContext,\n handlerResponse,\n );\n await sendWebResponse(res, response);\n await integration.log?.({\n category: integration.category,\n slot: integration.category,\n type: integration.type,\n phase: \"request:end\",\n route: {\n kind: \"route\",\n path: route.path,\n methods: route.methods,\n },\n request,\n response,\n requestId,\n durationMs: Date.now() - startedAt,\n context: handlerContext.req.snapshot(),\n });\n return;\n } catch (error) {\n await integration.log?.({\n category: integration.category,\n slot: integration.category,\n type: integration.type,\n phase: \"request:error\",\n route: {\n kind: \"route\",\n path: route.path,\n methods: route.methods,\n },\n request,\n requestId,\n durationMs: Date.now() - startedAt,\n error,\n context: handlerContext.req.snapshot(),\n });\n throw error;\n }\n }\n },\n };\n\n Object.defineProperty(plugin, FARM_INTEGRATION_PLUGIN_SERVER_RUNTIME, {\n value: integration.serverRuntime !== false,\n });\n\n return plugin;\n}\n\nfunction createIntegrationHandlerContext(input: {\n integration: FarmIntegration;\n route: FarmIntegrationHandlerContext[\"route\"];\n request: Request;\n rawRequest: FarmRequest;\n params: FarmIntegrationRouteParams;\n pathname: string;\n requestId: string;\n pluginContext: FarmPluginContext;\n}): FarmIntegrationHandlerContext {\n const req = createIntegrationRequestContextStore(\n input.rawRequest,\n input.request,\n input.pluginContext,\n );\n\n return {\n request: input.request,\n requestId: input.requestId,\n url: new URL(input.request.url),\n pathname: input.pathname,\n method: input.request.method,\n params: input.params,\n input: {},\n args: createIntegrationRouteArgs({\n integration: input.integration,\n config: input.pluginContext.config,\n }),\n data: resolveIntegrationData(input.request),\n integration: {\n category: input.integration.category,\n slot: input.integration.category,\n type: input.integration.type,\n instance: input.integration.instance,\n },\n route: input.route,\n req,\n requestContext: req,\n config: input.pluginContext.config,\n isDev: input.pluginContext.isDev,\n isProd: input.pluginContext.isProd,\n };\n}\n\ntype NormalizedIntegrationRoute = Omit<FarmIntegrationRoute, \"method\" | \"methods\"> & {\n methods: readonly string[];\n __operation?: FarmIntegrationAPIOperation<any, any, any, any, any>;\n};\n\nfunction normalizeIntegrationRoutes(\n routes: readonly FarmIntegrationRoute[],\n): NormalizedIntegrationRoute[] {\n return routes.map((route) => ({\n ...route,\n methods: normalizeIntegrationRouteMethods(route),\n input: normalizeIntegrationRouteInputSchemas(route),\n }));\n}\n\nfunction normalizeIntegrationRouteMethods(route: Pick<FarmIntegrationRoute, \"method\" | \"methods\">) {\n const input =\n route.methods && route.methods.length > 0\n ? [...route.methods]\n : route.method\n ? [route.method]\n : [\"ALL\"];\n\n return input.map((method) => String(method).toUpperCase());\n}\n\nfunction normalizeIntegrationRouteInputSchemas<TBody, TQuery>(\n route: Pick<FarmIntegrationRoute<TBody, TQuery>, \"body\" | \"query\" | \"input\">,\n): FarmIntegrationRouteInputSchemas<TBody, TQuery> | undefined {\n const input: FarmIntegrationRouteInputSchemas<TBody, TQuery> = {\n ...route.input,\n };\n\n if (route.body) {\n input.body = route.body;\n }\n\n if (route.query) {\n input.query = route.query;\n }\n\n return input.body || input.query ? input : undefined;\n}\n\ntype IntegrationRouteInputValidationResult =\n | {\n success: true;\n input: FarmIntegrationRouteInput;\n }\n | {\n success: false;\n response: Response;\n };\n\nasync function validateIntegrationRouteInput(\n route: NormalizedIntegrationRoute,\n request: Request,\n url: URL,\n): Promise<IntegrationRouteInputValidationResult> {\n const schemas = route.input;\n if (!schemas?.body && !schemas?.query) {\n return {\n success: true,\n input: {},\n };\n }\n\n const input: FarmIntegrationRouteInput = {};\n const issues: FarmIntegrationValidationIssue[] = [];\n\n if (schemas.query) {\n const queryResult = await parseIntegrationInputSchema(\n \"query\",\n schemas.query,\n createQueryInput(url.searchParams),\n );\n if (queryResult.success) {\n input.query = queryResult.data;\n } else {\n issues.push(...queryResult.issues);\n }\n }\n\n if (schemas.body) {\n const bodyInput = await readIntegrationValidationBody(\n request,\n getIntegrationRouteBodyFormat(route),\n );\n\n if (bodyInput.success) {\n const bodyResult = await parseIntegrationInputSchema(\"body\", schemas.body, bodyInput.data);\n if (bodyResult.success) {\n input.body = bodyResult.data;\n } else {\n issues.push(...bodyResult.issues);\n }\n } else {\n issues.push(bodyInput.issue);\n }\n }\n\n if (issues.length > 0) {\n return {\n success: false,\n response: createIntegrationValidationResponse(issues),\n };\n }\n\n return {\n success: true,\n input,\n };\n}\n\nasync function parseIntegrationInputSchema<TValue>(\n source: FarmIntegrationRouteInputSource,\n schema: FarmIntegrationInputSchema<TValue>,\n value: unknown,\n): Promise<\n | {\n success: true;\n data: TValue;\n }\n | {\n success: false;\n issues: FarmIntegrationValidationIssue[];\n }\n> {\n const parser = schema.safeParseAsync || schema.safeParse;\n if (parser) {\n const result = await parser.call(schema, value);\n if (result.success) {\n return {\n success: true,\n data: result.data,\n };\n }\n\n return {\n success: false,\n issues: normalizeIntegrationValidationIssues(source, result.error),\n };\n }\n\n if (schema[\"~standard\"]?.validate) {\n const result = await schema[\"~standard\"].validate(value);\n if (\"value\" in result) {\n return {\n success: true,\n data: result.value,\n };\n }\n\n return {\n success: false,\n issues: normalizeIntegrationValidationIssues(source, {\n issues: result.issues,\n }),\n };\n }\n\n if (schema.parse) {\n try {\n return {\n success: true,\n data: await schema.parse(value),\n };\n } catch (error) {\n return {\n success: false,\n issues: normalizeIntegrationValidationIssues(\n source,\n normalizeIntegrationValidationError(error),\n ),\n };\n }\n }\n\n return {\n success: false,\n issues: [\n {\n source,\n message:\n \"Input schema must expose safeParse, safeParseAsync, parse, or ~standard.validate.\",\n },\n ],\n };\n}\n\nfunction createIntegrationValidationResponse(issues: readonly FarmIntegrationValidationIssue[]) {\n return Response.json(\n {\n error: \"Integration route input validation failed\",\n issues,\n },\n {\n status: 400,\n },\n );\n}\n\nfunction normalizeIntegrationValidationIssues(\n source: FarmIntegrationRouteInputSource,\n error: FarmIntegrationValidationErrorLike,\n): FarmIntegrationValidationIssue[] {\n if (Array.isArray(error.issues) && error.issues.length > 0) {\n return error.issues.map((issue) => ({\n source,\n path: normalizeIntegrationValidationPath(issue.path),\n code: issue.code,\n message: issue.message || \"Invalid input\",\n }));\n }\n\n return [\n {\n source,\n path: [],\n message: error.message || \"Invalid input\",\n },\n ];\n}\n\nfunction normalizeIntegrationValidationPath(\n path: readonly FarmIntegrationValidationPathSegment[] | undefined,\n): (string | number)[] {\n return (path || []).map((segment) => {\n const key =\n typeof segment === \"object\" && segment !== null && \"key\" in segment ? segment.key : segment;\n return typeof key === \"symbol\" ? key.description || key.toString() : key;\n });\n}\n\nfunction normalizeIntegrationValidationError(error: unknown): FarmIntegrationValidationErrorLike {\n if (error && typeof error === \"object\") {\n return error as FarmIntegrationValidationErrorLike;\n }\n\n return {\n message: error instanceof Error ? error.message : String(error || \"Invalid input\"),\n };\n}\n\nasync function readIntegrationValidationBody(\n request: Request,\n format: FarmIntegrationAPIBodyFormat,\n): Promise<\n | {\n success: true;\n data: unknown;\n }\n | {\n success: false;\n issue: FarmIntegrationValidationIssue;\n }\n> {\n if (request.method === \"GET\" || request.method === \"HEAD\" || format === \"none\") {\n return {\n success: true,\n data: undefined,\n };\n }\n\n try {\n if (format === \"form\") {\n return {\n success: true,\n data: createFormInput(await request.clone().formData()),\n };\n }\n\n const text = await request.clone().text();\n if (text.trim().length === 0) {\n return {\n success: true,\n data: undefined,\n };\n }\n\n return {\n success: true,\n data: JSON.parse(text),\n };\n } catch (error) {\n return {\n success: false,\n issue: {\n source: \"body\",\n path: [],\n message:\n format === \"json\"\n ? \"Expected a valid JSON request body.\"\n : error instanceof Error && error.message\n ? error.message\n : \"Could not parse request body.\",\n },\n };\n }\n}\n\nfunction getIntegrationRouteBodyFormat(route: NormalizedIntegrationRoute) {\n return route.bodyFormat || route.__operation?.bodyFormat || \"json\";\n}\n\nfunction createIntegrationRouteArgs(input: {\n integration: FarmIntegration;\n config: FarmPluginContext[\"config\"];\n}): FarmIntegrationRouteArgs {\n let clientPromise: Promise<unknown | undefined> | undefined;\n let ormPromise: Promise<unknown> | undefined;\n\n const getClient = () => {\n clientPromise ??= import(\"./storage\").then(({ resolveStorageRuntimeClient }) =>\n resolveStorageRuntimeClient(input.config.storage),\n );\n return clientPromise;\n };\n\n const getOrm = () => {\n if (!input.integration.schema) {\n throw new Error(\n `Integration \"${input.integration.type}\" does not define a schema for ctx.args.db.`,\n );\n }\n\n ormPromise ??= import(\"./integration-orm\").then(({ createIntegrationOrm }) =>\n createIntegrationOrm({\n schema: input.integration.schema!,\n config: input.config,\n }),\n );\n return ormPromise;\n };\n\n return {\n db: createLazyIntegrationOrmClient(getOrm) as never,\n getDb: getOrm as never,\n storage: {\n getClient,\n getOrm: getOrm as never,\n },\n };\n}\n\nfunction createLazyIntegrationOrmClient(resolveOrm: () => Promise<unknown>) {\n const modelProxyCache = new Map<PropertyKey, unknown>();\n\n return new Proxy(\n {},\n {\n get(_target, prop) {\n if (prop === \"then\") {\n return undefined;\n }\n\n if (prop === \"transaction\" || prop === \"batch\") {\n return async (...args: unknown[]) => {\n const orm = (await resolveOrm()) as Record<PropertyKey, unknown>;\n const member = orm[prop];\n if (typeof member !== \"function\") {\n throw new Error(`Integration ORM does not expose \"${String(prop)}\".`);\n }\n return member.apply(orm, args);\n };\n }\n\n if (prop === \"$driver\") {\n return undefined;\n }\n\n if (!modelProxyCache.has(prop)) {\n modelProxyCache.set(prop, createLazyIntegrationOrmModel(resolveOrm, prop));\n }\n\n return modelProxyCache.get(prop);\n },\n },\n );\n}\n\nfunction createLazyIntegrationOrmModel(resolveOrm: () => Promise<unknown>, modelName: PropertyKey) {\n return new Proxy(\n {},\n {\n get(_target, prop) {\n if (prop === \"then\") {\n return undefined;\n }\n\n return async (...args: unknown[]) => {\n const orm = (await resolveOrm()) as Record<PropertyKey, Record<PropertyKey, unknown>>;\n const model = orm[modelName];\n const member = model?.[prop];\n if (typeof member !== \"function\") {\n throw new Error(\n `Integration ORM model \"${String(modelName)}\" does not expose \"${String(prop)}\".`,\n );\n }\n return member.apply(model, args);\n };\n },\n },\n );\n}\n\nasync function runIntegrationRouteBeforeHooks(\n route: NormalizedIntegrationRoute,\n request: Request,\n context: FarmIntegrationHandlerContext,\n): Promise<Response | undefined> {\n const hookContext = context as FarmIntegrationRouteHookContext;\n hookContext.response = undefined;\n\n for (const hook of route.before || []) {\n const response = await hook(request, hookContext);\n if (response) {\n hookContext.response = response;\n return response;\n }\n\n if (hookContext.response) {\n return hookContext.response;\n }\n }\n\n return undefined;\n}\n\nasync function runIntegrationRouteAfterHooks(\n route: NormalizedIntegrationRoute,\n request: Request,\n context: FarmIntegrationHandlerContext,\n response: Response,\n): Promise<Response> {\n const hookContext = context as FarmIntegrationRouteHookContext;\n let currentResponse = response;\n\n for (const hook of route.after || []) {\n hookContext.response = currentResponse;\n const nextResponse = await hook(request, hookContext);\n currentResponse = nextResponse || hookContext.response || currentResponse;\n }\n\n hookContext.response = currentResponse;\n return currentResponse;\n}\n\nfunction createQueryInput(searchParams: URLSearchParams): Record<string, string | string[]> {\n const input: Record<string, string | string[]> = {};\n searchParams.forEach((value, key) => {\n const existing = input[key];\n if (existing === undefined) {\n input[key] = value;\n return;\n }\n\n input[key] = Array.isArray(existing) ? [...existing, value] : [existing, value];\n });\n return input;\n}\n\nfunction createFormInput(\n formData: FormData,\n): Record<string, FormDataEntryValue | FormDataEntryValue[]> {\n const input: Record<string, FormDataEntryValue | FormDataEntryValue[]> = {};\n formData.forEach((value, key) => {\n const existing = input[key];\n if (existing === undefined) {\n input[key] = value;\n return;\n }\n\n input[key] = Array.isArray(existing) ? [...existing, value] : [existing, value];\n });\n return input;\n}\n\nexport async function dispatchIntegrationRequest(\n runtime: RegisteredIntegrationRuntime,\n request: Request,\n options: {\n currentRequest?: Request;\n data?: FarmIntegrationData;\n internal?: boolean;\n } = {},\n): Promise<Response | null> {\n const integration = runtime.integration;\n const url = new URL(request.url);\n const pathname = url.pathname;\n const requestId =\n request.headers.get(\"x-request-id\") ||\n options.currentRequest?.headers.get(\"x-request-id\") ||\n String(Date.now());\n const routes = normalizeIntegrationRoutes(integration.routes || []);\n const middleware = [...(integration.middleware || [])];\n\n for (const entry of middleware) {\n const params = resolveMatcherParams(entry.matcher, pathname);\n if (!params) {\n continue;\n }\n\n const handlerContext = createServerIntegrationHandlerContext({\n runtime,\n route: {\n kind: \"middleware\",\n path: normalizeMatcher(entry.matcher),\n methods: [\"ALL\"],\n },\n request,\n params,\n pathname,\n requestId,\n currentRequest: options.currentRequest,\n data: options.data,\n internal: options.internal === true,\n });\n const startedAt = Date.now();\n\n await integration.log?.({\n category: integration.category,\n slot: integration.category,\n type: integration.type,\n phase: \"request:start\",\n route: {\n kind: \"middleware\",\n path: normalizeMatcher(entry.matcher),\n methods: [\"ALL\"],\n },\n request,\n requestId,\n context: handlerContext.req.snapshot(),\n });\n\n try {\n const response = await entry.handler(request, handlerContext);\n if (response) {\n await integration.log?.({\n category: integration.category,\n slot: integration.category,\n type: integration.type,\n phase: \"request:end\",\n route: {\n kind: \"middleware\",\n path: normalizeMatcher(entry.matcher),\n methods: [\"ALL\"],\n },\n request,\n response,\n requestId,\n durationMs: Date.now() - startedAt,\n context: handlerContext.req.snapshot(),\n });\n return response;\n }\n\n await integration.log?.({\n category: integration.category,\n slot: integration.category,\n type: integration.type,\n phase: \"request:end\",\n route: {\n kind: \"middleware\",\n path: normalizeMatcher(entry.matcher),\n methods: [\"ALL\"],\n },\n request,\n requestId,\n durationMs: Date.now() - startedAt,\n context: handlerContext.req.snapshot(),\n });\n } catch (error) {\n await integration.log?.({\n category: integration.category,\n slot: integration.category,\n type: integration.type,\n phase: \"request:error\",\n route: {\n kind: \"middleware\",\n path: normalizeMatcher(entry.matcher),\n methods: [\"ALL\"],\n },\n request,\n requestId,\n durationMs: Date.now() - startedAt,\n error,\n context: handlerContext.req.snapshot(),\n });\n throw error;\n }\n }\n\n for (const route of routes) {\n const params = matchesMethod(route.methods, request.method)\n ? extractPathParams(route.path, pathname)\n : null;\n if (!params) {\n continue;\n }\n\n const handlerContext = createServerIntegrationHandlerContext({\n runtime,\n route: {\n kind: \"route\",\n path: route.path,\n methods: route.methods,\n },\n request,\n params,\n pathname,\n requestId,\n currentRequest: options.currentRequest,\n data: options.data,\n internal: options.internal === true,\n });\n const startedAt = Date.now();\n\n await integration.log?.({\n category: integration.category,\n slot: integration.category,\n type: integration.type,\n phase: \"request:start\",\n route: {\n kind: \"route\",\n path: route.path,\n methods: route.methods,\n },\n request,\n requestId,\n context: handlerContext.req.snapshot(),\n });\n\n try {\n const validation = await validateIntegrationRouteInput(route, request, url);\n if (!validation.success) {\n await integration.log?.({\n category: integration.category,\n slot: integration.category,\n type: integration.type,\n phase: \"request:end\",\n route: {\n kind: \"route\",\n path: route.path,\n methods: route.methods,\n },\n request,\n response: validation.response,\n requestId,\n durationMs: Date.now() - startedAt,\n context: handlerContext.req.snapshot(),\n });\n return validation.response;\n }\n handlerContext.input = validation.input;\n\n for (const middlewareEntry of route.middleware || []) {\n const middlewareResponse = await middlewareEntry.handler(request, handlerContext);\n if (middlewareResponse) {\n await integration.log?.({\n category: integration.category,\n slot: integration.category,\n type: integration.type,\n phase: \"request:end\",\n route: {\n kind: \"route\",\n path: route.path,\n methods: route.methods,\n },\n request,\n response: middlewareResponse,\n requestId,\n durationMs: Date.now() - startedAt,\n context: handlerContext.req.snapshot(),\n });\n return middlewareResponse;\n }\n }\n\n const beforeResponse = await runIntegrationRouteBeforeHooks(route, request, handlerContext);\n if (beforeResponse) {\n const response = await runIntegrationRouteAfterHooks(\n route,\n request,\n handlerContext,\n beforeResponse,\n );\n await integration.log?.({\n category: integration.category,\n slot: integration.category,\n type: integration.type,\n phase: \"request:end\",\n route: {\n kind: \"route\",\n path: route.path,\n methods: route.methods,\n },\n request,\n response,\n requestId,\n durationMs: Date.now() - startedAt,\n context: handlerContext.req.snapshot(),\n });\n return response;\n }\n\n const handlerResponse = await route.handler(request, handlerContext);\n const response = await runIntegrationRouteAfterHooks(\n route,\n request,\n handlerContext,\n handlerResponse,\n );\n await integration.log?.({\n category: integration.category,\n slot: integration.category,\n type: integration.type,\n phase: \"request:end\",\n route: {\n kind: \"route\",\n path: route.path,\n methods: route.methods,\n },\n request,\n response,\n requestId,\n durationMs: Date.now() - startedAt,\n context: handlerContext.req.snapshot(),\n });\n return response;\n } catch (error) {\n await integration.log?.({\n category: integration.category,\n slot: integration.category,\n type: integration.type,\n phase: \"request:error\",\n route: {\n kind: \"route\",\n path: route.path,\n methods: route.methods,\n },\n request,\n requestId,\n durationMs: Date.now() - startedAt,\n error,\n context: handlerContext.req.snapshot(),\n });\n throw error;\n }\n }\n\n return null;\n}\n\n(globalThis as GlobalWithIntegrationRuntimeRegistry)[INTEGRATION_REQUEST_DISPATCHER_KEY] =\n dispatchIntegrationRequest;\n\nfunction createIntegrationRequestContextStore(\n rawRequest: FarmRequest,\n request: Request,\n pluginContext: FarmPluginContext,\n): FarmIntegrationRequestContextStore {\n return {\n get(key) {\n const requestValue = pluginContext.requestContext.get(request, key);\n if (requestValue !== undefined) {\n return requestValue;\n }\n\n return pluginContext.requestContext.get(rawRequest, key);\n },\n set(key, value, options) {\n pluginContext.requestContext.set(rawRequest, key, value, options);\n pluginContext.requestContext.set(request, key, value, options);\n },\n has(key) {\n return (\n pluginContext.requestContext.has(request, key) ||\n pluginContext.requestContext.has(rawRequest, key)\n );\n },\n delete(key) {\n const deletedRequest = pluginContext.requestContext.delete(request, key);\n const deletedRaw = pluginContext.requestContext.delete(rawRequest, key);\n return deletedRequest || deletedRaw;\n },\n clear() {\n pluginContext.requestContext.clear(rawRequest);\n pluginContext.requestContext.clear(request);\n },\n snapshot(options) {\n const merged = pluginContext.requestContext.getAll(rawRequest, options);\n const requestSnapshot = pluginContext.requestContext.getAll(request, options);\n for (const [key, value] of requestSnapshot) {\n merged.set(key, value);\n }\n return merged;\n },\n };\n}\n\nfunction createServerIntegrationHandlerContext(input: {\n runtime: RegisteredIntegrationRuntime;\n route: FarmIntegrationHandlerContext[\"route\"];\n request: Request;\n params: FarmIntegrationRouteParams;\n pathname: string;\n requestId: string;\n currentRequest?: Request;\n data?: FarmIntegrationData;\n internal?: boolean;\n}): FarmIntegrationHandlerContext {\n const req = createServerIntegrationRequestContextStore(input.request, input.currentRequest);\n\n if (input.internal) {\n req.set(FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY, true);\n }\n\n return {\n request: input.request,\n requestId: input.requestId,\n url: new URL(input.request.url),\n pathname: input.pathname,\n method: input.request.method,\n params: input.params,\n input: {},\n args: createIntegrationRouteArgs({\n integration: input.runtime.integration,\n config: input.runtime.config,\n }),\n data: resolveIntegrationData(input.request, input.data),\n integration: {\n category: input.runtime.integration.category,\n slot: input.runtime.integration.category,\n type: input.runtime.integration.type,\n instance: input.runtime.integration.instance,\n },\n route: input.route,\n req,\n requestContext: req,\n config: input.runtime.config,\n isDev: input.runtime.isDev,\n isProd: input.runtime.isProd,\n };\n}\n\nfunction createServerIntegrationRequestContextStore(\n request: Request,\n currentRequest?: Request,\n): FarmIntegrationRequestContextStore {\n return {\n get(key) {\n const requestValue = getRequestContext(request, key);\n if (requestValue !== undefined) {\n return requestValue;\n }\n\n if (currentRequest) {\n return getRequestContext(currentRequest, key);\n }\n\n return undefined;\n },\n set(key, value, options) {\n setRequestContext(request, key, value, options);\n if (currentRequest) {\n setRequestContext(currentRequest, key, value, options);\n }\n },\n has(key) {\n return (\n hasRequestContext(request, key) ||\n (!!currentRequest && hasRequestContext(currentRequest, key))\n );\n },\n delete(key) {\n const deletedRequest = deleteRequestContext(request, key);\n const deletedCurrent = currentRequest ? deleteRequestContext(currentRequest, key) : false;\n return deletedRequest || deletedCurrent;\n },\n clear() {\n clearRequestContext(request);\n if (currentRequest) {\n clearRequestContext(currentRequest);\n }\n },\n snapshot(options) {\n const merged = currentRequest\n ? getRequestContextSnapshot(currentRequest, options)\n : new Map<string, unknown>();\n const requestSnapshot = getRequestContextSnapshot(request, options);\n for (const [key, value] of requestSnapshot) {\n merged.set(key, value);\n }\n return merged;\n },\n };\n}\n\nfunction createWebRequest(req: FarmRequest, fullUrl: string, body?: Buffer): Request {\n const headers = new Headers();\n for (const [key, value] of Object.entries(req.headers)) {\n if (value == null) {\n continue;\n }\n\n if (Array.isArray(value)) {\n for (const item of value) {\n headers.append(key, item);\n }\n continue;\n }\n\n headers.set(key, value);\n }\n\n return new Request(fullUrl, {\n method: req.method,\n headers,\n body: body as BodyInit | undefined,\n });\n}\n\nfunction matchesMethod(methods: readonly string[], method: string | undefined): boolean {\n if (!method) {\n return false;\n }\n\n return methods.some((item) => item.toUpperCase() === method.toUpperCase());\n}\n\nfunction matchesMatcher(\n matcher: string | readonly string[] | undefined,\n pathname: string,\n): boolean {\n return resolveMatcherParams(matcher, pathname) !== null;\n}\n\nfunction resolveMatcherParams(\n matcher: string | readonly string[] | undefined,\n pathname: string,\n): FarmIntegrationRouteParams | null {\n if (!matcher) {\n return {};\n }\n\n const list = Array.isArray(matcher) ? matcher : [matcher];\n for (const item of list) {\n if (item === \"/(.*)\" || item === \"*\") {\n return {};\n }\n if (item.endsWith(\"(.*)\")) {\n const prefix = item.slice(0, -4);\n if (pathname === prefix || pathname.startsWith(`${prefix}/`)) {\n return {};\n }\n continue;\n }\n const params = extractPathParams(item, pathname);\n if (params) {\n return params;\n }\n }\n\n return null;\n}\n\nfunction matchesPath(pattern: string, pathname: string): boolean {\n return extractPathParams(pattern, pathname) !== null;\n}\n\nfunction extractPathParams(pattern: string, pathname: string): FarmIntegrationRouteParams | null {\n const routeSegments = splitPath(pattern);\n const pathSegments = splitPath(pathname);\n const params: FarmIntegrationRouteParams = {};\n\n let routeIndex = 0;\n let pathIndex = 0;\n\n while (routeIndex < routeSegments.length && pathIndex < pathSegments.length) {\n const routeSegment = routeSegments[routeIndex];\n const pathSegment = pathSegments[pathIndex];\n\n if (isCatchAllSegment(routeSegment)) {\n params[getSegmentParamName(routeSegment)] = pathSegments\n .slice(pathIndex)\n .map((segment) => decodeURIComponent(segment));\n return params;\n }\n\n if (isDynamicSegment(routeSegment)) {\n params[getSegmentParamName(routeSegment)] = decodeURIComponent(pathSegment);\n routeIndex += 1;\n pathIndex += 1;\n continue;\n }\n\n if (routeSegment !== pathSegment) {\n return null;\n }\n\n routeIndex += 1;\n pathIndex += 1;\n }\n\n if (routeIndex === routeSegments.length && pathIndex === pathSegments.length) {\n return params;\n }\n\n if (routeIndex === routeSegments.length - 1 && isCatchAllSegment(routeSegments[routeIndex])) {\n params[getSegmentParamName(routeSegments[routeIndex])] = [];\n return params;\n }\n\n return null;\n}\n\nfunction splitPath(value: string): string[] {\n return value.split(\"/\").filter(Boolean);\n}\n\nfunction isDynamicSegment(segment: string): boolean {\n return segment.startsWith(\"[\") && segment.endsWith(\"]\");\n}\n\nfunction isCatchAllSegment(segment: string): boolean {\n return segment.startsWith(\"[...\") && segment.endsWith(\"]\");\n}\n\nfunction getSegmentParamName(segment: string): string {\n if (isCatchAllSegment(segment)) {\n return segment.slice(4, -1);\n }\n\n return segment.slice(1, -1);\n}\n\nfunction getRequestId(req: FarmRequest): string {\n const headerValue = req.headers[\"x-request-id\"];\n if (Array.isArray(headerValue)) {\n return headerValue[0] || String(Date.now());\n }\n return headerValue || String(Date.now());\n}\n\nasync function readRequestBody(req: FarmRequest): Promise<Buffer> {\n return await new Promise((resolve, reject) => {\n const chunks: Buffer[] = [];\n req.on(\"data\", (chunk) => {\n chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));\n });\n req.on(\"end\", () => {\n resolve(Buffer.concat(chunks));\n });\n req.on(\"error\", reject);\n });\n}\n\nfunction normalizeMatcher(matcher: string | readonly string[] | undefined): string {\n if (!matcher) {\n return \"/(.*)\";\n }\n return typeof matcher === \"string\" ? matcher : matcher.join(\", \");\n}\n"],"mappings":";;;;;;;;;;;;AAeA,IAAM,4BAA4B,uBAAO,IAAI,0BAA0B;AAMvE,SAAS,yBAAyB;AAChC,QAAM,cAAc;AACpB,MAAI,CAAC,YAAY,yBAAyB,GAAG;AAC3C,gBAAY,yBAAyB,IAAI,oBAAI,QAG3C;AAAA,EACJ;AAEA,SAAO,YAAY,yBAAyB;AAC9C;AAVS;AAYT,SAAS,UAAU,QAAqD;AACtE,QAAM,sBAAsB,uBAAuB;AACnD,MAAI,SAAS,oBAAoB,IAAI,MAAM;AAC3C,MAAI,CAAC,QAAQ;AACX,aAAS;AAAA,MACP,aAAa,oBAAI,IAAiB;AAAA,MAClC,aAAa,oBAAI,IAAiB;AAAA,IACpC;AACA,wBAAoB,IAAI,QAAQ,MAAM;AAAA,EACxC;AACA,SAAO;AACT;AAXS;AAaF,SAAS,kBACd,QACA,KACA,OACA,UAAoC,CAAC,GAC/B;AACN,QAAM,SAAS,UAAU,MAAM;AAC/B,SAAO,YAAY,IAAI,KAAK,KAAK;AACjC,MAAI,QAAQ,cAAc;AACxB,WAAO,YAAY,IAAI,KAAK,KAAK;AAAA,EACnC;AACF;AAXgB;AAaT,SAAS,kBACd,QACA,KACe;AACf,QAAM,sBAAsB,uBAAuB;AACnD,QAAM,SAAS,oBAAoB,IAAI,MAAM;AAC7C,SAAO,QAAQ,YAAY,IAAI,GAAG;AACpC;AAPgB;AAST,SAAS,kBAAkB,QAA+B,KAAsB;AACrF,QAAM,sBAAsB,uBAAuB;AACnD,QAAM,SAAS,oBAAoB,IAAI,MAAM;AAC7C,SAAO,QAAQ,YAAY,IAAI,GAAG,KAAK;AACzC;AAJgB;AAMT,SAAS,qBAAqB,QAA+B,KAAsB;AACxF,QAAM,sBAAsB,uBAAuB;AACnD,QAAM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I,CAAC;AACzC;AANS;AAQT,eAAe,gBAAgB,KAAmC;AAChE,SAAO,MAAM,IAAI,QAAQ,CAAC,SAAS,WAAW;AAC5C,UAAM,SAAmB,CAAC;AAC1B,QAAI,GAAG,QAAQ,CAAC,UAAU;AACxB,aAAO,KAAK,OAAO,SAAS,KAAK,IAAI,QAAQ,OAAO,KAAK,KAAK,CAAC;AAAA,IACjE,CAAC;AACD,QAAI,GAAG,OAAO,MAAM;AAClB,cAAQ,OAAO,OAAO,MAAM,CAAC;AAAA,IAC/B,CAAC;AACD,QAAI,GAAG,SAAS,MAAM;AAAA,EACxB,CAAC;AACH;AAXe;AAaf,SAAS,iBAAiB,SAAyD;AACjF,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AACA,SAAO,OAAO,YAAY,WAAW,UAAU,QAAQ,KAAK,IAAI;AAClE;AALS;","names":["api","response"]}
@@ -0,0 +1,218 @@
1
+ import {
2
+ writeFileIfChanged
3
+ } from "./chunk-USWZZUEH.mjs";
4
+ import {
5
+ __name
6
+ } from "./chunk-CGILA3WO.mjs";
7
+
8
+ // src/type-generator.ts
9
+ import { readFileSync, existsSync, readdirSync, mkdirSync } from "fs";
10
+ import { join, relative, dirname } from "path";
11
+ var _APITypeGenerator = class _APITypeGenerator {
12
+ constructor(appDir) {
13
+ this.appDirs = Array.isArray(appDir) ? [...appDir] : [appDir];
14
+ }
15
+ /**
16
+ * Scan all API route files and extract route information
17
+ */
18
+ scanAPIRoutes() {
19
+ const routes = /* @__PURE__ */ new Map();
20
+ for (const appDir of this.appDirs) {
21
+ const apiDir = join(appDir, "api");
22
+ if (!existsSync(apiDir)) continue;
23
+ const discovered = [];
24
+ this.scanDirectory(apiDir, appDir, discovered);
25
+ for (const route of discovered) {
26
+ routes.set(route.path, route);
27
+ }
28
+ }
29
+ return Array.from(routes.values()).sort((left, right) => left.path.localeCompare(right.path));
30
+ }
31
+ scanDirectory(dir, appDir, routes, basePath = "") {
32
+ const items = readdirSync(dir, { withFileTypes: true });
33
+ for (const item of items) {
34
+ const fullPath = join(dir, item.name);
35
+ if (item.isDirectory()) {
36
+ const newBasePath = basePath ? `${basePath}/${item.name}` : item.name;
37
+ this.scanDirectory(fullPath, appDir, routes, newBasePath);
38
+ } else if (/^route\.(ts|tsx|js|jsx)$/.test(item.name)) {
39
+ const routeInfo = this.extractRouteInfo(fullPath, appDir, basePath);
40
+ if (routeInfo) {
41
+ routes.push(routeInfo);
42
+ }
43
+ }
44
+ }
45
+ }
46
+ extractRouteInfo(filePath, appDir, basePath) {
47
+ try {
48
+ const content = readFileSync(filePath, "utf-8");
49
+ const methods = this.extractExportedMethods(content);
50
+ if (methods.length === 0) {
51
+ return null;
52
+ }
53
+ const relativePath = relative(appDir, filePath);
54
+ const apiPath = basePath ? `/api/${basePath}` : "/api";
55
+ return {
56
+ path: apiPath,
57
+ methods,
58
+ filePath,
59
+ relativePath
60
+ };
61
+ } catch (error) {
62
+ console.warn(`Failed to read route file ${filePath}:`, error);
63
+ return null;
64
+ }
65
+ }
66
+ extractExportedMethods(content) {
67
+ const methods = [];
68
+ const httpMethods = ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD"];
69
+ for (const method of httpMethods) {
70
+ const patterns = [
71
+ new RegExp(`export\\s+const\\s+${method}\\s*=`, "g"),
72
+ new RegExp(`export\\s+(?:async\\s+)?function\\s+${method}\\s*\\(`, "g"),
73
+ new RegExp(`export\\s*{\\s*${method}\\s*}`, "g"),
74
+ new RegExp(`export\\s*{\\s*${method}\\s*as\\s+\\w+\\s*}`, "g")
75
+ ];
76
+ for (const pattern of patterns) {
77
+ if (pattern.test(content)) {
78
+ methods.push(method);
79
+ break;
80
+ }
81
+ }
82
+ }
83
+ return methods;
84
+ }
85
+ /**
86
+ * Generate TypeScript code for the API router
87
+ */
88
+ generateAPIRouter(routes, options = {}) {
89
+ const imports = [];
90
+ const routeGroups = /* @__PURE__ */ new Map();
91
+ for (const route of routes) {
92
+ const key = route.path;
93
+ if (!routeGroups.has(key)) {
94
+ routeGroups.set(key, []);
95
+ }
96
+ routeGroups.get(key).push(route);
97
+ }
98
+ const nestedStructure = {};
99
+ for (const [path, routeList] of routeGroups) {
100
+ const route = routeList[0];
101
+ const importPath = this.getRouteImportPath(route, options.outFile);
102
+ const routeName = this.pathToRouteName(route.path);
103
+ const cleanPath = path === "/api" ? "" : path.replace(/^\/api\//, "");
104
+ const parts = cleanPath ? cleanPath.split("/") : [];
105
+ const allMethods = routeList.flatMap((r) => r.methods);
106
+ for (const method of allMethods) {
107
+ const importName = `${method}_${routeName}`;
108
+ imports.push(
109
+ `import type { ${method} as ${importName} } from ${JSON.stringify(importPath)};`
110
+ );
111
+ }
112
+ if (parts.length === 0) {
113
+ for (const method of allMethods) {
114
+ const importName = `${method}_${routeName}`;
115
+ const methodName = method.toLowerCase();
116
+ nestedStructure[methodName] = `typeof ${importName}`;
117
+ }
118
+ } else {
119
+ let current = nestedStructure;
120
+ for (let i = 0; i < parts.length; i++) {
121
+ const part = parts[i];
122
+ if (i === parts.length - 1) {
123
+ current[part] = {};
124
+ for (const method of allMethods) {
125
+ const importName = `${method}_${routeName}`;
126
+ const methodName = method.toLowerCase();
127
+ current[part][methodName] = `typeof ${importName}`;
128
+ }
129
+ } else {
130
+ if (!current[part]) {
131
+ current[part] = {};
132
+ }
133
+ current = current[part];
134
+ }
135
+ }
136
+ }
137
+ }
138
+ const typeExports = this.structureToTypeString(nestedStructure, 1);
139
+ return `/**
140
+ * Auto-generated API router types
141
+ * This file is automatically generated - do not edit manually
142
+ *
143
+ * This file contains only TypeScript types for the API client.
144
+ * Runtime imports are used only at the type level.
145
+ */
146
+
147
+ ${imports.join("\n")}
148
+
149
+ // Type-only representation of your API routes
150
+ export type APIRouter = {
151
+ ${typeExports}
152
+ };
153
+ `;
154
+ }
155
+ getRouteImportPath(route, outFile) {
156
+ if (!outFile) {
157
+ return `../app/${route.relativePath.replace(/\\/g, "/").replace(/\.(ts|tsx|js|jsx)$/, "")}`;
158
+ }
159
+ const relativeImport = relative(dirname(outFile), route.filePath).replace(/\\/g, "/").replace(/\.(ts|tsx|js|jsx)$/, "");
160
+ return relativeImport.startsWith(".") ? relativeImport : `./${relativeImport}`;
161
+ }
162
+ pathToRouteName(path) {
163
+ return (path === "/api" ? "root" : path.replace(/^\/api\//, "")).replace(/\//g, "_").replace(/[^a-zA-Z0-9_]/g, "");
164
+ }
165
+ structureToTypeString(obj, indent) {
166
+ const spaces = " ".repeat(indent);
167
+ const lines = [];
168
+ for (const [key, value] of Object.entries(obj)) {
169
+ const propertyKey = this.toTypePropertyKey(key);
170
+ if (typeof value === "string") {
171
+ lines.push(`${spaces}${propertyKey}: ${value};`);
172
+ } else if (typeof value === "object") {
173
+ lines.push(`${spaces}${propertyKey}: {`);
174
+ lines.push(this.structureToTypeString(value, indent + 1));
175
+ lines.push(`${spaces}};`);
176
+ }
177
+ }
178
+ return lines.join("\n");
179
+ }
180
+ toTypePropertyKey(key) {
181
+ return /^[$A-Z_][0-9A-Z_$]*$/i.test(key) ? key : JSON.stringify(key);
182
+ }
183
+ getBaseExportName(path) {
184
+ const cleanPath = path.replace(/^\/api\//, "");
185
+ if (cleanPath === "") {
186
+ return "api";
187
+ }
188
+ return cleanPath;
189
+ }
190
+ getExportName(path, method) {
191
+ const cleanPath = path.replace(/^\/api\//, "");
192
+ if (cleanPath === "") {
193
+ return method.toLowerCase();
194
+ }
195
+ const parts = cleanPath.split("/");
196
+ if (parts.length === 1) {
197
+ return parts[0];
198
+ }
199
+ return parts.join(".");
200
+ }
201
+ /**
202
+ * Generate the API index file
203
+ */
204
+ generateAPIIndex(outputPath) {
205
+ const routes = this.scanAPIRoutes();
206
+ const content = this.generateAPIRouter(routes);
207
+ mkdirSync(dirname(outputPath), { recursive: true });
208
+ writeFileIfChanged(outputPath, content);
209
+ console.log(`\u2705 Generated API types for ${routes.length} routes`);
210
+ }
211
+ };
212
+ __name(_APITypeGenerator, "APITypeGenerator");
213
+ var APITypeGenerator = _APITypeGenerator;
214
+
215
+ export {
216
+ APITypeGenerator
217
+ };
218
+ //# sourceMappingURL=chunk-LGHEOHBU.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/type-generator.ts"],"sourcesContent":["import { readFileSync, existsSync, readdirSync, mkdirSync } from \"fs\";\nimport { join, relative, dirname } from \"path\";\nimport { writeFileIfChanged } from \"./write-file-if-changed\";\n\nexport interface APIRouteInfo {\n path: string;\n methods: string[];\n filePath: string;\n relativePath: string;\n}\n\nexport class APITypeGenerator {\n private appDirs: string[];\n\n constructor(appDir: string | readonly string[]) {\n this.appDirs = Array.isArray(appDir) ? [...appDir] : [appDir as string];\n }\n\n /**\n * Scan all API route files and extract route information\n */\n scanAPIRoutes(): APIRouteInfo[] {\n const routes = new Map<string, APIRouteInfo>();\n\n for (const appDir of this.appDirs) {\n const apiDir = join(appDir, \"api\");\n if (!existsSync(apiDir)) continue;\n\n const discovered: APIRouteInfo[] = [];\n this.scanDirectory(apiDir, appDir, discovered);\n for (const route of discovered) {\n routes.set(route.path, route);\n }\n }\n\n return Array.from(routes.values()).sort((left, right) => left.path.localeCompare(right.path));\n }\n\n private scanDirectory(dir: string, appDir: string, routes: APIRouteInfo[], basePath = \"\") {\n const items = readdirSync(dir, { withFileTypes: true });\n\n for (const item of items) {\n const fullPath = join(dir, item.name);\n\n if (item.isDirectory()) {\n const newBasePath = basePath ? `${basePath}/${item.name}` : item.name;\n this.scanDirectory(fullPath, appDir, routes, newBasePath);\n } else if (/^route\\.(ts|tsx|js|jsx)$/.test(item.name)) {\n const routeInfo = this.extractRouteInfo(fullPath, appDir, basePath);\n if (routeInfo) {\n routes.push(routeInfo);\n }\n }\n }\n }\n\n private extractRouteInfo(\n filePath: string,\n appDir: string,\n basePath: string,\n ): APIRouteInfo | null {\n try {\n const content = readFileSync(filePath, \"utf-8\");\n const methods = this.extractExportedMethods(content);\n\n if (methods.length === 0) {\n return null;\n }\n\n const relativePath = relative(appDir, filePath);\n const apiPath = basePath ? `/api/${basePath}` : \"/api\";\n\n return {\n path: apiPath,\n methods,\n filePath,\n relativePath,\n };\n } catch (error) {\n console.warn(`Failed to read route file ${filePath}:`, error);\n return null;\n }\n }\n\n private extractExportedMethods(content: string): string[] {\n const methods: string[] = [];\n const httpMethods = [\"GET\", \"POST\", \"PUT\", \"DELETE\", \"PATCH\", \"OPTIONS\", \"HEAD\"];\n\n for (const method of httpMethods) {\n // Look for export const METHOD = or export { METHOD }\n const patterns = [\n new RegExp(`export\\\\s+const\\\\s+${method}\\\\s*=`, \"g\"),\n new RegExp(`export\\\\s+(?:async\\\\s+)?function\\\\s+${method}\\\\s*\\\\(`, \"g\"),\n new RegExp(`export\\\\s*{\\\\s*${method}\\\\s*}`, \"g\"),\n new RegExp(`export\\\\s*{\\\\s*${method}\\\\s*as\\\\s+\\\\w+\\\\s*}`, \"g\"),\n ];\n\n for (const pattern of patterns) {\n if (pattern.test(content)) {\n methods.push(method);\n break;\n }\n }\n }\n\n return methods;\n }\n\n /**\n * Generate TypeScript code for the API router\n */\n generateAPIRouter(routes: APIRouteInfo[], options: { outFile?: string } = {}): string {\n const imports: string[] = [];\n\n // Group routes by path to handle multiple methods\n const routeGroups = new Map<string, APIRouteInfo[]>();\n\n for (const route of routes) {\n const key = route.path;\n if (!routeGroups.has(key)) {\n routeGroups.set(key, []);\n }\n routeGroups.get(key)!.push(route);\n }\n\n // Build nested structure\n const nestedStructure: any = {};\n\n for (const [path, routeList] of routeGroups) {\n const route = routeList[0];\n const importPath = this.getRouteImportPath(route, options.outFile);\n const routeName = this.pathToRouteName(route.path);\n const cleanPath = path === \"/api\" ? \"\" : path.replace(/^\\/api\\//, \"\");\n const parts = cleanPath ? cleanPath.split(\"/\") : [];\n\n // Collect all methods for this route\n const allMethods = routeList.flatMap((r) => r.methods);\n\n // Generate imports\n for (const method of allMethods) {\n const importName = `${method}_${routeName}`;\n imports.push(\n `import type { ${method} as ${importName} } from ${JSON.stringify(importPath)};`,\n );\n }\n\n if (parts.length === 0) {\n for (const method of allMethods) {\n const importName = `${method}_${routeName}`;\n const methodName = method.toLowerCase();\n nestedStructure[methodName] = `typeof ${importName}`;\n }\n } else {\n // Build nested object\n let current = nestedStructure;\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i];\n if (i === parts.length - 1) {\n // Last part - add methods\n current[part] = {};\n for (const method of allMethods) {\n const importName = `${method}_${routeName}`;\n const methodName = method.toLowerCase();\n current[part][methodName] = `typeof ${importName}`;\n }\n } else {\n // Intermediate part - create nested object\n if (!current[part]) {\n current[part] = {};\n }\n current = current[part];\n }\n }\n }\n }\n\n // Convert nested structure to TypeScript code\n const typeExports = this.structureToTypeString(nestedStructure, 1);\n\n return `/**\n * Auto-generated API router types\n * This file is automatically generated - do not edit manually\n *\n * This file contains only TypeScript types for the API client.\n * Runtime imports are used only at the type level.\n */\n\n${imports.join(\"\\n\")}\n\n// Type-only representation of your API routes\nexport type APIRouter = {\n${typeExports}\n};\n`;\n }\n\n private getRouteImportPath(route: APIRouteInfo, outFile?: string): string {\n if (!outFile) {\n return `../app/${route.relativePath.replace(/\\\\/g, \"/\").replace(/\\.(ts|tsx|js|jsx)$/, \"\")}`;\n }\n\n const relativeImport = relative(dirname(outFile), route.filePath)\n .replace(/\\\\/g, \"/\")\n .replace(/\\.(ts|tsx|js|jsx)$/, \"\");\n return relativeImport.startsWith(\".\") ? relativeImport : `./${relativeImport}`;\n }\n\n private pathToRouteName(path: string): string {\n return (path === \"/api\" ? \"root\" : path.replace(/^\\/api\\//, \"\"))\n .replace(/\\//g, \"_\")\n .replace(/[^a-zA-Z0-9_]/g, \"\");\n }\n\n private structureToTypeString(obj: any, indent: number): string {\n const spaces = \" \".repeat(indent);\n const lines: string[] = [];\n\n for (const [key, value] of Object.entries(obj)) {\n const propertyKey = this.toTypePropertyKey(key);\n\n if (typeof value === \"string\") {\n // It's a type reference\n lines.push(`${spaces}${propertyKey}: ${value};`);\n } else if (typeof value === \"object\") {\n // It's a nested object\n lines.push(`${spaces}${propertyKey}: {`);\n lines.push(this.structureToTypeString(value, indent + 1));\n lines.push(`${spaces}};`);\n }\n }\n\n return lines.join(\"\\n\");\n }\n\n private toTypePropertyKey(key: string): string {\n return /^[$A-Z_][0-9A-Z_$]*$/i.test(key) ? key : JSON.stringify(key);\n }\n\n private getBaseExportName(path: string): string {\n const cleanPath = path.replace(/^\\/api\\//, \"\");\n\n if (cleanPath === \"\") {\n return \"api\";\n }\n\n // Convert path to nested structure\n // /api/auth/login -> ['auth', 'login']\n return cleanPath;\n }\n\n private getExportName(path: string, method: string): string {\n const cleanPath = path.replace(/^\\/api\\//, \"\");\n\n if (cleanPath === \"\") {\n return method.toLowerCase();\n }\n\n const parts = cleanPath.split(\"/\");\n if (parts.length === 1) {\n // For single-level paths like /api/hello, just use the path name\n return parts[0];\n }\n\n // For nested paths like /api/auth/login, create nested structure\n // This matches the expected API client usage: api.auth.login()\n return parts.join(\".\");\n }\n\n /**\n * Generate the API index file\n */\n generateAPIIndex(outputPath: string): void {\n const routes = this.scanAPIRoutes();\n const content = this.generateAPIRouter(routes);\n\n mkdirSync(dirname(outputPath), { recursive: true });\n writeFileIfChanged(outputPath, content);\n console.log(`✅ Generated API types for ${routes.length} routes`);\n }\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,cAAc,YAAY,aAAa,iBAAiB;AACjE,SAAS,MAAM,UAAU,eAAe;AAUjC,IAAM,oBAAN,MAAM,kBAAiB;AAAA,EAG5B,YAAY,QAAoC;AAC9C,SAAK,UAAU,MAAM,QAAQ,MAAM,IAAI,CAAC,GAAG,MAAM,IAAI,CAAC,MAAgB;AAAA,EACxE;AAAA;AAAA;AAAA;AAAA,EAKA,gBAAgC;AAC9B,UAAM,SAAS,oBAAI,IAA0B;AAE7C,eAAW,UAAU,KAAK,SAAS;AACjC,YAAM,SAAS,KAAK,QAAQ,KAAK;AACjC,UAAI,CAAC,WAAW,MAAM,EAAG;AAEzB,YAAM,aAA6B,CAAC;AACpC,WAAK,cAAc,QAAQ,QAA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AACjC,QAAI,MAAM,WAAW,GAAG;AAEtB,aAAO,MAAM,CAAC;AAAA,IAChB;AAIA,WAAO,MAAM,KAAK,GAAG;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA,EAKA,iBAAiB,YAA0B;AACzC,UAAM,SAAS,KAAK,cAAc;AAClC,UAAM,UAAU,KAAK,kBAAkB,MAAM;AAE7C,cAAU,QAAQ,UAAU,GAAG,EAAE,WAAW,KAAK,CAAC;AAClD,uBAAmB,YAAY,OAAO;AACtC,YAAQ,IAAI,kCAA6B,OAAO,MAAM,SAAS;AAAA,EACjE;AACF;AA5Q8B;AAAvB,IAAM,mBAAN;","names":[]}
@@ -0,0 +1,24 @@
1
+ import {
2
+ __name
3
+ } from "./chunk-CGILA3WO.mjs";
4
+
5
+ // src/server/request-bridge.ts
6
+ var CURRENT_REQUEST_RESOLVER_KEY = /* @__PURE__ */ Symbol.for("farm.currentRequestResolver");
7
+ function getGlobalState() {
8
+ return globalThis;
9
+ }
10
+ __name(getGlobalState, "getGlobalState");
11
+ function _setCurrentRequestResolver(resolver) {
12
+ getGlobalState()[CURRENT_REQUEST_RESOLVER_KEY] = resolver;
13
+ }
14
+ __name(_setCurrentRequestResolver, "_setCurrentRequestResolver");
15
+ function _resolveCurrentRequest() {
16
+ return getGlobalState()[CURRENT_REQUEST_RESOLVER_KEY]?.();
17
+ }
18
+ __name(_resolveCurrentRequest, "_resolveCurrentRequest");
19
+
20
+ export {
21
+ _setCurrentRequestResolver,
22
+ _resolveCurrentRequest
23
+ };
24
+ //# sourceMappingURL=chunk-LM2YNO4U.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/request-bridge.ts"],"sourcesContent":["type CurrentRequestResolver = () => Request | undefined;\n\nconst CURRENT_REQUEST_RESOLVER_KEY = Symbol.for(\"farm.currentRequestResolver\");\n\ntype GlobalWithCurrentRequestResolver = typeof globalThis & {\n [CURRENT_REQUEST_RESOLVER_KEY]?: CurrentRequestResolver;\n};\n\nfunction getGlobalState(): GlobalWithCurrentRequestResolver {\n return globalThis as GlobalWithCurrentRequestResolver;\n}\n\nexport function _setCurrentRequestResolver(resolver: CurrentRequestResolver | undefined): void {\n getGlobalState()[CURRENT_REQUEST_RESOLVER_KEY] = resolver;\n}\n\nexport function _resolveCurrentRequest(): Request | undefined {\n return getGlobalState()[CURRENT_REQUEST_RESOLVER_KEY]?.();\n}\n"],"mappings":";;;;;AAEA,IAAM,+BAA+B,uBAAO,IAAI,6BAA6B;AAM7E,SAAS,iBAAmD;AAC1D,SAAO;AACT;AAFS;AAIF,SAAS,2BAA2B,UAAoD;AAC7F,iBAAe,EAAE,4BAA4B,IAAI;AACnD;AAFgB;AAIT,SAAS,yBAA8C;AAC5D,SAAO,eAAe,EAAE,4BAA4B,IAAI;AAC1D;AAFgB;","names":[]}