@farm.js/core 0.1.16 → 0.1.18

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 (390) hide show
  1. package/dist/after.cjs +12 -225
  2. package/dist/agent-runtime.cjs +83 -2800
  3. package/dist/agent-runtime.d.mts +3 -3
  4. package/dist/agent-runtime.d.ts +3 -3
  5. package/dist/api/client.cjs +17 -4026
  6. package/dist/api/client.d.mts +3 -3
  7. package/dist/api/client.d.ts +3 -3
  8. package/dist/api/client.mjs +3 -3
  9. package/dist/api/route-manager.cjs +34 -4317
  10. package/dist/api/route-manager.d.mts +3 -3
  11. package/dist/api/route-manager.d.ts +3 -3
  12. package/dist/api/route-manager.mjs +5 -5
  13. package/dist/api/runtime.cjs +29 -2660
  14. package/dist/api/runtime.d.mts +3 -3
  15. package/dist/api/runtime.d.ts +3 -3
  16. package/dist/api/runtime.mjs +6 -3
  17. package/dist/{api-client-B-n3pm_Q.d.mts → api-client-Cx54IR5g.d.mts} +2 -2
  18. package/dist/{api-client-C0_NZEBl.d.ts → api-client-DykpaKcY.d.ts} +2 -2
  19. package/dist/api.cjs +88 -8361
  20. package/dist/api.d.mts +5 -5
  21. package/dist/api.d.ts +5 -5
  22. package/dist/api.mjs +8 -8
  23. package/dist/{app-AyjEsCBq.d.ts → app-BHY_10Lm.d.ts} +3 -3
  24. package/dist/{app-CYPHeOo_.d.mts → app-BMk0do23.d.mts} +3 -3
  25. package/dist/app-markdown.cjs +39 -280
  26. package/dist/app-markdown.d.mts +4 -4
  27. package/dist/app-markdown.d.ts +4 -4
  28. package/dist/app-markdown.mjs +3 -3
  29. package/dist/cache.cjs +38 -1526
  30. package/dist/cache.d.mts +11 -1
  31. package/dist/cache.d.ts +11 -1
  32. package/dist/cache.mjs +1 -1
  33. package/dist/chunk-22GUSVNJ.cjs +351 -0
  34. package/dist/chunk-2CQ74SP6.cjs +13 -0
  35. package/dist/chunk-2SJ4RQ6P.cjs +57 -0
  36. package/dist/chunk-3376ZTRC.cjs +1 -0
  37. package/dist/{chunk-IL5RWYK7.mjs → chunk-3XG26Z3J.mjs} +1 -1
  38. package/dist/{chunk-7HDZYYS4.mjs → chunk-4OOBRCJX.mjs} +27 -5
  39. package/dist/chunk-4PNUXIVU.cjs +472 -0
  40. package/dist/chunk-4PPEPOZZ.cjs +21 -0
  41. package/dist/chunk-4ZFL5GFN.cjs +520 -0
  42. package/dist/{chunk-B76DT5Y6.mjs → chunk-57J3Y7Y3.mjs} +1 -1
  43. package/dist/chunk-5OVTOKGH.cjs +65 -0
  44. package/dist/chunk-5QIKR7RR.cjs +224 -0
  45. package/dist/{chunk-MOQNHLTS.mjs → chunk-5QOEPUYE.mjs} +5 -2
  46. package/dist/{chunk-HKLRP3BN.mjs → chunk-5SPPCN5J.mjs} +1 -1
  47. package/dist/chunk-5ZSWG4UX.cjs +127 -0
  48. package/dist/chunk-62YJ2IEB.cjs +238 -0
  49. package/dist/chunk-6EODJYCX.cjs +183 -0
  50. package/dist/chunk-6EXBPJ24.cjs +434 -0
  51. package/dist/chunk-6QQDAAAZ.cjs +38 -0
  52. package/dist/chunk-6V4TDWEC.cjs +455 -0
  53. package/dist/{chunk-LUC2FAGW.mjs → chunk-6VQIKZZO.mjs} +1 -1
  54. package/dist/chunk-72ADZ6GQ.cjs +19 -0
  55. package/dist/chunk-75BRBIFP.cjs +172 -0
  56. package/dist/{chunk-7ZWL7XOU.mjs → chunk-76DG3LF3.mjs} +1 -1
  57. package/dist/chunk-7W3CPVXS.cjs +24 -0
  58. package/dist/chunk-A6WIQH5Z.cjs +31 -0
  59. package/dist/{chunk-EWDK36MM.mjs → chunk-A72YEUZ3.mjs} +1 -1
  60. package/dist/chunk-AFOD3LYZ.cjs +377 -0
  61. package/dist/chunk-AMDMVWMI.cjs +39 -0
  62. package/dist/chunk-AORPIPNB.cjs +552 -0
  63. package/dist/chunk-ARJWXNQL.cjs +256 -0
  64. package/dist/{chunk-ZHOIQC6U.mjs → chunk-ATERBVHQ.mjs} +2 -2
  65. package/dist/chunk-AWRISO2H.cjs +2199 -0
  66. package/dist/chunk-AYJR42WX.cjs +711 -0
  67. package/dist/chunk-B4CH33IG.cjs +644 -0
  68. package/dist/chunk-BIDYX3SL.cjs +91 -0
  69. package/dist/chunk-BSTRERPP.cjs +40 -0
  70. package/dist/chunk-BYODCJD6.cjs +663 -0
  71. package/dist/chunk-C3VRMB6H.cjs +85 -0
  72. package/dist/chunk-C5GUTBZK.cjs +173 -0
  73. package/dist/chunk-CIAGU2X4.cjs +337 -0
  74. package/dist/chunk-CMGMGHUZ.cjs +27 -0
  75. package/dist/chunk-CXP5U3RW.cjs +54 -0
  76. package/dist/chunk-D2ULAULS.cjs +166 -0
  77. package/dist/chunk-D7JTOLFK.cjs +285 -0
  78. package/dist/chunk-DVM4FKZL.cjs +169 -0
  79. package/dist/chunk-DYEJQTDN.cjs +49 -0
  80. package/dist/chunk-E2BMSZ2W.cjs +151 -0
  81. package/dist/chunk-E3UK5IIB.cjs +593 -0
  82. package/dist/chunk-EM6SBQKM.cjs +470 -0
  83. package/dist/{chunk-27JNCYEK.mjs → chunk-EN7WTEAY.mjs} +2 -2
  84. package/dist/{chunk-IGO2HEV7.mjs → chunk-F6SJAKFJ.mjs} +62 -28
  85. package/dist/{chunk-GSDIZACQ.mjs → chunk-FG5H2VCJ.mjs} +2 -2
  86. package/dist/chunk-FJSWYIR7.cjs +482 -0
  87. package/dist/chunk-FK6GO24V.cjs +54 -0
  88. package/dist/chunk-FXUUWYAX.cjs +654 -0
  89. package/dist/chunk-G3HRIVEY.cjs +395 -0
  90. package/dist/chunk-G643DQCH.cjs +13 -0
  91. package/dist/chunk-G7HXGLEC.cjs +175 -0
  92. package/dist/chunk-GDSHDTJ4.cjs +152 -0
  93. package/dist/chunk-GNEO2XOF.cjs +2040 -0
  94. package/dist/{chunk-NHHKW2T6.mjs → chunk-GYKJCFTS.mjs} +170 -52
  95. package/dist/chunk-H6G5INWM.cjs +1094 -0
  96. package/dist/chunk-HBTUGXHS.cjs +180 -0
  97. package/dist/chunk-HREOKQWT.cjs +45 -0
  98. package/dist/chunk-I4J452B7.cjs +435 -0
  99. package/dist/chunk-I57LW5VZ.cjs +94 -0
  100. package/dist/chunk-I7PUUDGY.cjs +389 -0
  101. package/dist/chunk-IAMRBF3Z.cjs +86 -0
  102. package/dist/chunk-IKNRN4VS.cjs +14214 -0
  103. package/dist/chunk-IQXFRNY2.cjs +169 -0
  104. package/dist/chunk-IXTFU4PL.cjs +2355 -0
  105. package/dist/chunk-J2OP5GG3.cjs +725 -0
  106. package/dist/chunk-J3LOGE4T.cjs +42 -0
  107. package/dist/chunk-J7FSKED3.cjs +93 -0
  108. package/dist/chunk-JDNHKPTD.cjs +22 -0
  109. package/dist/chunk-JSROZYYO.cjs +164 -0
  110. package/dist/chunk-K6FNHVDR.cjs +696 -0
  111. package/dist/chunk-KGZIORNL.cjs +43 -0
  112. package/dist/{chunk-LZK5CXDW.mjs → chunk-KLSSO6YD.mjs} +2 -2
  113. package/dist/{chunk-TYVVIQ5M.mjs → chunk-KPNVGRBL.mjs} +32 -25
  114. package/dist/chunk-KR6CKSXT.cjs +15 -0
  115. package/dist/chunk-KROWKCUH.cjs +185 -0
  116. package/dist/chunk-KVFPGF2M.cjs +46 -0
  117. package/dist/{chunk-KUO3GBPK.mjs → chunk-L6V3P73N.mjs} +1 -1
  118. package/dist/chunk-LCCBO7PJ.cjs +46 -0
  119. package/dist/chunk-LIUGYUX3.cjs +22 -0
  120. package/dist/chunk-LTNGXMQ6.cjs +55 -0
  121. package/dist/chunk-M2L4MYDQ.cjs +14 -0
  122. package/dist/chunk-MCJLA63J.cjs +1 -0
  123. package/dist/chunk-MKB2EGIR.cjs +148 -0
  124. package/dist/chunk-MQ3H6LT5.cjs +202 -0
  125. package/dist/chunk-MT763TDW.cjs +43 -0
  126. package/dist/chunk-MWSK6C4J.cjs +18 -0
  127. package/dist/chunk-MWWVKDW3.cjs +169 -0
  128. package/dist/{chunk-KTGFMHET.mjs → chunk-N6UROPT7.mjs} +1 -1
  129. package/dist/chunk-NO3WWW3N.cjs +192 -0
  130. package/dist/{chunk-NDD2YVGU.mjs → chunk-NRVGEI5I.mjs} +10 -3
  131. package/dist/chunk-NV3A5DXM.cjs +862 -0
  132. package/dist/chunk-NWOD6NIT.cjs +9 -0
  133. package/dist/chunk-NZKJGRB3.cjs +230 -0
  134. package/dist/chunk-OAVTUMJP.cjs +1496 -0
  135. package/dist/chunk-OHY2ZWUG.cjs +25 -0
  136. package/dist/chunk-OI6CMLWX.cjs +47 -0
  137. package/dist/chunk-OIEOCXKG.cjs +453 -0
  138. package/dist/chunk-OWOUTKIJ.cjs +558 -0
  139. package/dist/chunk-OX6O6WVA.cjs +74 -0
  140. package/dist/chunk-OXSIH4D6.cjs +476 -0
  141. package/dist/chunk-OYEUREB6.cjs +35 -0
  142. package/dist/chunk-PCOTGFSM.cjs +139 -0
  143. package/dist/chunk-PZYCPSCC.cjs +35 -0
  144. package/dist/chunk-QBK2AA4U.cjs +445 -0
  145. package/dist/chunk-QBPXNZGV.cjs +487 -0
  146. package/dist/{chunk-IXTEENRS.mjs → chunk-QGVJVSNX.mjs} +5 -5
  147. package/dist/chunk-QNPEUFHQ.cjs +27 -0
  148. package/dist/chunk-QZRVZSPN.cjs +236 -0
  149. package/dist/chunk-R5A5KNVX.cjs +20 -0
  150. package/dist/chunk-R5JIFR6B.cjs +42 -0
  151. package/dist/chunk-R6AIILII.cjs +193 -0
  152. package/dist/chunk-RG3ZOTG5.cjs +34 -0
  153. package/dist/chunk-ROUTX2E5.cjs +390 -0
  154. package/dist/chunk-RTHIVJ2G.cjs +54 -0
  155. package/dist/chunk-S3A45T7F.cjs +166 -0
  156. package/dist/chunk-S3JO3N4H.cjs +17 -0
  157. package/dist/chunk-SK35NQKK.cjs +27 -0
  158. package/dist/chunk-SU7MH53P.cjs +180 -0
  159. package/dist/chunk-SVRTJOUF.cjs +113 -0
  160. package/dist/chunk-SWN467MP.cjs +18 -0
  161. package/dist/{chunk-6SCB2MXB.mjs → chunk-SXHV42UQ.mjs} +16 -1
  162. package/dist/{chunk-OWTIOHON.mjs → chunk-SYGGPS4A.mjs} +2 -2
  163. package/dist/chunk-SYQ3MOWW.cjs +73 -0
  164. package/dist/chunk-T5CERMEH.cjs +417 -0
  165. package/dist/chunk-TFAXUHWX.cjs +206 -0
  166. package/dist/chunk-TIWHTW3Q.cjs +24 -0
  167. package/dist/chunk-TKJZFIML.cjs +20 -0
  168. package/dist/chunk-TKNSDBBN.cjs +193 -0
  169. package/dist/{chunk-NC333MFA.mjs → chunk-TSWW5BVH.mjs} +7 -4
  170. package/dist/chunk-TWGMSEHX.cjs +525 -0
  171. package/dist/chunk-TYQUSXUG.cjs +1357 -0
  172. package/dist/chunk-U4KT7QP3.cjs +23 -0
  173. package/dist/{chunk-LK6FGAQR.mjs → chunk-UDBJCUPA.mjs} +7 -4
  174. package/dist/chunk-UJ2C4ICS.cjs +277 -0
  175. package/dist/chunk-UN5GHC5V.cjs +10244 -0
  176. package/dist/chunk-UQZ4AYTH.cjs +168 -0
  177. package/dist/chunk-US2QVW3E.cjs +36 -0
  178. package/dist/{chunk-NUD6XBMO.mjs → chunk-UTBVHYS3.mjs} +2 -2
  179. package/dist/{chunk-76MNRHTS.mjs → chunk-UUYF3CHN.mjs} +2 -2
  180. package/dist/chunk-VB6UCX3V.cjs +421 -0
  181. package/dist/chunk-VEKFLAQM.cjs +300 -0
  182. package/dist/chunk-VQDBNVOO.cjs +14 -0
  183. package/dist/chunk-W4E7WMXE.cjs +71 -0
  184. package/dist/{chunk-VVTREAG5.mjs → chunk-WD4YXVLV.mjs} +11 -3
  185. package/dist/{chunk-UQZPTIML.mjs → chunk-WD5PNSOB.mjs} +2 -2
  186. package/dist/chunk-WJ3HK3LJ.cjs +1102 -0
  187. package/dist/chunk-WMAPPDMM.cjs +28 -0
  188. package/dist/chunk-WMOGFOUJ.cjs +223 -0
  189. package/dist/chunk-WPYFSQKK.cjs +37 -0
  190. package/dist/chunk-WZMNW2IW.cjs +1415 -0
  191. package/dist/chunk-XGC343EY.cjs +443 -0
  192. package/dist/{chunk-DPZUDPVJ.mjs → chunk-XP777LRD.mjs} +1 -1
  193. package/dist/chunk-XSKZORAS.cjs +727 -0
  194. package/dist/chunk-XWAWFQFS.cjs +82 -0
  195. package/dist/{chunk-KATQ6I56.mjs → chunk-XWAYMDLB.mjs} +1 -1
  196. package/dist/chunk-Y4YMF2NQ.cjs +460 -0
  197. package/dist/chunk-Y4YWHNKU.cjs +250 -0
  198. package/dist/chunk-Y53ZSFN6.cjs +504 -0
  199. package/dist/chunk-YA6LLTIJ.cjs +411 -0
  200. package/dist/chunk-YFPGHF5F.cjs +202 -0
  201. package/dist/chunk-YJRZR7VU.cjs +28 -0
  202. package/dist/chunk-YTAABQEV.cjs +1 -0
  203. package/dist/chunk-YX3DBN4M.cjs +18 -0
  204. package/dist/chunk-YZTASLPQ.cjs +64 -0
  205. package/dist/chunk-Z5HIWVDP.cjs +2173 -0
  206. package/dist/{chunk-Q3MDL7TM.mjs → chunk-ZCNJKLA2.mjs} +30 -11
  207. package/dist/chunk-ZEG3OPIB.cjs +93 -0
  208. package/dist/chunk-ZMN3H73H.cjs +155 -0
  209. package/dist/client/lifecycle.cjs +6 -35
  210. package/dist/{client-plugins-CqVtZi5X.d.ts → client-plugins-C089bQhN.d.ts} +2 -2
  211. package/dist/{client-plugins-CIPRtSsW.d.mts → client-plugins-JXXmZliS.d.mts} +2 -2
  212. package/dist/client-plugins.cjs +7 -448
  213. package/dist/client-plugins.d.mts +3 -3
  214. package/dist/client-plugins.d.ts +3 -3
  215. package/dist/client.cjs +171 -9774
  216. package/dist/client.d.mts +8 -8
  217. package/dist/client.d.ts +8 -8
  218. package/dist/client.mjs +6 -6
  219. package/dist/config.cjs +8 -36
  220. package/dist/config.d.mts +3 -3
  221. package/dist/config.d.ts +3 -3
  222. package/dist/cron.cjs +24 -491
  223. package/dist/cron.mjs +2 -2
  224. package/dist/deferred.cjs +26 -475
  225. package/dist/deployment.cjs +39 -210
  226. package/dist/devtools-OUIPHVV6.cjs +388 -0
  227. package/dist/{devtools-IU7LKZOH.mjs → devtools-UFVTMQX5.mjs} +7 -7
  228. package/dist/devtools-client-4WAPJY5L.cjs +254 -0
  229. package/dist/devtools-ui-5GBDIGMK.cjs +1296 -0
  230. package/dist/docs.cjs +46 -5649
  231. package/dist/docs.mjs +9 -9
  232. package/dist/{endpoint-kSAxE52R.d.ts → endpoint-1zA994xL.d.ts} +1 -1
  233. package/dist/{endpoint-Bu3XgeMK.d.mts → endpoint-DAc96i93.d.mts} +1 -1
  234. package/dist/env-types.cjs +5 -226
  235. package/dist/env.cjs +23 -306
  236. package/dist/env.d.mts +5 -3
  237. package/dist/env.d.ts +5 -3
  238. package/dist/env.mjs +2 -1
  239. package/dist/environment/vite.cjs +8 -372
  240. package/dist/environment.cjs +12 -94
  241. package/dist/font.cjs +13 -63
  242. package/dist/headers.cjs +7 -123
  243. package/dist/i18n/client.cjs +55 -294
  244. package/dist/i18n/index.cjs +22 -209
  245. package/dist/i18n/server.cjs +22 -745
  246. package/dist/image/server.cjs +13 -729
  247. package/dist/image/sharp.cjs +33 -171
  248. package/dist/image.cjs +41 -85
  249. package/dist/index.cjs +1151 -67862
  250. package/dist/index.d.mts +14 -14
  251. package/dist/index.d.ts +14 -14
  252. package/dist/index.mjs +34 -34
  253. package/dist/instrumentation.cjs +12 -138
  254. package/dist/integration-orm-55F7CII5.cjs +13 -0
  255. package/dist/integrations.cjs +55 -4090
  256. package/dist/integrations.d.mts +3 -3
  257. package/dist/integrations.d.ts +3 -3
  258. package/dist/internal/app-markdown-runtime.cjs +27 -224
  259. package/dist/internal/app-markdown-runtime.d.mts +3 -3
  260. package/dist/internal/app-markdown-runtime.d.ts +3 -3
  261. package/dist/internal/app-markdown-runtime.mjs +2 -2
  262. package/dist/internal/build-runtime.cjs +120 -52038
  263. package/dist/internal/build-runtime.d.mts +5 -5
  264. package/dist/internal/build-runtime.d.ts +5 -5
  265. package/dist/internal/build-runtime.mjs +23 -23
  266. package/dist/internal/cli-runtime.cjs +67 -13765
  267. package/dist/internal/cli-runtime.mjs +13 -13
  268. package/dist/internal/client-error-overlay.cjs +80 -733
  269. package/dist/internal/client-error-overlay.mjs +1 -1
  270. package/dist/internal/client-runtime.cjs +81 -913
  271. package/dist/internal/compression-runtime.cjs +8 -214
  272. package/dist/internal/compression-runtime.d.mts +3 -3
  273. package/dist/internal/compression-runtime.d.ts +3 -3
  274. package/dist/internal/config-runtime.cjs +42 -6535
  275. package/dist/internal/config-runtime.d.mts +4 -4
  276. package/dist/internal/config-runtime.d.ts +4 -4
  277. package/dist/internal/config-runtime.mjs +7 -7
  278. package/dist/internal/docs-precompiled-runtime.cjs +26 -46
  279. package/dist/internal/infra-analytics-runtime.cjs +10 -536
  280. package/dist/internal/isolated-boundary.cjs +14 -414
  281. package/dist/internal/metadata-image-runtime.cjs +7 -285
  282. package/dist/internal/product-telemetry-runtime.cjs +42 -97
  283. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  284. package/dist/internal/production-node-env.cjs +6 -63
  285. package/dist/internal/production-runtime.cjs +418 -7073
  286. package/dist/internal/production-runtime.d.mts +9 -9
  287. package/dist/internal/production-runtime.d.ts +9 -9
  288. package/dist/internal/production-runtime.mjs +6 -6
  289. package/dist/internal/request-cookies.cjs +6 -54
  290. package/dist/json-ld.cjs +24 -50
  291. package/dist/layers-E4WPJNY5.cjs +17 -0
  292. package/dist/manager-G4B2IPYE.cjs +14 -0
  293. package/dist/markdown.cjs +21 -532
  294. package/dist/markdown.mjs +1 -1
  295. package/dist/{metadata-8g__AMPM.d.ts → metadata-BcNJP4fq.d.ts} +1 -1
  296. package/dist/{metadata-OMX6wFNf.d.mts → metadata-C1Z9vLbb.d.mts} +1 -1
  297. package/dist/middleware.cjs +36 -2988
  298. package/dist/middleware.d.mts +5 -5
  299. package/dist/middleware.d.ts +5 -5
  300. package/dist/middleware.mjs +4 -4
  301. package/dist/navigation.cjs +22 -2588
  302. package/dist/nitro-4I2MYLY2.cjs +652 -0
  303. package/dist/{nitro-3N4ZXRYM.mjs → nitro-CVZ36JM5.mjs} +4 -4
  304. package/dist/observability.cjs +22 -614
  305. package/dist/og.cjs +5 -28
  306. package/dist/plugin.cjs +106 -37291
  307. package/dist/plugin.d.mts +3 -3
  308. package/dist/plugin.d.ts +3 -3
  309. package/dist/plugin.mjs +19 -19
  310. package/dist/{production-runtime-W3M0eNDV.d.mts → production-runtime-jcrTlRTb.d.mts} +1 -1
  311. package/dist/{production-runtime-BJh7o6Cr.d.ts → production-runtime-oKmC0WU-.d.ts} +1 -1
  312. package/dist/query/client.cjs +113 -449
  313. package/dist/query/index.cjs +26 -288
  314. package/dist/query/parsers.cjs +23 -247
  315. package/dist/query/server.cjs +36 -298
  316. package/dist/{render-plan-io7pvDNc.d.mts → render-plan-BLIfc4jt.d.mts} +1 -1
  317. package/dist/{render-plan-Be4ZGTJP.d.ts → render-plan-DOB9cV-h.d.ts} +1 -1
  318. package/dist/renderer/react/client.cjs +9 -43
  319. package/dist/renderer/react/server.cjs +40 -103
  320. package/dist/renderer/react/vite.cjs +7 -29
  321. package/dist/renderer-client.cjs +126 -4261
  322. package/dist/renderer-client.d.mts +5 -5
  323. package/dist/renderer-client.d.ts +5 -5
  324. package/dist/renderer-client.mjs +3 -3
  325. package/dist/renderer.cjs +31 -249
  326. package/dist/{request-DZkHYQ89.d.mts → request-Cr53NRHr.d.mts} +1 -1
  327. package/dist/{request-G8JhKr4F.d.ts → request-Dt2gNuQD.d.ts} +1 -1
  328. package/dist/request.cjs +5 -68
  329. package/dist/request.d.mts +4 -4
  330. package/dist/request.d.ts +4 -4
  331. package/dist/{route-C_eLaFTZ.d.mts → route-B0XrsrFk.d.mts} +1 -1
  332. package/dist/{route-BxNJT447.d.ts → route-DOEpbyWZ.d.ts} +1 -1
  333. package/dist/{route-rendering-BcLLPJgN.d.ts → route-rendering-CWYd8Mv1.d.ts} +1 -1
  334. package/dist/{route-rendering-CbAKr1TY.d.mts → route-rendering-CeFBEAoZ.d.mts} +1 -1
  335. package/dist/router.cjs +11 -474
  336. package/dist/routes.cjs +42 -2424
  337. package/dist/routes.d.mts +4 -4
  338. package/dist/routes.d.ts +4 -4
  339. package/dist/routes.mjs +2 -2
  340. package/dist/schema-dev-notice-MXSZMVDG.cjs +56 -0
  341. package/dist/schema.cjs +6 -33
  342. package/dist/search-client-G3RICOFU.cjs +13 -0
  343. package/dist/server-action-security.cjs +25 -541
  344. package/dist/server-fn-client.cjs +6 -337
  345. package/dist/server-fn-client.d.mts +3 -3
  346. package/dist/server-fn-client.d.ts +3 -3
  347. package/dist/server-fn.cjs +32 -1799
  348. package/dist/server-fn.d.mts +1 -1
  349. package/dist/server-fn.d.ts +1 -1
  350. package/dist/server-fn.mjs +2 -2
  351. package/dist/server-plugins.cjs +15 -884
  352. package/dist/server-plugins.d.mts +4 -4
  353. package/dist/server-plugins.d.ts +4 -4
  354. package/dist/server-query-client.cjs +15 -1849
  355. package/dist/server-query-client.d.mts +1 -1
  356. package/dist/server-query-client.d.ts +1 -1
  357. package/dist/server-query-client.mjs +4 -4
  358. package/dist/server-query.cjs +16 -1796
  359. package/dist/server-query.d.mts +1 -1
  360. package/dist/server-query.d.ts +1 -1
  361. package/dist/server-query.mjs +3 -3
  362. package/dist/server.cjs +296 -44522
  363. package/dist/server.d.mts +9 -9
  364. package/dist/server.d.ts +9 -9
  365. package/dist/server.mjs +22 -22
  366. package/dist/{spa-router-BcS_4nqm.d.mts → spa-router-CQWiYGxS.d.mts} +2 -2
  367. package/dist/{spa-router-BzFBUJkn.d.ts → spa-router-Wjiw-8hB.d.ts} +2 -2
  368. package/dist/storage.cjs +57 -576
  369. package/dist/testing.cjs +92 -3148
  370. package/dist/testing.d.mts +3 -3
  371. package/dist/testing.d.ts +3 -3
  372. package/dist/testing.mjs +11 -7
  373. package/dist/theme/client.cjs +13 -108
  374. package/dist/theme/index.cjs +6 -68
  375. package/dist/theme/runtime.cjs +13 -78
  376. package/dist/theme/server.cjs +10 -179
  377. package/dist/{utils-C4yrAhNc.d.ts → utils-B0XJmG_b.d.ts} +1 -1
  378. package/dist/{utils-5kQP1mFR.d.mts → utils-uUxF0K0P.d.mts} +1 -1
  379. package/dist/version.cjs +4 -32
  380. package/dist/version.mjs +1 -1
  381. package/dist/vite.cjs +119 -37622
  382. package/dist/vite.d.mts +3 -3
  383. package/dist/vite.d.ts +3 -3
  384. package/dist/vite.mjs +19 -19
  385. package/dist/workflows.cjs +19 -1040
  386. package/dist/workflows.mjs +2 -2
  387. package/package.json +2 -2
  388. package/dist/{chunk-VO5SCWF5.mjs → chunk-BNGS6KJ6.mjs} +0 -0
  389. package/dist/{chunk-MUUZJLCI.mjs → chunk-EGJDUF4Q.mjs} +3 -3
  390. package/dist/{chunk-4L7SZOHZ.mjs → chunk-YHOCRI4H.mjs} +3 -3
