@es-joy/jsoe 0.24.2 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +9 -0
- package/.ncurc.cjs +2 -2
- package/CHANGES.md +51 -0
- package/README.md +23 -13
- package/badges/coverage-badge.svg +1 -1
- package/dist/eslint.config.d.ts +3 -0
- package/dist/eslint.config.d.ts.map +1 -0
- package/dist/formatAndTypeChoices.d.ts +28 -30
- package/dist/formatAndTypeChoices.d.ts.map +1 -1
- package/dist/formats/indexedDBKey.d.ts.map +1 -1
- package/dist/formats/schema.d.ts +46 -3
- package/dist/formats/schema.d.ts.map +1 -1
- package/dist/formats/structuredCloning.d.ts +3 -0
- package/dist/formats/structuredCloning.d.ts.map +1 -1
- package/dist/formats.d.ts +24 -6
- package/dist/formats.d.ts.map +1 -1
- package/dist/fundamentalTypes/BooleanObjectType.d.ts.map +1 -1
- package/dist/fundamentalTypes/NumberObjectType.d.ts.map +1 -1
- package/dist/fundamentalTypes/StringObjectType.d.ts.map +1 -1
- package/dist/fundamentalTypes/arrayReferenceType.d.ts.map +1 -1
- package/dist/fundamentalTypes/arrayType.d.ts +7 -0
- package/dist/fundamentalTypes/arrayType.d.ts.map +1 -1
- package/dist/fundamentalTypes/bigintObjectType.d.ts.map +1 -1
- package/dist/fundamentalTypes/bigintType.d.ts +10 -0
- package/dist/fundamentalTypes/bigintType.d.ts.map +1 -1
- package/dist/fundamentalTypes/blobType.d.ts.map +1 -1
- package/dist/fundamentalTypes/booleanType.d.ts.map +1 -1
- package/dist/fundamentalTypes/catchType.d.ts +2 -2
- package/dist/fundamentalTypes/catchType.d.ts.map +1 -1
- package/dist/fundamentalTypes/dateType.d.ts.map +1 -1
- package/dist/fundamentalTypes/domexceptionType.d.ts.map +1 -1
- package/dist/fundamentalTypes/enumType.d.ts +2 -2
- package/dist/fundamentalTypes/enumType.d.ts.map +1 -1
- package/dist/fundamentalTypes/errorType.d.ts.map +1 -1
- package/dist/fundamentalTypes/fileType.d.ts +6 -0
- package/dist/fundamentalTypes/fileType.d.ts.map +1 -1
- package/dist/fundamentalTypes/functionType.d.ts.map +1 -1
- package/dist/fundamentalTypes/literalType.d.ts +3 -2
- package/dist/fundamentalTypes/literalType.d.ts.map +1 -1
- package/dist/fundamentalTypes/looseRecordType.d.ts +6 -0
- package/dist/fundamentalTypes/looseRecordType.d.ts.map +1 -0
- package/dist/fundamentalTypes/nanType.d.ts.map +1 -1
- package/dist/fundamentalTypes/neverType.d.ts +2 -2
- package/dist/fundamentalTypes/neverType.d.ts.map +1 -1
- package/dist/fundamentalTypes/noneditableType.d.ts.map +1 -1
- package/dist/fundamentalTypes/nullType.d.ts.map +1 -1
- package/dist/fundamentalTypes/numberType.d.ts.map +1 -1
- package/dist/fundamentalTypes/promiseType.d.ts.map +1 -1
- package/dist/fundamentalTypes/regexpType.d.ts.map +1 -1
- package/dist/fundamentalTypes/stringType.d.ts.map +1 -1
- package/dist/fundamentalTypes/symbolType.d.ts.map +1 -1
- package/dist/fundamentalTypes/undefinedType.d.ts.map +1 -1
- package/dist/fundamentalTypes/voidType.d.ts +2 -2
- package/dist/fundamentalTypes/voidType.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/rollup.config.d.ts +30 -0
- package/dist/rollup.config.d.ts.map +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/src/formatAndTypeChoices.d.ts +108 -0
- package/dist/src/formatAndTypeChoices.d.ts.map +1 -0
- package/dist/src/formats/arbitraryJS.d.ts +4 -0
- package/dist/src/formats/arbitraryJS.d.ts.map +1 -0
- package/dist/src/formats/indexedDBKey.d.ts +4 -0
- package/dist/src/formats/indexedDBKey.d.ts.map +1 -0
- package/dist/src/formats/json.d.ts +4 -0
- package/dist/src/formats/json.d.ts.map +1 -0
- package/dist/src/formats/schema.d.ts +17 -0
- package/dist/src/formats/schema.d.ts.map +1 -0
- package/dist/src/formats/structuredCloning.d.ts +19 -0
- package/dist/src/formats/structuredCloning.d.ts.map +1 -0
- package/dist/src/formats.d.ts +135 -0
- package/dist/src/formats.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/BooleanObjectType.d.ts +8 -0
- package/dist/src/fundamentalTypes/BooleanObjectType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/NumberObjectType.d.ts +6 -0
- package/dist/src/fundamentalTypes/NumberObjectType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/StringObjectType.d.ts +6 -0
- package/dist/src/fundamentalTypes/StringObjectType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/arrayReferenceType.d.ts +8 -0
- package/dist/src/fundamentalTypes/arrayReferenceType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/arrayType.d.ts +29 -0
- package/dist/src/fundamentalTypes/arrayType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/bigintObjectType.d.ts +6 -0
- package/dist/src/fundamentalTypes/bigintObjectType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/bigintType.d.ts +6 -0
- package/dist/src/fundamentalTypes/bigintType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/blobType.d.ts +11 -0
- package/dist/src/fundamentalTypes/blobType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/booleanType.d.ts +8 -0
- package/dist/src/fundamentalTypes/booleanType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/catchType.d.ts +6 -0
- package/dist/src/fundamentalTypes/catchType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/dateType.d.ts +26 -0
- package/dist/src/fundamentalTypes/dateType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/domexceptionType.d.ts +6 -0
- package/dist/src/fundamentalTypes/domexceptionType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/enumType.d.ts +6 -0
- package/dist/src/fundamentalTypes/enumType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/errorType.d.ts +6 -0
- package/dist/src/fundamentalTypes/errorType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/fileType.d.ts +13 -0
- package/dist/src/fundamentalTypes/fileType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/filelistType.d.ts +6 -0
- package/dist/src/fundamentalTypes/filelistType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/functionType.d.ts +7 -0
- package/dist/src/fundamentalTypes/functionType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/literalType.d.ts +6 -0
- package/dist/src/fundamentalTypes/literalType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/mapType.d.ts +6 -0
- package/dist/src/fundamentalTypes/mapType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/nanType.d.ts +6 -0
- package/dist/src/fundamentalTypes/nanType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/neverType.d.ts +6 -0
- package/dist/src/fundamentalTypes/neverType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/noneditableType.d.ts +6 -0
- package/dist/src/fundamentalTypes/noneditableType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/nullType.d.ts +6 -0
- package/dist/src/fundamentalTypes/nullType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/numberType.d.ts +6 -0
- package/dist/src/fundamentalTypes/numberType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/objectReferenceType.d.ts +8 -0
- package/dist/src/fundamentalTypes/objectReferenceType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/objectType.d.ts +6 -0
- package/dist/src/fundamentalTypes/objectType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/promiseType.d.ts +6 -0
- package/dist/src/fundamentalTypes/promiseType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/recordType.d.ts +6 -0
- package/dist/src/fundamentalTypes/recordType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/regexpType.d.ts +8 -0
- package/dist/src/fundamentalTypes/regexpType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/setType.d.ts +6 -0
- package/dist/src/fundamentalTypes/setType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/sparseUndefinedType.d.ts +6 -0
- package/dist/src/fundamentalTypes/sparseUndefinedType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/stringType.d.ts +6 -0
- package/dist/src/fundamentalTypes/stringType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/symbolType.d.ts +8 -0
- package/dist/src/fundamentalTypes/symbolType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/tupleType.d.ts +6 -0
- package/dist/src/fundamentalTypes/tupleType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/undefinedType.d.ts +6 -0
- package/dist/src/fundamentalTypes/undefinedType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/voidType.d.ts +6 -0
- package/dist/src/fundamentalTypes/voidType.d.ts.map +1 -0
- package/dist/src/index.d.ts +12 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/subTypes/blobHTMLType.d.ts +20 -0
- package/dist/src/subTypes/blobHTMLType.d.ts.map +1 -0
- package/dist/src/subTypes/falseType.d.ts +8 -0
- package/dist/src/subTypes/falseType.d.ts.map +1 -0
- package/dist/src/subTypes/trueType.d.ts +8 -0
- package/dist/src/subTypes/trueType.d.ts.map +1 -0
- package/dist/src/superTypes/SpecialNumberType.d.ts +6 -0
- package/dist/src/superTypes/SpecialNumberType.d.ts.map +1 -0
- package/dist/src/superTypes/SpecialRealNumberType.d.ts +6 -0
- package/dist/src/superTypes/SpecialRealNumberType.d.ts.map +1 -0
- package/dist/src/superTypes/buffersourceType.d.ts +8 -0
- package/dist/src/superTypes/buffersourceType.d.ts.map +1 -0
- package/dist/src/superTypes/dommatrixType.d.ts +6 -0
- package/dist/src/superTypes/dommatrixType.d.ts.map +1 -0
- package/dist/src/superTypes/dompointType.d.ts +6 -0
- package/dist/src/superTypes/dompointType.d.ts.map +1 -0
- package/dist/src/superTypes/domrectType.d.ts +6 -0
- package/dist/src/superTypes/domrectType.d.ts.map +1 -0
- package/dist/src/superTypes/errorsSpecialType.d.ts +8 -0
- package/dist/src/superTypes/errorsSpecialType.d.ts.map +1 -0
- package/dist/src/typeChoices.d.ts +140 -0
- package/dist/src/typeChoices.d.ts.map +1 -0
- package/dist/src/types.d.ts +758 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/utils/FileList.d.ts +26 -0
- package/dist/src/utils/FileList.d.ts.map +1 -0
- package/dist/src/utils/dialogs.d.ts +111 -0
- package/dist/src/utils/dialogs.d.ts.map +1 -0
- package/dist/src/utils/jsonPointer.d.ts +46 -0
- package/dist/src/utils/jsonPointer.d.ts.map +1 -0
- package/dist/src/utils/media.d.ts +18 -0
- package/dist/src/utils/media.d.ts.map +1 -0
- package/dist/src/utils/objects.d.ts +16 -0
- package/dist/src/utils/objects.d.ts.map +1 -0
- package/dist/src/utils/templateUtils.d.ts +59 -0
- package/dist/src/utils/templateUtils.d.ts.map +1 -0
- package/dist/src/utils/types.d.ts +2 -0
- package/dist/src/utils/types.d.ts.map +1 -0
- package/dist/src/vendor-imports.d.ts +4 -0
- package/dist/src/vendor-imports.d.ts.map +1 -0
- package/dist/subTypes/blobHTMLType.d.ts.map +1 -1
- package/dist/superTypes/SpecialRealNumberType.d.ts.map +1 -1
- package/dist/superTypes/buffersourceType.d.ts.map +1 -1
- package/dist/superTypes/dommatrixType.d.ts.map +1 -1
- package/dist/superTypes/dompointType.d.ts.map +1 -1
- package/dist/superTypes/domrectType.d.ts.map +1 -1
- package/dist/superTypes/errorsSpecialType.d.ts.map +1 -1
- package/dist/typeChoices.d.ts +21 -87
- package/dist/typeChoices.d.ts.map +1 -1
- package/dist/types.d.ts +90 -64
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/FileList.d.ts +4 -3
- package/dist/utils/FileList.d.ts.map +1 -1
- package/dist/utils/dialogs.d.ts +4 -4
- package/dist/utils/dialogs.d.ts.map +1 -1
- package/dist/utils/media.d.ts.map +1 -1
- package/dist/utils/schemaMeta.d.ts +92 -0
- package/dist/utils/schemaMeta.d.ts.map +1 -0
- package/dist/utils/templateUtils.d.ts +3 -3
- package/dist/utils/templateUtils.d.ts.map +1 -1
- package/dist/utils/timing.d.ts +2 -0
- package/dist/utils/timing.d.ts.map +1 -0
- package/dist/utils/types.d.ts +1 -0
- package/dist/utils/types.d.ts.map +1 -1
- package/dist/vendor-imports.d.ts +3 -1
- package/docs/proposals/schema-meta.md +233 -0
- package/eslint.config.js +51 -4
- package/licenseInfo.json +1 -1
- package/package.json +52 -42
- package/pnpm-workspace.yaml +57 -0
- package/rollup.config.js +20 -18
- package/server.js +3 -3
- package/src/deepEqual.js +77 -66
- package/src/deepEqual.js.map +1 -1
- package/src/formatAndTypeChoices.js +62 -58
- package/src/formats/indexedDBKey.js +3 -4
- package/src/formats/schema.js +824 -475
- package/src/formats/structuredCloning.js +189 -80
- package/src/formats.js +17 -5
- package/src/fundamentalTypes/BooleanObjectType.js +4 -5
- package/src/fundamentalTypes/NumberObjectType.js +4 -4
- package/src/fundamentalTypes/StringObjectType.js +3 -4
- package/src/fundamentalTypes/arrayReferenceType.js +0 -2
- package/src/fundamentalTypes/arrayType.js +624 -389
- package/src/fundamentalTypes/bigintObjectType.js +3 -2
- package/src/fundamentalTypes/bigintType.js +79 -17
- package/src/fundamentalTypes/blobType.js +35 -35
- package/src/fundamentalTypes/booleanType.js +16 -8
- package/src/fundamentalTypes/dateType.js +6 -8
- package/src/fundamentalTypes/domexceptionType.js +5 -4
- package/src/fundamentalTypes/errorType.js +39 -32
- package/src/fundamentalTypes/fileType.js +238 -52
- package/src/fundamentalTypes/functionType.js +61 -41
- package/src/fundamentalTypes/nanType.js +5 -4
- package/src/fundamentalTypes/noneditableType.js +4 -3
- package/src/fundamentalTypes/nullType.js +3 -2
- package/src/fundamentalTypes/numberType.js +72 -20
- package/src/fundamentalTypes/promiseType.js +16 -40
- package/src/fundamentalTypes/regexpType.js +7 -13
- package/src/fundamentalTypes/stringType.js +176 -110
- package/src/fundamentalTypes/symbolType.js +3 -2
- package/src/fundamentalTypes/undefinedType.js +3 -2
- package/src/index.js +6 -5
- package/src/jsoe.css +107 -8
- package/src/subTypes/blobHTMLType.js +23 -10
- package/src/superTypes/SpecialNumberType.js +6 -6
- package/src/superTypes/SpecialRealNumberType.js +10 -9
- package/src/superTypes/buffersourceType.js +86 -75
- package/src/superTypes/dommatrixType.js +6 -5
- package/src/superTypes/dompointType.js +6 -5
- package/src/superTypes/domrectType.js +6 -5
- package/src/superTypes/errorsSpecialType.js +54 -35
- package/src/typeChoices.js +373 -53
- package/src/types.js +157 -97
- package/src/utils/FileList.js +3 -3
- package/src/utils/dialogs.js +5 -7
- package/src/utils/jsonPointer.js +1 -1
- package/src/utils/media.js +1 -0
- package/src/utils/schemaMeta.js +257 -0
- package/src/utils/templateUtils.js +3 -3
- package/src/utils/timing.js +12 -0
- package/src/utils/types.js +19 -0
- package/src/vendor-imports.js +10 -2
- package/tsconfig.json +2 -0
- package/vendor/acorn/dist/acorn.d.mts +46 -5
- package/vendor/acorn/dist/acorn.d.ts +46 -5
- package/vendor/acorn/dist/acorn.js +394 -117
- package/vendor/acorn/dist/acorn.mjs +394 -117
- package/vendor/acorn/dist/bin.js +1 -1
- package/vendor/jamilih/dist/{jml-es.js → jml.mjs} +590 -312
- package/vendor/jamilih/package.json +1 -1
- package/vendor/mime/dist/types/other.js +719 -0
- package/vendor/mime/dist/types/standard.js +366 -0
- package/vendor/typeson-registry/dist/index.js +519 -99
- package/vendor/zod/classic/checks.d.ts +1 -0
- package/vendor/zod/classic/checks.js +1 -0
- package/vendor/zod/classic/coerce.d.ts +17 -0
- package/vendor/zod/classic/coerce.js +17 -0
- package/vendor/zod/classic/compat.d.ts +48 -0
- package/vendor/zod/classic/compat.js +31 -0
- package/vendor/zod/classic/deep-partial.d.ts +14 -0
- package/vendor/zod/classic/deep-partial.js +13 -0
- package/vendor/zod/classic/errors.d.ts +29 -0
- package/vendor/zod/classic/errors.js +57 -0
- package/vendor/zod/classic/external.d.ts +19 -0
- package/vendor/zod/classic/external.js +17 -0
- package/vendor/zod/classic/from-json-schema.d.ts +12 -0
- package/vendor/zod/classic/from-json-schema.js +660 -0
- package/vendor/zod/classic/in-out.d.ts +8 -0
- package/vendor/zod/classic/in-out.js +36 -0
- package/vendor/zod/classic/index.d.ts +3 -0
- package/vendor/zod/classic/index.js +4 -0
- package/vendor/zod/classic/iso.d.ts +7 -0
- package/vendor/zod/classic/iso.js +15 -0
- package/vendor/zod/classic/package.json +7 -0
- package/vendor/zod/classic/parse.d.ts +44 -0
- package/vendor/zod/classic/parse.js +16 -0
- package/vendor/zod/classic/schemas.d.ts +802 -0
- package/vendor/zod/classic/schemas.js +1491 -0
- package/vendor/zod/core/api.d.ts +329 -0
- package/vendor/zod/core/api.js +1104 -0
- package/vendor/zod/core/checks.d.ts +278 -0
- package/vendor/zod/core/checks.js +581 -0
- package/vendor/zod/core/compile.d.ts +51 -0
- package/vendor/zod/core/compile.js +1783 -0
- package/vendor/zod/core/core.d.ts +82 -0
- package/vendor/zod/core/core.js +141 -0
- package/vendor/zod/core/doc.d.ts +16 -0
- package/vendor/zod/core/doc.js +33 -0
- package/vendor/zod/core/errors.d.ts +225 -0
- package/vendor/zod/core/errors.js +270 -0
- package/vendor/zod/core/index.d.ts +19 -0
- package/vendor/zod/core/index.js +19 -0
- package/vendor/zod/core/json-schema-generator.d.ts +65 -0
- package/vendor/zod/core/json-schema-generator.js +99 -0
- package/vendor/zod/core/json-schema-processors.d.ts +49 -0
- package/vendor/zod/core/json-schema-processors.js +747 -0
- package/vendor/zod/core/json-schema.d.ts +89 -0
- package/vendor/zod/core/memoizer.d.ts +15 -0
- package/vendor/zod/core/memoizer.js +265 -0
- package/vendor/zod/core/package.json +7 -0
- package/vendor/zod/core/parse.d.ts +52 -0
- package/vendor/zod/core/parse.js +154 -0
- package/vendor/zod/core/regexes.d.ts +87 -0
- package/vendor/zod/core/regexes.js +150 -0
- package/vendor/zod/core/registries.d.ts +35 -0
- package/vendor/zod/core/registries.js +51 -0
- package/vendor/zod/core/schemas.d.ts +1253 -0
- package/vendor/zod/core/schemas.js +2440 -0
- package/vendor/zod/core/standard-schema.d.ts +126 -0
- package/vendor/zod/core/to-json-schema.d.ts +153 -0
- package/vendor/zod/core/to-json-schema.js +650 -0
- package/vendor/zod/core/util.d.ts +257 -0
- package/vendor/zod/core/util.js +846 -0
- package/vendor/zod/core/versions.d.ts +5 -0
- package/vendor/zod/core/versions.js +5 -0
- package/vendor/zod/core/visit.d.ts +30 -0
- package/vendor/zod/core/visit.js +169 -0
- package/vendor/zod/index.d.ts +3 -0
- package/vendor/zod/index.js +4 -0
- package/vendor/zod/locales/ar.d.ts +4 -0
- package/vendor/zod/locales/ar.js +109 -0
- package/vendor/zod/locales/az.d.ts +4 -0
- package/vendor/zod/locales/az.js +108 -0
- package/vendor/zod/locales/be.d.ts +4 -0
- package/vendor/zod/locales/be.js +166 -0
- package/vendor/zod/locales/bg.d.ts +4 -0
- package/vendor/zod/locales/bg.js +123 -0
- package/vendor/zod/locales/bn.d.ts +4 -0
- package/vendor/zod/locales/bn.js +111 -0
- package/vendor/zod/locales/ca.d.ts +4 -0
- package/vendor/zod/locales/ca.js +110 -0
- package/vendor/zod/locales/ckb.d.ts +4 -0
- package/vendor/zod/locales/ckb.js +131 -0
- package/vendor/zod/locales/cs.d.ts +4 -0
- package/vendor/zod/locales/cs.js +114 -0
- package/vendor/zod/locales/da.d.ts +4 -0
- package/vendor/zod/locales/da.js +118 -0
- package/vendor/zod/locales/de.d.ts +4 -0
- package/vendor/zod/locales/de.js +111 -0
- package/vendor/zod/locales/el.d.ts +4 -0
- package/vendor/zod/locales/el.js +110 -0
- package/vendor/zod/locales/en.d.ts +4 -0
- package/vendor/zod/locales/en.js +123 -0
- package/vendor/zod/locales/eo.d.ts +4 -0
- package/vendor/zod/locales/eo.js +112 -0
- package/vendor/zod/locales/es.d.ts +4 -0
- package/vendor/zod/locales/es.js +134 -0
- package/vendor/zod/locales/fa.d.ts +4 -0
- package/vendor/zod/locales/fa.js +117 -0
- package/vendor/zod/locales/fi.d.ts +4 -0
- package/vendor/zod/locales/fi.js +115 -0
- package/vendor/zod/locales/fr-CA.d.ts +4 -0
- package/vendor/zod/locales/fr-CA.js +110 -0
- package/vendor/zod/locales/fr.d.ts +4 -0
- package/vendor/zod/locales/fr.js +127 -0
- package/vendor/zod/locales/gu.d.ts +4 -0
- package/vendor/zod/locales/gu.js +111 -0
- package/vendor/zod/locales/he.d.ts +4 -0
- package/vendor/zod/locales/he.js +219 -0
- package/vendor/zod/locales/hi.d.ts +4 -0
- package/vendor/zod/locales/hi.js +109 -0
- package/vendor/zod/locales/hr.d.ts +4 -0
- package/vendor/zod/locales/hr.js +124 -0
- package/vendor/zod/locales/hu.d.ts +4 -0
- package/vendor/zod/locales/hu.js +111 -0
- package/vendor/zod/locales/hy.d.ts +4 -0
- package/vendor/zod/locales/hy.js +156 -0
- package/vendor/zod/locales/id.d.ts +4 -0
- package/vendor/zod/locales/id.js +109 -0
- package/vendor/zod/locales/index.d.ts +62 -0
- package/vendor/zod/locales/index.js +62 -0
- package/vendor/zod/locales/is.d.ts +4 -0
- package/vendor/zod/locales/is.js +112 -0
- package/vendor/zod/locales/it.d.ts +4 -0
- package/vendor/zod/locales/it.js +111 -0
- package/vendor/zod/locales/ja.d.ts +4 -0
- package/vendor/zod/locales/ja.js +110 -0
- package/vendor/zod/locales/ka.d.ts +4 -0
- package/vendor/zod/locales/ka.js +115 -0
- package/vendor/zod/locales/kh.d.ts +5 -0
- package/vendor/zod/locales/kh.js +5 -0
- package/vendor/zod/locales/km.d.ts +4 -0
- package/vendor/zod/locales/km.js +113 -0
- package/vendor/zod/locales/kn.d.ts +4 -0
- package/vendor/zod/locales/kn.js +114 -0
- package/vendor/zod/locales/ko.d.ts +4 -0
- package/vendor/zod/locales/ko.js +114 -0
- package/vendor/zod/locales/lt.d.ts +4 -0
- package/vendor/zod/locales/lt.js +205 -0
- package/vendor/zod/locales/mk.d.ts +4 -0
- package/vendor/zod/locales/mk.js +112 -0
- package/vendor/zod/locales/ms.d.ts +4 -0
- package/vendor/zod/locales/ms.js +110 -0
- package/vendor/zod/locales/ne.d.ts +4 -0
- package/vendor/zod/locales/ne.js +109 -0
- package/vendor/zod/locales/nl.d.ts +4 -0
- package/vendor/zod/locales/nl.js +113 -0
- package/vendor/zod/locales/nn.d.ts +4 -0
- package/vendor/zod/locales/nn.js +111 -0
- package/vendor/zod/locales/no.d.ts +4 -0
- package/vendor/zod/locales/no.js +111 -0
- package/vendor/zod/locales/ota.d.ts +4 -0
- package/vendor/zod/locales/ota.js +112 -0
- package/vendor/zod/locales/package.json +7 -0
- package/vendor/zod/locales/pl.d.ts +4 -0
- package/vendor/zod/locales/pl.js +112 -0
- package/vendor/zod/locales/ps.d.ts +4 -0
- package/vendor/zod/locales/ps.js +117 -0
- package/vendor/zod/locales/pt-BR.d.ts +4 -0
- package/vendor/zod/locales/pt-BR.js +141 -0
- package/vendor/zod/locales/pt.d.ts +4 -0
- package/vendor/zod/locales/pt.js +140 -0
- package/vendor/zod/locales/ro.d.ts +4 -0
- package/vendor/zod/locales/ro.js +120 -0
- package/vendor/zod/locales/ru.d.ts +4 -0
- package/vendor/zod/locales/ru.js +166 -0
- package/vendor/zod/locales/sk.d.ts +4 -0
- package/vendor/zod/locales/sk.js +114 -0
- package/vendor/zod/locales/sl.d.ts +4 -0
- package/vendor/zod/locales/sl.js +112 -0
- package/vendor/zod/locales/sv.d.ts +4 -0
- package/vendor/zod/locales/sv.js +113 -0
- package/vendor/zod/locales/ta.d.ts +4 -0
- package/vendor/zod/locales/ta.js +113 -0
- package/vendor/zod/locales/th.d.ts +4 -0
- package/vendor/zod/locales/th.js +113 -0
- package/vendor/zod/locales/tk.d.ts +4 -0
- package/vendor/zod/locales/tk.js +105 -0
- package/vendor/zod/locales/tr.d.ts +4 -0
- package/vendor/zod/locales/tr.js +108 -0
- package/vendor/zod/locales/ua.d.ts +5 -0
- package/vendor/zod/locales/ua.js +5 -0
- package/vendor/zod/locales/uk.d.ts +4 -0
- package/vendor/zod/locales/uk.js +111 -0
- package/vendor/zod/locales/ur.d.ts +4 -0
- package/vendor/zod/locales/ur.js +113 -0
- package/vendor/zod/locales/uz.d.ts +4 -0
- package/vendor/zod/locales/uz.js +111 -0
- package/vendor/zod/locales/vi.d.ts +4 -0
- package/vendor/zod/locales/vi.js +111 -0
- package/vendor/zod/locales/yo.d.ts +4 -0
- package/vendor/zod/locales/yo.js +110 -0
- package/vendor/zod/locales/zh-CN.d.ts +4 -0
- package/vendor/zod/locales/zh-CN.js +112 -0
- package/vendor/zod/locales/zh-TW.d.ts +4 -0
- package/vendor/zod/locales/zh-TW.js +110 -0
- package/vendor/zod/mini/checks.d.ts +1 -0
- package/vendor/zod/mini/checks.js +1 -0
- package/vendor/zod/mini/coerce.d.ts +7 -0
- package/vendor/zod/mini/coerce.js +22 -0
- package/vendor/zod/mini/deep-partial.d.ts +14 -0
- package/vendor/zod/mini/deep-partial.js +13 -0
- package/vendor/zod/mini/external.d.ts +16 -0
- package/vendor/zod/mini/external.js +16 -0
- package/vendor/zod/mini/in-out.d.ts +8 -0
- package/vendor/zod/mini/in-out.js +36 -0
- package/vendor/zod/mini/index.d.ts +3 -0
- package/vendor/zod/mini/index.js +3 -0
- package/vendor/zod/mini/iso.d.ts +22 -0
- package/vendor/zod/mini/iso.js +34 -0
- package/vendor/zod/mini/package.json +7 -0
- package/vendor/zod/mini/parse.d.ts +1 -0
- package/vendor/zod/mini/parse.js +1 -0
- package/vendor/zod/mini/schemas.d.ts +475 -0
- package/vendor/zod/mini/schemas.js +987 -0
- package/vendor/zod/package.json +7 -0
- package/vendor/zodexy/dist/esm/index.js +1274 -0
- package/vendor/zodexy/dist/index.js +1088 -0
- package/vendor/zodexy/dist/schema.zodexy.json +1036 -0
- package/dist/fundamentalTypes/nativeEnumType.d.ts +0 -6
- package/dist/fundamentalTypes/nativeEnumType.d.ts.map +0 -1
- package/src/fundamentalTypes/catchType.js +0 -140
- package/src/fundamentalTypes/enumType.js +0 -52
- package/src/fundamentalTypes/literalType.js +0 -81
- package/src/fundamentalTypes/nativeEnumType.js +0 -157
- package/src/fundamentalTypes/neverType.js +0 -49
- package/src/fundamentalTypes/recordType.js +0 -42
- package/src/fundamentalTypes/tupleType.js +0 -39
- package/src/fundamentalTypes/voidType.js +0 -48
- package/vendor/zod/lib/index.mjs +0 -4236
- package/vendor/zodex/dist/esm/dezerialize.d.ts +0 -26
- package/vendor/zodex/dist/esm/dezerialize.js +0 -393
- package/vendor/zodex/dist/esm/index.d.ts +0 -9
- package/vendor/zodex/dist/esm/index.js +0 -4
- package/vendor/zodex/dist/esm/infer.d.ts +0 -29
- package/vendor/zodex/dist/esm/package.json +0 -1
- package/vendor/zodex/dist/esm/types.d.ts +0 -201
- package/vendor/zodex/dist/esm/types.js +0 -13
- package/vendor/zodex/dist/esm/ui.d.ts +0 -23
- package/vendor/zodex/dist/esm/ui.js +0 -10
- package/vendor/zodex/dist/esm/zerialize.d.ts +0 -50
- package/vendor/zodex/dist/esm/zerialize.js +0 -417
- package/vendor/zodex/dist/esm/zod-types.d.ts +0 -11
- /package/vendor/{zodex/dist/esm/infer.js → zod/core/json-schema.js} +0 -0
- /package/vendor/{zodex/dist/esm/zod-types.js → zod/core/standard-schema.js} +0 -0
|
@@ -0,0 +1,660 @@
|
|
|
1
|
+
import { globalRegistry } from "../core/registries.js";
|
|
2
|
+
import { assignProp, isPlainObject } from "../core/util.js";
|
|
3
|
+
import * as _checks from "./checks.js";
|
|
4
|
+
import * as _iso from "./iso.js";
|
|
5
|
+
import * as _schemas from "./schemas.js";
|
|
6
|
+
// Local z object to avoid circular dependency with ../index.js
|
|
7
|
+
const z = {
|
|
8
|
+
..._schemas,
|
|
9
|
+
..._checks,
|
|
10
|
+
iso: _iso,
|
|
11
|
+
};
|
|
12
|
+
// Keys that are recognized and handled by the conversion logic
|
|
13
|
+
const RECOGNIZED_KEYS = /*@__PURE__*/ new Set([
|
|
14
|
+
// Schema identification
|
|
15
|
+
"$schema",
|
|
16
|
+
"$ref",
|
|
17
|
+
"$defs",
|
|
18
|
+
"definitions",
|
|
19
|
+
// Core schema keywords
|
|
20
|
+
"$id",
|
|
21
|
+
"id",
|
|
22
|
+
"$comment",
|
|
23
|
+
"$anchor",
|
|
24
|
+
"$vocabulary",
|
|
25
|
+
"$dynamicRef",
|
|
26
|
+
"$dynamicAnchor",
|
|
27
|
+
// Type
|
|
28
|
+
"type",
|
|
29
|
+
"enum",
|
|
30
|
+
"const",
|
|
31
|
+
// Composition
|
|
32
|
+
"anyOf",
|
|
33
|
+
"oneOf",
|
|
34
|
+
"allOf",
|
|
35
|
+
"not",
|
|
36
|
+
// Object
|
|
37
|
+
"properties",
|
|
38
|
+
"required",
|
|
39
|
+
"additionalProperties",
|
|
40
|
+
"patternProperties",
|
|
41
|
+
"propertyNames",
|
|
42
|
+
"minProperties",
|
|
43
|
+
"maxProperties",
|
|
44
|
+
// Array
|
|
45
|
+
"items",
|
|
46
|
+
"prefixItems",
|
|
47
|
+
"additionalItems",
|
|
48
|
+
"minItems",
|
|
49
|
+
"maxItems",
|
|
50
|
+
"uniqueItems",
|
|
51
|
+
"contains",
|
|
52
|
+
"minContains",
|
|
53
|
+
"maxContains",
|
|
54
|
+
// String
|
|
55
|
+
"minLength",
|
|
56
|
+
"maxLength",
|
|
57
|
+
"pattern",
|
|
58
|
+
"format",
|
|
59
|
+
// Number
|
|
60
|
+
"minimum",
|
|
61
|
+
"maximum",
|
|
62
|
+
"exclusiveMinimum",
|
|
63
|
+
"exclusiveMaximum",
|
|
64
|
+
"multipleOf",
|
|
65
|
+
// Already handled metadata
|
|
66
|
+
"description",
|
|
67
|
+
"default",
|
|
68
|
+
// Content
|
|
69
|
+
"contentEncoding",
|
|
70
|
+
"contentMediaType",
|
|
71
|
+
"contentSchema",
|
|
72
|
+
// Unsupported (error-throwing)
|
|
73
|
+
"unevaluatedItems",
|
|
74
|
+
"unevaluatedProperties",
|
|
75
|
+
"if",
|
|
76
|
+
"then",
|
|
77
|
+
"else",
|
|
78
|
+
"dependentSchemas",
|
|
79
|
+
"dependentRequired",
|
|
80
|
+
// OpenAPI
|
|
81
|
+
"nullable",
|
|
82
|
+
"readOnly",
|
|
83
|
+
]);
|
|
84
|
+
function detectVersion(schema, defaultTarget) {
|
|
85
|
+
const $schema = schema.$schema;
|
|
86
|
+
if ($schema === "https://json-schema.org/draft/2020-12/schema") {
|
|
87
|
+
return "draft-2020-12";
|
|
88
|
+
}
|
|
89
|
+
if ($schema === "http://json-schema.org/draft-07/schema#") {
|
|
90
|
+
return "draft-7";
|
|
91
|
+
}
|
|
92
|
+
if ($schema === "http://json-schema.org/draft-04/schema#") {
|
|
93
|
+
return "draft-4";
|
|
94
|
+
}
|
|
95
|
+
// Use defaultTarget if provided, otherwise default to draft-2020-12
|
|
96
|
+
return defaultTarget ?? "draft-2020-12";
|
|
97
|
+
}
|
|
98
|
+
// Positional schemas constrain the elements that are present; only minItems makes them required.
|
|
99
|
+
function applyMinItems(items, minItems) {
|
|
100
|
+
return items.map((item, index) => (index < minItems ? item : item.optional()));
|
|
101
|
+
}
|
|
102
|
+
// Inverse of the encoding applied to $ref pointer segments in to-json-schema.ts. Per RFC 6901 the `~1` replacement must run before `~0`.
|
|
103
|
+
function decodeJSONPointerSegment(segment) {
|
|
104
|
+
return segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
105
|
+
}
|
|
106
|
+
function resolveRef(ref, ctx) {
|
|
107
|
+
if (!ref.startsWith("#")) {
|
|
108
|
+
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
109
|
+
}
|
|
110
|
+
const path = ref.slice(1).split("/").filter(Boolean);
|
|
111
|
+
// Handle root reference "#"
|
|
112
|
+
if (path.length === 0) {
|
|
113
|
+
return ctx.rootSchema;
|
|
114
|
+
}
|
|
115
|
+
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
116
|
+
if (path[0] === defsKey) {
|
|
117
|
+
const key = path[1] === undefined ? undefined : decodeJSONPointerSegment(path[1]);
|
|
118
|
+
if (!key || !ctx.defs[key]) {
|
|
119
|
+
throw new Error(`Reference not found: ${ref}`);
|
|
120
|
+
}
|
|
121
|
+
return ctx.defs[key];
|
|
122
|
+
}
|
|
123
|
+
throw new Error(`Reference not found: ${ref}`);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Rejects every own key that fails `keySchema`, before `objectSchema` runs. The
|
|
127
|
+
* guard has to see the raw input: an object parse drops `__proto__` and can add
|
|
128
|
+
* keys from a property `default`, so its output is not the set of names the
|
|
129
|
+
* instance actually carried.
|
|
130
|
+
*/
|
|
131
|
+
function checkPropertyNames(objectSchema, keySchema) {
|
|
132
|
+
// An identity transform, not z.any(), so `toJSONSchema` reports the object on both the input and the output side of the pipe.
|
|
133
|
+
const guard = z
|
|
134
|
+
.transform((value) => value)
|
|
135
|
+
.check((payload) => {
|
|
136
|
+
const value = payload.value;
|
|
137
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
138
|
+
return;
|
|
139
|
+
for (const key of Object.getOwnPropertyNames(value)) {
|
|
140
|
+
const result = keySchema.safeParse(key);
|
|
141
|
+
if (result.success)
|
|
142
|
+
continue;
|
|
143
|
+
payload.issues.push({
|
|
144
|
+
code: "invalid_key",
|
|
145
|
+
origin: "record",
|
|
146
|
+
issues: result.error.issues,
|
|
147
|
+
input: key,
|
|
148
|
+
path: [key],
|
|
149
|
+
continue: true,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
return guard.pipe(objectSchema);
|
|
154
|
+
}
|
|
155
|
+
function getTupleRest(restSchema, ctx) {
|
|
156
|
+
if (restSchema === false) {
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
if (restSchema === undefined || restSchema === true) {
|
|
160
|
+
return z.any();
|
|
161
|
+
}
|
|
162
|
+
return convertSchema(restSchema, ctx);
|
|
163
|
+
}
|
|
164
|
+
// the RFC 3339 full-time keyword, narrower than `z.iso.time()`; local because sharing it via `timeSource` pins that builder into every bundle (+139 B gzipped on a mini `z.boolean()`)
|
|
165
|
+
const fullTime = /^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;
|
|
166
|
+
function convertBaseSchema(schema, ctx) {
|
|
167
|
+
// Handle unsupported features
|
|
168
|
+
if (schema.not !== undefined) {
|
|
169
|
+
// Special case: { not: {} } represents never
|
|
170
|
+
if (typeof schema.not === "object" && Object.keys(schema.not).length === 0) {
|
|
171
|
+
return z.never();
|
|
172
|
+
}
|
|
173
|
+
throw new Error("not is not supported in Zod (except { not: {} } for never)");
|
|
174
|
+
}
|
|
175
|
+
if (schema.unevaluatedItems !== undefined) {
|
|
176
|
+
throw new Error("unevaluatedItems is not supported");
|
|
177
|
+
}
|
|
178
|
+
if (schema.unevaluatedProperties !== undefined) {
|
|
179
|
+
throw new Error("unevaluatedProperties is not supported");
|
|
180
|
+
}
|
|
181
|
+
if (schema.if !== undefined || schema.then !== undefined || schema.else !== undefined) {
|
|
182
|
+
throw new Error("Conditional schemas (if/then/else) are not supported");
|
|
183
|
+
}
|
|
184
|
+
if (schema.dependentSchemas !== undefined || schema.dependentRequired !== undefined) {
|
|
185
|
+
throw new Error("dependentSchemas and dependentRequired are not supported");
|
|
186
|
+
}
|
|
187
|
+
// Handle $ref
|
|
188
|
+
if (schema.$ref) {
|
|
189
|
+
const refPath = schema.$ref;
|
|
190
|
+
if (ctx.refs.has(refPath)) {
|
|
191
|
+
return ctx.refs.get(refPath);
|
|
192
|
+
}
|
|
193
|
+
if (ctx.processing.has(refPath)) {
|
|
194
|
+
// Circular reference - use lazy
|
|
195
|
+
return z.lazy(() => {
|
|
196
|
+
if (!ctx.refs.has(refPath)) {
|
|
197
|
+
throw new Error(`Circular reference not resolved: ${refPath}`);
|
|
198
|
+
}
|
|
199
|
+
return ctx.refs.get(refPath);
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
ctx.processing.add(refPath);
|
|
203
|
+
const resolved = resolveRef(refPath, ctx);
|
|
204
|
+
const zodSchema = convertSchema(resolved, ctx);
|
|
205
|
+
ctx.refs.set(refPath, zodSchema);
|
|
206
|
+
ctx.processing.delete(refPath);
|
|
207
|
+
return zodSchema;
|
|
208
|
+
}
|
|
209
|
+
// Handle enum
|
|
210
|
+
if (schema.enum !== undefined) {
|
|
211
|
+
const enumValues = schema.enum;
|
|
212
|
+
// Special case: OpenAPI 3.0 null representation { type: "string", nullable: true, enum: [null] }
|
|
213
|
+
if (ctx.version === "openapi-3.0" &&
|
|
214
|
+
schema.nullable === true &&
|
|
215
|
+
enumValues.length === 1 &&
|
|
216
|
+
enumValues[0] === null) {
|
|
217
|
+
return z.null();
|
|
218
|
+
}
|
|
219
|
+
if (enumValues.length === 0) {
|
|
220
|
+
return z.never();
|
|
221
|
+
}
|
|
222
|
+
if (enumValues.length === 1) {
|
|
223
|
+
return z.literal(enumValues[0]);
|
|
224
|
+
}
|
|
225
|
+
// Check if all values are strings
|
|
226
|
+
if (enumValues.every((v) => typeof v === "string")) {
|
|
227
|
+
return z.enum(enumValues);
|
|
228
|
+
}
|
|
229
|
+
// Mixed types - use union of literals
|
|
230
|
+
const literalSchemas = enumValues.map((v) => z.literal(v));
|
|
231
|
+
if (literalSchemas.length < 2) {
|
|
232
|
+
return literalSchemas[0];
|
|
233
|
+
}
|
|
234
|
+
return z.union([literalSchemas[0], literalSchemas[1], ...literalSchemas.slice(2)]);
|
|
235
|
+
}
|
|
236
|
+
// Handle const
|
|
237
|
+
if (schema.const !== undefined) {
|
|
238
|
+
return z.literal(schema.const);
|
|
239
|
+
}
|
|
240
|
+
// Handle type
|
|
241
|
+
const type = schema.type;
|
|
242
|
+
if (Array.isArray(type)) {
|
|
243
|
+
// Expand type array into anyOf union
|
|
244
|
+
const typeSchemas = type.map((t) => {
|
|
245
|
+
const typeSchema = { ...schema, type: t };
|
|
246
|
+
return convertBaseSchema(typeSchema, ctx);
|
|
247
|
+
});
|
|
248
|
+
if (typeSchemas.length === 0) {
|
|
249
|
+
return z.never();
|
|
250
|
+
}
|
|
251
|
+
if (typeSchemas.length === 1) {
|
|
252
|
+
return typeSchemas[0];
|
|
253
|
+
}
|
|
254
|
+
return z.union(typeSchemas);
|
|
255
|
+
}
|
|
256
|
+
if (!type) {
|
|
257
|
+
// No type specified - empty schema (any)
|
|
258
|
+
return z.any();
|
|
259
|
+
}
|
|
260
|
+
let zodSchema;
|
|
261
|
+
switch (type) {
|
|
262
|
+
case "string": {
|
|
263
|
+
let stringSchema = z.string();
|
|
264
|
+
// Apply format using .check() with Zod format functions
|
|
265
|
+
if (schema.format) {
|
|
266
|
+
const format = schema.format;
|
|
267
|
+
// Map common formats to Zod check functions
|
|
268
|
+
if (format === "email") {
|
|
269
|
+
stringSchema = stringSchema.check(z.email());
|
|
270
|
+
}
|
|
271
|
+
else if (format === "uri" || format === "uri-reference") {
|
|
272
|
+
stringSchema = stringSchema.check(z.url());
|
|
273
|
+
}
|
|
274
|
+
else if (format === "uuid" || format === "guid") {
|
|
275
|
+
stringSchema = stringSchema.check(z.uuid());
|
|
276
|
+
}
|
|
277
|
+
else if (format === "date-time") {
|
|
278
|
+
stringSchema = stringSchema.check(z.iso.datetime({ offset: true }));
|
|
279
|
+
}
|
|
280
|
+
else if (format === "date") {
|
|
281
|
+
stringSchema = stringSchema.check(z.iso.date());
|
|
282
|
+
}
|
|
283
|
+
else if (format === "time") {
|
|
284
|
+
stringSchema = stringSchema.check(z.regex(fullTime));
|
|
285
|
+
}
|
|
286
|
+
else if (format === "duration") {
|
|
287
|
+
stringSchema = stringSchema.check(z.iso.duration());
|
|
288
|
+
}
|
|
289
|
+
else if (format === "hostname") {
|
|
290
|
+
stringSchema = stringSchema.check(z.hostname());
|
|
291
|
+
}
|
|
292
|
+
else if (format === "ipv4") {
|
|
293
|
+
stringSchema = stringSchema.check(z.ipv4());
|
|
294
|
+
}
|
|
295
|
+
else if (format === "ipv6") {
|
|
296
|
+
stringSchema = stringSchema.check(z.ipv6());
|
|
297
|
+
}
|
|
298
|
+
else if (format === "mac") {
|
|
299
|
+
stringSchema = stringSchema.check(z.mac());
|
|
300
|
+
}
|
|
301
|
+
else if (format === "cidr") {
|
|
302
|
+
stringSchema = stringSchema.check(z.cidrv4());
|
|
303
|
+
}
|
|
304
|
+
else if (format === "cidr-v6") {
|
|
305
|
+
stringSchema = stringSchema.check(z.cidrv6());
|
|
306
|
+
}
|
|
307
|
+
else if (format === "base64") {
|
|
308
|
+
stringSchema = stringSchema.check(z.base64());
|
|
309
|
+
}
|
|
310
|
+
else if (format === "base64url") {
|
|
311
|
+
stringSchema = stringSchema.check(z.base64url());
|
|
312
|
+
}
|
|
313
|
+
else if (format === "e164") {
|
|
314
|
+
stringSchema = stringSchema.check(z.e164());
|
|
315
|
+
}
|
|
316
|
+
else if (format === "credit_card") {
|
|
317
|
+
stringSchema = stringSchema.check(z.creditCard());
|
|
318
|
+
}
|
|
319
|
+
else if (format === "jwt") {
|
|
320
|
+
stringSchema = stringSchema.check(z.jwt());
|
|
321
|
+
}
|
|
322
|
+
else if (format === "emoji") {
|
|
323
|
+
stringSchema = stringSchema.check(z.emoji());
|
|
324
|
+
}
|
|
325
|
+
else if (format === "nanoid") {
|
|
326
|
+
stringSchema = stringSchema.check(z.nanoid());
|
|
327
|
+
}
|
|
328
|
+
else if (format === "cuid") {
|
|
329
|
+
stringSchema = stringSchema.check(z.cuid());
|
|
330
|
+
}
|
|
331
|
+
else if (format === "cuid2") {
|
|
332
|
+
stringSchema = stringSchema.check(z.cuid2());
|
|
333
|
+
}
|
|
334
|
+
else if (format === "ulid") {
|
|
335
|
+
stringSchema = stringSchema.check(z.ulid());
|
|
336
|
+
}
|
|
337
|
+
else if (format === "xid") {
|
|
338
|
+
stringSchema = stringSchema.check(z.xid());
|
|
339
|
+
}
|
|
340
|
+
else if (format === "ksuid") {
|
|
341
|
+
stringSchema = stringSchema.check(z.ksuid());
|
|
342
|
+
}
|
|
343
|
+
// Note: json-string format is not currently supported by Zod
|
|
344
|
+
// Custom formats are ignored - keep as plain string
|
|
345
|
+
}
|
|
346
|
+
// Apply constraints
|
|
347
|
+
if (typeof schema.minLength === "number") {
|
|
348
|
+
stringSchema = stringSchema.min(schema.minLength);
|
|
349
|
+
}
|
|
350
|
+
if (typeof schema.maxLength === "number") {
|
|
351
|
+
stringSchema = stringSchema.max(schema.maxLength);
|
|
352
|
+
}
|
|
353
|
+
if (schema.pattern) {
|
|
354
|
+
// JSON Schema patterns are not implicitly anchored (match anywhere in string)
|
|
355
|
+
stringSchema = stringSchema.regex(new RegExp(schema.pattern));
|
|
356
|
+
}
|
|
357
|
+
zodSchema = stringSchema;
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
case "number":
|
|
361
|
+
case "integer": {
|
|
362
|
+
let numberSchema = type === "integer" ? z.number().int() : z.number();
|
|
363
|
+
// Apply constraints
|
|
364
|
+
// In draft-04, `exclusiveMinimum: true` makes the sibling `minimum` exclusive rather than an independent bound, so the inclusive `.min()` is skipped; emitting it too would be dominated by the exclusive check and report a second, weaker issue.
|
|
365
|
+
if (typeof schema.minimum === "number" && schema.exclusiveMinimum !== true) {
|
|
366
|
+
numberSchema = numberSchema.min(schema.minimum);
|
|
367
|
+
}
|
|
368
|
+
if (typeof schema.maximum === "number" && schema.exclusiveMaximum !== true) {
|
|
369
|
+
numberSchema = numberSchema.max(schema.maximum);
|
|
370
|
+
}
|
|
371
|
+
if (typeof schema.exclusiveMinimum === "number") {
|
|
372
|
+
numberSchema = numberSchema.gt(schema.exclusiveMinimum);
|
|
373
|
+
}
|
|
374
|
+
else if (schema.exclusiveMinimum === true && typeof schema.minimum === "number") {
|
|
375
|
+
numberSchema = numberSchema.gt(schema.minimum);
|
|
376
|
+
}
|
|
377
|
+
if (typeof schema.exclusiveMaximum === "number") {
|
|
378
|
+
numberSchema = numberSchema.lt(schema.exclusiveMaximum);
|
|
379
|
+
}
|
|
380
|
+
else if (schema.exclusiveMaximum === true && typeof schema.maximum === "number") {
|
|
381
|
+
numberSchema = numberSchema.lt(schema.maximum);
|
|
382
|
+
}
|
|
383
|
+
if (typeof schema.multipleOf === "number") {
|
|
384
|
+
numberSchema = numberSchema.multipleOf(schema.multipleOf);
|
|
385
|
+
}
|
|
386
|
+
zodSchema = numberSchema;
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
case "boolean": {
|
|
390
|
+
zodSchema = z.boolean();
|
|
391
|
+
break;
|
|
392
|
+
}
|
|
393
|
+
case "null": {
|
|
394
|
+
zodSchema = z.null();
|
|
395
|
+
break;
|
|
396
|
+
}
|
|
397
|
+
case "object": {
|
|
398
|
+
const shape = {};
|
|
399
|
+
const properties = schema.properties || {};
|
|
400
|
+
const requiredSet = new Set(schema.required || []);
|
|
401
|
+
const additionalSchema = typeof schema.additionalProperties === "object"
|
|
402
|
+
? convertSchema(schema.additionalProperties, ctx)
|
|
403
|
+
: undefined;
|
|
404
|
+
// Convert properties - mark optional ones
|
|
405
|
+
for (const [key, propSchema] of Object.entries(properties)) {
|
|
406
|
+
const propZodSchema = convertSchema(propSchema, ctx);
|
|
407
|
+
// If not in required array, make it optional. assignProp so a __proto__ key becomes an own property instead of hitting the inherited setter
|
|
408
|
+
assignProp(shape, key, requiredSet.has(key) ? propZodSchema : propZodSchema.optional());
|
|
409
|
+
}
|
|
410
|
+
// Handle patternProperties
|
|
411
|
+
if (schema.patternProperties) {
|
|
412
|
+
// patternProperties: keys matching pattern must satisfy corresponding schema. Use loose records so non-matching keys pass through
|
|
413
|
+
const patternProps = schema.patternProperties;
|
|
414
|
+
const patternKeys = Object.keys(patternProps);
|
|
415
|
+
const looseRecords = [];
|
|
416
|
+
for (const pattern of patternKeys) {
|
|
417
|
+
const patternValue = convertSchema(patternProps[pattern], ctx);
|
|
418
|
+
const keySchema = z.string().regex(new RegExp(pattern));
|
|
419
|
+
looseRecords.push(z.looseRecord(keySchema, patternValue));
|
|
420
|
+
}
|
|
421
|
+
// Build intersection: object schema + all pattern property records
|
|
422
|
+
const schemasToIntersect = [];
|
|
423
|
+
if (Object.keys(shape).length > 0) {
|
|
424
|
+
// Use passthrough so patternProperties can validate additional keys
|
|
425
|
+
schemasToIntersect.push(z.object(shape).passthrough());
|
|
426
|
+
}
|
|
427
|
+
schemasToIntersect.push(...looseRecords);
|
|
428
|
+
if (schemasToIntersect.length === 0) {
|
|
429
|
+
zodSchema = z.object({}).passthrough();
|
|
430
|
+
}
|
|
431
|
+
else if (schemasToIntersect.length === 1) {
|
|
432
|
+
zodSchema = schemasToIntersect[0];
|
|
433
|
+
}
|
|
434
|
+
else {
|
|
435
|
+
// Chain intersections: (A & B) & C & D ...
|
|
436
|
+
let result = z.intersection(schemasToIntersect[0], schemasToIntersect[1]);
|
|
437
|
+
for (let i = 2; i < schemasToIntersect.length; i++) {
|
|
438
|
+
result = z.intersection(result, schemasToIntersect[i]);
|
|
439
|
+
}
|
|
440
|
+
zodSchema = result;
|
|
441
|
+
}
|
|
442
|
+
// When additionalProperties is false, reject keys that are neither defined in properties nor matched by any patternProperty.
|
|
443
|
+
if (schema.additionalProperties === false) {
|
|
444
|
+
const propertyKeys = Object.keys(shape);
|
|
445
|
+
const patterns = patternKeys.map((p) => new RegExp(p));
|
|
446
|
+
const basePatternSchema = zodSchema;
|
|
447
|
+
zodSchema = zodSchema.check((payload) => {
|
|
448
|
+
if (!isPlainObject(payload.value))
|
|
449
|
+
return;
|
|
450
|
+
const unrecognized = [];
|
|
451
|
+
for (const key of Object.keys(payload.value)) {
|
|
452
|
+
if (propertyKeys.includes(key))
|
|
453
|
+
continue;
|
|
454
|
+
if (patterns.some((regex) => regex.test(key)))
|
|
455
|
+
continue;
|
|
456
|
+
unrecognized.push(key);
|
|
457
|
+
}
|
|
458
|
+
if (unrecognized.length) {
|
|
459
|
+
payload.issues.push({
|
|
460
|
+
code: "unrecognized_keys",
|
|
461
|
+
keys: unrecognized,
|
|
462
|
+
input: payload.value,
|
|
463
|
+
inst: basePatternSchema,
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
else {
|
|
470
|
+
// Handle additionalProperties. In JSON Schema, additionalProperties defaults to true (allow any extra properties). In Zod, objects strip unknown keys by default, so we need to handle this explicitly
|
|
471
|
+
const objectSchema = z.object(shape);
|
|
472
|
+
if (schema.additionalProperties === false) {
|
|
473
|
+
// Strict mode - no extra properties allowed
|
|
474
|
+
zodSchema = objectSchema.strict();
|
|
475
|
+
}
|
|
476
|
+
else if (additionalSchema) {
|
|
477
|
+
// Extra properties must match the specified schema
|
|
478
|
+
zodSchema = objectSchema.catchall(additionalSchema);
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
// additionalProperties is true or undefined - allow any extra properties (passthrough)
|
|
482
|
+
zodSchema = objectSchema.passthrough();
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
// propertyNames constrains key *names* only, and says nothing about which keys are required or how their values validate. Layering it on top of the result keeps properties/patternProperties/additionalProperties composing underneath. `true` allows every name, so it needs no guard.
|
|
486
|
+
if (schema.propertyNames !== undefined && schema.propertyNames !== true) {
|
|
487
|
+
// Keys are always strings, so a propertyNames subschema that omits `type` still constrains them — without this it would convert to z.any().
|
|
488
|
+
const keyJSONSchema = typeof schema.propertyNames === "object" && schema.propertyNames.type === undefined
|
|
489
|
+
? { type: "string", ...schema.propertyNames }
|
|
490
|
+
: schema.propertyNames;
|
|
491
|
+
zodSchema = checkPropertyNames(zodSchema, convertSchema(keyJSONSchema, ctx));
|
|
492
|
+
}
|
|
493
|
+
break;
|
|
494
|
+
}
|
|
495
|
+
case "array": {
|
|
496
|
+
// TODO: uniqueItems and contains/minContains/maxContains are not supported
|
|
497
|
+
// Check if this is a tuple (prefixItems or items as array)
|
|
498
|
+
const prefixItems = schema.prefixItems;
|
|
499
|
+
const items = schema.items;
|
|
500
|
+
if (prefixItems && Array.isArray(prefixItems)) {
|
|
501
|
+
// Tuple with prefixItems (draft-2020-12)
|
|
502
|
+
const minItems = typeof schema.minItems === "number" ? schema.minItems : 0;
|
|
503
|
+
const tupleItems = prefixItems.map((item) => convertSchema(item, ctx));
|
|
504
|
+
const positionalItems = applyMinItems(tupleItems, minItems);
|
|
505
|
+
const rest = !Array.isArray(items) ? getTupleRest(items, ctx) : undefined;
|
|
506
|
+
const tupleSchema = z.tuple(positionalItems);
|
|
507
|
+
zodSchema = rest ? tupleSchema.rest(rest) : tupleSchema;
|
|
508
|
+
// Apply minItems/maxItems constraints to tuples
|
|
509
|
+
if (typeof schema.minItems === "number") {
|
|
510
|
+
zodSchema = zodSchema.check(z.minLength(schema.minItems));
|
|
511
|
+
}
|
|
512
|
+
if (typeof schema.maxItems === "number") {
|
|
513
|
+
zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
else if (Array.isArray(items)) {
|
|
517
|
+
// Tuple with items array (draft-7)
|
|
518
|
+
const minItems = typeof schema.minItems === "number" ? schema.minItems : 0;
|
|
519
|
+
const tupleItems = items.map((item) => convertSchema(item, ctx));
|
|
520
|
+
const positionalItems = applyMinItems(tupleItems, minItems);
|
|
521
|
+
const rest = getTupleRest(schema.additionalItems, ctx);
|
|
522
|
+
const tupleSchema = z.tuple(positionalItems);
|
|
523
|
+
zodSchema = rest ? tupleSchema.rest(rest) : tupleSchema;
|
|
524
|
+
// Apply minItems/maxItems constraints to tuples
|
|
525
|
+
if (typeof schema.minItems === "number") {
|
|
526
|
+
zodSchema = zodSchema.check(z.minLength(schema.minItems));
|
|
527
|
+
}
|
|
528
|
+
if (typeof schema.maxItems === "number") {
|
|
529
|
+
zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
else if (items !== undefined) {
|
|
533
|
+
// Regular array
|
|
534
|
+
const element = convertSchema(items, ctx);
|
|
535
|
+
let arraySchema = z.array(element);
|
|
536
|
+
// Apply constraints
|
|
537
|
+
if (typeof schema.minItems === "number") {
|
|
538
|
+
arraySchema = arraySchema.min(schema.minItems);
|
|
539
|
+
}
|
|
540
|
+
if (typeof schema.maxItems === "number") {
|
|
541
|
+
arraySchema = arraySchema.max(schema.maxItems);
|
|
542
|
+
}
|
|
543
|
+
zodSchema = arraySchema;
|
|
544
|
+
}
|
|
545
|
+
else {
|
|
546
|
+
// No items specified - array of any
|
|
547
|
+
zodSchema = z.array(z.any());
|
|
548
|
+
}
|
|
549
|
+
break;
|
|
550
|
+
}
|
|
551
|
+
default:
|
|
552
|
+
throw new Error(`Unsupported type: ${type}`);
|
|
553
|
+
}
|
|
554
|
+
return zodSchema;
|
|
555
|
+
}
|
|
556
|
+
function convertSchema(schema, ctx) {
|
|
557
|
+
if (typeof schema === "boolean") {
|
|
558
|
+
return schema ? z.any() : z.never();
|
|
559
|
+
}
|
|
560
|
+
// Convert base schema first (ignoring composition keywords)
|
|
561
|
+
let baseSchema = convertBaseSchema(schema, ctx);
|
|
562
|
+
const hasExplicitType = schema.type || schema.enum !== undefined || schema.const !== undefined;
|
|
563
|
+
// Process composition keywords LAST (they can appear together)
|
|
564
|
+
// Handle anyOf - wrap base schema with union
|
|
565
|
+
if (schema.anyOf && Array.isArray(schema.anyOf)) {
|
|
566
|
+
const options = schema.anyOf.map((s) => convertSchema(s, ctx));
|
|
567
|
+
const anyOfUnion = z.union(options);
|
|
568
|
+
baseSchema = hasExplicitType ? z.intersection(baseSchema, anyOfUnion) : anyOfUnion;
|
|
569
|
+
}
|
|
570
|
+
// Handle oneOf - exclusive union (exactly one must match)
|
|
571
|
+
if (schema.oneOf && Array.isArray(schema.oneOf)) {
|
|
572
|
+
const options = schema.oneOf.map((s) => convertSchema(s, ctx));
|
|
573
|
+
const oneOfUnion = z.xor(options);
|
|
574
|
+
baseSchema = hasExplicitType ? z.intersection(baseSchema, oneOfUnion) : oneOfUnion;
|
|
575
|
+
}
|
|
576
|
+
// Handle allOf - wrap base schema with intersection
|
|
577
|
+
if (schema.allOf && Array.isArray(schema.allOf)) {
|
|
578
|
+
if (schema.allOf.length === 0) {
|
|
579
|
+
baseSchema = hasExplicitType ? baseSchema : z.any();
|
|
580
|
+
}
|
|
581
|
+
else {
|
|
582
|
+
let result = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0], ctx);
|
|
583
|
+
const startIdx = hasExplicitType ? 0 : 1;
|
|
584
|
+
for (let i = startIdx; i < schema.allOf.length; i++) {
|
|
585
|
+
result = z.intersection(result, convertSchema(schema.allOf[i], ctx));
|
|
586
|
+
}
|
|
587
|
+
baseSchema = result;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
// Handle nullable (OpenAPI 3.0)
|
|
591
|
+
if (schema.nullable === true && ctx.version === "openapi-3.0") {
|
|
592
|
+
baseSchema = z.nullable(baseSchema);
|
|
593
|
+
}
|
|
594
|
+
// Handle readOnly
|
|
595
|
+
if (schema.readOnly === true) {
|
|
596
|
+
baseSchema = z.readonly(baseSchema);
|
|
597
|
+
}
|
|
598
|
+
// Apply `default` so it wraps the fully-composed schema. This ensures `parse(undefined) -> default` works regardless of which branch of `convertBaseSchema` produced the inner schema (enum/const/not/typed/etc.).
|
|
599
|
+
if (schema.default !== undefined) {
|
|
600
|
+
baseSchema = baseSchema.default(schema.default);
|
|
601
|
+
}
|
|
602
|
+
// Collect non-description annotation metadata into the user-supplied registry. Description is handled separately below via `.describe()` to preserve the contract that `schema.description` reads from globalRegistry.
|
|
603
|
+
const extraMeta = {};
|
|
604
|
+
const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
|
|
605
|
+
for (const key of coreMetadataKeys) {
|
|
606
|
+
if (key in schema) {
|
|
607
|
+
extraMeta[key] = schema[key];
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
|
|
611
|
+
for (const key of contentMetadataKeys) {
|
|
612
|
+
if (key in schema) {
|
|
613
|
+
extraMeta[key] = schema[key];
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
// `propertyNames` is enforced by a key guard, which `toJSONSchema` cannot infer, so the original keyword is carried as metadata to keep the round-trip lossless. Only where it was actually applied: on any other type it is inert, and on a `$ref` the metadata would land on the target every reference shares.
|
|
617
|
+
if (schema.propertyNames !== undefined && schema.type === "object" && schema.$ref === undefined) {
|
|
618
|
+
extraMeta.propertyNames = schema.propertyNames;
|
|
619
|
+
}
|
|
620
|
+
for (const key of Object.keys(schema)) {
|
|
621
|
+
if (!RECOGNIZED_KEYS.has(key)) {
|
|
622
|
+
assignProp(extraMeta, key, schema[key]);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
if (Object.keys(extraMeta).length > 0) {
|
|
626
|
+
ctx.registry.add(baseSchema, extraMeta);
|
|
627
|
+
}
|
|
628
|
+
// Apply description last. `.describe()` clones the schema and sets `_zod.parent` on the clone, so registry lookups on the returned reference still resolve `extraMeta` via parent inheritance.
|
|
629
|
+
if (schema.description) {
|
|
630
|
+
baseSchema = baseSchema.describe(schema.description);
|
|
631
|
+
}
|
|
632
|
+
return baseSchema;
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Converts a JSON Schema to a Zod schema. This function should be considered semi-experimental. It's behavior is liable to change. */
|
|
636
|
+
export function fromJSONSchema(schema, params) {
|
|
637
|
+
// Handle boolean schemas
|
|
638
|
+
if (typeof schema === "boolean") {
|
|
639
|
+
return schema ? z.any() : z.never();
|
|
640
|
+
}
|
|
641
|
+
// Normalize input via a JSON round-trip. This guarantees the converter walks a plain, finite, JSON-valid object graph: cyclic inputs fail here, getter/Proxy-based properties are materialized into static values, and class instances collapse to plain objects.
|
|
642
|
+
let normalized;
|
|
643
|
+
try {
|
|
644
|
+
normalized = JSON.parse(JSON.stringify(schema));
|
|
645
|
+
}
|
|
646
|
+
catch {
|
|
647
|
+
throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas");
|
|
648
|
+
}
|
|
649
|
+
const version = detectVersion(normalized, params?.defaultTarget);
|
|
650
|
+
const defs = (normalized.$defs || normalized.definitions || {});
|
|
651
|
+
const ctx = {
|
|
652
|
+
version,
|
|
653
|
+
defs,
|
|
654
|
+
refs: new Map(),
|
|
655
|
+
processing: new Set(),
|
|
656
|
+
rootSchema: normalized,
|
|
657
|
+
registry: params?.registry ?? globalRegistry,
|
|
658
|
+
};
|
|
659
|
+
return convertSchema(normalized, ctx);
|
|
660
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type * as core from "../core/index.js";
|
|
2
|
+
import * as schemas from "./schemas.js";
|
|
3
|
+
export type input<T> = core.input<T>;
|
|
4
|
+
export type output<T> = core.output<T>;
|
|
5
|
+
/** Returns a copy of the schema with every pipe replaced by its input side. A codec's checks are dropped: they constrain the decoded value the input side never produces. */
|
|
6
|
+
export declare function input<T extends core.$ZodType>(schema: T): schemas.ZodType<core.input<T>, core.input<T>>;
|
|
7
|
+
/** Returns a copy of the schema with every pipe replaced by its output side, carrying over the pipe's own checks. */
|
|
8
|
+
export declare function output<T extends core.$ZodType>(schema: T): schemas.ZodType<core.output<T>, core.output<T>>;
|