vercel 59.14.0 → 59.15.0

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 (459) hide show
  1. package/dist/chunks/add-7XFD2OHW.js +8 -0
  2. package/dist/chunks/add-HZC7AUBY.js +8 -0
  3. package/dist/chunks/add-PYUNJZ6K.js +8 -0
  4. package/dist/chunks/build-EFKQ6BND.js +7 -0
  5. package/dist/chunks/chunk-2B2MN3U5.js +8 -0
  6. package/dist/chunks/chunk-2H77IRPI.js +9 -0
  7. package/dist/chunks/chunk-2I64AYHG.js +7 -0
  8. package/dist/chunks/chunk-2PPXY24N.js +20 -0
  9. package/dist/chunks/chunk-2S6PE6GB.js +7 -0
  10. package/dist/chunks/{chunk-PIMIVJYK.js → chunk-3FMJYJUR.js} +7 -32
  11. package/dist/chunks/chunk-3IAQUNQH.js +7 -0
  12. package/dist/chunks/chunk-3QHJYVCY.js +7 -0
  13. package/dist/chunks/chunk-3QT7VOE3.js +7 -0
  14. package/dist/chunks/chunk-3TXEXPUW.js +7 -0
  15. package/dist/chunks/chunk-4MZK6JT6.js +7 -0
  16. package/dist/chunks/chunk-4NE5IQ25.js +7 -0
  17. package/dist/chunks/chunk-4PNSSS3L.js +7 -0
  18. package/dist/chunks/chunk-4QX77CP7.js +7 -0
  19. package/dist/chunks/chunk-57GHYR4Y.js +25 -0
  20. package/dist/chunks/chunk-5QQNYN4N.js +7 -0
  21. package/dist/chunks/chunk-5XJNPXQK.js +7 -0
  22. package/dist/chunks/chunk-6L236MNA.js +7 -0
  23. package/dist/chunks/chunk-6PFC3KWQ.js +7 -0
  24. package/dist/chunks/chunk-6QKS6QK7.js +7 -0
  25. package/dist/chunks/chunk-6RIQPTJA.js +8 -0
  26. package/dist/chunks/chunk-6TAQ6OWD.js +13 -0
  27. package/dist/chunks/chunk-6YAADRQB.js +9 -0
  28. package/dist/chunks/chunk-75CPY75D.js +15 -0
  29. package/dist/chunks/chunk-7HL2RPUO.js +7 -0
  30. package/dist/chunks/chunk-7PNYOSDU.js +9 -0
  31. package/dist/chunks/chunk-7R5FEXZ5.js +7 -0
  32. package/dist/chunks/chunk-7RMCBXBB.js +62 -0
  33. package/dist/chunks/chunk-7RR7MIMT.js +7 -0
  34. package/dist/chunks/chunk-7T6TL3GQ.js +7 -0
  35. package/dist/chunks/chunk-ADUYPK2G.js +13 -0
  36. package/dist/chunks/chunk-AFPOIDM5.js +7 -0
  37. package/dist/chunks/chunk-AM46JVVN.js +7 -0
  38. package/dist/chunks/chunk-AVSPFBLM.js +7 -0
  39. package/dist/chunks/chunk-B4ATVYZW.js +7 -0
  40. package/dist/chunks/chunk-BATE73HA.js +9 -0
  41. package/dist/chunks/{chunk-64IF634X.js → chunk-BRK4OB4B.js} +1 -12
  42. package/dist/chunks/chunk-BVH2AEFE.js +7 -0
  43. package/dist/chunks/chunk-CN2QZO4U.js +7 -0
  44. package/dist/chunks/chunk-COQGD2EI.js +8 -0
  45. package/dist/chunks/chunk-CUAIEGNE.js +7 -0
  46. package/dist/chunks/chunk-CVKB54WW.js +7 -0
  47. package/dist/chunks/{chunk-A3NYPUKZ.js → chunk-CZSOZKHX.js} +1 -11
  48. package/dist/chunks/chunk-D4MW3RDW.js +7 -0
  49. package/dist/chunks/chunk-DFVNL5ML.js +7 -0
  50. package/dist/chunks/chunk-EE3FVJLV.js +16 -0
  51. package/dist/chunks/chunk-EGMJRU5P.js +28 -0
  52. package/dist/chunks/chunk-ENBTTYJR.js +7 -0
  53. package/dist/chunks/chunk-ENS6KX2F.js +7 -0
  54. package/dist/chunks/chunk-EOBD4ZEG.js +8 -0
  55. package/dist/chunks/chunk-EOCTK4EA.js +7 -0
  56. package/dist/chunks/chunk-EQ52F4LH.js +7 -0
  57. package/dist/chunks/chunk-ETV3C2CV.js +7 -0
  58. package/dist/chunks/chunk-EVZRQGNK.js +7 -0
  59. package/dist/chunks/chunk-F2ZWW2IO.js +8 -0
  60. package/dist/chunks/chunk-FAW6NBLQ.js +7 -0
  61. package/dist/chunks/chunk-FI772UVH.js +7 -0
  62. package/dist/chunks/chunk-FKCOBJFH.js +7 -0
  63. package/dist/chunks/chunk-FVGESGJI.js +45 -0
  64. package/dist/chunks/chunk-G5FC5ZCO.js +9 -0
  65. package/dist/chunks/chunk-G6CTAHKY.js +39 -0
  66. package/dist/chunks/chunk-G7Y77DFH.js +7 -0
  67. package/dist/chunks/chunk-GHAY4PSD.js +7 -0
  68. package/dist/chunks/chunk-GHM7V3GG.js +7 -0
  69. package/dist/chunks/chunk-GRNTLNC7.js +7 -0
  70. package/dist/chunks/chunk-GTRGQIY2.js +10 -0
  71. package/dist/chunks/chunk-GU6VIFR5.js +7 -0
  72. package/dist/chunks/{constants-YMCRE6IG.js → chunk-GZNDA6SV.js} +2 -9
  73. package/dist/chunks/chunk-HBFPLBTX.js +10 -0
  74. package/dist/chunks/chunk-HEGJZJO7.js +7 -0
  75. package/dist/chunks/chunk-HSJ6AHWG.js +12 -0
  76. package/dist/chunks/chunk-HTC6KO2B.js +7 -0
  77. package/dist/chunks/chunk-HVUHCRZB.js +18 -0
  78. package/dist/chunks/chunk-HZZ5L472.js +7 -0
  79. package/dist/chunks/chunk-IVSSTHB6.js +7 -0
  80. package/dist/chunks/chunk-IVWPQYIH.js +7 -0
  81. package/dist/chunks/chunk-J3U3L45Y.js +7 -0
  82. package/dist/chunks/chunk-JAJW3P42.js +7 -0
  83. package/dist/chunks/chunk-JEIMW3CO.js +7 -0
  84. package/dist/chunks/chunk-JIYY3B4C.js +7 -0
  85. package/dist/chunks/chunk-JKTQV2QJ.js +7 -0
  86. package/dist/chunks/chunk-JTVVBRW7.js +7 -0
  87. package/dist/chunks/chunk-JYAUUIR4.js +7 -0
  88. package/dist/chunks/chunk-JZRMH5UA.js +7 -0
  89. package/dist/chunks/chunk-K2RAW5DI.js +10 -0
  90. package/dist/chunks/chunk-K3KJZLBD.js +7 -0
  91. package/dist/chunks/chunk-KK4AJES5.js +36 -0
  92. package/dist/chunks/chunk-KKS7XWEX.js +7 -0
  93. package/dist/chunks/chunk-KNEWCUWF.js +14 -0
  94. package/dist/chunks/chunk-KO733OJG.js +9 -0
  95. package/dist/chunks/chunk-L243RUIR.js +19 -0
  96. package/dist/chunks/chunk-L3JDEHCQ.js +7 -0
  97. package/dist/chunks/chunk-LDM3SQAU.js +13 -0
  98. package/dist/chunks/chunk-LNPMDXBJ.js +7 -0
  99. package/dist/chunks/chunk-M2W3HKV3.js +23 -0
  100. package/dist/chunks/chunk-M2XARQBF.js +9 -0
  101. package/dist/chunks/chunk-M5AV545M.js +7 -0
  102. package/dist/chunks/chunk-MAVRGZQP.js +7 -0
  103. package/dist/chunks/chunk-MBL6TXEJ.js +7 -0
  104. package/dist/chunks/chunk-MEAY2K5Z.js +11 -0
  105. package/dist/chunks/chunk-MY4MONOH.js +7 -0
  106. package/dist/chunks/chunk-N3N5UHIL.js +7 -0
  107. package/dist/chunks/chunk-N3ZZ7FHQ.js +7 -0
  108. package/dist/chunks/chunk-N6CNMMSZ.js +7 -0
  109. package/dist/chunks/chunk-NBVY237X.js +7 -0
  110. package/dist/chunks/chunk-NGNOUPWS.js +25 -0
  111. package/dist/chunks/chunk-NHTF332K.js +7 -0
  112. package/dist/chunks/chunk-NNP5NITU.js +15 -0
  113. package/dist/chunks/chunk-NS4FH2TY.js +11 -0
  114. package/dist/chunks/chunk-NUGLE4QY.js +11 -0
  115. package/dist/chunks/chunk-NWFHHUKZ.js +7 -0
  116. package/dist/chunks/chunk-O7G3CZ42.js +7 -0
  117. package/dist/chunks/chunk-OD6RZ3XZ.js +8 -0
  118. package/dist/chunks/chunk-OHDEHZLX.js +7 -0
  119. package/dist/chunks/chunk-OK3S6KFX.js +16 -0
  120. package/dist/chunks/chunk-OKZDOANA.js +23 -0
  121. package/dist/chunks/chunk-OSCCYU74.js +7 -0
  122. package/dist/chunks/chunk-OUHPDA7Q.js +7 -0
  123. package/dist/chunks/chunk-P2O5DOYE.js +7 -0
  124. package/dist/chunks/chunk-PHW54NU5.js +13 -0
  125. package/dist/chunks/chunk-PPCFQQSU.js +7 -0
  126. package/dist/chunks/chunk-QGIGNMII.js +8 -0
  127. package/dist/chunks/chunk-QGIQK47P.js +7 -0
  128. package/dist/chunks/chunk-QHJLRTVY.js +7 -0
  129. package/dist/chunks/{chunk-2473DUBR.js → chunk-QR7QPUFN.js} +1 -9
  130. package/dist/chunks/chunk-QTKJC2O5.js +7 -0
  131. package/dist/chunks/chunk-R2TGGVCT.js +19 -0
  132. package/dist/chunks/chunk-RAIBQIKB.js +7 -0
  133. package/dist/chunks/chunk-RCTYVKM5.js +16 -0
  134. package/dist/chunks/chunk-RKAUVPOQ.js +86 -0
  135. package/dist/chunks/chunk-S5CEIACD.js +7 -0
  136. package/dist/chunks/chunk-SGWVKRSR.js +8 -0
  137. package/dist/chunks/chunk-SOJCELXH.js +7 -0
  138. package/dist/chunks/chunk-SXUEGVWB.js +7 -0
  139. package/dist/chunks/{chunk-GGPE5377.js → chunk-T3GQAMBJ.js} +1 -9
  140. package/dist/chunks/chunk-T52FMXWC.js +7 -0
  141. package/dist/chunks/chunk-TG2RCYTH.js +7 -0
  142. package/dist/chunks/chunk-TJCIHDPZ.js +9 -0
  143. package/dist/chunks/chunk-TKBXN4H3.js +9 -0
  144. package/dist/chunks/chunk-TRTEXGVN.js +7 -0
  145. package/dist/chunks/chunk-TXELFFNK.js +15 -0
  146. package/dist/chunks/chunk-U56NHYAH.js +7 -0
  147. package/dist/chunks/chunk-U7KCDTCH.js +12 -0
  148. package/dist/chunks/chunk-UETTIYUQ.js +8 -0
  149. package/dist/chunks/chunk-UGMZQZJE.js +24 -0
  150. package/dist/chunks/chunk-ULLWCOYC.js +7 -0
  151. package/dist/chunks/chunk-UXTHEQVJ.js +21 -0
  152. package/dist/chunks/chunk-VLZ47RWM.js +44 -0
  153. package/dist/chunks/chunk-WKZ6JSGZ.js +7 -0
  154. package/dist/chunks/chunk-WPS6JZF6.js +7 -0
  155. package/dist/chunks/chunk-WRILLB46.js +7 -0
  156. package/dist/chunks/chunk-WUZD4KBL.js +7 -0
  157. package/dist/chunks/chunk-XCJDGQO7.js +7 -0
  158. package/dist/chunks/{pkg-56KRLZ5K.js → chunk-XD2LZRBS.js} +1 -7
  159. package/dist/chunks/chunk-XFVGX5HG.js +7 -0
  160. package/dist/chunks/chunk-XHOGOH6N.js +7 -0
  161. package/dist/chunks/{update-route-version-E3V47KNI.js → chunk-XPXOV5UO.js} +1 -7
  162. package/dist/chunks/chunk-XQ73QIQ3.js +7 -0
  163. package/dist/chunks/chunk-XSVBYDYI.js +8 -0
  164. package/dist/chunks/chunk-YKZLKOOD.js +12 -0
  165. package/dist/chunks/chunk-YMVDWVMO.js +7 -0
  166. package/dist/chunks/chunk-YPTLSODC.js +7 -0
  167. package/dist/chunks/chunk-YV6CTDHR.js +7 -0
  168. package/dist/chunks/chunk-Z6Y55QJW.js +23 -0
  169. package/dist/chunks/chunk-ZDX75YNZ.js +7 -0
  170. package/dist/chunks/chunk-ZIPVX7LD.js +7 -0
  171. package/dist/chunks/chunk-ZKYS7EAB.js +7 -0
  172. package/dist/chunks/chunk-ZT6KDLLY.js +20 -0
  173. package/dist/chunks/chunk-ZXE4XYIV.js +7 -0
  174. package/dist/chunks/chunk-ZZQRMRWD.js +20 -0
  175. package/dist/chunks/cjs-GOQHXIHX.js +54 -0
  176. package/dist/chunks/clear-5NQAVWIF.js +8 -0
  177. package/dist/chunks/compile-vercel-config-6J2XUFRK.js +7 -0
  178. package/dist/chunks/config-CKYRXZXL.js +7 -0
  179. package/dist/chunks/config-VNUY4RJ4.js +8 -0
  180. package/dist/chunks/connect-git-provider-GIU5WZ52.js +7 -0
  181. package/dist/chunks/constants-G4UYVLOF.js +7 -0
  182. package/dist/chunks/create-project-SRQGD4JY.js +7 -0
  183. package/dist/chunks/delete-GTXXCSKQ.js +10 -0
  184. package/dist/chunks/delete-HRJEO4MI.js +9 -0
  185. package/dist/chunks/detect-projects-2GNCZ4CS.js +7 -0
  186. package/dist/chunks/detect-services-GHILEGNU.js +7 -0
  187. package/dist/chunks/disable-RWCRVG5O.js +7 -0
  188. package/dist/chunks/discard-SHFIYCJU.js +14 -0
  189. package/dist/chunks/edit-DMO3NSO2.js +9 -0
  190. package/dist/chunks/edit-EVQI2RSS.js +8 -0
  191. package/dist/chunks/enable-AWDU6STD.js +7 -0
  192. package/dist/chunks/esm-7HVUFWMN.js +7 -0
  193. package/dist/chunks/esm-BZBEM7YA.js +7 -0
  194. package/dist/chunks/esm-CXICLFA3.js +9 -0
  195. package/dist/chunks/esm-HDEHVK7I.js +9 -0
  196. package/dist/chunks/esm-NQRLKALI.js +20 -0
  197. package/dist/chunks/esm-SZZI53W7.js +7 -0
  198. package/dist/chunks/esm-WGJFGCLK.js +7 -0
  199. package/dist/chunks/exec-4AISDHUV.js +16372 -0
  200. package/dist/chunks/export-IQKTA4RS.js +19 -0
  201. package/dist/chunks/fetch-proxy-AEAWC6MD.js +7 -0
  202. package/dist/chunks/future-E2FHKPJN.js +7 -0
  203. package/dist/chunks/generate-cert-for-deploy-VKOWC4PZ.js +7 -0
  204. package/dist/chunks/image-LDFYNOCA.js +7 -0
  205. package/dist/chunks/import-builders-P7CXSX2D.js +7 -0
  206. package/dist/chunks/inspect-3N47ODIH.js +15 -0
  207. package/dist/chunks/inspect-53SGDDAH.js +20 -0
  208. package/dist/chunks/inspect-5INZDUQS.js +19 -0
  209. package/dist/chunks/inspect-WMT2M335.js +9 -0
  210. package/dist/chunks/inspect-Y6BUCOUV.js +13 -0
  211. package/dist/chunks/list-BIAPHKFM.js +11 -0
  212. package/dist/chunks/list-DMOCRRSE.js +16 -0
  213. package/dist/chunks/list-K5J7OULR.js +10 -0
  214. package/dist/chunks/login-DEAEVUHM.js +7 -0
  215. package/dist/chunks/login-SRVNHI4Y.js +9 -0
  216. package/dist/chunks/logs-GK7CJBYY.js +7 -0
  217. package/dist/chunks/ls-7ZX6DCJW.js +12 -0
  218. package/dist/chunks/ls-AJWN5ZR4.js +12 -0
  219. package/dist/chunks/ls-BFJWCRLZ.js +12 -0
  220. package/dist/chunks/ls-KGIE6HCO.js +12 -0
  221. package/dist/chunks/ls-UVKTHBTE.js +8 -0
  222. package/dist/chunks/ls-WEG45IOC.js +8 -0
  223. package/dist/chunks/native-self-update-KOJVRMHR.js +7 -0
  224. package/dist/chunks/open-OEWPI5G6.js +7 -0
  225. package/dist/chunks/openapi-MO5HYMHR.js +7 -0
  226. package/dist/chunks/permissions-EPQBQFE3.js +7 -0
  227. package/dist/chunks/pkg-YFU67U7I.js +7 -0
  228. package/dist/chunks/prompt-missing-credentials-IUHLYSQU.js +7 -0
  229. package/dist/chunks/publish-JG7MEPWT.js +15 -0
  230. package/dist/chunks/pull-MRKXG6TO.js +7 -0
  231. package/dist/chunks/purchase-domain-if-available-O5ARXEZ5.js +7 -0
  232. package/dist/chunks/push-XOXJDFYO.js +7 -0
  233. package/dist/chunks/query-AL7C6WV2.js +12 -0
  234. package/dist/chunks/reauthenticate-SH4XR7NH.js +7 -0
  235. package/dist/chunks/reorder-5DMRFDBY.js +10 -0
  236. package/dist/chunks/reply-WSRNZWFD.js +9 -0
  237. package/dist/chunks/repo-info-to-url-SK3VX6UL.js +7 -0
  238. package/dist/chunks/resolve-YJUXQVOZ.js +12 -0
  239. package/dist/chunks/resolve-deployment-framework-preset-XF3NJIDS.js +7 -0
  240. package/dist/chunks/restore-QT3DBGKU.js +16 -0
  241. package/dist/chunks/rm-MHPIUEZ5.js +8 -0
  242. package/dist/chunks/rm-MVZFU6RG.js +8 -0
  243. package/dist/chunks/rm-PXR4J2US.js +8 -0
  244. package/dist/chunks/rm-WB2AIP3N.js +8 -0
  245. package/dist/chunks/rm-XRP6MRUT.js +8 -0
  246. package/dist/chunks/routes-5DERZV5M.js +7 -0
  247. package/dist/chunks/rule-inspect-TT3DRGCS.js +8 -0
  248. package/dist/chunks/rules-B5GW4KJH.js +7 -0
  249. package/dist/chunks/schema-JY5QTZOG.js +14 -0
  250. package/dist/chunks/schema-KCNKVFT3.js +44 -0
  251. package/dist/chunks/select-org-KSCYSESV.js +7 -0
  252. package/dist/chunks/set-7BANEWEL.js +7 -0
  253. package/dist/chunks/setup-and-link-ZAV3EFGC.js +7 -0
  254. package/dist/chunks/slugify-O5DBATYT.js +7 -0
  255. package/dist/chunks/stamp-OX4YO3KY.js +7 -0
  256. package/dist/chunks/tags-VZR66NUC.js +7 -0
  257. package/dist/chunks/types-LRXQEDYI.js +14 -0
  258. package/dist/chunks/update-RBFNNSWE.js +8 -0
  259. package/dist/chunks/update-route-version-XZAFPQJC.js +7 -0
  260. package/dist/chunks/utils-B5ZTMQKY.js +58 -0
  261. package/dist/chunks/vlt-builder-importer-YVCYYRVV.js +11 -0
  262. package/dist/commands/build/index.js +24 -4925
  263. package/dist/commands/deploy/index.js +43 -2875
  264. package/dist/commands/dev/index.js +56 -23857
  265. package/dist/commands/env/index.js +26 -3411
  266. package/dist/commands/link/index.js +4 -284
  267. package/dist/commands/list/index.js +6 -566
  268. package/dist/commands-bulk.js +1187 -87691
  269. package/dist/help.js +1 -8
  270. package/dist/index.js +19 -2591
  271. package/dist/version.mjs +1 -1
  272. package/package.json +50 -51
  273. package/dist/chunks/add-EQZRT4XL.js +0 -221
  274. package/dist/chunks/add-KMDROZC3.js +0 -196
  275. package/dist/chunks/add-QPJ3XMBV.js +0 -145
  276. package/dist/chunks/build-W4HPTAOB.js +0 -251
  277. package/dist/chunks/chunk-26CU4Q3C.js +0 -598
  278. package/dist/chunks/chunk-2HSQ7YUK.js +0 -93
  279. package/dist/chunks/chunk-2JIX6UMI.js +0 -4626
  280. package/dist/chunks/chunk-2LCFOK66.js +0 -1536
  281. package/dist/chunks/chunk-332LMJLZ.js +0 -16014
  282. package/dist/chunks/chunk-3HZLXCVL.js +0 -137
  283. package/dist/chunks/chunk-3VM7HWF6.js +0 -104
  284. package/dist/chunks/chunk-3ZE5CFVM.js +0 -346
  285. package/dist/chunks/chunk-4IALDGB7.js +0 -22
  286. package/dist/chunks/chunk-4KD5BYHB.js +0 -127
  287. package/dist/chunks/chunk-4TUMNBEE.js +0 -231
  288. package/dist/chunks/chunk-4WG2MYCI.js +0 -163
  289. package/dist/chunks/chunk-57RHXXXG.js +0 -150
  290. package/dist/chunks/chunk-5AJPMLDV.js +0 -28
  291. package/dist/chunks/chunk-5EIV6LPQ.js +0 -305
  292. package/dist/chunks/chunk-5NF5HOBJ.js +0 -1854
  293. package/dist/chunks/chunk-653QRQAD.js +0 -417
  294. package/dist/chunks/chunk-67CRVWDF.js +0 -81
  295. package/dist/chunks/chunk-6E6KPBXY.js +0 -43
  296. package/dist/chunks/chunk-75VENWDN.js +0 -1892
  297. package/dist/chunks/chunk-7MRDIPJY.js +0 -107
  298. package/dist/chunks/chunk-7NRNFV77.js +0 -875
  299. package/dist/chunks/chunk-7Q45OKWR.js +0 -149
  300. package/dist/chunks/chunk-AHU7WNL2.js +0 -24
  301. package/dist/chunks/chunk-AINIBIP4.js +0 -39
  302. package/dist/chunks/chunk-AJ5HUOWB.js +0 -14059
  303. package/dist/chunks/chunk-AKLTIZCU.js +0 -46
  304. package/dist/chunks/chunk-AQ6P3IGG.js +0 -49
  305. package/dist/chunks/chunk-B5NH7SLK.js +0 -324
  306. package/dist/chunks/chunk-B5XLQKHI.js +0 -849
  307. package/dist/chunks/chunk-BEQV3X2L.js +0 -86
  308. package/dist/chunks/chunk-CAHP7UGE.js +0 -79
  309. package/dist/chunks/chunk-CFDDM4TX.js +0 -13618
  310. package/dist/chunks/chunk-CJV7J7B5.js +0 -314
  311. package/dist/chunks/chunk-CV5YC2EN.js +0 -867
  312. package/dist/chunks/chunk-CXFY6A6W.js +0 -255
  313. package/dist/chunks/chunk-D5SMZXVO.js +0 -233
  314. package/dist/chunks/chunk-E336ZXPP.js +0 -43
  315. package/dist/chunks/chunk-EDMW7SBH.js +0 -246
  316. package/dist/chunks/chunk-EFYMIIER.js +0 -40
  317. package/dist/chunks/chunk-EKPSCRJZ.js +0 -26
  318. package/dist/chunks/chunk-EOZFDJSY.js +0 -18
  319. package/dist/chunks/chunk-EWBCSDTM.js +0 -1708
  320. package/dist/chunks/chunk-EZKW5YJ2.js +0 -177
  321. package/dist/chunks/chunk-F2QLCXCF.js +0 -2399
  322. package/dist/chunks/chunk-FGDKMNEN.js +0 -21
  323. package/dist/chunks/chunk-FRVG4OW3.js +0 -7438
  324. package/dist/chunks/chunk-FVF4UHDM.js +0 -1288
  325. package/dist/chunks/chunk-G5FBSUL4.js +0 -822
  326. package/dist/chunks/chunk-GDOUDU6O.js +0 -74
  327. package/dist/chunks/chunk-GGP5R3FU.js +0 -129
  328. package/dist/chunks/chunk-GVNCVKCI.js +0 -68
  329. package/dist/chunks/chunk-GY5I4AYD.js +0 -122
  330. package/dist/chunks/chunk-GZLPFESR.js +0 -48
  331. package/dist/chunks/chunk-HB4UKFDO.js +0 -1295
  332. package/dist/chunks/chunk-HD4DR3DA.js +0 -818
  333. package/dist/chunks/chunk-HKHXKSXQ.js +0 -152
  334. package/dist/chunks/chunk-HM24ZWQL.js +0 -174
  335. package/dist/chunks/chunk-HRXRELD3.js +0 -338
  336. package/dist/chunks/chunk-IB5L4LKZ.js +0 -1082
  337. package/dist/chunks/chunk-IIMSID24.js +0 -104
  338. package/dist/chunks/chunk-J7JKZM4T.js +0 -58
  339. package/dist/chunks/chunk-JC2O346E.js +0 -137
  340. package/dist/chunks/chunk-JSD4EZL3.js +0 -34
  341. package/dist/chunks/chunk-JZXJZX7O.js +0 -257
  342. package/dist/chunks/chunk-K3RED3VO.js +0 -566
  343. package/dist/chunks/chunk-KFWQ3EFH.js +0 -151
  344. package/dist/chunks/chunk-KW7BS25T.js +0 -466
  345. package/dist/chunks/chunk-KXDWXXJH.js +0 -70
  346. package/dist/chunks/chunk-LERVNZTD.js +0 -90
  347. package/dist/chunks/chunk-LYAAQDNS.js +0 -242
  348. package/dist/chunks/chunk-M5I6INNF.js +0 -61
  349. package/dist/chunks/chunk-N6HP5BLI.js +0 -18190
  350. package/dist/chunks/chunk-ND5CF2H3.js +0 -53
  351. package/dist/chunks/chunk-NFU4XJIR.js +0 -120
  352. package/dist/chunks/chunk-NW34PW6V.js +0 -1772
  353. package/dist/chunks/chunk-OAMU5QO6.js +0 -18
  354. package/dist/chunks/chunk-OCIZ6ZYA.js +0 -253
  355. package/dist/chunks/chunk-ORQZKIIB.js +0 -2914
  356. package/dist/chunks/chunk-P3SKP5WM.js +0 -27
  357. package/dist/chunks/chunk-P4QNYOFB.js +0 -96
  358. package/dist/chunks/chunk-P7VSBDR4.js +0 -827
  359. package/dist/chunks/chunk-PEC3CQSK.js +0 -90
  360. package/dist/chunks/chunk-PMSMUMUO.js +0 -30
  361. package/dist/chunks/chunk-PNGVSHR3.js +0 -40
  362. package/dist/chunks/chunk-POOO7W47.js +0 -916
  363. package/dist/chunks/chunk-PRWJUY5U.js +0 -848
  364. package/dist/chunks/chunk-Q2DGFCO7.js +0 -579
  365. package/dist/chunks/chunk-RBF2NPUP.js +0 -577
  366. package/dist/chunks/chunk-RBIFXFZX.js +0 -52
  367. package/dist/chunks/chunk-RDTRWLWB.js +0 -11441
  368. package/dist/chunks/chunk-RN6V5ODW.js +0 -114
  369. package/dist/chunks/chunk-RNSMTWA6.js +0 -122
  370. package/dist/chunks/chunk-RTJASENB.js +0 -59
  371. package/dist/chunks/chunk-RVBZ64EQ.js +0 -52
  372. package/dist/chunks/chunk-S7KYDPEM.js +0 -1564
  373. package/dist/chunks/chunk-SLPSPYVR.js +0 -334
  374. package/dist/chunks/chunk-SM3F3PYJ.js +0 -522
  375. package/dist/chunks/chunk-TO7QZGYK.js +0 -105
  376. package/dist/chunks/chunk-TSBUHSN7.js +0 -3495
  377. package/dist/chunks/chunk-TSFWMUCY.js +0 -506
  378. package/dist/chunks/chunk-TZ2YI2VH.js +0 -87
  379. package/dist/chunks/chunk-UG2WOB5L.js +0 -150
  380. package/dist/chunks/chunk-UNKHOYMF.js +0 -559
  381. package/dist/chunks/chunk-UOVWUSLG.js +0 -2099
  382. package/dist/chunks/chunk-V4RMJKQP.js +0 -36
  383. package/dist/chunks/chunk-VGIMO3ZK.js +0 -17
  384. package/dist/chunks/chunk-VGKSIKCC.js +0 -92
  385. package/dist/chunks/chunk-VP5Y3SZG.js +0 -106
  386. package/dist/chunks/chunk-VXYGCOKL.js +0 -28
  387. package/dist/chunks/chunk-W7FGI2GZ.js +0 -233
  388. package/dist/chunks/chunk-WGGABYO5.js +0 -31
  389. package/dist/chunks/chunk-XDGOOW3K.js +0 -60
  390. package/dist/chunks/chunk-XFF5TGRA.js +0 -303
  391. package/dist/chunks/chunk-XNIZGCN5.js +0 -58
  392. package/dist/chunks/chunk-XPJLPUKO.js +0 -117
  393. package/dist/chunks/chunk-XUAWTW4W.js +0 -467
  394. package/dist/chunks/chunk-YPQSDAEW.js +0 -29
  395. package/dist/chunks/chunk-YS76T533.js +0 -270
  396. package/dist/chunks/chunk-ZDU2NODC.js +0 -104
  397. package/dist/chunks/chunk-ZW6HETRE.js +0 -97
  398. package/dist/chunks/cjs-DV4RM7XU.js +0 -20743
  399. package/dist/chunks/clear-4IACMLFU.js +0 -141
  400. package/dist/chunks/compile-vercel-config-PQQ3OCLV.js +0 -33
  401. package/dist/chunks/config-BQQKMQBP.js +0 -168
  402. package/dist/chunks/config-OCPNHXQL.js +0 -127
  403. package/dist/chunks/delete-HRKIYPCO.js +0 -159
  404. package/dist/chunks/delete-P2UL3KTU.js +0 -226
  405. package/dist/chunks/detect-projects-ODNU4PK2.js +0 -18
  406. package/dist/chunks/detect-services-U7QGT7VO.js +0 -40
  407. package/dist/chunks/disable-3NYMICQ3.js +0 -198
  408. package/dist/chunks/discard-RNVEJUK3.js +0 -145
  409. package/dist/chunks/edit-63S2RQHR.js +0 -162
  410. package/dist/chunks/edit-CTENFZ7H.js +0 -647
  411. package/dist/chunks/enable-WILWXAHV.js +0 -204
  412. package/dist/chunks/exec-4IPHZ55G.js +0 -1291
  413. package/dist/chunks/export-YHGV3EPK.js +0 -177
  414. package/dist/chunks/fetch-proxy-R3JZNXBZ.js +0 -99
  415. package/dist/chunks/image-MWKS2YMB.js +0 -75
  416. package/dist/chunks/import-builders-H55X5VYD.js +0 -39
  417. package/dist/chunks/inspect-JTJMK6TO.js +0 -596
  418. package/dist/chunks/inspect-KBIPLMGR.js +0 -216
  419. package/dist/chunks/inspect-OP26FDBY.js +0 -171
  420. package/dist/chunks/inspect-SW4UMWTB.js +0 -175
  421. package/dist/chunks/inspect-WPLZPVBO.js +0 -145
  422. package/dist/chunks/list-HE7DWAWH.js +0 -387
  423. package/dist/chunks/list-OUG7WCT7.js +0 -404
  424. package/dist/chunks/list-QUSEURJZ.js +0 -426
  425. package/dist/chunks/login-MIIQJVF3.js +0 -233
  426. package/dist/chunks/ls-24N3DUK4.js +0 -183
  427. package/dist/chunks/ls-3Y7KEFKT.js +0 -175
  428. package/dist/chunks/ls-75F5HIJ5.js +0 -188
  429. package/dist/chunks/ls-REN6X2X5.js +0 -204
  430. package/dist/chunks/ls-W4STUDXK.js +0 -223
  431. package/dist/chunks/ls-Z4CTSD6C.js +0 -210
  432. package/dist/chunks/open-ARMCLPBK.js +0 -116
  433. package/dist/chunks/permissions-JKI67F62.js +0 -99
  434. package/dist/chunks/publish-SMSQ7OX2.js +0 -155
  435. package/dist/chunks/pull-4QZJZELD.js +0 -45
  436. package/dist/chunks/push-T6IYQY2J.js +0 -191
  437. package/dist/chunks/query-CP3JK5LW.js +0 -725
  438. package/dist/chunks/reorder-RAWKFGLV.js +0 -412
  439. package/dist/chunks/reply-235UHUD4.js +0 -176
  440. package/dist/chunks/resolve-5KCLN7QV.js +0 -237
  441. package/dist/chunks/resolve-deployment-framework-preset-NPE6RLV3.js +0 -36
  442. package/dist/chunks/restore-D24WAUAN.js +0 -252
  443. package/dist/chunks/rm-DBQDXSOC.js +0 -162
  444. package/dist/chunks/rm-G5INO77R.js +0 -148
  445. package/dist/chunks/rm-NLKSEKZ5.js +0 -195
  446. package/dist/chunks/rm-QV76CJA4.js +0 -322
  447. package/dist/chunks/rm-TZ4PDDUK.js +0 -147
  448. package/dist/chunks/routes-QVMBXOSX.js +0 -24
  449. package/dist/chunks/rule-inspect-76MC7I2D.js +0 -123
  450. package/dist/chunks/rules-IDUXVTPG.js +0 -89
  451. package/dist/chunks/schema-AV6BHGKY.js +0 -237
  452. package/dist/chunks/schema-QJVQTNB4.js +0 -381
  453. package/dist/chunks/set-L5NFQSCF.js +0 -250
  454. package/dist/chunks/setup-and-link-USSVDKCM.js +0 -65
  455. package/dist/chunks/stamp-AA7R3MZS.js +0 -16
  456. package/dist/chunks/tags-2NLUU4EC.js +0 -69
  457. package/dist/chunks/types-4GAJ7XQQ.js +0 -116
  458. package/dist/chunks/update-WGLBB65M.js +0 -224
  459. package/dist/chunks/vlt-builder-importer-USCFHWPL.js +0 -322
