@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.
- package/CHANGELOG.md +788 -0
- package/LICENSE +21 -0
- package/README.md +541 -0
- package/dist/.build-fingerprint +1 -0
- package/dist/agent-file-refresh-ZEMK33AX.js +38 -0
- package/dist/answer-shape-K67TAAPY.js +33 -0
- package/dist/backend-dir-2U53CIAL.js +39 -0
- package/dist/backend-slot-7QXW2QYC.js +28 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +255 -0
- package/dist/branch-NCRNWQBQ.js +61 -0
- package/dist/branch-commands-ACIRCEQJ.js +79 -0
- package/dist/bundle.d.ts +223 -0
- package/dist/bundle.js +153 -0
- package/dist/capture-WAXPD7DR.js +41 -0
- package/dist/chunk-27GWNP2I.js +23 -0
- package/dist/chunk-2CMJZDCL.js +177 -0
- package/dist/chunk-2EZ3ZJZZ.js +302 -0
- package/dist/chunk-2GNFDZA2.js +390 -0
- package/dist/chunk-2MNLRIOX.js +11 -0
- package/dist/chunk-2TFRR6JV.js +104 -0
- package/dist/chunk-2ZUEE4EK.js +408 -0
- package/dist/chunk-36JUQZVQ.js +22 -0
- package/dist/chunk-3DRXWLJ5.js +83 -0
- package/dist/chunk-3JDU4VRL.js +137 -0
- package/dist/chunk-3KZCLN4Z.js +241 -0
- package/dist/chunk-3LDULPRE.js +168 -0
- package/dist/chunk-3M4LFYNQ.js +111 -0
- package/dist/chunk-3XI5CTUE.js +22 -0
- package/dist/chunk-3YW23UFH.js +50 -0
- package/dist/chunk-45UIT5T2.js +862 -0
- package/dist/chunk-4BW2SG2N.js +46 -0
- package/dist/chunk-4KHEMC32.js +79 -0
- package/dist/chunk-4POWHT2K.js +321 -0
- package/dist/chunk-4Q2GN7NW.js +192 -0
- package/dist/chunk-5A2PLKZB.js +70 -0
- package/dist/chunk-5FBYXK5P.js +159 -0
- package/dist/chunk-5HVXPTU4.js +323 -0
- package/dist/chunk-5QU2P5CA.js +304 -0
- package/dist/chunk-5V5XU32D.js +191 -0
- package/dist/chunk-5ZSO4T2G.js +10 -0
- package/dist/chunk-622HUCZT.js +10 -0
- package/dist/chunk-65HWOMGV.js +177 -0
- package/dist/chunk-6ELFRN3P.js +365 -0
- package/dist/chunk-6HO3NCSJ.js +1055 -0
- package/dist/chunk-6IUMKYWI.js +457 -0
- package/dist/chunk-6KEB3C3U.js +65 -0
- package/dist/chunk-6MR5TI5V.js +987 -0
- package/dist/chunk-6NNTNXN7.js +157 -0
- package/dist/chunk-6PBR37LN.js +97 -0
- package/dist/chunk-6QXLMMT3.js +155 -0
- package/dist/chunk-6ZGJCBZS.js +224 -0
- package/dist/chunk-73IVBKMA.js +250 -0
- package/dist/chunk-7G3CTU7I.js +286 -0
- package/dist/chunk-A3UDOZB6.js +222 -0
- package/dist/chunk-A6E77GDW.js +85 -0
- package/dist/chunk-AHJWCYQO.js +660 -0
- package/dist/chunk-AKNCFVKZ.js +36 -0
- package/dist/chunk-AM4FKL4J.js +237 -0
- package/dist/chunk-AN6BL47T.js +26 -0
- package/dist/chunk-AOSYVMUS.js +147 -0
- package/dist/chunk-APWXY5SL.js +182 -0
- package/dist/chunk-AWEIIR2U.js +218 -0
- package/dist/chunk-AWQ7BQTQ.js +73 -0
- package/dist/chunk-BAUZOWGX.js +393 -0
- package/dist/chunk-BHACRS6R.js +940 -0
- package/dist/chunk-BWPNT55T.js +680 -0
- package/dist/chunk-C6RIMRU4.js +187 -0
- package/dist/chunk-CGVQZXYG.js +263 -0
- package/dist/chunk-CIMQZRRE.js +162 -0
- package/dist/chunk-CJHQKJU4.js +113 -0
- package/dist/chunk-CTMO46PK.js +1897 -0
- package/dist/chunk-D53J55C5.js +106 -0
- package/dist/chunk-D7VGG3WS.js +90 -0
- package/dist/chunk-DAD3ONIS.js +245 -0
- package/dist/chunk-DGWHAVRG.js +162 -0
- package/dist/chunk-DX4QR4B2.js +483 -0
- package/dist/chunk-EHP3WPEG.js +21 -0
- package/dist/chunk-ELP2HMXC.js +432 -0
- package/dist/chunk-ERVIASGL.js +21 -0
- package/dist/chunk-ET4Y4XCB.js +865 -0
- package/dist/chunk-ETO6LGLD.js +4750 -0
- package/dist/chunk-EUUUMY7J.js +24 -0
- package/dist/chunk-FQJ2TTHP.js +218 -0
- package/dist/chunk-FQOF7E2E.js +133 -0
- package/dist/chunk-FWD7AL6N.js +21 -0
- package/dist/chunk-FXFV3KU6.js +138 -0
- package/dist/chunk-FXRQOWTE.js +171 -0
- package/dist/chunk-G554NZNI.js +210 -0
- package/dist/chunk-GSGDWJB5.js +13 -0
- package/dist/chunk-H2V3N23D.js +66 -0
- package/dist/chunk-H5C7MBCR.js +159 -0
- package/dist/chunk-HHN734BU.js +371 -0
- package/dist/chunk-HRVBLCVJ.js +243 -0
- package/dist/chunk-HVRUQXGD.js +1264 -0
- package/dist/chunk-I4F5TCJH.js +130 -0
- package/dist/chunk-IDOTCMDV.js +57 -0
- package/dist/chunk-IGOLHKWF.js +427 -0
- package/dist/chunk-JGE7CAWB.js +148 -0
- package/dist/chunk-JTUKLCXS.js +92 -0
- package/dist/chunk-JZGVVJSI.js +66 -0
- package/dist/chunk-K4WX6UUU.js +923 -0
- package/dist/chunk-K5BBGTYZ.js +217 -0
- package/dist/chunk-K6RXBGUB.js +427 -0
- package/dist/chunk-KTSDSD36.js +165 -0
- package/dist/chunk-L5JYN3NM.js +1038 -0
- package/dist/chunk-LIEOKXKD.js +354 -0
- package/dist/chunk-LLNZGEFK.js +51 -0
- package/dist/chunk-LPECSJ2J.js +55 -0
- package/dist/chunk-LQCMKAJ7.js +413 -0
- package/dist/chunk-LRN4ZJCQ.js +1145 -0
- package/dist/chunk-MJ4ZVHKN.js +17 -0
- package/dist/chunk-MXHSQOC4.js +3061 -0
- package/dist/chunk-N5GKCWE5.js +367 -0
- package/dist/chunk-NA3PXMEF.js +10 -0
- package/dist/chunk-NAQDMEHV.js +76 -0
- package/dist/chunk-NWKXM5RD.js +109 -0
- package/dist/chunk-NZOWWHU5.js +196 -0
- package/dist/chunk-OHX6MIUZ.js +184 -0
- package/dist/chunk-OOXWYAA4.js +15 -0
- package/dist/chunk-OPHB5ORL.js +1990 -0
- package/dist/chunk-OXA6PSZT.js +1725 -0
- package/dist/chunk-P2HAGF6H.js +73 -0
- package/dist/chunk-PTHVMXZI.js +3036 -0
- package/dist/chunk-PZ5AY32C.js +10 -0
- package/dist/chunk-Q325JKYB.js +189 -0
- package/dist/chunk-Q7DGTQ5G.js +255 -0
- package/dist/chunk-QCNYHBL7.js +601 -0
- package/dist/chunk-QO6BVGS5.js +145 -0
- package/dist/chunk-QXTKSOFI.js +76 -0
- package/dist/chunk-ROY4YAEQ.js +66 -0
- package/dist/chunk-RTJRZFFY.js +447 -0
- package/dist/chunk-SAVJUS2X.js +128 -0
- package/dist/chunk-SFLHVCKX.js +173 -0
- package/dist/chunk-STSFNCY4.js +127 -0
- package/dist/chunk-SWBF2LTK.js +170 -0
- package/dist/chunk-T5KELPAR.js +109 -0
- package/dist/chunk-TFFGOFVZ.js +1481 -0
- package/dist/chunk-TLHIFK4M.js +256 -0
- package/dist/chunk-TLQE7ZN3.js +156 -0
- package/dist/chunk-TPHWJ7UG.js +1981 -0
- package/dist/chunk-TRJCALW3.js +291 -0
- package/dist/chunk-TTEIYD5P.js +133 -0
- package/dist/chunk-U64O2MXY.js +407 -0
- package/dist/chunk-UCQ2VUTG.js +630 -0
- package/dist/chunk-UTI5G6OJ.js +44 -0
- package/dist/chunk-UVHDMMIP.js +188 -0
- package/dist/chunk-UZ6QQWJT.js +120 -0
- package/dist/chunk-VAX3UZOY.js +686 -0
- package/dist/chunk-W3HBUKFO.js +57 -0
- package/dist/chunk-WKQLGKCL.js +2823 -0
- package/dist/chunk-WQFNASK4.js +560 -0
- package/dist/chunk-WRBKLYSJ.js +224 -0
- package/dist/chunk-WTPZRR4I.js +17 -0
- package/dist/chunk-WZDJ2LLX.js +2385 -0
- package/dist/chunk-X2NL4KUO.js +14 -0
- package/dist/chunk-X4DVXBFY.js +38 -0
- package/dist/chunk-X677DMZM.js +7050 -0
- package/dist/chunk-XBKMWY7F.js +612 -0
- package/dist/chunk-XNCP4KYO.js +78 -0
- package/dist/chunk-XVBGLISP.js +35 -0
- package/dist/chunk-XW6KISBB.js +1192 -0
- package/dist/chunk-YGZHHAAB.js +8156 -0
- package/dist/chunk-YHEFQUQB.js +186 -0
- package/dist/chunk-YLDALTWZ.js +653 -0
- package/dist/chunk-YU4HSQW7.js +229 -0
- package/dist/chunk-ZDPP6RKB.js +27 -0
- package/dist/chunk-ZFDZKNGG.js +194 -0
- package/dist/chunk-ZIY7RNUT.js +49 -0
- package/dist/chunk-ZYJP6BOO.js +30 -0
- package/dist/cli.d.ts +1111 -0
- package/dist/cli.js +165 -0
- package/dist/codegen-command-VR2GWR6C.js +173 -0
- package/dist/codegen.d.ts +115 -0
- package/dist/codegen.js +19 -0
- package/dist/commands-GJMJ4XYZ.js +76 -0
- package/dist/completion-ZQLO6PB6.js +738 -0
- package/dist/config-MBYGCAFK.js +136 -0
- package/dist/deploy-command-JVZPWHMK.js +180 -0
- package/dist/deploy-source-3W45CXMP.js +81 -0
- package/dist/dev-env-sync-HN44K4D5.js +188 -0
- package/dist/diagnostics-UEAAHWVF.js +30 -0
- package/dist/display-name-hint-ABBPVQIR.js +46 -0
- package/dist/emit-CyhBDxli.d.ts +7007 -0
- package/dist/env-example-refresh-ET5HMMDW.js +126 -0
- package/dist/env-pull-command-TNMNB3CV.js +323 -0
- package/dist/env-target-O4HRKTGZ.js +40 -0
- package/dist/env-var-command-ZIRDCAZA.js +427 -0
- package/dist/ephemeral-P7F3PMAD.js +54 -0
- package/dist/ephemeral-command-CLJJKOFT.js +592 -0
- package/dist/ephemeral-state-PYCBSOGX.js +61 -0
- package/dist/file-lock-PT74GWYW.js +10 -0
- package/dist/generate-command-AYEOLA26.js +510 -0
- package/dist/gitignore-3SJ3WNRG.js +51 -0
- package/dist/guards-4EBNCZDC.js +162 -0
- package/dist/hosted-file-PSHJB3HX.js +28 -0
- package/dist/impersonate-command-5JAS3WSV.js +152 -0
- package/dist/import-EQSFU6JC.js +19 -0
- package/dist/index.d.ts +5470 -0
- package/dist/index.js +371 -0
- package/dist/init-command-X2FR4UAK.js +125 -0
- package/dist/init-modules-RY7UHAOL.js +50 -0
- package/dist/init-web-M4YZSZK6.js +42 -0
- package/dist/internal.d.ts +179 -0
- package/dist/internal.js +2634 -0
- package/dist/io-RC56QSN5.js +26 -0
- package/dist/keep-data-merge-7MPLVAVI.js +1119 -0
- package/dist/lambda-config-reconcile-OUZ4OYAB.js +116 -0
- package/dist/landed-753YLJ5H.js +40 -0
- package/dist/landing-record-SU52SKXU.js +61 -0
- package/dist/live-diff-YONW2VI3.js +65 -0
- package/dist/local-engine-choice-CH5X3W7E.js +79 -0
- package/dist/local-engine-command-Z3OL7VOD.js +766 -0
- package/dist/local-engine-config-5U3SC434.js +39 -0
- package/dist/local-engine-deploy-PCQ4SNPB.js +39 -0
- package/dist/local-engine-process-EHTE5LLU.js +63 -0
- package/dist/local-engine-state-A4FTRFAF.js +32 -0
- package/dist/local-engine-update-check-6L645VBL.js +162 -0
- package/dist/lock-MRRHW5GS.js +87 -0
- package/dist/lock-commands-2QG25HL7.js +963 -0
- package/dist/login-command-QPYRWOXZ.js +538 -0
- package/dist/logout-command-WOIQLDP6.js +56 -0
- package/dist/loop-ALIZLOSX.js +191 -0
- package/dist/marketplace-command-K5YL42NO.js +977 -0
- package/dist/marketplace-resolve-LY32JES5.js +40 -0
- package/dist/meta-client-YXGPW53C.js +244 -0
- package/dist/module-manifest-JFGHU2TC.js +38 -0
- package/dist/near-key.d.ts +13 -0
- package/dist/near-key.js +8 -0
- package/dist/node.d.ts +95 -0
- package/dist/node.js +969 -0
- package/dist/operation-outcome-TZSESNC7.js +51 -0
- package/dist/output-target-AL3I44GG.js +47 -0
- package/dist/package-manager-PRAHUSCN.js +34 -0
- package/dist/plan-disclosure-6G4MLZKD.js +114 -0
- package/dist/plugin-contributions-WRNY5ABG.js +28 -0
- package/dist/plugin-prompt-4VA3B4FF.js +20 -0
- package/dist/plugin-questions-JTSYA74Q.js +24 -0
- package/dist/plugin.d.ts +396 -0
- package/dist/plugin.js +1 -0
- package/dist/preflight-command-2T5Z36MI.js +321 -0
- package/dist/profile-command-AH3PIM4X.js +800 -0
- package/dist/profile-pointer-GRWJU3YD.js +31 -0
- package/dist/profile-select-74TRDEPD.js +23 -0
- package/dist/project-dependency-KSH63ODT.js +35 -0
- package/dist/project-sdk-REPPOIBD.js +24 -0
- package/dist/promote-command-PCWT5N6S.js +140 -0
- package/dist/prompt-II3F3LND.js +27 -0
- package/dist/publish-command-TTDUUJI5.js +414 -0
- package/dist/pull-command-VBO7C4S3.js +161 -0
- package/dist/pull-superseded-GJWLG7XO.js +20 -0
- package/dist/release-command-N4ZPKMHR.js +146 -0
- package/dist/release-ns-command-3KFDMZ6G.js +1745 -0
- package/dist/response-HlXahv4K.d.ts +925 -0
- package/dist/retry-command-AS5EVREX.js +34 -0
- package/dist/routes-manifest-SNWUVBT6.js +43 -0
- package/dist/runtime-XETHVF33.js +14 -0
- package/dist/scaffold.d.ts +1911 -0
- package/dist/scaffold.js +107 -0
- package/dist/secrets-file-LVZD6IIM.js +56 -0
- package/dist/secrets-fill-command-TTCPSVXN.js +218 -0
- package/dist/seed-VU7C3QYS.js +46 -0
- package/dist/sent-writes-N7X4OVXT.js +22 -0
- package/dist/source-resolve-S2XA3XZF.js +83 -0
- package/dist/static-host-B2Y6AG3W.js +352 -0
- package/dist/status-command-RUDXTF7I.js +554 -0
- package/dist/store-6VNCD4D7.js +20 -0
- package/dist/store-ARM6VMO5.js +98 -0
- package/dist/store-DuYfzKlW.d.ts +3144 -0
- package/dist/suggest-6FOOYKHG.js +12 -0
- package/dist/sveltekit.d.ts +154 -0
- package/dist/sveltekit.js +109 -0
- package/dist/sync-contributions-UCEROO26.js +415 -0
- package/dist/table-ENAVMITR.js +42 -0
- package/dist/tables-command-GUPXXSB5.js +156 -0
- package/dist/tenant-IIHPOHGP.js +42 -0
- package/dist/tenant-command-D5HGI2X4.js +965 -0
- package/dist/test-command-TIKZMDPZ.js +476 -0
- package/dist/tests-BGGIOK3L.js +26 -0
- package/dist/token-NICJUTMT.js +72 -0
- package/dist/toolchain-hooks-GHKLUJOH.js +96 -0
- package/dist/toolchain-modules-5EAZUONB.js +24 -0
- package/dist/tracked-backend-EIBUMDZA.js +80 -0
- package/dist/update-check-2W2NLDTC.js +136 -0
- package/dist/upgrade-command-QHNFWM7O.js +531 -0
- package/dist/verify-rollout-DRCK5TDD.js +61 -0
- package/dist/whoami-command-STGINTXH.js +51 -0
- package/dist/workspace-2CLHU2LK.js +93 -0
- package/dist/workspace-binding-56PIIPCP.js +54 -0
- package/dist/workspace-command-JEXQETJD.js +535 -0
- package/dist/workspace-env-F2RFMSC5.js +70 -0
- package/dist/workspace-export-OJSH2HIW.js +21 -0
- package/dist/writable-VA7OISSK.js +25 -0
- package/dist/xano-ICFUSPFR.js +42 -0
- package/dist/xanosdk-import-GN42TO2B.js +56 -0
- package/dist/xanosdk-project-S6DXJONQ.js +41 -0
- package/dist/xdo-CxDr2Q1C.d.ts +1371 -0
- package/guides/README.md +33 -0
- package/guides/authoring.md +921 -0
- package/guides/cli.md +401 -0
- package/guides/codegen.md +177 -0
- package/guides/codes.md +404 -0
- package/guides/coverage.md +74 -0
- package/guides/deploying.md +1525 -0
- package/guides/environment.md +400 -0
- package/guides/marketplace.md +415 -0
- package/guides/module-contract.md +558 -0
- package/guides/object-kinds.md +433 -0
- package/guides/project-structure.md +43 -0
- package/guides/scaffold.md +351 -0
- package/guides/typed-frontend.md +242 -0
- package/llms/client.md +63 -0
- package/llms/errors.md +56 -0
- package/llms/fields.md +176 -0
- package/llms/filters.md +183 -0
- package/llms/kinds-agent-mcp.md +30 -0
- package/llms/kinds-core.md +100 -0
- package/llms/kinds-knowledge.md +20 -0
- package/llms/kinds-realtime.md +76 -0
- package/llms/lambda.md +94 -0
- package/llms/legacy.md +44 -0
- package/llms/lock.md +40 -0
- package/llms/object-kinds.md +34 -0
- package/llms/statements-calls.md +62 -0
- package/llms/statements-catalog.md +320 -0
- package/llms/statements-data.md +66 -0
- package/llms/statements-runtime.md +68 -0
- package/llms/tests.md +59 -0
- package/llms/toolchain.md +16 -0
- package/llms/triggers.md +36 -0
- package/llms/values.md +29 -0
- package/llms-full.txt +2085 -0
- package/llms.txt +493 -0
- package/manifest.json +11224 -0
- package/package.json +162 -0
- package/types/lambda-globals.d.ts +129 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import {
|
|
2
|
+
hasString,
|
|
3
|
+
listAnswer
|
|
4
|
+
} from "./chunk-6PBR37LN.js";
|
|
5
|
+
import {
|
|
6
|
+
READ_AFTERMATH,
|
|
7
|
+
explainFetchFailure,
|
|
8
|
+
httpFailure,
|
|
9
|
+
readBodyText
|
|
10
|
+
} from "./chunk-YLDALTWZ.js";
|
|
11
|
+
import {
|
|
12
|
+
detail,
|
|
13
|
+
info,
|
|
14
|
+
warn
|
|
15
|
+
} from "./chunk-PTHVMXZI.js";
|
|
16
|
+
|
|
17
|
+
// src/deploy/microservice-status.ts
|
|
18
|
+
var TIMEOUT_MS = 3e4;
|
|
19
|
+
var MICROSERVICE_READ = "Microservice status read";
|
|
20
|
+
var POLL_INTERVAL_MS = 2e3;
|
|
21
|
+
var WAIT_DEADLINE_MS = 3e5;
|
|
22
|
+
function asString(v) {
|
|
23
|
+
return typeof v === "string" && v !== "" ? v : void 0;
|
|
24
|
+
}
|
|
25
|
+
function asNumber(v) {
|
|
26
|
+
return typeof v === "number" ? v : void 0;
|
|
27
|
+
}
|
|
28
|
+
function classify(row) {
|
|
29
|
+
const status = row.status ?? "";
|
|
30
|
+
if (status === "disabled") return "disabled";
|
|
31
|
+
if ((row.tenantDeploy ?? "auto") === "manual") return "manual";
|
|
32
|
+
switch (status) {
|
|
33
|
+
case "ok": {
|
|
34
|
+
return "ready";
|
|
35
|
+
}
|
|
36
|
+
case "error": {
|
|
37
|
+
return "failed";
|
|
38
|
+
}
|
|
39
|
+
// `pending` is the state a freshly imported row sits in until the engine
|
|
40
|
+
// picks it up; both it and `deploying` mean "not serving yet, keep looking".
|
|
41
|
+
case "pending":
|
|
42
|
+
case "deploying": {
|
|
43
|
+
return "inFlight";
|
|
44
|
+
}
|
|
45
|
+
default: {
|
|
46
|
+
return "unknown";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function isAwaited(m) {
|
|
51
|
+
return m.disposition === "inFlight";
|
|
52
|
+
}
|
|
53
|
+
function project(row) {
|
|
54
|
+
const tenantDeploy = asString(row.tenant_deploy) ?? "auto";
|
|
55
|
+
const status = asString(row.status) ?? "";
|
|
56
|
+
return {
|
|
57
|
+
id: asNumber(row.id),
|
|
58
|
+
name: asString(row.name) ?? "",
|
|
59
|
+
kind: asString(row.kind),
|
|
60
|
+
tenantDeploy,
|
|
61
|
+
status,
|
|
62
|
+
statusDetail: asString(row.status_detail),
|
|
63
|
+
deployedAt: asString(row.deployed_at),
|
|
64
|
+
disposition: classify({ status, tenantDeploy })
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
var isMicroserviceRow = (row) => hasString(row, "name");
|
|
68
|
+
async function listMicroservices(auth, target, opts = {}) {
|
|
69
|
+
const fetchFn = opts.fetchFn ?? fetch;
|
|
70
|
+
const root = `${target.baseUrl.replace(/\/$/, "")}/api:meta/workspace/${target.workspaceId}/microservice`;
|
|
71
|
+
const out = [];
|
|
72
|
+
let page = 1;
|
|
73
|
+
for (; ; ) {
|
|
74
|
+
const url = `${root}?page=${page}`;
|
|
75
|
+
let res;
|
|
76
|
+
try {
|
|
77
|
+
res = await fetchFn(url, {
|
|
78
|
+
method: "GET",
|
|
79
|
+
headers: { accept: "application/json", Authorization: `Bearer ${auth.access_token}` },
|
|
80
|
+
signal: AbortSignal.timeout(TIMEOUT_MS)
|
|
81
|
+
});
|
|
82
|
+
} catch (err) {
|
|
83
|
+
throw explainFetchFailure(err, { url, what: MICROSERVICE_READ, timeoutMs: TIMEOUT_MS, aftermath: READ_AFTERMATH });
|
|
84
|
+
}
|
|
85
|
+
const text = await readBodyText(res, MICROSERVICE_READ, { url, timeoutMs: TIMEOUT_MS });
|
|
86
|
+
if (!res.ok) {
|
|
87
|
+
throw new Error(httpFailure(MICROSERVICE_READ, res, text));
|
|
88
|
+
}
|
|
89
|
+
const { rows, envelope } = listAnswer(text, MICROSERVICE_READ, url, isMicroserviceRow);
|
|
90
|
+
out.push(...rows.map((r) => project(r)));
|
|
91
|
+
const next = envelope?.nextPage;
|
|
92
|
+
if (typeof next !== "number" || next <= page) return out;
|
|
93
|
+
page = next;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async function waitForMicroservices(auth, target, opts = {}) {
|
|
97
|
+
const now = opts.now ?? Date.now;
|
|
98
|
+
const sleep = opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
99
|
+
const totalDeadlineMs = opts.totalDeadlineMs ?? WAIT_DEADLINE_MS;
|
|
100
|
+
const pollIntervalMs = opts.pollIntervalMs ?? POLL_INTERVAL_MS;
|
|
101
|
+
const start = now();
|
|
102
|
+
let microservices = [];
|
|
103
|
+
let sawAnyRead = false;
|
|
104
|
+
for (; ; ) {
|
|
105
|
+
try {
|
|
106
|
+
microservices = await listMicroservices(auth, target, opts);
|
|
107
|
+
sawAnyRead = true;
|
|
108
|
+
opts.onPoll?.(microservices);
|
|
109
|
+
if (!microservices.some((m) => isAwaited(m))) {
|
|
110
|
+
return { microservices, timedOut: false, hadFailure: microservices.some((m) => m.disposition === "failed") };
|
|
111
|
+
}
|
|
112
|
+
} catch (err) {
|
|
113
|
+
if (!sawAnyRead) throw err;
|
|
114
|
+
}
|
|
115
|
+
if (now() - start + pollIntervalMs > totalDeadlineMs) {
|
|
116
|
+
return {
|
|
117
|
+
microservices,
|
|
118
|
+
timedOut: true,
|
|
119
|
+
hadFailure: microservices.some((m) => m.disposition === "failed")
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
await sleep(pollIntervalMs);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// src/emit/microservice-view.ts
|
|
127
|
+
async function readMicroservices(auth, baseUrl, workspaceId = 1) {
|
|
128
|
+
try {
|
|
129
|
+
return await listMicroservices(auth, { baseUrl, workspaceId });
|
|
130
|
+
} catch (err) {
|
|
131
|
+
warn(`Could not read microservices: ${err instanceof Error ? err.message : String(err)}`, "microservice.status-unreadable");
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
var DISPOSITION_LABEL = {
|
|
136
|
+
ready: { icon: "\u2713", why: "ready" },
|
|
137
|
+
inFlight: { icon: "\u2026", why: "starting" },
|
|
138
|
+
failed: { icon: "\u2717", why: "failed" },
|
|
139
|
+
manual: { icon: "\u2013", why: "not started \u2014 set to deploy manually" },
|
|
140
|
+
disabled: { icon: "\u2013", why: "disabled" },
|
|
141
|
+
unknown: { icon: "\u2013", why: "unrecognized state" }
|
|
142
|
+
};
|
|
143
|
+
function microserviceLine(m) {
|
|
144
|
+
const { icon, why } = DISPOSITION_LABEL[m.disposition];
|
|
145
|
+
const useDetail = m.disposition !== "manual" && m.disposition !== "disabled";
|
|
146
|
+
const reason = (useDetail ? m.statusDetail : void 0) ?? why;
|
|
147
|
+
return `${icon} ${m.name} \u2014 ${m.disposition === "unknown" ? `${why} (${m.status})` : reason}`;
|
|
148
|
+
}
|
|
149
|
+
function readyRatio(microservices) {
|
|
150
|
+
return {
|
|
151
|
+
ready: microservices.filter((m) => m.disposition === "ready").length,
|
|
152
|
+
// Rows the engine was never going to start don't belong in a readiness ratio.
|
|
153
|
+
startable: microservices.filter((m) => m.disposition !== "manual" && m.disposition !== "disabled").length
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function printMicroserviceSection(microservices) {
|
|
157
|
+
if (microservices === null || microservices.length === 0) return;
|
|
158
|
+
const { ready, startable } = readyRatio(microservices);
|
|
159
|
+
info(startable === 0 ? "Microservices (none set to start):" : `Microservices (${ready}/${startable} ready):`);
|
|
160
|
+
for (const m of microservices) detail(microserviceLine(m));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export {
|
|
164
|
+
isAwaited,
|
|
165
|
+
waitForMicroservices,
|
|
166
|
+
readMicroservices,
|
|
167
|
+
microserviceLine,
|
|
168
|
+
readyRatio,
|
|
169
|
+
printMicroserviceSection
|
|
170
|
+
};
|
|
171
|
+
//# sourceMappingURL=chunk-FXRQOWTE.js.map
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import {
|
|
2
|
+
encodeInput,
|
|
3
|
+
f,
|
|
4
|
+
input
|
|
5
|
+
} from "./chunk-N5GKCWE5.js";
|
|
6
|
+
|
|
7
|
+
// src/kinds/trigger-inputs.ts
|
|
8
|
+
var ERROR_EVENT_DESCRIPTION = `Which event fired the trigger. "new" fires on first capture and on every snapshot re-capture for non-ignored signatures (rate-limited by the ~5min snapshot dedup window). "regression" fires when a previously-fixed signature re-occurs (the fix didn't hold, or the same bug regressed back). "fixed" fires when a user marks a signature as fixed.`;
|
|
9
|
+
function realtimeClientInput() {
|
|
10
|
+
return input.object(
|
|
11
|
+
{
|
|
12
|
+
extras: f.json(),
|
|
13
|
+
permissions: f.object({ dbo_id: f.int(), row_id: f.text() }, { required: true })
|
|
14
|
+
},
|
|
15
|
+
{ required: true }
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
function encodeAll(map) {
|
|
19
|
+
return Object.entries(map).map(([name, d]) => encodeInput(name, d));
|
|
20
|
+
}
|
|
21
|
+
var CATALOG = {
|
|
22
|
+
// Database trigger — new/old rows, action op, datasource label.
|
|
23
|
+
database: () => ({
|
|
24
|
+
new: input.json(),
|
|
25
|
+
old: input.json(),
|
|
26
|
+
action: input.enum(["insert", "update", "delete", "truncate"], { required: true }),
|
|
27
|
+
// NOTE (Xano quirk, mirror don't fix): the engine stores `datasource`
|
|
28
|
+
// as `text` but copy-pastes the `action` enum into its `values`. We mirror
|
|
29
|
+
// the stored shape exactly rather than "correcting" it.
|
|
30
|
+
datasource: input.text({ required: true, values: ["insert", "update", "delete", "truncate"] })
|
|
31
|
+
}),
|
|
32
|
+
// Toolset trigger — the connected toolset + its tools. This is the AGENT
|
|
33
|
+
// shape; an MCP server's trigger adds `prompts`/`resources`
|
|
34
|
+
// (`mcpServerPrimitives`).
|
|
35
|
+
toolset: () => ({
|
|
36
|
+
toolset: input.object(
|
|
37
|
+
{
|
|
38
|
+
id: f.int({ description: "The toolset ID" }),
|
|
39
|
+
name: f.text({ description: "The toolset name", methods: ["trim"] }),
|
|
40
|
+
instructions: f.text({ description: "The toolset instructions", methods: ["trim"] })
|
|
41
|
+
},
|
|
42
|
+
{ description: "The toolset being connected to" }
|
|
43
|
+
),
|
|
44
|
+
tools: input.list(
|
|
45
|
+
input.object({
|
|
46
|
+
id: f.int({ description: "The tool ID" }),
|
|
47
|
+
name: f.text({ description: "The tool name", methods: ["trim"] }),
|
|
48
|
+
instructions: f.text({ description: "The tool instructions", methods: ["trim"] })
|
|
49
|
+
}),
|
|
50
|
+
{ description: "The list of tools on the MCP Server" }
|
|
51
|
+
)
|
|
52
|
+
}),
|
|
53
|
+
// Workspace lifecycle trigger — branch action + the branches involved.
|
|
54
|
+
workspace: () => ({
|
|
55
|
+
to_branch: input.object({ id: f.int(), label: f.text({ methods: ["trim"] }) }),
|
|
56
|
+
from_branch: input.object({ id: f.int(), label: f.text({ methods: ["trim"] }) }),
|
|
57
|
+
action: input.enum(["branch_live", "branch_merge", "branch_new"], { required: true })
|
|
58
|
+
}),
|
|
59
|
+
// Realtime channel trigger — message/join action + channel/client/options/payload.
|
|
60
|
+
workspace_realtime_channel: () => ({
|
|
61
|
+
action: input.enum(["message", "join"], { required: true, default: "message" }),
|
|
62
|
+
channel: input.text({ required: true }),
|
|
63
|
+
client: input.object(
|
|
64
|
+
{
|
|
65
|
+
extras: f.json(),
|
|
66
|
+
permissions: f.object(
|
|
67
|
+
{ dbo_id: f.int(), row_id: f.text() },
|
|
68
|
+
{ required: true }
|
|
69
|
+
)
|
|
70
|
+
},
|
|
71
|
+
{ required: true }
|
|
72
|
+
),
|
|
73
|
+
options: input.object({ authenticated: f.bool(), channel: f.text() }),
|
|
74
|
+
payload: input.json({ required: true, nullable: true })
|
|
75
|
+
}),
|
|
76
|
+
// Realtime SERVER lifecycle trigger — connect/disconnect on a realtime server.
|
|
77
|
+
// Mirrors the engine's stored input array exactly: the action enum carries NO
|
|
78
|
+
// default (unlike the legacy channel trigger's `"message"`), and `client` is
|
|
79
|
+
// the same connecting-client object both realtime lifecycle types use.
|
|
80
|
+
realtime_server: () => ({
|
|
81
|
+
action: input.enum(["connect", "disconnect"], { required: true }),
|
|
82
|
+
realtime_server: input.text({ required: true }),
|
|
83
|
+
client: realtimeClientInput()
|
|
84
|
+
}),
|
|
85
|
+
// Realtime CHANNEL lifecycle trigger — join/leave/deliver on a channel. Same
|
|
86
|
+
// shape as the server type with the addressed channel path in place of the
|
|
87
|
+
// server name.
|
|
88
|
+
//
|
|
89
|
+
// The action enum carries all THREE actions the engine declares for this type,
|
|
90
|
+
// regardless of which ones a given trigger enables: the enum describes what
|
|
91
|
+
// `action` can hold at runtime, and the per-trigger selection lives in `meta`.
|
|
92
|
+
//
|
|
93
|
+
// `payload` IS declared, and it is what distinguishes this type from the server
|
|
94
|
+
// one above. It sits between `channel` and `client`, and it is the message body
|
|
95
|
+
// — optional (a join/leave carries none) and nullable, unlike the LEGACY
|
|
96
|
+
// channel trigger's required `payload`.
|
|
97
|
+
//
|
|
98
|
+
// A sweep of a current instance is unanimous: every channel trigger stores
|
|
99
|
+
// four entries in this order, and every realtime_server trigger stores three.
|
|
100
|
+
// Without this entry a pulled channel trigger would regenerate an input
|
|
101
|
+
// short, so `inp("payload")` would not resolve and re-deploying would drop an
|
|
102
|
+
// entry the engine supplies.
|
|
103
|
+
channel: () => ({
|
|
104
|
+
action: input.enum(["join", "leave", "deliver"], { required: true }),
|
|
105
|
+
channel: input.text({ required: true }),
|
|
106
|
+
payload: input.json({ nullable: true }),
|
|
107
|
+
client: realtimeClientInput()
|
|
108
|
+
}),
|
|
109
|
+
// Error trigger — the error signature schema (verbatim from the engine).
|
|
110
|
+
error: () => ({
|
|
111
|
+
event: input.enum(["new", "regression", "fixed"], { description: ERROR_EVENT_DESCRIPTION }),
|
|
112
|
+
id: input.int({
|
|
113
|
+
description: "The error signature row id. Use to build deep links into the error-logs UI."
|
|
114
|
+
}),
|
|
115
|
+
signature: input.text({ description: "Stable hash that identifies this error signature." }),
|
|
116
|
+
error: input.object(
|
|
117
|
+
{
|
|
118
|
+
code: f.text({ description: "Machine-readable error code." }),
|
|
119
|
+
message: f.text({ description: "Human-readable error message." })
|
|
120
|
+
},
|
|
121
|
+
{ description: "Error code and message captured from the failing run." }
|
|
122
|
+
),
|
|
123
|
+
caller: input.object(
|
|
124
|
+
{
|
|
125
|
+
type: f.text({
|
|
126
|
+
description: "Caller kind (api, function, task, middleware, trigger, unknown)."
|
|
127
|
+
}),
|
|
128
|
+
id: f.int({ description: "Caller object id." }),
|
|
129
|
+
name: f.text({ description: "Caller object name.", nullable: true })
|
|
130
|
+
},
|
|
131
|
+
{ description: "Where the error originated. Null on 'fixed' events.", nullable: true }
|
|
132
|
+
),
|
|
133
|
+
statement: input.object(
|
|
134
|
+
{
|
|
135
|
+
name: f.text({ description: "Statement name." }),
|
|
136
|
+
xsid: f.text({ description: "Statement xsid within the function stack." })
|
|
137
|
+
},
|
|
138
|
+
{ description: "Failing statement. Null on 'fixed' events.", nullable: true }
|
|
139
|
+
),
|
|
140
|
+
actor: input.object(
|
|
141
|
+
{
|
|
142
|
+
id: f.int({ description: "User id." }),
|
|
143
|
+
name: f.text({ description: "User name.", nullable: true })
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
description: "User who marked the error as fixed. Populated only for 'fixed' events.",
|
|
147
|
+
nullable: true
|
|
148
|
+
}
|
|
149
|
+
),
|
|
150
|
+
count: input.object(
|
|
151
|
+
{
|
|
152
|
+
total: f.int({ description: "Total occurrences since first seen." }),
|
|
153
|
+
last_hour: f.int({ description: "Occurrences in the last hour." })
|
|
154
|
+
},
|
|
155
|
+
{ description: "Occurrence counts for this signature." }
|
|
156
|
+
),
|
|
157
|
+
first_seen: input.text({ description: "ISO-8601 UTC timestamp of the first occurrence." }),
|
|
158
|
+
last_seen: input.text({ description: "ISO-8601 UTC timestamp of the most recent occurrence." }),
|
|
159
|
+
fixed_at: input.text({
|
|
160
|
+
description: "ISO-8601 UTC timestamp the error was marked fixed. Null otherwise.",
|
|
161
|
+
nullable: true
|
|
162
|
+
})
|
|
163
|
+
})
|
|
164
|
+
};
|
|
165
|
+
function mcpServerPrimitives() {
|
|
166
|
+
const primitive = (kind, uri) => input.list(
|
|
167
|
+
input.object({
|
|
168
|
+
id: f.int({ description: `The ${kind} ID` }),
|
|
169
|
+
name: f.text({ description: `The ${kind} name`, methods: ["trim"] }),
|
|
170
|
+
description: f.text({ description: `The ${kind} description`, methods: ["trim"] }),
|
|
171
|
+
...uri ? { uri: f.text({ description: "The resource URI or URI template", methods: ["trim"] }) } : {}
|
|
172
|
+
}),
|
|
173
|
+
{ description: `The list of ${kind}s on the MCP Server` }
|
|
174
|
+
);
|
|
175
|
+
return { prompts: primitive("prompt", false), resources: primitive("resource", true) };
|
|
176
|
+
}
|
|
177
|
+
var MCP_TRIGGER_AUTH_DESCRIPTION = "The signed-in user {dbo, id, extras} when the MCP server requires sign-in, else null";
|
|
178
|
+
function mcpServerAuthInput(toolset) {
|
|
179
|
+
return {
|
|
180
|
+
...toolset,
|
|
181
|
+
name: "auth",
|
|
182
|
+
type: "json",
|
|
183
|
+
description: MCP_TRIGGER_AUTH_DESCRIPTION,
|
|
184
|
+
nullable: true,
|
|
185
|
+
default: null,
|
|
186
|
+
children: [],
|
|
187
|
+
methods: [],
|
|
188
|
+
style: { type: "single" }
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function impliedInputs(objType, toolsetType = "mcp") {
|
|
192
|
+
if (!Object.hasOwn(CATALOG, objType)) {
|
|
193
|
+
throw new Error(`No implied trigger inputs for obj_type ${JSON.stringify(objType)}.`);
|
|
194
|
+
}
|
|
195
|
+
const map = CATALOG[objType]();
|
|
196
|
+
if (objType !== "toolset" || toolsetType !== "mcp") return encodeAll(map);
|
|
197
|
+
const inputs = encodeAll({ ...map, ...mcpServerPrimitives() });
|
|
198
|
+
const toolset = inputs.find((i) => i.name === "toolset");
|
|
199
|
+
if (!toolset) throw new Error("The toolset trigger implies no `toolset` input to derive `auth` from.");
|
|
200
|
+
return [...inputs, mcpServerAuthInput(toolset)];
|
|
201
|
+
}
|
|
202
|
+
function isTriggerObjType(value) {
|
|
203
|
+
return typeof value === "string" && Object.prototype.hasOwnProperty.call(CATALOG, value);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export {
|
|
207
|
+
impliedInputs,
|
|
208
|
+
isTriggerObjType
|
|
209
|
+
};
|
|
210
|
+
//# sourceMappingURL=chunk-G554NZNI.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/util/env-name.ts
|
|
2
|
+
function isRepresentableName(name) {
|
|
3
|
+
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(name);
|
|
4
|
+
}
|
|
5
|
+
function safeNames(names) {
|
|
6
|
+
return names.map((n) => n.replace(/[\u0000-\u001F\u007F]/g, "?")).join(", ");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
isRepresentableName,
|
|
11
|
+
safeNames
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=chunk-GSGDWJB5.js.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// src/workspace/non-json.ts
|
|
2
|
+
function nonJsonKind(value) {
|
|
3
|
+
switch (typeof value) {
|
|
4
|
+
case "function":
|
|
5
|
+
return "a function";
|
|
6
|
+
case "symbol":
|
|
7
|
+
return "a symbol";
|
|
8
|
+
case "bigint":
|
|
9
|
+
return `a bigint (${String(value)}n)`;
|
|
10
|
+
case "object": {
|
|
11
|
+
if (value === null || Array.isArray(value)) return void 0;
|
|
12
|
+
const proto = Object.getPrototypeOf(value);
|
|
13
|
+
if (proto === null || proto === Object.prototype) return void 0;
|
|
14
|
+
const name = value.constructor?.name;
|
|
15
|
+
if (typeof name !== "string" || name === "") return "a class instance";
|
|
16
|
+
return ["Date", "Map", "Set", "RegExp"].includes(name) ? `a ${name}` : `a ${name} instance`;
|
|
17
|
+
}
|
|
18
|
+
default:
|
|
19
|
+
return void 0;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function findNonJson(root) {
|
|
23
|
+
const stack = [[root, ""]];
|
|
24
|
+
const seen = /* @__PURE__ */ new Set();
|
|
25
|
+
while (stack.length > 0) {
|
|
26
|
+
const [node, path] = stack.pop();
|
|
27
|
+
if (nonJsonKind(node) !== void 0) return { path, value: node };
|
|
28
|
+
if (node === null || typeof node !== "object" || seen.has(node)) continue;
|
|
29
|
+
seen.add(node);
|
|
30
|
+
if (Array.isArray(node)) {
|
|
31
|
+
for (let i = node.length - 1; i >= 0; i--) stack.push([node[i], `${path}[${i}]`]);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const keys = Object.keys(node);
|
|
35
|
+
for (let i = keys.length - 1; i >= 0; i--) {
|
|
36
|
+
const key = keys[i];
|
|
37
|
+
stack.push([node[key], path === "" ? key : `${path}.${key}`]);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return void 0;
|
|
41
|
+
}
|
|
42
|
+
function jsonFate(value) {
|
|
43
|
+
if (typeof value === "symbol") return ["JSON drops it", "a string"];
|
|
44
|
+
if (typeof value === "bigint") return ["`JSON.stringify` throws on it", "`Number(big)` or `String(big)`"];
|
|
45
|
+
if (value instanceof Date) return ["JSON rewrites it as an ISO string", "`date.toISOString()` or its epoch ms"];
|
|
46
|
+
if (value instanceof Map) return ["JSON writes it as `{}`", "`Object.fromEntries(map)`"];
|
|
47
|
+
if (value instanceof Set) return ["JSON writes it as `{}`", "`[...set]`"];
|
|
48
|
+
if (value instanceof RegExp) return ["JSON writes it as `{}`", "its `.source` string"];
|
|
49
|
+
return ["JSON keeps only its own enumerable fields", "a plain record"];
|
|
50
|
+
}
|
|
51
|
+
function nonJsonMessage(owner, location, value) {
|
|
52
|
+
if (location.startsWith(`${owner}, at `)) location = location.slice(owner.length + ", at ".length);
|
|
53
|
+
if (typeof value !== "function") {
|
|
54
|
+
const [fate, instead] = jsonFate(value);
|
|
55
|
+
return `${owner}: ${nonJsonKind(value) ?? "a value JSON cannot carry"} is stored at ${location}. ${fate}, so the bundle would not hold the value you wrote, and the next pull could not read it back. Write plain JSON there \u2014 ${instead}.`;
|
|
56
|
+
}
|
|
57
|
+
const tagged = typeof value.tag === "string" && Array.isArray(value.filters);
|
|
58
|
+
const input = value.value;
|
|
59
|
+
return `${owner}: ${tagged ? "a callable tagged value (a trigger input accessor such as `t.action`)" : "a function"} is stored as a function at ${location}. JSON writes a function as \`null\` (or drops it), so the bundle would carry a hole where the value was, and the next pull could not read it back.` + (tagged && typeof input === "string" ? ` Spell the input by name in this position \u2014 \`inp(${JSON.stringify(input)})\`.` : " Pass a tagged value (`c.*`, `ref()`, `inp()`, \u2026) or a plain JSON value instead.");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export {
|
|
63
|
+
findNonJson,
|
|
64
|
+
nonJsonMessage
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=chunk-H2V3N23D.js.map
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import {
|
|
2
|
+
UsageError,
|
|
3
|
+
flagNames,
|
|
4
|
+
unknownFlag
|
|
5
|
+
} from "./chunk-PTHVMXZI.js";
|
|
6
|
+
|
|
7
|
+
// src/emit/plugin-questions.ts
|
|
8
|
+
function hostLabel(host) {
|
|
9
|
+
return host === "init" ? "xanosdk init" : `xanosdk marketplace ${host}`;
|
|
10
|
+
}
|
|
11
|
+
function hostHelpTarget(host) {
|
|
12
|
+
return host === "init" ? { command: "init" } : { command: "marketplace", subcommand: host };
|
|
13
|
+
}
|
|
14
|
+
function isRegistryFlag(flag) {
|
|
15
|
+
return flagNames().includes(flag);
|
|
16
|
+
}
|
|
17
|
+
function flagFor(question) {
|
|
18
|
+
return question.flag ?? question.id;
|
|
19
|
+
}
|
|
20
|
+
function questionSets(plugins) {
|
|
21
|
+
return plugins.filter((p) => p.plugin.questions !== void 0 && p.plugin.questions.length > 0).map((p) => ({ pkg: p.pkg, questions: p.plugin.questions }));
|
|
22
|
+
}
|
|
23
|
+
function assertNoFlagCollisions(sets, host) {
|
|
24
|
+
const claimed = /* @__PURE__ */ new Map();
|
|
25
|
+
for (const set of sets) {
|
|
26
|
+
for (const question of set.questions) {
|
|
27
|
+
const flag = flagFor(question);
|
|
28
|
+
if (isRegistryFlag(flag)) {
|
|
29
|
+
throw new UsageError(
|
|
30
|
+
`${set.pkg} asks a question whose flag \`--${flag}\` is already a \`${hostLabel(host)}\` flag, so it could never be answered \u2014 the CLI would consume it first.`,
|
|
31
|
+
{
|
|
32
|
+
helpFor: hostHelpTarget(host),
|
|
33
|
+
suggestion: `That is the module's bug to fix: its question \`${question.id}\` should declare a distinct \`flag\` (for example \`--${set.pkg.replace(/^@[^/]+\//, "")}-${flag}\`). Report it, or disable the module in this project's package.json "xanosdk" block.`
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
const owner = claimed.get(flag);
|
|
38
|
+
if (owner !== void 0) {
|
|
39
|
+
throw new UsageError(
|
|
40
|
+
`${set.pkg} and ${owner} both derive the flag \`--${flag}\`, so only one of them could ever be answered by it during \`${hostLabel(host)}\`.`,
|
|
41
|
+
{
|
|
42
|
+
helpFor: hostHelpTarget(host),
|
|
43
|
+
suggestion: `One of the two must declare a distinct \`flag\` on that question.`
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
claimed.set(flag, set.pkg);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function answerFromFlags(question, remaining) {
|
|
52
|
+
const name = flagFor(question);
|
|
53
|
+
const long = `--${name}`;
|
|
54
|
+
const negated = `--no-${name}`;
|
|
55
|
+
for (let i = 0; i < remaining.length; i++) {
|
|
56
|
+
const arg = remaining[i];
|
|
57
|
+
if (question.type === "boolean" && arg === negated) {
|
|
58
|
+
remaining.splice(i, 1);
|
|
59
|
+
return { given: true, value: false };
|
|
60
|
+
}
|
|
61
|
+
if (arg === long) {
|
|
62
|
+
if (question.type === "boolean") {
|
|
63
|
+
remaining.splice(i, 1);
|
|
64
|
+
return { given: true, value: true };
|
|
65
|
+
}
|
|
66
|
+
throw new UsageError(
|
|
67
|
+
`${long} takes its value with an equals sign: \`${long}=<value>\`.`,
|
|
68
|
+
{
|
|
69
|
+
suggestion: `Flags contributed by an installed module are not known to the parser until the module loads, so it cannot tell \`${long} value\` from a flag followed by a positional argument.`
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
if (arg.startsWith(`${long}=`)) {
|
|
74
|
+
const value = arg.slice(long.length + 1);
|
|
75
|
+
remaining.splice(i, 1);
|
|
76
|
+
if (question.type === "boolean") return { given: true, value: value !== "false" };
|
|
77
|
+
return { given: true, value };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return { given: false };
|
|
81
|
+
}
|
|
82
|
+
function assertChoice(pkg, question, value, host) {
|
|
83
|
+
if (question.type !== "choice") return;
|
|
84
|
+
const choices = question.choices ?? [];
|
|
85
|
+
if (!choices.includes(String(value))) {
|
|
86
|
+
throw new UsageError(
|
|
87
|
+
`${pkg}: --${flagFor(question)} expects one of ${choices.map((c) => `\`${c}\``).join(", ")}, not \`${String(value)}\`.`,
|
|
88
|
+
{ helpFor: hostHelpTarget(host) }
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function priorIsUsable(question, value) {
|
|
93
|
+
if (question.type === "boolean") return typeof value === "boolean";
|
|
94
|
+
if (typeof value !== "string") return false;
|
|
95
|
+
if (question.type === "choice") return (question.choices ?? []).includes(value);
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
async function resolvePluginAnswers(sets, opts) {
|
|
99
|
+
const remaining = [...opts.unknownFlags];
|
|
100
|
+
const byPackage = {};
|
|
101
|
+
for (const set of sets) {
|
|
102
|
+
const stored = opts.prior?.[set.pkg] ?? {};
|
|
103
|
+
const answers = {};
|
|
104
|
+
const sources = {};
|
|
105
|
+
const dropped = [];
|
|
106
|
+
for (const question of set.questions) {
|
|
107
|
+
if (question.when !== void 0 && !question.when(answers)) {
|
|
108
|
+
if (stored[question.id] !== void 0) dropped.push({ id: question.id, why: "excluded" });
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
const fromFlag = answerFromFlags(question, remaining);
|
|
112
|
+
if (fromFlag.given) {
|
|
113
|
+
assertChoice(set.pkg, question, fromFlag.value, opts.host);
|
|
114
|
+
answers[question.id] = fromFlag.value;
|
|
115
|
+
sources[question.id] = "flag";
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const raw = stored[question.id];
|
|
119
|
+
let prior;
|
|
120
|
+
if (raw !== void 0) {
|
|
121
|
+
if (priorIsUsable(question, raw)) prior = raw;
|
|
122
|
+
else dropped.push({ id: question.id, why: "unusable" });
|
|
123
|
+
}
|
|
124
|
+
const asked = await opts.prompter.ask(set.pkg, question, prior ?? question.default);
|
|
125
|
+
if (asked !== void 0) {
|
|
126
|
+
assertChoice(set.pkg, question, asked, opts.host);
|
|
127
|
+
answers[question.id] = asked;
|
|
128
|
+
sources[question.id] = "prompt";
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (prior !== void 0) {
|
|
132
|
+
answers[question.id] = prior;
|
|
133
|
+
sources[question.id] = "config";
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
answers[question.id] = question.default;
|
|
137
|
+
sources[question.id] = "default";
|
|
138
|
+
}
|
|
139
|
+
byPackage[set.pkg] = { answers, sources, dropped };
|
|
140
|
+
}
|
|
141
|
+
if (remaining.length > 0) {
|
|
142
|
+
throw unknownFlag(
|
|
143
|
+
remaining,
|
|
144
|
+
hostHelpTarget(opts.host),
|
|
145
|
+
sets.flatMap((s) => s.questions.map(flagFor))
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
return byPackage;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export {
|
|
152
|
+
hostLabel,
|
|
153
|
+
hostHelpTarget,
|
|
154
|
+
flagFor,
|
|
155
|
+
questionSets,
|
|
156
|
+
assertNoFlagCollisions,
|
|
157
|
+
resolvePluginAnswers
|
|
158
|
+
};
|
|
159
|
+
//# sourceMappingURL=chunk-H5C7MBCR.js.map
|