@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
@@ -1,1062 +1,41 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
30
2
 
31
- // src/workflows.ts
32
- var workflows_exports = {};
33
- __export(workflows_exports, {
34
- DEFAULT_FARM_WORKFLOW_DIRS: () => DEFAULT_FARM_WORKFLOW_DIRS,
35
- DEFAULT_FARM_WORKFLOW_ROUTE: () => DEFAULT_FARM_WORKFLOW_ROUTE,
36
- DEFAULT_FARM_WORKFLOW_SECRET_ENV: () => DEFAULT_FARM_WORKFLOW_SECRET_ENV,
37
- applyFarmWorkflowVercelCrons: () => applyFarmWorkflowVercelCrons,
38
- createFarmWorkflowRequestHandler: () => createFarmWorkflowRequestHandler,
39
- createFarmWorkflowVercelCrons: () => createFarmWorkflowVercelCrons,
40
- defineCron: () => defineCron,
41
- defineTask: () => defineTask,
42
- defineWorkflow: () => defineWorkflow,
43
- discoverFarmWorkflows: () => discoverFarmWorkflows,
44
- prepareFarmWorkflowsForNitro: () => prepareFarmWorkflowsForNitro,
45
- resolveWorkflowsConfig: () => resolveWorkflowsConfig,
46
- runFarmWorkflowModule: () => runFarmWorkflowModule
47
- });
48
- module.exports = __toCommonJS(workflows_exports);
49
3
 
50
- // src/routing/specificity.ts
51
- var _BrowserUnstableRouteError = class _BrowserUnstableRouteError extends TypeError {
52
- constructor(message) {
53
- super(message);
54
- this.name = "BrowserUnstableRouteError";
55
- }
56
- };
57
- __name(_BrowserUnstableRouteError, "BrowserUnstableRouteError");
58
- var BrowserUnstableRouteError = _BrowserUnstableRouteError;
59
- function assertBrowserStableRoutePath(pattern) {
60
- if (pattern.includes("\\") || hasControlCharacter(pattern)) {
61
- throw new BrowserUnstableRouteError(
62
- `Route path "${pattern}" cannot contain backslashes or control characters.`
63
- );
64
- }
65
- for (const segment of pattern.split("/").filter(Boolean)) {
66
- if (segment.startsWith("(") && segment.endsWith(")") || segment.startsWith("[") && segment.endsWith("]")) {
67
- continue;
68
- }
69
- let decoded = segment;
70
- try {
71
- decoded = decodeURIComponent(segment);
72
- } catch {
73
- }
74
- if (decoded === "." || decoded === ".." || decoded.includes("/") || decoded.includes("\\") || hasControlCharacter(decoded)) {
75
- throw new BrowserUnstableRouteError(
76
- `Route path "${pattern}" contains browser-unstable segment "${segment}".`
77
- );
78
- }
79
- }
80
- }
81
- __name(assertBrowserStableRoutePath, "assertBrowserStableRoutePath");
82
- function hasControlCharacter(value) {
83
- return Array.from(value).some((character) => {
84
- const code = character.charCodeAt(0);
85
- return code <= 31 || code >= 127 && code <= 159;
86
- });
87
- }
88
- __name(hasControlCharacter, "hasControlCharacter");
89
4
 
