@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,352 @@
1
+ import {
2
+ tarGz
3
+ } from "./chunk-X4DVXBFY.js";
4
+ import {
5
+ writeTransportFailure
6
+ } from "./chunk-6PBR37LN.js";
7
+ import {
8
+ SENT_AFTERMATH,
9
+ fetchOrExplain,
10
+ httpFailure,
11
+ parseJsonAnswer,
12
+ serverMessage,
13
+ unexpectedAnswerError,
14
+ withWriteStatusAftermath
15
+ } from "./chunk-YLDALTWZ.js";
16
+ import "./chunk-QXTKSOFI.js";
17
+ import "./chunk-X2NL4KUO.js";
18
+ import "./chunk-PTHVMXZI.js";
19
+ import "./chunk-UTI5G6OJ.js";
20
+ import "./chunk-2EZ3ZJZZ.js";
21
+ import "./chunk-5ZSO4T2G.js";
22
+ import "./chunk-TFFGOFVZ.js";
23
+ import "./chunk-36JUQZVQ.js";
24
+ import {
25
+ SERVER_BUNDLE,
26
+ SERVER_ENV,
27
+ isServerPath
28
+ } from "./chunk-OOXWYAA4.js";
29
+ import "./chunk-PZ5AY32C.js";
30
+
31
+ // src/deploy/static-host.ts
32
+ import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from "fs";
33
+ import { join, relative, sep } from "path";
34
+ var STATIC_TIMEOUT_MS = 12e4;
35
+ var MAX_ARCHIVE_BYTES = 100 * 1024 * 1024;
36
+ function scanFiles(dir, opts = {}) {
37
+ const files = [];
38
+ const links = walkBuild(dir, opts, (path, full) => files.push({ path, data: readFileSync(full) }));
39
+ return { files, links };
40
+ }
41
+ function walkBuild(dir, opts, onFile) {
42
+ const links = [];
43
+ const root = realpathSync(dir);
44
+ const inside = (real) => real === root || real.startsWith(root.endsWith(sep) ? root : root + sep);
45
+ const visiting = /* @__PURE__ */ new Set();
46
+ const walk = (cur, real) => {
47
+ if (visiting.has(real)) return;
48
+ visiting.add(real);
49
+ for (const ent of readdirSync(cur, { withFileTypes: true })) {
50
+ const full = join(cur, ent.name);
51
+ const path = relative(dir, full).split(sep).join("/");
52
+ if (opts.server === false && isServerPath(path)) continue;
53
+ if (ent.isSymbolicLink()) {
54
+ let target;
55
+ try {
56
+ target = realpathSync(full);
57
+ } catch {
58
+ links.push({ path, reason: "broken" });
59
+ continue;
60
+ }
61
+ if (!inside(target)) {
62
+ links.push({ path, reason: "outside" });
63
+ continue;
64
+ }
65
+ const st = statSync(target);
66
+ if (st.isDirectory()) walk(full, target);
67
+ else if (st.isFile()) onFile(path, full);
68
+ } else if (ent.isDirectory()) walk(full, join(real, ent.name));
69
+ else if (ent.isFile()) onFile(path, full);
70
+ }
71
+ visiting.delete(real);
72
+ };
73
+ walk(dir, root);
74
+ return links;
75
+ }
76
+ function collectFiles(dir, opts = {}) {
77
+ return scanFiles(dir, opts).files;
78
+ }
79
+ var UNREQUESTED_DOTFILES = /* @__PURE__ */ new Set([".DS_Store", ".gitkeep", ".gitignore", ".nojekyll"]);
80
+ function isHiddenPath(path) {
81
+ const segs = path.split("/");
82
+ return segs.some((seg) => seg.startsWith(".")) && !UNREQUESTED_DOTFILES.has(segs.at(-1));
83
+ }
84
+ function assertStaticDir(dir, label, maxBytes = MAX_ARCHIVE_BYTES, opts = {}) {
85
+ const where = `${label === void 0 ? "" : `${label} `}${dir}`;
86
+ const stat = statSync(dir, { throwIfNoEntry: false });
87
+ if (stat === void 0) throw new StaticDirError(`${where}: directory not found.`);
88
+ if (!stat.isDirectory()) throw new StaticDirError(`${where}: not a directory.`);
89
+ const serverRendered = opts.serverRendered === true;
90
+ if (serverRendered) assertWithinEngineLimits(dir, where);
91
+ const files = collectFiles(dir, { server: serverRendered });
92
+ if (files.length === 0) throw new StaticDirError(`${where}: no files to deploy (directory is empty).`);
93
+ const rendered = files.some((f) => f.path === SERVER_BUNDLE);
94
+ if (!rendered && !files.some((f) => f.path === "index.html")) {
95
+ throw new StaticDirError(
96
+ `${where}: no index.html at its root, so the static host would have no entry page. ` + (existsSync(join(dir, SERVER_BUNDLE)) ? `Its server half (${SERVER_BUNDLE}) renders pages on a local engine only (\`--local-engine\`); a host that serves files needs the root page prerendered.` : `Point it at the build output directory \u2014 the one that holds index.html.`)
97
+ );
98
+ }
99
+ assertArchiveFits(files, where, maxBytes);
100
+ }
101
+ var ENGINE_MAX_FILES = 2e4;
102
+ var ENGINE_MAX_UNPACKED_BYTES = 256 * 1024 * 1024;
103
+ function assertWithinEngineLimits(dir, where) {
104
+ let files = 0;
105
+ let bytes = 0;
106
+ walkBuild(dir, { server: true }, (_path, full) => {
107
+ files++;
108
+ bytes += statSync(full).size;
109
+ });
110
+ const advice = "Point at the build output only (not the project root or node_modules), or trim what it ships.";
111
+ if (files > ENGINE_MAX_FILES) {
112
+ throw new StaticDirError(
113
+ `${where}: ${files.toLocaleString("en-US")} files, over a local engine's limit of ${ENGINE_MAX_FILES.toLocaleString("en-US")}. ${advice}`
114
+ );
115
+ }
116
+ if (bytes > ENGINE_MAX_UNPACKED_BYTES) {
117
+ const mb = (n) => Number((n / (1024 * 1024)).toFixed(2));
118
+ throw new StaticDirError(
119
+ `${where}: ${mb(bytes)} MB unpacked, over a local engine's limit of ${mb(ENGINE_MAX_UNPACKED_BYTES)} MB. ${advice}`
120
+ );
121
+ }
122
+ }
123
+ function assertArchiveFits(files, where, maxBytes) {
124
+ const bound = files.reduce((sum, f) => sum + f.data.length + 1024, 1024);
125
+ if (bound <= maxBytes) return;
126
+ const size = tarGz2(files).length;
127
+ if (size > maxBytes) throw new StaticDirError(overCapMessage(where, size, maxBytes));
128
+ }
129
+ function overCapMessage(where, size, maxBytes = MAX_ARCHIVE_BYTES) {
130
+ const mb = (n) => `${Number((n / (1024 * 1024)).toFixed(2))} MB`;
131
+ return `${where}: the compressed build is ${mb(size)}, over the ${mb(maxBytes)} cap for a static upload. Point at the build output only (not the project root or node_modules), or trim what it ships.`;
132
+ }
133
+ var StaticDirError = class extends Error {
134
+ name = "StaticDirError";
135
+ };
136
+ function findSeedLeaks(dir, values) {
137
+ values = values.filter((v) => v.scannable !== false);
138
+ if (values.length === 0 || !existsSync(dir)) return [];
139
+ const leaks = [];
140
+ for (const file of collectFiles(dir, { server: false })) {
141
+ const text = file.data.toString("latin1");
142
+ const seen = /* @__PURE__ */ new Set();
143
+ for (const v of values) {
144
+ const key = `${v.table}\0${v.column}`;
145
+ if (seen.has(key) || !text.includes(v.value)) continue;
146
+ seen.add(key);
147
+ leaks.push({ file: file.path, table: v.table, column: v.column });
148
+ }
149
+ }
150
+ return leaks;
151
+ }
152
+ function tarGz2(files) {
153
+ return tarGz(files.map((f) => ({ name: f.path, data: f.data })));
154
+ }
155
+ function detectRouting(paths) {
156
+ for (const raw of paths) {
157
+ const path = raw.replace(/^\.?\//, "");
158
+ if (path === "" || path.toLowerCase() === "index.html") continue;
159
+ if (/\.html?$/i.test(path)) return "multipage";
160
+ }
161
+ return "spa";
162
+ }
163
+ function multipageOnlyForErrorPage(paths) {
164
+ const docs = paths.map((p) => p.replace(/^\.?\//, "").toLowerCase()).filter((p) => /\.html?$/.test(p));
165
+ return docs.includes("index.html") && docs.some((p) => p !== "index.html") && docs.every((p) => p === "index.html" || p === "404.html" || p === "200.html");
166
+ }
167
+ function pickUrl(parsed) {
168
+ const dev = parsed.dev;
169
+ const direct = [parsed.custom_url, parsed.default_url, parsed.url, dev?.custom_url, dev?.default_url, dev?.url].find(
170
+ (c) => typeof c === "string" && c !== ""
171
+ );
172
+ if (direct !== void 0) return /^https?:\/\//.test(direct) ? direct : `https://${direct}`;
173
+ const host = [dev?.custom, dev?.host].find((c) => typeof c === "string" && c !== "");
174
+ return host !== void 0 ? `https://${host}` : void 0;
175
+ }
176
+ function pickCanonical(parsed) {
177
+ const dev = parsed.dev;
178
+ const build = parsed.build;
179
+ return [parsed.canonical, dev?.canonical, build?.canonical].find(
180
+ (c) => typeof c === "string" && c !== ""
181
+ );
182
+ }
183
+ function envScript(env) {
184
+ const body = Object.entries(env).map(([k, v]) => `window[${JSON.stringify(k)}]=${JSON.stringify(v)};`).join("").replace(/</g, "\\u003c");
185
+ return `<script>${body}</script>`;
186
+ }
187
+ function injectEnv(html, script) {
188
+ const markup = maskNonMarkup(html);
189
+ const at = (m) => m === null ? void 0 : m.index + m[0].length;
190
+ const anchor = at(/<head(?=[\s>/])[^>]*>/i.exec(markup)) ?? at(/<html(?=[\s>/])[^>]*>/i.exec(markup)) ?? at(/^\s*<!doctype[^>]*>/i.exec(markup)) ?? (/<(?:title|meta|link|base|body)(?=[\s>/])/i.test(markup) ? 0 : void 0);
191
+ if (anchor === void 0) return void 0;
192
+ return html.slice(0, anchor) + script + html.slice(anchor);
193
+ }
194
+ function maskNonMarkup(html) {
195
+ return html.replace(
196
+ /<!--[\s\S]*?(?:-->|$)|<!\[CDATA\[[\s\S]*?(?:\]\]>|$)|<(script|style|noscript|template)(?=[\s>/])[\s\S]*?(?:<\/\1\s*>|$)|<[a-z][^\s/>]*(?:"[^"]*"|'[^']*'|[^'">])*>?/gi,
197
+ (m, element) => element !== void 0 || m.startsWith("<!") ? " ".repeat(m.length) : m.replace(/"[^"]*"|'[^']*'/g, (q) => `${q[0]}${" ".repeat(q.length - 2)}${q[0]}`)
198
+ );
199
+ }
200
+ async function deployStaticHost(req) {
201
+ const serverRendered = req.serverRendered === true;
202
+ assertStaticDir(req.dir, req.label, MAX_ARCHIVE_BYTES, { serverRendered });
203
+ const { files, links } = scanFiles(req.dir, { server: serverRendered });
204
+ const hidden = serverRendered ? [] : files.map((f) => f.path).filter(isHiddenPath);
205
+ const hasServer = existsSync(join(req.dir, SERVER_BUNDLE));
206
+ const envSkipped = [];
207
+ let envDocuments = 0;
208
+ const env = req.env ?? {};
209
+ if (Object.keys(env).length > 0) {
210
+ const script = envScript(env);
211
+ for (const file of files) {
212
+ if (!/\.html?$/i.test(file.path) || isServerPath(file.path)) continue;
213
+ const rewritten = injectEnv(file.data.toString("utf8"), script);
214
+ if (rewritten === void 0) {
215
+ envSkipped.push(file.path);
216
+ continue;
217
+ }
218
+ file.data = Buffer.from(rewritten, "utf8");
219
+ envDocuments++;
220
+ }
221
+ }
222
+ if (serverRendered && hasServer && Object.keys(env).length > 0) {
223
+ const i = files.findIndex((f) => f.path === SERVER_ENV);
224
+ if (i >= 0) files.splice(i, 1);
225
+ files.push({ path: SERVER_ENV, data: Buffer.from(JSON.stringify(env), "utf8") });
226
+ }
227
+ const archive = tarGz2(files);
228
+ if (archive.length > MAX_ARCHIVE_BYTES) {
229
+ throw new StaticDirError(overCapMessage(`${req.label === void 0 ? "" : `${req.label} `}${req.dir}`, archive.length));
230
+ }
231
+ const servedPaths = files.filter((f) => !isServerPath(f.path)).map((f) => f.path);
232
+ const routing = req.routing ?? detectRouting(servedPaths);
233
+ const routingSuspect = req.routing === void 0 && routing === "multipage" && !hasServer && multipageOnlyForErrorPage(servedPaths);
234
+ const host = req.host ?? "default";
235
+ const url = `${req.baseUrl.replace(/\/$/, "")}/api:meta/workspace/${req.workspaceId}/static_host/${encodeURIComponent(host)}/build`;
236
+ const form = new FormData();
237
+ form.append("name", "xanosdk-deploy");
238
+ form.append("routing", routing);
239
+ form.append("file", new Blob([archive], { type: "application/gzip" }), "build.tar.gz");
240
+ const res = await fetchOrExplain(
241
+ url,
242
+ {
243
+ method: "POST",
244
+ headers: { Authorization: `Bearer ${req.accessToken}` },
245
+ body: form,
246
+ signal: AbortSignal.timeout(STATIC_TIMEOUT_MS)
247
+ },
248
+ "Static-host build",
249
+ STATIC_TIMEOUT_MS
250
+ ).catch((err) => {
251
+ throw writeTransportFailure(err);
252
+ });
253
+ const text = await res.text().catch((err) => {
254
+ throw writeTransportFailure(err);
255
+ });
256
+ if (!res.ok) {
257
+ if (serverMessage(text) === "Invalid host") {
258
+ throw new StaticHostNotFoundError(host, await listStaticHostNames(req).catch(() => void 0));
259
+ }
260
+ throw Object.assign(
261
+ new Error(withWriteStatusAftermath(httpFailure("Static-host build", res, text), res.status, void 0, { atomic: true })),
262
+ { status: res.status }
263
+ );
264
+ }
265
+ const answer = parseJsonAnswer(text, "Static-host build", url, { aftermath: SENT_AFTERMATH });
266
+ const parsed = answer !== null && typeof answer === "object" && !Array.isArray(answer) ? answer : {};
267
+ const live = pickUrl(parsed);
268
+ if (live === void 0) throw unexpectedAnswerError("Static-host build", text, url, { aftermath: SENT_AFTERMATH });
269
+ return {
270
+ url: live,
271
+ canonical: pickCanonical(parsed),
272
+ envInjected: envDocuments > 0,
273
+ envDocuments,
274
+ envSkipped,
275
+ routing,
276
+ ...routingSuspect ? {
277
+ routingSuspect: true,
278
+ routingSuspectPages: servedPaths.map((p) => p.replace(/^\.?\//, "")).filter((p) => /\.html?$/i.test(p) && p.toLowerCase() !== "index.html")
279
+ } : {},
280
+ ...hasServer ? { serverBundle: serverRendered ? "uploaded" : "omitted" } : {},
281
+ ...hidden.length > 0 ? { hiddenUnserved: hidden } : {},
282
+ ...links.length > 0 ? { skippedLinks: links } : {},
283
+ raw: text
284
+ };
285
+ }
286
+ var StaticHostNotFoundError = class extends Error {
287
+ constructor(host, names, outcome = "Nothing was published.") {
288
+ super(
289
+ `No static host named "${host}" exists on the target` + (names === void 0 ? "" : names.length === 0 ? " \u2014 it has none yet" : ` \u2014 its hosts are ${names.map((n) => `"${n}"`).join(", ")}`) + `. Only \`default\` is created on first publish: drop \`--static-host\` to publish to it, or name a host that exists (created in the Xano dashboard's static hosting). ${outcome}`
290
+ );
291
+ this.host = host;
292
+ this.names = names;
293
+ }
294
+ host;
295
+ names;
296
+ name = "StaticHostNotFoundError";
297
+ exitCode = 8;
298
+ };
299
+ var STATIC_READ_TIMEOUT_MS = 2e4;
300
+ async function readStaticHostRows(req) {
301
+ const rows = [];
302
+ const root = `${req.baseUrl.replace(/\/$/, "")}/api:meta/workspace/${req.workspaceId}/static_host`;
303
+ for (let page = 1; page <= 10; page++) {
304
+ const res = await fetchOrExplain(
305
+ `${root}?page=${page}`,
306
+ {
307
+ headers: { Authorization: `Bearer ${req.accessToken}` },
308
+ signal: AbortSignal.timeout(STATIC_READ_TIMEOUT_MS)
309
+ },
310
+ "Reading the static hosts",
311
+ STATIC_READ_TIMEOUT_MS
312
+ );
313
+ const text = await res.text();
314
+ if (!res.ok) throw new Error(httpFailure("Reading the static hosts", res, text));
315
+ const parsed = parseJsonAnswer(text, "Reading the static hosts", root) ?? {};
316
+ if (!Array.isArray(parsed.items)) throw new Error("Reading the static hosts: the answer carried no list.");
317
+ for (const item of parsed.items) {
318
+ if (item !== null && typeof item === "object") rows.push(item);
319
+ }
320
+ if (typeof parsed.nextPage !== "number") break;
321
+ }
322
+ return rows;
323
+ }
324
+ async function listStaticHostNames(req) {
325
+ const rows = await readStaticHostRows(req);
326
+ return rows.map((r) => r.name).filter((n) => typeof n === "string" && n !== "");
327
+ }
328
+ async function listServingStaticHosts(req) {
329
+ const serving = [];
330
+ for (const row of await readStaticHostRows(req)) {
331
+ const host = typeof row.name === "string" ? row.name : "";
332
+ for (const env of [row.dev, row.prod]) {
333
+ if (env === null || typeof env !== "object") continue;
334
+ const url = pickUrl(env);
335
+ if (url !== void 0 && !serving.some((s) => s.url === url)) serving.push({ host, url });
336
+ }
337
+ }
338
+ return serving;
339
+ }
340
+ export {
341
+ StaticDirError,
342
+ StaticHostNotFoundError,
343
+ assertStaticDir,
344
+ deployStaticHost,
345
+ detectRouting,
346
+ findSeedLeaks,
347
+ listServingStaticHosts,
348
+ listStaticHostNames,
349
+ multipageOnlyForErrorPage,
350
+ tarGz2 as tarGz
351
+ };
352
+ //# sourceMappingURL=static-host-B2Y6AG3W.js.map