@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,106 @@
1
+ import {
2
+ registeredModules,
3
+ withoutComments
4
+ } from "./chunk-5HVXPTU4.js";
5
+ import {
6
+ pastePath,
7
+ warn
8
+ } from "./chunk-PTHVMXZI.js";
9
+ import {
10
+ shellQuote
11
+ } from "./chunk-5ZSO4T2G.js";
12
+
13
+ // src/emit/pull-superseded.ts
14
+ import { readFileSync } from "fs";
15
+ import { join } from "path";
16
+ function factoriesOf(incoming) {
17
+ const out = /* @__PURE__ */ new Set();
18
+ for (const text of incoming.values()) {
19
+ for (const m of withoutComments(text).matchAll(/(?<![\w$.])([A-Za-z_$][\w$]*)\s*\(\s*\{\s*name\s*:\s*["'`]/g)) out.add(m[1]);
20
+ }
21
+ return out;
22
+ }
23
+ function declaredDefs(text, factories) {
24
+ if (factories.size === 0) return [];
25
+ const code = withoutComments(text);
26
+ const call = new RegExp(`(?<![\\w$.])(${[...factories].map((f) => f.replace(/\$/g, "\\$")).join("|")})\\s*\\(\\s*\\{`, "g");
27
+ const starts = [...code.matchAll(call)].map((m) => ({ at: m.index, kind: m[1] }));
28
+ const out = [];
29
+ starts.forEach(({ at, kind }, i) => {
30
+ const chunk = code.slice(at, starts[i + 1]?.at ?? code.length);
31
+ const name = /\bname\s*:\s*(["'`])([^"'`]+)\1/.exec(chunk)?.[2];
32
+ if (name === void 0) return;
33
+ const verb = /\bverb\s*:\s*(["'`])([A-Za-z]+)\1/.exec(chunk)?.[2];
34
+ out.push({ kind, name, ...verb === void 0 ? {} : { verb: verb.toUpperCase() } });
35
+ });
36
+ return out;
37
+ }
38
+ var keyOf = (d) => `${d.kind}\0${d.name}\0${d.verb ?? ""}`;
39
+ function read(path) {
40
+ try {
41
+ return readFileSync(path, "utf8");
42
+ } catch {
43
+ return void 0;
44
+ }
45
+ }
46
+ function keptDuplicates(dirAbs, incoming, kept, backendDir) {
47
+ const factories = factoriesOf(incoming);
48
+ const pulled = /* @__PURE__ */ new Map();
49
+ for (const [p, text] of incoming) {
50
+ for (const d of declaredDefs(text, factories)) if (!pulled.has(keyOf(d))) pulled.set(keyOf(d), `${backendDir}/${p}`);
51
+ }
52
+ const out = [];
53
+ for (const p of kept) {
54
+ const text = read(join(dirAbs, p));
55
+ if (text === void 0) continue;
56
+ const defs = declaredDefs(text, factories);
57
+ const objects = defs.flatMap((d) => {
58
+ const into = pulled.get(keyOf(d));
59
+ return into === void 0 ? [] : [{ ...d, into }];
60
+ });
61
+ if (objects.length > 0) out.push({ file: `${backendDir}/${p}`, objects, only: objects.length === defs.length });
62
+ }
63
+ return out;
64
+ }
65
+ function replacedRegistrations(dirAbs, incoming, rewritten, backendDir) {
66
+ const out = [];
67
+ for (const p of rewritten) {
68
+ const current = read(join(dirAbs, p));
69
+ if (current === void 0) continue;
70
+ const after = new Set(registeredModules(withoutComments(incoming.get(p) ?? "")).map((r) => `${r.pkg}\0${r.register}`));
71
+ for (const r of registeredModules(withoutComments(current))) {
72
+ if (!after.has(`${r.pkg}\0${r.register}`)) out.push({ file: `${backendDir}/${p}`, ...r });
73
+ }
74
+ }
75
+ return out;
76
+ }
77
+ var label = (o) => `${o.kind} "${o.name}"${o.verb === void 0 ? "" : ` (${o.verb})`}`;
78
+ function reportSuperseded(duplicates, replaced, backendDir, inCleanGit) {
79
+ if (duplicates.length > 0) {
80
+ const one = duplicates.length === 1;
81
+ const lines = duplicates.map(
82
+ (d) => `${pastePath(d.file)}: ${d.objects.map((o) => `${label(o)} \u2192 ${pastePath(o.into)}`).join(", ")}` + (d.only ? "" : ` \u2014 it declares more than that, so move the rest into the decoded tree before deleting it`)
83
+ );
84
+ const removable = duplicates.filter((d) => d.only).map((d) => shellQuote(pastePath(d.file)));
85
+ warn(
86
+ `${duplicates.length} kept file${one ? " defines" : "s define"} objects the decoded tree declares too. ${pastePath(`${backendDir}/index.ts`)} registers the decoded copies, so ${one ? "that file is" : "those files are"} no longer part of the project and editing ${one ? "it" : "them"} changes nothing:`,
87
+ "pull.kept-duplicates",
88
+ [...lines, ...removable.length > 0 ? [`Once the new tree is written, delete the duplicates: \`rm ${removable.join(" ")}\``] : []]
89
+ );
90
+ }
91
+ for (const r of replaced) {
92
+ const back = inCleanGit ? `To keep the module registered instead, undo the replace right after it lands: \`git checkout HEAD -- ${shellQuote(pastePath(backendDir))} && git clean -fd -- ${shellQuote(pastePath(backendDir))}\`` : `To keep the module registered instead, re-add its import and \`${r.register}(\u2026)\` call to ${pastePath(r.file)} and drop the decoded copies of its objects from the register lists there`;
93
+ warn(
94
+ `${pastePath(r.file)} registers ${r.pkg} (\`${r.register}\`), and the decoded entry registers plain copies of the objects it contributed instead \u2014 a later ${r.pkg} upgrade no longer reaches them.`,
95
+ "pull.module-replaced",
96
+ [back]
97
+ );
98
+ }
99
+ }
100
+
101
+ export {
102
+ keptDuplicates,
103
+ replacedRegistrations,
104
+ reportSuperseded
105
+ };
106
+ //# sourceMappingURL=chunk-D53J55C5.js.map
@@ -0,0 +1,90 @@
1
+ import {
2
+ compareSemver,
3
+ parseSemver
4
+ } from "./chunk-2TFRR6JV.js";
5
+ import {
6
+ shellWord
7
+ } from "./chunk-FWD7AL6N.js";
8
+ import {
9
+ installedCliAt,
10
+ pathsShownFrom
11
+ } from "./chunk-PTHVMXZI.js";
12
+
13
+ // src/emit/project-sdk.ts
14
+ import { existsSync, readFileSync, realpathSync } from "fs";
15
+ import { createRequire } from "module";
16
+ import { basename, dirname, join, relative, resolve, sep } from "path";
17
+ var PACKAGE = "@xano/sdk";
18
+ function projectSdkVersion(dir) {
19
+ try {
20
+ const pkg = JSON.parse(readFileSync(createRequire(join(dir, "package.json")).resolve(`${PACKAGE}/package.json`), "utf8"));
21
+ return typeof pkg.version === "string" ? pkg.version : void 0;
22
+ } catch {
23
+ return void 0;
24
+ }
25
+ }
26
+ function versionAt(pkgJson) {
27
+ try {
28
+ const v = JSON.parse(readFileSync(pkgJson, "utf8")).version;
29
+ return typeof v === "string" ? v : void 0;
30
+ } catch {
31
+ return void 0;
32
+ }
33
+ }
34
+ function installedSdk(dir) {
35
+ let selfChecked = false;
36
+ for (let d = resolve(dir); ; d = dirname(d)) {
37
+ const own = join(d, "package.json");
38
+ if (!selfChecked && existsSync(own)) {
39
+ selfChecked = true;
40
+ try {
41
+ if (JSON.parse(readFileSync(own, "utf8")).name === PACKAGE) {
42
+ const version = versionAt(own);
43
+ if (version !== void 0) return { version, root: d };
44
+ }
45
+ } catch {
46
+ }
47
+ }
48
+ const installed = join(d, "node_modules", ...PACKAGE.split("/"), "package.json");
49
+ if (existsSync(installed)) {
50
+ const version = versionAt(installed);
51
+ return version === void 0 ? void 0 : { version, root: d };
52
+ }
53
+ if (dirname(d) === d) return void 0;
54
+ }
55
+ }
56
+ function skewedProjectSdk(dir, running) {
57
+ const installed = installedSdk(dir);
58
+ if (installed === void 0) return void 0;
59
+ const a = parseSemver(installed.version);
60
+ const b = parseSemver(running);
61
+ return a && b && compareSemver(a, b) !== 0 ? installed : void 0;
62
+ }
63
+ function installedCliCommand(root, tail) {
64
+ const home = real(root);
65
+ const typed = real(pathsShownFrom() ?? process.cwd());
66
+ const spelled = (from, to) => shellWord(relative(from, to).split(sep).join("/") || ".");
67
+ const command = `${installedCliAt(home)} ${tail((p) => spelled(home, real(p)))}`;
68
+ return typed === home ? command : `cd ${spelled(typed, home)} && ${command}`;
69
+ }
70
+ function real(path) {
71
+ const absolute = resolve(path);
72
+ try {
73
+ return realpathSync(absolute);
74
+ } catch {
75
+ const parent = dirname(absolute);
76
+ return parent === absolute ? absolute : join(real(parent), basename(absolute));
77
+ }
78
+ }
79
+ function skewNote(what, running, installed, command) {
80
+ return `Left ${what} as it is: this CLI is @xano/sdk ${running} and the project has ${installed} installed, whose wording \`npm run xano:check\` compares against. Run \`${command}\` to render it with the installed CLI.`;
81
+ }
82
+
83
+ export {
84
+ projectSdkVersion,
85
+ installedSdk,
86
+ skewedProjectSdk,
87
+ installedCliCommand,
88
+ skewNote
89
+ };
90
+ //# sourceMappingURL=chunk-D7VGG3WS.js.map
@@ -0,0 +1,245 @@
1
+ import {
2
+ backendDirFor,
3
+ backendDirIn
4
+ } from "./chunk-5A2PLKZB.js";
5
+ import {
6
+ XANO_DIR
7
+ } from "./chunk-AHJWCYQO.js";
8
+ import {
9
+ projectRootFrom
10
+ } from "./chunk-ROY4YAEQ.js";
11
+ import {
12
+ LocalFileNotFoundError,
13
+ UsageError,
14
+ displayPath
15
+ } from "./chunk-PTHVMXZI.js";
16
+ import {
17
+ isRepresentableName
18
+ } from "./chunk-GSGDWJB5.js";
19
+
20
+ // src/emit/workspace-env.ts
21
+ import { existsSync, readFileSync } from "fs";
22
+ import { join } from "path";
23
+ var WORKSPACE_ENV_BASENAME = ".env";
24
+ var WORKSPACE_ENV_EXAMPLE_BASENAME = ".env.example";
25
+ var WORKSPACE_ENV_FILE = `${XANO_DIR}/${WORKSPACE_ENV_BASENAME}`;
26
+ var WORKSPACE_ENV_EXAMPLE_FILE = `${XANO_DIR}/${WORKSPACE_ENV_EXAMPLE_BASENAME}`;
27
+ function workspaceEnvPathIn(cwd) {
28
+ return join(backendDirIn(projectRootFrom(cwd)), ".env");
29
+ }
30
+ function defaultWorkspaceEnvPath(file) {
31
+ return join(backendDirFor(file), ".env");
32
+ }
33
+ function declaredEnv(settings) {
34
+ const env = settings.env;
35
+ if (!Array.isArray(env)) return [];
36
+ return env.map((e) => e).filter((e) => typeof e.name === "string" && e.name !== "").map((e) => ({ name: e.name, value: typeof e.value === "string" ? e.value : "" }));
37
+ }
38
+ function isRepresentable(value) {
39
+ return isRepresentableValue(value);
40
+ }
41
+ function isRepresentableValue(value) {
42
+ return valueProblem(value) === void 0;
43
+ }
44
+ function valueProblem(value) {
45
+ if (/[\n\r]/.test(value)) return "newline";
46
+ if (value !== value.trim()) return "edge-whitespace";
47
+ return isQuoted(value) ? "quoted" : void 0;
48
+ }
49
+ var VALUE_PROBLEM_WORDS = {
50
+ newline: "carries a newline",
51
+ "edge-whitespace": "has leading or trailing whitespace",
52
+ quoted: "is wrapped in a matching quote pair that reading the file would strip"
53
+ };
54
+ function isQuoted(value) {
55
+ const quote = value[0];
56
+ return (quote === '"' || quote === "'") && value.length > 1 && value.endsWith(quote);
57
+ }
58
+ function classifyEnv(args) {
59
+ const values = Object.assign(/* @__PURE__ */ Object.create(null), args.fileValues, args.flagValues);
60
+ const supplied = new Set(Object.keys(values));
61
+ const declared = new Set(args.declaredNames);
62
+ const declaredValues = args.declaredValues ?? {};
63
+ return {
64
+ values,
65
+ clearing: args.declaredNames.filter(
66
+ (n) => !supplied.has(n) && (Object.hasOwn(declaredValues, n) ? declaredValues[n] : "") === ""
67
+ ),
68
+ additions: Object.keys(values).filter((n) => !declared.has(n))
69
+ };
70
+ }
71
+ function parseEnvFile(path, label = "--backend-env-file") {
72
+ let source;
73
+ try {
74
+ source = readFileSync(path, "utf8");
75
+ } catch (err) {
76
+ const missing = err.code === "ENOENT";
77
+ throw new (!label.startsWith("--") ? Error : missing ? LocalFileNotFoundError : UsageError)(
78
+ `${label}: could not read ${displayPath(path)}. Check the path, and make sure the file is present wherever this runs (a CI secret mounted at deploy time, not a file committed to the repo).`
79
+ );
80
+ }
81
+ const out = /* @__PURE__ */ Object.create(null);
82
+ for (const [n, raw] of source.split("\n").entries()) {
83
+ const line = raw.trim();
84
+ if (line === "" || line.startsWith("#")) continue;
85
+ const body = line.startsWith("export ") ? line.slice("export ".length).trim() : line;
86
+ const eq = body.indexOf("=");
87
+ if (eq <= 0) {
88
+ throw new Error(
89
+ `${label}: ${displayPath(path)} line ${n + 1} is not KEY=VALUE. Comments start with "#"; blank lines are ignored.`
90
+ );
91
+ }
92
+ const key = body.slice(0, eq).trim();
93
+ let value = body.slice(eq + 1).trim();
94
+ if (isQuoted(value)) value = value.slice(1, -1);
95
+ out[key] = value;
96
+ }
97
+ return out;
98
+ }
99
+ function readWorkspaceEnvFile(path) {
100
+ if (!existsSync(path)) return void 0;
101
+ return parseEnvFile(path, WORKSPACE_ENV_FILE);
102
+ }
103
+ function commentSafe(name) {
104
+ return name.replace(/[\u0000-\u001F\u007F]/g, "?");
105
+ }
106
+ function envFileLabels(backendDir) {
107
+ return {
108
+ env: `${backendDir}/${WORKSPACE_ENV_BASENAME}`,
109
+ example: `${backendDir}/${WORKSPACE_ENV_EXAMPLE_BASENAME}`
110
+ };
111
+ }
112
+ function renderWorkspaceEnvExample(names, backendDir = XANO_DIR) {
113
+ const { env: envFile, example: exampleFile } = envFileLabels(backendDir);
114
+ const header = `# ${exampleFile} \u2014 the template for ${envFile}.
115
+ #
116
+ # ${backendDir}/ is COMMITTED in full: the source, the lock, and this file. Two
117
+ # files are ignored on purpose, and which secret goes in which is decided by how
118
+ # that secret is ADDRESSED. Do not "tidy" this up by ignoring ${backendDir}/
119
+ # wholesale: the source is the review surface.
120
+ #
121
+ # - ${envFile} \u2014 BACKEND variables, addressed by NAME. Declared by
122
+ # \`workspaceConfig({ env })\` and read at request time with \`env("NAME")\`.
123
+ # Those names are listed below; the values are yours to fill in.
124
+ # - ${backendDir}/.secrets.json \u2014 DOCUMENTATION tokens, addressed by the OBJECT
125
+ # that holds them (the workspace, or an API group). They have no name of
126
+ # their own, so they are not listed here at all. \`npx xanosdk pull\` writes that
127
+ # file and every build reads it back; nobody edits it by hand. They are NOT
128
+ # backend variables: they never reach the workspace's env, and
129
+ # \`env("NAME")\` does not read them.
130
+ #
131
+ # To fill it in:
132
+ #
133
+ # cp ${exampleFile} ${envFile} # then edit in the values
134
+ # npx xanosdk env pull # or fetch them from a running backend
135
+ #
136
+ # Every command that compiles a bundle (deploy, export, preflight) reads
137
+ # ${envFile} by default. CI does not have it \u2014 the file is ignored \u2014 so an
138
+ # automated deploy mounts its own and passes \`--backend-env-file <path>\`, or supplies
139
+ # names one at a time with \`--env-var KEY=VALUE\`.
140
+ #
141
+ # A deploy REPLACES the backend's env set. A name declared in
142
+ # \`workspaceConfig({ env })\` with no line in ${envFile} therefore REFUSES the
143
+ # deploy rather than clearing the live value; \`--allow-empty-env=NAME\` opts one
144
+ # name out of that. The refusal is part of the compile, so a pre-built bundle
145
+ # (\`deploy --bundle <path>\`) ships whatever env it was built with \u2014 resolve the
146
+ # values on the \`export\` that builds it.
147
+ #
148
+ # A documentation token follows the same discipline in its own file, with
149
+ # \`--allow-empty-doc-token=<scope>\` as its opt-out \u2014 but an UNSUPPLIED one emits
150
+ # no \`documentation\` block at all, so a bundle built without it leaves the
151
+ # target's gate alone rather than clearing it. Only the opt-out clears a gate,
152
+ # and clearing one makes that doc site publicly readable.
153
+ #
154
+ # This file is generated. Every pull, and every export, rewrites it from the
155
+ # names the backend declares. ${envFile} is yours: neither touches it. Only
156
+ # \`npx xanosdk env pull\` (which asks before replacing it), and \`npx xanosdk init --from\`
157
+ # or \`npx xanosdk generate\` on a bundle that carries values, write it.
158
+ `;
159
+ if (names.length === 0) {
160
+ return `${header}#
161
+ # This backend declares no env vars. Add them with \`workspaceConfig({ env })\`
162
+ # and the next export or pull will list them here. (Documentation tokens are never listed
163
+ # here \u2014 they live in ${backendDir}/.secrets.json, keyed by the object they gate.)
164
+ `;
165
+ }
166
+ const lines = names.map(
167
+ ({ name, representable, problem }) => representable ? `# ${commentSafe(name)}=` : problem === "name" ? (
168
+ // No `NAME=` shape: the line must not parse back as a declared name, and
169
+ // no flag can supply a name `--env-var` refuses.
170
+ `# "${commentSafe(name)}" (not a usable env var name \u2014 letters, digits and _, not starting
171
+ # with a digit \u2014 so no file or flag can supply it. Rename it in \`workspaceConfig({ env })\`.)`
172
+ ) : `# ${commentSafe(name)}= (this value cannot be written here \u2014 it ${VALUE_PROBLEM_WORDS[problem ?? "newline"]},
173
+ # so the dotenv format cannot carry it. Pass it with
174
+ # \`--env-var ${commentSafe(name)}=...\` instead.)`
175
+ );
176
+ return `${header}#
177
+ # One line per declared name. Uncomment and fill in the ones you need.
178
+
179
+ ${lines.join("\n")}
180
+ `;
181
+ }
182
+ function namesInEnvExample(path) {
183
+ if (!existsSync(path)) return [];
184
+ const out = [];
185
+ for (const raw of readFileSync(path, "utf8").split("\n")) {
186
+ const m = /^#?\s*([A-Za-z_][A-Za-z0-9_]*)=/.exec(raw.trim());
187
+ if (m) out.push(m[1]);
188
+ }
189
+ return out;
190
+ }
191
+ function renderWorkspaceEnvFile(values, provenance, backendDir = XANO_DIR, exampleExists = true, writer = "xanosdk env pull") {
192
+ const { env: envFile, example: exampleFile } = envFileLabels(backendDir);
193
+ const omitted = [];
194
+ const lines = [];
195
+ for (const [name, value] of Object.entries(values)) {
196
+ if (isRepresentableName(name) && isRepresentableValue(value)) lines.push(`${name}=${value}`);
197
+ else omitted.push(name);
198
+ }
199
+ const badNames = omitted.filter((n) => !isRepresentableName(n));
200
+ const badValues = omitted.filter((n) => isRepresentableName(n));
201
+ const header = `# ${envFile} \u2014 backend env values. NOT committed${exampleExists ? ` (see ${exampleFile})` : ""}.
202
+ #
203
+ # Written by \`${writer}\` from: ${provenance.source}
204
+ # at ${provenance.at}
205
+ #
206
+ # Every command that compiles a bundle reads this file by default. Re-running
207
+ # \`npx xanosdk env pull\` REPLACES it wholesale.
208
+ ${// A NAME no env var can have is said as the name's fault: blaming its value
209
+ // ("no newlines or edge whitespace") sent the reader to a value that was fine.
210
+ badValues.length === 0 ? "" : `#
211
+ # NOT written, because the dotenv format cannot carry ${badValues.length === 1 ? "its value" : "their values"}
212
+ # (a newline, edge whitespace, or a wrapping quote pair): ${badValues.map(commentSafe).join(", ")}.
213
+ # Pass ${badValues.length === 1 ? "it" : "each"} at deploy time with \`--env-var NAME=...\` instead.
214
+ `}${badNames.length === 0 ? "" : `#
215
+ # NOT written, because ${badNames.length === 1 ? "it is not a usable env var name" : "they are not usable env var names"}
216
+ # (letters, digits and _, not starting with a digit): ${badNames.map((n) => `"${commentSafe(n)}"`).join(", ")}.
217
+ `}`;
218
+ return {
219
+ content: lines.length === 0 ? `${header}#
220
+ # This backend declares no env vars, so there is nothing to fill in.
221
+ ` : `${header}
222
+ ${lines.join("\n")}
223
+ `,
224
+ omitted
225
+ };
226
+ }
227
+
228
+ export {
229
+ WORKSPACE_ENV_BASENAME,
230
+ WORKSPACE_ENV_EXAMPLE_BASENAME,
231
+ WORKSPACE_ENV_FILE,
232
+ WORKSPACE_ENV_EXAMPLE_FILE,
233
+ workspaceEnvPathIn,
234
+ defaultWorkspaceEnvPath,
235
+ declaredEnv,
236
+ isRepresentable,
237
+ valueProblem,
238
+ classifyEnv,
239
+ parseEnvFile,
240
+ readWorkspaceEnvFile,
241
+ renderWorkspaceEnvExample,
242
+ namesInEnvExample,
243
+ renderWorkspaceEnvFile
244
+ };
245
+ //# sourceMappingURL=chunk-DAD3ONIS.js.map
@@ -0,0 +1,162 @@
1
+ // src/emit/managed-blocks.ts
2
+ var HASH_DIALECT = {
3
+ begin: (pkg) => `# xanosdk:begin ${pkg}`,
4
+ end: (pkg) => `# xanosdk:end ${pkg}`,
5
+ stamp: (version) => `# xanosdk ${version} \u2014 generated; edits inside this block are overwritten`,
6
+ parseStamp: (block) => /^# xanosdk (\S+) — generated/m.exec(block)?.[1] ?? null
7
+ };
8
+ var CONFLICT_MARKERS = ["<<<<<<<", ">>>>>>>"];
9
+ function composeBlock(spec, lines, version) {
10
+ const body = trimBlankEdges(lines.flatMap((line) => line.split(/\r?\n/)));
11
+ if (body.length === 0) return "";
12
+ const { dialect, pkg } = spec;
13
+ assertNoForgedMarkers(body, spec);
14
+ return [dialect.begin(pkg), dialect.stamp(version), "", ...body, dialect.end(pkg)].join("\n");
15
+ }
16
+ function assertNoForgedMarkers(body, spec) {
17
+ const { dialect, pkg } = spec;
18
+ const where = spec.file === void 0 ? "" : ` in ${spec.file}`;
19
+ const markers = [dialect.begin("").trim(), dialect.end("").trim()];
20
+ for (const line of body) {
21
+ const trimmed = line.trim();
22
+ if (!markers.some((marker) => trimmed.startsWith(marker))) continue;
23
+ throw new Error(
24
+ `xanosdk managed block for ${pkg}${where} would contain a line that spells a block marker (${trimmed}). Writing it would leave the file with markers no run can balance, and every command that could repair it reads the same count.`
25
+ );
26
+ }
27
+ }
28
+ function gitattributesSpec(pkg) {
29
+ return { dialect: HASH_DIALECT, pkg, file: ".gitattributes" };
30
+ }
31
+ function linesOutsideBlocks(text, dialect) {
32
+ const begin = dialect.begin("");
33
+ const end = dialect.end("");
34
+ const out = [];
35
+ let inside = false;
36
+ for (const line of text.split(/\r?\n/)) {
37
+ const trimmed = line.trim();
38
+ if (trimmed.startsWith(begin)) inside = true;
39
+ else if (trimmed.startsWith(end)) inside = false;
40
+ else if (!inside && trimmed !== "") out.push(trimmed);
41
+ }
42
+ return out;
43
+ }
44
+ function blockPackages(text, dialect) {
45
+ const begin = dialect.begin("");
46
+ const out = [];
47
+ for (const line of text.split(/\r?\n/)) {
48
+ const trimmed = line.trim();
49
+ if (!trimmed.startsWith(begin)) continue;
50
+ const pkg = trimmed.slice(begin.length).trim();
51
+ if (pkg !== "" && !out.includes(pkg)) out.push(pkg);
52
+ }
53
+ return out;
54
+ }
55
+ function findBlock(text, spec) {
56
+ return locate(text, spec);
57
+ }
58
+ function blockVersion(text, spec) {
59
+ const span = locate(text, spec);
60
+ return span === null ? null : spec.dialect.parseStamp(span.text);
61
+ }
62
+ function upsertBlock(existing, spec, block) {
63
+ const before = existing ?? "";
64
+ if (block.trim().length === 0) return removeBlock(before, spec);
65
+ const eol = detectEol(before);
66
+ const rendered = block.replace(/\r?\n/g, eol);
67
+ const span = locate(before, spec);
68
+ if (span !== null) {
69
+ return settle(before, before.slice(0, span.start) + rendered + before.slice(span.end));
70
+ }
71
+ if (before.trim().length === 0) return settle(before, rendered + eol);
72
+ const tail = trailingNewlines(before);
73
+ return settle(before, trimEndLines(before) + eol + eol + rendered + (tail === "" ? eol : tail));
74
+ }
75
+ function removeBlock(existing, spec) {
76
+ const before = existing ?? "";
77
+ const span = locate(before, spec);
78
+ if (span === null) return { text: before, changed: false };
79
+ const eol = detectEol(before);
80
+ const tail = trailingNewlines(before);
81
+ const head = trimEndLines(before.slice(0, span.start));
82
+ const rest = trimStartLines(before.slice(span.end));
83
+ let out = head === "" || rest === "" ? head + rest : head + eol + eol + rest;
84
+ if (out !== "" && tail !== "" && !/\r?\n$/.test(out)) out += tail;
85
+ return settle(before, out);
86
+ }
87
+ function locate(text, spec) {
88
+ const { dialect, pkg } = spec;
89
+ const where = spec.file === void 0 ? "" : ` in ${spec.file}`;
90
+ const begins = lineOccurrences(text, dialect.begin(pkg));
91
+ const ends = lineOccurrences(text, dialect.end(pkg));
92
+ if (begins.length === 0 && ends.length === 0) return null;
93
+ if (begins.length > 1 || ends.length > 1) {
94
+ throw new Error(
95
+ `unbalanced xanosdk managed block for ${pkg}${where}: found ${begins.length} BEGIN and ${ends.length} END markers where at most one of each is valid \u2014 usually the residue of a merge. Keep the copy you want and delete the rest by hand; rewriting it automatically would strand whichever copy we did not pick.`
96
+ );
97
+ }
98
+ if (begins.length === 0 || ends.length === 0 || ends[0] < begins[0]) {
99
+ throw new Error(
100
+ `unbalanced xanosdk managed block for ${pkg}${where}: found ${begins.length === 0 ? "no" : "a"} BEGIN and ${ends.length === 0 ? "no" : "an"} END marker. Repair or remove the block by hand \u2014 rewriting it automatically would risk destroying whatever is between them.`
101
+ );
102
+ }
103
+ const start = begins[0];
104
+ const end = ends[0] + dialect.end(pkg).length;
105
+ const block = text.slice(start, end);
106
+ if (CONFLICT_MARKERS.some((marker) => hasLineStarting(block, marker))) {
107
+ throw new Error(
108
+ `xanosdk managed block for ${pkg}${where} contains git conflict markers. Resolve the conflict by hand, then re-run \u2014 rewriting a conflicted block would silently discard one side of it.`
109
+ );
110
+ }
111
+ return { start, end, text: block };
112
+ }
113
+ function lineOccurrences(text, marker) {
114
+ const hits = [];
115
+ for (let i = text.indexOf(marker); i !== -1; i = text.indexOf(marker, i + marker.length)) {
116
+ if (i !== 0 && text[i - 1] !== "\n") continue;
117
+ let j = i + marker.length;
118
+ while (text[j] === " " || text[j] === " ") j++;
119
+ if (text[j] === "\r") j++;
120
+ if (j === text.length || text[j] === "\n") hits.push(i);
121
+ }
122
+ return hits;
123
+ }
124
+ function hasLineStarting(text, marker) {
125
+ return text.startsWith(marker) || text.includes(`
126
+ ${marker}`);
127
+ }
128
+ function detectEol(text) {
129
+ return text.includes("\r\n") ? "\r\n" : "\n";
130
+ }
131
+ function trailingNewlines(text) {
132
+ return /(?:\r?\n)*$/.exec(text)?.[0] ?? "";
133
+ }
134
+ function trimEndLines(text) {
135
+ return text.replace(/[ \t]*(?:\r?\n[ \t]*)*$/, "");
136
+ }
137
+ function trimStartLines(text) {
138
+ return text.replace(/^[ \t]*(?:\r?\n[ \t]*)*/, "");
139
+ }
140
+ function trimBlankEdges(lines) {
141
+ let start = 0;
142
+ let end = lines.length;
143
+ while (start < end && lines[start].trim() === "") start++;
144
+ while (end > start && lines[end - 1].trim() === "") end--;
145
+ return lines.slice(start, end);
146
+ }
147
+ function settle(before, after) {
148
+ return { text: after, changed: after !== before };
149
+ }
150
+
151
+ export {
152
+ HASH_DIALECT,
153
+ composeBlock,
154
+ gitattributesSpec,
155
+ linesOutsideBlocks,
156
+ blockPackages,
157
+ findBlock,
158
+ blockVersion,
159
+ upsertBlock,
160
+ removeBlock
161
+ };
162
+ //# sourceMappingURL=chunk-DGWHAVRG.js.map