@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,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
XANO_DIR
|
|
3
|
+
} from "./chunk-AHJWCYQO.js";
|
|
4
|
+
import {
|
|
5
|
+
projectRootFrom
|
|
6
|
+
} from "./chunk-ROY4YAEQ.js";
|
|
7
|
+
import {
|
|
8
|
+
relForwardSlash
|
|
9
|
+
} from "./chunk-PTHVMXZI.js";
|
|
10
|
+
|
|
11
|
+
// src/emit/backend-dir.ts
|
|
12
|
+
import { existsSync, readdirSync } from "fs";
|
|
13
|
+
import { basename, dirname, join, resolve } from "path";
|
|
14
|
+
var DECODE_MARKER = ".xanosdk-codegen.json";
|
|
15
|
+
function backendDirFor(entryFile) {
|
|
16
|
+
const dir = dirname(resolve(entryFile));
|
|
17
|
+
const root = projectRootFrom(dir);
|
|
18
|
+
for (let at = dir; ; at = dirname(at)) {
|
|
19
|
+
if (existsSync(join(at, DECODE_MARKER))) return at;
|
|
20
|
+
if (at === root || dirname(at) === at || !at.startsWith(root)) break;
|
|
21
|
+
}
|
|
22
|
+
const nested = nestedBackendDir(dir, root);
|
|
23
|
+
if (nested !== void 0) return nested;
|
|
24
|
+
const top = relForwardSlash(root, dir).split("/")[0] ?? "";
|
|
25
|
+
return join(root, top === "" ? XANO_DIR : top);
|
|
26
|
+
}
|
|
27
|
+
function nestedBackendDir(dir, root) {
|
|
28
|
+
const rel = relForwardSlash(root, dir);
|
|
29
|
+
if (rel === "" || !rel.includes("/")) return void 0;
|
|
30
|
+
const ancestors = [];
|
|
31
|
+
for (let at = dir; at !== root && dirname(at) !== at; at = dirname(at)) ancestors.push(at);
|
|
32
|
+
return ancestors.find((at) => basename(at) === XANO_DIR) ?? ancestors.find((at) => existsSync(join(at, "xano.lock"))) ?? dir;
|
|
33
|
+
}
|
|
34
|
+
function backendDirIn(projectRoot) {
|
|
35
|
+
const root = resolve(projectRoot);
|
|
36
|
+
const scaffolded = join(root, XANO_DIR);
|
|
37
|
+
if (existsSync(scaffolded)) return scaffolded;
|
|
38
|
+
let found;
|
|
39
|
+
let entries;
|
|
40
|
+
try {
|
|
41
|
+
entries = readdirSync(root, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
|
|
42
|
+
} catch {
|
|
43
|
+
return scaffolded;
|
|
44
|
+
}
|
|
45
|
+
for (const name of entries) {
|
|
46
|
+
if (name === "node_modules" || name.startsWith(".")) continue;
|
|
47
|
+
const dir = join(root, name);
|
|
48
|
+
if (!existsSync(join(dir, "xano.lock")) || !existsSync(join(dir, "index.ts"))) continue;
|
|
49
|
+
if (found !== void 0) return scaffolded;
|
|
50
|
+
found = dir;
|
|
51
|
+
}
|
|
52
|
+
return found ?? scaffolded;
|
|
53
|
+
}
|
|
54
|
+
function resolveBackendDir(cwd, dir, refuse) {
|
|
55
|
+
if (dir === void 0) return relForwardSlash(cwd, backendDirIn(cwd)) || XANO_DIR;
|
|
56
|
+
const rel = relForwardSlash(cwd, resolve(cwd, dir));
|
|
57
|
+
if (rel === "") {
|
|
58
|
+
throw refuse(
|
|
59
|
+
`--backend-dir must name a directory inside this project, and "${dir}" is not one.`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
return rel;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export {
|
|
66
|
+
backendDirFor,
|
|
67
|
+
backendDirIn,
|
|
68
|
+
resolveBackendDir
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=chunk-5A2PLKZB.js.map
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import {
|
|
2
|
+
atomicWrite
|
|
3
|
+
} from "./chunk-LLNZGEFK.js";
|
|
4
|
+
import {
|
|
5
|
+
assertValidProfileName
|
|
6
|
+
} from "./chunk-QXTKSOFI.js";
|
|
7
|
+
import {
|
|
8
|
+
UsageError
|
|
9
|
+
} from "./chunk-PTHVMXZI.js";
|
|
10
|
+
import {
|
|
11
|
+
shellQuote
|
|
12
|
+
} from "./chunk-5ZSO4T2G.js";
|
|
13
|
+
|
|
14
|
+
// src/auth/profile-pointer.ts
|
|
15
|
+
import { existsSync, readFileSync } from "fs";
|
|
16
|
+
import { dirname, join, resolve } from "path";
|
|
17
|
+
import { homedir } from "os";
|
|
18
|
+
var POINTER_FILE = "xano.profile.json";
|
|
19
|
+
var TOKEN_BEARING = [
|
|
20
|
+
"access_token",
|
|
21
|
+
"refresh_token",
|
|
22
|
+
"meta_api_token",
|
|
23
|
+
"token",
|
|
24
|
+
"secret",
|
|
25
|
+
"client_secret",
|
|
26
|
+
"password",
|
|
27
|
+
"api_key",
|
|
28
|
+
"apikey",
|
|
29
|
+
"authorization",
|
|
30
|
+
"bearer",
|
|
31
|
+
"access_key",
|
|
32
|
+
"private_key"
|
|
33
|
+
];
|
|
34
|
+
var MAX_SCAN_DEPTH = 6;
|
|
35
|
+
function leakedKeys(value, path = [], depth = 0) {
|
|
36
|
+
if (depth > MAX_SCAN_DEPTH || typeof value !== "object" || value === null) return [];
|
|
37
|
+
if (Array.isArray(value)) {
|
|
38
|
+
return value.flatMap((item, i) => leakedKeys(item, [...path, String(i)], depth + 1));
|
|
39
|
+
}
|
|
40
|
+
return Object.entries(value).flatMap(([key, child]) => {
|
|
41
|
+
const here = [...path, key];
|
|
42
|
+
if (TOKEN_BEARING.includes(key.toLowerCase())) return [here.join(".")];
|
|
43
|
+
return leakedKeys(child, here, depth + 1);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function findPointerFile(startDir) {
|
|
47
|
+
return walkUp(startDir).pointer;
|
|
48
|
+
}
|
|
49
|
+
function walkUp(startDir) {
|
|
50
|
+
const start = resolve(startDir);
|
|
51
|
+
const home = resolve(homedir());
|
|
52
|
+
let dir = start;
|
|
53
|
+
for (; ; ) {
|
|
54
|
+
const candidate = join(dir, POINTER_FILE);
|
|
55
|
+
if (existsSync(candidate)) return { pointer: candidate, root: dir, bounded: true };
|
|
56
|
+
if (existsSync(join(dir, "package.json"))) return { root: dir, bounded: true };
|
|
57
|
+
if (existsSync(join(dir, ".git"))) return { root: dir, bounded: true };
|
|
58
|
+
const parent = dirname(dir);
|
|
59
|
+
if (parent === dir || dir === home) return { root: start, bounded: false };
|
|
60
|
+
dir = parent;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function readPointerFile(path) {
|
|
64
|
+
let text;
|
|
65
|
+
try {
|
|
66
|
+
text = readFileSync(path, "utf8").replace(/^\uFEFF/, "");
|
|
67
|
+
} catch (err) {
|
|
68
|
+
throw pointerFsFailure(err, path, "read");
|
|
69
|
+
}
|
|
70
|
+
let parsed;
|
|
71
|
+
try {
|
|
72
|
+
parsed = JSON.parse(text);
|
|
73
|
+
} catch {
|
|
74
|
+
throw new UsageError(
|
|
75
|
+
`${path} is not valid JSON. It names the credential profile this project uses, e.g. {"profile": "prod"} \u2014 or delete it to fall back to the default profile.`
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
79
|
+
throw pointerWithoutProfile(path, `holds ${jsonKind(parsed)}, not an object`);
|
|
80
|
+
}
|
|
81
|
+
const record = parsed;
|
|
82
|
+
const leaked = leakedKeys(record);
|
|
83
|
+
if (leaked.length > 0) {
|
|
84
|
+
throw new Error(
|
|
85
|
+
`${path} contains ${leaked.map((k) => `\`${k}\``).join(", ")}. This file is committed to version control and must never hold credentials \u2014 it names a profile and nothing else. Remove ${leaked.length === 1 ? "that key" : "those keys"}, and treat the value as leaked: run \`xanosdk logout\` for the affected profile and sign in again.`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
const name = record.profile;
|
|
89
|
+
if (name === void 0) throw pointerWithoutProfile(path, "has no `profile` key");
|
|
90
|
+
if (typeof name !== "string") {
|
|
91
|
+
throw pointerWithoutProfile(path, `has a \`profile\` that is ${jsonKind(name)}, not a name`);
|
|
92
|
+
}
|
|
93
|
+
assertValidProfileName(name, path);
|
|
94
|
+
return name;
|
|
95
|
+
}
|
|
96
|
+
function jsonKind(value) {
|
|
97
|
+
if (value === null) return "null";
|
|
98
|
+
if (Array.isArray(value)) return "an array";
|
|
99
|
+
return typeof value === "object" ? "an object" : `a ${typeof value}`;
|
|
100
|
+
}
|
|
101
|
+
function pointerWithoutProfile(path, what) {
|
|
102
|
+
return new UsageError(
|
|
103
|
+
`${path} ${what}. It names the credential profile this project uses, e.g. {"profile": "prod"} \u2014 rewrite it with \`xanosdk profile use <name>\`, or delete it to fall back to the default profile.`
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
function resolveProjectProfile(startDir) {
|
|
107
|
+
return findProjectPointer(startDir)?.profile;
|
|
108
|
+
}
|
|
109
|
+
function findProjectPointer(startDir) {
|
|
110
|
+
const path = findPointerFile(startDir);
|
|
111
|
+
if (path === void 0) return void 0;
|
|
112
|
+
return { path, profile: readPointerFile(path) };
|
|
113
|
+
}
|
|
114
|
+
function writePointerFile(dir, profile) {
|
|
115
|
+
assertValidProfileName(profile);
|
|
116
|
+
const path = join(resolve(dir), POINTER_FILE);
|
|
117
|
+
try {
|
|
118
|
+
atomicWrite(path, JSON.stringify({ profile }, null, 2) + "\n");
|
|
119
|
+
} catch (err) {
|
|
120
|
+
throw pointerFsFailure(err, path, "write");
|
|
121
|
+
}
|
|
122
|
+
return path;
|
|
123
|
+
}
|
|
124
|
+
function pointerFsFailure(err, path, op) {
|
|
125
|
+
const code = err?.code;
|
|
126
|
+
const pin = `It holds the project's profile pin, e.g. {"profile": "prod"}`;
|
|
127
|
+
switch (code) {
|
|
128
|
+
case "EISDIR":
|
|
129
|
+
return new UsageError(`${path} is a directory, not a file. ${pin}: remove or rename the directory, then run the command again.`);
|
|
130
|
+
case "ELOOP":
|
|
131
|
+
return new UsageError(`${path} is a symbolic link that loops back on itself (ELOOP). ${pin}: point it at a real file or remove it, then run the command again.`);
|
|
132
|
+
case "EACCES":
|
|
133
|
+
case "EPERM":
|
|
134
|
+
case "EROFS":
|
|
135
|
+
if (op === "read") return new UsageError(`${path} cannot be read by this user (${code}). Restore access with \`chmod u+r ${shellQuote(path)}\`, then run the command again.`);
|
|
136
|
+
return new UsageError(`${path} cannot be written: ${dirname(path)} is not writable here (${code}). Make it writable, then run the command again.`);
|
|
137
|
+
default:
|
|
138
|
+
return err;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function pointerRootFor(startDir) {
|
|
142
|
+
return walkUp(startDir).root;
|
|
143
|
+
}
|
|
144
|
+
function projectRootFor(startDir) {
|
|
145
|
+
const { root, bounded } = walkUp(startDir);
|
|
146
|
+
return bounded && resolve(root) !== resolve(homedir()) ? root : void 0;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export {
|
|
150
|
+
POINTER_FILE,
|
|
151
|
+
findPointerFile,
|
|
152
|
+
readPointerFile,
|
|
153
|
+
resolveProjectProfile,
|
|
154
|
+
findProjectPointer,
|
|
155
|
+
writePointerFile,
|
|
156
|
+
pointerRootFor,
|
|
157
|
+
projectRootFor
|
|
158
|
+
};
|
|
159
|
+
//# sourceMappingURL=chunk-5FBYXK5P.js.map
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import {
|
|
2
|
+
scanSource
|
|
3
|
+
} from "./chunk-VAX3UZOY.js";
|
|
4
|
+
|
|
5
|
+
// src/emit/register-calls.ts
|
|
6
|
+
function withoutComments(src) {
|
|
7
|
+
let spans;
|
|
8
|
+
try {
|
|
9
|
+
spans = scanSource(src).spans;
|
|
10
|
+
} catch {
|
|
11
|
+
return src;
|
|
12
|
+
}
|
|
13
|
+
const out = src.split("");
|
|
14
|
+
for (const { kind, start, end } of spans) {
|
|
15
|
+
if (kind !== "comment") continue;
|
|
16
|
+
for (let i = start; i < end; i++) if (out[i] !== "\n") out[i] = " ";
|
|
17
|
+
}
|
|
18
|
+
return out.join("");
|
|
19
|
+
}
|
|
20
|
+
function literal(name) {
|
|
21
|
+
return name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
22
|
+
}
|
|
23
|
+
function importsOf(code) {
|
|
24
|
+
const clause = `((?:(?!\\bfrom\\s*["'\`]|\\bimport\\b)[^;])*?)`;
|
|
25
|
+
const imports = new RegExp(
|
|
26
|
+
`(?<![\\w$.])import\\s+(?!type\\s*[{*]|type\\s+(?!from\\b)[\\w$])${clause}\\s*from\\s*(["'\`])([^"'\`\\n]+)\\2`,
|
|
27
|
+
"g"
|
|
28
|
+
);
|
|
29
|
+
const out = [];
|
|
30
|
+
for (const match of code.matchAll(imports)) {
|
|
31
|
+
const bound = match[1].trim();
|
|
32
|
+
const named = [];
|
|
33
|
+
const owners = [];
|
|
34
|
+
const brace = /\{([^}]*)\}/.exec(bound);
|
|
35
|
+
if (brace !== null) {
|
|
36
|
+
for (const part of brace[1].split(",")) {
|
|
37
|
+
const spec = /^\s*(type\s+)?([\w$]+|"[^"]*"|'[^']*')\s*(?:as\s+([\w$]+))?\s*$/.exec(part);
|
|
38
|
+
if (spec === null || spec[1] !== void 0) continue;
|
|
39
|
+
const imported = spec[2].replace(/^["']|["']$/g, "");
|
|
40
|
+
const local = spec[3] ?? imported;
|
|
41
|
+
if (imported === "default") owners.push(local);
|
|
42
|
+
else named.push({ imported, local });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const namespace = /\*\s*as\s+([\w$]+)/.exec(bound);
|
|
46
|
+
if (namespace !== null) owners.push(namespace[1]);
|
|
47
|
+
const head = /^([\w$]+)\s*(?:,|$)/.exec(bound);
|
|
48
|
+
if (head !== null) owners.push(head[1]);
|
|
49
|
+
out.push({ specifier: match[3], named, owners, start: match.index, end: match.index + match[0].length });
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
function codeOnly(code) {
|
|
54
|
+
try {
|
|
55
|
+
return scanSource(code).mask;
|
|
56
|
+
} catch {
|
|
57
|
+
return code;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function isPackage(specifier, pkg) {
|
|
61
|
+
return specifier === pkg || specifier.startsWith(`${pkg}/`);
|
|
62
|
+
}
|
|
63
|
+
function callsAny(mask, direct, owners, register) {
|
|
64
|
+
const out = { top: false, wrappers: [], opaque: false };
|
|
65
|
+
const alternatives = [
|
|
66
|
+
...direct.length > 0 ? [`(${direct.map(literal).join("|")})`] : [],
|
|
67
|
+
...owners.length > 0 ? [`(${owners.map(literal).join("|")})\\s*\\??\\.\\s*${literal(register)}`] : []
|
|
68
|
+
];
|
|
69
|
+
if (alternatives.length === 0) return out;
|
|
70
|
+
const concise = conciseBodies(mask);
|
|
71
|
+
const exported = exportedWorkspace(mask);
|
|
72
|
+
for (const m of mask.matchAll(new RegExp(`(?<![\\w$.])(?:${alternatives.join("|")})\\s*(?:\\?\\.\\s*)?\\(`, "g"))) {
|
|
73
|
+
const name = m[1] ?? m[2];
|
|
74
|
+
const scopes = enclosingScopes(mask, m.index, concise);
|
|
75
|
+
let shadowed = false;
|
|
76
|
+
let wrapper;
|
|
77
|
+
const params = [];
|
|
78
|
+
for (let k = scopes.length - 1; k >= 0; k--) {
|
|
79
|
+
const header = scopes[k].header;
|
|
80
|
+
if (header === void 0) continue;
|
|
81
|
+
if (header.params.includes(name)) {
|
|
82
|
+
shadowed = true;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
params.push(...header.params);
|
|
86
|
+
if (k === 0 && header.name !== void 0) wrapper = header.name;
|
|
87
|
+
}
|
|
88
|
+
if (shadowed) continue;
|
|
89
|
+
const target = workspaceArgument(mask, m.index + m[0].length, exported, params);
|
|
90
|
+
if (target === "other") continue;
|
|
91
|
+
if (target === "unknown") out.opaque = true;
|
|
92
|
+
else if (scopes.length === 0) out.top = true;
|
|
93
|
+
else if (wrapper !== void 0) out.wrappers.push(wrapper);
|
|
94
|
+
else out.opaque = true;
|
|
95
|
+
}
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
function exportedWorkspace(mask) {
|
|
99
|
+
const named = /(?<![\w$.])export\s+default\s+(?!function\b|class\b|async\b|new\b)([\w$]+)\s*(?:;|$)/m.exec(mask) ?? /(?<![\w$.])export\s*\{[^}]*?(?<![\w$])([\w$]+)\s+as\s+default\b/.exec(mask);
|
|
100
|
+
if (named !== null) return { name: named[1] };
|
|
101
|
+
if (/(?<![\w$.])export\s+default\s+workspace\s*\(/.test(mask)) return "fresh";
|
|
102
|
+
return void 0;
|
|
103
|
+
}
|
|
104
|
+
function workspaceArgument(mask, at, exported, params) {
|
|
105
|
+
if (exported === void 0) return "same";
|
|
106
|
+
const arg = /^\s*([\w$]+)\s*[,)]/.exec(mask.slice(at))?.[1];
|
|
107
|
+
if (arg === void 0) return "same";
|
|
108
|
+
if (exported !== "fresh" && arg === exported.name) return "same";
|
|
109
|
+
if (params.includes(arg)) return "same";
|
|
110
|
+
const created = new RegExp(`(?<![\\w$])(?:const|let|var)\\s+${literal(arg)}\\s*(?::[^=]*)?=\\s*workspace\\s*\\(`).test(mask);
|
|
111
|
+
return created ? "other" : "unknown";
|
|
112
|
+
}
|
|
113
|
+
function conciseBodies(mask) {
|
|
114
|
+
const out = [];
|
|
115
|
+
for (const m of mask.matchAll(/=>/g)) {
|
|
116
|
+
let start = m.index + 2;
|
|
117
|
+
while (start < mask.length && /\s/.test(mask[start])) start++;
|
|
118
|
+
if (mask[start] === "{") continue;
|
|
119
|
+
let depth = 0;
|
|
120
|
+
let end = start;
|
|
121
|
+
for (; end < mask.length; end++) {
|
|
122
|
+
const c = mask[end];
|
|
123
|
+
if (c === "(" || c === "[" || c === "{") depth++;
|
|
124
|
+
else if (c === ")" || c === "]" || c === "}") {
|
|
125
|
+
if (depth === 0) break;
|
|
126
|
+
depth--;
|
|
127
|
+
} else if (depth === 0 && (c === "," || c === ";")) break;
|
|
128
|
+
else if (depth === 0 && c === "\n") {
|
|
129
|
+
const last = /(\S)\s*$/.exec(mask.slice(start, end))?.[1];
|
|
130
|
+
const next = /^\s*(\S)/.exec(mask.slice(end))?.[1];
|
|
131
|
+
const continued = last !== void 0 && /[=+\-*/%&|^!?:<>.~]/.test(last) || next !== void 0 && /[.?+\-*/%&|^:=<>]/.test(next);
|
|
132
|
+
if (!continued) break;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
out.push({ start, end, header: functionHeader(mask.slice(Math.max(0, m.index - 500), m.index + 2)) });
|
|
136
|
+
}
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
function enclosingScopes(mask, at, concise) {
|
|
140
|
+
const scopes = openBraces(mask, at).map((b) => ({ start: b, header: functionHeader(mask.slice(Math.max(0, b - 500), b)) }));
|
|
141
|
+
for (const body of concise) if (body.start <= at && at < body.end) scopes.push({ start: body.start, header: body.header });
|
|
142
|
+
return scopes.sort((a, b) => a.start - b.start);
|
|
143
|
+
}
|
|
144
|
+
function openBraces(mask, at) {
|
|
145
|
+
const open = [];
|
|
146
|
+
for (let i = 0; i < at; i++) {
|
|
147
|
+
const c = mask[i];
|
|
148
|
+
if (c === "{") open.push(i);
|
|
149
|
+
else if (c === "}") open.pop();
|
|
150
|
+
}
|
|
151
|
+
return open;
|
|
152
|
+
}
|
|
153
|
+
function functionHeader(before) {
|
|
154
|
+
const declared = /(?<![\w$.])function\s*\*?\s*([\w$]+)?\s*(?:<[^>]*>)?\s*\(([^()]*)\)\s*(?::[^{}]*)?$/.exec(before);
|
|
155
|
+
const arrow = declared === null ? /(?:(?<![\w$])(?:const|let|var)\s+([\w$]+)\s*(?::[^=]*)?=\s*)?(?:async\s*)?(?:\(([^()]*)\)|([\w$]+))\s*(?::[^=]*)?=>\s*$/.exec(before) : null;
|
|
156
|
+
const m = declared ?? arrow;
|
|
157
|
+
if (m === null) return void 0;
|
|
158
|
+
let name = m[1];
|
|
159
|
+
if (declared !== null && name === void 0) {
|
|
160
|
+
name = /(?<![\w$])(?:const|let|var)\s+([\w$]+)\s*(?::[^=]*)?=\s*(?:async\s+)?function\s*\*?\s*(?:<[^>]*>)?\s*\([^()]*\)\s*(?::[^{}]*)?$/.exec(before)?.[1];
|
|
161
|
+
}
|
|
162
|
+
const list = m[2] ?? m[3] ?? "";
|
|
163
|
+
const params = [...list.replace(/:[^,=]*/g, "").matchAll(/[\w$]+/g)].map((p) => p[0]);
|
|
164
|
+
return { ...name === void 0 ? {} : { name }, params };
|
|
165
|
+
}
|
|
166
|
+
function callsAtTop(mask, names) {
|
|
167
|
+
if (names.length === 0) return false;
|
|
168
|
+
const concise = conciseBodies(mask);
|
|
169
|
+
for (const m of mask.matchAll(new RegExp(`(?<![\\w$.])(?:${names.map(literal).join("|")})\\s*\\(`, "g"))) {
|
|
170
|
+
if (/(?<![\w$])function\s*\*?\s*$/.test(mask.slice(Math.max(0, m.index - 30), m.index))) continue;
|
|
171
|
+
if (enclosingScopes(mask, m.index, concise).length === 0) return true;
|
|
172
|
+
}
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
function registerWrappers(code, pkg, register) {
|
|
176
|
+
return registerRead(code, pkg, register).wrappers;
|
|
177
|
+
}
|
|
178
|
+
function callsImportedAtTop(code, names) {
|
|
179
|
+
const locals = [];
|
|
180
|
+
for (const imp of importsOf(withoutComments(code))) {
|
|
181
|
+
if (!/^[./]/.test(imp.specifier)) continue;
|
|
182
|
+
for (const n of imp.named) if (names.includes(n.imported)) locals.push(n.local);
|
|
183
|
+
}
|
|
184
|
+
return callsAtTop(codeOnly(code), locals);
|
|
185
|
+
}
|
|
186
|
+
function destructured(pattern, register) {
|
|
187
|
+
for (const part of pattern.split(",")) {
|
|
188
|
+
const m = /^\s*([\w$]+)\s*(?::\s*([\w$]+))?\s*(?:=[^,]*)?$/.exec(part);
|
|
189
|
+
if (m !== null && m[1] === register) return m[2] ?? m[1];
|
|
190
|
+
}
|
|
191
|
+
return void 0;
|
|
192
|
+
}
|
|
193
|
+
function stringAt(code, at) {
|
|
194
|
+
const m = /^\s*(["'`])([^"'`\n\\$]*)\1/.exec(code.slice(at));
|
|
195
|
+
return m === null ? void 0 : { value: m[2], end: at + m[0].length };
|
|
196
|
+
}
|
|
197
|
+
function registerState(code, pkg, register) {
|
|
198
|
+
return registerRead(code, pkg, register).state;
|
|
199
|
+
}
|
|
200
|
+
function registerRead(code, pkg, register) {
|
|
201
|
+
const mask = codeOnly(code);
|
|
202
|
+
const direct = [];
|
|
203
|
+
const owners = [];
|
|
204
|
+
let unknown = false;
|
|
205
|
+
const importSpans = [];
|
|
206
|
+
for (const imp of importsOf(code)) {
|
|
207
|
+
if (!isPackage(imp.specifier, pkg)) continue;
|
|
208
|
+
for (const n of imp.named) if (n.imported === register) direct.push(n.local);
|
|
209
|
+
owners.push(...imp.owners);
|
|
210
|
+
importSpans.push([imp.start, imp.end]);
|
|
211
|
+
}
|
|
212
|
+
for (const m of mask.matchAll(/(?<![\w$.])import\s*\(/g)) {
|
|
213
|
+
const spec = stringAt(code, m.index + m[0].length);
|
|
214
|
+
if (spec === void 0 || !isPackage(spec.value, pkg)) continue;
|
|
215
|
+
const close = /^\s*\)/.exec(code.slice(spec.end));
|
|
216
|
+
if (close === null) {
|
|
217
|
+
unknown = true;
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
const after = spec.end + close[0].length;
|
|
221
|
+
const before = mask.slice(Math.max(0, m.index - 2e3), m.index);
|
|
222
|
+
const bound = /(?<![\w$])(?:const|let|var)(?:\s*\{([^}]*)\}|\s+([\w$]+))\s*=\s*(?:await\s+)?$/.exec(before);
|
|
223
|
+
if (bound !== null) {
|
|
224
|
+
if (bound[1] !== void 0) {
|
|
225
|
+
const local = destructured(bound[1], register);
|
|
226
|
+
if (local !== void 0) direct.push(local);
|
|
227
|
+
} else owners.push(bound[2]);
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
const member = new RegExp(`^\\s*\\)\\s*\\??\\.\\s*${literal(register)}\\s*(?:\\?\\.\\s*)?\\(`).exec(mask.slice(after));
|
|
231
|
+
if (/\(\s*await\s+$/.test(before) && member !== null) return { state: "yes", wrappers: [] };
|
|
232
|
+
unknown = true;
|
|
233
|
+
}
|
|
234
|
+
const reexport = new RegExp(`(?<![\\w$.])export\\s*(\\*|\\{[^}]*\\})[^;]*?\\bfrom\\s*(["'\`])([^"'\`\\n]+)\\2`, "g");
|
|
235
|
+
for (const m of code.matchAll(reexport)) {
|
|
236
|
+
if (isPackage(m[3], pkg) && (m[1] === "*" || new RegExp(`(?<![\\w$])${literal(register)}(?![\\w$])`).test(m[1]))) unknown = true;
|
|
237
|
+
}
|
|
238
|
+
for (const owner of owners) {
|
|
239
|
+
for (const m of mask.matchAll(new RegExp(`(?<![\\w$.])${literal(owner)}(?![\\w$])`, "g"))) {
|
|
240
|
+
if (importSpans.some(([s, e]) => m.index >= s && m.index < e)) continue;
|
|
241
|
+
const end = m.index + owner.length;
|
|
242
|
+
const rest = mask.slice(end);
|
|
243
|
+
const before = mask.slice(Math.max(0, m.index - 2e3), m.index);
|
|
244
|
+
if (/(?<![\w$])(?:const|let|var)\s+$/.test(before) && /^\s*=(?!=)/.test(rest)) continue;
|
|
245
|
+
if (/^\s*\??\.\s*[\w$]/.test(rest)) {
|
|
246
|
+
const alias = new RegExp(`(?<![\\w$])(?:const|let|var)\\s+([\\w$]+)\\s*=\\s*$`).exec(before);
|
|
247
|
+
if (alias !== null && new RegExp(`^\\s*\\??\\.\\s*${literal(register)}(?![\\w$])(?!\\s*[(?.[])`).test(rest)) direct.push(alias[1]);
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
const bracket = /^\s*(?:\?\.\s*)?\[/.exec(rest);
|
|
251
|
+
if (bracket !== null) {
|
|
252
|
+
const key = stringAt(code, end + bracket[0].length);
|
|
253
|
+
if (key === void 0 || !/^\s*\]/.test(code.slice(key.end))) {
|
|
254
|
+
unknown = true;
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
if (key.value !== register) continue;
|
|
258
|
+
const tail = mask.slice(key.end).replace(/^\s*\]/, "");
|
|
259
|
+
if (/^\s*(?:\?\.\s*)?\(/.test(tail)) return { state: "yes", wrappers: [] };
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
const pattern = /(?<![\w$])(?:const|let|var)\s*\{([^}]*)\}\s*=\s*$/.exec(before);
|
|
263
|
+
if (pattern !== null) {
|
|
264
|
+
const local = destructured(pattern[1], register);
|
|
265
|
+
if (local !== void 0) direct.push(local);
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
if (/^\s*\??\.\s*\(/.test(rest)) continue;
|
|
269
|
+
unknown = true;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
for (const local of direct) {
|
|
273
|
+
for (const m of mask.matchAll(new RegExp(`(?<![\\w$.])${literal(local)}(?![\\w$])`, "g"))) {
|
|
274
|
+
if (importSpans.some(([s, e]) => m.index >= s && m.index < e)) continue;
|
|
275
|
+
const rest = mask.slice(m.index + local.length);
|
|
276
|
+
if (/^\s*(?:\?\.\s*)?\(/.test(rest)) continue;
|
|
277
|
+
const before = mask.slice(Math.max(0, m.index - 2e3), m.index);
|
|
278
|
+
if (/(?<![\w$])(?:const|let|var)\s+$/.test(before) || /(?<![\w$])(?:const|let|var)\s*\{[^}]*$/.test(before)) continue;
|
|
279
|
+
if (/(?<![\w$.])function\s*\*?\s*[\w$]*\s*(?:<[^>]*>)?\s*\([^()]*$/.test(before)) continue;
|
|
280
|
+
if (/\([^()]*$/.test(before) && /^[^()]*\)\s*(?::[^=]*)?=>/.test(rest)) continue;
|
|
281
|
+
unknown = true;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
const calls = callsAny(mask, direct, owners, register);
|
|
285
|
+
if (calls.top || callsAtTop(mask, calls.wrappers)) return { state: "yes", wrappers: [] };
|
|
286
|
+
const nested = calls.opaque || calls.wrappers.length > 0;
|
|
287
|
+
return { state: unknown || nested ? "unknown" : "no", wrappers: [...new Set(calls.wrappers)] };
|
|
288
|
+
}
|
|
289
|
+
function callsRegister(code, pkg, register) {
|
|
290
|
+
return registerState(code, pkg, register) === "yes";
|
|
291
|
+
}
|
|
292
|
+
function packageOf(specifier) {
|
|
293
|
+
const parts = specifier.split("/");
|
|
294
|
+
return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
|
|
295
|
+
}
|
|
296
|
+
function registeredModules(code) {
|
|
297
|
+
const mask = codeOnly(code);
|
|
298
|
+
const found = /* @__PURE__ */ new Map();
|
|
299
|
+
for (const imp of importsOf(code)) {
|
|
300
|
+
if (/^[./]/.test(imp.specifier) || /^[a-z]+:/i.test(imp.specifier)) continue;
|
|
301
|
+
const pkg = packageOf(imp.specifier);
|
|
302
|
+
if (pkg === "@xano/sdk") continue;
|
|
303
|
+
const candidates = new Set(imp.named.map((n) => n.imported).filter((n) => /^register[A-Z]/.test(n)));
|
|
304
|
+
for (const owner of imp.owners) {
|
|
305
|
+
for (const m of mask.matchAll(new RegExp(`(?<![\\w$.])${literal(owner)}\\s*\\??\\.\\s*(register[A-Z][\\w$]*)`, "g"))) {
|
|
306
|
+
candidates.add(m[1]);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
for (const register of candidates) {
|
|
310
|
+
if (callsRegister(code, pkg, register)) found.set(`${pkg}\0${register}`, { pkg, register });
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return [...found.values()];
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export {
|
|
317
|
+
withoutComments,
|
|
318
|
+
registerWrappers,
|
|
319
|
+
callsImportedAtTop,
|
|
320
|
+
registerState,
|
|
321
|
+
registeredModules
|
|
322
|
+
};
|
|
323
|
+
//# sourceMappingURL=chunk-5HVXPTU4.js.map
|