@@ -1,1892 +0,0 @@
1
- import { createRequire as __createRequire } from 'node:module';
2
- import { fileURLToPath as __fileURLToPath } from 'node:url';
3
- import { dirname as __dirname_ } from 'node:path';
4
- const require = __createRequire(import.meta.url);
5
- const __filename = __fileURLToPath(import.meta.url);
6
- const __dirname = __dirname_(__filename);
7
- import {
8
- formatCondition,
9
- formatTransform,
10
- isTargetTransform
11
- } from "./chunk-TSFWMUCY.js";
12
- import {
13
- output_manager_default
14
- } from "./chunk-2JIX6UMI.js";
15
- import {
16
- require_source
17
- } from "./chunk-S7KYDPEM.js";
18
- import {
19
- __toESM
20
- } from "./chunk-TZ2YI2VH.js";
21
-
22
- // src/util/routes/env.ts
23
- function extractEnvVarNames(value) {
24
- const names = /* @__PURE__ */ new Set();
25
- for (const m of value.matchAll(/\$\{?([A-Z_][A-Z0-9_]*)\}?/g)) {
26
- names.add(m[1]);
27
- }
28
- return Array.from(names);
29
- }
30
- function escapeRegex(value) {
31
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
32
- }
33
- function referencesEnvVar(value, name) {
34
- const escapedName = escapeRegex(name);
35
- return new RegExp(
36
- `\\$(?:\\{${escapedName}\\}|${escapedName}(?![A-Za-z0-9_]))`
37
- ).test(value);
38
- }
39
- function referencesBracedEnvVar(value, name) {
40
- return new RegExp(`\\$\\{${escapeRegex(name)}\\}`).test(value);
41
- }
42
- function collectReferencedEnvVars(values, explicitEnv = [], excludedNames = /* @__PURE__ */ new Set()) {
43
- const names = new Set(
44
- explicitEnv.filter(
45
- (name) => values.some((value) => referencesEnvVar(value, name))
46
- )
47
- );
48
- for (const value of values) {
49
- for (const name of extractEnvVarNames(value)) {
50
- if (!excludedNames.has(name) || names.has(name) || referencesBracedEnvVar(value, name)) {
51
- names.add(name);
52
- }
53
- }
54
- }
55
- return Array.from(names);
56
- }
57
- function collectNamedRegexCaptures(source) {
58
- return new Set(
59
- Array.from(
60
- source.matchAll(/\(\?<([a-zA-Z][a-zA-Z0-9_]*)>/g),
61
- (match) => match[1]
62
- )
63
- );
64
- }
65
- function populateRouteEnv(route, srcSyntax = "regex") {
66
- const excludedNames = srcSyntax === "regex" && route.src ? collectNamedRegexCaptures(route.src) : /* @__PURE__ */ new Set();
67
- const routeValues = [
68
- ...route.dest ? [route.dest] : [],
69
- ...Object.values(route.headers || {})
70
- ];
71
- const routeEnv = collectReferencedEnvVars(
72
- routeValues,
73
- route.env,
74
- excludedNames
75
- );
76
- route.env = routeEnv.length > 0 ? routeEnv : void 0;
77
- if (route.transforms) {
78
- for (const transform of route.transforms) {
79
- const args = transform.args ? Array.isArray(transform.args) ? transform.args : [transform.args] : [];
80
- const names = collectReferencedEnvVars(
81
- args,
82
- transform.env,
83
- excludedNames
84
- );
85
- transform.env = names.length > 0 ? names : void 0;
86
- }
87
- }
88
- }
89
-
90
- // src/util/routes/generate-route.ts
91
- async function generateRoute(client, projectId, input, options = {}) {
92
- const { teamId } = options;
93
- const query = new URLSearchParams();
94
- if (teamId)
95
- query.set("teamId", teamId);
96
- const queryString = query.toString();
97
- const url = `/v1/projects/${projectId}/routes/generate${queryString ? `?${queryString}` : ""}`;
98
- return await client.fetch(url, {
99
- method: "POST",
100
- headers: {
101
- "Content-Type": "application/json"
102
- },
103
- body: JSON.stringify(input)
104
- });
105
- }
106
-
107
- // src/util/routes/parse-transforms.ts
108
- function parseTransforms(values, type, op) {
109
- return values.map((value) => parseTransform(value, type, op));
110
- }
111
- function parseTransform(input, type, op) {
112
- if (op === "delete") {
113
- const key2 = input.trim();
114
- if (!key2) {
115
- throw new Error("Delete operation requires a key");
116
- }
117
- return {
118
- type,
119
- op,
120
- target: { key: key2 }
121
- };
122
- }
123
- const eqIndex = input.indexOf("=");
124
- if (eqIndex === -1) {
125
- throw new Error(`Invalid format: "${input}". Expected format: key=value`);
126
- }
127
- const key = input.slice(0, eqIndex).trim();
128
- const args = input.slice(eqIndex + 1);
129
- if (!key) {
130
- throw new Error("Transform key cannot be empty");
131
- }
132
- return {
133
- type,
134
- op,
135
- target: { key },
136
- args
137
- };
138
- }
139
- function collectTransforms(flags) {
140
- const transforms = [];
141
- if (flags.setResponseHeader) {
142
- transforms.push(
143
- ...parseTransforms(flags.setResponseHeader, "response.headers", "set")
144
- );
145
- }
146
- if (flags.appendResponseHeader) {
147
- transforms.push(
148
- ...parseTransforms(
149
- flags.appendResponseHeader,
150
- "response.headers",
151
- "append"
152
- )
153
- );
154
- }
155
- if (flags.deleteResponseHeader) {
156
- transforms.push(
157
- ...parseTransforms(
158
- flags.deleteResponseHeader,
159
- "response.headers",
160
- "delete"
161
- )
162
- );
163
- }
164
- if (flags.setRequestHeader) {
165
- transforms.push(
166
- ...parseTransforms(flags.setRequestHeader, "request.headers", "set")
167
- );
168
- }
169
- if (flags.appendRequestHeader) {
170
- transforms.push(
171
- ...parseTransforms(flags.appendRequestHeader, "request.headers", "append")
172
- );
173
- }
174
- if (flags.deleteRequestHeader) {
175
- transforms.push(
176
- ...parseTransforms(flags.deleteRequestHeader, "request.headers", "delete")
177
- );
178
- }
179
- if (flags.setRequestQuery) {
180
- transforms.push(
181
- ...parseTransforms(flags.setRequestQuery, "request.query", "set")
182
- );
183
- }
184
- if (flags.appendRequestQuery) {
185
- transforms.push(
186
- ...parseTransforms(flags.appendRequestQuery, "request.query", "append")
187
- );
188
- }
189
- if (flags.deleteRequestQuery) {
190
- transforms.push(
191
- ...parseTransforms(flags.deleteRequestQuery, "request.query", "delete")
192
- );
193
- }
194
- return transforms;
195
- }
196
- function collectResponseHeaders(setHeaders) {
197
- const headers = {};
198
- for (const input of setHeaders) {
199
- const eqIndex = input.indexOf("=");
200
- if (eqIndex === -1) {
201
- throw new Error(
202
- `Invalid header format: "${input}". Expected format: key=value`
203
- );
204
- }
205
- const key = input.slice(0, eqIndex).trim();
206
- const value = input.slice(eqIndex + 1);
207
- if (!key) {
208
- throw new Error("Header key cannot be empty");
209
- }
210
- headers[key] = value;
211
- }
212
- return headers;
213
- }
214
-
215
- // src/util/routes/interactive.ts
216
- var MAX_NAME_LENGTH = 256;
217
- var MAX_DESCRIPTION_LENGTH = 1024;
218
- var MAX_CONDITIONS = 16;
219
- var VALID_SYNTAXES = [
220
- "regex",
221
- "path-to-regexp",
222
- "equals"
223
- ];
224
- var REDIRECT_STATUS_CODES = [301, 302, 303, 307, 308];
225
- var VALID_ACTION_TYPES = [
226
- "rewrite",
227
- "redirect",
228
- "set-status"
229
- ];
230
- var ALL_ACTION_CHOICES = [
231
- { name: "Rewrite", value: "rewrite", exclusive: true },
232
- { name: "Redirect", value: "redirect", exclusive: true },
233
- { name: "Set Status Code", value: "set-status", exclusive: true },
234
- { name: "Response Headers", value: "response-headers" },
235
- { name: "Request Headers", value: "request-headers" },
236
- { name: "Request Query", value: "request-query" }
237
- ];
238
- function stripQuotes(str) {
239
- if (str.startsWith('"') && str.endsWith('"') && str.length >= 2) {
240
- return str.slice(1, -1);
241
- }
242
- if (str.startsWith("'") && str.endsWith("'") && str.length >= 2) {
243
- return str.slice(1, -1);
244
- }
245
- return str;
246
- }
247
- function extractTransformFlags(flags) {
248
- return {
249
- setResponseHeader: flags["--set-response-header"],
250
- appendResponseHeader: flags["--append-response-header"],
251
- deleteResponseHeader: flags["--delete-response-header"],
252
- setRequestHeader: flags["--set-request-header"],
253
- appendRequestHeader: flags["--append-request-header"],
254
- deleteRequestHeader: flags["--delete-request-header"],
255
- setRequestQuery: flags["--set-request-query"],
256
- appendRequestQuery: flags["--append-request-query"],
257
- deleteRequestQuery: flags["--delete-request-query"]
258
- };
259
- }
260
- function collectHeadersAndTransforms(transformFlags) {
261
- const headers = transformFlags.setResponseHeader ? collectResponseHeaders(transformFlags.setResponseHeader) : {};
262
- const transforms = collectTransforms({
263
- ...transformFlags,
264
- setResponseHeader: void 0
265
- // Already handled in headers
266
- });
267
- return { headers, transforms };
268
- }
269
- function hasAnyTransformFlags(flags) {
270
- const tf = extractTransformFlags(flags);
271
- return !!(tf.setResponseHeader || tf.appendResponseHeader || tf.deleteResponseHeader || tf.setRequestHeader || tf.appendRequestHeader || tf.deleteRequestHeader || tf.setRequestQuery || tf.appendRequestQuery || tf.deleteRequestQuery);
272
- }
273
- function validateActionFlags(action, dest, status) {
274
- if (!action) {
275
- if (dest || status !== void 0) {
276
- return "--action is required when using --dest or --status. Use --action rewrite, --action redirect, or --action set-status.";
277
- }
278
- return null;
279
- }
280
- if (!VALID_ACTION_TYPES.includes(action)) {
281
- return `Invalid action type: "${action}". Valid types: ${VALID_ACTION_TYPES.join(", ")}`;
282
- }
283
- switch (action) {
284
- case "rewrite":
285
- if (!dest)
286
- return "--action rewrite requires --dest.";
287
- if (status !== void 0)
288
- return "--action rewrite does not accept --status.";
289
- break;
290
- case "redirect":
291
- if (!dest)
292
- return "--action redirect requires --dest.";
293
- if (status === void 0)
294
- return `--action redirect requires --status (${REDIRECT_STATUS_CODES.join(", ")}).`;
295
- if (!REDIRECT_STATUS_CODES.includes(status))
296
- return `Invalid redirect status: ${status}. Must be one of: ${REDIRECT_STATUS_CODES.join(", ")}`;
297
- break;
298
- case "set-status":
299
- if (dest)
300
- return "--action set-status does not accept --dest.";
301
- if (status === void 0)
302
- return "--action set-status requires --status.";
303
- if (status < 100 || status > 599)
304
- return "Status code must be between 100 and 599.";
305
- break;
306
- }
307
- return null;
308
- }
309
- async function collectActionDetails(client, actionType, flags) {
310
- switch (actionType) {
311
- case "rewrite": {
312
- const dest = await client.input.text({
313
- message: "Destination URL:",
314
- validate: (val) => val ? true : "Destination is required"
315
- });
316
- Object.assign(flags, { "--dest": dest });
317
- break;
318
- }
319
- case "redirect": {
320
- const dest = await client.input.text({
321
- message: "Destination URL:",
322
- validate: (val) => val ? true : "Destination is required"
323
- });
324
- const status = await client.input.select({
325
- message: "Status code:",
326
- choices: [
327
- { name: "307 - Temporary Redirect", value: 307 },
328
- { name: "308 - Permanent Redirect", value: 308 },
329
- { name: "301 - Moved Permanently", value: 301 },
330
- { name: "302 - Found", value: 302 },
331
- { name: "303 - See Other", value: 303 }
332
- ]
333
- });
334
- Object.assign(flags, { "--dest": dest, "--status": status });
335
- break;
336
- }
337
- case "set-status": {
338
- const statusCode = await client.input.text({
339
- message: "HTTP status code:",
340
- validate: (val) => {
341
- const num = parseInt(val, 10);
342
- if (isNaN(num) || num < 100 || num > 599) {
343
- return "Status code must be between 100 and 599";
344
- }
345
- return true;
346
- }
347
- });
348
- Object.assign(flags, { "--status": parseInt(statusCode, 10) });
349
- break;
350
- }
351
- case "response-headers": {
352
- await collectInteractiveHeaders(client, "response", flags);
353
- break;
354
- }
355
- case "request-headers": {
356
- await collectInteractiveHeaders(client, "request-header", flags);
357
- break;
358
- }
359
- case "request-query": {
360
- await collectInteractiveHeaders(client, "request-query", flags);
361
- break;
362
- }
363
- }
364
- }
365
- async function collectInteractiveConditions(client, flags) {
366
- let addMore = true;
367
- while (addMore) {
368
- const currentHas = flags["--has"] || [];
369
- const currentMissing = flags["--missing"] || [];
370
- if (currentHas.length > 0 || currentMissing.length > 0) {
371
- output_manager_default.log("\nCurrent conditions:");
372
- for (const c of currentHas) {
373
- output_manager_default.print(` has: ${c}
374
- `);
375
- }
376
- for (const c of currentMissing) {
377
- output_manager_default.print(` does not have: ${c}
378
- `);
379
- }
380
- output_manager_default.print("\n");
381
- }
382
- const conditionType = await client.input.select({
383
- message: "Condition type:",
384
- choices: [
385
- { name: "has - Request must have this", value: "has" },
386
- {
387
- name: "does not have - Request must NOT have this",
388
- value: "missing"
389
- }
390
- ]
391
- });
392
- const targetType = await client.input.select({
393
- message: "What to check:",
394
- choices: [
395
- { name: "Header", value: "header" },
396
- { name: "Cookie", value: "cookie" },
397
- { name: "Query Parameter", value: "query" },
398
- { name: "Host", value: "host" }
399
- ]
400
- });
401
- let conditionValue;
402
- if (targetType === "host") {
403
- const operator = await client.input.select({
404
- message: "How to match the host:",
405
- choices: [
406
- { name: "Equals", value: "eq" },
407
- { name: "Contains", value: "contains" },
408
- { name: "Matches (regex)", value: "re" }
409
- ]
410
- });
411
- const hostInput = await client.input.text({
412
- message: operator === "re" ? "Host pattern (regex):" : "Host value:",
413
- validate: (val) => {
414
- if (!val)
415
- return "Host value is required";
416
- if (operator === "re") {
417
- try {
418
- new RegExp(val);
419
- return true;
420
- } catch {
421
- return "Invalid regex pattern";
422
- }
423
- }
424
- return true;
425
- }
426
- });
427
- conditionValue = `host:${operator}=${hostInput}`;
428
- } else {
429
- const key = await client.input.text({
430
- message: `${targetType.charAt(0).toUpperCase() + targetType.slice(1)} name:`,
431
- validate: (val) => val ? true : `${targetType} name is required`
432
- });
433
- const operator = await client.input.select({
434
- message: "How to match the value:",
435
- choices: [
436
- { name: "Exists (any value)", value: "exists" },
437
- { name: "Equals", value: "eq" },
438
- { name: "Contains", value: "contains" },
439
- { name: "Matches (regex)", value: "re" }
440
- ]
441
- });
442
- if (operator === "exists") {
443
- conditionValue = `${targetType}:${key}:exists`;
444
- } else {
445
- const valueInput = await client.input.text({
446
- message: operator === "re" ? "Value pattern (regex):" : "Value:",
447
- validate: (val) => {
448
- if (!val)
449
- return "Value is required";
450
- if (operator === "re") {
451
- try {
452
- new RegExp(val);
453
- return true;
454
- } catch {
455
- return "Invalid regex pattern";
456
- }
457
- }
458
- return true;
459
- }
460
- });
461
- conditionValue = `${targetType}:${key}:${operator}=${valueInput}`;
462
- }
463
- }
464
- const flagName = conditionType === "has" ? "--has" : "--missing";
465
- const existing = flags[flagName] || [];
466
- flags[flagName] = [...existing, conditionValue];
467
- const totalConditions = (flags["--has"] || []).length + (flags["--missing"] || []).length;
468
- if (totalConditions >= MAX_CONDITIONS) {
469
- output_manager_default.warn(`Maximum ${MAX_CONDITIONS} conditions reached.`);
470
- break;
471
- }
472
- addMore = await client.input.confirm("Add another condition?", false);
473
- }
474
- }
475
- function formatCollectedItems(flags, type) {
476
- const items = [];
477
- const prefix = type === "response" ? "response-header" : type === "request-header" ? "request-header" : "request-query";
478
- const setItems = flags[`--set-${prefix}`] || [];
479
- const appendItems = flags[`--append-${prefix}`] || [];
480
- const deleteItems = flags[`--delete-${prefix}`] || [];
481
- for (const item of setItems) {
482
- items.push(` set: ${item}`);
483
- }
484
- for (const item of appendItems) {
485
- items.push(` append: ${item}`);
486
- }
487
- for (const item of deleteItems) {
488
- items.push(` delete: ${item}`);
489
- }
490
- return items;
491
- }
492
- async function collectInteractiveHeaders(client, type, flags) {
493
- const flagName = type === "response" ? "--set-response-header" : type === "request-header" ? "--set-request-header" : "--set-request-query";
494
- const sectionName = type === "response" ? "Response Headers" : type === "request-header" ? "Request Headers" : "Request Query Parameters";
495
- const itemName = type === "response" ? "response header" : type === "request-header" ? "request header" : "query parameter";
496
- output_manager_default.log(`
497
- --- ${sectionName} ---`);
498
- let addMore = true;
499
- while (addMore) {
500
- const collected = formatCollectedItems(flags, type);
501
- if (collected.length > 0) {
502
- output_manager_default.log(`
503
- Current ${sectionName.toLowerCase()}:`);
504
- for (const item of collected) {
505
- output_manager_default.print(`${item}
506
- `);
507
- }
508
- output_manager_default.print("\n");
509
- }
510
- const op = await client.input.select({
511
- message: `${sectionName} operation:`,
512
- choices: [
513
- { name: "Set", value: "set" },
514
- { name: "Append", value: "append" },
515
- { name: "Delete", value: "delete" }
516
- ]
517
- });
518
- const key = await client.input.text({
519
- message: `${itemName.charAt(0).toUpperCase() + itemName.slice(1)} name:`,
520
- validate: (val) => val ? true : `${itemName} name is required`
521
- });
522
- if (op === "delete") {
523
- const opFlagName = flagName.replace("--set-", "--delete-");
524
- const existing = flags[opFlagName] || [];
525
- flags[opFlagName] = [...existing, key];
526
- } else {
527
- const value = await client.input.text({
528
- message: `${itemName.charAt(0).toUpperCase() + itemName.slice(1)} value:`
529
- });
530
- const opFlagName = op === "append" ? flagName.replace("--set-", "--append-") : flagName;
531
- const existing = flags[opFlagName] || [];
532
- flags[opFlagName] = [...existing, `${key}=${value}`];
533
- }
534
- addMore = await client.input.confirm(`Add another ${itemName}?`, false);
535
- }
536
- }
537
-
538
- // src/util/routes/ai-transform.ts
539
- var import_chalk = __toESM(require_source(), 1);
540
-
541
- // src/util/routes/parse-conditions.ts
542
- var CONDITION_OPERATORS = [
543
- "eq",
544
- "contains",
545
- "re",
546
- "exists"
547
- ];
548
- function escapeRegExp(str) {
549
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
550
- }
551
- function buildConditionValue(operator, value) {
552
- if (operator === "exists")
553
- return void 0;
554
- if (operator === "re")
555
- return value;
556
- const escapedValue = escapeRegExp(value);
557
- if (operator === "contains")
558
- return `.*${escapedValue}.*`;
559
- return `^${escapedValue}$`;
560
- }
561
- function validateRegexPattern(pattern, context) {
562
- try {
563
- new RegExp(pattern);
564
- } catch (e) {
565
- throw new Error(
566
- `Invalid regex in ${context}: "${pattern}". ${e instanceof Error ? e.message : ""}`
567
- );
568
- }
569
- }
570
- function parseOperatorValue(valuePart) {
571
- if (valuePart === "exists") {
572
- return { operator: "exists", rawValue: "" };
573
- }
574
- const eqIdx = valuePart.indexOf("=");
575
- if (eqIdx === -1)
576
- return null;
577
- const maybeOp = valuePart.slice(0, eqIdx);
578
- if (CONDITION_OPERATORS.includes(maybeOp)) {
579
- return {
580
- operator: maybeOp,
581
- rawValue: valuePart.slice(eqIdx + 1)
582
- };
583
- }
584
- return null;
585
- }
586
- function parseConditions(conditions) {
587
- return conditions.map(parseCondition);
588
- }
589
- function parseCondition(condition) {
590
- const parts = condition.split(":");
591
- if (parts.length < 2) {
592
- throw new Error(
593
- `Invalid condition format: "${condition}". Expected format: type:key or type:key:value`
594
- );
595
- }
596
- const type = parts[0].toLowerCase();
597
- const validTypes = ["header", "cookie", "query", "host"];
598
- if (!validTypes.includes(type)) {
599
- throw new Error(
600
- `Invalid condition type: "${type}". Valid types: ${validTypes.join(", ")}`
601
- );
602
- }
603
- if (type === "host") {
604
- const rawValue = parts.slice(1).join(":");
605
- if (!rawValue) {
606
- throw new Error("Host condition requires a value");
607
- }
608
- const opResult2 = parseOperatorValue(rawValue);
609
- if (opResult2) {
610
- if (opResult2.operator === "exists") {
611
- throw new Error(
612
- 'Host condition does not support "exists" operator (host always has a value)'
613
- );
614
- }
615
- if (opResult2.operator !== "re" && !opResult2.rawValue) {
616
- throw new Error(
617
- `Host condition with "${opResult2.operator}" operator requires a value`
618
- );
619
- }
620
- const compiledValue = buildConditionValue(
621
- opResult2.operator,
622
- opResult2.rawValue
623
- );
624
- if (compiledValue !== void 0) {
625
- validateRegexPattern(compiledValue, "host condition");
626
- }
627
- return { type: "host", value: compiledValue };
628
- }
629
- validateRegexPattern(rawValue, "host condition");
630
- return { type: "host", value: rawValue };
631
- }
632
- const key = parts[1];
633
- if (!key) {
634
- throw new Error(`${type} condition requires a key`);
635
- }
636
- const valuePart = parts.length > 2 ? parts.slice(2).join(":") : void 0;
637
- if (valuePart === void 0) {
638
- return { type, key };
639
- }
640
- const opResult = parseOperatorValue(valuePart);
641
- if (opResult) {
642
- if (opResult.operator === "exists") {
643
- return { type, key };
644
- }
645
- if (opResult.operator !== "re" && !opResult.rawValue) {
646
- throw new Error(
647
- `Condition "${opResult.operator}" operator requires a value after "="`
648
- );
649
- }
650
- const compiledValue = buildConditionValue(
651
- opResult.operator,
652
- opResult.rawValue
653
- );
654
- if (compiledValue !== void 0) {
655
- validateRegexPattern(compiledValue, `${type} condition value`);
656
- }
657
- return {
658
- type,
659
- key,
660
- ...compiledValue !== void 0 && { value: compiledValue }
661
- };
662
- }
663
- validateRegexPattern(valuePart, `${type} condition value`);
664
- return {
665
- type,
666
- key,
667
- value: valuePart
668
- };
669
- }
670
- function formatCondition2(field) {
671
- if (field.type === "host") {
672
- return `host:${field.value}`;
673
- }
674
- if (field.value) {
675
- return `${field.type}:${field.key}:${field.value}`;
676
- }
677
- return `${field.type}:${field.key}`;
678
- }
679
-
680
- // src/util/routes/ai-transform.ts
681
- function isTargetTransformType(transform, type) {
682
- return transform.type === type && isTargetTransform(transform);
683
- }
684
- function stringifyTransformArgs(args) {
685
- return Array.isArray(args) ? args.join(", ") : args;
686
- }
687
- function isPathTransform(transform) {
688
- return transform.type === "request.path";
689
- }
690
- function generatedRouteToAddInput(generated) {
691
- const hasConditions = [];
692
- const missingConditions = [];
693
- const headers = {};
694
- const transforms = [];
695
- let dest;
696
- let status;
697
- if (generated.conditions) {
698
- for (const c of generated.conditions) {
699
- const compiledValue = c.value !== void 0 ? buildConditionValue(c.operator, c.value) : void 0;
700
- const field = c.field === "host" ? { type: "host", value: compiledValue ?? c.value ?? "" } : {
701
- type: c.field,
702
- key: c.key ?? "",
703
- ...compiledValue !== void 0 && { value: compiledValue }
704
- };
705
- if (c.missing) {
706
- missingConditions.push(field);
707
- } else {
708
- hasConditions.push(field);
709
- }
710
- }
711
- }
712
- for (const action of generated.actions) {
713
- switch (action.type) {
714
- case "rewrite":
715
- dest = action.dest;
716
- break;
717
- case "redirect":
718
- dest = action.dest;
719
- status = action.status;
720
- break;
721
- case "set-status":
722
- status = action.status;
723
- break;
724
- case "modify": {
725
- if (action.subType === "transform-request-path") {
726
- if (!action.requestPath)
727
- break;
728
- transforms.push({
729
- type: "request.path",
730
- op: action.requestPath.op,
731
- args: action.requestPath.value,
732
- ...action.requestPath.env && { env: action.requestPath.env }
733
- });
734
- } else if (action.subType === "response-headers" && action.headers) {
735
- for (const h of action.headers) {
736
- if (h.op === "set") {
737
- headers[h.key] = h.value ?? "";
738
- } else {
739
- transforms.push({
740
- type: "response.headers",
741
- op: h.op,
742
- target: { key: h.key },
743
- ...h.op !== "delete" && h.value && { args: h.value }
744
- });
745
- }
746
- }
747
- } else if (action.subType === "transform-request-header" && action.headers) {
748
- for (const h of action.headers) {
749
- transforms.push({
750
- type: "request.headers",
751
- op: h.op,
752
- target: { key: h.key },
753
- ...h.op !== "delete" && h.value && { args: h.value }
754
- });
755
- }
756
- } else if (action.subType === "transform-request-query" && action.headers) {
757
- for (const h of action.headers) {
758
- transforms.push({
759
- type: "request.query",
760
- op: h.op,
761
- target: { key: h.key },
762
- ...h.op !== "delete" && h.value && { args: h.value }
763
- });
764
- }
765
- }
766
- break;
767
- }
768
- }
769
- }
770
- return {
771
- name: generated.name,
772
- description: generated.description || void 0,
773
- srcSyntax: generated.pathCondition.syntax,
774
- route: {
775
- src: generated.pathCondition.value,
776
- ...dest !== void 0 && { dest },
777
- ...status !== void 0 && { status },
778
- ...Object.keys(headers).length > 0 && { headers },
779
- ...transforms.length > 0 && { transforms },
780
- ...hasConditions.length > 0 && { has: hasConditions },
781
- ...missingConditions.length > 0 && { missing: missingConditions }
782
- }
783
- };
784
- }
785
- function convertRouteToCurrentRoute(generated) {
786
- return {
787
- name: generated.name,
788
- description: generated.description || void 0,
789
- pathCondition: generated.pathCondition,
790
- conditions: generated.conditions,
791
- actions: generated.actions
792
- };
793
- }
794
- function routingRuleToCurrentRoute(rule) {
795
- const conditions = [];
796
- const actions = [];
797
- if (rule.route.has) {
798
- for (const c of rule.route.has) {
799
- conditions.push({
800
- field: c.type,
801
- operator: c.value !== void 0 ? "re" : "exists",
802
- key: c.key,
803
- value: c.value !== void 0 ? typeof c.value === "string" ? c.value : JSON.stringify(c.value) : void 0,
804
- missing: false
805
- });
806
- }
807
- }
808
- if (rule.route.missing) {
809
- for (const c of rule.route.missing) {
810
- conditions.push({
811
- field: c.type,
812
- operator: c.value !== void 0 ? "re" : "exists",
813
- key: c.key,
814
- value: c.value !== void 0 ? typeof c.value === "string" ? c.value : JSON.stringify(c.value) : void 0,
815
- missing: true
816
- });
817
- }
818
- }
819
- const isRedirect = rule.route.dest && rule.route.status && REDIRECT_STATUS_CODES.includes(rule.route.status);
820
- if (isRedirect) {
821
- actions.push({
822
- type: "redirect",
823
- dest: rule.route.dest,
824
- status: rule.route.status
825
- });
826
- } else if (rule.route.dest) {
827
- actions.push({ type: "rewrite", dest: rule.route.dest });
828
- } else if (rule.route.status) {
829
- actions.push({ type: "set-status", status: rule.route.status });
830
- }
831
- const responseHeaders = rule.route.headers ? Object.entries(rule.route.headers).map(([key, value]) => ({
832
- key,
833
- value,
834
- op: "set"
835
- })) : [];
836
- const allTransforms = rule.route.transforms ?? [];
837
- const responseHeaderTransforms = allTransforms.filter((t) => isTargetTransformType(t, "response.headers")).map((t) => ({
838
- key: typeof t.target.key === "string" ? t.target.key : String(t.target.key),
839
- value: stringifyTransformArgs(t.args),
840
- op: t.op
841
- }));
842
- const allResponseHeaders = [...responseHeaders, ...responseHeaderTransforms];
843
- if (allResponseHeaders.length > 0) {
844
- actions.push({
845
- type: "modify",
846
- subType: "response-headers",
847
- headers: allResponseHeaders
848
- });
849
- }
850
- const requestHeaders = allTransforms.filter((t) => isTargetTransformType(t, "request.headers")).map((t) => ({
851
- key: typeof t.target.key === "string" ? t.target.key : String(t.target.key),
852
- value: stringifyTransformArgs(t.args),
853
- op: t.op
854
- }));
855
- if (requestHeaders.length > 0) {
856
- actions.push({
857
- type: "modify",
858
- subType: "transform-request-header",
859
- headers: requestHeaders
860
- });
861
- }
862
- const requestQuery = allTransforms.filter((t) => isTargetTransformType(t, "request.query")).map((t) => ({
863
- key: typeof t.target.key === "string" ? t.target.key : String(t.target.key),
864
- value: stringifyTransformArgs(t.args),
865
- op: t.op
866
- }));
867
- if (requestQuery.length > 0) {
868
- actions.push({
869
- type: "modify",
870
- subType: "transform-request-query",
871
- headers: requestQuery
872
- });
873
- }
874
- const requestPathTransforms = allTransforms.filter(isPathTransform);
875
- for (const requestPath of requestPathTransforms) {
876
- actions.push({
877
- type: "modify",
878
- subType: "transform-request-path",
879
- requestPath: {
880
- value: requestPath.args,
881
- op: requestPath.op,
882
- ...requestPath.env && { env: requestPath.env }
883
- }
884
- });
885
- }
886
- return {
887
- name: rule.name,
888
- description: rule.description,
889
- pathCondition: {
890
- value: rule.route.src,
891
- syntax: rule.srcSyntax ?? "regex"
892
- },
893
- ...conditions.length > 0 && { conditions },
894
- actions
895
- };
896
- }
897
- function printGeneratedRoutePreview(generated) {
898
- output_manager_default.print("\n");
899
- output_manager_default.print(` ${import_chalk.default.bold("Generated Route:")}
900
- `);
901
- output_manager_default.print(` ${import_chalk.default.cyan("Name:")} ${generated.name}
902
- `);
903
- if (generated.description) {
904
- output_manager_default.print(` ${import_chalk.default.cyan("Description:")} ${generated.description}
905
- `);
906
- }
907
- output_manager_default.print(
908
- ` ${import_chalk.default.cyan("Source:")} ${generated.pathCondition.value}
909
- `
910
- );
911
- if (generated.conditions && generated.conditions.length > 0) {
912
- output_manager_default.print(` ${import_chalk.default.cyan("Conditions:")}
913
- `);
914
- for (const c of generated.conditions) {
915
- const prefix = c.missing ? "does not have" : "has";
916
- const operatorLabel = c.operator === "eq" ? "equal to" : c.operator === "contains" ? "containing" : c.operator === "re" ? "matching" : "";
917
- const key = c.key ? ` ${import_chalk.default.cyan(`"${c.key}"`)}` : "";
918
- const value = c.operator === "exists" || !c.value ? "" : ` ${operatorLabel} ${import_chalk.default.cyan(`"${c.value}"`)}`;
919
- output_manager_default.print(` ${import_chalk.default.gray(prefix)} ${c.field}${key}${value}
920
- `);
921
- }
922
- }
923
- for (const action of generated.actions) {
924
- if (action.type === "rewrite" && action.dest) {
925
- output_manager_default.print(
926
- ` ${import_chalk.default.cyan("Action:")} Rewrite \u2192 ${action.dest}
927
- `
928
- );
929
- } else if (action.type === "redirect" && action.dest) {
930
- output_manager_default.print(
931
- ` ${import_chalk.default.cyan("Action:")} Redirect \u2192 ${action.dest} (${action.status})
932
- `
933
- );
934
- } else if (action.type === "set-status" && action.status) {
935
- output_manager_default.print(
936
- ` ${import_chalk.default.cyan("Action:")} Set Status ${action.status}
937
- `
938
- );
939
- }
940
- }
941
- for (const action of generated.actions) {
942
- if (action.type === "modify" && action.subType === "transform-request-path" && action.requestPath) {
943
- output_manager_default.print(` ${import_chalk.default.cyan("Request Path:")}
944
- `);
945
- const env = action.requestPath.env?.length ? import_chalk.default.gray(` (env: ${action.requestPath.env.join(", ")})`) : "";
946
- output_manager_default.print(
947
- ` ${import_chalk.default.yellow(action.requestPath.op)} ${import_chalk.default.cyan("path")} = ${action.requestPath.value}${env}
948
- `
949
- );
950
- } else if (action.type === "modify" && action.headers) {
951
- const label = action.subType === "response-headers" ? "Response Headers" : action.subType === "transform-request-header" ? "Request Headers" : "Request Query";
952
- output_manager_default.print(` ${import_chalk.default.cyan(`${label}:`)}
953
- `);
954
- for (const h of action.headers) {
955
- if (h.op === "delete") {
956
- output_manager_default.print(` ${import_chalk.default.yellow(h.op)} ${import_chalk.default.cyan(h.key)}
957
- `);
958
- } else {
959
- output_manager_default.print(
960
- ` ${import_chalk.default.yellow(h.op)} ${import_chalk.default.cyan(h.key)} = ${h.value}
961
- `
962
- );
963
- }
964
- }
965
- }
966
- }
967
- output_manager_default.print("\n");
968
- }
969
-
970
- // src/commands/routes/edit-interactive.ts
971
- var import_chalk2 = __toESM(require_source(), 1);
972
- function getPrimaryActionType(route) {
973
- const { dest, status } = route.route;
974
- if (dest && status && REDIRECT_STATUS_CODES.includes(status)) {
975
- return "redirect";
976
- }
977
- if (dest)
978
- return "rewrite";
979
- if (status)
980
- return "set-status";
981
- return null;
982
- }
983
- function getPrimaryActionLabel(route) {
984
- const actionType = getPrimaryActionType(route);
985
- switch (actionType) {
986
- case "rewrite":
987
- return `Rewrite \u2192 ${route.route.dest}`;
988
- case "redirect":
989
- return `Redirect \u2192 ${route.route.dest} (${route.route.status})`;
990
- case "set-status":
991
- return `Set Status ${route.route.status}`;
992
- default:
993
- return "(none)";
994
- }
995
- }
996
- function getResponseHeaders(route) {
997
- const headers = route.route.headers ?? {};
998
- return Object.entries(headers).map(([key, value]) => ({ key, value }));
999
- }
1000
- function getTransformsByType(route, type) {
1001
- const transforms = route.route.transforms ?? [];
1002
- return transforms.filter((t) => t.type === type);
1003
- }
1004
- function printRouteConfig(route) {
1005
- output_manager_default.print("\n");
1006
- output_manager_default.print(` ${import_chalk2.default.cyan("Name:")} ${route.name}
1007
- `);
1008
- if (route.description) {
1009
- output_manager_default.print(` ${import_chalk2.default.cyan("Description:")} ${route.description}
1010
- `);
1011
- }
1012
- output_manager_default.print(
1013
- ` ${import_chalk2.default.cyan("Source:")} ${route.route.src} ${import_chalk2.default.gray(`(${route.srcSyntax ?? "regex"})`)}
1014
- `
1015
- );
1016
- output_manager_default.print(
1017
- ` ${import_chalk2.default.cyan("Status:")} ${route.enabled === false ? import_chalk2.default.red("Disabled") : import_chalk2.default.green("Enabled")}
1018
- `
1019
- );
1020
- const actionLabel = getPrimaryActionLabel(route);
1021
- output_manager_default.print(` ${import_chalk2.default.cyan("Action:")} ${actionLabel}
1022
- `);
1023
- const hasConds = route.route.has ?? [];
1024
- if (hasConds.length > 0) {
1025
- output_manager_default.print(`
1026
- ${import_chalk2.default.cyan("Has conditions:")}
1027
- `);
1028
- for (const c of hasConds) {
1029
- output_manager_default.print(` ${formatCondition(c)}
1030
- `);
1031
- }
1032
- }
1033
- const missingConds = route.route.missing ?? [];
1034
- if (missingConds.length > 0) {
1035
- output_manager_default.print(`
1036
- ${import_chalk2.default.cyan("Does not have conditions:")}
1037
- `);
1038
- for (const c of missingConds) {
1039
- output_manager_default.print(` ${formatCondition(c)}
1040
- `);
1041
- }
1042
- }
1043
- const responseHeaders = getResponseHeaders(route);
1044
- if (responseHeaders.length > 0) {
1045
- output_manager_default.print(`
1046
- ${import_chalk2.default.cyan("Response Headers:")}
1047
- `);
1048
- for (const h of responseHeaders) {
1049
- output_manager_default.print(` ${import_chalk2.default.cyan(h.key)} = ${h.value}
1050
- `);
1051
- }
1052
- }
1053
- const requestHeaders = getTransformsByType(route, "request.headers");
1054
- if (requestHeaders.length > 0) {
1055
- output_manager_default.print(`
1056
- ${import_chalk2.default.cyan("Request Headers:")}
1057
- `);
1058
- for (const t of requestHeaders) {
1059
- output_manager_default.print(` ${formatTransform(t)}
1060
- `);
1061
- }
1062
- }
1063
- const requestQuery = getTransformsByType(route, "request.query");
1064
- if (requestQuery.length > 0) {
1065
- output_manager_default.print(`
1066
- ${import_chalk2.default.cyan("Request Query:")}
1067
- `);
1068
- for (const t of requestQuery) {
1069
- output_manager_default.print(` ${formatTransform(t)}
1070
- `);
1071
- }
1072
- }
1073
- const requestPaths = getTransformsByType(route, "request.path");
1074
- if (requestPaths.length > 0) {
1075
- output_manager_default.print(`
1076
- ${import_chalk2.default.cyan("Request Path:")}
1077
- `);
1078
- for (const transform of requestPaths) {
1079
- const env = transform.env?.length ? import_chalk2.default.gray(` (env: ${transform.env.join(", ")})`) : "";
1080
- output_manager_default.print(` ${formatTransform(transform)}${env}
1081
- `);
1082
- }
1083
- }
1084
- output_manager_default.print("\n");
1085
- }
1086
- function cloneRoute(route) {
1087
- return JSON.parse(JSON.stringify(route));
1088
- }
1089
- function applyFlagMutations(route, flags) {
1090
- if (flags["--name"] !== void 0) {
1091
- const name = flags["--name"];
1092
- if (name.length > MAX_NAME_LENGTH) {
1093
- return `Name must be ${MAX_NAME_LENGTH} characters or less.`;
1094
- }
1095
- route.name = name;
1096
- }
1097
- if (flags["--description"] !== void 0) {
1098
- const desc = flags["--description"];
1099
- if (desc.length > MAX_DESCRIPTION_LENGTH) {
1100
- return `Description must be ${MAX_DESCRIPTION_LENGTH} characters or less.`;
1101
- }
1102
- route.description = desc || void 0;
1103
- }
1104
- if (flags["--src"] !== void 0) {
1105
- route.route.src = stripQuotes(flags["--src"]);
1106
- }
1107
- if (flags["--src-syntax"] !== void 0) {
1108
- const syntax = flags["--src-syntax"];
1109
- if (!VALID_SYNTAXES.includes(syntax)) {
1110
- return `Invalid syntax: "${syntax}". Valid options: ${VALID_SYNTAXES.join(", ")}`;
1111
- }
1112
- route.srcSyntax = syntax;
1113
- }
1114
- const actionFlag = flags["--action"];
1115
- const destFlag = flags["--dest"];
1116
- const statusFlag = flags["--status"];
1117
- const noDest = flags["--no-dest"];
1118
- const noStatus = flags["--no-status"];
1119
- if (actionFlag) {
1120
- if (!VALID_ACTION_TYPES.includes(actionFlag)) {
1121
- return `Invalid action type: "${actionFlag}". Valid types: ${VALID_ACTION_TYPES.join(", ")}`;
1122
- }
1123
- switch (actionFlag) {
1124
- case "rewrite": {
1125
- const dest = destFlag ? stripQuotes(destFlag) : void 0;
1126
- if (!dest)
1127
- return "--action rewrite requires --dest.";
1128
- route.route.dest = dest;
1129
- delete route.route.status;
1130
- break;
1131
- }
1132
- case "redirect": {
1133
- const dest = destFlag ? stripQuotes(destFlag) : void 0;
1134
- if (!dest)
1135
- return "--action redirect requires --dest.";
1136
- if (statusFlag === void 0)
1137
- return `--action redirect requires --status (${REDIRECT_STATUS_CODES.join(", ")}).`;
1138
- if (!REDIRECT_STATUS_CODES.includes(statusFlag))
1139
- return `Invalid redirect status: ${statusFlag}. Must be one of: ${REDIRECT_STATUS_CODES.join(", ")}`;
1140
- route.route.dest = dest;
1141
- route.route.status = statusFlag;
1142
- break;
1143
- }
1144
- case "set-status": {
1145
- if (statusFlag === void 0)
1146
- return "--action set-status requires --status.";
1147
- if (statusFlag < 100 || statusFlag > 599)
1148
- return "Status code must be between 100 and 599.";
1149
- delete route.route.dest;
1150
- route.route.status = statusFlag;
1151
- break;
1152
- }
1153
- }
1154
- } else {
1155
- if (destFlag !== void 0) {
1156
- route.route.dest = stripQuotes(destFlag);
1157
- }
1158
- if (statusFlag !== void 0) {
1159
- route.route.status = statusFlag;
1160
- }
1161
- if (noDest) {
1162
- delete route.route.dest;
1163
- }
1164
- if (noStatus) {
1165
- delete route.route.status;
1166
- }
1167
- }
1168
- if (flags["--clear-conditions"]) {
1169
- route.route.has = [];
1170
- route.route.missing = [];
1171
- }
1172
- if (flags["--clear-headers"]) {
1173
- route.route.headers = {};
1174
- }
1175
- if (flags["--clear-transforms"]) {
1176
- route.route.transforms = [];
1177
- }
1178
- const transformFlags = extractTransformFlags(flags);
1179
- try {
1180
- const { headers, transforms } = collectHeadersAndTransforms(transformFlags);
1181
- if (Object.keys(headers).length > 0) {
1182
- route.route.headers = {
1183
- ...route.route.headers ?? {},
1184
- ...headers
1185
- };
1186
- }
1187
- if (transforms.length > 0) {
1188
- const existing = route.route.transforms ?? [];
1189
- route.route.transforms = [...existing, ...transforms];
1190
- }
1191
- } catch (e) {
1192
- return `Invalid transform format. ${e instanceof Error ? e.message : ""}`;
1193
- }
1194
- const hasFlags = flags["--has"];
1195
- const missingFlags = flags["--missing"];
1196
- try {
1197
- if (hasFlags) {
1198
- const newHas = parseConditions(hasFlags);
1199
- const existingHas = route.route.has ?? [];
1200
- route.route.has = [...existingHas, ...newHas];
1201
- }
1202
- if (missingFlags) {
1203
- const newMissing = parseConditions(missingFlags);
1204
- const existingMissing = route.route.missing ?? [];
1205
- route.route.missing = [...existingMissing, ...newMissing];
1206
- }
1207
- } catch (e) {
1208
- return e instanceof Error ? e.message : "Invalid condition format";
1209
- }
1210
- const totalConditions = (route.route.has ?? []).length + (route.route.missing ?? []).length;
1211
- if (totalConditions > MAX_CONDITIONS) {
1212
- return `Too many conditions: ${totalConditions}. Maximum is ${MAX_CONDITIONS}.`;
1213
- }
1214
- const hasDest = !!route.route.dest;
1215
- const hasStatus = !!route.route.status;
1216
- const hasHeaders = Object.keys(route.route.headers ?? {}).length > 0;
1217
- const hasTransforms = (route.route.transforms ?? []).length > 0;
1218
- if (!hasDest && !hasStatus && !hasHeaders && !hasTransforms) {
1219
- return "This edit would leave the route with no action. Add --action, headers, or transforms.";
1220
- }
1221
- return null;
1222
- }
1223
- async function runInteractiveEditLoop(client, route) {
1224
- for (; ; ) {
1225
- const hasConds = (route.route.has ?? []).length;
1226
- const missingConds = (route.route.missing ?? []).length;
1227
- const responseHeaders = getAllResponseHeaders(route).length;
1228
- const requestHeaders = getTransformsByType(route, "request.headers").length;
1229
- const requestQuery = getTransformsByType(route, "request.query").length;
1230
- const requestPaths = getTransformsByType(route, "request.path").length;
1231
- const syntaxLabel = route.srcSyntax === "path-to-regexp" ? "Pattern" : route.srcSyntax === "equals" ? "Exact" : "Regex";
1232
- const descriptionPreview = route.description ? route.description.length > 40 ? route.description.slice(0, 40) + "..." : route.description : "";
1233
- const editChoices = [
1234
- { name: `Name (${route.name})`, value: "name" },
1235
- {
1236
- name: descriptionPreview ? `Description (${descriptionPreview})` : "Description",
1237
- value: "description"
1238
- },
1239
- {
1240
- name: `Source (${syntaxLabel}: ${route.route.src})`,
1241
- value: "source"
1242
- },
1243
- {
1244
- name: `Primary action (${getPrimaryActionLabel(route)})`,
1245
- value: "action"
1246
- },
1247
- {
1248
- name: `Conditions (${hasConds} has, ${missingConds} missing)`,
1249
- value: "conditions"
1250
- },
1251
- {
1252
- name: `Response Headers (${responseHeaders})`,
1253
- value: "response-headers"
1254
- },
1255
- {
1256
- name: `Request Headers (${requestHeaders})`,
1257
- value: "request-headers"
1258
- },
1259
- {
1260
- name: `Request Query (${requestQuery})`,
1261
- value: "request-query"
1262
- },
1263
- {
1264
- name: `Request Path (${requestPaths})`,
1265
- value: "request-path"
1266
- },
1267
- { name: "Done - save changes", value: "done" }
1268
- ];
1269
- const choice = await client.input.select({
1270
- message: "What would you like to edit?",
1271
- choices: editChoices,
1272
- pageSize: editChoices.length,
1273
- loop: false
1274
- });
1275
- switch (choice) {
1276
- case "name":
1277
- await editName(client, route);
1278
- break;
1279
- case "description":
1280
- await editDescription(client, route);
1281
- break;
1282
- case "source":
1283
- await editSource(client, route);
1284
- break;
1285
- case "action":
1286
- await editPrimaryAction(client, route);
1287
- break;
1288
- case "conditions":
1289
- await editConditions(client, route);
1290
- break;
1291
- case "response-headers":
1292
- await editResponseHeaders(client, route);
1293
- break;
1294
- case "request-headers":
1295
- await editTransformsByType(
1296
- client,
1297
- route,
1298
- "request.headers",
1299
- "request-header"
1300
- );
1301
- break;
1302
- case "request-query":
1303
- await editTransformsByType(
1304
- client,
1305
- route,
1306
- "request.query",
1307
- "request-query"
1308
- );
1309
- break;
1310
- case "request-path":
1311
- await editRequestPaths(client, route);
1312
- break;
1313
- case "done":
1314
- break;
1315
- }
1316
- if (choice === "done") {
1317
- const hasDest = !!route.route.dest;
1318
- const hasStatus = !!route.route.status;
1319
- const hasHeaders = Object.keys(route.route.headers ?? {}).length > 0;
1320
- const hasTransforms = (route.route.transforms ?? []).length > 0;
1321
- if (!hasDest && !hasStatus && !hasHeaders && !hasTransforms) {
1322
- output_manager_default.warn(
1323
- "Route has no action (no destination, status, or headers). Add an action before saving."
1324
- );
1325
- continue;
1326
- }
1327
- break;
1328
- }
1329
- }
1330
- }
1331
- async function editName(client, route) {
1332
- const name = await client.input.text({
1333
- message: `Name (current: ${route.name}):`,
1334
- validate: (val) => {
1335
- if (!val)
1336
- return "Route name is required";
1337
- if (val.length > MAX_NAME_LENGTH)
1338
- return `Name must be ${MAX_NAME_LENGTH} characters or less`;
1339
- return true;
1340
- }
1341
- });
1342
- route.name = name;
1343
- }
1344
- async function editDescription(client, route) {
1345
- const desc = await client.input.text({
1346
- message: `Description${route.description ? ` (current: ${route.description})` : ""}:`,
1347
- validate: (val) => val && val.length > MAX_DESCRIPTION_LENGTH ? `Description must be ${MAX_DESCRIPTION_LENGTH} characters or less` : true
1348
- });
1349
- route.description = desc || void 0;
1350
- }
1351
- async function editSource(client, route) {
1352
- const syntaxChoice = await client.input.select({
1353
- message: `Path syntax (current: ${route.srcSyntax ?? "regex"}):`,
1354
- choices: [
1355
- {
1356
- name: "Path pattern (e.g., /api/:version/users/:id)",
1357
- value: "path-to-regexp"
1358
- },
1359
- { name: "Exact match (e.g., /about)", value: "equals" },
1360
- { name: "Regular expression (e.g., ^/api/(.*)$)", value: "regex" }
1361
- ]
1362
- });
1363
- route.srcSyntax = syntaxChoice;
1364
- const src = await client.input.text({
1365
- message: `Path pattern (current: ${route.route.src}):`,
1366
- validate: (val) => {
1367
- if (!val)
1368
- return "Path pattern is required";
1369
- return true;
1370
- }
1371
- });
1372
- route.route.src = src;
1373
- }
1374
- async function editPrimaryAction(client, route) {
1375
- const currentType = getPrimaryActionType(route);
1376
- const choices = [];
1377
- if (currentType === "rewrite" || currentType === "redirect") {
1378
- choices.push({ name: "Change destination", value: "change-dest" });
1379
- }
1380
- if (currentType === "redirect" || currentType === "set-status") {
1381
- choices.push({ name: "Change status code", value: "change-status" });
1382
- }
1383
- if (currentType !== "rewrite") {
1384
- choices.push({ name: "Switch to Rewrite", value: "switch-rewrite" });
1385
- }
1386
- if (currentType !== "redirect") {
1387
- choices.push({ name: "Switch to Redirect", value: "switch-redirect" });
1388
- }
1389
- if (currentType !== "set-status") {
1390
- choices.push({
1391
- name: "Switch to Set Status Code",
1392
- value: "switch-set-status"
1393
- });
1394
- }
1395
- if (currentType) {
1396
- choices.push({
1397
- name: "Remove primary action",
1398
- value: "remove"
1399
- });
1400
- } else {
1401
- choices.push({ name: "Add Rewrite", value: "switch-rewrite" });
1402
- choices.push({ name: "Add Redirect", value: "switch-redirect" });
1403
- choices.push({ name: "Add Set Status Code", value: "switch-set-status" });
1404
- }
1405
- choices.push({ name: "Back", value: "back" });
1406
- const action = await client.input.select({
1407
- message: `Primary action (current: ${getPrimaryActionLabel(route)}):`,
1408
- choices
1409
- });
1410
- const flags = {};
1411
- switch (action) {
1412
- case "change-dest": {
1413
- const dest = await client.input.text({
1414
- message: `Destination (current: ${route.route.dest}):`,
1415
- validate: (val) => val ? true : "Destination is required"
1416
- });
1417
- route.route.dest = dest;
1418
- break;
1419
- }
1420
- case "change-status": {
1421
- if (currentType === "redirect") {
1422
- const status = await client.input.select({
1423
- message: `Status code (current: ${route.route.status}):`,
1424
- choices: [
1425
- { name: "307 - Temporary Redirect", value: 307 },
1426
- { name: "308 - Permanent Redirect", value: 308 },
1427
- { name: "301 - Moved Permanently", value: 301 },
1428
- { name: "302 - Found", value: 302 },
1429
- { name: "303 - See Other", value: 303 }
1430
- ]
1431
- });
1432
- route.route.status = status;
1433
- } else {
1434
- const statusCode = await client.input.text({
1435
- message: `Status code (current: ${route.route.status}):`,
1436
- validate: (val) => {
1437
- const num = parseInt(val, 10);
1438
- if (isNaN(num) || num < 100 || num > 599) {
1439
- return "Status code must be between 100 and 599";
1440
- }
1441
- return true;
1442
- }
1443
- });
1444
- route.route.status = parseInt(statusCode, 10);
1445
- }
1446
- break;
1447
- }
1448
- case "switch-rewrite": {
1449
- await collectActionDetails(client, "rewrite", flags);
1450
- route.route.dest = flags["--dest"];
1451
- delete route.route.status;
1452
- break;
1453
- }
1454
- case "switch-redirect": {
1455
- await collectActionDetails(client, "redirect", flags);
1456
- route.route.dest = flags["--dest"];
1457
- route.route.status = flags["--status"];
1458
- break;
1459
- }
1460
- case "switch-set-status": {
1461
- await collectActionDetails(client, "set-status", flags);
1462
- delete route.route.dest;
1463
- route.route.status = flags["--status"];
1464
- break;
1465
- }
1466
- case "remove": {
1467
- delete route.route.dest;
1468
- delete route.route.status;
1469
- break;
1470
- }
1471
- }
1472
- }
1473
- async function editConditions(client, route) {
1474
- for (; ; ) {
1475
- const hasConds = route.route.has ?? [];
1476
- const missingConds = route.route.missing ?? [];
1477
- if (hasConds.length > 0 || missingConds.length > 0) {
1478
- output_manager_default.print("\n");
1479
- if (hasConds.length > 0) {
1480
- output_manager_default.print(` ${import_chalk2.default.cyan("Has conditions:")}
1481
- `);
1482
- hasConds.forEach((c, i) => {
1483
- output_manager_default.print(
1484
- ` ${import_chalk2.default.gray(`${i + 1}.`)} ${formatCondition(c)}
1485
- `
1486
- );
1487
- });
1488
- }
1489
- if (missingConds.length > 0) {
1490
- output_manager_default.print(` ${import_chalk2.default.cyan("Does not have conditions:")}
1491
- `);
1492
- missingConds.forEach((c, i) => {
1493
- output_manager_default.print(
1494
- ` ${import_chalk2.default.gray(`${hasConds.length + i + 1}.`)} ${formatCondition(c)}
1495
- `
1496
- );
1497
- });
1498
- }
1499
- output_manager_default.print("\n");
1500
- } else {
1501
- output_manager_default.print("\n No conditions set.\n\n");
1502
- }
1503
- const choices = [];
1504
- if (hasConds.length > 0 || missingConds.length > 0) {
1505
- choices.push({ name: "Remove a condition", value: "remove" });
1506
- }
1507
- choices.push({ name: "Add a new condition", value: "add" });
1508
- choices.push({ name: "Back", value: "back" });
1509
- const action = await client.input.select({
1510
- message: "Conditions:",
1511
- choices
1512
- });
1513
- if (action === "back")
1514
- break;
1515
- if (action === "remove") {
1516
- const allConds = [
1517
- ...hasConds.map((c, i) => ({
1518
- label: `[has] ${formatCondition(c)}`,
1519
- idx: i,
1520
- kind: "has"
1521
- })),
1522
- ...missingConds.map((c, i) => ({
1523
- label: `[does not have] ${formatCondition(c)}`,
1524
- idx: i,
1525
- kind: "missing"
1526
- }))
1527
- ];
1528
- const toRemove = await client.input.select({
1529
- message: "Select condition to remove:",
1530
- choices: [
1531
- ...allConds.map((c, i) => ({
1532
- name: c.label,
1533
- value: i
1534
- })),
1535
- { name: "Cancel", value: -1 }
1536
- ]
1537
- });
1538
- if (toRemove !== -1) {
1539
- const selected = allConds[toRemove];
1540
- if (selected.kind === "has") {
1541
- hasConds.splice(selected.idx, 1);
1542
- route.route.has = hasConds;
1543
- } else {
1544
- missingConds.splice(selected.idx, 1);
1545
- route.route.missing = missingConds;
1546
- }
1547
- }
1548
- }
1549
- if (action === "add") {
1550
- const existingHasStrings = hasConds.map(
1551
- (c) => formatCondition2(c)
1552
- );
1553
- const existingMissingStrings = missingConds.map(
1554
- (c) => formatCondition2(c)
1555
- );
1556
- const tempFlags = {
1557
- "--has": existingHasStrings.length > 0 ? existingHasStrings : void 0,
1558
- "--missing": existingMissingStrings.length > 0 ? existingMissingStrings : void 0
1559
- };
1560
- const hasBefore = existingHasStrings.length;
1561
- const missingBefore = existingMissingStrings.length;
1562
- await collectInteractiveConditions(client, tempFlags);
1563
- const allHas = tempFlags["--has"] || [];
1564
- const allMissing = tempFlags["--missing"] || [];
1565
- const newHas = allHas.slice(hasBefore);
1566
- const newMissing = allMissing.slice(missingBefore);
1567
- if (newHas.length > 0) {
1568
- const parsed = parseConditions(newHas);
1569
- const existing = route.route.has ?? [];
1570
- route.route.has = [...existing, ...parsed];
1571
- }
1572
- if (newMissing.length > 0) {
1573
- const parsed = parseConditions(newMissing);
1574
- const existing = route.route.missing ?? [];
1575
- route.route.missing = [...existing, ...parsed];
1576
- }
1577
- break;
1578
- }
1579
- }
1580
- }
1581
- function getAllResponseHeaders(route) {
1582
- const items = [];
1583
- for (const [key, value] of Object.entries(route.route.headers ?? {})) {
1584
- items.push({ op: "set", key, value, source: "headers" });
1585
- }
1586
- const transforms = route.route.transforms ?? [];
1587
- for (const t of transforms) {
1588
- if (t.type === "response.headers") {
1589
- items.push({
1590
- op: t.op,
1591
- key: typeof t.target.key === "string" ? t.target.key : JSON.stringify(t.target.key),
1592
- value: typeof t.args === "string" ? t.args : void 0,
1593
- source: "transform"
1594
- });
1595
- }
1596
- }
1597
- return items;
1598
- }
1599
- function formatResponseHeaderItem(item) {
1600
- if (item.op === "delete") {
1601
- return `${import_chalk2.default.yellow(item.op)} ${import_chalk2.default.cyan(item.key)}`;
1602
- }
1603
- return `${import_chalk2.default.yellow(item.op)} ${import_chalk2.default.cyan(item.key)} = ${item.value}`;
1604
- }
1605
- async function editResponseHeaders(client, route) {
1606
- for (; ; ) {
1607
- const allHeaders = getAllResponseHeaders(route);
1608
- if (allHeaders.length > 0) {
1609
- output_manager_default.print("\n");
1610
- output_manager_default.print(` ${import_chalk2.default.cyan("Response Headers:")}
1611
- `);
1612
- allHeaders.forEach((h, i) => {
1613
- output_manager_default.print(
1614
- ` ${import_chalk2.default.gray(`${i + 1}.`)} ${formatResponseHeaderItem(h)}
1615
- `
1616
- );
1617
- });
1618
- output_manager_default.print("\n");
1619
- } else {
1620
- output_manager_default.print("\n No response headers set.\n\n");
1621
- }
1622
- const choices = [];
1623
- if (allHeaders.length > 0) {
1624
- choices.push({ name: "Remove a response header", value: "remove" });
1625
- }
1626
- choices.push({ name: "Add a response header", value: "add" });
1627
- choices.push({ name: "Back", value: "back" });
1628
- const action = await client.input.select({
1629
- message: "Response Headers:",
1630
- choices
1631
- });
1632
- if (action === "back")
1633
- break;
1634
- if (action === "remove") {
1635
- const toRemove = await client.input.select({
1636
- message: "Select response header to remove:",
1637
- choices: [
1638
- ...allHeaders.map((h, i) => ({
1639
- name: h.op === "delete" ? `${h.op} ${h.key}` : `${h.op} ${h.key} = ${h.value}`,
1640
- value: i
1641
- })),
1642
- { name: "Cancel", value: -1 }
1643
- ]
1644
- });
1645
- if (toRemove !== -1) {
1646
- const item = allHeaders[toRemove];
1647
- if (item.source === "headers") {
1648
- const currentHeaders = { ...route.route.headers ?? {} };
1649
- delete currentHeaders[item.key];
1650
- route.route.headers = currentHeaders;
1651
- } else {
1652
- const transforms = route.route.transforms ?? [];
1653
- const idx = transforms.findIndex(
1654
- (t) => t.type === "response.headers" && t.op === item.op && (typeof t.target.key === "string" ? t.target.key : JSON.stringify(t.target.key)) === item.key
1655
- );
1656
- if (idx !== -1) {
1657
- transforms.splice(idx, 1);
1658
- route.route.transforms = transforms;
1659
- }
1660
- }
1661
- }
1662
- }
1663
- if (action === "add") {
1664
- const tempFlags = {};
1665
- await collectInteractiveHeaders(client, "response", tempFlags);
1666
- const setHeaders = tempFlags["--set-response-header"] || [];
1667
- for (const h of setHeaders) {
1668
- const eqIdx = h.indexOf("=");
1669
- if (eqIdx !== -1) {
1670
- const key = h.slice(0, eqIdx).trim();
1671
- const value = h.slice(eqIdx + 1);
1672
- route.route.headers = {
1673
- ...route.route.headers ?? {},
1674
- [key]: value
1675
- };
1676
- }
1677
- }
1678
- const appendHeaders = tempFlags["--append-response-header"] || [];
1679
- const deleteHeaders = tempFlags["--delete-response-header"] || [];
1680
- const existing = route.route.transforms ?? [];
1681
- const newTransforms = [];
1682
- for (const h of appendHeaders) {
1683
- const eqIdx = h.indexOf("=");
1684
- if (eqIdx !== -1) {
1685
- newTransforms.push({
1686
- type: "response.headers",
1687
- op: "append",
1688
- target: { key: h.slice(0, eqIdx).trim() },
1689
- args: h.slice(eqIdx + 1)
1690
- });
1691
- }
1692
- }
1693
- for (const key of deleteHeaders) {
1694
- newTransforms.push({
1695
- type: "response.headers",
1696
- op: "delete",
1697
- target: { key: key.trim() }
1698
- });
1699
- }
1700
- if (newTransforms.length > 0) {
1701
- route.route.transforms = [...existing, ...newTransforms];
1702
- }
1703
- break;
1704
- }
1705
- }
1706
- }
1707
- async function editTransformsByType(client, route, transformType, headerType) {
1708
- const label = transformType === "request.headers" ? "Request Headers" : "Request Query";
1709
- const itemName = transformType === "request.headers" ? "request header" : "query parameter";
1710
- for (; ; ) {
1711
- const allTransforms = route.route.transforms ?? [];
1712
- const matching = allTransforms.filter((t) => t.type === transformType);
1713
- if (matching.length > 0) {
1714
- output_manager_default.print("\n");
1715
- output_manager_default.print(` ${import_chalk2.default.cyan(`${label}:`)}
1716
- `);
1717
- matching.forEach((t, i) => {
1718
- output_manager_default.print(
1719
- ` ${import_chalk2.default.gray(`${i + 1}.`)} ${formatTransform(t)}
1720
- `
1721
- );
1722
- });
1723
- output_manager_default.print("\n");
1724
- } else {
1725
- output_manager_default.print(`
1726
- No ${label.toLowerCase()} set.
1727
-
1728
- `);
1729
- }
1730
- const choices = [];
1731
- if (matching.length > 0) {
1732
- choices.push({ name: `Remove a ${itemName}`, value: "remove" });
1733
- }
1734
- choices.push({ name: `Add a ${itemName}`, value: "add" });
1735
- choices.push({ name: "Back", value: "back" });
1736
- const action = await client.input.select({
1737
- message: `${label}:`,
1738
- choices
1739
- });
1740
- if (action === "back")
1741
- break;
1742
- if (action === "remove") {
1743
- const toRemove = await client.input.select({
1744
- message: `Select ${itemName} to remove:`,
1745
- choices: [
1746
- ...matching.map((t, i) => ({
1747
- name: formatTransform(t),
1748
- value: i
1749
- })),
1750
- { name: "Cancel", value: -1 }
1751
- ]
1752
- });
1753
- if (toRemove !== -1) {
1754
- let matchIdx = 0;
1755
- const removeIdx = allTransforms.findIndex((t) => {
1756
- if (t.type === transformType) {
1757
- if (matchIdx === toRemove)
1758
- return true;
1759
- matchIdx++;
1760
- }
1761
- return false;
1762
- });
1763
- if (removeIdx !== -1) {
1764
- allTransforms.splice(removeIdx, 1);
1765
- route.route.transforms = allTransforms;
1766
- }
1767
- }
1768
- }
1769
- if (action === "add") {
1770
- const tempFlags = {};
1771
- await collectInteractiveHeaders(client, headerType, tempFlags);
1772
- const tfFlags = extractTransformFlags(tempFlags);
1773
- const { transforms } = collectHeadersAndTransforms(tfFlags);
1774
- if (transforms.length > 0) {
1775
- route.route.transforms = [...allTransforms, ...transforms];
1776
- }
1777
- break;
1778
- }
1779
- }
1780
- }
1781
- async function editRequestPaths(client, route) {
1782
- for (; ; ) {
1783
- const allTransforms = route.route.transforms ?? [];
1784
- const matching = allTransforms.filter(
1785
- (transform) => transform.type === "request.path"
1786
- );
1787
- if (matching.length > 0) {
1788
- output_manager_default.print(`
1789
- ${import_chalk2.default.cyan("Request Path:")}
1790
- `);
1791
- matching.forEach((transform, index) => {
1792
- const env = transform.env?.length ? import_chalk2.default.gray(` (env: ${transform.env.join(", ")})`) : "";
1793
- output_manager_default.print(
1794
- ` ${import_chalk2.default.gray(`${index + 1}.`)} ${formatTransform(transform)}${env}
1795
- `
1796
- );
1797
- });
1798
- output_manager_default.print("\n");
1799
- } else {
1800
- output_manager_default.print("\n No request path transforms set.\n\n");
1801
- }
1802
- const choices = [];
1803
- if (matching.length > 0) {
1804
- choices.push({
1805
- name: "Remove a request path transform",
1806
- value: "remove"
1807
- });
1808
- }
1809
- choices.push({ name: "Add a request path transform", value: "add" });
1810
- choices.push({ name: "Back", value: "back" });
1811
- const action = await client.input.select({
1812
- message: "Request Path:",
1813
- choices
1814
- });
1815
- if (action === "back")
1816
- break;
1817
- if (action === "remove") {
1818
- const toRemove = await client.input.select({
1819
- message: "Select request path transform to remove:",
1820
- choices: [
1821
- ...matching.map((transform, index) => ({
1822
- name: formatTransform(transform),
1823
- value: index
1824
- })),
1825
- { name: "Cancel", value: -1 }
1826
- ]
1827
- });
1828
- if (toRemove !== -1) {
1829
- let matchIndex = 0;
1830
- const removeIndex = allTransforms.findIndex((transform) => {
1831
- if (transform.type === "request.path") {
1832
- if (matchIndex === toRemove)
1833
- return true;
1834
- matchIndex++;
1835
- }
1836
- return false;
1837
- });
1838
- if (removeIndex !== -1) {
1839
- allTransforms.splice(removeIndex, 1);
1840
- route.route.transforms = allTransforms;
1841
- }
1842
- }
1843
- }
1844
- if (action === "add") {
1845
- const example = route.srcSyntax === "path-to-regexp" ? "/:path*" : route.srcSyntax === "regex" ? "/$1" : "/internal";
1846
- const args = await client.input.text({
1847
- message: `Runtime-visible request path (e.g., ${example}):`,
1848
- validate: (value) => {
1849
- if (!value.startsWith("/") || value.startsWith("//")) {
1850
- return "Request path must be an origin-form path starting with a single `/`";
1851
- }
1852
- if (/[?#\s\x00-\x1f\x7f]/.test(value)) {
1853
- return "Request path cannot contain a query, fragment, whitespace, or control characters";
1854
- }
1855
- return true;
1856
- }
1857
- });
1858
- route.route.transforms = [
1859
- ...allTransforms,
1860
- { type: "request.path", op: "set", args }
1861
- ];
1862
- break;
1863
- }
1864
- }
1865
- }
1866
-
1867
- export {
1868
- parseConditions,
1869
- populateRouteEnv,
1870
- generateRoute,
1871
- MAX_NAME_LENGTH,
1872
- MAX_DESCRIPTION_LENGTH,
1873
- MAX_CONDITIONS,
1874
- VALID_SYNTAXES,
1875
- REDIRECT_STATUS_CODES,
1876
- ALL_ACTION_CHOICES,
1877
- stripQuotes,
1878
- extractTransformFlags,
1879
- collectHeadersAndTransforms,
1880
- hasAnyTransformFlags,
1881
- validateActionFlags,
1882
- collectActionDetails,
1883
- collectInteractiveConditions,
1884
- generatedRouteToAddInput,
1885
- convertRouteToCurrentRoute,
1886
- routingRuleToCurrentRoute,
1887
- printGeneratedRoutePreview,
1888
- printRouteConfig,
1889
- cloneRoute,
1890
- applyFlagMutations,
1891
- runInteractiveEditLoop
1892
- };