90
- // src/server-http.ts
91
- var DEFAULT_FARM_SERVER_BODY_SIZE_LIMIT = 1e7;
92
- var DEFAULT_FARM_SERVER_HEADERS_TIMEOUT = 6e4;
93
- var DEFAULT_FARM_SERVER_REQUEST_TIMEOUT = 3e5;
94
- var DEFAULT_FARM_SERVER_KEEP_ALIVE_TIMEOUT = 5e3;
95
- var DEFAULT_FARM_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT = 3e4;
96
- var MAX_FARM_SERVER_TIMEOUT = 2147483647;
97
- var _FarmRequestBodyError = class _FarmRequestBodyError extends Error {
98
- constructor(code, status, message) {
99
- super(message);
100
- this.name = "FarmRequestBodyError";
101
- this.code = code;
102
- this.status = status;
103
- }
104
- };
105
- __name(_FarmRequestBodyError, "FarmRequestBodyError");
106
- var FarmRequestBodyError = _FarmRequestBodyError;
107
- function resolveFarmServerConfig(config) {
108
- const headersTimeout = parseFarmServerDuration(
109
- config?.headersTimeout ?? DEFAULT_FARM_SERVER_HEADERS_TIMEOUT,
110
- "server.headersTimeout"
111
- );
112
- const requestTimeout = parseFarmServerDuration(
113
- config?.requestTimeout ?? DEFAULT_FARM_SERVER_REQUEST_TIMEOUT,
114
- "server.requestTimeout"
115
- );
116
- if (headersTimeout > requestTimeout) {
117
- throw new TypeError("server.headersTimeout must not exceed server.requestTimeout");
118
- }
119
- return Object.freeze({
120
- bodySizeLimit: parseBodySizeLimit(
121
- config?.bodySizeLimit ?? DEFAULT_FARM_SERVER_BODY_SIZE_LIMIT,
122
- "server.bodySizeLimit"
123
- ),
124
- trustProxy: config?.trustProxy === true,
125
- headersTimeout,
126
- requestTimeout,
127
- keepAliveTimeout: parseFarmServerDuration(
128
- config?.keepAliveTimeout ?? DEFAULT_FARM_SERVER_KEEP_ALIVE_TIMEOUT,
129
- "server.keepAliveTimeout"
130
- ),
131
- gracefulShutdownTimeout: parseFarmServerDuration(
132
- config?.gracefulShutdownTimeout ?? DEFAULT_FARM_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT,
133
- "server.gracefulShutdownTimeout"
134
- ),
135
- health: resolveFarmServerHealthConfig(config?.health)
136
- });
137
- }
138
- __name(resolveFarmServerConfig, "resolveFarmServerConfig");
139
- function parseFarmServerDuration(value, optionName = "duration") {
140
- if (typeof value === "number") {
141
- if (!Number.isSafeInteger(value) || value <= 0) {
142
- throw new TypeError(`${optionName} must be a positive safe integer`);
143
- }
144
- if (value > MAX_FARM_SERVER_TIMEOUT) {
145
- throw new TypeError(`${optionName} must not exceed ${MAX_FARM_SERVER_TIMEOUT} milliseconds`);
146
- }
147
- return value;
148
- }
149
- const match = value.trim().toLowerCase().match(/^(\d+(?:\.\d+)?)\s*(ms|s|m|h)$/);
150
- if (!match) {
151
- throw new TypeError(`${optionName} must be milliseconds or a duration such as "30s" or "2m"`);
152
- }
153
- const amount = Number(match[1]);
154
- const unit = match[2];
155
- const multiplier = unit === "ms" ? 1 : unit === "s" ? 1e3 : unit === "m" ? 6e4 : 36e5;
156
- const milliseconds = Math.floor(amount * multiplier);
157
- if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0) {
158
- throw new TypeError(`${optionName} must resolve to a positive safe integer`);
159
- }
160
- if (milliseconds > MAX_FARM_SERVER_TIMEOUT) {
161
- throw new TypeError(`${optionName} must not exceed ${MAX_FARM_SERVER_TIMEOUT} milliseconds`);
162
- }
163
- return milliseconds;
164
- }
165
- __name(parseFarmServerDuration, "parseFarmServerDuration");
166
- function resolveFarmServerHealthConfig(config) {
167
- if (config === false || config && "enabled" in config && config.enabled === false) {
168
- return Object.freeze({
169
- enabled: false,
170
- livenessPath: "/_farm/health/live",
171
- readinessPath: "/_farm/health/ready"
172
- });
173
- }
174
- const livenessPath = normalizeHealthPath(
175
- config?.livenessPath ?? "/_farm/health/live",
176
- "server.health.livenessPath"
177
- );
178
- const readinessPath = normalizeHealthPath(
179
- config?.readinessPath ?? "/_farm/health/ready",
180
- "server.health.readinessPath"
181
- );
182
- if (livenessPath === readinessPath) {
183
- throw new TypeError("server.health livenessPath and readinessPath must be different");
184
- }
185
- return Object.freeze({ enabled: true, livenessPath, readinessPath });
186
- }
187
- __name(resolveFarmServerHealthConfig, "resolveFarmServerHealthConfig");
188
- function normalizeHealthPath(value, optionName) {
189
- const path = value.trim();
190
- if (!path.startsWith("/") || path.includes("?") || path.includes("#") || path.includes("*")) {
191
- throw new TypeError(`${optionName} must be an absolute pathname without a query or wildcard`);
192
- }
193
- const normalized = path.length > 1 ? path.replace(/\/+$/, "") || "/" : path;
194
- assertBrowserStableRoutePath(normalized);
195
- return normalized;
196
- }
197
- __name(normalizeHealthPath, "normalizeHealthPath");
198
- function parseBodySizeLimit(value, optionName = "bodySizeLimit") {
199
- if (typeof value === "number") {
200
- if (!Number.isSafeInteger(value) || value <= 0) {
201
- throw new TypeError(`${optionName} must be a positive safe integer`);
202
- }
203
- return value;
204
- }
205
- const match = value.trim().toLowerCase().match(/^(\d+(?:\.\d+)?)\s*(b|kb|mb|gb|kib|mib|gib)?$/);
206
- if (!match) {
207
- throw new TypeError(`${optionName} must be bytes or a size string such as "500kb" or "10mb"`);
208
- }
209
- const amount = Number(match[1]);
210
- const unit = match[2] ?? "b";
211
- const multiplier = {
212
- b: 1,
213
- kb: 1e3,
214
- mb: 1e6,
215
- gb: 1e9,
216
- kib: 1024,
217
- mib: 1048576,
218
- gib: 1073741824
219
- };
220
- const bytes = Math.floor(amount * multiplier[unit]);
221
- if (!Number.isSafeInteger(bytes) || bytes <= 0) {
222
- throw new TypeError(`${optionName} must resolve to a positive safe integer`);
223
- }
224
- return bytes;
225
- }
226
- __name(parseBodySizeLimit, "parseBodySizeLimit");
227
- async function readFarmRequestBody(request, limit) {
228
- try {
229
- validateContentLength(request.headers.get("content-length"), limit);
230
- } catch (error) {
231
- void request.body?.cancel(error).catch(() => {
232
- });
233
- throw error;
234
- }
235
- throwIfAborted(request.signal);
236
- if (!request.body) return new Uint8Array();
237
- const reader = request.body.getReader();
238
- const chunks = [];
239
- let total = 0;
240
- const cancelBodyRead = /* @__PURE__ */ __name(() => {
241
- void reader.cancel(request.signal.reason).catch(() => {
242
- });
243
- }, "cancelBodyRead");
244
- request.signal.addEventListener("abort", cancelBodyRead, { once: true });
245
- try {
246
- while (true) {
247
- throwIfAborted(request.signal);
248
- const { done, value } = await reader.read();
249
- throwIfAborted(request.signal);
250
- if (done) break;
251
- if (!value) continue;
252
- total += value.byteLength;
253
- if (total > limit) {
254
- const error = new FarmRequestBodyError("BODY_TOO_LARGE", 413, "Request body is too large");
255
- void reader.cancel(error).catch(() => {
256
- });
257
- throw error;
258
- }
259
- chunks.push(value);
260
- }
261
- } catch (error) {
262
- if (request.signal.aborted) throwIfAborted(request.signal);
263
- throw error;
264
- } finally {
265
- request.signal.removeEventListener("abort", cancelBodyRead);
266
- reader.releaseLock();
267
- }
268
- const body = new Uint8Array(total);
269
- let offset = 0;
270
- for (const chunk of chunks) {
271
- body.set(chunk, offset);
272
- offset += chunk.byteLength;
273
- }
274
- return body;
275
- }
276
- __name(readFarmRequestBody, "readFarmRequestBody");
277
- function createFarmRequestBodyErrorResponse(error) {
278
- if (!(error instanceof FarmRequestBodyError)) return null;
279
- return new Response(error.status === 413 ? "Payload Too Large" : "Bad Request", {
280
- status: error.status,
281
- headers: {
282
- "cache-control": "no-store",
283
- "content-type": "text/plain; charset=utf-8",
284
- "x-content-type-options": "nosniff"
285
- }
286
- });
287
- }
288
- __name(createFarmRequestBodyErrorResponse, "createFarmRequestBodyErrorResponse");
289
- function validateContentLength(value, limit) {
290
- const contentLength = value?.trim();
291
- if (!contentLength) return;
292
- if (!/^\d+$/.test(contentLength)) {
293
- throw new FarmRequestBodyError("INVALID_CONTENT_LENGTH", 400, "Invalid content-length header");
294
- }
295
- if (Number(contentLength) > limit) {
296
- throw new FarmRequestBodyError("BODY_TOO_LARGE", 413, "Request body is too large");
297
- }
298
- }
299
- __name(validateContentLength, "validateContentLength");
300
- function throwIfAborted(signal) {
301
- if (!signal.aborted) return;
302
- if (signal.reason !== void 0) throw signal.reason;
303
- throw new DOMException("The operation was aborted", "AbortError");
304
- }
305
- __name(throwIfAborted, "throwIfAborted");
306
5
 
