schema-truth 0.8.11 → 0.8.12
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/dist/{ajv-Oz83L2oz.js → ajv-91NQz0R7.js} +1 -1
- package/dist/ajv.js +1 -1
- package/dist/{arktype-CxN3-TRa.js → arktype-Cl_XiSs3.js} +5 -4
- package/dist/arktype.js +1 -1
- package/dist/cli/ajv.js +2 -2
- package/dist/cli/arktype.js +2 -2
- package/dist/cli/effect.js +2 -2
- package/dist/cli/typebox.js +2 -2
- package/dist/cli/valibot.js +2 -2
- package/dist/cli/yup.js +2 -2
- package/dist/cli/zod.js +2 -2
- package/dist/{cli-t-ecjlut.js → cli-BxbvZp5H.js} +2 -2
- package/dist/{effect-8GBWHUkD.js → effect-BLTKj8GH.js} +7 -3
- package/dist/effect.js +1 -1
- package/dist/{helper-OCkRyx4U.js → helper-DRuGda2P.js} +13 -3
- package/dist/index.js +8 -8
- package/dist/{typebox-tm9Mgdik.js → typebox-BTCR9bNo.js} +1 -1
- package/dist/typebox.js +1 -1
- package/dist/{valibot-BTO7Xd8i.js → valibot-C1qkFYn6.js} +3 -3
- package/dist/valibot.js +1 -1
- package/dist/{yup-DKlaai37.js → yup-Cec-EEni.js} +1 -1
- package/dist/yup.js +1 -1
- package/dist/{zod-DI_MK5Ow.js → zod-CnDLSw9x.js} +3 -3
- package/dist/zod.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bt as normalizeTypes, c as sanitizeSchema, yt as makeSafeKey } from "./helper-DRuGda2P.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.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as schemaToAjv } from "./ajv-
|
|
1
|
+
export { t as schemaToAjv } from "./ajv-91NQz0R7.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as unionPrimitiveTypes, An as QUOTE_OR_BACKSLASH_PATTERN, Bt as isNullTypeMember, C as isNullMatchedFirst, D as ownProperties, E as numberWirePattern, F as regexSource, G as planDocument, Gt as isQuoted, H as definitionsOf, Ht as isObjectPrototypeProperty, It as isArktypeDefinition, J as schemaNamer, Jt as isSchemaObject, Lt as isComposite, M as wireNullText, Mt as hasFixedLength, N as wireNumericKind, O as stringboolPattern, P as formatPattern, Q as enumWithoutWrappedNull, Rn as UNSAFE_GENERATED_MARKER, Rt as isDeepLocalPointer, S as integerWirePattern, T as isPrimitiveUnion, U as emitOptionsOf, Vt as isNullable, W as missingDefinitionComment, Xt as isStringWireLocation, Y as discriminatedMembers, Yt as isShapelessMember, _ as valueListLiteral, at as findCodeExtensionKeysInSchema, bt as normalizeTypes, c as sanitizeSchema, ct as constraintPredicate, d as hasParameterSerialization, et as itemsSchemaOf, f as parameterReaders, ft as regexLiteral, g as notPredicate, h as isBigintFormat, i as isEvaluatedKeyExpression, in as DEFAULT_ROOT_NAME, it as callbackType, j as wireArrayOnce, jt as hasFixedItemCount, k as stringboolTruthyPattern, kt as hasCombinator, lt as foldAllOfMembers, m as withoutParameterSerialization, nt as arktypeWrap, p as propertyEmitOptions, pn as INTEGER_TEXT_PATTERN, q as rootNameOf, qt as isRootRef, r as evaluatedProperties, rt as callbackReturn, sn as DEFINITION_REF_PREFIXES, st as constraintMessage, tt as arktypePreprocess, u as withPolymorphicBases, ut as isKeywordOnlyMember, v as hoistNestedRefs, vt as issueMessageExpression, w as isNullTextRead, x as impliedWireType, xn as NUMBER_RANGES, xt as resolveOpenAPIRef, yt as makeSafeKey } from "./helper-DRuGda2P.js";
|
|
2
2
|
import { n as bigintCall, r as bigintLiteral, t as bigintBounds } from "./bigint-CkHij6xv.js";
|
|
3
3
|
// src/generator/arktype/number.ts
|
|
4
4
|
/** The comparators of a numeric node: `>= 1`, `< 5`, `% 2`. */
|
|
@@ -288,6 +288,7 @@ function object(schema, rootName, isArktype, options) {
|
|
|
288
288
|
names: Object.keys(properties),
|
|
289
289
|
patterns: Object.keys(schema.patternProperties ?? {})
|
|
290
290
|
}, "key");
|
|
291
|
+
const onlyEvaluatedKeys = isEvaluated === void 0 ? "Object.keys(data).length === 0" : `Object.keys(data).every((key) => ${isEvaluated})`;
|
|
291
292
|
const additionalMode = schema.additionalProperties === true ? "delete" : schema.additionalProperties === false && schema.patternProperties === void 0 ? "reject" : void 0;
|
|
292
293
|
const required = new Set(schema.required);
|
|
293
294
|
const props = [...Object.entries(properties).map(([key, propSchema]) => {
|
|
@@ -307,15 +308,15 @@ function object(schema, rootName, isArktype, options) {
|
|
|
307
308
|
const dependentSchemasNarrows = schema.dependentSchemas ? Object.entries(schema.dependentSchemas).map(([key, subSchema]) => {
|
|
308
309
|
return narrowPredicate(`!('${key}' in data) || ${callbackType(arktype(subSchema, rootName, isArktype, options), isArktype)}.allows(data)`, depSchMessage);
|
|
309
310
|
}) : [];
|
|
310
|
-
const additionalPropertiesNarrow = schema.additionalProperties === false && (addlPropsMessage !== void 0 || schema.patternProperties !== void 0) ? narrowPredicate(
|
|
311
|
+
const additionalPropertiesNarrow = schema.additionalProperties === false && (addlPropsMessage !== void 0 || schema.patternProperties !== void 0) ? narrowPredicate(onlyEvaluatedKeys, addlPropsMessage) : "";
|
|
311
312
|
const unevaluatedPropertiesNarrow = (() => {
|
|
312
313
|
const restSchema = typeof schema.additionalProperties === "object" ? schema.additionalProperties : schema.unevaluatedProperties;
|
|
313
314
|
if (restSchema === void 0 || restSchema === true) return "";
|
|
314
315
|
const message = typeof schema.additionalProperties === "object" ? addlPropsMessage : unevalPropsRawMessage;
|
|
315
|
-
if (restSchema === false) return narrowPredicate(
|
|
316
|
+
if (restSchema === false) return narrowPredicate(onlyEvaluatedKeys, message);
|
|
316
317
|
if (typeof restSchema === "object") {
|
|
317
318
|
const s = callbackType(arktype(restSchema, rootName, isArktype, options), isArktype);
|
|
318
|
-
return narrowPredicate(`Object.entries(data).every(([key, value]) => ${isEvaluated} || ${s}.allows(value))`, message);
|
|
319
|
+
return narrowPredicate(isEvaluated === void 0 ? `Object.values(data).every((value) => ${s}.allows(value))` : `Object.entries(data).every(([key, value]) => ${isEvaluated} || ${s}.allows(value))`, message);
|
|
319
320
|
}
|
|
320
321
|
return "";
|
|
321
322
|
})();
|
package/dist/arktype.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as schemaToArktype } from "./arktype-
|
|
1
|
+
export { t as schemaToArktype } from "./arktype-Cl_XiSs3.js";
|
package/dist/cli/ajv.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as schemaToAjv } from "../ajv-
|
|
3
|
-
import { n as version, t as cli } from "../cli-
|
|
2
|
+
import { t as schemaToAjv } from "../ajv-91NQz0R7.js";
|
|
3
|
+
import { n as version, t as cli } from "../cli-BxbvZp5H.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/arktype.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as schemaToArktype } from "../arktype-
|
|
3
|
-
import { n as version, t as cli } from "../cli-
|
|
2
|
+
import { t as schemaToArktype } from "../arktype-Cl_XiSs3.js";
|
|
3
|
+
import { n as version, t as cli } from "../cli-BxbvZp5H.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/effect.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as schemaToEffect } from "../effect-
|
|
3
|
-
import { n as version, t as cli } from "../cli-
|
|
2
|
+
import { t as schemaToEffect } from "../effect-BLTKj8GH.js";
|
|
3
|
+
import { n as version, t as cli } from "../cli-BxbvZp5H.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/typebox.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as schemaToTypebox } from "../typebox-
|
|
3
|
-
import { n as version, t as cli } from "../cli-
|
|
2
|
+
import { t as schemaToTypebox } from "../typebox-BTCR9bNo.js";
|
|
3
|
+
import { n as version, t as cli } from "../cli-BxbvZp5H.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/valibot.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as schemaToValibot } from "../valibot-
|
|
3
|
-
import { n as version, t as cli } from "../cli-
|
|
2
|
+
import { t as schemaToValibot } from "../valibot-C1qkFYn6.js";
|
|
3
|
+
import { n as version, t as cli } from "../cli-BxbvZp5H.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-
|
|
3
|
-
import { n as version, t as cli } from "../cli-
|
|
2
|
+
import { t as schemaToYup } from "../yup-Cec-EEni.js";
|
|
3
|
+
import { n as version, t as cli } from "../cli-BxbvZp5H.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-
|
|
3
|
-
import { n as version, t as cli } from "../cli-
|
|
2
|
+
import { t as schemaToZod } from "../zod-CnDLSw9x.js";
|
|
3
|
+
import { n as version, t as cli } from "../cli-BxbvZp5H.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 {
|
|
1
|
+
import { Kt as isRecord } from "./helper-DRuGda2P.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.
|
|
12
|
+
var version = "0.8.12";
|
|
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 {
|
|
1
|
+
import { A as unionPrimitiveTypes, At as hasConditional, Bt as isNullTypeMember, D as ownProperties, E as numberWirePattern, F as regexSource, Ft as hasType, G as planDocument, H as definitionsOf, Ht as isObjectPrototypeProperty, J as schemaNamer, Jt as isSchemaObject, K as renderDefinitions, L as deepEqualExpression, Lt as isComposite, Mt as hasFixedLength, N as wireNumericKind, O as stringboolPattern, P as formatPattern, Q as enumWithoutWrappedNull, R as jsLiteral, Rn as UNSAFE_GENERATED_MARKER, S as integerWirePattern, T as isPrimitiveUnion, U as emitOptionsOf, Vt as isNullable, Xt as isStringWireLocation, Y as discriminatedMembers, Yt as isShapelessMember, Z as hasRootSelfReference, _ as valueListLiteral, at as findCodeExtensionKeysInSchema, b as effectWrap, bt as normalizeTypes, c as sanitizeSchema, ct as constraintPredicate, d as hasParameterSerialization, et as itemsSchemaOf, f as parameterReaders, ft as regexLiteral, g as notPredicate, gt as effectMessage, h as isBigintFormat, ht as effectErrorPart, i as isEvaluatedKeyExpression, in as DEFAULT_ROOT_NAME, j as wireArrayOnce, jt as hasFixedItemCount, k as stringboolTruthyPattern, kt as hasCombinator, l as refTarget, lt as foldAllOfMembers, m as withoutParameterSerialization, mt as effectError, p as propertyEmitOptions, pn as INTEGER_TEXT_PATTERN, q as rootNameOf, r as evaluatedProperties, s as typeDeclaration, st as constraintMessage, u as withPolymorphicBases, ut as isKeywordOnlyMember, v as hoistNestedRefs, w as isNullTextRead, x as impliedWireType, xn as NUMBER_RANGES, y as effectPreprocess, yt as makeSafeKey, zt as isDefaultOnlyMember } from "./helper-DRuGda2P.js";
|
|
2
2
|
import { n as bigintCall, r as bigintLiteral, t as bigintBounds } from "./bigint-CkHij6xv.js";
|
|
3
3
|
// src/generator/effect/number.ts
|
|
4
4
|
/** The bound and `multipleOf` checks of a numeric node. */
|
|
@@ -228,7 +228,7 @@ function object(schema, rootName, isEffect, options) {
|
|
|
228
228
|
names: Object.keys(properties),
|
|
229
229
|
patterns: Object.keys(schema.patternProperties ?? {})
|
|
230
230
|
}, "key");
|
|
231
|
-
const unevaluatedKeysFilter = closed ? `Schema.makeFilter((input)
|
|
231
|
+
const unevaluatedKeysFilter = closed ? `Schema.makeFilter((input)=>${isEvaluated === void 0 ? "Object.keys(input).length===0" : `Object.keys(input).every((key)=>${isEvaluated})`}${effectErrorPart(strictExtrasMessage ?? errorMessage)})` : extraSchema !== void 0 ? `Schema.makeFilter((input)=>${isEvaluated === void 0 ? "Object.values(input).every((value)=>" : `Object.entries(input).every(([key,value])=>${isEvaluated}||`}Schema.is(Schema.toEncoded(${effect(extraSchema, rootName, isEffect, options)}))(value))${effectErrorPart(extraMessage ?? errorMessage)})` : "";
|
|
232
232
|
const ifThenElseFilters = (() => {
|
|
233
233
|
if (!schema.if) return [];
|
|
234
234
|
const ifSchema = effect(schema.if, rootName, isEffect, options);
|
|
@@ -420,7 +420,11 @@ function objectKeysCheck(inner, schema, rootName, isEffect, options) {
|
|
|
420
420
|
const unevaluatedSchema = typeof unevaluated === "object" ? unevaluated : void 0;
|
|
421
421
|
const evaluated = unevaluated === false || unevaluatedSchema !== void 0 ? evaluatedProperties(schema, options?.definitions) : void 0;
|
|
422
422
|
const accepts = (s) => `Schema.is(Schema.toEncoded(${effect(s, rootName, isEffect, options)}))(v)`;
|
|
423
|
-
const
|
|
423
|
+
const unevaluatedEvery = (isEvaluated) => {
|
|
424
|
+
if (unevaluatedSchema === void 0) return isEvaluated === void 0 ? "Object.keys(input).length===0" : `Object.keys(input).every((k)=>${isEvaluated})`;
|
|
425
|
+
return isEvaluated === void 0 ? `Object.values(input).every((v)=>${accepts(unevaluatedSchema)})` : `Object.entries(input).every(([k,v])=>${isEvaluated}||${accepts(unevaluatedSchema)})`;
|
|
426
|
+
};
|
|
427
|
+
const filters = [...patterns.map(([pattern, propSchema]) => `Schema.makeFilter((input)=>typeof input!=='object'||input===null||Array.isArray(input)||Object.entries(input).every(([k,v])=>!new RegExp(${JSON.stringify(pattern)}).test(k)||${accepts(propSchema)})${effectErrorPart(schema["x-patternProperties-message"])})`), ...evaluated === void 0 ? [] : [`Schema.makeFilter((input)=>typeof input!=='object'||input===null||Array.isArray(input)||${unevaluatedEvery(isEvaluatedKeyExpression(evaluated, "k"))}${effectErrorPart(schema["x-unevaluatedProperties-message"])})`]];
|
|
424
428
|
if (filters.length === 0) return inner;
|
|
425
429
|
return `Schema.Unknown.check(${filters.join(",")}).pipe(Schema.decodeTo(${inner}))`;
|
|
426
430
|
}
|
package/dist/effect.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as schemaToEffect } from "./effect-
|
|
1
|
+
export { t as schemaToEffect } from "./effect-BLTKj8GH.js";
|
|
@@ -3043,10 +3043,20 @@ function evaluatedProperties(schema, definitions, reading = /* @__PURE__ */ new
|
|
|
3043
3043
|
}
|
|
3044
3044
|
/**
|
|
3045
3045
|
* The emitted expression that tells whether `key` is evaluated: a lookup in the names
|
|
3046
|
-
* plus one `RegExp` test per pattern.
|
|
3046
|
+
* plus one `RegExp` test per pattern. With no names the lookup is left out, as `[]` is
|
|
3047
|
+
* typed `never[]` and `[].includes(key)` does not type-check; with neither, no key is
|
|
3048
|
+
* evaluated and it is `undefined`, so the caller can skip reading the key at all.
|
|
3047
3049
|
*/
|
|
3048
3050
|
function isEvaluatedKeyExpression(evaluated, key) {
|
|
3049
|
-
|
|
3051
|
+
const checks = [...evaluated.names.length > 0 ? [`${JSON.stringify(evaluated.names)}.includes(${key})`] : [], ...evaluated.patterns.map((pattern) => `new RegExp(${JSON.stringify(pattern)}).test(${key})`)];
|
|
3052
|
+
return checks.length > 0 ? checks.join("||") : void 0;
|
|
3053
|
+
}
|
|
3054
|
+
/**
|
|
3055
|
+
* The emitted loop body that runs `body` for a key `isEvaluated` does not cover: inside
|
|
3056
|
+
* an `if` when some key is evaluated, as it is when none is.
|
|
3057
|
+
*/
|
|
3058
|
+
function unlessEvaluated(isEvaluated, body) {
|
|
3059
|
+
return isEvaluated === void 0 ? body : `if(!(${isEvaluated})){${body}}`;
|
|
3050
3060
|
}
|
|
3051
3061
|
// src/helper/valibot-wrap.ts
|
|
3052
3062
|
/** A default as the Valibot literal of the schema's input: a bigint for a 64-bit integer. */
|
|
@@ -3158,4 +3168,4 @@ function zodWrap(zodStr, schema, options) {
|
|
|
3158
3168
|
if (preprocess) return preprocess;
|
|
3159
3169
|
return withMeta;
|
|
3160
3170
|
}
|
|
3161
|
-
export {
|
|
3171
|
+
export { isOptionalByDefault as $, ARKTYPE_CODE_EXTENSION_KEYS as $t, unionPrimitiveTypes as A, QUOTE_OR_BACKSLASH_PATTERN as An, hasConditional as At, typeboxMetaOpts as B, WIRE_PRIMITIVE_ORDER as Bn, isNullTypeMember as Bt, isNullMatchedFirst as C, NUMERIC_KEYWORDS as Cn, toPascalCase as Ct, ownProperties as D, OUTPUT_EXTENSION as Dn, zodError as Dt, numberWirePattern as E, OPENAPI_COMPONENT_SUFFIX_MAP as En, zodBaseError as Et, regexSource as F, STRING_KEYWORDS as Fn, hasType as Ft, planDocument as G, isQuoted as Gt, definitionsOf as H, isObjectPrototypeProperty as Ht, timePattern as I, STRING_WIRE_LOCATIONS as In, isArktypeDefinition as It, schemaNamer as J, isSchemaObject as Jt, renderDefinitions as K, isRecord as Kt, deepEqualExpression as L, UNICODE_ESCAPE_PATTERN as Ln, isComposite as Lt, wireNullText as M, STRINGBOOL_PATTERN as Mn, hasFixedLength as Mt, wireNumericKind as N, STRINGBOOL_TRUTHY_PATTERN as Nn, hasNumericKeyword as Nt, stringboolPattern as O, PARAM_LOCATIONS as On, zodErrorPart as Ot, formatPattern as P, STRING_FORMATS as Pn, hasStringKeyword as Pt, enumWithoutWrappedNull as Q, ANCHOR_REF_PATTERN as Qt, jsLiteral as R, UNSAFE_GENERATED_MARKER as Rn, isDeepLocalPointer as Rt, integerWirePattern as S, NUMBER_WIRE_PATTERN as Sn, toIdentifierPascalCase as St, isPrimitiveUnion as T, OFFSET_PATTERN_SOURCE as Tn, valibotErrorPart as Tt, emitOptionsOf as U, isPlainObject as Ut, typeboxRefOpt as V, ZOD_CODE_EXTENSION_KEYS as Vn, isNullable as Vt, missingDefinitionComment as W, isPrimitive as Wt, cyclicDefinitionNames as X, isStringWireLocation as Xt, discriminatedMembers as Y, isShapelessMember as Yt, hasRootSelfReference as Z, ALL_CODE_EXTENSION_KEYS as Zt, valueListLiteral as _, MISSING_DEFINITION_PREFIX as _n, encodeNonAscii as _t, unlessEvaluated as a, DEFINITION_KEYWORDS as an, findCodeExtensionKeysInSchema as at, effectWrap as b, NUMBER_FORMATS as bn, normalizeTypes as bt, sanitizeSchema as c, EFFECT_CODE_EXTENSION_KEYS as cn, constraintPredicate as ct, hasParameterSerialization as d, IF_THEN_ELSE_UNSUPPORTED_MARKER as dn, patternSource as dt, ARROW_FUNCTION_PATTERN as en, itemsSchemaOf as et, parameterReaders as f, INPUT_EXTENSIONS as fn, regexLiteral as ft, notPredicate as g, JSON_SCHEMA_TYPES as gn, effectMessage as gt, isBigintFormat as h, ISO_4217_CURRENCY_CODES as hn, effectErrorPart as ht, isEvaluatedKeyExpression as i, DEFAULT_ROOT_NAME as in, callbackType as it, wireArrayOnce as j, ROOT_REFS as jn, hasFixedItemCount as jt, stringboolTruthyPattern as k, PARAM_STYLES as kn, hasCombinator as kt, refTarget as l, FORMAT_PATTERNS as ln, foldAllOfMembers as lt, withoutParameterSerialization as m, INTEGER_WIRE_PATTERN as mn, effectError as mt, valibotWrap as n, CONTENT_ENCODINGS as nn, arktypeWrap as nt, typeboxWrap as o, DEFINITION_POINTER_PATTERN as on, hasNotKeyword as ot, propertyEmitOptions as p, INTEGER_TEXT_PATTERN as pn, coerceDefault as pt, rootNameOf as q, isRootRef as qt, evaluatedProperties as r, DATE_PATTERN_SOURCE as rn, callbackReturn as rt, typeDeclaration as s, DEFINITION_REF_PREFIXES as sn, constraintMessage as st, zodWrap as t, COMPONENT_SCHEMA_REF_PREFIX as tn, arktypePreprocess as tt, withPolymorphicBases as u, IDENTIFIER_PATTERN as un, isKeywordOnlyMember as ut, hoistNestedRefs as v, NON_IDENTIFIER_CHARACTER_PATTERN as vn, issueMessageExpression as vt, isNullTextRead as w, OBJECT_PROTOTYPE_PROPERTIES as wn, valibotError as wt, impliedWireType as x, NUMBER_RANGES as xn, resolveOpenAPIRef as xt, effectPreprocess as y, NOT_KEYWORD_UNSUPPORTED_MARKER as yn, makeSafeKey as yt, typeboxDefaultOpt as z, VALIBOT_CODE_EXTENSION_KEYS as zn, isDefaultOnlyMember as zt };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { $t as
|
|
1
|
+
import { $t as ARKTYPE_CODE_EXTENSION_KEYS, An as QUOTE_OR_BACKSLASH_PATTERN, Bn as WIRE_PRIMITIVE_ORDER, Cn as NUMERIC_KEYWORDS, Ct as toPascalCase, Dn as OUTPUT_EXTENSION, Dt as zodError, En as OPENAPI_COMPONENT_SUFFIX_MAP, Et as zodBaseError, Fn as STRING_KEYWORDS, In as STRING_WIRE_LOCATIONS, Ln as UNICODE_ESCAPE_PATTERN, Mn as STRINGBOOL_PATTERN, Nn as STRINGBOOL_TRUTHY_PATTERN, On as PARAM_LOCATIONS, Ot as zodErrorPart, Pn as STRING_FORMATS, Qt as ANCHOR_REF_PATTERN, Rn as UNSAFE_GENERATED_MARKER, Sn as NUMBER_WIRE_PATTERN, St as toIdentifierPascalCase, Tn as OFFSET_PATTERN_SOURCE, Tt as valibotErrorPart, Vn as ZOD_CODE_EXTENSION_KEYS, Zt as ALL_CODE_EXTENSION_KEYS, _n as MISSING_DEFINITION_PREFIX, _t as encodeNonAscii, an as DEFINITION_KEYWORDS, bn as NUMBER_FORMATS, bt as normalizeTypes, cn as EFFECT_CODE_EXTENSION_KEYS, dn as IF_THEN_ELSE_UNSUPPORTED_MARKER, en as ARROW_FUNCTION_PATTERN, fn as INPUT_EXTENSIONS, gn as JSON_SCHEMA_TYPES, gt as effectMessage, hn as ISO_4217_CURRENCY_CODES, ht as effectErrorPart, in as DEFAULT_ROOT_NAME, jn as ROOT_REFS, kn as PARAM_STYLES, ln as FORMAT_PATTERNS, mn as INTEGER_WIRE_PATTERN, mt as effectError, nn as CONTENT_ENCODINGS, on as DEFINITION_POINTER_PATTERN, pn as INTEGER_TEXT_PATTERN, pt as coerceDefault, rn as DATE_PATTERN_SOURCE, sn as DEFINITION_REF_PREFIXES, tn as COMPONENT_SCHEMA_REF_PREFIX, un as IDENTIFIER_PATTERN, vn as NON_IDENTIFIER_CHARACTER_PATTERN, vt as issueMessageExpression, wn as OBJECT_PROTOTYPE_PROPERTIES, wt as valibotError, xn as NUMBER_RANGES, xt as resolveOpenAPIRef, yn as NOT_KEYWORD_UNSUPPORTED_MARKER, yt as makeSafeKey, zn as VALIBOT_CODE_EXTENSION_KEYS } from "./helper-DRuGda2P.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-
|
|
4
|
-
import { n as arktype, t as schemaToArktype } from "./arktype-
|
|
5
|
-
import { n as effect, r as wholeValueMessage, t as schemaToEffect } from "./effect-
|
|
6
|
-
import { n as nestedTypeboxOptions, r as typebox, t as schemaToTypebox } from "./typebox-
|
|
7
|
-
import { n as valibot, t as schemaToValibot } from "./valibot-
|
|
8
|
-
import { n as yup, t as schemaToYup } from "./yup-
|
|
9
|
-
import { i as zod, n as forwardIssue, r as nestedIssueMessageWrap, t as schemaToZod } from "./zod-
|
|
3
|
+
import { n as ajv, t as schemaToAjv } from "./ajv-91NQz0R7.js";
|
|
4
|
+
import { n as arktype, t as schemaToArktype } from "./arktype-Cl_XiSs3.js";
|
|
5
|
+
import { n as effect, r as wholeValueMessage, t as schemaToEffect } from "./effect-BLTKj8GH.js";
|
|
6
|
+
import { n as nestedTypeboxOptions, r as typebox, t as schemaToTypebox } from "./typebox-BTCR9bNo.js";
|
|
7
|
+
import { n as valibot, t as schemaToValibot } from "./valibot-C1qkFYn6.js";
|
|
8
|
+
import { n as yup, t as schemaToYup } from "./yup-Cec-EEni.js";
|
|
9
|
+
import { i as zod, n as forwardIssue, r as nestedIssueMessageWrap, t as schemaToZod } from "./zod-CnDLSw9x.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 { $ as
|
|
1
|
+
import { $ as isOptionalByDefault, B as typeboxMetaOpts, Bt as isNullTypeMember, G as planDocument, H as definitionsOf, J as schemaNamer, K as renderDefinitions, Lt as isComposite, Mt as hasFixedLength, Nt as hasNumericKeyword, O as stringboolPattern, Pt as hasStringKeyword, Q as enumWithoutWrappedNull, Rt as isDeepLocalPointer, Sn as NUMBER_WIRE_PATTERN, U as emitOptionsOf, V as typeboxRefOpt, Vt as isNullable, W as missingDefinitionComment, X as cyclicDefinitionNames, Xt as isStringWireLocation, Y as discriminatedMembers, Yt as isShapelessMember, Z as hasRootSelfReference, bt as normalizeTypes, c as sanitizeSchema, dt as patternSource, et as itemsSchemaOf, in as DEFAULT_ROOT_NAME, k as stringboolTruthyPattern, kt as hasCombinator, lt as foldAllOfMembers, mn as INTEGER_WIRE_PATTERN, o as typeboxWrap, ot as hasNotKeyword, q as rootNameOf, qt as isRootRef, sn as DEFINITION_REF_PREFIXES, u as withPolymorphicBases, ut as isKeywordOnlyMember, v as hoistNestedRefs, xt as resolveOpenAPIRef, yn as NOT_KEYWORD_UNSUPPORTED_MARKER, yt as makeSafeKey, z as typeboxDefaultOpt, zt as isDefaultOnlyMember } from "./helper-DRuGda2P.js";
|
|
2
2
|
import { t as bigintBounds } from "./bigint-CkHij6xv.js";
|
|
3
3
|
// src/generator/typebox/enum.ts
|
|
4
4
|
function lit(v) {
|
package/dist/typebox.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as schemaToTypebox } from "./typebox-
|
|
1
|
+
export { t as schemaToTypebox } from "./typebox-BTCR9bNo.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as isOptionalByDefault, A as unionPrimitiveTypes, At as hasConditional, Bt as isNullTypeMember, D as ownProperties, E as numberWirePattern, F as regexSource, Ft as hasType, G as planDocument, H as definitionsOf, Ht as isObjectPrototypeProperty, J as schemaNamer, Jt as isSchemaObject, K as renderDefinitions, L as deepEqualExpression, Mt as hasFixedLength, N as wireNumericKind, O as stringboolPattern, P as formatPattern, Q as enumWithoutWrappedNull, R as jsLiteral, Rn as UNSAFE_GENERATED_MARKER, S as integerWirePattern, T as isPrimitiveUnion, Tt as valibotErrorPart, U as emitOptionsOf, Vt as isNullable, Wt as isPrimitive, Xt as isStringWireLocation, Y as discriminatedMembers, Yt as isShapelessMember, Z as hasRootSelfReference, _ as valueListLiteral, a as unlessEvaluated, at as findCodeExtensionKeysInSchema, bt as normalizeTypes, c as sanitizeSchema, ct as constraintPredicate, d as hasParameterSerialization, et as itemsSchemaOf, f as parameterReaders, ft as regexLiteral, g as notPredicate, h as isBigintFormat, i as isEvaluatedKeyExpression, in as DEFAULT_ROOT_NAME, j as wireArrayOnce, jt as hasFixedItemCount, k as stringboolTruthyPattern, kt as hasCombinator, l as refTarget, lt as foldAllOfMembers, m as withoutParameterSerialization, n as valibotWrap, p as propertyEmitOptions, pn as INTEGER_TEXT_PATTERN, q as rootNameOf, r as evaluatedProperties, s as typeDeclaration, st as constraintMessage, u as withPolymorphicBases, ut as isKeywordOnlyMember, v as hoistNestedRefs, vt as issueMessageExpression, w as isNullTextRead, wt as valibotError, x as impliedWireType, xn as NUMBER_RANGES, yt as makeSafeKey, zt as isDefaultOnlyMember } from "./helper-DRuGda2P.js";
|
|
2
2
|
import { n as bigintCall, r as bigintLiteral, t as bigintBounds } from "./bigint-CkHij6xv.js";
|
|
3
3
|
// src/generator/valibot/type.ts
|
|
4
4
|
/** The TypeScript type declared beside a recursive Valibot schema: its output type. */
|
|
@@ -289,7 +289,7 @@ function object(schema, rootName, isValibot, options) {
|
|
|
289
289
|
names: Object.keys(properties),
|
|
290
290
|
patterns: Object.keys(schema.patternProperties ?? {})
|
|
291
291
|
}, "key");
|
|
292
|
-
const unevaluatedKeysCheck = closedByCheck ? `v.check((input)
|
|
292
|
+
const unevaluatedKeysCheck = closedByCheck ? `v.check((input)=>${isEvaluated === void 0 ? "Object.keys(input).length===0" : `Object.keys(input).every((key)=>${isEvaluated})`}${valibotErrorPart(strictExtrasMessage ?? errorMessage)})` : extraSchema !== void 0 ? `v.check((input)=>${isEvaluated === void 0 ? "Object.values(input).every((value)=>" : `Object.entries(input).every(([key,value])=>${isEvaluated}||`}v.safeParse(${valibot(extraSchema, rootName, isValibot, options)},value).success)${valibotErrorPart(extraMessage ?? errorMessage)})` : "";
|
|
293
293
|
const actions = [
|
|
294
294
|
minPropertiesCheck,
|
|
295
295
|
maxPropertiesCheck,
|
|
@@ -440,7 +440,7 @@ function objectKeysCheck(inner, schema, rootName, isValibot, options) {
|
|
|
440
440
|
const patternMessage = schema["x-patternProperties-message"];
|
|
441
441
|
const patternChecks = patterns.map(([pattern, propSchema]) => `if(new RegExp(${JSON.stringify(pattern)}).test(k)){const result=v.safeParse(${valibot(propSchema, rootName, isValibot, options)},val);if(!result.success){${forwardKeyIssues(patternMessage)}}}`).join("");
|
|
442
442
|
const message = schema["x-unevaluatedProperties-message"];
|
|
443
|
-
return `v.pipe(v.unknown(),v.rawCheck(({dataset,addIssue})=>{if(!dataset.typed)return;const o=dataset.value;if(typeof o!=='object'||o===null||Array.isArray(o))return;for(const [k,val] of Object.entries(o)){${patternChecks}${evaluated === void 0 ? "" :
|
|
443
|
+
return `v.pipe(v.unknown(),v.rawCheck(({dataset,addIssue})=>{if(!dataset.typed)return;const o=dataset.value;if(typeof o!=='object'||o===null||Array.isArray(o))return;for(const [k,val] of Object.entries(o)){${patternChecks}${evaluated === void 0 ? "" : unlessEvaluated(isEvaluatedKeyExpression(evaluated, "k"), unevaluatedSchema === void 0 ? `addIssue({message:${message === void 0 ? `'Unevaluated property: '+k` : JSON.stringify(message)}})` : `const result=v.safeParse(${valibot(unevaluatedSchema, rootName, isValibot, options)},val);if(!result.success){${forwardKeyIssues(message)}}`)}}}),${inner})`;
|
|
444
444
|
}
|
|
445
445
|
/**
|
|
446
446
|
* Generate Valibot schema code from JSON Schema.
|
package/dist/valibot.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as schemaToValibot } from "./valibot-
|
|
1
|
+
export { t as schemaToValibot } from "./valibot-C1qkFYn6.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { J as schemaNamer, bt as normalizeTypes, c as sanitizeSchema, q as rootNameOf, yt as makeSafeKey } from "./helper-DRuGda2P.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.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as schemaToYup } from "./yup-
|
|
1
|
+
export { t as schemaToYup } from "./yup-Cec-EEni.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as unionPrimitiveTypes, At as hasConditional, Bt as isNullTypeMember, C as isNullMatchedFirst, Dt as zodError, E as numberWirePattern, Et as zodBaseError, Ft as hasType, G as planDocument, H as definitionsOf, Ht as isObjectPrototypeProperty, I as timePattern, J as schemaNamer, Jt as isSchemaObject, K as renderDefinitions, L as deepEqualExpression, Lt as isComposite, M as wireNullText, Mt as hasFixedLength, N as wireNumericKind, Ot as zodErrorPart, Q as enumWithoutWrappedNull, Rn as UNSAFE_GENERATED_MARKER, S as integerWirePattern, T as isPrimitiveUnion, U as emitOptionsOf, Ut as isPlainObject, Vt as isNullable, Wt as isPrimitive, Xt as isStringWireLocation, Y as discriminatedMembers, Yt as isShapelessMember, Z as hasRootSelfReference, _ as valueListLiteral, a as unlessEvaluated, at as findCodeExtensionKeysInSchema, bt as normalizeTypes, c as sanitizeSchema, ct as constraintPredicate, d as hasParameterSerialization, et as itemsSchemaOf, f as parameterReaders, ft as regexLiteral, g as notPredicate, h as isBigintFormat, hn as ISO_4217_CURRENCY_CODES, i as isEvaluatedKeyExpression, in as DEFAULT_ROOT_NAME, j as wireArrayOnce, kt as hasCombinator, l as refTarget, lt as foldAllOfMembers, m as withoutParameterSerialization, p as propertyEmitOptions, q as rootNameOf, r as evaluatedProperties, s as typeDeclaration, st as constraintMessage, t as zodWrap, u as withPolymorphicBases, ut as isKeywordOnlyMember, v as hoistNestedRefs, vt as issueMessageExpression, w as isNullTextRead, x as impliedWireType, yt as makeSafeKey, zt as isDefaultOnlyMember } from "./helper-DRuGda2P.js";
|
|
2
2
|
import { n as bigintCall, r as bigintLiteral, t as bigintBounds } from "./bigint-CkHij6xv.js";
|
|
3
3
|
// src/generator/zod/type.ts
|
|
4
4
|
/** The TypeScript type declared beside a recursive Zod schema. */
|
|
@@ -312,7 +312,7 @@ function object(schema, rootName, isZod, options) {
|
|
|
312
312
|
names: Object.keys(properties),
|
|
313
313
|
patterns: Object.keys(schema.patternProperties ?? {})
|
|
314
314
|
}, "key");
|
|
315
|
-
const objectExpr = `${partialBase}${minProperties}${maxProperties}${propertyNames}${patternProperties}${requiredPresent}${closedByCheck ? `.refine((val)
|
|
315
|
+
const objectExpr = `${partialBase}${minProperties}${maxProperties}${propertyNames}${patternProperties}${requiredPresent}${closedByCheck ? `.refine((val)=>${isEvaluated === void 0 ? "Object.keys(val).length===0" : `Object.keys(val).every((key)=>${isEvaluated})`}${zodErrorPart(strictMessage ?? errorMessage)})` : extraSchema !== void 0 ? `.refine((val)=>${isEvaluated === void 0 ? "Object.values(val).every((value)=>" : `Object.entries(val).every(([key,value])=>${isEvaluated}||`}${zod(extraSchema, rootName, isZod, options)}.safeParse(value).success)${zodErrorPart(extraMessage ?? errorMessage)})` : ""}${dependentRequired}${dependentSchemas}${ifThenElse}`;
|
|
316
316
|
const hasInheritedName = Object.keys(properties).some(isObjectPrototypeProperty);
|
|
317
317
|
return isStringWireLocation(options?.paramIn) && hasInheritedName ? `z.preprocess(${OWN_PROPERTIES_PREPROCESS},${objectExpr})` : objectExpr;
|
|
318
318
|
}
|
|
@@ -611,7 +611,7 @@ function objectKeysCheck(inner, schema, rootName, isZod, options) {
|
|
|
611
611
|
const patternMessage = schema["x-patternProperties-message"];
|
|
612
612
|
const patternChecks = patterns.map(([pattern, propSchema]) => `if(new RegExp(${JSON.stringify(pattern)}).test(k)){const result=${zod(propSchema, rootName, isZod, options)}.safeParse(v);if(!result.success){${forwardKeyIssues(patternMessage)}}}`).join("");
|
|
613
613
|
const message = schema["x-unevaluatedProperties-message"];
|
|
614
|
-
return `(()=>{const Schema=${inner};return z.unknown().check((ctx)=>{const o=ctx.value;if(typeof o!=='object'||o===null||Array.isArray(o))return;for(const [k,v] of Object.entries(o)){${patternChecks}${evaluated === void 0 ? "" :
|
|
614
|
+
return `(()=>{const Schema=${inner};return z.unknown().check((ctx)=>{const o=ctx.value;if(typeof o!=='object'||o===null||Array.isArray(o))return;for(const [k,v] of Object.entries(o)){${patternChecks}${evaluated === void 0 ? "" : unlessEvaluated(isEvaluatedKeyExpression(evaluated, "k"), unevaluatedSchema === void 0 ? `ctx.issues.push({code:'custom',input:o,path:[k],message:${message === void 0 ? "`Unrecognized key: \"${k}\"`" : JSON.stringify(message)}})` : `const result=${zod(unevaluatedSchema, rootName, isZod, options)}.safeParse(v);if(!result.success){${forwardKeyIssues(message)}}`)}}}).pipe(Schema)})()`;
|
|
615
615
|
}
|
|
616
616
|
function node(schema, rootName, isZod, options) {
|
|
617
617
|
const isStringWireParam = isStringWireLocation(options?.paramIn);
|
package/dist/zod.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as schemaToZod } from "./zod-
|
|
1
|
+
export { t as schemaToZod } from "./zod-CnDLSw9x.js";
|