@xanots/sdk 0.0.9 → 0.0.11

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.
Files changed (116) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +66 -21
  3. package/dist/.build-fingerprint +1 -1
  4. package/dist/{agent-file-refresh-4W37DGXS.js → agent-file-refresh-QNKN5RYD.js} +3 -3
  5. package/dist/bin.js +10 -8
  6. package/dist/{branch-commands-PBQ36L4A.js → branch-commands-2BLOC2GR.js} +13 -11
  7. package/dist/bundle.d.ts +218 -0
  8. package/dist/bundle.js +143 -0
  9. package/dist/{capture-7PO6SGB4.js → capture-4WVJY4DQ.js} +2 -2
  10. package/dist/{chunk-OW2QZEWL.js → chunk-22TKBSDV.js} +2 -2
  11. package/dist/{chunk-ZOYMZZ3S.js → chunk-3INK4Y4E.js} +1 -1
  12. package/dist/{chunk-NDZFBZHC.js → chunk-3UABJA4X.js} +1 -1
  13. package/dist/{chunk-6Z5CNWFC.js → chunk-4IF54NU5.js} +37 -6
  14. package/dist/{chunk-KSV7VOEX.js → chunk-4Q7ZOHH7.js} +3 -3
  15. package/dist/{chunk-QTNO2WD6.js → chunk-7ZYW652H.js} +1 -1
  16. package/dist/{chunk-4PTSTDIG.js → chunk-AIZKXUNP.js} +2 -2
  17. package/dist/{chunk-P5C2YKAM.js → chunk-ANUDXFEX.js} +18 -27
  18. package/dist/{chunk-4BXJGVZ3.js → chunk-BC2C5GVI.js} +2 -69
  19. package/dist/chunk-BSK7ELHU.js +70 -0
  20. package/dist/chunk-CTD5ZCV6.js +28 -0
  21. package/dist/{chunk-5HCDZ2XN.js → chunk-DBFU47BJ.js} +2 -2
  22. package/dist/{chunk-OKNSR7MT.js → chunk-DIA7CT7J.js} +129 -150
  23. package/dist/chunk-EHP3WPEG.js +21 -0
  24. package/dist/{chunk-JQLR64UC.js → chunk-F6CYJ7TN.js} +21 -6
  25. package/dist/{chunk-BKDJN76G.js → chunk-FE5I6S6N.js} +1 -1
  26. package/dist/{chunk-5YQOIFT4.js → chunk-G4EJMQLD.js} +2 -2
  27. package/dist/{chunk-L6TPHWAU.js → chunk-HYBN4H3F.js} +60 -86
  28. package/dist/{chunk-QIWBCS7N.js → chunk-JGCWTCA7.js} +2 -2
  29. package/dist/{chunk-MDXR5E5Q.js → chunk-K5IOND4K.js} +2 -2
  30. package/dist/{chunk-4PE4ZAB7.js → chunk-KA6G2L7U.js} +5 -5
  31. package/dist/chunk-OHX6MIUZ.js +184 -0
  32. package/dist/{chunk-UDL46O35.js → chunk-OWGCOGKK.js} +155 -3
  33. package/dist/{chunk-QONOJO45.js → chunk-QK7ZQJLP.js} +140 -20
  34. package/dist/{chunk-3QW5NFZJ.js → chunk-QKM4U5UK.js} +3 -3
  35. package/dist/{chunk-7OXFMCTX.js → chunk-QYMAZRAU.js} +7 -7
  36. package/dist/{chunk-K3YSQDXJ.js → chunk-RCT7UX7B.js} +92 -75
  37. package/dist/{chunk-T4XPCJRF.js → chunk-TCFIPDB3.js} +1 -1
  38. package/dist/{chunk-ZZLPTHT5.js → chunk-UOZMSF4C.js} +15 -8
  39. package/dist/{chunk-7JDT4PBU.js → chunk-VAF6A3YD.js} +5 -179
  40. package/dist/{chunk-6DHBYBTO.js → chunk-VNQM3V2C.js} +1 -2
  41. package/dist/chunk-WGPXT2G2.js +22 -0
  42. package/dist/{chunk-6AAT2AYQ.js → chunk-WP4OZZV4.js} +2 -2
  43. package/dist/{chunk-OYMR5AMJ.js → chunk-XEOX6AM7.js} +2 -2
  44. package/dist/{chunk-MU3O43L2.js → chunk-YBC3IKMF.js} +2 -2
  45. package/dist/chunk-ZQ2PKR6R.js +40 -0
  46. package/dist/cli.d.ts +57 -31
  47. package/dist/cli.js +9 -7
  48. package/dist/codegen-command-FUT2KJB6.js +49 -0
  49. package/dist/codegen.d.ts +2 -1
  50. package/dist/{completion-A6BZ3XGU.js → completion-WF46272M.js} +2 -2
  51. package/dist/{config-NL33PN4D.js → config-476F3PT5.js} +1 -1
  52. package/dist/{deploy-command-5TTI4TUP.js → deploy-command-IP7V7GT4.js} +69 -100
  53. package/dist/{ephemeral-command-7TK52YQM.js → ephemeral-command-U4AQ3TXX.js} +25 -28
  54. package/dist/index.d.ts +6 -4
  55. package/dist/index.js +10 -9
  56. package/dist/init-command-NPVL32L6.js +34 -0
  57. package/dist/{onboard-command-EHOHKQQU.js → init-web-3JNFG6GI.js} +10 -10
  58. package/dist/internal.d.ts +4 -4
  59. package/dist/internal.js +86 -73
  60. package/dist/io-P2H75UV2.js +12 -0
  61. package/dist/{live-diff-QK4KC2FJ.js → live-diff-IXKBVG4K.js} +3 -3
  62. package/dist/{lock-GFXD6G2E.js → lock-46FWYE4D.js} +3 -2
  63. package/dist/{lock-commands-ET7NIOLH.js → lock-commands-ZZKZ4LZJ.js} +23 -21
  64. package/dist/{login-command-DFCURZLC.js → login-command-Z6CHTA57.js} +7 -7
  65. package/dist/{logout-command-WXVZQCAV.js → logout-command-ER6IKAYJ.js} +2 -2
  66. package/dist/{loop-7SAIGRCZ.js → loop-D5NPL4VH.js} +3 -3
  67. package/dist/{marketplace-command-BCOAAN2I.js → marketplace-command-P4IPLJ6J.js} +6 -6
  68. package/dist/{meta-client-57ZWVHST.js → meta-client-K2J4XH64.js} +6 -6
  69. package/dist/node.d.ts +5 -4
  70. package/dist/node.js +15 -13
  71. package/dist/{validate-command-SK5FPCV7.js → preflight-command-K346GPTY.js} +20 -18
  72. package/dist/{profile-command-QJAAUZIV.js → profile-command-LJSBDV2L.js} +5 -5
  73. package/dist/{release-command-4EXVLYV2.js → release-command-IMNTIVWK.js} +42 -38
  74. package/dist/response-BQVQ24l1.d.ts +844 -0
  75. package/dist/{routes-manifest-SP3ZXLMR.js → routes-manifest-PWZHDOI5.js} +2 -2
  76. package/dist/scaffold.js +2 -2
  77. package/dist/{static-host-D6KS7X45.js → static-host-3WMV7IZO.js} +1 -1
  78. package/dist/status-command-AL47VG7H.js +162 -0
  79. package/dist/{store-CUCBSYLj.d.ts → store-BLyNeQ8S.d.ts} +21 -8
  80. package/dist/{test-command-2F5LKMI6.js → test-command-YAZLKLGQ.js} +45 -28
  81. package/dist/{upgrade-command-QL523I62.js → upgrade-command-BN3EHAOI.js} +16 -14
  82. package/dist/{workspace-K72NP7SX.js → workspace-2COHDBM3.js} +1 -1
  83. package/dist/{workspace-command-HYA6JEKK.js → workspace-command-MNK7Y7MQ.js} +36 -34
  84. package/dist/{workspace-export-AJMGN3CQ.js → workspace-export-DURY5WYL.js} +2 -2
  85. package/dist/{response-CVAE2kMj.d.ts → xdo-BjJj5W_E.d.ts} +1 -837
  86. package/guides/README.md +2 -2
  87. package/guides/cli.md +17 -19
  88. package/guides/codegen.md +21 -5
  89. package/guides/coverage.md +1 -1
  90. package/guides/deploying.md +31 -34
  91. package/guides/environment.md +4 -4
  92. package/guides/object-kinds.md +3 -3
  93. package/guides/project-structure.md +1 -1
  94. package/guides/scaffold.md +25 -2
  95. package/guides/typed-frontend.md +2 -2
  96. package/llms/filters.md +11 -10
  97. package/llms/kinds-agent-mcp.md +1 -1
  98. package/llms/kinds-core.md +2 -2
  99. package/llms/kinds-realtime.md +1 -1
  100. package/llms/lock.md +5 -5
  101. package/llms/statements-data.md +3 -1
  102. package/llms/tests.md +1 -1
  103. package/llms/values.md +1 -1
  104. package/llms-full.txt +65 -63
  105. package/llms.txt +40 -41
  106. package/manifest.json +96 -427
  107. package/package.json +7 -2
  108. package/dist/chunk-3EYUR3TX.js +0 -100
  109. package/dist/chunk-JQJPFUZI.js +0 -118
  110. package/dist/chunk-YNZFIY4J.js +0 -78
  111. package/dist/codegen-command-YSCSCVT5.js +0 -43
  112. package/dist/env-target-4T7AT347.js +0 -16
  113. package/dist/init-command-OVFFW4QS.js +0 -30
  114. package/dist/io-M7XZEMK7.js +0 -11
  115. package/dist/sandbox-details-command-EDO56IY3.js +0 -18
  116. package/dist/sandbox-export-command-MO6DEZ7Z.js +0 -24
@@ -1076,840 +1076,4 @@ type PersistedFunctionRow = FunctionXdo & {
1076
1076
  };
1077
1077
  };
1078
1078
 
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 };
1079
+ 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 };