@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,187 @@
|
|
|
1
|
+
import {
|
|
2
|
+
hasString,
|
|
3
|
+
listAnswer,
|
|
4
|
+
notTheAnswer,
|
|
5
|
+
writeTransportFailure
|
|
6
|
+
} from "./chunk-6PBR37LN.js";
|
|
7
|
+
import {
|
|
8
|
+
SENT_AFTERMATH,
|
|
9
|
+
fetchOrExplain,
|
|
10
|
+
readBodyText,
|
|
11
|
+
safeHttpFailure,
|
|
12
|
+
withWriteStatusAftermath
|
|
13
|
+
} from "./chunk-YLDALTWZ.js";
|
|
14
|
+
import {
|
|
15
|
+
isNonPublicColumn
|
|
16
|
+
} from "./chunk-HVRUQXGD.js";
|
|
17
|
+
|
|
18
|
+
// src/deploy/table.ts
|
|
19
|
+
var TIMEOUT_MS = 3e4;
|
|
20
|
+
function asString(v) {
|
|
21
|
+
return typeof v === "string" && v !== "" ? v : void 0;
|
|
22
|
+
}
|
|
23
|
+
function asNumber(v) {
|
|
24
|
+
return typeof v === "number" ? v : void 0;
|
|
25
|
+
}
|
|
26
|
+
function projectTable(raw) {
|
|
27
|
+
const id = asNumber(raw.id);
|
|
28
|
+
const name = asString(raw.name);
|
|
29
|
+
const guid = asString(raw.guid);
|
|
30
|
+
if (id === void 0 || name === void 0 || guid === void 0) return [];
|
|
31
|
+
return [{ id, name, guid, guardedColumns: guardedIn(raw.schema) }];
|
|
32
|
+
}
|
|
33
|
+
function guardedIn(schema, prefix = "") {
|
|
34
|
+
if (!Array.isArray(schema)) return [];
|
|
35
|
+
return schema.flatMap((col) => {
|
|
36
|
+
if (col === null || typeof col !== "object") return [];
|
|
37
|
+
const c = col;
|
|
38
|
+
const colName = asString(c.name);
|
|
39
|
+
if (colName === void 0) return [];
|
|
40
|
+
const path = `${prefix}${colName}`;
|
|
41
|
+
return isNonPublicColumn(c) ? [path] : guardedIn(c.children, `${path}.`);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function base(workspaceId) {
|
|
45
|
+
return `/api:meta/workspace/${workspaceId}/table`;
|
|
46
|
+
}
|
|
47
|
+
var PER_PAGE = 1e3;
|
|
48
|
+
var isTableRow = (row) => typeof row.id === "number" && hasString(row, "name") && hasString(row, "guid");
|
|
49
|
+
async function listTables(auth, opts) {
|
|
50
|
+
const out = [];
|
|
51
|
+
for (let page = 1; ; page++) {
|
|
52
|
+
const path = `${base(opts.workspaceId)}?page=${page}&per_page=${PER_PAGE}`;
|
|
53
|
+
const res = await metaFetch(auth, path, "list tables", { method: "GET" }, opts.base);
|
|
54
|
+
const text = await readText(res, "list tables", opts.binding);
|
|
55
|
+
const { rows } = listAnswer(text, "list tables", routeUrl(auth, path, opts.base).href, isTableRow, { safe: true });
|
|
56
|
+
for (const r of rows) out.push(...projectTable(r));
|
|
57
|
+
if (rows.length < PER_PAGE) return out;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async function someTableRow(auth, opts, match) {
|
|
61
|
+
for (let page = 1; ; page++) {
|
|
62
|
+
const path = `${base(opts.workspaceId)}/${opts.tableId}/content?page=${page}&per_page=${PER_PAGE}`;
|
|
63
|
+
const res = await metaFetch(auth, path, "read table rows", { method: "GET" }, opts.base);
|
|
64
|
+
const text = await readText(res, "read table rows", opts.binding);
|
|
65
|
+
const { rows } = listAnswer(text, "read table rows", routeUrl(auth, path, opts.base).href, () => true, { safe: true });
|
|
66
|
+
if (rows.some(match)) return true;
|
|
67
|
+
if (rows.length < PER_PAGE) return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async function tableRowIds(auth, opts) {
|
|
71
|
+
const ids = /* @__PURE__ */ new Set();
|
|
72
|
+
for (let page = 1; ; page++) {
|
|
73
|
+
const path = `${base(opts.workspaceId)}/${opts.tableId}/content?page=${page}&per_page=${PER_PAGE}`;
|
|
74
|
+
const res = await metaFetch(auth, path, "read table rows", { method: "GET" }, opts.base);
|
|
75
|
+
const text = await readText(res, "read table rows", opts.binding);
|
|
76
|
+
const { rows } = listAnswer(text, "read table rows", routeUrl(auth, path, opts.base).href, () => true, { safe: true });
|
|
77
|
+
for (const row of rows) if (row.id !== void 0 && row.id !== null) ids.add(String(row.id));
|
|
78
|
+
if (rows.length < PER_PAGE) return ids;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async function countTableRows(auth, opts) {
|
|
82
|
+
const path = `${base(opts.workspaceId)}/${opts.tableId}/content?page=1&per_page=1`;
|
|
83
|
+
const res = await metaFetch(auth, path, "count table rows", { method: "GET" }, opts.base);
|
|
84
|
+
const text = await readText(res, "count table rows", opts.binding);
|
|
85
|
+
const { envelope } = listAnswer(text, "count table rows", routeUrl(auth, path, opts.base).href, () => true, { safe: true });
|
|
86
|
+
const total = envelope?.itemsTotal;
|
|
87
|
+
return typeof total === "number" && Number.isInteger(total) && total >= 0 ? total : void 0;
|
|
88
|
+
}
|
|
89
|
+
function tableRowCounter(auth, opts) {
|
|
90
|
+
let listed;
|
|
91
|
+
return async ({ name, guid }) => {
|
|
92
|
+
listed ??= listTables(auth, opts).catch(() => void 0);
|
|
93
|
+
const tables = await listed;
|
|
94
|
+
const here = (guid === void 0 ? void 0 : tables?.find((t) => t.guid === guid)) ?? tables?.find((t) => t.name === name);
|
|
95
|
+
if (here === void 0) return void 0;
|
|
96
|
+
return countTableRows(auth, { ...opts, tableId: here.id }).catch(() => void 0);
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
async function truncateTable(auth, opts) {
|
|
100
|
+
const path = `${base(opts.workspaceId)}/${opts.tableId}/truncate?reset=true`;
|
|
101
|
+
const res = await metaFetch(auth, path, "truncate table", { method: "DELETE" }, opts.base);
|
|
102
|
+
const text = await readBodyText(res, "truncate table", { aftermath: SENT_AFTERMATH });
|
|
103
|
+
if (!res.ok) {
|
|
104
|
+
const head = safeHttpFailure("truncate table", res, text, binding(auth, opts.workspaceId, opts.base));
|
|
105
|
+
throw new Error(withWriteStatusAftermath(head, res.status));
|
|
106
|
+
}
|
|
107
|
+
writeAcknowledged(text, "truncate table", routeUrl(auth, path, opts.base).href);
|
|
108
|
+
}
|
|
109
|
+
function writeAcknowledged(text, action, url) {
|
|
110
|
+
if (text.trim() === "") return;
|
|
111
|
+
try {
|
|
112
|
+
JSON.parse(text);
|
|
113
|
+
} catch {
|
|
114
|
+
throw notTheAnswer(action, text, url, { safe: true, write: true });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
async function insertTableRows(auth, opts) {
|
|
118
|
+
if (opts.rows.length === 0) return;
|
|
119
|
+
const path = `${base(opts.workspaceId)}/${opts.tableId}/content/bulk`;
|
|
120
|
+
const res = await metaFetch(
|
|
121
|
+
auth,
|
|
122
|
+
path,
|
|
123
|
+
"insert table rows",
|
|
124
|
+
{
|
|
125
|
+
method: "POST",
|
|
126
|
+
headers: { "Content-Type": "application/json" },
|
|
127
|
+
body: JSON.stringify({ items: opts.rows })
|
|
128
|
+
},
|
|
129
|
+
opts.base
|
|
130
|
+
);
|
|
131
|
+
if (!res.ok) {
|
|
132
|
+
await readBodyText(res, "insert table rows", { aftermath: SENT_AFTERMATH });
|
|
133
|
+
const head = safeHttpFailure("insert table rows", res, "", binding(auth, opts.workspaceId, opts.base));
|
|
134
|
+
throw new Error(withWriteStatusAftermath(head, res.status));
|
|
135
|
+
}
|
|
136
|
+
writeAcknowledged(await readBodyText(res, "insert table rows", { aftermath: SENT_AFTERMATH }), "insert table rows", routeUrl(auth, path, opts.base).href);
|
|
137
|
+
}
|
|
138
|
+
function routeUrl(auth, path, base2) {
|
|
139
|
+
return base2 !== void 0 ? new URL(`${base2.replace(/\/$/, "")}${path}`) : new URL(path, auth.instance);
|
|
140
|
+
}
|
|
141
|
+
async function metaFetch(auth, path, action, init, base2) {
|
|
142
|
+
const url = routeUrl(auth, path, base2);
|
|
143
|
+
return fetchOrExplain(
|
|
144
|
+
url.href,
|
|
145
|
+
{
|
|
146
|
+
...init,
|
|
147
|
+
headers: {
|
|
148
|
+
accept: "application/json",
|
|
149
|
+
Authorization: `Bearer ${auth.access_token}`,
|
|
150
|
+
...init?.headers ?? {}
|
|
151
|
+
},
|
|
152
|
+
signal: AbortSignal.timeout(TIMEOUT_MS)
|
|
153
|
+
},
|
|
154
|
+
action,
|
|
155
|
+
TIMEOUT_MS
|
|
156
|
+
).catch((err) => {
|
|
157
|
+
throw (init?.method ?? "GET").toUpperCase() !== "GET" ? writeTransportFailure(err) : err;
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
function binding(auth, workspaceId, base2) {
|
|
161
|
+
return {
|
|
162
|
+
boundWorkspaceId: auth.workspaceId,
|
|
163
|
+
instance: auth.instance,
|
|
164
|
+
profile: auth.profile,
|
|
165
|
+
addressedWorkspaceId: workspaceId,
|
|
166
|
+
credentialType: auth.credentialType,
|
|
167
|
+
tenantHost: base2 !== void 0
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
async function readText(res, action, bind) {
|
|
171
|
+
const text = await readBodyText(res, action);
|
|
172
|
+
if (!res.ok) throw Object.assign(new Error(safeHttpFailure(action, res, text, bind)), { status: res.status });
|
|
173
|
+
return text;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export {
|
|
177
|
+
projectTable,
|
|
178
|
+
guardedIn,
|
|
179
|
+
listTables,
|
|
180
|
+
someTableRow,
|
|
181
|
+
tableRowIds,
|
|
182
|
+
countTableRows,
|
|
183
|
+
tableRowCounter,
|
|
184
|
+
truncateTable,
|
|
185
|
+
insertTableRows
|
|
186
|
+
};
|
|
187
|
+
//# sourceMappingURL=chunk-C6RIMRU4.js.map
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clearEphemeralLanding,
|
|
3
|
+
ephemeralLandedOn,
|
|
4
|
+
ephemeralStatePath,
|
|
5
|
+
recordEphemeralLanding
|
|
6
|
+
} from "./chunk-5QU2P5CA.js";
|
|
7
|
+
import {
|
|
8
|
+
contextFlags
|
|
9
|
+
} from "./chunk-NAQDMEHV.js";
|
|
10
|
+
import {
|
|
11
|
+
backendDirIn
|
|
12
|
+
} from "./chunk-5A2PLKZB.js";
|
|
13
|
+
import {
|
|
14
|
+
forgetPrunedInLockFile,
|
|
15
|
+
readLockFile,
|
|
16
|
+
recordLandingInLockFile,
|
|
17
|
+
writeLockFile
|
|
18
|
+
} from "./chunk-P2HAGF6H.js";
|
|
19
|
+
import {
|
|
20
|
+
destinationKey,
|
|
21
|
+
isEphemeralDestinationKey,
|
|
22
|
+
landedIdentities,
|
|
23
|
+
landedOn,
|
|
24
|
+
withStoredColumns,
|
|
25
|
+
withoutLanding
|
|
26
|
+
} from "./chunk-TLQE7ZN3.js";
|
|
27
|
+
import {
|
|
28
|
+
displayPath,
|
|
29
|
+
info,
|
|
30
|
+
warn
|
|
31
|
+
} from "./chunk-PTHVMXZI.js";
|
|
32
|
+
import {
|
|
33
|
+
displayLockKey
|
|
34
|
+
} from "./chunk-6MR5TI5V.js";
|
|
35
|
+
import {
|
|
36
|
+
shellQuote
|
|
37
|
+
} from "./chunk-5ZSO4T2G.js";
|
|
38
|
+
|
|
39
|
+
// src/emit/landing-record.ts
|
|
40
|
+
import { resolve, dirname, join, basename } from "path";
|
|
41
|
+
import { existsSync } from "fs";
|
|
42
|
+
import { execFileSync } from "child_process";
|
|
43
|
+
function landingLockPath(args, opts = {}) {
|
|
44
|
+
if (args.noLock) return void 0;
|
|
45
|
+
if (args.lockPath !== void 0) return resolve(args.lockPath);
|
|
46
|
+
if (opts.entryFile !== void 0) return join(dirname(resolve(opts.entryFile)), "xano.lock");
|
|
47
|
+
if (opts.fromProject === false) return void 0;
|
|
48
|
+
const lock = join(backendDirIn(process.cwd()), "xano.lock");
|
|
49
|
+
return existsSync(lock) ? lock : void 0;
|
|
50
|
+
}
|
|
51
|
+
function landedRecordFor(lockPath, destKey) {
|
|
52
|
+
if (isEphemeralDestinationKey(destKey)) {
|
|
53
|
+
const dir = process.cwd();
|
|
54
|
+
return { record: ephemeralLandedOn(dir, destKey), file: displayPath(ephemeralStatePath(dir)), local: true };
|
|
55
|
+
}
|
|
56
|
+
return { record: landedOn(readLockFile(lockPath), destKey), file: displayPath(lockPath), local: false };
|
|
57
|
+
}
|
|
58
|
+
function unvouchedIdentities(identities, lock, lockPath) {
|
|
59
|
+
const keys = Object.keys(identities);
|
|
60
|
+
if (lock === void 0 || keys.length === 0) return keys.map((k) => displayLockKey(k));
|
|
61
|
+
const exact = (key) => {
|
|
62
|
+
const entry = lock.objects[key];
|
|
63
|
+
if (entry?.guid !== identities[key].guid) return false;
|
|
64
|
+
return !key.startsWith("toolset:") || entry.type === "agent" === (identities[key].type === "agent");
|
|
65
|
+
};
|
|
66
|
+
const matched = keys.filter(exact);
|
|
67
|
+
if (matched.length === 0) return keys.map((k) => displayLockKey(k));
|
|
68
|
+
const rest = keys.filter((k) => !exact(k));
|
|
69
|
+
if (rest.length === 0) return [];
|
|
70
|
+
const held = /* @__PURE__ */ new Set([
|
|
71
|
+
...Object.values(lock.objects).flatMap((e) => e.guid === void 0 ? [] : [e.guid]),
|
|
72
|
+
...Object.values(lock.landed ?? {}).flatMap((record) => Object.values(record).map((e) => e.guid))
|
|
73
|
+
]);
|
|
74
|
+
const inHistory = rest.length <= HISTORY_LOOKUPS && lockPath !== void 0 ? guidInLockHistory(lockPath) : void 0;
|
|
75
|
+
return rest.filter((k) => {
|
|
76
|
+
const guid = identities[k].guid;
|
|
77
|
+
return !held.has(guid) && inHistory?.(guid) !== true;
|
|
78
|
+
}).map((k) => displayLockKey(k));
|
|
79
|
+
}
|
|
80
|
+
var HISTORY_LOOKUPS = 25;
|
|
81
|
+
function guidInLockHistory(lockPath) {
|
|
82
|
+
const git = (...argv) => execFileSync("git", argv, {
|
|
83
|
+
cwd: dirname(resolve(lockPath)),
|
|
84
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
85
|
+
timeout: 5e3,
|
|
86
|
+
encoding: "utf8"
|
|
87
|
+
}).trim();
|
|
88
|
+
const file = `./${basename(lockPath)}`;
|
|
89
|
+
try {
|
|
90
|
+
if (git("rev-parse", "--is-shallow-repository") === "true") return void 0;
|
|
91
|
+
if (git("log", "-1", "--format=%H", "--", file) === "") return void 0;
|
|
92
|
+
} catch {
|
|
93
|
+
return void 0;
|
|
94
|
+
}
|
|
95
|
+
return (guid) => {
|
|
96
|
+
try {
|
|
97
|
+
return git("log", "-1", "--format=%H", `-S${JSON.stringify(guid)}`, "--", file) !== "";
|
|
98
|
+
} catch {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function recordForeignLanding(opts) {
|
|
104
|
+
let lock;
|
|
105
|
+
if (opts.lockPath !== void 0 && existsSync(opts.lockPath)) {
|
|
106
|
+
try {
|
|
107
|
+
lock = readLockFile(opts.lockPath);
|
|
108
|
+
} catch {
|
|
109
|
+
lock = void 0;
|
|
110
|
+
}
|
|
111
|
+
} else if (opts.dest.kind !== "ephemeral") {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
const identities = landedIdentities(opts.bundle);
|
|
115
|
+
const unvouched = unvouchedIdentities(identities, lock, opts.lockPath);
|
|
116
|
+
const ours = lock !== void 0 && Object.keys(identities).length > 0 && unvouched.length === 0;
|
|
117
|
+
if (!ours && opts.mode === "merge") return null;
|
|
118
|
+
const removed = ours ? { ...removedByGuid(lock, opts.removedGuids), ...opts.removed ?? {} } : {};
|
|
119
|
+
return recordLanding({
|
|
120
|
+
lockPath: opts.lockPath,
|
|
121
|
+
instance: opts.instance,
|
|
122
|
+
dest: opts.dest,
|
|
123
|
+
update: {
|
|
124
|
+
mode: opts.mode,
|
|
125
|
+
identities: ours ? withStoredColumns(identities, opts.stored) : {},
|
|
126
|
+
...Object.keys(removed).length > 0 ? { removed } : {}
|
|
127
|
+
},
|
|
128
|
+
...opts.removedBy !== void 0 ? { removedBy: opts.removedBy } : {},
|
|
129
|
+
foreign: !ours,
|
|
130
|
+
...ours ? {} : { unmatched: unvouched },
|
|
131
|
+
...opts.unreadable === true ? { unreadable: true } : {}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function removedByGuid(lock, guids) {
|
|
135
|
+
if (lock === void 0 || guids === void 0 || guids.length === 0) return {};
|
|
136
|
+
const gone = new Set(guids);
|
|
137
|
+
const out = {};
|
|
138
|
+
for (const [key, entry] of Object.entries(lock.objects)) {
|
|
139
|
+
if (entry.guid !== void 0 && gone.has(entry.guid)) out[key] = { guid: entry.guid };
|
|
140
|
+
}
|
|
141
|
+
return out;
|
|
142
|
+
}
|
|
143
|
+
function recordLanding(opts) {
|
|
144
|
+
const destination = destinationKey(opts.instance, opts.dest);
|
|
145
|
+
const cleared = opts.foreign === true && opts.update.mode === "replace";
|
|
146
|
+
const why = unmatchedPhrase(opts.unmatched);
|
|
147
|
+
const serves = opts.unreadable === true ? `objects this project cannot confirm as its own (the release archive could not be read back)` : `another source's objects${why}`;
|
|
148
|
+
const unmatched = opts.foreign === true ? [...opts.unmatched ?? []] : [];
|
|
149
|
+
if (opts.dest.kind === "ephemeral") {
|
|
150
|
+
const dir = process.cwd();
|
|
151
|
+
const shown2 = displayPath(ephemeralStatePath(dir));
|
|
152
|
+
try {
|
|
153
|
+
const result2 = recordEphemeralLanding(dir, destination, opts.update);
|
|
154
|
+
if (cleared && result2.changed) {
|
|
155
|
+
info(
|
|
156
|
+
`Cleared this project's landing record for ${destination} in ${shown2} \u2014 it now serves ${serves}. Until this project lands there again, a \`--keep-data\` deploy lists what it removes there as another source's, and \`xanosdk deploy --to tenant:${shellQuote(opts.dest.name)} --prune${contextFlags()}\` refuses to delete any of it.`
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
let lockDropped2 = [];
|
|
160
|
+
if (opts.lockPath !== void 0 && opts.update.removed !== void 0) {
|
|
161
|
+
try {
|
|
162
|
+
lockDropped2 = forgotPruned(displayPath(opts.lockPath), forgetPrunedInLockFile(opts.lockPath, opts.update), opts.removedBy);
|
|
163
|
+
} catch (err) {
|
|
164
|
+
unforgotten(displayPath(opts.lockPath), err);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return { destination, file: shown2, recorded: result2.recorded, changed: result2.changed, cleared, lockDropped: lockDropped2, unmatched };
|
|
168
|
+
} catch (err) {
|
|
169
|
+
unrecorded(shown2, err);
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (opts.lockPath === void 0) return null;
|
|
174
|
+
let result;
|
|
175
|
+
try {
|
|
176
|
+
result = recordLandingInLockFile(opts.lockPath, destination, opts.update);
|
|
177
|
+
} catch (err) {
|
|
178
|
+
unrecorded(displayPath(opts.lockPath), err);
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
if (result === void 0) return null;
|
|
182
|
+
const shown = displayPath(opts.lockPath);
|
|
183
|
+
if (result.changed) {
|
|
184
|
+
info(
|
|
185
|
+
cleared ? `Cleared this project's landing record for ${destination} in ${shown} \u2014 it now serves ${serves}, so \`--prune\` there deletes nothing until this project lands again. Commit it.` : `Recorded what this project landed on ${destination} in ${shown} \u2014 commit it: \`--prune\` deletes only what this record names.`
|
|
186
|
+
);
|
|
187
|
+
} else if (cleared) {
|
|
188
|
+
info(
|
|
189
|
+
`Recorded nothing for ${destination} in ${shown} \u2014 ` + (opts.unreadable === true ? `what landed could not be checked against this project's lock (the release archive could not be read back), so` : `what landed does not match this project's lock (another source's objects${why}), so`) + ` \`--prune\` from here deletes nothing there until this project lands again.`
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
const lockDropped = forgotPruned(shown, result.forgotten, opts.removedBy);
|
|
193
|
+
return { destination, file: shown, recorded: result.recorded, changed: result.changed, cleared, lockDropped, unmatched };
|
|
194
|
+
}
|
|
195
|
+
function unmatchedPhrase(unmatched) {
|
|
196
|
+
if (unmatched === void 0 || unmatched.length === 0) return "";
|
|
197
|
+
const SHOWN = 5;
|
|
198
|
+
const n = unmatched.length;
|
|
199
|
+
const listed = unmatched.slice(0, SHOWN).join(", ") + (n > SHOWN ? `, and ${n - SHOWN} more` : "");
|
|
200
|
+
return ` (${n === 1 ? "1 identity" : `${n} identities`} this project's lock does not know: ${listed})`;
|
|
201
|
+
}
|
|
202
|
+
function holdsLanding(lockPath, instance, dest) {
|
|
203
|
+
try {
|
|
204
|
+
const key = destinationKey(instance, dest);
|
|
205
|
+
if (dest.kind === "ephemeral") return ephemeralLandedOn(process.cwd(), key) !== void 0;
|
|
206
|
+
if (lockPath === void 0 || !existsSync(lockPath)) return false;
|
|
207
|
+
return landedOn(readLockFile(lockPath), key) !== void 0;
|
|
208
|
+
} catch {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
function forgetLanding(lockPath, instance, dest) {
|
|
213
|
+
try {
|
|
214
|
+
if (dest.kind === "ephemeral") {
|
|
215
|
+
const dir = process.cwd();
|
|
216
|
+
return clearEphemeralLanding(dir, instance, dest.name) ? displayPath(ephemeralStatePath(dir)) : void 0;
|
|
217
|
+
}
|
|
218
|
+
if (lockPath === void 0 || !existsSync(lockPath)) return void 0;
|
|
219
|
+
const lock = readLockFile(lockPath);
|
|
220
|
+
const next = withoutLanding(lock, destinationKey(instance, dest));
|
|
221
|
+
if (next === lock || !writeLockFile(lockPath, next)) return void 0;
|
|
222
|
+
const shown = displayPath(lockPath);
|
|
223
|
+
info(`Removed its landing record from ${shown} \u2014 commit it.`);
|
|
224
|
+
return shown;
|
|
225
|
+
} catch {
|
|
226
|
+
return void 0;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
function forgotPruned(shown, keys, by = "prune") {
|
|
230
|
+
const n = keys?.length ?? 0;
|
|
231
|
+
if (n === 0) return [];
|
|
232
|
+
info(
|
|
233
|
+
`Dropped the ${n === 1 ? "entry" : `${n} entries`} the ${by} deleted from ${shown}'s objects, so the next export does not read ${n === 1 ? "it" : "them"} as renamed or deleted \u2014 commit it.`
|
|
234
|
+
);
|
|
235
|
+
return keys.map((key) => displayLockKey(key));
|
|
236
|
+
}
|
|
237
|
+
function unforgotten(shown, err) {
|
|
238
|
+
warn(
|
|
239
|
+
`The prune landed, but ${shown} could not be updated: ${err instanceof Error ? err.message : String(err)}`,
|
|
240
|
+
"landing.record-failed",
|
|
241
|
+
["The next export reads the deleted objects' entries as orphans; drop them with `xanosdk lock prune <entry-file>`."]
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
function unrecorded(shown, err) {
|
|
245
|
+
warn(
|
|
246
|
+
`The write landed, but it could not be recorded in ${shown}: ${err instanceof Error ? err.message : String(err)}`,
|
|
247
|
+
"landing.record-failed",
|
|
248
|
+
[
|
|
249
|
+
"A later `--prune` here deletes only what that record names, so it will refuse these objects until a landing is recorded."
|
|
250
|
+
]
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export {
|
|
255
|
+
landingLockPath,
|
|
256
|
+
landedRecordFor,
|
|
257
|
+
unvouchedIdentities,
|
|
258
|
+
recordForeignLanding,
|
|
259
|
+
recordLanding,
|
|
260
|
+
holdsLanding,
|
|
261
|
+
forgetLanding
|
|
262
|
+
};
|
|
263
|
+
//# sourceMappingURL=chunk-CGVQZXYG.js.map
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// src/statements/args.ts
|
|
2
|
+
function argsOrEmpty(a) {
|
|
3
|
+
return a ?? {};
|
|
4
|
+
}
|
|
5
|
+
function assertArg(statement, name, v, opts) {
|
|
6
|
+
if (v === void 0 || v === null && !opts?.nullable)
|
|
7
|
+
throw new Error(
|
|
8
|
+
`Statement "${label(statement)}": required argument "${name}" is missing${v === null ? " (got null)" : ""}.`
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
function label(statement) {
|
|
12
|
+
return statement.replace(/^mvp:/, "");
|
|
13
|
+
}
|
|
14
|
+
var PROTO_KEY = 'a literal `__proto__:` key sets the object\'s prototype in JavaScript \u2014 write it computed: `["__proto__"]: \u2026`';
|
|
15
|
+
function protoKeyed(v) {
|
|
16
|
+
const p = typeof v === "object" && v !== null ? Object.getPrototypeOf(v) : null;
|
|
17
|
+
return p !== null && p !== Object.prototype && !Object.hasOwn(p, "constructor");
|
|
18
|
+
}
|
|
19
|
+
function describeArg(v) {
|
|
20
|
+
if (v === null) return "null";
|
|
21
|
+
if (v === void 0) return "undefined";
|
|
22
|
+
if (Array.isArray(v)) return `a JS array (${v.length} item${v.length === 1 ? "" : "s"})`;
|
|
23
|
+
if (protoKeyed(v)) return `a record with a \`__proto__\` key (${PROTO_KEY})`;
|
|
24
|
+
if (isTaggedArg(v)) return `a tagged value (${valueSpelling(v.tag)})`;
|
|
25
|
+
if (typeof v === "function") return "a function";
|
|
26
|
+
if (typeof v === "object") {
|
|
27
|
+
const proto = Object.getPrototypeOf(v);
|
|
28
|
+
if (proto === null || proto === Object.prototype) return "a plain object";
|
|
29
|
+
const name = v.constructor?.name;
|
|
30
|
+
if (typeof name !== "string" || name === "") return "a class instance";
|
|
31
|
+
if (["Date", "Map", "Set", "WeakMap", "WeakSet", "RegExp", "Promise", "Error"].includes(name)) return `a ${name}`;
|
|
32
|
+
return `${/^[AEIOU]/.test(name) && !/^U(RL|RI|UID|int|ni|se)/.test(name) ? "an" : "a"} ${name} instance`;
|
|
33
|
+
}
|
|
34
|
+
return `a ${typeof v}`;
|
|
35
|
+
}
|
|
36
|
+
function valueSpelling(tag) {
|
|
37
|
+
if (tag.startsWith("const:")) return `c.${tag.slice("const:".length)}(\u2026)`;
|
|
38
|
+
const helper = { var: "ref", input: "inp", setting: "env", col: "col", auth: "auth", const: "c.text" };
|
|
39
|
+
return helper[tag] !== void 0 ? `${helper[tag]}(\u2026)` : `tag "${tag}"`;
|
|
40
|
+
}
|
|
41
|
+
function isTaggedArg(v) {
|
|
42
|
+
return (typeof v === "object" || typeof v === "function") && v !== null && typeof v.tag === "string" && "value" in v && Array.isArray(v.filters);
|
|
43
|
+
}
|
|
44
|
+
function assertValueArg(statement, name, v) {
|
|
45
|
+
assertArg(statement, name, v);
|
|
46
|
+
if (isTaggedArg(v)) return;
|
|
47
|
+
throw new Error(valueArgMessage(statement, name, v));
|
|
48
|
+
}
|
|
49
|
+
function presentValueArg(statement, name, v) {
|
|
50
|
+
if (v === void 0 || v === null) return false;
|
|
51
|
+
if (isTaggedArg(v)) return true;
|
|
52
|
+
throw new Error(valueArgMessage(statement, name, v));
|
|
53
|
+
}
|
|
54
|
+
function numberRemedy(v) {
|
|
55
|
+
if (!Number.isFinite(v)) return ` ${v} is not representable as a stored number \u2014 use a finite value, or \`c.null()\` for none.`;
|
|
56
|
+
if (Number.isSafeInteger(v)) return ` Wrap it: \`c.int(${v})\`.`;
|
|
57
|
+
if (Number.isInteger(v)) {
|
|
58
|
+
return ` It is past Number.MAX_SAFE_INTEGER, so the literal was already rounded \u2014 write the exact digits as \`c.int("<digits>")\` or \`c.int(<digits>n)\`.`;
|
|
59
|
+
}
|
|
60
|
+
return ` Wrap it: \`c.decimal(${v})\`.`;
|
|
61
|
+
}
|
|
62
|
+
function valueArgMessage(statement, name, v) {
|
|
63
|
+
const plain = Array.isArray(v) || typeof v === "object" && v !== null;
|
|
64
|
+
return `Statement "${label(statement)}": argument "${name}" must be a tagged value (\`c.*\`, \`ref()\`, \`inp()\`, \u2026) \u2014 got ${describeArg(v)}.` + (plain ? " A plain JS value stores an empty slot that deploys clean and then fails every request \u2014 an array of rows is `c.array([{ \u2026 }])` (plain JSON inside), a record is `c.obj({ \u2026 })`." : typeof v === "number" ? numberRemedy(v) : typeof v === "string" ? ` Wrap it: \`c.text(${JSON.stringify(v)})\`.` : typeof v === "boolean" ? ` Wrap it: \`c.bool(${v})\`.` : "");
|
|
65
|
+
}
|
|
66
|
+
function assertOneOf(statement, name, v, allowed) {
|
|
67
|
+
if (v === void 0) return;
|
|
68
|
+
if (typeof v === "string" && allowed.includes(v)) return;
|
|
69
|
+
throw new Error(
|
|
70
|
+
`Statement "${label(statement)}": argument "${name}" accepts only ${allowed.map((a) => JSON.stringify(a)).join(" | ")} \u2014 got ${typeof v === "string" ? JSON.stringify(v) : describeArg(v)}.`
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
function assertStatements(statement, name, v) {
|
|
74
|
+
assertArg(statement, name, v);
|
|
75
|
+
if (!Array.isArray(v)) {
|
|
76
|
+
throw new Error(
|
|
77
|
+
`Statement "${label(statement)}": argument "${name}" must be an array of statements \u2014 got ${describeArg(v)}.`
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
v.forEach((entry, i) => {
|
|
81
|
+
if (isStatementEntry(entry)) return;
|
|
82
|
+
throw new Error(
|
|
83
|
+
`Statement "${label(statement)}": argument "${name}[${i}]" must be a statement (\`s.*\`) \u2014 got ${describeStatementEntry(entry)}.${conditionalEntryHint(entry)}`
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function assertListArg(statement, name, v, item) {
|
|
88
|
+
if (v === void 0 || v === null) return;
|
|
89
|
+
if (!Array.isArray(v)) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
`Statement "${label(statement)}": argument "${name}" must be an array${item ? ` of ${item.want}` : ""} \u2014 got ${describeEntry(v)}.`
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
if (item === void 0) return;
|
|
95
|
+
v.forEach((entry, i) => {
|
|
96
|
+
if (item.test(entry)) return;
|
|
97
|
+
throw new Error(`Statement "${label(statement)}": argument "${name}[${i}]" must be ${item.want} \u2014 got ${describeEntry(entry)}.`);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
function isRecordArg(v) {
|
|
101
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
102
|
+
}
|
|
103
|
+
function conditionalEntryHint(entry) {
|
|
104
|
+
return entry === false || entry === void 0 ? " A `cond && s.x()` entry leaves false/undefined behind \u2014 spread it instead: `...(cond ? [s.x()] : [])`, or use `s.conditional` for a runtime condition." : "";
|
|
105
|
+
}
|
|
106
|
+
var RAW_ENVELOPE_KEY = /* @__PURE__ */ Symbol.for("xanosdk.statement.rawEnvelope");
|
|
107
|
+
function isStatementEntry(v) {
|
|
108
|
+
if (typeof v !== "object" || v === null) return false;
|
|
109
|
+
if (v[RAW_ENVELOPE_KEY] !== void 0) return true;
|
|
110
|
+
return typeof v.name === "string";
|
|
111
|
+
}
|
|
112
|
+
function describeStatementEntry(v) {
|
|
113
|
+
return isTaggedArg(v) ? "a value (`c.*`/`ref()`), not a statement" : describeEntry(v);
|
|
114
|
+
}
|
|
115
|
+
function describeEntry(v) {
|
|
116
|
+
if (typeof v === "boolean" || typeof v === "number") return `${typeof v} ${String(v)}`;
|
|
117
|
+
if (typeof v === "bigint") return `bigint ${String(v)}n`;
|
|
118
|
+
if (typeof v === "string") return `the string ${JSON.stringify(v.length > 40 ? `${v.slice(0, 40)}\u2026` : v)}`;
|
|
119
|
+
return describeArg(v);
|
|
120
|
+
}
|
|
121
|
+
function assertVarName(statement, name, arg = "name") {
|
|
122
|
+
assertArg(statement, arg, name);
|
|
123
|
+
if (typeof name !== "string") {
|
|
124
|
+
throw new Error(`Statement "${statement}": argument "${arg}" must be the variable name as a string \u2014 got ${describeEntry(name)}.`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
var VAR_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
128
|
+
function isVarName(name) {
|
|
129
|
+
return VAR_NAME.test(name);
|
|
130
|
+
}
|
|
131
|
+
function assertNewVarName(statement, name, arg = "name") {
|
|
132
|
+
assertVarName(statement, name, arg);
|
|
133
|
+
if (name === "") throw new Error(`Statement "${statement}": argument "${arg}" is empty \u2014 name the variable.`);
|
|
134
|
+
if (!VAR_NAME.test(name)) {
|
|
135
|
+
throw new Error(
|
|
136
|
+
`Statement "${statement}": ${JSON.stringify(name)} is not a variable name \u2014 use a letter or underscore, then letters, digits and underscores (e.g. "order_total").`
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export {
|
|
142
|
+
argsOrEmpty,
|
|
143
|
+
assertArg,
|
|
144
|
+
PROTO_KEY,
|
|
145
|
+
protoKeyed,
|
|
146
|
+
describeArg,
|
|
147
|
+
isTaggedArg,
|
|
148
|
+
assertValueArg,
|
|
149
|
+
presentValueArg,
|
|
150
|
+
assertOneOf,
|
|
151
|
+
assertStatements,
|
|
152
|
+
assertListArg,
|
|
153
|
+
isRecordArg,
|
|
154
|
+
conditionalEntryHint,
|
|
155
|
+
isStatementEntry,
|
|
156
|
+
describeStatementEntry,
|
|
157
|
+
describeEntry,
|
|
158
|
+
assertVarName,
|
|
159
|
+
isVarName,
|
|
160
|
+
assertNewVarName
|
|
161
|
+
};
|
|
162
|
+
//# sourceMappingURL=chunk-CIMQZRRE.js.map
|