wellcrafted 0.32.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -55
- package/dist/error/index.d.ts +83 -101
- package/dist/error/index.d.ts.map +1 -1
- package/dist/error/index.js +69 -78
- package/dist/error/index.js.map +1 -1
- package/dist/{index-Cd0uJHqj.d.ts → index-8WW9UMob.d.ts} +2 -2
- package/dist/{index-Cd0uJHqj.d.ts.map → index-8WW9UMob.d.ts.map} +1 -1
- package/dist/json.d.ts +25 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +0 -0
- package/dist/query/index.d.ts +2 -3
- package/dist/query/index.d.ts.map +1 -1
- package/dist/query/index.js.map +1 -1
- package/dist/result/index.d.ts +3 -3
- package/dist/{result-DolxQXIZ.d.ts → result-BgPMmUXd.d.ts} +2 -26
- package/dist/result-BgPMmUXd.d.ts.map +1 -0
- package/dist/result-DnOm5ds5.js.map +1 -1
- package/dist/standard-schema/index.d.ts +1 -7
- package/dist/standard-schema/index.d.ts.map +1 -1
- package/dist/standard-schema/index.js.map +1 -1
- package/package.json +5 -1
- package/dist/result-DolxQXIZ.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["schema: T","innerSchema: TSchema","value: unknown","issue: StandardSchemaV1.Issue","options: StandardJSONSchemaV1.Options","innerSchema: TSchema","value: unknown","issue: StandardSchemaV1.Issue","options: StandardJSONSchemaV1.Options","dataSchema: TDataSchema","errorSchema: TErrorSchema","value: unknown","innerResult","issue: StandardSchemaV1.Issue","options: StandardJSONSchemaV1.Options"],"sources":["../../src/standard-schema/failures.ts","../../src/standard-schema/types.ts","../../src/standard-schema/err.ts","../../src/standard-schema/ok.ts","../../src/standard-schema/result.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"./types.js\";\n\nexport const FAILURES = {\n\tEXPECTED_OBJECT: { issues: [{ message: \"Expected object\" }] },\n\tEXPECTED_DATA_ERROR_PROPS: {\n\t\tissues: [{ message: \"Expected object with 'data' and 'error' properties\" }],\n\t},\n\tEXPECTED_ERROR_NULL: {\n\t\tissues: [\n\t\t\t{\n\t\t\t\tmessage: \"Expected 'error' to be null for Ok variant\",\n\t\t\t\tpath: [\"error\"],\n\t\t\t},\n\t\t],\n\t},\n\tEXPECTED_ERROR_NOT_NULL: {\n\t\tissues: [\n\t\t\t{\n\t\t\t\tmessage: \"Expected 'error' to be non-null for Err variant\",\n\t\t\t\tpath: [\"error\"],\n\t\t\t},\n\t\t],\n\t},\n} as const satisfies Record<string, StandardSchemaV1.FailureResult>;\n","/**\n * Standard Schema type definitions.\n *\n * These interfaces are copied from the Standard Schema specification\n * (https://standardschema.dev) to avoid external dependencies.\n *\n * @see https://github.com/standard-schema/standard-schema\n */\n\n// #########################\n// ### Standard Typed ###\n// #########################\n\n/**\n * The Standard Typed interface. This is a base type extended by other specs.\n */\nexport type StandardTypedV1<Input = unknown, Output = Input> = {\n\t/** The Standard properties. */\n\treadonly \"~standard\": StandardTypedV1.Props<Input, Output>;\n};\n\nexport declare namespace StandardTypedV1 {\n\t/** The Standard Typed properties interface. */\n\ttype Props<Input = unknown, Output = Input> = {\n\t\t/** The version number of the standard. */\n\t\treadonly version: 1;\n\t\t/** The vendor name of the schema library. */\n\t\treadonly vendor: string;\n\t\t/** Inferred types associated with the schema. */\n\t\treadonly types?: Types<Input, Output> | undefined;\n\t};\n\n\t/** The Standard Typed types interface. */\n\ttype Types<Input = unknown, Output = Input> = {\n\t\t/** The input type of the schema. */\n\t\treadonly input: Input;\n\t\t/** The output type of the schema. */\n\t\treadonly output: Output;\n\t};\n\n\t/** Infers the input type of a Standard Typed. */\n\ttype InferInput<Schema extends StandardTypedV1> = NonNullable<\n\t\tSchema[\"~standard\"][\"types\"]\n\t>[\"input\"];\n\n\t/** Infers the output type of a Standard Typed. */\n\ttype InferOutput<Schema extends StandardTypedV1> = NonNullable<\n\t\tSchema[\"~standard\"][\"types\"]\n\t>[\"output\"];\n}\n\n// ##########################\n// ### Standard Schema ###\n// ##########################\n\n/**\n * The Standard Schema interface.\n *\n * Extends StandardTypedV1 with a validate function for runtime validation.\n */\nexport type StandardSchemaV1<Input = unknown, Output = Input> = {\n\t/** The Standard Schema properties. */\n\treadonly \"~standard\": StandardSchemaV1.Props<Input, Output>;\n};\n\nexport declare namespace StandardSchemaV1 {\n\t/** The Standard Schema properties interface. */\n\ttype Props<Input = unknown, Output = Input> = StandardTypedV1.Props<\n\t\tInput,\n\t\tOutput\n\t> & {\n\t\t/** Validates unknown input values. */\n\t\treadonly validate: (\n\t\t\tvalue: unknown,\n\t\t\toptions?: StandardSchemaV1.Options | undefined,\n\t\t) => Result<Output> | Promise<Result<Output>>;\n\t};\n\n\t/** The result interface of the validate function. */\n\ttype Result<Output> = SuccessResult<Output> | FailureResult;\n\n\t/** The result interface if validation succeeds. */\n\ttype SuccessResult<Output> = {\n\t\t/** The typed output value. */\n\t\treadonly value: Output;\n\t\t/** A falsy value for `issues` indicates success. */\n\t\treadonly issues?: undefined;\n\t};\n\n\t/** Options for the validate function. */\n\ttype Options = {\n\t\t/** Explicit support for additional vendor-specific parameters, if needed. */\n\t\treadonly libraryOptions?: Record<string, unknown> | undefined;\n\t};\n\n\t/** The result interface if validation fails. */\n\ttype FailureResult = {\n\t\t/** The issues of failed validation. */\n\t\treadonly issues: ReadonlyArray<Issue>;\n\t};\n\n\t/** The issue interface of the failure output. */\n\ttype Issue = {\n\t\t/** The error message of the issue. */\n\t\treadonly message: string;\n\t\t/** The path of the issue, if any. */\n\t\treadonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;\n\t};\n\n\t/** The path segment interface of the issue. */\n\ttype PathSegment = {\n\t\t/** The key representing a path segment. */\n\t\treadonly key: PropertyKey;\n\t};\n\n\t/** Infers the input type of a Standard Schema. */\n\ttype InferInput<Schema extends StandardTypedV1> =\n\t\tStandardTypedV1.InferInput<Schema>;\n\n\t/** Infers the output type of a Standard Schema. */\n\ttype InferOutput<Schema extends StandardTypedV1> =\n\t\tStandardTypedV1.InferOutput<Schema>;\n}\n\n// ###############################\n// ### Standard JSON Schema ###\n// ###############################\n\n/**\n * The Standard JSON Schema interface.\n *\n * Extends StandardTypedV1 with methods for generating JSON Schema.\n */\nexport type StandardJSONSchemaV1<Input = unknown, Output = Input> = {\n\t/** The Standard JSON Schema properties. */\n\treadonly \"~standard\": StandardJSONSchemaV1.Props<Input, Output>;\n};\n\nexport declare namespace StandardJSONSchemaV1 {\n\t/** The Standard JSON Schema properties interface. */\n\ttype Props<Input = unknown, Output = Input> = StandardTypedV1.Props<\n\t\tInput,\n\t\tOutput\n\t> & {\n\t\t/** Methods for generating the input/output JSON Schema. */\n\t\treadonly jsonSchema: StandardJSONSchemaV1.Converter;\n\t};\n\n\t/** The Standard JSON Schema converter interface. */\n\ttype Converter = {\n\t\t/** Converts the input type to JSON Schema. May throw if conversion is not supported. */\n\t\treadonly input: (\n\t\t\toptions: StandardJSONSchemaV1.Options,\n\t\t) => Record<string, unknown>;\n\t\t/** Converts the output type to JSON Schema. May throw if conversion is not supported. */\n\t\treadonly output: (\n\t\t\toptions: StandardJSONSchemaV1.Options,\n\t\t) => Record<string, unknown>;\n\t};\n\n\t/**\n\t * The target version of the generated JSON Schema.\n\t *\n\t * It is *strongly recommended* that implementers support `\"draft-2020-12\"` and `\"draft-07\"`,\n\t * as they are both in wide use. All other targets can be implemented on a best-effort basis.\n\t * Libraries should throw if they don't support a specified target.\n\t *\n\t * The `\"openapi-3.0\"` target is intended as a standardized specifier for OpenAPI 3.0\n\t * which is a superset of JSON Schema `\"draft-04\"`.\n\t */\n\ttype Target =\n\t\t| \"draft-2020-12\"\n\t\t| \"draft-07\"\n\t\t| \"openapi-3.0\"\n\t\t// Accepts any string for future targets while preserving autocomplete\n\t\t| (string & {});\n\n\t/** The options for the input/output methods. */\n\ttype Options = {\n\t\t/** Specifies the target version of the generated JSON Schema. */\n\t\treadonly target: Target;\n\t\t/** Explicit support for additional vendor-specific parameters, if needed. */\n\t\treadonly libraryOptions?: Record<string, unknown> | undefined;\n\t};\n\n\t/** Infers the input type of a Standard JSON Schema. */\n\ttype InferInput<Schema extends StandardTypedV1> =\n\t\tStandardTypedV1.InferInput<Schema>;\n\n\t/** Infers the output type of a Standard JSON Schema. */\n\ttype InferOutput<Schema extends StandardTypedV1> =\n\t\tStandardTypedV1.InferOutput<Schema>;\n}\n\n// ###############################\n// ### Utility Types ###\n// ###############################\n\n/**\n * A schema that implements both StandardSchemaV1 and StandardJSONSchemaV1.\n */\nexport type StandardFullSchemaV1<Input = unknown, Output = Input> = {\n\treadonly \"~standard\": StandardSchemaV1.Props<Input, Output> &\n\t\tStandardJSONSchemaV1.Props<Input, Output>;\n};\n\n/**\n * Checks if a schema has validation capability.\n */\nexport function hasValidate<T extends StandardTypedV1>(\n\tschema: T,\n): schema is T & StandardSchemaV1 {\n\treturn (\n\t\t\"validate\" in schema[\"~standard\"] &&\n\t\ttypeof schema[\"~standard\"].validate === \"function\"\n\t);\n}\n\n/**\n * Checks if a schema has JSON Schema generation capability.\n */\nexport function hasJsonSchema<T extends StandardTypedV1>(\n\tschema: T,\n): schema is T & StandardJSONSchemaV1 {\n\treturn (\n\t\t\"jsonSchema\" in schema[\"~standard\"] &&\n\t\ttypeof schema[\"~standard\"].jsonSchema === \"object\" &&\n\t\tschema[\"~standard\"].jsonSchema !== null\n\t);\n}\n","import { FAILURES } from \"./failures.js\";\nimport {\n\thasJsonSchema,\n\thasValidate,\n\ttype StandardJSONSchemaV1,\n\ttype StandardSchemaV1,\n\ttype StandardTypedV1,\n} from \"./types.js\";\n\n/**\n * Output type for ErrSchema - wraps inner schema's types with Err structure.\n *\n * Preserves the capabilities of the input schema:\n * - If input has validate, output has validate\n * - If input has jsonSchema, output has jsonSchema\n */\nexport type Err<TSchema extends StandardTypedV1> = {\n\treadonly \"~standard\": {\n\t\treadonly version: 1;\n\t\treadonly vendor: \"wellcrafted\";\n\t\treadonly types: {\n\t\t\treadonly input: {\n\t\t\t\tdata: null;\n\t\t\t\terror: StandardTypedV1.InferInput<TSchema>;\n\t\t\t};\n\t\t\treadonly output: {\n\t\t\t\tdata: null;\n\t\t\t\terror: StandardTypedV1.InferOutput<TSchema>;\n\t\t\t};\n\t\t};\n\t} & (TSchema extends StandardSchemaV1\n\t\t? {\n\t\t\t\treadonly validate: StandardSchemaV1.Props<\n\t\t\t\t\t{ data: null; error: StandardTypedV1.InferInput<TSchema> },\n\t\t\t\t\t{ data: null; error: StandardTypedV1.InferOutput<TSchema> }\n\t\t\t\t>[\"validate\"];\n\t\t\t}\n\t\t: Record<string, never>) &\n\t\t(TSchema extends StandardJSONSchemaV1\n\t\t\t? { readonly jsonSchema: StandardJSONSchemaV1.Converter }\n\t\t\t: Record<string, never>);\n};\n\nfunction createErrValidate<TSchema extends StandardSchemaV1>(\n\tinnerSchema: TSchema,\n): StandardSchemaV1.Props<\n\t{ data: null; error: StandardTypedV1.InferInput<TSchema> },\n\t{ data: null; error: StandardTypedV1.InferOutput<TSchema> }\n>[\"validate\"] {\n\treturn (value: unknown) => {\n\t\tif (typeof value !== \"object\" || value === null) {\n\t\t\treturn FAILURES.EXPECTED_OBJECT;\n\t\t}\n\n\t\tif (!(\"data\" in value) || !(\"error\" in value)) {\n\t\t\treturn FAILURES.EXPECTED_DATA_ERROR_PROPS;\n\t\t}\n\n\t\tconst obj = value as { data: unknown; error: unknown };\n\n\t\tif (obj.error === null) {\n\t\t\treturn FAILURES.EXPECTED_ERROR_NOT_NULL;\n\t\t}\n\n\t\tconst innerResult = innerSchema[\"~standard\"].validate(obj.error);\n\n\t\tif (innerResult instanceof Promise) {\n\t\t\treturn innerResult.then((r) => {\n\t\t\t\tif (r.issues) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tissues: r.issues.map((issue: StandardSchemaV1.Issue) => ({\n\t\t\t\t\t\t\t...issue,\n\t\t\t\t\t\t\tpath: [\"error\", ...(issue.path || [])],\n\t\t\t\t\t\t})),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn { value: { data: null as null, error: r.value } };\n\t\t\t});\n\t\t}\n\n\t\tif (innerResult.issues) {\n\t\t\treturn {\n\t\t\t\tissues: innerResult.issues.map((issue: StandardSchemaV1.Issue) => ({\n\t\t\t\t\t...issue,\n\t\t\t\t\tpath: [\"error\", ...(issue.path || [])],\n\t\t\t\t})),\n\t\t\t};\n\t\t}\n\n\t\treturn { value: { data: null as null, error: innerResult.value } };\n\t};\n}\n\nfunction createErrJsonSchema<TSchema extends StandardJSONSchemaV1>(\n\tinnerSchema: TSchema,\n): StandardJSONSchemaV1.Converter {\n\treturn {\n\t\tinput(options: StandardJSONSchemaV1.Options) {\n\t\t\treturn {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tdata: { type: \"null\" },\n\t\t\t\t\terror: innerSchema[\"~standard\"].jsonSchema.input(options),\n\t\t\t\t},\n\t\t\t\trequired: [\"data\", \"error\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t};\n\t\t},\n\t\toutput(options: StandardJSONSchemaV1.Options) {\n\t\t\treturn {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tdata: { type: \"null\" },\n\t\t\t\t\terror: innerSchema[\"~standard\"].jsonSchema.output(options),\n\t\t\t\t},\n\t\t\t\trequired: [\"data\", \"error\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t};\n\t\t},\n\t};\n}\n\n/**\n * Wraps a Standard Schema into an Err variant schema.\n *\n * Takes a schema for type E and returns a schema for `{ data: null, error: E }`.\n * Preserves the capabilities of the input schema (validate, jsonSchema, or both).\n *\n * @example\n * ```typescript\n * import { z } from \"zod\";\n * import { ErrSchema } from \"wellcrafted/standard-schema\";\n *\n * const errorSchema = z.object({ code: z.string(), message: z.string() });\n * const errResultSchema = ErrSchema(errorSchema);\n *\n * // Validates: { data: null, error: { code: \"NOT_FOUND\", message: \"User not found\" } }\n * const result = errResultSchema[\"~standard\"].validate({\n * data: null,\n * error: { code: \"NOT_FOUND\", message: \"User not found\" },\n * });\n * ```\n */\nexport function ErrSchema<TSchema extends StandardTypedV1>(\n\tinnerSchema: TSchema,\n): Err<TSchema> {\n\tconst base = {\n\t\t\"~standard\": {\n\t\t\tversion: 1 as const,\n\t\t\tvendor: \"wellcrafted\",\n\t\t\ttypes: {\n\t\t\t\tinput: undefined as unknown as {\n\t\t\t\t\tdata: null;\n\t\t\t\t\terror: StandardTypedV1.InferInput<TSchema>;\n\t\t\t\t},\n\t\t\t\toutput: undefined as unknown as {\n\t\t\t\t\tdata: null;\n\t\t\t\t\terror: StandardTypedV1.InferOutput<TSchema>;\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t};\n\n\tif (hasValidate(innerSchema)) {\n\t\t(base[\"~standard\"] as Record<string, unknown>).validate =\n\t\t\tcreateErrValidate(innerSchema);\n\t}\n\n\tif (hasJsonSchema(innerSchema)) {\n\t\t(base[\"~standard\"] as Record<string, unknown>).jsonSchema =\n\t\t\tcreateErrJsonSchema(innerSchema);\n\t}\n\n\treturn base as Err<TSchema>;\n}\n","import { FAILURES } from \"./failures.js\";\nimport {\n\thasJsonSchema,\n\thasValidate,\n\ttype StandardJSONSchemaV1,\n\ttype StandardSchemaV1,\n\ttype StandardTypedV1,\n} from \"./types.js\";\n\n/**\n * Output type for OkSchema - wraps inner schema's types with Ok structure.\n *\n * Preserves the capabilities of the input schema:\n * - If input has validate, output has validate\n * - If input has jsonSchema, output has jsonSchema\n */\nexport type Ok<TSchema extends StandardTypedV1> = {\n\treadonly \"~standard\": {\n\t\treadonly version: 1;\n\t\treadonly vendor: \"wellcrafted\";\n\t\treadonly types: {\n\t\t\treadonly input: {\n\t\t\t\tdata: StandardTypedV1.InferInput<TSchema>;\n\t\t\t\terror: null;\n\t\t\t};\n\t\t\treadonly output: {\n\t\t\t\tdata: StandardTypedV1.InferOutput<TSchema>;\n\t\t\t\terror: null;\n\t\t\t};\n\t\t};\n\t} & (TSchema extends StandardSchemaV1\n\t\t? {\n\t\t\t\treadonly validate: StandardSchemaV1.Props<\n\t\t\t\t\t{ data: StandardTypedV1.InferInput<TSchema>; error: null },\n\t\t\t\t\t{ data: StandardTypedV1.InferOutput<TSchema>; error: null }\n\t\t\t\t>[\"validate\"];\n\t\t\t}\n\t\t: Record<string, never>) &\n\t\t(TSchema extends StandardJSONSchemaV1\n\t\t\t? { readonly jsonSchema: StandardJSONSchemaV1.Converter }\n\t\t\t: Record<string, never>);\n};\n\nfunction createOkValidate<TSchema extends StandardSchemaV1>(\n\tinnerSchema: TSchema,\n): StandardSchemaV1.Props<\n\t{ data: StandardTypedV1.InferInput<TSchema>; error: null },\n\t{ data: StandardTypedV1.InferOutput<TSchema>; error: null }\n>[\"validate\"] {\n\treturn (value: unknown) => {\n\t\tif (typeof value !== \"object\" || value === null) {\n\t\t\treturn FAILURES.EXPECTED_OBJECT;\n\t\t}\n\n\t\tif (!(\"data\" in value) || !(\"error\" in value)) {\n\t\t\treturn FAILURES.EXPECTED_DATA_ERROR_PROPS;\n\t\t}\n\n\t\tconst obj = value as { data: unknown; error: unknown };\n\n\t\tif (obj.error !== null) {\n\t\t\treturn FAILURES.EXPECTED_ERROR_NULL;\n\t\t}\n\n\t\tconst innerResult = innerSchema[\"~standard\"].validate(obj.data);\n\n\t\tif (innerResult instanceof Promise) {\n\t\t\treturn innerResult.then((r) => {\n\t\t\t\tif (r.issues) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tissues: r.issues.map((issue: StandardSchemaV1.Issue) => ({\n\t\t\t\t\t\t\t...issue,\n\t\t\t\t\t\t\tpath: [\"data\", ...(issue.path || [])],\n\t\t\t\t\t\t})),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn { value: { data: r.value, error: null as null } };\n\t\t\t});\n\t\t}\n\n\t\tif (innerResult.issues) {\n\t\t\treturn {\n\t\t\t\tissues: innerResult.issues.map((issue: StandardSchemaV1.Issue) => ({\n\t\t\t\t\t...issue,\n\t\t\t\t\tpath: [\"data\", ...(issue.path || [])],\n\t\t\t\t})),\n\t\t\t};\n\t\t}\n\n\t\treturn { value: { data: innerResult.value, error: null as null } };\n\t};\n}\n\nfunction createOkJsonSchema<TSchema extends StandardJSONSchemaV1>(\n\tinnerSchema: TSchema,\n): StandardJSONSchemaV1.Converter {\n\treturn {\n\t\tinput(options: StandardJSONSchemaV1.Options) {\n\t\t\treturn {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tdata: innerSchema[\"~standard\"].jsonSchema.input(options),\n\t\t\t\t\terror: { type: \"null\" },\n\t\t\t\t},\n\t\t\t\trequired: [\"data\", \"error\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t};\n\t\t},\n\t\toutput(options: StandardJSONSchemaV1.Options) {\n\t\t\treturn {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tdata: innerSchema[\"~standard\"].jsonSchema.output(options),\n\t\t\t\t\terror: { type: \"null\" },\n\t\t\t\t},\n\t\t\t\trequired: [\"data\", \"error\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t};\n\t\t},\n\t};\n}\n\n/**\n * Wraps a Standard Schema into an Ok variant schema.\n *\n * Takes a schema for type T and returns a schema for `{ data: T, error: null }`.\n * Preserves the capabilities of the input schema (validate, jsonSchema, or both).\n *\n * @example\n * ```typescript\n * import { z } from \"zod\";\n * import { OkSchema } from \"wellcrafted/standard-schema\";\n *\n * const userSchema = z.object({ name: z.string() });\n * const okUserSchema = OkSchema(userSchema);\n *\n * // Validates: { data: { name: \"Alice\" }, error: null }\n * const result = okUserSchema[\"~standard\"].validate({\n * data: { name: \"Alice\" },\n * error: null,\n * });\n * ```\n */\nexport function OkSchema<TSchema extends StandardTypedV1>(\n\tinnerSchema: TSchema,\n): Ok<TSchema> {\n\tconst base = {\n\t\t\"~standard\": {\n\t\t\tversion: 1 as const,\n\t\t\tvendor: \"wellcrafted\",\n\t\t\ttypes: {\n\t\t\t\tinput: undefined as unknown as {\n\t\t\t\t\tdata: StandardTypedV1.InferInput<TSchema>;\n\t\t\t\t\terror: null;\n\t\t\t\t},\n\t\t\t\toutput: undefined as unknown as {\n\t\t\t\t\tdata: StandardTypedV1.InferOutput<TSchema>;\n\t\t\t\t\terror: null;\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t};\n\n\tif (hasValidate(innerSchema)) {\n\t\t(base[\"~standard\"] as Record<string, unknown>).validate =\n\t\t\tcreateOkValidate(innerSchema);\n\t}\n\n\tif (hasJsonSchema(innerSchema)) {\n\t\t(base[\"~standard\"] as Record<string, unknown>).jsonSchema =\n\t\t\tcreateOkJsonSchema(innerSchema);\n\t}\n\n\treturn base as Ok<TSchema>;\n}\n","import { FAILURES } from \"./failures.js\";\nimport {\n\thasJsonSchema,\n\thasValidate,\n\ttype StandardJSONSchemaV1,\n\ttype StandardSchemaV1,\n\ttype StandardTypedV1,\n} from \"./types.js\";\n\n/**\n * Output type for ResultSchema - creates a discriminated union of Ok and Err.\n *\n * Preserves the capabilities of the input schemas:\n * - If both inputs have validate, output has validate\n * - If both inputs have jsonSchema, output has jsonSchema\n */\nexport type Result<\n\tTDataSchema extends StandardTypedV1,\n\tTErrorSchema extends StandardTypedV1,\n> = {\n\treadonly \"~standard\": {\n\t\treadonly version: 1;\n\t\treadonly vendor: \"wellcrafted\";\n\t\treadonly types: {\n\t\t\treadonly input:\n\t\t\t\t| { data: StandardTypedV1.InferInput<TDataSchema>; error: null }\n\t\t\t\t| { data: null; error: StandardTypedV1.InferInput<TErrorSchema> };\n\t\t\treadonly output:\n\t\t\t\t| { data: StandardTypedV1.InferOutput<TDataSchema>; error: null }\n\t\t\t\t| { data: null; error: StandardTypedV1.InferOutput<TErrorSchema> };\n\t\t};\n\t} & (TDataSchema extends StandardSchemaV1\n\t\t? TErrorSchema extends StandardSchemaV1\n\t\t\t? {\n\t\t\t\t\treadonly validate: StandardSchemaV1.Props<\n\t\t\t\t\t\t| {\n\t\t\t\t\t\t\t\tdata: StandardTypedV1.InferInput<TDataSchema>;\n\t\t\t\t\t\t\t\terror: null;\n\t\t\t\t\t\t }\n\t\t\t\t\t\t| {\n\t\t\t\t\t\t\t\tdata: null;\n\t\t\t\t\t\t\t\terror: StandardTypedV1.InferInput<TErrorSchema>;\n\t\t\t\t\t\t },\n\t\t\t\t\t\t| {\n\t\t\t\t\t\t\t\tdata: StandardTypedV1.InferOutput<TDataSchema>;\n\t\t\t\t\t\t\t\terror: null;\n\t\t\t\t\t\t }\n\t\t\t\t\t\t| {\n\t\t\t\t\t\t\t\tdata: null;\n\t\t\t\t\t\t\t\terror: StandardTypedV1.InferOutput<TErrorSchema>;\n\t\t\t\t\t\t }\n\t\t\t\t\t>[\"validate\"];\n\t\t\t\t}\n\t\t\t: Record<string, never>\n\t\t: Record<string, never>) &\n\t\t(TDataSchema extends StandardJSONSchemaV1\n\t\t\t? TErrorSchema extends StandardJSONSchemaV1\n\t\t\t\t? { readonly jsonSchema: StandardJSONSchemaV1.Converter }\n\t\t\t\t: Record<string, never>\n\t\t\t: Record<string, never>);\n};\n\nfunction createResultValidate<\n\tTDataSchema extends StandardSchemaV1,\n\tTErrorSchema extends StandardSchemaV1,\n>(\n\tdataSchema: TDataSchema,\n\terrorSchema: TErrorSchema,\n): StandardSchemaV1.Props<\n\t| { data: StandardTypedV1.InferInput<TDataSchema>; error: null }\n\t| { data: null; error: StandardTypedV1.InferInput<TErrorSchema> },\n\t| { data: StandardTypedV1.InferOutput<TDataSchema>; error: null }\n\t| { data: null; error: StandardTypedV1.InferOutput<TErrorSchema> }\n>[\"validate\"] {\n\treturn (value: unknown) => {\n\t\tif (typeof value !== \"object\" || value === null) {\n\t\t\treturn FAILURES.EXPECTED_OBJECT;\n\t\t}\n\n\t\tif (!(\"data\" in value) || !(\"error\" in value)) {\n\t\t\treturn FAILURES.EXPECTED_DATA_ERROR_PROPS;\n\t\t}\n\n\t\tconst obj = value as { data: unknown; error: unknown };\n\n\t\tconst isOk = obj.error === null;\n\n\t\tif (isOk) {\n\t\t\tconst innerResult = dataSchema[\"~standard\"].validate(obj.data);\n\n\t\t\tif (innerResult instanceof Promise) {\n\t\t\t\treturn innerResult.then((r) => {\n\t\t\t\t\tif (r.issues) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tissues: r.issues.map((issue: StandardSchemaV1.Issue) => ({\n\t\t\t\t\t\t\t\t...issue,\n\t\t\t\t\t\t\t\tpath: [\"data\", ...(issue.path || [])],\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\treturn { value: { data: r.value, error: null as null } };\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (innerResult.issues) {\n\t\t\t\treturn {\n\t\t\t\t\tissues: innerResult.issues.map((issue: StandardSchemaV1.Issue) => ({\n\t\t\t\t\t\t...issue,\n\t\t\t\t\t\tpath: [\"data\", ...(issue.path || [])],\n\t\t\t\t\t})),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn { value: { data: innerResult.value, error: null as null } };\n\t\t}\n\n\t\tconst innerResult = errorSchema[\"~standard\"].validate(obj.error);\n\n\t\tif (innerResult instanceof Promise) {\n\t\t\treturn innerResult.then((r) => {\n\t\t\t\tif (r.issues) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tissues: r.issues.map((issue: StandardSchemaV1.Issue) => ({\n\t\t\t\t\t\t\t...issue,\n\t\t\t\t\t\t\tpath: [\"error\", ...(issue.path || [])],\n\t\t\t\t\t\t})),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn { value: { data: null as null, error: r.value } };\n\t\t\t});\n\t\t}\n\n\t\tif (innerResult.issues) {\n\t\t\treturn {\n\t\t\t\tissues: innerResult.issues.map((issue: StandardSchemaV1.Issue) => ({\n\t\t\t\t\t...issue,\n\t\t\t\t\tpath: [\"error\", ...(issue.path || [])],\n\t\t\t\t})),\n\t\t\t};\n\t\t}\n\n\t\treturn { value: { data: null as null, error: innerResult.value } };\n\t};\n}\n\nfunction createResultJsonSchema<\n\tTDataSchema extends StandardJSONSchemaV1,\n\tTErrorSchema extends StandardJSONSchemaV1,\n>(\n\tdataSchema: TDataSchema,\n\terrorSchema: TErrorSchema,\n): StandardJSONSchemaV1.Converter {\n\treturn {\n\t\tinput(options: StandardJSONSchemaV1.Options) {\n\t\t\treturn {\n\t\t\t\toneOf: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tdata: dataSchema[\"~standard\"].jsonSchema.input(options),\n\t\t\t\t\t\t\terror: { type: \"null\" },\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequired: [\"data\", \"error\"],\n\t\t\t\t\t\tadditionalProperties: false,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tdata: { type: \"null\" },\n\t\t\t\t\t\t\terror: errorSchema[\"~standard\"].jsonSchema.input(options),\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequired: [\"data\", \"error\"],\n\t\t\t\t\t\tadditionalProperties: false,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t},\n\t\toutput(options: StandardJSONSchemaV1.Options) {\n\t\t\treturn {\n\t\t\t\toneOf: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tdata: dataSchema[\"~standard\"].jsonSchema.output(options),\n\t\t\t\t\t\t\terror: { type: \"null\" },\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequired: [\"data\", \"error\"],\n\t\t\t\t\t\tadditionalProperties: false,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tdata: { type: \"null\" },\n\t\t\t\t\t\t\terror: errorSchema[\"~standard\"].jsonSchema.output(options),\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequired: [\"data\", \"error\"],\n\t\t\t\t\t\tadditionalProperties: false,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t},\n\t};\n}\n\n/**\n * Combines two Standard Schemas into a Result discriminated union schema.\n *\n * Takes a data schema for type T and an error schema for type E, returning a schema\n * for `{ data: T, error: null } | { data: null, error: E }`.\n *\n * Preserves the capabilities of the input schemas - if both have validate, output\n * has validate; if both have jsonSchema, output has jsonSchema.\n *\n * @example\n * ```typescript\n * import { z } from \"zod\";\n * import { ResultSchema } from \"wellcrafted/standard-schema\";\n *\n * const userSchema = z.object({ id: z.string(), name: z.string() });\n * const errorSchema = z.object({ code: z.string(), message: z.string() });\n * const resultSchema = ResultSchema(userSchema, errorSchema);\n *\n * // Validates Ok variant: { data: { id: \"1\", name: \"Alice\" }, error: null }\n * // Validates Err variant: { data: null, error: { code: \"NOT_FOUND\", message: \"...\" } }\n * const result = resultSchema[\"~standard\"].validate({\n * data: { id: \"1\", name: \"Alice\" },\n * error: null,\n * });\n * ```\n */\nexport function ResultSchema<\n\tTDataSchema extends StandardTypedV1,\n\tTErrorSchema extends StandardTypedV1,\n>(\n\tdataSchema: TDataSchema,\n\terrorSchema: TErrorSchema,\n): Result<TDataSchema, TErrorSchema> {\n\tconst base = {\n\t\t\"~standard\": {\n\t\t\tversion: 1 as const,\n\t\t\tvendor: \"wellcrafted\",\n\t\t\ttypes: {\n\t\t\t\tinput: undefined as unknown as\n\t\t\t\t\t| { data: StandardTypedV1.InferInput<TDataSchema>; error: null }\n\t\t\t\t\t| { data: null; error: StandardTypedV1.InferInput<TErrorSchema> },\n\t\t\t\toutput: undefined as unknown as\n\t\t\t\t\t| { data: StandardTypedV1.InferOutput<TDataSchema>; error: null }\n\t\t\t\t\t| { data: null; error: StandardTypedV1.InferOutput<TErrorSchema> },\n\t\t\t},\n\t\t},\n\t};\n\n\tif (hasValidate(dataSchema) && hasValidate(errorSchema)) {\n\t\t(base[\"~standard\"] as Record<string, unknown>).validate =\n\t\t\tcreateResultValidate(dataSchema, errorSchema);\n\t}\n\n\tif (hasJsonSchema(dataSchema) && hasJsonSchema(errorSchema)) {\n\t\t(base[\"~standard\"] as Record<string, unknown>).jsonSchema =\n\t\t\tcreateResultJsonSchema(dataSchema, errorSchema);\n\t}\n\n\treturn base as Result<TDataSchema, TErrorSchema>;\n}\n"],"mappings":";AAEA,MAAa,WAAW;CACvB,iBAAiB,EAAE,QAAQ,CAAC,EAAE,SAAS,kBAAmB,CAAC,EAAE;CAC7D,2BAA2B,EAC1B,QAAQ,CAAC,EAAE,SAAS,qDAAsD,CAAC,EAC3E;CACD,qBAAqB,EACpB,QAAQ,CACP;EACC,SAAS;EACT,MAAM,CAAC,OAAQ;CACf,CACD,EACD;CACD,yBAAyB,EACxB,QAAQ,CACP;EACC,SAAS;EACT,MAAM,CAAC,OAAQ;CACf,CACD,EACD;AACD;;;;;;;AC0LD,SAAgB,YACfA,QACiC;AACjC,QACC,cAAc,OAAO,uBACd,OAAO,aAAa,aAAa;AAEzC;;;;AAKD,SAAgB,cACfA,QACqC;AACrC,QACC,gBAAgB,OAAO,uBAChB,OAAO,aAAa,eAAe,YAC1C,OAAO,aAAa,eAAe;AAEpC;;;;AC1LD,SAAS,kBACRC,aAIa;AACb,QAAO,CAACC,UAAmB;AAC1B,aAAW,UAAU,YAAY,UAAU,KAC1C,QAAO,SAAS;AAGjB,QAAM,UAAU,YAAY,WAAW,OACtC,QAAO,SAAS;EAGjB,MAAM,MAAM;AAEZ,MAAI,IAAI,UAAU,KACjB,QAAO,SAAS;EAGjB,MAAM,cAAc,YAAY,aAAa,SAAS,IAAI,MAAM;AAEhE,MAAI,uBAAuB,QAC1B,QAAO,YAAY,KAAK,CAAC,MAAM;AAC9B,OAAI,EAAE,OACL,QAAO,EACN,QAAQ,EAAE,OAAO,IAAI,CAACC,WAAmC;IACxD,GAAG;IACH,MAAM,CAAC,SAAS,GAAI,MAAM,QAAQ,CA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,EACD;AAED,KAAI,YAAY,WAAW,IAAI,YAAY,YAAY,CACtD,CAAC,KAAK,aAAyC,WAC9C,qBAAqB,YAAY,YAAY;AAG/C,KAAI,cAAc,WAAW,IAAI,cAAc,YAAY,CAC1D,CAAC,KAAK,aAAyC,aAC9C,uBAAuB,YAAY,YAAY;AAGjD,QAAO;AACP"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["schema: T","innerSchema: TSchema","value: unknown","issue: StandardSchemaV1.Issue","options: StandardJSONSchemaV1.Options","innerSchema: TSchema","value: unknown","issue: StandardSchemaV1.Issue","options: StandardJSONSchemaV1.Options","dataSchema: TDataSchema","errorSchema: TErrorSchema","value: unknown","innerResult","issue: StandardSchemaV1.Issue","options: StandardJSONSchemaV1.Options"],"sources":["../../src/standard-schema/failures.ts","../../src/standard-schema/types.ts","../../src/standard-schema/err.ts","../../src/standard-schema/ok.ts","../../src/standard-schema/result.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"./types.js\";\n\nexport const FAILURES = {\n\tEXPECTED_OBJECT: { issues: [{ message: \"Expected object\" }] },\n\tEXPECTED_DATA_ERROR_PROPS: {\n\t\tissues: [{ message: \"Expected object with 'data' and 'error' properties\" }],\n\t},\n\tEXPECTED_ERROR_NULL: {\n\t\tissues: [\n\t\t\t{\n\t\t\t\tmessage: \"Expected 'error' to be null for Ok variant\",\n\t\t\t\tpath: [\"error\"],\n\t\t\t},\n\t\t],\n\t},\n\tEXPECTED_ERROR_NOT_NULL: {\n\t\tissues: [\n\t\t\t{\n\t\t\t\tmessage: \"Expected 'error' to be non-null for Err variant\",\n\t\t\t\tpath: [\"error\"],\n\t\t\t},\n\t\t],\n\t},\n} as const satisfies Record<string, StandardSchemaV1.FailureResult>;\n","/**\n * Standard Schema type definitions.\n *\n * These interfaces are copied from the Standard Schema specification\n * (https://standardschema.dev) to avoid external dependencies.\n *\n * @see https://github.com/standard-schema/standard-schema\n */\n\n// #########################\n// ### Standard Typed ###\n// #########################\n\n/**\n * The Standard Typed interface. This is a base type extended by other specs.\n */\nexport type StandardTypedV1<Input = unknown, Output = Input> = {\n\t/** The Standard properties. */\n\treadonly \"~standard\": StandardTypedV1.Props<Input, Output>;\n};\n\nexport declare namespace StandardTypedV1 {\n\t/** The Standard Typed properties interface. */\n\ttype Props<Input = unknown, Output = Input> = {\n\t\t/** The version number of the standard. */\n\t\treadonly version: 1;\n\t\t/** The vendor name of the schema library. */\n\t\treadonly vendor: string;\n\t\t/** Inferred types associated with the schema. */\n\t\treadonly types?: Types<Input, Output> | undefined;\n\t};\n\n\t/** The Standard Typed types interface. */\n\ttype Types<Input = unknown, Output = Input> = {\n\t\t/** The input type of the schema. */\n\t\treadonly input: Input;\n\t\t/** The output type of the schema. */\n\t\treadonly output: Output;\n\t};\n\n\t/** Infers the input type of a Standard Typed. */\n\ttype InferInput<Schema extends StandardTypedV1> = NonNullable<\n\t\tSchema[\"~standard\"][\"types\"]\n\t>[\"input\"];\n\n\t/** Infers the output type of a Standard Typed. */\n\ttype InferOutput<Schema extends StandardTypedV1> = NonNullable<\n\t\tSchema[\"~standard\"][\"types\"]\n\t>[\"output\"];\n}\n\n// ##########################\n// ### Standard Schema ###\n// ##########################\n\n/**\n * The Standard Schema interface.\n *\n * Extends StandardTypedV1 with a validate function for runtime validation.\n */\nexport type StandardSchemaV1<Input = unknown, Output = Input> = {\n\t/** The Standard Schema properties. */\n\treadonly \"~standard\": StandardSchemaV1.Props<Input, Output>;\n};\n\nexport declare namespace StandardSchemaV1 {\n\t/** The Standard Schema properties interface. */\n\ttype Props<Input = unknown, Output = Input> = StandardTypedV1.Props<\n\t\tInput,\n\t\tOutput\n\t> & {\n\t\t/** Validates unknown input values. */\n\t\treadonly validate: (\n\t\t\tvalue: unknown,\n\t\t\toptions?: StandardSchemaV1.Options | undefined,\n\t\t) => Result<Output> | Promise<Result<Output>>;\n\t};\n\n\t/** The result interface of the validate function. */\n\ttype Result<Output> = SuccessResult<Output> | FailureResult;\n\n\t/** The result interface if validation succeeds. */\n\ttype SuccessResult<Output> = {\n\t\t/** The typed output value. */\n\t\treadonly value: Output;\n\t\t/** A falsy value for `issues` indicates success. */\n\t\treadonly issues?: undefined;\n\t};\n\n\t/** Options for the validate function. */\n\ttype Options = {\n\t\t/** Explicit support for additional vendor-specific parameters, if needed. */\n\t\treadonly libraryOptions?: Record<string, unknown> | undefined;\n\t};\n\n\t/** The result interface if validation fails. */\n\ttype FailureResult = {\n\t\t/** The issues of failed validation. */\n\t\treadonly issues: ReadonlyArray<Issue>;\n\t};\n\n\t/** The issue interface of the failure output. */\n\ttype Issue = {\n\t\t/** The error message of the issue. */\n\t\treadonly message: string;\n\t\t/** The path of the issue, if any. */\n\t\treadonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;\n\t};\n\n\t/** The path segment interface of the issue. */\n\ttype PathSegment = {\n\t\t/** The key representing a path segment. */\n\t\treadonly key: PropertyKey;\n\t};\n\n\t/** Infers the input type of a Standard Schema. */\n\ttype InferInput<Schema extends StandardTypedV1> =\n\t\tStandardTypedV1.InferInput<Schema>;\n\n\t/** Infers the output type of a Standard Schema. */\n\ttype InferOutput<Schema extends StandardTypedV1> =\n\t\tStandardTypedV1.InferOutput<Schema>;\n}\n\n// ###############################\n// ### Standard JSON Schema ###\n// ###############################\n\n/**\n * The Standard JSON Schema interface.\n *\n * Extends StandardTypedV1 with methods for generating JSON Schema.\n */\nexport type StandardJSONSchemaV1<Input = unknown, Output = Input> = {\n\t/** The Standard JSON Schema properties. */\n\treadonly \"~standard\": StandardJSONSchemaV1.Props<Input, Output>;\n};\n\nexport declare namespace StandardJSONSchemaV1 {\n\t/** The Standard JSON Schema properties interface. */\n\ttype Props<Input = unknown, Output = Input> = StandardTypedV1.Props<\n\t\tInput,\n\t\tOutput\n\t> & {\n\t\t/** Methods for generating the input/output JSON Schema. */\n\t\treadonly jsonSchema: StandardJSONSchemaV1.Converter;\n\t};\n\n\t/** The Standard JSON Schema converter interface. */\n\ttype Converter = {\n\t\t/** Converts the input type to JSON Schema. May throw if conversion is not supported. */\n\t\treadonly input: (\n\t\t\toptions: StandardJSONSchemaV1.Options,\n\t\t) => Record<string, unknown>;\n\t\t/** Converts the output type to JSON Schema. May throw if conversion is not supported. */\n\t\treadonly output: (\n\t\t\toptions: StandardJSONSchemaV1.Options,\n\t\t) => Record<string, unknown>;\n\t};\n\n\t/**\n\t * The target version of the generated JSON Schema.\n\t *\n\t * It is *strongly recommended* that implementers support `\"draft-2020-12\"` and `\"draft-07\"`,\n\t * as they are both in wide use. All other targets can be implemented on a best-effort basis.\n\t * Libraries should throw if they don't support a specified target.\n\t *\n\t * The `\"openapi-3.0\"` target is intended as a standardized specifier for OpenAPI 3.0\n\t * which is a superset of JSON Schema `\"draft-04\"`.\n\t */\n\ttype Target =\n\t\t| \"draft-2020-12\"\n\t\t| \"draft-07\"\n\t\t| \"openapi-3.0\"\n\t\t// Accepts any string for future targets while preserving autocomplete\n\t\t| (string & {});\n\n\t/** The options for the input/output methods. */\n\ttype Options = {\n\t\t/** Specifies the target version of the generated JSON Schema. */\n\t\treadonly target: Target;\n\t\t/** Explicit support for additional vendor-specific parameters, if needed. */\n\t\treadonly libraryOptions?: Record<string, unknown> | undefined;\n\t};\n\n\t/** Infers the input type of a Standard JSON Schema. */\n\ttype InferInput<Schema extends StandardTypedV1> =\n\t\tStandardTypedV1.InferInput<Schema>;\n\n\t/** Infers the output type of a Standard JSON Schema. */\n\ttype InferOutput<Schema extends StandardTypedV1> =\n\t\tStandardTypedV1.InferOutput<Schema>;\n}\n\n/**\n * Checks if a schema has validation capability.\n */\nexport function hasValidate<T extends StandardTypedV1>(\n\tschema: T,\n): schema is T & StandardSchemaV1 {\n\treturn (\n\t\t\"validate\" in schema[\"~standard\"] &&\n\t\ttypeof schema[\"~standard\"].validate === \"function\"\n\t);\n}\n\n/**\n * Checks if a schema has JSON Schema generation capability.\n */\nexport function hasJsonSchema<T extends StandardTypedV1>(\n\tschema: T,\n): schema is T & StandardJSONSchemaV1 {\n\treturn (\n\t\t\"jsonSchema\" in schema[\"~standard\"] &&\n\t\ttypeof schema[\"~standard\"].jsonSchema === \"object\" &&\n\t\tschema[\"~standard\"].jsonSchema !== null\n\t);\n}\n","import { FAILURES } from \"./failures.js\";\nimport {\n\thasJsonSchema,\n\thasValidate,\n\ttype StandardJSONSchemaV1,\n\ttype StandardSchemaV1,\n\ttype StandardTypedV1,\n} from \"./types.js\";\n\n/**\n * Output type for ErrSchema - wraps inner schema's types with Err structure.\n *\n * Preserves the capabilities of the input schema:\n * - If input has validate, output has validate\n * - If input has jsonSchema, output has jsonSchema\n */\nexport type Err<TSchema extends StandardTypedV1> = {\n\treadonly \"~standard\": {\n\t\treadonly version: 1;\n\t\treadonly vendor: \"wellcrafted\";\n\t\treadonly types: {\n\t\t\treadonly input: {\n\t\t\t\tdata: null;\n\t\t\t\terror: StandardTypedV1.InferInput<TSchema>;\n\t\t\t};\n\t\t\treadonly output: {\n\t\t\t\tdata: null;\n\t\t\t\terror: StandardTypedV1.InferOutput<TSchema>;\n\t\t\t};\n\t\t};\n\t} & (TSchema extends StandardSchemaV1\n\t\t? {\n\t\t\t\treadonly validate: StandardSchemaV1.Props<\n\t\t\t\t\t{ data: null; error: StandardTypedV1.InferInput<TSchema> },\n\t\t\t\t\t{ data: null; error: StandardTypedV1.InferOutput<TSchema> }\n\t\t\t\t>[\"validate\"];\n\t\t\t}\n\t\t: Record<string, never>) &\n\t\t(TSchema extends StandardJSONSchemaV1\n\t\t\t? { readonly jsonSchema: StandardJSONSchemaV1.Converter }\n\t\t\t: Record<string, never>);\n};\n\nfunction createErrValidate<TSchema extends StandardSchemaV1>(\n\tinnerSchema: TSchema,\n): StandardSchemaV1.Props<\n\t{ data: null; error: StandardTypedV1.InferInput<TSchema> },\n\t{ data: null; error: StandardTypedV1.InferOutput<TSchema> }\n>[\"validate\"] {\n\treturn (value: unknown) => {\n\t\tif (typeof value !== \"object\" || value === null) {\n\t\t\treturn FAILURES.EXPECTED_OBJECT;\n\t\t}\n\n\t\tif (!(\"data\" in value) || !(\"error\" in value)) {\n\t\t\treturn FAILURES.EXPECTED_DATA_ERROR_PROPS;\n\t\t}\n\n\t\tconst obj = value as { data: unknown; error: unknown };\n\n\t\tif (obj.error === null) {\n\t\t\treturn FAILURES.EXPECTED_ERROR_NOT_NULL;\n\t\t}\n\n\t\tconst innerResult = innerSchema[\"~standard\"].validate(obj.error);\n\n\t\tif (innerResult instanceof Promise) {\n\t\t\treturn innerResult.then((r) => {\n\t\t\t\tif (r.issues) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tissues: r.issues.map((issue: StandardSchemaV1.Issue) => ({\n\t\t\t\t\t\t\t...issue,\n\t\t\t\t\t\t\tpath: [\"error\", ...(issue.path || [])],\n\t\t\t\t\t\t})),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn { value: { data: null as null, error: r.value } };\n\t\t\t});\n\t\t}\n\n\t\tif (innerResult.issues) {\n\t\t\treturn {\n\t\t\t\tissues: innerResult.issues.map((issue: StandardSchemaV1.Issue) => ({\n\t\t\t\t\t...issue,\n\t\t\t\t\tpath: [\"error\", ...(issue.path || [])],\n\t\t\t\t})),\n\t\t\t};\n\t\t}\n\n\t\treturn { value: { data: null as null, error: innerResult.value } };\n\t};\n}\n\nfunction createErrJsonSchema<TSchema extends StandardJSONSchemaV1>(\n\tinnerSchema: TSchema,\n): StandardJSONSchemaV1.Converter {\n\treturn {\n\t\tinput(options: StandardJSONSchemaV1.Options) {\n\t\t\treturn {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tdata: { type: \"null\" },\n\t\t\t\t\terror: innerSchema[\"~standard\"].jsonSchema.input(options),\n\t\t\t\t},\n\t\t\t\trequired: [\"data\", \"error\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t};\n\t\t},\n\t\toutput(options: StandardJSONSchemaV1.Options) {\n\t\t\treturn {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tdata: { type: \"null\" },\n\t\t\t\t\terror: innerSchema[\"~standard\"].jsonSchema.output(options),\n\t\t\t\t},\n\t\t\t\trequired: [\"data\", \"error\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t};\n\t\t},\n\t};\n}\n\n/**\n * Wraps a Standard Schema into an Err variant schema.\n *\n * Takes a schema for type E and returns a schema for `{ data: null, error: E }`.\n * Preserves the capabilities of the input schema (validate, jsonSchema, or both).\n *\n * @example\n * ```typescript\n * import { z } from \"zod\";\n * import { ErrSchema } from \"wellcrafted/standard-schema\";\n *\n * const errorSchema = z.object({ code: z.string(), message: z.string() });\n * const errResultSchema = ErrSchema(errorSchema);\n *\n * // Validates: { data: null, error: { code: \"NOT_FOUND\", message: \"User not found\" } }\n * const result = errResultSchema[\"~standard\"].validate({\n * data: null,\n * error: { code: \"NOT_FOUND\", message: \"User not found\" },\n * });\n * ```\n */\nexport function ErrSchema<TSchema extends StandardTypedV1>(\n\tinnerSchema: TSchema,\n): Err<TSchema> {\n\tconst base = {\n\t\t\"~standard\": {\n\t\t\tversion: 1 as const,\n\t\t\tvendor: \"wellcrafted\",\n\t\t\ttypes: {\n\t\t\t\tinput: undefined as unknown as {\n\t\t\t\t\tdata: null;\n\t\t\t\t\terror: StandardTypedV1.InferInput<TSchema>;\n\t\t\t\t},\n\t\t\t\toutput: undefined as unknown as {\n\t\t\t\t\tdata: null;\n\t\t\t\t\terror: StandardTypedV1.InferOutput<TSchema>;\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t};\n\n\tif (hasValidate(innerSchema)) {\n\t\t(base[\"~standard\"] as Record<string, unknown>).validate =\n\t\t\tcreateErrValidate(innerSchema);\n\t}\n\n\tif (hasJsonSchema(innerSchema)) {\n\t\t(base[\"~standard\"] as Record<string, unknown>).jsonSchema =\n\t\t\tcreateErrJsonSchema(innerSchema);\n\t}\n\n\treturn base as Err<TSchema>;\n}\n","import { FAILURES } from \"./failures.js\";\nimport {\n\thasJsonSchema,\n\thasValidate,\n\ttype StandardJSONSchemaV1,\n\ttype StandardSchemaV1,\n\ttype StandardTypedV1,\n} from \"./types.js\";\n\n/**\n * Output type for OkSchema - wraps inner schema's types with Ok structure.\n *\n * Preserves the capabilities of the input schema:\n * - If input has validate, output has validate\n * - If input has jsonSchema, output has jsonSchema\n */\nexport type Ok<TSchema extends StandardTypedV1> = {\n\treadonly \"~standard\": {\n\t\treadonly version: 1;\n\t\treadonly vendor: \"wellcrafted\";\n\t\treadonly types: {\n\t\t\treadonly input: {\n\t\t\t\tdata: StandardTypedV1.InferInput<TSchema>;\n\t\t\t\terror: null;\n\t\t\t};\n\t\t\treadonly output: {\n\t\t\t\tdata: StandardTypedV1.InferOutput<TSchema>;\n\t\t\t\terror: null;\n\t\t\t};\n\t\t};\n\t} & (TSchema extends StandardSchemaV1\n\t\t? {\n\t\t\t\treadonly validate: StandardSchemaV1.Props<\n\t\t\t\t\t{ data: StandardTypedV1.InferInput<TSchema>; error: null },\n\t\t\t\t\t{ data: StandardTypedV1.InferOutput<TSchema>; error: null }\n\t\t\t\t>[\"validate\"];\n\t\t\t}\n\t\t: Record<string, never>) &\n\t\t(TSchema extends StandardJSONSchemaV1\n\t\t\t? { readonly jsonSchema: StandardJSONSchemaV1.Converter }\n\t\t\t: Record<string, never>);\n};\n\nfunction createOkValidate<TSchema extends StandardSchemaV1>(\n\tinnerSchema: TSchema,\n): StandardSchemaV1.Props<\n\t{ data: StandardTypedV1.InferInput<TSchema>; error: null },\n\t{ data: StandardTypedV1.InferOutput<TSchema>; error: null }\n>[\"validate\"] {\n\treturn (value: unknown) => {\n\t\tif (typeof value !== \"object\" || value === null) {\n\t\t\treturn FAILURES.EXPECTED_OBJECT;\n\t\t}\n\n\t\tif (!(\"data\" in value) || !(\"error\" in value)) {\n\t\t\treturn FAILURES.EXPECTED_DATA_ERROR_PROPS;\n\t\t}\n\n\t\tconst obj = value as { data: unknown; error: unknown };\n\n\t\tif (obj.error !== null) {\n\t\t\treturn FAILURES.EXPECTED_ERROR_NULL;\n\t\t}\n\n\t\tconst innerResult = innerSchema[\"~standard\"].validate(obj.data);\n\n\t\tif (innerResult instanceof Promise) {\n\t\t\treturn innerResult.then((r) => {\n\t\t\t\tif (r.issues) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tissues: r.issues.map((issue: StandardSchemaV1.Issue) => ({\n\t\t\t\t\t\t\t...issue,\n\t\t\t\t\t\t\tpath: [\"data\", ...(issue.path || [])],\n\t\t\t\t\t\t})),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn { value: { data: r.value, error: null as null } };\n\t\t\t});\n\t\t}\n\n\t\tif (innerResult.issues) {\n\t\t\treturn {\n\t\t\t\tissues: innerResult.issues.map((issue: StandardSchemaV1.Issue) => ({\n\t\t\t\t\t...issue,\n\t\t\t\t\tpath: [\"data\", ...(issue.path || [])],\n\t\t\t\t})),\n\t\t\t};\n\t\t}\n\n\t\treturn { value: { data: innerResult.value, error: null as null } };\n\t};\n}\n\nfunction createOkJsonSchema<TSchema extends StandardJSONSchemaV1>(\n\tinnerSchema: TSchema,\n): StandardJSONSchemaV1.Converter {\n\treturn {\n\t\tinput(options: StandardJSONSchemaV1.Options) {\n\t\t\treturn {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tdata: innerSchema[\"~standard\"].jsonSchema.input(options),\n\t\t\t\t\terror: { type: \"null\" },\n\t\t\t\t},\n\t\t\t\trequired: [\"data\", \"error\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t};\n\t\t},\n\t\toutput(options: StandardJSONSchemaV1.Options) {\n\t\t\treturn {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tdata: innerSchema[\"~standard\"].jsonSchema.output(options),\n\t\t\t\t\terror: { type: \"null\" },\n\t\t\t\t},\n\t\t\t\trequired: [\"data\", \"error\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t};\n\t\t},\n\t};\n}\n\n/**\n * Wraps a Standard Schema into an Ok variant schema.\n *\n * Takes a schema for type T and returns a schema for `{ data: T, error: null }`.\n * Preserves the capabilities of the input schema (validate, jsonSchema, or both).\n *\n * @example\n * ```typescript\n * import { z } from \"zod\";\n * import { OkSchema } from \"wellcrafted/standard-schema\";\n *\n * const userSchema = z.object({ name: z.string() });\n * const okUserSchema = OkSchema(userSchema);\n *\n * // Validates: { data: { name: \"Alice\" }, error: null }\n * const result = okUserSchema[\"~standard\"].validate({\n * data: { name: \"Alice\" },\n * error: null,\n * });\n * ```\n */\nexport function OkSchema<TSchema extends StandardTypedV1>(\n\tinnerSchema: TSchema,\n): Ok<TSchema> {\n\tconst base = {\n\t\t\"~standard\": {\n\t\t\tversion: 1 as const,\n\t\t\tvendor: \"wellcrafted\",\n\t\t\ttypes: {\n\t\t\t\tinput: undefined as unknown as {\n\t\t\t\t\tdata: StandardTypedV1.InferInput<TSchema>;\n\t\t\t\t\terror: null;\n\t\t\t\t},\n\t\t\t\toutput: undefined as unknown as {\n\t\t\t\t\tdata: StandardTypedV1.InferOutput<TSchema>;\n\t\t\t\t\terror: null;\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t};\n\n\tif (hasValidate(innerSchema)) {\n\t\t(base[\"~standard\"] as Record<string, unknown>).validate =\n\t\t\tcreateOkValidate(innerSchema);\n\t}\n\n\tif (hasJsonSchema(innerSchema)) {\n\t\t(base[\"~standard\"] as Record<string, unknown>).jsonSchema =\n\t\t\tcreateOkJsonSchema(innerSchema);\n\t}\n\n\treturn base as Ok<TSchema>;\n}\n","import { FAILURES } from \"./failures.js\";\nimport {\n\thasJsonSchema,\n\thasValidate,\n\ttype StandardJSONSchemaV1,\n\ttype StandardSchemaV1,\n\ttype StandardTypedV1,\n} from \"./types.js\";\n\n/**\n * Output type for ResultSchema - creates a discriminated union of Ok and Err.\n *\n * Preserves the capabilities of the input schemas:\n * - If both inputs have validate, output has validate\n * - If both inputs have jsonSchema, output has jsonSchema\n */\nexport type Result<\n\tTDataSchema extends StandardTypedV1,\n\tTErrorSchema extends StandardTypedV1,\n> = {\n\treadonly \"~standard\": {\n\t\treadonly version: 1;\n\t\treadonly vendor: \"wellcrafted\";\n\t\treadonly types: {\n\t\t\treadonly input:\n\t\t\t\t| { data: StandardTypedV1.InferInput<TDataSchema>; error: null }\n\t\t\t\t| { data: null; error: StandardTypedV1.InferInput<TErrorSchema> };\n\t\t\treadonly output:\n\t\t\t\t| { data: StandardTypedV1.InferOutput<TDataSchema>; error: null }\n\t\t\t\t| { data: null; error: StandardTypedV1.InferOutput<TErrorSchema> };\n\t\t};\n\t} & (TDataSchema extends StandardSchemaV1\n\t\t? TErrorSchema extends StandardSchemaV1\n\t\t\t? {\n\t\t\t\t\treadonly validate: StandardSchemaV1.Props<\n\t\t\t\t\t\t| {\n\t\t\t\t\t\t\t\tdata: StandardTypedV1.InferInput<TDataSchema>;\n\t\t\t\t\t\t\t\terror: null;\n\t\t\t\t\t\t }\n\t\t\t\t\t\t| {\n\t\t\t\t\t\t\t\tdata: null;\n\t\t\t\t\t\t\t\terror: StandardTypedV1.InferInput<TErrorSchema>;\n\t\t\t\t\t\t },\n\t\t\t\t\t\t| {\n\t\t\t\t\t\t\t\tdata: StandardTypedV1.InferOutput<TDataSchema>;\n\t\t\t\t\t\t\t\terror: null;\n\t\t\t\t\t\t }\n\t\t\t\t\t\t| {\n\t\t\t\t\t\t\t\tdata: null;\n\t\t\t\t\t\t\t\terror: StandardTypedV1.InferOutput<TErrorSchema>;\n\t\t\t\t\t\t }\n\t\t\t\t\t>[\"validate\"];\n\t\t\t\t}\n\t\t\t: Record<string, never>\n\t\t: Record<string, never>) &\n\t\t(TDataSchema extends StandardJSONSchemaV1\n\t\t\t? TErrorSchema extends StandardJSONSchemaV1\n\t\t\t\t? { readonly jsonSchema: StandardJSONSchemaV1.Converter }\n\t\t\t\t: Record<string, never>\n\t\t\t: Record<string, never>);\n};\n\nfunction createResultValidate<\n\tTDataSchema extends StandardSchemaV1,\n\tTErrorSchema extends StandardSchemaV1,\n>(\n\tdataSchema: TDataSchema,\n\terrorSchema: TErrorSchema,\n): StandardSchemaV1.Props<\n\t| { data: StandardTypedV1.InferInput<TDataSchema>; error: null }\n\t| { data: null; error: StandardTypedV1.InferInput<TErrorSchema> },\n\t| { data: StandardTypedV1.InferOutput<TDataSchema>; error: null }\n\t| { data: null; error: StandardTypedV1.InferOutput<TErrorSchema> }\n>[\"validate\"] {\n\treturn (value: unknown) => {\n\t\tif (typeof value !== \"object\" || value === null) {\n\t\t\treturn FAILURES.EXPECTED_OBJECT;\n\t\t}\n\n\t\tif (!(\"data\" in value) || !(\"error\" in value)) {\n\t\t\treturn FAILURES.EXPECTED_DATA_ERROR_PROPS;\n\t\t}\n\n\t\tconst obj = value as { data: unknown; error: unknown };\n\n\t\tconst isOk = obj.error === null;\n\n\t\tif (isOk) {\n\t\t\tconst innerResult = dataSchema[\"~standard\"].validate(obj.data);\n\n\t\t\tif (innerResult instanceof Promise) {\n\t\t\t\treturn innerResult.then((r) => {\n\t\t\t\t\tif (r.issues) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tissues: r.issues.map((issue: StandardSchemaV1.Issue) => ({\n\t\t\t\t\t\t\t\t...issue,\n\t\t\t\t\t\t\t\tpath: [\"data\", ...(issue.path || [])],\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\treturn { value: { data: r.value, error: null as null } };\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (innerResult.issues) {\n\t\t\t\treturn {\n\t\t\t\t\tissues: innerResult.issues.map((issue: StandardSchemaV1.Issue) => ({\n\t\t\t\t\t\t...issue,\n\t\t\t\t\t\tpath: [\"data\", ...(issue.path || [])],\n\t\t\t\t\t})),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn { value: { data: innerResult.value, error: null as null } };\n\t\t}\n\n\t\tconst innerResult = errorSchema[\"~standard\"].validate(obj.error);\n\n\t\tif (innerResult instanceof Promise) {\n\t\t\treturn innerResult.then((r) => {\n\t\t\t\tif (r.issues) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tissues: r.issues.map((issue: StandardSchemaV1.Issue) => ({\n\t\t\t\t\t\t\t...issue,\n\t\t\t\t\t\t\tpath: [\"error\", ...(issue.path || [])],\n\t\t\t\t\t\t})),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn { value: { data: null as null, error: r.value } };\n\t\t\t});\n\t\t}\n\n\t\tif (innerResult.issues) {\n\t\t\treturn {\n\t\t\t\tissues: innerResult.issues.map((issue: StandardSchemaV1.Issue) => ({\n\t\t\t\t\t...issue,\n\t\t\t\t\tpath: [\"error\", ...(issue.path || [])],\n\t\t\t\t})),\n\t\t\t};\n\t\t}\n\n\t\treturn { value: { data: null as null, error: innerResult.value } };\n\t};\n}\n\nfunction createResultJsonSchema<\n\tTDataSchema extends StandardJSONSchemaV1,\n\tTErrorSchema extends StandardJSONSchemaV1,\n>(\n\tdataSchema: TDataSchema,\n\terrorSchema: TErrorSchema,\n): StandardJSONSchemaV1.Converter {\n\treturn {\n\t\tinput(options: StandardJSONSchemaV1.Options) {\n\t\t\treturn {\n\t\t\t\toneOf: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tdata: dataSchema[\"~standard\"].jsonSchema.input(options),\n\t\t\t\t\t\t\terror: { type: \"null\" },\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequired: [\"data\", \"error\"],\n\t\t\t\t\t\tadditionalProperties: false,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tdata: { type: \"null\" },\n\t\t\t\t\t\t\terror: errorSchema[\"~standard\"].jsonSchema.input(options),\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequired: [\"data\", \"error\"],\n\t\t\t\t\t\tadditionalProperties: false,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t},\n\t\toutput(options: StandardJSONSchemaV1.Options) {\n\t\t\treturn {\n\t\t\t\toneOf: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tdata: dataSchema[\"~standard\"].jsonSchema.output(options),\n\t\t\t\t\t\t\terror: { type: \"null\" },\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequired: [\"data\", \"error\"],\n\t\t\t\t\t\tadditionalProperties: false,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tdata: { type: \"null\" },\n\t\t\t\t\t\t\terror: errorSchema[\"~standard\"].jsonSchema.output(options),\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequired: [\"data\", \"error\"],\n\t\t\t\t\t\tadditionalProperties: false,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t},\n\t};\n}\n\n/**\n * Combines two Standard Schemas into a Result discriminated union schema.\n *\n * Takes a data schema for type T and an error schema for type E, returning a schema\n * for `{ data: T, error: null } | { data: null, error: E }`.\n *\n * Preserves the capabilities of the input schemas - if both have validate, output\n * has validate; if both have jsonSchema, output has jsonSchema.\n *\n * @example\n * ```typescript\n * import { z } from \"zod\";\n * import { ResultSchema } from \"wellcrafted/standard-schema\";\n *\n * const userSchema = z.object({ id: z.string(), name: z.string() });\n * const errorSchema = z.object({ code: z.string(), message: z.string() });\n * const resultSchema = ResultSchema(userSchema, errorSchema);\n *\n * // Validates Ok variant: { data: { id: \"1\", name: \"Alice\" }, error: null }\n * // Validates Err variant: { data: null, error: { code: \"NOT_FOUND\", message: \"...\" } }\n * const result = resultSchema[\"~standard\"].validate({\n * data: { id: \"1\", name: \"Alice\" },\n * error: null,\n * });\n * ```\n */\nexport function ResultSchema<\n\tTDataSchema extends StandardTypedV1,\n\tTErrorSchema extends StandardTypedV1,\n>(\n\tdataSchema: TDataSchema,\n\terrorSchema: TErrorSchema,\n): Result<TDataSchema, TErrorSchema> {\n\tconst base = {\n\t\t\"~standard\": {\n\t\t\tversion: 1 as const,\n\t\t\tvendor: \"wellcrafted\",\n\t\t\ttypes: {\n\t\t\t\tinput: undefined as unknown as\n\t\t\t\t\t| { data: StandardTypedV1.InferInput<TDataSchema>; error: null }\n\t\t\t\t\t| { data: null; error: StandardTypedV1.InferInput<TErrorSchema> },\n\t\t\t\toutput: undefined as unknown as\n\t\t\t\t\t| { data: StandardTypedV1.InferOutput<TDataSchema>; error: null }\n\t\t\t\t\t| { data: null; error: StandardTypedV1.InferOutput<TErrorSchema> },\n\t\t\t},\n\t\t},\n\t};\n\n\tif (hasValidate(dataSchema) && hasValidate(errorSchema)) {\n\t\t(base[\"~standard\"] as Record<string, unknown>).validate =\n\t\t\tcreateResultValidate(dataSchema, errorSchema);\n\t}\n\n\tif (hasJsonSchema(dataSchema) && hasJsonSchema(errorSchema)) {\n\t\t(base[\"~standard\"] as Record<string, unknown>).jsonSchema =\n\t\t\tcreateResultJsonSchema(dataSchema, errorSchema);\n\t}\n\n\treturn base as Result<TDataSchema, TErrorSchema>;\n}\n"],"mappings":";AAEA,MAAa,WAAW;CACvB,iBAAiB,EAAE,QAAQ,CAAC,EAAE,SAAS,kBAAmB,CAAC,EAAE;CAC7D,2BAA2B,EAC1B,QAAQ,CAAC,EAAE,SAAS,qDAAsD,CAAC,EAC3E;CACD,qBAAqB,EACpB,QAAQ,CACP;EACC,SAAS;EACT,MAAM,CAAC,OAAQ;CACf,CACD,EACD;CACD,yBAAyB,EACxB,QAAQ,CACP;EACC,SAAS;EACT,MAAM,CAAC,OAAQ;CACf,CACD,EACD;AACD;;;;;;;AC8KD,SAAgB,YACfA,QACiC;AACjC,QACC,cAAc,OAAO,uBACd,OAAO,aAAa,aAAa;AAEzC;;;;AAKD,SAAgB,cACfA,QACqC;AACrC,QACC,gBAAgB,OAAO,uBAChB,OAAO,aAAa,eAAe,YAC1C,O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;IACN,YAAY;KACX,MAAM,WAAW,aAAa,WAAW,OAAO,QAAQ;KACxD,OAAO,EAAE,MAAM,OAAQ;IACvB;IACD,UAAU,CAAC,QAAQ,OAAQ;IAC3B,sBAAsB;GACtB,GACD;IACC,MAAM;IACN,YAAY;KACX,MAAM,EAAE,MAAM,OAAQ;KACtB,OAAO,YAAY,aAAa,WAAW,OAAO,QAAQ;IAC1D;IACD,UAAU,CAAC,QAAQ,OAAQ;IAC3B,sBAAsB;GACtB,CACD,EACD;EACD;CACD;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BD,SAAgB,aAIfL,YACAC,aACoC;CACpC,MAAM,OAAO,EACZ,aAAa;EACZ,SAAS;EACT,QAAQ;EACR,OAAO;GACN;GAGA;EAGA;CACD,EACD;AAED,KAAI,YAAY,WAAW,IAAI,YAAY,YAAY,CACtD,CAAC,KAAK,aAAyC,WAC9C,qBAAqB,YAAY,YAAY;AAG/C,KAAI,cAAc,WAAW,IAAI,cAAc,YAAY,CAC1D,CAAC,KAAK,aAAyC,aAC9C,uBAAuB,YAAY,YAAY;AAGjD,QAAO;AACP"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wellcrafted",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"description": "Delightful TypeScript patterns for elegant, type-safe applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
"types": "./dist/error/index.d.ts",
|
|
18
18
|
"import": "./dist/error/index.js"
|
|
19
19
|
},
|
|
20
|
+
"./json": {
|
|
21
|
+
"types": "./dist/json.d.ts",
|
|
22
|
+
"import": "./dist/json.js"
|
|
23
|
+
},
|
|
20
24
|
"./brand": {
|
|
21
25
|
"types": "./dist/brand.d.ts",
|
|
22
26
|
"import": "./dist/brand.js"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,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