import { h as ValidationViolation } from "./errors-CyuuoKx0.js"; import { t as StandardSchemaV1 } from "./standard-DIedMFAS.js"; //#region src/core/schema/validate.d.ts /** * The outcome of {@link standardValidate}: the typed value on success, or the * violations on failure. Standard Schema has no notion of a non-blocking * warning, so every mapped violation is `"error"` severity. */ type StandardParseResult = { ok: true; value: T; } | { ok: false; violations: ValidationViolation[]; }; /** Map Standard Schema issues to {@link ValidationViolation}s under `basePath`. */ declare function issuesToViolations(issues: ReadonlyArray, basePath?: string): ValidationViolation[]; /** * Validate `input` against any Standard Schema, awaiting an async validator. * Returns the typed value or the violations—never throws for a validation * failure (only a schema that itself throws would propagate). `basePath` * prefixes every violation path, so a caller validating one field's value can * anchor the issues at that field's key. */ declare function standardValidate(schema: Schema, input: unknown, basePath?: string): Promise>>; /** * Validate `input` and return the typed value, throwing * {@link LouiseValidationError} (carrying the structured violations) on * failure. For call sites that want an exception rather than a result branch—for example, * sharing the same `instanceof LouiseValidationError → 422` mapping the * `Rule` engine already uses. */ declare function parseOrThrow(schema: Schema, input: unknown): Promise>; /** * Parse a raw JSON string, then validate it against `schema`. A malformed body * becomes a violation (rather than a thrown `SyntaxError`), so a caller handles * "not JSON" and "wrong shape" through the same result branch—for example, parsing a * signature-verified webhook body post-verify, where the HMAC proves the sender * but not the payload's shape. */ declare function parseJson(schema: Schema, raw: string): Promise>>; /** * Extract the first balanced JSON object/array embedded in `text`—tolerating * model prose and ```json fences around it—respecting strings and escapes so * a `}` inside a string value doesn't end the scan early. Returns the JSON * substring, or `null` when no balanced object/array is present. Replaces the * brittle `indexOf("{")`/`lastIndexOf("}")` slice. */ declare function extractJson(text: string): string | null; /** * Parse the JSON an LLM emitted (often wrapped in prose or a ```json fence) and * validate it against `schema`—the canonical untrusted-JSON case. Extracts * the first balanced object/array ({@link extractJson}) rather than slicing on * the first/last brace, then validates. Never throws: a missing/malformed JSON * blob or a shape mismatch both come back as violations, so callers keep a * graceful-degrade branch instead of a try/catch (#99). Pair with the model's * own `response_format`/JSON-schema constraint where the provider supports it. */ declare function parseModelJson(schema: Schema, modelText: string): Promise>>; //#endregion //#region src/core/schema/builders.d.ts interface StringOptions { /** Minimum length (inclusive). */ min?: number; /** Maximum length (inclusive). */ max?: number; /** A pattern the string must match. */ pattern?: RegExp; /** Override the failure message for every check. */ message?: string; } declare function string(options?: StringOptions): StandardSchemaV1; interface NumberOptions { /** Require an integer. */ int?: boolean; /** Minimum value (inclusive). */ min?: number; /** Maximum value (inclusive). */ max?: number; /** Override the failure message for every check. */ message?: string; } declare function number(options?: NumberOptions): StandardSchemaV1; declare function boolean(): StandardSchemaV1; /** One of a fixed set of string literals (mirrors `select` allowlists). */ declare function enumOf(...values: Values): StandardSchemaV1; /** Accept any value, passing it through untouched (for example, a rich field `value`). */ declare function unknown(): StandardSchemaV1; /** Allow `undefined`, otherwise validate with `inner`. */ declare function optional(inner: Schema): StandardSchemaV1 | undefined, StandardSchemaV1.InferOutput | undefined>; interface ArrayOptions { /** Minimum length (inclusive). */ min?: number; /** Maximum length (inclusive). */ max?: number; /** Override the failure message for the non-array / bounds checks. */ message?: string; } /** * An array whose every element is validated by `item`. Element issues are * re-pathed under their index (`0`, `1`, …)—mirroring how {@link object} * re-paths by key—so a caller sees `items.2.qty`, not a flat message. Used by * the commerce webhook schemas to parse order line-item lists (offers/items). */ declare function array(item: Item, options?: ArrayOptions): StandardSchemaV1[]>; type Shape = Record; type InferShape = { [K in keyof S]: StandardSchemaV1.InferOutput; }; /** * An object with the declared keys. Unknown keys are dropped from the output * (not an error)—safer than the `as T` casts it replaces, since a forged * request can't smuggle extra fields through. Each key's issues are re-pathed * under that key. */ declare function object(shape: S): StandardSchemaV1>; /** An object of arbitrary string keys, each value validated by `valueSchema` * (defaults to {@link unknown})—for the patch bodies that carry a * `Record`. */ declare function record>(valueSchema?: Value): StandardSchemaV1>>; /** * The built-in zero-dep schema builder, namespaced so call sites read * `s.object({ collection: s.string(), value: s.unknown() })` without shadowing * the `string`/`number`/`object` globals. Every result is a Standard Schema—hand * it to {@link standardValidate} or set it as a field's `schema`. */ declare const s: { readonly object: typeof object; readonly string: typeof string; readonly number: typeof number; readonly boolean: typeof boolean; readonly enumOf: typeof enumOf; readonly unknown: typeof unknown; readonly record: typeof record; readonly array: typeof array; readonly optional: typeof optional; }; //#endregion export { StandardParseResult as a, parseJson as c, standardValidate as d, s as i, parseModelJson as l, NumberOptions as n, extractJson as o, StringOptions as r, issuesToViolations as s, ArrayOptions as t, parseOrThrow as u };