@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,304 @@
|
|
|
1
|
+
import {
|
|
2
|
+
filledAt,
|
|
3
|
+
withValidFilled
|
|
4
|
+
} from "./chunk-ZYJP6BOO.js";
|
|
5
|
+
import {
|
|
6
|
+
withFileLockSync
|
|
7
|
+
} from "./chunk-QO6BVGS5.js";
|
|
8
|
+
import {
|
|
9
|
+
unreadableError
|
|
10
|
+
} from "./chunk-JZGVVJSI.js";
|
|
11
|
+
import {
|
|
12
|
+
destinationKey,
|
|
13
|
+
nextLandedRecord
|
|
14
|
+
} from "./chunk-TLQE7ZN3.js";
|
|
15
|
+
import {
|
|
16
|
+
ensureGitignored
|
|
17
|
+
} from "./chunk-XW6KISBB.js";
|
|
18
|
+
import {
|
|
19
|
+
atomicWrite
|
|
20
|
+
} from "./chunk-LLNZGEFK.js";
|
|
21
|
+
import {
|
|
22
|
+
DEFAULT_PROFILE
|
|
23
|
+
} from "./chunk-QXTKSOFI.js";
|
|
24
|
+
|
|
25
|
+
// src/deploy/ephemeral-state.ts
|
|
26
|
+
import { readFileSync, mkdirSync } from "fs";
|
|
27
|
+
import { dirname, join, resolve } from "path";
|
|
28
|
+
function environmentKey(scope) {
|
|
29
|
+
return `${scope.profile?.name ?? DEFAULT_PROFILE}/${hostOf(scope.instance)}/${scope.workspaceId}`;
|
|
30
|
+
}
|
|
31
|
+
function hostOf(instance) {
|
|
32
|
+
try {
|
|
33
|
+
return new URL(instance).host;
|
|
34
|
+
} catch {
|
|
35
|
+
return instance.replace(/\//g, "_");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function ephemeralStatePath(dir) {
|
|
39
|
+
return join(resolve(dir), ".xano", "ephemeral.json");
|
|
40
|
+
}
|
|
41
|
+
function stateLockPath(dir) {
|
|
42
|
+
return `${ephemeralStatePath(dir)}.lock`;
|
|
43
|
+
}
|
|
44
|
+
function readEphemeralState(dir) {
|
|
45
|
+
const path = ephemeralStatePath(dir);
|
|
46
|
+
let text;
|
|
47
|
+
try {
|
|
48
|
+
text = readFileSync(path, "utf8");
|
|
49
|
+
} catch {
|
|
50
|
+
return { version: 1, environments: {} };
|
|
51
|
+
}
|
|
52
|
+
return parseState(text) ?? { version: 1, environments: {} };
|
|
53
|
+
}
|
|
54
|
+
function isAbsent(err) {
|
|
55
|
+
const code = err?.code;
|
|
56
|
+
return code === "ENOENT" || code === "ENOTDIR";
|
|
57
|
+
}
|
|
58
|
+
function readStateForWrite(dir) {
|
|
59
|
+
const path = ephemeralStatePath(dir);
|
|
60
|
+
try {
|
|
61
|
+
readFileSync(path);
|
|
62
|
+
} catch (err) {
|
|
63
|
+
if (!isAbsent(err) && err.code !== "EISDIR") throw unreadableError(path);
|
|
64
|
+
}
|
|
65
|
+
return readEphemeralState(dir);
|
|
66
|
+
}
|
|
67
|
+
function parseState(text) {
|
|
68
|
+
try {
|
|
69
|
+
const parsed = JSON.parse(text);
|
|
70
|
+
const envs = parsed?.environments;
|
|
71
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed) && envs !== null && typeof envs === "object" && !Array.isArray(envs)) {
|
|
72
|
+
const landed = validLanded(parsed.landed);
|
|
73
|
+
return { version: 1, environments: { ...envs }, ...landed !== void 0 ? { landed } : {} };
|
|
74
|
+
}
|
|
75
|
+
} catch {
|
|
76
|
+
}
|
|
77
|
+
return void 0;
|
|
78
|
+
}
|
|
79
|
+
function unreadableEphemeralState(dir) {
|
|
80
|
+
const path = ephemeralStatePath(dir);
|
|
81
|
+
let text;
|
|
82
|
+
try {
|
|
83
|
+
text = readFileSync(path, "utf8");
|
|
84
|
+
} catch (err) {
|
|
85
|
+
return isAbsent(err) ? void 0 : path;
|
|
86
|
+
}
|
|
87
|
+
return parseState(text) === void 0 ? path : void 0;
|
|
88
|
+
}
|
|
89
|
+
function getEnvironment(state, scope) {
|
|
90
|
+
const record = state.environments[keyIn(state, scope)];
|
|
91
|
+
return record === void 0 ? void 0 : withValidFilled(record);
|
|
92
|
+
}
|
|
93
|
+
function keyIn(state, scope) {
|
|
94
|
+
const key = environmentKey(scope);
|
|
95
|
+
if (key in state.environments) return key;
|
|
96
|
+
const legacy = String(scope.workspaceId);
|
|
97
|
+
return legacy in state.environments ? legacy : key;
|
|
98
|
+
}
|
|
99
|
+
function adoptsLegacy(state, scope) {
|
|
100
|
+
return keyIn(state, scope) === String(scope.workspaceId);
|
|
101
|
+
}
|
|
102
|
+
function setEnvironment(dir, scope, record) {
|
|
103
|
+
withFileLockSync(stateLockPath(dir), () => setEnvironmentLocked(dir, scope, record));
|
|
104
|
+
}
|
|
105
|
+
function setEnvironmentLocked(dir, scope, record) {
|
|
106
|
+
const state = readStateForWrite(dir);
|
|
107
|
+
const adopting = adoptsLegacy(state, scope);
|
|
108
|
+
const replaced = state.environments[keyIn(state, scope)]?.name;
|
|
109
|
+
if (replaced !== void 0 && replaced !== record.name && state.landed !== void 0) {
|
|
110
|
+
const { [ephemeralLandingKey(scope.instance, replaced)]: _gone, ...landed } = state.landed;
|
|
111
|
+
state.landed = landed;
|
|
112
|
+
}
|
|
113
|
+
const { credential: _carried, ...rest } = record;
|
|
114
|
+
state.environments[environmentKey(scope)] = {
|
|
115
|
+
...rest,
|
|
116
|
+
profile: scope.profile?.name ?? DEFAULT_PROFILE,
|
|
117
|
+
instance: scope.instance,
|
|
118
|
+
...scope.profile === void 0 ? { credential: "environment" } : {}
|
|
119
|
+
};
|
|
120
|
+
if (adopting) delete state.environments[String(scope.workspaceId)];
|
|
121
|
+
writeState(dir, state);
|
|
122
|
+
}
|
|
123
|
+
function markEnvironmentFilled(dir, scope, url, landed = {}) {
|
|
124
|
+
withFileLockSync(stateLockPath(dir), () => markEnvironmentFilledLocked(dir, scope, url, landed));
|
|
125
|
+
}
|
|
126
|
+
function markEnvironmentFilledLocked(dir, scope, url, landed) {
|
|
127
|
+
const record = getEnvironment(readEphemeralState(dir), scope);
|
|
128
|
+
if (record === void 0) return;
|
|
129
|
+
const { release: _release, entry: _entry, ...rest } = record;
|
|
130
|
+
setEnvironment(dir, scope, {
|
|
131
|
+
...rest,
|
|
132
|
+
filled: filledAt(url),
|
|
133
|
+
...landed.release === void 0 ? {} : { release: landed.release },
|
|
134
|
+
...landed.entry === void 0 ? {} : { entry: landed.entry }
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function recordStaticUrl(dir, scope, staticUrl) {
|
|
138
|
+
withFileLockSync(stateLockPath(dir), () => recordStaticUrlLocked(dir, scope, staticUrl));
|
|
139
|
+
}
|
|
140
|
+
function recordStaticUrlLocked(dir, scope, staticUrl) {
|
|
141
|
+
const record = getEnvironment(readEphemeralState(dir), scope);
|
|
142
|
+
if (record === void 0) return;
|
|
143
|
+
const { static_down: _down, static_unchecked: _unchecked, ...rest } = record;
|
|
144
|
+
setEnvironment(dir, scope, { ...rest, static_url: staticUrl });
|
|
145
|
+
}
|
|
146
|
+
function clearEnvironment(dir, scope) {
|
|
147
|
+
return withFileLockSync(stateLockPath(dir), () => clearEnvironmentLocked(dir, scope));
|
|
148
|
+
}
|
|
149
|
+
function clearEnvironmentLocked(dir, scope) {
|
|
150
|
+
const state = readEphemeralState(dir);
|
|
151
|
+
const keys = [environmentKey(scope), ...adoptsLegacy(state, scope) ? [String(scope.workspaceId)] : []].filter(
|
|
152
|
+
(k) => k in state.environments
|
|
153
|
+
);
|
|
154
|
+
if (keys.length === 0) return false;
|
|
155
|
+
const landed = { ...state.landed ?? {} };
|
|
156
|
+
for (const key of keys) {
|
|
157
|
+
const name = state.environments[key]?.name;
|
|
158
|
+
if (name !== void 0) delete landed[ephemeralLandingKey(scope.instance, name)];
|
|
159
|
+
delete state.environments[key];
|
|
160
|
+
}
|
|
161
|
+
writeState(dir, { ...state, landed });
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
function clearEnvironmentsNamed(dir, instance, name) {
|
|
165
|
+
return withFileLockSync(stateLockPath(dir), () => clearEnvironmentsNamedLocked(dir, instance, name));
|
|
166
|
+
}
|
|
167
|
+
function clearEnvironmentsNamedLocked(dir, instance, name) {
|
|
168
|
+
const state = readEphemeralState(dir);
|
|
169
|
+
const host = hostOf(instance);
|
|
170
|
+
const keys = Object.entries(state.environments).filter(
|
|
171
|
+
([key, record]) => record.name === name && (record.instance !== void 0 ? hostOf(record.instance) === host : key.split("/")[1] === host)
|
|
172
|
+
).map(([key]) => key);
|
|
173
|
+
if (keys.length === 0) return false;
|
|
174
|
+
for (const key of keys) delete state.environments[key];
|
|
175
|
+
const landed = { ...state.landed ?? {} };
|
|
176
|
+
delete landed[ephemeralLandingKey(instance, name)];
|
|
177
|
+
writeState(dir, { ...state, landed });
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
function ephemeralLandingKey(instance, name) {
|
|
181
|
+
return destinationKey(instance, { kind: "ephemeral", name });
|
|
182
|
+
}
|
|
183
|
+
function ephemeralLandedOn(dir, destKey) {
|
|
184
|
+
const record = readEphemeralState(dir).landed?.[destKey];
|
|
185
|
+
return record === void 0 || Object.keys(record).length === 0 ? void 0 : record;
|
|
186
|
+
}
|
|
187
|
+
function allLandings(dir, lock) {
|
|
188
|
+
return [...Object.entries(lock.landed ?? {}), ...Object.entries(readEphemeralState(dir).landed ?? {})];
|
|
189
|
+
}
|
|
190
|
+
function recordEphemeralLanding(dir, destKey, update) {
|
|
191
|
+
return withFileLockSync(stateLockPath(dir), () => recordEphemeralLandingLocked(dir, destKey, update));
|
|
192
|
+
}
|
|
193
|
+
function recordEphemeralLandingLocked(dir, destKey, update) {
|
|
194
|
+
const state = readStateForWrite(dir);
|
|
195
|
+
const before = state.landed?.[destKey] ?? {};
|
|
196
|
+
const next = nextLandedRecord(before, update);
|
|
197
|
+
const changed = JSON.stringify(sortedRecord(before)) !== JSON.stringify(sortedRecord(next));
|
|
198
|
+
if (changed) {
|
|
199
|
+
const landed = { ...state.landed ?? {} };
|
|
200
|
+
if (Object.keys(next).length > 0) landed[destKey] = next;
|
|
201
|
+
else delete landed[destKey];
|
|
202
|
+
writeState(dir, { ...state, landed });
|
|
203
|
+
}
|
|
204
|
+
return { changed, recorded: Object.keys(next).length };
|
|
205
|
+
}
|
|
206
|
+
function clearEphemeralLanding(dir, instance, name) {
|
|
207
|
+
return withFileLockSync(stateLockPath(dir), () => clearEphemeralLandingLocked(dir, instance, name));
|
|
208
|
+
}
|
|
209
|
+
function clearEphemeralLandingLocked(dir, instance, name) {
|
|
210
|
+
const state = readEphemeralState(dir);
|
|
211
|
+
const key = ephemeralLandingKey(instance, name);
|
|
212
|
+
if (state.landed?.[key] === void 0) return false;
|
|
213
|
+
const { [key]: _dropped, ...landed } = state.landed;
|
|
214
|
+
writeState(dir, { ...state, landed });
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
function sortedRecord(record) {
|
|
218
|
+
const columns = (e) => e.columns === void 0 ? "" : JSON.stringify(Object.keys(e.columns).sort().map((c) => [c, e.columns[c]]));
|
|
219
|
+
return Object.keys(record).sort().map((k) => [k, record[k].guid, record[k].type ?? "", columns(record[k])]);
|
|
220
|
+
}
|
|
221
|
+
function validLanded(raw) {
|
|
222
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
223
|
+
const out = {};
|
|
224
|
+
for (const [dest, entries] of Object.entries(raw)) {
|
|
225
|
+
if (!/^[^/\s]+\/ephemeral\/[^/\s]+$/.test(dest)) continue;
|
|
226
|
+
if (entries === null || typeof entries !== "object" || Array.isArray(entries)) continue;
|
|
227
|
+
const record = {};
|
|
228
|
+
for (const [key, e] of Object.entries(entries)) {
|
|
229
|
+
const { guid, type, columns } = e ?? {};
|
|
230
|
+
if (typeof guid !== "string" || guid === "" || !/^[a-z_]+:./i.test(key)) continue;
|
|
231
|
+
record[key] = type === "agent" && key.startsWith("toolset:") ? { guid, type: "agent" } : { guid };
|
|
232
|
+
const stored = key.startsWith("dbo:") ? validColumns(columns) : void 0;
|
|
233
|
+
if (stored !== void 0) record[key].columns = stored;
|
|
234
|
+
}
|
|
235
|
+
if (Object.keys(record).length > 0) out[dest] = record;
|
|
236
|
+
}
|
|
237
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
238
|
+
}
|
|
239
|
+
function validColumns(raw) {
|
|
240
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
241
|
+
const out = {};
|
|
242
|
+
for (const [column, type] of Object.entries(raw)) {
|
|
243
|
+
if (typeof type === "string" && type !== "") out[column] = type;
|
|
244
|
+
}
|
|
245
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
246
|
+
}
|
|
247
|
+
var RECORD_KEY_ORDER = [
|
|
248
|
+
"name",
|
|
249
|
+
"display",
|
|
250
|
+
"url",
|
|
251
|
+
"expires_at",
|
|
252
|
+
"profile",
|
|
253
|
+
"instance",
|
|
254
|
+
"credential",
|
|
255
|
+
"credential_file",
|
|
256
|
+
"filled",
|
|
257
|
+
"static_url",
|
|
258
|
+
"static_down",
|
|
259
|
+
"static_unchecked",
|
|
260
|
+
"entry",
|
|
261
|
+
"release"
|
|
262
|
+
];
|
|
263
|
+
function inRecordOrder(record) {
|
|
264
|
+
const rank = (k) => {
|
|
265
|
+
const i = RECORD_KEY_ORDER.indexOf(k);
|
|
266
|
+
return i === -1 ? RECORD_KEY_ORDER.length : i;
|
|
267
|
+
};
|
|
268
|
+
const keys = Object.keys(record).sort((a, b) => rank(a) - rank(b) || a.localeCompare(b));
|
|
269
|
+
return Object.fromEntries(keys.map((k) => [k, record[k]]));
|
|
270
|
+
}
|
|
271
|
+
function writeState(dir, state) {
|
|
272
|
+
const path = ephemeralStatePath(dir);
|
|
273
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
274
|
+
const landed = {};
|
|
275
|
+
for (const dest of Object.keys(state.landed ?? {}).sort()) {
|
|
276
|
+
const src = state.landed[dest];
|
|
277
|
+
if (Object.keys(src).length === 0) continue;
|
|
278
|
+
landed[dest] = Object.fromEntries(Object.keys(src).sort().map((k) => [k, src[k]]));
|
|
279
|
+
}
|
|
280
|
+
const environments = {};
|
|
281
|
+
for (const key of Object.keys(state.environments)) environments[key] = inRecordOrder(state.environments[key]);
|
|
282
|
+
const body = Object.keys(landed).length > 0 ? { version: 1, environments, landed } : { version: 1, environments };
|
|
283
|
+
atomicWrite(path, JSON.stringify(body, null, 2) + "\n");
|
|
284
|
+
ensureGitignored(path);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export {
|
|
288
|
+
environmentKey,
|
|
289
|
+
ephemeralStatePath,
|
|
290
|
+
readEphemeralState,
|
|
291
|
+
unreadableEphemeralState,
|
|
292
|
+
getEnvironment,
|
|
293
|
+
setEnvironment,
|
|
294
|
+
markEnvironmentFilled,
|
|
295
|
+
recordStaticUrl,
|
|
296
|
+
clearEnvironment,
|
|
297
|
+
clearEnvironmentsNamed,
|
|
298
|
+
ephemeralLandingKey,
|
|
299
|
+
ephemeralLandedOn,
|
|
300
|
+
allLandings,
|
|
301
|
+
recordEphemeralLanding,
|
|
302
|
+
clearEphemeralLanding
|
|
303
|
+
};
|
|
304
|
+
//# sourceMappingURL=chunk-5QU2P5CA.js.map
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defaultHistory,
|
|
3
|
+
emptyMiddleware
|
|
4
|
+
} from "./chunk-4POWHT2K.js";
|
|
5
|
+
import {
|
|
6
|
+
RAW_ENVELOPE,
|
|
7
|
+
encodeStatement,
|
|
8
|
+
registerStatement
|
|
9
|
+
} from "./chunk-YU4HSQW7.js";
|
|
10
|
+
import {
|
|
11
|
+
isTaggedValue
|
|
12
|
+
} from "./chunk-OXA6PSZT.js";
|
|
13
|
+
import {
|
|
14
|
+
resolveRef
|
|
15
|
+
} from "./chunk-NZOWWHU5.js";
|
|
16
|
+
|
|
17
|
+
// src/kinds/history.ts
|
|
18
|
+
var CONTAINER_DEFAULT_ENABLED = {
|
|
19
|
+
query: true,
|
|
20
|
+
tool: true,
|
|
21
|
+
message: false
|
|
22
|
+
};
|
|
23
|
+
var WORKSPACE_HISTORY_TYPES = [
|
|
24
|
+
"query",
|
|
25
|
+
"function",
|
|
26
|
+
"task",
|
|
27
|
+
"tool",
|
|
28
|
+
"trigger",
|
|
29
|
+
"middleware",
|
|
30
|
+
"message",
|
|
31
|
+
// The MCP primitives. Both default ON, like `tool`. An instance from before
|
|
32
|
+
// they existed stores neither pair; it reads the absent pair as that default.
|
|
33
|
+
"prompt",
|
|
34
|
+
"resource"
|
|
35
|
+
];
|
|
36
|
+
function scalarToEnabledLimit(input) {
|
|
37
|
+
if (input === false) return { enabled: false, limit: 100 };
|
|
38
|
+
if (input === true) return { enabled: true, limit: 100 };
|
|
39
|
+
if (input === "all") return { enabled: true, limit: -1 };
|
|
40
|
+
if (!Number.isInteger(input) || input < 0) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
`history takes true, false, "all" or an integer depth >= 0, got ${JSON.stringify(input)}`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
return { enabled: true, limit: input };
|
|
46
|
+
}
|
|
47
|
+
function encodeHistory(objType, input) {
|
|
48
|
+
if (input === void 0) return defaultHistory(objType);
|
|
49
|
+
const { enabled, limit } = scalarToEnabledLimit(input);
|
|
50
|
+
return { inherit: false, enabled, limit };
|
|
51
|
+
}
|
|
52
|
+
function encodeContainerHistory(prefix, input) {
|
|
53
|
+
const { inherit, enabled, limit } = input === void 0 ? { inherit: true, enabled: CONTAINER_DEFAULT_ENABLED[prefix], limit: 100 } : { inherit: false, ...scalarToEnabledLimit(input) };
|
|
54
|
+
return {
|
|
55
|
+
inherit,
|
|
56
|
+
[`${prefix}_enabled`]: enabled,
|
|
57
|
+
[`${prefix}_limit`]: limit
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function buildWorkspaceHistory(map) {
|
|
61
|
+
const out = {};
|
|
62
|
+
for (const t of WORKSPACE_HISTORY_TYPES) {
|
|
63
|
+
const input = map[t];
|
|
64
|
+
const { enabled, limit } = input === void 0 ? { enabled: defaultHistory(t).enabled, limit: 100 } : scalarToEnabledLimit(input);
|
|
65
|
+
out[`${t}_enabled`] = enabled;
|
|
66
|
+
out[`${t}_limit`] = limit;
|
|
67
|
+
}
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// src/kinds/middleware-attach.ts
|
|
72
|
+
function isRawEntry(entry) {
|
|
73
|
+
return typeof entry === "object" && entry !== null && entry[RAW_ENVELOPE] !== void 0;
|
|
74
|
+
}
|
|
75
|
+
function parseEntry(entry) {
|
|
76
|
+
if (typeof entry === "object" && "middleware" in entry) {
|
|
77
|
+
return { ref: entry.middleware, active: entry.active };
|
|
78
|
+
}
|
|
79
|
+
return { ref: entry };
|
|
80
|
+
}
|
|
81
|
+
function middlewareAttachStatement(args) {
|
|
82
|
+
return {
|
|
83
|
+
name: "mvp:middleware",
|
|
84
|
+
context: { middleware: { id: resolveRef("middleware", args.middleware) } },
|
|
85
|
+
...args.active === false ? { disabled: true } : {}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
registerStatement("mvp:middleware", middlewareAttachStatement);
|
|
89
|
+
function encodeMiddlewareEntry(entry) {
|
|
90
|
+
if (isRawEntry(entry)) return encodeStatement(entry);
|
|
91
|
+
const { ref, active } = parseEntry(entry);
|
|
92
|
+
return encodeStatement(middlewareAttachStatement({ middleware: ref, active }));
|
|
93
|
+
}
|
|
94
|
+
function middlewareEntryGuid(entry) {
|
|
95
|
+
const id = entry?.context?.middleware?.id;
|
|
96
|
+
return typeof id === "string" ? id : void 0;
|
|
97
|
+
}
|
|
98
|
+
function buildMiddlewareBlock(attach) {
|
|
99
|
+
if (!attach) return emptyMiddleware();
|
|
100
|
+
return {
|
|
101
|
+
pre_customize: attach.pre !== void 0,
|
|
102
|
+
post_customize: attach.post !== void 0,
|
|
103
|
+
pre: encodeMiddlewareList(attach.pre),
|
|
104
|
+
post: encodeMiddlewareList(attach.post)
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function encodeMiddlewareList(entries) {
|
|
108
|
+
return (entries ?? []).map(encodeMiddlewareEntry);
|
|
109
|
+
}
|
|
110
|
+
function clear() {
|
|
111
|
+
return [];
|
|
112
|
+
}
|
|
113
|
+
function stackReferencesAuth(stack) {
|
|
114
|
+
return (stack ?? []).some(nodeReferencesAuth);
|
|
115
|
+
}
|
|
116
|
+
function nodeReferencesAuth(node) {
|
|
117
|
+
if (node === null || typeof node !== "object" && typeof node !== "function") return false;
|
|
118
|
+
if (isTaggedValue(node) && node.tag === "auth") return true;
|
|
119
|
+
if (Array.isArray(node)) return node.some(nodeReferencesAuth);
|
|
120
|
+
return Object.values(node).some(nodeReferencesAuth);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// src/kinds/stored-name.ts
|
|
124
|
+
var NAME_MAX = 200;
|
|
125
|
+
var EXTRA = {
|
|
126
|
+
route: "_-{}/",
|
|
127
|
+
plain: "_-"
|
|
128
|
+
};
|
|
129
|
+
var PATTERN = {
|
|
130
|
+
route: /^[A-Za-z0-9_\-{}/]+$/,
|
|
131
|
+
plain: /^[A-Za-z0-9_-]+$/
|
|
132
|
+
};
|
|
133
|
+
var DESCRIPTION = {
|
|
134
|
+
route: 'only letters, digits, "_", "-", "/", and the "{}" of a path param',
|
|
135
|
+
plain: 'only letters, digits, "_" and "-"'
|
|
136
|
+
};
|
|
137
|
+
function assertCanonical(context, canonical) {
|
|
138
|
+
if (canonical === void 0 || canonical === "") return;
|
|
139
|
+
if (canonical.length > NAME_MAX) {
|
|
140
|
+
throw new Error(
|
|
141
|
+
`${context}: the canonical is ${canonical.length} characters \u2014 the engine stores at most ${NAME_MAX}. Shorten it, or omit it and let \`xanosdk export <entry>\` mint one.`
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
if (PATTERN.plain.test(canonical)) return;
|
|
145
|
+
const bad = [.../* @__PURE__ */ new Set([...canonical])].filter((ch) => !/[A-Za-z0-9_-]/.test(ch));
|
|
146
|
+
throw new Error(
|
|
147
|
+
`${context}: the canonical contains ${bad.map((ch) => JSON.stringify(ch)).join(", ")}, which cannot appear in a URL token. A canonical holds ${DESCRIPTION.plain} \u2014 it is the \`<canonical>\` of \`/api:<canonical>\` and of the MCP/realtime stream paths. Unlike a name, the engine does NOT reject or blank it: it stores the value verbatim, the deploy succeeds, and every client then 404s against an address the router cannot match. Omit \`canonical\` to let \`xanosdk export <entry>\` mint one, or supply a token in charset.`
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
function assertStoredName(context, name, shape) {
|
|
151
|
+
if (name.length > NAME_MAX) {
|
|
152
|
+
throw new Error(
|
|
153
|
+
`${context}: the name is ${name.length} characters \u2014 the engine stores at most ${NAME_MAX}, and a longer one is dropped rather than truncated, leaving the object with an empty name. Shorten it.`
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
if (PATTERN[shape].test(name)) return;
|
|
157
|
+
if (!name) throw new Error(`${context}: the name is empty.`);
|
|
158
|
+
const allowed = /* @__PURE__ */ new Set([...EXTRA[shape]]);
|
|
159
|
+
const bad = [.../* @__PURE__ */ new Set([...name])].filter(
|
|
160
|
+
(ch) => !/[A-Za-z0-9]/.test(ch) && !allowed.has(ch)
|
|
161
|
+
);
|
|
162
|
+
const list = bad.map((ch) => JSON.stringify(ch)).join(", ");
|
|
163
|
+
const hint = bad.includes(".") ? ` A "." is the one authors reach for: an endpoint that serves a file wants "export_zip" or "export/zip", not "export.zip" \u2014 the extension belongs in the response headers.` : "";
|
|
164
|
+
throw new Error(
|
|
165
|
+
`${context}: the name contains ${list}, which the engine cannot store. This name holds ${DESCRIPTION[shape]}.${hint} Xano does not reject the write \u2014 it saves the object with an EMPTY name, so it deploys clean and then 404s "Unable to locate request." on every request.`
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
function assertNameAsStored(kind, name) {
|
|
169
|
+
if (typeof name !== "string" || name === "" || name.trim() === name) return;
|
|
170
|
+
const head = `${kind} ${JSON.stringify(name)}: `;
|
|
171
|
+
throw new Error(
|
|
172
|
+
name.trim() === "" ? `${head}the name is empty.` : `${head}the engine stores it trimmed, so it reads back as a rename. Write ${JSON.stringify(name.trim())}.`
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export {
|
|
177
|
+
WORKSPACE_HISTORY_TYPES,
|
|
178
|
+
encodeHistory,
|
|
179
|
+
encodeContainerHistory,
|
|
180
|
+
buildWorkspaceHistory,
|
|
181
|
+
encodeMiddlewareEntry,
|
|
182
|
+
middlewareEntryGuid,
|
|
183
|
+
buildMiddlewareBlock,
|
|
184
|
+
encodeMiddlewareList,
|
|
185
|
+
clear,
|
|
186
|
+
stackReferencesAuth,
|
|
187
|
+
assertCanonical,
|
|
188
|
+
assertStoredName,
|
|
189
|
+
assertNameAsStored
|
|
190
|
+
};
|
|
191
|
+
//# sourceMappingURL=chunk-5V5XU32D.js.map
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import {
|
|
2
|
+
landedStep
|
|
3
|
+
} from "./chunk-4KHEMC32.js";
|
|
4
|
+
import {
|
|
5
|
+
CliError,
|
|
6
|
+
UsageError,
|
|
7
|
+
style,
|
|
8
|
+
terminalText
|
|
9
|
+
} from "./chunk-PTHVMXZI.js";
|
|
10
|
+
|
|
11
|
+
// src/emit/prompt.ts
|
|
12
|
+
import { createInterface } from "readline";
|
|
13
|
+
var EXIT_PROMPT_CANCELLED = 130;
|
|
14
|
+
var CANCELLED = /* @__PURE__ */ Symbol("cancelled");
|
|
15
|
+
function promptCancelled() {
|
|
16
|
+
const landed = landedStep();
|
|
17
|
+
const after = landed === void 0 ? "Nothing was changed." : landed.ifCancelled ?? landed.said;
|
|
18
|
+
return new CliError("SDK_ERROR", `Cancelled. ${after}`, { exitCode: EXIT_PROMPT_CANCELLED });
|
|
19
|
+
}
|
|
20
|
+
async function questionOrCancel(rl, text, output = process.stderr) {
|
|
21
|
+
if (typeof rl.once !== "function" || typeof rl.off !== "function") return rl.question(text);
|
|
22
|
+
let onInterrupt;
|
|
23
|
+
const cancelled = new Promise((_, reject) => {
|
|
24
|
+
onInterrupt = () => {
|
|
25
|
+
output.write("\n");
|
|
26
|
+
reject(promptCancelled());
|
|
27
|
+
};
|
|
28
|
+
rl.once("SIGINT", onInterrupt);
|
|
29
|
+
});
|
|
30
|
+
try {
|
|
31
|
+
return await Promise.race([rl.question(text), cancelled]);
|
|
32
|
+
} finally {
|
|
33
|
+
rl.off("SIGINT", onInterrupt);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function confirm(message, opts) {
|
|
37
|
+
if (process.stdin.isTTY !== true) throw needsConfirmation(message, opts.refusal);
|
|
38
|
+
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
39
|
+
try {
|
|
40
|
+
const onClose = () => settle(null);
|
|
41
|
+
const onInterrupt = () => settle(CANCELLED);
|
|
42
|
+
let settle;
|
|
43
|
+
const answer = await new Promise((resolve) => {
|
|
44
|
+
settle = resolve;
|
|
45
|
+
rl.once("close", onClose);
|
|
46
|
+
rl.once("SIGINT", onInterrupt);
|
|
47
|
+
rl.question(terminalText(`${style.yellow("?")} ${message} (y/N) `), resolve);
|
|
48
|
+
}).finally(() => {
|
|
49
|
+
rl.off("close", onClose);
|
|
50
|
+
rl.off("SIGINT", onInterrupt);
|
|
51
|
+
});
|
|
52
|
+
if (answer === CANCELLED) {
|
|
53
|
+
process.stderr.write("\n");
|
|
54
|
+
throw promptCancelled();
|
|
55
|
+
}
|
|
56
|
+
if (answer === null) {
|
|
57
|
+
process.stderr.write("\n");
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
return /^y(es)?$/i.test(answer.trim());
|
|
61
|
+
} finally {
|
|
62
|
+
rl.close();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function needsConfirmation(message, refusal, lead = "Cannot ask for confirmation: stdin is not a terminal.") {
|
|
66
|
+
const text = `${lead} It would have asked: ${message.trim()}
|
|
67
|
+
Re-run as \`${refusal.rerun}\` to answer yes without being asked.${refusal.note ?? ""}`;
|
|
68
|
+
return new CliError("SDK_USAGE", text, {
|
|
69
|
+
exitCode: 1,
|
|
70
|
+
details: { reason: "needs-confirmation", ...refusal.details }
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
var MAX_EMPTY_ANSWERS = 3;
|
|
74
|
+
async function promptLine(message, opts) {
|
|
75
|
+
if (process.stdin.isTTY !== true) {
|
|
76
|
+
throw new UsageError(`Cannot prompt: stdin is not a terminal. ${opts.noTtyHint}`);
|
|
77
|
+
}
|
|
78
|
+
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
79
|
+
if (opts.mask === true) {
|
|
80
|
+
const iface = rl;
|
|
81
|
+
let atPrompt = false;
|
|
82
|
+
iface._writeToOutput = (chunk) => {
|
|
83
|
+
if (!atPrompt) {
|
|
84
|
+
process.stderr.write(chunk);
|
|
85
|
+
atPrompt = true;
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (chunk.includes("\n")) {
|
|
89
|
+
process.stderr.write("\n");
|
|
90
|
+
atPrompt = false;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
for (let attempt = 0; attempt < MAX_EMPTY_ANSWERS; attempt++) {
|
|
96
|
+
const onClose = () => settle(null);
|
|
97
|
+
const onInterrupt = () => settle(CANCELLED);
|
|
98
|
+
let settle;
|
|
99
|
+
const answer = await new Promise((resolve) => {
|
|
100
|
+
settle = resolve;
|
|
101
|
+
rl.once("close", onClose);
|
|
102
|
+
rl.once("SIGINT", onInterrupt);
|
|
103
|
+
rl.question(terminalText(`${style.yellow("?")} ${message} `), resolve);
|
|
104
|
+
}).finally(() => {
|
|
105
|
+
rl.off("close", onClose);
|
|
106
|
+
rl.off("SIGINT", onInterrupt);
|
|
107
|
+
});
|
|
108
|
+
if (answer === CANCELLED) {
|
|
109
|
+
process.stderr.write("\n");
|
|
110
|
+
throw promptCancelled();
|
|
111
|
+
}
|
|
112
|
+
if (answer === null) throw new UsageError(`Input ended before an answer arrived. ${opts.noTtyHint}`);
|
|
113
|
+
const trimmed = answer.trim();
|
|
114
|
+
if (trimmed !== "") return trimmed;
|
|
115
|
+
process.stderr.write(terminalText(`${style.yellow("!")} A value is required.
|
|
116
|
+
`));
|
|
117
|
+
}
|
|
118
|
+
throw new UsageError(`No value entered. ${opts.noTtyHint}`);
|
|
119
|
+
} finally {
|
|
120
|
+
rl.close();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
var STDIN_IDLE_MS = 3e4;
|
|
124
|
+
async function readStdin() {
|
|
125
|
+
const stdin = process.stdin;
|
|
126
|
+
if (stdin.isTTY === true) return void 0;
|
|
127
|
+
return new Promise((resolve, reject) => {
|
|
128
|
+
const chunks = [];
|
|
129
|
+
let timer;
|
|
130
|
+
const done = () => {
|
|
131
|
+
clearTimeout(timer);
|
|
132
|
+
stdin.off("data", onData);
|
|
133
|
+
stdin.off("end", onEnd);
|
|
134
|
+
stdin.off("error", onError);
|
|
135
|
+
};
|
|
136
|
+
const onIdle = () => {
|
|
137
|
+
done();
|
|
138
|
+
stdin.pause();
|
|
139
|
+
reject(
|
|
140
|
+
new UsageError(
|
|
141
|
+
`stdin is not a terminal, and nothing arrived on it for ${STDIN_IDLE_MS / 1e3}s. Pipe the value in (\`printf %s "$VALUE" | xanosdk \u2026\`), or close stdin (\`</dev/null\`) when there is none.`
|
|
142
|
+
)
|
|
143
|
+
);
|
|
144
|
+
};
|
|
145
|
+
const arm = () => {
|
|
146
|
+
clearTimeout(timer);
|
|
147
|
+
timer = setTimeout(onIdle, STDIN_IDLE_MS);
|
|
148
|
+
};
|
|
149
|
+
const onData = (chunk) => {
|
|
150
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
151
|
+
arm();
|
|
152
|
+
};
|
|
153
|
+
const onEnd = () => {
|
|
154
|
+
done();
|
|
155
|
+
resolve(Buffer.concat(chunks).toString("utf8"));
|
|
156
|
+
};
|
|
157
|
+
const onError = (err) => {
|
|
158
|
+
done();
|
|
159
|
+
reject(err);
|
|
160
|
+
};
|
|
161
|
+
stdin.on("data", onData);
|
|
162
|
+
stdin.once("end", onEnd);
|
|
163
|
+
stdin.once("error", onError);
|
|
164
|
+
arm();
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export {
|
|
169
|
+
promptCancelled,
|
|
170
|
+
questionOrCancel,
|
|
171
|
+
confirm,
|
|
172
|
+
needsConfirmation,
|
|
173
|
+
promptLine,
|
|
174
|
+
STDIN_IDLE_MS,
|
|
175
|
+
readStdin
|
|
176
|
+
};
|
|
177
|
+
//# sourceMappingURL=chunk-65HWOMGV.js.map
|