307
- // src/search-params.ts
308
- function searchParamsToObject(searchParams) {
309
- const output = {};
310
- searchParams.forEach((value, key) => {
311
- if (key === "__proto__" || key === "constructor" || key === "prototype") return;
312
- const existing = Object.prototype.hasOwnProperty.call(output, key) ? output[key] : void 0;
313
- if (existing !== void 0) {
314
- if (Array.isArray(existing)) {
315
- existing.push(value);
316
- } else {
317
- output[key] = [existing, value];
318
- }
319
- } else {
320
- output[key] = value;
321
- }
322
- });
323
- return output;
324
- }
325
- __name(searchParamsToObject, "searchParamsToObject");
326
6
 
327
- // src/secret-compare.ts
328
- function farmSecretsMatch(provided, expected) {
329
- if (typeof provided !== "string" || typeof expected !== "string") return false;
330
- if (expected.length === 0) return false;
331
- let mismatch = provided.length ^ expected.length;
332
- const length = Math.max(provided.length, expected.length);
333
- for (let index = 0; index < length; index += 1) {
334
- const providedCode = index < provided.length ? provided.charCodeAt(index) : 0;
335
- const expectedCode = index < expected.length ? expected.charCodeAt(index) : 0;
336
- mismatch |= providedCode ^ expectedCode;
337
- }
338
- return mismatch === 0;
339
- }
340
- __name(farmSecretsMatch, "farmSecretsMatch");
341
7
 
342
- // src/utils/runtime-env.ts
343
- function getFarmRuntimeBindings() {
344
- const runtimeBindings = globalThis.__env__;
345
- return runtimeBindings && typeof runtimeBindings === "object" ? runtimeBindings : void 0;
346
- }
347
- __name(getFarmRuntimeBindings, "getFarmRuntimeBindings");
348
- function readFarmEnvironmentValue(name) {
349
- const runtimeValue = getFarmRuntimeBindings()?.[name];
350
- if (typeof runtimeValue === "string") return runtimeValue;
351
- return typeof process !== "undefined" ? process.env?.[name] : void 0;
352
- }
353
- __name(readFarmEnvironmentValue, "readFarmEnvironmentValue");
354
- function isFarmDeployedRuntime() {
355
- if (getFarmRuntimeBindings()) return true;
356
- return readFarmEnvironmentValue("NODE_ENV") === "production";
357
- }
358
- __name(isFarmDeployedRuntime, "isFarmDeployedRuntime");
359
8
 
360
- // src/utils/decode.ts
361
- function decodeRouteSegment(segment) {
362
- try {
363
- return decodeURIComponent(segment);
364
- } catch {
365
- return segment;
366
- }
367
- }
368
- __name(decodeRouteSegment, "decodeRouteSegment");
369
9
 
370
- // src/utils.ts
371
- function toPosixPath(filePath) {
372
- return filePath.replace(/\\/g, "/");
373
- }
374
- __name(toPosixPath, "toPosixPath");
375
10
 
376
- // src/plugins/route-pattern.ts
377
- function validateConfigRouteSource(source, field = "Config route source") {
378
- if (typeof source !== "string" || source.length === 0) {
379
- throw new TypeError(`${field} must be a non-empty pathname pattern.`);
380
- }
381
- if (source.trim() !== source) {
382
- throw new Error(`${field} cannot contain leading or trailing whitespace.`);
383
- }
384
- if (!source.startsWith("/")) {
385
- throw new Error(`${field} must start with "/".`);
386
- }
387
- if (source.includes("?") || source.includes("#")) {
388
- throw new Error(`${field} must be a pathname without a query string or hash.`);
389
- }
390
- if (source.includes("\\") || Array.from(source).some((character) => {
391
- const code = character.charCodeAt(0);
392
- return code <= 31 || code >= 127 && code <= 159;
393
- })) {
394
- throw new Error(`${field} cannot contain backslashes or control characters.`);
395
- }
396
- assertBrowserStableRoutePath(source);
397
- return source;
398
- }
399
- __name(validateConfigRouteSource, "validateConfigRouteSource");
400
11
 
