@lunora/values 1.0.0-alpha.9 → 1.0.0-alpha.91

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/dist/index.d.mts CHANGED
@@ -38,7 +38,14 @@ declare const describeValue: (value: unknown, options?: {
38
38
  literal?: boolean;
39
39
  }) => string;
40
40
  declare const formatPath: (path: ValidationPath) => string;
41
- /** Branded id type, e.g. `Id<"users">`. */
41
+ /**
42
+ * A cyrb53 string hash — fast, well-distributed, 53-bit, with good avalanche
43
+ * behaviour. Public-domain (bryc). Two independent accumulators seeded from
44
+ * `seed` are mixed and combined; we down-fold the 53-bit result to an unsigned
45
+ * 32-bit integer for faker's seed.
46
+ */
47
+ declare const cyrb53: (text: string, seed?: number) => number;
48
+ /** Branded id type, e.g. `Id<"users">`. */
42
49
  type Id<TableName extends string> = string & {
43
50
  readonly __table: TableName;
44
51
  };
@@ -80,7 +87,7 @@ interface MetaOptions {
80
87
  * Runtime "kind" tag attached to every validator. Codegen and reflective tools
81
88
  * use this to inspect the shape without crawling the closure.
82
89
  */
83
- type ValidatorKind = "any" | "array" | "bigint" | "boolean" | "bytes" | "date" | "from" | "id" | "literal" | "null" | "number" | "object" | "optional" | "record" | "storage" | "string" | "timestamp" | "union";
90
+ type ValidatorKind = "any" | "array" | "bigint" | "boolean" | "bytes" | "date" | "from" | "geoPoint" | "id" | "literal" | "null" | "number" | "object" | "optional" | "record" | "storage" | "string" | "timestamp" | "union";
84
91
  interface Validator<T = unknown> extends StandardSchemaV1<T, T> {
85
92
  readonly __type: T;
86
93
  /**
@@ -96,7 +103,15 @@ interface Validator<T = unknown> extends StandardSchemaV1<T, T> {
96
103
  *
97
104
  * Works in any context — argument validators, column validators, or
98
105
  * standalone — so it can encode invariants like
99
- * `v.number().check(n => n >= 0)` or
106
+ * `v.number().check(n => n >= 0)`.
107
+ *
108
+ * For the common length/format/range cases, prefer the named shortcuts
109
+ * (`v.string().min(1)`, `.max(n)`, `.length(n)`, `.pattern(re)`, `.email()`,
110
+ * `.url()`; `v.number().min(n)`, `.max(n)`, `.int()`, `.positive()`;
111
+ * `v.array(...).min(n)`, `.max(n)`) — each is sugar over this same
112
+ * `.check(predicate, { schema })` path, so the predicate and the JSON Schema
113
+ * keyword are set together and can never drift apart. `.check()` remains the
114
+ * escape hatch for anything the shortcuts don't cover, e.g.
100
115
  * `v.string().check(s => s.length > 0, { message: "non-empty", schema: { minLength: 1 } })`.
101
116
  */
102
117
  check: (predicate: (value: T) => boolean, options?: CheckOptions | string) => Validator<T>;
@@ -108,8 +123,8 @@ interface Validator<T = unknown> extends StandardSchemaV1<T, T> {
108
123
  * `schema` fragments (later wins on conflicting keys).
109
124
  */
110
125
  meta: (options: MetaOptions) => Validator<T>;
111
- parse: (value: unknown) => T;
112
- safeParse: (value: unknown) => {
126
+ parse: (value: unknown, options?: ParseOptions) => T;
127
+ safeParse: (value: unknown, options?: ParseOptions) => {
113
128
  error: ValidationError;
114
129
  ok: false;
115
130
  } | {
@@ -182,7 +197,14 @@ interface ColumnValidator<TSelect, TInsert> extends Column<TSelect, TInsert>, Va
182
197
  $defaultFn: (function_: () => TSelect) => ColumnValidator<TSelect, TInsert | undefined>;
183
198
  /** Recompute the field on every patch/replace when not explicitly provided. */
184
199
  $onUpdateFn: (function_: () => TSelect) => ColumnValidator<TSelect, TInsert>;
185
- /** Override the inferred select/insert type without changing runtime parsing (e.g. `v.string().$type&lt;Id&lt;"users">>()`). */
200
+ /**
201
+ * Override the type `Infer<>` gives this validator without changing runtime
202
+ * parsing (e.g. `v.string().$type<Brand>()`). An unchecked assertion: the
203
+ * parser still accepts any value of the base kind, so codegen's `Doc_*` /
204
+ * `Insert_*` / procedure-arg types keep the base type (`string`) — the one
205
+ * the stored value is actually guaranteed to have. For a document id use
206
+ * `v.id("users")`, which is checked.
207
+ */
186
208
  $type: <TOverride>() => ColumnValidator<TOverride, TOverride>;
187
209
  /** Refinement predicate run after parsing — see {@link Validator.check}. Chainable; preserves column modifiers. */
188
210
  check: (predicate: (value: TSelect) => boolean, options?: CheckOptions | string) => ColumnValidator<TSelect, TInsert>;
@@ -211,6 +233,81 @@ interface TimestampColumnValidator extends ColumnValidator<number, number> {
211
233
  /** Default to the current epoch-ms (`Date.now()`) at insert time; field becomes optional on insert. */
212
234
  defaultNow: () => ColumnValidator<number, number | undefined>;
213
235
  }
236
+ /**
237
+ * A {@link ColumnValidator} for `v.string()` with ergonomic refinement
238
+ * shortcuts. Each method is sugar over `.check(predicate, { schema })` — it
239
+ * sets the runtime predicate AND the matching JSON Schema keyword in one call
240
+ * so the two can never drift (see the module-level `.check()` docstring for
241
+ * the underlying two-part mechanism). Chainable among each other; `.check()`/
242
+ * `.meta()` compose after them but the return narrows to the base
243
+ * {@link ColumnValidator} (no further refinement shortcuts after that point).
244
+ */
245
+ interface StringColumnValidator extends ColumnValidator<string, string> {
246
+ /** Require a valid email address (`format: "email"`). Uses a pragmatic (non-RFC-5322-exhaustive) pattern. */
247
+ email: () => StringColumnValidator;
248
+ /** Require exactly `length` characters (`minLength`/`maxLength` both set to `length`). */
249
+ length: (length: number) => StringColumnValidator;
250
+ /** Require at most `max` characters (`maxLength`). */
251
+ max: (max: number) => StringColumnValidator;
252
+ /** Require at least `min` characters (`minLength`). */
253
+ min: (min: number) => StringColumnValidator;
254
+ /**
255
+ * Require the value to match `pattern` (JSON Schema `pattern` set from
256
+ * `pattern.source`; emitted `pattern` does not encode `pattern.flags` — a
257
+ * case-insensitive `/i` regex, for instance, emits a flag-less JSON Schema
258
+ * pattern). A `g`/`y`-flagged `pattern` is tested statelessly (its
259
+ * `lastIndex` is never consulted or advanced), so a single validator
260
+ * instance gives the same answer for the same input on every call.
261
+ */
262
+ pattern: (pattern: RegExp) => StringColumnValidator;
263
+ /**
264
+ * Require a valid `http:`/`https:` URL (`format: "uri"`). Parseable by the
265
+ * WHATWG `URL` constructor is necessary but not sufficient — schemes such as
266
+ * `javascript:`, `data:`, `file:`, and `vbscript:` all parse successfully but
267
+ * are rejected here, since accepting them lets a validated "link" field carry
268
+ * an XSS payload straight into an anchor's `href` or `window.location` at
269
+ * render time.
270
+ */
271
+ url: () => StringColumnValidator;
272
+ }
273
+ /**
274
+ * A {@link ColumnValidator} for `v.number()` with ergonomic refinement
275
+ * shortcuts — see {@link StringColumnValidator} for the delegation pattern.
276
+ */
277
+ interface NumberColumnValidator extends ColumnValidator<number, number> {
278
+ /** Require an integer value (`Number.isInteger`); JSON Schema `type` narrows to `"integer"`. */
279
+ int: () => NumberColumnValidator;
280
+ /** Require at most `max` (`maximum`). */
281
+ max: (max: number) => NumberColumnValidator;
282
+ /** Require at least `min` (`minimum`). */
283
+ min: (min: number) => NumberColumnValidator;
284
+ /** Require a value strictly greater than zero (`exclusiveMinimum: 0`). */
285
+ positive: () => NumberColumnValidator;
286
+ }
287
+ /**
288
+ * A {@link ColumnValidator} for `v.object(...)`, carrying the `.strip()` opt-out.
289
+ */
290
+ interface ObjectColumnValidator<T> extends ColumnValidator<T, T> {
291
+ /**
292
+ * Drop keys this shape does not declare, even under `.output()`.
293
+ *
294
+ * Only meaningful there — input parsing strips already. Say it when the
295
+ * narrowing is deliberate (trimming an internal field off a row before it
296
+ * reaches a client); without it, an undeclared key on the way OUT is an
297
+ * error, because the alternative is deleting server data silently.
298
+ */
299
+ strip: () => ObjectColumnValidator<T>;
300
+ }
301
+ /**
302
+ * A {@link ColumnValidator} for `v.array(...)` with ergonomic length-refinement
303
+ * shortcuts — see {@link StringColumnValidator} for the delegation pattern.
304
+ */
305
+ interface ArrayColumnValidator<TItem> extends ColumnValidator<TItem[], TItem[]> {
306
+ /** Require at most `max` items (`maxItems`). */
307
+ max: (max: number) => ArrayColumnValidator<TItem>;
308
+ /** Require at least `min` items (`minItems`). */
309
+ min: (min: number) => ArrayColumnValidator<TItem>;
310
+ }
214
311
  /** The type a validator/column presents on **select** (reads). */
215
312
  type InferSelect<V> = V extends Validator<infer T> ? T : never;
216
313
  /** The type a validator/column accepts on **insert** (writes). */
@@ -223,8 +320,13 @@ type SelectShape<S extends Record<string, Validator>> = { [K in keyof S]: InferS
223
320
  * become optional keys.
224
321
  */
225
322
  type InsertShape<S extends Record<string, Validator>> = { [K in keyof S as undefined extends InferInsert<S[K]> ? K : never]?: Exclude<InferInsert<S[K]>, undefined>; } & { [K in keyof S as undefined extends InferInsert<S[K]> ? never : K]: InferInsert<S[K]>; };
226
- declare const string: () => ColumnValidator<string, string>;
227
- declare const number: () => ColumnValidator<number, number>;
323
+ /** Options for {@link Validator.parse} / {@link Validator.safeParse}. */
324
+ interface ParseOptions {
325
+ /** See {@link ParseContext.rejectUnknownKeys}. */
326
+ rejectUnknownKeys?: boolean;
327
+ }
328
+ declare const string: () => StringColumnValidator;
329
+ declare const number: () => NumberColumnValidator;
228
330
  /** Epoch-millisecond timestamp (`number`). Pair with `.defaultNow()` for an insert-time clock. */
229
331
  declare const timestamp: () => TimestampColumnValidator;
230
332
  /** Calendar date stored as an epoch-millisecond `number`. Pair with `.defaultNow()` for an insert-time clock. */
@@ -244,8 +346,35 @@ declare const id: <TableName extends string>(tableName: TableName) => ColumnVali
244
346
  * signed URLs); omit it for the app's default bucket.
245
347
  */
246
348
  declare const storage: (bucket?: string) => ColumnValidator<string, string>;
349
+ /**
350
+ * A geographic point — latitude/longitude in decimal degrees (WGS84). The value
351
+ * a `v.geoPoint()` column reads/writes. Stored as a JSON object alongside the
352
+ * row; a `.geoIndex(name, { field })` on the table maintains a geohash companion
353
+ * so `withGeoIndex(name, q => q.near(point, radius) | q.within(bbox))` can answer
354
+ * proximity/bounding-box reads.
355
+ */
356
+ interface GeoPoint {
357
+ /** Latitude in decimal degrees, `-90 … 90`. */
358
+ lat: number;
359
+ /** Longitude in decimal degrees, `-180 … 180`. */
360
+ lng: number;
361
+ }
362
+ /**
363
+ * A latitude/longitude point (WGS84 decimal degrees). Parses an object with
364
+ * finite `lat` ∈ `[-90, 90]` and `lng` ∈ `[-180, 180]`; any other shape or an
365
+ * out-of-range coordinate throws a {@link ValidationError}. Pair with a table's
366
+ * `.geoIndex(name, { field })` to enable `near` / `within` reads.
367
+ */
368
+ declare const geoPoint: () => ColumnValidator<GeoPoint, GeoPoint>;
247
369
  declare const literal: <T extends bigint | boolean | number | string | null>(literalValue: T) => ColumnValidator<T, T>;
248
- declare const array: <V extends Validator>(inner: V) => ColumnValidator<Infer<V>[], Infer<V>[]>;
370
+ /**
371
+ * True when `validator` is marked with {@link sensitive} or wraps a marked
372
+ * validator anywhere in its tree. Coarse on purpose: an argument whose tree holds
373
+ * any secret is treated as a secret as a whole, which fails closed where a
374
+ * per-field walk over wire-encoded values would not.
375
+ */
376
+ declare const containsSensitive: (validator: Validator) => boolean;
377
+ declare const array: <V extends Validator>(inner: V) => ArrayColumnValidator<Infer<V>>;
249
378
  /**
250
379
  * Split a value-type map into optional + required keys: any member whose value
251
380
  * type includes `undefined` becomes an optional key. The single optionality rule
@@ -253,45 +382,144 @@ declare const array: <V extends Validator>(inner: V) => ColumnValidator<Infer<V>
253
382
  * inference (`InferValidatorMap` in `./validator-map`), so the two can never
254
383
  * drift. (`InsertShape` stays separate — it additionally `Exclude`s `undefined`
255
384
  * from the optional value, a deliberate insert-type difference.)
385
+ *
386
+ * `undefined extends M[K]` is the type-level spelling of "the parser accepts
387
+ * this field absent" — the same question `acceptsAbsent` in
388
+ * `./json-schema-core` answers structurally. It is broader than
389
+ * `v.optional(...)` on purpose: `v.any()` returns its input unchanged, so it
390
+ * parses an absent field happily, and a `v.union(...)` with an `any`/optional
391
+ * member does too. Anything narrower would mark a key required that the runtime
392
+ * does not require — which is how a generated `_generated/api.ts` came to reject
393
+ * args the server accepts (issue #688).
256
394
  */
257
395
  type OptionalizeShape<M> = { [K in keyof M as undefined extends M[K] ? K : never]?: M[K]; } & { [K in keyof M as undefined extends M[K] ? never : K]: M[K]; };
258
396
  type ObjectShape = Record<string, Validator>;
259
397
  type ObjectShapeType<S extends ObjectShape> = OptionalizeShape<{ [K in keyof S]: Infer<S[K]>; }>;
260
- declare const objectValidator: <S extends ObjectShape>(shape: S) => ColumnValidator<ObjectShapeType<S>, ObjectShapeType<S>>;
398
+ declare const objectValidator: <S extends ObjectShape>(shape: S, stripUnknown?: boolean) => ObjectColumnValidator<ObjectShapeType<S>>;
399
+ /**
400
+ * Mark a validator's value as sensitive. Parsing and the accepted set are
401
+ * unchanged. A failed parse withholds the value from `received` and the message
402
+ * (see {@link ParseContext.redact}); the JSON Schema node is `writeOnly`, with
403
+ * `format: "password"` on a plain string; and the request log, the MCP proposal
404
+ * and the offline queue treat the argument as a secret (see
405
+ * {@link containsSensitive}). In a recorded string the value is masked wherever it
406
+ * appears if it is four or more characters, as a whole word or number if it is
407
+ * three, and only as the whole string if it is shorter. A string of four or more
408
+ * characters is also matched in its JSON-escaped spelling, since a handler that
409
+ * serializes its arguments writes that form.
410
+ *
411
+ * A marker is a meta flag on the same kind rather than a kind of its own, so
412
+ * every `switch (kind)` and `kind === "optional"` test keeps its meaning and
413
+ * `v.sensitive(v.optional(x))` stays optional.
414
+ */
415
+ declare const sensitive: <V extends Validator>(validator: V) => V;
261
416
  declare const record: <K extends Validator<string>, V extends Validator>(keyValidator: K, valueValidator: V) => ColumnValidator<Record<Infer<K>, Infer<V>>, Record<Infer<K>, Infer<V>>>;
262
417
  declare const union: <Vs extends ReadonlyArray<Validator>>(...members: Vs) => ColumnValidator<Infer<Vs[number]>, Infer<Vs[number]>>;
263
418
  declare const optional: <V extends Validator>(inner: V) => ColumnValidator<Infer<V> | undefined, Infer<V> | undefined>;
419
+ /** Every member of a shape made optional — the result of {@link partial}. */
420
+ type PartialShape<S extends ObjectShape> = { [K in keyof S]: ColumnValidator<Infer<S[K]> | undefined, Infer<S[K]> | undefined>; };
421
+ /**
422
+ * Wrap every member of a shape in {@link optional}.
423
+ *
424
+ * A patch-style procedure takes "any subset of these columns" — the same shape
425
+ * the table declares, with nothing required. Spelling that out by hand means a
426
+ * second copy of the shape that has to be kept in step with the first, and the
427
+ * failure when it drifts is quiet: a column added to the table is simply not
428
+ * accepted by the patch, and nothing typechecks it against the table.
429
+ *
430
+ * Takes and returns a *shape record* rather than a `v.object(...)`, so the one
431
+ * function serves both positions — a procedure's args map (`.input(...)`) and a
432
+ * nested object (`v.object(v.partial(shape))`).
433
+ *
434
+ * A member that is already `v.optional(...)` is passed through rather than
435
+ * double-wrapped, so this is idempotent.
436
+ *
437
+ * **Pass the fields a caller may patch, not a whole table's shape.** Handing this
438
+ * `schema.tables.x.shape` makes every present and *future* column client-writable:
439
+ * add `ownerId`, `role`, or `isVerified` to the table later and it silently joins
440
+ * the patch, with no diff on the procedure to review. Row-level policies do not
441
+ * close that — they decide which ROW you may write, not which fields — so the
442
+ * allow-list has to be here.
443
+ * @example
444
+ * ```ts
445
+ * const editable = { body: v.string(), title: v.string() };
446
+ *
447
+ * mutation.input({ id: v.id("threads"), ...v.partial(editable) }).mutation(…)
448
+ * ```
449
+ */
450
+ declare const partial: <S extends ObjectShape>(shape: S) => PartialShape<S>;
264
451
  declare const any: () => ColumnValidator<unknown, unknown>;
265
452
  /**
266
- * Infer the output type of a Standard Schema v1 object. When the schema omits
267
- * `~standard.types` (it is optional in the spec), falls back to `unknown` so
268
- * callers always get a usable type rather than `never`.
453
+ * The type a Standard Schema v1 object validates TO — what a read gets back.
454
+ *
455
+ * Defer to the spec's own helper rather than matching `~standard.types`: the spec
456
+ * declares that property optional (it is a phantom that never exists at runtime),
457
+ * so every real library types it as a union with `undefined`, and a hand-written
458
+ * `extends { output: infer O }` misses all of them. A schema that declares no
459
+ * `types` still resolves through the constraint to `unknown`.
460
+ */
461
+ type InferStandardOutput<S extends StandardSchemaV1> = StandardSchemaV1.InferOutput<S>;
462
+ /**
463
+ * The type a Standard Schema v1 object validates FROM — what a write supplies.
464
+ *
465
+ * Distinct from {@link InferStandardOutput} only for a transforming schema
466
+ * (`z.string().transform(…)`, `z.coerce.number()`), where the value handed in is
467
+ * not the value stored. Identical for everything else.
269
468
  */
270
- type InferStandardOutput<S extends StandardSchemaV1> = S["~standard"]["types"] extends {
271
- output: infer O;
272
- } ? O : unknown;
469
+ type InferStandardInput<S extends StandardSchemaV1> = StandardSchemaV1.InferInput<S>;
273
470
  /**
274
471
  * Wrap any Standard Schema v1 validator (`zod`, `valibot`, `arktype`, …) so it
275
- * can be used as an **args** validator in `query`/`mutation`/`action`. The
276
- * wrapped validator's output type is inferred from `~standard.types.output`
277
- * when declared; falls back to `unknown` when the schema omits the types field.
472
+ * can be used as an args validator in `query`/`mutation`/`action`, or as a table
473
+ * column. The wrapped validator's output type is inferred from
474
+ * `~standard.types.output` when declared; falls back to `unknown` when the
475
+ * schema omits the types field.
476
+ *
477
+ * **Columns are stored by the value's runtime type.** A shard row is a JSON
478
+ * document, so a `v.from()` column needs no SQL type of its own. For a
479
+ * `.global()` table it maps to a TEXT column holding whatever the encoder
480
+ * produces: a scalar is written verbatim (a `v.from(z.string())` column holds a
481
+ * bare `hello`, not `"hello"`), and an object or array is JSON-encoded. That is
482
+ * the same rule `v.union` and `v.any` follow, and it is why the column cannot be
483
+ * a Postgres/MySQL `JSON` column — a bare `hello` is not valid JSON.
484
+ *
485
+ * The consequence worth knowing: a stored *string* that itself looks like JSON
486
+ * (`'{"a":1}'`) is ambiguous on read and decodes to the parsed object. Declare
487
+ * the column with a concrete `v.*` type when the plain column type matters — for
488
+ * a comparison index, or to avoid that ambiguity.
278
489
  *
279
- * **Args-only.** `v.from(...)` validators must not be used as table columns —
280
- * `defineTable` checks the `kind` and throws a clear error if you try.
490
+ * **Not seedable.** `@lunora/seed` cannot introspect an external schema to
491
+ * invent a valid value, so it refuses a `v.from()` column with an actionable
492
+ * error rather than generating one that fails validation on insert.
281
493
  *
282
- * **Sync-only.** Standard Schema allows async `validate`; Lunora args
283
- * validation is synchronous and throws when a Promise is returned.
494
+ * **Sync-only.** Standard Schema allows async `validate`; Lunora validation is
495
+ * synchronous and throws when a Promise is returned.
496
+ *
497
+ * **Reads and writes can differ.** A write supplies the schema's INPUT and a read
498
+ * gets its OUTPUT back, because what is stored is `validate()`'s result. The two
499
+ * coincide for every non-transforming schema; they part for `z.coerce.number()`
500
+ * and friends, where typing the insert side as the output would demand the
501
+ * post-transform value from a caller whose value the validator is there to
502
+ * transform.
284
503
  */
285
- declare const from: <S extends StandardSchemaV1>(schema: S) => ColumnValidator<InferStandardOutput<S>, InferStandardOutput<S>>;
504
+ declare const from: <S extends StandardSchemaV1>(schema: S) => ColumnValidator<InferStandardOutput<S>, InferStandardInput<S>>;
286
505
  /**
287
506
  * True when `validator` is `v.from(...)` or structurally wraps one through
288
- * `v.optional` / `v.array` / `v.object` / `v.record` / `v.union`. `defineTable`
289
- * uses it to reject Standard-Schema-backed validators anywhere in a column —
290
- * not just at the top level — since they are args-only and have no SQL column
291
- * type. The nested children live on the validator's `_meta` (`inner`, `shape`,
292
- * `members`, `keyValidator`/`valueValidator`) and are themselves validators.
507
+ * `v.optional` / `v.array` / `v.object` / `v.record` / `v.union`. The nested
508
+ * children live on the validator's `_meta` (`inner`, `shape`, `members`,
509
+ * `keyValidator`/`valueValidator`) and are themselves validators.
510
+ *
511
+ * For tooling that must know whether a value is validated by an external
512
+ * Standard Schema rather than a concrete `v.*` type — a seeder that cannot
513
+ * invent a conforming value, a JSON Schema exporter that has nothing to
514
+ * describe. `defineTable` no longer calls it: a `v.from()` column is allowed
515
+ * and stores JSON, see {@link from}.
293
516
  */
294
517
  declare const isOrWrapsFromValidator: (validator: Validator) => boolean;
518
+ /**
519
+ * The names of a function's arguments that carry a {@link sensitive} marker.
520
+ * Memoised per args object: the request log asks on every dispatch.
521
+ */
522
+ declare const sensitiveArgumentNames: (args: Readonly<Record<string, unknown>>) => ReadonlySet<string>;
295
523
  /**
296
524
  * The inner validator wrapped by `v.optional(inner)`, or `undefined` for any
297
525
  * other validator. The nested child lives on the validator's internal `_meta`
@@ -302,6 +530,15 @@ declare const isOrWrapsFromValidator: (validator: Validator) => boolean;
302
530
  * @returns The inner validator if `v.optional(...)`, otherwise `undefined`.
303
531
  */
304
532
  declare const optionalInner: (validator: Validator) => Validator | undefined;
533
+ /**
534
+ * True when every value `validator` accepts is a string: `v.string()`, `v.id()`,
535
+ * `v.storage()`, a `v.literal("…")`, or a `v.union(...)` of those. For tooling
536
+ * that carries a value as a string on a wire (a URL segment, a topic key) and
537
+ * must refuse, up front, a validator that could never match it. The members of a
538
+ * union and the value of a literal live on `_meta`; this accessor keeps that
539
+ * knowledge in the package that owns validator internals.
540
+ */
541
+ declare const isStringValidator: (validator: Validator) => boolean;
305
542
  /**
306
543
  * Validator/codec namespace. Each factory returns a {@link Validator} with a
307
544
  * runtime `parse`/`safeParse` plus a phantom `__type` field for inference.
@@ -314,13 +551,16 @@ declare const v: {
314
551
  bytes: typeof bytes;
315
552
  date: typeof date;
316
553
  from: typeof from;
554
+ geoPoint: typeof geoPoint;
317
555
  id: typeof id;
318
556
  literal: typeof literal;
319
557
  null: typeof nullValidator;
320
558
  number: typeof number;
321
559
  object: typeof objectValidator;
322
560
  optional: typeof optional;
561
+ partial: typeof partial;
323
562
  record: typeof record;
563
+ sensitive: typeof sensitive;
324
564
  storage: typeof storage;
325
565
  string: typeof string;
326
566
  timestamp: typeof timestamp;
@@ -343,7 +583,7 @@ interface JsonSchema {
343
583
  * no runtime metadata — so `constraints`/`isNullable` may be inert there).
344
584
  *
345
585
  * A reader normalizes a `TNode` to the small set of children/leaves the mapper
346
- * recurses over. Composite accessors (`inner`/`shape`/`members`/`valueChild`)
586
+ * recurses over. Composite accessors (`inner`/`shape`/`members`/`keyChild`/`valueChild`)
347
587
  * return the same `TNode` type so the mapper can recurse uniformly; leaf concerns
348
588
  * that differ between the two sources — how a literal's `const` is computed,
349
589
  * whether a `.check()`/`.meta()` constraint fragment exists, whether `.nullable()`
@@ -361,6 +601,12 @@ interface SchemaNodeReader<TNode> {
361
601
  inner: (node: TNode) => TNode | undefined;
362
602
  /** Whether `.nullable()` was applied (runtime: `_meta.column.notNull === false`). */
363
603
  isNullable: (node: TNode) => boolean;
604
+ /**
605
+ * Key-child of a `record` node, mapped to `propertyNames`. May be absent on
606
+ * the IR side (and on a `v.record(v.string(), …)` whose key validator adds
607
+ * no constraint beyond `type: "string"` it is merely redundant, not wrong).
608
+ */
609
+ keyChild: (node: TNode) => TNode | undefined;
364
610
  /** Discriminating validator kind. */
365
611
  kind: (node: TNode) => ValidatorKind;
366
612
  /**
@@ -371,6 +617,11 @@ interface SchemaNodeReader<TNode> {
371
617
  literalSchema: (node: TNode) => JsonSchema;
372
618
  /** Member nodes of a `union`. */
373
619
  members: (node: TNode) => ReadonlyArray<TNode>;
620
+ /**
621
+ * Whether the node is marked sensitive (`v.sensitive`). A sensitive node is
622
+ * emitted `writeOnly`, and a plain string also gets `format: "password"`.
623
+ */
624
+ sensitive: (node: TNode) => boolean;
374
625
  /** Property nodes of an `object`, keyed by property name. */
375
626
  shape: (node: TNode) => Record<string, TNode>;
376
627
  /** Target table name of an `id` node. */
@@ -385,10 +636,13 @@ interface SchemaNodeReader<TNode> {
385
636
  * so nested objects/arrays/unions/records are fully expanded (never collapsed to
386
637
  * one level).
387
638
  *
388
- * `date`/`timestamp` are epoch-millisecond numbers in Lunora (not ISO strings),
389
- * so they schema as integers; `bigint` schemas as an int64 (JSON has no bigint
390
- * type, so `format: int64` is the conventional OpenAPI carrier); `bytes` is an
391
- * `ArrayBuffer`, surfaced as base64 per JSON Schema 2020-12 content encoding.
639
+ * Each node names the JSON CARRIER, not the decoded JS type — the transport
640
+ * decodes before the parser sees a value, so describing the JS type would
641
+ * advertise shapes no JSON body can hold. `date`/`timestamp` are
642
+ * epoch-millisecond numbers in Lunora (not ISO strings), so they schema as
643
+ * integers; `bigint` rides as an int64 decimal string, the same carrier the
644
+ * wire codec and `v.literal(5n)` use; `bytes` is an `ArrayBuffer`, surfaced as
645
+ * base64 per JSON Schema 2020-12 content encoding.
392
646
  *
393
647
  * A `.check()`/`.meta()` JSON Schema fragment (when the reader exposes one) is
394
648
  * shallow-merged onto the node — constraint keys win on conflict. A `.nullable()`
@@ -397,9 +651,34 @@ interface SchemaNodeReader<TNode> {
397
651
  */
398
652
  declare const jsonSchemaFromNode: <TNode>(node: TNode, reader: SchemaNodeReader<TNode>) => JsonSchema;
399
653
  /**
400
- * Build `{ type: "object", properties, required, additionalProperties: false }`
401
- * from a node shape. A `v.optional(...)` property is the only thing that drops
402
- * out of `required`; every other property is required.
654
+ * True when the parser accepts this node's field ABSENT — the only honest test
655
+ * for whether a key is optional.
656
+ *
657
+ * `kind === "optional"` used to be the whole test, which called two kinds
658
+ * required that parse `{}` happily: `v.any()` (its parser returns `undefined`
659
+ * unchanged) and a `v.union(...)` with an optional or `any` member (the union
660
+ * tries members, one of which accepts `undefined`). A contract that requires a
661
+ * field the server does not cannot be satisfied by a generated client.
662
+ *
663
+ * Shared beyond JSON Schema's `required`: `@lunora/codegen`'s api emitter runs it
664
+ * over the build-time validator IR to decide `key?: T` vs `key: T`, so the
665
+ * generated `_generated/api.ts` argument types, the emitted OpenAPI/OpenRPC
666
+ * specs, and `Infer`'s `undefined extends …` optionality rule all answer this
667
+ * one question the same way.
668
+ * @returns `true` when an absent value parses.
669
+ */
670
+ declare const acceptsAbsent: <TNode>(node: TNode, reader: SchemaNodeReader<TNode>) => boolean;
671
+ /**
672
+ * Build `{ type: "object", properties, required }` from a node shape.
673
+ *
674
+ * Deliberately NOT `additionalProperties: false`: `v.object` STRIPS an
675
+ * undeclared key rather than refusing it (only `.output()`'s
676
+ * `rejectUnknownKeys` mode refuses one, and it is not what this schema
677
+ * describes), so closing the object had a spec-validating client reject bodies
678
+ * the server accepts. Absent means allowed, which is what the parser does.
679
+ *
680
+ * `required` lists every key whose field cannot be absent — see
681
+ * {@link acceptsAbsent}.
403
682
  */
404
683
  declare const objectSchemaFromNodes: <TNode>(shape: Record<string, TNode>, reader: SchemaNodeReader<TNode>) => JsonSchema;
405
684
  /**
@@ -467,7 +746,7 @@ declare const DEFER_VALIDATION: unique symbol;
467
746
  declare const installCompiledValidatorMap: (validators: object, compiled: CompiledValidatorMap) => void;
468
747
  /**
469
748
  * Validate each declared field of `source` through its validator, re-wrapping
470
- * any {@link ValidationError} with a `label.&lt;key>:` prefix and the rebuilt path
749
+ * any {@link ValidationError} with a `label.<key>:` prefix and the rebuilt path
471
750
  * `[key, ...error.path]` so the failure points at the offending field. Optional
472
751
  * fields absent from the source are skipped (so `v.optional` passes and a
473
752
  * required validator fails on `undefined`).
@@ -484,4 +763,4 @@ declare const installCompiledValidatorMap: (validators: object, compiled: Compil
484
763
  * which case the interpreted loop below runs and owns the result (and any error).
485
764
  */
486
765
  declare const parseValidatorMap: (validators: ValidatorMap, source: Record<string, unknown>, label: string) => Record<string, unknown>;
487
- export { type CheckOptions, type Column, type ColumnMeta, type ColumnValidator, type CompiledValidatorMap, DEFER_VALIDATION, type Id, type Infer, type InferInsert, type InferSelect, type InferStandardOutput, type InferValidatorMap, type InsertShape, type JsonSchema, type JsonSchemaFragment, type MetaOptions, type SchemaNodeReader, type SelectShape, type ServerDefaultContext, type TimestampColumnValidator, ValidationError, type ValidationPath, type Validator, type ValidatorKind, type ValidatorMap, argsToJsonSchema, describeValue, formatPath, installCompiledValidatorMap, isOrWrapsFromValidator, jsonSchemaFromNode, objectSchemaFromNodes, optionalInner, parseValidatorMap, toJsonSchema, v };
766
+ export { type ArrayColumnValidator, type CheckOptions, type Column, type ColumnMeta, type ColumnValidator, type CompiledValidatorMap, DEFER_VALIDATION, type GeoPoint, type Id, type Infer, type InferInsert, type InferSelect, type InferStandardInput, type InferStandardOutput, type InferValidatorMap, type InsertShape, type JsonSchema, type JsonSchemaFragment, type MetaOptions, type NumberColumnValidator, type ObjectColumnValidator, type ParseOptions, type SchemaNodeReader, type SelectShape, type ServerDefaultContext, type StringColumnValidator, type TimestampColumnValidator, ValidationError, type ValidationPath, type Validator, type ValidatorKind, type ValidatorMap, acceptsAbsent, argsToJsonSchema, containsSensitive, cyrb53, describeValue, formatPath, installCompiledValidatorMap, isOrWrapsFromValidator, isStringValidator, jsonSchemaFromNode, objectSchemaFromNodes, optionalInner, parseValidatorMap, sensitiveArgumentNames, toJsonSchema, v };