schema-truth 0.8.4 → 0.8.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Schema Truth
2
2
 
3
- **[schema-truth](https://www.npmjs.com/package/schema-truth)** generates type-safe validation schemas from a [JSON Schema](https://json-schema.org/) or [OpenAPI](https://www.openapis.org/) document — one CLI per target library, each written in that library's own idiom.
3
+ **[schema-truth](https://www.npmjs.com/package/schema-truth)** generates type-safe validation schemas from a [JSON Schema](https://json-schema.org/) or [OpenAPI](https://openapis.org/) document — one CLI per target library, each written in that library's own idiom.
4
4
 
5
5
  ## Installation
6
6
 
@@ -1,4 +1,4 @@
1
- import { _t as makeSafeKey, s as sanitizeSchema, vt as normalizeTypes } from "./helper-WSNbEQKr.js";
1
+ import { s as sanitizeSchema, vt as makeSafeKey, yt as normalizeTypes } from "./helper-1oDB5NHM.js";
2
2
  // src/generator/ajv/integer.ts
3
3
  /**
4
4
  * Reconstruct a draft-07 integer schema. `minimum` is the only numeric keyword
package/dist/ajv.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { r as JSONSchema } from "./index-DLVjyrKu.js";
1
+ import { r as JSONSchema } from "./index-DZry7F2L.js";
2
2
  /**
3
3
  * Convert a JSON Schema document to Ajv TypeScript: a reconstructed draft-07
4
4
  * schema object and `ajv.compile(...)`.
package/dist/ajv.js CHANGED
@@ -1 +1 @@
1
- export { t as schemaToAjv } from "./ajv-DejgT2o1.js";
1
+ export { t as schemaToAjv } from "./ajv-BjWqjOc9.js";
@@ -1,4 +1,4 @@
1
- import { $ as arktypePreprocess, A as wireArrayOnce, At as hasFixedLength, Bt as isObjectPrototypeProperty, C as isNullTextRead, D as stringboolPattern, Dt as hasCombinator, E as ownProperties, Ft as isComposite, Gt as isRootRef, H as emitOptionsOf, In as UNSAFE_GENERATED_MARKER, It as isDeepLocalPointer, J as discriminatedMembers, Jt as isStringWireLocation, K as rootNameOf, Kt as isSchemaObject, M as wireNumericKind, N as formatPattern, O as stringboolTruthyPattern, On as QUOTE_OR_BACKSLASH_PATTERN, P as regexSource, Pt as isArktypeDefinition, Q as itemsSchemaOf, Rt as isNullTypeMember, S as isNullMatchedFirst, T as numberWirePattern, U as missingDefinitionComment, Ut as isQuoted, V as definitionsOf, W as planDocument, _ as hoistNestedRefs, _t as makeSafeKey, an as DEFINITION_REF_PREFIXES, at as constraintMessage, b as impliedWireType, ct as isKeywordOnlyMember, d as parameterReaders, dn as INTEGER_TEXT_PATTERN, et as arktypeWrap, f as propertyEmitOptions, g as valueListLiteral, gt as issueMessageExpression, h as notPredicate, i as isEvaluatedKeyExpression, j as wireNullText, k as unionPrimitiveTypes, kt as hasFixedItemCount, l as withPolymorphicBases, m as isBigintFormat, nn as DEFAULT_ROOT_NAME, nt as callbackType, ot as constraintPredicate, p as withoutParameterSerialization, q as schemaNamer, qt as isShapelessMember, r as evaluatedProperties, rt as findCodeExtensionKeysInSchema, s as sanitizeSchema, st as foldAllOfMembers, tt as callbackReturn, u as hasParameterSerialization, ut as regexLiteral, vt as normalizeTypes, w as isPrimitiveUnion, x as integerWirePattern, yn as NUMBER_RANGES, yt as resolveOpenAPIRef, zt as isNullable } from "./helper-WSNbEQKr.js";
1
+ import { $ as itemsSchemaOf, A as wireArrayOnce, At as hasFixedItemCount, Bt as isNullable, C as isNullTextRead, D as stringboolPattern, E as ownProperties, Ft as isArktypeDefinition, H as emitOptionsOf, It as isComposite, J as discriminatedMembers, Jt as isShapelessMember, K as rootNameOf, Kt as isRootRef, Ln as UNSAFE_GENERATED_MARKER, Lt as isDeepLocalPointer, M as wireNumericKind, N as formatPattern, O as stringboolTruthyPattern, Ot as hasCombinator, P as regexSource, S as isNullMatchedFirst, T as numberWirePattern, U as missingDefinitionComment, V as definitionsOf, Vt as isObjectPrototypeProperty, W as planDocument, Wt as isQuoted, Yt as isStringWireLocation, Z as enumWithoutWrappedNull, _ as hoistNestedRefs, _t as issueMessageExpression, b as impliedWireType, bn as NUMBER_RANGES, bt as resolveOpenAPIRef, ct as foldAllOfMembers, d as parameterReaders, dt as regexLiteral, et as arktypePreprocess, f as propertyEmitOptions, fn as INTEGER_TEXT_PATTERN, g as valueListLiteral, h as notPredicate, i as isEvaluatedKeyExpression, it as findCodeExtensionKeysInSchema, j as wireNullText, jt as hasFixedLength, k as unionPrimitiveTypes, kn as QUOTE_OR_BACKSLASH_PATTERN, l as withPolymorphicBases, lt as isKeywordOnlyMember, m as isBigintFormat, nt as callbackReturn, on as DEFINITION_REF_PREFIXES, ot as constraintMessage, p as withoutParameterSerialization, q as schemaNamer, qt as isSchemaObject, r as evaluatedProperties, rn as DEFAULT_ROOT_NAME, rt as callbackType, s as sanitizeSchema, st as constraintPredicate, tt as arktypeWrap, u as hasParameterSerialization, vt as makeSafeKey, w as isPrimitiveUnion, x as integerWirePattern, yt as normalizeTypes, zt as isNullTypeMember } from "./helper-1oDB5NHM.js";
2
2
  // src/generator/arktype/number.ts
3
3
  /** The comparators of a numeric node: `>= 1`, `< 5`, `% 2`. */
4
4
  function numericConstraints(schema) {
@@ -207,8 +207,15 @@ function lit(v, isBigint) {
207
207
  if (typeof v === "number" || typeof v === "boolean") return String(v);
208
208
  return JSON.stringify(v) ?? "null";
209
209
  }
210
+ /** A member of a string-DSL union that is one literal, and the same text as a JS literal. */
211
+ const DSL_LITERAL_PATTERN = /^(?:'[^'\\]*'|-?\d+(?:\.\d+)?(?:e[+-]?\d+)?n?|true|false|null)$/u;
212
+ /** Whether every member of a string-DSL union is a single literal `type.enumerated` takes. */
213
+ function isDslLiteralUnion(members) {
214
+ return members.every((member) => DSL_LITERAL_PATTERN.test(member));
215
+ }
210
216
  /**
211
- * The ArkType definition of an enum: a `"a | b | c"` string union. The members of an
217
+ * The ArkType definition of an enum: a `"a | b | c"` string union, or
218
+ * `type.enumerated(a, b, c)` past {@link ARKTYPE_STRING_UNION_LIMIT} members. The members of an
212
219
  * int64 / uint64 enum are bigint literals, as the value they match is.
213
220
  */
214
221
  function _enum(schema) {
@@ -227,7 +234,9 @@ function _enum(schema) {
227
234
  if (errorMessage) return `type(${expr})${describe}`;
228
235
  return expr;
229
236
  }
230
- const expr = `"${schema.enum.map((v) => lit(v, isBigint)).join(" | ")}"`;
237
+ const members = schema.enum.map((v) => lit(v, isBigint));
238
+ if (members.length > 16) return `type.enumerated(${members.join(",")})${describe}`;
239
+ const expr = `"${members.join(" | ")}"`;
231
240
  if (errorMessage) return `type(${expr})${describe}`;
232
241
  return expr;
233
242
  }
@@ -473,8 +482,22 @@ function string(schema) {
473
482
  function combine(op, inScope) {
474
483
  return (acc, s) => inScope && isArktypeDefinition(acc) ? `[${acc},"${op}",${s}]` : `type(${acc}).${op === "&" ? "and" : "or"}(${s})`;
475
484
  }
485
+ /** `items` in consecutive groups of at most `size`. */
486
+ function chunksOf(items, size) {
487
+ return Array.from({ length: Math.ceil(items.length / size) }, (_, i) => items.slice(i * size, (i + 1) * size));
488
+ }
489
+ /**
490
+ * A union of ArkType expressions. Quoted members join into one string-DSL union, unless
491
+ * there are more than {@link ARKTYPE_STRING_UNION_LIMIT} of them: then literals become
492
+ * `type.enumerated(...)` and anything else is joined in groups, so no single string is
493
+ * long enough to exceed TypeScript's instantiation depth.
494
+ */
476
495
  function unionStr(schemas, inScope = false) {
477
- return schemas.every(isQuoted) ? `"${schemas.map((s) => s.slice(1, -1)).join(" | ")}"` : schemas.reduce(combine("|", inScope));
496
+ if (!schemas.every(isQuoted)) return schemas.reduce(combine("|", inScope));
497
+ const members = schemas.map((s) => s.slice(1, -1));
498
+ if (members.length <= 16) return `"${members.join(" | ")}"`;
499
+ if (isDslLiteralUnion(members)) return `type.enumerated(${members.join(",")})`;
500
+ return chunksOf(members, 16).map((group) => `"${group.join(" | ")}"`).reduce(combine("|", inScope));
478
501
  }
479
502
  function intersectionStr(schemas, inScope = false) {
480
503
  return schemas.every(isQuoted) ? `"${schemas.map((s) => s.slice(1, -1)).join(" & ")}"` : schemas.reduce(combine("&", inScope));
@@ -567,7 +590,10 @@ function node(schema, rootName, isArktype, options) {
567
590
  ...options?.unsafeCodeExtensions === true && { unsafeCodeExtensions: true },
568
591
  ...isArktype && { scopeMode: true }
569
592
  };
570
- const arktypeWrap$1 = (arktypeStr, s) => arktypeWrap(arktypeStr, s, codeExtOpts);
593
+ const arktypeWrap$1 = (arktypeStr, s, extra) => arktypeWrap(arktypeStr, s, {
594
+ ...codeExtOpts,
595
+ ...extra
596
+ });
571
597
  const readonly = (v) => options?.readonly ? `${v}.readonly()` : v;
572
598
  const isStringWireParam = isStringWireLocation(options?.paramIn);
573
599
  const isWireCoerced = isStringWireParam && schema["x-coerce"] !== false;
@@ -688,7 +714,7 @@ function node(schema, rootName, isArktype, options) {
688
714
  if (schema.enum) {
689
715
  const values = schema.enum.filter((value) => value !== null);
690
716
  const input = values.length > 0 ? literalInput(values) : void 0;
691
- if (input === void 0) return arktypeWrap$1(_enum(schema), schema);
717
+ if (input === void 0) return arktypeWrap$1(_enum(enumWithoutWrappedNull(schema)), schema);
692
718
  const hasNull = values.length < schema.enum.length;
693
719
  return arktypeWrap$1(wireNumeric(input, _enum({
694
720
  ...schema,
@@ -777,7 +803,7 @@ function node(schema, rootName, isArktype, options) {
777
803
  if (isWireCoerced) return arktypeWrap$1("\"string.date.parse\"", schema);
778
804
  return arktypeWrap$1("\"Date\"", schema);
779
805
  }
780
- if (types.length === 1 && types[0] === "null") return arktypeWrap$1("\"null\"", schema);
806
+ if (types.length === 1 && types[0] === "null") return arktypeWrap$1("\"null\"", schema, { nullSchema: true });
781
807
  if (typeof schema.additionalProperties === "object") return readonly(arktypeWrap$1(object(schema, rootName, isArktype, options), schema));
782
808
  return arktypeWrap$1("\"unknown\"", schema);
783
809
  }
package/dist/arktype.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { r as JSONSchema } from "./index-DLVjyrKu.js";
2
- import { n as GenerateOptions } from "./index-DU2Nd8eI.js";
1
+ import { r as JSONSchema } from "./index-DZry7F2L.js";
2
+ import { n as GenerateOptions } from "./index-MUEfIMdR.js";
3
3
  /**
4
4
  * A whole JSON Schema document as an ArkType module. A document with definitions becomes
5
5
  * a `scope({...}).export()` so members can name one another; one without is a bare
package/dist/arktype.js CHANGED
@@ -1 +1 @@
1
- export { t as schemaToArktype } from "./arktype-CzTltPwP.js";
1
+ export { t as schemaToArktype } from "./arktype-pHeYh_IG.js";
package/dist/cli/ajv.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { t as schemaToAjv } from "../ajv-DejgT2o1.js";
3
- import { n as version, t as cli } from "../cli-CGTme770.js";
2
+ import { t as schemaToAjv } from "../ajv-BjWqjOc9.js";
3
+ import { n as version, t as cli } from "../cli-CtOh--vr.js";
4
4
  import * as Effect from "effect/Effect";
5
5
  import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
6
6
  import * as NodeServices from "@effect/platform-node/NodeServices";
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { t as schemaToArktype } from "../arktype-CzTltPwP.js";
3
- import { n as version, t as cli } from "../cli-CGTme770.js";
2
+ import { t as schemaToArktype } from "../arktype-pHeYh_IG.js";
3
+ import { n as version, t as cli } from "../cli-CtOh--vr.js";
4
4
  import * as Effect from "effect/Effect";
5
5
  import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
6
6
  import * as NodeServices from "@effect/platform-node/NodeServices";
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { t as schemaToEffect } from "../effect-Dj8qARFi.js";
3
- import { n as version, t as cli } from "../cli-CGTme770.js";
2
+ import { t as schemaToEffect } from "../effect-CM1XVqvf.js";
3
+ import { n as version, t as cli } from "../cli-CtOh--vr.js";
4
4
  import * as Effect from "effect/Effect";
5
5
  import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
6
6
  import * as NodeServices from "@effect/platform-node/NodeServices";
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { t as schemaToTypebox } from "../typebox-RAJnIZwI.js";
3
- import { n as version, t as cli } from "../cli-CGTme770.js";
2
+ import { t as schemaToTypebox } from "../typebox-D1GT2WSK.js";
3
+ import { n as version, t as cli } from "../cli-CtOh--vr.js";
4
4
  import * as Effect from "effect/Effect";
5
5
  import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
6
6
  import * as NodeServices from "@effect/platform-node/NodeServices";
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { t as schemaToValibot } from "../valibot-CLUhG6tp.js";
3
- import { n as version, t as cli } from "../cli-CGTme770.js";
2
+ import { t as schemaToValibot } from "../valibot-1p_Y7fu6.js";
3
+ import { n as version, t as cli } from "../cli-CtOh--vr.js";
4
4
  import * as Effect from "effect/Effect";
5
5
  import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
6
6
  import * as NodeServices from "@effect/platform-node/NodeServices";
package/dist/cli/yup.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { t as schemaToYup } from "../yup-DfE_ofEu.js";
3
- import { n as version, t as cli } from "../cli-CGTme770.js";
2
+ import { t as schemaToYup } from "../yup-IOat93gr.js";
3
+ import { n as version, t as cli } from "../cli-CtOh--vr.js";
4
4
  import * as Effect from "effect/Effect";
5
5
  import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
6
6
  import * as NodeServices from "@effect/platform-node/NodeServices";
package/dist/cli/zod.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { t as schemaToZod } from "../zod-BhYAQ3iW.js";
3
- import { n as version, t as cli } from "../cli-CGTme770.js";
2
+ import { t as schemaToZod } from "../zod-B-mxbHoq.js";
3
+ import { n as version, t as cli } from "../cli-CtOh--vr.js";
4
4
  import * as Effect from "effect/Effect";
5
5
  import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
6
6
  import * as NodeServices from "@effect/platform-node/NodeServices";
@@ -1,4 +1,4 @@
1
- import { Wt as isRecord } from "./helper-WSNbEQKr.js";
1
+ import { Gt as isRecord } from "./helper-1oDB5NHM.js";
2
2
  import { i as fmt, n as parseSchemaFile } from "./parser-RBrkz7ZL.js";
3
3
  import * as Effect from "effect/Effect";
4
4
  import path from "node:path";
@@ -9,7 +9,7 @@ import * as Stdio from "effect/Stdio";
9
9
  import "@effect/platform-node/NodeFileSystem";
10
10
  import * as FileSystem from "effect/FileSystem";
11
11
  // package.json
12
- var version = "0.8.4";
12
+ var version = "0.8.5";
13
13
  // src/file/index.ts
14
14
  /** Creates the directory and its parents. An existing directory is not an error. */
15
15
  function mkdir(dir) {
@@ -1,4 +1,4 @@
1
- import { A as wireArrayOnce, At as hasFixedLength, Bt as isObjectPrototypeProperty, C as isNullTextRead, D as stringboolPattern, Dt as hasCombinator, E as ownProperties, Ft as isComposite, G as renderDefinitions, H as emitOptionsOf, I as deepEqualExpression, In as UNSAFE_GENERATED_MARKER, J as discriminatedMembers, Jt as isStringWireLocation, K as rootNameOf, Kt as isSchemaObject, L as jsLiteral, Lt as isDefaultOnlyMember, M as wireNumericKind, N as formatPattern, Nt as hasType, O as stringboolTruthyPattern, Ot as hasConditional, P as regexSource, Q as itemsSchemaOf, Rt as isNullTypeMember, T as numberWirePattern, V as definitionsOf, W as planDocument, X as hasRootSelfReference, _ as hoistNestedRefs, _t as makeSafeKey, at as constraintMessage, b as impliedWireType, c as refTarget, ct as isKeywordOnlyMember, d as parameterReaders, dn as INTEGER_TEXT_PATTERN, f as propertyEmitOptions, ft as effectError, g as valueListLiteral, h as notPredicate, i as isEvaluatedKeyExpression, k as unionPrimitiveTypes, kt as hasFixedItemCount, l as withPolymorphicBases, m as isBigintFormat, mt as effectMessage, nn as DEFAULT_ROOT_NAME, o as typeDeclaration, ot as constraintPredicate, p as withoutParameterSerialization, pt as effectErrorPart, q as schemaNamer, qt as isShapelessMember, r as evaluatedProperties, rt as findCodeExtensionKeysInSchema, s as sanitizeSchema, st as foldAllOfMembers, u as hasParameterSerialization, ut as regexLiteral, v as effectPreprocess, vt as normalizeTypes, w as isPrimitiveUnion, x as integerWirePattern, y as effectWrap, yn as NUMBER_RANGES, zt as isNullable } from "./helper-WSNbEQKr.js";
1
+ import { $ as itemsSchemaOf, A as wireArrayOnce, At as hasFixedItemCount, Bt as isNullable, C as isNullTextRead, D as stringboolPattern, E as ownProperties, G as renderDefinitions, H as emitOptionsOf, I as deepEqualExpression, It as isComposite, J as discriminatedMembers, Jt as isShapelessMember, K as rootNameOf, L as jsLiteral, Ln as UNSAFE_GENERATED_MARKER, M as wireNumericKind, N as formatPattern, O as stringboolTruthyPattern, Ot as hasCombinator, P as regexSource, Pt as hasType, Rt as isDefaultOnlyMember, T as numberWirePattern, V as definitionsOf, Vt as isObjectPrototypeProperty, W as planDocument, X as hasRootSelfReference, Yt as isStringWireLocation, Z as enumWithoutWrappedNull, _ as hoistNestedRefs, b as impliedWireType, bn as NUMBER_RANGES, c as refTarget, ct as foldAllOfMembers, d as parameterReaders, dt as regexLiteral, f as propertyEmitOptions, fn as INTEGER_TEXT_PATTERN, g as valueListLiteral, h as notPredicate, ht as effectMessage, i as isEvaluatedKeyExpression, it as findCodeExtensionKeysInSchema, jt as hasFixedLength, k as unionPrimitiveTypes, kt as hasConditional, l as withPolymorphicBases, lt as isKeywordOnlyMember, m as isBigintFormat, mt as effectErrorPart, o as typeDeclaration, ot as constraintMessage, p as withoutParameterSerialization, pt as effectError, q as schemaNamer, qt as isSchemaObject, r as evaluatedProperties, rn as DEFAULT_ROOT_NAME, s as sanitizeSchema, st as constraintPredicate, u as hasParameterSerialization, v as effectPreprocess, vt as makeSafeKey, w as isPrimitiveUnion, x as integerWirePattern, y as effectWrap, yt as normalizeTypes, zt as isNullTypeMember } from "./helper-1oDB5NHM.js";
2
2
  // src/generator/effect/number.ts
3
3
  /** The bound and `multipleOf` checks of a numeric node. */
4
4
  function numberChecks(schema, lit = (n) => `${n}`, suffix = "") {
@@ -127,7 +127,12 @@ function _enum(schema) {
127
127
  const errorMessage = schema["x-enum-message"] ?? schema["x-error-message"];
128
128
  const annotate = (code) => errorMessage ? `${code}.annotate(${effectError(errorMessage)})` : code;
129
129
  const tuple = (arr) => `Schema.Tuple([${arr.map((i) => `Schema.Literal(${lit(i)})`).join(",")}])`;
130
- const literals = (values) => values.length > 1 ? `Schema.Literals([${values.map(lit).join(",")}])` : `Schema.Literal(${lit(values[0])})`;
130
+ const literals = (values) => {
131
+ const nonNull = values.filter((v) => v !== null);
132
+ if (nonNull.length === 0) return "Schema.Null";
133
+ const code = nonNull.length > 1 ? `Schema.Literals([${nonNull.map(lit).join(",")}])` : `Schema.Literal(${lit(nonNull[0])})`;
134
+ return nonNull.length < values.length ? `Schema.NullOr(${code})` : code;
135
+ };
131
136
  if (hasType(schema, "number") || hasType(schema, "integer") || hasType(schema, "boolean")) return annotate(literals(schema.enum));
132
137
  if (hasType(schema, "array")) {
133
138
  if (schema.enum.length === 1 && Array.isArray(schema.enum[0])) return annotate(tuple(schema.enum[0]));
@@ -449,7 +454,8 @@ function node(schema, rootName, isEffect, options) {
449
454
  ...isNullTextRead(s) && { nullText: true }
450
455
  };
451
456
  };
452
- const effectWrap$1 = (effectStr, s) => effectWrap(effectStr, s, {
457
+ const effectWrap$1 = (effectStr, s, extra) => effectWrap(effectStr, s, {
458
+ ...extra,
453
459
  ...codeExtOpts,
454
460
  ...wireOptions(s),
455
461
  ...options?.definitions !== void 0 && { definitions: options.definitions }
@@ -545,7 +551,7 @@ function node(schema, rootName, isEffect, options) {
545
551
  if (schema.enum) {
546
552
  const values = schema.enum.filter((value) => value !== null);
547
553
  const input = values.length > 0 ? literalInput(values) : void 0;
548
- if (input === void 0) return effectWrap$1(_enum(schema), schema);
554
+ if (input === void 0) return effectWrap$1(_enum(enumWithoutWrappedNull(schema)), schema);
549
555
  const hasNull = values.length < schema.enum.length;
550
556
  const piped = `${input}.pipe(Schema.decodeTo(${_enum({
551
557
  ...schema,
@@ -627,7 +633,7 @@ function node(schema, rootName, isEffect, options) {
627
633
  return out;
628
634
  })();
629
635
  const checks = [
630
- isFixedLength ? `Schema.isLengthBetween(${schema.minItems},${schema.minItems}${sizeArg})` : void 0,
636
+ isFixedLength ? `Schema.isBetweenLength(${schema.minItems},${schema.minItems}${sizeArg})` : void 0,
631
637
  !isFixedLength && typeof schema.minItems === "number" ? `Schema.isMinLength(${schema.minItems}${minArg})` : void 0,
632
638
  !isFixedLength && typeof schema.maxItems === "number" ? `Schema.isMaxLength(${schema.maxItems}${maxArg})` : void 0,
633
639
  schema.uniqueItems === true ? `Schema.isUnique(${uniqueArg.slice(1)})` : void 0,
@@ -640,7 +646,7 @@ function node(schema, rootName, isEffect, options) {
640
646
  if (isWireCoerced) return effectWrap$1("Schema.DateFromString", schema);
641
647
  return effectWrap$1("Schema.Date", schema);
642
648
  }
643
- if (types.length === 1 && types[0] === "null") return effectWrap$1("Schema.Null", schema);
649
+ if (types.length === 1 && types[0] === "null") return effectWrap$1("Schema.Null", schema, { nullSchema: true });
644
650
  if (typeof schema.additionalProperties === "object") return effectWrap$1(object(schema, rootName, isEffect, options), schema);
645
651
  return effectWrap$1("Schema.Unknown", schema);
646
652
  }
package/dist/effect.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { r as JSONSchema } from "./index-DLVjyrKu.js";
2
- import { n as GenerateOptions } from "./index-DU2Nd8eI.js";
1
+ import { r as JSONSchema } from "./index-DZry7F2L.js";
2
+ import { n as GenerateOptions } from "./index-MUEfIMdR.js";
3
3
  /**
4
4
  * A whole JSON Schema document as an Effect Schema module: imports, `$defs` in
5
5
  * dependency order, the root export, and the inferred type.
package/dist/effect.js CHANGED
@@ -1 +1 @@
1
- export { t as schemaToEffect } from "./effect-Dj8qARFi.js";
1
+ export { t as schemaToEffect } from "./effect-CM1XVqvf.js";
@@ -397,7 +397,7 @@ const UNSAFE_GENERATED_MARKER = "// @generated-with-unsafe-code-extensions";
397
397
  /** The first line of a file whose generator dropped `if` / `then` / `else`. */
398
398
  const IF_THEN_ELSE_UNSUPPORTED_MARKER = "// FIXME: JSON Schema if/then/else is not yet supported by this generator; conditional validation is omitted";
399
399
  /** The first line of a TypeBox file whose generator dropped a `not` keyword. */
400
- const NOT_KEYWORD_UNSUPPORTED_MARKER = "// FIXME: JSON Schema `not` is not enforced by this generator; TypeBox v1 has no runtime `Type.Not` and `Value.Check` ignores the keyword (falls back to `Type.Any()`)";
400
+ const NOT_KEYWORD_UNSUPPORTED_MARKER = "// FIXME: JSON Schema `not` is not enforced by this generator; TypeBox v1 has no runtime `Type.Not` and `Value.Check` ignores the keyword (the schema is generated without it)";
401
401
  /** The comment left where a `$ref` names a definition the document does not hold. */
402
402
  const MISSING_DEFINITION_PREFIX = "// ⚠️ missing definition for ";
403
403
  /** A JSON Pointer `$ref` to a named definition: `#/$defs/Name` or `#/definitions/Name`. */
@@ -1554,8 +1554,8 @@ function hasKeyword(root, keywords) {
1554
1554
  }
1555
1555
  /**
1556
1556
  * Whether a schema (at any depth) uses the JSON Schema `not` keyword. The TypeBox
1557
- * generator falls back to `Type.Any()` because TypeBox v1 has no runtime `Type.Not(...)`
1558
- * and `Value.Check` does not evaluate `not`.
1557
+ * generator drops the keyword (a bare `not` falls back to `Type.Any()`) because TypeBox v1
1558
+ * has no runtime `Type.Not(...)` and `Value.Check` does not evaluate `not`.
1559
1559
  */
1560
1560
  function hasNotKeyword(schema) {
1561
1561
  return hasKeyword(schema, ["not"]);
@@ -1666,7 +1666,7 @@ function arktypePreprocess(readers, inner, input = "unknown") {
1666
1666
  function arktypeWrap(arktypeStr, schema, options) {
1667
1667
  const inScope = options?.scopeMode === true;
1668
1668
  const isDefinition = isArktypeDefinition;
1669
- const withNullable = isNullable(schema) ? isQuoted(arktypeStr) ? `"${arktypeStr.slice(1, -1)} | null"` : inScope && isDefinition(arktypeStr) ? `[${arktypeStr},"|","null"]` : `type(${arktypeStr}).or("null")` : arktypeStr;
1669
+ const withNullable = isNullable(schema) && options?.nullSchema !== true ? isQuoted(arktypeStr) ? `"${arktypeStr.slice(1, -1)} | null"` : inScope && isDefinition(arktypeStr) ? `[${arktypeStr},"|","null"]` : `type(${arktypeStr}).or("null")` : arktypeStr;
1670
1670
  const withReadonly = schema["x-readonly"] === true ? isDefinition(withNullable) ? `type(${withNullable}).readonly()` : `${withNullable}.readonly()` : withNullable;
1671
1671
  const brand = schema["x-brand"];
1672
1672
  const withBrand = typeof brand === "string" ? isDefinition(withReadonly) ? `type(${withReadonly}).brand("${brand}")` : `${withReadonly}.brand("${brand}")` : withReadonly;
@@ -1698,6 +1698,19 @@ function itemsSchemaOf(items) {
1698
1698
  if (isSchemaList(items)) return items[0];
1699
1699
  }
1700
1700
  /**
1701
+ * The node an enum emitter reads: without the `null` among its values when the nullability
1702
+ * wrapper adds `null` already (`type: ['string', 'null'], enum: ['a', null]`), so the value is
1703
+ * not listed twice. An enum of nothing but `null` keeps it.
1704
+ */
1705
+ function enumWithoutWrappedNull(schema) {
1706
+ if (schema.enum === void 0 || !isNullable(schema)) return schema;
1707
+ const values = schema.enum.filter((value) => value !== null);
1708
+ return values.length === 0 || values.length === schema.enum.length ? schema : {
1709
+ ...schema,
1710
+ enum: values
1711
+ };
1712
+ }
1713
+ /**
1701
1714
  * The example values of a node: `examples` as given, or the single OpenAPI `example`
1702
1715
  * lifted into a list. `undefined` when the node carries neither.
1703
1716
  */
@@ -2284,7 +2297,7 @@ function defaultLiteral$1(schema, value) {
2284
2297
  */
2285
2298
  function effectWrap(effectStr, schema, options) {
2286
2299
  const nullText = options?.nullText === true;
2287
- const withNullable = isNullable(schema) || nullText && !isNullMatchedFirst(schema) ? `Schema.NullOr(${effectStr})` : effectStr;
2300
+ const withNullable = isNullable(schema) && options?.nullSchema !== true || nullText && !isNullMatchedFirst(schema) ? `Schema.NullOr(${effectStr})` : effectStr;
2288
2301
  const withNullText = nullText ? effectPreprocess([wireNullText("input")], withNullable) : withNullable;
2289
2302
  const brand = schema["x-brand"];
2290
2303
  const withBrand = typeof brand === "string" ? `${withNullText}.pipe(Schema.brand("${brand}"))` : withNullText;
@@ -2968,8 +2981,8 @@ function nonNullType(schema, flavour, rootName) {
2968
2981
  * time, because TypeBox stores metadata on the schema object during
2969
2982
  * construction and exposes no post-construction `.meta()` method.
2970
2983
  */
2971
- function typeboxWrap(typeboxStr, schema, definitions) {
2972
- const withNullable = isNullable(schema) ? `Type.Union([${typeboxStr},Type.Null()])` : typeboxStr;
2984
+ function typeboxWrap(typeboxStr, schema, definitions, options) {
2985
+ const withNullable = isNullable(schema) && options?.nullSchema !== true ? `Type.Union([${typeboxStr},Type.Null()])` : typeboxStr;
2973
2986
  const withReadonly = schema["x-readonly"] === true ? `Type.Readonly(${withNullable})` : withNullable;
2974
2987
  return hasKeptDefault(schema, definitions) ? `Type.Optional(${withReadonly})` : withReadonly;
2975
2988
  }
@@ -3061,7 +3074,7 @@ function defaultLiteral(schema, value, stringWire) {
3061
3074
  */
3062
3075
  function valibotWrap(valibotStr, schema, options) {
3063
3076
  const nullText = options?.nullText === true;
3064
- const withNullable = isNullable(schema) || nullText && !isNullMatchedFirst(schema) ? `v.nullable(${valibotStr})` : valibotStr;
3077
+ const withNullable = isNullable(schema) && options?.nullSchema !== true || nullText && !isNullMatchedFirst(schema) ? `v.nullable(${valibotStr})` : valibotStr;
3065
3078
  const withNullText = nullText ? `v.pipe(v.unknown(),v.transform(${wireNullText("input")}),${withNullable})` : withNullable;
3066
3079
  const defaultResult = schema.default !== void 0 ? coerceDefault(schema, schema.default, options?.definitions) : void 0;
3067
3080
  const withDefault = defaultResult?.keep ? `v.optional(${withNullText},${defaultLiteral(schema, defaultResult.value, options?.stringWire === true)})` : withNullText;
@@ -3113,7 +3126,7 @@ function zodWrap(zodStr, schema, options) {
3113
3126
  return JSON.stringify(value);
3114
3127
  };
3115
3128
  const defaultResult = schema.default !== void 0 ? coerceDefault(schema, schema.default, options?.definitions) : void 0;
3116
- const withNullable = isNullable(schema) ? `${zodStr}.nullable()` : zodStr;
3129
+ const withNullable = isNullable(schema) && options?.nullSchema !== true ? `${zodStr}.nullable()` : zodStr;
3117
3130
  const withDefault = defaultResult?.keep ? `${withNullable}.default(${formatLiteral(defaultResult.value)})` : withNullable;
3118
3131
  const withReadonly = schema["x-readonly"] === true ? `${withDefault}.readonly()` : withDefault;
3119
3132
  const withPrefault = schema["x-prefault"] !== void 0 ? `${withReadonly}.prefault(${formatLiteral(schema["x-prefault"])})` : withReadonly;
@@ -3141,4 +3154,4 @@ function zodWrap(zodStr, schema, options) {
3141
3154
  if (preprocess) return preprocess;
3142
3155
  return withMeta;
3143
3156
  }
3144
- export { arktypePreprocess as $, COMPONENT_SCHEMA_REF_PREFIX as $t, wireArrayOnce as A, STRINGBOOL_PATTERN as An, hasFixedLength as At, typeboxRefOpt as B, isObjectPrototypeProperty as Bt, isNullTextRead as C, OFFSET_PATTERN_SOURCE as Cn, valibotErrorPart as Ct, stringboolPattern as D, PARAM_STYLES as Dn, hasCombinator as Dt, ownProperties as E, PARAM_LOCATIONS as En, zodErrorPart as Et, timePattern as F, UNICODE_ESCAPE_PATTERN as Fn, isComposite as Ft, renderDefinitions as G, isRootRef as Gt, emitOptionsOf as H, isPrimitive as Ht, deepEqualExpression as I, UNSAFE_GENERATED_MARKER as In, isDeepLocalPointer as It, discriminatedMembers as J, isStringWireLocation as Jt, rootNameOf as K, isSchemaObject as Kt, jsLiteral as L, VALIBOT_CODE_EXTENSION_KEYS as Ln, isDefaultOnlyMember as Lt, wireNumericKind as M, STRING_FORMATS as Mn, hasStringKeyword as Mt, formatPattern as N, STRING_KEYWORDS as Nn, hasType as Nt, stringboolTruthyPattern as O, QUOTE_OR_BACKSLASH_PATTERN as On, hasConditional as Ot, regexSource as P, STRING_WIRE_LOCATIONS as Pn, isArktypeDefinition as Pt, itemsSchemaOf as Q, ARROW_FUNCTION_PATTERN as Qt, typeboxDefaultOpt as R, WIRE_PRIMITIVE_ORDER as Rn, isNullTypeMember as Rt, isNullMatchedFirst as S, OBJECT_PROTOTYPE_PROPERTIES as Sn, valibotError as St, numberWirePattern as T, OUTPUT_EXTENSION as Tn, zodError as Tt, missingDefinitionComment as U, isQuoted as Ut, definitionsOf as V, isPlainObject as Vt, planDocument as W, isRecord as Wt, hasRootSelfReference as X, ANCHOR_REF_PATTERN as Xt, cyclicDefinitionNames as Y, ALL_CODE_EXTENSION_KEYS as Yt, isOptionalByDefault as Z, ARKTYPE_CODE_EXTENSION_KEYS as Zt, hoistNestedRefs as _, NOT_KEYWORD_UNSUPPORTED_MARKER as _n, makeSafeKey as _t, typeboxWrap as a, DEFINITION_REF_PREFIXES as an, constraintMessage as at, impliedWireType as b, NUMBER_WIRE_PATTERN as bn, toIdentifierPascalCase as bt, refTarget as c, IDENTIFIER_PATTERN as cn, isKeywordOnlyMember as ct, parameterReaders as d, INTEGER_TEXT_PATTERN as dn, coerceDefault as dt, CONTENT_ENCODINGS as en, arktypeWrap as et, propertyEmitOptions as f, INTEGER_WIRE_PATTERN as fn, effectError as ft, valueListLiteral as g, NON_IDENTIFIER_CHARACTER_PATTERN as gn, issueMessageExpression as gt, notPredicate as h, MISSING_DEFINITION_PREFIX as hn, encodeNonAscii as ht, isEvaluatedKeyExpression as i, DEFINITION_POINTER_PATTERN as in, hasNotKeyword as it, wireNullText as j, STRINGBOOL_TRUTHY_PATTERN as jn, hasNumericKeyword as jt, unionPrimitiveTypes as k, ROOT_REFS as kn, hasFixedItemCount as kt, withPolymorphicBases as l, IF_THEN_ELSE_UNSUPPORTED_MARKER as ln, patternSource as lt, isBigintFormat as m, JSON_SCHEMA_TYPES as mn, effectMessage as mt, valibotWrap as n, DEFAULT_ROOT_NAME as nn, callbackType as nt, typeDeclaration as o, EFFECT_CODE_EXTENSION_KEYS as on, constraintPredicate as ot, withoutParameterSerialization as p, ISO_4217_CURRENCY_CODES as pn, effectErrorPart as pt, schemaNamer as q, isShapelessMember as qt, evaluatedProperties as r, DEFINITION_KEYWORDS as rn, findCodeExtensionKeysInSchema as rt, sanitizeSchema as s, FORMAT_PATTERNS as sn, foldAllOfMembers as st, zodWrap as t, DATE_PATTERN_SOURCE as tn, callbackReturn as tt, hasParameterSerialization as u, INPUT_EXTENSIONS as un, regexLiteral as ut, effectPreprocess as v, NUMBER_FORMATS as vn, normalizeTypes as vt, isPrimitiveUnion as w, OPENAPI_COMPONENT_SUFFIX_MAP as wn, zodBaseError as wt, integerWirePattern as x, NUMERIC_KEYWORDS as xn, toPascalCase as xt, effectWrap as y, NUMBER_RANGES as yn, resolveOpenAPIRef as yt, typeboxMetaOpts as z, ZOD_CODE_EXTENSION_KEYS as zn, isNullable as zt };
3157
+ export { itemsSchemaOf as $, ARROW_FUNCTION_PATTERN as $t, wireArrayOnce as A, ROOT_REFS as An, hasFixedItemCount as At, typeboxRefOpt as B, ZOD_CODE_EXTENSION_KEYS as Bn, isNullable as Bt, isNullTextRead as C, OBJECT_PROTOTYPE_PROPERTIES as Cn, valibotError as Ct, stringboolPattern as D, PARAM_LOCATIONS as Dn, zodErrorPart as Dt, ownProperties as E, OUTPUT_EXTENSION as En, zodError as Et, timePattern as F, STRING_WIRE_LOCATIONS as Fn, isArktypeDefinition as Ft, renderDefinitions as G, isRecord as Gt, emitOptionsOf as H, isPlainObject as Ht, deepEqualExpression as I, UNICODE_ESCAPE_PATTERN as In, isComposite as It, discriminatedMembers as J, isShapelessMember as Jt, rootNameOf as K, isRootRef as Kt, jsLiteral as L, UNSAFE_GENERATED_MARKER as Ln, isDeepLocalPointer as Lt, wireNumericKind as M, STRINGBOOL_TRUTHY_PATTERN as Mn, hasNumericKeyword as Mt, formatPattern as N, STRING_FORMATS as Nn, hasStringKeyword as Nt, stringboolTruthyPattern as O, PARAM_STYLES as On, hasCombinator as Ot, regexSource as P, STRING_KEYWORDS as Pn, hasType as Pt, isOptionalByDefault as Q, ARKTYPE_CODE_EXTENSION_KEYS as Qt, typeboxDefaultOpt as R, VALIBOT_CODE_EXTENSION_KEYS as Rn, isDefaultOnlyMember as Rt, isNullMatchedFirst as S, NUMERIC_KEYWORDS as Sn, toPascalCase as St, numberWirePattern as T, OPENAPI_COMPONENT_SUFFIX_MAP as Tn, zodBaseError as Tt, missingDefinitionComment as U, isPrimitive as Ut, definitionsOf as V, isObjectPrototypeProperty as Vt, planDocument as W, isQuoted as Wt, hasRootSelfReference as X, ALL_CODE_EXTENSION_KEYS as Xt, cyclicDefinitionNames as Y, isStringWireLocation as Yt, enumWithoutWrappedNull as Z, ANCHOR_REF_PATTERN as Zt, hoistNestedRefs as _, NON_IDENTIFIER_CHARACTER_PATTERN as _n, issueMessageExpression as _t, typeboxWrap as a, DEFINITION_POINTER_PATTERN as an, hasNotKeyword as at, impliedWireType as b, NUMBER_RANGES as bn, resolveOpenAPIRef as bt, refTarget as c, FORMAT_PATTERNS as cn, foldAllOfMembers as ct, parameterReaders as d, INPUT_EXTENSIONS as dn, regexLiteral as dt, COMPONENT_SCHEMA_REF_PREFIX as en, arktypePreprocess as et, propertyEmitOptions as f, INTEGER_TEXT_PATTERN as fn, coerceDefault as ft, valueListLiteral as g, MISSING_DEFINITION_PREFIX as gn, encodeNonAscii as gt, notPredicate as h, JSON_SCHEMA_TYPES as hn, effectMessage as ht, isEvaluatedKeyExpression as i, DEFINITION_KEYWORDS as in, findCodeExtensionKeysInSchema as it, wireNullText as j, STRINGBOOL_PATTERN as jn, hasFixedLength as jt, unionPrimitiveTypes as k, QUOTE_OR_BACKSLASH_PATTERN as kn, hasConditional as kt, withPolymorphicBases as l, IDENTIFIER_PATTERN as ln, isKeywordOnlyMember as lt, isBigintFormat as m, ISO_4217_CURRENCY_CODES as mn, effectErrorPart as mt, valibotWrap as n, DATE_PATTERN_SOURCE as nn, callbackReturn as nt, typeDeclaration as o, DEFINITION_REF_PREFIXES as on, constraintMessage as ot, withoutParameterSerialization as p, INTEGER_WIRE_PATTERN as pn, effectError as pt, schemaNamer as q, isSchemaObject as qt, evaluatedProperties as r, DEFAULT_ROOT_NAME as rn, callbackType as rt, sanitizeSchema as s, EFFECT_CODE_EXTENSION_KEYS as sn, constraintPredicate as st, zodWrap as t, CONTENT_ENCODINGS as tn, arktypeWrap as tt, hasParameterSerialization as u, IF_THEN_ELSE_UNSUPPORTED_MARKER as un, patternSource as ut, effectPreprocess as v, NOT_KEYWORD_UNSUPPORTED_MARKER as vn, makeSafeKey as vt, isPrimitiveUnion as w, OFFSET_PATTERN_SOURCE as wn, valibotErrorPart as wt, integerWirePattern as x, NUMBER_WIRE_PATTERN as xn, toIdentifierPascalCase as xt, effectWrap as y, NUMBER_FORMATS as yn, normalizeTypes as yt, typeboxMetaOpts as z, WIRE_PRIMITIVE_ORDER as zn, isNullTypeMember as zt };
@@ -163,7 +163,7 @@ declare const UNSAFE_GENERATED_MARKER = "// @generated-with-unsafe-code-extensio
163
163
  /** The first line of a file whose generator dropped `if` / `then` / `else`. */
164
164
  declare const IF_THEN_ELSE_UNSUPPORTED_MARKER = "// FIXME: JSON Schema if/then/else is not yet supported by this generator; conditional validation is omitted";
165
165
  /** The first line of a TypeBox file whose generator dropped a `not` keyword. */
166
- declare const NOT_KEYWORD_UNSUPPORTED_MARKER = "// FIXME: JSON Schema `not` is not enforced by this generator; TypeBox v1 has no runtime `Type.Not` and `Value.Check` ignores the keyword (falls back to `Type.Any()`)";
166
+ declare const NOT_KEYWORD_UNSUPPORTED_MARKER = "// FIXME: JSON Schema `not` is not enforced by this generator; TypeBox v1 has no runtime `Type.Not` and `Value.Check` ignores the keyword (the schema is generated without it)";
167
167
  /** The comment left where a `$ref` names a definition the document does not hold. */
168
168
  declare const MISSING_DEFINITION_PREFIX = "// ⚠️ missing definition for ";
169
169
  /** A JSON Pointer `$ref` to a named definition: `#/$defs/Name` or `#/definitions/Name`. */
@@ -1,4 +1,4 @@
1
- import { h as ParamStyle, m as ParamIn, r as JSONSchema } from "./index-DLVjyrKu.js";
1
+ import { h as ParamStyle, m as ParamIn, r as JSONSchema } from "./index-DZry7F2L.js";
2
2
  /** Named schemas a `default` beside a `$ref` is reconciled against. */
3
3
  type SchemaDefinitions = {
4
4
  readonly [name: string]: JSONSchema;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { $ as QUOTE_OR_BACKSLASH_PATTERN, A as DEFINITION_REF_PREFIXES, B as MISSING_DEFINITION_PREFIX, C as ARROW_FUNCTION_PATTERN, D as DEFAULT_ROOT_NAME, E as DATE_PATTERN_SOURCE, F as INPUT_EXTENSIONS, G as NUMBER_WIRE_PATTERN, H as NOT_KEYWORD_UNSUPPORTED_MARKER, I as INTEGER_TEXT_PATTERN, J as OFFSET_PATTERN_SOURCE, K as NUMERIC_KEYWORDS, L as INTEGER_WIRE_PATTERN, M as FORMAT_PATTERNS, N as IDENTIFIER_PATTERN, O as DEFINITION_KEYWORDS, P as IF_THEN_ELSE_UNSUPPORTED_MARKER, Q as PARAM_STYLES, R as ISO_4217_CURRENCY_CODES, S as ARKTYPE_CODE_EXTENSION_KEYS, T as CONTENT_ENCODINGS, U as NUMBER_FORMATS, V as NON_IDENTIFIER_CHARACTER_PATTERN, W as NUMBER_RANGES, X as OUTPUT_EXTENSION, Y as OPENAPI_COMPONENT_SUFFIX_MAP, Z as PARAM_LOCATIONS, _ as XExtMessages, a as JSONSchemaNumberFormat, at as STRING_WIRE_LOCATIONS, b as ALL_CODE_EXTENSION_KEYS, c as JSONSchemaTypes, ct as VALIBOT_CODE_EXTENSION_KEYS, d as Ref, et as ROOT_REFS, f as parseSchemaFile, g as XExtParam, h as ParamStyle, i as JSONSchemaFormat, it as STRING_KEYWORDS, j as EFFECT_CODE_EXTENSION_KEYS, k as DEFINITION_POINTER_PATTERN, l as LocalRef, lt as WIRE_PRIMITIVE_ORDER, m as ParamIn, n as ExternalRef, nt as STRINGBOOL_TRUTHY_PATTERN, o as JSONSchemaStringFormat, ot as UNICODE_ESCAPE_PATTERN, p as XExtTransform, q as OBJECT_PROTOTYPE_PROPERTIES, r as JSONSchema, rt as STRING_FORMATS, s as JSONSchemaType, st as UNSAFE_GENERATED_MARKER, t as ContentEncoding, tt as STRINGBOOL_PATTERN, u as ParseError, ut as ZOD_CODE_EXTENSION_KEYS, v as XExtCode, w as COMPONENT_SCHEMA_REF_PREFIX, x as ANCHOR_REF_PATTERN, y as JSONValue, z as JSON_SCHEMA_TYPES } from "./index-DLVjyrKu.js";
1
+ import { $ as QUOTE_OR_BACKSLASH_PATTERN, A as DEFINITION_REF_PREFIXES, B as MISSING_DEFINITION_PREFIX, C as ARROW_FUNCTION_PATTERN, D as DEFAULT_ROOT_NAME, E as DATE_PATTERN_SOURCE, F as INPUT_EXTENSIONS, G as NUMBER_WIRE_PATTERN, H as NOT_KEYWORD_UNSUPPORTED_MARKER, I as INTEGER_TEXT_PATTERN, J as OFFSET_PATTERN_SOURCE, K as NUMERIC_KEYWORDS, L as INTEGER_WIRE_PATTERN, M as FORMAT_PATTERNS, N as IDENTIFIER_PATTERN, O as DEFINITION_KEYWORDS, P as IF_THEN_ELSE_UNSUPPORTED_MARKER, Q as PARAM_STYLES, R as ISO_4217_CURRENCY_CODES, S as ARKTYPE_CODE_EXTENSION_KEYS, T as CONTENT_ENCODINGS, U as NUMBER_FORMATS, V as NON_IDENTIFIER_CHARACTER_PATTERN, W as NUMBER_RANGES, X as OUTPUT_EXTENSION, Y as OPENAPI_COMPONENT_SUFFIX_MAP, Z as PARAM_LOCATIONS, _ as XExtMessages, a as JSONSchemaNumberFormat, at as STRING_WIRE_LOCATIONS, b as ALL_CODE_EXTENSION_KEYS, c as JSONSchemaTypes, ct as VALIBOT_CODE_EXTENSION_KEYS, d as Ref, et as ROOT_REFS, f as parseSchemaFile, g as XExtParam, h as ParamStyle, i as JSONSchemaFormat, it as STRING_KEYWORDS, j as EFFECT_CODE_EXTENSION_KEYS, k as DEFINITION_POINTER_PATTERN, l as LocalRef, lt as WIRE_PRIMITIVE_ORDER, m as ParamIn, n as ExternalRef, nt as STRINGBOOL_TRUTHY_PATTERN, o as JSONSchemaStringFormat, ot as UNICODE_ESCAPE_PATTERN, p as XExtTransform, q as OBJECT_PROTOTYPE_PROPERTIES, r as JSONSchema, rt as STRING_FORMATS, s as JSONSchemaType, st as UNSAFE_GENERATED_MARKER, t as ContentEncoding, tt as STRINGBOOL_PATTERN, u as ParseError, ut as ZOD_CODE_EXTENSION_KEYS, v as XExtCode, w as COMPONENT_SCHEMA_REF_PREFIX, x as ANCHOR_REF_PATTERN, y as JSONValue, z as JSON_SCHEMA_TYPES } from "./index-DZry7F2L.js";
2
2
  import { schemaToAjv } from "./ajv.js";
3
- import { n as GenerateOptions, r as SchemaDefinitions, t as EmitOptions } from "./index-DU2Nd8eI.js";
3
+ import { n as GenerateOptions, r as SchemaDefinitions, t as EmitOptions } from "./index-MUEfIMdR.js";
4
4
  import { schemaToArktype } from "./arktype.js";
5
5
  import { schemaToEffect } from "./effect.js";
6
6
  import { TypeboxGenerateOptions, schemaToTypebox } from "./typebox.js";
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import { $t as COMPONENT_SCHEMA_REF_PREFIX, An as STRINGBOOL_PATTERN, Cn as OFFSET_PATTERN_SOURCE, Ct as valibotErrorPart, Dn as PARAM_STYLES, En as PARAM_LOCATIONS, Et as zodErrorPart, Fn as UNICODE_ESCAPE_PATTERN, In as UNSAFE_GENERATED_MARKER, Ln as VALIBOT_CODE_EXTENSION_KEYS, Mn as STRING_FORMATS, Nn as STRING_KEYWORDS, On as QUOTE_OR_BACKSLASH_PATTERN, Pn as STRING_WIRE_LOCATIONS, Qt as ARROW_FUNCTION_PATTERN, Rn as WIRE_PRIMITIVE_ORDER, Sn as OBJECT_PROTOTYPE_PROPERTIES, St as valibotError, Tn as OUTPUT_EXTENSION, Tt as zodError, Xt as ANCHOR_REF_PATTERN, Yt as ALL_CODE_EXTENSION_KEYS, Zt as ARKTYPE_CODE_EXTENSION_KEYS, _n as NOT_KEYWORD_UNSUPPORTED_MARKER, _t as makeSafeKey, an as DEFINITION_REF_PREFIXES, bn as NUMBER_WIRE_PATTERN, bt as toIdentifierPascalCase, cn as IDENTIFIER_PATTERN, dn as INTEGER_TEXT_PATTERN, dt as coerceDefault, en as CONTENT_ENCODINGS, fn as INTEGER_WIRE_PATTERN, ft as effectError, gn as NON_IDENTIFIER_CHARACTER_PATTERN, gt as issueMessageExpression, hn as MISSING_DEFINITION_PREFIX, ht as encodeNonAscii, in as DEFINITION_POINTER_PATTERN, jn as STRINGBOOL_TRUTHY_PATTERN, kn as ROOT_REFS, ln as IF_THEN_ELSE_UNSUPPORTED_MARKER, mn as JSON_SCHEMA_TYPES, mt as effectMessage, nn as DEFAULT_ROOT_NAME, on as EFFECT_CODE_EXTENSION_KEYS, pn as ISO_4217_CURRENCY_CODES, pt as effectErrorPart, rn as DEFINITION_KEYWORDS, sn as FORMAT_PATTERNS, tn as DATE_PATTERN_SOURCE, un as INPUT_EXTENSIONS, vn as NUMBER_FORMATS, vt as normalizeTypes, wn as OPENAPI_COMPONENT_SUFFIX_MAP, wt as zodBaseError, xn as NUMERIC_KEYWORDS, xt as toPascalCase, yn as NUMBER_RANGES, yt as resolveOpenAPIRef, zn as ZOD_CODE_EXTENSION_KEYS } from "./helper-WSNbEQKr.js";
1
+ import { $t as ARROW_FUNCTION_PATTERN, An as ROOT_REFS, Bn as ZOD_CODE_EXTENSION_KEYS, Cn as OBJECT_PROTOTYPE_PROPERTIES, Ct as valibotError, Dn as PARAM_LOCATIONS, Dt as zodErrorPart, En as OUTPUT_EXTENSION, Et as zodError, Fn as STRING_WIRE_LOCATIONS, In as UNICODE_ESCAPE_PATTERN, Ln as UNSAFE_GENERATED_MARKER, Mn as STRINGBOOL_TRUTHY_PATTERN, Nn as STRING_FORMATS, On as PARAM_STYLES, Pn as STRING_KEYWORDS, Qt as ARKTYPE_CODE_EXTENSION_KEYS, Rn as VALIBOT_CODE_EXTENSION_KEYS, Sn as NUMERIC_KEYWORDS, St as toPascalCase, Tn as OPENAPI_COMPONENT_SUFFIX_MAP, Tt as zodBaseError, Xt as ALL_CODE_EXTENSION_KEYS, Zt as ANCHOR_REF_PATTERN, _n as NON_IDENTIFIER_CHARACTER_PATTERN, _t as issueMessageExpression, an as DEFINITION_POINTER_PATTERN, bn as NUMBER_RANGES, bt as resolveOpenAPIRef, cn as FORMAT_PATTERNS, dn as INPUT_EXTENSIONS, en as COMPONENT_SCHEMA_REF_PREFIX, fn as INTEGER_TEXT_PATTERN, ft as coerceDefault, gn as MISSING_DEFINITION_PREFIX, gt as encodeNonAscii, hn as JSON_SCHEMA_TYPES, ht as effectMessage, in as DEFINITION_KEYWORDS, jn as STRINGBOOL_PATTERN, kn as QUOTE_OR_BACKSLASH_PATTERN, ln as IDENTIFIER_PATTERN, mn as ISO_4217_CURRENCY_CODES, mt as effectErrorPart, nn as DATE_PATTERN_SOURCE, on as DEFINITION_REF_PREFIXES, pn as INTEGER_WIRE_PATTERN, pt as effectError, rn as DEFAULT_ROOT_NAME, sn as EFFECT_CODE_EXTENSION_KEYS, tn as CONTENT_ENCODINGS, un as IF_THEN_ELSE_UNSUPPORTED_MARKER, vn as NOT_KEYWORD_UNSUPPORTED_MARKER, vt as makeSafeKey, wn as OFFSET_PATTERN_SOURCE, wt as valibotErrorPart, xn as NUMBER_WIRE_PATTERN, xt as toIdentifierPascalCase, yn as NUMBER_FORMATS, yt as normalizeTypes, zn as WIRE_PRIMITIVE_ORDER } from "./helper-1oDB5NHM.js";
2
2
  import { i as fmt, n as parseSchemaFile, r as FormatError, t as ParseError } from "./parser-RBrkz7ZL.js";
3
- import { n as ajv, t as schemaToAjv } from "./ajv-DejgT2o1.js";
4
- import { n as arktype, t as schemaToArktype } from "./arktype-CzTltPwP.js";
5
- import { n as effect, r as wholeValueMessage, t as schemaToEffect } from "./effect-Dj8qARFi.js";
6
- import { n as nestedTypeboxOptions, r as typebox, t as schemaToTypebox } from "./typebox-RAJnIZwI.js";
7
- import { n as valibot, t as schemaToValibot } from "./valibot-CLUhG6tp.js";
8
- import { n as yup, t as schemaToYup } from "./yup-DfE_ofEu.js";
9
- import { i as zod, n as forwardIssue, r as nestedIssueMessageWrap, t as schemaToZod } from "./zod-BhYAQ3iW.js";
3
+ import { n as ajv, t as schemaToAjv } from "./ajv-BjWqjOc9.js";
4
+ import { n as arktype, t as schemaToArktype } from "./arktype-pHeYh_IG.js";
5
+ import { n as effect, r as wholeValueMessage, t as schemaToEffect } from "./effect-CM1XVqvf.js";
6
+ import { n as nestedTypeboxOptions, r as typebox, t as schemaToTypebox } from "./typebox-D1GT2WSK.js";
7
+ import { n as valibot, t as schemaToValibot } from "./valibot-1p_Y7fu6.js";
8
+ import { n as yup, t as schemaToYup } from "./yup-IOat93gr.js";
9
+ import { i as zod, n as forwardIssue, r as nestedIssueMessageWrap, t as schemaToZod } from "./zod-B-mxbHoq.js";
10
10
  export { ALL_CODE_EXTENSION_KEYS, ANCHOR_REF_PATTERN, ARKTYPE_CODE_EXTENSION_KEYS, ARROW_FUNCTION_PATTERN, COMPONENT_SCHEMA_REF_PREFIX, CONTENT_ENCODINGS, DATE_PATTERN_SOURCE, DEFAULT_ROOT_NAME, DEFINITION_KEYWORDS, DEFINITION_POINTER_PATTERN, DEFINITION_REF_PREFIXES, EFFECT_CODE_EXTENSION_KEYS, FORMAT_PATTERNS, FormatError, IDENTIFIER_PATTERN, IF_THEN_ELSE_UNSUPPORTED_MARKER, INPUT_EXTENSIONS, INTEGER_TEXT_PATTERN, INTEGER_WIRE_PATTERN, ISO_4217_CURRENCY_CODES, JSON_SCHEMA_TYPES, MISSING_DEFINITION_PREFIX, NON_IDENTIFIER_CHARACTER_PATTERN, NOT_KEYWORD_UNSUPPORTED_MARKER, NUMBER_FORMATS, NUMBER_RANGES, NUMBER_WIRE_PATTERN, NUMERIC_KEYWORDS, OBJECT_PROTOTYPE_PROPERTIES, OFFSET_PATTERN_SOURCE, OPENAPI_COMPONENT_SUFFIX_MAP, OUTPUT_EXTENSION, PARAM_LOCATIONS, PARAM_STYLES, ParseError, QUOTE_OR_BACKSLASH_PATTERN, ROOT_REFS, STRINGBOOL_PATTERN, STRINGBOOL_TRUTHY_PATTERN, STRING_FORMATS, STRING_KEYWORDS, STRING_WIRE_LOCATIONS, UNICODE_ESCAPE_PATTERN, UNSAFE_GENERATED_MARKER, VALIBOT_CODE_EXTENSION_KEYS, WIRE_PRIMITIVE_ORDER, ZOD_CODE_EXTENSION_KEYS, ajv, arktype, coerceDefault, effect, effectError, effectErrorPart, effectMessage, encodeNonAscii, fmt, forwardIssue, issueMessageExpression, makeSafeKey, nestedIssueMessageWrap, nestedTypeboxOptions, normalizeTypes, parseSchemaFile, resolveOpenAPIRef, schemaToAjv, schemaToArktype, schemaToEffect, schemaToTypebox, schemaToValibot, schemaToYup, schemaToZod, toIdentifierPascalCase, toPascalCase, typebox, valibot, valibotError, valibotErrorPart, wholeValueMessage, yup, zod, zodBaseError, zodError, zodErrorPart };
@@ -1,4 +1,4 @@
1
- import { At as hasFixedLength, B as typeboxRefOpt, D as stringboolPattern, Dt as hasCombinator, Ft as isComposite, G as renderDefinitions, Gt as isRootRef, H as emitOptionsOf, It as isDeepLocalPointer, J as discriminatedMembers, Jt as isStringWireLocation, K as rootNameOf, Lt as isDefaultOnlyMember, Mt as hasStringKeyword, O as stringboolTruthyPattern, Q as itemsSchemaOf, R as typeboxDefaultOpt, Rt as isNullTypeMember, T as numberWirePattern, U as missingDefinitionComment, V as definitionsOf, W as planDocument, X as hasRootSelfReference, Y as cyclicDefinitionNames, Z as isOptionalByDefault, _ as hoistNestedRefs, _n as NOT_KEYWORD_UNSUPPORTED_MARKER, _t as makeSafeKey, a as typeboxWrap, an as DEFINITION_REF_PREFIXES, ct as isKeywordOnlyMember, it as hasNotKeyword, jt as hasNumericKeyword, l as withPolymorphicBases, lt as patternSource, nn as DEFAULT_ROOT_NAME, q as schemaNamer, qt as isShapelessMember, s as sanitizeSchema, st as foldAllOfMembers, vt as normalizeTypes, x as integerWirePattern, yt as resolveOpenAPIRef, z as typeboxMetaOpts, zt as isNullable } from "./helper-WSNbEQKr.js";
1
+ import { $ as itemsSchemaOf, B as typeboxRefOpt, Bt as isNullable, D as stringboolPattern, G as renderDefinitions, H as emitOptionsOf, It as isComposite, J as discriminatedMembers, Jt as isShapelessMember, K as rootNameOf, Kt as isRootRef, Lt as isDeepLocalPointer, Mt as hasNumericKeyword, Nt as hasStringKeyword, O as stringboolTruthyPattern, Ot as hasCombinator, Q as isOptionalByDefault, R as typeboxDefaultOpt, Rt as isDefaultOnlyMember, T as numberWirePattern, U as missingDefinitionComment, V as definitionsOf, W as planDocument, X as hasRootSelfReference, Y as cyclicDefinitionNames, Yt as isStringWireLocation, Z as enumWithoutWrappedNull, _ as hoistNestedRefs, a as typeboxWrap, at as hasNotKeyword, bt as resolveOpenAPIRef, ct as foldAllOfMembers, jt as hasFixedLength, l as withPolymorphicBases, lt as isKeywordOnlyMember, on as DEFINITION_REF_PREFIXES, q as schemaNamer, rn as DEFAULT_ROOT_NAME, s as sanitizeSchema, ut as patternSource, vn as NOT_KEYWORD_UNSUPPORTED_MARKER, vt as makeSafeKey, x as integerWirePattern, yt as normalizeTypes, z as typeboxMetaOpts, zt as isNullTypeMember } from "./helper-1oDB5NHM.js";
2
2
  // src/generator/typebox/enum.ts
3
3
  function lit(v) {
4
4
  if (v === null) return "null";
@@ -435,14 +435,18 @@ function typebox(schema, rootName = DEFAULT_ROOT_NAME, isTypebox = false, option
435
435
  ], hostRef);
436
436
  return typeboxWrap(baseResult, withMergedDefault, definitions);
437
437
  }
438
- if (schema.not) return typeboxWrap(tbPrim("Type.Any", schema, messageOpt(schema["x-not-message"]), hostRef), schema);
438
+ if (schema.not) {
439
+ const { not: dropped, ...withoutNot } = schema;
440
+ if (dropped !== void 0 && withoutNot.type !== void 0) return typebox(withoutNot, rootName, isTypebox, options);
441
+ return typeboxWrap(tbPrim("Type.Any", schema, messageOpt(schema["x-not-message"]), hostRef), schema);
442
+ }
439
443
  if (schema.const !== void 0) {
440
444
  const constMessage = schema["x-const-message"] ?? schema["x-error-message"];
441
445
  if (schema.const === null) return typeboxWrap(tbPrim("Type.Null", schema, messageOpt(constMessage), hostRef), schema);
442
446
  if (typeof schema.const === "object") return typeboxWrap(tbPrim("Type.Any", schema, messageOpt(constMessage), hostRef), schema);
443
447
  return typeboxWrap(tbComp("Type.Literal", JSON.stringify(schema.const), schema, messageOpt(constMessage), hostRef), schema);
444
448
  }
445
- if (schema.enum) return typeboxWrap(_enum(schema, hostRef), schema);
449
+ if (schema.enum) return typeboxWrap(_enum(enumWithoutWrappedNull(schema), hostRef), schema);
446
450
  if (schema.properties) return readonly(typeboxWrap(object(schema, rootName, isTypebox, options), schema));
447
451
  const types = normalizeTypes(schema.type);
448
452
  if (types.includes("string")) return typeboxWrap(string(schema, hostRef), schema);
@@ -511,7 +515,7 @@ function typebox(schema, rootName = DEFAULT_ROOT_NAME, isTypebox = false, option
511
515
  const wire = wireString(schema, hostRef);
512
516
  return typeboxWrap(`Codec(${wire}).Decode((value)=>new Date(value)).Encode((value)=>value.toISOString())`, schema);
513
517
  }
514
- if (types.length === 1 && types[0] === "null") return typeboxWrap(tbPrim("Type.Null", schema, [], hostRef), schema);
518
+ if (types.length === 1 && types[0] === "null") return typeboxWrap(tbPrim("Type.Null", schema, [], hostRef), schema, void 0, { nullSchema: true });
515
519
  if (typeof schema.additionalProperties === "object") return readonly(typeboxWrap(object(schema, rootName, isTypebox, options), schema));
516
520
  return typeboxWrap(tbPrim("Type.Any", schema, [], hostRef), schema);
517
521
  }
package/dist/typebox.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { r as JSONSchema } from "./index-DLVjyrKu.js";
2
- import { n as GenerateOptions } from "./index-DU2Nd8eI.js";
1
+ import { r as JSONSchema } from "./index-DZry7F2L.js";
2
+ import { n as GenerateOptions } from "./index-MUEfIMdR.js";
3
3
  /** The options of `schemaToTypebox`: the common ones, plus a host `$ref` name. */
4
4
  export type TypeboxGenerateOptions = Omit<GenerateOptions, 'unsafeCodeExtensions'> & {
5
5
  /**
package/dist/typebox.js CHANGED
@@ -1 +1 @@
1
- export { t as schemaToTypebox } from "./typebox-RAJnIZwI.js";
1
+ export { t as schemaToTypebox } from "./typebox-D1GT2WSK.js";
@@ -1,4 +1,4 @@
1
- import { A as wireArrayOnce, At as hasFixedLength, Bt as isObjectPrototypeProperty, C as isNullTextRead, Ct as valibotErrorPart, D as stringboolPattern, Dt as hasCombinator, E as ownProperties, G as renderDefinitions, H as emitOptionsOf, Ht as isPrimitive, I as deepEqualExpression, In as UNSAFE_GENERATED_MARKER, J as discriminatedMembers, Jt as isStringWireLocation, K as rootNameOf, Kt as isSchemaObject, L as jsLiteral, Lt as isDefaultOnlyMember, M as wireNumericKind, N as formatPattern, Nt as hasType, O as stringboolTruthyPattern, Ot as hasConditional, P as regexSource, Q as itemsSchemaOf, Rt as isNullTypeMember, St as valibotError, T as numberWirePattern, V as definitionsOf, W as planDocument, X as hasRootSelfReference, Z as isOptionalByDefault, _ as hoistNestedRefs, _t as makeSafeKey, at as constraintMessage, b as impliedWireType, c as refTarget, ct as isKeywordOnlyMember, d as parameterReaders, dn as INTEGER_TEXT_PATTERN, f as propertyEmitOptions, g as valueListLiteral, gt as issueMessageExpression, h as notPredicate, i as isEvaluatedKeyExpression, k as unionPrimitiveTypes, kt as hasFixedItemCount, l as withPolymorphicBases, m as isBigintFormat, n as valibotWrap, nn as DEFAULT_ROOT_NAME, o as typeDeclaration, ot as constraintPredicate, p as withoutParameterSerialization, q as schemaNamer, qt as isShapelessMember, r as evaluatedProperties, rt as findCodeExtensionKeysInSchema, s as sanitizeSchema, st as foldAllOfMembers, u as hasParameterSerialization, ut as regexLiteral, vt as normalizeTypes, w as isPrimitiveUnion, x as integerWirePattern, yn as NUMBER_RANGES, zt as isNullable } from "./helper-WSNbEQKr.js";
1
+ import { $ as itemsSchemaOf, A as wireArrayOnce, At as hasFixedItemCount, Bt as isNullable, C as isNullTextRead, Ct as valibotError, D as stringboolPattern, E as ownProperties, G as renderDefinitions, H as emitOptionsOf, I as deepEqualExpression, J as discriminatedMembers, Jt as isShapelessMember, K as rootNameOf, L as jsLiteral, Ln as UNSAFE_GENERATED_MARKER, M as wireNumericKind, N as formatPattern, O as stringboolTruthyPattern, Ot as hasCombinator, P as regexSource, Pt as hasType, Q as isOptionalByDefault, Rt as isDefaultOnlyMember, T as numberWirePattern, Ut as isPrimitive, V as definitionsOf, Vt as isObjectPrototypeProperty, W as planDocument, X as hasRootSelfReference, Yt as isStringWireLocation, Z as enumWithoutWrappedNull, _ as hoistNestedRefs, _t as issueMessageExpression, b as impliedWireType, bn as NUMBER_RANGES, c as refTarget, ct as foldAllOfMembers, d as parameterReaders, dt as regexLiteral, f as propertyEmitOptions, fn as INTEGER_TEXT_PATTERN, g as valueListLiteral, h as notPredicate, i as isEvaluatedKeyExpression, it as findCodeExtensionKeysInSchema, jt as hasFixedLength, k as unionPrimitiveTypes, kt as hasConditional, l as withPolymorphicBases, lt as isKeywordOnlyMember, m as isBigintFormat, n as valibotWrap, o as typeDeclaration, ot as constraintMessage, p as withoutParameterSerialization, q as schemaNamer, qt as isSchemaObject, r as evaluatedProperties, rn as DEFAULT_ROOT_NAME, s as sanitizeSchema, st as constraintPredicate, u as hasParameterSerialization, vt as makeSafeKey, w as isPrimitiveUnion, wt as valibotErrorPart, x as integerWirePattern, yt as normalizeTypes, zt as isNullTypeMember } from "./helper-1oDB5NHM.js";
2
2
  // src/generator/valibot/type.ts
3
3
  /** The TypeScript type declared beside a recursive Valibot schema: its output type. */
4
4
  function type(schema, rootName = DEFAULT_ROOT_NAME) {
@@ -471,7 +471,8 @@ function node(schema, rootName, isValibot, options) {
471
471
  ...isNullTextRead(s) && { nullText: true }
472
472
  };
473
473
  };
474
- const valibotWrap$1 = (valibotStr, s) => valibotWrap(valibotStr, s, {
474
+ const valibotWrap$1 = (valibotStr, s, extra) => valibotWrap(valibotStr, s, {
475
+ ...extra,
475
476
  ...codeExtOpts,
476
477
  ...wireOptions(s),
477
478
  ...options?.definitions !== void 0 && { definitions: options.definitions }
@@ -582,7 +583,7 @@ function node(schema, rootName, isValibot, options) {
582
583
  if (schema.enum) {
583
584
  const values = schema.enum.filter((value) => value !== null);
584
585
  const input = values.length > 0 ? literalInput(values) : void 0;
585
- if (input === void 0) return valibotWrap$1(_enum(schema), schema);
586
+ if (input === void 0) return valibotWrap$1(_enum(enumWithoutWrappedNull(schema)), schema);
586
587
  const hasNull = values.length < schema.enum.length;
587
588
  const piped = prependPipe(input, _enum({
588
589
  ...schema,
@@ -677,7 +678,7 @@ function node(schema, rootName, isValibot, options) {
677
678
  if (isWireCoerced) return valibotWrap$1(`v.pipe(v.string(),v.transform((input)=>new Date(input)),v.date())`, schema);
678
679
  return valibotWrap$1("v.date()", schema);
679
680
  }
680
- if (types.length === 1 && types[0] === "null") return valibotWrap$1("v.null()", schema);
681
+ if (types.length === 1 && types[0] === "null") return valibotWrap$1("v.null()", schema, { nullSchema: true });
681
682
  if (typeof schema.additionalProperties === "object") return readonly(valibotWrap$1(object(schema, rootName, isValibot, options), schema));
682
683
  return valibotWrap$1("v.any()", schema);
683
684
  }
package/dist/valibot.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { r as JSONSchema } from "./index-DLVjyrKu.js";
2
- import { n as GenerateOptions } from "./index-DU2Nd8eI.js";
1
+ import { r as JSONSchema } from "./index-DZry7F2L.js";
2
+ import { n as GenerateOptions } from "./index-MUEfIMdR.js";
3
3
  /**
4
4
  * A whole JSON Schema document as a Valibot module: imports, `$defs` in dependency
5
5
  * order, the root export, and the inferred output type.
package/dist/valibot.js CHANGED
@@ -1 +1 @@
1
- export { t as schemaToValibot } from "./valibot-CLUhG6tp.js";
1
+ export { t as schemaToValibot } from "./valibot-1p_Y7fu6.js";
@@ -1,4 +1,4 @@
1
- import { K as rootNameOf, _t as makeSafeKey, q as schemaNamer, s as sanitizeSchema, vt as normalizeTypes } from "./helper-WSNbEQKr.js";
1
+ import { K as rootNameOf, q as schemaNamer, s as sanitizeSchema, vt as makeSafeKey, yt as normalizeTypes } from "./helper-1oDB5NHM.js";
2
2
  // src/generator/yup/integer.ts
3
3
  /**
4
4
  * Generate a Yup integer schema as `yup.number().integer()`, with `minimum`
package/dist/yup.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { r as JSONSchema } from "./index-DLVjyrKu.js";
2
- import { n as GenerateOptions } from "./index-DU2Nd8eI.js";
1
+ import { r as JSONSchema } from "./index-DZry7F2L.js";
2
+ import { n as GenerateOptions } from "./index-MUEfIMdR.js";
3
3
  /**
4
4
  * Convert a JSON Schema document to Yup schema source.
5
5
  *
package/dist/yup.js CHANGED
@@ -1 +1 @@
1
- export { t as schemaToYup } from "./yup-DfE_ofEu.js";
1
+ export { t as schemaToYup } from "./yup-IOat93gr.js";
@@ -1,4 +1,4 @@
1
- import { A as wireArrayOnce, At as hasFixedLength, Bt as isObjectPrototypeProperty, C as isNullTextRead, Dt as hasCombinator, Et as zodErrorPart, F as timePattern, Ft as isComposite, G as renderDefinitions, H as emitOptionsOf, Ht as isPrimitive, I as deepEqualExpression, In as UNSAFE_GENERATED_MARKER, J as discriminatedMembers, Jt as isStringWireLocation, K as rootNameOf, Kt as isSchemaObject, Lt as isDefaultOnlyMember, M as wireNumericKind, Nt as hasType, Ot as hasConditional, Q as itemsSchemaOf, Rt as isNullTypeMember, S as isNullMatchedFirst, T as numberWirePattern, Tt as zodError, V as definitionsOf, Vt as isPlainObject, W as planDocument, X as hasRootSelfReference, _ as hoistNestedRefs, _t as makeSafeKey, at as constraintMessage, b as impliedWireType, c as refTarget, ct as isKeywordOnlyMember, d as parameterReaders, f as propertyEmitOptions, g as valueListLiteral, gt as issueMessageExpression, h as notPredicate, i as isEvaluatedKeyExpression, j as wireNullText, k as unionPrimitiveTypes, l as withPolymorphicBases, m as isBigintFormat, nn as DEFAULT_ROOT_NAME, o as typeDeclaration, ot as constraintPredicate, p as withoutParameterSerialization, pn as ISO_4217_CURRENCY_CODES, q as schemaNamer, qt as isShapelessMember, r as evaluatedProperties, rt as findCodeExtensionKeysInSchema, s as sanitizeSchema, st as foldAllOfMembers, t as zodWrap, u as hasParameterSerialization, ut as regexLiteral, vt as normalizeTypes, w as isPrimitiveUnion, wt as zodBaseError, x as integerWirePattern, zt as isNullable } from "./helper-WSNbEQKr.js";
1
+ import { $ as itemsSchemaOf, A as wireArrayOnce, Bt as isNullable, C as isNullTextRead, Dt as zodErrorPart, Et as zodError, F as timePattern, G as renderDefinitions, H as emitOptionsOf, Ht as isPlainObject, I as deepEqualExpression, It as isComposite, J as discriminatedMembers, Jt as isShapelessMember, K as rootNameOf, Ln as UNSAFE_GENERATED_MARKER, M as wireNumericKind, Ot as hasCombinator, Pt as hasType, Rt as isDefaultOnlyMember, S as isNullMatchedFirst, T as numberWirePattern, Tt as zodBaseError, Ut as isPrimitive, V as definitionsOf, Vt as isObjectPrototypeProperty, W as planDocument, X as hasRootSelfReference, Yt as isStringWireLocation, Z as enumWithoutWrappedNull, _ as hoistNestedRefs, _t as issueMessageExpression, b as impliedWireType, c as refTarget, ct as foldAllOfMembers, d as parameterReaders, dt as regexLiteral, f as propertyEmitOptions, g as valueListLiteral, h as notPredicate, i as isEvaluatedKeyExpression, it as findCodeExtensionKeysInSchema, j as wireNullText, jt as hasFixedLength, k as unionPrimitiveTypes, kt as hasConditional, l as withPolymorphicBases, lt as isKeywordOnlyMember, m as isBigintFormat, mn as ISO_4217_CURRENCY_CODES, o as typeDeclaration, ot as constraintMessage, p as withoutParameterSerialization, q as schemaNamer, qt as isSchemaObject, r as evaluatedProperties, rn as DEFAULT_ROOT_NAME, s as sanitizeSchema, st as constraintPredicate, t as zodWrap, u as hasParameterSerialization, vt as makeSafeKey, w as isPrimitiveUnion, x as integerWirePattern, yt as normalizeTypes, zt as isNullTypeMember } from "./helper-1oDB5NHM.js";
2
2
  // src/generator/zod/type.ts
3
3
  /** The TypeScript type declared beside a recursive Zod schema. */
4
4
  function type(schema, rootName = DEFAULT_ROOT_NAME) {
@@ -549,7 +549,10 @@ function zodNotPredicate(inner, parent) {
549
549
  const bigint = isBigintFormat(parent);
550
550
  const shared = notPredicate(inner, "val", "val", bigint);
551
551
  if (shared !== void 0) return shared;
552
- if (Array.isArray(inner.enum)) return `(val) => !${valueListLiteral(inner.enum, bigint)}.includes(val)`;
552
+ if (Array.isArray(inner.enum)) {
553
+ const list = valueListLiteral(inner.enum, bigint);
554
+ return isNullable(parent) && !inner.enum.includes(null) ? `(val) => val === null || !${list}.includes(val)` : `(val) => !${list}.includes(val)`;
555
+ }
553
556
  if (inner.oneOf || inner.anyOf || inner.allOf) return `(val) => !${zod(inner)}.safeParse(val).success`;
554
557
  }
555
558
  /**
@@ -610,7 +613,8 @@ function node(schema, rootName, isZod, options) {
610
613
  const isStringWireParam = isStringWireLocation(options?.paramIn);
611
614
  const isWireCoerced = isStringWireParam && schema["x-coerce"] !== false;
612
615
  const codeExtOpts = options?.unsafeCodeExtensions === true ? { unsafeCodeExtensions: true } : {};
613
- const zodWrap$1 = (zodStr, s) => zodWrap(zodStr, s, {
616
+ const zodWrap$1 = (zodStr, s, extra) => zodWrap(zodStr, s, {
617
+ ...extra,
614
618
  ...codeExtOpts,
615
619
  ...options?.definitions !== void 0 && { definitions: options.definitions }
616
620
  });
@@ -709,7 +713,7 @@ function node(schema, rootName, isZod, options) {
709
713
  if (schema.enum) {
710
714
  const values = schema.enum.filter((value) => value !== null);
711
715
  const input = values.length > 0 ? literalInput(values) : void 0;
712
- if (input === void 0) return zodWrap$1(_enum(schema), schema);
716
+ if (input === void 0) return zodWrap$1(_enum(enumWithoutWrappedNull(schema)), schema);
713
717
  const hasNull = values.length < schema.enum.length;
714
718
  const piped = `${input}.pipe(${_enum({
715
719
  ...schema,
@@ -804,7 +808,7 @@ function node(schema, rootName, isZod, options) {
804
808
  }
805
809
  if (types.length === 1 && types[0] === "null") {
806
810
  const errorMessage = schema["x-error-message"];
807
- return zodWrap$1(`z.null(${errorMessage ? zodError(errorMessage) : ""})`, schema);
811
+ return zodWrap$1(`z.null(${errorMessage ? zodError(errorMessage) : ""})`, schema, { nullSchema: true });
808
812
  }
809
813
  if (typeof schema.additionalProperties === "object") return readonly(zodWrap$1(object(schema, rootName, isZod, options), schema));
810
814
  return zodWrap$1("z.any()", schema);
package/dist/zod.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { r as JSONSchema } from "./index-DLVjyrKu.js";
2
- import { n as GenerateOptions } from "./index-DU2Nd8eI.js";
1
+ import { r as JSONSchema } from "./index-DZry7F2L.js";
2
+ import { n as GenerateOptions } from "./index-MUEfIMdR.js";
3
3
  /**
4
4
  * A whole JSON Schema document as a Zod module: imports, `$defs` in dependency order,
5
5
  * the root export, and the inferred type.
package/dist/zod.js CHANGED
@@ -1 +1 @@
1
- export { t as schemaToZod } from "./zod-BhYAQ3iW.js";
1
+ export { t as schemaToZod } from "./zod-B-mxbHoq.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "schema-truth",
3
- "version": "0.8.4",
3
+ "version": "0.8.5",
4
4
  "description": "Generate Zod/Valibot/Effect/TypeBox/ArkType/Ajv/Yup schemas from JSON or YAML files",
5
5
  "keywords": [
6
6
  "ajv",