schema-truth 0.8.10 → 0.8.11

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.
@@ -1,4 +1,5 @@
1
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-OCkRyx4U.js";
2
+ import { n as bigintCall, r as bigintLiteral, t as bigintBounds } from "./bigint-CkHij6xv.js";
2
3
  // src/generator/arktype/number.ts
3
4
  /** The comparators of a numeric node: `>= 1`, `< 5`, `% 2`. */
4
5
  function numericConstraints(schema) {
@@ -156,11 +157,11 @@ function bigintNarrows(schema, lit) {
156
157
  const range = schema.format === void 0 ? void 0 : NUMBER_RANGES[schema.format];
157
158
  return [
158
159
  range === void 0 ? void 0 : `.narrow((data, ctx) => (data >= ${range.minimum} && data <= ${range.maximum}) || ctx.mustBe(${JSON.stringify(schema.format === "uint64" ? "a uint64" : "an int64")}))`,
159
- schema.minimum === void 0 ? void 0 : schema.exclusiveMinimum === true ? `.narrow((data, ctx) => data > ${lit(schema.minimum)} || ctx.mustBe(${JSON.stringify(`more than ${schema.minimum}`)}))` : `.narrow((data, ctx) => data >= ${lit(schema.minimum)} || ctx.mustBe(${JSON.stringify(`at least ${schema.minimum}`)}))`,
160
- typeof schema.exclusiveMinimum === "number" ? `.narrow((data, ctx) => data > ${lit(schema.exclusiveMinimum)} || ctx.mustBe(${JSON.stringify(`more than ${schema.exclusiveMinimum}`)}))` : void 0,
161
- schema.maximum === void 0 ? void 0 : schema.exclusiveMaximum === true ? `.narrow((data, ctx) => data < ${lit(schema.maximum)} || ctx.mustBe(${JSON.stringify(`less than ${schema.maximum}`)}))` : `.narrow((data, ctx) => data <= ${lit(schema.maximum)} || ctx.mustBe(${JSON.stringify(`at most ${schema.maximum}`)}))`,
162
- typeof schema.exclusiveMaximum === "number" ? `.narrow((data, ctx) => data < ${lit(schema.exclusiveMaximum)} || ctx.mustBe(${JSON.stringify(`less than ${schema.exclusiveMaximum}`)}))` : void 0,
163
- schema.multipleOf === void 0 ? void 0 : `.narrow((data, ctx) => data % ${lit(schema.multipleOf)} === 0n || ctx.mustBe(${JSON.stringify(`a multiple of ${schema.multipleOf}`)}))`
160
+ schema.minimum === void 0 ? void 0 : schema.exclusiveMinimum === true ? `.narrow((data, ctx) => data > ${lit(schema.minimum)} || ctx.mustBe(${JSON.stringify(`more than ${BigInt(schema.minimum)}`)}))` : `.narrow((data, ctx) => data >= ${lit(schema.minimum)} || ctx.mustBe(${JSON.stringify(`at least ${BigInt(schema.minimum)}`)}))`,
161
+ typeof schema.exclusiveMinimum === "number" ? `.narrow((data, ctx) => data > ${lit(schema.exclusiveMinimum)} || ctx.mustBe(${JSON.stringify(`more than ${BigInt(schema.exclusiveMinimum)}`)}))` : void 0,
162
+ schema.maximum === void 0 ? void 0 : schema.exclusiveMaximum === true ? `.narrow((data, ctx) => data < ${lit(schema.maximum)} || ctx.mustBe(${JSON.stringify(`less than ${BigInt(schema.maximum)}`)}))` : `.narrow((data, ctx) => data <= ${lit(schema.maximum)} || ctx.mustBe(${JSON.stringify(`at most ${BigInt(schema.maximum)}`)}))`,
163
+ typeof schema.exclusiveMaximum === "number" ? `.narrow((data, ctx) => data < ${lit(schema.exclusiveMaximum)} || ctx.mustBe(${JSON.stringify(`less than ${BigInt(schema.exclusiveMaximum)}`)}))` : void 0,
164
+ schema.multipleOf === void 0 ? void 0 : `.narrow((data, ctx) => data % ${lit(schema.multipleOf)} === 0n || ctx.mustBe(${JSON.stringify(`a multiple of ${BigInt(schema.multipleOf)}`)}))`
164
165
  ].filter((v) => v !== void 0).join("");
165
166
  }
166
167
  /**
@@ -172,10 +173,10 @@ function integer(schema, options) {
172
173
  const errorMessage = schema["x-error-message"] ?? schema["x-required-message"];
173
174
  const describe = errorMessage ? `.describe(${JSON.stringify(errorMessage)})` : "";
174
175
  if (schema.format === "bigint") {
175
- const narrows = bigintNarrows(schema, (n) => `BigInt(${n})`);
176
+ const narrows = bigintNarrows(bigintBounds(schema), bigintCall);
176
177
  return `${options?.wire === true ? bigintMorph(true) : narrows || errorMessage ? "type(\"bigint\")" : "\"bigint\""}${narrows}${describe}`;
177
178
  }
178
- if (isInt64(schema)) return `${bigintMorph(options?.wire === true)}${bigintNarrows(schema, (n) => `${n}n`)}${describe}`;
179
+ if (isInt64(schema)) return `${bigintMorph(options?.wire === true)}${bigintNarrows(bigintBounds(schema), bigintLiteral)}${describe}`;
179
180
  const range = rangeConstraints(schema.format);
180
181
  const constraints = [...range, ...numericConstraints(schema)];
181
182
  if (hasPerKeywordMessage(schema)) return `${usesExponent(range) ? methodChain("number.integer", range) : `type(${constraintDefinition("number.integer", range)})`}${numericNarrows(schema, errorMessage)}${describe}`;
package/dist/arktype.js CHANGED
@@ -1 +1 @@
1
- export { t as schemaToArktype } from "./arktype-DDbxpolC.js";
1
+ export { t as schemaToArktype } from "./arktype-CxN3-TRa.js";
@@ -0,0 +1,70 @@
1
+ // src/helper/bigint.ts
2
+ /** A bigint literal, `5n`, spelled in digits however the number prints. */
3
+ function bigintLiteral(n) {
4
+ return `${BigInt(n)}n`;
5
+ }
6
+ /**
7
+ * A `BigInt(5)` call, the spelling `format: bigint` has always used. A divisor a number
8
+ * cannot hold exactly is written as a literal, `12345678901234567n`, which keeps every digit.
9
+ */
10
+ function bigintCall(n) {
11
+ return typeof n === "bigint" ? `${n}n` : `BigInt(${n})`;
12
+ }
13
+ /**
14
+ * A bigint check takes an integer, but a schema's bound can be fractional: `BigInt(0.5)`
15
+ * throws a `RangeError` and `0.5n` does not parse. A fractional bound is rounded to the
16
+ * integer that admits the same bigints: an inclusive minimum and an exclusive maximum
17
+ * round up, an inclusive maximum and an exclusive minimum round down. A non-finite bound
18
+ * (a YAML `.inf`) is left out; `sanitizeSchema` drops it before the generator anyway.
19
+ */
20
+ function bigintBound(value, round) {
21
+ return value !== void 0 && Number.isFinite(value) ? Math[round](value) : void 0;
22
+ }
23
+ /**
24
+ * The positive integer divisor a bigint `multipleOf` check can use. An integer is taken as
25
+ * it is (`BigInt(value)` is exact for any integer a number holds), and a negative one by its
26
+ * absolute value, which has the same multiples. A bigint `x` is a multiple of `p / q` (in
27
+ * lowest terms) exactly when it is a multiple of `p`, so a fraction reduces to its
28
+ * numerator: 2.5 is 5/2 and becomes `5`. The fraction is read from the number's shortest
29
+ * decimal spelling. Zero or a non-finite divisor has no such integer and is left out (a
30
+ * bigint `% 0n` throws). A reduced divisor a number cannot hold exactly stays a bigint.
31
+ */
32
+ function bigintDivisor(value) {
33
+ if (typeof value !== "number" || !Number.isFinite(value) || value === 0) return void 0;
34
+ const magnitude = Math.abs(value);
35
+ if (Number.isInteger(magnitude)) return magnitude;
36
+ const match = /^(\d+)(?:\.(\d+))?(?:e-(\d+))?$/.exec(String(magnitude));
37
+ if (!match) return void 0;
38
+ const [, whole = "", fraction = "", exponent = "0"] = match;
39
+ const scale = fraction.length + Number(exponent);
40
+ const numerator = BigInt(whole + fraction);
41
+ let [a, b] = [numerator, 10n ** BigInt(scale)];
42
+ while (b !== 0n) [a, b] = [b, a % b];
43
+ const divisor = numerator / a;
44
+ return BigInt(Number(divisor)) === divisor ? Number(divisor) : divisor;
45
+ }
46
+ /**
47
+ * The schema with its bounds and `multipleOf` made integers a bigint check can take: see
48
+ * {@link bigintBound} and {@link bigintDivisor}. A bound or divisor that has no such
49
+ * integer is left out, together with the draft-04 boolean or the message that belongs to it.
50
+ */
51
+ function bigintBounds(schema) {
52
+ const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, "x-multipleOf-message": multipleOfMessage, ...rest } = schema;
53
+ const isExclusiveMin = exclusiveMinimum === true;
54
+ const isExclusiveMax = exclusiveMaximum === true;
55
+ const min = bigintBound(minimum, isExclusiveMin ? "floor" : "ceil");
56
+ const max = bigintBound(maximum, isExclusiveMax ? "ceil" : "floor");
57
+ const exMin = typeof exclusiveMinimum === "number" ? bigintBound(exclusiveMinimum, "floor") : min !== void 0 ? exclusiveMinimum : void 0;
58
+ const exMax = typeof exclusiveMaximum === "number" ? bigintBound(exclusiveMaximum, "ceil") : max !== void 0 ? exclusiveMaximum : void 0;
59
+ const divisor = bigintDivisor(multipleOf);
60
+ return {
61
+ ...rest,
62
+ ...min !== void 0 && { minimum: min },
63
+ ...max !== void 0 && { maximum: max },
64
+ ...exMin !== void 0 && { exclusiveMinimum: exMin },
65
+ ...exMax !== void 0 && { exclusiveMaximum: exMax },
66
+ ...divisor !== void 0 && { multipleOf: divisor },
67
+ ...divisor !== void 0 && multipleOfMessage !== void 0 && { "x-multipleOf-message": multipleOfMessage }
68
+ };
69
+ }
70
+ export { bigintCall as n, bigintLiteral as r, bigintBounds as t };
package/dist/cli/ajv.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { t as schemaToAjv } from "../ajv-Oz83L2oz.js";
3
- import { n as version, t as cli } from "../cli-C90ppADh.js";
3
+ import { n as version, t as cli } from "../cli-t-ecjlut.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-DDbxpolC.js";
3
- import { n as version, t as cli } from "../cli-C90ppADh.js";
2
+ import { t as schemaToArktype } from "../arktype-CxN3-TRa.js";
3
+ import { n as version, t as cli } from "../cli-t-ecjlut.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-CHLS1Yit.js";
3
- import { n as version, t as cli } from "../cli-C90ppADh.js";
2
+ import { t as schemaToEffect } from "../effect-8GBWHUkD.js";
3
+ import { n as version, t as cli } from "../cli-t-ecjlut.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-DNkk6MCh.js";
3
- import { n as version, t as cli } from "../cli-C90ppADh.js";
2
+ import { t as schemaToTypebox } from "../typebox-tm9Mgdik.js";
3
+ import { n as version, t as cli } from "../cli-t-ecjlut.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-Vj1GeCcx.js";
3
- import { n as version, t as cli } from "../cli-C90ppADh.js";
2
+ import { t as schemaToValibot } from "../valibot-BTO7Xd8i.js";
3
+ import { n as version, t as cli } from "../cli-t-ecjlut.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
2
  import { t as schemaToYup } from "../yup-DKlaai37.js";
