@nicolastoulemont/std 0.8.0 → 0.8.2
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 +47 -15
- 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/data/index.d.mts +1 -1
- package/dist/data-BHYPdqWZ.mjs.map +1 -1
- package/dist/duration/index.d.mts +1 -1
- package/dist/fx/index.d.mts +1 -1
- package/dist/{index-Ctqe1fD1.d.mts → index-B0flvtFB.d.mts} +2 -2
- package/dist/{index-Ctqe1fD1.d.mts.map → index-B0flvtFB.d.mts.map} +1 -1
- package/dist/{index-UINIHFuh.d.mts → index-B2Z7-XGR.d.mts} +2 -2
- package/dist/{index-UINIHFuh.d.mts.map → index-B2Z7-XGR.d.mts.map} +1 -1
- package/dist/index-B41_sFR6.d.mts +64 -0
- package/dist/index-B41_sFR6.d.mts.map +1 -0
- package/dist/{index-MsJqfQu0.d.mts → index-C4DOLLaU.d.mts} +2 -2
- package/dist/{index-MsJqfQu0.d.mts.map → index-C4DOLLaU.d.mts.map} +1 -1
- package/dist/{index-DfQGXBQI.d.mts → index-C6W3_n_Q.d.mts} +2 -2
- package/dist/{index-DfQGXBQI.d.mts.map → index-C6W3_n_Q.d.mts.map} +1 -1
- package/dist/index-D8rDE60Y.d.mts.map +1 -1
- package/dist/{index-BsPOcZk9.d.mts → index-DCUGtEcj.d.mts} +2 -2
- package/dist/{index-BsPOcZk9.d.mts.map → index-DCUGtEcj.d.mts.map} +1 -1
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +1 -1
- package/dist/queue/index.d.mts +1 -1
- package/dist/schedule/index.d.mts +1 -1
- package/dist/{schedule-B9K_2Z21.d.mts → schedule-D2651VJY.d.mts} +3 -3
- package/dist/{schedule-B9K_2Z21.d.mts.map → schedule-D2651VJY.d.mts.map} +1 -1
- package/dist/schema/index.d.mts +1 -1
- package/dist/schema/index.mjs +1 -1
- package/dist/schema-DstB1_VK.mjs +2 -0
- package/dist/schema-DstB1_VK.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-E1pjcc0Y.d.mts} +19 -2
- package/dist/schema.types-E1pjcc0Y.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.is`
|
|
263
|
+
Use `Schema.is` for direct in-memory proof checks.
|
|
264
|
+
Use `Schema.refine` when you need a reusable preserved-shape predicate, especially with higher-order APIs like `Array.filter`.
|
|
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.is` and `Schema.refine` with sync proof schemas that validate the current value in place. Transforms, defaults, and coercions should continue to use `Schema.parse`.
|
|
264
267
|
|
|
265
268
|
#### Boundary Parsing Example
|
|
266
269
|
|
|
@@ -305,13 +308,14 @@ if (Result.isOk(result)) {
|
|
|
305
308
|
}
|
|
306
309
|
```
|
|
307
310
|
|
|
308
|
-
#### In-Memory
|
|
311
|
+
#### Direct In-Memory Proof Example
|
|
309
312
|
|
|
310
313
|
```ts
|
|
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,59 @@ 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
|
-
const
|
|
336
|
+
declare const ticket: PersistedTicket
|
|
337
|
+
|
|
338
|
+
if (Schema.is(ticket, ChatTicketSchema)) {
|
|
339
|
+
ticket.id
|
|
340
|
+
ticket.chatId.toUpperCase()
|
|
341
|
+
}
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
In direct control flow, TypeScript preserves the current type shape and intersects in the schema-proven fields.
|
|
345
|
+
|
|
346
|
+
#### Reusable Preserved-Shape Predicate Example
|
|
347
|
+
|
|
348
|
+
```ts
|
|
349
|
+
import { Schema } from "@nicolastoulemont/std"
|
|
350
|
+
import { z } from "zod"
|
|
339
351
|
|
|
340
|
-
|
|
352
|
+
type PersistedTicket = {
|
|
353
|
+
id: string
|
|
354
|
+
channel: "chat" | "email"
|
|
355
|
+
chatId?: string | null
|
|
356
|
+
}
|
|
341
357
|
|
|
342
|
-
|
|
343
|
-
|
|
358
|
+
type ChatTicketFields = {
|
|
359
|
+
channel: "chat"
|
|
360
|
+
chatId: string
|
|
344
361
|
}
|
|
362
|
+
|
|
363
|
+
const ChatTicketSchema: Schema.SyncSchema<PersistedTicket, ChatTicketFields> = z.object({
|
|
364
|
+
channel: z.literal("chat"),
|
|
365
|
+
chatId: z.string(),
|
|
366
|
+
})
|
|
367
|
+
|
|
368
|
+
type ChatTicket = Schema.Refine<PersistedTicket, typeof ChatTicketSchema>
|
|
369
|
+
|
|
370
|
+
const isChatTicket = Schema.refine(ChatTicketSchema)
|
|
371
|
+
|
|
372
|
+
declare const tickets: PersistedTicket[]
|
|
373
|
+
|
|
374
|
+
const chatTickets = tickets.filter(isChatTicket)
|
|
345
375
|
```
|
|
346
376
|
|
|
377
|
+
Use `Schema.Infer<typeof schema>` when you need the exact schema output, and use `Schema.parse` whenever the schema changes the output shape.
|
|
378
|
+
|
|
347
379
|
### Adt
|
|
348
380
|
|
|
349
381
|
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-C6W3_n_Q.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 * })\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,QAA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CAMhF,IAAM,EAAS,EAAa,EAHR,CAAE,GAAI,EAAkB,OAAM,CAGD,EAAK,CAStD,OAPI,EAAO,OAAS,MACX,EAAI,EAAO,MAAM,CAMnB,EADQ,CAAE,GAAI,EAAO,MAAkB,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"}
|
|
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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,EAAQ,EAAO,CAC1C,EAAO,EAAkB,EAAM,EAAQ,EAAO,CAC9C,EAAS,EAA2C,EAAK,CACzD,EAAO,EAAyC,EAAK,CAGrD,EAAe,GAA6D,CAMhF,IAAM,EAAS,EAAa,EAHR,CAAE,GAAI,EAAkB,OAAM,CAGD,EAAK,CAStD,OAPI,EAAO,OAAS,MACX,EAAI,EAAO,MAAM,CAMnB,EADQ,CAAE,GAAI,EAAO,MAAkB,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"}
|
package/dist/data/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as data_d_exports } from "../index-
|
|
1
|
+
import { t as data_d_exports } from "../index-B2Z7-XGR.mjs";
|
|
2
2
|
export { data_d_exports as Data };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-BHYPdqWZ.mjs","names":["array","struct","tagged","TaggedError","tuple","taggedImpl","TaggedErrorImpl","structImpl","tupleImpl","arrayImpl"],"sources":["../src/data/data.array.ts","../src/data/data.struct.ts","../src/data/data.tagged.ts","../src/data/data.tagged-error.ts","../src/data/data.tuple.ts","../src/data/data.ts"],"sourcesContent":["import { deepEquals, deepHash } from \"../equality/equality\"\nimport type { ArrayValue } from \"./data.types\"\n\n/**\n * Create an array with structural equality.\n *\n * The returned array is frozen (immutable) and has non-enumerable\n * equals() and hash() methods for structural comparison.\n *\n * The map() and filter() methods are overridden to return ArrayValue,\n * enabling method chaining with preserved equality semantics.\n *\n * @template T - The element type of the array\n * @param items - The array elements\n * @returns A frozen array with equals(), hash(), map(), and filter()\n *\n * @see {@link tuple} for fixed-length typed tuples\n * @see {@link struct} for object value types\n *\n * @example\n * ```ts\n * const arr1 = array([1, 2, 3])\n * const arr2 = array([1, 2, 3])\n *\n * arr1.equals(arr2) // true\n * arr1.hash() // number\n *\n * // Chainable operations return ArrayValue\n * arr1.map(x => x * 2) // ArrayValue<number>\n * arr1.filter(x => x > 1) // ArrayValue<number>\n *\n * // Chained equality check\n * arr1.map(x => x * 2).equals(array([2, 4, 6])) // true\n *\n * // Array is frozen\n * arr1[0] = 5 // TypeError\n * arr1.push(4) // TypeError\n * ```\n */\nexport function array<T>(items: readonly T[]): ArrayValue<T> {\n const value = [...items]\n\n // Add equals method (non-enumerable)\n Object.defineProperty(value, \"equals\", {\n value: (other: readonly T[]) => deepEquals(value, other),\n enumerable: false,\n writable: false,\n configurable: false,\n })\n\n // Add hash method (non-enumerable)\n Object.defineProperty(value, \"hash\", {\n value: () => deepHash(value),\n enumerable: false,\n writable: false,\n configurable: false,\n })\n\n // Override map to return ArrayValue\n const originalMap = value.map.bind(value)\n Object.defineProperty(value, \"map\", {\n value: <U>(fn: (item: T, index: number, arr: readonly T[]) => U): ArrayValue<U> => {\n return array(originalMap(fn))\n },\n enumerable: false,\n writable: false,\n configurable: false,\n })\n\n // Override filter to return ArrayValue\n const originalFilter = value.filter.bind(value)\n Object.defineProperty(value, \"filter\", {\n value: (fn: (item: T, index: number, arr: readonly T[]) => boolean): ArrayValue<T> => {\n return array(originalFilter(fn))\n },\n enumerable: false,\n writable: false,\n configurable: false,\n })\n\n // Override slice to return ArrayValue\n const originalSlice = value.slice.bind(value)\n Object.defineProperty(value, \"slice\", {\n value: (start?: number, end?: number): ArrayValue<T> => {\n return array(originalSlice(start, end))\n },\n enumerable: false,\n writable: false,\n configurable: false,\n })\n\n // Override concat to return ArrayValue\n const originalConcat = value.concat.bind(value)\n Object.defineProperty(value, \"concat\", {\n value: (...args: readonly (T | readonly T[])[]): ArrayValue<T> => {\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for concat argument spread\n return array(originalConcat(...(args as T[][])))\n },\n enumerable: false,\n writable: false,\n configurable: false,\n })\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for generic array return type\n return Object.freeze(value) as unknown as ArrayValue<T>\n}\n","import { deepEquals, deepHash } from \"../equality/equality\"\nimport type { StructValue } from \"./data.types\"\n\n/**\n * Create a frozen value object with structural equality.\n *\n * Unlike tagged(), struct() does not add a _tag discriminator.\n * Use this for simple value objects that don't need discrimination.\n *\n * The returned object is frozen (immutable) and has non-enumerable\n * equals() and hash() methods for structural comparison.\n *\n * @template T - The object shape type\n * @param input - The object to wrap\n * @returns A frozen object with equals() and hash() methods\n *\n * @see {@link tagged} for discriminated value objects with _tag\n * @see {@link array} for array value types\n *\n * @example\n * ```ts\n * const point = struct({ x: 10, y: 20 })\n * const point2 = struct({ x: 10, y: 20 })\n *\n * point.equals(point2) // true\n * point.hash() // number\n *\n * // Object is frozen\n * point.x = 5 // TypeError\n *\n * // equals/hash are non-enumerable\n * Object.keys(point) // [\"x\", \"y\"]\n * ```\n */\nexport function struct<T extends Record<string, unknown>>(input: T): StructValue<T> {\n const value = { ...input }\n\n // Add equals method (non-enumerable)\n Object.defineProperty(value, \"equals\", {\n value: (other: T) => deepEquals(value, other),\n enumerable: false,\n writable: false,\n configurable: false,\n })\n\n // Add hash method (non-enumerable)\n Object.defineProperty(value, \"hash\", {\n value: () => deepHash(value),\n enumerable: false,\n writable: false,\n configurable: false,\n })\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for generic struct return type\n return Object.freeze(value) as StructValue<T>\n}\n","import { createEqualsMethod, createHashMethod } from \"../equality/equality\"\nimport type { Discriminator } from \"../shared/discriminator.types\"\nimport type { TaggedConstructor, TaggedValue } from \"./data.types\"\n\n/**\n * Create a tagged value constructor without schema validation.\n *\n * Unlike variant(), this creates values directly without validation.\n * Values are frozen and have structural equality via equals() and hash() methods.\n *\n * @template T - The data shape type (excluding _tag)\n * @param tag - The _tag discriminator value\n * @returns A constructor function with is(), equals(), and hash() methods\n *\n * @see {@link variant} for validated variant with schema support\n * @see {@link struct} for untagged value objects\n *\n * @example\n * ```ts\n * const Person = tagged<{ name: string; age: number }>(\"Person\")\n *\n * const alice = Person({ name: \"Alice\", age: 30 })\n * // => { _tag: \"Person\", name: \"Alice\", age: 30 }\n *\n * Person.equals(alice, Person({ name: \"Alice\", age: 30 })) // true\n * Person.is(alice) // true\n *\n * // Type guard usage\n * if (Person.is(unknownValue)) {\n * console.log(unknownValue.name) // TypeScript knows it's a Person\n * }\n *\n * // Values are frozen (immutable)\n * alice.name = \"Bob\" // TypeError\n * ```\n */\nexport function tagged<T extends Record<string, unknown>>(tag: string): TaggedConstructor<typeof tag, T> {\n type Output = TaggedValue<typeof tag, T>\n\n // Constructor function\n const constructor = (input: T): Output => {\n return Object.freeze({ ...input, _tag: tag }) as Output\n }\n\n // Type guard\n constructor.is = (value: unknown): value is Output => {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"_tag\" in value &&\n // oxlint-disable-next-line no-unsafe-type-assertion -- Already checked with 'in' operator\n (value as Discriminator)._tag === tag\n )\n }\n\n // Equality (static method on constructor)\n constructor.equals = createEqualsMethod<typeof tag, T>(tag)\n\n // Hashing (static method on constructor)\n constructor.hash = createHashMethod<typeof tag, T>(tag)\n\n // Store tag for reflection\n constructor._tag = tag\n\n return constructor as TaggedConstructor<typeof tag, T>\n}\n","import { FxTypeId } from \"../fx/fx.types\"\nimport type { TaggedErrorFactory } from \"./data.tagged-error.types\"\n\n/* oxlint-disable no-unsafe-type-assertion -- Tagged error factories intentionally cast to preserve ergonomic constructor signatures and Fx marker channels. */\n\n/**\n * Create a class-based tagged error type (Effect-style syntax).\n * Returns a class that can be extended to create custom error types.\n * Errors are native Error objects with proper stack traces and instanceof support.\n * Implements Yieldable protocol so errors can be directly yielded in Fx.gen computations.\n *\n * @template Tag - The error tag (discriminator string)\n * @param tag - The error tag\n * @returns A class that can be extended with custom data\n *\n * @example\n * ```ts\n * // Error with data\n * class NotFoundError extends TaggedError(\"NotFoundError\")<{ id: string }> {}\n * const err = new NotFoundError({ id: \"123\" })\n * err.id // \"123\"\n * err._tag // \"NotFoundError\"\n * err.stack // Error stack trace\n *\n * // Error without data\n * class UnauthorizedError extends TaggedError(\"UnauthorizedError\") {}\n * const err2 = new UnauthorizedError()\n *\n * // Direct yielding in Fx.gen computation\n * const program = Fx.gen(function* () {\n * yield* new NotFoundError({ id: \"123\" }) // Short-circuits with error\n * })\n *\n * // instanceof checks work\n * if (err instanceof NotFoundError) {\n * console.log(err.id)\n * }\n * ```\n */\nexport function TaggedError<Tag extends string>(tag: Tag): TaggedErrorFactory<Tag> {\n return class TaggedErrorImpl<Data extends object = object> extends Error {\n static readonly _tag: Tag = tag\n readonly _tag: Tag = tag\n\n readonly [FxTypeId] = {\n _A: () => undefined as never,\n _E: () => this as TaggedErrorImpl<Data>,\n _R: () => undefined as never,\n }\n\n constructor(...args: keyof Data extends never ? [] : [data: Data]) {\n super(tag)\n this.name = tag\n const data = args[0]\n if (data) Object.assign(this, data)\n Object.setPrototypeOf(this, new.target.prototype)\n }\n\n *[Symbol.iterator](): Generator<this, never, unknown> {\n yield this\n throw new Error(\"Unreachable: Fx.gen should short-circuit on error\")\n }\n } as unknown as TaggedErrorFactory<Tag>\n}\n\n/* oxlint-enable no-unsafe-type-assertion */\n","import { deepEquals, deepHash } from \"../equality/equality\"\nimport type { TupleValue } from \"./data.types\"\n\n/**\n * Create a tuple with structural equality.\n *\n * The returned tuple is frozen (immutable) and has non-enumerable\n * equals() and hash() methods for structural comparison.\n *\n * @template T - The tuple type as a readonly array of element types\n * @param args - The tuple elements\n * @returns A frozen tuple-like array with equals() and hash() methods\n *\n * @see {@link array} for variable-length arrays with equality\n * @see {@link struct} for object value types\n *\n * @example\n * ```ts\n * const t1 = tuple(1, \"hello\", true)\n * const t2 = tuple(1, \"hello\", true)\n *\n * t1.equals(t2) // true\n * t1.hash() // number\n *\n * // Access elements (typed)\n * t1[0] // number\n * t1[1] // string\n * t1[2] // boolean\n *\n * // Tuple is frozen\n * t1[0] = 5 // TypeError\n * ```\n */\nexport function tuple<T extends readonly unknown[]>(...args: T): TupleValue<T> {\n const value = [...args]\n\n // Add equals method (non-enumerable)\n Object.defineProperty(value, \"equals\", {\n value: (other: readonly unknown[]) => deepEquals(value, other),\n enumerable: false,\n writable: false,\n configurable: false,\n })\n\n // Add hash method (non-enumerable)\n Object.defineProperty(value, \"hash\", {\n value: () => deepHash(value),\n enumerable: false,\n writable: false,\n configurable: false,\n })\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for generic tuple return type\n return Object.freeze(value) as unknown as TupleValue<T>\n}\n","/**\n * Structural data constructors for tagged objects, tuples, arrays, and records.\n *\n * **Mental model**\n * - `Data` helpers create immutable-friendly values with structural equality semantics.\n * - Use `tagged` and `TaggedError` to model domain objects and errors.\n *\n * **Common tasks**\n * - Build tagged records via `Data.tagged`.\n * - Define typed tagged errors with `Data.TaggedError`.\n * - Create structural containers with `Data.struct`, `Data.tuple`, and `Data.array`.\n *\n * **Gotchas**\n * - These constructors are value-level utilities, not validation schemas.\n * - Prefer explicit tagged names for debugging and pattern matching.\n *\n * **Quickstart**\n *\n * @example\n * ```ts\n * import { Data } from \"@nicolastoulemont/std\"\n *\n * const User = Data.tagged<{ id: string }>(\"User\")\n * const user = User({ id: \"u1\" })\n * // => { _tag: \"User\", id: \"u1\" }\n * ```\n *\n * @module\n */\nimport { array as arrayImpl } from \"./data.array\"\nimport { struct as structImpl } from \"./data.struct\"\nimport { tagged as taggedImpl } from \"./data.tagged\"\nimport { TaggedError as TaggedErrorImpl } from \"./data.tagged-error\"\nexport type { TaggedErrorClass, TaggedErrorFactory, TaggedErrorInstance } from \"./data.tagged-error.types\"\nimport { tuple as tupleImpl } from \"./data.tuple\"\n\n/**\n * Construct tagged data objects.\n *\n * @example\n * ```ts\n * import { Data } from \"@nicolastoulemont/std\"\n *\n * const User = Data.tagged<{ id: string }>(\"User\")\n * const user = User({ id: \"u1\" })\n * // => { _tag: \"User\", id: \"u1\" }\n * ```\n */\nexport const tagged = taggedImpl\n\n/**\n * Construct tagged error classes.\n *\n * @example\n * ```ts\n * import { Data } from \"@nicolastoulemont/std\"\n *\n * class NotFoundError extends Data.TaggedError(\"NotFoundError\")<{ id: string }> {}\n * const error = new NotFoundError({ id: \"u1\" })\n * // => { _tag: \"NotFoundError\", id: \"u1\" }\n * ```\n */\nexport const TaggedError = TaggedErrorImpl\n\n/**\n * Construct immutable-like structs with stable structural behavior.\n *\n * @example\n * ```ts\n * import { Data } from \"@nicolastoulemont/std\"\n *\n * const point = Data.struct({ x: 1, y: 2 })\n * const same = point.equals({ x: 1, y: 2 })\n * // => true\n * ```\n */\nexport const struct = structImpl\n\n/**\n * Construct immutable-like tuples with stable structural behavior.\n *\n * @example\n * ```ts\n * import { Data } from \"@nicolastoulemont/std\"\n *\n * const pair = Data.tuple(\"left\", 1)\n * const first = pair[0]\n * // => \"left\"\n * ```\n */\nexport const tuple = tupleImpl\n\n/**\n * Construct immutable-like arrays with stable structural behavior.\n *\n * @example\n * ```ts\n * import { Data } from \"@nicolastoulemont/std\"\n *\n * const ids = Data.array([\"a\", \"b\"])\n * const upper = ids.map((id) => id.toUpperC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PdqWZ.mjs","names":["array","struct","tagged","TaggedError","tuple","taggedImpl","TaggedErrorImpl","structImpl","tupleImpl","arrayImpl"],"sources":["../src/data/data.array.ts","../src/data/data.struct.ts","../src/data/data.tagged.ts","../src/data/data.tagged-error.ts","../src/data/data.tuple.ts","../src/data/data.ts"],"sourcesContent":["import { deepEquals, deepHash } from \"../equality/equality\"\nimport type { ArrayValue } from \"./data.types\"\n\n/**\n * Create an array with structural equality.\n *\n * The returned array is frozen (immutable) and has non-enumerable\n * equals() and hash() methods for structural comparison.\n *\n * The map() and filter() methods are overridden to return ArrayValue,\n * enabling method chaining with preserved equality semantics.\n *\n * @template T - The element type of the array\n * @param items - The array elements\n * @returns A frozen array with equals(), hash(), map(), and filter()\n *\n * @see {@link tuple} for fixed-length typed tuples\n * @see {@link struct} for object value types\n *\n * @example\n * ```ts\n * const arr1 = array([1, 2, 3])\n * const arr2 = array([1, 2, 3])\n *\n * arr1.equals(arr2) // true\n * arr1.hash() // number\n *\n * // Chainable operations return ArrayValue\n * arr1.map(x => x * 2) // ArrayValue<number>\n * arr1.filter(x => x > 1) // ArrayValue<number>\n *\n * // Chained equality check\n * arr1.map(x => x * 2).equals(array([2, 4, 6])) // true\n *\n * // Array is frozen\n * arr1[0] = 5 // TypeError\n * arr1.push(4) // TypeError\n * ```\n */\nexport function array<T>(items: readonly T[]): ArrayValue<T> {\n const value = [...items]\n\n // Add equals method (non-enumerable)\n Object.defineProperty(value, \"equals\", {\n value: (other: readonly T[]) => deepEquals(value, other),\n enumerable: false,\n writable: false,\n configurable: false,\n })\n\n // Add hash method (non-enumerable)\n Object.defineProperty(value, \"hash\", {\n value: () => deepHash(value),\n enumerable: false,\n writable: false,\n configurable: false,\n })\n\n // Override map to return ArrayValue\n const originalMap = value.map.bind(value)\n Object.defineProperty(value, \"map\", {\n value: <U>(fn: (item: T, index: number, arr: readonly T[]) => U): ArrayValue<U> => {\n return array(originalMap(fn))\n },\n enumerable: false,\n writable: false,\n configurable: false,\n })\n\n // Override filter to return ArrayValue\n const originalFilter = value.filter.bind(value)\n Object.defineProperty(value, \"filter\", {\n value: (fn: (item: T, index: number, arr: readonly T[]) => boolean): ArrayValue<T> => {\n return array(originalFilter(fn))\n },\n enumerable: false,\n writable: false,\n configurable: false,\n })\n\n // Override slice to return ArrayValue\n const originalSlice = value.slice.bind(value)\n Object.defineProperty(value, \"slice\", {\n value: (start?: number, end?: number): ArrayValue<T> => {\n return array(originalSlice(start, end))\n },\n enumerable: false,\n writable: false,\n configurable: false,\n })\n\n // Override concat to return ArrayValue\n const originalConcat = value.concat.bind(value)\n Object.defineProperty(value, \"concat\", {\n value: (...args: readonly (T | readonly T[])[]): ArrayValue<T> => {\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for concat argument spread\n return array(originalConcat(...(args as T[][])))\n },\n enumerable: false,\n writable: false,\n configurable: false,\n })\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for generic array return type\n return Object.freeze(value) as unknown as ArrayValue<T>\n}\n","import { deepEquals, deepHash } from \"../equality/equality\"\nimport type { StructValue } from \"./data.types\"\n\n/**\n * Create a frozen value object with structural equality.\n *\n * Unlike tagged(), struct() does not add a _tag discriminator.\n * Use this for simple value objects that don't need discrimination.\n *\n * The returned object is frozen (immutable) and has non-enumerable\n * equals() and hash() methods for structural comparison.\n *\n * @template T - The object shape type\n * @param input - The object to wrap\n * @returns A frozen object with equals() and hash() methods\n *\n * @see {@link tagged} for discriminated value objects with _tag\n * @see {@link array} for array value types\n *\n * @example\n * ```ts\n * const point = struct({ x: 10, y: 20 })\n * const point2 = struct({ x: 10, y: 20 })\n *\n * point.equals(point2) // true\n * point.hash() // number\n *\n * // Object is frozen\n * point.x = 5 // TypeError\n *\n * // equals/hash are non-enumerable\n * Object.keys(point) // [\"x\", \"y\"]\n * ```\n */\nexport function struct<T extends Record<string, unknown>>(input: T): StructValue<T> {\n const value = { ...input }\n\n // Add equals method (non-enumerable)\n Object.defineProperty(value, \"equals\", {\n value: (other: T) => deepEquals(value, other),\n enumerable: false,\n writable: false,\n configurable: false,\n })\n\n // Add hash method (non-enumerable)\n Object.defineProperty(value, \"hash\", {\n value: () => deepHash(value),\n enumerable: false,\n writable: false,\n configurable: false,\n })\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for generic struct return type\n return Object.freeze(value) as StructValue<T>\n}\n","import { createEqualsMethod, createHashMethod } from \"../equality/equality\"\nimport type { Discriminator } from \"../shared/discriminator.types\"\nimport type { TaggedConstructor, TaggedValue } from \"./data.types\"\n\n/**\n * Create a tagged value constructor without schema validation.\n *\n * Unlike variant(), this creates values directly without validation.\n * Values are frozen and have structural equality via equals() and hash() methods.\n *\n * @template T - The data shape type (excluding _tag)\n * @param tag - The _tag discriminator value\n * @returns A constructor function with is(), equals(), and hash() methods\n *\n * @see {@link variant} for validated variant with schema support\n * @see {@link struct} for untagged value objects\n *\n * @example\n * ```ts\n * const Person = tagged<{ name: string; age: number }>(\"Person\")\n *\n * const alice = Person({ name: \"Alice\", age: 30 })\n * // => { _tag: \"Person\", name: \"Alice\", age: 30 }\n *\n * Person.equals(alice, Person({ name: \"Alice\", age: 30 })) // true\n * Person.is(alice) // true\n *\n * // Type guard usage\n * if (Person.is(unknownValue)) {\n * console.log(unknownValue.name) // TypeScript knows it's a Person\n * }\n *\n * // Values are frozen (immutable)\n * alice.name = \"Bob\" // TypeError\n * ```\n */\nexport function tagged<T extends Record<string, unknown>>(tag: string): TaggedConstructor<typeof tag, T> {\n type Output = TaggedValue<typeof tag, T>\n\n // Constructor function\n const constructor = (input: T): Output => {\n return Object.freeze({ ...input, _tag: tag }) as Output\n }\n\n // Type guard\n constructor.is = (value: unknown): value is Output => {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"_tag\" in value &&\n // oxlint-disable-next-line no-unsafe-type-assertion -- Already checked with 'in' operator\n (value as Discriminator)._tag === tag\n )\n }\n\n // Equality (static method on constructor)\n constructor.equals = createEqualsMethod<typeof tag, T>(tag)\n\n // Hashing (static method on constructor)\n constructor.hash = createHashMethod<typeof tag, T>(tag)\n\n // Store tag for reflection\n constructor._tag = tag\n\n return constructor as TaggedConstructor<typeof tag, T>\n}\n","import { FxTypeId } from \"../fx/fx.types\"\nimport type { TaggedErrorFactory } from \"./data.tagged-error.types\"\n\n/* oxlint-disable no-unsafe-type-assertion -- Tagged error factories intentionally cast to preserve ergonomic constructor signatures and Fx marker channels. */\n\n/**\n * Create a class-based tagged error type (Effect-style syntax).\n * Returns a class that can be extended to create custom error types.\n * Errors are native Error objects with proper stack traces and instanceof support.\n * Implements Yieldable protocol so errors can be directly yielded in Fx.gen computations.\n *\n * @template Tag - The error tag (discriminator string)\n * @param tag - The error tag\n * @returns A class that can be extended with custom data\n *\n * @example\n * ```ts\n * // Error with data\n * class NotFoundError extends TaggedError(\"NotFoundError\")<{ id: string }> {}\n * const err = new NotFoundError({ id: \"123\" })\n * err.id // \"123\"\n * err._tag // \"NotFoundError\"\n * err.stack // Error stack trace\n *\n * // Error without data\n * class UnauthorizedError extends TaggedError(\"UnauthorizedError\") {}\n * const err2 = new UnauthorizedError()\n *\n * // Direct yielding in Fx.gen computation\n * const program = Fx.gen(function* () {\n * yield* new NotFoundError({ id: \"123\" }) // Short-circuits with error\n * })\n *\n * // instanceof checks work\n * if (err instanceof NotFoundError) {\n * console.log(err.id)\n * }\n * ```\n */\nexport function TaggedError<Tag extends string>(tag: Tag): TaggedErrorFactory<Tag> {\n return class TaggedErrorImpl<Data extends object = object> extends Error {\n static readonly _tag: Tag = tag\n readonly _tag: Tag = tag\n\n readonly [FxTypeId] = {\n _A: () => undefined as never,\n _E: () => this as TaggedErrorImpl<Data>,\n _R: () => undefined as never,\n }\n\n constructor(...args: keyof Data extends never ? [] : [data: Data]) {\n super(tag)\n this.name = tag\n const data = args[0]\n if (data) Object.assign(this, data)\n Object.setPrototypeOf(this, new.target.prototype)\n }\n\n *[Symbol.iterator](): Generator<this, never, unknown> {\n yield this\n throw new Error(\"Unreachable: Fx.gen should short-circuit on error\")\n }\n } as unknown as TaggedErrorFactory<Tag>\n}\n\n/* oxlint-enable no-unsafe-type-assertion */\n","import { deepEquals, deepHash } from \"../equality/equality\"\nimport type { TupleValue } from \"./data.types\"\n\n/**\n * Create a tuple with structural equality.\n *\n * The returned tuple is frozen (immutable) and has non-enumerable\n * equals() and hash() methods for structural comparison.\n *\n * @template T - The tuple type as a readonly array of element types\n * @param args - The tuple elements\n * @returns A frozen tuple-like array with equals() and hash() methods\n *\n * @see {@link array} for variable-length arrays with equality\n * @see {@link struct} for object value types\n *\n * @example\n * ```ts\n * const t1 = tuple(1, \"hello\", true)\n * const t2 = tuple(1, \"hello\", true)\n *\n * t1.equals(t2) // true\n * t1.hash() // number\n *\n * // Access elements (typed)\n * t1[0] // number\n * t1[1] // string\n * t1[2] // boolean\n *\n * // Tuple is frozen\n * t1[0] = 5 // TypeError\n * ```\n */\nexport function tuple<T extends readonly unknown[]>(...args: T): TupleValue<T> {\n const value = [...args]\n\n // Add equals method (non-enumerable)\n Object.defineProperty(value, \"equals\", {\n value: (other: readonly unknown[]) => deepEquals(value, other),\n enumerable: false,\n writable: false,\n configurable: false,\n })\n\n // Add hash method (non-enumerable)\n Object.defineProperty(value, \"hash\", {\n value: () => deepHash(value),\n enumerable: false,\n writable: false,\n configurable: false,\n })\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for generic tuple return type\n return Object.freeze(value) as unknown as TupleValue<T>\n}\n","/**\n * Structural data constructors for tagged objects, tuples, arrays, and records.\n *\n * **Mental model**\n * - `Data` helpers create immutable-friendly values with structural equality semantics.\n * - Use `tagged` and `TaggedError` to model domain objects and errors.\n *\n * **Common tasks**\n * - Build tagged records via `Data.tagged`.\n * - Define typed tagged errors with `Data.TaggedError`.\n * - Create structural containers with `Data.struct`, `Data.tuple`, and `Data.array`.\n *\n * **Gotchas**\n * - These constructors are value-level utilities, not validation schemas.\n * - Prefer explicit tagged names for debugging and pattern matching.\n *\n * **Quickstart**\n *\n * @example\n * ```ts\n * import { Data } from \"@nicolastoulemont/std\"\n *\n * const User = Data.tagged<{ id: string }>(\"User\")\n * const user = User({ id: \"u1\" })\n * // => { _tag: \"User\", id: \"u1\" }\n * ```\n *\n * @module\n */\nimport { array as arrayImpl } from \"./data.array\"\nimport { struct as structImpl } from \"./data.struct\"\nimport { tagged as taggedImpl } from \"./data.tagged\"\nimport { TaggedError as TaggedErrorImpl } from \"./data.tagged-error\"\nexport type { TaggedErrorClass, TaggedErrorCore, TaggedErrorFactory, TaggedErrorInstance } from \"./data.tagged-error.types\"\nimport { tuple as tupleImpl } from \"./data.tuple\"\n\n/**\n * Construct tagged data objects.\n *\n * @example\n * ```ts\n * import { Data } from \"@nicolastoulemont/std\"\n *\n * const User = Data.tagged<{ id: string }>(\"User\")\n * const user = User({ id: \"u1\" })\n * // => { _tag: \"User\", id: \"u1\" }\n * ```\n */\nexport const tagged = taggedImpl\n\n/**\n * Construct tagged error classes.\n *\n * @example\n * ```ts\n * import { Data } from \"@nicolastoulemont/std\"\n *\n * class NotFoundError extends Data.TaggedError(\"NotFoundError\")<{ id: string }> {}\n * const error = new NotFoundError({ id: \"u1\" })\n * // => { _tag: \"NotFoundError\", id: \"u1\" }\n * ```\n */\nexport const TaggedError = TaggedErrorImpl\n\n/**\n * Construct immutable-like structs with stable structural behavior.\n *\n * @example\n * ```ts\n * import { Data } from \"@nicolastoulemont/std\"\n *\n * const point = Data.struct({ x: 1, y: 2 })\n * const same = point.equals({ x: 1, y: 2 })\n * // => true\n * ```\n */\nexport const struct = structImpl\n\n/**\n * Construct immutable-like tuples with stable structural behavior.\n *\n * @example\n * ```ts\n * import { Data } from \"@nicolastoulemont/std\"\n *\n * const pair = Data.tuple(\"left\", 1)\n * const first = pair[0]\n * // => \"left\"\n * ```\n */\nexport const tuple = tupleImpl\n\n/**\n * Construct immutable-like arrays with stable structural behavior.\n *\n * @example\n * ```ts\n * import { Data } from \"@nicolastoulemont/std\"\n *\n * const ids = Data.array([\"a\", \"b\"])\n * const upper = ids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+1,2 @@
|
|
|
1
|
-
import { r as duration_d_exports } from "../index-
|
|
1
|
+
import { r as duration_d_exports } from "../index-DCUGtEcj.mjs";
|
|
2
2
|
export { duration_d_exports as Duration };
|
package/dist/fx/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as fx_d_exports } from "../index-
|
|
1
|
+
import { t as fx_d_exports } from "../index-C4DOLLaU.mjs";
|
|
2
2
|
export { fx_d_exports as Fx };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as TaggedErrorFactory } from "./index-
|
|
1
|
+
import { n as TaggedErrorFactory } from "./index-B2Z7-XGR.mjs";
|
|
2
2
|
import { i as QueueOptions, n as Queue, r as QueueBoundedOptions } from "./queue.types-B-l5XYbU.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/queue/queue.d.ts
|
|
@@ -104,4 +104,4 @@ declare const bounded: (maxSize: number, options?: QueueBoundedOptions) => Queue
|
|
|
104
104
|
declare const unbounded: (options?: QueueOptions) => Queue;
|
|
105
105
|
//#endregion
|
|
106
106
|
export { queue_d_exports as t };
|
|
107
|
-
//# sourceMappingURL=index-
|
|
107
|
+
//# sourceMappingURL=index-B0flvtFB.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-B0flvtFB.d.mts","names":[],"sources":["../src/queue/queue.ts"],"sourcesContent":[],"mappings":";;;;;;;cAsCsB,uBAAA;;;;;;;;;;;;cAcT,gBAAA,SAAyB;;;cAA0E,wBAAA;;;;;;;;;;;;cAYnG,iBAAA,SAA0B;;;cAA8D,4BAAA;;;;;;;;;;;;cAYxF,qBAAA,SAA8B;;;;;;;;;;;;;;;cAoG9B,iCAAgC;;;;;;;;;;;;;cAoWhC,iBAAkB,iBAAe;;;;;;;;;;;;;cAcjC,qCAAsC,wBAAsB;;;;;;;;;;;;;cAc5D,sBAAuB,iBAAe"}
|
|
@@ -289,7 +289,7 @@ declare function TaggedError$1<Tag extends string>(tag: Tag): TaggedErrorFactory
|
|
|
289
289
|
*/
|
|
290
290
|
declare function tuple$1<T extends readonly unknown[]>(...args: T): TupleValue<T>;
|
|
291
291
|
declare namespace data_d_exports {
|
|
292
|
-
export { TaggedError, TaggedErrorClass, TaggedErrorFactory, TaggedErrorInstance, array, struct, tagged, tuple };
|
|
292
|
+
export { TaggedError, TaggedErrorClass, TaggedErrorCore, TaggedErrorFactory, TaggedErrorInstance, array, struct, tagged, tuple };
|
|
293
293
|
}
|
|
294
294
|
/**
|
|
295
295
|
* Construct tagged data objects.
|
|
@@ -358,4 +358,4 @@ declare const tuple: typeof tuple$1;
|
|
|
358
358
|
declare const array: typeof array$1;
|
|
359
359
|
//#endregion
|
|
360
360
|
export { TaggedErrorFactory as n, data_d_exports as t };
|
|
361
|
-
//# sourceMappingURL=index-
|
|
361
|
+
//# sourceMappingURL=index-B2Z7-XGR.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-B2Z7-XGR.d.mts","names":[],"sources":["../src/data/data.types.ts","../src/data/data.array.ts","../src/data/data.struct.ts","../src/data/data.tagged.ts","../src/data/data.tagged-error.types.ts","../src/data/data.tagged-error.ts","../src/data/data.tuple.ts","../src/data/data.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAUY,KAAA,WAAW,CAAA,YAAA,MAAA,EAAA,CAAA,CAAA,GAA0B,QAA1B,CAAmC,CAAnC,CAAA,GAAwC,aAAxC,CAAsD,GAAtD,CAAA;;;;;;AAOX,KAAA,iBAAiB,CAAA,YAAA,MAAA,EAAA,CAAA,CAAA,GAAA;EAEZ;EAEP,SAAA,IAAA,EAFO,GAEP;EAAgB;EAAK,CAAA,KAAA,EAArB,CAAqB,CAAA,EAAjB,WAAiB,CAAL,GAAK,EAAA,CAAA,CAAA;EAAjB;EAE6B,EAAA,CAAA,KAAA,EAAA,OAAA,CAAA,EAAA,KAAA,IAAZ,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,OO3BG,aP2BH;;;;;;;;;;;;;AAOC,cOpBT,MPoBS,EAAA,OOpBH,QPoBG;;;;;;;;;;;;;cONT,cAAK;;;ANnDlB;;;;;;;;ACLA;;AAAiE,cKsEpD,KLtEoD,EAAA,OKsE/C,OLtE+C"}
|
|
@@ -0,0 +1,64 @@
|
|
|
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-E1pjcc0Y.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
|
+
type RefineFn = {
|
|
18
|
+
<S extends SyncSchema, Base extends Input<S>>(value: Base, schema: S): value is Refine<Base, S>;
|
|
19
|
+
<S extends SyncSchema>(schema: S): <Base extends Input<S>>(value: Base) => value is Refine<Base, S>;
|
|
20
|
+
};
|
|
21
|
+
type Is = {
|
|
22
|
+
<Base, Sub extends Base>(value: Base, schema: SyncRefinementSchema<Base, Sub>): value is Sub;
|
|
23
|
+
<S extends SyncSchema>(value: unknown, schema: S): value is Output<S>;
|
|
24
|
+
<Base, Sub extends Base>(schema: SyncRefinementSchema<Base, Sub>): (value: Base) => value is Sub;
|
|
25
|
+
<S extends SyncSchema>(schema: S): (value: unknown) => value is Output<S>;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Create a sync-only schema-backed reusable type guard that preserves the original value shape.
|
|
29
|
+
*
|
|
30
|
+
* Use this when a schema validates only a subset of a broader in-memory value
|
|
31
|
+
* and you need the preserved shape to survive higher-order APIs like
|
|
32
|
+
* `Array.filter`. The narrowed type is `Base & Output<typeof schema>`, not the
|
|
33
|
+
* exact schema output.
|
|
34
|
+
*
|
|
35
|
+
* Supports both data-first and data-last styles:
|
|
36
|
+
* - Data-first: `Schema.refine(value, schema)`
|
|
37
|
+
* - Data-last: `Schema.refine(schema)(value)`
|
|
38
|
+
*
|
|
39
|
+
* Only use this with sync proof schemas that validate properties already
|
|
40
|
+
* present on the original value. Transforms, defaults, and coercions are not
|
|
41
|
+
* safe here because they can change the schema output without changing the
|
|
42
|
+
* original input value.
|
|
43
|
+
*/
|
|
44
|
+
declare function refine<S extends SyncSchema, Base extends Input<S>>(value: Base, schema: S): value is Refine<Base, S>;
|
|
45
|
+
declare function refine<S extends SyncSchema>(schema: S): <Base extends Input<S>>(value: Base) => value is Refine<Base, S>;
|
|
46
|
+
/**
|
|
47
|
+
* Create a sync-only schema-backed proof guard.
|
|
48
|
+
*
|
|
49
|
+
* On `unknown` values this narrows to the exact schema output. On already-typed
|
|
50
|
+
* values, TypeScript preserves the current shape during direct control-flow
|
|
51
|
+
* checks. Use `Schema.refine` when that preserved shape must survive
|
|
52
|
+
* higher-order APIs like `Array.filter`.
|
|
53
|
+
*
|
|
54
|
+
* Supports both data-first and data-last styles:
|
|
55
|
+
* - Data-first: `Schema.is(value, schema)`
|
|
56
|
+
* - Data-last: `Schema.is(schema)(value)`
|
|
57
|
+
*/
|
|
58
|
+
declare function is<Base, Sub extends Base>(value: Base, schema: SyncRefinementSchema<Base, Sub>): value is Sub;
|
|
59
|
+
declare function is<S extends SyncSchema>(value: unknown, schema: S): value is Output<S>;
|
|
60
|
+
declare function is<Base, Sub extends Base>(schema: SyncRefinementSchema<Base, Sub>): (value: Base) => value is Sub;
|
|
61
|
+
declare function is<S extends SyncSchema>(schema: S): (value: unknown) => value is Output<S>;
|
|
62
|
+
//#endregion
|
|
63
|
+
export { schema_d_exports as t };
|
|
64
|
+
//# sourceMappingURL=index-B41_sFR6.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-B41_sFR6.d.mts","names":[],"sources":["../src/schema/schema.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;iBA0DgB,gBAAgB,oBAAoB,YAAY,MAAM,OAAO,OAAW,OAAO,IAAI;iBACnF,gBAAgB,0BACtB,YACC,MAAM,OAAO,QAAQ,OAAW,OAAO,IAAI;KAoB1C,QAAA;aACC,yBAAyB,MAAM,WAAW,cAAc,aAAa,OAAQ,MAAM;aACnF,oBAAoB,kBAAkB,MAAM,WAAW,kBAAkB,OAAQ,MAAM;;KAGxF,EAAA;qBACS,aAAa,cAAc,qBAAqB,MAAM,gBAAgB;aAC9E,oCAAoC,aAAa,OAAO;qBAChD,cAAc,qBAAqB,MAAM,eAAe,kBAAkB;aAClF,oBAAoB,iCAAiC,OAAO;;AAhCzE;;;;;;;;;;AACA;;;;;;;AAEsD,iBAsDtC,MAtDsC,CAAA,UAsDrB,UAtDqB,EAAA,aAsDI,KAtDJ,CAsDU,CAtDV,CAAA,CAAA,CAAA,KAAA,EAsDqB,IAtDrB,EAAA,MAAA,EAsDmC,CAtDnC,CAAA,EAAA,KAAA,IAsDgD,MAtDhD,CAsDwD,IAtDxD,EAsD8D,CAtD9D,CAAA;AAAtB,iBAuDhB,MAvDgB,CAAA,UAuDC,UAvDD,CAAA,CAAA,MAAA,EAuDqB,CAvDrB,CAAA,EAAA,CAAA,aAuDuC,KAvDvC,CAuD6C,CAvD7C,CAAA,CAAA,CAAA,KAAA,EAuDwD,IAvDxD,EAAA,GAAA,KAAA,IAuD0E,MAvD1E,CAuDkF,IAvDlF,EAuDwF,CAvDxF,CAAA;;;AAoBhC;;;;;;;;;;AAEiC,iBAsDjB,EAtDiB,CAAA,IAAA,EAAA,YAsDI,IAtDJ,CAAA,CAAA,KAAA,EAsDiB,IAtDjB,EAAA,MAAA,EAsD+B,oBAtD/B,CAsDoD,IAtDpD,EAsD0D,GAtD1D,CAAA,CAAA,EAAA,KAAA,IAsD0E,GAtD1E;AAAwB,iBAuDzC,EAvDyC,CAAA,UAuD5B,UAvD4B,CAAA,CAAA,KAAA,EAAA,OAAA,EAAA,MAAA,EAuDQ,CAvDR,CAAA,EAAA,KAAA,IAuDqB,MAvDrB,CAuD4B,CAvD5B,CAAA;AAAN,iBAwDnC,EAxDmC,CAAA,IAAA,EAAA,YAwDd,IAxDc,CAAA,CAAA,MAAA,EAwDA,oBAxDA,CAwDqB,IAxDrB,EAwD2B,GAxD3B,CAAA,CAAA,EAAA,CAAA,KAAA,EAwD0C,IAxD1C,EAAA,GAAA,KAAA,IAwD4D,GAxD5D;AAAiB,iBAyDpD,EAzDoD,CAAA,UAyDvC,UAzDuC,CAAA,CAAA,MAAA,EAyDnB,CAzDmB,CAAA,EAAA,CAAA,KAAA,EAAA,OAAA,EAAA,GAAA,KAAA,IAyDc,MAzDd,CAyDqB,CAzDrB,CAAA"}
|
|
@@ -2,7 +2,7 @@ import { a as FxError, c as FxTypeId, d as FxYieldable, f as RunnableFx, h as is
|
|
|
2
2
|
import { a as ResultFromTry, m as Ok, p as Err, t as Result } from "./result.types-BKzChyWY.mjs";
|
|
3
3
|
import { r as Option } from "./option.types-D9hrKcfa.mjs";
|
|
4
4
|
import { t as Concurrency } from "./queue.types-B-l5XYbU.mjs";
|
|
5
|
-
import { n as SyncRetrySchedule, t as RetrySchedule } from "./schedule-
|
|
5
|
+
import { n as SyncRetrySchedule, t as RetrySchedule } from "./schedule-D2651VJY.mjs";
|
|
6
6
|
|
|
7
7
|
//#region src/fx/exit.d.ts
|
|
8
8
|
/**
|
|
@@ -455,4 +455,4 @@ declare const match: {
|
|
|
455
455
|
};
|
|
456
456
|
//#endregion
|
|
457
457
|
export { fx_d_exports as t };
|
|
458
|
-
//# sourceMappingURL=index-
|
|
458
|
+
//# sourceMappingURL=index-C4DOLLaU.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-C4DOLLaU.d.mts","names":[],"sources":["../src/fx/exit.ts","../src/fx/fx.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;KAUK,MAAA;;;;AAToD;AA+BzD;;;;;;;AAmBuF;;;;;;;AAiGvF;;AA3GoC,KATxB,IASwB,CAAA,GAAA,EAAA,GAAA,CAAA,GATX,EASW,CATR,GASQ,CAAA,GATH,GASG,CATC,GASD,CAAA,GATM,MASN;;;;KAsC/B,SAT8B,CAAA,GAAA,EAAA,GAAA,EAAA,GAAA,CAAA,GAAA;EAAG,SAAA,EAAA,EAAA,CAAA,KAAA,EAUf,GAVe,EAAA,GAUT,GAVS;EAAR,SAAA,GAAA,EAAA,CAAA,KAAA,EAWN,GAXM,EAAA,GAWA,GAXA;EAAqB,SAAA,MAAA,EAAA,CAAA,MAAA,EAAA,OAAA,EAAA,GAYX,GAZW;CAoC5B;;;;AAA8B,cA0CxC,IA1CwC,EAAA;EAAG,SAAA,EAAA,EAAA,CAAA,GAAA,CAAA,CAAA,KAAA,EAjE3B,GAiE2B,EAAA,GAjEvB,EAiEuB,CAjEpB,GAiEoB,CAAA;EAAhB,SAAA,GAAA,EAAA,CAAA,GAAA,CAAA,CAAA,KAAA,EA5DV,GA4DU,EAAA,GA5DN,GA4DM,CA5DF,GA4DE,CAAA;EAAqB,SAAA,MAAA,EAAA,CAAA,MAAA,EAAA,OAAA,EAAA,GAvDpB,MAuDoB;EAC7B,SAAA,IAAA,EAAA,CAAA,GAAA,EAAA,GAAA,CAAA,CAAA,IAAA,EA/CN,IA+CM,CA/CD,GA+CC,E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ACtB,OAAO,KAAG,KAAG,SAAO,aAClC,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4BN,uCAAiC,0DACrB,iBAAiB,KAAG,KAAG,qBAC3B,QAAQ,KAAG,KAAG,SAAO,aACnC,YAAY;;;;;;;;;;;;KA+HH;;2BACK,sBAAsB,QAAQ;iBAAoB;OAAS;;;;;;;;;;;;;;;;cA4D/D,YAAG;;;;;;;;;;;;;;cAeH,WAAE;;;;;;;;;;;;;;cAeF,YAAG;;;;;;;;;;;;;;;;;;;;cAqBH;gBAtiBC,iDAAiD,mBAAmB,gBAAc,IAAI,YAAY,MAAI;aACvG,yBACC,kBACG,2CAA2C,SAAO,YAAY,MAAI;;;;;;;;;;;;;;;cAkjBtE;;;;;;;;;;;;;;;;;;;;;;;;;;;cAaA,eAAE,MAAA,OAAA;;;;;;;;;;;;cAaF,kBAAG,QAAA,cAAA;;;;;;;;;;;;cAaH,mBAAM,MAAA,OAAA,YAAA;cAEb,MAAY;;;;;;;;;;;;;;cA+BL;;;iBArKqC,aAAa,YAAY,GAAG,OAAK;;;oBAC9B,YAAY,GAAG,eAAa,MAAM"}
|
|
@@ -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-E1pjcc0Y.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-C6W3_n_Q.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index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;;AAMA;;;;;AAAuG;AAW5E;AAe3B;;;AACgB,KG1CJ,KH0CI,CAAA,CAAA,CAAA,GG1CO,QH0CP,CG1CoB,CH0CpB,CAAA;;;;;;;;;;;;;;AAchB;;AACiD,KGxCrC,YHwCqC,CAAA,CAAA,CAAA,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-D8rDE60Y.d.mts","names":[],"sources":["../src/order/order.types.ts","../src/order/order.ts"],"sourcesContent":[],"mappings":";;;;AAOA;AAOA;;;AAAgD,KAPpC,UAAA,GAOoC,CAAA,CAAA,GAAA,CAAA,GAAA,CAAA;;AAKhD;;;;KALY,uBAAqB,SAAS,MAAM;;;;KAKpC;oBACQ;oBACA;;;;;;;AAdpB;AAOA;;;;;AAKA;;KCsBY,WAAW,QAAU;;;;;;;;;;;KAYrB,QAAA,GAAW;;;;;;;;;;;;;;;;;;;;AAZX,iBAiCI,
|
|
1
|
+
{"version":3,"file":"index-D8rDE60Y.d.mts","names":[],"sources":["../src/order/order.types.ts","../src/order/order.ts"],"sourcesContent":[],"mappings":";;;;AAOA;AAOA;;;AAAgD,KAPpC,UAAA,GAOoC,CAAA,CAAA,GAAA,CAAA,GAAA,CAAA;;AAKhD;;;;KALY,uBAAqB,SAAS,MAAM;;;;KAKpC;oBACQ;oBACA;;;;;;;AAdpB;AAOA;;;;;AAKA;;KCsBY,WA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as TaggedErrorFactory } from "./index-B2Z7-XGR.mjs";
|
|
3
3
|
import { t as Result } from "./index-CIvNgjsx.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/duration/duration.d.ts
|
|
@@ -93,4 +93,4 @@ declare const parse: (input: string) => Result<Duration, DurationParseError>;
|
|
|
93
93
|
declare const from: (input: Input) => Result<Duration, InputError>;
|
|
94
94
|
//#endregion
|
|
95
95
|
export { InputError as n, duration_d_exports as r, Input as t };
|
|
96
|
-
//# sourceMappingURL=index-
|
|
96
|
+
//# sourceMappingURL=index-DCUGtEcj.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-DCUGtEcj.d.mts","names":[],"sources":["../src/duration/duration.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;KA4BY,QAAA,GAAW;;;;KAKX,IAAA;;;;KAiBA,WAAA,gBAA2B;;;;KAK3B,KAAA,GAAQ,oBAAoB;cAAW,yBAAA;;;;cAKtC,kBAAA,SAA2B;;;AAhCxC,CAAA,CAAA,CAAA;AAsBA,cAaK,8BAbsC,EAatC,kBAbsC,CAAA,2BAAA,CAAA;AAK3C;AAAmD;AAKnD;AAGK,cAKQ,yBAAA,SAAkC,8BAL1C,CAAA;EAKQ,KAAA,EAAA,MAAA;EAGR,OAAA,EAAA,MAAA;AAKL,CAAA,CAAA,CAAA;cALK,8BAQK,EARL,kBAQK,CAAA,2BAAA,CAAA;;;;AAME,cATC,yBAAA,SAAkC,8BASJ,CAAA;EAK/B,KAAA,EAbH,KAaG;EAAa,OAAA,EAAA,MAAA;EAA4B,KAAA,CAAA,EAX3C,kBAW2C,GAXtB,yBAWsB;CAAqB,CAAA,CAAA;AAwB1E;AAKA;AAKA;AAKa,KA5CD,UAAA,GAAa,kBA4CkD;AAK3E;AAKA;AAKA;AAiCa,KAvFD,UAAA,GAAa,yBAkHxB,GAlHoD,kBAkHpD,GAlHyE,yBAkHzE;;;;AA3BkD,cA/DtC,MA+DsC,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,GA/DZ,QA+DY;AAgCnD;;;AAA4D,cA1F/C,OA0F+C,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,GA1FpB,QA0FoB;;;;cArF/C,4BAA2B;;;;cAK3B,0BAAyB;;;;cAKzB,yBAAwB;;;;cAKxB,0BAAyB;;;;cAKzB,qBAAsB;;;;cAiCtB,0BAAyB,OAAc,UAAU;;;;cAgCjD,cAAe,UAAQ,OAAc,UAAU"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { t as adt_d_exports } from "./index-
|
|
1
|
+
import { t as adt_d_exports } from "./index-C6W3_n_Q.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";
|
|
5
5
|
import "./context/index.mjs";
|
|
6
|
-
import { t as data_d_exports } from "./index-
|
|
6
|
+
import { t as data_d_exports } from "./index-B2Z7-XGR.mjs";
|
|
7
7
|
import { n as result_d_exports } from "./index-CIvNgjsx.mjs";
|
|
8
|
-
import { r as duration_d_exports } from "./index-
|
|
8
|
+
import { r as duration_d_exports } from "./index-DCUGtEcj.mjs";
|
|
9
9
|
import { t as either_d_exports } from "./index-dCRymj_g.mjs";
|
|
10
10
|
import { n as flow, t as pipe } from "./index-D7mFNjot.mjs";
|
|
11
|
-
import { r as schedule_d_exports } from "./schedule-
|
|
12
|
-
import { t as fx_d_exports } from "./index-
|
|
11
|
+
import { r as schedule_d_exports } from "./schedule-D2651VJY.mjs";
|
|
12
|
+
import { t as fx_d_exports } from "./index-C4DOLLaU.mjs";
|
|
13
13
|
import { r as scope_d_exports } from "./scope-CuM3CzwG.mjs";
|
|
14
14
|
import { t as layer_d_exports } from "./index-uE3S3Krx.mjs";
|
|
15
15
|
import { t as multithread_d_exports } from "./index-DR7hzXU4.mjs";
|
|
@@ -17,9 +17,9 @@ import { t as option_d_exports } from "./index-BqJ1GWAF.mjs";
|
|
|
17
17
|
import { t as order_d_exports } from "./index-D8rDE60Y.mjs";
|
|
18
18
|
import { t as predicate_d_exports } from "./index-CNTYbcY9.mjs";
|
|
19
19
|
import { t as provide_d_exports } from "./index-crtzMG48.mjs";
|
|
20
|
-
import { t as queue_d_exports } from "./index-
|
|
20
|
+
import { t as queue_d_exports } from "./index-B0flvtFB.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-B41_sFR6.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-DstB1_VK.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/queue/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as queue_d_exports } from "../index-
|
|
1
|
+
import { t as queue_d_exports } from "../index-B0flvtFB.mjs";
|
|
2
2
|
export { queue_d_exports as Queue };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { r as schedule_d_exports } from "../schedule-
|
|
1
|
+
import { r as schedule_d_exports } from "../schedule-D2651VJY.mjs";
|
|
2
2
|
export { schedule_d_exports as Schedule };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as TaggedErrorFactory } from "./index-
|
|
2
|
-
import { n as InputError, t as Input } from "./index-
|
|
1
|
+
import { n as TaggedErrorFactory } from "./index-B2Z7-XGR.mjs";
|
|
2
|
+
import { n as InputError, t as Input } from "./index-DCUGtEcj.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/schedule/schedule.d.ts
|
|
5
5
|
declare namespace schedule_d_exports {
|
|
@@ -180,4 +180,4 @@ declare const fixed: (options: FixedScheduleOptions) => AsyncRetrySchedule;
|
|
|
180
180
|
declare const exponential: (options: ExponentialScheduleOptions) => AsyncRetrySchedule;
|
|
181
181
|
//#endregion
|
|
182
182
|
export { SyncRetrySchedule as n, schedule_d_exports as r, RetrySchedule as t };
|
|
183
|
-
//# sourceMappingURL=schedule-
|
|
183
|
+
//# sourceMappingURL=schedule-D2651VJY.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedule-
|
|
1
|
+
{"version":3,"file":"schedule-D2651VJY.d.mts","names":[],"sources":["../src/schedule/schedule.ts"],"sourcesContent":[],"mappings":";;;;;;;AAoPA;AAiBA;AAmBA;;;;;;;;;;;;KAzOY,aAAA,GAAgB,oBAAoB;;;;;;;;;;;KAYpC,iBAAA;;;;;;;;;;;;;;;;KAiBA,kBAAA;;;;;;cAKX,qCAAA;;;;;;;;;;;;;;;cAgBY,8BAAA,SAAuC;;;;cAG/C,gCAAA;;;;;;;;;;;;;;;;cAiBQ,yBAAA,SAAkC;;SAEtC;;UAEC;;cACL,iCAAA;;;;;;;;;;;;;;;cAgBQ,0BAAA,SAAmC;;;;KAK3C,oBAAA;;;;;;kBAMa;;KAGb,0BAAA;;;;;;sBAMiB;;;;;;;;;;sBAUA;;;;;;;;;;;;;;cA4ET,2BAA0B;;;;;;;;;;;;;cAiB1B,iBAAkB,yBAAuB;;;;;;;;;;;;;;cAmBzC,uBAAwB,+BAA6B"}
|
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-B41_sFR6.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-DstB1_VK.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:()=>f,parse:()=>c,refine:()=>u});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`);function u(...e){return l(...e)}const d=t(2,(e,t)=>a(t,e,`Schema.is()`)._tag===`Ok`);function f(...e){return d(...e)}export{s as t};
|
|
2
|
+
//# sourceMappingURL=schema-DstB1_VK.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-DstB1_VK.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.is` is a sync-only proof guard for direct in-memory checks.\n * - `Schema.refine` is the reusable preserved-shape guard for higher-order APIs like `Array.filter`.\n *\n * **Common tasks**\n * - Parse loose external data into validated subtypes.\n * - Use `Schema.is` for direct control-flow checks against already-typed values.\n * - Reuse a schema as a preserved-shape predicate with `Schema.refine`.\n * - Name reusable narrowed types with `Schema.Refine<Base, typeof schema>` or exact schema outputs with `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.is` and `Schema.refine` must only be used with proof schemas that validate the current value in place.\n * - Transforms, defaults, coercions, and other output-changing schemas should use `Schema.parse`.\n * - `Schema.is` narrows `unknown` to the exact schema output, but in direct control flow TypeScript preserves the current value shape.\n * - `Schema.refine` exists for the cases where you need that preserved shape to survive higher-order APIs like `Array.filter`.\n *\n * @module\n */\nimport { dual } from \"../shared/dual\"\nimport { isPromise } from \"../shared/is-promise\"\nimport { toThrownValidationError, toValidationResult, validateSync } from \"./schema.shared\"\nimport type {\n Input,\n Output,\n Refine as Refined,\n SyncRefinementSchema,\n SyncSchema,\n ValidationError,\n} 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\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\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 */\nconst refineImpl = dual(2, (value: unknown, schema: SyncSchema) => {\n return validateSync(schema, value, \"Schema.refine()\")._tag === \"Ok\"\n}) as RefineFn\n\n/**\n * Create a sync-only schema-backed reusable 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 * and you need the preserved shape to survive higher-order APIs like\n * `Array.filter`. The narrowed type is `Base & Output<typeof schema>`, not the\n * 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 proof schemas that validate properties already\n * present on the original value. Transforms, defaults, and coercions are not\n * safe here because they can change the schema output without changing the\n * original input value.\n */\nexport function refine<S extends SyncSchema, Base extends Input<S>>(value: Base, schema: S): value is Refined<Base, S>\nexport function refine<S extends SyncSchema>(schema: S): <Base extends Input<S>>(value: Base) => value is Refined<Base, S>\nexport function refine(...args: [value: unknown, schema: SyncSchema] | [schema: SyncSchema]) {\n return (refineImpl as (...args: [unknown, SyncSchema] | [SyncSchema]) => boolean | ((value: unknown) => boolean))(...args)\n}\n\nconst isImpl = dual(2, (value: unknown, schema: SyncSchema) => {\n return validateSync(schema, value, \"Schema.is()\")._tag === \"Ok\"\n}) as Is\n\n/**\n * Create a sync-only schema-backed proof guard.\n *\n * On `unknown` values this narrows to the exact schema output. On already-typed\n * values, TypeScript preserves the current shape during direct control-flow\n * checks. Use `Schema.refine` when that preserved shape must survive\n * higher-order APIs like `Array.filter`.\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 function is<Base, Sub extends Base>(value: Base, schema: SyncRefinementSchema<Base, Sub>): value is Sub\nexport function is<S extends SyncSchema>(value: unknown, schema: S): value is Output<S>\nexport function is<Base, Sub extends Base>(schema: SyncRefinementSchema<Base, Sub>): (value: Base) => value is Sub\nexport function is<S extends SyncSchema>(schema: S): (value: unknown) => value is Output<S>\nexport function is(...args: [value: unknown, schema: SyncSchema] | [schema: SyncSchema]) {\n return (isImpl as (...args: [unknown, SyncSchema] | [SyncSchema]) => boolean | ((value: unknown) => boolean))(...args)\n}\n/* oxlint-enable no-explicit-any, no-unsafe-return, no-unsafe-type-assertion */\n"],"mappings":"qQA8DA,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,GAkBvD,MAAM,EAAa,EAAK,GAAI,EAAgB,IACnC,EAAa,EAAQ,EAAO,kBAAkB,CAAC,OAAS,KAC/D,CAqBF,SAAgB,EAAO,GAAG,EAAmE,CAC3F,OAAQ,EAA0G,GAAG,EAAK,CAG5H,MAAM,EAAS,EAAK,GAAI,EAAgB,IAC/B,EAAa,EAAQ,EAAO,cAAc,CAAC,OAAS,KAC3D,CAkBF,SAAgB,EAAG,GAAG,EAAmE,CACvF,OAAQ,EAAsG,GAAG,EAAK"}
|
|
@@ -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,22 @@ 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 by
|
|
18
|
+
* `Schema.is()` when the starting value is `unknown`.
|
|
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. This is also the shape TypeScript derives in
|
|
26
|
+
* direct control-flow checks when `Schema.is()` is used on an already-typed
|
|
27
|
+
* value.
|
|
28
|
+
*/
|
|
29
|
+
type Refine<Base, S extends StandardSchemaV1> = Base extends Input<S> ? Base extends unknown ? Prettify<Base & Output<S>> : never : never;
|
|
13
30
|
/**
|
|
14
31
|
* Normalized validation issue shape used across std modules.
|
|
15
32
|
*/
|
|
@@ -41,5 +58,5 @@ type RefinementSchema<Base, Sub extends Base> = StandardSchemaV1<Base, Sub>;
|
|
|
41
58
|
*/
|
|
42
59
|
type SyncRefinementSchema<Base, Sub extends Base> = SyncSchema<Base, Sub>;
|
|
43
60
|
//#endregion
|
|
44
|
-
export {
|
|
45
|
-
//# sourceMappingURL=schema.types-
|
|
61
|
+
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 };
|
|
62
|
+
//# sourceMappingURL=schema.types-E1pjcc0Y.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.types-E1pjcc0Y.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,CAAA,CAAA,QAAA,CAAA;;;;;AAQlB;;AAAuD,KAA3C,KAA2C,CAAA,UAA3B,gBAA2B,CAAA,GAAP,MAAO,CAAA,CAAA,CAAA;;;AAUvD;;;;;;AAEe,KAFH,MAEG,CAAA,IAAA,EAAA,UAFoB,gBAEpB,CAAA,GAFwC,IAExC,SAFqD,KAErD,CAF2D,CAE3D,CAAA,GADX,IACW,SAAA,OAAA,GAAT,QAAS,CAAA,IAAA,GAAO,MAAP,CAAc,CAAd,CAAA,CAAA,GAAA,KAAA,GAAA,KAAA;;;;AAAD,KAOF,eAAA,GAPE;EAOF,SAAA,OAAA,EAAe,MAAA;EAQf,SAAA,IAAA,CAAA,EANM,aAMS,CANK,WAOC,CAAA,GAAA,SAAd;AAOnB,CAAA;;;;AAAkE,KARtD,eAAA,GAQsD;EAAL,SAAA,MAAA,EAP1C,aAO0C,CAP5B,eAO4B,CAAA;CACf;;;;;AACZ,KAFtB,UAEuC,CAAA,SAAA,OAAA,EAAA,UAFA,MAEA,CAAA,GAFU,IAEV,CAFe,gBAEf,CAFgC,MAEhC,EAFwC,OAExC,CAAA,EAAA,WAAA,CAAA,GAAA;EAAM,SAAA,WAAA,EADjC,IACiC,CAD5B,gBAC4B,CADX,MACW,EADH,OACG,CAAA,CAAA,WAAA,CAAA,EAAA,UAAA,CAAA,GAAA;IAO7C,QAAA,EAAA,CAAA,KAAgB,EAAA,OAAA,EAAA,GAPM,gBAAA,CAAiB,MAOvB,CAP8B,OAO9B,CAAA;EAAmB,CAAA;CAAyB;;;;AAK5D,KALA,gBAKoB,CAAA,IAAA,EAAA,YALe,IAKf,CAAA,GALuB,gBAKvB,CALwC,IAKxC,EAL8C,GAK9C,CAAA;;;;AAA2B,KAA/C,oBAA+C,CAAA,IAAA,EAAA,YAAR,IAAQ,CAAA,GAAA,UAAA,CAAW,IAAX,EAAiB,GAAjB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,36 +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,OAAQ,EAAgB,EAAO,OAAO,CAAE,CAAC,CAGxDC,EAAU,EAAO,MAAM,CAGhC,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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.types-CFzzx4bw.d.mts","names":[],"sources":["../src/schema/schema.types.ts"],"sourcesContent":[],"mappings":";;;;;;AAKA;AAA4B,KAAhB,KAAgB,CA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