/**
* Standard Schema v1 integration.
*
* This file is the entry point for **schema validation**. Any
* validator that implements the [Standard Schema v1
* protocol](https://standardschema.dev) — Zod, Valibot, ArkType, Effect
* Schema, etc. — can be attached to a `Collection` or `defineNoydbStore`
* and will:
*
* 1. Validate the record BEFORE encryption on `put()` — bad data is
* rejected at the store boundary with a rich issue list.
* 2. Validate the record AFTER decryption on `get()`/`list()`/`query()`
* — stored data that has drifted from the current schema throws
* loudly instead of silently propagating garbage to the UI.
*
* ## Why vendor the types?
*
* Standard Schema is a protocol, not a library. The spec is <200 lines of
* TypeScript and has no runtime. There's an official `@standard-schema/spec`
* types package on npm, but pulling it in would add a dependency edge
* purely for type definitions. Vendoring the minimal surface keeps
* `@noy-db/core` at **zero runtime dependencies** and gives us freedom to
* evolve the helpers without a version-lock on the spec package.
*
* If the spec changes in a breaking way (unlikely — it's frozen at v1),
* we update this file and bump our minor.
*
* ## Why not just run `schema.parse(value)` directly?
*
* Because then we'd be locked to whichever validator happens to have
* `.parse`. Standard Schema's `'~standard'.validate` contract is the same
* across every implementation and includes a structured issues list,
* which is much more useful than a thrown error for programmatic error
* handling (e.g., rendering field-level messages in a Vue component).
*/
/**
* The Standard Schema v1 protocol. A schema is any object that exposes a
* `'~standard'` property with `version: 1` and a `validate` function.
*
* The type parameters are:
* - `Input` — the type accepted by `validate` (what the user passes in)
* - `Output` — the type produced by `validate` (what we store/return,
* may differ from Input if the schema transforms or coerces)
*
* In most cases `Input === Output`, but validators that transform
* (Zod's `.transform`, Valibot's `transform`, etc.) can narrow or widen.
*
* We intentionally keep the `types` field `readonly` and optional — the
* spec marks it as optional because it's only used for inference, and
* not every implementation bothers populating it at runtime.
*/
export interface StandardSchemaV1 {
readonly '~standard': {
readonly version: 1;
readonly vendor: string;
readonly validate: (value: unknown) => StandardSchemaV1SyncResult