3
- import { n as version, t as cli } from "../cli-C90ppADh.js";
3
+ import { n as version, t as cli } from "../cli-t-ecjlut.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-04J51AMt.js";
3
- import { n as version, t as cli } from "../cli-C90ppADh.js";
2
+ import { t as schemaToZod } from "../zod-DI_MK5Ow.js";
3
+ import { n as version, t as cli } from "../cli-t-ecjlut.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";
@@ -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.10";
12
+ var version = "0.8.11";
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,5 @@
1
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-OCkRyx4U.js";
2
+ import { n as bigintCall, r as bigintLiteral, t as bigintBounds } from "./bigint-CkHij6xv.js";
2
3
  // src/generator/effect/number.ts
3
4
  /** The bound and `multipleOf` checks of a numeric node. */
4
5
  function numberChecks(schema, lit = (n) => `${n}`, suffix = "") {
@@ -80,8 +81,8 @@ function integer(schema, options) {
80
81
  const errorMessage = schema["x-error-message"] ?? schema["x-required-message"];
81
82
  const annotate = (base) => errorMessage ? `${base}.annotate(${effectError(errorMessage)})` : base;
82
83
  if (schema.format === "bigint" || isInt64(schema)) {
83
- const lit = (n) => schema.format === "bigint" ? `BigInt(${n})` : `${n}n`;
84
- const checks = [...schema.format === "bigint" ? [] : [int64Range(schema.format ?? "")], ...numberChecks(schema, lit, "BigInt")].filter((check) => check !== "");
84
+ const lit = schema.format === "bigint" ? bigintCall : bigintLiteral;
85
+ const checks = [...schema.format === "bigint" ? [] : [int64Range(schema.format ?? "")], ...numberChecks(bigintBounds(schema), lit, "BigInt")].filter((check) => check !== "");
85
86
  const input = schema.format === "bigint" ? isWire ? "Schema.BigIntFromString" : "Schema.BigInt" : int64Input(isWire);
86
87
  return annotate(checks.length > 0 ? `${input}.check(${checks.join(",")})` : input);
87
88
  }
package/dist/effect.js CHANGED
@@ -1 +1 @@
1
- export { t as schemaToEffect } from "./effect-CHLS1Yit.js";
1
+ export { t as schemaToEffect } from "./effect-8GBWHUkD.js";
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
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-OCkRyx4U.js";
2
2
  import { i as fmt, n as parseSchemaFile, r as FormatError, t as ParseError } from "./parser-RBrkz7ZL.js";
3
3
  import { n as ajv, t as schemaToAjv } from "./ajv-Oz83L2oz.js";
4
- import { n as arktype, t as schemaToArktype } from "./arktype-DDbxpolC.js";
5
- import { n as effect, r as wholeValueMessage, t as schemaToEffect } from "./effect-CHLS1Yit.js";
6
- import { n as nestedTypeboxOptions, r as typebox, t as schemaToTypebox } from "./typebox-DNkk6MCh.js";
7
- import { n as valibot, t as schemaToValibot } from "./valibot-Vj1GeCcx.js";
4
+ import { n as arktype, t as schemaToArktype } from "./arktype-CxN3-TRa.js";
5
+ import { n as effect, r as wholeValueMessage, t as schemaToEffect } from "./effect-8GBWHUkD.js";
6
+ import { n as nestedTypeboxOptions, r as typebox, t as schemaToTypebox } from "./typebox-tm9Mgdik.js";
7
+ import { n as valibot, t as schemaToValibot } from "./valibot-BTO7Xd8i.js";
8
8
  import { n as yup, t as schemaToYup } from "./yup-DKlaai37.js";
9
- import { i as zod, n as forwardIssue, r as nestedIssueMessageWrap, t as schemaToZod } from "./zod-04J51AMt.js";
9
+ import { i as zod, n as forwardIssue, r as nestedIssueMessageWrap, t as schemaToZod } from "./zod-DI_MK5Ow.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,5 @@
1
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, 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, pn as INTEGER_WIRE_PATTERN, q as schemaNamer, rn as DEFAULT_ROOT_NAME, s as sanitizeSchema, ut as patternSource, vn as NOT_KEYWORD_UNSUPPORTED_MARKER, vt as makeSafeKey, xn as NUMBER_WIRE_PATTERN, yt as normalizeTypes, z as typeboxMetaOpts, zt as isNullTypeMember } from "./helper-OCkRyx4U.js";
2
+ import { t as bigintBounds } from "./bigint-CkHij6xv.js";
2
3
  // src/generator/typebox/enum.ts
3
4
  function lit(v) {
4
5
  if (v === null) return "null";
@@ -29,22 +30,6 @@ function _enum(schema, ref) {
29
30
  return `Type.Union([${schema.enum.map(member).join(",")}]${optsTrailer})`;
30
31
  }
31
32
  // src/generator/typebox/integer.ts
32
- function bigintBound(keyword, value, round) {
33
- return typeof value === "number" && Number.isFinite(value) ? `${keyword}:${Math[round](value)}` : void 0;
34
- }
35
- function bigintDivisor(value) {
36
- if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) return void 0;
37
- const match = /^(\d+)(?:\.(\d+))?(?:e([+-]\d+))?$/.exec(String(value));
38
- if (!match) return void 0;
39
- const [, whole, fraction = "", exponent = "0"] = match;
40
- const numerator = BigInt(whole + fraction);
41
- const scale = Number(exponent) - fraction.length;
42
- if (scale >= 0) return numerator * 10n ** BigInt(scale);
43
- let [a, b] = [numerator, 10n ** BigInt(-scale)];
44
- while (b !== 0n) [a, b] = [b, a % b];
45
- const divisor = numerator / a;
46
- return BigInt(Number(divisor)) === divisor ? Number(divisor) : void 0;
47
- }
48
33
  function integer(schema, ref) {
49
34
  const errorMessage = schema["x-error-message"];
50
35
  const requiredMessage = schema["x-required-message"];
@@ -54,8 +39,9 @@ function integer(schema, ref) {
54
39
  const exclusiveMaximumMessage = schema["x-exclusiveMaximum-message"];
55
40
  const minimumKeyword = schema.exclusiveMinimum === true && schema.minimum !== void 0 ? "exclusiveMinimum" : "minimum";
56
41
  const maximumKeyword = schema.exclusiveMaximum === true && schema.maximum !== void 0 ? "exclusiveMaximum" : "maximum";
57
- const bigintMultipleOf = schema.format === "bigint" ? bigintDivisor(schema.multipleOf) : void 0;
58
- const multipleOfMessage = schema.format === "bigint" && bigintMultipleOf === void 0 ? void 0 : schema["x-multipleOf-message"];
42
+ const bigint = schema.format === "bigint" ? bigintBounds(schema) : void 0;
43
+ const bigintMultipleOf = typeof bigint?.multipleOf === "number" ? bigint.multipleOf : void 0;
44
+ const multipleOfMessage = bigint === void 0 ? schema["x-multipleOf-message"] : bigintMultipleOf === void 0 ? void 0 : bigint["x-multipleOf-message"];
59
45
  const perKeywordEntries = [];
60
46
  if (requiredMessage) perKeywordEntries.push(`required:${JSON.stringify(requiredMessage)}`);
61
47
  if (minMessage && minimumKeyword === "minimum") perKeywordEntries.push(`minimum:${JSON.stringify(minMessage)}`);
@@ -65,14 +51,14 @@ function integer(schema, ref) {
65
51
  if (multipleOfMessage) perKeywordEntries.push(`multipleOf:${JSON.stringify(multipleOfMessage)}`);
66
52
  const errorMessageField = perKeywordEntries.length === 0 ? errorMessage ? `errorMessage:${JSON.stringify(errorMessage)}` : void 0 : `errorMessage:{${perKeywordEntries.join(",")}${errorMessage ? `,_:${JSON.stringify(errorMessage)}` : ""}}`;
67
53
  const metaOpts = [...typeboxMetaOpts(schema), ...typeboxDefaultOpt(schema)];
68
- if (schema.format === "bigint") {
54
+ if (bigint !== void 0) {
69
55
  const opts = [
70
56
  ...typeboxRefOpt(ref),
71
- bigintBound(minimumKeyword, schema.minimum, minimumKeyword === "minimum" ? "ceil" : "floor"),
72
- bigintBound("exclusiveMinimum", schema.exclusiveMinimum, "floor"),
73
- bigintBound(maximumKeyword, schema.maximum, maximumKeyword === "maximum" ? "floor" : "ceil"),
74
- bigintBound("exclusiveMaximum", schema.exclusiveMaximum, "ceil"),
75
- bigintMultipleOf !== void 0 ? `multipleOf:${bigintMultipleOf}` : void 0,
57
+ bigint.minimum !== void 0 ? `${minimumKeyword}:${bigint.minimum}` : void 0,
58
+ typeof bigint.exclusiveMinimum === "number" ? `exclusiveMinimum:${bigint.exclusiveMinimum}` : void 0,
59
+ bigint.maximum !== void 0 ? `${maximumKeyword}:${bigint.maximum}` : void 0,
60
+ typeof bigint.exclusiveMaximum === "number" ? `exclusiveMaximum:${bigint.exclusiveMaximum}` : void 0,
61
+ bigintMultipleOf === void 0 ? void 0 : `multipleOf:${BigInt(bigintMultipleOf)}`,
76
62
  errorMessageField,
77
63
  ...metaOpts
78
64
  ].filter((v) => v !== void 0);
package/dist/typebox.js CHANGED
@@ -1 +1 @@
1
- export { t as schemaToTypebox } from "./typebox-DNkk6MCh.js";
1
+ export { t as schemaToTypebox } from "./typebox-tm9Mgdik.js";
@@ -1,4 +1,5 @@
1
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-OCkRyx4U.js";
2
+ import { n as bigintCall, r as bigintLiteral, t as bigintBounds } from "./bigint-CkHij6xv.js";
2
3
  // src/generator/valibot/type.ts
3
4
  /** The TypeScript type declared beside a recursive Valibot schema: its output type. */
4
5
  function type(schema, rootName = DEFAULT_ROOT_NAME) {
@@ -92,7 +93,7 @@ function integer(schema, options) {
92
93
  const requiredMessage = schema["x-required-message"];
93
94
  const baseErrorArg = errorMessage ? valibotError(errorMessage) : requiredMessage ? valibotError(requiredMessage) : "";
94
95
  if (schema.format === "bigint") {
95
- const actions = numberActions(schema, (n) => `BigInt(${n})`);
96
+ const actions = numberActions(bigintBounds(schema), bigintCall);
96
97
  const base = `v.bigint(${baseErrorArg})`;
97
98
  const items = isWire ? [
98
99
  "v.string()",
@@ -104,7 +105,7 @@ function integer(schema, options) {
104
105
  return `v.pipe(${[...items, ...actions].join(",")})`;
105
106
  }
106
107
  if (isInt64(schema)) {
107
- const actions = [...rangeActions(schema.format), ...numberActions(schema, (n) => `${n}n`)];
108
+ const actions = [...rangeActions(schema.format), ...numberActions(bigintBounds(schema), bigintLiteral)];
108
109
  return `v.pipe(${[...int64Input(isWire, baseErrorArg), ...actions].join(",")})`;
109
110
  }
110
111
  const actions = [
package/dist/valibot.js CHANGED
@@ -1 +1 @@
1
- export { t as schemaToValibot } from "./valibot-Vj1GeCcx.js";
1
+ export { t as schemaToValibot } from "./valibot-BTO7Xd8i.js";
@@ -1,4 +1,5 @@
1
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-OCkRyx4U.js";
2
+ import { n as bigintCall, r as bigintLiteral, t as bigintBounds } from "./bigint-CkHij6xv.js";
2
3
  // src/generator/zod/type.ts
3
4
  /** The TypeScript type declared beside a recursive Zod schema. */
4
5
  function type(schema, rootName = DEFAULT_ROOT_NAME) {
@@ -94,7 +95,8 @@ function int64Input(isWire, baseErrorArg = "") {
94
95
  * min/max/multipleOf constraints and `x-*-message` vendor extensions translated
95
96
  * to Zod v4 `{error: "msg"}` parameters.
96
97
  */
97
- function integer(schema, options) {
98
+ function integer(node, options) {
99
+ const schema = node.format === "bigint" || isInt64(node) ? bigintBounds(node) : node;
98
100
  const isWire = options?.wire === true;
99
101
  const errorMessage = schema["x-error-message"];
100
102
  const requiredMessage = schema["x-required-message"];
@@ -103,14 +105,14 @@ function integer(schema, options) {
103
105
  const baseErrorArg = zodBaseError(errorMessage, readsText ? void 0 : requiredMessage);
104
106
  const isBigint = schema.format === "bigint";
105
107
  const isInt32 = schema.format === "int32" || schema.format === "uint32";
106
- const is64 = isInt64(schema);
108
+ const is64 = isInt64(node);
107
109
  const bigintBase = readsText && isBigint;
108
110
  const numberPipe = isCoerce && isInt32;
109
111
  const numberChain = isCoerce && !isBigint && !is64 && !isInt32;
110
112
  const base = bigintBase ? `z.coerce.bigint(${baseErrorArg})` : isInt32 ? `z.${schema.format === "uint32" ? "uint32" : "int32"}(${baseErrorArg})` : is64 ? `z.${schema.format === "uint64" ? "uint64" : "int64"}(${baseErrorArg})` : isBigint ? `z.bigint(${baseErrorArg})` : `z.int(${baseErrorArg})`;
111
113
  const lit = (n) => {
112
- if (schema.format === "bigint") return `BigInt(${n})`;
113
- if (is64) return `${n}n`;
114
+ if (isBigint) return bigintCall(n);
115
+ if (is64) return bigintLiteral(n);
114
116
  return `${n}`;
115
117
  };
116
118
  const minimumMessage = schema["x-minimum-message"] ?? errorMessage;
@@ -143,7 +145,7 @@ function integer(schema, options) {
143
145
  })();
144
146
  const multipleOfMessage = schema["x-multipleOf-message"] ?? errorMessage;
145
147
  const multipleOfErrorArg = zodErrorPart(multipleOfMessage);
146
- const multipleOf = typeof schema.multipleOf === "number" ? `.multipleOf(${lit(schema.multipleOf)}${multipleOfErrorArg})` : void 0;
148
+ const multipleOf = schema.multipleOf !== void 0 ? `.multipleOf(${lit(schema.multipleOf)}${multipleOfErrorArg})` : void 0;
147
149
  const constraints = [
148
150
  minimum,
149
151
  maximum,
package/dist/zod.js CHANGED
@@ -1 +1 @@
1
- export { t as schemaToZod } from "./zod-04J51AMt.js";
1
+ export { t as schemaToZod } from "./zod-DI_MK5Ow.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "schema-truth",
3
- "version": "0.8.10",
3
+ "version": "0.8.11",
4
4
  "description": "Generate Zod/Valibot/Effect/TypeBox/ArkType/Ajv/Yup schemas from JSON or YAML files",
5
5
  "keywords": [
6
6
  "ajv",