@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,396 @@
1
+ /**
2
+ * `@xano/sdk/plugin` — the contract a **toolchain module** compiles against.
3
+ *
4
+ * ── The two kinds of module ─────────────────────────────────────────────────
5
+ *
6
+ * A WORKSPACE module (`@xano-sdk/auth`, `@xano-sdk/chatbot`) adds tables and
7
+ * endpoints to the deployed bundle. You install it, register it in your
8
+ * `xano/index.ts`, and what it contributes ships to your instance.
9
+ *
10
+ * A TOOLCHAIN module extends the **CLI** instead. It adds nothing to the
11
+ * workspace — registering it into `xano/index.ts` would be meaningless, because
12
+ * there is nothing to register. What it does is participate in the commands:
13
+ * declare questions, contribute to files the project owns, and run when a
14
+ * bundle is compiled or a workspace is checked.
15
+ *
16
+ * The shape this contract was built for is a module that renders the compiled
17
+ * workspace to a committed tree on every deploy, so a backend change can be
18
+ * reviewed as what the engine will actually run.
19
+ *
20
+ * ── Contributions apply to a PROJECT, not to a scaffold ─────────────────────
21
+ *
22
+ * A module is configured whenever its project is RECONCILED, and `xanosdk init`
23
+ * is only the first of those moments. Installing the module into a project that
24
+ * already exists, re-answering its questions later, and removing it again all
25
+ * run the same pass: read what the project declares, ask what is unanswered,
26
+ * and bring the files it owns into line.
27
+ *
28
+ * So {@link ToolchainPlugin.contributes} is a pure function from answers to
29
+ * contributions, with no knowledge of which command is running and no access to
30
+ * the filesystem. Only that makes the reconcile idempotent — the correct state
31
+ * is a function of the project's dependencies and its stored answers, so it can
32
+ * be rebuilt from scratch at any moment, however the module arrived.
33
+ *
34
+ * ── Why this is a types-only entry ──────────────────────────────────────────
35
+ *
36
+ * Nothing here has a runtime representation. A module does:
37
+ *
38
+ * import type { ToolchainPlugin, BundleContext } from "@xano/sdk/plugin";
39
+ *
40
+ * and the import erases at compile time, so the module's published bundle does
41
+ * not carry the SDK and does not resolve it at runtime. That matters because
42
+ * the SDK is the thing IMPORTING the plugin — a plugin that pulled the SDK back
43
+ * in would load a second copy of the compiler into the process that is already
44
+ * running one.
45
+ *
46
+ * The plugin's own `package.json` still declares `@xano/sdk` as a **peer**,
47
+ * because the hooks are handed real compiled data and the module is only
48
+ * correct against the SDK versions whose shapes it understands.
49
+ *
50
+ * ── How the SDK finds a plugin ──────────────────────────────────────────────
51
+ *
52
+ * From the module's own `package.json`:
53
+ *
54
+ * "xanosdk": { "kind": "toolchain", "plugin": "./dist/plugin.js" }
55
+ *
56
+ * `kind` routes it away from the workspace loader; `plugin` names the file
57
+ * whose default export is a {@link ToolchainPlugin}.
58
+ *
59
+ * Per-project configuration lives in the CONSUMING project's `package.json`,
60
+ * under the same `"xanosdk"` key, namespaced by package name:
61
+ *
62
+ * "xanosdk": { "@acme/reviewable": { "enabled": true, "dir": "rendered" } }
63
+ *
64
+ * That block is written from the answers to {@link ToolchainPlugin.questions}
65
+ * and read back on every later run, which is what makes a choice made once
66
+ * survive every run after it. It is also the only memory a module has, which is
67
+ * why {@link ToolchainPlugin.answersFromConfig} exists: without the inverse
68
+ * mapping, re-asking the questions would offer shipped defaults and silently
69
+ * overwrite what the user chose.
70
+ */
71
+ /**
72
+ * One question a module contributes to the questionnaire.
73
+ *
74
+ * DECLARATIVE DATA, never a prompt callback, and the two reasons are both
75
+ * hard. A callback would let a module hang a command on a TTY read in CI, where
76
+ * there is no one to answer it — the SDK could not even impose a timeout,
77
+ * because it cannot tell a slow prompt from a slow computation. And
78
+ * `init --web` renders the questionnaire as a browser form, which can display
79
+ * a list of choices but cannot run a module's callback at all.
80
+ *
81
+ * Declaring the question as data means the SDK owns every way of answering it:
82
+ * interactively, from a derived flag, from a form field, or from the answer the
83
+ * project already stored.
84
+ */
85
+ interface PluginQuestion {
86
+ /** Stable key this question's answer is stored under. */
87
+ readonly id: string;
88
+ /** The prompt shown to a human. One line, no trailing punctuation. */
89
+ readonly label: string;
90
+ /** What kind of answer this takes. */
91
+ readonly type: "boolean" | "string" | "choice";
92
+ /** The allowed values, for `type: "choice"`. Ignored otherwise. */
93
+ readonly choices?: readonly string[];
94
+ /**
95
+ * The answer used when the question is not asked and the project has stored
96
+ * nothing for it — a non-interactive run with no flag, or a `when` that
97
+ * excluded it.
98
+ *
99
+ * A project's own stored answer OUTRANKS this: on a re-ask, the stored value
100
+ * is both the prompt's default and the non-interactive fallback, so a
101
+ * repeated run never quietly resets a choice back to what you shipped.
102
+ */
103
+ readonly default: string | boolean;
104
+ /**
105
+ * The long-flag name that answers this question without a prompt, without
106
+ * its leading dashes.
107
+ *
108
+ * Derived from `id` when omitted. Declare it when the derived name would read
109
+ * badly — `--reviewable-dir` rather than `--dir` — or would collide with a
110
+ * flag the CLI already owns. A collision is REFUSED, with a message naming
111
+ * your module and the command that hit it, so it fails loudly rather than
112
+ * binding your question to a flag the CLI consumed first.
113
+ *
114
+ * A `string` or `choice` question is answered with `--flag=value`, not
115
+ * `--flag value`. The CLI cannot know a contributed flag takes a value — your
116
+ * module is not loaded when the arguments are parsed — so it never consumes
117
+ * the following token, and the spaced form would leave that value where a
118
+ * positional argument is read from. A `boolean` question takes the bare
119
+ * `--flag`, or `--no-flag` to decline one whose default is true.
120
+ */
121
+ readonly flag?: string;
122
+ /**
123
+ * Whether to ask at all, given the answers so far.
124
+ *
125
+ * A question excluded this way is not asked AND no answer is recorded for it
126
+ * — an unasked question has no answer, and recording one would make a later
127
+ * `deploy` act on a choice nobody made. On a re-ask that also means a stale
128
+ * key a previous run stored for it is DELETED from the project's config, and
129
+ * the deletion is reported.
130
+ */
131
+ readonly when?: (answers: PluginAnswers) => boolean;
132
+ }
133
+ /** The answers to a module's own questions, keyed by {@link PluginQuestion.id}. */
134
+ type PluginAnswers = Readonly<Record<string, string | boolean>>;
135
+ /**
136
+ * What a module contributes to a project — computed from its answers, applied
137
+ * whenever the project is reconciled.
138
+ *
139
+ * ADDITIVE AGAINST NAMED SLOTS THE SDK OWNS — a module returns lines and a
140
+ * config object, and the SDK composes them into the files it maintains. A
141
+ * module never hands back a whole file, never rewrites a script string, and
142
+ * never touches the disk itself.
143
+ *
144
+ * That constraint is what makes two installed modules safe together: neither
145
+ * can clobber the other's contribution, because neither is writing the file.
146
+ * Each module's lines land in a marked block naming it, so re-answering its
147
+ * questions rewrites exactly that span and nothing around it — which is what
148
+ * lets a module be re-configured or removed in a project that already exists.
149
+ *
150
+ * It also moves the failure earlier: a malformed contribution is refused where
151
+ * it was written rather than producing a broken file the user meets later.
152
+ *
153
+ * PURE. Called with nothing but the answers, possibly several times in one run,
154
+ * and expected to return the same contributions for the same answers.
155
+ *
156
+ * An EMPTY contribution is meaningful: returning no `gitattributes` lines
157
+ * REMOVES the module's block rather than leaving an empty one, which is how a
158
+ * module whose answers turned it off stops applying rules the user declined.
159
+ */
160
+ interface ProjectContributions {
161
+ /**
162
+ * Lines the module adds to the project's `.gitattributes`, in its own marked
163
+ * block. Each entry is one line, without a trailing newline.
164
+ *
165
+ * A rule for `*`, or one that sets `text`/`eol`, is REFUSED: both apply to
166
+ * paths the module does not own — `*` to every path in the repository — and
167
+ * could renormalize line endings repo-wide on the next checkout. Contribute
168
+ * display rules (`linguist-*`, `diff`) for the paths you own instead.
169
+ */
170
+ readonly gitattributes?: readonly string[];
171
+ /**
172
+ * The module's own block in the project's `package.json` `"xanosdk"` object,
173
+ * stored under the module's package name.
174
+ *
175
+ * This is the value {@link BundleContext.config} hands back on every later
176
+ * run, so it is the module's whole memory of what was decided — and the value
177
+ * {@link ToolchainPlugin.answersFromConfig} is asked to read back.
178
+ */
179
+ readonly config?: Readonly<Record<string, unknown>>;
180
+ }
181
+ /**
182
+ * What a hook reports back.
183
+ *
184
+ * `failed` is distinct from a thrown error, and the distinction is the whole
185
+ * reason the field exists. A THROWN error is a broken plugin: it could not do
186
+ * its job, and on a normal run the command carries on without it. `failed` is a
187
+ * working plugin reporting that **the thing it checked does not pass** — a
188
+ * committed tree that no longer matches the source, say.
189
+ *
190
+ * Collapsing the two would break both directions. A bug in a plugin would fail
191
+ * a deploy that is fine, and a real staleness finding would be swallowed as a
192
+ * plugin bug. `preflight` maps `failed` onto the same non-zero exit code it
193
+ * uses for its own findings, which is what lets CI keep gating on it.
194
+ */
195
+ interface HookResult {
196
+ /** One line for the command's normal output. Omitted when there is nothing to say. */
197
+ readonly message?: string;
198
+ /** Per-item notes shown under the message. */
199
+ readonly warnings?: readonly string[];
200
+ /**
201
+ * The check this hook performed did not pass.
202
+ *
203
+ * Not "the hook errored" — see above. Set this only when the plugin ran
204
+ * correctly and the answer is no.
205
+ */
206
+ readonly failed?: boolean;
207
+ }
208
+ /**
209
+ * A compiled workspace bundle's payload — the object every kind's encoded
210
+ * records hang off, keyed by payload key (`table`, `query`, `app`, …).
211
+ *
212
+ * Structural rather than imported from the compiler on purpose: this entry has
213
+ * to stay types-only and self-contained, and a plugin that wants the precise
214
+ * per-kind shapes can depend on `@xano/sdk/internal` for them.
215
+ */
216
+ type BundlePayload = Readonly<Record<string, unknown>>;
217
+ /** Which command a hook is firing under. */
218
+ type HookCommand = "export" | "deploy";
219
+ /**
220
+ * What `onBundle` is handed.
221
+ *
222
+ * Fired on `export` and `deploy`, AFTER the bundle compiles and BEFORE the
223
+ * network call. That placement is deliberate: the tree describes the SOURCE, so
224
+ * writing it before the deploy means a failed deploy still leaves a correct
225
+ * tree, and a tree never claims something shipped that did not.
226
+ */
227
+ interface BundleContext {
228
+ /**
229
+ * The compiled payload.
230
+ *
231
+ * Workspace env VALUES are blanked before you see them — `payload.env`
232
+ * entries keep their `name` and carry `value: ""`. A hook's output is
233
+ * typically committed, and the real values come from a gitignored file, so
234
+ * handing them to a renderer would be handing them to git. The declarations
235
+ * survive because they are structure; the secrets do not.
236
+ */
237
+ readonly bundle: {
238
+ readonly payload: BundlePayload;
239
+ };
240
+ /**
241
+ * The entry file the bundle was compiled from — **absent** on the
242
+ * `--bundle <path>` branch, where the input is already-serialized text with
243
+ * no entry and no registry behind it.
244
+ *
245
+ * Optional rather than a made-up path because a plugin may legitimately want
246
+ * to decline that branch: a tree rendered from a bundle the project did not
247
+ * compile describes something other than the source beside it.
248
+ */
249
+ readonly entry?: string;
250
+ /** The project root every relative path resolves against. */
251
+ readonly cwd: string;
252
+ /** Which command fired this. */
253
+ readonly command: HookCommand;
254
+ /**
255
+ * The run is a verification, not a write: `--frozen-lock`, `export --check`,
256
+ * or `deploy --to … --dry-run`.
257
+ *
258
+ * A plugin under `frozen` must COMPARE and report, never write. It is also
259
+ * the mode in which a plugin failing to load is fatal rather than a warning
260
+ * — a guard that silently stops running is worse than one that fails loudly.
261
+ */
262
+ readonly frozen: boolean;
263
+ /** The running `@xano/sdk` version, for a plugin's own peer-range check. */
264
+ readonly sdkVersion: string;
265
+ /** This module's block from the project's `package.json` `"xanosdk"` object. */
266
+ readonly config: Readonly<Record<string, unknown>>;
267
+ }
268
+ /**
269
+ * The engine's own rendering of the deployed workspace, or why it could not be
270
+ * had.
271
+ *
272
+ * Tagged because the difference is load-bearing: a missing text route must
273
+ * report as UNAVAILABLE, never as drift. Treating a failed fetch as an empty
274
+ * rendering would diff every object in the workspace against nothing and
275
+ * report a catastrophic mismatch that is really a network error.
276
+ */
277
+ type EngineRendering = {
278
+ readonly kind: "text";
279
+ readonly text: string;
280
+ } | {
281
+ readonly kind: "error";
282
+ readonly why: string;
283
+ };
284
+ /**
285
+ * What `onPreflight` is handed.
286
+ *
287
+ * The SDK owns the FETCH and nothing else. `exportMultidoc` is a generic engine
288
+ * route — the same class of thing as an API query parameter — and it is not
289
+ * reachable from any published subpath, so a plugin could not call it itself.
290
+ *
291
+ * Every derivation past that point belongs to the plugin: it has both payloads,
292
+ * so it renders both local sides and computes its own exclusions. No rendering
293
+ * knowledge stays behind in the SDK.
294
+ */
295
+ interface PreflightContext {
296
+ /** The engine's rendering of what it actually has, or why it is unavailable. */
297
+ readonly engineRendering: EngineRendering;
298
+ /**
299
+ * The payload as the ENGINE exported it after import — so both sides of a
300
+ * comparison built from this share one JSON, and any difference is the
301
+ * plugin's own rendering.
302
+ *
303
+ * Env values are blanked here too, for the reason given on
304
+ * {@link BundleContext.bundle}. Both payloads are blanked identically, so a
305
+ * comparison between them is unaffected; a comparison against
306
+ * {@link PreflightContext.engineRendering} should exclude env values, which
307
+ * the engine has no reason to blank.
308
+ */
309
+ readonly exportedPayload: BundlePayload;
310
+ /**
311
+ * The compiled payload with its guids translated to the engine's re-minted
312
+ * ones — the artifact side of the comparison, showing only what the engine
313
+ * normalizes on import.
314
+ */
315
+ readonly remappedPayload: BundlePayload;
316
+ /** The command was run with `--verbose`; report at length. */
317
+ readonly verbose: boolean;
318
+ /** The project root every relative path resolves against. */
319
+ readonly cwd: string;
320
+ /** The running `@xano/sdk` version, for a plugin's own peer-range check. */
321
+ readonly sdkVersion: string;
322
+ /** This module's block from the project's `package.json` `"xanosdk"` object. */
323
+ readonly config: Readonly<Record<string, unknown>>;
324
+ }
325
+ /**
326
+ * What a toolchain module's `xanosdk.plugin` file default-exports.
327
+ *
328
+ * Five hooks, and deliberately no more. This contract was designed from one
329
+ * example, and a contract designed from one example generalizes badly — so it
330
+ * covers exactly what that first module needs and stops. The SECOND toolchain
331
+ * module is the one that should generalize it, with the real second set of
332
+ * requirements in hand.
333
+ *
334
+ * Every hook is optional: a module that only adds a `.gitattributes` line
335
+ * declares {@link ToolchainPlugin.contributes} alone.
336
+ *
337
+ * ── Contract skew is refused, never absorbed ────────────────────────────────
338
+ *
339
+ * Because every hook is optional, a module written against an older shape of
340
+ * this contract would load, register, and contribute NOTHING — silently, since
341
+ * "a module with no contributions" is a legitimate outcome. So the SDK refuses
342
+ * a plugin whose shape says it was built against a contract that no longer
343
+ * exists, by name, with the upgrade to make:
344
+ *
345
+ * - a `files` hook and no `contributes` — `files` was renamed once the hook
346
+ * stopped running only at scaffold time. Rename it.
347
+ * - a `ciSteps` entry in what `contributes` returns — the slot is gone. A
348
+ * module's own check already rides on `xanosdk export --frozen-lock` through
349
+ * {@link ToolchainPlugin.onBundle} with {@link BundleContext.frozen} set, so
350
+ * it needed no workflow step of its own. Drop it.
351
+ */
352
+ interface ToolchainPlugin {
353
+ /**
354
+ * Repeated from the manifest so the module and its `package.json` must
355
+ * agree. A plugin whose default export does not say `"toolchain"` is refused
356
+ * — the mismatch means one of the two is stale, and guessing which would run
357
+ * code the manifest did not describe.
358
+ */
359
+ readonly kind: "toolchain";
360
+ /** Questions added to the questionnaire, asked after the SDK's own. */
361
+ readonly questions?: readonly PluginQuestion[];
362
+ /**
363
+ * What this module contributes to the project, given its answers.
364
+ *
365
+ * Runs whenever the project is reconciled — at `init`, when the module is
366
+ * installed into an existing project, and when its questions are re-asked —
367
+ * so it must be pure and must not look at the filesystem.
368
+ */
369
+ readonly contributes?: (answers: PluginAnswers) => ProjectContributions;
370
+ /**
371
+ * Read this module's stored config block back into the answers that produced
372
+ * it — the inverse of {@link ToolchainPlugin.contributes}.
373
+ *
374
+ * `contributes` is a MODULE-PRIVATE transform: only you know that
375
+ * `{ enabled: true, dir: "xanoscript" }` came from
376
+ * `{ xanoscript: true, dir: "xanoscript" }`. The SDK will not guess, and
377
+ * matching question ids to same-named config keys would be a convention this
378
+ * contract does not state.
379
+ *
380
+ * Without it, a re-ask offers your shipped defaults — and non-interactively
381
+ * ANSWERS with them — silently resetting a directory the user chose. So
382
+ * declare it whenever your config keys are not your question ids.
383
+ *
384
+ * Optional. A module that omits it gets shipped defaults on a re-ask, and the
385
+ * user is TOLD that is what happened rather than left to discover it. Keys
386
+ * that match no declared question are ignored, and a throw is reported and
387
+ * degrades to the defaults — this hook can never take a command down.
388
+ */
389
+ readonly answersFromConfig?: (config: Readonly<Record<string, unknown>>) => PluginAnswers;
390
+ /** Runs on `export` and `deploy`, after compile and before the network call. */
391
+ readonly onBundle?: (ctx: BundleContext) => Promise<HookResult>;
392
+ /** Runs on `preflight`, contributing a comparison to the report. */
393
+ readonly onPreflight?: (ctx: PreflightContext) => Promise<HookResult>;
394
+ }
395
+
396
+ export type { BundleContext, BundlePayload, EngineRendering, HookCommand, HookResult, PluginAnswers, PluginQuestion, PreflightContext, ProjectContributions, ToolchainPlugin };
package/dist/plugin.js ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=plugin.js.map