@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,408 @@
1
+ import {
2
+ asTimestamp
3
+ } from "./chunk-2MNLRIOX.js";
4
+ import {
5
+ explainFetchFailure,
6
+ fetchOrExplain,
7
+ fetchReadOrExplain,
8
+ parseJsonAnswer,
9
+ retryingFetch,
10
+ safeHttpFailure,
11
+ statusLabel,
12
+ writeStatusAftermath
13
+ } from "./chunk-YLDALTWZ.js";
14
+
15
+ // src/deploy/release.ts
16
+ var TIMEOUT_MS = 3e4;
17
+ var ReleaseHttpError = class extends Error {
18
+ constructor(status, action, statusText, body, bind, aftermath) {
19
+ const head = safeHttpFailure(action, { status, statusText }, body, bind);
20
+ super(aftermath === void 0 ? head : `${head}
21
+ ${aftermath}`);
22
+ this.status = status;
23
+ this.name = "ReleaseHttpError";
24
+ }
25
+ status;
26
+ };
27
+ var DEPLOY_TIMEOUT_MS = 6e5;
28
+ var ORIGIN_MARKER = "[xanosdk] cut from";
29
+ var COPY_MARKER = "[xanosdk] copied from";
30
+ var RESERVED_DESCRIPTION_PREFIX = "[xanosdk]";
31
+ var ORIGIN_LINE = /(?:^|\n\n)\[xanosdk\] cut from ([a-z]+) "([^"\n]+)"\s*$/;
32
+ var CUT_LINE = /^\[xanosdk\] cut from ([a-z]+) "([^"\n]+)"$/;
33
+ var COPY_LINE = /^\[xanosdk\] copied from release ("(?:[^"\\\n]|\\.)*") of workspace (\d+) on ([^\s"]+)$/;
34
+ function reservedDescriptionLine(description) {
35
+ return description.split(/\r?\n|\r/).find((l) => l.trimStart().startsWith(RESERVED_DESCRIPTION_PREFIX));
36
+ }
37
+ function describeWithOrigin(description, origin) {
38
+ const line = `${ORIGIN_MARKER} ${origin.type} ${JSON.stringify(origin.name)}`;
39
+ return description === void 0 || description === "" ? line : `${description}
40
+
41
+ ${line}`;
42
+ }
43
+ function describeAsCopy(description, copied) {
44
+ const { host, workspaceId, release } = copied.source;
45
+ const lines = [
46
+ ...copied.cut === void 0 ? [] : [`${ORIGIN_MARKER} ${copied.cut.type} ${JSON.stringify(copied.cut.name)}`],
47
+ `${COPY_MARKER} release ${JSON.stringify(release)} of workspace ${workspaceId} on ${host}`
48
+ ].join("\n");
49
+ return description === void 0 || description === "" ? lines : `${description}
50
+
51
+ ${lines}`;
52
+ }
53
+ function splitRecordedOrigin(description) {
54
+ if (description === void 0) return { description };
55
+ const m = ORIGIN_LINE.exec(description);
56
+ if (m === null || m[1] === "branch") return { description };
57
+ return { description: description.slice(0, m.index), origin: { type: m[1], name: m[2] } };
58
+ }
59
+ function splitCopiedFrom(description) {
60
+ if (description === void 0) return { description };
61
+ const lines = description.replace(/\s+$/, "").split("\n");
62
+ const copy = COPY_LINE.exec(lines[lines.length - 1] ?? "");
63
+ if (copy === null) return { description };
64
+ let release;
65
+ try {
66
+ release = JSON.parse(copy[1]);
67
+ } catch {
68
+ return { description };
69
+ }
70
+ if (typeof release !== "string") return { description };
71
+ let at = lines.length - 1;
72
+ const cutMatch = at > 0 ? CUT_LINE.exec(lines[at - 1]) : null;
73
+ if (cutMatch !== null) at--;
74
+ if (at > 0 && lines[at - 1] !== "") return { description };
75
+ const source = { host: copy[3], workspaceId: Number(copy[2]), release };
76
+ return {
77
+ description: lines.slice(0, Math.max(at - 1, 0)).join("\n"),
78
+ copiedFrom: { source, ...cutMatch === null ? {} : { cut: { type: cutMatch[1], name: cutMatch[2] } } }
79
+ };
80
+ }
81
+ function asString(v) {
82
+ return typeof v === "string" && v !== "" ? v : void 0;
83
+ }
84
+ function asReportedString(v) {
85
+ return typeof v === "string" ? v : void 0;
86
+ }
87
+ function asNumber(v) {
88
+ return typeof v === "number" ? v : void 0;
89
+ }
90
+ function positiveSize(v) {
91
+ const n = asNumber(v);
92
+ return n !== void 0 && n > 0 ? n : void 0;
93
+ }
94
+ function projectRelease(raw) {
95
+ const tables = Array.isArray(raw.tables) ? raw.tables : [];
96
+ const environmentCut = raw.branch === "" || raw.branch === void 0 || raw.branch === null;
97
+ const copied = splitCopiedFrom(asReportedString(raw.description));
98
+ const described = copied.copiedFrom !== void 0 ? { description: copied.description } : environmentCut ? splitRecordedOrigin(asReportedString(raw.description)) : { description: asReportedString(raw.description) };
99
+ return {
100
+ id: asNumber(raw.id),
101
+ name: asString(raw.name) ?? "",
102
+ description: described.description,
103
+ ...described.origin !== void 0 ? { recordedOrigin: described.origin } : {},
104
+ ...copied.copiedFrom !== void 0 ? { copiedFrom: copied.copiedFrom } : {},
105
+ branch: raw.branch === "" ? null : asReportedString(raw.branch),
106
+ hotfix: raw.hotfix === true,
107
+ seededTables: tables.flatMap((t) => {
108
+ if (t === null || typeof t !== "object") return [];
109
+ const row = t;
110
+ const name = asString(row.name);
111
+ return name === void 0 ? [] : [{ name, guid: asString(row.guid), count: asNumber(row.cnt) }];
112
+ }),
113
+ createdAt: asTimestamp(raw.created_at),
114
+ // No `workspaceId`: no release route reports one. The field read
115
+ // `raw.workspace?.id` against a `workspace` object none of list, get or
116
+ // create has ever sent, so it was always `undefined` and never appeared in
117
+ // `--json` at all. A caller already knows the workspace — it is in the URL
118
+ // it asked on. See `test/fixtures/release/live-records.json`.
119
+ //
120
+ // Either signal proves the archive is there. `resource_size` is the one the
121
+ // routes actually send — as recorded, NO route carries `resource`, and
122
+ // keying on the path alone reported EVERY release as having lost its
123
+ // contents, including one cut seconds earlier. The path clause stays
124
+ // because an engine that does send it must not be read as an empty
125
+ // archive; it is a fallback, not the primary signal.
126
+ hasResource: asString(raw.resource) !== void 0 || (asNumber(raw.resource_size) ?? 0) > 0,
127
+ resourceSize: positiveSize(raw.resource_size)
128
+ };
129
+ }
130
+ function metaRequest(auth, path, init, timeoutMs, base2) {
131
+ const url = base2 !== void 0 ? new URL(`${base2.replace(/\/$/, "")}${path}`) : new URL(path, auth.instance);
132
+ return {
133
+ url: url.href,
134
+ init: {
135
+ ...init,
136
+ headers: {
137
+ accept: "application/json",
138
+ Authorization: `Bearer ${auth.access_token}`,
139
+ ...init.headers ?? {}
140
+ },
141
+ signal: AbortSignal.timeout(timeoutMs)
142
+ }
143
+ };
144
+ }
145
+ async function metaWrite(auth, path, action, init, timeoutMs = TIMEOUT_MS, base2) {
146
+ const req = metaRequest(auth, path, init, timeoutMs, base2);
147
+ return fetchOrExplain(req.url, req.init, action, timeoutMs);
148
+ }
149
+ async function metaRead(auth, path, action, base2) {
150
+ const req = metaRequest(auth, path, { method: "GET" }, TIMEOUT_MS, base2);
151
+ return fetchReadOrExplain(req.url, req.init, action, TIMEOUT_MS);
152
+ }
153
+ function binding(auth, workspaceId, base2) {
154
+ return {
155
+ boundWorkspaceId: auth.workspaceId,
156
+ instance: auth.instance,
157
+ profile: auth.profile,
158
+ addressedWorkspaceId: workspaceId,
159
+ credentialType: auth.credentialType,
160
+ tenantHost: base2 !== void 0
161
+ };
162
+ }
163
+ async function readJson(res, action, bind) {
164
+ const text = await res.text();
165
+ if (!res.ok) throw new ReleaseHttpError(res.status, action, res.statusText, text, bind);
166
+ return parseJsonAnswer(text, action, res.url, { safe: true });
167
+ }
168
+ function base(workspaceId) {
169
+ return `/api:meta/workspace/${workspaceId}/release`;
170
+ }
171
+ var PER_PAGE = 100;
172
+ function pageRows(body) {
173
+ if (Array.isArray(body)) return body;
174
+ if (body === null || typeof body !== "object") return [];
175
+ const items = body.items;
176
+ return Array.isArray(items) ? items : [];
177
+ }
178
+ function nextPageOf(body) {
179
+ if (body === null || typeof body !== "object" || Array.isArray(body)) return void 0;
180
+ const next = body.nextPage;
181
+ if (next === null) return null;
182
+ return typeof next === "number" ? next : void 0;
183
+ }
184
+ async function listReleases(auth, opts) {
185
+ const out = [];
186
+ let page = 1;
187
+ for (; ; ) {
188
+ const path = `${base(opts.workspaceId)}?page=${page}&per_page=${PER_PAGE}`;
189
+ const res = await metaRead(auth, path, "list releases", opts.base);
190
+ const body = await readJson(res, "list releases", binding(auth, opts.workspaceId, opts.base));
191
+ const rows = pageRows(body);
192
+ for (const r of rows) {
193
+ if (r !== null && typeof r === "object") out.push(projectRelease(r));
194
+ }
195
+ const next = nextPageOf(body);
196
+ if (next === void 0) {
197
+ if (rows.length < PER_PAGE) return out;
198
+ page += 1;
199
+ continue;
200
+ }
201
+ if (next === null) return out;
202
+ if (next <= page) return out;
203
+ page = next;
204
+ }
205
+ }
206
+ async function getRelease(auth, opts) {
207
+ const path = `${base(opts.workspaceId)}/${opts.id}`;
208
+ const res = await metaRead(auth, path, "get release", opts.base);
209
+ if (res.status === 404) return null;
210
+ const raw = await readJson(res, "get release", binding(auth, opts.workspaceId, opts.base));
211
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
212
+ throw new Error(`get release: the instance did not return a release record.`);
213
+ }
214
+ return projectRelease(raw);
215
+ }
216
+ async function findRelease(auth, opts) {
217
+ const all = await listReleases(auth, opts);
218
+ return all.find((r) => r.name === opts.name) ?? null;
219
+ }
220
+ var MAX_RELEASE_NAME = 100;
221
+ function assertUsableReleaseName(name) {
222
+ if (name.trim() === "") {
223
+ throw new Error(
224
+ `\`release create\` needs a name and was given an empty one.
225
+ The engine does not reject one \u2014 it would store a release that \`release show\`, \`export\` and \`promote\` all address BY NAME and so none of them could reach.`
226
+ );
227
+ }
228
+ if (name.includes("/") || name.includes("\\") || name.includes(":")) {
229
+ throw new Error(
230
+ `A release name cannot address a location, and "${name}" does.
231
+ The name is what \`xanosdk release export\` writes the file as, so a name holding \`/\`, \`\\\` or \`:\` would put that file somewhere nobody asked for \u2014 outside the directory the export was invoked from when the name also traverses up, and on another drive when it begins \`C:\` on Windows.
232
+ Name the release, and use \`--path\` on the export to choose where it lands.`
233
+ );
234
+ }
235
+ if (name.startsWith(".")) {
236
+ throw new Error(
237
+ `A release name cannot begin with a dot, and "${name}" does.
238
+ \`.\` and \`..\` address a directory rather than name one, and any other leading dot exports to a hidden file in the working directory that a reader will not see.`
239
+ );
240
+ }
241
+ if ([...name].length > MAX_RELEASE_NAME) {
242
+ throw new Error(
243
+ `A release name can be at most ${MAX_RELEASE_NAME} characters, and this one is ${[...name].length}.
244
+ The name is what every release command addresses it by and what \`release export\` writes the file as. Pick a shorter one \u2014 put the detail in \`--description\`.`
245
+ );
246
+ }
247
+ const unpromotable = unpromotableReleasePart(name);
248
+ if (unpromotable !== void 0) {
249
+ throw new Error(
250
+ `A release name cannot hold \`${unpromotable}\`, and "${name}" does.
251
+ It would be cut, but \`xanosdk promote\` could never land it: the route a promote lands a release by cannot address a name holding ${UNPROMOTABLE_RELEASE_PARTS}. Name it "${promotableReleaseName(name)}" instead.`
252
+ );
253
+ }
254
+ if ([...name].some((ch) => ch.charCodeAt(0) < 32 || ch.charCodeAt(0) === 127)) {
255
+ throw new Error(
256
+ `A release name cannot carry a control character (a tab, a newline, \u2026), and ${JSON.stringify(name)} does.
257
+ The engine stores it as typed, so every command that addresses the release \u2014 and the file \`release export\` writes \u2014 would need the same invisible character typed back.`
258
+ );
259
+ }
260
+ }
261
+ function unpromotableReleasePart(name) {
262
+ if (name.includes("..")) return "..";
263
+ return ["+", "=", "|"].find((ch) => name.includes(ch));
264
+ }
265
+ function untenantDeployableReleasePart(name) {
266
+ return ["=", "|"].find((ch) => name.includes(ch));
267
+ }
268
+ var UNPROMOTABLE_RELEASE_PARTS = "`+`, `=`, `|` or `..`";
269
+ function promotableReleaseName(name) {
270
+ return name.replace(/\.{2,}/g, ".").replace(/[+=|]/g, "-");
271
+ }
272
+ async function createRelease(auth, opts) {
273
+ const body = { name: opts.name, branch: opts.branch };
274
+ if (opts.description !== void 0) body.description = opts.description;
275
+ if (opts.hotfix !== void 0) body.hotfix = opts.hotfix;
276
+ if (opts.tableIds !== void 0) body.table_ids = opts.tableIds;
277
+ if (opts.sourceTenant !== void 0) body.source_tenant = opts.sourceTenant;
278
+ const res = await metaWrite(
279
+ auth,
280
+ base(opts.workspaceId),
281
+ "create release",
282
+ {
283
+ method: "POST",
284
+ headers: { "Content-Type": "application/json" },
285
+ body: JSON.stringify(body)
286
+ },
287
+ DEPLOY_TIMEOUT_MS,
288
+ opts.base
289
+ );
290
+ return projectRelease(await readJson(res, "create release", binding(auth, opts.workspaceId, opts.base)));
291
+ }
292
+ async function deployRelease(auth, opts) {
293
+ const body = { set_live: opts.setLive === true };
294
+ if (opts.branch !== void 0) body.branch = opts.branch;
295
+ const path = `${base(opts.workspaceId)}/${encodeURIComponent(opts.name)}/deploy`;
296
+ const res = await metaWrite(
297
+ auth,
298
+ path,
299
+ "deploy release",
300
+ { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) },
301
+ DEPLOY_TIMEOUT_MS
302
+ );
303
+ return projectRelease(await readJson(res, "deploy release", binding(auth, opts.workspaceId)));
304
+ }
305
+ async function downloadRelease(auth, opts) {
306
+ const path = `${base(opts.workspaceId)}/${opts.id}/export`;
307
+ const res = await metaRead(auth, path, "export release", opts.base);
308
+ const link = await readJson(res, "export release", binding(auth, opts.workspaceId, opts.base));
309
+ const src = typeof link.src === "string" && link.src !== "" ? link.src : void 0;
310
+ if (src === void 0) {
311
+ throw new Error(`export release: the instance returned no download link.`);
312
+ }
313
+ let file;
314
+ try {
315
+ file = await retryingFetch(src, { method: "GET", signal: AbortSignal.timeout(DEPLOY_TIMEOUT_MS) });
316
+ } catch (err) {
317
+ throw explainFetchFailure(err, {
318
+ url: src,
319
+ what: "download release archive",
320
+ timeoutMs: DEPLOY_TIMEOUT_MS,
321
+ display: "the release download link"
322
+ });
323
+ }
324
+ if (!file.ok) {
325
+ throw Object.assign(
326
+ new Error(`download release archive failed (${statusLabel(file)}). The link may have expired \u2014 retry.`),
327
+ { status: file.status }
328
+ );
329
+ }
330
+ return new Uint8Array(await file.arrayBuffer());
331
+ }
332
+ async function importRelease(auth, opts) {
333
+ const form = new FormData();
334
+ form.append("file", new Blob([opts.archive], { type: "application/gzip" }), "release.tar.gz");
335
+ const res = await metaWrite(
336
+ auth,
337
+ `${base(opts.workspaceId)}/import`,
338
+ "import release",
339
+ { method: "POST", body: form },
340
+ DEPLOY_TIMEOUT_MS
341
+ );
342
+ const body = await readJson(res, "import release", binding(auth, opts.workspaceId));
343
+ const id = body !== null && typeof body === "object" ? body.id : void 0;
344
+ if (typeof id !== "number") {
345
+ throw new Error(`import release: the instance returned no release id.`);
346
+ }
347
+ return { id };
348
+ }
349
+ async function updateReleaseDescription(auth, opts) {
350
+ const res = await metaWrite(auth, `${base(opts.workspaceId)}/${opts.id}`, "update release", {
351
+ method: "PUT",
352
+ headers: { "Content-Type": "application/json" },
353
+ body: JSON.stringify({ name: opts.name, description: opts.description })
354
+ });
355
+ const body = await readJson(res, "update release", binding(auth, opts.workspaceId));
356
+ if (body === null || typeof body !== "object" || Array.isArray(body)) {
357
+ throw new Error(`update release: the instance answered with no release record.`);
358
+ }
359
+ return projectRelease(body);
360
+ }
361
+ var SCRATCH_WORKSPACE_NAME = /"workspace-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"/gi;
362
+ async function exportRelease(auth, opts) {
363
+ const path = `${base(opts.workspaceId)}/${opts.id}/multidoc${opts.records === true ? "?records=true" : ""}`;
364
+ const res = await metaRead(auth, path, "export release");
365
+ const text = await res.text();
366
+ if (!res.ok) throw new ReleaseHttpError(res.status, "export release", res.statusText, text, binding(auth, opts.workspaceId));
367
+ return opts.name === void 0 ? text : text.replace(SCRATCH_WORKSPACE_NAME, JSON.stringify(opts.name));
368
+ }
369
+ async function deleteRelease(auth, opts) {
370
+ const path = `${base(opts.workspaceId)}/${opts.id}`;
371
+ const res = await metaWrite(auth, path, "delete release", { method: "DELETE" }, TIMEOUT_MS, opts.base);
372
+ if (res.status === 404) return { alreadyGone: true };
373
+ if (!res.ok) {
374
+ throw new ReleaseHttpError(
375
+ res.status,
376
+ "delete release",
377
+ res.statusText,
378
+ await res.text(),
379
+ binding(auth, opts.workspaceId, opts.base),
380
+ writeStatusAftermath(res.status)
381
+ );
382
+ }
383
+ return { alreadyGone: false };
384
+ }
385
+
386
+ export {
387
+ ReleaseHttpError,
388
+ RESERVED_DESCRIPTION_PREFIX,
389
+ reservedDescriptionLine,
390
+ describeWithOrigin,
391
+ describeAsCopy,
392
+ listReleases,
393
+ getRelease,
394
+ findRelease,
395
+ assertUsableReleaseName,
396
+ unpromotableReleasePart,
397
+ untenantDeployableReleasePart,
398
+ UNPROMOTABLE_RELEASE_PARTS,
399
+ promotableReleaseName,
400
+ createRelease,
401
+ deployRelease,
402
+ downloadRelease,
403
+ importRelease,
404
+ updateReleaseDescription,
405
+ exportRelease,
406
+ deleteRelease
407
+ };
408
+ //# sourceMappingURL=chunk-2ZUEE4EK.js.map
@@ -0,0 +1,22 @@
1
+ // src/util/article.ts
2
+ function article(word) {
3
+ const w = word.trim().toLowerCase();
4
+ const digits = /^\d+/.exec(w)?.[0];
5
+ if (digits !== void 0) {
6
+ if (digits.startsWith("8")) return "an";
7
+ const lead = digits.length % 3 === 2 ? digits.slice(0, 2) : "";
8
+ return lead === "11" || lead === "18" ? "an" : "a";
9
+ }
10
+ if (/^(uu|uni|uint|use|usu|uti|ur[il]|eu|one\b|once)/.test(w)) return "a";
11
+ if (/^(mcp|llm|mfa|sql|sms|smtp|ssl|ssh|xml|html|http|rpc)/.test(w)) return "an";
12
+ return /^[aeiou]/.test(w) ? "an" : "a";
13
+ }
14
+ function withArticle(word) {
15
+ return `${article(word)} ${word}`;
16
+ }
17
+
18
+ export {
19
+ article,
20
+ withArticle
21
+ };
22
+ //# sourceMappingURL=chunk-36JUQZVQ.js.map
@@ -0,0 +1,83 @@
1
+ import {
2
+ tarGz
3
+ } from "./chunk-X4DVXBFY.js";
4
+
5
+ // src/validate/archive.ts
6
+ import { gunzipSync } from "zlib";
7
+ function encodeWorkspaceArchive(workspaceJson, extra = []) {
8
+ return tarGz([
9
+ { name: "workspace.json", data: Buffer.from(workspaceJson, "utf8") },
10
+ ...extra.map((e) => ({
11
+ name: e.name,
12
+ data: typeof e.content === "string" ? Buffer.from(e.content, "utf8") : Buffer.from(e.content)
13
+ }))
14
+ ]);
15
+ }
16
+ function archiveHostedFiles(archive) {
17
+ return Object.entries(readArchiveEntries(archive)).filter(([name]) => name.startsWith("vault/")).map(([name, data]) => ({ name, content: data }));
18
+ }
19
+ var MAX_UNWRAPPED_BYTES = 1024 * 1024 * 1024;
20
+ var ArchiveTooLargeError = class extends Error {
21
+ constructor(maxBytes) {
22
+ super(`The archive decompresses to more than ${maxBytes} bytes, so it was not read.`);
23
+ this.maxBytes = maxBytes;
24
+ }
25
+ maxBytes;
26
+ name = "ArchiveTooLargeError";
27
+ };
28
+ function unwrapGzip(data, opts = {}) {
29
+ const maxBytes = opts.maxBytes ?? MAX_UNWRAPPED_BYTES;
30
+ let buf = Buffer.from(data);
31
+ let guard = 0;
32
+ while (buf.length > 2 && buf[0] === 31 && buf[1] === 139 && guard++ < 8) {
33
+ try {
34
+ buf = gunzipSync(buf, { maxOutputLength: maxBytes });
35
+ } catch (err) {
36
+ if (err.code === "ERR_BUFFER_TOO_LARGE") {
37
+ throw new ArchiveTooLargeError(maxBytes);
38
+ }
39
+ throw err;
40
+ }
41
+ }
42
+ return buf;
43
+ }
44
+ function readArchiveEntries(data) {
45
+ const out = {};
46
+ for (const [name, bytes] of Object.entries(readTar(unwrapGzip(data)))) {
47
+ out[name.replace(/^\.\//, "")] = bytes;
48
+ }
49
+ return out;
50
+ }
51
+ function decodeWorkspaceArchive(data) {
52
+ const files = readTar(unwrapGzip(data));
53
+ const key = Object.keys(files).find((k) => k.endsWith("workspace.json"));
54
+ if (key === void 0) {
55
+ const seen = Object.keys(files).join(", ") || "none";
56
+ throw new Error(`Workspace export archive has no workspace.json (entries: ${seen}).`);
57
+ }
58
+ return JSON.parse(files[key].toString("utf8"));
59
+ }
60
+ function readTar(buf) {
61
+ const files = {};
62
+ let off = 0;
63
+ while (off + 512 <= buf.length) {
64
+ const name = buf.toString("utf8", off, off + 100).replace(/\0.*$/, "");
65
+ if (name === "") break;
66
+ const sizeField = buf.toString("utf8", off + 124, off + 136).replace(/\0.*$/, "").trim();
67
+ const size = parseInt(sizeField || "0", 8);
68
+ const start = off + 512;
69
+ if (Number.isFinite(size) && size > 0) files[name] = buf.subarray(start, start + size);
70
+ off = start + Math.ceil(size / 512) * 512;
71
+ }
72
+ return files;
73
+ }
74
+
75
+ export {
76
+ encodeWorkspaceArchive,
77
+ archiveHostedFiles,
78
+ ArchiveTooLargeError,
79
+ unwrapGzip,
80
+ readArchiveEntries,
81
+ decodeWorkspaceArchive
82
+ };
83
+ //# sourceMappingURL=chunk-3DRXWLJ5.js.map
@@ -0,0 +1,137 @@
1
+ // src/workspace/documentation-token.ts
2
+ var WORKSPACE_SECRETS_BASENAME = ".secrets.json";
3
+ var WORKSPACE_SECRETS_FILE = `xano/${WORKSPACE_SECRETS_BASENAME}`;
4
+ function supplyTokenRemedy(remedy, scope) {
5
+ return remedy.supply?.(scope) ?? `--doc-token "${scope}=<value>"`;
6
+ }
7
+ function allowEmptyTokenRemedy(remedy, scope) {
8
+ return remedy.allowEmpty?.(scope) ?? `--allow-empty-doc-token="${scope}"`;
9
+ }
10
+ var SCAFFOLD_SECRETS_REMEDY = { file: WORKSPACE_SECRETS_FILE, fill: "xanosdk secrets fill" };
11
+ function documentationScopeLabel(scope) {
12
+ return scope.kind === "workspace" ? "the workspace" : `API group "${scope.name}"`;
13
+ }
14
+ function documentationScopeFlagLabel(scope) {
15
+ return scope.kind === "workspace" ? "workspace" : scope.name;
16
+ }
17
+ function documentationScopeKey(scope) {
18
+ return scope.kind === "workspace" ? "workspace" : `${API_GROUP_SCOPE_PREFIX}${scope.guid ?? scope.name}`;
19
+ }
20
+ var API_GROUP_SCOPE_PREFIX = "apiGroup:";
21
+ function normalizeDocumentationScopeKey(key) {
22
+ return key.startsWith("app:") ? `${API_GROUP_SCOPE_PREFIX}${key.slice("app:".length)}` : key;
23
+ }
24
+ function apiGroupScope(record) {
25
+ const guid = typeof record.guid === "string" && record.guid !== "" ? record.guid : void 0;
26
+ return {
27
+ kind: "api_group",
28
+ name: typeof record.name === "string" ? record.name : "(unnamed)",
29
+ ...guid !== void 0 ? { guid } : {}
30
+ };
31
+ }
32
+ function documentationTokenLiteral(block) {
33
+ if (block === null || typeof block !== "object" || Array.isArray(block)) return void 0;
34
+ const token = block.token;
35
+ return typeof token === "string" && token !== "" ? token : void 0;
36
+ }
37
+ function awaitsDocumentationToken(block) {
38
+ if (block === null || typeof block !== "object" || Array.isArray(block)) return false;
39
+ return !Object.hasOwn(block, "token");
40
+ }
41
+ function declaresDocumentationGate(block) {
42
+ if (!awaitsDocumentationToken(block)) return false;
43
+ return block.require_token === true;
44
+ }
45
+ function documentationTokenDeclarations(args) {
46
+ const out = [];
47
+ const ws = args.workspace;
48
+ if (ws !== null && typeof ws === "object" && !Array.isArray(ws)) {
49
+ const block = ws.documentation;
50
+ if (awaitsDocumentationToken(block)) {
51
+ const scope = { kind: "workspace" };
52
+ out.push({
53
+ scope,
54
+ key: documentationScopeKey(scope),
55
+ gated: declaresDocumentationGate(block),
56
+ published: false
57
+ });
58
+ }
59
+ }
60
+ for (const group of args.apiGroups ?? []) {
61
+ if (group === null || typeof group !== "object" || Array.isArray(group)) continue;
62
+ const record = group;
63
+ if (!awaitsDocumentationToken(record.documentation)) continue;
64
+ const scope = apiGroupScope(record);
65
+ out.push({
66
+ scope,
67
+ key: documentationScopeKey(scope),
68
+ gated: declaresDocumentationGate(record.documentation),
69
+ published: record.swagger === true
70
+ });
71
+ }
72
+ return out;
73
+ }
74
+ function resolveDocumentationBlock(block, key, values, allowEmpty) {
75
+ if (block === null || typeof block !== "object" || Array.isArray(block)) return void 0;
76
+ const record = { ...block };
77
+ if (!awaitsDocumentationToken(record)) return record;
78
+ if (Object.hasOwn(values, key)) return { ...record, token: values[key] };
79
+ if (allowEmpty.has(key)) return { ...record, token: "" };
80
+ return declaresDocumentationGate(record) ? void 0 : record;
81
+ }
82
+ function resolveDocumentationTokens(args) {
83
+ const allowEmpty = new Set([...args.allowEmpty ?? []].map(normalizeDocumentationScopeKey));
84
+ const values = Object.fromEntries(
85
+ Object.entries(args.values).map(([key, value]) => [normalizeDocumentationScopeKey(key), value])
86
+ );
87
+ args = { ...args, values, allowEmpty };
88
+ const workspace = { ...args.workspace };
89
+ if (Object.hasOwn(workspace, "documentation")) {
90
+ const resolved = resolveDocumentationBlock(
91
+ workspace.documentation,
92
+ documentationScopeKey({ kind: "workspace" }),
93
+ args.values,
94
+ allowEmpty
95
+ );
96
+ if (resolved === void 0) delete workspace.documentation;
97
+ else workspace.documentation = resolved;
98
+ }
99
+ const unresolvedGroups = [];
100
+ const apiGroups = args.apiGroups?.map((group) => {
101
+ if (group === null || typeof group !== "object" || Array.isArray(group)) return group;
102
+ const record = group;
103
+ if (!Object.hasOwn(record, "documentation")) return group;
104
+ const scope = apiGroupScope(record);
105
+ const declared = declaresDocumentationGate(record.documentation);
106
+ const resolved = resolveDocumentationBlock(
107
+ record.documentation,
108
+ documentationScopeKey(scope),
109
+ args.values,
110
+ allowEmpty
111
+ );
112
+ const copy = { ...record };
113
+ if (resolved === void 0) {
114
+ delete copy.documentation;
115
+ if (declared) unresolvedGroups.push(scope.name);
116
+ } else copy.documentation = resolved;
117
+ return copy;
118
+ });
119
+ return { workspace, apiGroups, unresolvedGroups };
120
+ }
121
+
122
+ export {
123
+ WORKSPACE_SECRETS_BASENAME,
124
+ WORKSPACE_SECRETS_FILE,
125
+ supplyTokenRemedy,
126
+ allowEmptyTokenRemedy,
127
+ SCAFFOLD_SECRETS_REMEDY,
128
+ documentationScopeLabel,
129
+ documentationScopeFlagLabel,
130
+ documentationScopeKey,
131
+ normalizeDocumentationScopeKey,
132
+ apiGroupScope,
133
+ documentationTokenLiteral,
134
+ documentationTokenDeclarations,
135
+ resolveDocumentationTokens
136
+ };
137
+ //# sourceMappingURL=chunk-3JDU4VRL.js.map