@xano/sdk 1.0.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 (336) hide show
  1. package/CHANGELOG.md +788 -0
  2. package/LICENSE +21 -0
  3. package/README.md +541 -0
  4. package/dist/.build-fingerprint +1 -0
  5. package/dist/agent-file-refresh-ZEMK33AX.js +38 -0
  6. package/dist/answer-shape-K67TAAPY.js +33 -0
  7. package/dist/backend-dir-2U53CIAL.js +39 -0
  8. package/dist/backend-slot-7QXW2QYC.js +28 -0
  9. package/dist/bin.d.ts +1 -0
  10. package/dist/bin.js +255 -0
  11. package/dist/branch-NCRNWQBQ.js +61 -0
  12. package/dist/branch-commands-ACIRCEQJ.js +79 -0
  13. package/dist/bundle.d.ts +223 -0
  14. package/dist/bundle.js +153 -0
  15. package/dist/capture-WAXPD7DR.js +41 -0
  16. package/dist/chunk-27GWNP2I.js +23 -0
  17. package/dist/chunk-2CMJZDCL.js +177 -0
  18. package/dist/chunk-2EZ3ZJZZ.js +302 -0
  19. package/dist/chunk-2GNFDZA2.js +390 -0
  20. package/dist/chunk-2MNLRIOX.js +11 -0
  21. package/dist/chunk-2TFRR6JV.js +104 -0
  22. package/dist/chunk-2ZUEE4EK.js +408 -0
  23. package/dist/chunk-36JUQZVQ.js +22 -0
  24. package/dist/chunk-3DRXWLJ5.js +83 -0
  25. package/dist/chunk-3JDU4VRL.js +137 -0
  26. package/dist/chunk-3KZCLN4Z.js +241 -0
  27. package/dist/chunk-3LDULPRE.js +168 -0
  28. package/dist/chunk-3M4LFYNQ.js +111 -0
  29. package/dist/chunk-3XI5CTUE.js +22 -0
  30. package/dist/chunk-3YW23UFH.js +50 -0
  31. package/dist/chunk-45UIT5T2.js +862 -0
  32. package/dist/chunk-4BW2SG2N.js +46 -0
  33. package/dist/chunk-4KHEMC32.js +79 -0
  34. package/dist/chunk-4POWHT2K.js +321 -0
  35. package/dist/chunk-4Q2GN7NW.js +192 -0
  36. package/dist/chunk-5A2PLKZB.js +70 -0
  37. package/dist/chunk-5FBYXK5P.js +159 -0
  38. package/dist/chunk-5HVXPTU4.js +323 -0
  39. package/dist/chunk-5QU2P5CA.js +304 -0
  40. package/dist/chunk-5V5XU32D.js +191 -0
  41. package/dist/chunk-5ZSO4T2G.js +10 -0
  42. package/dist/chunk-622HUCZT.js +10 -0
  43. package/dist/chunk-65HWOMGV.js +177 -0
  44. package/dist/chunk-6ELFRN3P.js +365 -0
  45. package/dist/chunk-6HO3NCSJ.js +1055 -0
  46. package/dist/chunk-6IUMKYWI.js +457 -0
  47. package/dist/chunk-6KEB3C3U.js +65 -0
  48. package/dist/chunk-6MR5TI5V.js +987 -0
  49. package/dist/chunk-6NNTNXN7.js +157 -0
  50. package/dist/chunk-6PBR37LN.js +97 -0
  51. package/dist/chunk-6QXLMMT3.js +155 -0
  52. package/dist/chunk-6ZGJCBZS.js +224 -0
  53. package/dist/chunk-73IVBKMA.js +250 -0
  54. package/dist/chunk-7G3CTU7I.js +286 -0
  55. package/dist/chunk-A3UDOZB6.js +222 -0
  56. package/dist/chunk-A6E77GDW.js +85 -0
  57. package/dist/chunk-AHJWCYQO.js +660 -0
  58. package/dist/chunk-AKNCFVKZ.js +36 -0
  59. package/dist/chunk-AM4FKL4J.js +237 -0
  60. package/dist/chunk-AN6BL47T.js +26 -0
  61. package/dist/chunk-AOSYVMUS.js +147 -0
  62. package/dist/chunk-APWXY5SL.js +182 -0
  63. package/dist/chunk-AWEIIR2U.js +218 -0
  64. package/dist/chunk-AWQ7BQTQ.js +73 -0
  65. package/dist/chunk-BAUZOWGX.js +393 -0
  66. package/dist/chunk-BHACRS6R.js +940 -0
  67. package/dist/chunk-BWPNT55T.js +680 -0
  68. package/dist/chunk-C6RIMRU4.js +187 -0
  69. package/dist/chunk-CGVQZXYG.js +263 -0
  70. package/dist/chunk-CIMQZRRE.js +162 -0
  71. package/dist/chunk-CJHQKJU4.js +113 -0
  72. package/dist/chunk-CTMO46PK.js +1897 -0
  73. package/dist/chunk-D53J55C5.js +106 -0
  74. package/dist/chunk-D7VGG3WS.js +90 -0
  75. package/dist/chunk-DAD3ONIS.js +245 -0
  76. package/dist/chunk-DGWHAVRG.js +162 -0
  77. package/dist/chunk-DX4QR4B2.js +483 -0
  78. package/dist/chunk-EHP3WPEG.js +21 -0
  79. package/dist/chunk-ELP2HMXC.js +432 -0
  80. package/dist/chunk-ERVIASGL.js +21 -0
  81. package/dist/chunk-ET4Y4XCB.js +865 -0
  82. package/dist/chunk-ETO6LGLD.js +4750 -0
  83. package/dist/chunk-EUUUMY7J.js +24 -0
  84. package/dist/chunk-FQJ2TTHP.js +218 -0
  85. package/dist/chunk-FQOF7E2E.js +133 -0
  86. package/dist/chunk-FWD7AL6N.js +21 -0
  87. package/dist/chunk-FXFV3KU6.js +138 -0
  88. package/dist/chunk-FXRQOWTE.js +171 -0
  89. package/dist/chunk-G554NZNI.js +210 -0
  90. package/dist/chunk-GSGDWJB5.js +13 -0
  91. package/dist/chunk-H2V3N23D.js +66 -0
  92. package/dist/chunk-H5C7MBCR.js +159 -0
  93. package/dist/chunk-HHN734BU.js +371 -0
  94. package/dist/chunk-HRVBLCVJ.js +243 -0
  95. package/dist/chunk-HVRUQXGD.js +1264 -0
  96. package/dist/chunk-I4F5TCJH.js +130 -0
  97. package/dist/chunk-IDOTCMDV.js +57 -0
  98. package/dist/chunk-IGOLHKWF.js +427 -0
  99. package/dist/chunk-JGE7CAWB.js +148 -0
  100. package/dist/chunk-JTUKLCXS.js +92 -0
  101. package/dist/chunk-JZGVVJSI.js +66 -0
  102. package/dist/chunk-K4WX6UUU.js +923 -0
  103. package/dist/chunk-K5BBGTYZ.js +217 -0
  104. package/dist/chunk-K6RXBGUB.js +427 -0
  105. package/dist/chunk-KTSDSD36.js +165 -0
  106. package/dist/chunk-L5JYN3NM.js +1038 -0
  107. package/dist/chunk-LIEOKXKD.js +354 -0
  108. package/dist/chunk-LLNZGEFK.js +51 -0
  109. package/dist/chunk-LPECSJ2J.js +55 -0
  110. package/dist/chunk-LQCMKAJ7.js +413 -0
  111. package/dist/chunk-LRN4ZJCQ.js +1145 -0
  112. package/dist/chunk-MJ4ZVHKN.js +17 -0
  113. package/dist/chunk-MXHSQOC4.js +3061 -0
  114. package/dist/chunk-N5GKCWE5.js +367 -0
  115. package/dist/chunk-NA3PXMEF.js +10 -0
  116. package/dist/chunk-NAQDMEHV.js +76 -0
  117. package/dist/chunk-NWKXM5RD.js +109 -0
  118. package/dist/chunk-NZOWWHU5.js +196 -0
  119. package/dist/chunk-OHX6MIUZ.js +184 -0
  120. package/dist/chunk-OOXWYAA4.js +15 -0
  121. package/dist/chunk-OPHB5ORL.js +1990 -0
  122. package/dist/chunk-OXA6PSZT.js +1725 -0
  123. package/dist/chunk-P2HAGF6H.js +73 -0
  124. package/dist/chunk-PTHVMXZI.js +3036 -0
  125. package/dist/chunk-PZ5AY32C.js +10 -0
  126. package/dist/chunk-Q325JKYB.js +189 -0
  127. package/dist/chunk-Q7DGTQ5G.js +255 -0
  128. package/dist/chunk-QCNYHBL7.js +601 -0
  129. package/dist/chunk-QO6BVGS5.js +145 -0
  130. package/dist/chunk-QXTKSOFI.js +76 -0
  131. package/dist/chunk-ROY4YAEQ.js +66 -0
  132. package/dist/chunk-RTJRZFFY.js +447 -0
  133. package/dist/chunk-SAVJUS2X.js +128 -0
  134. package/dist/chunk-SFLHVCKX.js +173 -0
  135. package/dist/chunk-STSFNCY4.js +127 -0
  136. package/dist/chunk-SWBF2LTK.js +170 -0
  137. package/dist/chunk-T5KELPAR.js +109 -0
  138. package/dist/chunk-TFFGOFVZ.js +1481 -0
  139. package/dist/chunk-TLHIFK4M.js +256 -0
  140. package/dist/chunk-TLQE7ZN3.js +156 -0
  141. package/dist/chunk-TPHWJ7UG.js +1981 -0
  142. package/dist/chunk-TRJCALW3.js +291 -0
  143. package/dist/chunk-TTEIYD5P.js +133 -0
  144. package/dist/chunk-U64O2MXY.js +407 -0
  145. package/dist/chunk-UCQ2VUTG.js +630 -0
  146. package/dist/chunk-UTI5G6OJ.js +44 -0
  147. package/dist/chunk-UVHDMMIP.js +188 -0
  148. package/dist/chunk-UZ6QQWJT.js +120 -0
  149. package/dist/chunk-VAX3UZOY.js +686 -0
  150. package/dist/chunk-W3HBUKFO.js +57 -0
  151. package/dist/chunk-WKQLGKCL.js +2823 -0
  152. package/dist/chunk-WQFNASK4.js +560 -0
  153. package/dist/chunk-WRBKLYSJ.js +224 -0
  154. package/dist/chunk-WTPZRR4I.js +17 -0
  155. package/dist/chunk-WZDJ2LLX.js +2385 -0
  156. package/dist/chunk-X2NL4KUO.js +14 -0
  157. package/dist/chunk-X4DVXBFY.js +38 -0
  158. package/dist/chunk-X677DMZM.js +7050 -0
  159. package/dist/chunk-XBKMWY7F.js +612 -0
  160. package/dist/chunk-XNCP4KYO.js +78 -0
  161. package/dist/chunk-XVBGLISP.js +35 -0
  162. package/dist/chunk-XW6KISBB.js +1192 -0
  163. package/dist/chunk-YGZHHAAB.js +8156 -0
  164. package/dist/chunk-YHEFQUQB.js +186 -0
  165. package/dist/chunk-YLDALTWZ.js +653 -0
  166. package/dist/chunk-YU4HSQW7.js +229 -0
  167. package/dist/chunk-ZDPP6RKB.js +27 -0
  168. package/dist/chunk-ZFDZKNGG.js +194 -0
  169. package/dist/chunk-ZIY7RNUT.js +49 -0
  170. package/dist/chunk-ZYJP6BOO.js +30 -0
  171. package/dist/cli.d.ts +1111 -0
  172. package/dist/cli.js +165 -0
  173. package/dist/codegen-command-VR2GWR6C.js +173 -0
  174. package/dist/codegen.d.ts +115 -0
  175. package/dist/codegen.js +19 -0
  176. package/dist/commands-GJMJ4XYZ.js +76 -0
  177. package/dist/completion-ZQLO6PB6.js +738 -0
  178. package/dist/config-MBYGCAFK.js +136 -0
  179. package/dist/deploy-command-JVZPWHMK.js +180 -0
  180. package/dist/deploy-source-3W45CXMP.js +81 -0
  181. package/dist/dev-env-sync-HN44K4D5.js +188 -0
  182. package/dist/diagnostics-UEAAHWVF.js +30 -0
  183. package/dist/display-name-hint-ABBPVQIR.js +46 -0
  184. package/dist/emit-CyhBDxli.d.ts +7007 -0
  185. package/dist/env-example-refresh-ET5HMMDW.js +126 -0
  186. package/dist/env-pull-command-TNMNB3CV.js +323 -0
  187. package/dist/env-target-O4HRKTGZ.js +40 -0
  188. package/dist/env-var-command-ZIRDCAZA.js +427 -0
  189. package/dist/ephemeral-P7F3PMAD.js +54 -0
  190. package/dist/ephemeral-command-CLJJKOFT.js +592 -0
  191. package/dist/ephemeral-state-PYCBSOGX.js +61 -0
  192. package/dist/file-lock-PT74GWYW.js +10 -0
  193. package/dist/generate-command-AYEOLA26.js +510 -0
  194. package/dist/gitignore-3SJ3WNRG.js +51 -0
  195. package/dist/guards-4EBNCZDC.js +162 -0
  196. package/dist/hosted-file-PSHJB3HX.js +28 -0
  197. package/dist/impersonate-command-5JAS3WSV.js +152 -0
  198. package/dist/import-EQSFU6JC.js +19 -0
  199. package/dist/index.d.ts +5470 -0
  200. package/dist/index.js +371 -0
  201. package/dist/init-command-X2FR4UAK.js +125 -0
  202. package/dist/init-modules-RY7UHAOL.js +50 -0
  203. package/dist/init-web-M4YZSZK6.js +42 -0
  204. package/dist/internal.d.ts +179 -0
  205. package/dist/internal.js +2634 -0
  206. package/dist/io-RC56QSN5.js +26 -0
  207. package/dist/keep-data-merge-7MPLVAVI.js +1119 -0
  208. package/dist/lambda-config-reconcile-OUZ4OYAB.js +116 -0
  209. package/dist/landed-753YLJ5H.js +40 -0
  210. package/dist/landing-record-SU52SKXU.js +61 -0
  211. package/dist/live-diff-YONW2VI3.js +65 -0
  212. package/dist/local-engine-choice-CH5X3W7E.js +79 -0
  213. package/dist/local-engine-command-Z3OL7VOD.js +766 -0
  214. package/dist/local-engine-config-5U3SC434.js +39 -0
  215. package/dist/local-engine-deploy-PCQ4SNPB.js +39 -0
  216. package/dist/local-engine-process-EHTE5LLU.js +63 -0
  217. package/dist/local-engine-state-A4FTRFAF.js +32 -0
  218. package/dist/local-engine-update-check-6L645VBL.js +162 -0
  219. package/dist/lock-MRRHW5GS.js +87 -0
  220. package/dist/lock-commands-2QG25HL7.js +963 -0
  221. package/dist/login-command-QPYRWOXZ.js +538 -0
  222. package/dist/logout-command-WOIQLDP6.js +56 -0
  223. package/dist/loop-ALIZLOSX.js +191 -0
  224. package/dist/marketplace-command-K5YL42NO.js +977 -0
  225. package/dist/marketplace-resolve-LY32JES5.js +40 -0
  226. package/dist/meta-client-YXGPW53C.js +244 -0
  227. package/dist/module-manifest-JFGHU2TC.js +38 -0
  228. package/dist/near-key.d.ts +13 -0
  229. package/dist/near-key.js +8 -0
  230. package/dist/node.d.ts +95 -0
  231. package/dist/node.js +969 -0
  232. package/dist/operation-outcome-TZSESNC7.js +51 -0
  233. package/dist/output-target-AL3I44GG.js +47 -0
  234. package/dist/package-manager-PRAHUSCN.js +34 -0
  235. package/dist/plan-disclosure-6G4MLZKD.js +114 -0
  236. package/dist/plugin-contributions-WRNY5ABG.js +28 -0
  237. package/dist/plugin-prompt-4VA3B4FF.js +20 -0
  238. package/dist/plugin-questions-JTSYA74Q.js +24 -0
  239. package/dist/plugin.d.ts +396 -0
  240. package/dist/plugin.js +1 -0
  241. package/dist/preflight-command-2T5Z36MI.js +321 -0
  242. package/dist/profile-command-AH3PIM4X.js +800 -0
  243. package/dist/profile-pointer-GRWJU3YD.js +31 -0
  244. package/dist/profile-select-74TRDEPD.js +23 -0
  245. package/dist/project-dependency-KSH63ODT.js +35 -0
  246. package/dist/project-sdk-REPPOIBD.js +24 -0
  247. package/dist/promote-command-PCWT5N6S.js +140 -0
  248. package/dist/prompt-II3F3LND.js +27 -0
  249. package/dist/publish-command-TTDUUJI5.js +414 -0
  250. package/dist/pull-command-VBO7C4S3.js +161 -0
  251. package/dist/pull-superseded-GJWLG7XO.js +20 -0
  252. package/dist/release-command-N4ZPKMHR.js +146 -0
  253. package/dist/release-ns-command-3KFDMZ6G.js +1745 -0
  254. package/dist/response-HlXahv4K.d.ts +925 -0
  255. package/dist/retry-command-AS5EVREX.js +34 -0
  256. package/dist/routes-manifest-SNWUVBT6.js +43 -0
  257. package/dist/runtime-XETHVF33.js +14 -0
  258. package/dist/scaffold.d.ts +1911 -0
  259. package/dist/scaffold.js +107 -0
  260. package/dist/secrets-file-LVZD6IIM.js +56 -0
  261. package/dist/secrets-fill-command-TTCPSVXN.js +218 -0
  262. package/dist/seed-VU7C3QYS.js +46 -0
  263. package/dist/sent-writes-N7X4OVXT.js +22 -0
  264. package/dist/source-resolve-S2XA3XZF.js +83 -0
  265. package/dist/static-host-B2Y6AG3W.js +352 -0
  266. package/dist/status-command-RUDXTF7I.js +554 -0
  267. package/dist/store-6VNCD4D7.js +20 -0
  268. package/dist/store-ARM6VMO5.js +98 -0
  269. package/dist/store-DuYfzKlW.d.ts +3144 -0
  270. package/dist/suggest-6FOOYKHG.js +12 -0
  271. package/dist/sveltekit.d.ts +154 -0
  272. package/dist/sveltekit.js +109 -0
  273. package/dist/sync-contributions-UCEROO26.js +415 -0
  274. package/dist/table-ENAVMITR.js +42 -0
  275. package/dist/tables-command-GUPXXSB5.js +156 -0
  276. package/dist/tenant-IIHPOHGP.js +42 -0
  277. package/dist/tenant-command-D5HGI2X4.js +965 -0
  278. package/dist/test-command-TIKZMDPZ.js +476 -0
  279. package/dist/tests-BGGIOK3L.js +26 -0
  280. package/dist/token-NICJUTMT.js +72 -0
  281. package/dist/toolchain-hooks-GHKLUJOH.js +96 -0
  282. package/dist/toolchain-modules-5EAZUONB.js +24 -0
  283. package/dist/tracked-backend-EIBUMDZA.js +80 -0
  284. package/dist/update-check-2W2NLDTC.js +136 -0
  285. package/dist/upgrade-command-QHNFWM7O.js +531 -0
  286. package/dist/verify-rollout-DRCK5TDD.js +61 -0
  287. package/dist/whoami-command-STGINTXH.js +51 -0
  288. package/dist/workspace-2CLHU2LK.js +93 -0
  289. package/dist/workspace-binding-56PIIPCP.js +54 -0
  290. package/dist/workspace-command-JEXQETJD.js +535 -0
  291. package/dist/workspace-env-F2RFMSC5.js +70 -0
  292. package/dist/workspace-export-OJSH2HIW.js +21 -0
  293. package/dist/writable-VA7OISSK.js +25 -0
  294. package/dist/xano-ICFUSPFR.js +42 -0
  295. package/dist/xanosdk-import-GN42TO2B.js +56 -0
  296. package/dist/xanosdk-project-S6DXJONQ.js +41 -0
  297. package/dist/xdo-CxDr2Q1C.d.ts +1371 -0
  298. package/guides/README.md +33 -0
  299. package/guides/authoring.md +921 -0
  300. package/guides/cli.md +401 -0
  301. package/guides/codegen.md +177 -0
  302. package/guides/codes.md +404 -0
  303. package/guides/coverage.md +74 -0
  304. package/guides/deploying.md +1525 -0
  305. package/guides/environment.md +400 -0
  306. package/guides/marketplace.md +415 -0
  307. package/guides/module-contract.md +558 -0
  308. package/guides/object-kinds.md +433 -0
  309. package/guides/project-structure.md +43 -0
  310. package/guides/scaffold.md +351 -0
  311. package/guides/typed-frontend.md +242 -0
  312. package/llms/client.md +63 -0
  313. package/llms/errors.md +56 -0
  314. package/llms/fields.md +176 -0
  315. package/llms/filters.md +183 -0
  316. package/llms/kinds-agent-mcp.md +30 -0
  317. package/llms/kinds-core.md +100 -0
  318. package/llms/kinds-knowledge.md +20 -0
  319. package/llms/kinds-realtime.md +76 -0
  320. package/llms/lambda.md +94 -0
  321. package/llms/legacy.md +44 -0
  322. package/llms/lock.md +40 -0
  323. package/llms/object-kinds.md +34 -0
  324. package/llms/statements-calls.md +62 -0
  325. package/llms/statements-catalog.md +320 -0
  326. package/llms/statements-data.md +66 -0
  327. package/llms/statements-runtime.md +68 -0
  328. package/llms/tests.md +59 -0
  329. package/llms/toolchain.md +16 -0
  330. package/llms/triggers.md +36 -0
  331. package/llms/values.md +29 -0
  332. package/llms-full.txt +2085 -0
  333. package/llms.txt +493 -0
  334. package/manifest.json +11224 -0
  335. package/package.json +162 -0
  336. package/types/lambda-globals.d.ts +129 -0
