@xanots/sdk 0.0.10 → 0.0.12
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 +33 -0
- package/README.md +48 -5
- package/dist/.build-fingerprint +1 -1
- package/dist/{agent-file-refresh-QNKN5RYD.js → agent-file-refresh-GQWAAOBV.js} +4 -4
- package/dist/bin.js +12 -11
- package/dist/{branch-commands-2BLOC2GR.js → branch-commands-5KMPAAZV.js} +7 -7
- package/dist/bundle.d.ts +218 -0
- package/dist/bundle.js +143 -0
- package/dist/{capture-4WVJY4DQ.js → capture-YLUVAITI.js} +2 -2
- package/dist/chunk-2VTJSI6X.js +192 -0
- package/dist/{chunk-5XZ744TS.js → chunk-2ZCUO2UG.js} +1 -1
- package/dist/{chunk-OYMR5AMJ.js → chunk-3LQGF2WS.js} +2 -2
- package/dist/{chunk-WP4OZZV4.js → chunk-3VFCKHOB.js} +2 -2
- package/dist/{chunk-XHEXOES3.js → chunk-5YDINUAP.js} +1 -1
- package/dist/{chunk-LU7TRWMC.js → chunk-6VNRMKFJ.js} +2 -2
- package/dist/{chunk-CTD5ZCV6.js → chunk-7WRJPKGK.js} +2 -2
- package/dist/{chunk-3INK4Y4E.js → chunk-AE3PDSDS.js} +1 -1
- package/dist/{chunk-5YCQ2QHH.js → chunk-AG5GCZDD.js} +2 -2
- package/dist/{chunk-DBFU47BJ.js → chunk-AOFFKSJC.js} +2 -2
- package/dist/{chunk-TCFIPDB3.js → chunk-AVGDL6RB.js} +1 -1
- package/dist/{chunk-4BXJGVZ3.js → chunk-DCMANKMX.js} +2 -69
- package/dist/{chunk-WHOJWOSV.js → chunk-EETVJZAZ.js} +1 -1
- package/dist/chunk-EHP3WPEG.js +21 -0
- package/dist/{chunk-W24FJHPD.js → chunk-ELK7UALJ.js} +3 -3
- package/dist/{chunk-VNQM3V2C.js → chunk-EXENFOWE.js} +2 -2
- package/dist/{chunk-P6TAVLOX.js → chunk-GSP2BY4F.js} +17 -10
- package/dist/{chunk-AIZKXUNP.js → chunk-IMLYGQK6.js} +2 -2
- package/dist/{chunk-LBYWGMOA.js → chunk-N74KDCBD.js} +176 -42
- package/dist/{chunk-3IGNIP6R.js → chunk-NDP7OUPS.js} +1 -1
- package/dist/chunk-OHX6MIUZ.js +184 -0
- package/dist/{chunk-EQW3YT5U.js → chunk-P6PVBQL6.js} +2 -2
- package/dist/{chunk-I7DQDJAM.js → chunk-PLE5QQOZ.js} +55 -56
- package/dist/chunk-PR7OXHGZ.js +70 -0
- package/dist/{chunk-VKSOTZK3.js → chunk-QYSQ3UDO.js} +160 -8
- package/dist/{chunk-ZQ2PKR6R.js → chunk-RQ3FXV4K.js} +2 -2
- package/dist/{chunk-Q77KNEUL.js → chunk-RQNMTDXD.js} +1703 -2
- package/dist/{chunk-QKM4U5UK.js → chunk-TJS2AF5Y.js} +2 -2
- package/dist/{chunk-DIA7CT7J.js → chunk-V5Y7D4LH.js} +11 -2
- package/dist/{chunk-KA6G2L7U.js → chunk-VK26K7AY.js} +3 -3
- package/dist/{chunk-YYFXVYPX.js → chunk-VPAWRBK5.js} +12 -16
- package/dist/{chunk-5R73LFWK.js → chunk-VRNZ2NVV.js} +7 -7
- package/dist/{chunk-ACCBOMCB.js → chunk-XT3XQ4PF.js} +32 -27
- package/dist/{chunk-7JDT4PBU.js → chunk-XWFRNJMQ.js} +5 -179
- package/dist/{chunk-7ZYW652H.js → chunk-YHS6VVLJ.js} +2 -2
- package/dist/{chunk-75Z74TA7.js → chunk-YX22LKQE.js} +2 -2
- package/dist/{chunk-F6CYJ7TN.js → chunk-Z2ZIE5CO.js} +2 -2
- package/dist/cli.d.ts +13 -6
- package/dist/cli.js +11 -10
- package/dist/codegen-command-Y2SPMAUW.js +47 -0
- package/dist/codegen.d.ts +5 -4
- package/dist/codegen.js +2 -2
- package/dist/{completion-WF46272M.js → completion-HJU5QEFB.js} +2 -2
- package/dist/{deploy-command-QTIVA22A.js → deploy-command-XHS5PKPV.js} +20 -19
- package/dist/{ephemeral-command-U4AQ3TXX.js → ephemeral-command-2NKPEXUU.js} +8 -8
- package/dist/index.d.ts +88 -102
- package/dist/index.js +13 -12
- package/dist/init-command-23FFNUFT.js +32 -0
- package/dist/internal.d.ts +10 -16
- package/dist/internal.js +76 -54
- package/dist/io-UBDMMDH6.js +12 -0
- package/dist/{live-diff-IXKBVG4K.js → live-diff-HCOTN5WC.js} +3 -3
- package/dist/{lock-GFXD6G2E.js → lock-HQ4KARU2.js} +3 -2
- package/dist/{lock-commands-DQ7CUMIV.js → lock-commands-WCRC56ME.js} +12 -11
- package/dist/{login-command-Z6CHTA57.js → login-command-P7LXD5TE.js} +6 -6
- package/dist/{loop-D5NPL4VH.js → loop-IC5ISSYB.js} +3 -3
- package/dist/{marketplace-command-P4IPLJ6J.js → marketplace-command-T6JCHW7J.js} +4 -4
- package/dist/{meta-client-K2J4XH64.js → meta-client-LKRKR3L2.js} +4 -4
- package/dist/node.d.ts +6 -5
- package/dist/node.js +18 -17
- package/dist/{preflight-command-GZ2GE5RN.js → preflight-command-TZWPHBXY.js} +17 -16
- package/dist/{profile-command-LJSBDV2L.js → profile-command-WBNSMQSI.js} +3 -3
- package/dist/{release-command-YUBTNHVX.js → release-command-WEFYRTCI.js} +27 -26
- package/dist/response-D6xGLEIn.d.ts +839 -0
- package/dist/{routes-manifest-PWZHDOI5.js → routes-manifest-5ZFKUQWA.js} +2 -2
- package/dist/{runtime-V4C3AC3A.js → runtime-LSLIDALK.js} +1 -1
- package/dist/scaffold.d.ts +16 -8
- package/dist/scaffold.js +7 -11
- package/dist/{static-host-3WMV7IZO.js → static-host-4JDQCHUW.js} +1 -1
- package/dist/{status-command-AL47VG7H.js → status-command-VARULAR5.js} +4 -4
- package/dist/{store-BG1UPZ3Z.d.ts → store-DAnUIi1T.d.ts} +95 -87
- package/dist/{test-command-YAZLKLGQ.js → test-command-YCAR4O35.js} +7 -7
- package/dist/{upgrade-command-FB5QJ363.js → upgrade-command-GYEIMJBG.js} +16 -16
- package/dist/{workspace-2COHDBM3.js → workspace-33KHFLX3.js} +2 -2
- package/dist/{workspace-command-43P42FBP.js → workspace-command-2ZTGT26W.js} +28 -27
- package/dist/{workspace-export-DURY5WYL.js → workspace-export-MLYTYZS5.js} +3 -3
- package/dist/{response-CVAE2kMj.d.ts → xdo-ODuJklk6.d.ts} +28 -860
- package/guides/authoring.md +11 -2
- package/guides/typed-frontend.md +5 -5
- package/llms/filters.md +11 -10
- package/llms/kinds-core.md +1 -1
- package/llms/statements-data.md +6 -3
- package/llms/values.md +1 -1
- package/llms-full.txt +53 -42
- package/llms.txt +34 -27
- package/manifest.json +6 -2
- package/package.json +7 -2
- package/dist/chunk-ANUDXFEX.js +0 -881
- package/dist/chunk-JGCWTCA7.js +0 -95
- package/dist/chunk-YBC3IKMF.js +0 -845
- package/dist/codegen-command-GB3H2KQ7.js +0 -46
- package/dist/init-command-MAXULNAD.js +0 -33
- package/dist/io-M7XZEMK7.js +0 -11
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The shared tagged-value primitive
|
|
2
|
+
* The shared tagged-value primitive. Every place a function references
|
|
3
3
|
* data — input bindings, statement context, response — uses this `{value, tag,
|
|
4
4
|
* filters}` shape. Built and tested once here, reused everywhere.
|
|
5
5
|
*/
|
|
@@ -10,7 +10,7 @@ type Value = TaggedValue;
|
|
|
10
10
|
* A {@link Value} that also carries, **at the type level only**, the name of the
|
|
11
11
|
* stack variable it references (`ref("user")` → `RefValue<"user">`). The `__ref`
|
|
12
12
|
* carrier is phantom — never present at runtime — and required (not optional) so
|
|
13
|
-
* `InferResponse`'s trace
|
|
13
|
+
* `InferResponse`'s trace matches only real refs, never a plain `Value`.
|
|
14
14
|
* Because it is a subtype of `Value`, every existing `ref(...)` use — filter
|
|
15
15
|
* args, `db.query` `where`, response fields — keeps type-checking unchanged.
|
|
16
16
|
*/
|
|
@@ -41,7 +41,7 @@ type FilteredValue<Base = unknown, Chain extends readonly unknown[] = readonly u
|
|
|
41
41
|
* an editor's hover distinguishes a pattern from the text beside it.
|
|
42
42
|
*
|
|
43
43
|
* It is deliberately NOT used to restrict `s.expect.to_match` or the `fl.regex_*`
|
|
44
|
-
* pattern slot
|
|
44
|
+
* pattern slot. A nominal restriction there
|
|
45
45
|
* would have to reject `Value`, and `inp()`, `env()`, `auth()` and `sys.*` all
|
|
46
46
|
* return exactly `Value` — the same type `c.text` does — so it would reject every
|
|
47
47
|
* DYNAMIC pattern along with the broken constant ones. The enforcement is instead
|
|
@@ -63,15 +63,15 @@ type FlattenFilters<Fs extends readonly unknown[]> = Fs extends readonly [
|
|
|
63
63
|
* *statically rejected* where it would silently fail at runtime: inside a
|
|
64
64
|
* `db.edit`/`db.add` `row`, `{tag:"col"}` does not resolve to the row's stored
|
|
65
65
|
* value — it evaluates to `null`, so a following `fl.add(1)` computes `null + 1`
|
|
66
|
-
* and the engine aborts ("Numbers are required for mathematical operations"
|
|
67
|
-
*
|
|
66
|
+
* and the engine aborts ("Numbers are required for mathematical operations").
|
|
67
|
+
* `col()` is only meaningful in a `db.query` `where`/view expression.
|
|
68
68
|
*/
|
|
69
69
|
type ColValue = Value & {
|
|
70
70
|
readonly __col: true;
|
|
71
71
|
};
|
|
72
72
|
/**
|
|
73
73
|
* The error branch surfaced when a tagged {@link Value} is nested inside a
|
|
74
|
-
* `c.obj`/`c.array` literal
|
|
74
|
+
* `c.obj`/`c.array` literal. The long message is the *property key*
|
|
75
75
|
* so TypeScript prints it verbatim in the "property … is missing" diagnostic; a
|
|
76
76
|
* `Value` has no such key, so intersecting it here makes the offending position
|
|
77
77
|
* fail to type-check. The runtime guard ({@link assertPlainJson}) carries the
|
|
@@ -107,7 +107,7 @@ type BlankTag = Exclude<Extract<Tag, `const${string}`>, "const" | "const:obj">;
|
|
|
107
107
|
/**
|
|
108
108
|
* Tags {@link c.null} can spell — the two the engine stores a `"null"` value
|
|
109
109
|
* under. `const:null` is the plain one; `const:obj` is the object-typed null a
|
|
110
|
-
* `db.*` statement's `@meta` slot carries
|
|
110
|
+
* `db.*` statement's `@meta` slot carries.
|
|
111
111
|
*
|
|
112
112
|
* Listed rather than derived: a `"null"` value under any OTHER constant tag is
|
|
113
113
|
* unobserved, and inventing spellings for it would offer an authoring form for
|
|
@@ -141,7 +141,7 @@ declare const c: {
|
|
|
141
141
|
* A `number` that is not an integer, or is past `Number.MAX_SAFE_INTEGER`,
|
|
142
142
|
* **throws**: by the time such a literal reaches here its precision is already
|
|
143
143
|
* gone, so encoding it would write a value the caller did not type. The throw
|
|
144
|
-
* names the string form.
|
|
144
|
+
* names the string form.
|
|
145
145
|
*/
|
|
146
146
|
int(n: number | bigint | string): Value;
|
|
147
147
|
/**
|
|
@@ -181,7 +181,7 @@ declare const c: {
|
|
|
181
181
|
* null** the engine writes into a `db.*` statement's `@meta` slot —
|
|
182
182
|
* `c.null("const:obj")` → `{tag:"const:obj", value:"null"}`, 16 of them across
|
|
183
183
|
* eight ordinary queries in the survey corpus, which had no spelling and came
|
|
184
|
-
* back as `rawValue
|
|
184
|
+
* back as `rawValue`.
|
|
185
185
|
*
|
|
186
186
|
* ⚠ Not the same bytes as `c.obj(null)`, which is the BLANK object
|
|
187
187
|
* (`value: ""`). Both evaluate to null — the engine JSON-decodes the stored
|
|
@@ -195,7 +195,7 @@ declare const c: {
|
|
|
195
195
|
* (`fl.regex_test`/`regex_match`/`regex_replace`/…). Xano runs PHP `preg_*`, so
|
|
196
196
|
* the pattern MUST be delimiter-wrapped — a bare `c.text("^…$")` is an invalid
|
|
197
197
|
* PCRE and the filter then matches *nothing* for every input, so a precondition
|
|
198
|
-
* built on it silently rejects all values
|
|
198
|
+
* built on it silently rejects all values. This wraps the raw
|
|
199
199
|
* pattern in `/…/`, escapes any interior `/`, and appends `flags`, so the result
|
|
200
200
|
* is always valid; `withFilters` rejects a bare `c.text` pattern and points here.
|
|
201
201
|
*
|
|
@@ -216,8 +216,13 @@ declare const c: {
|
|
|
216
216
|
* `text("now") |to_epoch_ms` chain; both evaluate to the same epoch-ms number
|
|
217
217
|
* on a live engine, and both persist verbatim, but the native tag is what the
|
|
218
218
|
* editor writes and needs no filter to get there. Chain math onto it as usual:
|
|
219
|
-
* `withFilters(c.now(), fl.epochms_add_ms(c.int(-maxAgeMs)))`.
|
|
220
|
-
*
|
|
219
|
+
* `withFilters(c.now(), fl.epochms_add_ms(c.int(-maxAgeMs)))`.
|
|
220
|
+
*
|
|
221
|
+
* Inside an `obj()` the tag is flattened into an expression string, where the
|
|
222
|
+
* identifier `now` alone is the STRING "now" — so `obj()` writes the
|
|
223
|
+
* `now|to_epochms` coercion that restores this tag's meaning. A `c.now()` used
|
|
224
|
+
* as a FILTER ARGUMENT there is refused: the coercion cannot be written in
|
|
225
|
+
* that position. Hoist it with `s.set_var` and `ref()` it.
|
|
221
226
|
*/
|
|
222
227
|
now(): Value;
|
|
223
228
|
/**
|
|
@@ -226,7 +231,6 @@ declare const c: {
|
|
|
226
231
|
* compile error and throws at runtime — it would serialize as internal
|
|
227
232
|
* representation the engine can't decode. For a computed/multi-key object
|
|
228
233
|
* response use a record of values (`response: { key: value }`), not `c.obj`.
|
|
229
|
-
* See issue #42.
|
|
230
234
|
*
|
|
231
235
|
* Called with no argument it is the **empty object**, `{}` — the same default
|
|
232
236
|
* the editor gives a new object variable, and the only empty form current
|
|
@@ -243,7 +247,7 @@ declare const c: {
|
|
|
243
247
|
* same bytes instead of being quietly re-pointed at `{}`.
|
|
244
248
|
*
|
|
245
249
|
* A **populated** object is stored the way the editor stores one: an empty
|
|
246
|
-
* `{}` base carrying one `set` filter per key
|
|
250
|
+
* `{}` base carrying one `set` filter per key. It is NOT a
|
|
247
251
|
* populated JSON string — that form fails the request at runtime, see
|
|
248
252
|
* {@link objSetFilters}.
|
|
249
253
|
*
|
|
@@ -257,7 +261,7 @@ declare const c: {
|
|
|
257
261
|
/**
|
|
258
262
|
* Array constant → JSON-string value with `tag:"const:array"`. Takes **plain
|
|
259
263
|
* JSON literals only** — like {@link obj}, a nested tagged value is a compile
|
|
260
|
-
* error and throws at runtime.
|
|
264
|
+
* error and throws at runtime.
|
|
261
265
|
*/
|
|
262
266
|
array<const T extends readonly unknown[]>(a: T & RejectValues<T>): Value;
|
|
263
267
|
/**
|
|
@@ -308,7 +312,7 @@ interface RefOptions {
|
|
|
308
312
|
* compiles to the raw var path `$owner.user_id`, which the engine resolves in
|
|
309
313
|
* a single lookup — so when the base var `owner` is null (e.g. a `db.get` that
|
|
310
314
|
* matched no row), it raises a runtime `ERROR_FATAL` "Unable to locate var"
|
|
311
|
-
* (HTTP 500) instead of yielding null
|
|
315
|
+
* (HTTP 500) instead of yielding null.
|
|
312
316
|
*
|
|
313
317
|
* With `safe: true` the path compiles through the `get` filter
|
|
314
318
|
* (`$owner|get:"user_id"`), which walks the remaining path and resolves to
|
|
@@ -324,7 +328,7 @@ interface RefOptions {
|
|
|
324
328
|
*
|
|
325
329
|
* Pass `{ safe: true }` to make a *nested* path null-safe: `ref("owner.user_id",
|
|
326
330
|
* { safe: true })` resolves to null instead of 500ing when the base `owner` is
|
|
327
|
-
* null
|
|
331
|
+
* null — the intent-revealing opt-in for drilling into a `db.get`
|
|
328
332
|
* result that may not exist.
|
|
329
333
|
*
|
|
330
334
|
* Picking a reference helper (these are easy to mix up):
|
|
@@ -339,7 +343,7 @@ declare function ref<const Name extends string>(name: Name, opts?: RefOptions):
|
|
|
339
343
|
/**
|
|
340
344
|
* The second parameter every non-`ref` reference creator declares, so that
|
|
341
345
|
* passing `{ safe: true }` to one is a COMPILE error whose expected type is the
|
|
342
|
-
* explanation
|
|
346
|
+
* explanation.
|
|
343
347
|
*
|
|
344
348
|
* `safe` was silently dropped before this: the creators took one parameter, so
|
|
345
349
|
* JavaScript discarded the extra argument and TypeScript never saw it. An
|
|
@@ -353,7 +357,7 @@ declare function inp(name: string, opts?: SafeIsRefOnly): Value;
|
|
|
353
357
|
* Reference a table **column**: `{tag:"col", value}` (used in `db.query` `where` +
|
|
354
358
|
* table views). See {@link ref} for the full picker. The return is branded
|
|
355
359
|
* {@link ColValue} so it is a *compile error* to pass `col()` into a `db.edit`/
|
|
356
|
-
* `db.add` `row` — where it would resolve to `null` at runtime
|
|
360
|
+
* `db.add` `row` — where it would resolve to `null` at runtime.
|
|
357
361
|
*/
|
|
358
362
|
declare function col(name: string, opts?: SafeIsRefOnly): ColValue;
|
|
359
363
|
/**
|
|
@@ -422,7 +426,7 @@ type ToolsetPath = "token" | "params" | `params.${string}`;
|
|
|
422
426
|
* - `toolset("params.tenant")` — one parameter out of that object.
|
|
423
427
|
*
|
|
424
428
|
* Only bound while a tool runs under its toolset; anywhere else it reads empty
|
|
425
|
-
|
|
429
|
+
*.
|
|
426
430
|
*/
|
|
427
431
|
declare function toolset(path: ToolsetPath, opts?: SafeIsRefOnly): Value;
|
|
428
432
|
/**
|
|
@@ -745,7 +749,7 @@ declare function test(def: TestDef): TestDef;
|
|
|
745
749
|
* The SDK emits only authored fields. Server/auto-generated keys (`id`,
|
|
746
750
|
* `created_at`, `_xsid`, `@guid`, `@index`, `guid`, `_draft`, `stack_id`, …)
|
|
747
751
|
* are generated by the engine on import and are NEVER emitted here; the test
|
|
748
|
-
* normalizer
|
|
752
|
+
* normalizer strips them from the fixture before comparison.
|
|
749
753
|
*/
|
|
750
754
|
/**
|
|
751
755
|
* Xano tagged-value tags (verified against the Xano engine). The runtime
|
|
@@ -779,7 +783,7 @@ interface FilterXdo<N extends string = string> {
|
|
|
779
783
|
* Required here until now, which made a pulled workspace fail its own
|
|
780
784
|
* type-check: codegen emits a stored filter verbatim when no `fl.*` form
|
|
781
785
|
* reproduces it, and a verbatim emit of a filter stored without the key does
|
|
782
|
-
* not have it
|
|
786
|
+
* not have it. Writing `disabled: false` in would have been the
|
|
783
787
|
* other repair, and it is the wrong one — it ADDS a key the engine did not
|
|
784
788
|
* store, so the re-encode would no longer match the stored bytes and the value
|
|
785
789
|
* would degrade further rather than round-trip.
|
|
@@ -810,7 +814,7 @@ interface MethodXdo {
|
|
|
810
814
|
}
|
|
811
815
|
/**
|
|
812
816
|
* A field-bearing entry — the shape shared by function/query inputs and table
|
|
813
|
-
* columns
|
|
817
|
+
* columns. In the persisted form the two are byte-identical: both use
|
|
814
818
|
* `customize:{}`, numeric `market_item` ids, an `_xsid` placeholder, and a
|
|
815
819
|
* present `description`. (The older parser generation emitted `customize:""` /
|
|
816
820
|
* string ids for inputs; the live `mvp_query`/`mvp_dbo` rows show they converge.)
|
|
@@ -1076,840 +1080,4 @@ type PersistedFunctionRow = FunctionXdo & {
|
|
|
1076
1080
|
};
|
|
1077
1081
|
};
|
|
1078
1082
|
|
|
1079
|
-
|
|
1080
|
-
* A statement's per-test MOCK — the value a step returns instead of doing its
|
|
1081
|
-
* work, when one specific test runs.
|
|
1082
|
-
*
|
|
1083
|
-
* Authored keyed by TEST NAME, which is what the Xano editor shows and what
|
|
1084
|
-
* XanoScript spells. The stored form is keyed by test ID; the rewrite happens
|
|
1085
|
-
* at kind-encode time, the only place that knows both the stack and the test
|
|
1086
|
-
* list (see `../kinds/test-mocks.js`).
|
|
1087
|
-
*
|
|
1088
|
-
* A mock applies ONLY while its test runs. It has no effect on a normal
|
|
1089
|
-
* request, so mocking a step does not change what the deployed endpoint does.
|
|
1090
|
-
*/
|
|
1091
|
-
|
|
1092
|
-
/**
|
|
1093
|
-
* One mock: a value, or a value plus `enabled`.
|
|
1094
|
-
*
|
|
1095
|
-
* The bare form means enabled. The object form exists so a mock can be kept
|
|
1096
|
-
* around switched off — the editor stores a disabled mock rather than deleting
|
|
1097
|
-
* it, and dropping it on encode would lose an authored artefact.
|
|
1098
|
-
*/
|
|
1099
|
-
type MockEntry = Value | {
|
|
1100
|
-
value: Value;
|
|
1101
|
-
enabled?: boolean;
|
|
1102
|
-
};
|
|
1103
|
-
/** A statement's mocks, keyed by the name of the test each applies to. */
|
|
1104
|
-
type MockMap = Record<string, MockEntry>;
|
|
1105
|
-
/** The stored `mvp_test_mock` shape. */
|
|
1106
|
-
interface MockXdo {
|
|
1107
|
-
value: string;
|
|
1108
|
-
tag: string;
|
|
1109
|
-
filters: unknown[];
|
|
1110
|
-
enabled: boolean;
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
|
-
/**
|
|
1114
|
-
* Statement model, base envelope encoder, and registry (U5 — the KTD-4
|
|
1115
|
-
* extensibility seam).
|
|
1116
|
-
*
|
|
1117
|
-
* The real stored statement shape (from the golden fixture's `run[0]`) is lean:
|
|
1118
|
-
* `{name, as?, context, input}`. The base encoder fills the common envelope
|
|
1119
|
-
* (`input: []` default) so each concrete statement factory only declares its
|
|
1120
|
-
* `name`, optional `as`, and `context`. The registry maps statement name →
|
|
1121
|
-
* factory so the eventual ~500-statement catalog plugs in here.
|
|
1122
|
-
*/
|
|
1123
|
-
|
|
1124
|
-
/**
|
|
1125
|
-
* The type-level contract linking a branded db statement (the **producer** —
|
|
1126
|
-
* `db.get`/`db.query`/`db.add`/`db.edit`/`db.patch`/`db.add_or_edit`/`db.has`/
|
|
1127
|
-
* `db.bulk.patch`/`db.bulk.delete`, each returning `Statement & AsShapeBrand<…>`)
|
|
1128
|
-
* to `InferResponse`'s single-variable trace (the **consumer** — `TraceVar`,
|
|
1129
|
-
* which destructures this shape). Both `__as` (the stack variable the statement
|
|
1130
|
-
* binds) and `__shape` (the row shape it produces) are phantom carriers — never
|
|
1131
|
-
* present at runtime. Naming the contract here keeps producer and consumer
|
|
1132
|
-
* compiler-linked, so any further branded statement joins the trace by extending
|
|
1133
|
-
* this type with zero edits to the trace logic.
|
|
1134
|
-
*/
|
|
1135
|
-
type AsShapeBrand<As extends string, Shape> = {
|
|
1136
|
-
readonly __as: As;
|
|
1137
|
-
readonly __shape: Shape;
|
|
1138
|
-
};
|
|
1139
|
-
/**
|
|
1140
|
-
* The two envelope members every stack item carries, whatever it does.
|
|
1141
|
-
*
|
|
1142
|
-
* They are editor affordances rather than statement arguments — `disabled` is
|
|
1143
|
-
* how a step is commented out (it stays in the stack; the run engine skips it),
|
|
1144
|
-
* and `description` is the note shown on the step. `encodeStatement` writes both
|
|
1145
|
-
* for every statement, so every factory accepts them: the generated ones as two
|
|
1146
|
-
* more optional fields on their argument object, the positional specials as a
|
|
1147
|
-
* trailing options argument.
|
|
1148
|
-
*
|
|
1149
|
-
* Both are elided at their defaults on both sides of a round trip, so setting one
|
|
1150
|
-
* to `false`/`""` is the same bytes as omitting it.
|
|
1151
|
-
*/
|
|
1152
|
-
interface StatementAnnotations {
|
|
1153
|
-
/** Leave the step in the stack but skip it at runtime — Xano's "disable step". */
|
|
1154
|
-
disabled?: boolean;
|
|
1155
|
-
/** Free-text note on the step, shown in the editor beside it. */
|
|
1156
|
-
description?: string;
|
|
1157
|
-
/**
|
|
1158
|
-
* Per-test MOCKS — what this step returns instead of running, keyed by the
|
|
1159
|
-
* name of the test the mock applies to.
|
|
1160
|
-
*
|
|
1161
|
-
* `{ "happy path": c.int(1) }` makes the step return `1` while the test named
|
|
1162
|
-
* "happy path" runs, and changes nothing about a normal request. Wrap an
|
|
1163
|
-
* entry as `{ value, enabled: false }` to keep a mock switched off.
|
|
1164
|
-
*
|
|
1165
|
-
* Every name must match a test declared on the object this statement belongs
|
|
1166
|
-
* to; an unmatched name throws at encode time, because the engine silently
|
|
1167
|
-
* ignores a mock whose key is not a real test id.
|
|
1168
|
-
*/
|
|
1169
|
-
mock?: MockMap;
|
|
1170
|
-
}
|
|
1171
|
-
/**
|
|
1172
|
-
* {@link StatementAnnotations} plus the result-filter option, for the statements
|
|
1173
|
-
* that bind an `as` variable.
|
|
1174
|
-
*
|
|
1175
|
-
* Split from the annotations rather than folded into them so `asFilters` is only
|
|
1176
|
-
* offered where there is a binding to attach it to: a statement that returns
|
|
1177
|
-
* nothing (`precondition`, `switch`, `while`, …) should not surface the option
|
|
1178
|
-
* in autocomplete at all. The runtime guard in {@link assertBindsAs} still
|
|
1179
|
-
* backs this up for callers that reach past the types.
|
|
1180
|
-
*/
|
|
1181
|
-
interface StatementOptions extends StatementAnnotations {
|
|
1182
|
-
/**
|
|
1183
|
-
* Filters piped onto the result before it is bound — the editor's
|
|
1184
|
-
* `return as token | upper`.
|
|
1185
|
-
*
|
|
1186
|
-
* Authored from the same `fl.*` catalog as value filters and applied in
|
|
1187
|
-
* order, so `asFilters: [fl.trim(), fl.upper()]` trims and then upper-cases.
|
|
1188
|
-
*
|
|
1189
|
-
* The bound variable is RETYPED by the chain: `InferResponse` folds each
|
|
1190
|
-
* filter's declared result, so a `db.query` bound through `[fl.count()]` is a
|
|
1191
|
-
* `number`. Filters the engine declares as returning `any` (`get`, `set`,
|
|
1192
|
-
* `json_decode`, …) fold to `unknown` — see `values/filter-result.ts`.
|
|
1193
|
-
*/
|
|
1194
|
-
asFilters?: FilterXdo[];
|
|
1195
|
-
}
|
|
1196
|
-
/**
|
|
1197
|
-
* Apply {@link StatementOptions} to a built statement.
|
|
1198
|
-
*
|
|
1199
|
-
* Only members that were actually authored are copied, so a factory's own
|
|
1200
|
-
* `description` (a few statements route one) is not clobbered by an absent key.
|
|
1201
|
-
*
|
|
1202
|
-
* `asFilters` merges into the `output` envelope rather than replacing it: a db
|
|
1203
|
-
* statement's column selection (`output.items`) and its result filters live in
|
|
1204
|
-
* the same block, and dropping one to write the other would silently discard
|
|
1205
|
-
* whichever the factory set first.
|
|
1206
|
-
*/
|
|
1207
|
-
declare function annotate<T extends Statement>(stmt: T, a?: StatementOptions): T;
|
|
1208
|
-
/** What a statement factory returns before base-envelope encoding. */
|
|
1209
|
-
interface Statement {
|
|
1210
|
-
name: string;
|
|
1211
|
-
as?: string;
|
|
1212
|
-
context: unknown;
|
|
1213
|
-
input?: unknown[];
|
|
1214
|
-
/** `output` envelope. Lean (`{filters:[]}`) or rich (`{customize,filters,items}`) forms are both accepted and normalized to the full rich form. */
|
|
1215
|
-
output?: unknown;
|
|
1216
|
-
/** Statement description (defaults to `""`). */
|
|
1217
|
-
description?: string;
|
|
1218
|
-
/** Settings-registry bindings (defaults to `null`). */
|
|
1219
|
-
settings_registry?: unknown[] | null;
|
|
1220
|
-
/** Attached addons (defaults to `[]`). */
|
|
1221
|
-
addon?: unknown[];
|
|
1222
|
-
/** Async/runtime block (e.g. `mvp:call_agent`'s `{ mode }`); defaults to `null`. */
|
|
1223
|
-
runtime?: unknown;
|
|
1224
|
-
/**
|
|
1225
|
-
* Encoded per-test mocks, keyed by test NAME until the owning kind rewrites
|
|
1226
|
-
* the keys to test ids. Authored via the `mock` option, not set directly.
|
|
1227
|
-
*/
|
|
1228
|
-
mocks?: Record<string, MockXdo> | unknown;
|
|
1229
|
-
/** Whether the statement is disabled in the stack (defaults to `false`). */
|
|
1230
|
-
disabled?: boolean;
|
|
1231
|
-
}
|
|
1232
|
-
/**
|
|
1233
|
-
* Return a statement sequence from a helper **without losing the tuple**
|
|
1234
|
-
* (issue #11).
|
|
1235
|
-
*
|
|
1236
|
-
* `InferResponse` traces the `as` binding a `response` names by walking the
|
|
1237
|
-
* stack's TUPLE type. Spreading anything typed `Statement[]` widens the whole
|
|
1238
|
-
* array, and every binding — including ones declared *after* the spread —
|
|
1239
|
-
* becomes invisible, so the response silently resolves to
|
|
1240
|
-
* {@link StackTupleWidened}. A helper that emits more than one statement has to
|
|
1241
|
-
* return an array, so any shared helper triggers it:
|
|
1242
|
-
*
|
|
1243
|
-
* ```ts
|
|
1244
|
-
* // ✗ widens: every `as` in the calling stack stops being traceable
|
|
1245
|
-
* function assertOk(v: string): Statement[] { return [s.lambda({…}), s.precondition({…})]; }
|
|
1246
|
-
*
|
|
1247
|
-
* // ✓ tuple survives the spread
|
|
1248
|
-
* function assertOk(v: string) { return statements(s.lambda({…}), s.precondition({…})); }
|
|
1249
|
-
* ```
|
|
1250
|
-
*
|
|
1251
|
-
* Type-level only — the returned array is the arguments verbatim, so there is no
|
|
1252
|
-
* encoder involvement and no cost.
|
|
1253
|
-
*
|
|
1254
|
-
* **Fixed arity only.** A helper that builds its array in a loop cannot be a
|
|
1255
|
-
* tuple; declare `responseShape` on the calling def instead.
|
|
1256
|
-
*/
|
|
1257
|
-
declare function statements<const T extends readonly Statement[]>(...items: T): T;
|
|
1258
|
-
/** True when a statement name has a registered factory. */
|
|
1259
|
-
declare function isRegisteredStatement(name: string): boolean;
|
|
1260
|
-
/** Look up a registered factory, throwing a clear error when absent. */
|
|
1261
|
-
declare function getStatementFactory(name: string): (...args: any[]) => Statement;
|
|
1262
|
-
/**
|
|
1263
|
-
* Encode a statement into the stored `StackItemXdo`, filling the **full**
|
|
1264
|
-
* persisted envelope. Every stored statement carries the same 12 keys
|
|
1265
|
-
* regardless of type (confirmed against live `mvp_query`/`mvp_tool`), so the
|
|
1266
|
-
* envelope is uniform here rather than per-statement: empty members are emitted
|
|
1267
|
-
* with their canonical defaults so the output is 1:1 with the engine's
|
|
1268
|
-
* persisted form. `_xsid` is engine-generated on import; we emit `""` (the
|
|
1269
|
-
* stored placeholder) so the key is present for comparison.
|
|
1270
|
-
*/
|
|
1271
|
-
declare function encodeStatement(stmt: Statement): StackItemXdo;
|
|
1272
|
-
|
|
1273
|
-
/**
|
|
1274
|
-
* Shared field encoder (KTD-6). Function inputs and table columns are nearly
|
|
1275
|
-
* the same stored shape; this encoder fills the common defaults and is
|
|
1276
|
-
* parameterized by a `FieldContext` for the three spots where they differ:
|
|
1277
|
-
* `customize` (`""` vs `{}`), `market_item` id types (string vs numeric), and
|
|
1278
|
-
* whether `description` is emitted.
|
|
1279
|
-
*/
|
|
1280
|
-
|
|
1281
|
-
/** Field visibility — the engine's `access` enum. */
|
|
1282
|
-
type FieldAccess = "public" | "private" | "internal";
|
|
1283
|
-
/** Valid `format` values for text fields (per the engine's text-field schema). */
|
|
1284
|
-
type TextFormat = "" | "plaintext" | "yaml" | "html" | "xml" | "markdown";
|
|
1285
|
-
/** Field cardinality — `"single"` (scalar) or `"list"` (array column). */
|
|
1286
|
-
type FieldStyleType = "single" | "list";
|
|
1287
|
-
interface FieldOptions {
|
|
1288
|
-
required?: boolean;
|
|
1289
|
-
nullable?: boolean;
|
|
1290
|
-
/**
|
|
1291
|
-
* Default value. Authored as a `string`, `number`, or `boolean` for
|
|
1292
|
-
* ergonomics (`default: 0`, `default: false`); the engine stores it as a
|
|
1293
|
-
* string, so it's coerced at encode time (`0` → `"0"`, `false` → `"false"`).
|
|
1294
|
-
*
|
|
1295
|
-
* On a **table column** the default must stay within the Basic Multilingual
|
|
1296
|
-
* Plane: a 4-byte character (codepoint > U+FFFF — emoji, CJK-extension glyphs)
|
|
1297
|
-
* is mangled into an invalid UTF-8 sequence by the engine's default pipeline
|
|
1298
|
-
* and is rejected at export/encode time rather than 500ing at deploy with
|
|
1299
|
-
* Postgres `22021` (issue #45). BMP characters (accents, `€`, most CJK) store
|
|
1300
|
-
* fine. A *function/endpoint input* default binds at runtime and has no limit.
|
|
1301
|
-
*/
|
|
1302
|
-
default?: string | number | boolean;
|
|
1303
|
-
/**
|
|
1304
|
-
* Persist **no `default` key at all** for this field, rather than the empty
|
|
1305
|
-
* `default: ""` every other field carries.
|
|
1306
|
-
*
|
|
1307
|
-
* Set on a table's `uuid` PRIMARY KEY, which is the one column the engine
|
|
1308
|
-
* stores this way — its value is engine-generated, so there is nothing for a
|
|
1309
|
-
* default to mean, and absent vs empty are different stored bytes. Applied
|
|
1310
|
-
* automatically by `idType: "uuid"`; you rarely set it by hand.
|
|
1311
|
-
*
|
|
1312
|
-
* NOT a property of `uuid` in general: an ordinary (non-key) `uuid` column
|
|
1313
|
-
* does carry `default: ""`. Mutually exclusive with {@link default}.
|
|
1314
|
-
*/
|
|
1315
|
-
noDefault?: boolean;
|
|
1316
|
-
description?: string;
|
|
1317
|
-
/**
|
|
1318
|
-
* Methods/filters applied at bind time. Each entry is either a bare name
|
|
1319
|
-
* (`"trim"`), a colon-form string with args (`"min:8"` → `{name:"min",
|
|
1320
|
-
* arg:["8"]}`), or an explicit `{ name, arg }` object.
|
|
1321
|
-
*/
|
|
1322
|
-
methods?: MethodSpec[];
|
|
1323
|
-
/** Enum values (for `type:"enum"` fields), e.g. `["draft","live"]`. */
|
|
1324
|
-
values?: Array<string | number>;
|
|
1325
|
-
mode?: string;
|
|
1326
|
-
/** Text-field display format (text fields only; the engine drops it elsewhere). */
|
|
1327
|
-
format?: TextFormat;
|
|
1328
|
-
sensitive?: boolean;
|
|
1329
|
-
/**
|
|
1330
|
-
* Merge the referenced object's fields into this one rather than nesting them.
|
|
1331
|
-
*
|
|
1332
|
-
* **Leave this unset** unless reproducing a pulled field. It defaults to `false`,
|
|
1333
|
-
* which is what every field this SDK authors from scratch wants; it is here so a
|
|
1334
|
-
* pulled workspace's field can be recovered as a readable `f.*` call instead of
|
|
1335
|
-
* degrading to `rawField()`. Paired with {@link hidden} in the wild — 584 fields
|
|
1336
|
-
* across the sweep carry `merge: true` with a `hidden` list beside it.
|
|
1337
|
-
*/
|
|
1338
|
-
merge?: boolean;
|
|
1339
|
-
/**
|
|
1340
|
-
* Names to hide from this field's expansion (e.g. `["created_at"]`).
|
|
1341
|
-
*
|
|
1342
|
-
* **Leave this unset** unless reproducing a pulled field; it defaults to `[]`.
|
|
1343
|
-
* Each entry is resolved as a name and removed from the expanded shape, so an
|
|
1344
|
-
* entry naming nothing hides nothing — a stored `[""]` is a real spelling that
|
|
1345
|
-
* appears in the wild and round-trips verbatim here rather than being guessed at.
|
|
1346
|
-
*/
|
|
1347
|
-
hidden?: readonly string[];
|
|
1348
|
-
/** Field visibility in API output. Defaults to `"public"`. */
|
|
1349
|
-
access?: FieldAccess;
|
|
1350
|
-
style?: {
|
|
1351
|
-
type: FieldStyleType;
|
|
1352
|
-
};
|
|
1353
|
-
/**
|
|
1354
|
-
* Length bounds for an array field. Both members are `json`-typed in the
|
|
1355
|
-
* engine, not numeric — the editor declares them as `json` and every consumer
|
|
1356
|
-
* reads them through a numeric coercion (`+list.max`) — so a bound can arrive
|
|
1357
|
-
* as `5` or as `"5"` and neither spelling is wrong.
|
|
1358
|
-
*
|
|
1359
|
-
* That is also why "unset" has no single spelling: an empty `json` control
|
|
1360
|
-
* serializes to `""` on 8,814 fields in the sweep and to `{}` on two. Codegen
|
|
1361
|
-
* elides the block whenever every member is blank in either form (see
|
|
1362
|
-
* `hasNoListBounds`), so only a bound that is actually SET reaches this type.
|
|
1363
|
-
*/
|
|
1364
|
-
list?: {
|
|
1365
|
-
min?: string | number;
|
|
1366
|
-
max?: string | number;
|
|
1367
|
-
};
|
|
1368
|
-
vector?: {
|
|
1369
|
-
size: number;
|
|
1370
|
-
};
|
|
1371
|
-
/**
|
|
1372
|
-
* Array/list field — stored as `style:{type:"list"}` (e.g. `int[]`, `object[]`).
|
|
1373
|
-
* Ignored when an explicit `style` is given.
|
|
1374
|
-
*/
|
|
1375
|
-
array?: boolean;
|
|
1376
|
-
/** Nested fields for `type:"obj"` columns; each is itself a named, typed field. */
|
|
1377
|
-
children?: NestedField[];
|
|
1378
|
-
/**
|
|
1379
|
-
* Per-column overrides applied to this field's EXPANSION, keyed by the
|
|
1380
|
-
* expanded column's name. Meaningful on a merged field — an
|
|
1381
|
-
* {@link input.dbLink} — where the engine expands a table's columns into
|
|
1382
|
-
* request inputs and consults this map for each one.
|
|
1383
|
-
*
|
|
1384
|
-
* **Leave this unset** unless reproducing a pulled field; it defaults to `{}`.
|
|
1385
|
-
* Xano's own CRUD scaffold writes it, so it is the common shape in a pulled
|
|
1386
|
-
* workspace, not an edge case.
|
|
1387
|
-
*/
|
|
1388
|
-
customize?: Readonly<Record<string, FieldCustomization>>;
|
|
1389
|
-
}
|
|
1390
|
-
/**
|
|
1391
|
-
* One expanded column's override inside a merged field's {@link
|
|
1392
|
-
* FieldOptions.customize} map.
|
|
1393
|
-
*
|
|
1394
|
-
* Every member restates what the column already declares, so an omitted member
|
|
1395
|
-
* is not "inherit" — it is the stored default (`hidden:false`, `required:false`,
|
|
1396
|
-
* `default:""`, no methods). Author the ones you mean to change and accept the
|
|
1397
|
-
* rest, which is what the editor writes.
|
|
1398
|
-
*/
|
|
1399
|
-
interface FieldCustomization {
|
|
1400
|
-
/** Drop this column from the expansion entirely. */
|
|
1401
|
-
hidden?: boolean;
|
|
1402
|
-
/** Whether the expanded input is required. */
|
|
1403
|
-
required?: boolean;
|
|
1404
|
-
/** Default for the expanded input; stored as a string (`0` → `"0"`). */
|
|
1405
|
-
default?: string | number | boolean;
|
|
1406
|
-
/** Methods/filters appended to the column's own, in the same spellings as {@link FieldOptions.methods}. */
|
|
1407
|
-
methods?: readonly MethodSpec[];
|
|
1408
|
-
/** Overrides for an object column's OWN children, keyed by child name. */
|
|
1409
|
-
customize?: Readonly<Record<string, FieldCustomization>>;
|
|
1410
|
-
}
|
|
1411
|
-
/** A nested field inside an object column's `children` — a named, typed `FieldOptions`. */
|
|
1412
|
-
interface NestedField extends FieldOptions {
|
|
1413
|
-
name: string;
|
|
1414
|
-
type: string;
|
|
1415
|
-
}
|
|
1416
|
-
/**
|
|
1417
|
-
* A field method/filter: a bare name (`"trim"`), a colon-form string carrying
|
|
1418
|
-
* args (`"min:8"`, `"min:8:foo"` — first segment is the name, the rest are
|
|
1419
|
-
* args), or an explicit `{ name, arg }` object.
|
|
1420
|
-
*/
|
|
1421
|
-
type MethodSpec = string | {
|
|
1422
|
-
name: string;
|
|
1423
|
-
arg?: Array<string | number>;
|
|
1424
|
-
};
|
|
1425
|
-
/**
|
|
1426
|
-
* A type-narrowed {@link MethodSpec} for a field constructor: a bare method name
|
|
1427
|
-
* from the field type's valid set `N` (`"trim"`), the colon-form carrying args
|
|
1428
|
-
* (`"min:8"`), or the explicit `{ name, arg }` object — which stays a universal
|
|
1429
|
-
* escape hatch for any name the per-type union doesn't enumerate. The per-type
|
|
1430
|
-
* `N` unions live in `fields/generated/field-methods.generated.ts`.
|
|
1431
|
-
*/
|
|
1432
|
-
type MethodArg<N extends string> = N | `${N}:${string}` | {
|
|
1433
|
-
name: string;
|
|
1434
|
-
arg?: Array<string | number>;
|
|
1435
|
-
};
|
|
1436
|
-
/**
|
|
1437
|
-
* An options type `T` with its `methods` array widened to `readonly`. Field/input
|
|
1438
|
-
* constructors capture their options via a `const` type parameter so literal
|
|
1439
|
-
* flags (`required`/`nullable`/`array`) survive for `InferInput`; `const` also
|
|
1440
|
-
* makes any inline `methods: [...]` a readonly tuple, so a constructor's options
|
|
1441
|
-
* constraint must accept readonly arrays. The runtime cast back to `FieldOptions`
|
|
1442
|
-
* is safe — the encoder only ever reads (`.map`) the methods.
|
|
1443
|
-
*/
|
|
1444
|
-
type ReadonlyMethods<T, N extends string> = Omit<T, "methods"> & {
|
|
1445
|
-
methods?: readonly MethodArg<N>[];
|
|
1446
|
-
};
|
|
1447
|
-
|
|
1448
|
-
/**
|
|
1449
|
-
* Value-type algebra for the typed descriptor layer (U1/U2).
|
|
1450
|
-
*
|
|
1451
|
-
* Input and column constructors (`input.*`, `f.*`) return a runtime descriptor
|
|
1452
|
-
* of exactly `{ type, options }`. This module adds a **phantom brand** to those
|
|
1453
|
-
* return types that carries, at the TYPE LEVEL only, the field's value type `V`
|
|
1454
|
-
* and the literal options object `O` the caller passed. The brand props are
|
|
1455
|
-
* optional and never assigned at runtime, so the emitted object is unchanged and
|
|
1456
|
-
* every branded descriptor stays structurally assignable to the un-branded
|
|
1457
|
-
* `FieldDescriptor` / `InputDescriptor` — existing consumers are unaffected.
|
|
1458
|
-
*
|
|
1459
|
-
* `InferInput` (see `../inputs/infer.ts`) reads these brands to turn a query's
|
|
1460
|
-
* declared `input` map into the request-payload TS type. The same algebra powers
|
|
1461
|
-
* nested-object inference, since object `children` are built from `f.*`.
|
|
1462
|
-
*/
|
|
1463
|
-
/**
|
|
1464
|
-
* Opaque runtime value of a file input/column. The request payload carries a
|
|
1465
|
-
* resource reference (path/metadata), not the raw bytes — model it structurally
|
|
1466
|
-
* rather than as `unknown` so a consumer at least sees an object shape.
|
|
1467
|
-
*/
|
|
1468
|
-
interface XanoFileRef {
|
|
1469
|
-
/** Vault path, e.g. `/vault/<…>/<name>`. Join it to your base URL — see {@link import("./file-url.js").fileUrl}. */
|
|
1470
|
-
path?: string;
|
|
1471
|
-
name?: string;
|
|
1472
|
-
type?: string;
|
|
1473
|
-
size?: number;
|
|
1474
|
-
/** Storage visibility as stored on the column (`"public"` / `"private"`). */
|
|
1475
|
-
access?: string;
|
|
1476
|
-
/** Type-specific metadata — e.g. `{ width, height }` on an image. */
|
|
1477
|
-
meta?: unknown;
|
|
1478
|
-
/**
|
|
1479
|
-
* ⚠ The engine's own absolute URL, which on a tenant-scoped environment omits
|
|
1480
|
-
* the `/tenant/<name>` segment and 404s. Do NOT read it directly: pass the
|
|
1481
|
-
* file to `fileUrl(file, baseUrl)`, which joins the correct `path` to the base
|
|
1482
|
-
* URL your client already has (issue #31).
|
|
1483
|
-
*/
|
|
1484
|
-
url?: string;
|
|
1485
|
-
}
|
|
1486
|
-
/**
|
|
1487
|
-
* Opaque runtime value of a raw file **upload** (`input.file()`).
|
|
1488
|
-
*
|
|
1489
|
-
* Distinct from {@link XanoFileRef}, and the distinction matters: this is the
|
|
1490
|
-
* bytes as they arrive on the request (multipart, base64, or a fetched URI). It
|
|
1491
|
-
* is not yet stored anywhere and cannot be written to a file column. Pass it to
|
|
1492
|
-
* a `s.storage.create_*` statement (`create_image`, `create_attachment`, …) to
|
|
1493
|
-
* store it and get back the {@link XanoFileRef} a column holds.
|
|
1494
|
-
*/
|
|
1495
|
-
interface XanoFileUpload {
|
|
1496
|
-
readonly __fileUpload?: never;
|
|
1497
|
-
}
|
|
1498
|
-
/**
|
|
1499
|
-
* Marker value of a database-link input (`input.dbLink()`).
|
|
1500
|
-
*
|
|
1501
|
-
* Opaque on purpose: a dblink input does not bind a value of its own. The engine
|
|
1502
|
-
* EXPANDS it into one input per column of the linked table, so a table with
|
|
1503
|
-
* three columns turns one dblink entry into three request inputs. Read those by
|
|
1504
|
-
* their own column names — `inp("email")`, not `inp("user__")`.
|
|
1505
|
-
*/
|
|
1506
|
-
interface XanoDbLink {
|
|
1507
|
-
readonly __dbLink?: never;
|
|
1508
|
-
}
|
|
1509
|
-
/** Opaque runtime value of a geo input/column (a GeoJSON-shaped object). */
|
|
1510
|
-
/** One `{ lng, lat }` position, as the engine both accepts and returns. */
|
|
1511
|
-
interface XanoGeoPosition {
|
|
1512
|
-
lng: number;
|
|
1513
|
-
lat: number;
|
|
1514
|
-
}
|
|
1515
|
-
/**
|
|
1516
|
-
* The value of an `f.geo.*` column: `{ type, data }`.
|
|
1517
|
-
*
|
|
1518
|
-
* Named for what it is rather than for GeoJSON, which this is NOT — the
|
|
1519
|
-
* previous `XanoGeoJson` declared `{ type, coordinates }`, a shape the engine
|
|
1520
|
-
* neither accepts nor returns (issue #208).
|
|
1521
|
-
*
|
|
1522
|
-
* The same shape works in BOTH directions, verified live: seeding
|
|
1523
|
-
* `{ type: "point", data: { lng: 1, lat: 2 } }` reads back byte-identical, and
|
|
1524
|
-
* a polygon seeded as `{ type: "poly", data: [{ lng, lat }, …] }` reads back
|
|
1525
|
-
* with its ring closed for you. `type` is the engine's own abbreviation
|
|
1526
|
-
* (`"point"`, `"poly"`, …), not the GeoJSON keyword, and `data` nests by
|
|
1527
|
-
* geometry: an object for a point, an array of positions for a polygon.
|
|
1528
|
-
*
|
|
1529
|
-
* Raw WKT text (`c.text("POINT(1 2)")`) is also accepted wherever a value is
|
|
1530
|
-
* taken — it is just not the typed path, because a read never returns one.
|
|
1531
|
-
*/
|
|
1532
|
-
interface XanoGeoValue {
|
|
1533
|
-
type: string;
|
|
1534
|
-
data: XanoGeoPosition | XanoGeoPosition[] | XanoGeoPosition[][];
|
|
1535
|
-
}
|
|
1536
|
-
/**
|
|
1537
|
-
* Phantom brand intersected onto a descriptor's return type. `V` is the field's
|
|
1538
|
-
* base value type; `O` is the literal options object captured via a `const` type
|
|
1539
|
-
* parameter at the call site. Both props are optional and never present at
|
|
1540
|
-
* runtime.
|
|
1541
|
-
*/
|
|
1542
|
-
interface TypeBrand<V, O> {
|
|
1543
|
-
readonly __value?: V;
|
|
1544
|
-
readonly __opts?: O;
|
|
1545
|
-
}
|
|
1546
|
-
/** The base value type carried by a branded descriptor `D` (before array/nullable). */
|
|
1547
|
-
type BrandValue<D> = D extends TypeBrand<infer V, unknown> ? V : unknown;
|
|
1548
|
-
/** The literal options object captured on a branded descriptor `D`. */
|
|
1549
|
-
type BrandOpts<D> = D extends TypeBrand<unknown, infer O> ? O : object;
|
|
1550
|
-
type ApplyArray<T, O> = O extends {
|
|
1551
|
-
array: true;
|
|
1552
|
-
} ? T[] : T;
|
|
1553
|
-
type ApplyNullable<T, O> = O extends {
|
|
1554
|
-
nullable: true;
|
|
1555
|
-
} ? T | null : T;
|
|
1556
|
-
/**
|
|
1557
|
-
* The full value type of a single branded descriptor `D`: its base value with
|
|
1558
|
-
* `array` and `nullable` applied. (Optionality of the *key* is a map-level
|
|
1559
|
-
* concern handled by {@link FromFieldMap}.)
|
|
1560
|
-
*/
|
|
1561
|
-
type ValueOf<D> = ApplyNullable<ApplyArray<BrandValue<D>, BrandOpts<D>>, BrandOpts<D>>;
|
|
1562
|
-
/** Keys whose descriptor options declare `required: true`. */
|
|
1563
|
-
type RequiredKeys<M> = {
|
|
1564
|
-
[K in keyof M]: BrandOpts<M[K]> extends {
|
|
1565
|
-
required: true;
|
|
1566
|
-
} ? K : never;
|
|
1567
|
-
}[keyof M];
|
|
1568
|
-
/** Keys without `required: true` — optional in the produced payload type. */
|
|
1569
|
-
type OptionalKeys<M> = Exclude<keyof M, RequiredKeys<M>>;
|
|
1570
|
-
/**
|
|
1571
|
-
* Turn a named map of branded descriptors into an object type: required inputs
|
|
1572
|
-
* become required keys, everything else becomes an optional (`?`) key. Used both
|
|
1573
|
-
* for a query's top-level `input` map and for nested `object` children.
|
|
1574
|
-
*/
|
|
1575
|
-
type FromFieldMap<M> = Prettify<{
|
|
1576
|
-
[K in RequiredKeys<M>]: ValueOf<M[K]>;
|
|
1577
|
-
} & {
|
|
1578
|
-
[K in OptionalKeys<M>]?: ValueOf<M[K]>;
|
|
1579
|
-
}>;
|
|
1580
|
-
/**
|
|
1581
|
-
* Turn a named map of branded descriptors into a **row** type — the read shape
|
|
1582
|
-
* of a table. Unlike {@link FromFieldMap} (a request payload, where `required`
|
|
1583
|
-
* gates key optionality), every declared column is present on a returned row, so
|
|
1584
|
-
* all keys are required here; `nullable`/`array` still apply via {@link ValueOf}.
|
|
1585
|
-
* Powers `InferRow<typeof table>` (see `../kinds/table.ts`).
|
|
1586
|
-
*/
|
|
1587
|
-
type RowFromFieldMap<M> = Prettify<{
|
|
1588
|
-
[K in keyof M]: ValueOf<M[K]>;
|
|
1589
|
-
}>;
|
|
1590
|
-
/** Flatten an intersection into a single object literal for readable hovers. */
|
|
1591
|
-
type Prettify<T> = {
|
|
1592
|
-
[K in keyof T]: T[K];
|
|
1593
|
-
} & {};
|
|
1594
|
-
|
|
1595
|
-
declare const REFERENCEABLE_KINDS: Set<string>;
|
|
1596
|
-
/**
|
|
1597
|
-
* A reference to another workspace object: its def handle, or a bare name.
|
|
1598
|
-
*
|
|
1599
|
-
* A def may carry an explicit `guid` (its Xano identity). When present it's used
|
|
1600
|
-
* verbatim; otherwise the guid is derived from `name`. Pass def handles (which
|
|
1601
|
-
* carry the `guid`) rather than bare names when an object sets an explicit guid,
|
|
1602
|
-
* so the reference and the target agree on the *same* guid.
|
|
1603
|
-
*/
|
|
1604
|
-
type ObjectRef = string | {
|
|
1605
|
-
name: string;
|
|
1606
|
-
guid?: string;
|
|
1607
|
-
};
|
|
1608
|
-
/**
|
|
1609
|
-
* The guid for a `(type, name)` pair. A seeded `xano.lock` override wins (the
|
|
1610
|
-
* lock freezes identity across renames — see lock/store.ts); otherwise the
|
|
1611
|
-
* deterministic 32-char hex derivation. Every reference and every emitted
|
|
1612
|
-
* target flows through here, so a lock override propagates everywhere by
|
|
1613
|
-
* construction — including guids embedded inside strings at authoring time.
|
|
1614
|
-
*/
|
|
1615
|
-
declare function deriveGuid(type: string, name: string): string;
|
|
1616
|
-
/** Resolve a reference target (def handle or name) to the referenced object's guid. */
|
|
1617
|
-
declare function resolveRef(type: string, target: ObjectRef): string;
|
|
1618
|
-
|
|
1619
|
-
/**
|
|
1620
|
-
* AUTO-GENERATED by scripts/codegen-field-methods.ts — DO NOT EDIT BY HAND.
|
|
1621
|
-
*
|
|
1622
|
-
* Per-field-type method-name unions, distilled from the engine's column-create
|
|
1623
|
-
* API schema (the per-type field-schema definitions). Each
|
|
1624
|
-
* `f.<type>` / `input.<type>` constructor types its `methods` against the
|
|
1625
|
-
* matching union so only names valid for that field type are accepted (the
|
|
1626
|
-
* explicit `{ name, arg }` form remains a universal escape hatch).
|
|
1627
|
-
*
|
|
1628
|
-
* Regenerate with `npm run codegen:methods` (`-- --refresh` to re-distill upstream).
|
|
1629
|
-
*/
|
|
1630
|
-
/** Per-field-type method metadata (method name → colon-form arg type; `bool` = flag, no arg). */
|
|
1631
|
-
declare const FIELD_METHODS: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
1632
|
-
/** Field methods valid on `decimal` fields. */
|
|
1633
|
-
type DecimalMethod = "max" | "min";
|
|
1634
|
-
/** Field methods valid on `email` fields. */
|
|
1635
|
-
type EmailMethod = "lower" | "trim";
|
|
1636
|
-
/** Field methods valid on `int` fields. */
|
|
1637
|
-
type IntMethod = "max" | "min";
|
|
1638
|
-
/** Field methods valid on `password` fields. */
|
|
1639
|
-
type PasswordMethod = "max" | "min" | "minAlpha" | "minDigit" | "minLowerAlpha" | "minSymbol" | "minUpperAlpha" | "salt";
|
|
1640
|
-
/** Field methods valid on `tableRef` fields. */
|
|
1641
|
-
type TableRefMethod = "max" | "min";
|
|
1642
|
-
/** Field methods valid on `text` fields. */
|
|
1643
|
-
type TextMethod = "alphaOk" | "digitOk" | "lower" | "max" | "min" | "ok" | "pattern" | "startsWith" | "trim" | "upper";
|
|
1644
|
-
/** Field methods valid on `vector` fields. */
|
|
1645
|
-
type VectorMethod = "max" | "min";
|
|
1646
|
-
|
|
1647
|
-
/**
|
|
1648
|
-
* Rich field-type catalog (`f.*`). A typed, validated authoring surface over the
|
|
1649
|
-
* shared field encoder. Each constructor returns a {@link FieldDescriptor}
|
|
1650
|
-
* (`{ type, options }`) carrying the **stored** type string — the engine's
|
|
1651
|
-
* author-facing names differ from what it persists, so this layer applies the
|
|
1652
|
-
* authoritative mapping (the engine's stored-type map):
|
|
1653
|
-
*
|
|
1654
|
-
* object → obj · timestamp → epochms · image → blob_img ·
|
|
1655
|
-
* video → blob_video · audio → blob_audio · attachment → blob
|
|
1656
|
-
*
|
|
1657
|
-
* Every other type (text/int/decimal/bool/uuid/date/email/password/json/enum/
|
|
1658
|
-
* vector/geo_*) is stored under its own name. Columns and inputs both consume
|
|
1659
|
-
* descriptors; the per-context differences (`customize`, `market_item`,
|
|
1660
|
-
* `description`) are still applied by {@link encodeField}.
|
|
1661
|
-
*/
|
|
1662
|
-
|
|
1663
|
-
/** A typed field, ready to attach to a column/input name. */
|
|
1664
|
-
interface FieldDescriptor {
|
|
1665
|
-
/** The **stored** type string (post-mapping), e.g. `blob_img`, `epochms`. */
|
|
1666
|
-
type: string;
|
|
1667
|
-
options: FieldOptions;
|
|
1668
|
-
}
|
|
1669
|
-
/** A named map of fields — used for table schemas and object children. */
|
|
1670
|
-
type FieldMap = Record<string, FieldDescriptor>;
|
|
1671
|
-
/** Options accepted by every catalog constructor (no `values`/`children`/`vector` — those are positional). */
|
|
1672
|
-
type FieldOpts = Omit<FieldOptions, "values" | "children" | "vector">;
|
|
1673
|
-
/**
|
|
1674
|
-
* {@link FieldOpts} with `methods` narrowed to the field type's valid method set
|
|
1675
|
-
* `N` (see {@link MethodArg}). Types with no engine-declared methods use
|
|
1676
|
-
* `MethodOpts<never>`, leaving only the `{ name, arg }` escape hatch.
|
|
1677
|
-
*/
|
|
1678
|
-
type MethodOpts<N extends string> = Omit<FieldOpts, "methods"> & {
|
|
1679
|
-
methods?: MethodArg<N>[];
|
|
1680
|
-
};
|
|
1681
|
-
/** {@link MethodOpts} made safe to capture under a `const` type parameter (see {@link ReadonlyMethods}). */
|
|
1682
|
-
type ConstMethodOpts<N extends string> = ReadonlyMethods<MethodOpts<N>, N>;
|
|
1683
|
-
/** Convert a named field map into the encoder's `NestedField[]` form. */
|
|
1684
|
-
declare function toNestedFields(map: FieldMap): NestedField[];
|
|
1685
|
-
/**
|
|
1686
|
-
* The stored scalar type of a `tableRef` FK, derived from its `type` option: a
|
|
1687
|
-
* `uuid`-keyed reference stores a `string`, everything else (the default `int`)
|
|
1688
|
-
* stores a `number`. Keeps `InferRow` honest — a FK column is the referenced
|
|
1689
|
-
* table's PK value, never the loose `string | number`.
|
|
1690
|
-
*/
|
|
1691
|
-
type TableRefValue<O> = "uuid" extends (O extends {
|
|
1692
|
-
type: infer T;
|
|
1693
|
-
} ? T : never) ? string : number;
|
|
1694
|
-
/** The rich field-type catalog. */
|
|
1695
|
-
declare const f: {
|
|
1696
|
-
readonly text: <const O extends ConstMethodOpts<TextMethod> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<string, O>;
|
|
1697
|
-
readonly int: <const O extends ConstMethodOpts<IntMethod> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<number, O>;
|
|
1698
|
-
readonly decimal: <const O extends ConstMethodOpts<DecimalMethod> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<number, O>;
|
|
1699
|
-
readonly bool: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<boolean, O>;
|
|
1700
|
-
readonly uuid: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<string, O>;
|
|
1701
|
-
readonly date: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<string, O>;
|
|
1702
|
-
readonly email: <const O extends ConstMethodOpts<EmailMethod> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<string, O>;
|
|
1703
|
-
/** Password field; defaults to `access:"internal"` (the engine's stored default). */
|
|
1704
|
-
readonly password: <const O extends ConstMethodOpts<PasswordMethod> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<string, O>;
|
|
1705
|
-
/**
|
|
1706
|
-
* JSON column. Accepts an optional nested `children` schema — the structure the
|
|
1707
|
-
* editor shows when a `json` field is expanded, and what a pulled workspace
|
|
1708
|
-
* carries.
|
|
1709
|
-
*
|
|
1710
|
-
* `children` is spelled as an ARRAY of named, typed fields rather than the
|
|
1711
|
-
* `FieldMap` {@link FieldCatalog.object} takes positionally. The two are not
|
|
1712
|
-
* interchangeable: an object column's children are the column's own schema,
|
|
1713
|
-
* while a json column's are a description of the shape stored inside it, which
|
|
1714
|
-
* the engine persists in the order given. That order is part of the stored
|
|
1715
|
-
* bytes, and a map does not preserve it.
|
|
1716
|
-
*
|
|
1717
|
-
* Without this there is no way to author a structured JSON column at all
|
|
1718
|
-
* (issue #135).
|
|
1719
|
-
*/
|
|
1720
|
-
readonly json: <const O extends ConstMethodOpts<never> & {
|
|
1721
|
-
children?: readonly NestedField[];
|
|
1722
|
-
} = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<unknown, O>;
|
|
1723
|
-
/** Epoch-millisecond timestamp (authored as `timestamp`). */
|
|
1724
|
-
readonly timestamp: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<number, O>;
|
|
1725
|
-
/** Image file resource (stored `blob_img`). */
|
|
1726
|
-
readonly image: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<XanoFileRef, O>;
|
|
1727
|
-
/** Video file resource (stored `blob_video`). */
|
|
1728
|
-
readonly video: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<XanoFileRef, O>;
|
|
1729
|
-
/** Audio file resource (stored `blob_audio`). */
|
|
1730
|
-
readonly audio: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<XanoFileRef, O>;
|
|
1731
|
-
/** Generic file attachment (stored `blob`). */
|
|
1732
|
-
readonly attachment: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<XanoFileRef, O>;
|
|
1733
|
-
readonly geo: {
|
|
1734
|
-
readonly point: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<XanoGeoValue, O>;
|
|
1735
|
-
readonly multipoint: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<XanoGeoValue, O>;
|
|
1736
|
-
readonly linestring: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<XanoGeoValue, O>;
|
|
1737
|
-
readonly multilinestring: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<XanoGeoValue, O>;
|
|
1738
|
-
readonly polygon: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<XanoGeoValue, O>;
|
|
1739
|
-
readonly multipolygon: <const O extends ConstMethodOpts<never> = Record<string, never>>(options?: O) => FieldDescriptor & TypeBrand<XanoGeoValue, O>;
|
|
1740
|
-
};
|
|
1741
|
-
/**
|
|
1742
|
-
* Enum field. `values` may be empty — that is an enum column added in the
|
|
1743
|
-
* editor and not yet given its options, which the engine stores and which
|
|
1744
|
-
* appears in the survey corpus. Refusing it made the SDK stricter than the
|
|
1745
|
-
* engine and cost a real table its readable form.
|
|
1746
|
-
*
|
|
1747
|
-
* An empty `values` brands the column `never` — an enum permitting nothing can
|
|
1748
|
-
* hold nothing. Note what that becomes downstream: `InferRow` surfaces the
|
|
1749
|
-
* column as `undefined`, not `never`, so a read-time narrow written against
|
|
1750
|
-
* `never` (`if (row.e === "x")`) is dead differently than it looks.
|
|
1751
|
-
*/
|
|
1752
|
-
readonly enum: <const V extends ReadonlyArray<string | number>, const O extends ConstMethodOpts<never> = Record<string, never>>(values: V, options?: O) => FieldDescriptor & TypeBrand<V[number], O>;
|
|
1753
|
-
/** Vector field; `size` (>= 1) is the embedding dimensionality. */
|
|
1754
|
-
readonly vector: <const O extends ConstMethodOpts<VectorMethod> = Record<string, never>>(size: number, options?: O) => FieldDescriptor & TypeBrand<number[], O>;
|
|
1755
|
-
/** Nested object field (stored `obj`); `children` is a named field map. */
|
|
1756
|
-
readonly object: <const C extends FieldMap, const O extends ConstMethodOpts<never> = Record<string, never>>(children: C, options?: O) => FieldDescriptor & TypeBrand<FromFieldMap<C>, O>;
|
|
1757
|
-
/**
|
|
1758
|
-
* Table-reference (foreign-key) field — the column holds the referenced
|
|
1759
|
-
* table's primary key. The engine persists the link as a trailing `@` method
|
|
1760
|
-
* carrying the target table's id (`{name:"@", arg:["dbo=<guid>"]}`); on import
|
|
1761
|
-
* it parses that back into the column's `tableref_id`. The reference resolves to the
|
|
1762
|
-
* table's deterministic guid via the shared cross-object resolver, so it
|
|
1763
|
-
* agrees with the target table's payload `guid` with no shared registry.
|
|
1764
|
-
*
|
|
1765
|
-
* Defaults to an `int` column (matching an `int` primary key); pass
|
|
1766
|
-
* `{ type: "uuid" }` to reference a uuid-keyed table. A reference column may
|
|
1767
|
-
* only be `int` or `uuid` — the two valid primary-key types.
|
|
1768
|
-
*
|
|
1769
|
-
* @param table The referenced table (a `table()` def handle or its bare name).
|
|
1770
|
-
* For a **self-reference** (e.g. `tweets.reply_to → tweets`), the table's
|
|
1771
|
-
* `const` binding isn't assigned yet inside its own initializer — using the
|
|
1772
|
-
* handle throws a "used before declaration" error. Pass the **bare name**
|
|
1773
|
-
* instead: `f.tableRef("tweets", { type: "int" })`. Identity guids derive
|
|
1774
|
-
* from `(type, name)`, so the name form resolves to the same guid.
|
|
1775
|
-
*
|
|
1776
|
-
* Byte-verified whole-object against a persisted table readback
|
|
1777
|
-
* (`test/fixtures/tables/ex_field_table_ref.json`, asserted in
|
|
1778
|
-
* `test/conformance/kinds-corpus.test.ts`): the `@` method carries
|
|
1779
|
-
* `disabled:false`, sits last in `methods`, and its `dbo=` arg is the target
|
|
1780
|
-
* table's payload guid.
|
|
1781
|
-
*
|
|
1782
|
-
* The engine asserts the referenced table's primary-key type matches
|
|
1783
|
-
* (int↔int, uuid↔uuid). When the target is passed as a **def handle** its
|
|
1784
|
-
* `idType` is in hand, so a mismatch throws here instead of surfacing as an
|
|
1785
|
-
* import failure. The bare-name form (self-references) carries no schema —
|
|
1786
|
-
* there is nothing to check against, and it is not guessed at.
|
|
1787
|
-
*/
|
|
1788
|
-
readonly tableRef: <const O extends ConstMethodOpts<TableRefMethod> & {
|
|
1789
|
-
type?: "int" | "uuid";
|
|
1790
|
-
} = Record<string, never>>(table: ObjectRef, options?: O) => FieldDescriptor & TypeBrand<TableRefValue<O>, O>;
|
|
1791
|
-
};
|
|
1792
|
-
|
|
1793
|
-
/**
|
|
1794
|
-
* `obj({...})` — a **dynamic** object value: an object literal whose members can
|
|
1795
|
-
* be live references (`inp`/`ref`/`auth`/`col`) or constants. This is the
|
|
1796
|
-
* missing sibling of `c.obj` (issue #42): `c.obj` takes plain JSON only and
|
|
1797
|
-
* rejects nested tagged values, so it can't express `{ id: inp("id") }`.
|
|
1798
|
-
*
|
|
1799
|
-
* Xano stores a dynamic object as a single value with `tag: "const:expr2"` whose
|
|
1800
|
-
* `value` is the object rendered as a **XanoScript expression string** (verified
|
|
1801
|
-
* against the Xano engine's stored inline-value format). So `obj`
|
|
1802
|
-
* serializes each member to its XanoScript form (`$input.x`, `$var.x`, `$auth`,
|
|
1803
|
-
* `$db.col`, quoted strings, numbers) and wraps them in `{ … }`.
|
|
1804
|
-
*
|
|
1805
|
-
* Why `const:expr2` and not a structured `const:obj`: the Xano runtime value
|
|
1806
|
-
* evaluator resolves `const:obj` by JSON-decoding its value — it
|
|
1807
|
-
* treats the value as a *static JSON string*, so dynamic members (`$input.x`)
|
|
1808
|
-
* would never resolve. Only `const:expr2` is run through the expression parser
|
|
1809
|
-
* (it normalizes to `const:expr` and evaluates), so it is the sole
|
|
1810
|
-
* representation that resolves live references inside an object literal. That
|
|
1811
|
-
* choice is therefore runtime-verified, not a preference.
|
|
1812
|
-
*
|
|
1813
|
-
* The rendered string form (spacing/escaping) is now golden-verified: the
|
|
1814
|
-
* `call_agent` object-args fixture in the conformance corpus pins the exact
|
|
1815
|
-
* `const:expr` string this encoder emits for `obj({ question: inp(...) })`.
|
|
1816
|
-
*
|
|
1817
|
-
* **Supported members:** `inp()`, `ref()`, `auth()`, `col()`, `env()` /
|
|
1818
|
-
* `setting()` / `sys.*`, `c.now()`, `c.text/int/decimal/bool/null`, nested
|
|
1819
|
-
* `obj`-style records, and arrays of those — each optionally carrying a
|
|
1820
|
-
* **filter chain**, which renders as the expression language's own postfix pipe
|
|
1821
|
-
* (`$var.row|get:"address.city"`).
|
|
1822
|
-
*
|
|
1823
|
-
* The filter chain used to throw, and the rejection was wrong (#222). It
|
|
1824
|
-
* collided constantly, because `db.get` binds `null` on a miss — the SDK's own
|
|
1825
|
-
* headline gotcha — so almost every object built from a `db.get` result needs a
|
|
1826
|
-
* null-safe drill, which compiles through the `get` filter. One team counted
|
|
1827
|
-
* twenty pure-plumbing `s.set_var` statements written to work around it.
|
|
1828
|
-
*
|
|
1829
|
-
* The representation was never the obstacle: the engine's own parser stores
|
|
1830
|
-
* `{ …, goals: [$q.goal_1, …]|filter:$$ != null, … }` as ONE `const:expr2`
|
|
1831
|
-
* string, so a per-member chain is exactly what it carries. Nothing had to
|
|
1832
|
-
* change in the engine; the SDK was guessing that it could not.
|
|
1833
|
-
*
|
|
1834
|
-
* **On evidence.** The value of an `expr2` is an expression string the engine
|
|
1835
|
-
* parses — it is NOT XanoScript, and nothing validates its contents ahead of a
|
|
1836
|
-
* live run. So what backs this is the engine's own parser fixtures (paired
|
|
1837
|
-
* source → stored JSON), which show the exact string its tooling produces. A
|
|
1838
|
-
* rendering outside that set is not "probably fine"; it is unverified. Keep the
|
|
1839
|
-
* emitted grammar to shapes a fixture demonstrates.
|
|
1840
|
-
*
|
|
1841
|
-
* What still throws: a filter argument carrying its OWN chain (a trailing `|`
|
|
1842
|
-
* binds to the whole value, so it cannot be written without changing meaning),
|
|
1843
|
-
* a **disabled** filter (an expression string has nowhere to record that), and
|
|
1844
|
-
* the remaining exotic tags (`output`/`response`/`toolset`/`reg`). Build those
|
|
1845
|
-
* in a prior stack step and reference them with `ref`.
|
|
1846
|
-
*/
|
|
1847
|
-
|
|
1848
|
-
/**
|
|
1849
|
-
* A member of an {@link obj} literal — a {@link Value}, a raw scalar literal
|
|
1850
|
-
* (`string`/`number`/`boolean`, coerced to the matching constant), a nested
|
|
1851
|
-
* record, or an array. Raw scalars let `obj({ max_age_days: 3 })` and
|
|
1852
|
-
* `obj({ greeting: "hi" })` *just work* without wrapping each in `c.int`/`c.text`.
|
|
1853
|
-
*/
|
|
1854
|
-
type ObjMember = Value | string | number | boolean | ObjInput | ObjMember[];
|
|
1855
|
-
/** The record shape {@link obj} accepts: keys → members. */
|
|
1856
|
-
interface ObjInput {
|
|
1857
|
-
[key: string]: ObjMember;
|
|
1858
|
-
}
|
|
1859
|
-
/**
|
|
1860
|
-
* A {@link Value} that also carries, **at the type level only**, the member
|
|
1861
|
-
* record it was built from (`obj({ id: ref("u.id") })` → `ObjValue<{ id:
|
|
1862
|
-
* RefValue<"u.id"> }>`). The `__obj` carrier is phantom — never present at
|
|
1863
|
-
* runtime — and exists so `InferResponse` can recurse into the members and
|
|
1864
|
-
* resolve each one the way it resolves a top-level response key (issue #118).
|
|
1865
|
-
*
|
|
1866
|
-
* Before this, `obj()` returned a bare `Value`: the members were erased at the
|
|
1867
|
-
* signature, so the resolver saw no `__ref` to trace and every member landed on
|
|
1868
|
-
* the `unknown` floor. `{ user: obj({ id: ref("u.id") }) }` derived `{ user:
|
|
1869
|
-
* unknown }` while the identical refs written as object-literal keys derived
|
|
1870
|
-
* `{ id: number | null }` — and the mismatch only surfaced downstream, as
|
|
1871
|
-
* `unknown` flowing into a caller that had asked for a type.
|
|
1872
|
-
*
|
|
1873
|
-
* Because it is a subtype of `Value`, every existing `obj(...)` use — a request
|
|
1874
|
-
* body, an agent's `args`, a statement field — keeps type-checking unchanged.
|
|
1875
|
-
*/
|
|
1876
|
-
type ObjValue<T extends ObjInput = ObjInput> = Value & {
|
|
1877
|
-
readonly __obj: T;
|
|
1878
|
-
};
|
|
1879
|
-
/**
|
|
1880
|
-
* Build a dynamic object {@link Value} from a record of members. Members may be
|
|
1881
|
-
* references (`inp`/`ref`/`auth`/`col`), constants (`c.*`), nested records, or
|
|
1882
|
-
* arrays. Emits `tag:"const:expr2"` — the engine's dynamic-object representation.
|
|
1883
|
-
*
|
|
1884
|
-
* ```ts
|
|
1885
|
-
* obj({ id: inp("id"), name: c.text("Bob"), tags: [c.text("a"), ref("t")] })
|
|
1886
|
-
* // → { value: '{ id: $input.id, name: "Bob", tags: ["a", $var.t] }', tag: "const:expr2", filters: [] }
|
|
1887
|
-
* ```
|
|
1888
|
-
*
|
|
1889
|
-
* The member record is preserved on the return type as {@link ObjValue}, so a
|
|
1890
|
-
* response built with `obj()` traces through `InferResponse` exactly as the same
|
|
1891
|
-
* members written as object-literal keys would (issue #118). A dynamically-built
|
|
1892
|
-
* `ObjInput` has no literal to read and degrades to unknown-valued members.
|
|
1893
|
-
*/
|
|
1894
|
-
declare function obj<T extends ObjInput>(fields: T): ObjValue<T>;
|
|
1895
|
-
|
|
1896
|
-
/**
|
|
1897
|
-
* Response → `result[]` mapping, shared by every response-bearing kind
|
|
1898
|
-
* (function, query, tool, middleware, and the response-bearing triggers).
|
|
1899
|
-
* Extracted from the MVP's compile.ts so kinds beyond function can reuse it.
|
|
1900
|
-
*/
|
|
1901
|
-
|
|
1902
|
-
/**
|
|
1903
|
-
* A member of a record response — a {@link Value}, or a nested plain object
|
|
1904
|
-
* literal which is auto-wrapped via {@link obj} (so `response: { user: { id:
|
|
1905
|
-
* ref(x) } }` just works instead of failing tsc against `TaggedValue`; #133).
|
|
1906
|
-
*/
|
|
1907
|
-
type ResponseMember = Value | ObjInput;
|
|
1908
|
-
/** A single `Value` response, or a record of named result items. */
|
|
1909
|
-
type ResponseDef = Value | Record<string, ResponseMember>;
|
|
1910
|
-
/** Map a response into `result[]`: one unnamed item for a single value, or
|
|
1911
|
-
* one named item per key for a record. A record member that is a nested plain
|
|
1912
|
-
* object is auto-wrapped via {@link obj} (a dynamic `const:expr2` value). */
|
|
1913
|
-
declare function encodeResponse(response: ResponseDef | undefined): ResultItemXdo[];
|
|
1914
|
-
|
|
1915
|
-
export { type RowFromFieldMap as $, type MethodOpts as A, type BrandOpts as B, type CacheXdo as C, type DecimalMethod as D, type EmailMethod as E, type FunctionXdo as F, type MethodSpec as G, type HistoryXdo as H, type InputXdo as I, type MethodXdo as J, type MockEntry as K, type ListBoundsXdo as L, type MethodArg as M, type MockMap as N, type MockXdo as O, type ObjInput as P, type ObjMember as Q, REFERENCEABLE_KINDS as R, type ObjValue as S, type ObjectRef as T, type PasswordMethod as U, type Value as V, type PersistedFunctionRow as W, type RefValue as X, type RegexValue as Y, type ResponseDef as Z, type ResultItemXdo as _, FIELD_METHODS as a, type StackItemXdo as a0, type Statement as a1, type StatementAnnotations as a2, type StatementInputXdo as a3, type StatementOptions as a4, TAGS as a5, TEST_EXPECT_TYPES as a6, type TableRefMethod as a7, type Tag as a8, type TaggedValue as a9, setting as aA, statements as aB, sys as aC, test as aD, toolset as aE, withFilters as aF, type FieldOptions as aG, type Prettify as aH, type ReadonlyMethods as aI, type XanoFileUpload as aJ, type XanoDbLink as aK, type ConstMethodOpts as aL, type AsShapeBrand as aM, type TestDef as aa, type TestExpect as ab, type TestExpectType as ac, type TestXdo as ad, type TextFormat as ae, type TextMethod as af, type TypeBrand as ag, type ValueOf as ah, type VectorMethod as ai, type XanoFileRef as aj, type XanoGeoPosition as ak, type XanoGeoValue as al, annotate as am, auth as an, c as ao, caught as ap, col as aq, env as ar, expect as as, f as at, filter as au, inp as av, obj as aw, out as ax, ref as ay, resp as az, encodeStatement as b, type BrandValue as c, deriveGuid as d, encodeResponse as e, type CaughtField as f, getStatementFactory as g, type ConditionalContext as h, isRegisteredStatement as i, type ConditionalElifContext as j, type ExprGroup as k, type ExprNode as l, type ExprOperand as m, type ExprStatement as n, type FieldAccess as o, type FieldDescriptor as p, type FieldMap as q, resolveRef as r, type FieldOpts as s, toNestedFields as t, type FieldStyleType as u, type FieldXdo as v, type FilterXdo as w, type FilteredValue as x, type FromFieldMap as y, type IntMethod as z };
|
|
1083
|
+
export { inp as A, out as B, type CacheXdo as C, ref as D, type ExprGroup as E, type FunctionXdo as F, resp as G, type HistoryXdo as H, type InputXdo as I, setting as J, sys as K, type ListBoundsXdo as L, type MethodXdo as M, test as N, toolset as O, type PersistedFunctionRow as P, withFilters as Q, type RefValue as R, type StackItemXdo as S, TAGS as T, type Value as V, type CaughtField as a, type ConditionalContext as b, type ConditionalElifContext as c, type ExprNode as d, type ExprOperand as e, type ExprStatement as f, type FieldXdo as g, type FilterXdo as h, type FilteredValue as i, type RegexValue as j, type ResultItemXdo as k, type StatementInputXdo as l, TEST_EXPECT_TYPES as m, type Tag as n, type TaggedValue as o, type TestDef as p, type TestExpect as q, type TestExpectType as r, type TestXdo as s, auth as t, c as u, caught as v, col as w, env as x, expect as y, filter as z };
|