@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,217 @@
1
+ import {
2
+ isTaggedValue
3
+ } from "./chunk-OXA6PSZT.js";
4
+ import {
5
+ describeEntry,
6
+ protoKeyed
7
+ } from "./chunk-CIMQZRRE.js";
8
+
9
+ // src/values/obj.ts
10
+ var IDENT = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
11
+ function serializeValue(v, path, followed) {
12
+ const record = objSetRecord(v, path, followed);
13
+ if (record) return record;
14
+ const nowExpr = serializeEpochMs(v);
15
+ if (nowExpr !== null) return grouped(nowExpr + serializeFilters(v, path), v.filters, followed);
16
+ return grouped(serializeAtom(v, path) + serializeFilters(v, path), v.filters, followed);
17
+ }
18
+ function grouped(rendered, chain, followed) {
19
+ const tail = chain[chain.length - 1];
20
+ return followed && tail !== void 0 && tail.arg.length > 0 ? `(${rendered})` : rendered;
21
+ }
22
+ function serializeEpochMs(v) {
23
+ if (v.tag !== "const:epochms") return null;
24
+ if (v.value !== "now") return null;
25
+ return "now|to_epochms";
26
+ }
27
+ function objSetRecord(v, path, followed) {
28
+ if (v.tag !== "const:obj") return null;
29
+ if (v.value === "") {
30
+ throw new Error(
31
+ `obj(): \`${path}\` is \`c.obj(null)\`, the legacy BLANK object form \u2014 the engine evaluates it to null, not to {}. Write \`c.null()\` for the null, or \`c.obj()\` for an empty object.`
32
+ );
33
+ }
34
+ if (v.value !== "{}") {
35
+ const parsed = parseJson(v.value);
36
+ if (parsed === NOT_JSON) return null;
37
+ return grouped(serializeJson(parsed, path) + serializeFilters(v, path), v.filters, followed);
38
+ }
39
+ const members = [];
40
+ const keys = /* @__PURE__ */ new Set();
41
+ let i = 0;
42
+ for (; i < v.filters.length; i++) {
43
+ const f = v.filters[i];
44
+ if (f.name !== "set" || f.disabled || f.arg.length !== 2) break;
45
+ const [pathArg, member] = f.arg;
46
+ if (pathArg.tag !== "const" || pathArg.filters.length > 0) break;
47
+ const bracketed = pathArg.value.startsWith("[");
48
+ const key = parseSetPath(pathArg.value);
49
+ if (!IDENT.test(key)) {
50
+ if (!bracketed) break;
51
+ throw keyError(key, ` inside the \`c.obj\` at \`${path}\``);
52
+ }
53
+ if (keys.has(key)) break;
54
+ keys.add(key);
55
+ members.push([key, member]);
56
+ }
57
+ const parts = members.map(
58
+ ([key, member], idx) => `${key}: ${serializeValue(member, `${path}.${key}`, idx < members.length - 1)}`
59
+ );
60
+ const rendered = parts.length === 0 ? "{}" : `{ ${parts.join(", ")} }`;
61
+ const rest = { ...v, filters: v.filters.slice(i) };
62
+ return grouped(rendered + serializeFilters(rest, path), rest.filters, followed);
63
+ }
64
+ function parseSetPath(stored) {
65
+ const bracketed = /^\["(.*)"\]$/s.exec(stored);
66
+ return bracketed ? bracketed[1].replace(/\\(["\\])/g, "$1") : stored;
67
+ }
68
+ function keyError(key, where) {
69
+ return new Error(
70
+ `obj(): key "${key}"${where} must be a bare identifier ([A-Za-z_][A-Za-z0-9_]*) \u2014 XanoScript object keys aren't quoted.`
71
+ );
72
+ }
73
+ var NOT_JSON = /* @__PURE__ */ Symbol("not-json");
74
+ function parseJson(text) {
75
+ try {
76
+ return JSON.parse(text);
77
+ } catch {
78
+ return NOT_JSON;
79
+ }
80
+ }
81
+ function serializeJson(value, path) {
82
+ if (value === null) return "null";
83
+ if (typeof value === "string") return JSON.stringify(value);
84
+ if (typeof value === "boolean") return value ? "true" : "false";
85
+ if (typeof value === "number") return Number.isFinite(value) ? String(value) : "null";
86
+ if (Array.isArray(value)) {
87
+ return `[${value.map((el, i) => serializeJson(el, `${path}[${i}]`)).join(", ")}]`;
88
+ }
89
+ if (typeof value === "object") {
90
+ const parts = Object.entries(value).map(([key, member]) => {
91
+ if (!IDENT.test(key)) {
92
+ throw keyError(key, ` at \`${path}\``);
93
+ }
94
+ return `${key}: ${serializeJson(member, `${path}.${key}`)}`;
95
+ });
96
+ return parts.length === 0 ? "{}" : `{ ${parts.join(", ")} }`;
97
+ }
98
+ return "null";
99
+ }
100
+ function serializeFilters(v, path) {
101
+ let out = "";
102
+ for (const f of v.filters) {
103
+ if (f.disabled) {
104
+ throw new Error(
105
+ `obj(): the value at \`${path}\` carries a DISABLED \`${f.name}\` filter. An object literal is stored as one expression string, which has no spelling for a disabled filter \u2014 drop it, or build the value in a prior step (e.g. \`s.set_var\`) and reference it with \`ref\`.`
106
+ );
107
+ }
108
+ const args = f.arg.map((a, i) => {
109
+ if (a.filters.length > 0) {
110
+ throw new Error(
111
+ `obj(): the \`${f.name}\` filter on member \`${path}\` has an argument (#${i}) that carries its own filter chain (\`ref(\u2026, { safe: true })\` is one). In an expression a trailing \`|\` binds to the whole value, not to one argument, so this cannot be written without changing what it means. Compute the argument in a prior step (\`s.set_var\`) and reference it with \`ref\`.`
112
+ );
113
+ }
114
+ return serializeAtom(a, `${path}|${f.name}[${i}]`);
115
+ });
116
+ out += `|${f.name}${args.length > 0 ? `:${args.join(":")}` : ""}`;
117
+ }
118
+ return out;
119
+ }
120
+ function serializeAtom(v, path) {
121
+ switch (v.tag) {
122
+ case "const":
123
+ return JSON.stringify(v.value);
124
+ // double-quoted + escaped, valid XanoScript string
125
+ case "const:int":
126
+ case "const:decimal":
127
+ return v.value;
128
+ // already the numeric literal (e.g. "123", "1.5")
129
+ case "const:bool":
130
+ return v.value === "true" ? "true" : "false";
131
+ case "const:null":
132
+ return "null";
133
+ case "input":
134
+ return `$input.${v.value}`;
135
+ case "var":
136
+ return `$var.${v.value}`;
137
+ case "auth":
138
+ return v.value ? `$auth.${v.value}` : "$auth";
139
+ case "col":
140
+ return `$db.${v.value}`;
141
+ // A workspace env var and a built-in request var are the SAME tag; the
142
+ // built-ins just carry a `$`-prefixed name. Both spell `$env.` + the name,
143
+ // so `sys.remoteIp()` renders `$env.$remote_ip` and `env("STRIPE_KEY")`
144
+ // renders `$env.STRIPE_KEY`.
145
+ case "setting":
146
+ return `$env.${v.value}`;
147
+ // The engine's native current-time constant reaches this function ONLY as a
148
+ // filter argument — a member position is answered by `serializeEpochMs`
149
+ // above. There it is unwritable: the value needs a leading `|to_epochms` to
150
+ // evaluate as a time at all (see `serializeEpochMs`), and inside an argument
151
+ // a trailing `|` binds to the whole value rather than to the argument, which
152
+ // is the same wall a pre-filtered argument hits.
153
+ case "const:epochms":
154
+ throw new Error(
155
+ `obj(): \`${path}\` is \`c.now()\` used as a FILTER ARGUMENT. In an expression the current-time constant has to carry a \`|to_epochms\` coercion, and a \`|\` inside an argument binds to the whole value instead \u2014 so this cannot be written without changing what it means. Compute it in a prior step (\`s.set_var("now", c.now())\`) and reference it with \`ref("now")\`.`
156
+ );
157
+ // `c.array([…])` stores plain JSON, and the literal grammar spells the same
158
+ // list — so it renders to the identical bytes a bare `[…]` member does. The
159
+ // bare form always worked and this one used to throw, which made the empty
160
+ // list (`c.array([])`) an export failure with no named way through.
161
+ // A nested `obj()` (or `c.expression`) is already expression source: a
162
+ // record literal inlines as the same bytes a bare `{…}` member renders; any
163
+ // other expression is grouped so a following `|` or `,` cannot split it.
164
+ case "const:expr2":
165
+ return v.value[0] == "{" ? v.value : `(${v.value})`;
166
+ case "const:array": {
167
+ const parsed = parseJson(v.value);
168
+ if (parsed !== NOT_JSON) return serializeJson(parsed, path);
169
+ break;
170
+ }
171
+ }
172
+ throw new Error(
173
+ `obj(): \`${path}\` is a value tagged "${v.tag}", which an object literal cannot carry. Bind it in a prior step (\`s.set_var("x", \u2026)\`) and use \`ref("x")\`.`
174
+ );
175
+ }
176
+ function serializeMember(m, path, followed = false) {
177
+ if (typeof m === "string") return JSON.stringify(m);
178
+ if (typeof m === "number") return String(m);
179
+ if (typeof m === "boolean") return m ? "true" : "false";
180
+ if (m === null) return "null";
181
+ if (isTaggedValue(m)) return serializeValue(m, path, followed);
182
+ if (Array.isArray(m)) {
183
+ return `[${m.map((el, i) => serializeMember(el, `${path}[${i}]`, i < m.length - 1)).join(", ")}]`;
184
+ }
185
+ const proto = typeof m === "object" ? Object.getPrototypeOf(m) : 0;
186
+ if (proto === Object.prototype || proto === null) return serializeRecord(m, path);
187
+ throw new Error(
188
+ `obj(): \`${path}\` must be a Value (inp/ref/auth/col/c.*), a scalar literal (string/number/boolean), a nested object, or an array (got ${describeEntry(m)}).`
189
+ );
190
+ }
191
+ function serializeRecord(rec, path) {
192
+ const entries = Object.entries(rec);
193
+ const parts = entries.map(([key, member], idx) => {
194
+ if (!IDENT.test(key)) {
195
+ throw keyError(key, path ? ` at \`${path}\`` : "");
196
+ }
197
+ return `${key}: ${serializeMember(member, path ? `${path}.${key}` : key, idx < entries.length - 1)}`;
198
+ });
199
+ return parts.length === 0 ? "{}" : `{ ${parts.join(", ")} }`;
200
+ }
201
+ function obj(fields) {
202
+ if (typeof fields !== "object" || fields === null || Array.isArray(fields) || isTaggedValue(fields) || protoKeyed(fields)) {
203
+ throw new Error(
204
+ `obj() takes a { key: value } record \u2014 got ${isTaggedValue(fields) ? "a value (`c.*`/`ref()`), which needs no obj()" : describeEntry(fields)}.`
205
+ );
206
+ }
207
+ return {
208
+ value: serializeRecord(fields, ""),
209
+ tag: "const:expr2",
210
+ filters: []
211
+ };
212
+ }
213
+
214
+ export {
215
+ obj
216
+ };
217
+ //# sourceMappingURL=chunk-K5BBGTYZ.js.map
@@ -0,0 +1,427 @@
1
+ import {
2
+ confirm
3
+ } from "./chunk-65HWOMGV.js";
4
+ import {
5
+ discloseCanonicalMoves,
6
+ movesClause,
7
+ releaseCanonicalMoves
8
+ } from "./chunk-BWPNT55T.js";
9
+ import {
10
+ exportWorkspaceBundle
11
+ } from "./chunk-CJHQKJU4.js";
12
+ import {
13
+ DEFAULT_BRANCH_LABEL,
14
+ deleteBranch,
15
+ findBranch,
16
+ listBranchListing,
17
+ liveBranchLabel,
18
+ requireBranch,
19
+ setLiveBranch
20
+ } from "./chunk-TRJCALW3.js";
21
+ import {
22
+ sectionKind
23
+ } from "./chunk-45UIT5T2.js";
24
+ import {
25
+ assertOneName
26
+ } from "./chunk-ZIY7RNUT.js";
27
+ import {
28
+ getAccessToken
29
+ } from "./chunk-ET4Y4XCB.js";
30
+ import {
31
+ pipedYes
32
+ } from "./chunk-T5KELPAR.js";
33
+ import {
34
+ contextFlags
35
+ } from "./chunk-NAQDMEHV.js";
36
+ import {
37
+ shellWord
38
+ } from "./chunk-FWD7AL6N.js";
39
+ import {
40
+ describeWrite
41
+ } from "./chunk-4KHEMC32.js";
42
+ import {
43
+ CliError,
44
+ UsageError,
45
+ blank,
46
+ credentialWriteTarget,
47
+ describeWriteTarget,
48
+ detail,
49
+ discloseWriteTarget,
50
+ info,
51
+ isMachineOutput,
52
+ safeText,
53
+ step,
54
+ success,
55
+ suggestVerb,
56
+ warn,
57
+ writeJson,
58
+ writeTargetPayload
59
+ } from "./chunk-PTHVMXZI.js";
60
+ import {
61
+ suggestAll
62
+ } from "./chunk-UTI5G6OJ.js";
63
+
64
+ // src/emit/branch-commands.ts
65
+ var VERBS = ["list", "set-live", "delete"];
66
+ function assertVerb(verb) {
67
+ if (verb !== void 0 && VERBS.includes(verb)) return verb;
68
+ throw new UsageError(
69
+ verb === void 0 ? `\`xanosdk workspace branch\` needs a verb: ${VERBS.join(", ")}.` : `\`xanosdk workspace branch ${verb}\` is not a verb. Expected one of: ${VERBS.join(", ")}.`,
70
+ {
71
+ helpFor: { command: "workspace", subcommand: "branch" },
72
+ ...verb === void 0 ? {} : { suggestion: suggestVerb(verb, VERBS) }
73
+ }
74
+ );
75
+ }
76
+ function requireLabel(label, verb) {
77
+ if (label !== void 0 && label.trim() !== "") return label;
78
+ throw new UsageError(`\`xanosdk workspace branch ${verb}\` needs a branch label.`, {
79
+ helpFor: { command: "workspace", subcommand: "branch" }
80
+ });
81
+ }
82
+ function shownLabel(label) {
83
+ return safeText(/\s/.test(label) ? JSON.stringify(label) : label);
84
+ }
85
+ function renderUnaddressable(rows) {
86
+ if (rows.length === 0) return;
87
+ blank();
88
+ warn(
89
+ `${rows.length} branch${rows.length === 1 ? "" : "es"} here carr${rows.length === 1 ? "ies" : "y"} no label:`,
90
+ "branch.unlabeled",
91
+ [
92
+ ...rows.map((r) => {
93
+ const tags = [r.live ? "LIVE" : "", r.backup ? "backup" : ""].filter(Boolean).join(", ");
94
+ return `(unnamed, created ${r.createdAt ?? "at an unknown time"})${tags === "" ? "" : ` (${tags})`}`;
95
+ }),
96
+ "Every branch route addresses a branch by label, so these cannot be",
97
+ "selected, made live, or deleted from here \u2014 remove one in the Xano dashboard."
98
+ ]
99
+ );
100
+ }
101
+ function renderList(branches, unaddressable, workspaceId) {
102
+ blank();
103
+ step(`Branches in workspace #${workspaceId}`);
104
+ if (branches.length === 0 && unaddressable.length === 0) {
105
+ detail("none reported");
106
+ return;
107
+ }
108
+ for (const b of branches) {
109
+ const tags = [b.live ? "live" : "", b.backup ? "backup" : ""].filter(Boolean).join(", ");
110
+ detail(`${shownLabel(b.label)}${tags === "" ? "" : ` (${tags})`}`);
111
+ }
112
+ renderUnaddressable(unaddressable);
113
+ blank();
114
+ detail("Branches scope logic. Tables and microservices are shared by every branch.");
115
+ }
116
+ async function runBranchCommand(args) {
117
+ const verb = assertVerb(args.positionals[0]);
118
+ if (verb === "list" && args.positionals.length > 1) {
119
+ throw new UsageError(
120
+ `\`xanosdk workspace branch list\` takes no argument, and was also given \`${args.positionals[1]}\`.`,
121
+ { hintFor: { command: "workspace", subcommand: "branch" } }
122
+ );
123
+ }
124
+ if (args.expectLive !== void 0 && verb !== "set-live") {
125
+ throw new UsageError(
126
+ `\`--expect-live\` guards a switch of the live branch, and \`xanosdk workspace branch ${verb}\` makes none. It belongs to \`xanosdk workspace branch set-live <branch> --expect-live <label>\`; drop it here.`,
127
+ { hintFor: { command: "workspace", subcommand: "branch" } }
128
+ );
129
+ }
130
+ const typedLabel = args.positionals[1];
131
+ if (typedLabel !== void 0) assertOneName(typedLabel, "the branch label", { args, helpFor: { command: "workspace", subcommand: "branch" } });
132
+ if (verb === "delete" && typedLabel?.trim() === DEFAULT_BRANCH_LABEL) {
133
+ throw new UsageError(
134
+ `Branch "${DEFAULT_BRANCH_LABEL}" is the workspace's default branch, which cannot be deleted. Nothing was sent.`,
135
+ { hintFor: { command: "workspace", subcommand: "branch" } }
136
+ );
137
+ }
138
+ const auth = await getAccessToken(args);
139
+ const workspaceId = auth.workspaceId;
140
+ const target = { baseUrl: auth.instance, workspaceId };
141
+ const { branches, unaddressable } = await listBranchListing(auth, target).catch(async (err) => {
142
+ const { unansweredRead } = await import("./source-resolve-S2XA3XZF.js");
143
+ throw unansweredRead(err, `list the branches of workspace ${workspaceId}`, "workspace");
144
+ });
145
+ if (verb === "list") {
146
+ if (isMachineOutput(args)) {
147
+ writeJson({ workspaceId, instance: auth.instance, branches, unaddressable });
148
+ return;
149
+ }
150
+ renderList(branches, unaddressable, workspaceId);
151
+ return;
152
+ }
153
+ const typed = requireLabel(args.positionals[1], verb);
154
+ if (verb === "delete" && findBranch(branches, typed) === void 0) {
155
+ const label2 = typed;
156
+ const destination2 = credentialWriteTarget({ instance: auth.instance, workspaceId });
157
+ const known = branches.map((b) => shownLabel(b.label)).join(", ");
158
+ const near = suggestAll(label2.trim(), branches.filter((b) => !b.live && b.label.trim() !== DEFAULT_BRANCH_LABEL).map((b) => b.label));
159
+ const again = `${args.json === true ? " --json" : ""}${contextFlags(args)}`;
160
+ const missed = `No branch named "${label2}" on ${describeWriteTarget(destination2)} \u2014 nothing was deleted.`;
161
+ const meant = near.map((n) => `Did you mean "${safeText(n)}"? \`xanosdk workspace branch delete ${shellWord(n)}${again}\` deletes it, after asking to confirm.`);
162
+ const branchesLine = known !== "" ? [`Its branches: ${known}.`] : [];
163
+ if (near.length > 0) {
164
+ const { SourceError } = await import("./source-resolve-S2XA3XZF.js");
165
+ throw new SourceError([missed, ...meant, ...branchesLine].join("\n"), "gone", "workspace", near[0], near.length > 1 ? near : void 0);
166
+ }
167
+ warn(missed, "branch.not-found", branchesLine);
168
+ if (isMachineOutput(args)) {
169
+ writeJson({
170
+ verb: "delete",
171
+ destination: writeTargetPayload(destination2),
172
+ workspaceId,
173
+ branch: label2,
174
+ deleted: false,
175
+ alreadyGone: true,
176
+ declined: false
177
+ });
178
+ }
179
+ return;
180
+ }
181
+ const branch = requireBranch(branches, typed);
182
+ const label = branch.label;
183
+ if (verb === "delete" && branch.live) {
184
+ throw new CliError(
185
+ "SDK_BRANCH_LIVE",
186
+ `Branch "${label}" is the LIVE branch of workspace #${workspaceId} and cannot be deleted.
187
+ Promote another branch first (\`xanosdk workspace branch set-live <other>${pipedYes(args)}${contextFlags()}\`), then delete this one.`,
188
+ { exitCode: 2, details: { conflictsWith: { live: label } } }
189
+ );
190
+ }
191
+ const destination = credentialWriteTarget({ instance: auth.instance, workspaceId });
192
+ const refusing = verb === "delete" && args.yes !== true && process.stdin.isTTY !== true;
193
+ step(
194
+ verb === "set-live" ? `Making branch ${shownLabel(label)} live` : `${refusing ? "Would delete" : "Deleting"} branch ${shownLabel(label)}`
195
+ );
196
+ discloseWriteTarget(destination);
197
+ if (verb === "set-live") {
198
+ if (args.expectLive !== void 0) {
199
+ const mismatch = liveMismatch({ branches, unaddressable }, args.expectLive);
200
+ if (mismatch !== void 0) {
201
+ throw liveBranchMismatch(
202
+ `\`--expect-live ${args.expectLive}\` does not hold: ${mismatch.why}. Nothing was switched.
203
+ Check what is serving with \`xanosdk workspace branch list${contextFlags()}\`, then run set-live again.`,
204
+ mismatch.live
205
+ );
206
+ }
207
+ }
208
+ if (branch.live) {
209
+ success(`Branch "${label}" is already live in workspace #${workspaceId} \u2014 nothing to do.`);
210
+ if (isMachineOutput(args)) {
211
+ writeJson({
212
+ verb: "set-live",
213
+ destination: writeTargetPayload(destination),
214
+ workspaceId,
215
+ branch: label,
216
+ setLive: false,
217
+ alreadyLive: true,
218
+ declined: false
219
+ });
220
+ }
221
+ return;
222
+ }
223
+ const outgoing = branches.find((b) => b.live)?.label;
224
+ blank();
225
+ if (outgoing !== void 0) {
226
+ warn(
227
+ `This is a production cutover for workspace #${workspaceId}.`,
228
+ "branch.production-cutover",
229
+ [`The runtime stops serving "${outgoing}" and starts serving "${label}".`]
230
+ );
231
+ } else {
232
+ warn(`No branch is live in workspace #${workspaceId} \u2014 "${label}" becomes the branch the runtime serves.`, "branch.none-live");
233
+ }
234
+ detail("Table data is unaffected \u2014 it is shared by every branch either way.");
235
+ const readBranch = (name) => exportWorkspaceBundle(auth, {
236
+ base: auth.instance,
237
+ workspaceId,
238
+ label: `reading branch ${shownLabel(name)}`,
239
+ branch: name,
240
+ safeErrors: true
241
+ }).catch(() => void 0);
242
+ const [incoming, served] = await Promise.all([
243
+ readBranch(label),
244
+ outgoing === void 0 ? Promise.resolve(void 0) : readBranch(outgoing)
245
+ ]);
246
+ const stale = incoming === void 0 ? [] : staleSchemaRefs(incoming);
247
+ if (stale.length > 0) {
248
+ warn(
249
+ `"${label}"'s logic writes ${stale.length === 1 ? "a column" : `${stale.length} columns`} the shared tables no longer have \u2014 once it is live, ${stale.length === 1 ? "that write stores" : "those writes store"} nothing there:`,
250
+ "branch.stale-schema-refs",
251
+ stale
252
+ );
253
+ }
254
+ const moves = incoming === void 0 || served === void 0 ? [] : releaseCanonicalMoves(incoming, served);
255
+ discloseCanonicalMoves(moves, { subject: "the set-live", when: "as it goes live" });
256
+ blank();
257
+ if (!args.yes) {
258
+ const ok = await confirm(`Make "${label}" the live branch?${movesClause(moves)}`, {
259
+ flag: "--yes",
260
+ refusal: {
261
+ details: { verb: "set-live", branch: label, setLive: false, alreadyLive: false, declined: false },
262
+ rerun: branchRerun(args, "set-live", label)
263
+ }
264
+ });
265
+ if (!ok) {
266
+ info("Set-live cancelled \u2014 nothing was switched; the live branch is unchanged.");
267
+ if (isMachineOutput(args)) {
268
+ writeJson({
269
+ verb: "set-live",
270
+ destination: writeTargetPayload(destination),
271
+ workspaceId,
272
+ branch: label,
273
+ setLive: false,
274
+ alreadyLive: false,
275
+ declined: true
276
+ });
277
+ }
278
+ return;
279
+ }
280
+ }
281
+ if (args.expectLive !== void 0) {
282
+ const now = await listBranchListing(auth, target).catch(async (err) => {
283
+ const { unansweredRead } = await import("./source-resolve-S2XA3XZF.js");
284
+ throw unansweredRead(err, `list the branches of workspace ${workspaceId}`, "workspace");
285
+ });
286
+ const drift = liveMismatch(now, args.expectLive);
287
+ if (drift !== void 0) {
288
+ throw liveBranchMismatch(
289
+ `\`--expect-live ${args.expectLive}\` no longer holds \u2014 ${drift.why}. Live changed while this ran; the check is not atomic, so it is re-read before switching and the switch refused. Nothing was switched.
290
+ Check what is serving with \`xanosdk workspace branch list${contextFlags()}\`, then run set-live again.`,
291
+ drift.live
292
+ );
293
+ }
294
+ }
295
+ await describeWrite(
296
+ { what: `the switch of the live branch to "${label}"`, resolveWith: `xanosdk workspace branch list${contextFlags()}` },
297
+ () => setLiveBranch(auth, { ...target, label })
298
+ );
299
+ success(`Branch "${label}" is now live in workspace #${workspaceId}.`);
300
+ if (outgoing !== void 0) {
301
+ detail(`Roll back with \`xanosdk workspace branch set-live ${outgoing}${pipedYes(args)}${contextFlags()}\`.`);
302
+ }
303
+ if (isMachineOutput(args)) {
304
+ writeJson({
305
+ verb: "set-live",
306
+ destination: writeTargetPayload(destination),
307
+ workspaceId,
308
+ branch: label,
309
+ setLive: true,
310
+ alreadyLive: false,
311
+ previousBranch: outgoing,
312
+ canonicalMoves: moves,
313
+ declined: false
314
+ });
315
+ }
316
+ return;
317
+ }
318
+ if (!args.yes) {
319
+ const ok = await confirm(`Delete branch "${label}" from workspace #${workspaceId}?`, {
320
+ flag: "--yes",
321
+ refusal: {
322
+ details: { verb: "delete", branch: label, deleted: false, alreadyGone: false, declined: false },
323
+ rerun: branchRerun(args, "delete", label)
324
+ }
325
+ });
326
+ if (!ok) {
327
+ info("Deletion cancelled \u2014 nothing was deleted.");
328
+ if (isMachineOutput(args)) {
329
+ writeJson({
330
+ verb: "delete",
331
+ destination: writeTargetPayload(destination),
332
+ workspaceId,
333
+ branch: label,
334
+ deleted: false,
335
+ alreadyGone: false,
336
+ declined: true
337
+ });
338
+ }
339
+ return;
340
+ }
341
+ }
342
+ await describeWrite(
343
+ { what: `the delete of branch "${label}"`, resolveWith: `xanosdk workspace branch list${contextFlags()}` },
344
+ () => deleteBranch(auth, { ...target, label })
345
+ );
346
+ success(`Deleted branch "${label}" from workspace #${workspaceId}.`);
347
+ if (isMachineOutput(args)) {
348
+ writeJson({
349
+ verb: "delete",
350
+ destination: writeTargetPayload(destination),
351
+ workspaceId,
352
+ branch: label,
353
+ deleted: true,
354
+ alreadyGone: false,
355
+ declined: false
356
+ });
357
+ }
358
+ }
359
+ function liveMismatch(listing, expected) {
360
+ const live = liveBranchLabel(listing.branches);
361
+ if (live === expected) return void 0;
362
+ if (live !== void 0) return { why: `"${live}" is live, not "${expected}"`, live };
363
+ if (listing.unaddressable.some((b) => b.live)) {
364
+ return { why: `the live branch has no label, so it cannot be "${expected}"`, live: null };
365
+ }
366
+ return { why: `no branch reports as live, so "${expected}" is not`, live: null };
367
+ }
368
+ function liveBranchMismatch(message, live) {
369
+ return new CliError("SDK_LIVE_BRANCH_MISMATCH", message, { details: { conflictsWith: { live } }, exitCode: 2 });
370
+ }
371
+ function branchRerun(args, verb, label) {
372
+ const expect = verb === "set-live" && args.expectLive !== void 0 ? ` --expect-live ${shellWord(args.expectLive)}` : "";
373
+ return `xanosdk workspace branch ${verb} ${shellWord(label)}${expect} --yes${args.json === true ? " --json" : ""}${contextFlags(args)}`;
374
+ }
375
+ var ROW_WRITES = /^mvp:dbo_(?:add|edit|add_or_edit|patch)$/;
376
+ function staleSchemaRefs(bundle) {
377
+ const payload = bundle?.payload;
378
+ if (payload === null || typeof payload !== "object") return [];
379
+ const sections = payload;
380
+ const tables = /* @__PURE__ */ new Map();
381
+ for (const t of Array.isArray(sections.dbo) ? sections.dbo : []) {
382
+ if (typeof t?.guid !== "string") continue;
383
+ const schema = Array.isArray(t.schema) ? t.schema : [];
384
+ tables.set(t.guid, {
385
+ name: typeof t.name === "string" ? t.name : t.guid,
386
+ columns: new Set(schema.map((c) => c?.name).filter((n) => typeof n === "string"))
387
+ });
388
+ }
389
+ const out = /* @__PURE__ */ new Set();
390
+ const walk = (node, where) => {
391
+ if (Array.isArray(node)) {
392
+ for (const n of node) walk(n, where);
393
+ return;
394
+ }
395
+ if (node === null || typeof node !== "object") return;
396
+ const stmt = node;
397
+ const ref = stmt.context?.dbo?.id;
398
+ if (typeof stmt.name === "string" && ROW_WRITES.test(stmt.name) && typeof ref === "string" && Array.isArray(stmt.input)) {
399
+ const table = tables.get(ref);
400
+ for (const field of stmt.input) {
401
+ if (typeof field?.name !== "string" || field.ignore === true) continue;
402
+ if (table === void 0) out.add(`a table no longer there (${ref}).${field.name}${where}`);
403
+ else if (!table.columns.has(field.name)) out.add(`${table.name}.${field.name}${where}`);
404
+ }
405
+ }
406
+ for (const value of Object.values(stmt)) walk(value, where);
407
+ };
408
+ for (const [section, rows] of Object.entries(sections)) {
409
+ if (section === "dbo" || !Array.isArray(rows)) continue;
410
+ for (const row of rows) {
411
+ if (row === null || typeof row !== "object") continue;
412
+ const name = typeof row.name === "string" ? row.name : "";
413
+ const verb = typeof row.verb === "string" ? `${row.verb} ` : "";
414
+ walk(row, ` (${sectionKind(section, row)} ${verb}${name})`);
415
+ }
416
+ }
417
+ return [...out];
418
+ }
419
+
420
+ export {
421
+ shownLabel,
422
+ runBranchCommand,
423
+ liveMismatch,
424
+ liveBranchMismatch,
425
+ staleSchemaRefs
426
+ };
427
+ //# sourceMappingURL=chunk-K6RXBGUB.js.map