@nicolastoulemont/std 0.8.0 → 0.8.1
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/README.md +16 -13
- package/dist/adt/index.d.mts +1 -1
- package/dist/adt/index.mjs +1 -1
- package/dist/{adt-CzdkjlUM.mjs → adt-CPG_sa8q.mjs} +2 -2
- package/dist/{adt-CzdkjlUM.mjs.map → adt-CPG_sa8q.mjs.map} +1 -1
- package/dist/index-B4WfexUL.d.mts +57 -0
- package/dist/index-B4WfexUL.d.mts.map +1 -0
- package/dist/index-BqJ1GWAF.d.mts.map +1 -1
- package/dist/index-CIvNgjsx.d.mts.map +1 -1
- package/dist/{index-DfQGXBQI.d.mts → index-DUki2Bcp.d.mts} +2 -2
- package/dist/{index-DfQGXBQI.d.mts.map → index-DUki2Bcp.d.mts.map} +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/schema/index.d.mts +1 -1
- package/dist/schema/index.mjs +1 -1
- package/dist/schema-CJ-aaQe8.mjs +2 -0
- package/dist/schema-CJ-aaQe8.mjs.map +1 -0
- package/dist/schema.shared-Bjyroa6b.mjs +2 -0
- package/dist/schema.shared-Bjyroa6b.mjs.map +1 -0
- package/dist/{schema.types-CFzzx4bw.d.mts → schema.types-CBEXCwfs.d.mts} +17 -2
- package/dist/schema.types-CBEXCwfs.d.mts.map +1 -0
- package/package.json +1 -1
- package/dist/index-Ctg7XUOs.d.mts +0 -36
- package/dist/index-Ctg7XUOs.d.mts.map +0 -1
- package/dist/schema-D87TVF_b.mjs +0 -2
- package/dist/schema-D87TVF_b.mjs.map +0 -1
- package/dist/schema.shared-CI4eydjX.mjs +0 -2
- package/dist/schema.shared-CI4eydjX.mjs.map +0 -1
- package/dist/schema.types-CFzzx4bw.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -260,7 +260,10 @@ Schema wraps Standard Schema-compatible validators for two production use cases:
|
|
|
260
260
|
boundary parsing and sync-only refinement.
|
|
261
261
|
|
|
262
262
|
Use `Schema.parse` at I/O boundaries when a broad external type hides smaller implicit subtypes.
|
|
263
|
-
Use `Schema.
|
|
263
|
+
Use `Schema.refine` for in-memory narrowing when the schema validates only part of a broader value and you want to preserve the rest of the original shape.
|
|
264
|
+
Use `Schema.is` when the narrowed type should exactly match the schema output.
|
|
265
|
+
Use `Schema.Refine<Base, typeof schema>` for a reusable preserved-shape narrowed type, and `Schema.Infer<typeof schema>` for the exact schema output type.
|
|
266
|
+
Only use `Schema.refine` with sync schemas that prove properties already present on the original value. Transforms, defaults, and coercions should continue to use `Schema.parse`.
|
|
264
267
|
|
|
265
268
|
#### Boundary Parsing Example
|
|
266
269
|
|
|
@@ -311,7 +314,8 @@ if (Result.isOk(result)) {
|
|
|
311
314
|
import { Schema } from "@nicolastoulemont/std"
|
|
312
315
|
import { z } from "zod"
|
|
313
316
|
|
|
314
|
-
type
|
|
317
|
+
type PersistedTicket = {
|
|
318
|
+
id: string
|
|
315
319
|
channel: "chat" | "email"
|
|
316
320
|
chatId?: string | null
|
|
317
321
|
metadata?: {
|
|
@@ -319,31 +323,30 @@ type Ticket = {
|
|
|
319
323
|
} | null
|
|
320
324
|
}
|
|
321
325
|
|
|
322
|
-
type
|
|
326
|
+
type ChatTicketFields = {
|
|
323
327
|
channel: "chat"
|
|
324
328
|
chatId: string
|
|
325
|
-
metadata: {
|
|
326
|
-
conversationId: string
|
|
327
|
-
}
|
|
328
329
|
}
|
|
329
330
|
|
|
330
|
-
const ChatTicketSchema: Schema.
|
|
331
|
+
const ChatTicketSchema: Schema.SyncSchema<PersistedTicket, ChatTicketFields> = z.object({
|
|
331
332
|
channel: z.literal("chat"),
|
|
332
333
|
chatId: z.string(),
|
|
333
|
-
metadata: z.object({
|
|
334
|
-
conversationId: z.string(),
|
|
335
|
-
}),
|
|
336
334
|
})
|
|
337
335
|
|
|
338
|
-
|
|
336
|
+
type ChatTicket = Schema.Refine<PersistedTicket, typeof ChatTicketSchema>
|
|
337
|
+
|
|
338
|
+
const isChatTicket = Schema.refine(ChatTicketSchema)
|
|
339
339
|
|
|
340
|
-
declare const ticket:
|
|
340
|
+
declare const ticket: PersistedTicket
|
|
341
341
|
|
|
342
342
|
if (isChatTicket(ticket)) {
|
|
343
|
-
ticket.
|
|
343
|
+
ticket.id
|
|
344
|
+
ticket.chatId.toUpperCase()
|
|
344
345
|
}
|
|
345
346
|
```
|
|
346
347
|
|
|
348
|
+
Use `Schema.is` instead when the narrowed type should be the schema output itself rather than `Base & Output<typeof schema>`.
|
|
349
|
+
|
|
347
350
|
### Adt
|
|
348
351
|
|
|
349
352
|
Adt builds tagged unions backed by any Standard Schema-compatible validator.
|
package/dist/adt/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as adt_d_exports } from "../index-
|
|
1
|
+
import { t as adt_d_exports } from "../index-DUki2Bcp.mjs";
|
|
2
2
|
export { adt_d_exports as Adt };
|
package/dist/adt/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../adt-
|
|
1
|
+
import{t as e}from"../adt-CPG_sa8q.mjs";export{e as Adt};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./chunk-oQKkju2G.mjs";import{i as t,n,r,t as i}from"./equality-BX6BUidG.mjs";import{i as a,t as o}from"./result-D3VY0qBG.mjs";import{
|
|
2
|
-
//# sourceMappingURL=adt-
|
|
1
|
+
import{t as e}from"./chunk-oQKkju2G.mjs";import{i as t,n,r,t as i}from"./equality-BX6BUidG.mjs";import{i as a,t as o}from"./result-D3VY0qBG.mjs";import{r as s}from"./schema.shared-Bjyroa6b.mjs";function c(e,t){let n=t[e._tag];return n(e)}function l(e){return typeof e!=`object`||!e?!1:Object.getPrototypeOf(e)===null||Object.getPrototypeOf(e)===Object.prototype}function u(e){return typeof e==`function`&&`_variant`in e&&e._variant===!0}function d(e,t,n){return s(e,t,`ADT variant "${n}"`)}function f(e){return t=>l(t)&&`_tag`in t&&t._tag===e}function p(e){let t=new Set(e);return e=>l(e)&&`_tag`in e&&typeof e._tag==`string`&&t.has(e._tag)}function m(e,t,n,r){return n!==void 0&&r!==void 0?{kind:e,message:t,cause:n,validationIssues:r}:n===void 0?r===void 0?{kind:e,message:t}:{kind:e,message:t,validationIssues:r}:{kind:e,message:t,cause:n}}function h(e){return{to:e=>JSON.stringify(e),from:e=>{try{let t=JSON.parse(e);if(typeof t==`object`&&t&&`_tag`in t){let{_tag:e,...n}=t;return n}return t}catch{return null}}}}function g(e,t,n){let r=h(e),i={json:n=>{let i=d(t,{...n,_tag:e},e);if(i._tag===`Err`)return o(m(`ValidationError`,`Cannot encode invalid data: ${i.error.issues.map(e=>e.message).join(`, `)}`,void 0,i.error.issues));try{return a(r.to(i.value))}catch(e){return o(m(`EncodingError`,`JSON encoding failed: ${e instanceof Error?e.message:String(e)}`,e))}}};if(n)for(let[r,s]of Object.entries(n))i[r]=n=>{let i=d(t,{...n,_tag:e},e);if(i._tag===`Err`)return o(m(`ValidationError`,`Cannot encode invalid data: ${i.error.issues.map(e=>e.message).join(`, `)}`,void 0,i.error.issues));try{return a(s.to(i.value))}catch(e){return o(m(`EncodingError`,`Encoding with codec '${r}' failed: ${e instanceof Error?e.message:String(e)}`,e))}};return i}function _(e,t,n){let r=h(e),i={json:n=>{let i=r.from(n);if(i===null)return o(m(`DecodingError`,`Invalid JSON format`));let s=d(t,{...i,_tag:e},e);return s._tag===`Err`?o(m(`ValidationError`,`Decoded data failed schema validation`,void 0,s.error.issues)):a({...s.value,_tag:e})}};if(n)for(let[r,s]of Object.entries(n))i[r]=n=>{let i;try{i=s.from(n)}catch(e){return o(m(`DecodingError`,`Decoding with codec '${r}' threw an error`,e))}if(i===null)return o(m(`DecodingError`,`Codec '${r}' failed to decode input`));let c=d(t,{...i,_tag:e},e);return c._tag===`Err`?o(m(`ValidationError`,`Decoded data failed schema validation`,void 0,c.error.issues)):a({...c.value,_tag:e})};return i}function v(e,n,i){let s=f(e),c=g(e,n,i),l=_(e,n,i),u=r(e),p=t(e),m=t=>{let r=d(n,{...t,_tag:e},e);return r._tag===`Err`?o(r.error):a({...r.value,_tag:e})};return m._variant=!0,m._tag=e,m.schema=n,i&&(m.codecs=i),m.is=s,m.to=c,m.from=l,m.equals=u,m.hash=p,m}function y(e,t){let r=Object.keys(t),a={};for(let[e,n]of Object.entries(t))u(n)?n._tag===e?a[e]=n:n.codecs?a[e]=v(e,n.schema,n.codecs):a[e]=v(e,n.schema):a[e]=v(e,n);return{_name:e,is:p(r),equals:i(r),hash:n(r),...a}}var b=e({match:()=>C,union:()=>x,variant:()=>S});const x=y,S=v,C=c;export{b as t};
|
|
2
|
+
//# sourceMappingURL=adt-CPG_sa8q.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adt-CzdkjlUM.mjs","names":["match","validateSchemaSync","variant","union","variant","unionImpl","variantImpl","matchImpl"],"sources":["../src/adt/adt.match.ts","../src/shared/is-plain-object.ts","../src/adt/adt.utils.ts","../src/adt/adt.codec.ts","../src/adt/adt.variant.ts","../src/adt/adt.union.ts","../src/adt/adt.ts"],"sourcesContent":["/**\n * Handler functions for each variant in a discriminated union.\n * Each key maps to a function that receives the variant value and returns TResult.\n *\n * @template T - The discriminated union type (must have readonly _tag)\n * @template TResult - The return type of all handlers\n */\ntype AdtMatchHandlers<T extends { readonly _tag: string }, TResult> = {\n [K in T[\"_tag\"]]: (value: Extract<T, { readonly _tag: K }>) => TResult\n}\n\n/**\n * Exhaustive pattern matching for discriminated unions.\n *\n * TypeScript will error if any variant is missing from handlers,\n * ensuring exhaustive handling of all cases.\n *\n * @template T - The discriminated union type (must have readonly _tag)\n * @template TResult - The return type of all handlers\n * @template Handlers - The handler object type (inferred)\n * @param value - A discriminated union value with _tag\n * @param handlers - An object with a handler function for each variant\n * @returns The result of calling the matching handler\n *\n * @see {@link union} for creating discriminated unions\n * @see {@link variant} for creating individual variant types\n *\n * @example\n * ```ts\n * import { Adt } from \"@nicolastoulemont/std\"\n * import { z } from \"zod\"\n *\n * // Adt accepts any Standard Schema-compatible schema, such as zod, valibot, or arktype.\n * const Circle = Adt.variant(\"Circle\", z.object({ radius: z.number() }))\n * const Square = Adt.variant(\"Square\", z.object({ size: z.number() }))\n * const Shape = Adt.union(\"Shape\", { Circle, Square })\n * type Shape = Adt.Infer<typeof Shape>\n *\n * function describeShape(shape: Shape): string {\n * return Adt.match(shape, {\n * Circle: (c) => `Circle with radius ${c.radius}`,\n * Square: (s) => `Square with size ${s.size}`,\n * })\n * }\n * ```\n */\nexport function match<\n T extends { readonly _tag: string },\n TResult,\n Handlers extends AdtMatchHandlers<T, TResult> = AdtMatchHandlers<T, TResult>,\n>(value: T, handlers: Handlers): TResult {\n const tag = value._tag as keyof Handlers\n const handler = handlers[tag]\n // oxlint-disable-next-line no-explicit-any, no-unsafe-argument, no-unsafe-type-assertion -- Required for variant dispatch\n return handler(value as any)\n}\n","/**\n * Check if a value is a plain object.\n * A plain object is an object created with `{}`, `Object.create(null)`, or `new Object()`.\n * Arrays, functions, dates, maps, etc. are not considered plain objects.\n */\nexport function isPlainObject(value: unknown): value is Record<PropertyKey, unknown> {\n if (value === null || typeof value !== \"object\") {\n return false\n }\n\n return Object.getPrototypeOf(value) === null || Object.getPrototypeOf(value) === Object.prototype\n}\n","import { validateSync as validateSchemaSync } from \"../schema/schema.shared\"\nimport { isPlainObject } from \"../shared/is-plain-object\"\nimport type { AdtVariant } from \"./adt.types\"\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\"\n\n/**\n * Check if a value is an AdtVariant created by variant().\n * AdtVariants are callable functions with static properties.\n */\nexport function isVariant(value: unknown): value is AdtVariant {\n return typeof value === \"function\" && \"_variant\" in value && value[\"_variant\"] === true\n}\n\n/**\n * Validate data using a Standard Schema, enforcing sync-only validation.\n * Throws if the schema returns a Promise.\n */\nexport function validateSync<T>(schema: StandardSchemaV1<unknown, T>, data: unknown, _tag: string) {\n return validateSchemaSync(schema, data, `ADT variant \"${_tag}\"`)\n}\n\n/**\n * Create a type guard function for a specific _tag.\n */\nexport function createIsGuard<Tag extends string, T>(\n _tag: Tag,\n): (value: unknown) => value is T & { readonly _tag: Tag } {\n return (value: unknown): value is T & { readonly _tag: Tag } => {\n return isPlainObject(value) && \"_tag\" in value && value[\"_tag\"] === _tag\n }\n}\n\n/**\n * Create a type guard function for multiple _tags (AdtUnion root guard).\n */\nexport function createIsAnyGuard<T>(_tags: readonly string[]): (value: unknown) => value is T {\n const _tagSet = new Set(_tags)\n return (value: unknown): value is T => {\n return isPlainObject(value) && \"_tag\" in value && typeof value[\"_tag\"] === \"string\" && _tagSet.has(value[\"_tag\"])\n }\n}\n","import { ok, err } from \"../result/result\"\nimport type { Result } from \"../result/result.types\"\nimport type { ValidationError } from \"../schema/schema.types\"\nimport type { Discriminator } from \"../shared/discriminator.types\"\nimport type {\n AdtCodecConstraint,\n AdtCodecDef,\n AdtCodecError,\n AdtInferInput,\n AdtInferOutput,\n ToMethods,\n FromMethods,\n} from \"./adt.types\"\nimport { validateSync } from \"./adt.utils\"\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\"\n\n/**\n * Create a AdtCodecError with consistent structure.\n */\nfunction createCodecError(\n kind: AdtCodecError[\"kind\"],\n message: string,\n cause?: unknown,\n validationIssues?: ValidationError[\"issues\"],\n): AdtCodecError {\n if (cause !== undefined && validationIssues !== undefined) {\n return { kind, message, cause, validationIssues }\n }\n if (cause !== undefined) {\n return { kind, message, cause }\n }\n if (validationIssues !== undefined) {\n return { kind, message, validationIssues }\n }\n return { kind, message }\n}\n\n/**\n * Built-in JSON codec that works with any schema.\n * Encodes to JSON string and decodes with JSON.parse.\n */\nfunction createJsonCodec<Tag extends string, S extends StandardSchemaV1>(\n _tag: Tag,\n): AdtCodecDef<AdtInferOutput<S> & Discriminator<Tag>, string, AdtInferInput<S>> {\n return {\n to: (value) => {\n // JSON.stringify can throw for circular references, BigInt, etc.\n // We let it throw and catch it in the wrapper\n return JSON.stringify(value)\n },\n /* oxlint-disable no-unsafe-assignment, no-unsafe-type-assertion, no-unsafe-return -- Required for JSON parsing which returns unknown types */\n from: (input: string) => {\n try {\n const parsed = JSON.parse(input)\n // Return parsed object without _tag - it will be added during validation\n if (typeof parsed === \"object\" && parsed !== null && \"_tag\" in parsed) {\n const { _tag: _, ...rest } = parsed\n return rest as AdtInferInput<S>\n }\n return parsed\n } catch {\n return null\n }\n },\n /* oxlint-enable no-unsafe-assignment, no-unsafe-type-assertion, no-unsafe-return */\n }\n}\n\n/**\n * Create the \"to\" methods object with JSON codec and custom codecs.\n * All methods return Result<T, AdtCodecError> for consistent error handling.\n */\nexport function createToMethods<\n Tag extends string,\n S extends StandardSchemaV1,\n Codecs extends AdtCodecConstraint<Tag, S> | undefined = undefined,\n>(_tag: Tag, schema: S, customCodecs?: Codecs): ToMethods<S, Codecs> {\n type Output = AdtInferOutput<S> & Discriminator<Tag>\n\n const jsonCodec = createJsonCodec<Tag, S>(_tag)\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const to: Record<string, (value: AdtInferInput<S>) => Result<any, AdtCodecError>> = {\n json: (value: AdtInferInput<S>): Result<string, AdtCodecError> => {\n // First, create a validated variant to ensure the encoded payload is well-typed.\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for spreading generic input into object\n const taggedInput = { ...(value as object), _tag }\n const result = validateSync(schema, taggedInput, _tag)\n\n if (result._tag === \"Err\") {\n return err(\n createCodecError(\n \"ValidationError\",\n `Cannot encode invalid data: ${result.error.issues.map((i) => i.message).join(\", \")}`,\n undefined,\n result.error.issues,\n ),\n )\n }\n\n try {\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for validated value cast\n return ok(jsonCodec.to(result.value as Output))\n } catch (e) {\n return err(\n createCodecError(\"EncodingError\", `JSON encoding failed: ${e instanceof Error ? e.message : String(e)}`, e),\n )\n }\n },\n }\n\n // Add custom codecs\n if (customCodecs) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n for (const [name, codec] of Object.entries(customCodecs) as Array<[string, AdtCodecDef<Output, any, any>]>) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n to[name] = (value: AdtInferInput<S>): Result<any, AdtCodecError> => {\n // Validate input first\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for spreading generic input\n const taggedInput = { ...(value as object), _tag }\n const result = validateSync(schema, taggedInput, _tag)\n\n if (result._tag === \"Err\") {\n return err(\n createCodecError(\n \"ValidationError\",\n `Cannot encode invalid data: ${result.error.issues.map((i) => i.message).join(\", \")}`,\n undefined,\n result.error.issues,\n ),\n )\n }\n\n try {\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for validated value cast\n return ok(codec.to(result.value as Output))\n } catch (e) {\n return err(\n createCodecError(\n \"EncodingError\",\n `Encoding with codec '${name}' failed: ${e instanceof Error ? e.message : String(e)}`,\n e,\n ),\n )\n }\n }\n }\n }\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for generic return type\n return to as ToMethods<S, Codecs>\n}\n\n/**\n * Create the \"from\" methods object with JSON codec and custom codecs.\n * All methods return Result<T, AdtCodecError> for consistent error handling.\n */\nexport function createFromMethods<\n Tag extends string,\n S extends StandardSchemaV1,\n Codecs extends AdtCodecConstraint<Tag, S> | undefined = undefined,\n>(_tag: Tag, schema: S, customCodecs?: Codecs): FromMethods<Tag, S, Codecs> {\n type Output = AdtInferOutput<S> & Discriminator<Tag>\n\n const jsonCodec = createJsonCodec<Tag, S>(_tag)\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const from: Record<string, (input: any) => Result<Output, AdtCodecError>> = {\n json: (input: string): Result<Output, AdtCodecError> => {\n // Decode\n const decoded = jsonCodec.from(input)\n if (decoded === null) {\n return err(createCodecError(\"DecodingError\", \"Invalid JSON format\"))\n }\n\n // Validate through schema\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for spreading decoded value\n const taggedInput = { ...(decoded as object), _tag }\n const result = validateSync(schema, taggedInput, _tag)\n\n if (result._tag === \"Err\") {\n return err(\n createCodecError(\"ValidationError\", \"Decoded data failed schema validation\", undefined, result.error.issues),\n )\n }\n\n // Ensure _tag in output\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for output construction\n const output = { ...(result.value as object), _tag } as Output\n return ok(output)\n },\n }\n\n // Add custom codecs\n if (customCodecs) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n for (const [name, codec] of Object.entries(customCodecs) as Array<[string, AdtCodecDef<Output, any, any>]>) {\n from[name] = (input: unknown): Result<Output, AdtCodecError> => {\n // Decode\n let decoded: unknown\n try {\n decoded = codec.from(input)\n } catch (e) {\n return err(createCodecError(\"DecodingError\", `Decoding with codec '${name}' threw an error`, e))\n }\n\n if (decoded === null) {\n return err(createCodecError(\"DecodingError\", `Codec '${name}' failed to decode input`))\n }\n\n // Validate through schema\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for spreading decoded value\n const taggedInput = { ...(decoded as object), _tag }\n const result = validateSync(schema, taggedInput, _tag)\n\n if (result._tag === \"Err\") {\n return err(\n createCodecError(\n \"ValidationError\",\n \"Decoded data failed schema validation\",\n undefined,\n result.error.issues,\n ),\n )\n }\n\n // Ensure _tag in output\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for output construction\n const output = { ...(result.value as object), _tag } as Output\n return ok(output)\n }\n }\n }\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for generic return type\n return from as FromMethods<Tag, S, Codecs>\n}\n","import { createEqualsMethod, createHashMethod } from \"../equality/equality\"\nimport { ok, err } from \"../result/result\"\nimport type { Result } from \"../result/result.types\"\nimport type { ValidationError } from \"../schema/schema.types\"\nimport type { Discriminator } from \"../shared/discriminator.types\"\nimport { createToMethods, createFromMethods } from \"./adt.codec\"\nimport type { AdtCodecConstraint, AdtInferInput, AdtInferOutput, AdtVariant } from \"./adt.types\"\nimport { createIsGuard, validateSync } from \"./adt.utils\"\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\"\n\n/**\n * Create a standalone tagged variant from a Standard Schema with optional codecs.\n *\n * Variants can be used independently or composed into an AdtUnion via union().\n * All defaults should be defined at the schema level (e.g., Zod's .default()).\n *\n * @template Tag - The string literal type for the _tag discriminator\n * @template S - The Standard Schema type for validation\n * @template Codecs - Optional codec definitions for custom serialization formats\n * @param _tag - The _tag discriminator value\n * @param schema - A Standard Schema compliant validator\n * @param codecs - Optional codec definitions for custom serialization formats\n * @returns A callable AdtVariant with is(), to, and from methods\n *\n * @see {@link union} for composing variants into discriminated unions\n * @see {@link tagged} for unvalidated tagged value constructors\n *\n * @example\n * ```ts\n * const CircleSchema = z.object({\n * radius: z.number().positive(),\n * color: z.string().default('blue')\n * })\n *\n * // Basic variant with JSON codec (always included)\n * const Circle = variant('Circle', CircleSchema)\n *\n * const result = Circle({ radius: 10 })\n * // { _tag: \"Ok\", value: { _tag: \"Circle\", radius: 10, color: \"blue\" } }\n *\n * Circle.is(someValue) // type guard\n *\n * const json = Circle.to.json({ radius: 10 }) // JSON string\n * const result2 = Circle.from.json(json) // Result<Circle, AdtCodecError>\n *\n * // Variant with custom codec\n * const Circle2 = variant('Circle', CircleSchema, {\n * graphic: {\n * to: (circle) => `(${circle.radius})`,\n * from: (input: string) => {\n * const match = input.match(/^\\((\\d+)\\)$/)\n * return match ? { radius: parseInt(match[1]!) } : null\n * }\n * }\n * })\n *\n * const graphic = Circle2.to.graphic({ radius: 10 }) // \"(10)\"\n * const result3 = Circle2.from.graphic(\"(10)\") // Result<Circle, AdtCodecError>\n * ```\n */\n// Overload: with codecs\nexport function variant<Tag extends string, S extends StandardSchemaV1, Codecs extends AdtCodecConstraint<Tag, S>>(\n _tag: Tag,\n schema: S,\n codecs: Codecs,\n): AdtVariant<Tag, S, Codecs>\n\n// Overload: without codecs\nexport function variant<Tag extends string, S extends StandardSchemaV1>(_tag: Tag, schema: S): AdtVariant<Tag, S>\n\n// Implementation\nexport function variant<\n Tag extends string,\n S extends StandardSchemaV1,\n Codecs extends AdtCodecConstraint<Tag, S> | undefined,\n>(_tag: Tag, schema: S, codecs?: Codecs): AdtVariant<Tag, S, Codecs> {\n type Output = AdtInferOutput<S> & Discriminator<Tag>\n\n const isGuard = createIsGuard<Tag, Output>(_tag)\n const to = createToMethods(_tag, schema, codecs)\n const from = createFromMethods(_tag, schema, codecs)\n const equals = createEqualsMethod<Tag, AdtInferOutput<S>>(_tag)\n const hash = createHashMethod<Tag, AdtInferOutput<S>>(_tag)\n\n // Constructor function\n const constructor = (input: AdtInferInput<S>): Result<Output, ValidationError> => {\n // Add _tag to the input before validation\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for spreading generic input\n const taggedInput = { ...(input as object), _tag }\n\n // Validate using the schema\n const result = validateSync(schema, taggedInput, _tag)\n\n if (result._tag === \"Err\") {\n return err(result.error)\n }\n\n // Ensure _tag is in the output (schema might strip unknown keys)\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for output construction\n const output = { ...(result.value as object), _tag } as Output\n return ok(output)\n }\n\n // Attach static properties to constructor function\n constructor._variant = true as const\n constructor._tag = _tag\n constructor.schema = schema\n if (codecs) {\n // oxlint-disable-next-line no-unsafe-type-assertion -- Conditional assignment of codecs\n ;(constructor as { codecs?: Codecs }).codecs = codecs\n }\n constructor.is = isGuard\n constructor.to = to\n constructor.from = from\n constructor.equals = equals\n constructor.hash = hash\n\n return constructor as AdtVariant<Tag, S, Codecs>\n}\n","import { createADTEqualsMethod, createADTHashMethod } from \"../equality/equality\"\nimport type { AdtUnion, AdtVariantDef, AdtVariant } from \"./adt.types\"\nimport { createIsAnyGuard, isVariant } from \"./adt.utils\"\nimport { variant } from \"./adt.variant\"\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\"\n\n/**\n * Compose records or schemas into a discriminated union (AdtUnion).\n *\n * Accepts either:\n * - Pre-built AdtVariants from variant() (codecs are preserved)\n * - Raw Standard Schema validators (will be wrapped internally)\n *\n * When using pre-built records, the object key overrides the original _tag.\n *\n * @template R - Record of variant names to AdtVariants or StandardSchema validators\n * @param name - The name of this AdtUnion (for identification)\n * @param records - An object mapping _tag names to AdtVariants or schemas\n * @returns An AdtUnion object with accessors for each variant\n *\n * @see {@link variant} for creating individual variant types\n * @see {@link match} for exhaustive pattern matching on AdtUnion values\n *\n * @example\n * ```ts\n * // From pre-built variants\n * const Circle = variant('Circle', CircleSchema)\n * const Square = variant('Square', SquareSchema)\n * const Shape = union('Shape', { Circle, Square })\n *\n * // From raw schemas (JSON codec is automatically included)\n * const Shape = union('Shape', {\n * Circle: CircleSchema,\n * Square: SquareSchema\n * })\n *\n * // JSON codec works on all variants\n * Shape.Circle.to.json({ radius: 10 })\n * Shape.Circle.from.json(jsonString)\n *\n * // Mixed\n * const Shape = union('Shape', {\n * Circle, // Pre-built variant\n * Square: SquareSchema // Raw schema\n * })\n *\n * // Usage\n * Shape.Circle({ radius: 10 })\n * Shape.is(someValue) // type guard for any variant\n * Shape.Circle.is(someValue) // type guard for Circle\n * ```\n */\nexport function union<R extends Record<string, AdtVariantDef>>(name: string, records: R): AdtUnion<R> {\n const tags = Object.keys(records)\n const variants: Record<string, AdtVariant> = {}\n\n for (const [_tag, def] of Object.entries(records)) {\n if (isVariant(def)) {\n // Pre-built AdtVariant - key overrides original _tag\n if (def._tag === _tag) {\n // _tag matches key, use as-is (preserves codecs)\n variants[_tag] = def\n // oxlint-disable-next-line strict-boolean-expressions -- codecs can be undefined\n } else if (def.codecs) {\n // _tag differs from key - create new variant with key as _tag\n // Preserve codecs\n variants[_tag] = variant(_tag, def.schema, def.codecs)\n } else {\n // _tag differs from key and no codecs\n variants[_tag] = variant(_tag, def.schema)\n }\n } else {\n // Raw schema - wrap in variant\n // Note: Even without custom codecs, this still gets JSON codec!\n // oxlint-disable-next-line no-unsafe-type-assertion -- def is a StandardSchemaV1 in this branch\n variants[_tag] = variant(_tag, def as StandardSchemaV1)\n }\n }\n\n // Create the root type guard for any variant\n const isAnyVariant = createIsAnyGuard(tags)\n const equals = createADTEqualsMethod(tags)\n const hash = createADTHashMethod(tags)\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for generic AdtUnion return type\n return {\n _name: name,\n is: isAnyVariant,\n equals,\n hash,\n ...variants,\n } as AdtUnion<R>\n}\n","/**\n * Tagged union builders and match helpers.\n *\n * **Mental model**\n * - `Adt` helps build discriminated unions with runtime validation.\n * - Use `union`, `variant`, and `match` to model algebraic data types.\n *\n * **Common tasks**\n * - Define variants with `Adt.variant`.\n * - Combine variants with `Adt.union`.\n * - Pattern-match with `Adt.match`.\n *\n * **Gotchas**\n * - `Adt` codec/type helpers are mostly type-level.\n * - Prefer namespace imports from `@nicolastoulemont/std`.\n *\n * **Quickstart**\n *\n * @example\n * ```ts\n * import { Adt } from \"@nicolastoulemont/std\"\n * import { z } from \"zod\"\n *\n * // Adt accepts any Standard Schema-compatible schema, such as zod, valibot, or arktype.\n * const CircleSchema = z.object({ radius: z.number() })\n *\n * const Shape = Adt.union(\"Shape\", { Circle: CircleSchema })\n * const result = Shape.Circle({ radius: 2 })\n * // => { _tag: \"Ok\", value: { _tag: \"Circle\", radius: 2 } }\n * ```\n *\n * @module\n */\nimport { match as matchImpl } from \"./adt.match\"\nimport type {\n AdtInfer as AdtInferType,\n AdtVariantNames as AdtVariantNamesType,\n AdtVariantOf as AdtVariantOfType,\n} from \"./adt.types\"\nimport { union as unionImpl } from \"./adt.union\"\nimport { variant as variantImpl } from \"./adt.variant\"\n\n/**\n * Re-exported ADT inferred union helper.\n *\n * @example\n * ```ts\n * import { Adt } from \"@nicolastoulemont/std\"\n * import { z } from \"zod\"\n *\n * // Adt accepts any Standard Schema-compatible schema, such as zod, valibot, or arktype.\n * const Shape = Adt.union(\"Shape\", {\n * Circle: z.object({ radius: z.number() }),\n * })\n * type Shape = Adt.Infer<typeof Shape>\n * ```\n */\nexport type Infer<T> = AdtInferType<T>\n\n/**\n * Re-exported union variant name helper.\n *\n * @example\n * ```ts\n * import { Adt } from \"@nicolastoulemont/std\"\n * import { z } from \"zod\"\n *\n * // Adt accepts any Standard Schema-compatible schema, such as zod, valibot, or arktype.\n * const Shape = Adt.union(\"Shape\", {\n * Circle: z.object({ radius: z.number() }),\n * })\n * type Names = Adt.VariantNames<typeof Shape>\n * ```\n */\nexport type VariantNames<T> = AdtVariantNamesType<T>\n\n/**\n * Re-exported helper to extract a specific variant from an ADT.\n *\n * @example\n * ```ts\n * import { Adt } from \"@nicolastoulemont/std\"\n * import { z } from \"zod\"\n *\n * // Adt accepts any Standard Schema-compatible schema, such as zod, valibot, or arktype.\n * const Shape = Adt.union(\"Shape\", {\n * Circle: z.object({ radius: z.number() }),\n * })\n * type Circle = Adt.VariantOf<typeof Shape, \"Circle\">\n * ```\n */\nexport type VariantOf<T, K extends string> = AdtVariantOfType<T, K>\n\n/**\n * Build an ADT union from named variants.\n *\n * @example\n * ```ts\n * import { Adt } from \"@nicolastoulemont/std\"\n * import { z } from \"zod\"\n *\n * // Adt accepts any Standard Schema-compatible schema, such as zod, valibot, or arktype.\n * const CircleSchema = z.object({ radius: z.number() })\n *\n * const Shape = Adt.union(\"Shape\", { Circle: CircleSchema })\n * const result = Shape.Circle({ radius: 2 })\n * // => { _tag: \"Ok\", value: { _tag: \"Circle\", radius: 2 } }\n * ```\n */\nexport const union = unionImpl\n\n/**\n * Define one ADT variant with schema-backed validation.\n *\n * @example\n * ```ts\n * import { Adt } from \"@nicolastoulemont/std\"\n * import { z } from \"zod\"\n *\n * // Adt accepts any Standard Schema-compatible schema, such as zod, valibot, or arktype.\n * const CircleSchema = z.object({ radius: z.number() })\n *\n * const Circle = Adt.variant(\"Circle\", CircleSchema)\n * const result = Circle({ radius: 2 })\n * // => { _tag: \"Ok\", value: { _tag: \"Circle\", radius: 2 } }\n * ```\n */\nexport const variant = variantImpl\n\n/**\n * Match over ADT variants by discriminator tag.\n *\n * @example\n * ```ts\n * import { Adt } from \"@nicolastoulemont/std\"\n *\n * const label = Adt.match({ _tag: \"Circle\", radius: 2 } as const, {\n * Circle: (circle) => `r=${circle.radius}` ,\n * })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EAAY,GAAK,EACjB,EAAY,KAAO,EACnB,EAAY,OAAS,EACrB,EAAY,KAAO,EAEZ,ECjET,SAAgBC,EAA+C,EAAc,EAAyB,CACpG,IAAM,EAAO,OAAO,KAAK,EAAQ,CAC3B,EAAuC,EAAE,CAE/C,IAAK,GAAM,CAAC,EAAM,KAAQ,OAAO,QAAQ,EAAQ,CAC3C,EAAU,EAAI,CAEZ,EAAI,OAAS,EAEf,EAAS,GAAQ,EAER,EAAI,OAGb,EAAS,GAAQC,EAAQ,EAAM,EAAI,OAAQ,EAAI,OAAO,CAGtD,EAAS,GAAQA,EAAQ,EAAM,EAAI,OAAO,CAM5C,EAAS,GAAQA,EAAQ,EAAM,EAAwB,CAU3D,MAAO,CACL,MAAO,EACP,GAPmB,EAAiB,EAAK,CAQzC,OAPa,EAAsB,EAAK,CAQxC,KAPW,EAAoB,EAAK,CAQpC,GAAG,EACJ,kDCkBH,MAAa,EAAQC,EAkBR,EAAUC,EAeV,EAAQC"}
|
|
1
|
+
{"version":3,"file":"adt-CPG_sa8q.mjs","names":["match","validateSchemaSync","variant","union","variant","unionImpl","variantImpl","matchImpl"],"sources":["../src/adt/adt.match.ts","../src/shared/is-plain-object.ts","../src/adt/adt.utils.ts","../src/adt/adt.codec.ts","../src/adt/adt.variant.ts","../src/adt/adt.union.ts","../src/adt/adt.ts"],"sourcesContent":["/**\n * Handler functions for each variant in a discriminated union.\n * Each key maps to a function that receives the variant value and returns TResult.\n *\n * @template T - The discriminated union type (must have readonly _tag)\n * @template TResult - The return type of all handlers\n */\ntype AdtMatchHandlers<T extends { readonly _tag: string }, TResult> = {\n [K in T[\"_tag\"]]: (value: Extract<T, { readonly _tag: K }>) => TResult\n}\n\n/**\n * Exhaustive pattern matching for discriminated unions.\n *\n * TypeScript will error if any variant is missing from handlers,\n * ensuring exhaustive handling of all cases.\n *\n * @template T - The discriminated union type (must have readonly _tag)\n * @template TResult - The return type of all handlers\n * @template Handlers - The handler object type (inferred)\n * @param value - A discriminated union value with _tag\n * @param handlers - An object with a handler function for each variant\n * @returns The result of calling the matching handler\n *\n * @see {@link union} for creating discriminated unions\n * @see {@link variant} for creating individual variant types\n *\n * @example\n * ```ts\n * import { Adt } from \"@nicolastoulemont/std\"\n * import { z } from \"zod\"\n *\n * // Adt accepts any Standard Schema-compatible schema, such as zod, valibot, or arktype.\n * const Circle = Adt.variant(\"Circle\", z.object({ radius: z.number() }))\n * const Square = Adt.variant(\"Square\", z.object({ size: z.number() }))\n * const Shape = Adt.union(\"Shape\", { Circle, Square })\n * type Shape = Adt.Infer<typeof Shape>\n *\n * function describeShape(shape: Shape): string {\n * return Adt.match(shape, {\n * Circle: (c) => `Circle with radius ${c.radius}`,\n * Square: (s) => `Square with size ${s.size}`,\n * })\n * }\n * ```\n */\nexport function match<\n T extends { readonly _tag: string },\n TResult,\n Handlers extends AdtMatchHandlers<T, TResult> = AdtMatchHandlers<T, TResult>,\n>(value: T, handlers: Handlers): TResult {\n const tag = value._tag as keyof Handlers\n const handler = handlers[tag]\n // oxlint-disable-next-line no-explicit-any, no-unsafe-argument, no-unsafe-type-assertion -- Required for variant dispatch\n return handler(value as any)\n}\n","/**\n * Check if a value is a plain object.\n * A plain object is an object created with `{}`, `Object.create(null)`, or `new Object()`.\n * Arrays, functions, dates, maps, etc. are not considered plain objects.\n */\nexport function isPlainObject(value: unknown): value is Record<PropertyKey, unknown> {\n if (value === null || typeof value !== \"object\") {\n return false\n }\n\n return Object.getPrototypeOf(value) === null || Object.getPrototypeOf(value) === Object.prototype\n}\n","import { validateSync as validateSchemaSync } from \"../schema/schema.shared\"\nimport { isPlainObject } from \"../shared/is-plain-object\"\nimport type { AdtVariant } from \"./adt.types\"\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\"\n\n/**\n * Check if a value is an AdtVariant created by variant().\n * AdtVariants are callable functions with static properties.\n */\nexport function isVariant(value: unknown): value is AdtVariant {\n return typeof value === \"function\" && \"_variant\" in value && value[\"_variant\"] === true\n}\n\n/**\n * Validate data using a Standard Schema, enforcing sync-only validation.\n * Throws if the schema returns a Promise.\n */\nexport function validateSync<T>(schema: StandardSchemaV1<unknown, T>, data: unknown, _tag: string) {\n return validateSchemaSync(schema, data, `ADT variant \"${_tag}\"`)\n}\n\n/**\n * Create a type guard function for a specific _tag.\n */\nexport function createIsGuard<Tag extends string, T>(\n _tag: Tag,\n): (value: unknown) => value is T & { readonly _tag: Tag } {\n return (value: unknown): value is T & { readonly _tag: Tag } => {\n return isPlainObject(value) && \"_tag\" in value && value[\"_tag\"] === _tag\n }\n}\n\n/**\n * Create a type guard function for multiple _tags (AdtUnion root guard).\n */\nexport function createIsAnyGuard<T>(_tags: readonly string[]): (value: unknown) => value is T {\n const _tagSet = new Set(_tags)\n return (value: unknown): value is T => {\n return isPlainObject(value) && \"_tag\" in value && typeof value[\"_tag\"] === \"string\" && _tagSet.has(value[\"_tag\"])\n }\n}\n","import { ok, err } from \"../result/result\"\nimport type { Result } from \"../result/result.types\"\nimport type { ValidationError } from \"../schema/schema.types\"\nimport type { Discriminator } from \"../shared/discriminator.types\"\nimport type {\n AdtCodecConstraint,\n AdtCodecDef,\n AdtCodecError,\n AdtInferInput,\n AdtInferOutput,\n ToMethods,\n FromMethods,\n} from \"./adt.types\"\nimport { validateSync } from \"./adt.utils\"\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\"\n\n/**\n * Create a AdtCodecError with consistent structure.\n */\nfunction createCodecError(\n kind: AdtCodecError[\"kind\"],\n message: string,\n cause?: unknown,\n validationIssues?: ValidationError[\"issues\"],\n): AdtCodecError {\n if (cause !== undefined && validationIssues !== undefined) {\n return { kind, message, cause, validationIssues }\n }\n if (cause !== undefined) {\n return { kind, message, cause }\n }\n if (validationIssues !== undefined) {\n return { kind, message, validationIssues }\n }\n return { kind, message }\n}\n\n/**\n * Built-in JSON codec that works with any schema.\n * Encodes to JSON string and decodes with JSON.parse.\n */\nfunction createJsonCodec<Tag extends string, S extends StandardSchemaV1>(\n _tag: Tag,\n): AdtCodecDef<AdtInferOutput<S> & Discriminator<Tag>, string, AdtInferInput<S>> {\n return {\n to: (value) => {\n // JSON.stringify can throw for circular references, BigInt, etc.\n // We let it throw and catch it in the wrapper\n return JSON.stringify(value)\n },\n /* oxlint-disable no-unsafe-assignment, no-unsafe-type-assertion, no-unsafe-return -- Required for JSON parsing which returns unknown types */\n from: (input: string) => {\n try {\n const parsed = JSON.parse(input)\n // Return parsed object without _tag - it will be added during validation\n if (typeof parsed === \"object\" && parsed !== null && \"_tag\" in parsed) {\n const { _tag: _, ...rest } = parsed\n return rest as AdtInferInput<S>\n }\n return parsed\n } catch {\n return null\n }\n },\n /* oxlint-enable no-unsafe-assignment, no-unsafe-type-assertion, no-unsafe-return */\n }\n}\n\n/**\n * Create the \"to\" methods object with JSON codec and custom codecs.\n * All methods return Result<T, AdtCodecError> for consistent error handling.\n */\nexport function createToMethods<\n Tag extends string,\n S extends StandardSchemaV1,\n Codecs extends AdtCodecConstraint<Tag, S> | undefined = undefined,\n>(_tag: Tag, schema: S, customCodecs?: Codecs): ToMethods<S, Codecs> {\n type Output = AdtInferOutput<S> & Discriminator<Tag>\n\n const jsonCodec = createJsonCodec<Tag, S>(_tag)\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const to: Record<string, (value: AdtInferInput<S>) => Result<any, AdtCodecError>> = {\n json: (value: AdtInferInput<S>): Result<string, AdtCodecError> => {\n // First, create a validated variant to ensure the encoded payload is well-typed.\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for spreading generic input into object\n const taggedInput = { ...(value as object), _tag }\n const result = validateSync(schema, taggedInput, _tag)\n\n if (result._tag === \"Err\") {\n return err(\n createCodecError(\n \"ValidationError\",\n `Cannot encode invalid data: ${result.error.issues.map((i) => i.message).join(\", \")}`,\n undefined,\n result.error.issues,\n ),\n )\n }\n\n try {\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for validated value cast\n return ok(jsonCodec.to(result.value as Output))\n } catch (e) {\n return err(\n createCodecError(\"EncodingError\", `JSON encoding failed: ${e instanceof Error ? e.message : String(e)}`, e),\n )\n }\n },\n }\n\n // Add custom codecs\n if (customCodecs) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n for (const [name, codec] of Object.entries(customCodecs) as Array<[string, AdtCodecDef<Output, any, any>]>) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n to[name] = (value: AdtInferInput<S>): Result<any, AdtCodecError> => {\n // Validate input first\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for spreading generic input\n const taggedInput = { ...(value as object), _tag }\n const result = validateSync(schema, taggedInput, _tag)\n\n if (result._tag === \"Err\") {\n return err(\n createCodecError(\n \"ValidationError\",\n `Cannot encode invalid data: ${result.error.issues.map((i) => i.message).join(\", \")}`,\n undefined,\n result.error.issues,\n ),\n )\n }\n\n try {\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for validated value cast\n return ok(codec.to(result.value as Output))\n } catch (e) {\n return err(\n createCodecError(\n \"EncodingError\",\n `Encoding with codec '${name}' failed: ${e instanceof Error ? e.message : String(e)}`,\n e,\n ),\n )\n }\n }\n }\n }\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for generic return type\n return to as ToMethods<S, Codecs>\n}\n\n/**\n * Create the \"from\" methods object with JSON codec and custom codecs.\n * All methods return Result<T, AdtCodecError> for consistent error handling.\n */\nexport function createFromMethods<\n Tag extends string,\n S extends StandardSchemaV1,\n Codecs extends AdtCodecConstraint<Tag, S> | undefined = undefined,\n>(_tag: Tag, schema: S, customCodecs?: Codecs): FromMethods<Tag, S, Codecs> {\n type Output = AdtInferOutput<S> & Discriminator<Tag>\n\n const jsonCodec = createJsonCodec<Tag, S>(_tag)\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const from: Record<string, (input: any) => Result<Output, AdtCodecError>> = {\n json: (input: string): Result<Output, AdtCodecError> => {\n // Decode\n const decoded = jsonCodec.from(input)\n if (decoded === null) {\n return err(createCodecError(\"DecodingError\", \"Invalid JSON format\"))\n }\n\n // Validate through schema\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for spreading decoded value\n const taggedInput = { ...(decoded as object), _tag }\n const result = validateSync(schema, taggedInput, _tag)\n\n if (result._tag === \"Err\") {\n return err(\n createCodecError(\"ValidationError\", \"Decoded data failed schema validation\", undefined, result.error.issues),\n )\n }\n\n // Ensure _tag in output\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for output construction\n const output = { ...(result.value as object), _tag } as Output\n return ok(output)\n },\n }\n\n // Add custom codecs\n if (customCodecs) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n for (const [name, codec] of Object.entries(customCodecs) as Array<[string, AdtCodecDef<Output, any, any>]>) {\n from[name] = (input: unknown): Result<Output, AdtCodecError> => {\n // Decode\n let decoded: unknown\n try {\n decoded = codec.from(input)\n } catch (e) {\n return err(createCodecError(\"DecodingError\", `Decoding with codec '${name}' threw an error`, e))\n }\n\n if (decoded === null) {\n return err(createCodecError(\"DecodingError\", `Codec '${name}' failed to decode input`))\n }\n\n // Validate through schema\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for spreading decoded value\n const taggedInput = { ...(decoded as object), _tag }\n const result = validateSync(schema, taggedInput, _tag)\n\n if (result._tag === \"Err\") {\n return err(\n createCodecError(\n \"ValidationError\",\n \"Decoded data failed schema validation\",\n undefined,\n result.error.issues,\n ),\n )\n }\n\n // Ensure _tag in output\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for output construction\n const output = { ...(result.value as object), _tag } as Output\n return ok(output)\n }\n }\n }\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for generic return type\n return from as FromMethods<Tag, S, Codecs>\n}\n","import { createEqualsMethod, createHashMethod } from \"../equality/equality\"\nimport { ok, err } from \"../result/result\"\nimport type { Result } from \"../result/result.types\"\nimport type { ValidationError } from \"../schema/schema.types\"\nimport type { Discriminator } from \"../shared/discriminator.types\"\nimport { createToMethods, createFromMethods } from \"./adt.codec\"\nimport type { AdtCodecConstraint, AdtInferInput, AdtInferOutput, AdtVariant } from \"./adt.types\"\nimport { createIsGuard, validateSync } from \"./adt.utils\"\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\"\n\n/**\n * Create a standalone tagged variant from a Standard Schema with optional codecs.\n *\n * Variants can be used independently or composed into an AdtUnion via union().\n * All defaults should be defined at the schema level (e.g., Zod's .default()).\n *\n * @template Tag - The string literal type for the _tag discriminator\n * @template S - The Standard Schema type for validation\n * @template Codecs - Optional codec definitions for custom serialization formats\n * @param _tag - The _tag discriminator value\n * @param schema - A Standard Schema compliant validator\n * @param codecs - Optional codec definitions for custom serialization formats\n * @returns A callable AdtVariant with is(), to, and from methods\n *\n * @see {@link union} for composing variants into discriminated unions\n * @see {@link tagged} for unvalidated tagged value constructors\n *\n * @example\n * ```ts\n * const CircleSchema = z.object({\n * radius: z.number().positive(),\n * color: z.string().default('blue')\n * })\n *\n * // Basic variant with JSON codec (always included)\n * const Circle = variant('Circle', CircleSchema)\n *\n * const result = Circle({ radius: 10 })\n * // { _tag: \"Ok\", value: { _tag: \"Circle\", radius: 10, color: \"blue\" } }\n *\n * Circle.is(someValue) // type guard\n *\n * const json = Circle.to.json({ radius: 10 }) // JSON string\n * const result2 = Circle.from.json(json) // Result<Circle, AdtCodecError>\n *\n * // Variant with custom codec\n * const Circle2 = variant('Circle', CircleSchema, {\n * graphic: {\n * to: (circle) => `(${circle.radius})`,\n * from: (input: string) => {\n * const match = input.match(/^\\((\\d+)\\)$/)\n * return match ? { radius: parseInt(match[1]!) } : null\n * }\n * }\n * })\n *\n * const graphic = Circle2.to.graphic({ radius: 10 }) // \"(10)\"\n * const result3 = Circle2.from.graphic(\"(10)\") // Result<Circle, AdtCodecError>\n * ```\n */\n// Overload: with codecs\nexport function variant<Tag extends string, S extends StandardSchemaV1, Codecs extends AdtCodecConstraint<Tag, S>>(\n _tag: Tag,\n schema: S,\n codecs: Codecs,\n): AdtVariant<Tag, S, Codecs>\n\n// Overload: without codecs\nexport function variant<Tag extends string, S extends StandardSchemaV1>(_tag: Tag, schema: S): AdtVariant<Tag, S>\n\n// Implementation\nexport function variant<\n Tag extends string,\n S extends StandardSchemaV1,\n Codecs extends AdtCodecConstraint<Tag, S> | undefined,\n>(_tag: Tag, schema: S, codecs?: Codecs): AdtVariant<Tag, S, Codecs> {\n type Output = AdtInferOutput<S> & Discriminator<Tag>\n\n const isGuard = createIsGuard<Tag, Output>(_tag)\n const to = createToMethods(_tag, schema, codecs)\n const from = createFromMethods(_tag, schema, codecs)\n const equals = createEqualsMethod<Tag, AdtInferOutput<S>>(_tag)\n const hash = createHashMethod<Tag, AdtInferOutput<S>>(_tag)\n\n // Constructor function\n const constructor = (input: AdtInferInput<S>): Result<Output, ValidationError> => {\n // Add _tag to the input before validation\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for spreading generic input\n const taggedInput = { ...(input as object), _tag }\n\n // Validate using the schema\n const result = validateSync(schema, taggedInput, _tag)\n\n if (result._tag === \"Err\") {\n return err(result.error)\n }\n\n // Ensure _tag is in the output (schema might strip unknown keys)\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for output construction\n const output = { ...(result.value as object), _tag } as Output\n return ok(output)\n }\n\n // Attach static properties to constructor function\n constructor._variant = true as const\n constructor._tag = _tag\n constructor.schema = schema\n if (codecs) {\n // oxlint-disable-next-line no-unsafe-type-assertion -- Conditional assignment of codecs\n ;(constructor as { codecs?: Codecs }).codecs = codecs\n }\n constructor.is = isGuard\n constructor.to = to\n constructor.from = from\n constructor.equals = equals\n constructor.hash = hash\n\n return constructor as AdtVariant<Tag, S, Codecs>\n}\n","import { createADTEqualsMethod, createADTHashMethod } from \"../equality/equality\"\nimport type { AdtUnion, AdtVariantDef, AdtVariant } from \"./adt.types\"\nimport { createIsAnyGuard, isVariant } from \"./adt.utils\"\nimport { variant } from \"./adt.variant\"\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\"\n\n/**\n * Compose records or schemas into a discriminated union (AdtUnion).\n *\n * Accepts either:\n * - Pre-built AdtVariants from variant() (codecs are preserved)\n * - Raw Standard Schema validators (will be wrapped internally)\n *\n * When using pre-built records, the object key overrides the original _tag.\n *\n * @template R - Record of variant names to AdtVariants or StandardSchema validators\n * @param name - The name of this AdtUnion (for identification)\n * @param records - An object mapping _tag names to AdtVariants or schemas\n * @returns An AdtUnion object with accessors for each variant\n *\n * @see {@link variant} for creating individual variant types\n * @see {@link match} for exhaustive pattern matching on AdtUnion values\n *\n * @example\n * ```ts\n * // From pre-built variants\n * const Circle = variant('Circle', CircleSchema)\n * const Square = variant('Square', SquareSchema)\n * const Shape = union('Shape', { Circle, Square })\n *\n * // From raw schemas (JSON codec is automatically included)\n * const Shape = union('Shape', {\n * Circle: CircleSchema,\n * Square: SquareSchema\n * })\n *\n * // JSON codec works on all variants\n * Shape.Circle.to.json({ radius: 10 })\n * Shape.Circle.from.json(jsonString)\n *\n * // Mixed\n * const Shape = union('Shape', {\n * Circle, // Pre-built variant\n * Square: SquareSchema // Raw schema\n * })\n *\n * // Usage\n * Shape.Circle({ radius: 10 })\n * Shape.is(someValue) // type guard for any variant\n * Shape.Circle.is(someValue) // type guard for Circle\n * ```\n */\nexport function union<R extends Record<string, AdtVariantDef>>(name: string, records: R): AdtUnion<R> {\n const tags = Object.keys(records)\n const variants: Record<string, AdtVariant> = {}\n\n for (const [_tag, def] of Object.entries(records)) {\n if (isVariant(def)) {\n // Pre-built AdtVariant - key overrides original _tag\n if (def._tag === _tag) {\n // _tag matches key, use as-is (preserves codecs)\n variants[_tag] = def\n // oxlint-disable-next-line strict-boolean-expressions -- codecs can be undefined\n } else if (def.codecs) {\n // _tag differs from key - create new variant with key as _tag\n // Preserve codecs\n variants[_tag] = variant(_tag, def.schema, def.codecs)\n } else {\n // _tag differs from key and no codecs\n variants[_tag] = variant(_tag, def.schema)\n }\n } else {\n // Raw schema - wrap in variant\n // Note: Even without custom codecs, this still gets JSON codec!\n // oxlint-disable-next-line no-unsafe-type-assertion -- def is a StandardSchemaV1 in this branch\n variants[_tag] = variant(_tag, def as StandardSchemaV1)\n }\n }\n\n // Create the root type guard for any variant\n const isAnyVariant = createIsAnyGuard(tags)\n const equals = createADTEqualsMethod(tags)\n const hash = createADTHashMethod(tags)\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for generic AdtUnion return type\n return {\n _name: name,\n is: isAnyVariant,\n equals,\n hash,\n ...variants,\n } as AdtUnion<R>\n}\n","/**\n * Tagged union builders and match helpers.\n *\n * **Mental model**\n * - `Adt` helps build discriminated unions with runtime validation.\n * - Use `union`, `variant`, and `match` to model algebraic data types.\n *\n * **Common tasks**\n * - Define variants with `Adt.variant`.\n * - Combine variants with `Adt.union`.\n * - Pattern-match with `Adt.match`.\n *\n * **Gotchas**\n * - `Adt` codec/type helpers are mostly type-level.\n * - Prefer namespace imports from `@nicolastoulemont/std`.\n *\n * **Quickstart**\n *\n * @example\n * ```ts\n * import { Adt } from \"@nicolastoulemont/std\"\n * import { z } from \"zod\"\n *\n * // Adt accepts any Standard Schema-compatible schema, such as zod, valibot, or arktype.\n * const CircleSchema = z.object({ radius: z.number() })\n *\n * const Shape = Adt.union(\"Shape\", { Circle: CircleSchema })\n * const result = Shape.Circle({ radius: 2 })\n * // => { _tag: \"Ok\", value: { _tag: \"Circle\", radius: 2 } }\n * ```\n *\n * @module\n */\nimport { match as matchImpl } from \"./adt.match\"\nimport type {\n AdtInfer as AdtInferType,\n AdtVariantNames as AdtVariantNamesType,\n AdtVariantOf as AdtVariantOfType,\n} from \"./adt.types\"\nimport { union as unionImpl } from \"./adt.union\"\nimport { variant as variantImpl } from \"./adt.variant\"\n\n/**\n * Re-exported ADT inferred union helper.\n *\n * @example\n * ```ts\n * import { Adt } from \"@nicolastoulemont/std\"\n * import { z } from \"zod\"\n *\n * // Adt accepts any Standard Schema-compatible schema, such as zod, valibot, or arktype.\n * const Shape = Adt.union(\"Shape\", {\n * Circle: z.object({ radius: z.number() }),\n * })\n * type Shape = Adt.Infer<typeof Shape>\n * ```\n */\nexport type Infer<T> = AdtInferType<T>\n\n/**\n * Re-exported union variant name helper.\n *\n * @example\n * ```ts\n * import { Adt } from \"@nicolastoulemont/std\"\n * import { z } from \"zod\"\n *\n * // Adt accepts any Standard Schema-compatible schema, such as zod, valibot, or arktype.\n * const Shape = Adt.union(\"Shape\", {\n * Circle: z.object({ radius: z.number() }),\n * })\n * type Names = Adt.VariantNames<typeof Shape>\n * ```\n */\nexport type VariantNames<T> = AdtVariantNamesType<T>\n\n/**\n * Re-exported helper to extract a specific variant from an ADT.\n *\n * @example\n * ```ts\n * import { Adt } from \"@nicolastoulemont/std\"\n * import { z } from \"zod\"\n *\n * // Adt accepts any Standard Schema-compatible schema, such as zod, valibot, or arktype.\n * const Shape = Adt.union(\"Shape\", {\n * Circle: z.object({ radius: z.number() }),\n * })\n * type Circle = Adt.VariantOf<typeof Shape, \"Circle\">\n * ```\n */\nexport type VariantOf<T, K extends string> = AdtVariantOfType<T, K>\n\n/**\n * Build an ADT union from named variants.\n *\n * @example\n * ```ts\n * import { Adt } from \"@nicolastoulemont/std\"\n * import { z } from \"zod\"\n *\n * // Adt accepts any Standard Schema-compatible schema, such as zod, valibot, or arktype.\n * const CircleSchema = z.object({ radius: z.number() })\n *\n * const Shape = Adt.union(\"Shape\", { Circle: CircleSchema })\n * const result = Shape.Circle({ radius: 2 })\n * // => { _tag: \"Ok\", value: { _tag: \"Circle\", radius: 2 } }\n * ```\n */\nexport const union = unionImpl\n\n/**\n * Define one ADT variant with schema-backed validation.\n *\n * @example\n * ```ts\n * import { Adt } from \"@nicolastoulemont/std\"\n * import { z } from \"zod\"\n *\n * // Adt accepts any Standard Schema-compatible schema, such as zod, valibot, or arktype.\n * const CircleSchema = z.object({ radius: z.number() })\n *\n * const Circle = Adt.variant(\"Circle\", CircleSchema)\n * const result = Circle({ radius: 2 })\n * // => { _tag: \"Ok\", value: { _tag: \"Circle\", radius: 2 } }\n * ```\n */\nexport const variant = variantImpl\n\n/**\n * Match over ADT variants by discriminator tag.\n *\n * @example\n * ```ts\n * import { Adt } from \"@nicolastoulemont/std\"\n *\n * const label = Adt.match({ _tag: \"Circle\", radius: 2 } as const, {\n * Circle: (circle) => `r=${circle.radius}` ,\n * })\n * // => \"r=2\"\n * ```\n */\nexport const match = matchImpl\n"],"mappings":"kMA8CA,SAAgBA,EAId,EAAU,EAA6B,CAEvC,IAAM,EAAU,EADJ,EAAM,MAGlB,OAAO,EAAQ,EAAa,CCjD9B,SAAgB,EAAc,EAAuD,CAKnF,OAJsB,OAAO,GAAU,WAAnC,EACK,GAGF,OAAO,eAAe,EAAM,GAAK,MAAQ,OAAO,eAAe,EAAM,GAAK,OAAO,UCD1F,SAAgB,EAAU,EAAqC,CAC7D,OAAO,OAAO,GAAU,YAAc,aAAc,GAAS,EAAM,WAAgB,GAOrF,SAAgB,EAAgB,EAAsC,EAAe,EAAc,CACjG,OAAOC,EAAmB,EAAQ,EAAM,gBAAgB,EAAK,GAAG,CAMlE,SAAgB,EACd,EACyD,CACzD,MAAQ,IACC,EAAc,EAAM,EAAI,SAAU,GAAS,EAAM,OAAY,EAOxE,SAAgB,EAAoB,EAA0D,CAC5F,IAAM,EAAU,IAAI,IAAI,EAAM,CAC9B,MAAQ,IACC,EAAc,EAAM,EAAI,SAAU,GAAS,OAAO,EAAM,MAAY,UAAY,EAAQ,IAAI,EAAM,KAAQ,CCnBrH,SAAS,EACP,EACA,EACA,EACA,EACe,CAUf,OATI,IAAU,IAAA,IAAa,IAAqB,IAAA,GACvC,CAAE,OAAM,UAAS,QAAO,mBAAkB,CAE/C,IAAU,IAAA,GAGV,IAAqB,IAAA,GAGlB,CAAE,OAAM,UAAS,CAFf,CAAE,OAAM,UAAS,mBAAkB,CAHnC,CAAE,OAAM,UAAS,QAAO,CAYnC,SAAS,EACP,EAC+E,CAC/E,MAAO,CACL,GAAK,GAGI,KAAK,UAAU,EAAM,CAG9B,KAAO,GAAkB,CACvB,GAAI,CACF,IAAM,EAAS,KAAK,MAAM,EAAM,CAEhC,GA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,OAAM,CACnC,EAiBnB,MAbA,GAAY,SAAW,GACvB,EAAY,KAAO,EACnB,EAAY,OAAS,EACjB,IAEA,EAAoC,OAAS,GAEjD,EAAY,GAAK,EACjB,EAAY,GAAK,EACjB,EAAY,KAAO,EACnB,EAAY,OAAS,EACrB,EAAY,KAAO,EAEZ,ECjET,SAAgBC,EAA+C,EAAc,EAAyB,CACpG,IAAM,EAAO,OAAO,KAAK,EAAQ,CAC3B,EAAuC,EAAE,CAE/C,IAAK,GAAM,CAAC,EAAM,KAAQ,OAAO,QAAQ,EAAQ,CAC3C,EAAU,EAAI,CAEZ,EAAI,OAAS,EAEf,EAAS,GAAQ,EAER,EAAI,OAGb,EAAS,GAAQC,EAAQ,EAAM,EAAI,OAAQ,EAAI,OAAO,CAGtD,EAAS,GAAQA,EAAQ,EAAM,EAAI,OAAO,CAM5C,EAAS,GAAQA,EAAQ,EAAM,EAAwB,CAU3D,MAAO,CACL,MAAO,EACP,GAPmB,EAAiB,EAAK,CAQzC,OAPa,EAAsB,EAAK,CAQxC,KAPW,EAAoB,EAAK,CAQpC,GAAG,EACJ,kDCkBH,MAAa,EAAQC,EAkBR,EAAUC,EAeV,EAAQC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { t as Result } from "./result.types-BKzChyWY.mjs";
|
|
2
|
+
import { a as RefinementSchema, c as ValidationError, i as Refine, l as ValidationIssue, n as Input, o as SyncRefinementSchema, r as Output, s as SyncSchema, t as Infer } from "./schema.types-CBEXCwfs.mjs";
|
|
3
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
4
|
+
|
|
5
|
+
//#region src/schema/schema.d.ts
|
|
6
|
+
declare namespace schema_d_exports {
|
|
7
|
+
export { Infer, Input, Is, Output, Refine, RefineFn, RefinementSchema, SyncRefinementSchema, SyncSchema, ValidationError, ValidationIssue, is, parse, refine };
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Create a schema-backed parser.
|
|
11
|
+
*
|
|
12
|
+
* For sync schemas the returned parser is sync.
|
|
13
|
+
* For general Standard Schema values the returned parser is async.
|
|
14
|
+
*/
|
|
15
|
+
declare function parse<S extends SyncSchema>(schema: S): (value: Input<S>) => Result<Output<S>, ValidationError>;
|
|
16
|
+
declare function parse<S extends StandardSchemaV1>(schema: S): (value: Input<S>) => Promise<Result<Output<S>, ValidationError>>;
|
|
17
|
+
/**
|
|
18
|
+
* Create a sync-only schema-backed type guard that preserves the original value shape.
|
|
19
|
+
*
|
|
20
|
+
* Use this when a schema validates only a subset of a broader in-memory value.
|
|
21
|
+
* The narrowed type is `Base & Output<typeof schema>`, not the exact schema output.
|
|
22
|
+
*
|
|
23
|
+
* Supports both data-first and data-last styles:
|
|
24
|
+
* - Data-first: `Schema.refine(value, schema)`
|
|
25
|
+
* - Data-last: `Schema.refine(schema)(value)`
|
|
26
|
+
*
|
|
27
|
+
* Only use this with sync schemas that prove properties already present on the
|
|
28
|
+
* original value. Transforms, defaults, and coercions are not safe here because
|
|
29
|
+
* they can change the schema output without changing the original input value.
|
|
30
|
+
*/
|
|
31
|
+
type RefineFn = {
|
|
32
|
+
<S extends SyncSchema, Base extends Input<S>>(value: Base, schema: S): value is Refine<Base, S>;
|
|
33
|
+
<S extends SyncSchema>(schema: S): <Base extends Input<S>>(value: Base) => value is Refine<Base, S>;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Create a sync-only schema-backed type guard.
|
|
37
|
+
*
|
|
38
|
+
* Unlike `Schema.refine`, this narrows exactly to the schema output.
|
|
39
|
+
*
|
|
40
|
+
* This is intended for refinement schemas where the validated output is a
|
|
41
|
+
* subtype of the input value already in memory.
|
|
42
|
+
*
|
|
43
|
+
* Supports both data-first and data-last styles:
|
|
44
|
+
* - Data-first: `Schema.is(value, schema)`
|
|
45
|
+
* - Data-last: `Schema.is(schema)(value)`
|
|
46
|
+
*/
|
|
47
|
+
type Is = {
|
|
48
|
+
<Base, Sub extends Base>(value: Base, schema: SyncRefinementSchema<Base, Sub>): value is Sub;
|
|
49
|
+
<S extends SyncSchema>(value: unknown, schema: S): value is Output<S>;
|
|
50
|
+
<Base, Sub extends Base>(schema: SyncRefinementSchema<Base, Sub>): (value: Base) => value is Sub;
|
|
51
|
+
<S extends SyncSchema>(schema: S): (value: unknown) => value is Output<S>;
|
|
52
|
+
};
|
|
53
|
+
declare const refine: RefineFn;
|
|
54
|
+
declare const is: Is;
|
|
55
|
+
//#endregion
|
|
56
|
+
export { schema_d_exports as t };
|
|
57
|
+
//# sourceMappingURL=index-B4WfexUL.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-B4WfexUL.d.mts","names":[],"sources":["../src/schema/schema.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;iBAgDgB,gBAAgB,oBAAoB,YAAY,MAAM,OAAO,OAAW,OAAO,IAAI;iBACnF,gBAAgB,0BACtB,YACC,MAAM,OAAO,QAAQ,OAAW,OAAO,IAAI;;;;;;;;;;;AAHtD;;;;AAAgE,KAqCpD,QAAA,GArCoD;EAA+B,CAAA,UAsClF,UAtCkF,EAAA,aAsCzD,KAtCyD,CAsCnD,CAtCmD,CAAA,CAAA,CAAA,KAAA,EAsCxC,IAtCwC,EAAA,MAAA,EAsC1B,CAtC0B,CAAA,EAAA,KAAA,IAsCb,MAtCa,CAsCL,IAtCK,EAsCC,CAtCD,CAAA;EAAP,CAAA,UAuC3E,UAvC2E,CAAA,CAAA,MAAA,EAuCvD,CAvCuD,CAAA,EAAA,CAAA,aAuCrC,KAvCqC,CAuC/B,CAvC+B,CAAA,CAAA,CAAA,KAAA,EAuCpB,IAvCoB,EAAA,GAAA,KAAA,IAuCF,MAvCE,CAuCM,IAvCN,EAuCY,CAvCZ,CAAA;CAAW;;;AACnG;;;;;;;;;;AAE+B,KAmDnB,EAAA,GAnDmB;EAkCnB,CAAA,IAAA,EAAA,YAkBS,IAlBD,CAAA,CAAA,KAAA,EAkBc,IAlBd,EAAA,MAAA,EAkB4B,oBAlB5B,CAkBiD,IAlBjD,EAkBuD,GAlBvD,CAAA,CAAA,EAAA,KAAA,IAkBuE,GAlBvE;EACP,CAAA,UAkBA,UAlBA,CAAA,CAAA,KAAA,EAAA,OAAA,EAAA,MAAA,EAkBoC,CAlBpC,CAAA,EAAA,KAAA,IAkBiD,MAlBjD,CAkBwD,CAlBxD,CAAA;EAA+B,CAAA,IAAA,EAAA,YAmBvB,IAnBuB,CAAA,CAAA,MAAA,EAmBT,oBAnBS,CAmBY,IAnBZ,EAmBkB,GAnBlB,CAAA,CAAA,EAAA,CAAA,KAAA,EAmBiC,IAnBjC,EAAA,GAAA,KAAA,IAmBmD,GAnBnD;EAAN,CAAA,UAoBzB,UApByB,CAAA,CAAA,MAAA,EAoBL,CApBK,CAAA,EAAA,CAAA,KAAA,EAAA,OAAA,EAAA,GAAA,KAAA,IAoB4B,MApB5B,CAoBmC,CApBnC,CAAA;CAAiB;AAAc,cAwBxD,MAxBwD,EAwBhD,QAxBgD;AAAqB,cA4B7E,EA5B6E,EA4BzE,EA5ByE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-BqJ1GWAF.d.mts","names":[],"sources":["../src/option/option.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;cA0Da,2BAAkB;;;;;;;;;;AAA/B;AAYY,KAAA,kBAAA,GAAqB,YAAoB,CAAA,OAAA,oBAAR,CAAA;AAY7C;AAsBA;;;;;AA4BA;AAgCA;;;AAA+E,KAlFnE,MAkFmE,CAAA,CAAA,CAAA,GAlFvD,QAkFuD,CAlF5C,CAkF4C,CAAA;;;;AAc/E;;;;;;;AAmCA;AAsCA;AAsCA;AAsCA;AA4Ba,cA3PA,
|
|
1
|
+
{"version":3,"file":"index-BqJ1GWAF.d.mts","names":[],"sources":["../src/option/option.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;cA0Da,2BAAkB;;;;;;;;;;AAA/B;AAYY,KAAA,kBAAA,GAAqB,YAAo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G,iBAAe,QAAQ,SAAW,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmC1E,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAsCL,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAsCR,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAsCT,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAsCL,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;cA6BR,QAAQ;;;;;;;;;;;;;;;;;;;cAmCR,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;cAgDL,UAAU;;;;;;;;;;;;;;;;;;;;;;;cA2BV,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAiCd,OAAO;;;;;;;;;;;;;;;;;;;;cA8BP,SAAS;cA6BhB,MAAI"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { h as Prettify, t as Result } from "./result.types-BKzChyWY.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { c as ValidationError } from "./schema.types-CBEXCwfs.mjs";
|
|
3
3
|
import { t as Discriminator } from "./discriminator.types-C-ygT2S1.mjs";
|
|
4
4
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
5
5
|
|
|
@@ -455,4 +455,4 @@ declare const variant: typeof variant$1;
|
|
|
455
455
|
declare const match: typeof match$1;
|
|
456
456
|
//#endregion
|
|
457
457
|
export { adt_d_exports as t };
|
|
458
|
-
//# sourceMappingURL=index-
|
|
458
|
+
//# sourceMappingURL=index-DUki2Bcp.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-DUki2Bcp.d.mts","names":[],"sources":["../src/adt/adt.match.ts","../src/adt/adt.types.ts","../src/adt/adt.union.ts","../src/adt/adt.variant.ts","../src/adt/adt.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;KAOK,gBAAA,CAAA,UAAgB;EACb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GGxCnB,eHwCmB,CGxCC,CHwCD,CAAA;;;;;;;;;;;;;;;;AAMS,KG7B9C,SH6B8C,CAAA,CAAA,EAAA,YAAA,MAAA,CAAA,GG7Bb,YH6Ba,CG7BI,CH6BJ,EG7BO,GH6BP,CAAA;;;AAa1D;;;;;;;;;;;;;;AAkBwD,cG1C3C,KH0C2C,EAAA,OG1CtC,OH0CsC;;;;;;;;;;;;;;;;;AAqBxB,cG7CnB,OH6CmB,EAAA,OG7CZ,SH6CY;;;;;;;;;;AAmBhC;AAA2E;;;AAY/D,cG7DC,KH6DD,EAAA,OG7DM,OH6DN"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as adt_d_exports } from "./index-
|
|
1
|
+
import { t as adt_d_exports } from "./index-DUki2Bcp.mjs";
|
|
2
2
|
import { t as brand_d_exports } from "./index-BA0EsFxS.mjs";
|
|
3
3
|
import { n as service_d_exports } from "./service-D8mr0wwg.mjs";
|
|
4
4
|
import { n as context_d_exports } from "./context-B2dWloPl.mjs";
|
|
@@ -19,7 +19,7 @@ import { t as predicate_d_exports } from "./index-CNTYbcY9.mjs";
|
|
|
19
19
|
import { t as provide_d_exports } from "./index-crtzMG48.mjs";
|
|
20
20
|
import { t as queue_d_exports } from "./index-Ctqe1fD1.mjs";
|
|
21
21
|
import "./schedule/index.mjs";
|
|
22
|
-
import { t as schema_d_exports } from "./index-
|
|
22
|
+
import { t as schema_d_exports } from "./index-B4WfexUL.mjs";
|
|
23
23
|
import "./scope/index.mjs";
|
|
24
24
|
import "./service/index.mjs";
|
|
25
25
|
export { adt_d_exports as Adt, brand_d_exports as Brand, context_d_exports as Context, data_d_exports as Data, duration_d_exports as Duration, either_d_exports as Either, fx_d_exports as Fx, layer_d_exports as Layer, multithread_d_exports as Multithread, option_d_exports as Option, order_d_exports as Order, predicate_d_exports as Predicate, provide_d_exports as Provide, queue_d_exports as Queue, result_d_exports as Result, schedule_d_exports as Schedule, schema_d_exports as Schema, scope_d_exports as Scope, service_d_exports as Service, flow, pipe };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./adt-
|
|
1
|
+
import{t as e}from"./adt-CPG_sa8q.mjs";import{t}from"./flow-CNyLsPGb.mjs";import{a as n}from"./result-D3VY0qBG.mjs";import{t as r}from"./brand-DZgGDrAe.mjs";import{t as i}from"./context-0xDbwtpx.mjs";import"./context/index.mjs";import{n as a}from"./data-BHYPdqWZ.mjs";import{t as o}from"./duration-CYoDHcOR.mjs";import{r as s}from"./option-C2iCxAuJ.mjs";import{t as c}from"./either-G7uOu4Ar.mjs";import{t as l}from"./functions-ByAk682_.mjs";import{a as u}from"./queue-apiEOlRD.mjs";import{t as d}from"./fx-DUXDxwsU.mjs";import{t as f}from"./layer-CKtH7TRL.mjs";import{t as p}from"./multithread-Cyc8Bz45.mjs";import{t as m}from"./order-BXOBEKvB.mjs";import{t as h}from"./predicate-D_1SsIi4.mjs";import{n as g}from"./scope-gVt4PESc.mjs";import{t as _}from"./provide--yZE8x-n.mjs";import"./queue/index.mjs";import{t as v}from"./schedule-C6iN3oMt.mjs";import{t as y}from"./schema-CJ-aaQe8.mjs";import"./scope/index.mjs";import{t as b}from"./service-CWAIEH46.mjs";export{e as Adt,r as Brand,i as Context,a as Data,o as Duration,c as Either,d as Fx,f as Layer,p as Multithread,s as Option,m as Order,h as Predicate,_ as Provide,u as Queue,n as Result,v as Schedule,y as Schema,g as Scope,b as Service,t as flow,l as pipe};
|
package/dist/schema/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as schema_d_exports } from "../index-
|
|
1
|
+
import { t as schema_d_exports } from "../index-B4WfexUL.mjs";
|
|
2
2
|
export { schema_d_exports as Schema };
|
package/dist/schema/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../schema-
|
|
1
|
+
import{t as e}from"../schema-CJ-aaQe8.mjs";export{e as Schema};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./chunk-oQKkju2G.mjs";import{t}from"./dual-fN6OUwN_.mjs";import{n}from"./flow-CNyLsPGb.mjs";import{t as r}from"./result-D3VY0qBG.mjs";import{n as i,r as a,t as o}from"./schema.shared-Bjyroa6b.mjs";var s=e({is:()=>u,parse:()=>c,refine:()=>l});function c(e){return t=>{try{let a=e[`~standard`].validate(t);return n(a)?Promise.resolve(a).then(e=>i(e),e=>r(o(e))):i(a)}catch(e){return r(o(e))}}}const l=t(2,(e,t)=>a(t,e,`Schema.refine()`)._tag===`Ok`),u=t(2,(e,t)=>a(t,e,`Schema.is()`)._tag===`Ok`);export{s as t};
|
|
2
|
+
//# sourceMappingURL=schema-CJ-aaQe8.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-CJ-aaQe8.mjs","names":["Result.err"],"sources":["../src/schema/schema.ts"],"sourcesContent":["import { Result } from \"../result\"\nimport type { Result as ResultType } from \"../result/result.types\"\n/**\n * Standard Schema-backed parsing and refinement helpers.\n *\n * **Mental model**\n * - `Schema.parse` is for boundary validation and parsing.\n * - `Schema.refine` is for sync-only in-memory narrowing that preserves the original value shape.\n * - `Schema.is` is for sync-only exact-output narrowing when the schema output is the desired type.\n *\n * **Common tasks**\n * - Parse loose external data into validated subtypes.\n * - Reuse a schema as a type guard for in-memory narrowing with `Schema.refine`.\n * - Name reusable narrowed types with `Schema.Refine<Base, typeof schema>` or `Schema.Infer<typeof schema>`.\n *\n * **Gotchas**\n * - `Schema.parse` may be sync or async based on the schema type you preserve.\n * - `Schema.refine` and `Schema.is` support both data-first and data-last styles.\n * - `Schema.refine` and `Schema.is` are sync-only.\n * - `Schema.refine` must only be used with schemas that prove properties already present on the original value.\n * - `Schema.is` narrows exactly to the schema output, while `Schema.refine` narrows to `Base & Output`.\n *\n * @module\n */\nimport { dual } from \"../shared/dual\"\nimport { isPromise } from \"../shared/is-promise\"\nimport { toThrownValidationError, toValidationResult, validateSync } from \"./schema.shared\"\nimport type { Input, Output, Refine as Refined, SyncRefinementSchema, SyncSchema, ValidationError } from \"./schema.types\"\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\"\n\nexport type {\n Infer,\n Input,\n Output,\n Refine,\n RefinementSchema,\n SyncRefinementSchema,\n SyncSchema,\n ValidationError,\n ValidationIssue,\n} from \"./schema.types\"\n\n/**\n * Create a schema-backed parser.\n *\n * For sync schemas the returned parser is sync.\n * For general Standard Schema values the returned parser is async.\n */\nexport function parse<S extends SyncSchema>(schema: S): (value: Input<S>) => ResultType<Output<S>, ValidationError>\nexport function parse<S extends StandardSchemaV1>(\n schema: S,\n): (value: Input<S>) => Promise<ResultType<Output<S>, ValidationError>>\nexport function parse<S extends StandardSchemaV1>(schema: S) {\n return (value: Input<S>) => {\n try {\n const result = schema[\"~standard\"].validate(value)\n\n if (isPromise(result)) {\n return Promise.resolve(result).then(\n (validated) => toValidationResult(validated),\n (error) => Result.err(toThrownValidationError(error)),\n )\n }\n\n return toValidationResult(result)\n } catch (error) {\n return Result.err(toThrownValidationError(error))\n }\n }\n}\n\n/**\n * Create a sync-only schema-backed type guard that preserves the original value shape.\n *\n * Use this when a schema validates only a subset of a broader in-memory value.\n * The narrowed type is `Base & Output<typeof schema>`, not the exact schema output.\n *\n * Supports both data-first and data-last styles:\n * - Data-first: `Schema.refine(value, schema)`\n * - Data-last: `Schema.refine(schema)(value)`\n *\n * Only use this with sync schemas that prove properties already present on the\n * original value. Transforms, defaults, and coercions are not safe here because\n * they can change the schema output without changing the original input value.\n */\nexport type RefineFn = {\n <S extends SyncSchema, Base extends Input<S>>(value: Base, schema: S): value is Refined<Base, S>\n <S extends SyncSchema>(schema: S): <Base extends Input<S>>(value: Base) => value is Refined<Base, S>\n}\n\n/**\n * Create a sync-only schema-backed type guard.\n *\n * Unlike `Schema.refine`, this narrows exactly to the schema output.\n *\n * This is intended for refinement schemas where the validated output is a\n * subtype of the input value already in memory.\n *\n * Supports both data-first and data-last styles:\n * - Data-first: `Schema.is(value, schema)`\n * - Data-last: `Schema.is(schema)(value)`\n */\nexport type Is = {\n <Base, Sub extends Base>(value: Base, schema: SyncRefinementSchema<Base, Sub>): value is Sub\n <S extends SyncSchema>(value: unknown, schema: S): value is Output<S>\n <Base, Sub extends Base>(schema: SyncRefinementSchema<Base, Sub>): (value: Base) => value is Sub\n <S extends SyncSchema>(schema: S): (value: unknown) => value is Output<S>\n}\n\n/* oxlint-disable no-explicit-any, no-unsafe-return, no-unsafe-type-assertion -- dual() requires a single implementation signature */\nexport const refine: RefineFn = dual(2, (value: unknown, schema: SyncSchema) => {\n return validateSync(schema, value, \"Schema.refine()\")._tag === \"Ok\"\n}) as RefineFn\n\nexport const is: Is = dual(2, (value: unknown, schema: SyncSchema) => {\n return validateSync(schema, value, \"Schema.is()\")._tag === \"Ok\"\n}) as Is\n/* oxlint-enable no-explicit-any, no-unsafe-return, no-unsafe-type-assertion */\n"],"mappings":"qQAoDA,SAAgB,EAAkC,EAAW,CAC3D,MAAQ,IAAoB,CAC1B,GAAI,CACF,IAAM,EAAS,EAAO,aAAa,SAAS,EAAM,CASlD,OAPI,EAAU,EAAO,CACZ,QAAQ,QAAQ,EAAO,CAAC,KAC5B,GAAc,EAAmB,EAAU,CAC3C,GAAUA,EAAW,EAAwB,EAAM,CAAC,CACtD,CAGI,EAAmB,EAAO,OAC1B,EAAO,CACd,OAAOA,EAAW,EAAwB,EAAM,CAAC,GA4CvD,MAAa,EAAmB,EAAK,GAAI,EAAgB,IAChD,EAAa,EAAQ,EAAO,kBAAkB,CAAC,OAAS,KAC/D,CAEW,EAAS,EAAK,GAAI,EAAgB,IACtC,EAAa,EAAQ,EAAO,cAAc,CAAC,OAAS,KAC3D"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{n as e}from"./flow-CNyLsPGb.mjs";import{i as t,t as n}from"./result-D3VY0qBG.mjs";function r(e){return typeof e==`object`&&e&&`key`in e?e.key:e}function i(e){return e.map(e=>({message:e.message,path:e.path?.map(r)}))}function a(e){return e.issues?n({issues:i(e.issues)}):t(e.value)}function o(e){return e instanceof Error&&e.message.length>0?e.message:typeof e==`string`&&e.length>0?e:`Schema validation failed.`}function s(e){return{issues:[{message:o(e)}]}}function c(t,n,r){let i=t[`~standard`].validate(n);if(e(i))throw TypeError(`Async validation is not supported in ${r}.`);return a(i)}export{a as n,c as r,s as t};
|
|
2
|
+
//# sourceMappingURL=schema.shared-Bjyroa6b.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.shared-Bjyroa6b.mjs","names":["Result.err","Result.ok"],"sources":["../src/schema/schema.shared.ts"],"sourcesContent":["import { Result } from \"../result\"\nimport type { Result as ResultType } from \"../result/result.types\"\nimport { isPromise } from \"../shared/is-promise\"\nimport type { ValidationError, ValidationIssue } from \"./schema.types\"\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\"\n\nfunction normalizePathSegment(segment: PropertyKey | { readonly key: PropertyKey }): PropertyKey {\n return typeof segment === \"object\" && segment !== null && \"key\" in segment ? segment.key : segment\n}\n\nfunction normalizeIssues(\n issues: NonNullable<StandardSchemaV1.Result<unknown>[\"issues\"]>,\n): ReadonlyArray<ValidationIssue> {\n return issues.map((issue) => ({\n message: issue.message,\n path: issue.path?.map(normalizePathSegment),\n }))\n}\n\nexport function toValidationResult<T>(result: StandardSchemaV1.Result<T>): ResultType<T, ValidationError> {\n if (result.issues) {\n return Result.err({ issues: normalizeIssues(result.issues) })\n }\n\n return Result.ok(result.value)\n}\n\nfunction toErrorMessage(error: unknown): string {\n if (error instanceof Error && error.message.length > 0) {\n return error.message\n }\n\n if (typeof error === \"string\" && error.length > 0) {\n return error\n }\n\n return \"Schema validation failed.\"\n}\n\nexport function toThrownValidationError(error: unknown): ValidationError {\n return {\n issues: [{ message: toErrorMessage(error) }],\n }\n}\n\nexport function validateSync<T>(\n schema: StandardSchemaV1<unknown, T>,\n value: unknown,\n operation: string,\n): ResultType<T, ValidationError> {\n const result = schema[\"~standard\"].validate(value)\n\n if (isPromise(result)) {\n throw new TypeError(`Async validation is not supported in ${operation}.`)\n }\n\n return toValidationResult(result)\n}\n"],"mappings":"yFAMA,SAAS,EAAqB,EAAmE,CAC/F,OAAO,OAAO,GAAY,UAAY,GAAoB,QAAS,EAAU,EAAQ,IAAM,EAG7F,SAAS,EACP,EACgC,CAChC,OAAO,EAAO,IAAK,IAAW,CAC5B,QAAS,EAAM,QACf,KAAM,EAAM,MAAM,IAAI,EAAqB,CAC5C,EAAE,CAGL,SAAgB,EAAsB,EAAoE,CAKxG,OAJI,EAAO,OACFA,EAAW,CAAE,OAAQ,EAAgB,EAAO,OAAO,CAAE,CAAC,CAGxDC,EAAU,EAAO,MAAM,CAGhC,SAAS,EAAe,EAAwB,CAS9C,OARI,aAAiB,OAAS,EAAM,QAAQ,OAAS,EAC5C,EAAM,QAGX,OAAO,GAAU,UAAY,EAAM,OAAS,EACvC,EAGF,4BAGT,SAAgB,EAAwB,EAAiC,CACvE,MAAO,CACL,OAAQ,CAAC,CAAE,QAAS,EAAe,EAAM,CAAE,CAAC,CAC7C,CAGH,SAAgB,EACd,EACA,EACA,EACgC,CAChC,IAAM,EAAS,EAAO,aAAa,SAAS,EAAM,CAElD,GAAI,EAAU,EAAO,CACnB,MAAU,UAAU,wCAAwC,EAAU,GAAG,CAG3E,OAAO,EAAmB,EAAO"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { h as Prettify } from "./result.types-BKzChyWY.mjs";
|
|
1
2
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
3
|
|
|
3
4
|
//#region src/schema/schema.types.d.ts
|
|
@@ -10,6 +11,20 @@ type Input<S extends StandardSchemaV1> = NonNullable<S["~standard"]["types"]>["i
|
|
|
10
11
|
* Infer the output type from a Standard Schema.
|
|
11
12
|
*/
|
|
12
13
|
type Output<S extends StandardSchemaV1> = NonNullable<S["~standard"]["types"]>["output"];
|
|
14
|
+
/**
|
|
15
|
+
* Infer the validated output type from a Standard Schema.
|
|
16
|
+
*
|
|
17
|
+
* This matches the exact schema output used by `Schema.parse()` and
|
|
18
|
+
* `Schema.is()`.
|
|
19
|
+
*/
|
|
20
|
+
type Infer<S extends StandardSchemaV1> = Output<S>;
|
|
21
|
+
/**
|
|
22
|
+
* Compute the base-shape-preserving narrowed type used by `Schema.refine()`.
|
|
23
|
+
*
|
|
24
|
+
* This preserves fields already present on the base value while intersecting in
|
|
25
|
+
* the schema-proven output fields.
|
|
26
|
+
*/
|
|
27
|
+
type Refine<Base, S extends StandardSchemaV1> = Base extends Input<S> ? Base extends unknown ? Prettify<Base & Output<S>> : never : never;
|
|
13
28
|
/**
|
|
14
29
|
* Normalized validation issue shape used across std modules.
|
|
15
30
|
*/
|
|
@@ -41,5 +56,5 @@ type RefinementSchema<Base, Sub extends Base> = StandardSchemaV1<Base, Sub>;
|
|
|
41
56
|
*/
|
|
42
57
|
type SyncRefinementSchema<Base, Sub extends Base> = SyncSchema<Base, Sub>;
|
|
43
58
|
//#endregion
|
|
44
|
-
export {
|
|
45
|
-
//# sourceMappingURL=schema.types-
|
|
59
|
+
export { RefinementSchema as a, ValidationError as c, Refine as i, ValidationIssue as l, Input as n, SyncRefinementSchema as o, Output as r, SyncSchema as s, Infer as t };
|
|
60
|
+
//# sourceMappingURL=schema.types-CBEXCwfs.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.types-CBEXCwfs.d.mts","names":[],"sources":["../src/schema/schema.types.ts"],"sourcesContent":[],"mappings":";;;;;;;AAMA;AAA4B,KAAhB,KAAgB,CAAA,UAAA,gBAAA,CAAA,GAAoB,WAApB,CAAgC,CAAhC,CAAA,WAAA,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,OAAA,CAAA;;;;AAKhB,KAAA,MAAM,CAAA,UAAW,gBAAX,CAAA,GAA+B,WAA/B,CAA2C,CAA3C,CAAA,WAAA,CAAA,CAAA,OAAA,CAAA,CAA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0,0 @@
|
|
|
1
|
-
import { t as Result } from "./result.types-BKzChyWY.mjs";
|
|
2
|
-
import { a as SyncSchema, i as SyncRefinementSchema, n as Output, o as ValidationError, r as RefinementSchema, s as ValidationIssue, t as Input } from "./schema.types-CFzzx4bw.mjs";
|
|
3
|
-
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
4
|
-
|
|
5
|
-
//#region src/schema/schema.d.ts
|
|
6
|
-
declare namespace schema_d_exports {
|
|
7
|
-
export { Input, Is, Output, RefinementSchema, SyncRefinementSchema, SyncSchema, ValidationError, ValidationIssue, is, parse };
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Create a schema-backed parser.
|
|
11
|
-
*
|
|
12
|
-
* For sync schemas the returned parser is sync.
|
|
13
|
-
* For general Standard Schema values the returned parser is async.
|
|
14
|
-
*/
|
|
15
|
-
declare function parse<S extends SyncSchema>(schema: S): (value: Input<S>) => Result<Output<S>, ValidationError>;
|
|
16
|
-
declare function parse<S extends StandardSchemaV1>(schema: S): (value: Input<S>) => Promise<Result<Output<S>, ValidationError>>;
|
|
17
|
-
/**
|
|
18
|
-
* Create a sync-only schema-backed type guard.
|
|
19
|
-
*
|
|
20
|
-
* This is intended for refinement schemas where the validated output is a
|
|
21
|
-
* subtype of the input value already in memory.
|
|
22
|
-
*
|
|
23
|
-
* Supports both data-first and data-last styles:
|
|
24
|
-
* - Data-first: `Schema.is(value, schema)`
|
|
25
|
-
* - Data-last: `Schema.is(schema)(value)`
|
|
26
|
-
*/
|
|
27
|
-
type Is = {
|
|
28
|
-
<Base, Sub extends Base>(value: Base, schema: SyncRefinementSchema<Base, Sub>): value is Sub;
|
|
29
|
-
<S extends SyncSchema>(value: unknown, schema: S): value is Output<S>;
|
|
30
|
-
<Base, Sub extends Base>(schema: SyncRefinementSchema<Base, Sub>): (value: Base) => value is Sub;
|
|
31
|
-
<S extends SyncSchema>(schema: S): (value: unknown) => value is Output<S>;
|
|
32
|
-
};
|
|
33
|
-
declare const is: Is;
|
|
34
|
-
//#endregion
|
|
35
|
-
export { schema_d_exports as t };
|
|
36
|
-
//# sourceMappingURL=index-Ctg7XUOs.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-Ctg7XUOs.d.mts","names":[],"sources":["../src/schema/schema.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;iBAyCgB,gBAAgB,oBAAoB,YAAY,MAAM,OAAO,OAAW,OAAO,IAAI;iBACnF,gBAAgB,0BACtB,YACC,MAAM,OAAO,QAAQ,OAAW,OAAO,IAAI;;;;;;;AAHtD;;;;AAAgE,KA0BpD,EAAA,GA1BoD;EAA+B,CAAA,IAAA,EAAA,YA2B1E,IA3B0E,CAAA,CAAA,KAAA,EA2B7D,IA3B6D,EAAA,MAAA,EA2B/C,oBA3B+C,CA2B1B,IA3B0B,EA2BpB,GA3BoB,CAAA,CAAA,EAAA,KAAA,IA2BJ,GA3BI;EAAP,CAAA,UA4B3E,UA5B2E,CAAA,CAAA,KAAA,EAAA,OAAA,EAAA,MAAA,EA4BvC,CA5BuC,CAAA,EAAA,KAAA,IA4B1B,MA5B0B,CA4BnB,CA5BmB,CAAA;EAAW,CAAA,IAAA,EAAA,YA6B9E,IA7B8E,CAAA,CAAA,MAAA,EA6BhE,oBA7BgE,CA6B3C,IA7B2C,EA6BrC,GA7BqC,CAAA,CAAA,EAAA,CAAA,KAAA,EA6BtB,IA7BsB,EAAA,GAAA,KAAA,IA6BJ,GA7BI;EAAtB,CAAA,UA8BhE,UA9BgE,CAAA,CAAA,MAAA,EA8B5C,CA9B4C,CAAA,EAAA,CAAA,KAAA,EAAA,OAAA,EAAA,GAAA,KAAA,IA8BX,MA9BW,CA8BJ,CA9BI,CAAA;CAAU;AACvE,cAiCH,EAjCQ,EAiCJ,EAjCI"}
|
package/dist/schema-D87TVF_b.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./chunk-oQKkju2G.mjs";import{t}from"./dual-fN6OUwN_.mjs";import{n}from"./flow-CNyLsPGb.mjs";import{n as r,t as i}from"./schema.shared-CI4eydjX.mjs";var a=e({is:()=>s,parse:()=>o});function o(e){return t=>{let r=e[`~standard`].validate(t);return n(r)?Promise.resolve(r).then(i):i(r)}}const s=t(2,(e,t)=>r(t,e,`Schema.is()`)._tag===`Ok`);export{a as t};
|
|
2
|
-
//# sourceMappingURL=schema-D87TVF_b.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema-D87TVF_b.mjs","names":[],"sources":["../src/schema/schema.ts"],"sourcesContent":["import type { Result as ResultType } from \"../result/result.types\"\n/**\n * Standard Schema-backed parsing and refinement helpers.\n *\n * **Mental model**\n * - `Schema.parse` is for boundary validation and parsing.\n * - `Schema.is` is for sync-only refinement of values already in memory.\n *\n * **Common tasks**\n * - Parse loose external data into validated subtypes.\n * - Reuse a schema as a type guard for refinement-only narrowing.\n *\n * **Gotchas**\n * - `Schema.parse` may be sync or async based on the schema type you preserve.\n * - `Schema.is` supports both data-first and data-last styles.\n * - `Schema.is` must only be used with sync schemas that do not rely on transforms.\n *\n * @module\n */\nimport { dual } from \"../shared/dual\"\nimport { isPromise } from \"../shared/is-promise\"\nimport { toValidationResult, validateSync } from \"./schema.shared\"\nimport type { Input, Output, SyncRefinementSchema, SyncSchema, ValidationError } from \"./schema.types\"\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\"\n\nexport type {\n Input,\n Output,\n RefinementSchema,\n SyncRefinementSchema,\n SyncSchema,\n ValidationError,\n ValidationIssue,\n} from \"./schema.types\"\n\n/**\n * Create a schema-backed parser.\n *\n * For sync schemas the returned parser is sync.\n * For general Standard Schema values the returned parser is async.\n */\nexport function parse<S extends SyncSchema>(schema: S): (value: Input<S>) => ResultType<Output<S>, ValidationError>\nexport function parse<S extends StandardSchemaV1>(\n schema: S,\n): (value: Input<S>) => Promise<ResultType<Output<S>, ValidationError>>\nexport function parse<S extends StandardSchemaV1>(schema: S) {\n return (value: Input<S>) => {\n const result = schema[\"~standard\"].validate(value)\n\n if (isPromise(result)) {\n return Promise.resolve(result).then(toValidationResult)\n }\n\n return toValidationResult(result)\n }\n}\n\n/**\n * Create a sync-only schema-backed type guard.\n *\n * This is intended for refinement schemas where the validated output is a\n * subtype of the input value already in memory.\n *\n * Supports both data-first and data-last styles:\n * - Data-first: `Schema.is(value, schema)`\n * - Data-last: `Schema.is(schema)(value)`\n */\nexport type Is = {\n <Base, Sub extends Base>(value: Base, schema: SyncRefinementSchema<Base, Sub>): value is Sub\n <S extends SyncSchema>(value: unknown, schema: S): value is Output<S>\n <Base, Sub extends Base>(schema: SyncRefinementSchema<Base, Sub>): (value: Base) => value is Sub\n <S extends SyncSchema>(schema: S): (value: unknown) => value is Output<S>\n}\n\n/* oxlint-disable no-explicit-any, no-unsafe-return, no-unsafe-type-assertion -- dual() requires a single implementation signature */\nexport const is: Is = dual(2, (value: unknown, schema: SyncSchema) => {\n return validateSync(schema, value, \"Schema.is()\")._tag === \"Ok\"\n}) as Is\n/* oxlint-enable no-explicit-any, no-unsafe-return, no-unsafe-type-assertion */\n"],"mappings":"uMA6CA,SAAgB,EAAkC,EAAW,CAC3D,MAAQ,IAAoB,CAC1B,IAAM,EAAS,EAAO,aAAa,SAAS,EAAM,CAMlD,OAJI,EAAU,EAAO,CACZ,QAAQ,QAAQ,EAAO,CAAC,KAAK,EAAmB,CAGlD,EAAmB,EAAO,EAsBrC,MAAa,EAAS,EAAK,GAAI,EAAgB,IACtC,EAAa,EAAQ,EAAO,cAAc,CAAC,OAAS,KAC3D"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./flow-CNyLsPGb.mjs";import{i as t,t as n}from"./result-D3VY0qBG.mjs";function r(e){return typeof e==`object`&&e&&`key`in e?e.key:e}function i(e){return e.map(e=>({message:e.message,path:e.path?.map(r)}))}function a(e){return e.issues?n({issues:i(e.issues)}):t(e.value)}function o(t,n,r){let i=t[`~standard`].validate(n);if(e(i))throw TypeError(`Async validation is not supported in ${r}.`);return a(i)}export{o as n,a as t};
|
|
2
|
-
//# sourceMappingURL=schema.shared-CI4eydjX.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.shared-CI4eydjX.mjs","names":["Result.err","Result.ok"],"sources":["../src/schema/schema.shared.ts"],"sourcesContent":["import { Result } from \"../result\"\nimport type { Result as ResultType } from \"../result/result.types\"\nimport { isPromise } from \"../shared/is-promise\"\nimport type { ValidationError, ValidationIssue } from \"./schema.types\"\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\"\n\nfunction normalizePathSegment(segment: PropertyKey | { readonly key: PropertyKey }): PropertyKey {\n return typeof segment === \"object\" && segment !== null && \"key\" in segment ? segment.key : segment\n}\n\nfunction normalizeIssues(\n issues: NonNullable<StandardSchemaV1.Result<unknown>[\"issues\"]>,\n): ReadonlyArray<ValidationIssue> {\n return issues.map((issue) => ({\n message: issue.message,\n path: issue.path?.map(normalizePathSegment),\n }))\n}\n\nexport function toValidationResult<T>(result: StandardSchemaV1.Result<T>): ResultType<T, ValidationError> {\n if (result.issues) {\n return Result.err({ issues: normalizeIssues(result.issues) })\n }\n\n return Result.ok(result.value)\n}\n\nexport function validateSync<T>(\n schema: StandardSchemaV1<unknown, T>,\n value: unknown,\n operation: string,\n): ResultType<T, ValidationError> {\n const result = schema[\"~standard\"].validate(value)\n\n if (isPromise(result)) {\n throw new TypeError(`Async validation is not supported in ${operation}.`)\n }\n\n return toValidationResult(result)\n}\n"],"mappings":"yFAMA,SAAS,EAAqB,EAAmE,CAC/F,OAAO,OAAO,GAAY,UAAY,GAAoB,QAAS,EAAU,EAAQ,IAAM,EAG7F,SAAS,EACP,EACgC,CAChC,OAAO,EAAO,IAAK,IAAW,CAC5B,QAAS,EAAM,QACf,KAAM,EAAM,MAAM,IAAI,EAAqB,CAC5C,EAAE,CAGL,SAAgB,EAAsB,EAAoE,CAKxG,OAJI,EAAO,OACFA,EAAW,CAAE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