@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,925 @@
|
|
|
1
|
+
import { V as Value, i as FilterXdo, S as StackItemXdo, r as ResultItemXdo } from './xdo-CxDr2Q1C.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A statement's per-test MOCK — the value a step returns instead of doing its
|
|
5
|
+
* work, when one specific test runs.
|
|
6
|
+
*
|
|
7
|
+
* Authored keyed by TEST NAME, which is what the Xano editor shows and what
|
|
8
|
+
* XanoScript spells. The stored form is keyed by test ID; the rewrite happens
|
|
9
|
+
* at kind-encode time, the only place that knows both the stack and the test
|
|
10
|
+
* list (see `../kinds/test-mocks.js`).
|
|
11
|
+
*
|
|
12
|
+
* A mock applies ONLY while its test runs. It has no effect on a normal
|
|
13
|
+
* request, so mocking a step does not change what the deployed endpoint does.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* One mock: a value, or a value plus `enabled`.
|
|
18
|
+
*
|
|
19
|
+
* The bare form means enabled. The object form exists so a mock can be kept
|
|
20
|
+
* around switched off — the editor stores a disabled mock rather than deleting
|
|
21
|
+
* it, and dropping it on encode would lose an authored artefact.
|
|
22
|
+
*/
|
|
23
|
+
type MockEntry = Value | {
|
|
24
|
+
value: Value;
|
|
25
|
+
enabled?: boolean;
|
|
26
|
+
};
|
|
27
|
+
/** A statement's mocks, keyed by the name of the test each applies to. */
|
|
28
|
+
type MockMap = Record<string, MockEntry>;
|
|
29
|
+
/** The stored `mvp_test_mock` shape. */
|
|
30
|
+
interface MockXdo {
|
|
31
|
+
value: string;
|
|
32
|
+
tag: string;
|
|
33
|
+
filters: unknown[];
|
|
34
|
+
enabled: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Statement model, base envelope encoder, and registry (the extensibility
|
|
39
|
+
* seam).
|
|
40
|
+
*
|
|
41
|
+
* The real stored statement shape (from the golden fixture's `run[0]`) is lean:
|
|
42
|
+
* `{name, as?, context, input}`. The base encoder fills the common envelope
|
|
43
|
+
* (`input: []` default) so each concrete statement factory only declares its
|
|
44
|
+
* `name`, optional `as`, and `context`. The registry maps statement name →
|
|
45
|
+
* factory so the eventual ~500-statement catalog plugs in here.
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The type-level contract linking a branded db statement (the **producer** —
|
|
50
|
+
* `db.get`/`db.query`/`db.add`/`db.edit`/`db.patch`/`db.add_or_edit`/`db.has`/
|
|
51
|
+
* `db.bulk.patch`/`db.bulk.delete`, each returning `Statement & AsShapeBrand<…>`)
|
|
52
|
+
* to `InferResponse`'s single-variable trace (the **consumer** — `TraceVar`,
|
|
53
|
+
* which destructures this shape). Both `__as` (the stack variable the statement
|
|
54
|
+
* binds) and `__shape` (the row shape it produces) are phantom carriers — never
|
|
55
|
+
* present at runtime. Naming the contract here keeps producer and consumer
|
|
56
|
+
* compiler-linked, so any further branded statement joins the trace by extending
|
|
57
|
+
* this type with zero edits to the trace logic.
|
|
58
|
+
*/
|
|
59
|
+
type AsShapeBrand<As extends string, Shape> = {
|
|
60
|
+
readonly __as: As;
|
|
61
|
+
readonly __shape: Shape;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* The type-level mark of a statement that PROVES the stack variable `Name` is
|
|
65
|
+
* non-null by the time the next statement runs — `guard.found` (and
|
|
66
|
+
* `guard.owner`'s first step), which raise before continuing on a null binding.
|
|
67
|
+
* `InferResponse`'s trace drops `| null` from `Name`'s shape when one follows its
|
|
68
|
+
* binding. Phantom like {@link AsShapeBrand}: never present at runtime.
|
|
69
|
+
*/
|
|
70
|
+
type FoundBrand<Name extends string> = {
|
|
71
|
+
readonly __found: Name;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* The type-level mark of a statement whose sub-stack `Body` ALWAYS runs, in
|
|
75
|
+
* place — `db.transaction`, `group`, and `try_catch`'s `finally`.
|
|
76
|
+
* `InferResponse`'s trace reads `Body` as if it sat inline, so a binding made
|
|
77
|
+
* inside one is visible. A conditional body carries none. Phantom: never
|
|
78
|
+
* present at runtime.
|
|
79
|
+
*/
|
|
80
|
+
type BodyBrand<Body extends readonly unknown[]> = {
|
|
81
|
+
readonly __body: Body;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* The type-level mark of a sub-stack that MAY run — a loop body, a conditional
|
|
85
|
+
* branch, a switch case. A re-binding inside it unions with the binding from
|
|
86
|
+
* before it (it may never happen), and an {@link AppendBrand} inside it widens
|
|
87
|
+
* the list it appends to. Phantom.
|
|
88
|
+
*/
|
|
89
|
+
type MaybeBodyBrand<Body extends readonly unknown[]> = {
|
|
90
|
+
readonly __maybe: Body;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* The type-level mark of an in-place list mutator (`array.push`/`unshift`, and
|
|
94
|
+
* `merge` spreading a list): stack variable `Name` gains `Value`'s type as an
|
|
95
|
+
* element, so an accumulator seeded with `c.array([])` traces to that element's
|
|
96
|
+
* list instead of the empty tuple it was bound as. Phantom.
|
|
97
|
+
*/
|
|
98
|
+
type AppendBrand<Name extends string, V, Spread extends boolean = false> = {
|
|
99
|
+
readonly __append: readonly [Name, V, Spread];
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* The type-level mark of a `try_catch`. `try` runs in place but may stop at any
|
|
103
|
+
* statement, and `catch` may run in place of the rest of it: a name `try`
|
|
104
|
+
* re-binds unions with its binding from before, and a name BOTH bind is either
|
|
105
|
+
* one after it. Phantom: never present at runtime.
|
|
106
|
+
*/
|
|
107
|
+
type CatchBrand<Try extends readonly unknown[], Catch extends readonly unknown[]> = {
|
|
108
|
+
readonly __catch: [Try, Catch];
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* The type-level mark of a statement that runs EXACTLY ONE of `Branches` — a
|
|
112
|
+
* `conditional`'s `then`, each `elif` and `else`, or a `switch`'s cases and
|
|
113
|
+
* `default`. When every branch re-binds a name at its top level the value from
|
|
114
|
+
* before is gone, so `InferResponse` traces the union of the branches alone. A
|
|
115
|
+
* missing `else`/`default` is an empty branch, which re-binds nothing. Phantom.
|
|
116
|
+
*/
|
|
117
|
+
type BranchesBrand<Branches extends readonly (readonly unknown[])[]> = {
|
|
118
|
+
readonly __branches: Branches;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* The type-level mark of a dotted `s.update_var("row.title", …)`: member `Path`
|
|
122
|
+
* of stack variable `Name` now holds `Shape`, so `InferResponse` sets that
|
|
123
|
+
* member's type (a union with the old one where the update may not run). Phantom.
|
|
124
|
+
*/
|
|
125
|
+
type MemberUpdateBrand<Name extends string, Path extends string, Shape> = {
|
|
126
|
+
readonly __memberUpdate: readonly [Name, Path, Shape];
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* The two envelope members every stack item carries, whatever it does.
|
|
130
|
+
*
|
|
131
|
+
* They are editor affordances rather than statement arguments — `disabled` is
|
|
132
|
+
* how a step is commented out (it stays in the stack; the run engine skips it),
|
|
133
|
+
* and `description` is the note shown on the step. `encodeStatement` writes both
|
|
134
|
+
* for every statement, so every factory accepts them: the generated ones as two
|
|
135
|
+
* more optional fields on their argument object, the positional specials as a
|
|
136
|
+
* trailing options argument.
|
|
137
|
+
*
|
|
138
|
+
* Both are elided at their defaults on both sides of a round trip, so setting one
|
|
139
|
+
* to `false`/`""` is the same bytes as omitting it.
|
|
140
|
+
*/
|
|
141
|
+
interface StatementAnnotations {
|
|
142
|
+
/** Leave the step in the stack but skip it at runtime — Xano's "disable step". */
|
|
143
|
+
disabled?: boolean;
|
|
144
|
+
/** Free-text note on the step, shown in the editor beside it. */
|
|
145
|
+
description?: string;
|
|
146
|
+
/**
|
|
147
|
+
* Per-test MOCKS — what this step returns instead of running, keyed by the
|
|
148
|
+
* name of the test the mock applies to.
|
|
149
|
+
*
|
|
150
|
+
* `{ "happy path": c.int(1) }` makes the step return `1` while the test named
|
|
151
|
+
* "happy path" runs, and changes nothing about a normal request. Wrap an
|
|
152
|
+
* entry as `{ value, enabled: false }` to keep a mock switched off.
|
|
153
|
+
*
|
|
154
|
+
* Every name must match a test declared on the object this statement belongs
|
|
155
|
+
* to; an unmatched name throws at encode time, because the engine silently
|
|
156
|
+
* ignores a mock whose key is not a real test id.
|
|
157
|
+
*/
|
|
158
|
+
mock?: MockMap;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* {@link StatementAnnotations} plus the result-filter option, for the statements
|
|
162
|
+
* that bind an `as` variable.
|
|
163
|
+
*
|
|
164
|
+
* Split from the annotations rather than folded into them so `asFilters` is only
|
|
165
|
+
* offered where there is a binding to attach it to: a statement that returns
|
|
166
|
+
* nothing (`precondition`, `switch`, `while`, …) should not surface the option
|
|
167
|
+
* in autocomplete at all. The runtime guard in {@link assertBindsAs} still
|
|
168
|
+
* backs this up for callers that reach past the types.
|
|
169
|
+
*/
|
|
170
|
+
interface StatementOptions extends StatementAnnotations {
|
|
171
|
+
/**
|
|
172
|
+
* Filters piped onto the result before it is bound — the editor's
|
|
173
|
+
* `return as token | upper`.
|
|
174
|
+
*
|
|
175
|
+
* Authored from the same `fl.*` catalog as value filters and applied in
|
|
176
|
+
* order, so `asFilters: [fl.trim(), fl.upper()]` trims and then upper-cases.
|
|
177
|
+
*
|
|
178
|
+
* The bound variable is RETYPED by the chain: `InferResponse` folds each
|
|
179
|
+
* filter's declared result, so a `db.query` bound through `[fl.count()]` is a
|
|
180
|
+
* `number`. Filters the engine declares as returning `any` (`get`, `set`,
|
|
181
|
+
* `json_decode`, …) fold to `unknown` — see `values/filter-result.ts`.
|
|
182
|
+
*/
|
|
183
|
+
asFilters?: FilterXdo[];
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Apply {@link StatementOptions} to a built statement.
|
|
187
|
+
*
|
|
188
|
+
* Only members that were actually authored are copied, so a factory's own
|
|
189
|
+
* `description` (a few statements route one) is not clobbered by an absent key.
|
|
190
|
+
*
|
|
191
|
+
* `asFilters` merges into the `output` envelope rather than replacing it: a db
|
|
192
|
+
* statement's column selection (`output.items`) and its result filters live in
|
|
193
|
+
* the same block, and dropping one to write the other would silently discard
|
|
194
|
+
* whichever the factory set first.
|
|
195
|
+
*/
|
|
196
|
+
declare function annotate<T extends Statement>(stmt: T, a?: StatementOptions): T;
|
|
197
|
+
/** What a statement factory returns before base-envelope encoding. */
|
|
198
|
+
interface Statement {
|
|
199
|
+
name: string;
|
|
200
|
+
as?: string;
|
|
201
|
+
context: unknown;
|
|
202
|
+
input?: unknown[];
|
|
203
|
+
/** `output` envelope. Lean (`{filters:[]}`) or rich (`{customize,filters,items}`) forms are both accepted and normalized to the full rich form. */
|
|
204
|
+
output?: unknown;
|
|
205
|
+
/** Statement description (defaults to `""`). */
|
|
206
|
+
description?: string;
|
|
207
|
+
/** Settings-registry bindings (defaults to `null`). */
|
|
208
|
+
settings_registry?: unknown[] | null;
|
|
209
|
+
/** Attached addons (defaults to `[]`). */
|
|
210
|
+
addon?: unknown[];
|
|
211
|
+
/** Async/runtime block (e.g. `mvp:call_agent`'s `{ mode }`); defaults to `null`. */
|
|
212
|
+
runtime?: unknown;
|
|
213
|
+
/**
|
|
214
|
+
* Encoded per-test mocks, keyed by test NAME until the owning kind rewrites
|
|
215
|
+
* the keys to test ids. Authored via the `mock` option, not set directly.
|
|
216
|
+
*/
|
|
217
|
+
mocks?: Record<string, MockXdo> | unknown;
|
|
218
|
+
/** Whether the statement is disabled in the stack (defaults to `false`). */
|
|
219
|
+
disabled?: boolean;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Return a statement sequence from a helper **without losing the tuple**.
|
|
223
|
+
*
|
|
224
|
+
* `InferResponse` traces the `as` binding a `response` names by walking the
|
|
225
|
+
* stack's TUPLE type. Spreading anything typed `Statement[]` widens the whole
|
|
226
|
+
* array, and every binding — including ones declared *after* the spread —
|
|
227
|
+
* becomes invisible, so the response silently resolves to
|
|
228
|
+
* {@link StackTupleWidened}. A helper that emits more than one statement has to
|
|
229
|
+
* return an array, so any shared helper triggers it:
|
|
230
|
+
*
|
|
231
|
+
* ```ts
|
|
232
|
+
* // ✗ widens: every `as` in the calling stack stops being traceable
|
|
233
|
+
* function assertOk(v: string): Statement[] { return [s.lambda({…}), s.precondition({…})]; }
|
|
234
|
+
*
|
|
235
|
+
* // ✓ tuple survives the spread
|
|
236
|
+
* function assertOk(v: string) { return statements(s.lambda({…}), s.precondition({…})); }
|
|
237
|
+
* ```
|
|
238
|
+
*
|
|
239
|
+
* Type-level only — the returned array is the arguments verbatim, so there is no
|
|
240
|
+
* encoder involvement and no cost.
|
|
241
|
+
*
|
|
242
|
+
* **Fixed arity only.** A helper that builds its array in a loop cannot be a
|
|
243
|
+
* tuple; declare `responseShape` on the calling def instead.
|
|
244
|
+
*/
|
|
245
|
+
declare function statements<const T extends readonly Statement[]>(...items: T): T;
|
|
246
|
+
/** True when a statement name has a registered factory. */
|
|
247
|
+
declare function isRegisteredStatement(name: string): boolean;
|
|
248
|
+
/** Look up a registered factory, throwing a clear error when absent. */
|
|
249
|
+
declare function getStatementFactory(name: string): (...args: any[]) => Statement;
|
|
250
|
+
declare function encodeStatement(stmt: Statement): StackItemXdo;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Shared field encoder. Function inputs and table columns are nearly
|
|
254
|
+
* the same stored shape; this encoder fills the common defaults and is
|
|
255
|
+
* parameterized by a `FieldContext` for the three spots where they differ:
|
|
256
|
+
* `customize` (`""` vs `{}`), `market_item` id types (string vs numeric), and
|
|
257
|
+
* whether `description` is emitted.
|
|
258
|
+
*/
|
|
259
|
+
|
|
260
|
+
/** Field visibility — the engine's `access` enum. */
|
|
261
|
+
type FieldAccess = "public" | "private" | "internal";
|
|
262
|
+
/** Valid `format` values for text fields (per the engine's text-field schema). */
|
|
263
|
+
type TextFormat = "" | "plaintext" | "yaml" | "html" | "xml" | "markdown";
|
|
264
|
+
/** Field cardinality — `"single"` (scalar) or `"list"` (array column). */
|
|
265
|
+
type FieldStyleType = "single" | "list";
|
|
266
|
+
interface FieldOptions {
|
|
267
|
+
required?: boolean;
|
|
268
|
+
nullable?: boolean;
|
|
269
|
+
/**
|
|
270
|
+
* Default value. Authored as a `string`, `number`, or `boolean` for
|
|
271
|
+
* ergonomics (`default: 0`, `default: false`); the engine stores it as a
|
|
272
|
+
* string, so it's coerced at encode time (`0` → `"0"`, `false` → `"false"`).
|
|
273
|
+
*
|
|
274
|
+
* On a **table column** the default must stay within the Basic Multilingual
|
|
275
|
+
* Plane: a 4-byte character (codepoint > U+FFFF — emoji, CJK-extension glyphs)
|
|
276
|
+
* is mangled into an invalid UTF-8 sequence by the engine's default pipeline
|
|
277
|
+
* and is rejected at export/encode time rather than 500ing at deploy with
|
|
278
|
+
* Postgres `22021`. BMP characters (accents, `€`, most CJK) store
|
|
279
|
+
* fine. A *function/endpoint input* default binds at runtime and has no limit.
|
|
280
|
+
*/
|
|
281
|
+
default?: string | number | boolean;
|
|
282
|
+
/**
|
|
283
|
+
* Persist **no `default` key at all** for this field, rather than the empty
|
|
284
|
+
* `default: ""` every other field carries.
|
|
285
|
+
*
|
|
286
|
+
* Set on a table's `uuid` PRIMARY KEY, which is the one column the engine
|
|
287
|
+
* stores this way — its value is engine-generated, so there is nothing for a
|
|
288
|
+
* default to mean, and absent vs empty are different stored bytes. Applied
|
|
289
|
+
* automatically by `idType: "uuid"`; you rarely set it by hand.
|
|
290
|
+
*
|
|
291
|
+
* NOT a property of `uuid` in general: an ordinary (non-key) `uuid` column
|
|
292
|
+
* does carry `default: ""`. Mutually exclusive with {@link default}.
|
|
293
|
+
*/
|
|
294
|
+
noDefault?: boolean;
|
|
295
|
+
description?: string;
|
|
296
|
+
/**
|
|
297
|
+
* Methods/filters applied at bind time. Each entry is either a bare name
|
|
298
|
+
* (`"trim"`), a colon-form string with args (`"min:8"` → `{name:"min",
|
|
299
|
+
* arg:["8"]}`), or an explicit `{ name, arg }` object.
|
|
300
|
+
*/
|
|
301
|
+
methods?: MethodSpec[];
|
|
302
|
+
/** Enum values (for `type:"enum"` fields), e.g. `["draft","live"]`. */
|
|
303
|
+
values?: Array<string | number>;
|
|
304
|
+
mode?: string;
|
|
305
|
+
/** Text-field display format (text fields only; the engine drops it elsewhere). */
|
|
306
|
+
format?: TextFormat;
|
|
307
|
+
sensitive?: boolean;
|
|
308
|
+
/**
|
|
309
|
+
* Merge the referenced object's fields into this one rather than nesting them.
|
|
310
|
+
*
|
|
311
|
+
* **Leave this unset** unless reproducing a pulled field. It defaults to `false`,
|
|
312
|
+
* which is what every field this SDK authors from scratch wants; it is here so a
|
|
313
|
+
* pulled workspace's field can be recovered as a readable `f.*` call instead of
|
|
314
|
+
* degrading to `rawField()`. Paired with {@link hidden} in the wild — 584 fields
|
|
315
|
+
* across the sweep carry `merge: true` with a `hidden` list beside it.
|
|
316
|
+
*/
|
|
317
|
+
merge?: boolean;
|
|
318
|
+
/**
|
|
319
|
+
* Names to hide from this field's expansion (e.g. `["created_at"]`).
|
|
320
|
+
*
|
|
321
|
+
* **Leave this unset** unless reproducing a pulled field; it defaults to `[]`.
|
|
322
|
+
* Each entry is resolved as a name and removed from the expanded shape, so an
|
|
323
|
+
* entry naming nothing hides nothing — a stored `[""]` is a real spelling that
|
|
324
|
+
* appears in the wild and round-trips verbatim here rather than being guessed at.
|
|
325
|
+
*/
|
|
326
|
+
hidden?: readonly string[];
|
|
327
|
+
/** Field visibility in API output. Defaults to `"public"`. */
|
|
328
|
+
access?: FieldAccess;
|
|
329
|
+
style?: {
|
|
330
|
+
type: FieldStyleType;
|
|
331
|
+
};
|
|
332
|
+
/**
|
|
333
|
+
* Length bounds for an array field. Both members are `json`-typed in the
|
|
334
|
+
* engine, not numeric — the editor declares them as `json` and every consumer
|
|
335
|
+
* reads them through a numeric coercion (`+list.max`) — so a bound can arrive
|
|
336
|
+
* as `5` or as `"5"` and neither spelling is wrong.
|
|
337
|
+
*
|
|
338
|
+
* That is also why "unset" has no single spelling: an empty `json` control
|
|
339
|
+
* serializes to `""` on 8,814 fields in the sweep and to `{}` on two. Codegen
|
|
340
|
+
* elides the block whenever every member is blank in either form (see
|
|
341
|
+
* `hasNoListBounds`), so only a bound that is actually SET reaches this type.
|
|
342
|
+
*/
|
|
343
|
+
list?: {
|
|
344
|
+
min?: string | number;
|
|
345
|
+
max?: string | number;
|
|
346
|
+
};
|
|
347
|
+
vector?: {
|
|
348
|
+
size: number;
|
|
349
|
+
};
|
|
350
|
+
/**
|
|
351
|
+
* Array/list field — stored as `style:{type:"list"}` (e.g. `int[]`, `object[]`).
|
|
352
|
+
* Ignored when an explicit `style` is given.
|
|
353
|
+
*/
|
|
354
|
+
array?: boolean;
|
|
355
|
+
/** Nested fields for `type:"obj"` columns; each is itself a named, typed field. */
|
|
356
|
+
children?: NestedField[];
|
|
357
|
+
/**
|
|
358
|
+
* Per-column overrides applied to this field's EXPANSION, keyed by the
|
|
359
|
+
* expanded column's name. Meaningful on a merged field — an
|
|
360
|
+
* {@link input.dbLink} — where the engine expands a table's columns into
|
|
361
|
+
* request inputs and consults this map for each one.
|
|
362
|
+
*
|
|
363
|
+
* **Leave this unset** unless reproducing a pulled field; it defaults to `{}`.
|
|
364
|
+
* Xano's own CRUD scaffold writes it, so it is the common shape in a pulled
|
|
365
|
+
* workspace, not an edge case.
|
|
366
|
+
*/
|
|
367
|
+
customize?: Readonly<Record<string, FieldCustomization>>;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* One expanded column's override inside a merged field's {@link
|
|
371
|
+
* FieldOptions.customize} map.
|
|
372
|
+
*
|
|
373
|
+
* Every member restates what the column already declares, so an omitted member
|
|
374
|
+
* is not "inherit" — it is the stored default (`hidden:false`, `required:false`,
|
|
375
|
+
* `default:""`, no methods). Author the ones you mean to change and accept the
|
|
376
|
+
* rest, which is what the editor writes.
|
|
377
|
+
*/
|
|
378
|
+
interface FieldCustomization {
|
|
379
|
+
/** Drop this column from the expansion entirely. */
|
|
380
|
+
hidden?: boolean;
|
|
381
|
+
/** Whether the expanded input is required. */
|
|
382
|
+
required?: boolean;
|
|
383
|
+
/** Default for the expanded input; stored as a string (`0` → `"0"`). */
|
|
384
|
+
default?: string | number | boolean;
|
|
385
|
+
/** Methods/filters appended to the column's own, in the same spellings as {@link FieldOptions.methods}. */
|
|
386
|
+
methods?: readonly MethodSpec[];
|
|
387
|
+
/** Overrides for an object column's OWN children, keyed by child name. */
|
|
388
|
+
customize?: Readonly<Record<string, FieldCustomization>>;
|
|
389
|
+
}
|
|
390
|
+
/** A nested field inside an object column's `children` — a named, typed `FieldOptions`. */
|
|
391
|
+
interface NestedField extends FieldOptions {
|
|
392
|
+
name: string;
|
|
393
|
+
type: string;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Stored types a COLUMN is nullable by default: files, geo, uuid and vector.
|
|
397
|
+
* Pass `nullable: false` to override. The value types read the same list, so a
|
|
398
|
+
* column nullable by default infers `T | null`.
|
|
399
|
+
*/
|
|
400
|
+
declare const COLUMN_NULLABLE_TYPES: readonly ["blob", "blob_img", "blob_video", "blob_audio", "geo_point", "geo_multipoint", "geo_linestring", "geo_multilinestring", "geo_polygon", "geo_multipolygon", "uuid", "vector"];
|
|
401
|
+
/**
|
|
402
|
+
* Stored types an INPUT is nullable by default: the column list plus `file`,
|
|
403
|
+
* `date` and `epochms`, so an omitted optional one binds `null`. Pass
|
|
404
|
+
* `nullable: false` to override.
|
|
405
|
+
*/
|
|
406
|
+
declare const INPUT_NULLABLE_TYPES: readonly ["blob", "blob_img", "blob_video", "blob_audio", "geo_point", "geo_multipoint", "geo_linestring", "geo_multilinestring", "geo_polygon", "geo_multipolygon", "uuid", "vector", "file", "date", "epochms"];
|
|
407
|
+
/**
|
|
408
|
+
* A field method/filter: a bare name (`"trim"`), a colon-form string carrying
|
|
409
|
+
* args (`"min:8"`, `"min:8:foo"` — first segment is the name, the rest are
|
|
410
|
+
* args), or an explicit `{ name, arg }` object. A method whose argument is text
|
|
411
|
+
* (`startsWith`, `pattern`, `ok`, `salt`) takes everything after the first `:`
|
|
412
|
+
* as that one argument (`"startsWith:https://"`); `pattern`'s error text needs
|
|
413
|
+
* `{ name: "pattern", arg: [regex, errorText] }`.
|
|
414
|
+
*/
|
|
415
|
+
type MethodSpec = string | {
|
|
416
|
+
name: string;
|
|
417
|
+
arg?: Array<string | number>;
|
|
418
|
+
};
|
|
419
|
+
/**
|
|
420
|
+
* A type-narrowed {@link MethodSpec} for a field constructor: a bare method name
|
|
421
|
+
* from the field type's valid set `N` (`"trim"`), the colon-form carrying args
|
|
422
|
+
* (`"min:8"`), or the explicit `{ name, arg }` object — which stays a universal
|
|
423
|
+
* escape hatch for any name the per-type union doesn't enumerate. The per-type
|
|
424
|
+
* `N` unions live in `fields/generated/field-methods.generated.ts`.
|
|
425
|
+
*/
|
|
426
|
+
type MethodArg<N extends string> = N | `${N}:${string}` | {
|
|
427
|
+
name: string;
|
|
428
|
+
arg?: Array<string | number>;
|
|
429
|
+
};
|
|
430
|
+
/**
|
|
431
|
+
* An options type `T` with its `methods` array widened to `readonly`. Field/input
|
|
432
|
+
* constructors capture their options via a `const` type parameter so literal
|
|
433
|
+
* flags (`required`/`nullable`/`array`) survive for `InferInput`; `const` also
|
|
434
|
+
* makes any inline `methods: [...]` a readonly tuple, so a constructor's options
|
|
435
|
+
* constraint must accept readonly arrays. The runtime cast back to `FieldOptions`
|
|
436
|
+
* is safe — the encoder only ever reads (`.map`) the methods.
|
|
437
|
+
*/
|
|
438
|
+
type ReadonlyMethods<T, N extends string> = Omit<T, "methods"> & {
|
|
439
|
+
methods?: readonly MethodArg<N>[];
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Value-type algebra for the typed descriptor layer.
|
|
444
|
+
*
|
|
445
|
+
* Input and column constructors (`input.*`, `f.*`) return a runtime descriptor
|
|
446
|
+
* of exactly `{ type, options }`. This module adds a **phantom brand** to those
|
|
447
|
+
* return types that carries, at the TYPE LEVEL only, the field's value type `V`
|
|
448
|
+
* and the literal options object `O` the caller passed. The brand props are
|
|
449
|
+
* optional and never assigned at runtime, so the emitted object is unchanged and
|
|
450
|
+
* every branded descriptor stays structurally assignable to the un-branded
|
|
451
|
+
* `FieldDescriptor` / `InputDescriptor` — existing consumers are unaffected.
|
|
452
|
+
*
|
|
453
|
+
* `InferInput` (see `../inputs/infer.ts`) reads these brands to turn a query's
|
|
454
|
+
* declared `input` map into the request-payload TS type. The same algebra powers
|
|
455
|
+
* nested-object inference, since object `children` are built from `f.*`.
|
|
456
|
+
*/
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Opaque runtime value of a file input/column. The request payload carries a
|
|
460
|
+
* resource reference (path/metadata), not the raw bytes — model it structurally
|
|
461
|
+
* rather than as `unknown` so a consumer at least sees an object shape.
|
|
462
|
+
*/
|
|
463
|
+
interface XanoFileRef {
|
|
464
|
+
/** Vault path, e.g. `/vault/<…>/<name>`. Join it to your base URL — see {@link import("./file-url.js").fileUrl}. */
|
|
465
|
+
path?: string;
|
|
466
|
+
name?: string;
|
|
467
|
+
type?: string;
|
|
468
|
+
size?: number;
|
|
469
|
+
/** Storage visibility as stored on the column (`"public"` / `"private"`). */
|
|
470
|
+
access?: string;
|
|
471
|
+
/** Type-specific metadata — e.g. `{ width, height }` on an image. */
|
|
472
|
+
meta?: unknown;
|
|
473
|
+
/**
|
|
474
|
+
* ⚠ The engine's own absolute URL, which on a tenant-scoped environment omits
|
|
475
|
+
* the `/tenant/<name>` segment and 404s. Do NOT read it directly: pass the
|
|
476
|
+
* file to `fileUrl(file, baseUrl)`, which joins the correct `path` to the base
|
|
477
|
+
* URL your client already has.
|
|
478
|
+
*/
|
|
479
|
+
url?: string;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Opaque runtime value of a raw file **upload** (`input.file()`).
|
|
483
|
+
*
|
|
484
|
+
* Distinct from {@link XanoFileRef}, and the distinction matters: this is the
|
|
485
|
+
* bytes as they arrive on the request (multipart, base64, or a fetched URI). It
|
|
486
|
+
* is not yet stored anywhere and cannot be written to a file column. Pass it to
|
|
487
|
+
* a `s.storage.create_*` statement (`create_image`, `create_attachment`, …) to
|
|
488
|
+
* store it and get back the {@link XanoFileRef} a column holds.
|
|
489
|
+
*/
|
|
490
|
+
interface XanoFileUpload {
|
|
491
|
+
readonly __fileUpload?: never;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Marker value of a database-link input (`input.dbLink()`).
|
|
495
|
+
*
|
|
496
|
+
* Opaque on purpose: a dblink input does not bind a value of its own. The engine
|
|
497
|
+
* EXPANDS it into one input per column of the linked table, so a table with
|
|
498
|
+
* three columns turns one dblink entry into three request inputs. Read those by
|
|
499
|
+
* their own column names — `inp("email")`, not `inp("user__")`.
|
|
500
|
+
*/
|
|
501
|
+
interface XanoDbLink {
|
|
502
|
+
readonly __dbLink?: never;
|
|
503
|
+
}
|
|
504
|
+
/** One `{ lng, lat }` position, as the engine both accepts and returns. */
|
|
505
|
+
interface XanoGeoPosition {
|
|
506
|
+
lng: number;
|
|
507
|
+
lat: number;
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* The `data` nesting for each geo `type` name. The names are the engine's own
|
|
511
|
+
* and the ONLY spellings it takes — `"multipoint"`, `"linestring"`,
|
|
512
|
+
* `"multipoly"` and the other guessable names are refused with a 400.
|
|
513
|
+
*
|
|
514
|
+
* | column | `type` | `data` |
|
|
515
|
+
* |-------------------------|----------|------------------------|
|
|
516
|
+
* | `f.geo.point` | `point` | one position |
|
|
517
|
+
* | `f.geo.multipoint` | `points` | positions |
|
|
518
|
+
* | `f.geo.linestring` | `path` | positions |
|
|
519
|
+
* | `f.geo.multilinestring` | `paths` | arrays of positions |
|
|
520
|
+
* | `f.geo.polygon` | `poly` | positions (ring closed for you) |
|
|
521
|
+
* | `f.geo.multipolygon` | `polys` | arrays of positions |
|
|
522
|
+
*/
|
|
523
|
+
interface XanoGeoData {
|
|
524
|
+
point: XanoGeoPosition;
|
|
525
|
+
points: XanoGeoPosition[];
|
|
526
|
+
path: XanoGeoPosition[];
|
|
527
|
+
paths: XanoGeoPosition[][];
|
|
528
|
+
poly: XanoGeoPosition[];
|
|
529
|
+
polys: XanoGeoPosition[][];
|
|
530
|
+
}
|
|
531
|
+
/** A geo `type` name: `point`, `points`, `path`, `paths`, `poly`, `polys`. */
|
|
532
|
+
type XanoGeoType = keyof XanoGeoData;
|
|
533
|
+
/**
|
|
534
|
+
* The value of an `f.geo.*` column: `{ type, data }`, NOT GeoJSON (no
|
|
535
|
+
* `coordinates`, no `"Point"`/`"MultiPoint"` keywords).
|
|
536
|
+
*
|
|
537
|
+
* The same shape goes in and comes back: `{ type: "point", data: { lng: 1,
|
|
538
|
+
* lat: 2 } }` reads back identical, and a `poly` ring reads back closed. Each
|
|
539
|
+
* column's row type narrows `T` to its own name, so `f.geo.multipoint` reads as
|
|
540
|
+
* `XanoGeoValue<"points">`. With no argument this is the union of all six.
|
|
541
|
+
*
|
|
542
|
+
* Raw WKT text (`c.text("POINT(1 2)")`) is also accepted wherever a value is
|
|
543
|
+
* taken — it is just not the typed path, because a read never returns one.
|
|
544
|
+
*/
|
|
545
|
+
type XanoGeoValue<T extends XanoGeoType = XanoGeoType> = {
|
|
546
|
+
[K in T]: {
|
|
547
|
+
type: K;
|
|
548
|
+
data: XanoGeoData[K];
|
|
549
|
+
};
|
|
550
|
+
}[T];
|
|
551
|
+
/**
|
|
552
|
+
* Which surface a field is read on. Inputs and columns share one stored shape but
|
|
553
|
+
* not one set of `nullable` defaults, so the value type of the SAME descriptor
|
|
554
|
+
* can differ: `f.date()` is `string` as a column and `string | null` inside an
|
|
555
|
+
* input object.
|
|
556
|
+
*/
|
|
557
|
+
type ValueSurface = "input" | "column";
|
|
558
|
+
/** Stored types nullable by default on surface `Sf` — the encoder's own lists. */
|
|
559
|
+
type NullableByDefault<Sf extends ValueSurface> = Sf extends "column" ? (typeof COLUMN_NULLABLE_TYPES)[number] : (typeof INPUT_NULLABLE_TYPES)[number];
|
|
560
|
+
/**
|
|
561
|
+
* Phantom brand intersected onto a descriptor's return type. `V` is the field's
|
|
562
|
+
* base value type; `O` is the literal options object captured via a `const` type
|
|
563
|
+
* parameter at the call site; `T` is the stored type (`"date"`, `"blob_img"`, …),
|
|
564
|
+
* which decides the `nullable` default. All props are optional and never present
|
|
565
|
+
* at runtime.
|
|
566
|
+
*/
|
|
567
|
+
interface TypeBrand<V, O, T extends string = string> {
|
|
568
|
+
readonly __value?: V;
|
|
569
|
+
readonly __opts?: O;
|
|
570
|
+
readonly __type?: T;
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* The value of an object field, kept unresolved until a surface reads it: its
|
|
574
|
+
* children's `nullable` defaults depend on whether the object is an input or a
|
|
575
|
+
* column. Type-level only.
|
|
576
|
+
*/
|
|
577
|
+
interface ObjectOf<C> {
|
|
578
|
+
readonly __objectOf: C;
|
|
579
|
+
}
|
|
580
|
+
/** Resolve an {@link ObjectOf} value against surface `Sf`; any other value is unchanged. */
|
|
581
|
+
type ResolveValue<V, Sf extends ValueSurface> = V extends ObjectOf<infer C> ? FromFieldMap<C, Sf> : V;
|
|
582
|
+
/** A branded descriptor's value exactly as branded — objects still unresolved. */
|
|
583
|
+
type RawBrandValue<D> = D extends TypeBrand<infer V, unknown> ? V : unknown;
|
|
584
|
+
/** The base value type carried by a branded descriptor `D` (before array/nullable), read on surface `Sf`. */
|
|
585
|
+
type BrandValue<D, Sf extends ValueSurface = "input"> = ResolveValue<RawBrandValue<D>, Sf>;
|
|
586
|
+
/** The literal options object captured on a branded descriptor `D`. */
|
|
587
|
+
type BrandOpts<D> = D extends TypeBrand<unknown, infer O> ? O : object;
|
|
588
|
+
/** The stored type carried by a branded descriptor `D`; `string` when unbranded. */
|
|
589
|
+
type BrandType<D> = D extends TypeBrand<unknown, unknown, infer T> ? T : string;
|
|
590
|
+
type ApplyArray<T, O> = O extends {
|
|
591
|
+
array: true;
|
|
592
|
+
} ? T[] : T;
|
|
593
|
+
/**
|
|
594
|
+
* `| null` when the field can hold null: an explicit `nullable: true`, a
|
|
595
|
+
* `nullable` flag that is not a literal `false`, or no flag on a type the
|
|
596
|
+
* surface makes nullable by default.
|
|
597
|
+
*/
|
|
598
|
+
type ApplyNullable<T, O, St extends string, Sf extends ValueSurface> = O extends {
|
|
599
|
+
nullable: false;
|
|
600
|
+
} ? T : O extends {
|
|
601
|
+
nullable: boolean;
|
|
602
|
+
} ? T | null : [St] extends [NullableByDefault<Sf>] ? T | null : T;
|
|
603
|
+
/**
|
|
604
|
+
* The full value type of a single branded descriptor `D` read on surface `Sf`:
|
|
605
|
+
* its base value with `array` and `nullable` applied, `nullable` defaulting per
|
|
606
|
+
* stored type exactly as the encoder does. (Optionality of the *key* is a
|
|
607
|
+
* map-level concern handled by {@link FromFieldMap}.)
|
|
608
|
+
*/
|
|
609
|
+
type ValueOf<D, Sf extends ValueSurface> = ApplyNullable<ApplyArray<BrandValue<D, Sf>, BrandOpts<D>>, BrandOpts<D>, BrandType<D>, Sf>;
|
|
610
|
+
/** Keys whose descriptor options declare `required: true`. */
|
|
611
|
+
type RequiredKeys<M> = {
|
|
612
|
+
[K in keyof M]: BrandOpts<M[K]> extends {
|
|
613
|
+
required: true;
|
|
614
|
+
} ? K : never;
|
|
615
|
+
}[keyof M];
|
|
616
|
+
/** Keys without `required: true` — optional in the produced payload type. */
|
|
617
|
+
type OptionalKeys<M> = Exclude<keyof M, RequiredKeys<M>>;
|
|
618
|
+
/**
|
|
619
|
+
* Turn a named map of branded descriptors into an object type: required inputs
|
|
620
|
+
* become required keys, everything else becomes an optional (`?`) key. Used for
|
|
621
|
+
* a query's top-level `input` map (surface `"input"`), a seed row (`"column"`),
|
|
622
|
+
* and nested `object` children (the enclosing field's surface).
|
|
623
|
+
*/
|
|
624
|
+
type FromFieldMap<M, Sf extends ValueSurface = "input"> = Prettify<{
|
|
625
|
+
[K in RequiredKeys<M>]: ValueOf<M[K], Sf>;
|
|
626
|
+
} & {
|
|
627
|
+
[K in OptionalKeys<M>]?: ProtoKeySafe<K, ValueOf<M[K], Sf>>;
|
|
628
|
+
}>;
|
|
629
|
+
/**
|
|
630
|
+
* The value type of an OPTIONAL key named after an `Object.prototype` member
|
|
631
|
+
* (`constructor`, `toString`, `valueOf`, …). TypeScript checks an object
|
|
632
|
+
* literal's inherited member against such a key even when the literal omits it,
|
|
633
|
+
* so `{ name: "x" }` failed against `{ constructor?: number }` with "Function is
|
|
634
|
+
* not assignable". Widening only those keys to also admit the inherited member
|
|
635
|
+
* lets a literal omit the column; every other key is untouched.
|
|
636
|
+
*/
|
|
637
|
+
type ProtoKeySafe<K, V> = K extends keyof Object ? V | Object[K] : V;
|
|
638
|
+
/**
|
|
639
|
+
* Turn a named map of branded descriptors into a **row** type — the read shape
|
|
640
|
+
* of a table. Unlike {@link FromFieldMap} (a request payload, where `required`
|
|
641
|
+
* gates key optionality), every declared column is present on a returned row, so
|
|
642
|
+
* all keys are required here; `nullable`/`array` still apply via {@link ValueOf}.
|
|
643
|
+
* Powers `InferRow<typeof table>` (see `../kinds/table.ts`) on surface
|
|
644
|
+
* `"column"`, and an agent's structured output on `"input"`.
|
|
645
|
+
*/
|
|
646
|
+
type RowFromFieldMap<M, Sf extends ValueSurface = "column"> = Prettify<{
|
|
647
|
+
[K in keyof M]: ValueOf<M[K], Sf>;
|
|
648
|
+
}>;
|
|
649
|
+
/** Flatten an intersection into a single object literal for readable hovers. */
|
|
650
|
+
type Prettify<T> = {
|
|
651
|
+
[K in keyof T]: T[K];
|
|
652
|
+
} & {};
|
|
653
|
+
/**
|
|
654
|
+
* A const-inferred record `T` checked against the keys of `Shape`: every key
|
|
655
|
+
* `Shape` does not declare is retyped to a record naming the `Allowed` keys, so
|
|
656
|
+
* a misspelling (`perPage`, `filter`, `temprature`) is a compile error on that
|
|
657
|
+
* key. A generic parameter is inferred FROM the literal, so without this it
|
|
658
|
+
* widens to include the typo and TypeScript's excess-property check never runs.
|
|
659
|
+
* An object, not a string, so intersecting a literal (`5 & …`) is not `never`.
|
|
660
|
+
*/
|
|
661
|
+
type NoExtraKeys<T, Shape, Allowed extends string> = NoInfer<{
|
|
662
|
+
[K in Exclude<keyof T, keyof Shape>]: {
|
|
663
|
+
"unknown key; expected one of": Allowed;
|
|
664
|
+
};
|
|
665
|
+
}>;
|
|
666
|
+
|
|
667
|
+
declare const REFERENCEABLE_KINDS: Set<string>;
|
|
668
|
+
/**
|
|
669
|
+
* A reference to another workspace object: its def handle, or a bare name.
|
|
670
|
+
*
|
|
671
|
+
* A def may carry an explicit `guid` (its Xano identity). When present it's used
|
|
672
|
+
* verbatim; otherwise the guid is derived from `name`. Pass def handles (which
|
|
673
|
+
* carry the `guid`) rather than bare names when an object sets an explicit guid,
|
|
674
|
+
* so the reference and the target agree on the *same* guid.
|
|
675
|
+
*/
|
|
676
|
+
type ObjectRef = string | {
|
|
677
|
+
name: string;
|
|
678
|
+
guid?: string;
|
|
679
|
+
};
|
|
680
|
+
/**
|
|
681
|
+
* The guid for a `(type, name)` pair. A seeded `xano.lock` override wins (the
|
|
682
|
+
* lock freezes identity across renames — see lock/store.ts); otherwise the
|
|
683
|
+
* deterministic 32-char hex derivation. Every reference and every emitted
|
|
684
|
+
* target flows through here, so a lock override propagates everywhere by
|
|
685
|
+
* construction — including guids embedded inside strings at authoring time.
|
|
686
|
+
*/
|
|
687
|
+
declare function deriveGuid(type: string, name: string): string;
|
|
688
|
+
/**
|
|
689
|
+
* Resolve a reference target (def handle or name) to the referenced object's guid.
|
|
690
|
+
*
|
|
691
|
+
* `where` names the argument for the failure (`Statement "s.db.get": argument
|
|
692
|
+
* "table"`); without it the message still names the reference by its SDK kind.
|
|
693
|
+
* `kindLabel` overrides that kind where one stored type serves two — an agent is
|
|
694
|
+
* stored as a `toolset`, a word the author never typed.
|
|
695
|
+
*/
|
|
696
|
+
declare function resolveRef(type: string, target: ObjectRef, where?: string, kindLabel?: string): string;
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* Per-field-type method-name unions, distilled from the engine's column-create
|
|
700
|
+
* API schema (the per-type field-schema definitions). Each
|
|
701
|
+
* `f.<type>` / `input.<type>` constructor types its `methods` against the
|
|
702
|
+
* matching union so only names valid for that field type are accepted (the
|
|
703
|
+
* explicit `{ name, arg }` form remains a universal escape hatch).
|
|
704
|
+
*/
|
|
705
|
+
/** Per-field-type method metadata (method name → colon-form arg type; `bool` = flag, no arg). */
|
|
706
|
+
declare const FIELD_METHODS: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
707
|
+
/** Field methods valid on `decimal` fields. */
|
|
708
|
+
type DecimalMethod = "max" | "min";
|
|
709
|
+
/** Field methods valid on `email` fields. */
|
|
710
|
+
type EmailMethod = "lower" | "trim";
|
|
711
|
+
/** Field methods valid on `int` fields. */
|
|
712
|
+
type IntMethod = "max" | "min";
|
|
713
|
+
/** Field methods valid on `password` fields. */
|
|
714
|
+
type PasswordMethod = "max" | "min" | "minAlpha" | "minDigit" | "minLowerAlpha" | "minSymbol" | "minUpperAlpha" | "salt";
|
|
715
|
+
/** Field methods valid on `tableRef` fields. */
|
|
716
|
+
type TableRefMethod = "max" | "min";
|
|
717
|
+
/** Field methods valid on `text` fields. */
|
|
718
|
+
type TextMethod = "alphaOk" | "digitOk" | "lower" | "max" | "min" | "ok" | "pattern" | "startsWith" | "trim" | "upper";
|
|
719
|
+
/** Field methods valid on `vector` fields. */
|
|
720
|
+
type VectorMethod = "max" | "min";
|
|
721
|
+
|
|
722
|
+
/** A typed field, ready to attach to a column/input name. */
|
|
723
|
+
interface FieldDescriptor {
|
|
724
|
+
/** The **stored** type string (post-mapping), e.g. `blob_img`, `epochms`. */
|
|
725
|
+
type: string;
|
|
726
|
+
options: FieldOptions;
|
|
727
|
+
}
|
|
728
|
+
/** A named map of fields — used for table schemas and object children. */
|
|
729
|
+
type FieldMap = Record<string, FieldDescriptor>;
|
|
730
|
+
/** Options accepted by every catalog constructor (no `values`/`children`/`vector` — those are positional). */
|
|
731
|
+
type FieldOpts = Omit<FieldOptions, "values" | "children" | "vector">;
|
|
732
|
+
/**
|
|
733
|
+
* {@link FieldOpts} with `methods` narrowed to the field type's valid method set
|
|
734
|
+
* `N` (see {@link MethodArg}). Types with no engine-declared methods use
|
|
735
|
+
* `MethodOpts<never>`, leaving only the `{ name, arg }` escape hatch.
|
|
736
|
+
*/
|
|
737
|
+
type MethodOpts<N extends string> = Omit<FieldOpts, "methods"> & {
|
|
738
|
+
methods?: MethodArg<N>[];
|
|
739
|
+
};
|
|
740
|
+
/** {@link MethodOpts} made safe to capture under a `const` type parameter (see {@link ReadonlyMethods}). */
|
|
741
|
+
type ConstMethodOpts<N extends string> = ReadonlyMethods<MethodOpts<N>, N>;
|
|
742
|
+
/**
|
|
743
|
+
* An enum's `default` must be one of its `values` (or `""`, no default): the
|
|
744
|
+
* engine stores any text, and a default outside the list is a value no request
|
|
745
|
+
* can send back.
|
|
746
|
+
*/
|
|
747
|
+
type EnumDefault<V extends ReadonlyArray<string | number>, O = unknown> = NoInfer<O extends {
|
|
748
|
+
default: infer D;
|
|
749
|
+
} ? [D] extends [V[number] | `${V[number]}` | ""] ? unknown : {
|
|
750
|
+
default: {
|
|
751
|
+
"default must be one of": `${V[number]}`;
|
|
752
|
+
};
|
|
753
|
+
} : unknown>;
|
|
754
|
+
/** Convert a named field map into the encoder's `NestedField[]` form. */
|
|
755
|
+
declare function toNestedFields(map: FieldMap): NestedField[];
|
|
756
|
+
/**
|
|
757
|
+
* The stored scalar type of a `tableRef` FK, derived from its `type` option: a
|
|
758
|
+
* `uuid`-keyed reference stores a `string`, everything else (the default `int`)
|
|
759
|
+
* stores a `number`. Keeps `InferRow` honest — a FK column is the referenced
|
|
760
|
+
* table's PK value, never the loose `string | number`.
|
|
761
|
+
*/
|
|
762
|
+
type TableRefValue<T, O> = TableRefType<T, O> extends "uuid" ? string : number;
|
|
763
|
+
/**
|
|
764
|
+
* The stored type of a `tableRef` FK: the `type` option when given, else the
|
|
765
|
+
* handle's own `idType` (a uuid-keyed `table()` makes a uuid column), else `int`.
|
|
766
|
+
*/
|
|
767
|
+
type TableRefType<T, O> = O extends {
|
|
768
|
+
type: infer K extends "int" | "uuid";
|
|
769
|
+
} ? K : T extends {
|
|
770
|
+
readonly __row?: infer R;
|
|
771
|
+
} ? R extends {
|
|
772
|
+
id: infer I;
|
|
773
|
+
} ? [I] extends [string] ? "uuid" : "int" : "int" : "int";
|
|
774
|
+
/** The rich field-type catalog. */
|
|
775
|
+
declare const f: {
|
|
776
|
+
readonly text: <const O extends ConstMethodOpts<TextMethod> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<string, O, "text">;
|
|
777
|
+
readonly int: <const O extends ConstMethodOpts<IntMethod> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<number, O, "int">;
|
|
778
|
+
readonly decimal: <const O extends ConstMethodOpts<DecimalMethod> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<number, O, "decimal">;
|
|
779
|
+
readonly bool: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<boolean, O, "bool">;
|
|
780
|
+
readonly uuid: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<string, O, "uuid">;
|
|
781
|
+
readonly date: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<string, O, "date">;
|
|
782
|
+
readonly email: <const O extends ConstMethodOpts<EmailMethod> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<string, O, "email">;
|
|
783
|
+
/** Password field; defaults to `access:"internal"` (the engine's stored default). */
|
|
784
|
+
readonly password: <const O extends ConstMethodOpts<PasswordMethod> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<string, O, "password">;
|
|
785
|
+
/**
|
|
786
|
+
* JSON column. Accepts an optional nested `children` schema — the structure the
|
|
787
|
+
* editor shows when a `json` field is expanded, and what a pulled workspace
|
|
788
|
+
* carries.
|
|
789
|
+
*
|
|
790
|
+
* `children` is spelled as an ARRAY of named, typed fields rather than the
|
|
791
|
+
* `FieldMap` {@link FieldCatalog.object} takes positionally. The two are not
|
|
792
|
+
* interchangeable: an object column's children are the column's own schema,
|
|
793
|
+
* while a json column's are a description of the shape stored inside it, which
|
|
794
|
+
* the engine persists in the order given. That order is part of the stored
|
|
795
|
+
* bytes, and a map does not preserve it.
|
|
796
|
+
*
|
|
797
|
+
* Without this there is no way to author a structured JSON column at all.
|
|
798
|
+
*/
|
|
799
|
+
readonly json: <const O extends ConstMethodOpts<never> & {
|
|
800
|
+
children?: readonly NestedField[];
|
|
801
|
+
} = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<unknown, O, "json">;
|
|
802
|
+
/** Epoch-millisecond timestamp (authored as `timestamp`). */
|
|
803
|
+
readonly timestamp: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<number, O, "epochms">;
|
|
804
|
+
/** Image file resource (stored `blob_img`). */
|
|
805
|
+
readonly image: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<XanoFileRef, O, "blob_img">;
|
|
806
|
+
/** Video file resource (stored `blob_video`). */
|
|
807
|
+
readonly video: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<XanoFileRef, O, "blob_video">;
|
|
808
|
+
/** Audio file resource (stored `blob_audio`). */
|
|
809
|
+
readonly audio: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<XanoFileRef, O, "blob_audio">;
|
|
810
|
+
/** Generic file attachment (stored `blob`). */
|
|
811
|
+
readonly attachment: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<XanoFileRef, O, "blob">;
|
|
812
|
+
readonly geo: {
|
|
813
|
+
/** Value `{ type: "point", data: { lng, lat } }`. */
|
|
814
|
+
readonly point: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<{
|
|
815
|
+
type: "point";
|
|
816
|
+
data: XanoGeoPosition;
|
|
817
|
+
}, O, "geo_point">;
|
|
818
|
+
/** Value `{ type: "points", data: [{ lng, lat }, …] }`. */
|
|
819
|
+
readonly multipoint: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<{
|
|
820
|
+
type: "points";
|
|
821
|
+
data: XanoGeoPosition[];
|
|
822
|
+
}, O, "geo_multipoint">;
|
|
823
|
+
/** Value `{ type: "path", data: [{ lng, lat }, …] }`. */
|
|
824
|
+
readonly linestring: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<{
|
|
825
|
+
type: "path";
|
|
826
|
+
data: XanoGeoPosition[];
|
|
827
|
+
}, O, "geo_linestring">;
|
|
828
|
+
/** Value `{ type: "paths", data: [[{ lng, lat }, …], …] }`. */
|
|
829
|
+
readonly multilinestring: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<{
|
|
830
|
+
type: "paths";
|
|
831
|
+
data: XanoGeoPosition[][];
|
|
832
|
+
}, O, "geo_multilinestring">;
|
|
833
|
+
/** Value `{ type: "poly", data: [{ lng, lat }, …] }` — the ring is closed for you. */
|
|
834
|
+
readonly polygon: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<{
|
|
835
|
+
type: "poly";
|
|
836
|
+
data: XanoGeoPosition[];
|
|
837
|
+
}, O, "geo_polygon">;
|
|
838
|
+
/** Value `{ type: "polys", data: [[{ lng, lat }, …], …] }`. */
|
|
839
|
+
readonly multipolygon: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<{
|
|
840
|
+
type: "polys";
|
|
841
|
+
data: XanoGeoPosition[][];
|
|
842
|
+
}, O, "geo_multipolygon">;
|
|
843
|
+
};
|
|
844
|
+
/**
|
|
845
|
+
* Enum field. `values` may be empty — that is an enum column added in the
|
|
846
|
+
* editor and not yet given its options, which the engine stores and which
|
|
847
|
+
* appears in the survey corpus. Refusing it made the SDK stricter than the
|
|
848
|
+
* engine and cost a real table its readable form.
|
|
849
|
+
*
|
|
850
|
+
* An empty `values` brands the column `never` — an enum permitting nothing can
|
|
851
|
+
* hold nothing. Note what that becomes downstream: `InferRow` surfaces the
|
|
852
|
+
* column as `undefined`, not `never`, so a read-time narrow written against
|
|
853
|
+
* `never` (`if (row.e === "x")`) is dead differently than it looks.
|
|
854
|
+
*/
|
|
855
|
+
readonly enum: <const V extends ReadonlyArray<string | number>, const O extends ConstMethodOpts<never> = Record<string, never>>(values: V, options?: O & EnumDefault<V, O>) => FieldDescriptor & TypeBrand<V[number], O, "enum">;
|
|
856
|
+
/** Vector field; `size` (>= 1) is the embedding dimensionality. */
|
|
857
|
+
readonly vector: <const O extends ConstMethodOpts<VectorMethod> = Record<string, never>>(size: number, options?: O) => FieldDescriptor & TypeBrand<number[], O, "vector">;
|
|
858
|
+
/** Nested object field (stored `obj`); `children` is a named field map. */
|
|
859
|
+
readonly object: <const C extends FieldMap, const O extends ConstMethodOpts<never> = Record<string, never>>(children: C, options?: O) => FieldDescriptor & TypeBrand<ObjectOf<C>, O, "obj">;
|
|
860
|
+
/**
|
|
861
|
+
* Table-reference (foreign-key) field — the column holds the referenced
|
|
862
|
+
* table's primary key. The engine persists the link as a trailing `@` method
|
|
863
|
+
* carrying the target table's id (`{name:"@", arg:["dbo=<guid>"]}`); on import
|
|
864
|
+
* it parses that back into the column's `tableref_id`. The reference resolves to the
|
|
865
|
+
* table's deterministic guid via the shared cross-object resolver, so it
|
|
866
|
+
* agrees with the target table's payload `guid` with no shared registry.
|
|
867
|
+
*
|
|
868
|
+
* The column takes the target handle's key type (`idType`), else `int`; pass
|
|
869
|
+
* `{ type: "uuid" }` for a uuid-keyed table named by bare string. A reference
|
|
870
|
+
* column may only be `int` or `uuid` — the two valid primary-key types.
|
|
871
|
+
*
|
|
872
|
+
* @param table The referenced table (a `table()` def handle or its bare name).
|
|
873
|
+
* For a **self-reference** (e.g. `tweets.reply_to → tweets`), the table's
|
|
874
|
+
* `const` binding isn't assigned yet inside its own initializer — using the
|
|
875
|
+
* handle throws a "used before declaration" error. Pass the **bare name**
|
|
876
|
+
* instead: `f.tableRef("tweets", { type: "int" })`. Identity guids derive
|
|
877
|
+
* from `(type, name)`, so the name form resolves to the same guid.
|
|
878
|
+
*
|
|
879
|
+
* Byte-verified whole-object against a persisted table readback: the `@`
|
|
880
|
+
* method carries
|
|
881
|
+
* `disabled:false`, sits last in `methods`, and its `dbo=` arg is the target
|
|
882
|
+
* table's payload guid.
|
|
883
|
+
*
|
|
884
|
+
* The engine asserts the referenced table's primary-key type matches
|
|
885
|
+
* (int↔int, uuid↔uuid). When the target is passed as a **def handle** its
|
|
886
|
+
* `idType` is in hand, so a mismatch throws here instead of surfacing as an
|
|
887
|
+
* import failure. The bare-name form (self-references) carries no schema —
|
|
888
|
+
* there is nothing to check against, and it is not guessed at.
|
|
889
|
+
*/
|
|
890
|
+
readonly tableRef: <const T extends ObjectRef, const O extends ConstMethodOpts<TableRefMethod> & {
|
|
891
|
+
type?: "int" | "uuid";
|
|
892
|
+
} = Record<string, never>>(table: T, options?: O) => FieldDescriptor & TypeBrand<TableRefValue<T, O>, O, TableRefType<T, O>>;
|
|
893
|
+
};
|
|
894
|
+
|
|
895
|
+
/**
|
|
896
|
+
* Response → `result[]` mapping, shared by every response-bearing kind
|
|
897
|
+
* (function, query, tool, middleware, and the response-bearing triggers).
|
|
898
|
+
* Extracted from the MVP's compile.ts so kinds beyond function can reuse it.
|
|
899
|
+
*/
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* A member of a record response — a {@link Value}, or a nested plain object
|
|
903
|
+
* literal which is auto-wrapped via {@link obj} (so `response: { user: { id:
|
|
904
|
+
* ref(x) } }` just works instead of failing tsc against `TaggedValue`).
|
|
905
|
+
* A nested record refuses at the type level the values `obj()` refuses
|
|
906
|
+
* (`caught()`, `toolset()`, `resp()`, `out()`); a top-level key carries them.
|
|
907
|
+
*/
|
|
908
|
+
type ResponseMember = Value | ResponseRecord;
|
|
909
|
+
/** A nested response record: an `ObjInput` whose members are never `NotObjMember`s. */
|
|
910
|
+
interface ResponseRecord {
|
|
911
|
+
[key: string]: ResponseRecordMember;
|
|
912
|
+
}
|
|
913
|
+
type ResponseRecordMember = (Value & {
|
|
914
|
+
readonly __notObjMember?: NestedRecordRefusal;
|
|
915
|
+
}) | string | number | boolean | ResponseRecord | ResponseRecordMember[];
|
|
916
|
+
/** What a nested response record says to a value it cannot carry. */
|
|
917
|
+
type NestedRecordRefusal = "a nested response record cannot carry this value — bind it with s.set_var first and ref() the variable, or move it to a top-level response key";
|
|
918
|
+
/** A single `Value` response, or a record of named result items. */
|
|
919
|
+
type ResponseDef = Value | Record<string, ResponseMember>;
|
|
920
|
+
/** Map a response into `result[]`: one unnamed item for a single value, or
|
|
921
|
+
* one named item per key for a record. A record member that is a nested plain
|
|
922
|
+
* object is auto-wrapped via {@link obj} (a dynamic `const:expr2` value). */
|
|
923
|
+
declare function encodeResponse(response: ResponseDef | undefined): ResultItemXdo[];
|
|
924
|
+
|
|
925
|
+
export { type XanoGeoType as $, type AppendBrand as A, type BodyBrand as B, type CatchBrand as C, type DecimalMethod as D, type EmailMethod as E, type FieldAccess as F, type RowFromFieldMap as G, type StatementAnnotations as H, type IntMethod as I, type StatementOptions as J, type TextFormat as K, type TextMethod as L, type MaybeBodyBrand as M, type NoExtraKeys as N, type ObjectOf as O, type PasswordMethod as P, type TypeBrand as Q, type RawBrandValue as R, type Statement as S, type TableRefMethod as T, type VectorMethod as U, type ValueOf as V, type XanoFileRef as W, type XanoDbLink as X, type XanoFileUpload as Y, type XanoGeoData as Z, type XanoGeoPosition as _, type AsShapeBrand as a, type XanoGeoValue as a0, annotate as a1, f as a2, statements as a3, FIELD_METHODS as a4, REFERENCEABLE_KINDS as a5, deriveGuid as a6, encodeResponse as a7, encodeStatement as a8, getStatementFactory as a9, isRegisteredStatement as aa, resolveRef as ab, toNestedFields as ac, type BranchesBrand as b, type BrandOpts as c, type BrandType as d, type BrandValue as e, type ConstMethodOpts as f, type EnumDefault as g, type FieldDescriptor as h, type FieldMap as i, type FieldOptions as j, type FieldOpts as k, type FieldStyleType as l, type FoundBrand as m, type FromFieldMap as n, type MemberUpdateBrand as o, type MethodArg as p, type MethodOpts as q, type MethodSpec as r, type MockEntry as s, type MockMap as t, type MockXdo as u, type ObjectRef as v, type Prettify as w, type ProtoKeySafe as x, type ReadonlyMethods as y, type ResponseDef as z };
|