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

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 (424) hide show
  1. package/package.json +1 -1
  2. package/dist/after.cjs +0 -227
  3. package/dist/after.cjs.map +0 -1
  4. package/dist/after.d.mts +0 -25
  5. package/dist/after.d.ts +0 -25
  6. package/dist/after.mjs +0 -14
  7. package/dist/after.mjs.map +0 -1
  8. package/dist/agent-runtime.cjs +0 -2379
  9. package/dist/agent-runtime.cjs.map +0 -1
  10. package/dist/agent-runtime.d.mts +0 -94
  11. package/dist/agent-runtime.d.ts +0 -94
  12. package/dist/agent-runtime.mjs +0 -479
  13. package/dist/agent-runtime.mjs.map +0 -1
  14. package/dist/api/route-manager.d.mts +0 -66
  15. package/dist/api/route-manager.d.ts +0 -66
  16. package/dist/api/runtime.d.mts +0 -3
  17. package/dist/api/runtime.d.ts +0 -3
  18. package/dist/api.cjs +0 -4100
  19. package/dist/api.cjs.map +0 -1
  20. package/dist/api.d.mts +0 -48
  21. package/dist/api.d.ts +0 -48
  22. package/dist/api.mjs +0 -93
  23. package/dist/api.mjs.map +0 -1
  24. package/dist/app-BjN-da13.d.ts +0 -300
  25. package/dist/app-CakAr8Be.d.mts +0 -300
  26. package/dist/app-markdown.cjs +0 -220
  27. package/dist/app-markdown.cjs.map +0 -1
  28. package/dist/app-markdown.d.mts +0 -22
  29. package/dist/app-markdown.d.ts +0 -22
  30. package/dist/app-markdown.mjs +0 -26
  31. package/dist/app-markdown.mjs.map +0 -1
  32. package/dist/cache.cjs +0 -945
  33. package/dist/cache.cjs.map +0 -1
  34. package/dist/cache.d.mts +0 -192
  35. package/dist/cache.d.ts +0 -192
  36. package/dist/cache.mjs +0 -46
  37. package/dist/cache.mjs.map +0 -1
  38. package/dist/chunk-2CUKEMVR.mjs +0 -872
  39. package/dist/chunk-2CUKEMVR.mjs.map +0 -1
  40. package/dist/chunk-2ED5Q2GH.mjs +0 -422
  41. package/dist/chunk-2ED5Q2GH.mjs.map +0 -1
  42. package/dist/chunk-2NHCNRF6.mjs +0 -6241
  43. package/dist/chunk-2NHCNRF6.mjs.map +0 -1
  44. package/dist/chunk-32W4QEJP.mjs +0 -158
  45. package/dist/chunk-32W4QEJP.mjs.map +0 -1
  46. package/dist/chunk-3XNTL3FQ.mjs +0 -452
  47. package/dist/chunk-3XNTL3FQ.mjs.map +0 -1
  48. package/dist/chunk-44ZCFSKE.mjs +0 -84
  49. package/dist/chunk-44ZCFSKE.mjs.map +0 -1
  50. package/dist/chunk-4S3ORGFA.mjs +0 -44
  51. package/dist/chunk-4S3ORGFA.mjs.map +0 -1
  52. package/dist/chunk-5BY76U2M.mjs +0 -1
  53. package/dist/chunk-5BY76U2M.mjs.map +0 -1
  54. package/dist/chunk-5ZGPRGWV.mjs +0 -136
  55. package/dist/chunk-5ZGPRGWV.mjs.map +0 -1
  56. package/dist/chunk-65A7QIKI.mjs +0 -142
  57. package/dist/chunk-65A7QIKI.mjs.map +0 -1
  58. package/dist/chunk-74YTBPTY.mjs +0 -450
  59. package/dist/chunk-74YTBPTY.mjs.map +0 -1
  60. package/dist/chunk-7HO6AEOP.mjs +0 -74
  61. package/dist/chunk-7HO6AEOP.mjs.map +0 -1
  62. package/dist/chunk-7MABZJIM.mjs +0 -29
  63. package/dist/chunk-7MABZJIM.mjs.map +0 -1
  64. package/dist/chunk-7N62DNSO.mjs +0 -41
  65. package/dist/chunk-7N62DNSO.mjs.map +0 -1
  66. package/dist/chunk-7ZY5AIJO.mjs +0 -161
  67. package/dist/chunk-7ZY5AIJO.mjs.map +0 -1
  68. package/dist/chunk-A2LUXHD2.mjs +0 -7631
  69. package/dist/chunk-A2LUXHD2.mjs.map +0 -1
  70. package/dist/chunk-ALCLXXTY.mjs +0 -187
  71. package/dist/chunk-ALCLXXTY.mjs.map +0 -1
  72. package/dist/chunk-AZ7YUVNR.mjs +0 -65
  73. package/dist/chunk-AZ7YUVNR.mjs.map +0 -1
  74. package/dist/chunk-B232I2GP.mjs +0 -163
  75. package/dist/chunk-B232I2GP.mjs.map +0 -1
  76. package/dist/chunk-BHG3LVHH.mjs +0 -176
  77. package/dist/chunk-BHG3LVHH.mjs.map +0 -1
  78. package/dist/chunk-C2ROET2V.mjs +0 -718
  79. package/dist/chunk-C2ROET2V.mjs.map +0 -1
  80. package/dist/chunk-C3DLZMBU.mjs +0 -597
  81. package/dist/chunk-C3DLZMBU.mjs.map +0 -1
  82. package/dist/chunk-CGILA3WO.mjs +0 -14
  83. package/dist/chunk-CGILA3WO.mjs.map +0 -1
  84. package/dist/chunk-E2MPIBRE.mjs +0 -149
  85. package/dist/chunk-E2MPIBRE.mjs.map +0 -1
  86. package/dist/chunk-E6EPN5BT.mjs +0 -203
  87. package/dist/chunk-E6EPN5BT.mjs.map +0 -1
  88. package/dist/chunk-EEABSBKK.mjs +0 -10
  89. package/dist/chunk-EEABSBKK.mjs.map +0 -1
  90. package/dist/chunk-EJ7T4TPB.mjs +0 -622
  91. package/dist/chunk-EJ7T4TPB.mjs.map +0 -1
  92. package/dist/chunk-FQYDHKKU.mjs +0 -128
  93. package/dist/chunk-FQYDHKKU.mjs.map +0 -1
  94. package/dist/chunk-FRPWCMMG.mjs +0 -299
  95. package/dist/chunk-FRPWCMMG.mjs.map +0 -1
  96. package/dist/chunk-GN72QAIH.mjs +0 -146
  97. package/dist/chunk-GN72QAIH.mjs.map +0 -1
  98. package/dist/chunk-GQVGIUSN.mjs +0 -149
  99. package/dist/chunk-GQVGIUSN.mjs.map +0 -1
  100. package/dist/chunk-GS6K5OCM.mjs +0 -407
  101. package/dist/chunk-GS6K5OCM.mjs.map +0 -1
  102. package/dist/chunk-GXASWWJU.mjs +0 -364
  103. package/dist/chunk-GXASWWJU.mjs.map +0 -1
  104. package/dist/chunk-GY2STC2S.mjs +0 -180
  105. package/dist/chunk-GY2STC2S.mjs.map +0 -1
  106. package/dist/chunk-H2FA2SBS.mjs +0 -51
  107. package/dist/chunk-H2FA2SBS.mjs.map +0 -1
  108. package/dist/chunk-HNIQFZKB.mjs +0 -3550
  109. package/dist/chunk-HNIQFZKB.mjs.map +0 -1
  110. package/dist/chunk-ITN462YM.mjs +0 -98
  111. package/dist/chunk-ITN462YM.mjs.map +0 -1
  112. package/dist/chunk-J23HNLFY.mjs +0 -72
  113. package/dist/chunk-J23HNLFY.mjs.map +0 -1
  114. package/dist/chunk-J4FNJ5IU.mjs +0 -179
  115. package/dist/chunk-J4FNJ5IU.mjs.map +0 -1
  116. package/dist/chunk-J5YWQVI5.mjs +0 -211
  117. package/dist/chunk-J5YWQVI5.mjs.map +0 -1
  118. package/dist/chunk-JDEOUK5V.mjs +0 -427
  119. package/dist/chunk-JDEOUK5V.mjs.map +0 -1
  120. package/dist/chunk-JK25YEN6.mjs +0 -219
  121. package/dist/chunk-JK25YEN6.mjs.map +0 -1
  122. package/dist/chunk-K4667E2Q.mjs +0 -1916
  123. package/dist/chunk-K4667E2Q.mjs.map +0 -1
  124. package/dist/chunk-LGHEOHBU.mjs +0 -218
  125. package/dist/chunk-LGHEOHBU.mjs.map +0 -1
  126. package/dist/chunk-LLC7BNXW.mjs +0 -275
  127. package/dist/chunk-LLC7BNXW.mjs.map +0 -1
  128. package/dist/chunk-LM2YNO4U.mjs +0 -24
  129. package/dist/chunk-LM2YNO4U.mjs.map +0 -1
  130. package/dist/chunk-MIUW47JX.mjs +0 -639
  131. package/dist/chunk-MIUW47JX.mjs.map +0 -1
  132. package/dist/chunk-NM3CRAAL.mjs +0 -467
  133. package/dist/chunk-NM3CRAAL.mjs.map +0 -1
  134. package/dist/chunk-NNLCAVB6.mjs +0 -391
  135. package/dist/chunk-NNLCAVB6.mjs.map +0 -1
  136. package/dist/chunk-P7QDS5AT.mjs +0 -191
  137. package/dist/chunk-P7QDS5AT.mjs.map +0 -1
  138. package/dist/chunk-PFE6GMNE.mjs +0 -603
  139. package/dist/chunk-PFE6GMNE.mjs.map +0 -1
  140. package/dist/chunk-QGOHVJ6J.mjs +0 -63
  141. package/dist/chunk-QGOHVJ6J.mjs.map +0 -1
  142. package/dist/chunk-QGQX7SFC.mjs +0 -180
  143. package/dist/chunk-QGQX7SFC.mjs.map +0 -1
  144. package/dist/chunk-QKVUNGAH.mjs +0 -39
  145. package/dist/chunk-QKVUNGAH.mjs.map +0 -1
  146. package/dist/chunk-QM746KUO.mjs +0 -56
  147. package/dist/chunk-QM746KUO.mjs.map +0 -1
  148. package/dist/chunk-QTZZ2ISQ.mjs +0 -753
  149. package/dist/chunk-QTZZ2ISQ.mjs.map +0 -1
  150. package/dist/chunk-RBRLLZL5.mjs +0 -81
  151. package/dist/chunk-RBRLLZL5.mjs.map +0 -1
  152. package/dist/chunk-RHIFZZUI.mjs +0 -69
  153. package/dist/chunk-RHIFZZUI.mjs.map +0 -1
  154. package/dist/chunk-RSKVYESE.mjs +0 -187
  155. package/dist/chunk-RSKVYESE.mjs.map +0 -1
  156. package/dist/chunk-SCFX4UTD.mjs +0 -28
  157. package/dist/chunk-SCFX4UTD.mjs.map +0 -1
  158. package/dist/chunk-SL6HTIOK.mjs +0 -66
  159. package/dist/chunk-SL6HTIOK.mjs.map +0 -1
  160. package/dist/chunk-SPBBQLXI.mjs +0 -207
  161. package/dist/chunk-SPBBQLXI.mjs.map +0 -1
  162. package/dist/chunk-T4QJQK76.mjs +0 -459
  163. package/dist/chunk-T4QJQK76.mjs.map +0 -1
  164. package/dist/chunk-TQAEEJB4.mjs +0 -157
  165. package/dist/chunk-TQAEEJB4.mjs.map +0 -1
  166. package/dist/chunk-UB5UOSHB.mjs +0 -458
  167. package/dist/chunk-UB5UOSHB.mjs.map +0 -1
  168. package/dist/chunk-USWZZUEH.mjs +0 -25
  169. package/dist/chunk-USWZZUEH.mjs.map +0 -1
  170. package/dist/chunk-UVCIEUJC.mjs +0 -16
  171. package/dist/chunk-UVCIEUJC.mjs.map +0 -1
  172. package/dist/chunk-UXUAWNO5.mjs +0 -396
  173. package/dist/chunk-UXUAWNO5.mjs.map +0 -1
  174. package/dist/chunk-V3XURYJO.mjs +0 -756
  175. package/dist/chunk-V3XURYJO.mjs.map +0 -1
  176. package/dist/chunk-V6WE6JSZ.mjs +0 -352
  177. package/dist/chunk-V6WE6JSZ.mjs.map +0 -1
  178. package/dist/chunk-V7RBCSDJ.mjs +0 -170
  179. package/dist/chunk-V7RBCSDJ.mjs.map +0 -1
  180. package/dist/chunk-VCANOYFI.mjs +0 -588
  181. package/dist/chunk-VCANOYFI.mjs.map +0 -1
  182. package/dist/chunk-VY2UYN5R.mjs +0 -224
  183. package/dist/chunk-VY2UYN5R.mjs.map +0 -1
  184. package/dist/chunk-W2CRQFF6.mjs +0 -1352
  185. package/dist/chunk-W2CRQFF6.mjs.map +0 -1
  186. package/dist/chunk-WZ5QFROO.mjs +0 -23
  187. package/dist/chunk-WZ5QFROO.mjs.map +0 -1
  188. package/dist/chunk-XIVV5IWN.mjs +0 -541
  189. package/dist/chunk-XIVV5IWN.mjs.map +0 -1
  190. package/dist/chunk-YW7OBE6Q.mjs +0 -119
  191. package/dist/chunk-YW7OBE6Q.mjs.map +0 -1
  192. package/dist/chunk-Z5CQMP54.mjs +0 -365
  193. package/dist/chunk-Z5CQMP54.mjs.map +0 -1
  194. package/dist/chunk-ZBE6MLHL.mjs +0 -230
  195. package/dist/chunk-ZBE6MLHL.mjs.map +0 -1
  196. package/dist/chunk-ZZ57EH5Z.mjs +0 -173
  197. package/dist/chunk-ZZ57EH5Z.mjs.map +0 -1
  198. package/dist/client-BT1mFQas.d.mts +0 -447
  199. package/dist/client-Nn0q4eO4.d.ts +0 -447
  200. package/dist/client-cache-CIlyBlmx.d.ts +0 -6
  201. package/dist/client-cache-D-EZ7XVW.d.mts +0 -6
  202. package/dist/client-plugins-Cw4qUGsw.d.ts +0 -1855
  203. package/dist/client-plugins-DQQ1adXM.d.mts +0 -1855
  204. package/dist/client-plugins.cjs +0 -415
  205. package/dist/client-plugins.cjs.map +0 -1
  206. package/dist/client-plugins.d.mts +0 -22
  207. package/dist/client-plugins.d.ts +0 -22
  208. package/dist/client-plugins.mjs +0 -10
  209. package/dist/client-plugins.mjs.map +0 -1
  210. package/dist/client.cjs +0 -5402
  211. package/dist/client.cjs.map +0 -1
  212. package/dist/client.d.mts +0 -447
  213. package/dist/client.d.ts +0 -447
  214. package/dist/client.mjs +0 -110
  215. package/dist/client.mjs.map +0 -1
  216. package/dist/config.cjs +0 -38
  217. package/dist/config.cjs.map +0 -1
  218. package/dist/config.d.mts +0 -29
  219. package/dist/config.d.ts +0 -29
  220. package/dist/config.mjs +0 -10
  221. package/dist/config.mjs.map +0 -1
  222. package/dist/cron.cjs +0 -406
  223. package/dist/cron.cjs.map +0 -1
  224. package/dist/cron.d.mts +0 -78
  225. package/dist/cron.d.ts +0 -78
  226. package/dist/cron.mjs +0 -30
  227. package/dist/cron.mjs.map +0 -1
  228. package/dist/deferred.cjs +0 -438
  229. package/dist/deferred.cjs.map +0 -1
  230. package/dist/deferred.d.mts +0 -42
  231. package/dist/deferred.d.ts +0 -42
  232. package/dist/deferred.mjs +0 -28
  233. package/dist/deferred.mjs.map +0 -1
  234. package/dist/deployment.cjs +0 -199
  235. package/dist/deployment.cjs.map +0 -1
  236. package/dist/deployment.d.mts +0 -34
  237. package/dist/deployment.d.ts +0 -34
  238. package/dist/deployment.mjs +0 -38
  239. package/dist/deployment.mjs.map +0 -1
  240. package/dist/devtools-LVC3VB5P.mjs +0 -370
  241. package/dist/devtools-LVC3VB5P.mjs.map +0 -1
  242. package/dist/devtools-client-3XRTBND5.mjs +0 -216
  243. package/dist/devtools-client-3XRTBND5.mjs.map +0 -1
  244. package/dist/devtools-ui-NJKFORTG.mjs +0 -1349
  245. package/dist/devtools-ui-NJKFORTG.mjs.map +0 -1
  246. package/dist/docs.cjs +0 -5553
  247. package/dist/docs.cjs.map +0 -1
  248. package/dist/docs.d.mts +0 -69
  249. package/dist/docs.d.ts +0 -69
  250. package/dist/docs.mjs +0 -46
  251. package/dist/docs.mjs.map +0 -1
  252. package/dist/env-types.cjs +0 -223
  253. package/dist/env-types.cjs.map +0 -1
  254. package/dist/env-types.d.mts +0 -11
  255. package/dist/env-types.d.ts +0 -11
  256. package/dist/env-types.mjs +0 -9
  257. package/dist/env-types.mjs.map +0 -1
  258. package/dist/env.cjs +0 -215
  259. package/dist/env.cjs.map +0 -1
  260. package/dist/env.d.mts +0 -45
  261. package/dist/env.d.ts +0 -45
  262. package/dist/env.mjs +0 -22
  263. package/dist/env.mjs.map +0 -1
  264. package/dist/environment/vite.d.mts +0 -22
  265. package/dist/environment/vite.d.ts +0 -22
  266. package/dist/environment.cjs +0 -96
  267. package/dist/environment.cjs.map +0 -1
  268. package/dist/environment.d.mts +0 -18
  269. package/dist/environment.d.ts +0 -18
  270. package/dist/environment.mjs +0 -14
  271. package/dist/environment.mjs.map +0 -1
  272. package/dist/headers.cjs +0 -126
  273. package/dist/headers.cjs.map +0 -1
  274. package/dist/headers.d.mts +0 -22
  275. package/dist/headers.d.ts +0 -22
  276. package/dist/headers.mjs +0 -12
  277. package/dist/headers.mjs.map +0 -1
  278. package/dist/i18n/client.d.mts +0 -32
  279. package/dist/i18n/client.d.ts +0 -32
  280. package/dist/i18n/index.d.mts +0 -20
  281. package/dist/i18n/index.d.ts +0 -20
  282. package/dist/i18n/server.d.mts +0 -30
  283. package/dist/i18n/server.d.ts +0 -30
  284. package/dist/image/server.d.mts +0 -37
  285. package/dist/image/server.d.ts +0 -37
  286. package/dist/image/sharp.d.mts +0 -7
  287. package/dist/image/sharp.d.ts +0 -7
  288. package/dist/image-config-Duob7wER.d.mts +0 -50
  289. package/dist/image-config-Duob7wER.d.ts +0 -50
  290. package/dist/image.cjs +0 -209
  291. package/dist/image.cjs.map +0 -1
  292. package/dist/image.d.mts +0 -39
  293. package/dist/image.d.ts +0 -39
  294. package/dist/image.mjs +0 -165
  295. package/dist/image.mjs.map +0 -1
  296. package/dist/index.cjs +0 -41822
  297. package/dist/index.cjs.map +0 -1
  298. package/dist/index.d.mts +0 -451
  299. package/dist/index.d.ts +0 -451
  300. package/dist/index.mjs +0 -973
  301. package/dist/index.mjs.map +0 -1
  302. package/dist/integration-api-CHT2OKAf.d.mts +0 -93
  303. package/dist/integration-api-CHT2OKAf.d.ts +0 -93
  304. package/dist/integration-orm-GQLGU66X.mjs +0 -13
  305. package/dist/integration-orm-GQLGU66X.mjs.map +0 -1
  306. package/dist/integrations.cjs +0 -2820
  307. package/dist/integrations.cjs.map +0 -1
  308. package/dist/integrations.d.mts +0 -22
  309. package/dist/integrations.d.ts +0 -22
  310. package/dist/integrations.mjs +0 -51
  311. package/dist/integrations.mjs.map +0 -1
  312. package/dist/internal/build-runtime.d.mts +0 -39
  313. package/dist/internal/build-runtime.d.ts +0 -39
  314. package/dist/internal/client-runtime.d.mts +0 -2
  315. package/dist/internal/client-runtime.d.ts +0 -2
  316. package/dist/internal/config-runtime.d.mts +0 -39
  317. package/dist/internal/config-runtime.d.ts +0 -39
  318. package/dist/internal/production-node-env.d.mts +0 -12
  319. package/dist/internal/production-node-env.d.ts +0 -12
  320. package/dist/internal/production-runtime.d.mts +0 -39
  321. package/dist/internal/production-runtime.d.ts +0 -39
  322. package/dist/layers-VWVDTPUZ.mjs +0 -16
  323. package/dist/layers-VWVDTPUZ.mjs.map +0 -1
  324. package/dist/manager-THKFTOFE.mjs +0 -10
  325. package/dist/manager-THKFTOFE.mjs.map +0 -1
  326. package/dist/markdown.cjs +0 -299
  327. package/dist/markdown.cjs.map +0 -1
  328. package/dist/markdown.d.mts +0 -43
  329. package/dist/markdown.d.ts +0 -43
  330. package/dist/markdown.mjs +0 -14
  331. package/dist/markdown.mjs.map +0 -1
  332. package/dist/metadata-BAPg_Nmo.d.ts +0 -22
  333. package/dist/metadata-_6i9oFG3.d.mts +0 -22
  334. package/dist/middleware.cjs +0 -2148
  335. package/dist/middleware.cjs.map +0 -1
  336. package/dist/middleware.d.mts +0 -164
  337. package/dist/middleware.d.ts +0 -164
  338. package/dist/middleware.mjs +0 -49
  339. package/dist/middleware.mjs.map +0 -1
  340. package/dist/navigation-errors-Dvwpzaer.d.mts +0 -13
  341. package/dist/navigation-errors-Dvwpzaer.d.ts +0 -13
  342. package/dist/navigation.cjs +0 -1329
  343. package/dist/navigation.cjs.map +0 -1
  344. package/dist/navigation.d.mts +0 -14
  345. package/dist/navigation.d.ts +0 -14
  346. package/dist/navigation.mjs +0 -33
  347. package/dist/navigation.mjs.map +0 -1
  348. package/dist/nitro-QO5LV6QK.mjs +0 -689
  349. package/dist/nitro-QO5LV6QK.mjs.map +0 -1
  350. package/dist/observability.cjs +0 -186
  351. package/dist/observability.cjs.map +0 -1
  352. package/dist/observability.d.mts +0 -335
  353. package/dist/observability.d.ts +0 -335
  354. package/dist/observability.mjs +0 -16
  355. package/dist/observability.mjs.map +0 -1
  356. package/dist/params-BALtrRim.d.ts +0 -15
  357. package/dist/params-ry-lxqmy.d.mts +0 -15
  358. package/dist/plugin-BJDf43dc.d.mts +0 -165
  359. package/dist/plugin-BJDf43dc.d.ts +0 -165
  360. package/dist/plugin.cjs +0 -23225
  361. package/dist/plugin.d.mts +0 -22
  362. package/dist/plugin.d.ts +0 -22
  363. package/dist/production-runtime-BoJDc5mc.d.ts +0 -79
  364. package/dist/production-runtime-C_B79w2P.d.mts +0 -28
  365. package/dist/production-runtime-DDEM1D2q.d.ts +0 -28
  366. package/dist/production-runtime-DPfgMV9Y.d.mts +0 -79
  367. package/dist/query/client.d.mts +0 -61
  368. package/dist/query/client.d.ts +0 -61
  369. package/dist/query/index.d.mts +0 -90
  370. package/dist/query/index.d.ts +0 -90
  371. package/dist/query/parsers.d.mts +0 -25
  372. package/dist/query/parsers.d.ts +0 -25
  373. package/dist/query/server.d.mts +0 -55
  374. package/dist/query/server.d.ts +0 -55
  375. package/dist/request-BrFBuc8G.d.mts +0 -6
  376. package/dist/request-BslSZIRz.d.ts +0 -6
  377. package/dist/request.d.mts +0 -2
  378. package/dist/request.d.ts +0 -2
  379. package/dist/resolver-C6iecsDV.d.ts +0 -14
  380. package/dist/resolver-DlOPpjkB.d.mts +0 -14
  381. package/dist/route-runtime-DoOHzCAD.d.mts +0 -38
  382. package/dist/route-runtime-DoOHzCAD.d.ts +0 -38
  383. package/dist/router.d.mts +0 -36
  384. package/dist/router.d.ts +0 -36
  385. package/dist/routes.d.mts +0 -224
  386. package/dist/routes.d.ts +0 -224
  387. package/dist/runtime-9nQjVM7X.d.mts +0 -206
  388. package/dist/runtime-B6GvwDS1.d.ts +0 -27
  389. package/dist/runtime-DeAAZ6gO.d.mts +0 -27
  390. package/dist/runtime-DgeS2skB.d.ts +0 -206
  391. package/dist/server-action-security.d.mts +0 -43
  392. package/dist/server-action-security.d.ts +0 -43
  393. package/dist/server-fn-client.d.mts +0 -32
  394. package/dist/server-fn-client.d.ts +0 -32
  395. package/dist/server-fn.d.mts +0 -93
  396. package/dist/server-fn.d.ts +0 -93
  397. package/dist/server-plugins.d.mts +0 -55
  398. package/dist/server-plugins.d.ts +0 -55
  399. package/dist/server-query-client.d.mts +0 -50
  400. package/dist/server-query-client.d.ts +0 -50
  401. package/dist/server-query.d.mts +0 -36
  402. package/dist/server-query.d.ts +0 -36
  403. package/dist/server.d.mts +0 -48
  404. package/dist/server.d.ts +0 -48
  405. package/dist/storage.d.mts +0 -52
  406. package/dist/storage.d.ts +0 -52
  407. package/dist/testing.d.mts +0 -101
  408. package/dist/testing.d.ts +0 -101
  409. package/dist/transport-BmbGTXA5.d.mts +0 -49
  410. package/dist/transport-BmbGTXA5.d.ts +0 -49
  411. package/dist/types-BH1lhg5G.d.mts +0 -81
  412. package/dist/types-BH1lhg5G.d.ts +0 -81
  413. package/dist/types-C9N-nk5R.d.mts +0 -53
  414. package/dist/types-C9N-nk5R.d.ts +0 -53
  415. package/dist/types-D1A6-XvH.d.mts +0 -73
  416. package/dist/types-D1A6-XvH.d.ts +0 -73
  417. package/dist/utils-CHXlMDkg.d.mts +0 -23
  418. package/dist/utils-Drsyz1Vj.d.ts +0 -23
  419. package/dist/version.d.mts +0 -3
  420. package/dist/version.d.ts +0 -3
  421. package/dist/vite.d.mts +0 -22
  422. package/dist/vite.d.ts +0 -22
  423. package/dist/workflows.d.mts +0 -110
  424. package/dist/workflows.d.ts +0 -110
