@vielzeug/spell 3.1.1 → 26.10.0
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/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +30 -24
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +3 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/s.cjs +1 -1
- package/dist/s.cjs.map +1 -1
- package/dist/s.d.ts +7 -4
- package/dist/s.d.ts.map +1 -1
- package/dist/s.js +1 -1
- package/dist/s.js.map +1 -1
- package/dist/schemas/array.cjs +1 -1
- package/dist/schemas/array.cjs.map +1 -1
- package/dist/schemas/array.d.ts +3 -5
- package/dist/schemas/array.d.ts.map +1 -1
- package/dist/schemas/array.js +1 -1
- package/dist/schemas/array.js.map +1 -1
- package/dist/schemas/bigint.cjs +1 -1
- package/dist/schemas/bigint.cjs.map +1 -1
- package/dist/schemas/bigint.d.ts +2 -4
- package/dist/schemas/bigint.d.ts.map +1 -1
- package/dist/schemas/bigint.js +1 -1
- package/dist/schemas/bigint.js.map +1 -1
- package/dist/schemas/boolean.cjs +1 -1
- package/dist/schemas/boolean.cjs.map +1 -1
- package/dist/schemas/boolean.d.ts +2 -4
- package/dist/schemas/boolean.d.ts.map +1 -1
- package/dist/schemas/boolean.js +1 -1
- package/dist/schemas/boolean.js.map +1 -1
- package/dist/schemas/date.cjs +1 -1
- package/dist/schemas/date.cjs.map +1 -1
- package/dist/schemas/date.d.ts +2 -4
- package/dist/schemas/date.d.ts.map +1 -1
- package/dist/schemas/date.js +1 -1
- package/dist/schemas/date.js.map +1 -1
- package/dist/schemas/enum.cjs +1 -1
- package/dist/schemas/enum.cjs.map +1 -1
- package/dist/schemas/enum.d.ts +2 -4
- package/dist/schemas/enum.d.ts.map +1 -1
- package/dist/schemas/enum.js +1 -1
- package/dist/schemas/enum.js.map +1 -1
- package/dist/schemas/instanceof.cjs +1 -1
- package/dist/schemas/instanceof.cjs.map +1 -1
- package/dist/schemas/instanceof.d.ts +2 -4
- package/dist/schemas/instanceof.d.ts.map +1 -1
- package/dist/schemas/instanceof.js +1 -1
- package/dist/schemas/instanceof.js.map +1 -1
- package/dist/schemas/intersect.cjs +1 -1
- package/dist/schemas/intersect.cjs.map +1 -1
- package/dist/schemas/intersect.d.ts +3 -5
- package/dist/schemas/intersect.d.ts.map +1 -1
- package/dist/schemas/intersect.js +1 -1
- package/dist/schemas/intersect.js.map +1 -1
- package/dist/schemas/lazy.cjs +1 -1
- package/dist/schemas/lazy.cjs.map +1 -1
- package/dist/schemas/lazy.d.ts +4 -6
- package/dist/schemas/lazy.d.ts.map +1 -1
- package/dist/schemas/lazy.js +1 -1
- package/dist/schemas/lazy.js.map +1 -1
- package/dist/schemas/literal.cjs +1 -1
- package/dist/schemas/literal.cjs.map +1 -1
- package/dist/schemas/literal.d.ts +2 -4
- package/dist/schemas/literal.d.ts.map +1 -1
- package/dist/schemas/literal.js +1 -1
- package/dist/schemas/literal.js.map +1 -1
- package/dist/schemas/map.cjs +1 -1
- package/dist/schemas/map.cjs.map +1 -1
- package/dist/schemas/map.d.ts +3 -5
- package/dist/schemas/map.d.ts.map +1 -1
- package/dist/schemas/map.js +1 -1
- package/dist/schemas/map.js.map +1 -1
- package/dist/schemas/never.cjs +1 -1
- package/dist/schemas/never.cjs.map +1 -1
- package/dist/schemas/never.d.ts +2 -4
- package/dist/schemas/never.d.ts.map +1 -1
- package/dist/schemas/never.js +1 -1
- package/dist/schemas/never.js.map +1 -1
- package/dist/schemas/number.cjs +1 -1
- package/dist/schemas/number.cjs.map +1 -1
- package/dist/schemas/number.d.ts +2 -4
- package/dist/schemas/number.d.ts.map +1 -1
- package/dist/schemas/number.js +1 -1
- package/dist/schemas/number.js.map +1 -1
- package/dist/schemas/object.cjs +1 -1
- package/dist/schemas/object.cjs.map +1 -1
- package/dist/schemas/object.d.ts +19 -21
- package/dist/schemas/object.d.ts.map +1 -1
- package/dist/schemas/object.js +1 -1
- package/dist/schemas/object.js.map +1 -1
- package/dist/schemas/record.cjs +1 -1
- package/dist/schemas/record.cjs.map +1 -1
- package/dist/schemas/record.d.ts +3 -5
- package/dist/schemas/record.d.ts.map +1 -1
- package/dist/schemas/record.js +1 -1
- package/dist/schemas/record.js.map +1 -1
- package/dist/schemas/set.cjs +1 -1
- package/dist/schemas/set.cjs.map +1 -1
- package/dist/schemas/set.d.ts +3 -5
- package/dist/schemas/set.d.ts.map +1 -1
- package/dist/schemas/set.js +1 -1
- package/dist/schemas/set.js.map +1 -1
- package/dist/schemas/string.cjs +1 -1
- package/dist/schemas/string.cjs.map +1 -1
- package/dist/schemas/string.d.ts +2 -4
- package/dist/schemas/string.d.ts.map +1 -1
- package/dist/schemas/string.js +1 -1
- package/dist/schemas/string.js.map +1 -1
- package/dist/schemas/tuple.cjs +1 -1
- package/dist/schemas/tuple.cjs.map +1 -1
- package/dist/schemas/tuple.d.ts +4 -6
- package/dist/schemas/tuple.d.ts.map +1 -1
- package/dist/schemas/tuple.js +1 -1
- package/dist/schemas/tuple.js.map +1 -1
- package/dist/schemas/union.cjs +1 -1
- package/dist/schemas/union.cjs.map +1 -1
- package/dist/schemas/union.d.ts +4 -6
- package/dist/schemas/union.d.ts.map +1 -1
- package/dist/schemas/union.js +1 -1
- package/dist/schemas/union.js.map +1 -1
- package/dist/schemas/variant.cjs +1 -1
- package/dist/schemas/variant.cjs.map +1 -1
- package/dist/schemas/variant.d.ts +4 -6
- package/dist/schemas/variant.d.ts.map +1 -1
- package/dist/schemas/variant.js +1 -1
- package/dist/schemas/variant.js.map +1 -1
- package/dist/spell.cjs +2 -2
- package/dist/spell.cjs.map +1 -1
- package/dist/spell.iife.js +2 -2
- package/dist/spell.iife.js.map +1 -1
- package/dist/spell.js +2 -2
- package/dist/spell.js.map +1 -1
- package/dist/tolerate.cjs +2 -0
- package/dist/tolerate.cjs.map +1 -0
- package/dist/tolerate.d.ts +10 -0
- package/dist/tolerate.d.ts.map +1 -0
- package/dist/tolerate.js +2 -0
- package/dist/tolerate.js.map +1 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.ts +13 -52
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e,...t){let n=new Set(t);return e.preprocess(e=>{if(typeof e!=`object`||!e)return e;let t=!1;for(let r of Object.keys(e))if(n.has(r)){t=!0;break}if(!t)return e;let r={};for(let[t,i]of Object.entries(e))n.has(t)||(r[t]=i);return r})}exports.tolerate=e;
|
|
2
|
+
//# sourceMappingURL=tolerate.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tolerate.cjs","names":[],"sources":["../src/tolerate.ts"],"sourcesContent":["import type { Schema } from './core';\n\n/**\n * Accepts and drops named keys a record carries from an older schema version, instead of failing\n * `invalid_keys`. One call per removed field: the parsed output never sees the tolerated keys.\n *\n * @example\n * const hunter = tolerate(s.object({ name: s.string() }), 'woundCount');\n */\nexport function tolerate<Output extends object, Input>(\n schema: Schema<Output, Input>,\n ...keys: string[]\n): Schema<Output, Input> {\n const tolerated = new Set(keys);\n return schema.preprocess((value) => {\n if (typeof value !== 'object' || value === null) return value;\n let stripped = false;\n for (const key of Object.keys(value)) {\n if (tolerated.has(key)) {\n stripped = true;\n break;\n }\n }\n if (!stripped) return value;\n const next: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n if (!tolerated.has(key)) next[key] = entry;\n }\n return next;\n });\n}\n"],"mappings":"AASA,SAAgB,EACd,EACA,GAAG,EACoB,CACvB,IAAM,EAAY,IAAI,IAAI,CAAI,EAC9B,OAAO,EAAO,WAAY,GAAU,CAClC,GAAI,OAAO,GAAU,WAAY,EAAgB,OAAO,EACxD,IAAI,EAAW,GACf,IAAK,IAAM,KAAO,OAAO,KAAK,CAAK,EACjC,GAAI,EAAU,IAAI,CAAG,EAAG,CACtB,EAAW,GACX,KACF,CAEF,GAAI,CAAC,EAAU,OAAO,EACtB,IAAM,EAAgC,CAAC,EACvC,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAK,EACxC,EAAU,IAAI,CAAG,IAAG,EAAK,GAAO,GAEvC,OAAO,CACT,CAAC,CACH"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Schema } from './core';
|
|
2
|
+
/**
|
|
3
|
+
* Accepts and drops named keys a record carries from an older schema version, instead of failing
|
|
4
|
+
* `invalid_keys`. One call per removed field: the parsed output never sees the tolerated keys.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* const hunter = tolerate(s.object({ name: s.string() }), 'woundCount');
|
|
8
|
+
*/
|
|
9
|
+
export declare function tolerate<Output extends object, Input>(schema: Schema<Output, Input>, ...keys: string[]): Schema<Output, Input>;
|
|
10
|
+
//# sourceMappingURL=tolerate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tolerate.d.ts","sourceRoot":"","sources":["../src/tolerate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,MAAM,SAAS,MAAM,EAAE,KAAK,EACnD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAC7B,GAAG,IAAI,EAAE,MAAM,EAAE,GAChB,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAkBvB"}
|
package/dist/tolerate.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e,...t){let n=new Set(t);return e.preprocess(e=>{if(typeof e!=`object`||!e)return e;let t=!1;for(let r of Object.keys(e))if(n.has(r)){t=!0;break}if(!t)return e;let r={};for(let[t,i]of Object.entries(e))n.has(t)||(r[t]=i);return r})}export{e as tolerate};
|
|
2
|
+
//# sourceMappingURL=tolerate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tolerate.js","names":[],"sources":["../src/tolerate.ts"],"sourcesContent":["import type { Schema } from './core';\n\n/**\n * Accepts and drops named keys a record carries from an older schema version, instead of failing\n * `invalid_keys`. One call per removed field: the parsed output never sees the tolerated keys.\n *\n * @example\n * const hunter = tolerate(s.object({ name: s.string() }), 'woundCount');\n */\nexport function tolerate<Output extends object, Input>(\n schema: Schema<Output, Input>,\n ...keys: string[]\n): Schema<Output, Input> {\n const tolerated = new Set(keys);\n return schema.preprocess((value) => {\n if (typeof value !== 'object' || value === null) return value;\n let stripped = false;\n for (const key of Object.keys(value)) {\n if (tolerated.has(key)) {\n stripped = true;\n break;\n }\n }\n if (!stripped) return value;\n const next: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n if (!tolerated.has(key)) next[key] = entry;\n }\n return next;\n });\n}\n"],"mappings":"AASA,SAAgB,EACd,EACA,GAAG,EACoB,CACvB,IAAM,EAAY,IAAI,IAAI,CAAI,EAC9B,OAAO,EAAO,WAAY,GAAU,CAClC,GAAI,OAAO,GAAU,WAAY,EAAgB,OAAO,EACxD,IAAI,EAAW,GACf,IAAK,IAAM,KAAO,OAAO,KAAK,CAAK,EACjC,GAAI,EAAU,IAAI,CAAG,EAAG,CACtB,EAAW,GACX,KACF,CAEF,GAAI,CAAC,EAAU,OAAO,EACtB,IAAM,EAAgC,CAAC,EACvC,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAK,EACxC,EAAU,IAAI,CAAG,IAAG,EAAK,GAAO,GAEvC,OAAO,CACT,CAAC,CACH"}
|
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["/* -------------------- Error Codes -------------------- */\n\nexport const ErrorCode = {\n custom: 'custom',\n invalid_base64: 'invalid_base64',\n invalid_date: 'invalid_date',\n invalid_duration: 'invalid_duration',\n invalid_enum: 'invalid_enum',\n invalid_finite: 'invalid_finite',\n invalid_integer: 'invalid_integer',\n invalid_keys: 'invalid_keys',\n invalid_length: 'invalid_length',\n invalid_literal: 'invalid_literal',\n invalid_multiple_of: 'invalid_multiple_of',\n invalid_safe: 'invalid_safe',\n invalid_string: 'invalid_string',\n invalid_type: 'invalid_type',\n invalid_union: 'invalid_union',\n invalid_unique: 'invalid_unique',\n invalid_url: 'invalid_url',\n invalid_variant: 'invalid_variant',\n too_big: 'too_big',\n too_small: 'too_small',\n} as const;\n\nexport type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];\n\n/* -------------------- Messages -------------------- */\n\n/**\n * A validation message — either a static string or a function that receives context and returns a string.\n * **Note:** Static string values are used verbatim with no interpolation. Use the function form\n * for context-dependent messages (e.g. `(ctx) => \\`Must be at least ${ctx.min}\\``).\n */\nexport type MessageFn<Ctx extends Record<string, unknown> = Record<string, unknown>> = string | ((ctx: Ctx) => string);\n\n/* -------------------- JSON Schema -------------------- */\n\n/** Plain JSON Schema object (targeting JSON Schema 2020-12). */\nexport type JsonSchema = Record<string, unknown>;\n\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n readonly '~standard': StandardSchemaV1.Props<Input, Output>;\n}\n\nexport declare namespace StandardSchemaV1 {\n interface Props<Input = unknown, Output = Input> {\n readonly types?: Types<Input, Output> | undefined;\n readonly validate: (value: unknown, options?: Options | undefined) => Result<Output> | Promise<Result<Output>>;\n readonly vendor: string;\n readonly version: 1;\n }\n\n type Result<Output> = { readonly issues: readonly Issue[] } | { readonly issues?: undefined; readonly value: Output };\n\n interface Options {\n readonly libraryOptions?: Record<string, unknown> | undefined;\n }\n\n interface Issue {\n readonly message: string;\n readonly path?: readonly (PropertyKey | PathSegment)[] | undefined;\n }\n\n interface PathSegment {\n readonly key: PropertyKey;\n }\n\n interface Types<Input = unknown, Output = Input> {\n readonly input: Input;\n readonly output: Output;\n }\n\n type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];\n type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];\n}\n\n/* -------------------- Issues -------------------- */\n\n/**\n * A typed discriminated union of all issues emitted by built-in validators.\n *\n * Narrowing on `code` gives precise access to `params`:\n * ```ts\n * if (error.code === 'too_small') {\n * const min = error.params.min; // number | bigint | Date\n * }\n * ```\n */\nexport type Issue =\n | { code: 'custom'; message: string; params?: Record<string, unknown>; path: (string | number)[] }\n | { code: 'invalid_base64'; message: string; params: { format: string }; path: (string | number)[] }\n | { code: 'invalid_date'; message: string; params?: undefined; path: (string | number)[] }\n | { code: 'invalid_duration'; message: string; params: { format: string }; path: (string | number)[] }\n | { code: 'invalid_enum'; message: string; params: { values: readonly unknown[] }; path: (string | number)[] }\n | { code: 'invalid_finite'; message: string; params?: undefined; path: (string | number)[] }\n | { code: 'invalid_integer'; message: string; params?: undefined; path: (string | number)[] }\n | { code: 'invalid_keys'; message: string; params: { keys: string[] }; path: (string | number)[] }\n | { code: 'invalid_length'; message: string; params: { exact: number }; path: (string | number)[] }\n | { code: 'invalid_literal'; message: string; params: { expected: unknown }; path: (string | number)[] }\n | { code: 'invalid_multiple_of'; message: string; params: { step: number | bigint }; path: (string | number)[] }\n | { code: 'invalid_safe'; message: string; params?: undefined; path: (string | number)[] }\n | {\n code: 'invalid_string';\n message: string;\n params: { format?: string; includes?: string; pattern?: string; prefix?: string; suffix?: string };\n path: (string | number)[];\n }\n | { code: 'invalid_type'; message: string; params?: undefined; path: (string | number)[] }\n | { code: 'invalid_union'; message: string; params: { errors: Issue[][] }; path: (string | number)[] }\n | { code: 'invalid_unique'; message: string; params: { unique: true }; path: (string | number)[] }\n | { code: 'invalid_url'; message: string; params: { format: string }; path: (string | number)[] }\n | {\n code: 'invalid_variant';\n message: string;\n params: { discriminator: string; expected: string[] };\n path: (string | number)[];\n }\n | {\n code: 'too_big';\n message: string;\n params: { exclusive?: boolean; max: number | bigint | Date };\n path: (string | number)[];\n }\n | {\n code: 'too_small';\n message: string;\n params: { exclusive?: boolean; min: number | bigint | Date };\n path: (string | number)[];\n }\n | { code: string & {}; message: string; params?: Record<string, unknown>; path: (string | number)[] };\n\n/** ParseContext carries the active message set through the parse pipeline. */\nexport type ParseContext = {\n messages: import('./messages').Messages;\n};\n\n/**\n * Validator function. Receives the value after type-checking and the active ParseContext.\n * Returns an Issue array on failure, null on success, or a Promise for async validators.\n */\nexport type ValidateFn = (value: unknown, ctx?: ParseContext) => Issue[] | null | Promise<Issue[] | null>;\n\nexport type CheckContext = {\n addIssue: (issue: {\n code: string;\n message: string;\n params?: Record<string, unknown>;\n path?: (string | number)[];\n }) => void;\n};\n\n/**\n * Return type of a `check()` callback.\n * - `string` — validation failed; the string becomes the error message.\n * - `false` — validation failed with no message (use `addIssue` for a message).\n * - `true` / `null` / `void` — validation passed.\n *\n * The shorthand `condition || 'message'` works naturally:\n * ```ts\n * s.string().check((value) => value.length > 0 || 'Cannot be empty')\n * ```\n */\nexport type ValidateResult = boolean | null | undefined | string;\n\n/** Re-exported from errors for convenience — defined there. */\nexport type { FlatError, FlatErrorFirst } from './errors';\n\n/* -------------------- Schema Introspection -------------------- */\n\n/**\n * Visitor map for schema.walk(). Container handlers receive already-walked children (type R).\n * All handlers are optional — unmatched kinds return `null` unless an `unknown` fallback is provided.\n *\n * Each handler receives the concrete schema type for that kind, enabling access to\n * schema-specific properties (e.g. `ArraySchema.itemSchema`) without casting.\n */\nexport type SchemaWalker<R> = {\n array?: <T extends AnySchema, Mode extends SchemaMode>(\n schema: import('./schemas/array').ArraySchema<T, Mode>,\n item: R | null,\n ) => R;\n bigint?: <Input, Mode extends SchemaMode>(schema: import('./schemas/bigint').BigIntSchema<Input, Mode>) => R;\n boolean?: <Input, Mode extends SchemaMode>(schema: import('./schemas/boolean').BooleanSchema<Input, Mode>) => R;\n date?: <Input, Mode extends SchemaMode>(schema: import('./schemas/date').DateSchema<Input, Mode>) => R;\n enum?: <T extends import('./schemas/enum').EnumValues, Mode extends SchemaMode>(\n schema: import('./schemas/enum').EnumSchema<T, Mode>,\n ) => R;\n instanceof?: <T, Mode extends SchemaMode>(schema: import('./schemas/instanceof').InstanceOfSchema<T, Mode>) => R;\n intersect?: <T extends readonly AnySchema[], Mode extends SchemaMode>(\n schema: import('./schemas/intersect').IntersectSchema<T, Mode>,\n branches: (R | null)[],\n ) => R;\n lazy?: <T, Input, Mode extends SchemaMode>(schema: import('./schemas/lazy').LazySchema<T, Input, Mode>) => R;\n literal?: <T extends string | number | boolean | null | undefined, Mode extends SchemaMode>(\n schema: import('./schemas/literal').LiteralSchema<T, Mode>,\n ) => R;\n map?: <K extends AnySchema, V extends AnySchema, Mode extends SchemaMode>(\n schema: import('./schemas/map').MapSchema<K, V, Mode>,\n key: R | null,\n value: R | null,\n ) => R;\n never?: <Mode extends SchemaMode>(schema: import('./schemas/never').NeverSchema<Mode>) => R;\n number?: <Input, Mode extends SchemaMode>(schema: import('./schemas/number').NumberSchema<Input, Mode>) => R;\n object?: <T extends import('./schemas/object').ObjectShape, Mode extends SchemaMode>(\n schema: import('./schemas/object').ObjectSchema<T, Mode>,\n fields: Record<string, R | null>,\n ) => R;\n pipe?: <To extends AnySchema, From extends AnySchema, Mode extends SchemaMode>(\n schema: import('./core').PipeSchema<To, From, Mode>,\n from: R | null,\n to: R | null,\n ) => R;\n record?: <K extends AnySchema, V extends AnySchema, Mode extends SchemaMode>(\n schema: import('./schemas/record').RecordSchema<K, V, Mode>,\n key: R | null,\n value: R | null,\n ) => R;\n set?: <T extends AnySchema, Mode extends SchemaMode>(\n schema: import('./schemas/set').SetSchema<T, Mode>,\n item: R | null,\n ) => R;\n string?: <Input, Mode extends SchemaMode>(schema: import('./schemas/string').StringSchema<Input, Mode>) => R;\n tuple?: <T extends import('./schemas/tuple').TupleSchemas, Rest extends AnySchema | null, Mode extends SchemaMode>(\n schema: import('./schemas/tuple').TupleSchema<T, Rest, Mode>,\n items: (R | null)[],\n rest: R | null,\n ) => R;\n union?: <T extends readonly AnySchema[], Mode extends SchemaMode>(\n schema: import('./schemas/union').UnionSchema<T, Mode>,\n branches: (R | null)[],\n ) => R;\n unknown?: (schema: AnySchema) => R;\n variant?: <\n K extends string,\n M extends Record<string, import('./schemas/object').ObjectSchema<any, any>>,\n Mode extends SchemaMode,\n >(\n schema: import('./schemas/variant').VariantSchema<K, M, Mode>,\n branches: Record<string, R | null>,\n ) => R;\n};\n\ntype BaseDescriptor = {\n description?: string;\n isNullable?: boolean;\n isOptional?: boolean;\n};\n\nexport type SchemaDescriptor = BaseDescriptor &\n (\n | { kind: 'unknown' | 'never' | 'boolean' | 'bigint' | 'date' | 'lazy' }\n | { className: string; kind: 'instanceof' }\n | {\n contentEncoding?: string;\n format?: string;\n kind: 'string';\n maxLength?: number;\n minLength?: number;\n pattern?: string | null;\n }\n | {\n exclusiveMaximum?: number;\n exclusiveMinimum?: number;\n kind: 'number';\n maximum?: number;\n minimum?: number;\n multipleOf?: number;\n typeHint?: 'integer';\n }\n | { kind: 'literal'; value: string | number | boolean | null | undefined }\n | { kind: 'enum'; values: readonly (string | number)[] }\n | { items: SchemaDescriptor; kind: 'array'; maxItems?: number; minItems?: number }\n | { items: SchemaDescriptor[]; kind: 'tuple'; rest: SchemaDescriptor | null }\n | { fields: Record<string, SchemaDescriptor>; kind: 'object'; strict: boolean }\n | { key: SchemaDescriptor; kind: 'record'; value: SchemaDescriptor }\n | { items: SchemaDescriptor; kind: 'set' }\n | { key: SchemaDescriptor; kind: 'map'; value: SchemaDescriptor }\n | { branches: SchemaDescriptor[]; kind: 'union' | 'intersect' }\n | { branches: Record<string, SchemaDescriptor>; discriminator: string; kind: 'variant' }\n | { from: SchemaDescriptor; kind: 'pipe'; to: SchemaDescriptor }\n );\n\n/* -------------------- ParseResult (forward-references SpellValidationError) -------------------- */\n\nimport type { Schema } from './core';\n// Import only the type to avoid circular dependencies\nimport type { SpellValidationError } from './errors';\n\nexport type ParseResult<T> = { data: T; success: true } | { error: SpellValidationError; success: false };\n\n/* -------------------- Schema execution mode / Infer (forward-references Schema) -------------------- */\n\n/** @internal */\nexport const schemaInput = Symbol('spell.schemaInput');\n/** Public structural marker for a schema's parsing capability. */\nexport const schemaMode = Symbol('spell.schemaMode');\n/** @internal */\nexport const schemaOutput = Symbol('spell.schemaOutput');\nexport declare const schemaAcceptsMissing: unique symbol;\nexport type AcceptsMissing = { readonly [schemaAcceptsMissing]: true };\n\n/** Whether a schema can be parsed synchronously or requires asynchronous parsing. */\nexport type SchemaMode = 'async' | 'sync';\n\n/** A structural schema surface accepted by composition helpers. */\nexport type SchemaSurface<Output = unknown, Input = Output, Mode extends SchemaMode = SchemaMode> = {\n /** @internal */\n _parseFullAsync(value: unknown, ctx?: ParseContext): Promise<{ data: unknown; issues: Issue[] }>;\n /** @internal */\n _parseFullSync(value: unknown, ctx?: ParseContext): { data: unknown; issues: Issue[] };\n safeParseAsync(value: unknown, ctx?: ParseContext): Promise<ParseResult<Output>>;\n definition(): SchemaDescriptor;\n isOptional: boolean;\n optional(): SchemaSurface<Output | undefined, Input | undefined, Mode>;\n required(): SchemaSurface<Exclude<Output, undefined>, Exclude<Input, undefined>, Mode>;\n readonly [schemaInput]: Input;\n readonly [schemaMode]: Mode;\n readonly [schemaOutput]: Output;\n walk<R>(visitor: SchemaWalker<R>): R | null;\n};\n\nexport type AnySchema<Output = unknown, Input = Output, Mode extends SchemaMode = SchemaMode> = SchemaSurface<\n Output,\n Input,\n Mode\n>;\n\n/**\n * The synchronous parse capability every sync schema carries. UI adapters that accept\n * `AnySchema` cannot call `safeParse` on it (the surface type omits it); type adapter\n * parameters against this instead.\n *\n * The shape is structural, so an async-only schema is assignable to it; calling `safeParse`\n * on one returns a failed `ParseResult` (\"parse() cannot evaluate async checks\"). When the\n * schema's mode is not statically known, narrow with `InferSchemaMode` and use\n * `safeParseAsync` for async members.\n */\nexport type SyncParsable<T = unknown> = { safeParse(value: unknown): ParseResult<T> };\n\n/**\n * An issue path in either shape: spell-native `(string | number)[]` or the\n * Standard Schema `(PropertyKey | { key })[]` format.\n */\nexport type IssuePathSegment = PropertyKey | { readonly key: PropertyKey };\nexport type IssuePath = readonly IssuePathSegment[];\n\n/** Extracts a schema's parsing capability. */\nexport type InferSchemaMode<T> = T extends { readonly [schemaMode]: infer Mode extends SchemaMode } ? Mode : never;\n\n/** Selects async mode when any member of a schema collection is async. */\nexport type MergeSchemaModes<Modes extends SchemaMode> = 'async' extends Modes ? 'async' : 'sync';\n\nexport type InferOutput<T> =\n T extends Schema<infer Output, unknown, SchemaMode>\n ? Output\n : T extends { readonly [schemaOutput]: infer Output }\n ? Output\n : never;\ntype RawInferInput<T> = T extends { readonly [schemaInput]: infer Input } ? Input : unknown;\nexport type InferInput<T> = T extends AcceptsMissing ? RawInferInput<T> | undefined : RawInferInput<T>;\nexport type Infer<T> = InferOutput<T>;\n\n/** Re-exported for convenience — defined in messages.ts. */\nexport type { Messages } from './messages';\n"],"mappings":"AAEA,IAAa,EAAY,CACvB,OAAQ,SACR,eAAgB,iBAChB,aAAc,eACd,iBAAkB,mBAClB,aAAc,eACd,eAAgB,iBAChB,gBAAiB,kBACjB,aAAc,eACd,eAAgB,iBAChB,gBAAiB,kBACjB,oBAAqB,sBACrB,aAAc,eACd,eAAgB,iBAChB,aAAc,eACd,cAAe,gBACf,eAAgB,iBAChB,YAAa,cACb,gBAAiB,kBACjB,QAAS,UACT,UAAW,WACb"}
|
|
1
|
+
{"version":3,"file":"types.cjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["/* -------------------- Error Codes -------------------- */\n\nexport const ErrorCode = {\n custom: 'custom',\n invalid_base64: 'invalid_base64',\n invalid_date: 'invalid_date',\n invalid_duration: 'invalid_duration',\n invalid_enum: 'invalid_enum',\n invalid_finite: 'invalid_finite',\n invalid_integer: 'invalid_integer',\n invalid_keys: 'invalid_keys',\n invalid_length: 'invalid_length',\n invalid_literal: 'invalid_literal',\n invalid_multiple_of: 'invalid_multiple_of',\n invalid_safe: 'invalid_safe',\n invalid_string: 'invalid_string',\n invalid_type: 'invalid_type',\n invalid_union: 'invalid_union',\n invalid_unique: 'invalid_unique',\n invalid_url: 'invalid_url',\n invalid_variant: 'invalid_variant',\n too_big: 'too_big',\n too_small: 'too_small',\n} as const;\n\nexport type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];\n\n/* -------------------- Messages -------------------- */\n\n/**\n * A validation message — either a static string or a function that receives context and returns a string.\n * **Note:** Static string values are used verbatim with no interpolation. Use the function form\n * for context-dependent messages (e.g. `(ctx) => \\`Must be at least ${ctx.min}\\``).\n */\nexport type MessageFn<Ctx extends Record<string, unknown> = Record<string, unknown>> = string | ((ctx: Ctx) => string);\n\n/* -------------------- JSON Schema -------------------- */\n\n/** Plain JSON Schema object (targeting JSON Schema 2020-12). */\nexport type JsonSchema = Record<string, unknown>;\n\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n readonly '~standard': StandardSchemaV1.Props<Input, Output>;\n}\n\nexport declare namespace StandardSchemaV1 {\n interface Props<Input = unknown, Output = Input> {\n readonly types?: Types<Input, Output> | undefined;\n readonly validate: (value: unknown, options?: Options | undefined) => Result<Output> | Promise<Result<Output>>;\n readonly vendor: string;\n readonly version: 1;\n }\n\n type Result<Output> = { readonly issues: readonly Issue[] } | { readonly issues?: undefined; readonly value: Output };\n\n interface Options {\n readonly libraryOptions?: Record<string, unknown> | undefined;\n }\n\n interface Issue {\n readonly message: string;\n readonly path?: readonly (PropertyKey | PathSegment)[] | undefined;\n }\n\n interface PathSegment {\n readonly key: PropertyKey;\n }\n\n interface Types<Input = unknown, Output = Input> {\n readonly input: Input;\n readonly output: Output;\n }\n\n type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];\n type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];\n}\n\n/* -------------------- Issues -------------------- */\n\n/**\n * A typed discriminated union of all issues emitted by built-in validators.\n *\n * Narrowing on `code` gives precise access to `params`:\n * ```ts\n * if (error.code === 'too_small') {\n * const min = error.params.min; // number | bigint | Date\n * }\n * ```\n */\nexport type Issue =\n | { code: 'custom'; message: string; params?: Record<string, unknown>; path: (string | number)[] }\n | { code: 'invalid_base64'; message: string; params: { format: string }; path: (string | number)[] }\n | { code: 'invalid_date'; message: string; params?: undefined; path: (string | number)[] }\n | { code: 'invalid_duration'; message: string; params: { format: string }; path: (string | number)[] }\n | { code: 'invalid_enum'; message: string; params: { values: readonly unknown[] }; path: (string | number)[] }\n | { code: 'invalid_finite'; message: string; params?: undefined; path: (string | number)[] }\n | { code: 'invalid_integer'; message: string; params?: undefined; path: (string | number)[] }\n | { code: 'invalid_keys'; message: string; params: { keys: string[] }; path: (string | number)[] }\n | { code: 'invalid_length'; message: string; params: { exact: number }; path: (string | number)[] }\n | { code: 'invalid_literal'; message: string; params: { expected: unknown }; path: (string | number)[] }\n | { code: 'invalid_multiple_of'; message: string; params: { step: number | bigint }; path: (string | number)[] }\n | { code: 'invalid_safe'; message: string; params?: undefined; path: (string | number)[] }\n | {\n code: 'invalid_string';\n message: string;\n params: { format?: string; includes?: string; pattern?: string; prefix?: string; suffix?: string };\n path: (string | number)[];\n }\n | { code: 'invalid_type'; message: string; params?: undefined; path: (string | number)[] }\n | { code: 'invalid_union'; message: string; params: { errors: Issue[][] }; path: (string | number)[] }\n | { code: 'invalid_unique'; message: string; params: { unique: true }; path: (string | number)[] }\n | { code: 'invalid_url'; message: string; params: { format: string }; path: (string | number)[] }\n | {\n code: 'invalid_variant';\n message: string;\n params: { discriminator: string; expected: string[] };\n path: (string | number)[];\n }\n | {\n code: 'too_big';\n message: string;\n params: { exclusive?: boolean; max: number | bigint | Date };\n path: (string | number)[];\n }\n | {\n code: 'too_small';\n message: string;\n params: { exclusive?: boolean; min: number | bigint | Date };\n path: (string | number)[];\n }\n | { code: string & {}; message: string; params?: Record<string, unknown>; path: (string | number)[] };\n\n/** ParseContext carries the active message set through the parse pipeline. */\nexport type ParseContext = {\n messages: import('./messages').Messages;\n};\n\n/**\n * Validator function. Receives the value after type-checking and the active ParseContext.\n * Returns an Issue array on failure, null on success, or a Promise for async validators.\n */\nexport type ValidateFn = (value: unknown, ctx?: ParseContext) => Issue[] | null | Promise<Issue[] | null>;\n\nexport type CheckContext = {\n addIssue: (issue: {\n code: string;\n message: string;\n params?: Record<string, unknown>;\n path?: (string | number)[];\n }) => void;\n};\n\n/**\n * Return type of a `check()` callback.\n * - `string` — validation failed; the string becomes the error message.\n * - `false` — validation failed with no message (use `addIssue` for a message).\n * - `true` / `null` / `void` — validation passed.\n *\n * The shorthand `condition || 'message'` works naturally:\n * ```ts\n * s.string().check((value) => value.length > 0 || 'Cannot be empty')\n * ```\n */\nexport type ValidateResult = boolean | null | undefined | string;\n\n/** Re-exported from errors for convenience — defined there. */\nexport type { FlatError, FlatErrorFirst } from './errors';\n\ntype BaseDescriptor = {\n description?: string;\n isNullable?: boolean;\n isOptional?: boolean;\n};\n\nexport type SchemaDescriptor = BaseDescriptor &\n (\n | { kind: 'unknown' | 'never' | 'boolean' | 'bigint' | 'date' | 'lazy' }\n | { className: string; kind: 'instanceof' }\n | {\n contentEncoding?: string;\n format?: string;\n kind: 'string';\n maxLength?: number;\n minLength?: number;\n pattern?: string | null;\n }\n | {\n exclusiveMaximum?: number;\n exclusiveMinimum?: number;\n kind: 'number';\n maximum?: number;\n minimum?: number;\n multipleOf?: number;\n typeHint?: 'integer';\n }\n | { kind: 'literal'; value: string | number | boolean | null | undefined }\n | { kind: 'enum'; values: readonly (string | number)[] }\n | { items: SchemaDescriptor; kind: 'array'; maxItems?: number; minItems?: number }\n | { items: SchemaDescriptor[]; kind: 'tuple'; rest: SchemaDescriptor | null }\n | { fields: Record<string, SchemaDescriptor>; kind: 'object'; strict: boolean }\n | { key: SchemaDescriptor; kind: 'record'; value: SchemaDescriptor }\n | { items: SchemaDescriptor; kind: 'set' }\n | { key: SchemaDescriptor; kind: 'map'; value: SchemaDescriptor }\n | { branches: SchemaDescriptor[]; kind: 'union' | 'intersect' }\n | { branches: Record<string, SchemaDescriptor>; discriminator: string; kind: 'variant' }\n | { from: SchemaDescriptor; kind: 'pipe'; to: SchemaDescriptor }\n );\n\n/* -------------------- ParseResult (forward-references SpellValidationError) -------------------- */\n\nimport type { Schema } from './core';\n// Import only the type to avoid circular dependencies\nimport type { SpellValidationError } from './errors';\n\nexport type ParseResult<T> = { data: T; success: true } | { error: SpellValidationError; success: false };\n\n/* -------------------- Schema execution mode / Infer (forward-references Schema) -------------------- */\n\n/** Structural marker for a schema's input type. Emitted so public types can key on it. */\nexport const schemaInput = Symbol('spell.schemaInput');\n/** Structural marker for a schema's output type. Emitted so public types can key on it. */\nexport const schemaOutput = Symbol('spell.schemaOutput');\nexport declare const schemaAcceptsMissing: unique symbol;\nexport type AcceptsMissing = { readonly [schemaAcceptsMissing]: true };\n\n/** A structural schema surface accepted by composition helpers. */\nexport type SchemaSurface<Output = unknown, Input = Output> = {\n /** @internal */\n _parseFullAsync(value: unknown, ctx?: ParseContext): Promise<{ data: unknown; issues: Issue[] }>;\n /** @internal */\n _parseFullSync(value: unknown, ctx?: ParseContext): { data: unknown; issues: Issue[] };\n safeParseAsync(value: unknown, ctx?: ParseContext): Promise<ParseResult<Output>>;\n definition(): SchemaDescriptor;\n isOptional: boolean;\n optional(): SchemaSurface<Output | undefined, Input | undefined>;\n required(): SchemaSurface<Exclude<Output, undefined>, Exclude<Input, undefined>>;\n readonly [schemaInput]: Input;\n readonly [schemaOutput]: Output;\n};\n\nexport type AnySchema<Output = unknown, Input = Output> = SchemaSurface<Output, Input>;\n\n/**\n * The synchronous parse capability every schema carries. UI adapters that accept\n * `AnySchema` cannot call `safeParse` on it (the surface type omits it); type adapter\n * parameters against this instead.\n *\n * The shape is structural, so a schema with async checks is assignable to it; calling\n * `safeParse` on one returns a failed `ParseResult` (\"parse() cannot evaluate async\n * checks\"). Use `safeParseAsync` when async checks may be present.\n */\nexport type SyncParsable<T = unknown> = { safeParse(value: unknown): ParseResult<T> };\n\n/**\n * An issue path in either shape: spell-native `(string | number)[]` or the\n * Standard Schema `(PropertyKey | { key })[]` format.\n */\nexport type IssuePathSegment = PropertyKey | { readonly key: PropertyKey };\nexport type IssuePath = readonly IssuePathSegment[];\n\nexport type InferOutput<T> =\n T extends Schema<infer Output, unknown>\n ? Output\n : T extends { readonly [schemaOutput]: infer Output }\n ? Output\n : never;\ntype RawInferInput<T> = T extends { readonly [schemaInput]: infer Input } ? Input : unknown;\nexport type InferInput<T> = T extends AcceptsMissing ? RawInferInput<T> | undefined : RawInferInput<T>;\nexport type Infer<T> = InferOutput<T>;\n\n/** Re-exported for convenience — defined in messages.ts. */\nexport type { Messages } from './messages';\n"],"mappings":"AAEA,IAAa,EAAY,CACvB,OAAQ,SACR,eAAgB,iBAChB,aAAc,eACd,iBAAkB,mBAClB,aAAc,eACd,eAAgB,iBAChB,gBAAiB,kBACjB,aAAc,eACd,eAAgB,iBAChB,gBAAiB,kBACjB,oBAAqB,sBACrB,aAAc,eACd,eAAgB,iBAChB,aAAc,eACd,cAAe,gBACf,eAAgB,iBAChB,YAAa,cACb,gBAAiB,kBACjB,QAAS,UACT,UAAW,WACb"}
|
package/dist/types.d.ts
CHANGED
|
@@ -244,36 +244,6 @@ export type CheckContext = {
|
|
|
244
244
|
export type ValidateResult = boolean | null | undefined | string;
|
|
245
245
|
/** Re-exported from errors for convenience — defined there. */
|
|
246
246
|
export type { FlatError, FlatErrorFirst } from './errors';
|
|
247
|
-
/**
|
|
248
|
-
* Visitor map for schema.walk(). Container handlers receive already-walked children (type R).
|
|
249
|
-
* All handlers are optional — unmatched kinds return `null` unless an `unknown` fallback is provided.
|
|
250
|
-
*
|
|
251
|
-
* Each handler receives the concrete schema type for that kind, enabling access to
|
|
252
|
-
* schema-specific properties (e.g. `ArraySchema.itemSchema`) without casting.
|
|
253
|
-
*/
|
|
254
|
-
export type SchemaWalker<R> = {
|
|
255
|
-
array?: <T extends AnySchema, Mode extends SchemaMode>(schema: import('./schemas/array').ArraySchema<T, Mode>, item: R | null) => R;
|
|
256
|
-
bigint?: <Input, Mode extends SchemaMode>(schema: import('./schemas/bigint').BigIntSchema<Input, Mode>) => R;
|
|
257
|
-
boolean?: <Input, Mode extends SchemaMode>(schema: import('./schemas/boolean').BooleanSchema<Input, Mode>) => R;
|
|
258
|
-
date?: <Input, Mode extends SchemaMode>(schema: import('./schemas/date').DateSchema<Input, Mode>) => R;
|
|
259
|
-
enum?: <T extends import('./schemas/enum').EnumValues, Mode extends SchemaMode>(schema: import('./schemas/enum').EnumSchema<T, Mode>) => R;
|
|
260
|
-
instanceof?: <T, Mode extends SchemaMode>(schema: import('./schemas/instanceof').InstanceOfSchema<T, Mode>) => R;
|
|
261
|
-
intersect?: <T extends readonly AnySchema[], Mode extends SchemaMode>(schema: import('./schemas/intersect').IntersectSchema<T, Mode>, branches: (R | null)[]) => R;
|
|
262
|
-
lazy?: <T, Input, Mode extends SchemaMode>(schema: import('./schemas/lazy').LazySchema<T, Input, Mode>) => R;
|
|
263
|
-
literal?: <T extends string | number | boolean | null | undefined, Mode extends SchemaMode>(schema: import('./schemas/literal').LiteralSchema<T, Mode>) => R;
|
|
264
|
-
map?: <K extends AnySchema, V extends AnySchema, Mode extends SchemaMode>(schema: import('./schemas/map').MapSchema<K, V, Mode>, key: R | null, value: R | null) => R;
|
|
265
|
-
never?: <Mode extends SchemaMode>(schema: import('./schemas/never').NeverSchema<Mode>) => R;
|
|
266
|
-
number?: <Input, Mode extends SchemaMode>(schema: import('./schemas/number').NumberSchema<Input, Mode>) => R;
|
|
267
|
-
object?: <T extends import('./schemas/object').ObjectShape, Mode extends SchemaMode>(schema: import('./schemas/object').ObjectSchema<T, Mode>, fields: Record<string, R | null>) => R;
|
|
268
|
-
pipe?: <To extends AnySchema, From extends AnySchema, Mode extends SchemaMode>(schema: import('./core').PipeSchema<To, From, Mode>, from: R | null, to: R | null) => R;
|
|
269
|
-
record?: <K extends AnySchema, V extends AnySchema, Mode extends SchemaMode>(schema: import('./schemas/record').RecordSchema<K, V, Mode>, key: R | null, value: R | null) => R;
|
|
270
|
-
set?: <T extends AnySchema, Mode extends SchemaMode>(schema: import('./schemas/set').SetSchema<T, Mode>, item: R | null) => R;
|
|
271
|
-
string?: <Input, Mode extends SchemaMode>(schema: import('./schemas/string').StringSchema<Input, Mode>) => R;
|
|
272
|
-
tuple?: <T extends import('./schemas/tuple').TupleSchemas, Rest extends AnySchema | null, Mode extends SchemaMode>(schema: import('./schemas/tuple').TupleSchema<T, Rest, Mode>, items: (R | null)[], rest: R | null) => R;
|
|
273
|
-
union?: <T extends readonly AnySchema[], Mode extends SchemaMode>(schema: import('./schemas/union').UnionSchema<T, Mode>, branches: (R | null)[]) => R;
|
|
274
|
-
unknown?: (schema: AnySchema) => R;
|
|
275
|
-
variant?: <K extends string, M extends Record<string, import('./schemas/object').ObjectSchema<any, any>>, Mode extends SchemaMode>(schema: import('./schemas/variant').VariantSchema<K, M, Mode>, branches: Record<string, R | null>) => R;
|
|
276
|
-
};
|
|
277
247
|
type BaseDescriptor = {
|
|
278
248
|
description?: string;
|
|
279
249
|
isNullable?: boolean;
|
|
@@ -350,36 +320,33 @@ export type ParseResult<T> = {
|
|
|
350
320
|
error: SpellValidationError;
|
|
351
321
|
success: false;
|
|
352
322
|
};
|
|
353
|
-
/**
|
|
354
|
-
export declare const
|
|
323
|
+
/** Structural marker for a schema's input type. Emitted so public types can key on it. */
|
|
324
|
+
export declare const schemaInput: unique symbol;
|
|
325
|
+
/** Structural marker for a schema's output type. Emitted so public types can key on it. */
|
|
326
|
+
export declare const schemaOutput: unique symbol;
|
|
355
327
|
export declare const schemaAcceptsMissing: unique symbol;
|
|
356
328
|
export type AcceptsMissing = {
|
|
357
329
|
readonly [schemaAcceptsMissing]: true;
|
|
358
330
|
};
|
|
359
|
-
/** Whether a schema can be parsed synchronously or requires asynchronous parsing. */
|
|
360
|
-
export type SchemaMode = 'async' | 'sync';
|
|
361
331
|
/** A structural schema surface accepted by composition helpers. */
|
|
362
|
-
export type SchemaSurface<Output = unknown, Input = Output
|
|
332
|
+
export type SchemaSurface<Output = unknown, Input = Output> = {
|
|
363
333
|
safeParseAsync(value: unknown, ctx?: ParseContext): Promise<ParseResult<Output>>;
|
|
364
334
|
definition(): SchemaDescriptor;
|
|
365
335
|
isOptional: boolean;
|
|
366
|
-
optional(): SchemaSurface<Output | undefined, Input | undefined
|
|
367
|
-
required(): SchemaSurface<Exclude<Output, undefined>, Exclude<Input, undefined
|
|
336
|
+
optional(): SchemaSurface<Output | undefined, Input | undefined>;
|
|
337
|
+
required(): SchemaSurface<Exclude<Output, undefined>, Exclude<Input, undefined>>;
|
|
368
338
|
readonly [schemaInput]: Input;
|
|
369
|
-
readonly [schemaMode]: Mode;
|
|
370
339
|
readonly [schemaOutput]: Output;
|
|
371
|
-
walk<R>(visitor: SchemaWalker<R>): R | null;
|
|
372
340
|
};
|
|
373
|
-
export type AnySchema<Output = unknown, Input = Output
|
|
341
|
+
export type AnySchema<Output = unknown, Input = Output> = SchemaSurface<Output, Input>;
|
|
374
342
|
/**
|
|
375
|
-
* The synchronous parse capability every
|
|
343
|
+
* The synchronous parse capability every schema carries. UI adapters that accept
|
|
376
344
|
* `AnySchema` cannot call `safeParse` on it (the surface type omits it); type adapter
|
|
377
345
|
* parameters against this instead.
|
|
378
346
|
*
|
|
379
|
-
* The shape is structural, so
|
|
380
|
-
* on one returns a failed `ParseResult` ("parse() cannot evaluate async
|
|
381
|
-
*
|
|
382
|
-
* `safeParseAsync` for async members.
|
|
347
|
+
* The shape is structural, so a schema with async checks is assignable to it; calling
|
|
348
|
+
* `safeParse` on one returns a failed `ParseResult` ("parse() cannot evaluate async
|
|
349
|
+
* checks"). Use `safeParseAsync` when async checks may be present.
|
|
383
350
|
*/
|
|
384
351
|
export type SyncParsable<T = unknown> = {
|
|
385
352
|
safeParse(value: unknown): ParseResult<T>;
|
|
@@ -392,13 +359,7 @@ export type IssuePathSegment = PropertyKey | {
|
|
|
392
359
|
readonly key: PropertyKey;
|
|
393
360
|
};
|
|
394
361
|
export type IssuePath = readonly IssuePathSegment[];
|
|
395
|
-
|
|
396
|
-
export type InferSchemaMode<T> = T extends {
|
|
397
|
-
readonly [schemaMode]: infer Mode extends SchemaMode;
|
|
398
|
-
} ? Mode : never;
|
|
399
|
-
/** Selects async mode when any member of a schema collection is async. */
|
|
400
|
-
export type MergeSchemaModes<Modes extends SchemaMode> = 'async' extends Modes ? 'async' : 'sync';
|
|
401
|
-
export type InferOutput<T> = T extends Schema<infer Output, unknown, SchemaMode> ? Output : T extends {
|
|
362
|
+
export type InferOutput<T> = T extends Schema<infer Output, unknown> ? Output : T extends {
|
|
402
363
|
readonly [schemaOutput]: infer Output;
|
|
403
364
|
} ? Output : never;
|
|
404
365
|
type RawInferInput<T> = T extends {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;CAqBZ,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;AAInE;;;;GAIG;AACH,MAAM,MAAM,SAAS,CAAC,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,CAAC,CAAC;AAIvH,gEAAgE;AAChE,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE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,GAAG,WAAW,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAA;CAAE,CAAC;AAC3E,MAAM,MAAM,SAAS,GAAG,SAAS,gBAAgB,EAAE,CAAC;AAEpD,MAAM,MAAM,WAAW,CAAC,CAAC,IACvB,CAAC,SAAS,MAAM,CAAC,MAAM,MAAM,EAAE,OAAO,CAAC,GACnC,MAAM,GACN,CAAC,SAAS;IAAE,QAAQ,CAAC,CAAC,YAAY,CAAC,EAAE,MAAM,MAAM,CAAA;CAAE,GACjD,MAAM,GACN,KAAK,CAAC;AACd,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS;IAAE,QAAQ,CAAC,CAAC,WAAW,CAAC,EAAE,MAAM,KAAK,CAAA;CAAE,GAAG,KAAK,GAAG,OAAO,CAAC;AAC5F,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,SAAS,cAAc,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AACvG,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;AAEtC,4DAA4D;AAC5D,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["/* -------------------- Error Codes -------------------- */\n\nexport const ErrorCode = {\n custom: 'custom',\n invalid_base64: 'invalid_base64',\n invalid_date: 'invalid_date',\n invalid_duration: 'invalid_duration',\n invalid_enum: 'invalid_enum',\n invalid_finite: 'invalid_finite',\n invalid_integer: 'invalid_integer',\n invalid_keys: 'invalid_keys',\n invalid_length: 'invalid_length',\n invalid_literal: 'invalid_literal',\n invalid_multiple_of: 'invalid_multiple_of',\n invalid_safe: 'invalid_safe',\n invalid_string: 'invalid_string',\n invalid_type: 'invalid_type',\n invalid_union: 'invalid_union',\n invalid_unique: 'invalid_unique',\n invalid_url: 'invalid_url',\n invalid_variant: 'invalid_variant',\n too_big: 'too_big',\n too_small: 'too_small',\n} as const;\n\nexport type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];\n\n/* -------------------- Messages -------------------- */\n\n/**\n * A validation message — either a static string or a function that receives context and returns a string.\n * **Note:** Static string values are used verbatim with no interpolation. Use the function form\n * for context-dependent messages (e.g. `(ctx) => \\`Must be at least ${ctx.min}\\``).\n */\nexport type MessageFn<Ctx extends Record<string, unknown> = Record<string, unknown>> = string | ((ctx: Ctx) => string);\n\n/* -------------------- JSON Schema -------------------- */\n\n/** Plain JSON Schema object (targeting JSON Schema 2020-12). */\nexport type JsonSchema = Record<string, unknown>;\n\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n readonly '~standard': StandardSchemaV1.Props<Input, Output>;\n}\n\nexport declare namespace StandardSchemaV1 {\n interface Props<Input = unknown, Output = Input> {\n readonly types?: Types<Input, Output> | undefined;\n readonly validate: (value: unknown, options?: Options | undefined) => Result<Output> | Promise<Result<Output>>;\n readonly vendor: string;\n readonly version: 1;\n }\n\n type Result<Output> = { readonly issues: readonly Issue[] } | { readonly issues?: undefined; readonly value: Output };\n\n interface Options {\n readonly libraryOptions?: Record<string, unknown> | undefined;\n }\n\n interface Issue {\n readonly message: string;\n readonly path?: readonly (PropertyKey | PathSegment)[] | undefined;\n }\n\n interface PathSegment {\n readonly key: PropertyKey;\n }\n\n interface Types<Input = unknown, Output = Input> {\n readonly input: Input;\n readonly output: Output;\n }\n\n type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];\n type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];\n}\n\n/* -------------------- Issues -------------------- */\n\n/**\n * A typed discriminated union of all issues emitted by built-in validators.\n *\n * Narrowing on `code` gives precise access to `params`:\n * ```ts\n * if (error.code === 'too_small') {\n * const min = error.params.min; // number | bigint | Date\n * }\n * ```\n */\nexport type Issue =\n | { code: 'custom'; message: string; params?: Record<string, unknown>; path: (string | number)[] }\n | { code: 'invalid_base64'; message: string; params: { format: string }; path: (string | number)[] }\n | { code: 'invalid_date'; message: string; params?: undefined; path: (string | number)[] }\n | { code: 'invalid_duration'; message: string; params: { format: string }; path: (string | number)[] }\n | { code: 'invalid_enum'; message: string; params: { values: readonly unknown[] }; path: (string | number)[] }\n | { code: 'invalid_finite'; message: string; params?: undefined; path: (string | number)[] }\n | { code: 'invalid_integer'; message: string; params?: undefined; path: (string | number)[] }\n | { code: 'invalid_keys'; message: string; params: { keys: string[] }; path: (string | number)[] }\n | { code: 'invalid_length'; message: string; params: { exact: number }; path: (string | number)[] }\n | { code: 'invalid_literal'; message: string; params: { expected: unknown }; path: (string | number)[] }\n | { code: 'invalid_multiple_of'; message: string; params: { step: number | bigint }; path: (string | number)[] }\n | { code: 'invalid_safe'; message: string; params?: undefined; path: (string | number)[] }\n | {\n code: 'invalid_string';\n message: string;\n params: { format?: string; includes?: string; pattern?: string; prefix?: string; suffix?: string };\n path: (string | number)[];\n }\n | { code: 'invalid_type'; message: string; params?: undefined; path: (string | number)[] }\n | { code: 'invalid_union'; message: string; params: { errors: Issue[][] }; path: (string | number)[] }\n | { code: 'invalid_unique'; message: string; params: { unique: true }; path: (string | number)[] }\n | { code: 'invalid_url'; message: string; params: { format: string }; path: (string | number)[] }\n | {\n code: 'invalid_variant';\n message: string;\n params: { discriminator: string; expected: string[] };\n path: (string | number)[];\n }\n | {\n code: 'too_big';\n message: string;\n params: { exclusive?: boolean; max: number | bigint | Date };\n path: (string | number)[];\n }\n | {\n code: 'too_small';\n message: string;\n params: { exclusive?: boolean; min: number | bigint | Date };\n path: (string | number)[];\n }\n | { code: string & {}; message: string; params?: Record<string, unknown>; path: (string | number)[] };\n\n/** ParseContext carries the active message set through the parse pipeline. */\nexport type ParseContext = {\n messages: import('./messages').Messages;\n};\n\n/**\n * Validator function. Receives the value after type-checking and the active ParseContext.\n * Returns an Issue array on failure, null on success, or a Promise for async validators.\n */\nexport type ValidateFn = (value: unknown, ctx?: ParseContext) => Issue[] | null | Promise<Issue[] | null>;\n\nexport type CheckContext = {\n addIssue: (issue: {\n code: string;\n message: string;\n params?: Record<string, unknown>;\n path?: (string | number)[];\n }) => void;\n};\n\n/**\n * Return type of a `check()` callback.\n * - `string` — validation failed; the string becomes the error message.\n * - `false` — validation failed with no message (use `addIssue` for a message).\n * - `true` / `null` / `void` — validation passed.\n *\n * The shorthand `condition || 'message'` works naturally:\n * ```ts\n * s.string().check((value) => value.length > 0 || 'Cannot be empty')\n * ```\n */\nexport type ValidateResult = boolean | null | undefined | string;\n\n/** Re-exported from errors for convenience — defined there. */\nexport type { FlatError, FlatErrorFirst } from './errors';\n\n/* -------------------- Schema Introspection -------------------- */\n\n/**\n * Visitor map for schema.walk(). Container handlers receive already-walked children (type R).\n * All handlers are optional — unmatched kinds return `null` unless an `unknown` fallback is provided.\n *\n * Each handler receives the concrete schema type for that kind, enabling access to\n * schema-specific properties (e.g. `ArraySchema.itemSchema`) without casting.\n */\nexport type SchemaWalker<R> = {\n array?: <T extends AnySchema, Mode extends SchemaMode>(\n schema: import('./schemas/array').ArraySchema<T, Mode>,\n item: R | null,\n ) => R;\n bigint?: <Input, Mode extends SchemaMode>(schema: import('./schemas/bigint').BigIntSchema<Input, Mode>) => R;\n boolean?: <Input, Mode extends SchemaMode>(schema: import('./schemas/boolean').BooleanSchema<Input, Mode>) => R;\n date?: <Input, Mode extends SchemaMode>(schema: import('./schemas/date').DateSchema<Input, Mode>) => R;\n enum?: <T extends import('./schemas/enum').EnumValues, Mode extends SchemaMode>(\n schema: import('./schemas/enum').EnumSchema<T, Mode>,\n ) => R;\n instanceof?: <T, Mode extends SchemaMode>(schema: import('./schemas/instanceof').InstanceOfSchema<T, Mode>) => R;\n intersect?: <T extends readonly AnySchema[], Mode extends SchemaMode>(\n schema: import('./schemas/intersect').IntersectSchema<T, Mode>,\n branches: (R | null)[],\n ) => R;\n lazy?: <T, Input, Mode extends SchemaMode>(schema: import('./schemas/lazy').LazySchema<T, Input, Mode>) => R;\n literal?: <T extends string | number | boolean | null | undefined, Mode extends SchemaMode>(\n schema: import('./schemas/literal').LiteralSchema<T, Mode>,\n ) => R;\n map?: <K extends AnySchema, V extends AnySchema, Mode extends SchemaMode>(\n schema: import('./schemas/map').MapSchema<K, V, Mode>,\n key: R | null,\n value: R | null,\n ) => R;\n never?: <Mode extends SchemaMode>(schema: import('./schemas/never').NeverSchema<Mode>) => R;\n number?: <Input, Mode extends SchemaMode>(schema: import('./schemas/number').NumberSchema<Input, Mode>) => R;\n object?: <T extends import('./schemas/object').ObjectShape, Mode extends SchemaMode>(\n schema: import('./schemas/object').ObjectSchema<T, Mode>,\n fields: Record<string, R | null>,\n ) => R;\n pipe?: <To extends AnySchema, From extends AnySchema, Mode extends SchemaMode>(\n schema: import('./core').PipeSchema<To, From, Mode>,\n from: R | null,\n to: R | null,\n ) => R;\n record?: <K extends AnySchema, V extends AnySchema, Mode extends SchemaMode>(\n schema: import('./schemas/record').RecordSchema<K, V, Mode>,\n key: R | null,\n value: R | null,\n ) => R;\n set?: <T extends AnySchema, Mode extends SchemaMode>(\n schema: import('./schemas/set').SetSchema<T, Mode>,\n item: R | null,\n ) => R;\n string?: <Input, Mode extends SchemaMode>(schema: import('./schemas/string').StringSchema<Input, Mode>) => R;\n tuple?: <T extends import('./schemas/tuple').TupleSchemas, Rest extends AnySchema | null, Mode extends SchemaMode>(\n schema: import('./schemas/tuple').TupleSchema<T, Rest, Mode>,\n items: (R | null)[],\n rest: R | null,\n ) => R;\n union?: <T extends readonly AnySchema[], Mode extends SchemaMode>(\n schema: import('./schemas/union').UnionSchema<T, Mode>,\n branches: (R | null)[],\n ) => R;\n unknown?: (schema: AnySchema) => R;\n variant?: <\n K extends string,\n M extends Record<string, import('./schemas/object').ObjectSchema<any, any>>,\n Mode extends SchemaMode,\n >(\n schema: import('./schemas/variant').VariantSchema<K, M, Mode>,\n branches: Record<string, R | null>,\n ) => R;\n};\n\ntype BaseDescriptor = {\n description?: string;\n isNullable?: boolean;\n isOptional?: boolean;\n};\n\nexport type SchemaDescriptor = BaseDescriptor &\n (\n | { kind: 'unknown' | 'never' | 'boolean' | 'bigint' | 'date' | 'lazy' }\n | { className: string; kind: 'instanceof' }\n | {\n contentEncoding?: string;\n format?: string;\n kind: 'string';\n maxLength?: number;\n minLength?: number;\n pattern?: string | null;\n }\n | {\n exclusiveMaximum?: number;\n exclusiveMinimum?: number;\n kind: 'number';\n maximum?: number;\n minimum?: number;\n multipleOf?: number;\n typeHint?: 'integer';\n }\n | { kind: 'literal'; value: string | number | boolean | null | undefined }\n | { kind: 'enum'; values: readonly (string | number)[] }\n | { items: SchemaDescriptor; kind: 'array'; maxItems?: number; minItems?: number }\n | { items: SchemaDescriptor[]; kind: 'tuple'; rest: SchemaDescriptor | null }\n | { fields: Record<string, SchemaDescriptor>; kind: 'object'; strict: boolean }\n | { key: SchemaDescriptor; kind: 'record'; value: SchemaDescriptor }\n | { items: SchemaDescriptor; kind: 'set' }\n | { key: SchemaDescriptor; kind: 'map'; value: SchemaDescriptor }\n | { branches: SchemaDescriptor[]; kind: 'union' | 'intersect' }\n | { branches: Record<string, SchemaDescriptor>; discriminator: string; kind: 'variant' }\n | { from: SchemaDescriptor; kind: 'pipe'; to: SchemaDescriptor }\n );\n\n/* -------------------- ParseResult (forward-references SpellValidationError) -------------------- */\n\nimport type { Schema } from './core';\n// Import only the type to avoid circular dependencies\nimport type { SpellValidationError } from './errors';\n\nexport type ParseResult<T> = { data: T; success: true } | { error: SpellValidationError; success: false };\n\n/* -------------------- Schema execution mode / Infer (forward-references Schema) -------------------- */\n\n/** @internal */\nexport const schemaInput = Symbol('spell.schemaInput');\n/** Public structural marker for a schema's parsing capability. */\nexport const schemaMode = Symbol('spell.schemaMode');\n/** @internal */\nexport const schemaOutput = Symbol('spell.schemaOutput');\nexport declare const schemaAcceptsMissing: unique symbol;\nexport type AcceptsMissing = { readonly [schemaAcceptsMissing]: true };\n\n/** Whether a schema can be parsed synchronously or requires asynchronous parsing. */\nexport type SchemaMode = 'async' | 'sync';\n\n/** A structural schema surface accepted by composition helpers. */\nexport type SchemaSurface<Output = unknown, Input = Output, Mode extends SchemaMode = SchemaMode> = {\n /** @internal */\n _parseFullAsync(value: unknown, ctx?: ParseContext): Promise<{ data: unknown; issues: Issue[] }>;\n /** @internal */\n _parseFullSync(value: unknown, ctx?: ParseContext): { data: unknown; issues: Issue[] };\n safeParseAsync(value: unknown, ctx?: ParseContext): Promise<ParseResult<Output>>;\n definition(): SchemaDescriptor;\n isOptional: boolean;\n optional(): SchemaSurface<Output | undefined, Input | undefined, Mode>;\n required(): SchemaSurface<Exclude<Output, undefined>, Exclude<Input, undefined>, Mode>;\n readonly [schemaInput]: Input;\n readonly [schemaMode]: Mode;\n readonly [schemaOutput]: Output;\n walk<R>(visitor: SchemaWalker<R>): R | null;\n};\n\nexport type AnySchema<Output = unknown, Input = Output, Mode extends SchemaMode = SchemaMode> = SchemaSurface<\n Output,\n Input,\n Mode\n>;\n\n/**\n * The synchronous parse capability every sync schema carries. UI adapters that accept\n * `AnySchema` cannot call `safeParse` on it (the surface type omits it); type adapter\n * parameters against this instead.\n *\n * The shape is structural, so an async-only schema is assignable to it; calling `safeParse`\n * on one returns a failed `ParseResult` (\"parse() cannot evaluate async checks\"). When the\n * schema's mode is not statically known, narrow with `InferSchemaMode` and use\n * `safeParseAsync` for async members.\n */\nexport type SyncParsable<T = unknown> = { safeParse(value: unknown): ParseResult<T> };\n\n/**\n * An issue path in either shape: spell-native `(string | number)[]` or the\n * Standard Schema `(PropertyKey | { key })[]` format.\n */\nexport type IssuePathSegment = PropertyKey | { readonly key: PropertyKey };\nexport type IssuePath = readonly IssuePathSegment[];\n\n/** Extracts a schema's parsing capability. */\nexport type InferSchemaMode<T> = T extends { readonly [schemaMode]: infer Mode extends SchemaMode } ? Mode : never;\n\n/** Selects async mode when any member of a schema collection is async. */\nexport type MergeSchemaModes<Modes extends SchemaMode> = 'async' extends Modes ? 'async' : 'sync';\n\nexport type InferOutput<T> =\n T extends Schema<infer Output, unknown, SchemaMode>\n ? Output\n : T extends { readonly [schemaOutput]: infer Output }\n ? Output\n : never;\ntype RawInferInput<T> = T extends { readonly [schemaInput]: infer Input } ? Input : unknown;\nexport type InferInput<T> = T extends AcceptsMissing ? RawInferInput<T> | undefined : RawInferInput<T>;\nexport type Infer<T> = InferOutput<T>;\n\n/** Re-exported for convenience — defined in messages.ts. */\nexport type { Messages } from './messages';\n"],"mappings":"AAEA,IAAa,EAAY,CACvB,OAAQ,SACR,eAAgB,iBAChB,aAAc,eACd,iBAAkB,mBAClB,aAAc,eACd,eAAgB,iBAChB,gBAAiB,kBACjB,aAAc,eACd,eAAgB,iBAChB,gBAAiB,kBACjB,oBAAqB,sBACrB,aAAc,eACd,eAAgB,iBAChB,aAAc,eACd,cAAe,gBACf,eAAgB,iBAChB,YAAa,cACb,gBAAiB,kBACjB,QAAS,UACT,UAAW,WACb"}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["/* -------------------- Error Codes -------------------- */\n\nexport const ErrorCode = {\n custom: 'custom',\n invalid_base64: 'invalid_base64',\n invalid_date: 'invalid_date',\n invalid_duration: 'invalid_duration',\n invalid_enum: 'invalid_enum',\n invalid_finite: 'invalid_finite',\n invalid_integer: 'invalid_integer',\n invalid_keys: 'invalid_keys',\n invalid_length: 'invalid_length',\n invalid_literal: 'invalid_literal',\n invalid_multiple_of: 'invalid_multiple_of',\n invalid_safe: 'invalid_safe',\n invalid_string: 'invalid_string',\n invalid_type: 'invalid_type',\n invalid_union: 'invalid_union',\n invalid_unique: 'invalid_unique',\n invalid_url: 'invalid_url',\n invalid_variant: 'invalid_variant',\n too_big: 'too_big',\n too_small: 'too_small',\n} as const;\n\nexport type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];\n\n/* -------------------- Messages -------------------- */\n\n/**\n * A validation message — either a static string or a function that receives context and returns a string.\n * **Note:** Static string values are used verbatim with no interpolation. Use the function form\n * for context-dependent messages (e.g. `(ctx) => \\`Must be at least ${ctx.min}\\``).\n */\nexport type MessageFn<Ctx extends Record<string, unknown> = Record<string, unknown>> = string | ((ctx: Ctx) => string);\n\n/* -------------------- JSON Schema -------------------- */\n\n/** Plain JSON Schema object (targeting JSON Schema 2020-12). */\nexport type JsonSchema = Record<string, unknown>;\n\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n readonly '~standard': StandardSchemaV1.Props<Input, Output>;\n}\n\nexport declare namespace StandardSchemaV1 {\n interface Props<Input = unknown, Output = Input> {\n readonly types?: Types<Input, Output> | undefined;\n readonly validate: (value: unknown, options?: Options | undefined) => Result<Output> | Promise<Result<Output>>;\n readonly vendor: string;\n readonly version: 1;\n }\n\n type Result<Output> = { readonly issues: readonly Issue[] } | { readonly issues?: undefined; readonly value: Output };\n\n interface Options {\n readonly libraryOptions?: Record<string, unknown> | undefined;\n }\n\n interface Issue {\n readonly message: string;\n readonly path?: readonly (PropertyKey | PathSegment)[] | undefined;\n }\n\n interface PathSegment {\n readonly key: PropertyKey;\n }\n\n interface Types<Input = unknown, Output = Input> {\n readonly input: Input;\n readonly output: Output;\n }\n\n type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];\n type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];\n}\n\n/* -------------------- Issues -------------------- */\n\n/**\n * A typed discriminated union of all issues emitted by built-in validators.\n *\n * Narrowing on `code` gives precise access to `params`:\n * ```ts\n * if (error.code === 'too_small') {\n * const min = error.params.min; // number | bigint | Date\n * }\n * ```\n */\nexport type Issue =\n | { code: 'custom'; message: string; params?: Record<string, unknown>; path: (string | number)[] }\n | { code: 'invalid_base64'; message: string; params: { format: string }; path: (string | number)[] }\n | { code: 'invalid_date'; message: string; params?: undefined; path: (string | number)[] }\n | { code: 'invalid_duration'; message: string; params: { format: string }; path: (string | number)[] }\n | { code: 'invalid_enum'; message: string; params: { values: readonly unknown[] }; path: (string | number)[] }\n | { code: 'invalid_finite'; message: string; params?: undefined; path: (string | number)[] }\n | { code: 'invalid_integer'; message: string; params?: undefined; path: (string | number)[] }\n | { code: 'invalid_keys'; message: string; params: { keys: string[] }; path: (string | number)[] }\n | { code: 'invalid_length'; message: string; params: { exact: number }; path: (string | number)[] }\n | { code: 'invalid_literal'; message: string; params: { expected: unknown }; path: (string | number)[] }\n | { code: 'invalid_multiple_of'; message: string; params: { step: number | bigint }; path: (string | number)[] }\n | { code: 'invalid_safe'; message: string; params?: undefined; path: (string | number)[] }\n | {\n code: 'invalid_string';\n message: string;\n params: { format?: string; includes?: string; pattern?: string; prefix?: string; suffix?: string };\n path: (string | number)[];\n }\n | { code: 'invalid_type'; message: string; params?: undefined; path: (string | number)[] }\n | { code: 'invalid_union'; message: string; params: { errors: Issue[][] }; path: (string | number)[] }\n | { code: 'invalid_unique'; message: string; params: { unique: true }; path: (string | number)[] }\n | { code: 'invalid_url'; message: string; params: { format: string }; path: (string | number)[] }\n | {\n code: 'invalid_variant';\n message: string;\n params: { discriminator: string; expected: string[] };\n path: (string | number)[];\n }\n | {\n code: 'too_big';\n message: string;\n params: { exclusive?: boolean; max: number | bigint | Date };\n path: (string | number)[];\n }\n | {\n code: 'too_small';\n message: string;\n params: { exclusive?: boolean; min: number | bigint | Date };\n path: (string | number)[];\n }\n | { code: string & {}; message: string; params?: Record<string, unknown>; path: (string | number)[] };\n\n/** ParseContext carries the active message set through the parse pipeline. */\nexport type ParseContext = {\n messages: import('./messages').Messages;\n};\n\n/**\n * Validator function. Receives the value after type-checking and the active ParseContext.\n * Returns an Issue array on failure, null on success, or a Promise for async validators.\n */\nexport type ValidateFn = (value: unknown, ctx?: ParseContext) => Issue[] | null | Promise<Issue[] | null>;\n\nexport type CheckContext = {\n addIssue: (issue: {\n code: string;\n message: string;\n params?: Record<string, unknown>;\n path?: (string | number)[];\n }) => void;\n};\n\n/**\n * Return type of a `check()` callback.\n * - `string` — validation failed; the string becomes the error message.\n * - `false` — validation failed with no message (use `addIssue` for a message).\n * - `true` / `null` / `void` — validation passed.\n *\n * The shorthand `condition || 'message'` works naturally:\n * ```ts\n * s.string().check((value) => value.length > 0 || 'Cannot be empty')\n * ```\n */\nexport type ValidateResult = boolean | null | undefined | string;\n\n/** Re-exported from errors for convenience — defined there. */\nexport type { FlatError, FlatErrorFirst } from './errors';\n\ntype BaseDescriptor = {\n description?: string;\n isNullable?: boolean;\n isOptional?: boolean;\n};\n\nexport type SchemaDescriptor = BaseDescriptor &\n (\n | { kind: 'unknown' | 'never' | 'boolean' | 'bigint' | 'date' | 'lazy' }\n | { className: string; kind: 'instanceof' }\n | {\n contentEncoding?: string;\n format?: string;\n kind: 'string';\n maxLength?: number;\n minLength?: number;\n pattern?: string | null;\n }\n | {\n exclusiveMaximum?: number;\n exclusiveMinimum?: number;\n kind: 'number';\n maximum?: number;\n minimum?: number;\n multipleOf?: number;\n typeHint?: 'integer';\n }\n | { kind: 'literal'; value: string | number | boolean | null | undefined }\n | { kind: 'enum'; values: readonly (string | number)[] }\n | { items: SchemaDescriptor; kind: 'array'; maxItems?: number; minItems?: number }\n | { items: SchemaDescriptor[]; kind: 'tuple'; rest: SchemaDescriptor | null }\n | { fields: Record<string, SchemaDescriptor>; kind: 'object'; strict: boolean }\n | { key: SchemaDescriptor; kind: 'record'; value: SchemaDescriptor }\n | { items: SchemaDescriptor; kind: 'set' }\n | { key: SchemaDescriptor; kind: 'map'; value: SchemaDescriptor }\n | { branches: SchemaDescriptor[]; kind: 'union' | 'intersect' }\n | { branches: Record<string, SchemaDescriptor>; discriminator: string; kind: 'variant' }\n | { from: SchemaDescriptor; kind: 'pipe'; to: SchemaDescriptor }\n );\n\n/* -------------------- ParseResult (forward-references SpellValidationError) -------------------- */\n\nimport type { Schema } from './core';\n// Import only the type to avoid circular dependencies\nimport type { SpellValidationError } from './errors';\n\nexport type ParseResult<T> = { data: T; success: true } | { error: SpellValidationError; success: false };\n\n/* -------------------- Schema execution mode / Infer (forward-references Schema) -------------------- */\n\n/** Structural marker for a schema's input type. Emitted so public types can key on it. */\nexport const schemaInput = Symbol('spell.schemaInput');\n/** Structural marker for a schema's output type. Emitted so public types can key on it. */\nexport const schemaOutput = Symbol('spell.schemaOutput');\nexport declare const schemaAcceptsMissing: unique symbol;\nexport type AcceptsMissing = { readonly [schemaAcceptsMissing]: true };\n\n/** A structural schema surface accepted by composition helpers. */\nexport type SchemaSurface<Output = unknown, Input = Output> = {\n /** @internal */\n _parseFullAsync(value: unknown, ctx?: ParseContext): Promise<{ data: unknown; issues: Issue[] }>;\n /** @internal */\n _parseFullSync(value: unknown, ctx?: ParseContext): { data: unknown; issues: Issue[] };\n safeParseAsync(value: unknown, ctx?: ParseContext): Promise<ParseResult<Output>>;\n definition(): SchemaDescriptor;\n isOptional: boolean;\n optional(): SchemaSurface<Output | undefined, Input | undefined>;\n required(): SchemaSurface<Exclude<Output, undefined>, Exclude<Input, undefined>>;\n readonly [schemaInput]: Input;\n readonly [schemaOutput]: Output;\n};\n\nexport type AnySchema<Output = unknown, Input = Output> = SchemaSurface<Output, Input>;\n\n/**\n * The synchronous parse capability every schema carries. UI adapters that accept\n * `AnySchema` cannot call `safeParse` on it (the surface type omits it); type adapter\n * parameters against this instead.\n *\n * The shape is structural, so a schema with async checks is assignable to it; calling\n * `safeParse` on one returns a failed `ParseResult` (\"parse() cannot evaluate async\n * checks\"). Use `safeParseAsync` when async checks may be present.\n */\nexport type SyncParsable<T = unknown> = { safeParse(value: unknown): ParseResult<T> };\n\n/**\n * An issue path in either shape: spell-native `(string | number)[]` or the\n * Standard Schema `(PropertyKey | { key })[]` format.\n */\nexport type IssuePathSegment = PropertyKey | { readonly key: PropertyKey };\nexport type IssuePath = readonly IssuePathSegment[];\n\nexport type InferOutput<T> =\n T extends Schema<infer Output, unknown>\n ? Output\n : T extends { readonly [schemaOutput]: infer Output }\n ? Output\n : never;\ntype RawInferInput<T> = T extends { readonly [schemaInput]: infer Input } ? Input : unknown;\nexport type InferInput<T> = T extends AcceptsMissing ? RawInferInput<T> | undefined : RawInferInput<T>;\nexport type Infer<T> = InferOutput<T>;\n\n/** Re-exported for convenience — defined in messages.ts. */\nexport type { Messages } from './messages';\n"],"mappings":"AAEA,IAAa,EAAY,CACvB,OAAQ,SACR,eAAgB,iBAChB,aAAc,eACd,iBAAkB,mBAClB,aAAc,eACd,eAAgB,iBAChB,gBAAiB,kBACjB,aAAc,eACd,eAAgB,iBAChB,gBAAiB,kBACjB,oBAAqB,sBACrB,aAAc,eACd,eAAgB,iBAChB,aAAc,eACd,cAAe,gBACf,eAAgB,iBAChB,YAAa,cACb,gBAAiB,kBACjB,QAAS,UACT,UAAW,WACb"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vielzeug/spell",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "26.10.0",
|
|
4
4
|
"description": "Zero-dependency schema validation with Standard Schema interoperability",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -61,12 +61,12 @@
|
|
|
61
61
|
"test:types": "tsc -p tsconfig.types.json"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@vielzeug/arsenal": "
|
|
64
|
+
"@vielzeug/arsenal": "26.10.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@types/node": "^26.
|
|
67
|
+
"@types/node": "^26.6.2",
|
|
68
68
|
"typescript": "^6.0.3",
|
|
69
|
-
"vite": "^8.
|
|
70
|
-
"vitest": "^5.0.
|
|
69
|
+
"vite": "^8.3.0",
|
|
70
|
+
"vitest": "^5.0.1"
|
|
71
71
|
}
|
|
72
72
|
}
|