401
- // src/workflows.ts
402
- var import_node_path = require("path");
403
- var DEFAULT_FARM_WORKFLOW_DIRS = ["src/jobs", "src/workflows", "src/cron"];
404
- var DEFAULT_FARM_WORKFLOW_ROUTE = "/api/_farm/workflows";
405
- var DEFAULT_FARM_WORKFLOW_SECRET_ENV = "CRON_SECRET";
406
- var MISSING_FARM_WORKFLOW_SECRET_ERROR = "Workflow route requires a secret. Set the CRON_SECRET environment variable, configure workflows.secret, or set workflows.allowUnsecured to true.";
407
- function defineWorkflow(definition) {
408
- return {
409
- ...definition,
410
- kind: "farm-workflow"
411
- };
412
- }
413
- __name(defineWorkflow, "defineWorkflow");
414
- function defineTask(definition) {
415
- return defineWorkflow(definition);
416
- }
417
- __name(defineTask, "defineTask");
418
- function defineCron(definition) {
419
- return {
420
- ...definition,
421
- kind: "farm-workflow"
422
- };
423
- }
424
- __name(defineCron, "defineCron");
425
- function resolveWorkflowsConfig(workflows) {
426
- if (workflows === false) {
427
- return {
428
- enabled: false,
429
- dirs: [...DEFAULT_FARM_WORKFLOW_DIRS],
430
- route: DEFAULT_FARM_WORKFLOW_ROUTE,
431
- secretEnv: DEFAULT_FARM_WORKFLOW_SECRET_ENV
432
- };
433
- }
434
- const options = workflows && typeof workflows === "object" ? workflows : {};
435
- const dirs = normalizeWorkflowDirs(options);
436
- return {
437
- enabled: options.enabled ?? true,
438
- dirs,
439
- route: normalizeWorkflowRoute(options.route || DEFAULT_FARM_WORKFLOW_ROUTE),
440
- secretEnv: options.secretEnv || DEFAULT_FARM_WORKFLOW_SECRET_ENV,
441
- secret: options.secret,
442
- allowUnsecured: options.allowUnsecured === true
443
- };
444
- }
445
- __name(resolveWorkflowsConfig, "resolveWorkflowsConfig");
446
- async function discoverFarmWorkflows(config, options = {}) {
447
- const workflowConfig = isResolvedWorkflowConfig(config.workflows) ? config.workflows : resolveWorkflowsConfig(config.workflows);
448
- if (!workflowConfig.enabled) return [];
449
- const root = config.root || process.cwd();
450
- const files = await findWorkflowFiles(root, workflowConfig.dirs);
451
- const workflows = [];
452
- const seenIds = /* @__PURE__ */ new Map();
453
- for (const filePath of files) {
454
- const module2 = options.loadModule ? await options.loadModule(filePath) : await loadWorkflowModule(filePath, root);
455
- const definition = resolveWorkflowDefinition(module2);
456
- if (!definition) continue;
457
- const id = normalizeWorkflowId(
458
- definition.id || workflowIdFromFile(root, workflowConfig.dirs, filePath)
459
- );
460
- const previousPath = seenIds.get(id);
461
- if (previousPath) {
462
- throw new Error(
463
- `Duplicate Farm workflow id "${id}" found in ${relativePath(root, previousPath)} and ${relativePath(root, filePath)}.`
464
- );
465
- }
466
- seenIds.set(id, filePath);
467
- workflows.push({
468
- id,
469
- filePath,
470
- description: definition.description,
471
- schedule: normalizeSchedule(definition.schedule),
472
- timezone: definition.timezone,
473
- routePath: joinRoute(workflowConfig.route, encodeURIComponent(id))
474
- });
475
- }
476
- return workflows;
477
- }
478
- __name(discoverFarmWorkflows, "discoverFarmWorkflows");
479
- function createFarmWorkflowRequestHandler(options) {
480
- const workflowsById = new Map(options.workflows.map((workflow) => [workflow.id, workflow]));
481
- return /* @__PURE__ */ __name(async function handleFarmWorkflowRequest(request) {
482
- const url = new URL(request.url);
483
- const route = normalizeWorkflowRoute(options.config.route);
484
- if (url.pathname !== route && !url.pathname.startsWith(`${route}/`)) {
485
- return null;
486
- }
487
- if (url.pathname === route) {
488
- const secretError2 = verifyWorkflowSecret(request, options.config);
489
- if (secretError2) return secretError2;
490
- return Response.json({
491
- workflows: options.workflows.map(toWorkflowMetadata)
492
- });
493
- }
494
- const id = decodeRouteSegment(url.pathname.slice(route.length + 1));
495
- const secretError = verifyWorkflowSecret(request, options.config);
496
- if (secretError) return secretError;
497
- const workflow = workflowsById.get(id);
498
- if (!workflow) {
499
- return Response.json({ error: `Workflow "${id}" was not found.` }, { status: 404 });
500
- }
501
- let payload;
502
- try {
503
- payload = await readWorkflowPayload(
504
- request,
505
- resolveFarmServerConfig(options.server).bodySizeLimit
506
- );
507
- } catch (error) {
508
- const response = createFarmRequestBodyErrorResponse(error);
509
- if (response) return response;
510
- if (error instanceof SyntaxError) {
511
- return Response.json({ error: "Invalid workflow request body." }, { status: 400 });
512
- }
513
- throw error;
514
- }
515
- const module2 = await options.loadModule(workflow);
516
- const result = await runFarmWorkflowModule(module2, {
517
- id: workflow.id,
518
- name: workflow.id,
519
- payload,
520
- request,
521
- scheduledTime: readScheduledTime(payload)
522
- });
523
- return Response.json({
524
- id: workflow.id,
525
- ok: true,
526
- result: result ?? null
527
- });
528
- }, "handleFarmWorkflowRequest");
529
- }
530
- __name(createFarmWorkflowRequestHandler, "createFarmWorkflowRequestHandler");
531
- async function runFarmWorkflowModule(module2, context) {
532
- const definition = resolveWorkflowDefinition(module2);
533
- if (!definition) {
534
- throw new Error(`Farm workflow "${context.id}" does not export a workflow definition.`);
535
- }
536
- return await definition.run({
537
- id: context.id,
538
- name: context.name || context.id,
539
- payload: context.payload,
540
- scheduledTime: context.scheduledTime,
541
- request: context.request,
542
- event: context.event,
543
- env: context.env || process.env,
544
- data: /* @__PURE__ */ new Map(),
545
- log: console
546
- });
547
- }
548
- __name(runFarmWorkflowModule, "runFarmWorkflowModule");
549
- async function prepareFarmWorkflowsForNitro(config) {
550
- const workflowConfig = isResolvedWorkflowConfig(config.workflows) ? config.workflows : resolveWorkflowsConfig(config.workflows);
551
- const root = config.root || process.cwd();
552
- const distDir = config.distDir || ".farm";
553
- const fs = await import("fs/promises");
554
- const path = await import("path");
555
- const generatedDir = path.join(root, distDir, ".nitro", "farm-workflows");
556
- const workflows = await discoverFarmWorkflows({
557
- root,
558
- workflows: workflowConfig
559
- });
560
- if (workflows.length === 0) {
561
- await fs.rm(generatedDir, { recursive: true, force: true });
562
- return {
563
- workflows,
564
- tasks: {},
565
- scheduledTasks: {}
566
- };
567
- }
568
- await fs.rm(generatedDir, { recursive: true, force: true });
569
- await fs.mkdir(generatedDir, { recursive: true });
570
- const tasks = {};
571
- const scheduledTasks = createScheduledTasks(workflows);
572
- const wrapperNames = resolveWorkflowWrapperFileNames(workflows.map((workflow) => workflow.id));
573
- for (const workflow of workflows) {
574
- const wrapperPath = toPosixPath(
575
- path.join(generatedDir, `${wrapperNames.get(workflow.id)}.mjs`)
576
- );
577
- await fs.writeFile(wrapperPath, createNitroTaskWrapper(workflow), "utf8");
578
- tasks[workflow.id] = {
579
- handler: wrapperPath,
580
- description: workflow.description || `Farm workflow ${workflow.id}`
581
- };
582
- }
583
- const handlerPath = toPosixPath(path.join(generatedDir, "http-handler.mjs"));
584
- await fs.writeFile(
585
- handlerPath,
586
- createNitroWorkflowHTTPHandler(
587
- workflowConfig,
588
- workflows,
589
- resolveFarmServerConfig(config.server)
590
- ),
591
- "utf8"
592
- );
593
- const manifestPath = path.join(generatedDir, "manifest.json");
594
- await fs.writeFile(
595
- manifestPath,
596
- JSON.stringify(
597
- {
598
- route: workflowConfig.route,
599
- secretEnv: workflowConfig.secretEnv,
600
- trigger: {
601
- method: "GET",
602
- authorization: `Bearer $${workflowConfig.secretEnv}`
603
- },
604
- workflows: workflows.map(toWorkflowMetadata)
605
- },
606
- null,
607
- 2
608
- ),
609
- "utf8"
610
- );
611
- return {
612
- workflows,
613
- tasks,
614
- scheduledTasks,
615
- handlerPath,
616
- manifestPath
617
- };
618
- }
619
- __name(prepareFarmWorkflowsForNitro, "prepareFarmWorkflowsForNitro");
620
- function createFarmWorkflowVercelCrons(workflows) {
621
- return workflows.flatMap(
622
- (workflow) => workflow.schedule.map((schedule) => ({
623
- path: workflow.routePath,
624
- schedule
625
- }))
626
- );
627
- }
628
- __name(createFarmWorkflowVercelCrons, "createFarmWorkflowVercelCrons");
629
- function applyFarmWorkflowVercelCrons(vercelConfig, workflows) {
630
- const crons = createFarmWorkflowVercelCrons(workflows);
631
- if (crons.length === 0) return vercelConfig;
632
- const existingCrons = Array.isArray(vercelConfig.crons) ? vercelConfig.crons : [];
633
- const seen = new Set(existingCrons.map((cron) => `${cron.path}:${cron.schedule}`));
634
- const nextCrons = [...existingCrons];
635
- for (const cron of crons) {
636
- const key = `${cron.path}:${cron.schedule}`;
637
- if (seen.has(key)) continue;
638
- seen.add(key);
639
- nextCrons.push(cron);
640
- }
641
- return {
642
- ...vercelConfig,
643
- crons: nextCrons
644
- };
645
- }
646
- __name(applyFarmWorkflowVercelCrons, "applyFarmWorkflowVercelCrons");
647
- function isResolvedWorkflowConfig(value) {
648
- return !!value && typeof value === "object" && "dirs" in value && Array.isArray(value.dirs) && typeof value.route === "string";
649
- }
650
- __name(isResolvedWorkflowConfig, "isResolvedWorkflowConfig");
651
- function normalizeWorkflowDirs(options) {
652
- const rawDirs = options.dirs || (Array.isArray(options.dir) ? options.dir : options.dir ? [options.dir] : void 0);
653
- const dirs = rawDirs && rawDirs.length > 0 ? rawDirs : DEFAULT_FARM_WORKFLOW_DIRS;
654
- return [...new Set(dirs.map(normalizeWorkflowDir).filter(Boolean))];
655
- }
656
- __name(normalizeWorkflowDirs, "normalizeWorkflowDirs");
657
- function normalizeWorkflowDir(value) {
658
- const dir = value.trim();
659
- if (!dir) return "";
660
- return (0, import_node_path.isAbsolute)(dir) ? (0, import_node_path.normalize)(dir) : trimSlashes(dir);
661
- }
662
- __name(normalizeWorkflowDir, "normalizeWorkflowDir");
663
- function normalizeWorkflowRoute(route) {
664
- const trimmed = route.trim();
665
- if (!trimmed || trimmed === "/") return DEFAULT_FARM_WORKFLOW_ROUTE;
666
- const normalized = `/${trimSlashes(trimmed)}`;
667
- validateConfigRouteSource(normalized, "workflows.route");
668
- return normalized;
669
- }
670
- __name(normalizeWorkflowRoute, "normalizeWorkflowRoute");
671
- function normalizeWorkflowId(id) {
672
- const normalized = id.replace(/\\/g, "/").replace(/\.(tsx?|jsx?|mjs|cjs)$/, "").replace(/\/index$/, "").replace(/[^a-zA-Z0-9._/-]+/g, "-").replace(/^\/+|\/+$/g, "").replace(/\/+/g, "/");
673
- return normalized || "workflow";
674
- }
675
- __name(normalizeWorkflowId, "normalizeWorkflowId");
676
- function normalizeSchedule(schedule) {
677
- if (!schedule) return [];
678
- return (Array.isArray(schedule) ? schedule : [schedule]).map((value) => value.trim()).filter(Boolean);
679
- }
680
- __name(normalizeSchedule, "normalizeSchedule");
681
- function resolveWorkflowDefinition(module2) {
682
- const candidates = [module2.default, module2.workflow, module2.cron, module2.task, module2.job];
683
- for (const candidate of candidates) {
684
- if (candidate && typeof candidate === "object" && typeof candidate.run === "function") {
685
- return candidate;
686
- }
687
- }
688
- return null;
689
- }
690
- __name(resolveWorkflowDefinition, "resolveWorkflowDefinition");
691
- async function findWorkflowFiles(root, dirs) {
692
- const path = await import("path");
693
- const files = [];
694
- for (const dir of dirs) {
695
- const absoluteDir = path.isAbsolute(dir) ? dir : path.join(root, dir);
696
- if (!await pathExists(absoluteDir)) continue;
697
- await walkWorkflowDir(absoluteDir, files);
698
- }
699
- return files.sort();
700
- }
701
- __name(findWorkflowFiles, "findWorkflowFiles");
702
- async function walkWorkflowDir(dir, files) {
703
- const fs = await import("fs/promises");
704
- const path = await import("path");
705
- const entries = await fs.readdir(dir, { withFileTypes: true });
706
- for (const entry of entries) {
707
- const filePath = path.join(dir, entry.name);
708
- if (entry.isDirectory()) {
709
- if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
710
- await walkWorkflowDir(filePath, files);
711
- continue;
712
- }
713
- if (isWorkflowFile(entry.name)) {
714
- files.push(filePath);
715
- }
716
- }
717
- }
718
- __name(walkWorkflowDir, "walkWorkflowDir");
719
- async function pathExists(filePath) {
720
- const fs = await import("fs/promises");
721
- return fs.access(filePath).then(() => true).catch(() => false);
722
- }
723
- __name(pathExists, "pathExists");
724
- function isWorkflowFile(fileName) {
725
- return /\.(?:ts|tsx|js|jsx|mjs|cjs)$/.test(fileName) && !/\.d\.[cm]?ts$/.test(fileName);
726
- }
727
- __name(isWorkflowFile, "isWorkflowFile");
728
- async function loadWorkflowModule(filePath, root) {
729
- const fs = await import("fs/promises");
730
- const path = await import("path");
731
- const { pathToFileURL } = await import("url");
732
- const { build } = await import("esbuild");
733
- const outDir = path.join(root, ".farm", ".workflow-loader");
734
- await fs.mkdir(outDir, { recursive: true });
735
- const outfile = path.join(
736
- outDir,
737
- `workflow-${Date.now()}-${Math.random().toString(36).slice(2)}.mjs`
738
- );
739
- await build({
740
- absWorkingDir: root,
741
- entryPoints: [filePath],
742
- outfile,
743
- bundle: true,
744
- format: "esm",
745
- platform: "node",
746
- target: `node${process.versions.node.split(".")[0]}`,
747
- packages: "external",
748
- external: ["@farm.js/core", "@farm.js/core/*", "nitro", "nitro/*"],
749
- jsx: "automatic",
750
- logLevel: "silent",
751
- sourcemap: "inline"
752
- });
753
- try {
754
- return await import(
755
- /* @vite-ignore */
756
- `${pathToFileURL(outfile).href}?t=${Date.now()}`
757
- );
758
- } finally {
759
- await fs.unlink(outfile).catch(() => void 0);
760
- }
761
- }
762
- __name(loadWorkflowModule, "loadWorkflowModule");
763
- function workflowIdFromFile(root, dirs, filePath) {
764
- for (const dir of dirs) {
765
- const scanRoot = (0, import_node_path.isAbsolute)(dir) ? dir : (0, import_node_path.resolve)(root, dir);
766
- const candidate = (0, import_node_path.relative)(scanRoot, filePath);
767
- if (candidate && candidate !== ".." && !candidate.startsWith(`..${import_node_path.sep}`)) {
768
- return normalizeWorkflowId(candidate);
769
- }
770
- }
771
- return normalizeWorkflowId((0, import_node_path.relative)(root, filePath));
772
- }
773
- __name(workflowIdFromFile, "workflowIdFromFile");
774
- function createScheduledTasks(workflows) {
775
- const scheduleMap = /* @__PURE__ */ new Map();
776
- for (const workflow of workflows) {
777
- for (const schedule of workflow.schedule) {
778
- const taskIds = scheduleMap.get(schedule) || [];
779
- taskIds.push(workflow.id);
780
- scheduleMap.set(schedule, taskIds);
781
- }
782
- }
783
- return Object.fromEntries(
784
- [...scheduleMap.entries()].map(([schedule, taskIds]) => [
785
- schedule,
786
- taskIds.length === 1 ? taskIds[0] : taskIds
787
- ])
788
- );
789
- }
790
- __name(createScheduledTasks, "createScheduledTasks");
791
- function createNitroTaskWrapper(workflow) {
792
- const normalizedPath = workflow.filePath.replace(/\\/g, "/");
793
- return `
794
- import { defineTask } from "nitro/task";
795
- import { runFarmWorkflowModule } from "@farm.js/core/workflows";
796
- import * as workflowModule from ${JSON.stringify(normalizedPath)};
797
12
 
798
- export default defineTask({
799
- meta: {
800
- description: ${JSON.stringify(workflow.description || `Farm workflow ${workflow.id}`)}
801
- },
802
- async run(event) {
803
- const payload = event?.payload || {};
804
- const env = event?.context?.cloudflare?.env || event?.context?.env || process.env;
805
- return await runFarmWorkflowModule(workflowModule, {
806
- id: ${JSON.stringify(workflow.id)},
807
- name: event?.name || ${JSON.stringify(workflow.id)},
808
- payload,
809
- scheduledTime: payload.scheduledTime,
810
- request: event?.context?.request,
811
- event,
812
- env
813
- });
814
- }
815
- });
816
- `.trim();
817
- }
818
- __name(createNitroTaskWrapper, "createNitroTaskWrapper");
819
- function createNitroWorkflowHTTPHandler(config, workflows, server) {
820
- return `
821
- import { H3 } from "h3";
822
- import { runTask } from "nitro/task";
823
- import {
824
- createFarmRequestBodyErrorResponse,
825
- farmSecretsMatch,
826
- readFarmRequestBody,
827
- searchParamsToObject
828
- } from "@farm.js/core/internal/production-runtime";
829
13
 
830
- const route = ${JSON.stringify(config.route)};
831
- const secretEnv = ${JSON.stringify(config.secretEnv)};
832
- const inlineSecret = ${JSON.stringify(config.secret || "")};
833
- const allowUnsecured = ${JSON.stringify(config.allowUnsecured === true)};
834
- const bodySizeLimit = ${JSON.stringify(server.bodySizeLimit)};
835
- const workflows = ${JSON.stringify(workflows.map(toWorkflowMetadata))};
836
- const workflowIds = new Set(workflows.map((workflow) => workflow.id));
837
14
 
838
- function json(value, status = 200) {
839
- return new Response(JSON.stringify(value), {
840
- status,
841
- headers: { "content-type": "application/json" }
842
- });
843
- }
15
+ var _chunkK6FNHVDRcjs = require('./chunk-K6FNHVDR.cjs');
16
+ require('./chunk-JDNHKPTD.cjs');
17
+ require('./chunk-CMGMGHUZ.cjs');
18
+ require('./chunk-EM6SBQKM.cjs');
19
+ require('./chunk-5QIKR7RR.cjs');
20
+ require('./chunk-QNPEUFHQ.cjs');
21
+ require('./chunk-DVM4FKZL.cjs');
22
+ require('./chunk-US2QVW3E.cjs');
23
+ require('./chunk-BIDYX3SL.cjs');
24
+ require('./chunk-I57LW5VZ.cjs');
25
+ require('./chunk-NO3WWW3N.cjs');
26
+ require('./chunk-S3JO3N4H.cjs');
844
27
 
845
- function decodeRouteSegment(segment) {
846
- try {
847
- return decodeURIComponent(segment);
848
- } catch {
849
- return segment;
850
- }
851
- }
852
28
 
853
- function getHeader(event, name) {
854
- return event.req.headers.get(name);
855
- }
856
29
 
857
- function getSecret() {
858
- // Match the dev-path verifyWorkflowSecret's resolution (readFarmEnvironmentValue):
859
- // runtime bindings on globalThis.__env__ first, then process.env. Reading
860
- // process.env alone misses a Cloudflare Workers secret, so a correctly
861
- // configured deployment would see no secret and reject every request with 401.
862
- const runtimeBindings = globalThis.__env__;
863
- const runtimeSecret =
864
- runtimeBindings && typeof runtimeBindings === "object" ? runtimeBindings[secretEnv] : undefined;
865
- const resolved =
866
- typeof runtimeSecret === "string"
867
- ? runtimeSecret
868
- : typeof process !== "undefined"
869
- ? process.env?.[secretEnv]
870
- : undefined;
871
- return inlineSecret || resolved || "";
872
- }
873
30
 
874
- function verifySecret(event) {
875
- const secret = getSecret();
876
- if (!secret) {
877
- if (allowUnsecured) return null;
878
- return json({ error: ${JSON.stringify(MISSING_FARM_WORKFLOW_SECRET_ERROR)} }, 401);
879
- }
880
- const authorization = getHeader(event, "authorization") || "";
881
- const headerSecret = getHeader(event, "x-farm-workflow-secret") || "";
882
- const bearer = authorization.match(/^Bearer\\s+(.+)$/i)?.[1] || "";
883
- if (farmSecretsMatch(headerSecret, secret) || farmSecretsMatch(bearer, secret)) return null;
884
- return json({ error: "Unauthorized workflow request." }, 401);
885
- }
886
31
 
887
- async function readPayload(event) {
888
- if (event.req.method === "GET" || event.req.method === "HEAD") {
889
- return searchParamsToObject(event.url.searchParams);
890
- }
891
- const bytes = await readFarmRequestBody(event.req, bodySizeLimit);
892
- const text = new TextDecoder().decode(bytes);
893
- if (!text) return {};
894
- const contentType = (getHeader(event, "content-type") || "").split(";", 1)[0].trim().toLowerCase();
895
- if (
896
- contentType === "application/json" ||
897
- (contentType.startsWith("application/") && contentType.endsWith("+json"))
898
- ) {
899
- return JSON.parse(text);
900
- }
901
- return { text };
902
- }
903
32
 
904
- export default new H3()
905
- .get(route, (event) => {
906
- const unauthorized = verifySecret(event);
907
- if (unauthorized) return unauthorized;
908
- return { workflows };
909
- })
910
- .all(route + "/:id", async (event) => {
911
- const id = decodeRouteSegment(event.context.params?.id || "");
912
33
 
913
- // Verify the secret before consulting the workflow id map so the
914
- // existing-vs-missing distinction is not disclosed to callers without
915
- // the secret (a 401 for unknown ids would otherwise become a 404 oracle).
916
- const unauthorized = verifySecret(event);
917
- if (unauthorized) return unauthorized;
918
34
 
919
- if (!workflowIds.has(id)) {
920
- return json({ error: "Workflow " + id + " was not found." }, 404);
921
- }
922
35
 
923
- let payload;
924
- try {
925
- payload = await readPayload(event);
926
- } catch (error) {
927
- const response = createFarmRequestBodyErrorResponse(error);
928
- if (response) return response;
929
- if (error instanceof SyntaxError) return json({ error: "Invalid workflow request body." }, 400);
930
- throw error;
931
- }
932
- const result = await runTask(id, {
933
- payload,
934
- context: {
935
- source: "http",
936
- request: event.req,
937
- route,
938
- url: event.url.href,
939
- method: event.req.method
940
- }
941
- });
942
- return {
943
- id,
944
- ok: true,
945
- result: result ?? null
946
- };
947
- });
948
- `.trim();
949
- }
950
- __name(createNitroWorkflowHTTPHandler, "createNitroWorkflowHTTPHandler");
951
- function toWorkflowMetadata(workflow) {
952
- return {
953
- id: workflow.id,
954
- description: workflow.description || null,
955
- schedule: workflow.schedule,
956
- timezone: workflow.timezone || null,
957
- path: workflow.routePath
958
- };
959
- }
960
- __name(toWorkflowMetadata, "toWorkflowMetadata");
961
- async function readWorkflowPayload(request, bodySizeLimit) {
962
- const url = new URL(request.url);
963
- if (request.method === "GET" || request.method === "HEAD") {
964
- return searchParamsToObject(url.searchParams);
965
- }
966
- const bytes = await readFarmRequestBody(request, bodySizeLimit);
967
- const text = new TextDecoder().decode(bytes);
968
- if (!text) return {};
969
- const contentType = (request.headers.get("content-type") || "").split(";", 1)[0].trim().toLowerCase();
970
- if (contentType === "application/json" || contentType.startsWith("application/") && contentType.endsWith("+json")) {
971
- return JSON.parse(text);
972
- }
973
- return { text };
974
- }
975
- __name(readWorkflowPayload, "readWorkflowPayload");
976
- function readScheduledTime(payload) {
977
- return payload && typeof payload === "object" && "scheduledTime" in payload ? payload.scheduledTime : void 0;
978
- }
979
- __name(readScheduledTime, "readScheduledTime");
980
- function verifyWorkflowSecret(request, config) {
981
- const secret = config.secret || readFarmEnvironmentValue(config.secretEnv) || "";
982
- if (!secret) {
983
- if (config.allowUnsecured === true || !isFarmDeployedRuntime()) return null;
984
- return Response.json(
985
- {
986
- error: MISSING_FARM_WORKFLOW_SECRET_ERROR
987
- },
988
- { status: 401 }
989
- );
990
- }
991
- const authorization = request.headers.get("authorization") || "";
992
- const bearer = authorization.match(/^Bearer\s+(.+)$/i)?.[1] || "";
993
- const headerSecret = request.headers.get("x-farm-workflow-secret") || "";
994
- if (farmSecretsMatch(bearer, secret) || farmSecretsMatch(headerSecret, secret)) return null;
995
- return Response.json({ error: "Unauthorized workflow request." }, { status: 401 });
996
- }
997
- __name(verifyWorkflowSecret, "verifyWorkflowSecret");
998
- function joinRoute(...parts) {
999
- return `/${parts.map((part) => trimSlashes(part)).filter(Boolean).join("/")}`;
1000
- }
1001
- __name(joinRoute, "joinRoute");
1002
- function trimSlashes(value) {
1003
- return value.replace(/^\/+|\/+$/g, "");
1004
- }
1005
- __name(trimSlashes, "trimSlashes");
1006
- function resolveWorkflowWrapperFileNames(ids) {
1007
- const groups = /* @__PURE__ */ new Map();
1008
- for (const id of ids) {
1009
- const key = safeFileName(id).toLowerCase();
1010
- groups.set(key, (groups.get(key) ?? 0) + 1);
1011
- }
1012
- const resolved = /* @__PURE__ */ new Map();
1013
- const claimed = /* @__PURE__ */ new Map();
1014
- for (const id of ids) {
1015
- const base = safeFileName(id);
1016
- const key = base.toLowerCase();
1017
- const fileName = (groups.get(key) ?? 0) > 1 ? `${key}-${workflowIdFingerprint(id)}` : base;
1018
- const claimedBy = claimed.get(fileName.toLowerCase());
1019
- if (claimedBy !== void 0) {
1020
- throw new Error(
1021
- `Farm workflows ${JSON.stringify(claimedBy)} and ${JSON.stringify(id)} generate the same wrapper file ${JSON.stringify(`${fileName}.mjs`)}. Rename one of them.`
1022
- );
1023
- }
1024
- claimed.set(fileName.toLowerCase(), id);
1025
- resolved.set(id, fileName);
1026
- }
1027
- return resolved;
1028
- }
1029
- __name(resolveWorkflowWrapperFileNames, "resolveWorkflowWrapperFileNames");
1030
- function workflowIdFingerprint(value) {
1031
- let hash = 2166136261;
1032
- for (let index = 0; index < value.length; index += 1) {
1033
- hash ^= value.charCodeAt(index);
1034
- hash = Math.imul(hash, 16777619);
1035
- }
1036
- return (hash >>> 0).toString(16).padStart(8, "0");
1037
- }
1038
- __name(workflowIdFingerprint, "workflowIdFingerprint");
1039
- function safeFileName(value) {
1040
- return value.replace(/[^a-zA-Z0-9._-]+/g, "-") || "workflow";
1041
- }
1042
- __name(safeFileName, "safeFileName");
1043
- function relativePath(root, filePath) {
1044
- return filePath.replace(/\\/g, "/").replace(`${root.replace(/\\/g, "/")}/`, "");
1045
- }
1046
- __name(relativePath, "relativePath");
1047
- // Annotate the CommonJS export names for ESM import in node:
1048
- 0 && (module.exports = {
1049
- DEFAULT_FARM_WORKFLOW_DIRS,
1050
- DEFAULT_FARM_WORKFLOW_ROUTE,
1051
- DEFAULT_FARM_WORKFLOW_SECRET_ENV,
1052
- applyFarmWorkflowVercelCrons,
1053
- createFarmWorkflowRequestHandler,
1054
- createFarmWorkflowVercelCrons,
1055
- defineCron,
1056
- defineTask,
1057
- defineWorkflow,
1058
- discoverFarmWorkflows,
1059
- prepareFarmWorkflowsForNitro,
1060
- resolveWorkflowsConfig,
1061
- runFarmWorkflowModule
1062
- });
36
+
37
+
38
+
39
+
40
+
41
+ exports.DEFAULT_FARM_WORKFLOW_DIRS = _chunkK6FNHVDRcjs.DEFAULT_FARM_WORKFLOW_DIRS; exports.DEFAULT_FARM_WORKFLOW_ROUTE = _chunkK6FNHVDRcjs.DEFAULT_FARM_WORKFLOW_ROUTE; exports.DEFAULT_FARM_WORKFLOW_SECRET_ENV = _chunkK6FNHVDRcjs.DEFAULT_FARM_WORKFLOW_SECRET_ENV; exports.applyFarmWorkflowVercelCrons = _chunkK6FNHVDRcjs.applyFarmWorkflowVercelCrons; exports.createFarmWorkflowRequestHandler = _chunkK6FNHVDRcjs.createFarmWorkflowRequestHandler; exports.createFarmWorkflowVercelCrons = _chunkK6FNHVDRcjs.createFarmWorkflowVercelCrons; exports.defineCron = _chunkK6FNHVDRcjs.defineCron; exports.defineTask = _chunkK6FNHVDRcjs.defineTask; exports.defineWorkflow = _chunkK6FNHVDRcjs.defineWorkflow; exports.discoverFarmWorkflows = _chunkK6FNHVDRcjs.discoverFarmWorkflows; exports.prepareFarmWorkflowsForNitro = _chunkK6FNHVDRcjs.prepareFarmWorkflowsForNitro; exports.resolveWorkflowsConfig = _chunkK6FNHVDRcjs.resolveWorkflowsConfig; exports.runFarmWorkflowModule = _chunkK6FNHVDRcjs.runFarmWorkflowModule;