@@ -1,1352 +0,0 @@
1
- import {
2
- getFarmClientDataCache,
3
- normalizeFarmClientCacheKey
4
- } from "./chunk-TQAEEJB4.mjs";
5
- import {
6
- isFarmAPIStream,
7
- isJSONStreamResponse,
8
- readJSONStream
9
- } from "./chunk-ALCLXXTY.mjs";
10
- import {
11
- FARM_CACHE_INVALIDATION_HEADER,
12
- applyFarmCacheInvalidations,
13
- decodeFarmCacheInvalidations
14
- } from "./chunk-RBRLLZL5.mjs";
15
- import {
16
- __name
17
- } from "./chunk-CGILA3WO.mjs";
18
-
19
- // src/integration-client.ts
20
- var _IntegrationClientError = class _IntegrationClientError extends Error {
21
- constructor(message, response, data) {
22
- super(message);
23
- this.name = "IntegrationClientError";
24
- this.status = response.status;
25
- this.response = response;
26
- this.data = data;
27
- }
28
- };
29
- __name(_IntegrationClientError, "IntegrationClientError");
30
- var IntegrationClientError = _IntegrationClientError;
31
- var INTEGRATION_RUNTIME_REGISTRY_KEY = /* @__PURE__ */ Symbol.for("farm.integrationRuntimeRegistry");
32
- var CURRENT_REQUEST_RESOLVER_KEY = /* @__PURE__ */ Symbol.for("farm.currentRequestResolver");
33
- var INTEGRATION_REQUEST_DISPATCHER_KEY = /* @__PURE__ */ Symbol.for("farm.integrationRequestDispatcher");
34
- function isOperation(value) {
35
- return !!value && typeof value === "object" && value.kind === "farm-integration-api-operation";
36
- }
37
- __name(isOperation, "isOperation");
38
- function tryResolveSourceAPI(source) {
39
- if ("kind" in source && source.kind === "farm-integration") {
40
- if (!source.api) {
41
- return null;
42
- }
43
- return source.api;
44
- }
45
- return source;
46
- }
47
- __name(tryResolveSourceAPI, "tryResolveSourceAPI");
48
- function getIntegrationRuntimeRegistry() {
49
- const globalState = globalThis;
50
- return globalState[INTEGRATION_RUNTIME_REGISTRY_KEY] || /* @__PURE__ */ new Map();
51
- }
52
- __name(getIntegrationRuntimeRegistry, "getIntegrationRuntimeRegistry");
53
- function getRegisteredIntegrationRuntimeLocal(key) {
54
- return getIntegrationRuntimeRegistry().get(key);
55
- }
56
- __name(getRegisteredIntegrationRuntimeLocal, "getRegisteredIntegrationRuntimeLocal");
57
- function getRegisteredIntegrationsLocal() {
58
- return Object.fromEntries(
59
- Array.from(getIntegrationRuntimeRegistry().entries()).map(([key, runtime]) => [
60
- key,
61
- runtime.integration
62
- ])
63
- );
64
- }
65
- __name(getRegisteredIntegrationsLocal, "getRegisteredIntegrationsLocal");
66
- function resolveCurrentRequestLocal() {
67
- const globalState = globalThis;
68
- return globalState[CURRENT_REQUEST_RESOLVER_KEY]?.();
69
- }
70
- __name(resolveCurrentRequestLocal, "resolveCurrentRequestLocal");
71
- function resolveIntegrationRequestDispatcherLocal() {
72
- const globalState = globalThis;
73
- return globalState[INTEGRATION_REQUEST_DISPATCHER_KEY];
74
- }
75
- __name(resolveIntegrationRequestDispatcherLocal, "resolveIntegrationRequestDispatcherLocal");
76
- var INTEGRATION_DATA_HEADER = "x-farm-integration-data";
77
- var INTEGRATION_DATA_HEADER_MAX_LENGTH = 16 * 1024;
78
- var BLOCKED_INTEGRATION_DATA_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
79
- function isIntegrationClientData(value) {
80
- return !!value && typeof value === "object" && !Array.isArray(value);
81
- }
82
- __name(isIntegrationClientData, "isIntegrationClientData");
83
- function isPlainIntegrationDataObject(value) {
84
- if (!isIntegrationClientData(value)) {
85
- return false;
86
- }
87
- const prototype = Object.getPrototypeOf(value);
88
- return prototype === Object.prototype || prototype === null;
89
- }
90
- __name(isPlainIntegrationDataObject, "isPlainIntegrationDataObject");
91
- function sanitizeIntegrationClientDataValue(value) {
92
- if (Array.isArray(value)) {
93
- return value.map((item) => sanitizeIntegrationClientDataValue(item));
94
- }
95
- if (!isPlainIntegrationDataObject(value)) {
96
- return value;
97
- }
98
- const sanitized = {};
99
- for (const [key, item] of Object.entries(value)) {
100
- if (BLOCKED_INTEGRATION_DATA_KEYS.has(key)) {
101
- continue;
102
- }
103
- sanitized[key] = sanitizeIntegrationClientDataValue(item);
104
- }
105
- return sanitized;
106
- }
107
- __name(sanitizeIntegrationClientDataValue, "sanitizeIntegrationClientDataValue");
108
- function normalizeIntegrationClientData(value) {
109
- if (!isIntegrationClientData(value)) {
110
- return void 0;
111
- }
112
- const sanitized = sanitizeIntegrationClientDataValue(value);
113
- return isIntegrationClientData(sanitized) && Object.keys(sanitized).length > 0 ? sanitized : void 0;
114
- }
115
- __name(normalizeIntegrationClientData, "normalizeIntegrationClientData");
116
- function getIntegrationDataHeaderByteLength(value) {
117
- return new TextEncoder().encode(value).byteLength;
118
- }
119
- __name(getIntegrationDataHeaderByteLength, "getIntegrationDataHeaderByteLength");
120
- function mergeIntegrationClientData(...values) {
121
- let merged;
122
- for (const value of values) {
123
- const data = normalizeIntegrationClientData(value);
124
- if (!data) {
125
- continue;
126
- }
127
- merged = {
128
- ...merged,
129
- ...data
130
- };
131
- }
132
- return merged && Object.keys(merged).length > 0 ? merged : void 0;
133
- }
134
- __name(mergeIntegrationClientData, "mergeIntegrationClientData");
135
- function serializeIntegrationClientData(data) {
136
- const serialized = JSON.stringify(data);
137
- if (getIntegrationDataHeaderByteLength(serialized) > INTEGRATION_DATA_HEADER_MAX_LENGTH) {
138
- throw new Error(
139
- `Integration client data must be smaller than ${INTEGRATION_DATA_HEADER_MAX_LENGTH} bytes when sent over HTTP headers.`
140
- );
141
- }
142
- return serialized;
143
- }
144
- __name(serializeIntegrationClientData, "serializeIntegrationClientData");
145
- function appendIntegrationClientDataHeader(headers, data) {
146
- if (!data) {
147
- return;
148
- }
149
- headers.set(INTEGRATION_DATA_HEADER, serializeIntegrationClientData(data));
150
- }
151
- __name(appendIntegrationClientDataHeader, "appendIntegrationClientDataHeader");
152
- function resolveAutomaticClientNamespaces() {
153
- const globalState = globalThis;
154
- const manifest = globalState.window?.__FARM_INTEGRATION_API_MANIFEST__ || globalState.__FARM_INTEGRATION_API_MANIFEST__ || {};
155
- return Object.entries(manifest).map(([key, api]) => [key, api, api]);
156
- }
157
- __name(resolveAutomaticClientNamespaces, "resolveAutomaticClientNamespaces");
158
- function resolveAutomaticServerNamespaces() {
159
- return Object.entries(getRegisteredIntegrationsLocal()).flatMap(([key, source]) => {
160
- const api = tryResolveSourceAPI(source);
161
- return api ? [[key, api, source]] : [];
162
- });
163
- }
164
- __name(resolveAutomaticServerNamespaces, "resolveAutomaticServerNamespaces");
165
- function appendQuery(url, query) {
166
- if (!query) {
167
- return;
168
- }
169
- for (const [key, value] of Object.entries(query)) {
170
- if (value == null) {
171
- continue;
172
- }
173
- if (Array.isArray(value)) {
174
- for (const item of value) {
175
- if (item != null) {
176
- url.searchParams.append(key, String(item));
177
- }
178
- }
179
- continue;
180
- }
181
- url.searchParams.set(key, String(value));
182
- }
183
- }
184
- __name(appendQuery, "appendQuery");
185
- function appendHeaders(target, source) {
186
- if (!source) {
187
- return;
188
- }
189
- const headers = new Headers(source);
190
- headers.forEach((value, key) => {
191
- target.set(key, value);
192
- });
193
- }
194
- __name(appendHeaders, "appendHeaders");
195
- var DEFAULT_FORWARDED_HEADERS = [
196
- "authorization",
197
- "cookie",
198
- "x-client-ip",
199
- "x-forwarded-for",
200
- "x-forwarded-host",
201
- "x-forwarded-proto",
202
- "x-real-ip"
203
- ];
204
- function resolveRequestLike(request) {
205
- if (!request) {
206
- return void 0;
207
- }
208
- if (request instanceof Request) {
209
- return {
210
- url: request.url,
211
- headers: request.headers
212
- };
213
- }
214
- return {
215
- url: request.url,
216
- headers: request.headers ? new Headers(request.headers) : void 0
217
- };
218
- }
219
- __name(resolveRequestLike, "resolveRequestLike");
220
- function resolveServerBaseURL(explicitBaseURL, request) {
221
- if (explicitBaseURL) {
222
- return explicitBaseURL;
223
- }
224
- if (request?.url) {
225
- try {
226
- return new URL(request.url).origin;
227
- } catch {
228
- }
229
- }
230
- const headers = request?.headers;
231
- const host = headers?.get("x-forwarded-host") || headers?.get("host");
232
- if (host) {
233
- const proto = headers?.get("x-forwarded-proto") || "http";
234
- return `${proto}://${host}`;
235
- }
236
- return "http://localhost:3000";
237
- }
238
- __name(resolveServerBaseURL, "resolveServerBaseURL");
239
- function resolveForwardHeaders(request, forwardHeaders) {
240
- if (!request?.headers || forwardHeaders === false) {
241
- return new Headers();
242
- }
243
- const allowed = Array.isArray(forwardHeaders) && forwardHeaders.length > 0 ? new Set(forwardHeaders.map((item) => item.toLowerCase())) : new Set(DEFAULT_FORWARDED_HEADERS);
244
- const headers = new Headers();
245
- request.headers.forEach((value, key) => {
246
- if (allowed.has(key.toLowerCase())) {
247
- headers.set(key, value);
248
- }
249
- });
250
- return headers;
251
- }
252
- __name(resolveForwardHeaders, "resolveForwardHeaders");
253
- function createBody(format, body, headers) {
254
- if (body == null || format === "none") {
255
- return void 0;
256
- }
257
- if (format === "form") {
258
- if (body instanceof FormData || body instanceof URLSearchParams) {
259
- return body;
260
- }
261
- const form = new URLSearchParams();
262
- for (const [key, value] of Object.entries(body)) {
263
- if (value == null) {
264
- continue;
265
- }
266
- if (Array.isArray(value)) {
267
- for (const item of value) {
268
- if (item != null) {
269
- form.append(key, String(item));
270
- }
271
- }
272
- continue;
273
- }
274
- form.set(key, String(value));
275
- }
276
- headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
277
- return form;
278
- }
279
- headers.set("content-type", "application/json");
280
- return JSON.stringify(body);
281
- }
282
- __name(createBody, "createBody");
283
- async function parseResponseData(response) {
284
- if (response.status === 204 || response.status === 205) {
285
- return void 0;
286
- }
287
- const contentType = response.headers.get("content-type") || "";
288
- if (contentType.includes("application/json")) {
289
- return await response.json();
290
- }
291
- return await response.text();
292
- }
293
- __name(parseResponseData, "parseResponseData");
294
- async function safeParseResponseData(response) {
295
- try {
296
- return await parseResponseData(response);
297
- } catch {
298
- return void 0;
299
- }
300
- }
301
- __name(safeParseResponseData, "safeParseResponseData");
302
- function createResponseError(response, errorData) {
303
- const message = typeof errorData === "string" ? errorData : typeof errorData === "object" && errorData ? String(
304
- errorData.error || errorData.message || response.statusText
305
- ) : response.statusText || "Integration request failed.";
306
- return new IntegrationClientError(message, response, errorData);
307
- }
308
- __name(createResponseError, "createResponseError");
309
- function normalizeExecutionError(error) {
310
- if (error instanceof Error) {
311
- return error;
312
- }
313
- if (typeof error === "string" && error.length > 0) {
314
- return new Error(error);
315
- }
316
- return new Error("Integration request failed.");
317
- }
318
- __name(normalizeExecutionError, "normalizeExecutionError");
319
- async function finalizeOperationResponse(operation, response) {
320
- if (!response.ok) {
321
- const errorData = await safeParseResponseData(response);
322
- return {
323
- data: null,
324
- error: createResponseError(response, errorData)
325
- };
326
- }
327
- if (operation.responseFormat === "response") {
328
- return {
329
- data: response,
330
- error: null
331
- };
332
- }
333
- return {
334
- data: await parseResponseData(response),
335
- error: null
336
- };
337
- }
338
- __name(finalizeOperationResponse, "finalizeOperationResponse");
339
- async function executeClientOperation(operation, input, options, requestOptions) {
340
- try {
341
- if (!operation.path) {
342
- return {
343
- data: null,
344
- error: new Error(
345
- "Integration API operation path is missing. Pass a path to api.get/post/... or wrap pathless methods with api.route(path, { ... })."
346
- )
347
- };
348
- }
349
- const baseURL = options.baseURL || (typeof window !== "undefined" ? window.location.origin : "http://localhost:3000");
350
- const url = new URL(operation.path, baseURL);
351
- appendQuery(url, input.query);
352
- const headers = new Headers({
353
- "x-farm-integration-client": "1",
354
- ...options.headers,
355
- ...operation.headers,
356
- ...requestOptions?.headers
357
- });
358
- if (operation.responseFormat !== "response") {
359
- headers.set("accept", "application/json");
360
- }
361
- appendIntegrationClientDataHeader(
362
- headers,
363
- mergeIntegrationClientData(options.data, requestOptions?.data)
364
- );
365
- const response = await fetch(url.toString(), {
366
- method: operation.method,
367
- headers,
368
- body: createBody(operation.bodyFormat, input.body, headers),
369
- credentials: requestOptions?.credentials ?? operation.credentials ?? options.credentials ?? "include",
370
- signal: requestOptions?.signal
371
- });
372
- if (!response.ok) {
373
- const errorData = await safeParseResponseData(response);
374
- return {
375
- data: null,
376
- error: createResponseError(response, errorData)
377
- };
378
- }
379
- if (operation.responseFormat === "response") {
380
- return {
381
- data: response,
382
- error: null
383
- };
384
- }
385
- return {
386
- data: await parseResponseData(response),
387
- error: null
388
- };
389
- } catch (error) {
390
- return {
391
- data: null,
392
- error: normalizeExecutionError(error)
393
- };
394
- }
395
- }
396
- __name(executeClientOperation, "executeClientOperation");
397
- async function executeServerOperation(operation, input, options, requestOptions, integrationKey, source) {
398
- try {
399
- if (!operation.path) {
400
- return {
401
- data: null,
402
- error: new Error(
403
- "Integration API operation path is missing. Pass a path to api.get/post/... or wrap pathless methods with api.route(path, { ... })."
404
- )
405
- };
406
- }
407
- const serverRequestOptions = requestOptions && ("request" in requestOptions || "baseURL" in requestOptions || "forwardHeaders" in requestOptions) ? requestOptions : void 0;
408
- const currentRequest = serverRequestOptions?.request instanceof Request ? serverRequestOptions.request : options.request instanceof Request ? options.request : resolveCurrentRequestLocal();
409
- const request = resolveRequestLike(
410
- serverRequestOptions?.request ?? options.request ?? currentRequest
411
- );
412
- const baseURL = resolveServerBaseURL(serverRequestOptions?.baseURL ?? options.baseURL, request);
413
- const url = new URL(operation.path, baseURL);
414
- appendQuery(url, input.query);
415
- const headers = new Headers();
416
- appendHeaders(
417
- headers,
418
- resolveForwardHeaders(
419
- request,
420
- serverRequestOptions?.forwardHeaders ?? options.forwardHeaders
421
- )
422
- );
423
- appendHeaders(headers, options.headers);
424
- appendHeaders(headers, operation.headers);
425
- appendHeaders(headers, requestOptions?.headers);
426
- headers.set("x-farm-integration-client", "1");
427
- if (operation.responseFormat !== "response") {
428
- headers.set("accept", "application/json");
429
- }
430
- const data = mergeIntegrationClientData(options.data, requestOptions?.data);
431
- if (integrationKey) {
432
- const runtime = "kind" in (source || {}) && source.kind === "farm-integration" ? getRegisteredIntegrationRuntimeLocal(integrationKey) || {
433
- integration: source,
434
- config: {},
435
- isDev: process.env.NODE_ENV !== "production",
436
- isProd: process.env.NODE_ENV === "production"
437
- } : getRegisteredIntegrationRuntimeLocal(integrationKey);
438
- if (runtime) {
439
- const dispatchIntegrationRequest = resolveIntegrationRequestDispatcherLocal();
440
- const directResponse = dispatchIntegrationRequest ? await dispatchIntegrationRequest(
441
- runtime,
442
- new Request(url.toString(), {
443
- method: operation.method,
444
- headers,
445
- body: createBody(operation.bodyFormat, input.body, headers)
446
- }),
447
- {
448
- currentRequest,
449
- data,
450
- internal: true
451
- }
452
- ) : null;
453
- if (directResponse) {
454
- return await finalizeOperationResponse(operation, directResponse);
455
- }
456
- }
457
- }
458
- appendIntegrationClientDataHeader(headers, data);
459
- const response = await fetch(url.toString(), {
460
- method: operation.method,
461
- headers,
462
- body: createBody(operation.bodyFormat, input.body, headers),
463
- credentials: requestOptions?.credentials ?? operation.credentials ?? options.credentials ?? "include",
464
- signal: requestOptions?.signal
465
- });
466
- return await finalizeOperationResponse(operation, response);
467
- } catch (error) {
468
- return {
469
- data: null,
470
- error: normalizeExecutionError(error)
471
- };
472
- }
473
- }
474
- __name(executeServerOperation, "executeServerOperation");
475
- function createIntegrationClient(sources, options = {}) {
476
- const rawSources = "integrations" in sources ? sources.integrations : sources;
477
- const isServer = options.isServer === true;
478
- const namespaces = Object.entries(rawSources).map(([key, source]) => {
479
- const api = tryResolveSourceAPI(source);
480
- if (!api) {
481
- return null;
482
- }
483
- return [key, api, source];
484
- }).filter(
485
- (value) => value !== null
486
- );
487
- const cache = /* @__PURE__ */ new Map();
488
- const integrationNamespaces = new Proxy(
489
- {},
490
- {
491
- get(target, property) {
492
- if (typeof property !== "string") {
493
- return void 0;
494
- }
495
- if (Reflect.has(target, property)) {
496
- return Reflect.get(target, property);
497
- }
498
- if (cache.has(property)) {
499
- return cache.get(property);
500
- }
501
- const match = namespaces.find(([key]) => key === property);
502
- if (!match) {
503
- return void 0;
504
- }
505
- const namespace = isServer ? createServerNamespaceProxy(
506
- match[0],
507
- match[2],
508
- match[1],
509
- options
510
- ) : createNamespaceProxy(match[1], options);
511
- cache.set(property, namespace);
512
- return namespace;
513
- }
514
- }
515
- );
516
- if ("integrations" in sources) {
517
- Object.defineProperty(integrationNamespaces, "integrations", {
518
- value: integrationNamespaces,
519
- enumerable: false,
520
- configurable: false,
521
- writable: false
522
- });
523
- return integrationNamespaces;
524
- }
525
- return integrationNamespaces;
526
- }
527
- __name(createIntegrationClient, "createIntegrationClient");
528
- function createAutomaticIntegrationAliases(isServer, options = {}) {
529
- const cache = isServer ? /* @__PURE__ */ new Map() : null;
530
- const integrationNamespaces = new Proxy(
531
- {},
532
- {
533
- get(_target, property) {
534
- if (typeof property !== "string") {
535
- return void 0;
536
- }
537
- if (property === "integrations") {
538
- return integrationNamespaces;
539
- }
540
- if (cache?.has(property)) {
541
- return cache.get(property);
542
- }
543
- const namespaces = isServer ? resolveAutomaticServerNamespaces() : resolveAutomaticClientNamespaces();
544
- const match = namespaces.find(([key]) => key === property);
545
- if (!match) {
546
- return void 0;
547
- }
548
- const namespace = isServer ? createServerNamespaceProxy(
549
- match[0],
550
- match[2],
551
- match[1],
552
- options
553
- ) : createNamespaceProxy(match[1], options);
554
- cache?.set(property, namespace);
555
- return namespace;
556
- }
557
- }
558
- );
559
- Object.defineProperty(integrationNamespaces, "integrations", {
560
- value: integrationNamespaces,
561
- enumerable: false,
562
- configurable: false,
563
- writable: false
564
- });
565
- return integrationNamespaces;
566
- }
567
- __name(createAutomaticIntegrationAliases, "createAutomaticIntegrationAliases");
568
- function integrationsClient(options = {}) {
569
- return createAutomaticIntegrationAliases(
570
- false,
571
- options
572
- );
573
- }
574
- __name(integrationsClient, "integrationsClient");
575
- function integrationsServer(options = {}) {
576
- return createAutomaticIntegrationAliases(true, {
577
- ...options,
578
- isServer: true
579
- });
580
- }
581
- __name(integrationsServer, "integrationsServer");
582
- function createIntegrationServerClient(sources, options = {}) {
583
- return createIntegrationClient(sources, {
584
- ...options,
585
- isServer: true
586
- });
587
- }
588
- __name(createIntegrationServerClient, "createIntegrationServerClient");
589
- function createIntegrationApi(sources, options = {}) {
590
- const client = createIntegrationClient(sources, options);
591
- return {
592
- ...client,
593
- server(serverOptions = {}) {
594
- return createIntegrationServerClient(sources, {
595
- ...options,
596
- ...serverOptions
597
- });
598
- }
599
- };
600
- }
601
- __name(createIntegrationApi, "createIntegrationApi");
602
- function isIntegrationClientOptionsInput(value) {
603
- return !!value && typeof value === "object" && !Array.isArray(value) && ("baseURL" in value || "headers" in value || "credentials" in value || "data" in value || "isServer" in value);
604
- }
605
- __name(isIntegrationClientOptionsInput, "isIntegrationClientOptionsInput");
606
- function resolveIntegrationServerOptions(clientOptions = {}, serverOptions = {}) {
607
- const data = mergeIntegrationClientData(clientOptions.data, serverOptions.data);
608
- return {
609
- baseURL: clientOptions.baseURL,
610
- headers: clientOptions.headers,
611
- credentials: clientOptions.credentials,
612
- ...serverOptions,
613
- ...data ? { data } : {}
614
- };
615
- }
616
- __name(resolveIntegrationServerOptions, "resolveIntegrationServerOptions");
617
- function createIntegrationClients(sources, clientOptions, serverOptions) {
618
- if (arguments.length === 0 || isIntegrationClientOptionsInput(sources)) {
619
- const automaticClientOptions = isIntegrationClientOptionsInput(sources) ? sources : {};
620
- const automaticServerOptions = arguments.length > 1 ? clientOptions : void 0;
621
- return {
622
- api: integrationsServer(
623
- resolveIntegrationServerOptions(
624
- automaticClientOptions,
625
- automaticServerOptions
626
- )
627
- ),
628
- apiClient: integrationsClient(automaticClientOptions)
629
- };
630
- }
631
- const explicitSources = sources && "integrations" in sources ? sources.integrations : sources;
632
- return {
633
- api: createIntegrationServerClient(
634
- {
635
- integrations: explicitSources
636
- },
637
- resolveIntegrationServerOptions(clientOptions, serverOptions)
638
- ),
639
- apiClient: createIntegrationClient(
640
- {
641
- integrations: explicitSources
642
- },
643
- clientOptions
644
- )
645
- };
646
- }
647
- __name(createIntegrationClients, "createIntegrationClients");
648
- function createIntegrations(sources, clientOptions, serverOptions) {
649
- if (arguments.length === 0) {
650
- return createIntegrationClients();
651
- }
652
- return createIntegrationClients(
653
- sources,
654
- clientOptions,
655
- serverOptions
656
- );
657
- }
658
- __name(createIntegrations, "createIntegrations");
659
- function createClientSafeIntegrationAPI(api) {
660
- if (!api) {
661
- return void 0;
662
- }
663
- const entries = Object.entries(api).map(([key, value]) => {
664
- if (isOperation(value)) {
665
- return [
666
- key,
667
- {
668
- kind: value.kind,
669
- path: value.path,
670
- method: value.method,
671
- bodyFormat: value.bodyFormat,
672
- responseFormat: value.responseFormat,
673
- credentials: value.credentials,
674
- isServer: value.isServer,
675
- __pathless: value.__pathless
676
- }
677
- ];
678
- }
679
- if (value && typeof value === "object") {
680
- return [key, createClientSafeIntegrationAPI(value)];
681
- }
682
- return [key, value];
683
- });
684
- return Object.fromEntries(entries);
685
- }
686
- __name(createClientSafeIntegrationAPI, "createClientSafeIntegrationAPI");
687
- function getIntegrationAPIManifest() {
688
- const manifestEntries = Object.entries(getRegisteredIntegrationsLocal()).map(([key, integration]) => {
689
- const api = createClientSafeIntegrationAPI(integration.api);
690
- return api ? [key, api] : null;
691
- }).filter((value) => value !== null);
692
- return Object.fromEntries(manifestEntries);
693
- }
694
- __name(getIntegrationAPIManifest, "getIntegrationAPIManifest");
695
- function integrationClients(sources, clientOptions, serverOptions) {
696
- if (arguments.length === 0) {
697
- return createIntegrationClients();
698
- }
699
- return createIntegrationClients(
700
- sources,
701
- clientOptions,
702
- serverOptions
703
- );
704
- }
705
- __name(integrationClients, "integrationClients");
706
- function resolveSingleNamespaceOperation(api) {
707
- const entries = Object.entries(api);
708
- if (entries.length !== 1) {
709
- return null;
710
- }
711
- const [, value] = entries[0];
712
- return isOperation(value) ? value : null;
713
- }
714
- __name(resolveSingleNamespaceOperation, "resolveSingleNamespaceOperation");
715
- function createClientOperationCaller(operation, property, options) {
716
- if (operation.isServer === true) {
717
- return async () => {
718
- throw new Error(
719
- `Integration method "${property}" is registered with isServer: true and is only available from a server integration client.`
720
- );
721
- };
722
- }
723
- return async (input = {}, requestOptions) => {
724
- if (typeof window === "undefined") {
725
- throw new Error(
726
- "Client integration API cannot be called on the server. Pass { isServer: true } to createIntegrationClient(...) during server rendering, or provide { isServer: true, request } outside it."
727
- );
728
- }
729
- return executeClientOperation(operation, input, options, requestOptions);
730
- };
731
- }
732
- __name(createClientOperationCaller, "createClientOperationCaller");
733
- function createServerOperationCaller(operation, options, integrationKey, source) {
734
- return async (input = {}, requestOptions) => {
735
- if (typeof window !== "undefined") {
736
- throw new Error(
737
- "Server integration API cannot be called in the browser. Remove { isServer: true } and create a client integration API instead."
738
- );
739
- }
740
- return executeServerOperation(
741
- operation,
742
- input,
743
- options,
744
- requestOptions,
745
- integrationKey,
746
- source
747
- );
748
- };
749
- }
750
- __name(createServerOperationCaller, "createServerOperationCaller");
751
- function createNamespaceProxy(api, options) {
752
- const cache = /* @__PURE__ */ new Map();
753
- const directOperation = resolveSingleNamespaceOperation(api);
754
- const target = directOperation ? createClientOperationCaller(directOperation, directOperation.method.toLowerCase(), options) : {};
755
- return new Proxy(target, {
756
- get(targetObject, property, receiver) {
757
- if (typeof property !== "string") {
758
- return Reflect.get(targetObject, property, receiver);
759
- }
760
- if (cache.has(property)) {
761
- return cache.get(property);
762
- }
763
- const value = api[property];
764
- if (!value) {
765
- return Reflect.get(targetObject, property, receiver);
766
- }
767
- if (isOperation(value)) {
768
- const caller = createClientOperationCaller(value, property, options);
769
- cache.set(property, caller);
770
- return caller;
771
- }
772
- const namespace = createNamespaceProxy(value, options);
773
- cache.set(property, namespace);
774
- return namespace;
775
- }
776
- });
777
- }
778
- __name(createNamespaceProxy, "createNamespaceProxy");
779
- function createServerNamespaceProxy(integrationKey, source, api, options) {
780
- const cache = /* @__PURE__ */ new Map();
781
- const directOperation = resolveSingleNamespaceOperation(api);
782
- const target = directOperation ? createServerOperationCaller(directOperation, options, integrationKey, source) : {};
783
- return new Proxy(target, {
784
- get(targetObject, property, receiver) {
785
- if (typeof property !== "string") {
786
- return Reflect.get(targetObject, property, receiver);
787
- }
788
- if (cache.has(property)) {
789
- return cache.get(property);
790
- }
791
- const value = api[property];
792
- if (!value) {
793
- return Reflect.get(targetObject, property, receiver);
794
- }
795
- if (isOperation(value)) {
796
- const caller = createServerOperationCaller(value, options, integrationKey, source);
797
- cache.set(property, caller);
798
- return caller;
799
- }
800
- const namespace = createServerNamespaceProxy(
801
- integrationKey,
802
- source,
803
- value,
804
- options
805
- );
806
- cache.set(property, namespace);
807
- return namespace;
808
- }
809
- });
810
- }
811
- __name(createServerNamespaceProxy, "createServerNamespaceProxy");
812
-
813
- // src/api/client.ts
814
- var FARM_API_ROUTE_REF_SYMBOL = /* @__PURE__ */ Symbol.for("farm.api.route-ref");
815
- var FARM_API_ROUTE_META_SYMBOL = /* @__PURE__ */ Symbol.for("farm.api.route-meta");
816
- var _APIClientError = class _APIClientError extends Error {
817
- constructor(code, data, options) {
818
- super(options.message);
819
- this.name = "APIClientError";
820
- this.code = code;
821
- this.data = data;
822
- this.status = options.status;
823
- this.response = options.response;
824
- }
825
- };
826
- __name(_APIClientError, "APIClientError");
827
- var APIClientError = _APIClientError;
828
- function createAPIClient(options = {}) {
829
- options ?? (options = {});
830
- const baseURL = options.baseURL || (typeof window !== "undefined" ? window.location.origin : "http://localhost:3000");
831
- const integrationOptions = options.integrations === false ? false : {
832
- baseURL: options.baseURL,
833
- headers: options.headers,
834
- credentials: options.credentials,
835
- ...typeof options.integrations === "object" ? options.integrations : {}
836
- };
837
- const rootAliases = integrationOptions === false ? void 0 : {
838
- integrations: integrationsClient(integrationOptions)
839
- };
840
- const cacheState = getFarmClientDataCache();
841
- const inflightState = /* @__PURE__ */ new Map();
842
- const routeMeta = /* @__PURE__ */ new WeakMap();
843
- let requestCounter = 0;
844
- const fetchClient = /* @__PURE__ */ __name(async (path, requestOptions = {}) => {
845
- const url = new URL(path, baseURL);
846
- if (requestOptions.query) {
847
- Object.entries(requestOptions.query).forEach(([key, value]) => {
848
- if (value !== void 0 && value !== null) {
849
- url.searchParams.set(key, String(value));
850
- }
851
- });
852
- }
853
- const headers = {
854
- "Content-Type": "application/json",
855
- ...options.headers,
856
- ...requestOptions.headers
857
- };
858
- const fetchOptions = {
859
- method: requestOptions.method || "GET",
860
- headers
861
- };
862
- if (requestOptions.body !== void 0) {
863
- if (isFormData(requestOptions.body)) {
864
- deleteHeader(headers, "content-type");
865
- fetchOptions.body = requestOptions.body;
866
- } else {
867
- fetchOptions.body = JSON.stringify(requestOptions.body);
868
- }
869
- }
870
- const response = await fetch(url.toString(), fetchOptions);
871
- applyFarmCacheInvalidations(
872
- decodeFarmCacheInvalidations(response.headers?.get?.(FARM_CACHE_INVALIDATION_HEADER))
873
- );
874
- let data = void 0;
875
- if (response.status !== 204 && response.status !== 205) {
876
- data = isJSONStreamResponse(response) ? readJSONStream(response) : await response.json();
877
- }
878
- return { response, data };
879
- }, "fetchClient");
880
- const request = /* @__PURE__ */ __name(async (path, method, input = {}, clientOptions) => {
881
- const methodUpper = method.toUpperCase();
882
- const requestId = `${Date.now()}-${++requestCounter}`;
883
- const cacheOptions = clientOptions?.cache ? {
884
- ...options.cacheDefaults,
885
- ...clientOptions.cache
886
- } : void 0;
887
- const configuredCacheKey = clientOptions?.key ?? cacheOptions?.key;
888
- const cacheKey = normalizeFarmClientCacheKey(
889
- configuredCacheKey ?? buildCacheKey(methodUpper, path, input, baseURL)
890
- );
891
- const now = Date.now();
892
- const emitStatus = /* @__PURE__ */ __name((phase, payload) => {
893
- clientOptions?.onStatus?.({
894
- phase,
895
- requestId,
896
- method: methodUpper,
897
- key: cacheKey,
898
- input,
899
- timestamp: Date.now(),
900
- ...payload
901
- });
902
- }, "emitStatus");
903
- const entry = getValidCacheEntry(cacheState, cacheKey, now);
904
- const policy = cacheOptions?.policy ?? (cacheOptions ? "cache-first" : "network-only");
905
- const staleTime = cacheOptions?.staleTime ?? 0;
906
- const isCacheEnabled = Boolean(cacheOptions) && methodUpper === "GET";
907
- const isStale = entry ? isEntryStale(entry, now) : true;
908
- const applyOptimisticUpdates = /* @__PURE__ */ __name(() => {
909
- if (!clientOptions?.optimistic?.update?.length) return [];
910
- const snapshots = [];
911
- for (const update of clientOptions.optimistic.update) {
912
- const [target, targetInput, updater] = update.length === 2 ? [update[0], void 0, update[1]] : [update[0], update[1], update[2]];
913
- const targetKey = resolveTargetKey(routeMeta, target, targetInput, baseURL);
914
- if (!targetKey) continue;
915
- const targetEntry = getValidCacheEntry(cacheState, targetKey, now);
916
- const previousEntry = targetEntry ? { ...targetEntry } : void 0;
917
- const previousData = targetEntry?.data;
918
- const nextData = updater(previousData);
919
- cacheState.set(targetKey, {
920
- data: nextData,
921
- updatedAt: now,
922
- staleAt: targetEntry?.staleAt ?? now + (cacheOptions?.staleTime ?? options.cacheDefaults?.staleTime ?? 0),
923
- gcAt: targetEntry?.gcAt ?? getGcAt(now, cacheOptions?.gcTime ?? options.cacheDefaults?.gcTime),
924
- invalidatedAt: targetEntry?.invalidatedAt
925
- });
926
- snapshots.push({ key: targetKey, entry: previousEntry });
927
- }
928
- return snapshots;
929
- }, "applyOptimisticUpdates");
930
- const rollbackOptimisticUpdates = /* @__PURE__ */ __name((snapshots) => {
931
- if (!clientOptions?.optimistic?.rollbackOnError) return;
932
- for (const snapshot of snapshots) {
933
- if (!snapshot.entry) {
934
- cacheState.delete(snapshot.key);
935
- continue;
936
- }
937
- cacheState.set(snapshot.key, { ...snapshot.entry });
938
- }
939
- }, "rollbackOptimisticUpdates");
940
- const executeNetwork = /* @__PURE__ */ __name(async (opts) => {
941
- const dedupeMs = cacheOptions?.dedupeMs ?? 0;
942
- const inflight = inflightState.get(cacheKey);
943
- const allowDedupe = isCacheEnabled && dedupeMs > 0;
944
- if (allowDedupe && inflight && now - inflight.startedAt < dedupeMs) {
945
- emitStatus("pending", { isBackground: opts?.isBackground, data: entry?.data });
946
- const result2 = await inflight.promise;
947
- if (result2.error) {
948
- emitStatus("error", { error: result2.error, isBackground: opts?.isBackground });
949
- if (opts?.callCallbacks !== false) {
950
- clientOptions?.onError?.(result2.error);
951
- }
952
- } else {
953
- emitStatus("success", { data: result2.data, isBackground: opts?.isBackground });
954
- if (opts?.callCallbacks !== false) {
955
- clientOptions?.onSuccess?.(result2.data);
956
- }
957
- }
958
- return result2;
959
- }
960
- emitStatus(opts?.isBackground ? "revalidating" : "pending", {
961
- isBackground: opts?.isBackground
962
- });
963
- const promise = (async () => {
964
- const maxRetries = Math.max(0, clientOptions?.retry?.count ?? 0);
965
- let attempt = 0;
966
- while (true) {
967
- clientOptions?.onRequest?.({
968
- requestId,
969
- method: methodUpper,
970
- key: cacheKey,
971
- path,
972
- input,
973
- attempt,
974
- timestamp: Date.now()
975
- });
976
- try {
977
- const { response, data } = await fetchClient(path, {
978
- ...input,
979
- method: methodUpper
980
- });
981
- const error = response.ok ? null : createResponseError2(response, data);
982
- const responseEvent = {
983
- requestId,
984
- method: methodUpper,
985
- key: cacheKey,
986
- path,
987
- input,
988
- attempt,
989
- timestamp: Date.now(),
990
- response,
991
- data: response.ok ? data : void 0,
992
- error: error ?? void 0,
993
- ok: response.ok,
994
- status: response.status
995
- };
996
- clientOptions?.onResponse?.(response.ok ? data : void 0, error, responseEvent);
997
- if (!error) {
998
- return { data, error: null, key: cacheKey };
999
- }
1000
- if (attempt >= maxRetries) {
1001
- return { data: void 0, error, key: cacheKey };
1002
- }
1003
- } catch (err) {
1004
- const error = normalizeError(err);
1005
- const responseEvent = {
1006
- requestId,
1007
- method: methodUpper,
1008
- key: cacheKey,
1009
- path,
1010
- input,
1011
- attempt,
1012
- timestamp: Date.now(),
1013
- error,
1014
- ok: false
1015
- };
1016
- clientOptions?.onResponse?.(void 0, error, responseEvent);
1017
- if (attempt >= maxRetries) {
1018
- return { data: void 0, error, key: cacheKey };
1019
- }
1020
- }
1021
- attempt += 1;
1022
- const delay = typeof clientOptions?.retry?.delay === "function" ? clientOptions.retry.delay(attempt) : clientOptions?.retry?.delay ?? 0;
1023
- if (delay > 0) {
1024
- await new Promise((resolve) => setTimeout(resolve, delay));
1025
- }
1026
- }
1027
- })();
1028
- inflightState.set(cacheKey, { promise, startedAt: now });
1029
- try {
1030
- const result2 = await promise;
1031
- if (!result2.error && isCacheEnabled && !isFarmAPIStream(result2.data)) {
1032
- const updatedAt = Date.now();
1033
- cacheState.set(cacheKey, {
1034
- data: result2.data,
1035
- updatedAt,
1036
- staleAt: updatedAt + staleTime,
1037
- gcAt: getGcAt(updatedAt, cacheOptions?.gcTime),
1038
- invalidatedAt: void 0
1039
- });
1040
- }
1041
- if (result2.error) {
1042
- emitStatus("error", { error: result2.error, isBackground: opts?.isBackground });
1043
- if (opts?.callCallbacks !== false) {
1044
- clientOptions?.onError?.(result2.error);
1045
- }
1046
- } else {
1047
- emitStatus("success", { data: result2.data, isBackground: opts?.isBackground });
1048
- if (opts?.callCallbacks !== false) {
1049
- clientOptions?.onSuccess?.(result2.data);
1050
- }
1051
- }
1052
- return result2;
1053
- } finally {
1054
- inflightState.delete(cacheKey);
1055
- }
1056
- }, "executeNetwork");
1057
- const invalidateTargets = /* @__PURE__ */ __name(async () => {
1058
- if (!clientOptions?.invalidate) return;
1059
- const invalidateOptions = Array.isArray(clientOptions.invalidate) ? { targets: clientOptions.invalidate, refetch: false } : {
1060
- targets: clientOptions.invalidate.targets,
1061
- refetch: clientOptions.invalidate.refetch ?? false
1062
- };
1063
- for (const target of invalidateOptions.targets) {
1064
- const targetKey = resolveTargetKey(routeMeta, target, void 0, baseURL);
1065
- if (!targetKey) continue;
1066
- const existing = cacheState.get(targetKey);
1067
- if (existing) {
1068
- cacheState.set(targetKey, {
1069
- ...existing,
1070
- staleAt: 0,
1071
- invalidatedAt: Date.now()
1072
- });
1073
- }
1074
- emitStatus("invalidated", { key: targetKey });
1075
- if (invalidateOptions.refetch && existing && targetKey === cacheKey) {
1076
- void executeNetwork({ isBackground: true, callCallbacks: false });
1077
- }
1078
- }
1079
- }, "invalidateTargets");
1080
- const optimisticSnapshots = applyOptimisticUpdates();
1081
- if (isCacheEnabled) {
1082
- if (entry && !isStale && policy !== "network-only") {
1083
- emitStatus("success", { data: entry.data });
1084
- clientOptions?.onSuccess?.(entry.data);
1085
- clientOptions?.onSettled?.(entry.data, null);
1086
- return { data: entry.data, error: null, key: cacheKey };
1087
- }
1088
- if (entry && isStale && policy === "stale-while-revalidate") {
1089
- emitStatus("success", { data: entry.data });
1090
- clientOptions?.onSuccess?.(entry.data);
1091
- clientOptions?.onSettled?.(entry.data, null);
1092
- void executeNetwork({ isBackground: true, callCallbacks: false });
1093
- return { data: entry.data, error: null, key: cacheKey };
1094
- }
1095
- }
1096
- const result = await executeNetwork();
1097
- if (result.error) {
1098
- rollbackOptimisticUpdates(optimisticSnapshots);
1099
- }
1100
- await invalidateTargets();
1101
- clientOptions?.onSettled?.(result.data, result.error);
1102
- return result;
1103
- }, "request");
1104
- return createNestedProxy(
1105
- [],
1106
- request,
1107
- routeMeta,
1108
- baseURL,
1109
- options.baseURL === void 0,
1110
- rootAliases
1111
- );
1112
- }
1113
- __name(createAPIClient, "createAPIClient");
1114
- function createNestedProxy(path, client, routeMeta, baseURL, sameOrigin, rootAliases) {
1115
- const target = /* @__PURE__ */ __name(() => {
1116
- }, "target");
1117
- const proxy = new Proxy(target, {
1118
- // When accessing a property (api.hello)
1119
- get(_target, prop) {
1120
- if (prop === FARM_API_ROUTE_REF_SYMBOL) {
1121
- return path.length > 0;
1122
- }
1123
- if (prop === FARM_API_ROUTE_META_SYMBOL) {
1124
- const metadata = resolveRouteMeta({ path, baseURL });
1125
- return Object.freeze({
1126
- path: metadata.routePath,
1127
- method: metadata.method,
1128
- baseURL,
1129
- sameOrigin
1130
- });
1131
- }
1132
- if (path.length === 0 && typeof prop === "string" && rootAliases && prop in rootAliases) {
1133
- return rootAliases[prop];
1134
- }
1135
- if (typeof prop !== "string") {
1136
- return Reflect.get(_target, prop);
1137
- }
1138
- return createNestedProxy(
1139
- [...path, prop],
1140
- client,
1141
- routeMeta,
1142
- baseURL,
1143
- sameOrigin,
1144
- rootAliases
1145
- );
1146
- },
1147
- // When calling as a function
1148
- apply(_target, _thisArg, args) {
1149
- const lastPart = path[path.length - 1];
1150
- const httpMethods = ["get", "post", "put", "delete", "patch", "options", "head"];
1151
- if (httpMethods.includes(lastPart)) {
1152
- const routePath = "/api/" + path.slice(0, -1).join("/");
1153
- const method = lastPart.toUpperCase();
1154
- const [options, clientOptions] = args;
1155
- return client(routePath, method, options, clientOptions);
1156
- } else {
1157
- const routePath = "/api/" + path.join("/");
1158
- const [options, clientOptions] = args;
1159
- return client(routePath, options?.method || "GET", options, clientOptions);
1160
- }
1161
- }
1162
- });
1163
- routeMeta.set(proxy, { path: [...path], baseURL });
1164
- return proxy;
1165
- }
1166
- __name(createNestedProxy, "createNestedProxy");
1167
- function isAPIRouteRef(value) {
1168
- return typeof value === "function" && value[FARM_API_ROUTE_REF_SYMBOL] === true;
1169
- }
1170
- __name(isAPIRouteRef, "isAPIRouteRef");
1171
- function getAPIRouteRefMetadata(value) {
1172
- if (!isAPIRouteRef(value)) return null;
1173
- const metadata = value[FARM_API_ROUTE_META_SYMBOL];
1174
- if (!metadata || typeof metadata !== "object") return null;
1175
- const candidate = metadata;
1176
- if (typeof candidate.path !== "string" || typeof candidate.method !== "string" || typeof candidate.baseURL !== "string" || typeof candidate.sameOrigin !== "boolean") {
1177
- return null;
1178
- }
1179
- return {
1180
- path: candidate.path,
1181
- method: candidate.method,
1182
- baseURL: candidate.baseURL,
1183
- sameOrigin: candidate.sameOrigin
1184
- };
1185
- }
1186
- __name(getAPIRouteRefMetadata, "getAPIRouteRefMetadata");
1187
- function createServerAPIClient(endpoints, options = {}) {
1188
- if (options.integrations === false || Object.prototype.hasOwnProperty.call(endpoints, "integrations")) {
1189
- return endpoints;
1190
- }
1191
- Object.defineProperty(endpoints, "integrations", {
1192
- get() {
1193
- return integrationsServer(
1194
- typeof options.integrations === "object" ? options.integrations : {}
1195
- );
1196
- },
1197
- enumerable: false,
1198
- configurable: true
1199
- });
1200
- return endpoints;
1201
- }
1202
- __name(createServerAPIClient, "createServerAPIClient");
1203
- function buildCacheKey(method, path, input, baseURL) {
1204
- const keyInput = input && typeof input === "object" ? { query: input.query, body: input.body } : input;
1205
- const url = new URL(path, baseURL);
1206
- return `${method}:${url.origin}${url.pathname}:${stableStringify(keyInput ?? {})}`;
1207
- }
1208
- __name(buildCacheKey, "buildCacheKey");
1209
- function stableStringify(value) {
1210
- if (value === null || value === void 0) return String(value);
1211
- if (value instanceof Date) return value.toISOString();
1212
- if (typeof value !== "object") return JSON.stringify(value);
1213
- if (Array.isArray(value)) {
1214
- return `[${value.map((item) => stableStringify(item)).join(",")}]`;
1215
- }
1216
- const keys = Object.keys(value).sort();
1217
- const entries = keys.map((key) => `${JSON.stringify(key)}:${stableStringify(value[key])}`);
1218
- return `{${entries.join(",")}}`;
1219
- }
1220
- __name(stableStringify, "stableStringify");
1221
- function getGcAt(now, gcTime) {
1222
- if (gcTime === void 0) return void 0;
1223
- if (!Number.isFinite(gcTime) || gcTime <= 0) return now;
1224
- return now + gcTime;
1225
- }
1226
- __name(getGcAt, "getGcAt");
1227
- function getValidCacheEntry(cacheState, key, now) {
1228
- const entry = cacheState.get(key);
1229
- if (!entry) return void 0;
1230
- if (entry.gcAt !== void 0 && now >= entry.gcAt) {
1231
- cacheState.delete(key);
1232
- return void 0;
1233
- }
1234
- return entry;
1235
- }
1236
- __name(getValidCacheEntry, "getValidCacheEntry");
1237
- function isEntryStale(entry, now) {
1238
- if (entry.invalidatedAt !== void 0) return true;
1239
- return now >= entry.staleAt;
1240
- }
1241
- __name(isEntryStale, "isEntryStale");
1242
- function resolveTargetKey(routeMeta, target, input, baseURL = "http://localhost:3000") {
1243
- if (!target) return null;
1244
- if (typeof target === "string") return target;
1245
- if (typeof target === "function") {
1246
- const meta = routeMeta.get(target);
1247
- if (!meta) return null;
1248
- const { method, routePath } = resolveRouteMeta(meta);
1249
- return buildCacheKey(method, routePath, input ?? {}, meta.baseURL);
1250
- }
1251
- if (Array.isArray(target)) {
1252
- const [route, routeInput] = target;
1253
- if (typeof route === "function") {
1254
- return resolveTargetKey(routeMeta, route, routeInput, baseURL);
1255
- }
1256
- return normalizeFarmClientCacheKey(target);
1257
- }
1258
- if ("key" in target) return normalizeFarmClientCacheKey(target.key);
1259
- if ("path" in target) {
1260
- const method = target.method ?? "GET";
1261
- return buildCacheKey(method, target.path, target.input ?? {}, baseURL);
1262
- }
1263
- return null;
1264
- }
1265
- __name(resolveTargetKey, "resolveTargetKey");
1266
- function resolveRouteMeta(meta) {
1267
- const httpMethods = ["get", "post", "put", "delete", "patch", "options", "head"];
1268
- const lastPart = meta.path[meta.path.length - 1];
1269
- if (lastPart && httpMethods.includes(lastPart)) {
1270
- return {
1271
- routePath: "/api/" + meta.path.slice(0, -1).join("/"),
1272
- method: lastPart.toUpperCase()
1273
- };
1274
- }
1275
- return {
1276
- routePath: "/api/" + meta.path.join("/"),
1277
- method: "GET"
1278
- };
1279
- }
1280
- __name(resolveRouteMeta, "resolveRouteMeta");
1281
- function normalizeError(error) {
1282
- if (error instanceof APIClientError) return error;
1283
- const normalized = new APIClientError("network_error", void 0, {
1284
- status: 0,
1285
- message: error instanceof Error ? error.message : typeof error === "string" ? error : "Network request failed"
1286
- });
1287
- normalized.cause = error;
1288
- return normalized;
1289
- }
1290
- __name(normalizeError, "normalizeError");
1291
- function isFormData(value) {
1292
- return typeof value === "object" && value !== null && (typeof FormData !== "undefined" && value instanceof FormData || Object.prototype.toString.call(value) === "[object FormData]" && typeof value.entries === "function");
1293
- }
1294
- __name(isFormData, "isFormData");
1295
- function deleteHeader(headers, name) {
1296
- const normalized = name.toLowerCase();
1297
- for (const key of Object.keys(headers)) {
1298
- if (key.toLowerCase() === normalized) delete headers[key];
1299
- }
1300
- }
1301
- __name(deleteHeader, "deleteHeader");
1302
- function createResponseError2(response, data) {
1303
- const expected = readEndpointErrorEnvelope(data);
1304
- if (expected) {
1305
- return new APIClientError(expected.code, expected.data, {
1306
- status: response.status,
1307
- message: expected.message,
1308
- response
1309
- });
1310
- }
1311
- return new APIClientError("http_error", data, {
1312
- status: response.status,
1313
- message: `HTTP ${response.status}: ${response.statusText}`,
1314
- response
1315
- });
1316
- }
1317
- __name(createResponseError2, "createResponseError");
1318
- function readEndpointErrorEnvelope(data) {
1319
- if (!data || typeof data !== "object") return null;
1320
- const error = data.error;
1321
- if (!error || typeof error !== "object") return null;
1322
- const code = error.code;
1323
- const message = error.message;
1324
- if (typeof code !== "string" || typeof message !== "string") return null;
1325
- return {
1326
- code,
1327
- message,
1328
- data: error.data
1329
- };
1330
- }
1331
- __name(readEndpointErrorEnvelope, "readEndpointErrorEnvelope");
1332
-
1333
- export {
1334
- IntegrationClientError,
1335
- createIntegrationClient,
1336
- integrationsClient,
1337
- integrationsServer,
1338
- createIntegrationServerClient,
1339
- createIntegrationApi,
1340
- createIntegrationClients,
1341
- createIntegrations,
1342
- getIntegrationAPIManifest,
1343
- integrationClients,
1344
- FARM_API_ROUTE_REF_SYMBOL,
1345
- FARM_API_ROUTE_META_SYMBOL,
1346
- APIClientError,
1347
- createAPIClient,
1348
- isAPIRouteRef,
1349
- getAPIRouteRefMetadata,
1350
- createServerAPIClient
1351
- };
1352
- //# sourceMappingURL=chunk-W2CRQFF6.mjs.map