@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,457 @@
1
+ import {
2
+ resolveAuthRef
3
+ } from "./chunk-ZDPP6RKB.js";
4
+ import {
5
+ obj
6
+ } from "./chunk-K5BBGTYZ.js";
7
+ import {
8
+ assertOneOf,
9
+ leanInput
10
+ } from "./chunk-XVBGLISP.js";
11
+ import {
12
+ assertStoredName,
13
+ buildMiddlewareBlock,
14
+ encodeHistory
15
+ } from "./chunk-5V5XU32D.js";
16
+ import {
17
+ encodeTags,
18
+ registerKind,
19
+ resolveMockKeys
20
+ } from "./chunk-4POWHT2K.js";
21
+ import {
22
+ emitDiagnostic
23
+ } from "./chunk-2EZ3ZJZZ.js";
24
+ import {
25
+ lockKey
26
+ } from "./chunk-6MR5TI5V.js";
27
+ import {
28
+ rawResponseItems
29
+ } from "./chunk-AKNCFVKZ.js";
30
+ import {
31
+ encodeStack
32
+ } from "./chunk-YU4HSQW7.js";
33
+ import {
34
+ encodeInput
35
+ } from "./chunk-N5GKCWE5.js";
36
+ import {
37
+ deriveGuid,
38
+ deriveQueryGuid,
39
+ queryGroupComponent,
40
+ resolveRef
41
+ } from "./chunk-NZOWWHU5.js";
42
+ import {
43
+ getLockedCanonical
44
+ } from "./chunk-4BW2SG2N.js";
45
+ import {
46
+ describeEntry
47
+ } from "./chunk-CIMQZRRE.js";
48
+
49
+ // src/responses/response.ts
50
+ function warnUnboundReturn(kind, name, stack, response) {
51
+ if (response !== void 0) return;
52
+ if (!Array.isArray(stack) || !stack.some((statement) => statement?.name === "mvp:return")) return;
53
+ emitDiagnostic({
54
+ severity: "warning",
55
+ code: "response.unbound-return",
56
+ message: `${kind} "${name}" ends with s.return(...) but has no \`response\` field. The value DOES come back at runtime \u2014 a top-level s.return short-circuits the stack and carries its own value out \u2014 but the stored response envelope is empty, so the shape is invisible to InferResponse, to a typed frontend, and to codegen. Declare it too: \`response: <value>\` (e.g. \`response: ref("...")\`). Where both exist, whichever executes wins \u2014 an early s.return that fires beats the declared response.`
57
+ });
58
+ }
59
+ function isValue(x) {
60
+ return x !== void 0 && x !== null && typeof x.tag === "string" && "value" in x && "filters" in x;
61
+ }
62
+ function encodeResponse(response) {
63
+ if (response === void 0 || response === null) {
64
+ return [];
65
+ }
66
+ if (typeof response !== "object" && typeof response !== "function") {
67
+ throw new Error(
68
+ `response must be a value (\`ref("x")\`, \`c.int(5)\`, \u2026) or a { key: value } record \u2014 got ${describeEntry(response)}.`
69
+ );
70
+ }
71
+ const carried = rawResponseItems(response);
72
+ if (carried !== void 0) return carried;
73
+ if (isValue(response)) {
74
+ return [
75
+ { filters: response.filters, name: "", tag: response.tag, value: response.value, _xsid: "", disabled: false }
76
+ ];
77
+ }
78
+ return Object.entries(response).map(([name, member]) => {
79
+ if (member === void 0) {
80
+ throw new Error(
81
+ `\`response.${name}\` is undefined \u2014 a response key takes a value (\`ref("x")\`, \`c.*\`) or a { key: value } record. Check the expression that produced it, or drop the key.`
82
+ );
83
+ }
84
+ const value = isValue(member) ? member : obj(member);
85
+ return { filters: value.filters, name, tag: value.tag, value: value.value, _xsid: "", disabled: false };
86
+ });
87
+ }
88
+
89
+ // src/kinds/path-params.ts
90
+ var PARAM_MARKER = /\{([^/{}]+)\}/g;
91
+ var NON_SEGMENT_TYPES = /* @__PURE__ */ new Set(["obj", "json", "blob", "blob_img", "blob_video", "blob_audio", "vector"]);
92
+ function isSegmentType(type) {
93
+ return !NON_SEGMENT_TYPES.has(type) && !type.startsWith("geo_");
94
+ }
95
+ function parsePathParams(context, path) {
96
+ const params = [];
97
+ const cleaned = path.replace(/^\/+/, "");
98
+ let residue = "";
99
+ let cursor = 0;
100
+ for (const match of cleaned.matchAll(PARAM_MARKER)) {
101
+ residue += cleaned.slice(cursor, match.index);
102
+ cursor = match.index + match[0].length;
103
+ const name = match[1];
104
+ if (params.includes(name)) {
105
+ throw new Error(
106
+ `${context}: the path param \`${name}\` appears twice. Each {param} must be unique within one path \u2014 two segments cannot bind the same input.`
107
+ );
108
+ }
109
+ params.push(name);
110
+ }
111
+ residue += cleaned.slice(cursor);
112
+ if (residue.includes("{") || residue.includes("}")) {
113
+ throw new Error(
114
+ `${context}: "${path}" has an unmatched brace. A path param is written \`{name}\`, where the name holds no "/", "{" or "}" \u2014 it may sit anywhere in the path ("blog/{slug}", "blog/post-{slug}"), and each name must have an input of the same name to bind to.`
115
+ );
116
+ }
117
+ return params;
118
+ }
119
+ function assertPathParamInputs(context, params, inputs) {
120
+ for (const name of params) {
121
+ const descriptor = inputs?.[name];
122
+ if (!descriptor) {
123
+ throw new Error(
124
+ `${context}: the path declares {${name}} but there is no \`${name}\` input to bind it to, so the segment would be an inert part of the route string. Add it: input: { ${name}: input.text() }.`
125
+ );
126
+ }
127
+ if (descriptor.options?.array === true) {
128
+ throw new Error(
129
+ `${context}: the path param \`${name}\` cannot be a list \u2014 one path segment holds one value. Use a scalar input, or take the list as a query-string/body param under a different name.`
130
+ );
131
+ }
132
+ const type = descriptor.type;
133
+ if (!isSegmentType(type)) {
134
+ const article = /^[aeiou]/i.test(type) ? "an" : "a";
135
+ throw new Error(
136
+ `${context}: the path param \`${name}\` cannot be ${article} \`${type}\` \u2014 a path segment is a single string, so structured, binary, and multi-valued types have no URL form. Use a scalar input (text/int/uuid/\u2026), or move this value to a query-string or body param.`
137
+ );
138
+ }
139
+ }
140
+ }
141
+ function unboundPathParams(path, storedInput) {
142
+ let params;
143
+ try {
144
+ params = parsePathParams("path", path);
145
+ } catch {
146
+ return [];
147
+ }
148
+ const bound = new Set(
149
+ (Array.isArray(storedInput) ? storedInput : []).map(
150
+ (entry) => entry !== null && typeof entry === "object" ? entry.name : void 0
151
+ )
152
+ );
153
+ return params.filter((param) => !bound.has(param));
154
+ }
155
+ var DOT_SEGMENT = /^(\.|%2e){1,2}$/i;
156
+ var CHANNEL_VALUE = /^[A-Za-z0-9_-]+$/;
157
+ function fillPathParams(context, accessor, path, params, encode = false) {
158
+ const declared = parsePathParams(context, path);
159
+ const given = params ?? {};
160
+ for (const key of Object.keys(given)) {
161
+ if (!declared.includes(key)) {
162
+ throw new Error(
163
+ `${context}: ${accessor} was given \`${key}\`, which is not a {param} segment of the path. ` + (declared.length ? `Expected: ${declared.map((p) => `\`${p}\``).join(", ")}.` : `This path is static \u2014 call ${accessor} with no arguments.`)
164
+ );
165
+ }
166
+ }
167
+ return path.replace(PARAM_MARKER, (_all, key, at) => {
168
+ const value = given[key];
169
+ if (value === void 0 || value === null || value === "") {
170
+ throw new Error(
171
+ `${context}: ${accessor} needs a value for the path param \`${key}\` \u2014 pass { ${declared.map((p) => `${p}: \u2026 `).join(", ")}}.`
172
+ );
173
+ }
174
+ if (typeof value === "number" && !Number.isFinite(value)) {
175
+ throw new Error(
176
+ `${context}: the path param \`${key}\` is ${value} \u2014 not a finite value to put in a path.`
177
+ );
178
+ }
179
+ const text = String(value);
180
+ if (text.includes("/")) {
181
+ throw new Error(
182
+ `${context}: the path param \`${key}\` cannot contain "/" (got ${JSON.stringify(text)}) \u2014 it would fabricate a path segment and address a different route.`
183
+ );
184
+ }
185
+ if (!encode) {
186
+ if (!CHANNEL_VALUE.test(text)) {
187
+ throw new Error(
188
+ `${context}: the path param \`${key}\` is ${JSON.stringify(text)} \u2014 a channel segment holds only letters, digits, "_" and "-", so a join with it is refused.`
189
+ );
190
+ }
191
+ return text;
192
+ }
193
+ const segment = path.slice(path.lastIndexOf("/", at) + 1).split("/")[0].replace(PARAM_MARKER, (_m, k) => encodeURIComponent(String(given[k])));
194
+ if (DOT_SEGMENT.test(segment)) {
195
+ throw new Error(`${context}: the path param \`${key}\` makes the segment ${JSON.stringify(segment)} \u2014 URL parsers drop a "." or ".." segment, addressing another endpoint.`);
196
+ }
197
+ return encodeURIComponent(text);
198
+ });
199
+ }
200
+
201
+ // src/kinds/test.ts
202
+ function testIdSeed(ownerKind, ownerName, testName) {
203
+ return `${ownerKind}/${ownerName}:${testName}`;
204
+ }
205
+ function encodeTest(def, ownerKind, ownerName) {
206
+ if (!def.name) throw new Error("test: `name` is required.");
207
+ const owner = `${ownerKind} "${ownerName}" test "${String(def.name)}"`;
208
+ if (def.input !== void 0 && def.input !== null && (typeof def.input !== "object" || Array.isArray(def.input))) {
209
+ throw new Error(`${owner}: \`input\` must be a { name: value } record \u2014 got ${describeEntry(def.input)}.`);
210
+ }
211
+ if (def.expect !== void 0 && def.expect !== null && !Array.isArray(def.expect)) {
212
+ throw new Error(`${owner}: \`expect\` must be a list of expectations \u2014 got ${describeEntry(def.expect)}.`);
213
+ }
214
+ const datasource = def.datasource ?? "";
215
+ const xdo = {
216
+ datasource,
217
+ description: def.description ?? "",
218
+ expect: def.expect ?? [],
219
+ id: def.id ?? deriveGuid("test", testIdSeed(ownerKind, ownerName, def.name)),
220
+ input: Object.entries(def.input ?? {}).map(([name, v]) => leanInput(name, v)),
221
+ name: def.name,
222
+ token: def.token ?? ""
223
+ };
224
+ return xdo;
225
+ }
226
+ function encodeTests(defs, ownerKind, ownerName) {
227
+ if (defs === void 0 || defs === null) return [];
228
+ if (!Array.isArray(defs)) {
229
+ throw new Error(`${ownerKind} "${ownerName}": \`tests\` must be a list of tests \u2014 got ${describeEntry(defs)}.`);
230
+ }
231
+ defs.forEach((def, i) => {
232
+ if (typeof def !== "object" || def === null || Array.isArray(def)) {
233
+ throw new Error(`${ownerKind} "${ownerName}": \`tests[${i}]\` must be a test ({ name, input, expect }) \u2014 got ${describeEntry(def)}.`);
234
+ }
235
+ });
236
+ const seen = /* @__PURE__ */ new Set();
237
+ for (const def of defs) {
238
+ if (seen.has(def.name)) {
239
+ throw new Error(
240
+ `${ownerKind} "${ownerName}": two tests are named "${def.name}". A test name is how a statement's \`mock\` names the test it belongs to, so names must be unique within an object. Rename one of them.`
241
+ );
242
+ }
243
+ seen.add(def.name);
244
+ }
245
+ return defs.map((def) => encodeTest(def, ownerKind, ownerName));
246
+ }
247
+ function test(def) {
248
+ return def;
249
+ }
250
+
251
+ // src/kinds/query.ts
252
+ var HTTP_VERBS = ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"];
253
+ var QUERY_RESPONSE_TYPES = ["standard", "stream"];
254
+ function encodeExample(example) {
255
+ const out = {};
256
+ if (example?.input !== void 0 && example.input !== null) out.input = example.input;
257
+ if (example?.output !== void 0 && example.output !== null) out.output = example.output;
258
+ return out;
259
+ }
260
+ function defaultCache(override) {
261
+ return {
262
+ active: override !== void 0,
263
+ ttl: 3600,
264
+ input: true,
265
+ auth: true,
266
+ datasource: true,
267
+ ip: false,
268
+ headers: [],
269
+ env: [],
270
+ ...override
271
+ };
272
+ }
273
+ function resolveAuth(name, auth) {
274
+ return resolveAuthRef("query", name, auth);
275
+ }
276
+ function assertQueryPathParams(def) {
277
+ const context = `query "${def.name}"`;
278
+ assertStoredName(context, def.name, "route");
279
+ const params = parsePathParams(context, def.name);
280
+ assertPathParamInputs(context, params, def.input);
281
+ return params;
282
+ }
283
+ function assertQueryClosedSets(def) {
284
+ const context = `query "${def.name}"`;
285
+ assertOneOf(
286
+ context,
287
+ "verb",
288
+ def.verb,
289
+ HTTP_VERBS,
290
+ 'The engine does not reject an unrecognized verb \u2014 it stores NULL, and a null verb serves as GET. So the endpoint deploys clean, answers on the wrong method, and the method you meant 404s "Unable to locate request.", which reads as a routing or api-group problem.'
291
+ );
292
+ assertOneOf(
293
+ context,
294
+ "responseType",
295
+ def.responseType,
296
+ QUERY_RESPONSE_TYPES,
297
+ 'The engine does not reject an unrecognized response_type \u2014 it stores NULL, which falls back to "standard". So a misspelled stream deploys clean and then quietly buffers the whole response instead of streaming it.'
298
+ );
299
+ }
300
+ function encodeQuery(def) {
301
+ if (!def.name) throw new Error("query: `name` is required.");
302
+ if (!def.verb) throw new Error("query: `verb` is required.");
303
+ assertQueryPathParams(def);
304
+ assertQueryClosedSets(def);
305
+ warnUnboundReturn("query", def.name, def.stack, def.response);
306
+ const xdo = {
307
+ name: def.name,
308
+ description: def.description ?? "",
309
+ docs: def.docs ?? "",
310
+ api_enabled: def.apiEnabled ?? true,
311
+ auth: resolveAuth(def.name, def.auth),
312
+ response_type: def.responseType ?? "standard",
313
+ verb: def.verb,
314
+ disabled: def.disabled ?? false,
315
+ // The engine binds a query to its api group by the group's guid (export
316
+ // maps id→guid, import remaps guid→local id). Deriving that guid from the
317
+ // group's name is stateless and stable across syncs. A numeric `apiGroupId`
318
+ // is an explicit escape hatch and wins when given.
319
+ app: {
320
+ id: def.apiGroupId ?? (def.apiGroup !== void 0 ? resolveRef("app", def.apiGroup) : 0)
321
+ },
322
+ cache: defaultCache(def.cache),
323
+ output: [],
324
+ middleware: buildMiddlewareBlock(def.middleware),
325
+ tag: encodeTags(def.tags),
326
+ history: encodeHistory("query", def.history),
327
+ input: Object.entries(def.input ?? {}).map(([name, d]) => encodeInput(name, d)),
328
+ result: encodeResponse(def.response),
329
+ run: encodeStack("query", def.name, def.stack),
330
+ test: encodeTests(def.tests, "query", def.name),
331
+ example: encodeExample(def.example),
332
+ market_item: { id: 0, version: 0, guid: "" }
333
+ };
334
+ resolveMockKeys(xdo.run, xdo.test, "query", def.name);
335
+ return xdo;
336
+ }
337
+ function queryGuid(def) {
338
+ if (def.guid) return def.guid;
339
+ return deriveQueryGuid(queryGroupComponent(def), def.verb, def.name);
340
+ }
341
+ var queryKind = {
342
+ name: "query",
343
+ payloadKey: "query",
344
+ encode: encodeQuery,
345
+ guidOf: (def) => queryGuid(def)
346
+ };
347
+ registerKind(queryKind);
348
+ function resolveCanonical(def, override) {
349
+ if (override) return override;
350
+ const group = def.apiGroup;
351
+ if (group && typeof group === "object" && typeof group.canonical === "string" && group.canonical !== "") {
352
+ return group.canonical;
353
+ }
354
+ const groupName = typeof group === "string" ? group : group?.name;
355
+ if (groupName) {
356
+ const locked = getLockedCanonical(lockKey("app", groupName));
357
+ if (locked) return locked;
358
+ }
359
+ throw new Error(
360
+ `query "${def.name}": getPath() cannot resolve the api group's canonical URL token. Set an explicit \`apiGroup({ canonical })\`, or run \`xanosdk export <entry>\` once (it mints a unique canonical and freezes it in xano.lock) and seed that lock before importing defs \u2014 the CLI does this automatically, and build scripts call seedLockOverrides(readLockFile(path)) first. As a last resort pass one directly: getPath({ canonical: "..." }). (Minting here is unsafe \u2014 canonicals must be unique per instance across all workspaces, so they are only generated at locked export.)`
361
+ );
362
+ }
363
+ function pathSegment(name) {
364
+ return name.replace(/^\/+/, "");
365
+ }
366
+ function queryImpl(def) {
367
+ if (typeof def.name !== "string") {
368
+ throw new Error(`query: \`name\` must be the route path as a string \u2014 got ${describeEntry(def.name)}.`);
369
+ }
370
+ const params = assertQueryPathParams(def);
371
+ assertQueryClosedSets(def);
372
+ const context = `query "${def.name}"`;
373
+ const path = pathSegment(def.name);
374
+ const getPath = (opts) => `/api:${resolveCanonical(def, opts?.canonical)}/${params.length ? fillPathParams(context, "getPath()", path, opts?.params, true) : path}`;
375
+ const search = (values) => toSearchParams(
376
+ // A non-record goes through whole, so it is refused as the free function refuses it.
377
+ params.length && isPlainRecord(values) ? Object.fromEntries(Object.entries(values).filter(([key]) => !params.includes(key))) : values
378
+ );
379
+ return { ...def, getPath, toSearchParams: search };
380
+ }
381
+ function isPlainRecord(value) {
382
+ if (typeof value !== "object" || value === null) return false;
383
+ const proto = Object.getPrototypeOf(value);
384
+ return proto === Object.prototype || proto === null;
385
+ }
386
+ function toSearchParams(input) {
387
+ if (!isPlainRecord(input)) {
388
+ throw new Error(
389
+ `toSearchParams() takes the query input as a { name: value } record \u2014 got ${describeEntry(input)}.`
390
+ );
391
+ }
392
+ let params = new URLSearchParams();
393
+ const ancestors = [];
394
+ const fail = (path, why) => {
395
+ throw new TypeError(`toSearchParams: param "${path}" ${why}`);
396
+ };
397
+ const isScalar = (v) => typeof v === "string" || typeof v === "number" || typeof v === "boolean";
398
+ const encode = (path, value) => {
399
+ if (value == null) return false;
400
+ if (isScalar(value)) {
401
+ if (typeof value === "number" && !Number.isFinite(value)) fail(path, `is ${value} \u2014 not a finite value`);
402
+ params.append(path, String(value));
403
+ return true;
404
+ }
405
+ const proto = typeof value === "object" ? Object.getPrototypeOf(value) : 0;
406
+ if (path && !Array.isArray(value) && proto !== Object.prototype && proto !== null) {
407
+ fail(path, `is not a scalar, list or plain object (got ${describeEntry(value)})`);
408
+ }
409
+ if (ancestors.includes(value)) fail(path, "contains itself \u2014 a cycle has no query-string encoding");
410
+ ancestors.push(value);
411
+ let sent = false;
412
+ if (Array.isArray(value) && value.some(Array.isArray)) {
413
+ const outer = params;
414
+ params = new URLSearchParams();
415
+ value.forEach((item, index) => encode(`${path}[${index}]`, item));
416
+ params = outer;
417
+ params.append(path, JSON.stringify(value));
418
+ sent = true;
419
+ } else if (Array.isArray(value)) {
420
+ const plain = value.every(isScalar);
421
+ value.forEach((item, index) => {
422
+ if (!encode(`${path}[${plain ? "" : index}]`, item)) {
423
+ fail(`${path}[${index}]`, `is ${item == null ? item : "empty"}: a list item that sends nothing would move every later one up. Remove it, or give it a value`);
424
+ }
425
+ sent = true;
426
+ });
427
+ } else {
428
+ for (const [key, member] of Object.entries(value)) {
429
+ if (key === "" || /[[\]]/.test(key)) fail(path ? `${path}[${key}]` : key, "is empty or holds `[`/`]` \u2014 a query string cannot carry that name");
430
+ if (encode(path ? `${path}[${key}]` : key, member)) sent = true;
431
+ }
432
+ }
433
+ ancestors.pop();
434
+ return sent;
435
+ };
436
+ encode("", input);
437
+ return params;
438
+ }
439
+ var query = Object.assign(queryImpl, { toSearchParams });
440
+
441
+ export {
442
+ warnUnboundReturn,
443
+ encodeResponse,
444
+ parsePathParams,
445
+ assertPathParamInputs,
446
+ unboundPathParams,
447
+ fillPathParams,
448
+ encodeTests,
449
+ test,
450
+ defaultCache,
451
+ encodeQuery,
452
+ queryKind,
453
+ pathSegment,
454
+ toSearchParams,
455
+ query
456
+ };
457
+ //# sourceMappingURL=chunk-6IUMKYWI.js.map
@@ -0,0 +1,65 @@
1
+ // src/validate/runtime.ts
2
+ async function smokeRunFunctions(client, workspaceId, names, inputs = {}, withInputs = /* @__PURE__ */ new Set()) {
3
+ const out = [];
4
+ for (const name of names) {
5
+ const res = await client.runFunction(workspaceId, name, inputs[name] ?? {});
6
+ const ran = res.ok && !threw(res.body);
7
+ const needsInputs = !ran && withInputs.has(name) && isInputError(res.body);
8
+ out.push({ name, ran, status: res.status, detail: res.body, ...needsInputs ? { needsInputs: true } : {} });
9
+ }
10
+ return out;
11
+ }
12
+ function functionsWithInputs(bundle) {
13
+ const fns = field(field(bundle, "payload"), "function");
14
+ const out = /* @__PURE__ */ new Set();
15
+ if (!Array.isArray(fns)) return out;
16
+ for (const fn of fns) {
17
+ const name = field(fn, "name");
18
+ const input = field(fn, "input");
19
+ if (typeof name === "string" && Array.isArray(input) && input.length > 0) out.add(name);
20
+ }
21
+ return out;
22
+ }
23
+ var INPUT_ERROR_CODE = "ERROR_CODE_INPUT_ERROR";
24
+ function isInputError(body) {
25
+ const exception = field(field(body, "result"), "exception");
26
+ const codes = [field(body, "code"), field(exception, "error_type"), field(exception, "code")];
27
+ if (codes.includes(INPUT_ERROR_CODE)) return true;
28
+ return /\bMissing param\b/.test(runtimeErrorMessage(body) ?? "");
29
+ }
30
+ function threw(body) {
31
+ const result = body?.result;
32
+ const status = result?.status;
33
+ return typeof status === "string" && status !== "ok";
34
+ }
35
+ function runtimeErrorMessage(detail) {
36
+ const result = field(detail, "result");
37
+ const message = field(field(result, "exception"), "message") ?? field(detail, "message");
38
+ if (typeof message === "string" && message !== "") return message;
39
+ const thrown = field(field(result, "result"), "payload");
40
+ if (thrown === void 0) return void 0;
41
+ const store = field(result, "value_store") ?? field(detail, "value_store");
42
+ const value = typeof thrown === "string" && store !== null && typeof store === "object" && Object.hasOwn(store, thrown) ? store[thrown] : thrown;
43
+ if (value === void 0 || value === null || value === "") return void 0;
44
+ return typeof value === "string" ? value : JSON.stringify(value);
45
+ }
46
+ function describeRuntimeFailure(entry) {
47
+ const why = runtimeErrorMessage(entry.detail);
48
+ const requestFailed = entry.status < 200 || entry.status >= 300;
49
+ if (requestFailed) return `HTTP ${entry.status}${why !== void 0 ? `: ${why}` : ""}`;
50
+ if (why === void 0) return "threw";
51
+ const type = field(field(field(entry.detail, "result"), "exception"), "error_type");
52
+ const masked = type === "ERROR_CODE_BAD_REQUEST" && why === "Bad Request" || type === "ERROR_CODE_UNAUTHORIZED" && why === "Unauthorized";
53
+ return masked ? `threw ${why} \u2014 the run does not return the text of this error type` : `threw: ${why}`;
54
+ }
55
+ function field(v, key) {
56
+ return v !== null && typeof v === "object" ? v[key] : void 0;
57
+ }
58
+
59
+ export {
60
+ smokeRunFunctions,
61
+ functionsWithInputs,
62
+ runtimeErrorMessage,
63
+ describeRuntimeFailure
64
+ };
65
+ //# sourceMappingURL=chunk-6KEB3C3U.js.map