@lunora/values 1.0.0-alpha.15 → 1.0.0-alpha.16

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
@@ -361,24 +361,43 @@ type InferStandardOutput<S extends StandardSchemaV1> = S["~standard"]["types"] e
361
361
  } ? O : unknown;
362
362
  /**
363
363
  * Wrap any Standard Schema v1 validator (`zod`, `valibot`, `arktype`, …) so it
364
- * can be used as an **args** validator in `query`/`mutation`/`action`. The
365
- * wrapped validator's output type is inferred from `~standard.types.output`
366
- * when declared; falls back to `unknown` when the schema omits the types field.
364
+ * can be used as an args validator in `query`/`mutation`/`action`, or as a table
365
+ * column. The wrapped validator's output type is inferred from
366
+ * `~standard.types.output` when declared; falls back to `unknown` when the
367
+ * schema omits the types field.
367
368
  *
368
- * **Args-only.** `v.from(...)` validators must not be used as table columns
369
- * `defineTable` checks the `kind` and throws a clear error if you try.
369
+ * **Columns are stored by the value's runtime type.** A shard row is a JSON
370
+ * document, so a `v.from()` column needs no SQL type of its own. For a
371
+ * `.global()` table it maps to a TEXT column holding whatever the encoder
372
+ * produces: a scalar is written verbatim (a `v.from(z.string())` column holds a
373
+ * bare `hello`, not `"hello"`), and an object or array is JSON-encoded. That is
374
+ * the same rule `v.union` and `v.any` follow, and it is why the column cannot be
375
+ * a Postgres/MySQL `JSON` column — a bare `hello` is not valid JSON.
370
376
  *
371
- * **Sync-only.** Standard Schema allows async `validate`; Lunora args
372
- * validation is synchronous and throws when a Promise is returned.
377
+ * The consequence worth knowing: a stored *string* that itself looks like JSON
378
+ * (`'{"a":1}'`) is ambiguous on read and decodes to the parsed object. Declare
379
+ * the column with a concrete `v.*` type when the plain column type matters — for
380
+ * a comparison index, or to avoid that ambiguity.
381
+ *
382
+ * **Not seedable.** `@lunora/seed` cannot introspect an external schema to
383
+ * invent a valid value, so it refuses a `v.from()` column with an actionable
384
+ * error rather than generating one that fails validation on insert.
385
+ *
386
+ * **Sync-only.** Standard Schema allows async `validate`; Lunora validation is
387
+ * synchronous and throws when a Promise is returned.
373
388
  */
374
389
  declare const from: <S extends StandardSchemaV1>(schema: S) => ColumnValidator<InferStandardOutput<S>, InferStandardOutput<S>>;
375
390
  /**
376
391
  * True when `validator` is `v.from(...)` or structurally wraps one through
377
- * `v.optional` / `v.array` / `v.object` / `v.record` / `v.union`. `defineTable`
378
- * uses it to reject Standard-Schema-backed validators anywhere in a column —
379
- * not just at the top level — since they are args-only and have no SQL column
380
- * type. The nested children live on the validator's `_meta` (`inner`, `shape`,
381
- * `members`, `keyValidator`/`valueValidator`) and are themselves validators.
392
+ * `v.optional` / `v.array` / `v.object` / `v.record` / `v.union`. The nested
393
+ * children live on the validator's `_meta` (`inner`, `shape`, `members`,
394
+ * `keyValidator`/`valueValidator`) and are themselves validators.
395
+ *
396
+ * For tooling that must know whether a value is validated by an external
397
+ * Standard Schema rather than a concrete `v.*` type — a seeder that cannot
398
+ * invent a conforming value, a JSON Schema exporter that has nothing to
399
+ * describe. `defineTable` no longer calls it: a `v.from()` column is allowed
400
+ * and stores JSON, see {@link from}.
382
401
  */
383
402
  declare const isOrWrapsFromValidator: (validator: Validator) => boolean;
