@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,157 @@
1
+ import {
2
+ backendDirIn
3
+ } from "./chunk-5A2PLKZB.js";
4
+ import {
5
+ shellWord
6
+ } from "./chunk-FWD7AL6N.js";
7
+ import {
8
+ isHomeRelative
9
+ } from "./chunk-EUUUMY7J.js";
10
+ import {
11
+ pointerRootFor
12
+ } from "./chunk-5FBYXK5P.js";
13
+ import {
14
+ UsageError,
15
+ setTypedCwd
16
+ } from "./chunk-PTHVMXZI.js";
17
+
18
+ // src/emit/xanosdk-project.ts
19
+ import { existsSync, realpathSync, statSync } from "fs";
20
+ import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "path";
21
+ function isProjectDir(cwd) {
22
+ return existsSync(join(backendDirIn(cwd), "index.ts")) || existsSync(join(cwd, ".xano"));
23
+ }
24
+ function projectDirFrom(start) {
25
+ const root = pointerRootFor(start);
26
+ let dir = resolve(start);
27
+ for (; ; ) {
28
+ if (isProjectDir(dir)) return dir;
29
+ const parent = dirname(dir);
30
+ if (dir === root || parent === dir) return void 0;
31
+ dir = parent;
32
+ }
33
+ }
34
+ var RELATIVE_PATH_ARGS = ["out", "lockPath", "entryPath", "static", "bundle", "envFile", "secretsFile", "backendDir", "emit", "path"];
35
+ var PATH_VARS = ["XANO_CONFIG", "XANO_GLOBAL_CONFIG", "XANO_CLIENT_FILE", "XANOSDK_UPDATE_CACHE", "XANOSDK_PROVE_DIFF", "XANOSDK_LOCAL_ENGINE_HOME", "XANOSDK_LOCAL_ENGINE_OVERRIDE"];
36
+ function enterProjectRoot(args, cwd = process.cwd(), positional) {
37
+ const here = resolve(cwd);
38
+ const at = positional === "verb-path" ? 1 : 0;
39
+ const first = positional === void 0 ? void 0 : at === 1 ? args.positionals?.[1] : args.positionals?.[0] ?? args.file;
40
+ const typedEntry = positional === "entry" && first !== void 0 && first !== "-" && args.bundlePositional !== true ? first : args.entryPath;
41
+ const cwdRoot = projectDirFrom(here);
42
+ if (cwdRoot !== void 0 && typedEntry !== void 0) {
43
+ const owner = entryOwner(resolve(here, typedEntry), cwdRoot);
44
+ if (owner !== void 0 && owner !== cwdRoot) throw foreignEntryRefusal(args, here, cwdRoot, owner, typedEntry, first);
45
+ }
46
+ const root = cwdRoot ?? (typedEntry !== void 0 ? projectDirFrom(dirname(resolve(here, typedEntry))) : void 0);
47
+ if (root === void 0 || root === here) return void 0;
48
+ const fromRoot = (p) => {
49
+ if (p === void 0 || p === "-" || isAbsolute(p)) return p;
50
+ if (!existsSync(resolve(here, p)) && existsSync(resolve(root, p))) return p;
51
+ return relative(root, resolve(here, p)) || ".";
52
+ };
53
+ const next = { ...args };
54
+ for (const key of RELATIVE_PATH_ARGS) next[key] = fromRoot(args[key]);
55
+ if (first !== void 0 && (at === 0 || existsSync(resolve(here, first)))) {
56
+ const moved = fromRoot(first);
57
+ if (at === 0 && args.file === first) next.file = moved;
58
+ if (args.positionals !== void 0 && args.positionals.length > at) {
59
+ next.positionals = args.positionals.map((p, n) => n === at ? moved : p);
60
+ }
61
+ }
62
+ if (args.authFile !== void 0) next.authFile = resolve(here, args.authFile);
63
+ const engine = args.localEngineUrl;
64
+ if (engine !== void 0 && isRelativePath(engine)) next.localEngineUrl = fromRoot(engine);
65
+ const saved = PATH_VARS.map((name) => [name, process.env[name]]);
66
+ for (const [name, value] of saved) {
67
+ if (value !== void 0 && !isHomeRelative(value) && isRelativePath(value)) process.env[name] = resolve(here, value);
68
+ }
69
+ setTypedCwd(here);
70
+ process.chdir(root);
71
+ return {
72
+ args: next,
73
+ root,
74
+ restore: () => {
75
+ process.chdir(here);
76
+ setTypedCwd(void 0);
77
+ for (const [name, value] of saved) {
78
+ if (value === void 0) delete process.env[name];
79
+ else process.env[name] = value;
80
+ }
81
+ }
82
+ };
83
+ }
84
+ function ownsEntries(dir) {
85
+ return existsSync(join(backendDirIn(dir), "index.ts"));
86
+ }
87
+ function entryOwner(entry, cwdRoot) {
88
+ const root = realDir(cwdRoot);
89
+ let dir = realDir(isDirectory(entry) ? entry : dirname(entry));
90
+ const bound = realDir(pointerRootFor(dir));
91
+ for (; ; ) {
92
+ if (dir === root) return cwdRoot;
93
+ if (ownsEntries(dir)) return dir;
94
+ const parent = dirname(dir);
95
+ if (dir === bound || parent === dir) return void 0;
96
+ dir = parent;
97
+ }
98
+ }
99
+ function realDir(dir) {
100
+ try {
101
+ return realpathSync(dir);
102
+ } catch {
103
+ const parent = dirname(dir);
104
+ return parent === dir ? dir : join(realDir(parent), basename(dir));
105
+ }
106
+ }
107
+ function isDirectory(path) {
108
+ try {
109
+ return statSync(path).isDirectory();
110
+ } catch {
111
+ return false;
112
+ }
113
+ }
114
+ function foreignEntryRefusal(args, here, cwdRoot, owner, typedEntry, first) {
115
+ const shown = (dir) => {
116
+ const rel = relative(here, dir).split(sep).join("/") || ".";
117
+ return rel.split("/").filter((part) => part === "..").length > 2 ? dir : rel;
118
+ };
119
+ const rerunFrom = (dir) => {
120
+ const rebased = /* @__PURE__ */ new Map();
121
+ for (const value of [typedEntry, first, ...RELATIVE_PATH_ARGS.map((key) => args[key])]) {
122
+ if (value === void 0 || value === "-" || isAbsolute(value)) continue;
123
+ rebased.set(value, relative(dir, resolve(here, value)).split(sep).join("/") || ".");
124
+ }
125
+ const words = (args.argv ?? []).map((token) => {
126
+ const whole = rebased.get(token);
127
+ if (whole !== void 0) return whole;
128
+ const eq = token.indexOf("=");
129
+ if (token.startsWith("-") && eq !== -1) {
130
+ const value = rebased.get(token.slice(eq + 1));
131
+ if (value !== void 0) return `${token.slice(0, eq + 1)}${value}`;
132
+ }
133
+ return token;
134
+ });
135
+ return `cd ${shellWord(shown(dir))} && xanosdk ${words.map(shellWord).join(" ")}`;
136
+ };
137
+ let outside = dirname(cwdRoot);
138
+ while (outside !== void 0 && projectDirFrom(outside) !== void 0) {
139
+ const parent = dirname(outside);
140
+ outside = parent === outside ? void 0 : parent;
141
+ }
142
+ const ways = `Run it in that project: \`${rerunFrom(owner)}\`` + (outside === void 0 || args.argv === void 0 ? "." : `, or from a directory outside both: \`${rerunFrom(outside)}\`.`);
143
+ return new UsageError(
144
+ `${typedEntry} belongs to the project at ${owner}, not the one this command runs in (${cwdRoot}). A run uses one project for its credential, tracked backend, lock and landing record, so nothing was run. ${ways}`
145
+ );
146
+ }
147
+ function isRelativePath(value) {
148
+ return value !== "" && !isAbsolute(value) && !/^[a-z][a-z0-9+.-]*:\/\//i.test(value) && !/^v?\d+\.\d+\.\d+$/.test(value);
149
+ }
150
+
151
+ export {
152
+ isProjectDir,
153
+ projectDirFrom,
154
+ RELATIVE_PATH_ARGS,
155
+ enterProjectRoot
156
+ };
157
+ //# sourceMappingURL=chunk-6NNTNXN7.js.map
@@ -0,0 +1,97 @@
1
+ import {
2
+ SENT_AFTERMATH,
3
+ TransportError,
4
+ certificateFailureCode,
5
+ closeSentence,
6
+ lostAnswerHead,
7
+ markupSummary,
8
+ notJsonError,
9
+ parseJsonAnswer,
10
+ unexpectedAnswerError
11
+ } from "./chunk-YLDALTWZ.js";
12
+
13
+ // src/deploy/answer-shape.ts
14
+ function isRecord(v) {
15
+ return v !== null && typeof v === "object" && !Array.isArray(v);
16
+ }
17
+ function hasString(row, key) {
18
+ return typeof row[key] === "string" && row[key] !== "";
19
+ }
20
+ function refusalOpts(opts) {
21
+ return {
22
+ ...opts.safe === true ? { safe: true } : {},
23
+ ...opts.write === true ? { aftermath: SENT_AFTERMATH } : {}
24
+ };
25
+ }
26
+ function notTheAnswer(action, text, url, opts = {}) {
27
+ let parsed = true;
28
+ try {
29
+ JSON.parse(text);
30
+ } catch {
31
+ parsed = false;
32
+ }
33
+ return parsed || text.trim() === "" ? unexpectedAnswerError(action, text, url, refusalOpts(opts)) : notJsonError(action, text, url, refusalOpts(opts));
34
+ }
35
+ function parseAnswer(text, action, url, opts = {}) {
36
+ if (text.trim() === "") throw notTheAnswer(action, text, url, opts);
37
+ return parseJsonAnswer(text, action, url, refusalOpts(opts));
38
+ }
39
+ function recordAnswer(text, action, url, isAnswer, opts = {}) {
40
+ const data = parseAnswer(text, action, url, opts);
41
+ if (!isRecord(data) || !isAnswer(data)) throw notTheAnswer(action, text, url, opts);
42
+ return data;
43
+ }
44
+ function listAnswer(text, action, url, isRow, opts = {}) {
45
+ const data = parseAnswer(text, action, url, opts);
46
+ const envelope = isRecord(data) ? data : void 0;
47
+ const rows = Array.isArray(data) ? data : Array.isArray(envelope?.items) ? envelope.items : void 0;
48
+ if (rows === void 0 || !rows.every((r) => isRecord(r) && isRow(r))) throw notTheAnswer(action, text, url, opts);
49
+ return { rows, envelope };
50
+ }
51
+ function deleteAnswer(text, action, url, opts = {}) {
52
+ if (text.trim() === "null") return;
53
+ throw notTheAnswer(action, text, url, { ...opts, write: true });
54
+ }
55
+ function multidocAnswer(text, action, url) {
56
+ const refuse = () => notTheAnswer(action, text, url);
57
+ if (text.trim() === "" || markupSummary(text) !== void 0) throw refuse();
58
+ let isJson = true;
59
+ try {
60
+ JSON.parse(text);
61
+ } catch {
62
+ isJson = false;
63
+ }
64
+ if (isJson) throw unexpectedAnswerError(action, text, url);
65
+ const first = text.split("\n").map((l) => l.trim()).find((l) => l !== "" && !l.startsWith("//"));
66
+ if (first === void 0 || !/^[a-z][a-z_]*\s[^{]*\{/.test(first)) throw refuse();
67
+ return text;
68
+ }
69
+ var NOT_SENT = /* @__PURE__ */ new Set(["ECONNREFUSED", "ENOTFOUND", "EAI_AGAIN", "ENETUNREACH", "EHOSTUNREACH"]);
70
+ function writeTransportFailure(err) {
71
+ if (!(err instanceof TransportError)) return err;
72
+ if (certificateFailureCode(err) !== void 0) return err;
73
+ if (/may or may not have taken effect|Nothing was (sent|changed)/.test(err.message)) {
74
+ if (!/Nothing was changed/.test(err.message)) return err;
75
+ }
76
+ const first = err.message.split("\n")[0];
77
+ const inner = err.cause?.cause;
78
+ const code = inner?.code;
79
+ const notSent = typeof code === "string" && NOT_SENT.has(code) || inner?.message === "bad port";
80
+ const head = closeSentence(notSent ? first : lostAnswerHead(first, err.cause));
81
+ const aftermath = notSent ? "Nothing was sent \u2014 retry." : SENT_AFTERMATH;
82
+ return new TransportError(`${head}
83
+ ${aftermath}`, err.timeout, { cause: err.cause });
84
+ }
85
+
86
+ export {
87
+ isRecord,
88
+ hasString,
89
+ notTheAnswer,
90
+ parseAnswer,
91
+ recordAnswer,
92
+ listAnswer,
93
+ deleteAnswer,
94
+ multidocAnswer,
95
+ writeTransportFailure
96
+ };
97
+ //# sourceMappingURL=chunk-6PBR37LN.js.map
@@ -0,0 +1,155 @@
1
+ import {
2
+ NPM_RUN_TIMEOUT_MS,
3
+ isPeerConflict,
4
+ runNpmQuiet
5
+ } from "./chunk-ZFDZKNGG.js";
6
+ import {
7
+ shellWord
8
+ } from "./chunk-FWD7AL6N.js";
9
+ import {
10
+ isLocalSpecifier
11
+ } from "./chunk-2GNFDZA2.js";
12
+ import {
13
+ trackLocalWrite
14
+ } from "./chunk-4KHEMC32.js";
15
+ import {
16
+ addArgs,
17
+ installSite,
18
+ npmLockListsMember,
19
+ removeArgs,
20
+ yarnPlugAndPlayRoot
21
+ } from "./chunk-WRBKLYSJ.js";
22
+ import {
23
+ localPackageName,
24
+ localPathOf,
25
+ packageNameOf,
26
+ readInstalledManifestState
27
+ } from "./chunk-3LDULPRE.js";
28
+ import {
29
+ UsageError
30
+ } from "./chunk-PTHVMXZI.js";
31
+
32
+ // src/emit/project-dependency.ts
33
+ import { existsSync, readFileSync } from "fs";
34
+ import { isAbsolute, join, relative, resolve, sep } from "path";
35
+
36
+ // src/emit/npm-install.ts
37
+ async function installWithPeerRetry(specifier, cwd, opts = {}) {
38
+ const scope = opts.scope ?? [];
39
+ if (opts.manager !== void 0 && opts.manager !== "npm") {
40
+ const only = await runNpmQuiet([...addArgs(opts.manager, specifier), ...scope], cwd, { manager: opts.manager, ...opts.timeoutMs !== void 0 ? { timeoutMs: opts.timeoutMs } : {} });
41
+ return { ...only, peerConflict: null, retried: false };
42
+ }
43
+ const budget = opts.timeoutMs ?? NPM_RUN_TIMEOUT_MS;
44
+ const deadline = Date.now() + budget;
45
+ const first = await runNpmQuiet(["install", specifier, ...scope], cwd, { timeoutMs: budget });
46
+ if (first.status === 0 || !isPeerConflict(first.output)) {
47
+ return { ...first, peerConflict: null, retried: false };
48
+ }
49
+ const remaining = deadline - Date.now();
50
+ if (remaining <= 0) return { ...first, peerConflict: first.output, retried: false };
51
+ opts.onRetry?.();
52
+ const second = await runNpmQuiet(["install", specifier, ...scope, "--legacy-peer-deps"], cwd, {
53
+ timeoutMs: remaining
54
+ });
55
+ return { ...second, peerConflict: first.output, retried: true };
56
+ }
57
+
58
+ // src/emit/project-dependency.ts
59
+ function interruptedCheck(name, site, rerun) {
60
+ const ls = site.manager === "npm" ? ` (\`npm ls ${name}\`)` : "";
61
+ return `Check whether package.json lists ${name}${ls}, then re-run ${rerun === void 0 ? "the command" : `\`${rerun}\``} \u2014 it picks up what landed.`;
62
+ }
63
+ function refusePlugAndPlay(dir, rerun) {
64
+ const root = yarnPlugAndPlayRoot(dir);
65
+ if (root === void 0) return;
66
+ const rel = relative(process.cwd(), root).split(sep).join("/");
67
+ const rc = rel === "" ? ".yarnrc.yml" : `${rel}/.yarnrc.yml`;
68
+ const install = rel === "" ? "yarn install" : `(cd ${shellWord(rel)} && yarn install)`;
69
+ throw new UsageError(
70
+ `This project installs with Yarn Plug'n'Play, which Xano SDK does not support: the CLI, its modules and the scaffold's build read packages from node_modules. Add \`nodeLinker: node-modules\` to ${shellWord(rc)}, run \`${install}\`, then re-run \`${rerun}\`.`
71
+ );
72
+ }
73
+ function dependenciesOf(dir) {
74
+ const deps = /* @__PURE__ */ new Map();
75
+ try {
76
+ const manifest = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
77
+ for (const block of ["dependencies", "devDependencies", "optionalDependencies"]) {
78
+ for (const [name, range] of Object.entries(manifest[block] ?? {})) {
79
+ if (typeof range === "string") deps.set(name, range);
80
+ }
81
+ }
82
+ } catch {
83
+ }
84
+ return deps;
85
+ }
86
+ async function prepareInstallSite(dir, onLink) {
87
+ const site = installSite(dir);
88
+ const member = site.scope[0] === "-w" ? site.scope[1] : void 0;
89
+ if (member === void 0 || npmLockListsMember(site.cwd, member)) return { site, link: null };
90
+ onLink?.(member);
91
+ const link = await runNpmQuiet(["install", ...site.scope], site.cwd);
92
+ return {
93
+ site,
94
+ link: link.status === 0 ? link : { ...link, output: `Linking ${member} into the npm workspace at ${site.cwd} failed:
95
+ ${link.output}` }
96
+ };
97
+ }
98
+ async function addDependency(dir, specifier, opts = {}) {
99
+ const name = localPackageName(specifier, dir) ?? (isLocalSpecifier(specifier) ? specifier : packageNameOf(specifier));
100
+ const check = interruptedCheck(name, installSite(dir), opts.rerun);
101
+ return trackLocalWrite({ what: `the install of ${name}`, check }, async () => {
102
+ const { site, link } = await prepareInstallSite(dir, opts.onLink);
103
+ const installSpec = site.cwd === resolve(dir) ? specifier : rebaseSpec(specifier, dir, site.cwd);
104
+ if (link !== null && link.status !== 0) return { ...link, peerConflict: null, retried: false, site, installSpec };
105
+ const before = dependenciesOf(dir);
106
+ const result = await installWithPeerRetry(installSpec, site.cwd, {
107
+ ...opts.onRetry === void 0 ? {} : { onRetry: opts.onRetry },
108
+ scope: site.scope,
109
+ ...site.manager !== "npm" ? { manager: site.manager } : {}
110
+ });
111
+ if (result.status !== 0) return { ...result, site, installSpec };
112
+ const recorded = recordedDependency(dir, specifier, before);
113
+ const landed = recorded !== void 0 && readInstalledManifestState(dir, recorded).kind !== "absent" ? recorded : void 0;
114
+ return { ...result, site, installSpec, ...recorded === void 0 ? {} : { recorded }, ...landed === void 0 ? {} : { landed } };
115
+ });
116
+ }
117
+ async function removeDependency(dir, pkg, rerun) {
118
+ return trackLocalWrite({ what: `the removal of ${pkg}`, check: interruptedCheck(pkg, installSite(dir), rerun) }, async () => {
119
+ const { site, link } = await prepareInstallSite(dir);
120
+ if (link !== null && link.status !== 0) return { ...link, site, stillListed: true };
121
+ const args = [...removeArgs(site.manager, pkg), ...site.scope];
122
+ const result = await (site.manager === "npm" ? runNpmQuiet(args, site.cwd) : runNpmQuiet(args, site.cwd, { manager: site.manager }));
123
+ return { ...result, site, stillListed: result.status === 0 && dependenciesOf(dir).has(pkg) };
124
+ });
125
+ }
126
+ function recordedDependency(dir, specifier, before) {
127
+ const after = dependenciesOf(dir);
128
+ const known = localPackageName(specifier, dir) ?? (isLocalSpecifier(specifier) ? void 0 : packageNameOf(specifier));
129
+ const name = known ?? (() => {
130
+ const changed = [...after].filter(([n, range]) => before.get(n) !== range).map(([n]) => n);
131
+ if (changed.length === 1) return changed[0];
132
+ const same = [...after].filter(([, range]) => range === specifier).map(([n]) => n);
133
+ return same.length === 1 ? same[0] : void 0;
134
+ })();
135
+ return name !== void 0 && after.has(name) ? name : void 0;
136
+ }
137
+ function rebaseSpec(spec, from, to) {
138
+ const path = localPathOf(spec);
139
+ if (path === void 0 || isAbsolute(path)) return spec;
140
+ const abs = resolve(from, path);
141
+ if (!existsSync(abs)) return spec;
142
+ const rel = relative(resolve(to), abs).split(sep).join("/");
143
+ const rebased = rel.startsWith("..") ? rel : `./${rel}`;
144
+ return spec.startsWith("file:") ? `file:${rebased}` : rebased;
145
+ }
146
+
147
+ export {
148
+ refusePlugAndPlay,
149
+ dependenciesOf,
150
+ prepareInstallSite,
151
+ addDependency,
152
+ removeDependency,
153
+ recordedDependency
154
+ };
155
+ //# sourceMappingURL=chunk-6QXLMMT3.js.map
@@ -0,0 +1,224 @@
1
+ import {
2
+ assertNoFlagCollisions,
3
+ flagFor,
4
+ hostHelpTarget,
5
+ hostLabel,
6
+ questionSets,
7
+ resolvePluginAnswers
8
+ } from "./chunk-H5C7MBCR.js";
9
+ import {
10
+ gitattributesSpec
11
+ } from "./chunk-DGWHAVRG.js";
12
+ import {
13
+ UsageError,
14
+ warn
15
+ } from "./chunk-PTHVMXZI.js";
16
+ import {
17
+ withArticle
18
+ } from "./chunk-36JUQZVQ.js";
19
+
20
+ // src/emit/plugin-contributions.ts
21
+ function assertContractShape(pkg, plugin, host) {
22
+ const shape = plugin;
23
+ if (typeof shape["files"] === "function" && shape["contributes"] === void 0) {
24
+ throw new UsageError(
25
+ `${pkg} declares a \`files\` hook and no \`contributes\`, so it was built against a \`@xano/sdk/plugin\` contract that no longer exists \u2014 \`${hostLabel(host)}\` would register it and apply nothing.`,
26
+ {
27
+ helpFor: hostHelpTarget(host),
28
+ suggestion: `That is the module's upgrade to make: rename \`files(answers)\` to \`contributes(answers)\`, which returns a \`ProjectContributions\`. Until it ships, remove ${pkg} or set \`"${pkg}": { "enabled": false }\` in this project's package.json "xanosdk" block.`
29
+ }
30
+ );
31
+ }
32
+ }
33
+ function assertUsableContributions(pkg, parts, host) {
34
+ if (parts["ciSteps"] !== void 0) {
35
+ throw new UsageError(
36
+ `${pkg} contributes \`ciSteps\`, a slot \`@xano/sdk\` no longer has, so \`${hostLabel(host)}\` would drop its CI step in silence.`,
37
+ {
38
+ helpFor: hostHelpTarget(host),
39
+ suggestion: `That is the module's upgrade to make: drop the \`ciSteps\` entry. A module's own check already runs under \`xanosdk export --frozen-lock\`, which fires \`onBundle\` with \`frozen\` set, so it needs no workflow step of its own.`
40
+ }
41
+ );
42
+ }
43
+ const config = parts.config;
44
+ if (config !== void 0 && (typeof config !== "object" || config === null || Array.isArray(config))) {
45
+ throw new UsageError(
46
+ `${pkg} contributes a \`config\` that is ${describeValue(config)} where that module's settings object is expected, so \`${hostLabel(host)}\` would write a "xanosdk" block every later run refuses to read.`,
47
+ {
48
+ helpFor: hostHelpTarget(host),
49
+ suggestion: `That is the module's bug to fix: return a plain object from the \`config\` slot, or omit the slot entirely.`
50
+ }
51
+ );
52
+ }
53
+ const { dialect } = gitattributesSpec(pkg);
54
+ const markers = [dialect.begin("").trim(), dialect.end("").trim()];
55
+ for (const entry of parts.gitattributes ?? []) {
56
+ for (const line of entry.split(/\r?\n/)) {
57
+ const trimmed = line.trim();
58
+ const pattern = trimmed.split(/\s+/)[0] ?? "";
59
+ if (markers.some((marker) => trimmed.startsWith(marker))) {
60
+ throw new UsageError(
61
+ `${pkg} contributes a \`.gitattributes\` line that spells a xanosdk block marker (\`${trimmed}\`), which would leave the file with markers no run can balance.`,
62
+ {
63
+ helpFor: hostHelpTarget(host),
64
+ suggestion: `The markers are the SDK's: it writes them around whatever a module contributes. Contribute the rules alone.`
65
+ }
66
+ );
67
+ }
68
+ if (pattern === "*") {
69
+ throw new UsageError(
70
+ `${pkg} contributes a \`.gitattributes\` rule for \`*\`, which would override the line-ending rule every generated artifact is compared against.`,
71
+ {
72
+ helpFor: hostHelpTarget(host),
73
+ suggestion: `A module may only add rules for paths it owns.`
74
+ }
75
+ );
76
+ }
77
+ if (/\b(text|eol)\s*=/.test(line) || /\s-text\b/.test(line)) {
78
+ throw new UsageError(
79
+ `${pkg} contributes a \`.gitattributes\` rule that sets \`text\`/\`eol\` (\`${trimmed}\`). Line endings are the template's to set: a frozen check compares bytes, and a rule that reintroduces CRLF fails every run on a Windows checkout.`,
80
+ {
81
+ helpFor: hostHelpTarget(host),
82
+ suggestion: `Contribute display rules (\`linguist-*\`, \`diff\`) instead.`
83
+ }
84
+ );
85
+ }
86
+ }
87
+ }
88
+ }
89
+ function describeValue(value) {
90
+ if (value === null) return "null";
91
+ if (Array.isArray(value)) return "an array";
92
+ return withArticle(typeof value);
93
+ }
94
+ function priorAnswers(loaded, host) {
95
+ const out = {};
96
+ for (const p of loaded) {
97
+ assertContractShape(p.pkg, p.plugin, host);
98
+ if (p.plugin.answersFromConfig === void 0) continue;
99
+ if (Object.keys(p.config).length === 0) continue;
100
+ const ids = new Set((p.plugin.questions ?? []).map((q) => q.id));
101
+ let read;
102
+ try {
103
+ read = p.plugin.answersFromConfig(
104
+ p.config
105
+ ) ?? {};
106
+ } catch (error) {
107
+ warn(
108
+ `${p.pkg} could not read its stored settings back; its defaults were used instead.`,
109
+ "module.settings-unreadable",
110
+ [error instanceof Error ? error.message : String(error)]
111
+ );
112
+ continue;
113
+ }
114
+ const kept = {};
115
+ for (const [id, value] of Object.entries(read)) {
116
+ if (!ids.has(id)) continue;
117
+ if (typeof value === "string" || typeof value === "boolean")
118
+ kept[id] = value;
119
+ }
120
+ if (Object.keys(kept).length > 0) out[p.pkg] = kept;
121
+ }
122
+ return out;
123
+ }
124
+ async function runPluginQuestionnaire(loaded, opts) {
125
+ const sets = questionSets(loaded);
126
+ assertNoFlagCollisions(sets, opts.host);
127
+ const prior = priorAnswers(loaded, opts.host);
128
+ const resolved = await resolvePluginAnswers(sets, {
129
+ host: opts.host,
130
+ unknownFlags: opts.unknownFlags,
131
+ prompter: opts.prompter,
132
+ prior
133
+ });
134
+ const answers = {};
135
+ const sources = {};
136
+ const flags = {};
137
+ const questionsFor = new Map(sets.map((s) => [s.pkg, s.questions]));
138
+ for (const [pkg, r] of Object.entries(resolved)) {
139
+ answers[pkg] = r.answers;
140
+ sources[pkg] = r.sources;
141
+ flags[pkg] = Object.fromEntries(
142
+ (questionsFor.get(pkg) ?? []).filter((q) => r.answers[q.id] !== void 0).map((q) => [q.id, flagFor(q)])
143
+ );
144
+ for (const gone of r.dropped) {
145
+ warn(
146
+ gone.why === "excluded" ? `${pkg}: \`${gone.id}\` is no longer asked, so its stored setting was dropped.` : `${pkg}: the stored setting for \`${gone.id}\` is no longer a value that question accepts, so the module's default was used.`,
147
+ "module.setting-dropped"
148
+ );
149
+ }
150
+ }
151
+ return { answers, sources, flags, prior };
152
+ }
153
+ function recordedConfig(outcome, stored) {
154
+ if (outcome.status === "failed") return void 0;
155
+ if (outcome.status === "none") return stored === void 0 ? {} : void 0;
156
+ const parts = outcome.parts ?? {};
157
+ if (parts.config !== void 0) return parts.config;
158
+ if ((parts.gitattributes ?? []).length > 0) return stored === void 0 ? {} : void 0;
159
+ return { enabled: false };
160
+ }
161
+ function assertContributionsShape(pkg, returned, host) {
162
+ if (returned === void 0 || returned === null) return {};
163
+ const thenable = typeof returned.then === "function";
164
+ if (typeof returned !== "object" || Array.isArray(returned) || thenable) {
165
+ throw new UsageError(
166
+ `${pkg}'s \`contributes\` returned ${thenable ? "a Promise" : describeValue(returned)} where a \`ProjectContributions\` object is expected, so \`${hostLabel(host)}\` would read it as a module that contributes nothing and record it as switched off.`,
167
+ {
168
+ helpFor: hostHelpTarget(host),
169
+ suggestion: `That is the module's bug to fix: return an object (\`{ gitattributes, config }\`), or nothing at all. \`contributes\` is synchronous \u2014 an \`async\` one returns a Promise, which is this same refusal.`
170
+ }
171
+ );
172
+ }
173
+ return returned;
174
+ }
175
+ function contributionOutcomes(loaded, answers, host) {
176
+ const out = [];
177
+ for (const p of loaded) {
178
+ assertContractShape(p.pkg, p.plugin, host);
179
+ if (p.plugin.contributes === void 0) {
180
+ out.push({ pkg: p.pkg, version: p.version, status: "none" });
181
+ continue;
182
+ }
183
+ try {
184
+ const parts = assertContributionsShape(
185
+ p.pkg,
186
+ p.plugin.contributes(answers[p.pkg] ?? {}),
187
+ host
188
+ );
189
+ assertUsableContributions(p.pkg, parts, host);
190
+ if (parts.config !== void 0) JSON.stringify(parts.config);
191
+ out.push({
192
+ pkg: p.pkg,
193
+ version: p.version,
194
+ status: "contributed",
195
+ parts
196
+ });
197
+ } catch (error) {
198
+ if (error instanceof UsageError) throw error;
199
+ warn(
200
+ `${p.pkg} could not describe what it contributes and was skipped.`,
201
+ "module.describe-failed",
202
+ [error instanceof Error ? error.message : String(error)]
203
+ );
204
+ out.push({ pkg: p.pkg, version: p.version, status: "failed" });
205
+ }
206
+ }
207
+ return out;
208
+ }
209
+ function resolveContributions(loaded, answers, host) {
210
+ return contributionOutcomes(loaded, answers, host).flatMap(
211
+ (o) => o.status === "contributed" ? [{ pkg: o.pkg, version: o.version, parts: o.parts }] : []
212
+ );
213
+ }
214
+
215
+ export {
216
+ assertContractShape,
217
+ assertUsableContributions,
218
+ priorAnswers,
219
+ runPluginQuestionnaire,
220
+ recordedConfig,
221
+ contributionOutcomes,
222
+ resolveContributions
223
+ };
224
+ //# sourceMappingURL=chunk-6ZGJCBZS.js.map