@@ -0,0 +1,2173 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+
4
+
5
+
6
+ var _chunkSVRTJOUFcjs = require('./chunk-SVRTJOUF.cjs');
7
+
8
+
9
+ var _chunkG643DQCHcjs = require('./chunk-G643DQCH.cjs');
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+ var _chunkEM6SBQKMcjs = require('./chunk-EM6SBQKM.cjs');
22
+
23
+
24
+
25
+ var _chunkUQZ4AYTHcjs = require('./chunk-UQZ4AYTH.cjs');
26
+
27
+
28
+
29
+ var _chunkNZKJGRB3cjs = require('./chunk-NZKJGRB3.cjs');
30
+
31
+
32
+ var _chunkDVM4FKZLcjs = require('./chunk-DVM4FKZL.cjs');
33
+
34
+
35
+
36
+ var _chunkUS2QVW3Ecjs = require('./chunk-US2QVW3E.cjs');
37
+
38
+
39
+
40
+
41
+
42
+ var _chunkNO3WWW3Ncjs = require('./chunk-NO3WWW3N.cjs');
43
+
44
+
45
+ var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
46
+
47
+ // src/integration-request-security.ts
48
+ function resolveIntegrationAllowedOrigins(values, label) {
49
+ return Object.freeze((_nullishCoalesce(values, () => ( []))).map((value) => _chunkSVRTJOUFcjs.normalizeAllowedOriginPattern.call(void 0, value, label)));
50
+ }
51
+ _chunkS3JO3N4Hcjs.__name.call(void 0, resolveIntegrationAllowedOrigins, "resolveIntegrationAllowedOrigins");
52
+ function validateIntegrationRequestOrigin(request, policy = {}) {
53
+ const allowedOrigins = _nullishCoalesce(policy.allowedOrigins, () => ( []));
54
+ const requireOriginMetadata = _nullishCoalesce(policy.requireOriginMetadata, () => ( true));
55
+ const fetchSite = _optionalChain([request, 'access', _ => _.headers, 'access', _2 => _2.get, 'call', _3 => _3("sec-fetch-site"), 'optionalAccess', _4 => _4.trim, 'call', _5 => _5(), 'access', _6 => _6.toLowerCase, 'call', _7 => _7()]);
56
+ const source = _chunkSVRTJOUFcjs.getRequestSourceOrigin.call(void 0, request);
57
+ if (!source.ok) {
58
+ return { ok: false, reason: source.reason };
59
+ }
60
+ if (source.origin === null) {
61
+ if (fetchSite === "same-origin") {
62
+ return { ok: true };
63
+ }
64
+ if (requireOriginMetadata) {
65
+ return { ok: false, reason: fetchSite === "cross-site" ? "cross-site" : "missing-origin" };
66
+ }
67
+ return fetchSite === "cross-site" ? { ok: false, reason: "cross-site" } : { ok: true };
68
+ }
69
+ const requestUrl = new URL(request.url);
70
+ const matchesConfiguredOrigin = allowedOrigins.some(
71
+ (pattern) => _chunkSVRTJOUFcjs.matchesAllowedOrigin.call(void 0, source.origin, pattern)
72
+ );
73
+ const matchesRequest = source.origin === requestUrl.origin || _chunkSVRTJOUFcjs.matchesHostHeader.call(void 0, source.origin, request);
74
+ if (!matchesRequest && !matchesConfiguredOrigin) {
75
+ return { ok: false, reason: "cross-site" };
76
+ }
77
+ if (fetchSite === "cross-site" && !matchesConfiguredOrigin) {
78
+ return { ok: false, reason: "cross-site" };
79
+ }
80
+ return { ok: true };
81
+ }
82
+ _chunkS3JO3N4Hcjs.__name.call(void 0, validateIntegrationRequestOrigin, "validateIntegrationRequestOrigin");
83
+ function describeIntegrationOriginRejection(reason) {
84
+ switch (reason) {
85
+ case "missing-origin":
86
+ return "Request is missing same-origin metadata.";
87
+ case "opaque-origin":
88
+ return "Opaque origins are not allowed.";
89
+ case "invalid-origin":
90
+ return "Invalid request origin.";
91
+ case "cross-site":
92
+ return "Cross-site request was rejected.";
93
+ }
94
+ }
95
+ _chunkS3JO3N4Hcjs.__name.call(void 0, describeIntegrationOriginRejection, "describeIntegrationOriginRejection");
96
+
97
+ // src/plugin-integration-context.ts
98
+ var FARM_PLUGIN_INTEGRATION_CONTEXT = /* @__PURE__ */ Symbol.for("@farm.js/core/plugin-integration-context");
99
+ function setFarmPluginIntegrationContext(plugin, integration) {
100
+ Object.defineProperty(plugin, FARM_PLUGIN_INTEGRATION_CONTEXT, {
101
+ value: integration
102
+ });
103
+ }
104
+ _chunkS3JO3N4Hcjs.__name.call(void 0, setFarmPluginIntegrationContext, "setFarmPluginIntegrationContext");
105
+ function getFarmPluginIntegrationContext(plugin) {
106
+ const value = plugin[FARM_PLUGIN_INTEGRATION_CONTEXT];
107
+ return value && typeof value === "object" ? value : void 0;
108
+ }
109
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getFarmPluginIntegrationContext, "getFarmPluginIntegrationContext");
110
+
111
+ // src/integrations.ts
112
+ var FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY = "farm.integration.internalDispatch";
113
+ var FARM_INTEGRATION_SET_COOKIES_KEY = "farm:integration:set-cookies";
114
+ function forwardIntegrationSetCookies(context, cookies) {
115
+ if (cookies.length === 0) return;
116
+ const existing = _nullishCoalesce(context.req.get(FARM_INTEGRATION_SET_COOKIES_KEY), () => ( []));
117
+ context.req.set(FARM_INTEGRATION_SET_COOKIES_KEY, [...existing, ...cookies]);
118
+ }
119
+ _chunkS3JO3N4Hcjs.__name.call(void 0, forwardIntegrationSetCookies, "forwardIntegrationSetCookies");
120
+ function takeForwardedIntegrationSetCookies(context) {
121
+ const cookies = context.req.get(FARM_INTEGRATION_SET_COOKIES_KEY);
122
+ if (cookies && cookies.length > 0) {
123
+ context.req.delete(FARM_INTEGRATION_SET_COOKIES_KEY);
124
+ return cookies;
125
+ }
126
+ if (cookies) {
127
+ context.req.delete(FARM_INTEGRATION_SET_COOKIES_KEY);
128
+ }
129
+ return [];
130
+ }
131
+ _chunkS3JO3N4Hcjs.__name.call(void 0, takeForwardedIntegrationSetCookies, "takeForwardedIntegrationSetCookies");
132
+ function appendIntegrationForwardedCookies(response, cookies) {
133
+ if (cookies.length === 0) return response;
134
+ const headers = new Headers(response.headers);
135
+ for (const cookie of cookies) {
136
+ headers.append("set-cookie", cookie);
137
+ }
138
+ return new Response(response.body, {
139
+ status: response.status,
140
+ statusText: response.statusText,
141
+ headers
142
+ });
143
+ }
144
+ _chunkS3JO3N4Hcjs.__name.call(void 0, appendIntegrationForwardedCookies, "appendIntegrationForwardedCookies");
145
+ var defineIntegrationSchema = _chunkG643DQCHcjs.defineSchema;
146
+ var FARM_INTEGRATION_PLUGIN_SERVER_RUNTIME = /* @__PURE__ */ Symbol.for(
147
+ "@farm.js/core/integration-plugin-server-runtime"
148
+ );
149
+ var FARM_INTEGRATION_PLUGIN_OWNER = /* @__PURE__ */ Symbol.for("@farm.js/core/integration-plugin-owner");
150
+ function getFarmIntegrationPluginServerRuntime(plugin) {
151
+ const value = plugin[FARM_INTEGRATION_PLUGIN_SERVER_RUNTIME];
152
+ return typeof value === "boolean" ? value : void 0;
153
+ }
154
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getFarmIntegrationPluginServerRuntime, "getFarmIntegrationPluginServerRuntime");
155
+ function getFarmIntegrationPluginOwner(plugin) {
156
+ const value = plugin[FARM_INTEGRATION_PLUGIN_OWNER];
157
+ return value && typeof value === "object" ? value : void 0;
158
+ }
159
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getFarmIntegrationPluginOwner, "getFarmIntegrationPluginOwner");
160
+ function defineTypedIntegrationRoute(method, path, input) {
161
+ return {
162
+ path,
163
+ method,
164
+ middleware: input.middleware,
165
+ before: input.before,
166
+ after: input.after,
167
+ rawBody: input.rawBody,
168
+ bodyFormat: input.bodyFormat,
169
+ input: normalizeIntegrationRouteInputSchemas(input),
170
+ handler: input.handler,
171
+ __operation: _chunkNZKJGRB3cjs.defineIntegrationAPIOperation.call(void 0, {
172
+ path,
173
+ method,
174
+ bodyFormat: input.bodyFormat,
175
+ responseFormat: input.responseFormat,
176
+ headers: input.headers,
177
+ credentials: input.credentials,
178
+ isServer: input.isServer
179
+ })
180
+ };
181
+ }
182
+ _chunkS3JO3N4Hcjs.__name.call(void 0, defineTypedIntegrationRoute, "defineTypedIntegrationRoute");
183
+ function createIntegrationRouteFactory() {
184
+ return {
185
+ get(path, input) {
186
+ return defineTypedIntegrationRoute(
187
+ "GET",
188
+ path,
189
+ input
190
+ );
191
+ },
192
+ post(path, input) {
193
+ return defineTypedIntegrationRoute(
194
+ "POST",
195
+ path,
196
+ {
197
+ bodyFormat: "json",
198
+ ...input
199
+ }
200
+ );
201
+ },
202
+ query(path, input) {
203
+ return defineTypedIntegrationRoute("QUERY", path, {
204
+ bodyFormat: "json",
205
+ ...input
206
+ });
207
+ },
208
+ put(path, input) {
209
+ return defineTypedIntegrationRoute(
210
+ "PUT",
211
+ path,
212
+ {
213
+ bodyFormat: "json",
214
+ ...input
215
+ }
216
+ );
217
+ },
218
+ patch(path, input) {
219
+ return defineTypedIntegrationRoute("PATCH", path, {
220
+ bodyFormat: "json",
221
+ ...input
222
+ });
223
+ },
224
+ delete(path, input) {
225
+ return defineTypedIntegrationRoute("DELETE", path, {
226
+ bodyFormat: "json",
227
+ ...input
228
+ });
229
+ },
230
+ options(path, input) {
231
+ return defineTypedIntegrationRoute("OPTIONS", path, input);
232
+ },
233
+ head(path, input) {
234
+ return defineTypedIntegrationRoute(
235
+ "HEAD",
236
+ path,
237
+ input
238
+ );
239
+ }
240
+ };
241
+ }
242
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createIntegrationRouteFactory, "createIntegrationRouteFactory");
243
+ function createIntegrationRoute(_schema) {
244
+ return createIntegrationRouteFactory();
245
+ }
246
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createIntegrationRoute, "createIntegrationRoute");
247
+ var integrationRoute = createIntegrationRouteFactory();
248
+ var INTEGRATION_RUNTIME_REGISTRY_KEY = /* @__PURE__ */ Symbol.for("farm.integrationRuntimeRegistry");
249
+ var INTEGRATION_REQUEST_DISPATCHER_KEY = /* @__PURE__ */ Symbol.for("farm.integrationRequestDispatcher");
250
+ function getIntegrationRuntimeRegistry() {
251
+ const globalState = globalThis;
252
+ if (!globalState[INTEGRATION_RUNTIME_REGISTRY_KEY]) {
253
+ globalState[INTEGRATION_RUNTIME_REGISTRY_KEY] = /* @__PURE__ */ new Map();
254
+ }
255
+ return globalState[INTEGRATION_RUNTIME_REGISTRY_KEY];
256
+ }
257
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getIntegrationRuntimeRegistry, "getIntegrationRuntimeRegistry");
258
+ function isIntegrationEndpointRoute(value) {
259
+ return !!value && typeof value === "object" && typeof value.path === "string" && typeof value.handler === "function";
260
+ }
261
+ _chunkS3JO3N4Hcjs.__name.call(void 0, isIntegrationEndpointRoute, "isIntegrationEndpointRoute");
262
+ function flattenIntegrationEndpoints(endpoints) {
263
+ if (!endpoints) {
264
+ return [];
265
+ }
266
+ if (Array.isArray(endpoints)) {
267
+ return endpoints.flatMap((endpoint) => flattenIntegrationEndpoints(endpoint));
268
+ }
269
+ if (isIntegrationEndpointRoute(endpoints)) {
270
+ return [endpoints];
271
+ }
272
+ if (typeof endpoints === "object") {
273
+ return Object.values(endpoints).flatMap((endpoint) => flattenIntegrationEndpoints(endpoint));
274
+ }
275
+ return [];
276
+ }
277
+ _chunkS3JO3N4Hcjs.__name.call(void 0, flattenIntegrationEndpoints, "flattenIntegrationEndpoints");
278
+ function defineIntegration(integration) {
279
+ const category = _nullishCoalesce(integration.category, () => ( integration.slot));
280
+ if (!category) {
281
+ throw new Error("Integration category is required.");
282
+ }
283
+ if (integration.category && integration.slot && integration.category !== integration.slot) {
284
+ throw new Error("Integration category and slot must match when both are provided.");
285
+ }
286
+ const routeFactory = createIntegrationRoute(integration.schema);
287
+ const routes = typeof integration.routes === "function" ? integration.routes({
288
+ route: routeFactory,
289
+ integrationRoute: routeFactory
290
+ }) : integration.routes;
291
+ const endpoints = typeof integration.endpoints === "function" ? integration.endpoints({
292
+ endpoint: routeFactory,
293
+ route: routeFactory,
294
+ integrationRoute: routeFactory
295
+ }) : integration.endpoints;
296
+ const endpointRoutes = flattenIntegrationEndpoints(endpoints);
297
+ const allRoutes = _optionalChain([routes, 'optionalAccess', _8 => _8.length]) || endpointRoutes.length ? [...routes || [], ...endpointRoutes] : void 0;
298
+ for (const route of allRoutes || []) {
299
+ _chunkNO3WWW3Ncjs.assertUniqueRouteParameters.call(void 0, route.path, "api");
300
+ _chunkDVM4FKZLcjs.validateConfigRouteSource.call(void 0, route.path, `Integration route "${route.path}"`);
301
+ _chunkNO3WWW3Ncjs.assertTerminalCatchAll.call(void 0, route.path, "api");
302
+ }
303
+ const derivedApi = integration.api || (_optionalChain([allRoutes, 'optionalAccess', _9 => _9.length]) ? _chunkNZKJGRB3cjs.api.fromRoutes(
304
+ allRoutes
305
+ ) : void 0);
306
+ return {
307
+ kind: "farm-integration",
308
+ ...integration,
309
+ endpoints,
310
+ routes: allRoutes,
311
+ api: derivedApi,
312
+ category,
313
+ slot: category
314
+ };
315
+ }
316
+ _chunkS3JO3N4Hcjs.__name.call(void 0, defineIntegration, "defineIntegration");
317
+ function isFarmIntegration(value) {
318
+ return !!value && typeof value === "object" && value.kind === "farm-integration";
319
+ }
320
+ _chunkS3JO3N4Hcjs.__name.call(void 0, isFarmIntegration, "isFarmIntegration");
321
+ function resolveIntegrationPlugins(integrations) {
322
+ if (!integrations) {
323
+ return [];
324
+ }
325
+ const plugins = [];
326
+ for (const [key, integration] of Object.entries(integrations)) {
327
+ if (!integration || !isFarmIntegration(integration)) {
328
+ continue;
329
+ }
330
+ const owner = createIntegrationPluginOwner(key, integration, "lifecycle");
331
+ plugins.push(withIntegrationPluginOwner(createIntegrationPlugin(key, integration), owner));
332
+ plugins.push(...resolveIntegrationPluginContributions(key, integration));
333
+ }
334
+ return plugins;
335
+ }
336
+ _chunkS3JO3N4Hcjs.__name.call(void 0, resolveIntegrationPlugins, "resolveIntegrationPlugins");
337
+ function resolveIntegrationPluginContributions(key, integration) {
338
+ const contributions = integration.plugins;
339
+ if (!contributions) return [];
340
+ if (!Array.isArray(contributions)) {
341
+ throw new TypeError(`Integration "${key}" plugins must be an array`);
342
+ }
343
+ const names = /* @__PURE__ */ new Set();
344
+ return contributions.map((plugin, index) => {
345
+ if (!plugin || typeof plugin !== "object" || typeof plugin.name !== "string") {
346
+ throw new TypeError(`Integration "${key}" plugin at index ${index} is invalid`);
347
+ }
348
+ const name = plugin.name.trim();
349
+ if (!name) {
350
+ throw new TypeError(`Integration "${key}" plugin at index ${index} requires a name`);
351
+ }
352
+ if (names.has(name)) {
353
+ throw new Error(`Integration "${key}" contributes duplicate plugin name "${name}"`);
354
+ }
355
+ names.add(name);
356
+ return withIntegrationPluginOwner(
357
+ plugin,
358
+ createIntegrationPluginOwner(key, integration, "contribution"),
359
+ createIntegrationPluginContext(key, integration)
360
+ );
361
+ });
362
+ }
363
+ _chunkS3JO3N4Hcjs.__name.call(void 0, resolveIntegrationPluginContributions, "resolveIntegrationPluginContributions");
364
+ function createIntegrationPluginOwner(key, integration, source) {
365
+ return Object.freeze({
366
+ key,
367
+ category: integration.category,
368
+ type: integration.type,
369
+ source,
370
+ serverRuntime: integration.serverRuntime !== false
371
+ });
372
+ }
373
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createIntegrationPluginOwner, "createIntegrationPluginOwner");
374
+ function createIntegrationPluginContext(key, integration) {
375
+ return Object.freeze({
376
+ key,
377
+ category: integration.category,
378
+ type: integration.type,
379
+ instance: integration.instance,
380
+ serverRuntime: integration.serverRuntime !== false
381
+ });
382
+ }
383
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createIntegrationPluginContext, "createIntegrationPluginContext");
384
+ function withIntegrationPluginOwner(plugin, owner, integration) {
385
+ const descriptors = Object.getOwnPropertyDescriptors(plugin);
386
+ Reflect.deleteProperty(descriptors, FARM_INTEGRATION_PLUGIN_OWNER);
387
+ Reflect.deleteProperty(descriptors, FARM_INTEGRATION_PLUGIN_SERVER_RUNTIME);
388
+ const ownedPlugin = Object.create(Object.getPrototypeOf(plugin), descriptors);
389
+ Object.defineProperty(ownedPlugin, FARM_INTEGRATION_PLUGIN_OWNER, { value: owner });
390
+ Object.defineProperty(ownedPlugin, FARM_INTEGRATION_PLUGIN_SERVER_RUNTIME, {
391
+ value: owner.serverRuntime
392
+ });
393
+ if (integration) {
394
+ setFarmPluginIntegrationContext(ownedPlugin, integration);
395
+ }
396
+ return ownedPlugin;
397
+ }
398
+ _chunkS3JO3N4Hcjs.__name.call(void 0, withIntegrationPluginOwner, "withIntegrationPluginOwner");
399
+ function getIntegrationProviders(integrations) {
400
+ if (!integrations) {
401
+ return [];
402
+ }
403
+ const providers = [];
404
+ for (const integration of Object.values(integrations)) {
405
+ if (!integration || !isFarmIntegration(integration) || !_optionalChain([integration, 'access', _10 => _10.providers, 'optionalAccess', _11 => _11.length])) {
406
+ continue;
407
+ }
408
+ for (const provider of integration.providers) {
409
+ providers.push({
410
+ name: provider.name,
411
+ type: provider.type,
412
+ props: provider.props,
413
+ supportsIsolatedHydration: provider.supportsIsolatedHydration,
414
+ component: provider.component
415
+ });
416
+ }
417
+ }
418
+ return providers;
419
+ }
420
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getIntegrationProviders, "getIntegrationProviders");
421
+ function isFarmIntegrationProviderComponentReference(value) {
422
+ return Boolean(
423
+ value && typeof value === "object" && "module" in value && typeof value.module === "string" && value.module.length > 0
424
+ );
425
+ }
426
+ _chunkS3JO3N4Hcjs.__name.call(void 0, isFarmIntegrationProviderComponentReference, "isFarmIntegrationProviderComponentReference");
427
+ function getIntegrationDocumentNavigationMatchers(integrations) {
428
+ if (!integrations) {
429
+ return [];
430
+ }
431
+ const matchers = [];
432
+ for (const integration of Object.values(integrations)) {
433
+ if (!integration || !isFarmIntegration(integration) || !_optionalChain([integration, 'access', _12 => _12.documentNavigations, 'optionalAccess', _13 => _13.length])) {
434
+ continue;
435
+ }
436
+ for (const navigation of integration.documentNavigations) {
437
+ const items = Array.isArray(navigation.matcher) ? navigation.matcher : [navigation.matcher];
438
+ for (const item of items) {
439
+ matchers.push(item);
440
+ }
441
+ }
442
+ }
443
+ return matchers;
444
+ }
445
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getIntegrationDocumentNavigationMatchers, "getIntegrationDocumentNavigationMatchers");
446
+ function getIntegrationSchemas(integrations) {
447
+ if (!integrations) {
448
+ return {};
449
+ }
450
+ const schemaEntries = Object.entries(integrations).map(([key, integration]) => {
451
+ const schema = integration && isFarmIntegration(integration) ? integration.schema : void 0;
452
+ return schema ? [key, schema] : null;
453
+ }).filter((value) => value !== null);
454
+ return Object.fromEntries(schemaEntries);
455
+ }
456
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getIntegrationSchemas, "getIntegrationSchemas");
457
+ function getRegisteredIntegrationRuntime(key) {
458
+ return getIntegrationRuntimeRegistry().get(key);
459
+ }
460
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getRegisteredIntegrationRuntime, "getRegisteredIntegrationRuntime");
461
+ function getRegisteredIntegrations() {
462
+ return Object.fromEntries(
463
+ Array.from(getIntegrationRuntimeRegistry().entries()).map(([key, runtime]) => [
464
+ key,
465
+ runtime.integration
466
+ ])
467
+ );
468
+ }
469
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getRegisteredIntegrations, "getRegisteredIntegrations");
470
+ function getRegisteredIntegrationSchemas() {
471
+ return getIntegrationSchemas(getRegisteredIntegrations());
472
+ }
473
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getRegisteredIntegrationSchemas, "getRegisteredIntegrationSchemas");
474
+ function matchIntegrationRoute(integrations, input) {
475
+ if (!integrations) {
476
+ return null;
477
+ }
478
+ const method = normalizeIntegrationRequestMethod(input.method);
479
+ if (!method) {
480
+ return null;
481
+ }
482
+ const pathSegments = _chunkUS2QVW3Ecjs.canonicalizeRequestPathSegments.call(void 0, input.pathname);
483
+ for (const [key, integration] of Object.entries(integrations)) {
484
+ if (!integration || !isFarmIntegration(integration)) {
485
+ continue;
486
+ }
487
+ const routes = normalizeIntegrationRoutes(integration.routes || []);
488
+ for (const route of routes) {
489
+ if (!matchesMethod(route.methods, method)) {
490
+ continue;
491
+ }
492
+ const params = matchPathSegments(route[INTEGRATION_ROUTE_SEGMENTS], pathSegments);
493
+ if (!params) {
494
+ continue;
495
+ }
496
+ return {
497
+ key,
498
+ integration,
499
+ route: {
500
+ path: route.path,
501
+ methods: route.methods
502
+ },
503
+ params
504
+ };
505
+ }
506
+ }
507
+ return null;
508
+ }
509
+ _chunkS3JO3N4Hcjs.__name.call(void 0, matchIntegrationRoute, "matchIntegrationRoute");
510
+ function matchRegisteredIntegrationRoute(input) {
511
+ return matchIntegrationRoute(getRegisteredIntegrations(), input);
512
+ }
513
+ _chunkS3JO3N4Hcjs.__name.call(void 0, matchRegisteredIntegrationRoute, "matchRegisteredIntegrationRoute");
514
+ function createClientSafeIntegrationAPI(api2) {
515
+ if (!api2) {
516
+ return void 0;
517
+ }
518
+ const entries = Object.entries(api2).map(([key, value]) => {
519
+ if (value && typeof value === "object" && value.kind === "farm-integration-api-operation") {
520
+ const operation = value;
521
+ return [
522
+ key,
523
+ _chunkNZKJGRB3cjs.defineIntegrationAPIOperation.call(void 0, {
524
+ path: operation.path,
525
+ method: operation.method,
526
+ bodyFormat: operation.bodyFormat,
527
+ responseFormat: operation.responseFormat,
528
+ credentials: operation.credentials,
529
+ isServer: operation.isServer
530
+ })
531
+ ];
532
+ }
533
+ if (value && typeof value === "object") {
534
+ return [key, createClientSafeIntegrationAPI(value)];
535
+ }
536
+ return [key, value];
537
+ });
538
+ return Object.fromEntries(entries);
539
+ }
540
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createClientSafeIntegrationAPI, "createClientSafeIntegrationAPI");
541
+ function getRegisteredIntegrationAPIManifest() {
542
+ const manifestEntries = Object.entries(getRegisteredIntegrations()).map(([key, integration]) => {
543
+ const api2 = createClientSafeIntegrationAPI(integration.api);
544
+ return api2 ? [key, api2] : null;
545
+ }).filter((value) => value !== null);
546
+ return Object.fromEntries(manifestEntries);
547
+ }
548
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getRegisteredIntegrationAPIManifest, "getRegisteredIntegrationAPIManifest");
549
+ function getIntegrationRuntimeEnv() {
550
+ return typeof process !== "undefined" ? process.env : {};
551
+ }
552
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getIntegrationRuntimeEnv, "getIntegrationRuntimeEnv");
553
+ function isIntegrationConfigDefinition(value) {
554
+ return !!value && typeof value === "object" && ("schema" in value || "env" in value || "defaults" in value || "input" in value || "resolve" in value);
555
+ }
556
+ _chunkS3JO3N4Hcjs.__name.call(void 0, isIntegrationConfigDefinition, "isIntegrationConfigDefinition");
557
+ function mergeIntegrationConfigValue(current, next) {
558
+ if (next === void 0) {
559
+ return current;
560
+ }
561
+ if (isPlainIntegrationConfigObject(current) && isPlainIntegrationConfigObject(next)) {
562
+ return {
563
+ ...current,
564
+ ...next
565
+ };
566
+ }
567
+ return next;
568
+ }
569
+ _chunkS3JO3N4Hcjs.__name.call(void 0, mergeIntegrationConfigValue, "mergeIntegrationConfigValue");
570
+ function isPlainIntegrationConfigObject(value) {
571
+ return !!value && typeof value === "object" && !Array.isArray(value);
572
+ }
573
+ _chunkS3JO3N4Hcjs.__name.call(void 0, isPlainIntegrationConfigObject, "isPlainIntegrationConfigObject");
574
+ async function resolveIntegrationConfigPart(value, context) {
575
+ if (typeof value === "function") {
576
+ return value(context);
577
+ }
578
+ return value;
579
+ }
580
+ _chunkS3JO3N4Hcjs.__name.call(void 0, resolveIntegrationConfigPart, "resolveIntegrationConfigPart");
581
+ function resolveIntegrationEnvConfig(env) {
582
+ if (!env) {
583
+ return void 0;
584
+ }
585
+ const runtimeEnv = getIntegrationRuntimeEnv();
586
+ const config = {};
587
+ for (const [key, names] of Object.entries(env)) {
588
+ const envNames = Array.isArray(names) ? names : [names];
589
+ const value = envNames.map((name) => runtimeEnv[name]).find((entry) => entry !== void 0);
590
+ if (value !== void 0) {
591
+ config[key] = value;
592
+ }
593
+ }
594
+ return config;
595
+ }
596
+ _chunkS3JO3N4Hcjs.__name.call(void 0, resolveIntegrationEnvConfig, "resolveIntegrationEnvConfig");
597
+ async function parseIntegrationConfigSchema(integration, schema, value) {
598
+ const parser = schema.safeParseAsync || schema.safeParse;
599
+ if (parser) {
600
+ const result = await parser.call(schema, value);
601
+ if (result.success) {
602
+ return result.data;
603
+ }
604
+ throw createIntegrationConfigValidationError(integration, result.error);
605
+ }
606
+ if (_optionalChain([schema, 'access', _14 => _14["~standard"], 'optionalAccess', _15 => _15.validate])) {
607
+ const result = await schema["~standard"].validate(value);
608
+ if ("value" in result) {
609
+ return result.value;
610
+ }
611
+ throw createIntegrationConfigValidationError(integration, {
612
+ issues: result.issues
613
+ });
614
+ }
615
+ if (schema.parse) {
616
+ try {
617
+ return await schema.parse(value);
618
+ } catch (error) {
619
+ throw createIntegrationConfigValidationError(
620
+ integration,
621
+ normalizeIntegrationValidationError(error)
622
+ );
623
+ }
624
+ }
625
+ throw new Error(
626
+ `Integration "${integration.type}" config schema must expose safeParse, safeParseAsync, parse, or ~standard.validate.`
627
+ );
628
+ }
629
+ _chunkS3JO3N4Hcjs.__name.call(void 0, parseIntegrationConfigSchema, "parseIntegrationConfigSchema");
630
+ function createIntegrationConfigValidationError(integration, error) {
631
+ const issues = Array.isArray(error.issues) && error.issues.length > 0 ? error.issues.map((issue) => {
632
+ const normalizedPath = normalizeIntegrationValidationPath(issue.path);
633
+ const path = normalizedPath.length ? `${normalizedPath.join(".")}: ` : "";
634
+ return `${path}${issue.message || "Invalid config"}`;
635
+ }).join("; ") : error.message || "Invalid config";
636
+ return new Error(`Integration "${integration.type}" config validation failed: ${issues}`);
637
+ }
638
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createIntegrationConfigValidationError, "createIntegrationConfigValidationError");
639
+ async function resolveIntegrationConfig(integration, context) {
640
+ const config = integration.config;
641
+ if (!config) {
642
+ return void 0;
643
+ }
644
+ if (!isIntegrationConfigDefinition(config)) {
645
+ return parseIntegrationConfigSchema(integration, config, {});
646
+ }
647
+ let value = {};
648
+ value = mergeIntegrationConfigValue(
649
+ value,
650
+ await resolveIntegrationConfigPart(config.defaults, context)
651
+ );
652
+ value = mergeIntegrationConfigValue(value, resolveIntegrationEnvConfig(config.env));
653
+ value = mergeIntegrationConfigValue(
654
+ value,
655
+ await resolveIntegrationConfigPart(config.input, context)
656
+ );
657
+ value = mergeIntegrationConfigValue(value, await _optionalChain([config, 'access', _16 => _16.resolve, 'optionalCall', _17 => _17(context)]));
658
+ return config.schema ? parseIntegrationConfigSchema(integration, config.schema, value) : value;
659
+ }
660
+ _chunkS3JO3N4Hcjs.__name.call(void 0, resolveIntegrationConfig, "resolveIntegrationConfig");
661
+ function createIntegrationLifecycleLogger(integration, phase) {
662
+ const write = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (level, message, meta) => {
663
+ if (!integration.log) {
664
+ return;
665
+ }
666
+ void Promise.resolve(
667
+ integration.log({
668
+ category: integration.category,
669
+ slot: integration.category,
670
+ type: integration.type,
671
+ phase,
672
+ level,
673
+ message,
674
+ meta,
675
+ context: /* @__PURE__ */ new Map()
676
+ })
677
+ ).catch(() => {
678
+ });
679
+ }, "write");
680
+ return {
681
+ info(message, meta) {
682
+ write("info", message, meta);
683
+ },
684
+ warn(message, meta) {
685
+ write("warn", message, meta);
686
+ },
687
+ error(message, meta) {
688
+ write("error", message, meta);
689
+ }
690
+ };
691
+ }
692
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createIntegrationLifecycleLogger, "createIntegrationLifecycleLogger");
693
+ async function emitIntegrationLog(integration, event) {
694
+ try {
695
+ await _optionalChain([integration, 'access', _18 => _18.log, 'optionalCall', _19 => _19(event)]);
696
+ } catch (e) {
697
+ }
698
+ }
699
+ _chunkS3JO3N4Hcjs.__name.call(void 0, emitIntegrationLog, "emitIntegrationLog");
700
+ var INTEGRATION_DATA_HEADER = "x-farm-integration-data";
701
+ var INTEGRATION_DATA_HEADER_MAX_LENGTH = 16 * 1024;
702
+ var BLOCKED_INTEGRATION_DATA_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
703
+ function isFarmIntegrationData(value) {
704
+ return !!value && typeof value === "object" && !Array.isArray(value);
705
+ }
706
+ _chunkS3JO3N4Hcjs.__name.call(void 0, isFarmIntegrationData, "isFarmIntegrationData");
707
+ function isPlainIntegrationDataObject(value) {
708
+ if (!isFarmIntegrationData(value)) {
709
+ return false;
710
+ }
711
+ const prototype = Object.getPrototypeOf(value);
712
+ return prototype === Object.prototype || prototype === null;
713
+ }
714
+ _chunkS3JO3N4Hcjs.__name.call(void 0, isPlainIntegrationDataObject, "isPlainIntegrationDataObject");
715
+ function sanitizeIntegrationDataValue(value) {
716
+ if (Array.isArray(value)) {
717
+ return value.map((item) => sanitizeIntegrationDataValue(item));
718
+ }
719
+ if (!isPlainIntegrationDataObject(value)) {
720
+ return value;
721
+ }
722
+ const sanitized = {};
723
+ for (const [key, item] of Object.entries(value)) {
724
+ if (BLOCKED_INTEGRATION_DATA_KEYS.has(key)) {
725
+ continue;
726
+ }
727
+ sanitized[key] = sanitizeIntegrationDataValue(item);
728
+ }
729
+ return sanitized;
730
+ }
731
+ _chunkS3JO3N4Hcjs.__name.call(void 0, sanitizeIntegrationDataValue, "sanitizeIntegrationDataValue");
732
+ function normalizeIntegrationData(value) {
733
+ if (!isFarmIntegrationData(value)) {
734
+ return {};
735
+ }
736
+ const sanitized = sanitizeIntegrationDataValue(value);
737
+ return isFarmIntegrationData(sanitized) ? sanitized : {};
738
+ }
739
+ _chunkS3JO3N4Hcjs.__name.call(void 0, normalizeIntegrationData, "normalizeIntegrationData");
740
+ function getIntegrationDataHeaderByteLength(value) {
741
+ return new TextEncoder().encode(value).byteLength;
742
+ }
743
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getIntegrationDataHeaderByteLength, "getIntegrationDataHeaderByteLength");
744
+ function parseIntegrationDataHeader(request) {
745
+ const raw = request.headers.get(INTEGRATION_DATA_HEADER);
746
+ if (!raw) {
747
+ return {};
748
+ }
749
+ if (getIntegrationDataHeaderByteLength(raw) > INTEGRATION_DATA_HEADER_MAX_LENGTH) {
750
+ return {};
751
+ }
752
+ try {
753
+ const value = JSON.parse(raw);
754
+ return normalizeIntegrationData(value);
755
+ } catch (e2) {
756
+ return {};
757
+ }
758
+ }
759
+ _chunkS3JO3N4Hcjs.__name.call(void 0, parseIntegrationDataHeader, "parseIntegrationDataHeader");
760
+ function resolveIntegrationData(request, data) {
761
+ return {
762
+ ...parseIntegrationDataHeader(request),
763
+ ...normalizeIntegrationData(data)
764
+ };
765
+ }
766
+ _chunkS3JO3N4Hcjs.__name.call(void 0, resolveIntegrationData, "resolveIntegrationData");
767
+ function createIntegrationPlugin(integrationKey, integration) {
768
+ const routes = normalizeIntegrationRoutes(integration.routes || []);
769
+ const middleware = [...integration.middleware || []];
770
+ const cleanupCallbacks = [];
771
+ let integrationConfigPromise;
772
+ const runCleanup = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async () => {
773
+ const callbacks = cleanupCallbacks.splice(0).reverse();
774
+ for (const callback of callbacks) {
775
+ await callback();
776
+ }
777
+ }, "runCleanup");
778
+ const createLifecycleContext = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async (context, phase, options = {}) => {
779
+ const args = createIntegrationRouteArgs({
780
+ integration,
781
+ config: context.config
782
+ });
783
+ const configContext = {
784
+ key: integrationKey,
785
+ integration,
786
+ appConfig: context.config,
787
+ config: context.config,
788
+ args,
789
+ env: getIntegrationRuntimeEnv(),
790
+ isDev: context.isDev,
791
+ isProd: context.isProd
792
+ };
793
+ _nullishCoalesce(integrationConfigPromise, () => ( (integrationConfigPromise = resolveIntegrationConfig(integration, configContext))));
794
+ return {
795
+ ...configContext,
796
+ integrationConfig: await integrationConfigPromise,
797
+ log: createIntegrationLifecycleLogger(integration, phase),
798
+ reason: options.reason,
799
+ async cleanup(callback) {
800
+ if (callback) {
801
+ cleanupCallbacks.push(callback);
802
+ return;
803
+ }
804
+ await runCleanup();
805
+ }
806
+ };
807
+ }, "createLifecycleContext");
808
+ const plugin = {
809
+ name: `farm:integration:${integration.category}:${integration.type}`,
810
+ enforce: "pre",
811
+ async init(context) {
812
+ getIntegrationRuntimeRegistry().set(integrationKey, {
813
+ integration,
814
+ config: context.config,
815
+ isDev: context.isDev,
816
+ isProd: context.isProd
817
+ });
818
+ await createLifecycleContext(context, "validate");
819
+ if (integration.validate) {
820
+ await integration.validate(await createLifecycleContext(context, "validate"));
821
+ }
822
+ if (integration.setup) {
823
+ await integration.setup(await createLifecycleContext(context, "setup"));
824
+ }
825
+ if (!integration.log) {
826
+ return;
827
+ }
828
+ for (const route of routes) {
829
+ await emitIntegrationLog(integration, {
830
+ category: integration.category,
831
+ slot: integration.category,
832
+ type: integration.type,
833
+ phase: "registered",
834
+ route: {
835
+ kind: "route",
836
+ path: route.path,
837
+ methods: route.methods
838
+ },
839
+ context: /* @__PURE__ */ new Map()
840
+ });
841
+ }
842
+ for (const entry of middleware) {
843
+ await emitIntegrationLog(integration, {
844
+ category: integration.category,
845
+ slot: integration.category,
846
+ type: integration.type,
847
+ phase: "registered",
848
+ route: {
849
+ kind: "middleware",
850
+ path: normalizeMatcher(entry.matcher),
851
+ methods: ["ALL"]
852
+ },
853
+ context: /* @__PURE__ */ new Map()
854
+ });
855
+ }
856
+ },
857
+ async ready(context) {
858
+ if (integration.ready) {
859
+ await integration.ready(await createLifecycleContext(context, "ready"));
860
+ }
861
+ },
862
+ async shutdown(payload, context) {
863
+ try {
864
+ if (integration.dispose) {
865
+ await integration.dispose(
866
+ await createLifecycleContext(context, "dispose", {
867
+ reason: payload.reason
868
+ })
869
+ );
870
+ }
871
+ } finally {
872
+ await runCleanup();
873
+ }
874
+ },
875
+ async beforeRequest(req, res, context) {
876
+ const fullUrl = `http://${req.headers.host || "localhost"}${req.url || "/"}`;
877
+ const url = new URL(fullUrl);
878
+ const pathname = url.pathname;
879
+ const pathSegments = _chunkUS2QVW3Ecjs.canonicalizeRequestPathSegments.call(void 0, pathname);
880
+ const method = normalizeIntegrationRequestMethod(req.method);
881
+ const requestId = getRequestId(req);
882
+ let bodyLoaded = false;
883
+ let requestBody;
884
+ const getRequestBody = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async () => {
885
+ if (!bodyLoaded) {
886
+ bodyLoaded = true;
887
+ if (req.method && req.method !== "GET" && req.method !== "HEAD") {
888
+ requestBody = await _chunkEM6SBQKMcjs.readNodeRequestBody.call(void 0,
889
+ req,
890
+ _chunkEM6SBQKMcjs.resolveFarmServerConfig.call(void 0, context.config.server).bodySizeLimit
891
+ );
892
+ }
893
+ }
894
+ return requestBody;
895
+ }, "getRequestBody");
896
+ const createHandlerRequest = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async () => {
897
+ try {
898
+ return createWebRequest(req, fullUrl, await getRequestBody());
899
+ } catch (error) {
900
+ const response = _chunkEM6SBQKMcjs.createFarmRequestBodyErrorResponse.call(void 0, error);
901
+ if (!response) throw error;
902
+ await _chunkUQZ4AYTHcjs.sendWebResponse.call(void 0, res, response);
903
+ return null;
904
+ }
905
+ }, "createHandlerRequest");
906
+ for (const entry of middleware) {
907
+ const params = resolveMatcherParams(entry.matcher, pathname);
908
+ if (!params) {
909
+ continue;
910
+ }
911
+ const request = await createHandlerRequest();
912
+ if (!request) return;
913
+ const handlerContext = createIntegrationHandlerContext({
914
+ integration,
915
+ route: {
916
+ kind: "middleware",
917
+ path: normalizeMatcher(entry.matcher),
918
+ methods: ["ALL"]
919
+ },
920
+ request,
921
+ rawRequest: req,
922
+ params,
923
+ pathname,
924
+ requestId,
925
+ pluginContext: context
926
+ });
927
+ const startedAt = Date.now();
928
+ await emitIntegrationLog(integration, {
929
+ category: integration.category,
930
+ slot: integration.category,
931
+ type: integration.type,
932
+ phase: "request:start",
933
+ route: {
934
+ kind: "middleware",
935
+ path: normalizeMatcher(entry.matcher),
936
+ methods: ["ALL"]
937
+ },
938
+ request,
939
+ requestId,
940
+ context: handlerContext.req.snapshot()
941
+ });
942
+ try {
943
+ const response = await entry.handler(request, handlerContext);
944
+ const forwardedCookies = takeForwardedIntegrationSetCookies(handlerContext);
945
+ if (forwardedCookies.length > 0) {
946
+ const setCookieHeaders = new Headers();
947
+ for (const cookie of forwardedCookies) {
948
+ setCookieHeaders.append("set-cookie", cookie);
949
+ }
950
+ _chunkUQZ4AYTHcjs.applyWebResponseHeaders.call(void 0, res, setCookieHeaders, { appendSetCookie: true });
951
+ }
952
+ if (response) {
953
+ await _chunkUQZ4AYTHcjs.sendWebResponse.call(void 0, res, response);
954
+ await emitIntegrationLog(integration, {
955
+ category: integration.category,
956
+ slot: integration.category,
957
+ type: integration.type,
958
+ phase: "request:end",
959
+ route: {
960
+ kind: "middleware",
961
+ path: normalizeMatcher(entry.matcher),
962
+ methods: ["ALL"]
963
+ },
964
+ request,
965
+ response,
966
+ requestId,
967
+ durationMs: Date.now() - startedAt,
968
+ context: handlerContext.req.snapshot()
969
+ });
970
+ return;
971
+ }
972
+ await emitIntegrationLog(integration, {
973
+ category: integration.category,
974
+ slot: integration.category,
975
+ type: integration.type,
976
+ phase: "request:end",
977
+ route: {
978
+ kind: "middleware",
979
+ path: normalizeMatcher(entry.matcher),
980
+ methods: ["ALL"]
981
+ },
982
+ request,
983
+ requestId,
984
+ durationMs: Date.now() - startedAt,
985
+ context: handlerContext.req.snapshot()
986
+ });
987
+ } catch (error) {
988
+ await emitIntegrationLog(integration, {
989
+ category: integration.category,
990
+ slot: integration.category,
991
+ type: integration.type,
992
+ phase: "request:error",
993
+ route: {
994
+ kind: "middleware",
995
+ path: normalizeMatcher(entry.matcher),
996
+ methods: ["ALL"]
997
+ },
998
+ request,
999
+ requestId,
1000
+ durationMs: Date.now() - startedAt,
1001
+ error,
1002
+ context: handlerContext.req.snapshot()
1003
+ });
1004
+ throw error;
1005
+ }
1006
+ }
1007
+ for (const route of routes) {
1008
+ const params = method && matchesMethod(route.methods, method) ? matchPathSegments(route[INTEGRATION_ROUTE_SEGMENTS], pathSegments) : null;
1009
+ if (!params) {
1010
+ continue;
1011
+ }
1012
+ const request = await createHandlerRequest();
1013
+ if (!request) return;
1014
+ const handlerContext = createIntegrationHandlerContext({
1015
+ integration,
1016
+ route: {
1017
+ kind: "route",
1018
+ path: route.path,
1019
+ methods: route.methods
1020
+ },
1021
+ request,
1022
+ rawRequest: req,
1023
+ params,
1024
+ pathname,
1025
+ requestId,
1026
+ pluginContext: context
1027
+ });
1028
+ const startedAt = Date.now();
1029
+ await emitIntegrationLog(integration, {
1030
+ category: integration.category,
1031
+ slot: integration.category,
1032
+ type: integration.type,
1033
+ phase: "request:start",
1034
+ route: {
1035
+ kind: "route",
1036
+ path: route.path,
1037
+ methods: route.methods
1038
+ },
1039
+ request,
1040
+ requestId,
1041
+ context: handlerContext.req.snapshot()
1042
+ });
1043
+ try {
1044
+ const validation = await validateIntegrationRouteInput(route, request, url);
1045
+ if (!validation.success) {
1046
+ await _chunkUQZ4AYTHcjs.sendWebResponse.call(void 0, res, validation.response);
1047
+ await emitIntegrationLog(integration, {
1048
+ category: integration.category,
1049
+ slot: integration.category,
1050
+ type: integration.type,
1051
+ phase: "request:end",
1052
+ route: {
1053
+ kind: "route",
1054
+ path: route.path,
1055
+ methods: route.methods
1056
+ },
1057
+ request,
1058
+ response: validation.response,
1059
+ requestId,
1060
+ durationMs: Date.now() - startedAt,
1061
+ context: handlerContext.req.snapshot()
1062
+ });
1063
+ return;
1064
+ }
1065
+ handlerContext.input = validation.input;
1066
+ for (const middlewareEntry of route.middleware || []) {
1067
+ const middlewareResponse = await middlewareEntry.handler(request, handlerContext);
1068
+ if (middlewareResponse) {
1069
+ await _chunkUQZ4AYTHcjs.sendWebResponse.call(void 0, res, middlewareResponse);
1070
+ await emitIntegrationLog(integration, {
1071
+ category: integration.category,
1072
+ slot: integration.category,
1073
+ type: integration.type,
1074
+ phase: "request:end",
1075
+ route: {
1076
+ kind: "route",
1077
+ path: route.path,
1078
+ methods: route.methods
1079
+ },
1080
+ request,
1081
+ response: middlewareResponse,
1082
+ requestId,
1083
+ durationMs: Date.now() - startedAt,
1084
+ context: handlerContext.req.snapshot()
1085
+ });
1086
+ return;
1087
+ }
1088
+ }
1089
+ const beforeResponse = await runIntegrationRouteBeforeHooks(
1090
+ route,
1091
+ request,
1092
+ handlerContext
1093
+ );
1094
+ if (beforeResponse) {
1095
+ const response2 = await runIntegrationRouteAfterHooks(
1096
+ route,
1097
+ request,
1098
+ handlerContext,
1099
+ beforeResponse
1100
+ );
1101
+ await _chunkUQZ4AYTHcjs.sendWebResponse.call(void 0, res, response2);
1102
+ await emitIntegrationLog(integration, {
1103
+ category: integration.category,
1104
+ slot: integration.category,
1105
+ type: integration.type,
1106
+ phase: "request:end",
1107
+ route: {
1108
+ kind: "route",
1109
+ path: route.path,
1110
+ methods: route.methods
1111
+ },
1112
+ request,
1113
+ response: response2,
1114
+ requestId,
1115
+ durationMs: Date.now() - startedAt,
1116
+ context: handlerContext.req.snapshot()
1117
+ });
1118
+ return;
1119
+ }
1120
+ const handlerResponse = await route.handler(request, handlerContext);
1121
+ const response = await runIntegrationRouteAfterHooks(
1122
+ route,
1123
+ request,
1124
+ handlerContext,
1125
+ handlerResponse
1126
+ );
1127
+ await _chunkUQZ4AYTHcjs.sendWebResponse.call(void 0, res, response);
1128
+ await emitIntegrationLog(integration, {
1129
+ category: integration.category,
1130
+ slot: integration.category,
1131
+ type: integration.type,
1132
+ phase: "request:end",
1133
+ route: {
1134
+ kind: "route",
1135
+ path: route.path,
1136
+ methods: route.methods
1137
+ },
1138
+ request,
1139
+ response,
1140
+ requestId,
1141
+ durationMs: Date.now() - startedAt,
1142
+ context: handlerContext.req.snapshot()
1143
+ });
1144
+ return;
1145
+ } catch (error) {
1146
+ await emitIntegrationLog(integration, {
1147
+ category: integration.category,
1148
+ slot: integration.category,
1149
+ type: integration.type,
1150
+ phase: "request:error",
1151
+ route: {
1152
+ kind: "route",
1153
+ path: route.path,
1154
+ methods: route.methods
1155
+ },
1156
+ request,
1157
+ requestId,
1158
+ durationMs: Date.now() - startedAt,
1159
+ error,
1160
+ context: handlerContext.req.snapshot()
1161
+ });
1162
+ throw error;
1163
+ }
1164
+ }
1165
+ }
1166
+ };
1167
+ Object.defineProperty(plugin, FARM_INTEGRATION_PLUGIN_SERVER_RUNTIME, {
1168
+ value: integration.serverRuntime !== false
1169
+ });
1170
+ return plugin;
1171
+ }
1172
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createIntegrationPlugin, "createIntegrationPlugin");
1173
+ function createIntegrationHandlerContext(input) {
1174
+ const req = createIntegrationRequestContextStore(
1175
+ input.rawRequest,
1176
+ input.request,
1177
+ input.pluginContext
1178
+ );
1179
+ return {
1180
+ request: input.request,
1181
+ requestId: input.requestId,
1182
+ url: new URL(input.request.url),
1183
+ pathname: input.pathname,
1184
+ method: input.request.method,
1185
+ params: input.params,
1186
+ input: {},
1187
+ args: createIntegrationRouteArgs({
1188
+ integration: input.integration,
1189
+ config: input.pluginContext.config
1190
+ }),
1191
+ data: resolveIntegrationData(input.request),
1192
+ integration: {
1193
+ category: input.integration.category,
1194
+ slot: input.integration.category,
1195
+ type: input.integration.type,
1196
+ instance: input.integration.instance
1197
+ },
1198
+ route: input.route,
1199
+ req,
1200
+ requestContext: req,
1201
+ config: input.pluginContext.config,
1202
+ isDev: input.pluginContext.isDev,
1203
+ isProd: input.pluginContext.isProd
1204
+ };
1205
+ }
1206
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createIntegrationHandlerContext, "createIntegrationHandlerContext");
1207
+ var INTEGRATION_ROUTE_SEGMENTS = /* @__PURE__ */ Symbol("farm.integrationRouteSegments");
1208
+ var EMPTY_NORMALIZED_INTEGRATION_ROUTES = [];
1209
+ var normalizedIntegrationRoutesCache = /* @__PURE__ */ new WeakMap();
1210
+ function normalizeIntegrationRoutes(routes) {
1211
+ if (routes.length === 0) {
1212
+ return EMPTY_NORMALIZED_INTEGRATION_ROUTES;
1213
+ }
1214
+ const cached = normalizedIntegrationRoutesCache.get(routes);
1215
+ if (cached) {
1216
+ return cached;
1217
+ }
1218
+ const normalized = routes.map((route, index) => {
1219
+ _chunkNO3WWW3Ncjs.assertUniqueRouteParameters.call(void 0, route.path, "api");
1220
+ return {
1221
+ index,
1222
+ route: {
1223
+ ...route,
1224
+ methods: normalizeIntegrationRouteMethods(route),
1225
+ input: normalizeIntegrationRouteInputSchemas(route),
1226
+ [INTEGRATION_ROUTE_SEGMENTS]: splitPath(route.path)
1227
+ },
1228
+ specificity: _chunkNO3WWW3Ncjs.getRoutePatternSpecificity.call(void 0, route.path, "api")
1229
+ };
1230
+ }).sort(
1231
+ (left, right) => _chunkNO3WWW3Ncjs.compareRouteSpecificity.call(void 0, left.specificity, right.specificity) || left.index - right.index
1232
+ ).map(({ route }) => route);
1233
+ normalizedIntegrationRoutesCache.set(routes, normalized);
1234
+ return normalized;
1235
+ }
1236
+ _chunkS3JO3N4Hcjs.__name.call(void 0, normalizeIntegrationRoutes, "normalizeIntegrationRoutes");
1237
+ function normalizeIntegrationRouteMethods(route) {
1238
+ const input = route.methods && route.methods.length > 0 ? [...route.methods] : route.method ? [route.method] : ["ALL"];
1239
+ return input.map((method) => String(method).toUpperCase());
1240
+ }
1241
+ _chunkS3JO3N4Hcjs.__name.call(void 0, normalizeIntegrationRouteMethods, "normalizeIntegrationRouteMethods");
1242
+ function normalizeIntegrationRouteInputSchemas(route) {
1243
+ const input = {
1244
+ ...route.input
1245
+ };
1246
+ if (route.body) {
1247
+ input.body = route.body;
1248
+ }
1249
+ if (route.query) {
1250
+ input.query = route.query;
1251
+ }
1252
+ return input.body || input.query ? input : void 0;
1253
+ }
1254
+ _chunkS3JO3N4Hcjs.__name.call(void 0, normalizeIntegrationRouteInputSchemas, "normalizeIntegrationRouteInputSchemas");
1255
+ async function validateIntegrationRouteInput(route, request, url) {
1256
+ if (request.method.toUpperCase() === "QUERY" && !request.headers.has("content-type")) {
1257
+ return {
1258
+ success: false,
1259
+ response: Response.json(
1260
+ {
1261
+ error: "Invalid QUERY request",
1262
+ message: "QUERY requests must include a Content-Type header."
1263
+ },
1264
+ { status: 400 }
1265
+ )
1266
+ };
1267
+ }
1268
+ const schemas = route.input;
1269
+ if (!_optionalChain([schemas, 'optionalAccess', _20 => _20.body]) && !_optionalChain([schemas, 'optionalAccess', _21 => _21.query])) {
1270
+ return {
1271
+ success: true,
1272
+ input: {}
1273
+ };
1274
+ }
1275
+ const input = {};
1276
+ const issues = [];
1277
+ if (schemas.query) {
1278
+ const queryResult = await parseIntegrationInputSchema(
1279
+ "query",
1280
+ schemas.query,
1281
+ createQueryInput(url.searchParams)
1282
+ );
1283
+ if (queryResult.success) {
1284
+ input.query = queryResult.data;
1285
+ } else {
1286
+ issues.push(...queryResult.issues);
1287
+ }
1288
+ }
1289
+ if (schemas.body) {
1290
+ const bodyInput = await readIntegrationValidationBody(
1291
+ request,
1292
+ getIntegrationRouteBodyFormat(route)
1293
+ );
1294
+ if (bodyInput.success) {
1295
+ const bodyResult = await parseIntegrationInputSchema("body", schemas.body, bodyInput.data);
1296
+ if (bodyResult.success) {
1297
+ input.body = bodyResult.data;
1298
+ } else {
1299
+ issues.push(...bodyResult.issues);
1300
+ }
1301
+ } else {
1302
+ issues.push(bodyInput.issue);
1303
+ }
1304
+ }
1305
+ if (issues.length > 0) {
1306
+ return {
1307
+ success: false,
1308
+ response: createIntegrationValidationResponse(issues)
1309
+ };
1310
+ }
1311
+ return {
1312
+ success: true,
1313
+ input
1314
+ };
1315
+ }
1316
+ _chunkS3JO3N4Hcjs.__name.call(void 0, validateIntegrationRouteInput, "validateIntegrationRouteInput");
1317
+ async function parseIntegrationInputSchema(source, schema, value) {
1318
+ const parser = schema.safeParseAsync || schema.safeParse;
1319
+ if (parser) {
1320
+ const result = await parser.call(schema, value);
1321
+ if (result.success) {
1322
+ return {
1323
+ success: true,
1324
+ data: result.data
1325
+ };
1326
+ }
1327
+ return {
1328
+ success: false,
1329
+ issues: normalizeIntegrationValidationIssues(source, result.error)
1330
+ };
1331
+ }
1332
+ if (_optionalChain([schema, 'access', _22 => _22["~standard"], 'optionalAccess', _23 => _23.validate])) {
1333
+ const result = await schema["~standard"].validate(value);
1334
+ if ("value" in result) {
1335
+ return {
1336
+ success: true,
1337
+ data: result.value
1338
+ };
1339
+ }
1340
+ return {
1341
+ success: false,
1342
+ issues: normalizeIntegrationValidationIssues(source, {
1343
+ issues: result.issues
1344
+ })
1345
+ };
1346
+ }
1347
+ if (schema.parse) {
1348
+ try {
1349
+ return {
1350
+ success: true,
1351
+ data: await schema.parse(value)
1352
+ };
1353
+ } catch (error) {
1354
+ return {
1355
+ success: false,
1356
+ issues: normalizeIntegrationValidationIssues(
1357
+ source,
1358
+ normalizeIntegrationValidationError(error)
1359
+ )
1360
+ };
1361
+ }
1362
+ }
1363
+ return {
1364
+ success: false,
1365
+ issues: [
1366
+ {
1367
+ source,
1368
+ message: "Input schema must expose safeParse, safeParseAsync, parse, or ~standard.validate."
1369
+ }
1370
+ ]
1371
+ };
1372
+ }
1373
+ _chunkS3JO3N4Hcjs.__name.call(void 0, parseIntegrationInputSchema, "parseIntegrationInputSchema");
1374
+ function createIntegrationValidationResponse(issues) {
1375
+ return Response.json(
1376
+ {
1377
+ error: "Integration route input validation failed",
1378
+ issues
1379
+ },
1380
+ {
1381
+ status: 400
1382
+ }
1383
+ );
1384
+ }
1385
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createIntegrationValidationResponse, "createIntegrationValidationResponse");
1386
+ function normalizeIntegrationValidationIssues(source, error) {
1387
+ if (Array.isArray(error.issues) && error.issues.length > 0) {
1388
+ return error.issues.map((issue) => ({
1389
+ source,
1390
+ path: normalizeIntegrationValidationPath(issue.path),
1391
+ code: issue.code,
1392
+ message: issue.message || "Invalid input"
1393
+ }));
1394
+ }
1395
+ return [
1396
+ {
1397
+ source,
1398
+ path: [],
1399
+ message: error.message || "Invalid input"
1400
+ }
1401
+ ];
1402
+ }
1403
+ _chunkS3JO3N4Hcjs.__name.call(void 0, normalizeIntegrationValidationIssues, "normalizeIntegrationValidationIssues");
1404
+ function normalizeIntegrationValidationPath(path) {
1405
+ return (path || []).map((segment) => {
1406
+ const key = typeof segment === "object" && segment !== null && "key" in segment ? segment.key : segment;
1407
+ return typeof key === "symbol" ? key.description || key.toString() : key;
1408
+ });
1409
+ }
1410
+ _chunkS3JO3N4Hcjs.__name.call(void 0, normalizeIntegrationValidationPath, "normalizeIntegrationValidationPath");
1411
+ function normalizeIntegrationValidationError(error) {
1412
+ if (error && typeof error === "object") {
1413
+ return error;
1414
+ }
1415
+ return {
1416
+ message: error instanceof Error ? error.message : String(error || "Invalid input")
1417
+ };
1418
+ }
1419
+ _chunkS3JO3N4Hcjs.__name.call(void 0, normalizeIntegrationValidationError, "normalizeIntegrationValidationError");
1420
+ async function readIntegrationValidationBody(request, format) {
1421
+ if (request.method === "GET" || request.method === "HEAD" || format === "none") {
1422
+ return {
1423
+ success: true,
1424
+ data: void 0
1425
+ };
1426
+ }
1427
+ try {
1428
+ if (format === "form") {
1429
+ return {
1430
+ success: true,
1431
+ data: createFormInput(await request.clone().formData())
1432
+ };
1433
+ }
1434
+ const text = await request.clone().text();
1435
+ if (text.trim().length === 0) {
1436
+ return {
1437
+ success: true,
1438
+ data: void 0
1439
+ };
1440
+ }
1441
+ return {
1442
+ success: true,
1443
+ data: JSON.parse(text)
1444
+ };
1445
+ } catch (error) {
1446
+ return {
1447
+ success: false,
1448
+ issue: {
1449
+ source: "body",
1450
+ path: [],
1451
+ message: format === "json" ? "Expected a valid JSON request body." : error instanceof Error && error.message ? error.message : "Could not parse request body."
1452
+ }
1453
+ };
1454
+ }
1455
+ }
1456
+ _chunkS3JO3N4Hcjs.__name.call(void 0, readIntegrationValidationBody, "readIntegrationValidationBody");
1457
+ function getIntegrationRouteBodyFormat(route) {
1458
+ return route.bodyFormat || _optionalChain([route, 'access', _24 => _24.__operation, 'optionalAccess', _25 => _25.bodyFormat]) || "json";
1459
+ }
1460
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getIntegrationRouteBodyFormat, "getIntegrationRouteBodyFormat");
1461
+ function createIntegrationRouteArgs(input) {
1462
+ let clientPromise;
1463
+ let ormPromise;
1464
+ const getClient = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, () => {
1465
+ _nullishCoalesce(clientPromise, () => ( (clientPromise = import("./storage.cjs").then(
1466
+ ({ resolveStorageRuntimeClient }) => resolveStorageRuntimeClient(input.config.storage)
1467
+ ))));
1468
+ return clientPromise;
1469
+ }, "getClient");
1470
+ const getOrm = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, () => {
1471
+ if (!input.integration.schema) {
1472
+ throw new Error(
1473
+ `Integration "${input.integration.type}" does not define a schema for ctx.args.db.`
1474
+ );
1475
+ }
1476
+ _nullishCoalesce(ormPromise, () => ( (ormPromise = import("./integration-orm-55F7CII5.cjs").then(
1477
+ ({ createIntegrationOrm }) => createIntegrationOrm({
1478
+ schema: input.integration.schema,
1479
+ config: input.config
1480
+ })
1481
+ ))));
1482
+ return ormPromise;
1483
+ }, "getOrm");
1484
+ return {
1485
+ db: createLazyIntegrationOrmClient(getOrm),
1486
+ getDb: getOrm,
1487
+ storage: {
1488
+ getClient,
1489
+ getOrm
1490
+ }
1491
+ };
1492
+ }
1493
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createIntegrationRouteArgs, "createIntegrationRouteArgs");
1494
+ function createLazyIntegrationOrmClient(resolveOrm) {
1495
+ const modelProxyCache = /* @__PURE__ */ new Map();
1496
+ return new Proxy(
1497
+ {},
1498
+ {
1499
+ get(_target, prop) {
1500
+ if (prop === "then") {
1501
+ return void 0;
1502
+ }
1503
+ if (prop === "transaction" || prop === "batch") {
1504
+ return async (...args) => {
1505
+ const orm = await resolveOrm();
1506
+ const member = orm[prop];
1507
+ if (typeof member !== "function") {
1508
+ throw new Error(`Integration ORM does not expose "${String(prop)}".`);
1509
+ }
1510
+ return member.apply(orm, args);
1511
+ };
1512
+ }
1513
+ if (prop === "$driver") {
1514
+ return void 0;
1515
+ }
1516
+ if (!modelProxyCache.has(prop)) {
1517
+ modelProxyCache.set(prop, createLazyIntegrationOrmModel(resolveOrm, prop));
1518
+ }
1519
+ return modelProxyCache.get(prop);
1520
+ }
1521
+ }
1522
+ );
1523
+ }
1524
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createLazyIntegrationOrmClient, "createLazyIntegrationOrmClient");
1525
+ function createLazyIntegrationOrmModel(resolveOrm, modelName) {
1526
+ return new Proxy(
1527
+ {},
1528
+ {
1529
+ get(_target, prop) {
1530
+ if (prop === "then") {
1531
+ return void 0;
1532
+ }
1533
+ return async (...args) => {
1534
+ const orm = await resolveOrm();
1535
+ const model = orm[modelName];
1536
+ const member = _optionalChain([model, 'optionalAccess', _26 => _26[prop]]);
1537
+ if (typeof member !== "function") {
1538
+ throw new Error(
1539
+ `Integration ORM model "${String(modelName)}" does not expose "${String(prop)}".`
1540
+ );
1541
+ }
1542
+ return member.apply(model, args);
1543
+ };
1544
+ }
1545
+ }
1546
+ );
1547
+ }
1548
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createLazyIntegrationOrmModel, "createLazyIntegrationOrmModel");
1549
+ async function runIntegrationRouteBeforeHooks(route, request, context) {
1550
+ const hookContext = context;
1551
+ hookContext.response = void 0;
1552
+ for (const hook of route.before || []) {
1553
+ const response = await hook(request, hookContext);
1554
+ if (response) {
1555
+ hookContext.response = response;
1556
+ return response;
1557
+ }
1558
+ if (hookContext.response) {
1559
+ return hookContext.response;
1560
+ }
1561
+ }
1562
+ return void 0;
1563
+ }
1564
+ _chunkS3JO3N4Hcjs.__name.call(void 0, runIntegrationRouteBeforeHooks, "runIntegrationRouteBeforeHooks");
1565
+ async function runIntegrationRouteAfterHooks(route, request, context, response) {
1566
+ const hookContext = context;
1567
+ let currentResponse = response;
1568
+ for (const hook of route.after || []) {
1569
+ hookContext.response = currentResponse;
1570
+ const nextResponse = await hook(request, hookContext);
1571
+ currentResponse = nextResponse || hookContext.response || currentResponse;
1572
+ }
1573
+ hookContext.response = currentResponse;
1574
+ return currentResponse;
1575
+ }
1576
+ _chunkS3JO3N4Hcjs.__name.call(void 0, runIntegrationRouteAfterHooks, "runIntegrationRouteAfterHooks");
1577
+ function createQueryInput(searchParams) {
1578
+ const input = {};
1579
+ searchParams.forEach((value, key) => {
1580
+ if (key === "__proto__" || key === "constructor" || key === "prototype") return;
1581
+ const existing = input[key];
1582
+ if (existing === void 0) {
1583
+ input[key] = value;
1584
+ return;
1585
+ }
1586
+ input[key] = Array.isArray(existing) ? [...existing, value] : [existing, value];
1587
+ });
1588
+ return input;
1589
+ }
1590
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createQueryInput, "createQueryInput");
1591
+ function createFormInput(formData) {
1592
+ const input = {};
1593
+ formData.forEach((value, key) => {
1594
+ if (key === "__proto__" || key === "constructor" || key === "prototype") return;
1595
+ const existing = input[key];
1596
+ if (existing === void 0) {
1597
+ input[key] = value;
1598
+ return;
1599
+ }
1600
+ input[key] = Array.isArray(existing) ? [...existing, value] : [existing, value];
1601
+ });
1602
+ return input;
1603
+ }
1604
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createFormInput, "createFormInput");
1605
+ async function dispatchIntegrationRequest(runtime, request, options = {}) {
1606
+ try {
1607
+ request = await _chunkEM6SBQKMcjs.bufferFarmRequestBody.call(void 0,
1608
+ request,
1609
+ _chunkEM6SBQKMcjs.resolveFarmServerConfig.call(void 0, runtime.config.server).bodySizeLimit
1610
+ );
1611
+ } catch (error) {
1612
+ const response = _chunkEM6SBQKMcjs.createFarmRequestBodyErrorResponse.call(void 0, error);
1613
+ if (response) return response;
1614
+ throw error;
1615
+ }
1616
+ const integration = runtime.integration;
1617
+ const url = new URL(request.url);
1618
+ const pathname = url.pathname;
1619
+ const requestId = request.headers.get("x-request-id") || _optionalChain([options, 'access', _27 => _27.currentRequest, 'optionalAccess', _28 => _28.headers, 'access', _29 => _29.get, 'call', _30 => _30("x-request-id")]) || String(Date.now());
1620
+ const routes = normalizeIntegrationRoutes(integration.routes || []);
1621
+ const pathSegments = _chunkUS2QVW3Ecjs.canonicalizeRequestPathSegments.call(void 0, pathname);
1622
+ const method = normalizeIntegrationRequestMethod(request.method);
1623
+ const middleware = [...integration.middleware || []];
1624
+ const forwardedSetCookies = [];
1625
+ for (const entry of middleware) {
1626
+ const params = resolveMatcherParams(entry.matcher, pathname);
1627
+ if (!params) {
1628
+ continue;
1629
+ }
1630
+ const handlerContext = createServerIntegrationHandlerContext({
1631
+ runtime,
1632
+ route: {
1633
+ kind: "middleware",
1634
+ path: normalizeMatcher(entry.matcher),
1635
+ methods: ["ALL"]
1636
+ },
1637
+ request,
1638
+ params,
1639
+ pathname,
1640
+ requestId,
1641
+ currentRequest: options.currentRequest,
1642
+ data: options.data,
1643
+ internal: options.internal === true
1644
+ });
1645
+ const startedAt = Date.now();
1646
+ await emitIntegrationLog(integration, {
1647
+ category: integration.category,
1648
+ slot: integration.category,
1649
+ type: integration.type,
1650
+ phase: "request:start",
1651
+ route: {
1652
+ kind: "middleware",
1653
+ path: normalizeMatcher(entry.matcher),
1654
+ methods: ["ALL"]
1655
+ },
1656
+ request,
1657
+ requestId,
1658
+ context: handlerContext.req.snapshot()
1659
+ });
1660
+ try {
1661
+ const response = await entry.handler(request, handlerContext);
1662
+ forwardedSetCookies.push(...takeForwardedIntegrationSetCookies(handlerContext));
1663
+ if (response) {
1664
+ await emitIntegrationLog(integration, {
1665
+ category: integration.category,
1666
+ slot: integration.category,
1667
+ type: integration.type,
1668
+ phase: "request:end",
1669
+ route: {
1670
+ kind: "middleware",
1671
+ path: normalizeMatcher(entry.matcher),
1672
+ methods: ["ALL"]
1673
+ },
1674
+ request,
1675
+ response,
1676
+ requestId,
1677
+ durationMs: Date.now() - startedAt,
1678
+ context: handlerContext.req.snapshot()
1679
+ });
1680
+ return appendIntegrationForwardedCookies(response, forwardedSetCookies);
1681
+ }
1682
+ await emitIntegrationLog(integration, {
1683
+ category: integration.category,
1684
+ slot: integration.category,
1685
+ type: integration.type,
1686
+ phase: "request:end",
1687
+ route: {
1688
+ kind: "middleware",
1689
+ path: normalizeMatcher(entry.matcher),
1690
+ methods: ["ALL"]
1691
+ },
1692
+ request,
1693
+ requestId,
1694
+ durationMs: Date.now() - startedAt,
1695
+ context: handlerContext.req.snapshot()
1696
+ });
1697
+ } catch (error) {
1698
+ await emitIntegrationLog(integration, {
1699
+ category: integration.category,
1700
+ slot: integration.category,
1701
+ type: integration.type,
1702
+ phase: "request:error",
1703
+ route: {
1704
+ kind: "middleware",
1705
+ path: normalizeMatcher(entry.matcher),
1706
+ methods: ["ALL"]
1707
+ },
1708
+ request,
1709
+ requestId,
1710
+ durationMs: Date.now() - startedAt,
1711
+ error,
1712
+ context: handlerContext.req.snapshot()
1713
+ });
1714
+ throw error;
1715
+ }
1716
+ }
1717
+ for (const route of routes) {
1718
+ const params = method && matchesMethod(route.methods, method) ? matchPathSegments(route[INTEGRATION_ROUTE_SEGMENTS], pathSegments) : null;
1719
+ if (!params) {
1720
+ continue;
1721
+ }
1722
+ const handlerContext = createServerIntegrationHandlerContext({
1723
+ runtime,
1724
+ route: {
1725
+ kind: "route",
1726
+ path: route.path,
1727
+ methods: route.methods
1728
+ },
1729
+ request,
1730
+ params,
1731
+ pathname,
1732
+ requestId,
1733
+ currentRequest: options.currentRequest,
1734
+ data: options.data,
1735
+ internal: options.internal === true
1736
+ });
1737
+ const startedAt = Date.now();
1738
+ await emitIntegrationLog(integration, {
1739
+ category: integration.category,
1740
+ slot: integration.category,
1741
+ type: integration.type,
1742
+ phase: "request:start",
1743
+ route: {
1744
+ kind: "route",
1745
+ path: route.path,
1746
+ methods: route.methods
1747
+ },
1748
+ request,
1749
+ requestId,
1750
+ context: handlerContext.req.snapshot()
1751
+ });
1752
+ try {
1753
+ const validation = await validateIntegrationRouteInput(route, request, url);
1754
+ if (!validation.success) {
1755
+ await emitIntegrationLog(integration, {
1756
+ category: integration.category,
1757
+ slot: integration.category,
1758
+ type: integration.type,
1759
+ phase: "request:end",
1760
+ route: {
1761
+ kind: "route",
1762
+ path: route.path,
1763
+ methods: route.methods
1764
+ },
1765
+ request,
1766
+ response: validation.response,
1767
+ requestId,
1768
+ durationMs: Date.now() - startedAt,
1769
+ context: handlerContext.req.snapshot()
1770
+ });
1771
+ return appendIntegrationForwardedCookies(validation.response, forwardedSetCookies);
1772
+ }
1773
+ handlerContext.input = validation.input;
1774
+ for (const middlewareEntry of route.middleware || []) {
1775
+ const middlewareResponse = await middlewareEntry.handler(request, handlerContext);
1776
+ forwardedSetCookies.push(...takeForwardedIntegrationSetCookies(handlerContext));
1777
+ if (middlewareResponse) {
1778
+ await emitIntegrationLog(integration, {
1779
+ category: integration.category,
1780
+ slot: integration.category,
1781
+ type: integration.type,
1782
+ phase: "request:end",
1783
+ route: {
1784
+ kind: "route",
1785
+ path: route.path,
1786
+ methods: route.methods
1787
+ },
1788
+ request,
1789
+ response: middlewareResponse,
1790
+ requestId,
1791
+ durationMs: Date.now() - startedAt,
1792
+ context: handlerContext.req.snapshot()
1793
+ });
1794
+ return appendIntegrationForwardedCookies(middlewareResponse, forwardedSetCookies);
1795
+ }
1796
+ }
1797
+ const beforeResponse = await runIntegrationRouteBeforeHooks(route, request, handlerContext);
1798
+ if (beforeResponse) {
1799
+ const response2 = await runIntegrationRouteAfterHooks(
1800
+ route,
1801
+ request,
1802
+ handlerContext,
1803
+ beforeResponse
1804
+ );
1805
+ await emitIntegrationLog(integration, {
1806
+ category: integration.category,
1807
+ slot: integration.category,
1808
+ type: integration.type,
1809
+ phase: "request:end",
1810
+ route: {
1811
+ kind: "route",
1812
+ path: route.path,
1813
+ methods: route.methods
1814
+ },
1815
+ request,
1816
+ response: response2,
1817
+ requestId,
1818
+ durationMs: Date.now() - startedAt,
1819
+ context: handlerContext.req.snapshot()
1820
+ });
1821
+ return appendIntegrationForwardedCookies(response2, forwardedSetCookies);
1822
+ }
1823
+ const handlerResponse = await route.handler(request, handlerContext);
1824
+ const response = await runIntegrationRouteAfterHooks(
1825
+ route,
1826
+ request,
1827
+ handlerContext,
1828
+ handlerResponse
1829
+ );
1830
+ await emitIntegrationLog(integration, {
1831
+ category: integration.category,
1832
+ slot: integration.category,
1833
+ type: integration.type,
1834
+ phase: "request:end",
1835
+ route: {
1836
+ kind: "route",
1837
+ path: route.path,
1838
+ methods: route.methods
1839
+ },
1840
+ request,
1841
+ response,
1842
+ requestId,
1843
+ durationMs: Date.now() - startedAt,
1844
+ context: handlerContext.req.snapshot()
1845
+ });
1846
+ return appendIntegrationForwardedCookies(response, forwardedSetCookies);
1847
+ } catch (error) {
1848
+ await emitIntegrationLog(integration, {
1849
+ category: integration.category,
1850
+ slot: integration.category,
1851
+ type: integration.type,
1852
+ phase: "request:error",
1853
+ route: {
1854
+ kind: "route",
1855
+ path: route.path,
1856
+ methods: route.methods
1857
+ },
1858
+ request,
1859
+ requestId,
1860
+ durationMs: Date.now() - startedAt,
1861
+ error,
1862
+ context: handlerContext.req.snapshot()
1863
+ });
1864
+ throw error;
1865
+ }
1866
+ }
1867
+ if (forwardedSetCookies.length > 0) {
1868
+ _optionalChain([options, 'access', _31 => _31.onForwardedCookies, 'optionalCall', _32 => _32(forwardedSetCookies)]);
1869
+ }
1870
+ return null;
1871
+ }
1872
+ _chunkS3JO3N4Hcjs.__name.call(void 0, dispatchIntegrationRequest, "dispatchIntegrationRequest");
1873
+ async function dispatchIntegrationRequests(integrations, runtime, request, options = {}) {
1874
+ const setCookies = [];
1875
+ if (!integrations) {
1876
+ return { response: null, setCookies };
1877
+ }
1878
+ for (const integration of Object.values(integrations)) {
1879
+ if (!integration || !isFarmIntegration(integration)) {
1880
+ continue;
1881
+ }
1882
+ const hasMiddleware = (integration.middleware || []).length > 0;
1883
+ const hasRoutes = normalizeIntegrationRoutes(integration.routes || []).length > 0;
1884
+ if (!hasMiddleware && !hasRoutes) {
1885
+ continue;
1886
+ }
1887
+ const response = await dispatchIntegrationRequest(
1888
+ { ...runtime, integration },
1889
+ // Each dispatch buffers the body it is given, so hand every integration
1890
+ // its own clone rather than a Request another dispatch already read.
1891
+ request.clone(),
1892
+ {
1893
+ currentRequest: options.currentRequest,
1894
+ onForwardedCookies: /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (cookies) => setCookies.push(...cookies), "onForwardedCookies")
1895
+ }
1896
+ );
1897
+ if (response) {
1898
+ return {
1899
+ response: appendIntegrationForwardedCookies(response, setCookies),
1900
+ setCookies: []
1901
+ };
1902
+ }
1903
+ }
1904
+ return { response: null, setCookies };
1905
+ }
1906
+ _chunkS3JO3N4Hcjs.__name.call(void 0, dispatchIntegrationRequests, "dispatchIntegrationRequests");
1907
+ globalThis[INTEGRATION_REQUEST_DISPATCHER_KEY] = dispatchIntegrationRequest;
1908
+ function createIntegrationRequestContextStore(rawRequest, request, pluginContext) {
1909
+ return {
1910
+ get(key) {
1911
+ const requestValue = pluginContext.requestContext.get(request, key);
1912
+ if (requestValue !== void 0) {
1913
+ return requestValue;
1914
+ }
1915
+ return pluginContext.requestContext.get(rawRequest, key);
1916
+ },
1917
+ set(key, value, options) {
1918
+ pluginContext.requestContext.set(rawRequest, key, value, options);
1919
+ pluginContext.requestContext.set(request, key, value, options);
1920
+ },
1921
+ has(key) {
1922
+ return pluginContext.requestContext.has(request, key) || pluginContext.requestContext.has(rawRequest, key);
1923
+ },
1924
+ delete(key) {
1925
+ const deletedRequest = pluginContext.requestContext.delete(request, key);
1926
+ const deletedRaw = pluginContext.requestContext.delete(rawRequest, key);
1927
+ return deletedRequest || deletedRaw;
1928
+ },
1929
+ clear() {
1930
+ pluginContext.requestContext.clear(rawRequest);
1931
+ pluginContext.requestContext.clear(request);
1932
+ },
1933
+ snapshot(options) {
1934
+ const merged = pluginContext.requestContext.getAll(rawRequest, options);
1935
+ const requestSnapshot = pluginContext.requestContext.getAll(request, options);
1936
+ for (const [key, value] of requestSnapshot) {
1937
+ merged.set(key, value);
1938
+ }
1939
+ return merged;
1940
+ }
1941
+ };
1942
+ }
1943
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createIntegrationRequestContextStore, "createIntegrationRequestContextStore");
1944
+ function createServerIntegrationHandlerContext(input) {
1945
+ const req = createServerIntegrationRequestContextStore(input.request, input.currentRequest);
1946
+ if (input.internal) {
1947
+ req.set(FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY, true);
1948
+ }
1949
+ return {
1950
+ request: input.request,
1951
+ requestId: input.requestId,
1952
+ url: new URL(input.request.url),
1953
+ pathname: input.pathname,
1954
+ method: input.request.method,
1955
+ params: input.params,
1956
+ input: {},
1957
+ args: createIntegrationRouteArgs({
1958
+ integration: input.runtime.integration,
1959
+ config: input.runtime.config
1960
+ }),
1961
+ data: resolveIntegrationData(input.request, input.data),
1962
+ integration: {
1963
+ category: input.runtime.integration.category,
1964
+ slot: input.runtime.integration.category,
1965
+ type: input.runtime.integration.type,
1966
+ instance: input.runtime.integration.instance
1967
+ },
1968
+ route: input.route,
1969
+ req,
1970
+ requestContext: req,
1971
+ config: input.runtime.config,
1972
+ isDev: input.runtime.isDev,
1973
+ isProd: input.runtime.isProd
1974
+ };
1975
+ }
1976
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createServerIntegrationHandlerContext, "createServerIntegrationHandlerContext");
1977
+ function createServerIntegrationRequestContextStore(request, currentRequest) {
1978
+ return {
1979
+ get(key) {
1980
+ const requestValue = _chunkEM6SBQKMcjs.getRequestContext.call(void 0, request, key);
1981
+ if (requestValue !== void 0) {
1982
+ return requestValue;
1983
+ }
1984
+ if (currentRequest) {
1985
+ return _chunkEM6SBQKMcjs.getRequestContext.call(void 0, currentRequest, key);
1986
+ }
1987
+ return void 0;
1988
+ },
1989
+ set(key, value, options) {
1990
+ _chunkEM6SBQKMcjs.setRequestContext.call(void 0, request, key, value, options);
1991
+ if (currentRequest) {
1992
+ _chunkEM6SBQKMcjs.setRequestContext.call(void 0, currentRequest, key, value, options);
1993
+ }
1994
+ },
1995
+ has(key) {
1996
+ return _chunkEM6SBQKMcjs.hasRequestContext.call(void 0, request, key) || !!currentRequest && _chunkEM6SBQKMcjs.hasRequestContext.call(void 0, currentRequest, key);
1997
+ },
1998
+ delete(key) {
1999
+ const deletedRequest = _chunkEM6SBQKMcjs.deleteRequestContext.call(void 0, request, key);
2000
+ const deletedCurrent = currentRequest ? _chunkEM6SBQKMcjs.deleteRequestContext.call(void 0, currentRequest, key) : false;
2001
+ return deletedRequest || deletedCurrent;
2002
+ },
2003
+ clear() {
2004
+ _chunkEM6SBQKMcjs.clearRequestContext.call(void 0, request);
2005
+ if (currentRequest) {
2006
+ _chunkEM6SBQKMcjs.clearRequestContext.call(void 0, currentRequest);
2007
+ }
2008
+ },
2009
+ snapshot(options) {
2010
+ const merged = currentRequest ? _chunkEM6SBQKMcjs.getRequestContextSnapshot.call(void 0, currentRequest, options) : /* @__PURE__ */ new Map();
2011
+ const requestSnapshot = _chunkEM6SBQKMcjs.getRequestContextSnapshot.call(void 0, request, options);
2012
+ for (const [key, value] of requestSnapshot) {
2013
+ merged.set(key, value);
2014
+ }
2015
+ return merged;
2016
+ }
2017
+ };
2018
+ }
2019
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createServerIntegrationRequestContextStore, "createServerIntegrationRequestContextStore");
2020
+ function createWebRequest(req, fullUrl, body) {
2021
+ const headers = new Headers();
2022
+ for (const [key, value] of Object.entries(req.headers)) {
2023
+ if (value == null) {
2024
+ continue;
2025
+ }
2026
+ if (Array.isArray(value)) {
2027
+ for (const item of value) {
2028
+ headers.append(key, item);
2029
+ }
2030
+ continue;
2031
+ }
2032
+ headers.set(key, value);
2033
+ }
2034
+ return new Request(fullUrl, {
2035
+ method: req.method,
2036
+ headers,
2037
+ body
2038
+ });
2039
+ }
2040
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createWebRequest, "createWebRequest");
2041
+ function normalizeIntegrationRequestMethod(method) {
2042
+ return method ? method.toUpperCase() : void 0;
2043
+ }
2044
+ _chunkS3JO3N4Hcjs.__name.call(void 0, normalizeIntegrationRequestMethod, "normalizeIntegrationRequestMethod");
2045
+ function matchesMethod(methods, normalizedMethod) {
2046
+ return methods.some((candidate) => candidate === "ALL" || candidate === normalizedMethod);
2047
+ }
2048
+ _chunkS3JO3N4Hcjs.__name.call(void 0, matchesMethod, "matchesMethod");
2049
+ function resolveMatcherParams(matcher, pathname) {
2050
+ if (!matcher) {
2051
+ return {};
2052
+ }
2053
+ const list = Array.isArray(matcher) ? matcher : [matcher];
2054
+ let canonicalPathname;
2055
+ let canonicalSegments;
2056
+ for (const item of list) {
2057
+ if (item === "/(.*)" || item === "*") {
2058
+ return {};
2059
+ }
2060
+ if (item.endsWith("(.*)")) {
2061
+ _nullishCoalesce(canonicalPathname, () => ( (canonicalPathname = _chunkUS2QVW3Ecjs.canonicalizeRequestPathname.call(void 0, pathname))));
2062
+ const prefix = item.slice(0, -4);
2063
+ if (canonicalPathname === prefix || canonicalPathname.startsWith(`${prefix}/`)) {
2064
+ return {};
2065
+ }
2066
+ continue;
2067
+ }
2068
+ _nullishCoalesce(canonicalSegments, () => ( (canonicalSegments = _chunkUS2QVW3Ecjs.canonicalizeRequestPathSegments.call(void 0, pathname))));
2069
+ const params = matchPathSegments(splitPath(item), canonicalSegments);
2070
+ if (params) {
2071
+ return params;
2072
+ }
2073
+ }
2074
+ return null;
2075
+ }
2076
+ _chunkS3JO3N4Hcjs.__name.call(void 0, resolveMatcherParams, "resolveMatcherParams");
2077
+ function matchPathSegments(routeSegments, pathSegments) {
2078
+ const params = {};
2079
+ let routeIndex = 0;
2080
+ let pathIndex = 0;
2081
+ while (routeIndex < routeSegments.length && pathIndex < pathSegments.length) {
2082
+ const routeSegment = routeSegments[routeIndex];
2083
+ const pathSegment = pathSegments[pathIndex];
2084
+ if (isCatchAllSegment(routeSegment)) {
2085
+ params[getSegmentParamName(routeSegment)] = pathSegments.slice(pathIndex);
2086
+ return params;
2087
+ }
2088
+ if (isDynamicSegment(routeSegment)) {
2089
+ params[getSegmentParamName(routeSegment)] = pathSegment;
2090
+ routeIndex += 1;
2091
+ pathIndex += 1;
2092
+ continue;
2093
+ }
2094
+ if (routeSegment !== pathSegment) {
2095
+ return null;
2096
+ }
2097
+ routeIndex += 1;
2098
+ pathIndex += 1;
2099
+ }
2100
+ if (routeIndex === routeSegments.length && pathIndex === pathSegments.length) {
2101
+ return params;
2102
+ }
2103
+ if (routeIndex === routeSegments.length - 1 && isCatchAllSegment(routeSegments[routeIndex])) {
2104
+ params[getSegmentParamName(routeSegments[routeIndex])] = [];
2105
+ return params;
2106
+ }
2107
+ return null;
2108
+ }
2109
+ _chunkS3JO3N4Hcjs.__name.call(void 0, matchPathSegments, "matchPathSegments");
2110
+ function splitPath(value) {
2111
+ return value.split("/").filter(Boolean);
2112
+ }
2113
+ _chunkS3JO3N4Hcjs.__name.call(void 0, splitPath, "splitPath");
2114
+ function isDynamicSegment(segment) {
2115
+ return segment.startsWith("[") && segment.endsWith("]");
2116
+ }
2117
+ _chunkS3JO3N4Hcjs.__name.call(void 0, isDynamicSegment, "isDynamicSegment");
2118
+ function isCatchAllSegment(segment) {
2119
+ return segment.startsWith("[...") && segment.endsWith("]");
2120
+ }
2121
+ _chunkS3JO3N4Hcjs.__name.call(void 0, isCatchAllSegment, "isCatchAllSegment");
2122
+ function getSegmentParamName(segment) {
2123
+ if (isCatchAllSegment(segment)) {
2124
+ return segment.slice(4, -1);
2125
+ }
2126
+ return segment.slice(1, -1);
2127
+ }
2128
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getSegmentParamName, "getSegmentParamName");
2129
+ function getRequestId(req) {
2130
+ const headerValue = req.headers["x-request-id"];
2131
+ if (Array.isArray(headerValue)) {
2132
+ return headerValue[0] || String(Date.now());
2133
+ }
2134
+ return headerValue || String(Date.now());
2135
+ }
2136
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getRequestId, "getRequestId");
2137
+ function normalizeMatcher(matcher) {
2138
+ if (!matcher) {
2139
+ return "/(.*)";
2140
+ }
2141
+ return typeof matcher === "string" ? matcher : matcher.join(", ");
2142
+ }
2143
+ _chunkS3JO3N4Hcjs.__name.call(void 0, normalizeMatcher, "normalizeMatcher");
2144
+
2145
+
2146
+
2147
+
2148
+
2149
+
2150
+
2151
+
2152
+
2153
+
2154
+
2155
+
2156
+
2157
+
2158
+
2159
+
2160
+
2161
+
2162
+
2163
+
2164
+
2165
+
2166
+
2167
+
2168
+
2169
+
2170
+
2171
+
2172
+
2173
+ exports.resolveIntegrationAllowedOrigins = resolveIntegrationAllowedOrigins; exports.validateIntegrationRequestOrigin = validateIntegrationRequestOrigin; exports.describeIntegrationOriginRejection = describeIntegrationOriginRejection; exports.getFarmPluginIntegrationContext = getFarmPluginIntegrationContext; exports.FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY = FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY; exports.FARM_INTEGRATION_SET_COOKIES_KEY = FARM_INTEGRATION_SET_COOKIES_KEY; exports.forwardIntegrationSetCookies = forwardIntegrationSetCookies; exports.defineIntegrationSchema = defineIntegrationSchema; exports.getFarmIntegrationPluginServerRuntime = getFarmIntegrationPluginServerRuntime; exports.getFarmIntegrationPluginOwner = getFarmIntegrationPluginOwner; exports.createIntegrationRoute = createIntegrationRoute; exports.integrationRoute = integrationRoute; exports.defineIntegration = defineIntegration; exports.isFarmIntegration = isFarmIntegration; exports.resolveIntegrationPlugins = resolveIntegrationPlugins; exports.getIntegrationProviders = getIntegrationProviders; exports.isFarmIntegrationProviderComponentReference = isFarmIntegrationProviderComponentReference; exports.getIntegrationDocumentNavigationMatchers = getIntegrationDocumentNavigationMatchers; exports.getIntegrationSchemas = getIntegrationSchemas; exports.getRegisteredIntegrationRuntime = getRegisteredIntegrationRuntime; exports.getRegisteredIntegrations = getRegisteredIntegrations; exports.getRegisteredIntegrationSchemas = getRegisteredIntegrationSchemas; exports.matchIntegrationRoute = matchIntegrationRoute; exports.matchRegisteredIntegrationRoute = matchRegisteredIntegrationRoute; exports.getRegisteredIntegrationAPIManifest = getRegisteredIntegrationAPIManifest; exports.dispatchIntegrationRequest = dispatchIntegrationRequest; exports.dispatchIntegrationRequests = dispatchIntegrationRequests;