384
403
  /**
package/dist/index.d.ts CHANGED
@@ -361,24 +361,43 @@ type InferStandardOutput<S extends StandardSchemaV1> = S["~standard"]["types"] e
361
361
  } ? O : unknown;
362
362
  /**
363
363
  * Wrap any Standard Schema v1 validator (`zod`, `valibot`, `arktype`, …) so it
364
- * can be used as an **args** validator in `query`/`mutation`/`action`. The
365
- * wrapped validator's output type is inferred from `~standard.types.output`
366
- * when declared; falls back to `unknown` when the schema omits the types field.
364
+ * can be used as an args validator in `query`/`mutation`/`action`, or as a table
365
+ * column. The wrapped validator's output type is inferred from
366
+ * `~standard.types.output` when declared; falls back to `unknown` when the
367
+ * schema omits the types field.
367
368
  *
368
- * **Args-only.** `v.from(...)` validators must not be used as table columns
369
- * `defineTable` checks the `kind` and throws a clear error if you try.
369
+ * **Columns are stored by the value's runtime type.** A shard row is a JSON
370
+ * document, so a `v.from()` column needs no SQL type of its own. For a
371
+ * `.global()` table it maps to a TEXT column holding whatever the encoder
372
+ * produces: a scalar is written verbatim (a `v.from(z.string())` column holds a
373
+ * bare `hello`, not `"hello"`), and an object or array is JSON-encoded. That is
374
+ * the same rule `v.union` and `v.any` follow, and it is why the column cannot be
375
+ * a Postgres/MySQL `JSON` column — a bare `hello` is not valid JSON.
370
376
  *
371
- * **Sync-only.** Standard Schema allows async `validate`; Lunora args
372
- * validation is synchronous and throws when a Promise is returned.
377
+ * The consequence worth knowing: a stored *string* that itself looks like JSON
378
+ * (`'{"a":1}'`) is ambiguous on read and decodes to the parsed object. Declare
379
+ * the column with a concrete `v.*` type when the plain column type matters — for
380
+ * a comparison index, or to avoid that ambiguity.
381
+ *
382
+ * **Not seedable.** `@lunora/seed` cannot introspect an external schema to
383
+ * invent a valid value, so it refuses a `v.from()` column with an actionable
384
+ * error rather than generating one that fails validation on insert.
385
+ *
386
+ * **Sync-only.** Standard Schema allows async `validate`; Lunora validation is
387
+ * synchronous and throws when a Promise is returned.
373
388
  */
374
389
  declare const from: <S extends StandardSchemaV1>(schema: S) => ColumnValidator<InferStandardOutput<S>, InferStandardOutput<S>>;
375
390
  /**
376
391
  * True when `validator` is `v.from(...)` or structurally wraps one through
377
- * `v.optional` / `v.array` / `v.object` / `v.record` / `v.union`. `defineTable`
378
- * uses it to reject Standard-Schema-backed validators anywhere in a column —
379
- * not just at the top level — since they are args-only and have no SQL column
380
- * type. The nested children live on the validator's `_meta` (`inner`, `shape`,
381
- * `members`, `keyValidator`/`valueValidator`) and are themselves validators.
392
+ * `v.optional` / `v.array` / `v.object` / `v.record` / `v.union`. The nested
393
+ * children live on the validator's `_meta` (`inner`, `shape`, `members`,
394
+ * `keyValidator`/`valueValidator`) and are themselves validators.
395
+ *
396
+ * For tooling that must know whether a value is validated by an external
397
+ * Standard Schema rather than a concrete `v.*` type — a seeder that cannot
398
+ * invent a conforming value, a JSON Schema exporter that has nothing to
399
+ * describe. `defineTable` no longer calls it: a `v.from()` column is allowed
400
+ * and stores JSON, see {@link from}.
382
401
  */
383
402
  declare const isOrWrapsFromValidator: (validator: Validator) => boolean;
384
403
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/values",
3
- "version": "1.0.0-alpha.15",
3
+ "version": "1.0.0-alpha.16",
4
4
  "description": "Validators for Lunora: the v.* validator suite with end-to-end return-type inference",
5
5
  "keywords": [
6
6
  "cloudflare",