@@ -0,0 +1,738 @@
1
+ import {
2
+ GLOBAL_FLAGS,
3
+ argValues,
4
+ flagKey,
5
+ flagRefFor,
6
+ flagSpec,
7
+ flagValues,
8
+ getCommand,
9
+ liveCommandNames,
10
+ liveSubcommandNames,
11
+ takesProfileFlag,
12
+ visibleFlags
13
+ } from "./chunk-PTHVMXZI.js";
14
+ import "./chunk-UTI5G6OJ.js";
15
+ import "./chunk-2EZ3ZJZZ.js";
16
+ import "./chunk-5ZSO4T2G.js";
17
+ import "./chunk-TFFGOFVZ.js";
18
+ import "./chunk-36JUQZVQ.js";
19
+ import "./chunk-PZ5AY32C.js";
20
+
21
+ // src/emit/completion.ts
22
+ var COMPLETION_SHELLS = ["bash", "zsh", "fish"];
23
+ var UNSUPPORTED_SHELLS = /* @__PURE__ */ new Set([
24
+ "pwsh",
25
+ "powershell",
26
+ "cmd",
27
+ "sh",
28
+ "dash",
29
+ "ksh",
30
+ "tcsh",
31
+ "csh",
32
+ "nu",
33
+ "nushell",
34
+ "elvish",
35
+ "xonsh"
36
+ ]);
37
+ function isCompletionShell(s) {
38
+ return COMPLETION_SHELLS.includes(s);
39
+ }
40
+ function flagTokens(ref) {
41
+ const spec = flagSpec(ref);
42
+ return spec.match(/-{1,2}[a-z][a-z-]*/g) ?? [];
43
+ }
44
+ function takesNextWord(ref) {
45
+ const rest = flagSpec(ref).replace(/-{1,2}[a-z][a-z-]*,?/g, "").trim();
46
+ return rest !== "" && !rest.startsWith("=") && !rest.startsWith("[");
47
+ }
48
+ function valueFlagTokens() {
49
+ const refs = [...GLOBAL_FLAGS];
50
+ for (const name of liveCommandNames()) {
51
+ const spec = getCommand(name);
52
+ refs.push(...visibleFlags(spec) ?? []);
53
+ for (const verb of liveSubcommandNames(name)) refs.push(...visibleFlags(spec.subcommands[verb]) ?? []);
54
+ }
55
+ const valued = /* @__PURE__ */ new Set();
56
+ const switches = /* @__PURE__ */ new Set();
57
+ for (const ref of refs) for (const token of flagTokens(ref)) (takesNextWord(ref) ? valued : switches).add(token);
58
+ return [...valued].filter((t) => !switches.has(t)).sort();
59
+ }
60
+ function valueKind(ref) {
61
+ if (!takesNextWord(ref) || flagValues(ref) !== void 0) return void 0;
62
+ const key = flagKey(ref);
63
+ if (key === "profile" || key === "to-profile") return "profile";
64
+ const spec = flagSpec(ref);
65
+ if (/<dir>/.test(spec) || key.endsWith("-dir")) return "dir";
66
+ if (/<(path|file|p)>/.test(spec)) return "file";
67
+ return "free";
68
+ }
69
+ function inlineValueKind(ref) {
70
+ if (takesNextWord(ref) || flagValues(ref) !== void 0) return void 0;
71
+ const rest = flagSpec(ref).replace(/-{1,2}[a-z][a-z-]*,?/g, "").trim();
72
+ const placeholder = /^\[?=<([^>]+)>/.exec(rest)?.[1];
73
+ if (placeholder === void 0) return void 0;
74
+ const parts = placeholder.split("|");
75
+ if (parts.includes("dir")) return "dir";
76
+ if (parts.some((p) => p === "path" || p === "file")) return "file";
77
+ return "free";
78
+ }
79
+ function tokensFor(flags) {
80
+ return (flags ?? []).flatMap(flagTokens);
81
+ }
82
+ function wantsPaths(args) {
83
+ return (args ?? []).some((a) => a.path === true);
84
+ }
85
+ function firstArgValues(args) {
86
+ const first = args?.[0];
87
+ return first === void 0 ? [] : [...argValues(first) ?? []];
88
+ }
89
+ function valuedFlags(flags) {
90
+ const out = [];
91
+ for (const ref of flags ?? []) {
92
+ const values = flagValues(ref);
93
+ if (values === void 0) continue;
94
+ for (const token of flagTokens(ref)) out.push([token, [...values]]);
95
+ }
96
+ return out;
97
+ }
98
+ function describe(text) {
99
+ return text.replace(/`/g, "").replace(/\s+/g, " ").trim();
100
+ }
101
+ function sq(text) {
102
+ return `'${text.replace(/'/g, `'\\''`)}'`;
103
+ }
104
+ function inlineKindedFlags(flags) {
105
+ return (flags ?? []).flatMap((ref) => {
106
+ const kind = inlineValueKind(ref);
107
+ return kind === void 0 ? [] : flagTokens(ref).filter((t) => t.startsWith("--")).map((t) => [t, kind]);
108
+ });
109
+ }
110
+ function kindedFlags(flags, command, verb) {
111
+ const globals = GLOBAL_FLAGS.filter((key) => key !== "profile" || takesProfileFlag(command, verb));
112
+ const out = [];
113
+ const seen = /* @__PURE__ */ new Set();
114
+ for (const ref of [...flags ?? [], ...globals]) {
115
+ const kind = valueKind(ref);
116
+ if (kind === void 0) continue;
117
+ for (const token of flagTokens(ref)) {
118
+ if (seen.has(token)) continue;
119
+ seen.add(token);
120
+ out.push([token, kind]);
121
+ }
122
+ }
123
+ return out;
124
+ }
125
+ function globalTokens(command, verb) {
126
+ return GLOBAL_FLAGS.filter((key) => key !== "profile" || takesProfileFlag(command, verb)).filter((key) => key !== "version" || flagRefFor(command, verb, "engine-version") === void 0).filter((key) => key !== "version" || !(command === "env" && verb === "set")).flatMap((key) => flagTokens(key));
127
+ }
128
+ function withGlobals(own, command, verb) {
129
+ return [.../* @__PURE__ */ new Set([...own, ...globalTokens(command, verb)])];
130
+ }
131
+ function leadingGlobals() {
132
+ return GLOBAL_FLAGS.flatMap((key) => flagTokens(key)).join(" ");
133
+ }
134
+ var PROFILE_NAME_VERBS = ["use", "show", "delete", "set-default"];
135
+ var PROFILE_NAMES_JS = [
136
+ 'const fs=require("fs"),os=require("os"),p=require("path");',
137
+ 'const names=(f)=>{try{const j=JSON.parse(fs.readFileSync(f,"utf8"));',
138
+ 'const o=j&&typeof j.profiles==="object"&&j.profiles?j.profiles:null;',
139
+ "return o?Object.keys(o).filter((n)=>/^[A-Za-z0-9._-]+$/.test(n)):[];}catch{return [];}};",
140
+ "const a=process.argv.slice(1);let cfg,local=false,cmd;",
141
+ "for(let i=0;i<a.length;i++){const w=a[i];",
142
+ // bash splits `--config=/alt.json` at the `=` (COMP_WORDBREAKS): `--config`, `=`, `/alt.json`.
143
+ 'if(w==="--config"){cfg=a[++i];if(cfg==="=")cfg=a[++i];}else if(w.startsWith("--config="))cfg=w.slice(9);',
144
+ 'else if(w==="--local")local=true;else if(w==="-p"||w==="--profile"){i++;if(a[i]==="=")i++;}',
145
+ 'else if(!w.startsWith("-")&&cmd===undefined)cmd=w;}',
146
+ // A leading `~` the shell left unexpanded (quoted, or after `--config=`) is the home directory.
147
+ 'const tl=(f)=>f&&(f==="~"||f.startsWith("~/"))?p.join(os.homedir(),f.slice(1)):f;',
148
+ "cfg=tl(cfg||process.env.XANO_CONFIG);",
149
+ "const localFile=()=>{const home=p.resolve(os.homedir()),start=process.cwd();let d=start;for(;;){",
150
+ 'if(["xano.profile.json","package.json",".git"].some((m)=>fs.existsSync(p.join(d,m))))return p.join(d,".xano","auth.json");',
151
+ 'const up=p.dirname(d);if(up===d||d===home)return p.join(start,".xano","auth.json");d=up;}};',
152
+ 'const shared=tl(process.env.XANO_GLOBAL_CONFIG)||p.join(os.homedir(),".xanosdk","auth.json");',
153
+ "let file;if(cfg)file=cfg;else if(local)file=localFile();",
154
+ 'else if(cmd==="login"||cmd==="logout")file=shared;',
155
+ "else{const l=localFile();file=names(l).length?l:shared;}",
156
+ 'const n=names(file);if(n.length)console.log(n.join(" "));'
157
+ ].join("");
158
+ var ENGINE_NAME_VERBS = ["stop", "token"];
159
+ var ENGINE_RECORDS = { homeEnv: "XANOSDK_LOCAL_ENGINE_HOME", file: "engines.json" };
160
+ var ENGINE_NAMES_JS = [
161
+ 'const fs=require("fs"),os=require("os"),p=require("path");',
162
+ `const home=process.env.${ENGINE_RECORDS.homeEnv}||p.join(os.homedir(),".xanosdk","local-engine");`,
163
+ `try{const j=JSON.parse(fs.readFileSync(p.join(home,${JSON.stringify(ENGINE_RECORDS.file)}),"utf8"));`,
164
+ 'const e=j&&typeof j.engines==="object"&&j.engines?Object.values(j.engines):[];',
165
+ 'const n=[...new Set(e.map((r)=>r&&r.name).filter((x)=>typeof x==="string"&&/^[A-Za-z0-9._-]+$/.test(x)))];',
166
+ 'if(n.length)console.log(n.join(" "));}catch{}'
167
+ ].join("");
168
+ function scopes() {
169
+ const out = [];
170
+ for (const name of liveCommandNames()) {
171
+ const spec = getCommand(name);
172
+ out.push({
173
+ key: name,
174
+ flags: withGlobals(tokensFor(visibleFlags(spec)), name, void 0),
175
+ paths: wantsPaths(spec.args),
176
+ values: firstArgValues(spec.args),
177
+ valued: valuedFlags(visibleFlags(spec)),
178
+ kinds: kindedFlags(visibleFlags(spec), name, void 0),
179
+ inlineKinds: inlineKindedFlags(visibleFlags(spec))
180
+ });
181
+ for (const verb of liveSubcommandNames(name)) {
182
+ const sub = spec.subcommands[verb];
183
+ out.push({
184
+ key: `${name} ${verb}`,
185
+ flags: withGlobals(tokensFor(visibleFlags(sub)), name, verb),
186
+ paths: wantsPaths(sub.args),
187
+ values: firstArgValues(sub.args),
188
+ valued: valuedFlags(visibleFlags(sub)),
189
+ kinds: kindedFlags(visibleFlags(sub), name, verb),
190
+ inlineKinds: inlineKindedFlags(visibleFlags(sub))
191
+ });
192
+ }
193
+ }
194
+ return out;
195
+ }
196
+ function commandRows() {
197
+ return liveCommandNames().map((n) => [n, describe(getCommand(n).summary)]);
198
+ }
199
+ function subcommandRows(command) {
200
+ const spec = getCommand(command);
201
+ return liveSubcommandNames(command).map((v) => [v, describe(spec.subcommands[v].summary)]);
202
+ }
203
+ function renderBash() {
204
+ const commands = liveCommandNames().join(" ");
205
+ const subLines = liveCommandNames().filter((c) => liveSubcommandNames(c).length > 0).map((c) => ` ${c}) echo ${sq(liveSubcommandNames(c).join(" "))} ;;`);
206
+ const flagLines = scopes().filter((s) => s.flags.length > 0).map((s) => ` ${sq(s.key)}) echo ${sq(s.flags.join(" "))} ;;`);
207
+ const pathLines = scopes().filter((s) => s.paths).map((s) => sq(s.key)).join("|");
208
+ const valueLines = scopes().filter((s) => s.values.length > 0).map((s) => ` ${sq(s.key)}) echo ${sq(s.values.join(" "))} ;;`);
209
+ const flagValueLines = scopes().flatMap((s) => s.valued.map(([token, values]) => [`${s.key} ${token}`, values])).map(([k, values]) => ` ${sq(k)}) echo ${sq(values.join(" "))} ;;`);
210
+ const flagKindLines = scopes().flatMap(
211
+ (s) => s.kinds.map(([token, kind]) => ` ${sq(`${s.key} ${token}`)}) echo ${kind} ;;`)
212
+ );
213
+ const inlineKindLines = scopes().flatMap(
214
+ (s) => s.inlineKinds.map(([token, kind]) => ` ${sq(`${s.key} ${token}`)}) echo ${kind} ;;`)
215
+ );
216
+ return `# xanosdk completion for bash. Regenerate after upgrading:
217
+ # xanosdk completion bash > ~/.xanosdk-completion.bash
218
+ # echo 'source ~/.xanosdk-completion.bash' >> ~/.bashrc
219
+
220
+ _xanosdk_subcommands() {
221
+ case "$1" in
222
+ ${subLines.join("\n")}
223
+ esac
224
+ }
225
+
226
+ _xanosdk_flags() {
227
+ case "$1" in
228
+ ${flagLines.join("\n")}
229
+ esac
230
+ }
231
+
232
+ _xanosdk_argvalues() {
233
+ case "$1" in
234
+ ${valueLines.join("\n")}
235
+ esac
236
+ }
237
+
238
+ _xanosdk_flagvalues() {
239
+ case "$1" in
240
+ ${flagValueLines.join("\n")}
241
+ esac
242
+ }
243
+
244
+ # What the argument of a value flag is when it has no closed set: file, dir, profile, or free.
245
+ _xanosdk_flagkind() {
246
+ case "$1" in
247
+ ${flagKindLines.join("\n")}
248
+ esac
249
+ }
250
+
251
+ # The same, for a flag whose value is written only after \`=\` (\`--lock=<path>\`).
252
+ _xanosdk_inlinekind() {
253
+ case "$1" in
254
+ ${inlineKindLines.join("\n")}
255
+ esac
256
+ }
257
+
258
+ # Stored profile names (keys only \u2014 never a token), from the file this line reads.
259
+ _xanosdk_profiles() {
260
+ command -v node >/dev/null 2>&1 || return
261
+ node -e ${sq(PROFILE_NAMES_JS)} -- "\${COMP_WORDS[@]:1:COMP_CWORD-1}" 2>/dev/null
262
+ }
263
+
264
+ # Local engine names, from the engine records on this machine \u2014 nothing is started.
265
+ _xanosdk_engines() {
266
+ command -v node >/dev/null 2>&1 || return
267
+ node -e ${sq(ENGINE_NAMES_JS)} 2>/dev/null
268
+ }
269
+
270
+ _xanosdk() {
271
+ local cur cmd sub scope o=1
272
+ cur="\${COMP_WORDS[COMP_CWORD]}"
273
+ COMPREPLY=()
274
+
275
+ # Global flags typed before the command (\`xanosdk --json status\`) are
276
+ # skipped, value and all: the command is the first word after them.
277
+ while [ "$o" -lt "$COMP_CWORD" ]; do
278
+ case "\${COMP_WORDS[o]}" in
279
+ --json|--no-refresh|--profile=*) o=$((o + 1)) ;;
280
+ -p|--profile)
281
+ if [ "\${COMP_WORDS[o+1]}" = "=" ]; then o=$((o + 3)); else o=$((o + 2)); fi ;;
282
+ *) break ;;
283
+ esac
284
+ done
285
+ # Completing the value of a leading -p/--profile.
286
+ if [ "$COMP_CWORD" -lt "$o" ]; then
287
+ COMPREPLY=( $(compgen -W "$(_xanosdk_profiles)" -- "$cur") )
288
+ return
289
+ fi
290
+ cmd="\${COMP_WORDS[o]}"
291
+ sub="\${COMP_WORDS[o+1]}"
292
+
293
+ # The first word after any leading global flags is the command; a dash there
294
+ # is another global flag.
295
+ if [ "$COMP_CWORD" -eq "$o" ]; then
296
+ case "$cur" in
297
+ -*) COMPREPLY=( $(compgen -W ${sq(leadingGlobals())} -- "$cur") ) ;;
298
+ *) COMPREPLY=( $(compgen -W ${sq(commands)} -- "$cur") ) ;;
299
+ esac
300
+ return
301
+ fi
302
+
303
+ # \`help <command> [verb]\`: a command path, completed as one.
304
+ if [ "$cmd" = help ]; then
305
+ case "$cur" in
306
+ -*) ;;
307
+ *)
308
+ if [ "$COMP_CWORD" -eq $((o + 1)) ]; then
309
+ COMPREPLY=( $(compgen -W ${sq(commands)} -- "$cur") )
310
+ elif [ "$COMP_CWORD" -eq $((o + 2)) ]; then
311
+ COMPREPLY=( $(compgen -W "$(_xanosdk_subcommands "$sub")" -- "$cur") )
312
+ fi
313
+ return
314
+ ;;
315
+ esac
316
+ fi
317
+
318
+ # The word after a noun command is its verb.
319
+ local subs
320
+ subs="$(_xanosdk_subcommands "$cmd")"
321
+ if [ "$COMP_CWORD" -eq $((o + 1)) ] && [ -n "$subs" ]; then
322
+ COMPREPLY=( $(compgen -W "$subs" -- "$cur") )
323
+ return
324
+ fi
325
+
326
+ scope="$cmd"
327
+ if [ -n "$subs" ]; then scope="$cmd $sub"; fi
328
+
329
+ # A dash starts a flag; anything else is a positional.
330
+ case "$cur" in
331
+ -*)
332
+ COMPREPLY=( $(compgen -W "$(_xanosdk_flags "$scope")" -- "$cur") )
333
+ return
334
+ ;;
335
+ esac
336
+
337
+ # Directly after a flag that takes a value, that value, never the
338
+ # positional of the command.
339
+ local prev values kind eq=0
340
+ prev="\${COMP_WORDS[COMP_CWORD-1]}"
341
+ # bash splits \`--profile=prod\` at the \`=\` (COMP_WORDBREAKS): the flag is the
342
+ # word before it, and a bare \`=\` under the cursor is an empty value.
343
+ if [ "$cur" = "=" ]; then
344
+ cur=""
345
+ eq=1
346
+ elif [ "$prev" = "=" ] && [ "$COMP_CWORD" -ge 2 ]; then
347
+ prev="\${COMP_WORDS[COMP_CWORD-2]}"
348
+ eq=1
349
+ fi
350
+ case "$prev" in
351
+ -p|--profile)
352
+ COMPREPLY=( $(compgen -W "$(_xanosdk_profiles)" -- "$cur") )
353
+ return
354
+ ;;
355
+ esac
356
+ values="$(_xanosdk_flagvalues "$scope $prev")"
357
+ if [ -n "$values" ]; then
358
+ COMPREPLY=( $(compgen -W "$values" -- "$cur") )
359
+ return
360
+ fi
361
+ kind="$(_xanosdk_flagkind "$scope $prev")"
362
+ # After \`--flag=\` the word is the value of that flag, never a positional.
363
+ if [ -z "$kind" ] && [ "$eq" = 1 ] && [[ "$prev" == --* ]]; then
364
+ kind="$(_xanosdk_inlinekind "$scope $prev")"
365
+ [ -n "$kind" ] || kind=free
366
+ fi
367
+ case "$kind" in
368
+ profile)
369
+ COMPREPLY=( $(compgen -W "$(_xanosdk_profiles)" -- "$cur") )
370
+ return
371
+ ;;
372
+ file|dir)
373
+ compopt -o filenames 2>/dev/null
374
+ local IFS=$'\\n'
375
+ if [ "$kind" = dir ]; then COMPREPLY=( $(compgen -d -- "$cur") ); else COMPREPLY=( $(compgen -f -- "$cur") ); fi
376
+ return
377
+ ;;
378
+ # A free-form value (a name, a number, a URL): nothing to offer, not even files.
379
+ free)
380
+ compopt +o default 2>/dev/null
381
+ return
382
+ ;;
383
+ esac
384
+ # A profile name: the one \`profile use|show|delete|set-default\` takes.
385
+ case "$scope" in
386
+ ${PROFILE_NAME_VERBS.map((v) => sq(`profile ${v}`)).join("|")})
387
+ COMPREPLY=( $(compgen -W "$(_xanosdk_profiles)" -- "$cur") )
388
+ return
389
+ ;;
390
+ # The engine name \`local-engine stop|token\` takes.
391
+ ${ENGINE_NAME_VERBS.map((v) => sq(`local-engine ${v}`)).join("|")})
392
+ COMPREPLY=( $(compgen -W "$(_xanosdk_engines)" -- "$cur") )
393
+ return
394
+ ;;
395
+ esac
396
+
397
+ # A positional can take both a closed set and a file (deploy <source>: a
398
+ # backend kind or a bundle), so the set is offered and file names are
399
+ # added after it rather than instead of it.
400
+ values="$(_xanosdk_argvalues "$scope")"
401
+ if [ -n "$values" ]; then
402
+ COMPREPLY=( $(compgen -W "$values" -- "$cur") )
403
+ fi
404
+
405
+ case "$scope" in
406
+ ${pathLines || "''"}) COMPREPLY+=( $(compgen -f -- "$cur") ) ;;
407
+ esac
408
+ }
409
+
410
+ complete -o default -F _xanosdk xanosdk
411
+ `;
412
+ }
413
+ function renderZsh() {
414
+ const commandBlock = commandRows().map(([n, d]) => ` ${sq(`${n}:${d}`)}`).join("\n");
415
+ const familyBlocks = liveCommandNames().filter((c) => liveSubcommandNames(c).length > 0).map((c) => {
416
+ const rows = subcommandRows(c).map(([v, d]) => ` ${sq(`${v}:${d}`)}`).join("\n");
417
+ return ` ${c})
418
+ _xanosdk_verbs=(
419
+ ${rows}
420
+ )
421
+ ;;`;
422
+ }).join("\n");
423
+ const flagBlocks = scopes().filter((s) => s.flags.length > 0).map((s) => ` ${sq(s.key)}) _xanosdk_flags=(${s.flags.map(sq).join(" ")}) ;;`).join("\n");
424
+ const pathBlock = scopes().filter((s) => s.paths).map((s) => sq(s.key)).join("|");
425
+ const valueBlocks = scopes().filter((s) => s.values.length > 0).map((s) => ` ${sq(s.key)}) compadd ${s.values.map(sq).join(" ")}${s.paths ? "" : "; return"} ;;`).join("\n");
426
+ const flagValueBlocks = scopes().flatMap((s) => s.valued.map(([token, values]) => [`${s.key} ${token}`, values])).map(([k, values]) => ` ${sq(k)}) compadd ${values.map(sq).join(" ")}; return ;;`).join("\n");
427
+ const zshKind = {
428
+ file: "_files; return",
429
+ dir: "_files -/; return",
430
+ profile: "_xanosdk_profile_names; return",
431
+ // A free-form value (a name, a number, a URL): nothing to offer.
432
+ free: "return"
433
+ };
434
+ const flagKindBlocks = scopes().flatMap((s) => s.kinds.map(([token, kind]) => ` ${sq(`${s.key} ${token}`)}) ${zshKind[kind]} ;;`)).join("\n");
435
+ const inlineKindBlocks = scopes().flatMap((s) => s.inlineKinds.map(([token, kind]) => ` ${sq(`${s.key} ${token}`)}) ${zshKind[kind]} ;;`)).join("\n");
436
+ return `#compdef xanosdk
437
+ # xanosdk completion for zsh. Regenerate after upgrading:
438
+ # xanosdk completion zsh > "\${fpath[1]}/_xanosdk"
439
+ # # \u2026then restart your shell, or: autoload -U compinit && compinit
440
+
441
+ # Stored profile names (keys only \u2014 never a token), from the file this line reads.
442
+ _xanosdk_profile_names() {
443
+ (( $+commands[node] )) && compadd -- \${=$(node -e ${sq(PROFILE_NAMES_JS)} -- "\${(@)words[2,CURRENT-1]}" 2>/dev/null)}
444
+ }
445
+
446
+ _xanosdk() {
447
+ local -a _xanosdk_commands _xanosdk_verbs _xanosdk_flags
448
+ local cmd sub scope
449
+ _xanosdk_commands=(
450
+ ${commandBlock}
451
+ )
452
+
453
+ # Global flags typed before the command (\`xanosdk --json status\`) are
454
+ # skipped, value and all: the command is the first word after them.
455
+ local o=2
456
+ while (( o < CURRENT )); do
457
+ case "\${words[o]}" in
458
+ --json|--no-refresh|--profile=*) (( o += 1 )) ;;
459
+ -p|--profile) (( o += 2 )) ;;
460
+ *) break ;;
461
+ esac
462
+ done
463
+ # Completing the value of a leading -p/--profile.
464
+ if (( CURRENT < o )); then
465
+ _xanosdk_profile_names
466
+ return
467
+ fi
468
+
469
+ if (( CURRENT == o )); then
470
+ if [[ "\${words[CURRENT]}" == -* ]]; then
471
+ compadd -- ${leadingGlobals().split(" ").map(sq).join(" ")}
472
+ else
473
+ _describe -t commands 'xanosdk command' _xanosdk_commands
474
+ fi
475
+ return
476
+ fi
477
+
478
+ cmd="\${words[o]}"
479
+ case "$cmd" in
480
+ ${familyBlocks}
481
+ esac
482
+
483
+ # \`help <command> [verb]\`: a command path, completed as one.
484
+ if [[ "$cmd" == help && "\${words[CURRENT]}" != -* ]]; then
485
+ if (( CURRENT == o + 1 )); then
486
+ _describe -t commands 'xanosdk command' _xanosdk_commands
487
+ elif (( CURRENT == o + 2 )); then
488
+ cmd="\${words[o + 1]}"
489
+ case "$cmd" in
490
+ ${familyBlocks}
491
+ esac
492
+ (( \${#_xanosdk_verbs} )) && _describe -t subcommands "xanosdk $cmd subcommand" _xanosdk_verbs
493
+ fi
494
+ return
495
+ fi
496
+
497
+ if (( CURRENT == o + 1 )) && (( \${#_xanosdk_verbs} )); then
498
+ _describe -t subcommands "xanosdk $cmd subcommand" _xanosdk_verbs
499
+ return
500
+ fi
501
+
502
+ scope="$cmd"
503
+ if (( \${#_xanosdk_verbs} )); then
504
+ sub="\${words[o + 1]}"
505
+ scope="$cmd $sub"
506
+ fi
507
+
508
+ case "$scope" in
509
+ ${flagBlocks}
510
+ esac
511
+
512
+ # \`--flag=<value>\`: zsh keeps it one word, so the flag is what precedes its
513
+ # \`=\`, and the value completes after it as it would after \`--flag \`.
514
+ if [[ "\${words[CURRENT]}" == --*=* ]]; then
515
+ local eqflag="\${words[CURRENT]%%=*}"
516
+ compset -P "\${eqflag}="
517
+ case "$eqflag" in
518
+ --profile) _xanosdk_profile_names; return ;;
519
+ esac
520
+ case "$scope $eqflag" in
521
+ ${flagValueBlocks}
522
+ ${flagKindBlocks}
523
+ ${inlineKindBlocks}
524
+ esac
525
+ return
526
+ fi
527
+
528
+ if [[ "\${words[CURRENT]}" == -* ]]; then
529
+ compadd -a _xanosdk_flags
530
+ return
531
+ fi
532
+
533
+ # Directly after a flag that takes a value, that value, never the
534
+ # positional of the command.
535
+ case "\${words[CURRENT-1]}" in
536
+ -p|--profile) _xanosdk_profile_names; return ;;
537
+ esac
538
+ case "$scope \${words[CURRENT-1]}" in
539
+ ${flagValueBlocks}
540
+ ${flagKindBlocks}
541
+ esac
542
+
543
+ # A profile name: the one \`profile use|show|delete|set-default\` takes.
544
+ case "$scope" in
545
+ ${PROFILE_NAME_VERBS.map((v) => sq(`profile ${v}`)).join("|")})
546
+ _xanosdk_profile_names
547
+ return
548
+ ;;
549
+ esac
550
+ # The engine name \`local-engine stop|token\` takes, from the engine records on this machine.
551
+ case "$scope" in
552
+ ${ENGINE_NAME_VERBS.map((v) => sq(`local-engine ${v}`)).join("|")})
553
+ (( $+commands[node] )) && compadd -- \${=$(node -e ${sq(ENGINE_NAMES_JS)} 2>/dev/null)}
554
+ return
555
+ ;;
556
+ esac
557
+
558
+ case "$scope" in
559
+ ${valueBlocks}
560
+ esac
561
+
562
+ case "$scope" in
563
+ ${pathBlock || "'__none__'"}) _files ;;
564
+ esac
565
+ }
566
+
567
+ _xanosdk "$@"
568
+ `;
569
+ }
570
+ function renderFish() {
571
+ const families = liveCommandNames().filter((c) => subcommandRows(c).length > 0);
572
+ const valueFlags = new Set(valueFlagTokens());
573
+ const lines = [
574
+ "# xanosdk completion for fish. Regenerate after upgrading:",
575
+ "# xanosdk completion fish > ~/.config/fish/completions/xanosdk.fish",
576
+ "",
577
+ // Without this, fish offers files at every position.
578
+ "complete -c xanosdk -f",
579
+ "",
580
+ "# The command, and for a command with verbs the verb, typed so far. A flag",
581
+ "# is skipped, and so is the value of one that takes the next word",
582
+ "# (`-p prof status` is `status`, not `prof`).",
583
+ "function __xanosdk_scope",
584
+ " set -l typed (commandline -opc)",
585
+ " set -e typed[1]",
586
+ " set -l words",
587
+ " set -l skip 0",
588
+ " for w in $typed",
589
+ " if test $skip -eq 1",
590
+ " set skip 0",
591
+ " continue",
592
+ " end",
593
+ " switch $w",
594
+ ` case ${[...valueFlags].map(sq).join(" ")}`,
595
+ " set skip 1",
596
+ " case '-*'",
597
+ " case '*'",
598
+ " set -a words $w",
599
+ " end",
600
+ " end",
601
+ " test (count $words) -ge 1; or return",
602
+ ` if contains -- $words[1] ${families.map(sq).join(" ")}; and test (count $words) -ge 2`,
603
+ ' echo "$words[1] $words[2]"',
604
+ " else",
605
+ " echo $words[1]",
606
+ " end",
607
+ "end",
608
+ "",
609
+ "function __xanosdk_scope_is",
610
+ " set -l scope (__xanosdk_scope)",
611
+ ' test "$scope" = "$argv[1]"',
612
+ "end",
613
+ "",
614
+ "# No command typed yet \u2014 flags and their values aside.",
615
+ "function __xanosdk_no_command",
616
+ " set -l scope (__xanosdk_scope)",
617
+ ' test -z "$scope"',
618
+ "end",
619
+ "",
620
+ "# `help` followed by exactly the words in $argv (flags aside) \u2014 the help",
621
+ "# target typed so far, so the next word completes as a command or a verb.",
622
+ "function __xanosdk_help_on",
623
+ " set -l typed (commandline -opc)",
624
+ " set -e typed[1]",
625
+ " set -l words",
626
+ " for w in $typed",
627
+ " switch $w",
628
+ " case '-*'",
629
+ " case '*'",
630
+ " set -a words $w",
631
+ " end",
632
+ " end",
633
+ ' test "$words[1]" = help; or return 1',
634
+ " set -e words[1]",
635
+ ' test "$words" = "$argv"',
636
+ "end",
637
+ "",
638
+ "# Stored profile names (keys only \u2014 never a token), from the file this line reads.",
639
+ "function __xanosdk_profiles",
640
+ " set -l words (commandline -opc)",
641
+ " command -q node; or return",
642
+ ` node -e ${sq(PROFILE_NAMES_JS)} -- $words[2..-1] 2>/dev/null | string split ' '`,
643
+ "end",
644
+ "",
645
+ "# Local engine names, from the engine records on this machine \u2014 nothing is started.",
646
+ "function __xanosdk_engines",
647
+ " command -q node; or return",
648
+ ` node -e ${sq(ENGINE_NAMES_JS)} 2>/dev/null | string split ' '`,
649
+ "end",
650
+ "",
651
+ "# Directories for a directory flag's value. fish puts back a `--flag=` or `-f`",
652
+ "# it read off the token, so only the value is completed \u2014 and `-f=`'s `=` is",
653
+ "# part of what fish reads as the value.",
654
+ "function __xanosdk_dirs",
655
+ " set -l tok (commandline -ct)",
656
+ " set -l lead ''",
657
+ " if string match -qr -- '^--[^=]*=' $tok",
658
+ " set tok (string replace -r -- '^--[^=]*=' '' $tok)",
659
+ " else if string match -qr -- '^-[A-Za-z]=' $tok",
660
+ " set lead '='",
661
+ " set tok (string sub -s 4 -- $tok)",
662
+ " end",
663
+ ' for d in (__fish_complete_directories "$tok")',
664
+ " printf '%s%s\\n' $lead $d",
665
+ " end",
666
+ "end",
667
+ ""
668
+ ];
669
+ for (const [name, desc] of commandRows()) {
670
+ lines.push(`complete -c xanosdk -n __xanosdk_no_command -a ${sq(name)} -d ${sq(desc)}`);
671
+ }
672
+ for (const token of leadingGlobals().split(" ")) lines.push(fishFlagLine("__xanosdk_no_command", token, valueFlags));
673
+ for (const [name, desc] of commandRows()) {
674
+ lines.push(`complete -c xanosdk -n '__xanosdk_help_on' -a ${sq(name)} -d ${sq(desc)}`);
675
+ }
676
+ for (const command of families) {
677
+ for (const [verb, desc] of subcommandRows(command)) {
678
+ lines.push(`complete -c xanosdk -n ${sq(`__xanosdk_help_on ${command}`)} -a ${sq(verb)} -d ${sq(desc)}`);
679
+ }
680
+ }
681
+ for (const command of families) {
682
+ lines.push("");
683
+ const condition = `__xanosdk_scope_is ${sq(command)}`;
684
+ for (const [verb, desc] of subcommandRows(command)) {
685
+ lines.push(`complete -c xanosdk -n ${sq(condition)} -a ${sq(verb)} -d ${sq(desc)}`);
686
+ }
687
+ }
688
+ lines.push("");
689
+ for (const scope of scopes()) {
690
+ if (scope.flags.length === 0 && !scope.paths && scope.values.length === 0) continue;
691
+ const condition = `__xanosdk_scope_is ${sq(scope.key)}`;
692
+ const values = new Map(scope.valued);
693
+ const kinds = new Map(scope.kinds);
694
+ for (const token of scope.flags) lines.push(fishFlagLine(condition, token, valueFlags, values.get(token), kinds.get(token)));
695
+ if (scope.values.length > 0) {
696
+ lines.push(`complete -c xanosdk -n ${sq(condition)} -a ${sq(scope.values.join(" "))}`);
697
+ }
698
+ if (PROFILE_NAME_VERBS.some((v) => scope.key === `profile ${v}`)) {
699
+ lines.push(`complete -c xanosdk -n ${sq(condition)} -a '(__xanosdk_profiles)'`);
700
+ }
701
+ if (ENGINE_NAME_VERBS.some((v) => scope.key === `local-engine ${v}`)) {
702
+ lines.push(`complete -c xanosdk -n ${sq(condition)} -a '(__xanosdk_engines)'`);
703
+ }
704
+ if (scope.paths) lines.push(`complete -c xanosdk -n ${sq(condition)} -F`);
705
+ }
706
+ return lines.join("\n") + "\n";
707
+ }
708
+ function fishFlagLine(condition, token, valueFlags, set, kind) {
709
+ const bare = token.replace(/^-+/, "");
710
+ const which = token.startsWith("--") ? "-l" : "-s";
711
+ const cond = /^[a-z_]+$/.test(condition) ? condition : sq(condition);
712
+ const suffix = set !== void 0 ? ` -x -a ${sq(set.join(" "))}` : kind === "profile" || token === "-p" || token === "--profile" ? " -x -a '(__xanosdk_profiles)'" : kind === "file" ? " -r -F" : kind === "dir" ? " -x -a '(__xanosdk_dirs)'" : valueFlags.has(token) || kind === "free" ? " -x" : "";
713
+ return `complete -c xanosdk -n ${cond} ${which} ${sq(bare)}${suffix}`;
714
+ }
715
+ function renderCompletion(shell) {
716
+ switch (shell) {
717
+ case "bash":
718
+ return renderBash();
719
+ case "zsh":
720
+ return renderZsh();
721
+ case "fish":
722
+ return renderFish();
723
+ }
724
+ }
725
+ function runCompletionCommand(shell) {
726
+ process.stdout.write(renderCompletion(shell));
727
+ }
728
+ export {
729
+ COMPLETION_SHELLS,
730
+ ENGINE_RECORDS,
731
+ UNSUPPORTED_SHELLS,
732
+ inlineValueKind,
733
+ isCompletionShell,
734
+ renderCompletion,
735
+ runCompletionCommand,
736
+ valueKind
737
+ };
738
+ //# sourceMappingURL=completion-ZQLO6PB6.js.map