@langchain/core 1.0.0-alpha.3 → 1.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -19
- package/dist/caches/base.cjs +2 -2
- package/dist/caches/base.cjs.map +1 -1
- package/dist/callbacks/base.d.ts.map +1 -1
- package/dist/document_loaders/langsmith.cjs +1 -1
- package/dist/document_loaders/langsmith.cjs.map +1 -1
- package/dist/document_loaders/langsmith.js +1 -1
- package/dist/document_loaders/langsmith.js.map +1 -1
- package/dist/embeddings.cjs.map +1 -1
- package/dist/embeddings.d.cts +6 -6
- package/dist/embeddings.d.cts.map +1 -1
- package/dist/embeddings.d.ts +6 -6
- package/dist/embeddings.d.ts.map +1 -1
- package/dist/embeddings.js.map +1 -1
- package/dist/errors/index.cjs.map +1 -1
- package/dist/errors/index.js.map +1 -1
- package/dist/indexing/base.cjs +2 -2
- package/dist/indexing/base.cjs.map +1 -1
- package/dist/indexing/base.d.cts +0 -3
- package/dist/indexing/base.d.cts.map +1 -1
- package/dist/indexing/base.d.ts +0 -3
- package/dist/indexing/base.d.ts.map +1 -1
- package/dist/indexing/base.js +2 -2
- package/dist/indexing/base.js.map +1 -1
- package/dist/language_models/base.cjs +1 -1
- package/dist/language_models/base.cjs.map +1 -1
- package/dist/language_models/base.d.cts +3 -3
- package/dist/language_models/base.d.cts.map +1 -1
- package/dist/language_models/base.d.ts +3 -3
- package/dist/language_models/base.d.ts.map +1 -1
- package/dist/language_models/base.js +1 -1
- package/dist/language_models/base.js.map +1 -1
- package/dist/language_models/chat_models.cjs.map +1 -1
- package/dist/language_models/chat_models.d.ts.map +1 -1
- package/dist/language_models/chat_models.js.map +1 -1
- package/dist/language_models/llms.cjs.map +1 -1
- package/dist/language_models/llms.js.map +1 -1
- package/dist/load/import_map.cjs +1 -5
- package/dist/load/import_map.cjs.map +1 -1
- package/dist/load/import_map.js +3 -7
- package/dist/load/import_map.js.map +1 -1
- package/dist/load/index.cjs.map +1 -1
- package/dist/load/index.js.map +1 -1
- package/dist/load/serializable.cjs.map +1 -1
- package/dist/load/serializable.d.cts +1 -3
- package/dist/load/serializable.d.cts.map +1 -1
- package/dist/load/serializable.d.ts +1 -3
- package/dist/load/serializable.d.ts.map +1 -1
- package/dist/load/serializable.js.map +1 -1
- package/dist/messages/ai.cjs +2 -2
- package/dist/messages/ai.cjs.map +1 -1
- package/dist/messages/ai.js +2 -2
- package/dist/messages/ai.js.map +1 -1
- package/dist/messages/base.cjs +5 -5
- package/dist/messages/base.cjs.map +1 -1
- package/dist/messages/base.d.cts +1 -2
- package/dist/messages/base.d.cts.map +1 -1
- package/dist/messages/base.d.ts +1 -2
- package/dist/messages/base.d.ts.map +1 -1
- package/dist/messages/base.js +5 -5
- package/dist/messages/base.js.map +1 -1
- package/dist/messages/block_translators/utils.cjs +1 -1
- package/dist/messages/block_translators/utils.cjs.map +1 -1
- package/dist/messages/block_translators/utils.js +1 -1
- package/dist/messages/block_translators/utils.js.map +1 -1
- package/dist/messages/index.cjs +1 -1
- package/dist/messages/index.js +1 -1
- package/dist/messages/modifier.cjs +4 -1
- package/dist/messages/modifier.cjs.map +1 -1
- package/dist/messages/modifier.js +4 -1
- package/dist/messages/modifier.js.map +1 -1
- package/dist/messages/tool.cjs +7 -7
- package/dist/messages/tool.cjs.map +1 -1
- package/dist/messages/tool.js +7 -7
- package/dist/messages/tool.js.map +1 -1
- package/dist/messages/transformers.cjs +2 -2
- package/dist/messages/transformers.cjs.map +1 -1
- package/dist/messages/transformers.js +2 -2
- package/dist/messages/transformers.js.map +1 -1
- package/dist/messages/utils.cjs +5 -0
- package/dist/messages/utils.cjs.map +1 -1
- package/dist/messages/utils.js +5 -0
- package/dist/messages/utils.js.map +1 -1
- package/dist/output_parsers/list.cjs +1 -1
- package/dist/output_parsers/list.cjs.map +1 -1
- package/dist/output_parsers/list.js +1 -1
- package/dist/output_parsers/list.js.map +1 -1
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts +1 -1
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts +1 -1
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs +1 -1
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs.map +1 -1
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.js +1 -1
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.js.map +1 -1
- package/dist/output_parsers/structured.cjs +2 -1
- package/dist/output_parsers/structured.cjs.map +1 -1
- package/dist/output_parsers/structured.js +2 -1
- package/dist/output_parsers/structured.js.map +1 -1
- package/dist/prompts/chat.cjs +3 -1
- package/dist/prompts/chat.cjs.map +1 -1
- package/dist/prompts/chat.d.cts +4 -12
- package/dist/prompts/chat.d.cts.map +1 -1
- package/dist/prompts/chat.d.ts +4 -12
- package/dist/prompts/chat.d.ts.map +1 -1
- package/dist/prompts/chat.js +3 -1
- package/dist/prompts/chat.js.map +1 -1
- package/dist/prompts/image.cjs.map +1 -1
- package/dist/prompts/image.d.cts +0 -2
- package/dist/prompts/image.d.cts.map +1 -1
- package/dist/prompts/image.d.ts +0 -2
- package/dist/prompts/image.d.ts.map +1 -1
- package/dist/prompts/image.js.map +1 -1
- package/dist/prompts/pipeline.cjs.map +1 -1
- package/dist/prompts/pipeline.js.map +1 -1
- package/dist/prompts/prompt.cjs.map +1 -1
- package/dist/prompts/prompt.d.cts +4 -16
- package/dist/prompts/prompt.d.cts.map +1 -1
- package/dist/prompts/prompt.d.ts +4 -16
- package/dist/prompts/prompt.d.ts.map +1 -1
- package/dist/prompts/prompt.js.map +1 -1
- package/dist/prompts/structured.cjs.map +1 -1
- package/dist/prompts/structured.js.map +1 -1
- package/dist/prompts/template.cjs +4 -2
- package/dist/prompts/template.cjs.map +1 -1
- package/dist/prompts/template.js +4 -2
- package/dist/prompts/template.js.map +1 -1
- package/dist/runnables/base.cjs +6 -6
- package/dist/runnables/base.cjs.map +1 -1
- package/dist/runnables/base.d.cts +0 -3
- package/dist/runnables/base.d.cts.map +1 -1
- package/dist/runnables/base.d.ts +0 -3
- package/dist/runnables/base.d.ts.map +1 -1
- package/dist/runnables/base.js +6 -6
- package/dist/runnables/base.js.map +1 -1
- package/dist/runnables/branch.cjs +2 -2
- package/dist/runnables/branch.cjs.map +1 -1
- package/dist/runnables/branch.js +2 -2
- package/dist/runnables/branch.js.map +1 -1
- package/dist/runnables/config.cjs.map +1 -1
- package/dist/runnables/config.js.map +1 -1
- package/dist/runnables/graph.cjs +1 -1
- package/dist/runnables/graph.cjs.map +1 -1
- package/dist/runnables/graph.js +1 -1
- package/dist/runnables/graph.js.map +1 -1
- package/dist/runnables/graph_mermaid.cjs +26 -3
- package/dist/runnables/graph_mermaid.cjs.map +1 -1
- package/dist/runnables/graph_mermaid.js +26 -3
- package/dist/runnables/graph_mermaid.js.map +1 -1
- package/dist/runnables/remote.cjs.map +1 -1
- package/dist/runnables/remote.js.map +1 -1
- package/dist/runnables/types.d.cts +0 -1
- package/dist/runnables/types.d.cts.map +1 -1
- package/dist/runnables/types.d.ts +0 -1
- package/dist/runnables/types.d.ts.map +1 -1
- package/dist/singletons/async_local_storage/context.cjs.map +1 -1
- package/dist/singletons/async_local_storage/context.d.cts +0 -1
- package/dist/singletons/async_local_storage/context.d.cts.map +1 -1
- package/dist/singletons/async_local_storage/context.d.ts +0 -1
- package/dist/singletons/async_local_storage/context.d.ts.map +1 -1
- package/dist/singletons/async_local_storage/context.js.map +1 -1
- package/dist/singletons/callbacks.cjs.map +1 -1
- package/dist/singletons/callbacks.js.map +1 -1
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.d.cts +2 -2
- package/dist/tools/index.d.cts.map +1 -1
- package/dist/tools/index.d.ts +2 -2
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/types.d.cts +5 -5
- package/dist/tools/types.d.cts.map +1 -1
- package/dist/tools/types.d.ts +5 -5
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tracers/base.cjs.map +1 -1
- package/dist/tracers/base.js.map +1 -1
- package/dist/tracers/console.cjs +1 -1
- package/dist/tracers/console.cjs.map +1 -1
- package/dist/tracers/console.js +1 -1
- package/dist/tracers/console.js.map +1 -1
- package/dist/tracers/event_stream.cjs +1 -1
- package/dist/tracers/event_stream.cjs.map +1 -1
- package/dist/tracers/event_stream.d.cts +0 -1
- package/dist/tracers/event_stream.d.cts.map +1 -1
- package/dist/tracers/event_stream.d.ts +0 -1
- package/dist/tracers/event_stream.d.ts.map +1 -1
- package/dist/tracers/event_stream.js +1 -1
- package/dist/tracers/event_stream.js.map +1 -1
- package/dist/tracers/log_stream.cjs.map +1 -1
- package/dist/tracers/log_stream.js.map +1 -1
- package/dist/tracers/tracer_langchain.cjs.map +1 -1
- package/dist/tracers/tracer_langchain.js.map +1 -1
- package/dist/utils/chunk_array.cjs.map +1 -1
- package/dist/utils/chunk_array.js.map +1 -1
- package/dist/utils/env.cjs +1 -1
- package/dist/utils/env.cjs.map +1 -1
- package/dist/utils/env.js +1 -1
- package/dist/utils/env.js.map +1 -1
- package/dist/utils/event_source_parse.cjs.map +1 -1
- package/dist/utils/event_source_parse.d.cts.map +1 -1
- package/dist/utils/event_source_parse.d.ts.map +1 -1
- package/dist/utils/event_source_parse.js.map +1 -1
- package/dist/utils/hash.cjs +3 -8
- package/dist/utils/hash.cjs.map +1 -1
- package/dist/utils/hash.d.cts +1 -2
- package/dist/utils/hash.d.cts.map +1 -1
- package/dist/utils/hash.d.ts +1 -2
- package/dist/utils/hash.d.ts.map +1 -1
- package/dist/utils/hash.js +2 -6
- package/dist/utils/hash.js.map +1 -1
- package/dist/utils/js-sha256/hash.cjs +0 -9
- package/dist/utils/js-sha256/hash.cjs.map +1 -1
- package/dist/utils/js-sha256/hash.js +1 -5
- package/dist/utils/js-sha256/hash.js.map +1 -1
- package/dist/utils/json.cjs +2 -2
- package/dist/utils/json.cjs.map +1 -1
- package/dist/utils/json.js +2 -2
- package/dist/utils/json.js.map +1 -1
- package/dist/utils/json_schema.cjs +3 -2
- package/dist/utils/json_schema.cjs.map +1 -1
- package/dist/utils/json_schema.d.cts +8 -4
- package/dist/utils/json_schema.d.cts.map +1 -1
- package/dist/utils/json_schema.d.ts +8 -4
- package/dist/utils/json_schema.d.ts.map +1 -1
- package/dist/utils/json_schema.js +2 -1
- package/dist/utils/json_schema.js.map +1 -1
- package/dist/utils/stream.cjs.map +1 -1
- package/dist/utils/stream.js.map +1 -1
- package/dist/utils/testing/index.cjs.map +1 -1
- package/dist/utils/testing/index.d.cts +4 -9
- package/dist/utils/testing/index.d.cts.map +1 -1
- package/dist/utils/testing/index.d.ts +4 -9
- package/dist/utils/testing/index.d.ts.map +1 -1
- package/dist/utils/testing/index.js.map +1 -1
- package/dist/utils/zod-to-json-schema/Options.cjs +40 -0
- package/dist/utils/zod-to-json-schema/Options.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/Options.js +37 -0
- package/dist/utils/zod-to-json-schema/Options.js.map +1 -0
- package/dist/utils/zod-to-json-schema/Refs.cjs +30 -0
- package/dist/utils/zod-to-json-schema/Refs.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/Refs.js +30 -0
- package/dist/utils/zod-to-json-schema/Refs.js.map +1 -0
- package/dist/utils/zod-to-json-schema/errorMessages.cjs +18 -0
- package/dist/utils/zod-to-json-schema/errorMessages.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/errorMessages.d.cts +11 -0
- package/dist/utils/zod-to-json-schema/errorMessages.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/errorMessages.d.ts +11 -0
- package/dist/utils/zod-to-json-schema/errorMessages.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/errorMessages.js +16 -0
- package/dist/utils/zod-to-json-schema/errorMessages.js.map +1 -0
- package/dist/utils/zod-to-json-schema/getRelativePath.cjs +11 -0
- package/dist/utils/zod-to-json-schema/getRelativePath.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/getRelativePath.js +10 -0
- package/dist/utils/zod-to-json-schema/getRelativePath.js.map +1 -0
- package/dist/utils/zod-to-json-schema/index.cjs +37 -0
- package/dist/utils/zod-to-json-schema/index.js +37 -0
- package/dist/utils/zod-to-json-schema/parseDef.cjs +57 -0
- package/dist/utils/zod-to-json-schema/parseDef.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parseDef.js +57 -0
- package/dist/utils/zod-to-json-schema/parseDef.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parseTypes.d.cts +38 -0
- package/dist/utils/zod-to-json-schema/parseTypes.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parseTypes.d.ts +38 -0
- package/dist/utils/zod-to-json-schema/parseTypes.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/any.cjs +17 -0
- package/dist/utils/zod-to-json-schema/parsers/any.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/any.d.cts +7 -0
- package/dist/utils/zod-to-json-schema/parsers/any.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/any.d.ts +7 -0
- package/dist/utils/zod-to-json-schema/parsers/any.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/any.js +17 -0
- package/dist/utils/zod-to-json-schema/parsers/any.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/array.cjs +24 -0
- package/dist/utils/zod-to-json-schema/parsers/array.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/array.d.cts +14 -0
- package/dist/utils/zod-to-json-schema/parsers/array.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/array.d.ts +15 -0
- package/dist/utils/zod-to-json-schema/parsers/array.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/array.js +23 -0
- package/dist/utils/zod-to-json-schema/parsers/array.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/bigint.cjs +36 -0
- package/dist/utils/zod-to-json-schema/parsers/bigint.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/bigint.d.cts +16 -0
- package/dist/utils/zod-to-json-schema/parsers/bigint.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/bigint.d.ts +17 -0
- package/dist/utils/zod-to-json-schema/parsers/bigint.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/bigint.js +36 -0
- package/dist/utils/zod-to-json-schema/parsers/bigint.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/boolean.cjs +9 -0
- package/dist/utils/zod-to-json-schema/parsers/boolean.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/boolean.d.cts +7 -0
- package/dist/utils/zod-to-json-schema/parsers/boolean.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/boolean.d.ts +7 -0
- package/dist/utils/zod-to-json-schema/parsers/boolean.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/boolean.js +8 -0
- package/dist/utils/zod-to-json-schema/parsers/boolean.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/branded.cjs +10 -0
- package/dist/utils/zod-to-json-schema/parsers/branded.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/branded.js +10 -0
- package/dist/utils/zod-to-json-schema/parsers/branded.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/catch.cjs +10 -0
- package/dist/utils/zod-to-json-schema/parsers/catch.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/catch.js +10 -0
- package/dist/utils/zod-to-json-schema/parsers/catch.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/date.cjs +39 -0
- package/dist/utils/zod-to-json-schema/parsers/date.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/date.d.cts +17 -0
- package/dist/utils/zod-to-json-schema/parsers/date.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/date.d.ts +17 -0
- package/dist/utils/zod-to-json-schema/parsers/date.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/date.js +39 -0
- package/dist/utils/zod-to-json-schema/parsers/date.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/default.cjs +13 -0
- package/dist/utils/zod-to-json-schema/parsers/default.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/default.js +13 -0
- package/dist/utils/zod-to-json-schema/parsers/default.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/effects.cjs +11 -0
- package/dist/utils/zod-to-json-schema/parsers/effects.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/effects.js +11 -0
- package/dist/utils/zod-to-json-schema/parsers/effects.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/enum.cjs +12 -0
- package/dist/utils/zod-to-json-schema/parsers/enum.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/enum.d.cts +8 -0
- package/dist/utils/zod-to-json-schema/parsers/enum.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/enum.d.ts +10 -0
- package/dist/utils/zod-to-json-schema/parsers/enum.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/enum.js +11 -0
- package/dist/utils/zod-to-json-schema/parsers/enum.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/intersection.cjs +47 -0
- package/dist/utils/zod-to-json-schema/parsers/intersection.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/intersection.d.cts +10 -0
- package/dist/utils/zod-to-json-schema/parsers/intersection.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/intersection.d.ts +11 -0
- package/dist/utils/zod-to-json-schema/parsers/intersection.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/intersection.js +47 -0
- package/dist/utils/zod-to-json-schema/parsers/intersection.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/literal.cjs +18 -0
- package/dist/utils/zod-to-json-schema/parsers/literal.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/literal.d.cts +11 -0
- package/dist/utils/zod-to-json-schema/parsers/literal.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/literal.d.ts +12 -0
- package/dist/utils/zod-to-json-schema/parsers/literal.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/literal.js +17 -0
- package/dist/utils/zod-to-json-schema/parsers/literal.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/map.cjs +40 -0
- package/dist/utils/zod-to-json-schema/parsers/map.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/map.d.cts +17 -0
- package/dist/utils/zod-to-json-schema/parsers/map.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/map.d.ts +17 -0
- package/dist/utils/zod-to-json-schema/parsers/map.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/map.js +40 -0
- package/dist/utils/zod-to-json-schema/parsers/map.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/nativeEnum.cjs +18 -0
- package/dist/utils/zod-to-json-schema/parsers/nativeEnum.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.cts +8 -0
- package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.ts +10 -0
- package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/nativeEnum.js +17 -0
- package/dist/utils/zod-to-json-schema/parsers/nativeEnum.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/never.cjs +13 -0
- package/dist/utils/zod-to-json-schema/parsers/never.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/never.d.cts +9 -0
- package/dist/utils/zod-to-json-schema/parsers/never.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/never.d.ts +9 -0
- package/dist/utils/zod-to-json-schema/parsers/never.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/never.js +13 -0
- package/dist/utils/zod-to-json-schema/parsers/never.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/null.cjs +12 -0
- package/dist/utils/zod-to-json-schema/parsers/null.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/null.d.cts +7 -0
- package/dist/utils/zod-to-json-schema/parsers/null.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/null.d.ts +7 -0
- package/dist/utils/zod-to-json-schema/parsers/null.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/null.js +11 -0
- package/dist/utils/zod-to-json-schema/parsers/null.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/nullable.cjs +46 -0
- package/dist/utils/zod-to-json-schema/parsers/nullable.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/nullable.d.cts +12 -0
- package/dist/utils/zod-to-json-schema/parsers/nullable.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/nullable.d.ts +13 -0
- package/dist/utils/zod-to-json-schema/parsers/nullable.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/nullable.js +46 -0
- package/dist/utils/zod-to-json-schema/parsers/nullable.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/number.cjs +37 -0
- package/dist/utils/zod-to-json-schema/parsers/number.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/number.d.cts +15 -0
- package/dist/utils/zod-to-json-schema/parsers/number.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/number.d.ts +16 -0
- package/dist/utils/zod-to-json-schema/parsers/number.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/number.js +37 -0
- package/dist/utils/zod-to-json-schema/parsers/number.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/object.cjs +64 -0
- package/dist/utils/zod-to-json-schema/parsers/object.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/object.d.cts +12 -0
- package/dist/utils/zod-to-json-schema/parsers/object.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/object.d.ts +13 -0
- package/dist/utils/zod-to-json-schema/parsers/object.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/object.js +64 -0
- package/dist/utils/zod-to-json-schema/parsers/object.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/optional.cjs +20 -0
- package/dist/utils/zod-to-json-schema/parsers/optional.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/optional.js +20 -0
- package/dist/utils/zod-to-json-schema/parsers/optional.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/pipeline.cjs +28 -0
- package/dist/utils/zod-to-json-schema/parsers/pipeline.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/pipeline.js +28 -0
- package/dist/utils/zod-to-json-schema/parsers/pipeline.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/promise.cjs +10 -0
- package/dist/utils/zod-to-json-schema/parsers/promise.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/promise.js +10 -0
- package/dist/utils/zod-to-json-schema/parsers/promise.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/readonly.cjs +10 -0
- package/dist/utils/zod-to-json-schema/parsers/readonly.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/readonly.js +10 -0
- package/dist/utils/zod-to-json-schema/parsers/readonly.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/record.cjs +57 -0
- package/dist/utils/zod-to-json-schema/parsers/record.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/record.d.cts +14 -0
- package/dist/utils/zod-to-json-schema/parsers/record.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/record.d.ts +15 -0
- package/dist/utils/zod-to-json-schema/parsers/record.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/record.js +56 -0
- package/dist/utils/zod-to-json-schema/parsers/record.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/set.cjs +22 -0
- package/dist/utils/zod-to-json-schema/parsers/set.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/set.d.cts +15 -0
- package/dist/utils/zod-to-json-schema/parsers/set.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/set.d.ts +16 -0
- package/dist/utils/zod-to-json-schema/parsers/set.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/set.js +22 -0
- package/dist/utils/zod-to-json-schema/parsers/set.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/string.cjs +255 -0
- package/dist/utils/zod-to-json-schema/parsers/string.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/string.d.cts +28 -0
- package/dist/utils/zod-to-json-schema/parsers/string.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/string.d.ts +29 -0
- package/dist/utils/zod-to-json-schema/parsers/string.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/string.js +254 -0
- package/dist/utils/zod-to-json-schema/parsers/string.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/tuple.cjs +38 -0
- package/dist/utils/zod-to-json-schema/parsers/tuple.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/tuple.d.cts +15 -0
- package/dist/utils/zod-to-json-schema/parsers/tuple.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/tuple.d.ts +16 -0
- package/dist/utils/zod-to-json-schema/parsers/tuple.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/tuple.js +38 -0
- package/dist/utils/zod-to-json-schema/parsers/tuple.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/undefined.cjs +10 -0
- package/dist/utils/zod-to-json-schema/parsers/undefined.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/undefined.d.cts +9 -0
- package/dist/utils/zod-to-json-schema/parsers/undefined.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/undefined.d.ts +9 -0
- package/dist/utils/zod-to-json-schema/parsers/undefined.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/undefined.js +10 -0
- package/dist/utils/zod-to-json-schema/parsers/undefined.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/union.cjs +67 -0
- package/dist/utils/zod-to-json-schema/parsers/union.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/union.d.cts +24 -0
- package/dist/utils/zod-to-json-schema/parsers/union.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/union.d.ts +25 -0
- package/dist/utils/zod-to-json-schema/parsers/union.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/union.js +66 -0
- package/dist/utils/zod-to-json-schema/parsers/union.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/unknown.cjs +10 -0
- package/dist/utils/zod-to-json-schema/parsers/unknown.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/unknown.d.cts +7 -0
- package/dist/utils/zod-to-json-schema/parsers/unknown.d.cts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/unknown.d.ts +7 -0
- package/dist/utils/zod-to-json-schema/parsers/unknown.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/unknown.js +10 -0
- package/dist/utils/zod-to-json-schema/parsers/unknown.js.map +1 -0
- package/dist/utils/zod-to-json-schema/selectParser.cjs +81 -0
- package/dist/utils/zod-to-json-schema/selectParser.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/selectParser.js +80 -0
- package/dist/utils/zod-to-json-schema/selectParser.js.map +1 -0
- package/dist/utils/zod-to-json-schema/zodToJsonSchema.cjs +70 -0
- package/dist/utils/zod-to-json-schema/zodToJsonSchema.cjs.map +1 -0
- package/dist/utils/zod-to-json-schema/zodToJsonSchema.js +70 -0
- package/dist/utils/zod-to-json-schema/zodToJsonSchema.js.map +1 -0
- package/package.json +7 -36
- package/dist/utils/js-sha1/hash.cjs +0 -291
- package/dist/utils/js-sha1/hash.cjs.map +0 -1
- package/dist/utils/js-sha1/hash.d.cts +0 -9
- package/dist/utils/js-sha1/hash.d.cts.map +0 -1
- package/dist/utils/js-sha1/hash.d.ts +0 -9
- package/dist/utils/js-sha1/hash.d.ts.map +0 -1
- package/dist/utils/js-sha1/hash.js +0 -284
- package/dist/utils/js-sha1/hash.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"null.d.cts","names":["Refs","JsonSchema7NullType","parseNullDef"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/null.d.ts"],"sourcesContent":["import { Refs } from \"../Refs.js\";\nexport type JsonSchema7NullType = {\n type: \"null\";\n};\nexport declare function parseNullDef(refs: Refs): JsonSchema7NullType;\n"],"mappings":";AACYC,KAAAA,mBAAAA,GAAmB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"null.d.ts","names":["Refs","JsonSchema7NullType","parseNullDef"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/null.d.ts"],"sourcesContent":["import { Refs } from \"../Refs.js\";\nexport type JsonSchema7NullType = {\n type: \"null\";\n};\nexport declare function parseNullDef(refs: Refs): JsonSchema7NullType;\n"],"mappings":";AACYC,KAAAA,mBAAAA,GAAmB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/utils/zod-to-json-schema/parsers/null.ts
|
|
2
|
+
function parseNullDef(refs) {
|
|
3
|
+
return refs.target === "openApi3" ? {
|
|
4
|
+
enum: ["null"],
|
|
5
|
+
nullable: true
|
|
6
|
+
} : { type: "null" };
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { parseNullDef };
|
|
11
|
+
//# sourceMappingURL=null.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"null.js","names":["refs: Refs"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/null.ts"],"sourcesContent":["import { Refs } from \"../Refs.js\";\n\nexport type JsonSchema7NullType = {\n type: \"null\";\n};\n\nexport function parseNullDef(refs: Refs): JsonSchema7NullType {\n return refs.target === \"openApi3\"\n ? ({\n enum: [\"null\"],\n nullable: true,\n } as any)\n : {\n type: \"null\",\n };\n}\n"],"mappings":";AAMA,SAAgB,aAAaA,MAAiC;AAC5D,QAAO,KAAK,WAAW,aAClB;EACC,MAAM,CAAC,MAAO;EACd,UAAU;CACX,IACD,EACE,MAAM,OACP;AACN"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const require_union = require('./union.cjs');
|
|
2
|
+
const require_parseDef = require('../parseDef.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/utils/zod-to-json-schema/parsers/nullable.ts
|
|
5
|
+
function parseNullableDef(def, refs) {
|
|
6
|
+
if ([
|
|
7
|
+
"ZodString",
|
|
8
|
+
"ZodNumber",
|
|
9
|
+
"ZodBigInt",
|
|
10
|
+
"ZodBoolean",
|
|
11
|
+
"ZodNull"
|
|
12
|
+
].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
|
|
13
|
+
if (refs.target === "openApi3") return {
|
|
14
|
+
type: require_union.primitiveMappings[def.innerType._def.typeName],
|
|
15
|
+
nullable: true
|
|
16
|
+
};
|
|
17
|
+
return { type: [require_union.primitiveMappings[def.innerType._def.typeName], "null"] };
|
|
18
|
+
}
|
|
19
|
+
if (refs.target === "openApi3") {
|
|
20
|
+
const base$1 = require_parseDef.parseDef(def.innerType._def, {
|
|
21
|
+
...refs,
|
|
22
|
+
currentPath: [...refs.currentPath]
|
|
23
|
+
});
|
|
24
|
+
if (base$1 && "$ref" in base$1) return {
|
|
25
|
+
allOf: [base$1],
|
|
26
|
+
nullable: true
|
|
27
|
+
};
|
|
28
|
+
return base$1 && {
|
|
29
|
+
...base$1,
|
|
30
|
+
nullable: true
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const base = require_parseDef.parseDef(def.innerType._def, {
|
|
34
|
+
...refs,
|
|
35
|
+
currentPath: [
|
|
36
|
+
...refs.currentPath,
|
|
37
|
+
"anyOf",
|
|
38
|
+
"0"
|
|
39
|
+
]
|
|
40
|
+
});
|
|
41
|
+
return base && { anyOf: [base, { type: "null" }] };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
exports.parseNullableDef = parseNullableDef;
|
|
46
|
+
//# sourceMappingURL=nullable.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nullable.cjs","names":["def: ZodNullableDef","refs: Refs","primitiveMappings","base","parseDef"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/nullable.ts"],"sourcesContent":["import { ZodNullableDef } from \"zod/v3\";\nimport { parseDef } from \"../parseDef.js\";\nimport { JsonSchema7Type } from \"../parseTypes.js\";\nimport { Refs } from \"../Refs.js\";\nimport { JsonSchema7NullType } from \"./null.js\";\nimport { primitiveMappings } from \"./union.js\";\n\nexport type JsonSchema7NullableType =\n | {\n anyOf: [JsonSchema7Type, JsonSchema7NullType];\n }\n | {\n type: [string, \"null\"];\n };\n\nexport function parseNullableDef(\n def: ZodNullableDef,\n refs: Refs\n): JsonSchema7NullableType | undefined {\n if (\n [\"ZodString\", \"ZodNumber\", \"ZodBigInt\", \"ZodBoolean\", \"ZodNull\"].includes(\n def.innerType._def.typeName\n ) &&\n (!def.innerType._def.checks || !def.innerType._def.checks.length)\n ) {\n if (refs.target === \"openApi3\") {\n return {\n type: primitiveMappings[\n def.innerType._def.typeName as keyof typeof primitiveMappings\n ],\n nullable: true,\n } as any;\n }\n\n return {\n type: [\n primitiveMappings[\n def.innerType._def.typeName as keyof typeof primitiveMappings\n ],\n \"null\",\n ],\n };\n }\n\n if (refs.target === \"openApi3\") {\n const base = parseDef(def.innerType._def, {\n ...refs,\n currentPath: [...refs.currentPath],\n });\n\n if (base && \"$ref\" in base) return { allOf: [base], nullable: true } as any;\n\n return base && ({ ...base, nullable: true } as any);\n }\n\n const base = parseDef(def.innerType._def, {\n ...refs,\n currentPath: [...refs.currentPath, \"anyOf\", \"0\"],\n });\n\n return base && { anyOf: [base, { type: \"null\" }] };\n}\n"],"mappings":";;;;AAeA,SAAgB,iBACdA,KACAC,MACqC;AACrC,KACE;EAAC;EAAa;EAAa;EAAa;EAAc;CAAU,EAAC,SAC/D,IAAI,UAAU,KAAK,SACpB,KACA,CAAC,IAAI,UAAU,KAAK,UAAU,CAAC,IAAI,UAAU,KAAK,OAAO,SAC1D;AACA,MAAI,KAAK,WAAW,WAClB,QAAO;GACL,MAAMC,gCACJ,IAAI,UAAU,KAAK;GAErB,UAAU;EACX;AAGH,SAAO,EACL,MAAM,CACJA,gCACE,IAAI,UAAU,KAAK,WAErB,MACD,EACF;CACF;AAED,KAAI,KAAK,WAAW,YAAY;EAC9B,MAAMC,SAAOC,0BAAS,IAAI,UAAU,MAAM;GACxC,GAAG;GACH,aAAa,CAAC,GAAG,KAAK,WAAY;EACnC,EAAC;AAEF,MAAID,UAAQ,UAAUA,OAAM,QAAO;GAAE,OAAO,CAACA,MAAK;GAAE,UAAU;EAAM;AAEpE,SAAOA,UAAS;GAAE,GAAGA;GAAM,UAAU;EAAM;CAC5C;CAED,MAAM,OAAOC,0BAAS,IAAI,UAAU,MAAM;EACxC,GAAG;EACH,aAAa;GAAC,GAAG,KAAK;GAAa;GAAS;EAAI;CACjD,EAAC;AAEF,QAAO,QAAQ,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,OAAQ,CAAC,EAAE;AACnD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { JsonSchema7NullType } from "./null.cjs";
|
|
2
|
+
import { JsonSchema7Type } from "../parseTypes.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/zod-to-json-schema/parsers/nullable.d.ts
|
|
5
|
+
type JsonSchema7NullableType = {
|
|
6
|
+
anyOf: [JsonSchema7Type, JsonSchema7NullType];
|
|
7
|
+
} | {
|
|
8
|
+
type: [string, "null"];
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { JsonSchema7NullableType };
|
|
12
|
+
//# sourceMappingURL=nullable.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nullable.d.cts","names":["ZodNullableDef","JsonSchema7Type","Refs","JsonSchema7NullType","JsonSchema7NullableType","parseNullableDef"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/nullable.d.ts"],"sourcesContent":["import { ZodNullableDef } from \"zod/v3\";\nimport { JsonSchema7Type } from \"../parseTypes.js\";\nimport { Refs } from \"../Refs.js\";\nimport { JsonSchema7NullType } from \"./null.js\";\nexport type JsonSchema7NullableType = {\n anyOf: [JsonSchema7Type, JsonSchema7NullType];\n} | {\n type: [string, \"null\"];\n};\nexport declare function parseNullableDef(def: ZodNullableDef, refs: Refs): JsonSchema7NullableType | undefined;\n"],"mappings":";;;;AAIYI,KAAAA,uBAAAA,GAAuB;EAAA,KAAA,EAAA,CACvBH,eADuB,EACNE,mBADM,CAAA;CAAA,GAAA;EACR,IAAEA,EAAAA,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA;AAAmB,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { JsonSchema7NullType } from "./null.js";
|
|
2
|
+
import { JsonSchema7Type } from "../parseTypes.js";
|
|
3
|
+
import "zod/v3";
|
|
4
|
+
|
|
5
|
+
//#region src/utils/zod-to-json-schema/parsers/nullable.d.ts
|
|
6
|
+
type JsonSchema7NullableType = {
|
|
7
|
+
anyOf: [JsonSchema7Type, JsonSchema7NullType];
|
|
8
|
+
} | {
|
|
9
|
+
type: [string, "null"];
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { JsonSchema7NullableType };
|
|
13
|
+
//# sourceMappingURL=nullable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nullable.d.ts","names":["ZodNullableDef","JsonSchema7Type","Refs","JsonSchema7NullType","JsonSchema7NullableType","parseNullableDef"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/nullable.d.ts"],"sourcesContent":["import { ZodNullableDef } from \"zod/v3\";\nimport { JsonSchema7Type } from \"../parseTypes.js\";\nimport { Refs } from \"../Refs.js\";\nimport { JsonSchema7NullType } from \"./null.js\";\nexport type JsonSchema7NullableType = {\n anyOf: [JsonSchema7Type, JsonSchema7NullType];\n} | {\n type: [string, \"null\"];\n};\nexport declare function parseNullableDef(def: ZodNullableDef, refs: Refs): JsonSchema7NullableType | undefined;\n"],"mappings":";;;;;KAIYI,uBAAAA;EAAAA,KAAAA,EAAAA,CACAH,eADAG,EACiBD,mBADM,CAAA;CAAA,GAAA;EAAA,IACvBF,EAAAA,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA;CAAe"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { primitiveMappings } from "./union.js";
|
|
2
|
+
import { parseDef } from "../parseDef.js";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/zod-to-json-schema/parsers/nullable.ts
|
|
5
|
+
function parseNullableDef(def, refs) {
|
|
6
|
+
if ([
|
|
7
|
+
"ZodString",
|
|
8
|
+
"ZodNumber",
|
|
9
|
+
"ZodBigInt",
|
|
10
|
+
"ZodBoolean",
|
|
11
|
+
"ZodNull"
|
|
12
|
+
].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
|
|
13
|
+
if (refs.target === "openApi3") return {
|
|
14
|
+
type: primitiveMappings[def.innerType._def.typeName],
|
|
15
|
+
nullable: true
|
|
16
|
+
};
|
|
17
|
+
return { type: [primitiveMappings[def.innerType._def.typeName], "null"] };
|
|
18
|
+
}
|
|
19
|
+
if (refs.target === "openApi3") {
|
|
20
|
+
const base$1 = parseDef(def.innerType._def, {
|
|
21
|
+
...refs,
|
|
22
|
+
currentPath: [...refs.currentPath]
|
|
23
|
+
});
|
|
24
|
+
if (base$1 && "$ref" in base$1) return {
|
|
25
|
+
allOf: [base$1],
|
|
26
|
+
nullable: true
|
|
27
|
+
};
|
|
28
|
+
return base$1 && {
|
|
29
|
+
...base$1,
|
|
30
|
+
nullable: true
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const base = parseDef(def.innerType._def, {
|
|
34
|
+
...refs,
|
|
35
|
+
currentPath: [
|
|
36
|
+
...refs.currentPath,
|
|
37
|
+
"anyOf",
|
|
38
|
+
"0"
|
|
39
|
+
]
|
|
40
|
+
});
|
|
41
|
+
return base && { anyOf: [base, { type: "null" }] };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { parseNullableDef };
|
|
46
|
+
//# sourceMappingURL=nullable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nullable.js","names":["def: ZodNullableDef","refs: Refs","base"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/nullable.ts"],"sourcesContent":["import { ZodNullableDef } from \"zod/v3\";\nimport { parseDef } from \"../parseDef.js\";\nimport { JsonSchema7Type } from \"../parseTypes.js\";\nimport { Refs } from \"../Refs.js\";\nimport { JsonSchema7NullType } from \"./null.js\";\nimport { primitiveMappings } from \"./union.js\";\n\nexport type JsonSchema7NullableType =\n | {\n anyOf: [JsonSchema7Type, JsonSchema7NullType];\n }\n | {\n type: [string, \"null\"];\n };\n\nexport function parseNullableDef(\n def: ZodNullableDef,\n refs: Refs\n): JsonSchema7NullableType | undefined {\n if (\n [\"ZodString\", \"ZodNumber\", \"ZodBigInt\", \"ZodBoolean\", \"ZodNull\"].includes(\n def.innerType._def.typeName\n ) &&\n (!def.innerType._def.checks || !def.innerType._def.checks.length)\n ) {\n if (refs.target === \"openApi3\") {\n return {\n type: primitiveMappings[\n def.innerType._def.typeName as keyof typeof primitiveMappings\n ],\n nullable: true,\n } as any;\n }\n\n return {\n type: [\n primitiveMappings[\n def.innerType._def.typeName as keyof typeof primitiveMappings\n ],\n \"null\",\n ],\n };\n }\n\n if (refs.target === \"openApi3\") {\n const base = parseDef(def.innerType._def, {\n ...refs,\n currentPath: [...refs.currentPath],\n });\n\n if (base && \"$ref\" in base) return { allOf: [base], nullable: true } as any;\n\n return base && ({ ...base, nullable: true } as any);\n }\n\n const base = parseDef(def.innerType._def, {\n ...refs,\n currentPath: [...refs.currentPath, \"anyOf\", \"0\"],\n });\n\n return base && { anyOf: [base, { type: \"null\" }] };\n}\n"],"mappings":";;;;AAeA,SAAgB,iBACdA,KACAC,MACqC;AACrC,KACE;EAAC;EAAa;EAAa;EAAa;EAAc;CAAU,EAAC,SAC/D,IAAI,UAAU,KAAK,SACpB,KACA,CAAC,IAAI,UAAU,KAAK,UAAU,CAAC,IAAI,UAAU,KAAK,OAAO,SAC1D;AACA,MAAI,KAAK,WAAW,WAClB,QAAO;GACL,MAAM,kBACJ,IAAI,UAAU,KAAK;GAErB,UAAU;EACX;AAGH,SAAO,EACL,MAAM,CACJ,kBACE,IAAI,UAAU,KAAK,WAErB,MACD,EACF;CACF;AAED,KAAI,KAAK,WAAW,YAAY;EAC9B,MAAMC,SAAO,SAAS,IAAI,UAAU,MAAM;GACxC,GAAG;GACH,aAAa,CAAC,GAAG,KAAK,WAAY;EACnC,EAAC;AAEF,MAAIA,UAAQ,UAAUA,OAAM,QAAO;GAAE,OAAO,CAACA,MAAK;GAAE,UAAU;EAAM;AAEpE,SAAOA,UAAS;GAAE,GAAGA;GAAM,UAAU;EAAM;CAC5C;CAED,MAAM,OAAO,SAAS,IAAI,UAAU,MAAM;EACxC,GAAG;EACH,aAAa;GAAC,GAAG,KAAK;GAAa;GAAS;EAAI;CACjD,EAAC;AAEF,QAAO,QAAQ,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,OAAQ,CAAC,EAAE;AACnD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const require_errorMessages = require('../errorMessages.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/utils/zod-to-json-schema/parsers/number.ts
|
|
4
|
+
function parseNumberDef(def, refs) {
|
|
5
|
+
const res = { type: "number" };
|
|
6
|
+
if (!def.checks) return res;
|
|
7
|
+
for (const check of def.checks) switch (check.kind) {
|
|
8
|
+
case "int":
|
|
9
|
+
res.type = "integer";
|
|
10
|
+
require_errorMessages.addErrorMessage(res, "type", check.message, refs);
|
|
11
|
+
break;
|
|
12
|
+
case "min":
|
|
13
|
+
if (refs.target === "jsonSchema7") if (check.inclusive) require_errorMessages.setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
14
|
+
else require_errorMessages.setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
|
|
15
|
+
else {
|
|
16
|
+
if (!check.inclusive) res.exclusiveMinimum = true;
|
|
17
|
+
require_errorMessages.setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
18
|
+
}
|
|
19
|
+
break;
|
|
20
|
+
case "max":
|
|
21
|
+
if (refs.target === "jsonSchema7") if (check.inclusive) require_errorMessages.setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
22
|
+
else require_errorMessages.setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
|
|
23
|
+
else {
|
|
24
|
+
if (!check.inclusive) res.exclusiveMaximum = true;
|
|
25
|
+
require_errorMessages.setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
26
|
+
}
|
|
27
|
+
break;
|
|
28
|
+
case "multipleOf":
|
|
29
|
+
require_errorMessages.setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
return res;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
exports.parseNumberDef = parseNumberDef;
|
|
37
|
+
//# sourceMappingURL=number.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number.cjs","names":["def: ZodNumberDef","refs: Refs","res: JsonSchema7NumberType","addErrorMessage","setResponseValueAndErrors"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/number.ts"],"sourcesContent":["import { ZodNumberDef } from \"zod/v3\";\nimport {\n addErrorMessage,\n ErrorMessages,\n setResponseValueAndErrors,\n} from \"../errorMessages.js\";\nimport { Refs } from \"../Refs.js\";\n\nexport type JsonSchema7NumberType = {\n type: \"number\" | \"integer\";\n minimum?: number;\n exclusiveMinimum?: number;\n maximum?: number;\n exclusiveMaximum?: number;\n multipleOf?: number;\n errorMessage?: ErrorMessages<JsonSchema7NumberType>;\n};\n\nexport function parseNumberDef(\n def: ZodNumberDef,\n refs: Refs\n): JsonSchema7NumberType {\n const res: JsonSchema7NumberType = {\n type: \"number\",\n };\n\n if (!def.checks) return res;\n\n for (const check of def.checks) {\n switch (check.kind) {\n case \"int\":\n res.type = \"integer\";\n addErrorMessage(res, \"type\", check.message, refs);\n break;\n case \"min\":\n if (refs.target === \"jsonSchema7\") {\n if (check.inclusive) {\n setResponseValueAndErrors(\n res,\n \"minimum\",\n check.value,\n check.message,\n refs\n );\n } else {\n setResponseValueAndErrors(\n res,\n \"exclusiveMinimum\",\n check.value,\n check.message,\n refs\n );\n }\n } else {\n if (!check.inclusive) {\n res.exclusiveMinimum = true as any;\n }\n setResponseValueAndErrors(\n res,\n \"minimum\",\n check.value,\n check.message,\n refs\n );\n }\n break;\n case \"max\":\n if (refs.target === \"jsonSchema7\") {\n if (check.inclusive) {\n setResponseValueAndErrors(\n res,\n \"maximum\",\n check.value,\n check.message,\n refs\n );\n } else {\n setResponseValueAndErrors(\n res,\n \"exclusiveMaximum\",\n check.value,\n check.message,\n refs\n );\n }\n } else {\n if (!check.inclusive) {\n res.exclusiveMaximum = true as any;\n }\n setResponseValueAndErrors(\n res,\n \"maximum\",\n check.value,\n check.message,\n refs\n );\n }\n break;\n case \"multipleOf\":\n setResponseValueAndErrors(\n res,\n \"multipleOf\",\n check.value,\n check.message,\n refs\n );\n break;\n }\n }\n return res;\n}\n"],"mappings":";;;AAkBA,SAAgB,eACdA,KACAC,MACuB;CACvB,MAAMC,MAA6B,EACjC,MAAM,SACP;AAED,KAAI,CAAC,IAAI,OAAQ,QAAO;AAExB,MAAK,MAAM,SAAS,IAAI,OACtB,SAAQ,MAAM,MAAd;EACE,KAAK;GACH,IAAI,OAAO;GACXC,sCAAgB,KAAK,QAAQ,MAAM,SAAS,KAAK;AACjD;EACF,KAAK;AACH,OAAI,KAAK,WAAW,cAClB,KAAI,MAAM,WACRC,gDACE,KACA,WACA,MAAM,OACN,MAAM,SACN,KACD;QAEDA,gDACE,KACA,oBACA,MAAM,OACN,MAAM,SACN,KACD;QAEE;AACL,QAAI,CAAC,MAAM,WACT,IAAI,mBAAmB;IAEzBA,gDACE,KACA,WACA,MAAM,OACN,MAAM,SACN,KACD;GACF;AACD;EACF,KAAK;AACH,OAAI,KAAK,WAAW,cAClB,KAAI,MAAM,WACRA,gDACE,KACA,WACA,MAAM,OACN,MAAM,SACN,KACD;QAEDA,gDACE,KACA,oBACA,MAAM,OACN,MAAM,SACN,KACD;QAEE;AACL,QAAI,CAAC,MAAM,WACT,IAAI,mBAAmB;IAEzBA,gDACE,KACA,WACA,MAAM,OACN,MAAM,SACN,KACD;GACF;AACD;EACF,KAAK;GACHA,gDACE,KACA,cACA,MAAM,OACN,MAAM,SACN,KACD;AACD;CACH;AAEH,QAAO;AACR"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ErrorMessages } from "../errorMessages.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/zod-to-json-schema/parsers/number.d.ts
|
|
4
|
+
type JsonSchema7NumberType = {
|
|
5
|
+
type: "number" | "integer";
|
|
6
|
+
minimum?: number;
|
|
7
|
+
exclusiveMinimum?: number;
|
|
8
|
+
maximum?: number;
|
|
9
|
+
exclusiveMaximum?: number;
|
|
10
|
+
multipleOf?: number;
|
|
11
|
+
errorMessage?: ErrorMessages<JsonSchema7NumberType>;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { JsonSchema7NumberType };
|
|
15
|
+
//# sourceMappingURL=number.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number.d.cts","names":["ZodNumberDef","ErrorMessages","Refs","JsonSchema7NumberType","parseNumberDef"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/number.d.ts"],"sourcesContent":["import { ZodNumberDef } from \"zod/v3\";\nimport { ErrorMessages } from \"../errorMessages.js\";\nimport { Refs } from \"../Refs.js\";\nexport type JsonSchema7NumberType = {\n type: \"number\" | \"integer\";\n minimum?: number;\n exclusiveMinimum?: number;\n maximum?: number;\n exclusiveMaximum?: number;\n multipleOf?: number;\n errorMessage?: ErrorMessages<JsonSchema7NumberType>;\n};\nexport declare function parseNumberDef(def: ZodNumberDef, refs: Refs): JsonSchema7NumberType;\n"],"mappings":";;;AAGYG,KAAAA,qBAAAA,GAAqB;EAAA,IAAA,EAAA,QAAA,GAAA,SAAA;EAAA,OAOAA,CAAAA,EAAAA,MAAAA;EAAqB,gBAAnCF,CAAAA,EAAAA,MAAAA;EAAa,OAAA,CAAA,EAAA,MAAA;;;iBAAbA,cAAcE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ErrorMessages } from "../errorMessages.js";
|
|
2
|
+
import "zod/v3";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/zod-to-json-schema/parsers/number.d.ts
|
|
5
|
+
type JsonSchema7NumberType = {
|
|
6
|
+
type: "number" | "integer";
|
|
7
|
+
minimum?: number;
|
|
8
|
+
exclusiveMinimum?: number;
|
|
9
|
+
maximum?: number;
|
|
10
|
+
exclusiveMaximum?: number;
|
|
11
|
+
multipleOf?: number;
|
|
12
|
+
errorMessage?: ErrorMessages<JsonSchema7NumberType>;
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { JsonSchema7NumberType };
|
|
16
|
+
//# sourceMappingURL=number.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number.d.ts","names":["ZodNumberDef","ErrorMessages","Refs","JsonSchema7NumberType","parseNumberDef"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/number.d.ts"],"sourcesContent":["import { ZodNumberDef } from \"zod/v3\";\nimport { ErrorMessages } from \"../errorMessages.js\";\nimport { Refs } from \"../Refs.js\";\nexport type JsonSchema7NumberType = {\n type: \"number\" | \"integer\";\n minimum?: number;\n exclusiveMinimum?: number;\n maximum?: number;\n exclusiveMaximum?: number;\n multipleOf?: number;\n errorMessage?: ErrorMessages<JsonSchema7NumberType>;\n};\nexport declare function parseNumberDef(def: ZodNumberDef, refs: Refs): JsonSchema7NumberType;\n"],"mappings":";;;;KAGYG,qBAAAA;EAAAA,IAAAA,EAAAA,QAAAA,GAAAA,SAAqB;EAAA,OAAA,CAAA,EAAA,MAAA;EAAA,gBAOAA,CAAAA,EAAAA,MAAAA;EAAqB,OAAnCF,CAAAA,EAAAA,MAAAA;EAAa,gBAAA,CAAA,EAAA,MAAA;;iBAAbA,cAAcE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { addErrorMessage, setResponseValueAndErrors } from "../errorMessages.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/zod-to-json-schema/parsers/number.ts
|
|
4
|
+
function parseNumberDef(def, refs) {
|
|
5
|
+
const res = { type: "number" };
|
|
6
|
+
if (!def.checks) return res;
|
|
7
|
+
for (const check of def.checks) switch (check.kind) {
|
|
8
|
+
case "int":
|
|
9
|
+
res.type = "integer";
|
|
10
|
+
addErrorMessage(res, "type", check.message, refs);
|
|
11
|
+
break;
|
|
12
|
+
case "min":
|
|
13
|
+
if (refs.target === "jsonSchema7") if (check.inclusive) setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
14
|
+
else setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
|
|
15
|
+
else {
|
|
16
|
+
if (!check.inclusive) res.exclusiveMinimum = true;
|
|
17
|
+
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
18
|
+
}
|
|
19
|
+
break;
|
|
20
|
+
case "max":
|
|
21
|
+
if (refs.target === "jsonSchema7") if (check.inclusive) setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
22
|
+
else setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
|
|
23
|
+
else {
|
|
24
|
+
if (!check.inclusive) res.exclusiveMaximum = true;
|
|
25
|
+
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
26
|
+
}
|
|
27
|
+
break;
|
|
28
|
+
case "multipleOf":
|
|
29
|
+
setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
return res;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { parseNumberDef };
|
|
37
|
+
//# sourceMappingURL=number.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number.js","names":["def: ZodNumberDef","refs: Refs","res: JsonSchema7NumberType"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/number.ts"],"sourcesContent":["import { ZodNumberDef } from \"zod/v3\";\nimport {\n addErrorMessage,\n ErrorMessages,\n setResponseValueAndErrors,\n} from \"../errorMessages.js\";\nimport { Refs } from \"../Refs.js\";\n\nexport type JsonSchema7NumberType = {\n type: \"number\" | \"integer\";\n minimum?: number;\n exclusiveMinimum?: number;\n maximum?: number;\n exclusiveMaximum?: number;\n multipleOf?: number;\n errorMessage?: ErrorMessages<JsonSchema7NumberType>;\n};\n\nexport function parseNumberDef(\n def: ZodNumberDef,\n refs: Refs\n): JsonSchema7NumberType {\n const res: JsonSchema7NumberType = {\n type: \"number\",\n };\n\n if (!def.checks) return res;\n\n for (const check of def.checks) {\n switch (check.kind) {\n case \"int\":\n res.type = \"integer\";\n addErrorMessage(res, \"type\", check.message, refs);\n break;\n case \"min\":\n if (refs.target === \"jsonSchema7\") {\n if (check.inclusive) {\n setResponseValueAndErrors(\n res,\n \"minimum\",\n check.value,\n check.message,\n refs\n );\n } else {\n setResponseValueAndErrors(\n res,\n \"exclusiveMinimum\",\n check.value,\n check.message,\n refs\n );\n }\n } else {\n if (!check.inclusive) {\n res.exclusiveMinimum = true as any;\n }\n setResponseValueAndErrors(\n res,\n \"minimum\",\n check.value,\n check.message,\n refs\n );\n }\n break;\n case \"max\":\n if (refs.target === \"jsonSchema7\") {\n if (check.inclusive) {\n setResponseValueAndErrors(\n res,\n \"maximum\",\n check.value,\n check.message,\n refs\n );\n } else {\n setResponseValueAndErrors(\n res,\n \"exclusiveMaximum\",\n check.value,\n check.message,\n refs\n );\n }\n } else {\n if (!check.inclusive) {\n res.exclusiveMaximum = true as any;\n }\n setResponseValueAndErrors(\n res,\n \"maximum\",\n check.value,\n check.message,\n refs\n );\n }\n break;\n case \"multipleOf\":\n setResponseValueAndErrors(\n res,\n \"multipleOf\",\n check.value,\n check.message,\n refs\n );\n break;\n }\n }\n return res;\n}\n"],"mappings":";;;AAkBA,SAAgB,eACdA,KACAC,MACuB;CACvB,MAAMC,MAA6B,EACjC,MAAM,SACP;AAED,KAAI,CAAC,IAAI,OAAQ,QAAO;AAExB,MAAK,MAAM,SAAS,IAAI,OACtB,SAAQ,MAAM,MAAd;EACE,KAAK;GACH,IAAI,OAAO;GACX,gBAAgB,KAAK,QAAQ,MAAM,SAAS,KAAK;AACjD;EACF,KAAK;AACH,OAAI,KAAK,WAAW,cAClB,KAAI,MAAM,WACR,0BACE,KACA,WACA,MAAM,OACN,MAAM,SACN,KACD;QAED,0BACE,KACA,oBACA,MAAM,OACN,MAAM,SACN,KACD;QAEE;AACL,QAAI,CAAC,MAAM,WACT,IAAI,mBAAmB;IAEzB,0BACE,KACA,WACA,MAAM,OACN,MAAM,SACN,KACD;GACF;AACD;EACF,KAAK;AACH,OAAI,KAAK,WAAW,cAClB,KAAI,MAAM,WACR,0BACE,KACA,WACA,MAAM,OACN,MAAM,SACN,KACD;QAED,0BACE,KACA,oBACA,MAAM,OACN,MAAM,SACN,KACD;QAEE;AACL,QAAI,CAAC,MAAM,WACT,IAAI,mBAAmB;IAEzB,0BACE,KACA,WACA,MAAM,OACN,MAAM,SACN,KACD;GACF;AACD;EACF,KAAK;GACH,0BACE,KACA,cACA,MAAM,OACN,MAAM,SACN,KACD;AACD;CACH;AAEH,QAAO;AACR"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const require_parseDef = require('../parseDef.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/utils/zod-to-json-schema/parsers/object.ts
|
|
4
|
+
function parseObjectDef(def, refs) {
|
|
5
|
+
const forceOptionalIntoNullable = refs.target === "openAi";
|
|
6
|
+
const result = {
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: {}
|
|
9
|
+
};
|
|
10
|
+
const required = [];
|
|
11
|
+
const shape = def.shape();
|
|
12
|
+
for (const propName in shape) {
|
|
13
|
+
let propDef = shape[propName];
|
|
14
|
+
if (propDef === void 0 || propDef._def === void 0) continue;
|
|
15
|
+
let propOptional = safeIsOptional(propDef);
|
|
16
|
+
if (propOptional && forceOptionalIntoNullable) {
|
|
17
|
+
if (propDef._def.typeName === "ZodOptional") propDef = propDef._def.innerType;
|
|
18
|
+
if (!propDef.isNullable()) propDef = propDef.nullable();
|
|
19
|
+
propOptional = false;
|
|
20
|
+
}
|
|
21
|
+
const parsedDef = require_parseDef.parseDef(propDef._def, {
|
|
22
|
+
...refs,
|
|
23
|
+
currentPath: [
|
|
24
|
+
...refs.currentPath,
|
|
25
|
+
"properties",
|
|
26
|
+
propName
|
|
27
|
+
],
|
|
28
|
+
propertyPath: [
|
|
29
|
+
...refs.currentPath,
|
|
30
|
+
"properties",
|
|
31
|
+
propName
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
if (parsedDef === void 0) continue;
|
|
35
|
+
result.properties[propName] = parsedDef;
|
|
36
|
+
if (!propOptional) required.push(propName);
|
|
37
|
+
}
|
|
38
|
+
if (required.length) result.required = required;
|
|
39
|
+
const additionalProperties = decideAdditionalProperties(def, refs);
|
|
40
|
+
if (additionalProperties !== void 0) result.additionalProperties = additionalProperties;
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
function decideAdditionalProperties(def, refs) {
|
|
44
|
+
if (def.catchall._def.typeName !== "ZodNever") return require_parseDef.parseDef(def.catchall._def, {
|
|
45
|
+
...refs,
|
|
46
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
47
|
+
});
|
|
48
|
+
switch (def.unknownKeys) {
|
|
49
|
+
case "passthrough": return refs.allowedAdditionalProperties;
|
|
50
|
+
case "strict": return refs.rejectedAdditionalProperties;
|
|
51
|
+
case "strip": return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function safeIsOptional(schema) {
|
|
55
|
+
try {
|
|
56
|
+
return schema.isOptional();
|
|
57
|
+
} catch {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
exports.parseObjectDef = parseObjectDef;
|
|
64
|
+
//# sourceMappingURL=object.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object.cjs","names":["def: ZodObjectDef","refs: Refs","result: JsonSchema7ObjectType","required: string[]","parseDef","schema: ZodTypeAny"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/object.ts"],"sourcesContent":["import { ZodObjectDef, ZodTypeAny } from \"zod/v3\";\nimport { parseDef } from \"../parseDef.js\";\nimport { JsonSchema7Type } from \"../parseTypes.js\";\nimport { Refs } from \"../Refs.js\";\n\nexport type JsonSchema7ObjectType = {\n type: \"object\";\n properties: Record<string, JsonSchema7Type>;\n additionalProperties?: boolean | JsonSchema7Type;\n required?: string[];\n};\n\nexport function parseObjectDef(def: ZodObjectDef, refs: Refs) {\n const forceOptionalIntoNullable = refs.target === \"openAi\";\n\n const result: JsonSchema7ObjectType = {\n type: \"object\",\n properties: {},\n };\n\n const required: string[] = [];\n\n const shape = def.shape();\n\n for (const propName in shape) {\n let propDef = shape[propName];\n\n if (propDef === undefined || propDef._def === undefined) {\n continue;\n }\n\n let propOptional = safeIsOptional(propDef);\n\n if (propOptional && forceOptionalIntoNullable) {\n if (propDef._def.typeName === \"ZodOptional\") {\n propDef = propDef._def.innerType;\n }\n\n if (!propDef.isNullable()) {\n propDef = propDef.nullable();\n }\n\n propOptional = false;\n }\n\n const parsedDef = parseDef(propDef._def, {\n ...refs,\n currentPath: [...refs.currentPath, \"properties\", propName],\n propertyPath: [...refs.currentPath, \"properties\", propName],\n });\n\n if (parsedDef === undefined) {\n continue;\n }\n\n result.properties[propName] = parsedDef;\n\n if (!propOptional) {\n required.push(propName);\n }\n }\n\n if (required.length) {\n result.required = required;\n }\n\n const additionalProperties = decideAdditionalProperties(def, refs);\n\n if (additionalProperties !== undefined) {\n result.additionalProperties = additionalProperties;\n }\n\n return result;\n}\n\nfunction decideAdditionalProperties(def: ZodObjectDef, refs: Refs) {\n if (def.catchall._def.typeName !== \"ZodNever\") {\n return parseDef(def.catchall._def, {\n ...refs,\n currentPath: [...refs.currentPath, \"additionalProperties\"],\n });\n }\n\n switch (def.unknownKeys) {\n case \"passthrough\":\n return refs.allowedAdditionalProperties;\n case \"strict\":\n return refs.rejectedAdditionalProperties;\n case \"strip\":\n return refs.removeAdditionalStrategy === \"strict\"\n ? refs.allowedAdditionalProperties\n : refs.rejectedAdditionalProperties;\n }\n}\n\nfunction safeIsOptional(schema: ZodTypeAny): boolean {\n try {\n return schema.isOptional();\n } catch {\n return true;\n }\n}\n"],"mappings":";;;AAYA,SAAgB,eAAeA,KAAmBC,MAAY;CAC5D,MAAM,4BAA4B,KAAK,WAAW;CAElD,MAAMC,SAAgC;EACpC,MAAM;EACN,YAAY,CAAE;CACf;CAED,MAAMC,WAAqB,CAAE;CAE7B,MAAM,QAAQ,IAAI,OAAO;AAEzB,MAAK,MAAM,YAAY,OAAO;EAC5B,IAAI,UAAU,MAAM;AAEpB,MAAI,YAAY,UAAa,QAAQ,SAAS,OAC5C;EAGF,IAAI,eAAe,eAAe,QAAQ;AAE1C,MAAI,gBAAgB,2BAA2B;AAC7C,OAAI,QAAQ,KAAK,aAAa,eAC5B,UAAU,QAAQ,KAAK;AAGzB,OAAI,CAAC,QAAQ,YAAY,EACvB,UAAU,QAAQ,UAAU;GAG9B,eAAe;EAChB;EAED,MAAM,YAAYC,0BAAS,QAAQ,MAAM;GACvC,GAAG;GACH,aAAa;IAAC,GAAG,KAAK;IAAa;IAAc;GAAS;GAC1D,cAAc;IAAC,GAAG,KAAK;IAAa;IAAc;GAAS;EAC5D,EAAC;AAEF,MAAI,cAAc,OAChB;EAGF,OAAO,WAAW,YAAY;AAE9B,MAAI,CAAC,cACH,SAAS,KAAK,SAAS;CAE1B;AAED,KAAI,SAAS,QACX,OAAO,WAAW;CAGpB,MAAM,uBAAuB,2BAA2B,KAAK,KAAK;AAElE,KAAI,yBAAyB,QAC3B,OAAO,uBAAuB;AAGhC,QAAO;AACR;AAED,SAAS,2BAA2BJ,KAAmBC,MAAY;AACjE,KAAI,IAAI,SAAS,KAAK,aAAa,WACjC,QAAOG,0BAAS,IAAI,SAAS,MAAM;EACjC,GAAG;EACH,aAAa,CAAC,GAAG,KAAK,aAAa,sBAAuB;CAC3D,EAAC;AAGJ,SAAQ,IAAI,aAAZ;EACE,KAAK,cACH,QAAO,KAAK;EACd,KAAK,SACH,QAAO,KAAK;EACd,KAAK,QACH,QAAO,KAAK,6BAA6B,WACrC,KAAK,8BACL,KAAK;CACZ;AACF;AAED,SAAS,eAAeC,QAA6B;AACnD,KAAI;AACF,SAAO,OAAO,YAAY;CAC3B,QAAO;AACN,SAAO;CACR;AACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { JsonSchema7Type } from "../parseTypes.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/zod-to-json-schema/parsers/object.d.ts
|
|
4
|
+
type JsonSchema7ObjectType = {
|
|
5
|
+
type: "object";
|
|
6
|
+
properties: Record<string, JsonSchema7Type>;
|
|
7
|
+
additionalProperties?: boolean | JsonSchema7Type;
|
|
8
|
+
required?: string[];
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { JsonSchema7ObjectType };
|
|
12
|
+
//# sourceMappingURL=object.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object.d.cts","names":["ZodObjectDef","JsonSchema7Type","Refs","JsonSchema7ObjectType","Record","parseObjectDef"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/object.d.ts"],"sourcesContent":["import { ZodObjectDef } from \"zod/v3\";\nimport { JsonSchema7Type } from \"../parseTypes.js\";\nimport { Refs } from \"../Refs.js\";\nexport type JsonSchema7ObjectType = {\n type: \"object\";\n properties: Record<string, JsonSchema7Type>;\n additionalProperties?: boolean | JsonSchema7Type;\n required?: string[];\n};\nexport declare function parseObjectDef(def: ZodObjectDef, refs: Refs): JsonSchema7ObjectType;\n"],"mappings":";;;AAGYG,KAAAA,qBAAAA,GAAqB;EAAA,IAAA,EAAA,QAAA;EAAA,UAEFF,EAAfG,MAAeH,CAAAA,MAAAA,EAAAA,eAAAA,CAAAA;EAAe,oBAA9BG,CAAAA,EAAAA,OAAAA,GACqBH,eADrBG;EAAM,QACeH,CAAAA,EAAAA,MAAAA,EAAAA;AAAe,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { JsonSchema7Type } from "../parseTypes.js";
|
|
2
|
+
import "zod/v3";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/zod-to-json-schema/parsers/object.d.ts
|
|
5
|
+
type JsonSchema7ObjectType = {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: Record<string, JsonSchema7Type>;
|
|
8
|
+
additionalProperties?: boolean | JsonSchema7Type;
|
|
9
|
+
required?: string[];
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { JsonSchema7ObjectType };
|
|
13
|
+
//# sourceMappingURL=object.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object.d.ts","names":["ZodObjectDef","JsonSchema7Type","Refs","JsonSchema7ObjectType","Record","parseObjectDef"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/object.d.ts"],"sourcesContent":["import { ZodObjectDef } from \"zod/v3\";\nimport { JsonSchema7Type } from \"../parseTypes.js\";\nimport { Refs } from \"../Refs.js\";\nexport type JsonSchema7ObjectType = {\n type: \"object\";\n properties: Record<string, JsonSchema7Type>;\n additionalProperties?: boolean | JsonSchema7Type;\n required?: string[];\n};\nexport declare function parseObjectDef(def: ZodObjectDef, refs: Refs): JsonSchema7ObjectType;\n"],"mappings":";;;;KAGYG,qBAAAA;EAAAA,IAAAA,EAAAA,QAAAA;EAAqB,UAAA,EAEjBC,MAFiB,CAAA,MAAA,EAEFH,eAFE,CAAA;EAAA,oBAEFA,CAAAA,EAAAA,OAAAA,GACMA,eADNA;EAAe,QAA9BG,CAAAA,EAAAA,MAAAA,EAAAA;CAAM"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { parseDef } from "../parseDef.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/zod-to-json-schema/parsers/object.ts
|
|
4
|
+
function parseObjectDef(def, refs) {
|
|
5
|
+
const forceOptionalIntoNullable = refs.target === "openAi";
|
|
6
|
+
const result = {
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: {}
|
|
9
|
+
};
|
|
10
|
+
const required = [];
|
|
11
|
+
const shape = def.shape();
|
|
12
|
+
for (const propName in shape) {
|
|
13
|
+
let propDef = shape[propName];
|
|
14
|
+
if (propDef === void 0 || propDef._def === void 0) continue;
|
|
15
|
+
let propOptional = safeIsOptional(propDef);
|
|
16
|
+
if (propOptional && forceOptionalIntoNullable) {
|
|
17
|
+
if (propDef._def.typeName === "ZodOptional") propDef = propDef._def.innerType;
|
|
18
|
+
if (!propDef.isNullable()) propDef = propDef.nullable();
|
|
19
|
+
propOptional = false;
|
|
20
|
+
}
|
|
21
|
+
const parsedDef = parseDef(propDef._def, {
|
|
22
|
+
...refs,
|
|
23
|
+
currentPath: [
|
|
24
|
+
...refs.currentPath,
|
|
25
|
+
"properties",
|
|
26
|
+
propName
|
|
27
|
+
],
|
|
28
|
+
propertyPath: [
|
|
29
|
+
...refs.currentPath,
|
|
30
|
+
"properties",
|
|
31
|
+
propName
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
if (parsedDef === void 0) continue;
|
|
35
|
+
result.properties[propName] = parsedDef;
|
|
36
|
+
if (!propOptional) required.push(propName);
|
|
37
|
+
}
|
|
38
|
+
if (required.length) result.required = required;
|
|
39
|
+
const additionalProperties = decideAdditionalProperties(def, refs);
|
|
40
|
+
if (additionalProperties !== void 0) result.additionalProperties = additionalProperties;
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
function decideAdditionalProperties(def, refs) {
|
|
44
|
+
if (def.catchall._def.typeName !== "ZodNever") return parseDef(def.catchall._def, {
|
|
45
|
+
...refs,
|
|
46
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
47
|
+
});
|
|
48
|
+
switch (def.unknownKeys) {
|
|
49
|
+
case "passthrough": return refs.allowedAdditionalProperties;
|
|
50
|
+
case "strict": return refs.rejectedAdditionalProperties;
|
|
51
|
+
case "strip": return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function safeIsOptional(schema) {
|
|
55
|
+
try {
|
|
56
|
+
return schema.isOptional();
|
|
57
|
+
} catch {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
export { parseObjectDef };
|
|
64
|
+
//# sourceMappingURL=object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object.js","names":["def: ZodObjectDef","refs: Refs","result: JsonSchema7ObjectType","required: string[]","schema: ZodTypeAny"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/object.ts"],"sourcesContent":["import { ZodObjectDef, ZodTypeAny } from \"zod/v3\";\nimport { parseDef } from \"../parseDef.js\";\nimport { JsonSchema7Type } from \"../parseTypes.js\";\nimport { Refs } from \"../Refs.js\";\n\nexport type JsonSchema7ObjectType = {\n type: \"object\";\n properties: Record<string, JsonSchema7Type>;\n additionalProperties?: boolean | JsonSchema7Type;\n required?: string[];\n};\n\nexport function parseObjectDef(def: ZodObjectDef, refs: Refs) {\n const forceOptionalIntoNullable = refs.target === \"openAi\";\n\n const result: JsonSchema7ObjectType = {\n type: \"object\",\n properties: {},\n };\n\n const required: string[] = [];\n\n const shape = def.shape();\n\n for (const propName in shape) {\n let propDef = shape[propName];\n\n if (propDef === undefined || propDef._def === undefined) {\n continue;\n }\n\n let propOptional = safeIsOptional(propDef);\n\n if (propOptional && forceOptionalIntoNullable) {\n if (propDef._def.typeName === \"ZodOptional\") {\n propDef = propDef._def.innerType;\n }\n\n if (!propDef.isNullable()) {\n propDef = propDef.nullable();\n }\n\n propOptional = false;\n }\n\n const parsedDef = parseDef(propDef._def, {\n ...refs,\n currentPath: [...refs.currentPath, \"properties\", propName],\n propertyPath: [...refs.currentPath, \"properties\", propName],\n });\n\n if (parsedDef === undefined) {\n continue;\n }\n\n result.properties[propName] = parsedDef;\n\n if (!propOptional) {\n required.push(propName);\n }\n }\n\n if (required.length) {\n result.required = required;\n }\n\n const additionalProperties = decideAdditionalProperties(def, refs);\n\n if (additionalProperties !== undefined) {\n result.additionalProperties = additionalProperties;\n }\n\n return result;\n}\n\nfunction decideAdditionalProperties(def: ZodObjectDef, refs: Refs) {\n if (def.catchall._def.typeName !== \"ZodNever\") {\n return parseDef(def.catchall._def, {\n ...refs,\n currentPath: [...refs.currentPath, \"additionalProperties\"],\n });\n }\n\n switch (def.unknownKeys) {\n case \"passthrough\":\n return refs.allowedAdditionalProperties;\n case \"strict\":\n return refs.rejectedAdditionalProperties;\n case \"strip\":\n return refs.removeAdditionalStrategy === \"strict\"\n ? refs.allowedAdditionalProperties\n : refs.rejectedAdditionalProperties;\n }\n}\n\nfunction safeIsOptional(schema: ZodTypeAny): boolean {\n try {\n return schema.isOptional();\n } catch {\n return true;\n }\n}\n"],"mappings":";;;AAYA,SAAgB,eAAeA,KAAmBC,MAAY;CAC5D,MAAM,4BAA4B,KAAK,WAAW;CAElD,MAAMC,SAAgC;EACpC,MAAM;EACN,YAAY,CAAE;CACf;CAED,MAAMC,WAAqB,CAAE;CAE7B,MAAM,QAAQ,IAAI,OAAO;AAEzB,MAAK,MAAM,YAAY,OAAO;EAC5B,IAAI,UAAU,MAAM;AAEpB,MAAI,YAAY,UAAa,QAAQ,SAAS,OAC5C;EAGF,IAAI,eAAe,eAAe,QAAQ;AAE1C,MAAI,gBAAgB,2BAA2B;AAC7C,OAAI,QAAQ,KAAK,aAAa,eAC5B,UAAU,QAAQ,KAAK;AAGzB,OAAI,CAAC,QAAQ,YAAY,EACvB,UAAU,QAAQ,UAAU;GAG9B,eAAe;EAChB;EAED,MAAM,YAAY,SAAS,QAAQ,MAAM;GACvC,GAAG;GACH,aAAa;IAAC,GAAG,KAAK;IAAa;IAAc;GAAS;GAC1D,cAAc;IAAC,GAAG,KAAK;IAAa;IAAc;GAAS;EAC5D,EAAC;AAEF,MAAI,cAAc,OAChB;EAGF,OAAO,WAAW,YAAY;AAE9B,MAAI,CAAC,cACH,SAAS,KAAK,SAAS;CAE1B;AAED,KAAI,SAAS,QACX,OAAO,WAAW;CAGpB,MAAM,uBAAuB,2BAA2B,KAAK,KAAK;AAElE,KAAI,yBAAyB,QAC3B,OAAO,uBAAuB;AAGhC,QAAO;AACR;AAED,SAAS,2BAA2BH,KAAmBC,MAAY;AACjE,KAAI,IAAI,SAAS,KAAK,aAAa,WACjC,QAAO,SAAS,IAAI,SAAS,MAAM;EACjC,GAAG;EACH,aAAa,CAAC,GAAG,KAAK,aAAa,sBAAuB;CAC3D,EAAC;AAGJ,SAAQ,IAAI,aAAZ;EACE,KAAK,cACH,QAAO,KAAK;EACd,KAAK,SACH,QAAO,KAAK;EACd,KAAK,QACH,QAAO,KAAK,6BAA6B,WACrC,KAAK,8BACL,KAAK;CACZ;AACF;AAED,SAAS,eAAeG,QAA6B;AACnD,KAAI;AACF,SAAO,OAAO,YAAY;CAC3B,QAAO;AACN,SAAO;CACR;AACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const require_any = require('./any.cjs');
|
|
2
|
+
const require_parseDef = require('../parseDef.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/utils/zod-to-json-schema/parsers/optional.ts
|
|
5
|
+
const parseOptionalDef = (def, refs) => {
|
|
6
|
+
if (refs.currentPath.toString() === refs.propertyPath?.toString()) return require_parseDef.parseDef(def.innerType._def, refs);
|
|
7
|
+
const innerSchema = require_parseDef.parseDef(def.innerType._def, {
|
|
8
|
+
...refs,
|
|
9
|
+
currentPath: [
|
|
10
|
+
...refs.currentPath,
|
|
11
|
+
"anyOf",
|
|
12
|
+
"1"
|
|
13
|
+
]
|
|
14
|
+
});
|
|
15
|
+
return innerSchema ? { anyOf: [{ not: require_any.parseAnyDef(refs) }, innerSchema] } : require_any.parseAnyDef(refs);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.parseOptionalDef = parseOptionalDef;
|
|
20
|
+
//# sourceMappingURL=optional.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optional.cjs","names":["def: ZodOptionalDef","refs: Refs","parseDef","parseAnyDef"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/optional.ts"],"sourcesContent":["import { ZodOptionalDef } from \"zod/v3\";\nimport { parseDef } from \"../parseDef.js\";\nimport { JsonSchema7Type } from \"../parseTypes.js\";\nimport { Refs } from \"../Refs.js\";\nimport { parseAnyDef } from \"./any.js\";\n\nexport const parseOptionalDef = (\n def: ZodOptionalDef,\n refs: Refs\n): JsonSchema7Type | undefined => {\n if (refs.currentPath.toString() === refs.propertyPath?.toString()) {\n return parseDef(def.innerType._def, refs);\n }\n\n const innerSchema = parseDef(def.innerType._def, {\n ...refs,\n currentPath: [...refs.currentPath, \"anyOf\", \"1\"],\n });\n\n return innerSchema\n ? {\n anyOf: [\n {\n not: parseAnyDef(refs),\n },\n innerSchema,\n ],\n }\n : parseAnyDef(refs);\n};\n"],"mappings":";;;;AAMA,MAAa,mBAAmB,CAC9BA,KACAC,SACgC;AAChC,KAAI,KAAK,YAAY,UAAU,KAAK,KAAK,cAAc,UAAU,CAC/D,QAAOC,0BAAS,IAAI,UAAU,MAAM,KAAK;CAG3C,MAAM,cAAcA,0BAAS,IAAI,UAAU,MAAM;EAC/C,GAAG;EACH,aAAa;GAAC,GAAG,KAAK;GAAa;GAAS;EAAI;CACjD,EAAC;AAEF,QAAO,cACH,EACE,OAAO,CACL,EACE,KAAKC,wBAAY,KAAK,CACvB,GACD,WACD,EACF,IACDA,wBAAY,KAAK;AACtB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { parseAnyDef } from "./any.js";
|
|
2
|
+
import { parseDef } from "../parseDef.js";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/zod-to-json-schema/parsers/optional.ts
|
|
5
|
+
const parseOptionalDef = (def, refs) => {
|
|
6
|
+
if (refs.currentPath.toString() === refs.propertyPath?.toString()) return parseDef(def.innerType._def, refs);
|
|
7
|
+
const innerSchema = parseDef(def.innerType._def, {
|
|
8
|
+
...refs,
|
|
9
|
+
currentPath: [
|
|
10
|
+
...refs.currentPath,
|
|
11
|
+
"anyOf",
|
|
12
|
+
"1"
|
|
13
|
+
]
|
|
14
|
+
});
|
|
15
|
+
return innerSchema ? { anyOf: [{ not: parseAnyDef(refs) }, innerSchema] } : parseAnyDef(refs);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { parseOptionalDef };
|
|
20
|
+
//# sourceMappingURL=optional.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optional.js","names":["def: ZodOptionalDef","refs: Refs"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/optional.ts"],"sourcesContent":["import { ZodOptionalDef } from \"zod/v3\";\nimport { parseDef } from \"../parseDef.js\";\nimport { JsonSchema7Type } from \"../parseTypes.js\";\nimport { Refs } from \"../Refs.js\";\nimport { parseAnyDef } from \"./any.js\";\n\nexport const parseOptionalDef = (\n def: ZodOptionalDef,\n refs: Refs\n): JsonSchema7Type | undefined => {\n if (refs.currentPath.toString() === refs.propertyPath?.toString()) {\n return parseDef(def.innerType._def, refs);\n }\n\n const innerSchema = parseDef(def.innerType._def, {\n ...refs,\n currentPath: [...refs.currentPath, \"anyOf\", \"1\"],\n });\n\n return innerSchema\n ? {\n anyOf: [\n {\n not: parseAnyDef(refs),\n },\n innerSchema,\n ],\n }\n : parseAnyDef(refs);\n};\n"],"mappings":";;;;AAMA,MAAa,mBAAmB,CAC9BA,KACAC,SACgC;AAChC,KAAI,KAAK,YAAY,UAAU,KAAK,KAAK,cAAc,UAAU,CAC/D,QAAO,SAAS,IAAI,UAAU,MAAM,KAAK;CAG3C,MAAM,cAAc,SAAS,IAAI,UAAU,MAAM;EAC/C,GAAG;EACH,aAAa;GAAC,GAAG,KAAK;GAAa;GAAS;EAAI;CACjD,EAAC;AAEF,QAAO,cACH,EACE,OAAO,CACL,EACE,KAAK,YAAY,KAAK,CACvB,GACD,WACD,EACF,IACD,YAAY,KAAK;AACtB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const require_parseDef = require('../parseDef.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/utils/zod-to-json-schema/parsers/pipeline.ts
|
|
4
|
+
const parsePipelineDef = (def, refs) => {
|
|
5
|
+
if (refs.pipeStrategy === "input") return require_parseDef.parseDef(def.in._def, refs);
|
|
6
|
+
else if (refs.pipeStrategy === "output") return require_parseDef.parseDef(def.out._def, refs);
|
|
7
|
+
const a = require_parseDef.parseDef(def.in._def, {
|
|
8
|
+
...refs,
|
|
9
|
+
currentPath: [
|
|
10
|
+
...refs.currentPath,
|
|
11
|
+
"allOf",
|
|
12
|
+
"0"
|
|
13
|
+
]
|
|
14
|
+
});
|
|
15
|
+
const b = require_parseDef.parseDef(def.out._def, {
|
|
16
|
+
...refs,
|
|
17
|
+
currentPath: [
|
|
18
|
+
...refs.currentPath,
|
|
19
|
+
"allOf",
|
|
20
|
+
a ? "1" : "0"
|
|
21
|
+
]
|
|
22
|
+
});
|
|
23
|
+
return { allOf: [a, b].filter((x) => x !== void 0) };
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
exports.parsePipelineDef = parsePipelineDef;
|
|
28
|
+
//# sourceMappingURL=pipeline.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.cjs","names":["def: ZodPipelineDef<any, any>","refs: Refs","parseDef"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/pipeline.ts"],"sourcesContent":["import { ZodPipelineDef } from \"zod/v3\";\nimport { parseDef } from \"../parseDef.js\";\nimport { JsonSchema7Type } from \"../parseTypes.js\";\nimport { Refs } from \"../Refs.js\";\nimport { JsonSchema7AllOfType } from \"./intersection.js\";\n\nexport const parsePipelineDef = (\n def: ZodPipelineDef<any, any>,\n refs: Refs\n): JsonSchema7AllOfType | JsonSchema7Type | undefined => {\n if (refs.pipeStrategy === \"input\") {\n return parseDef(def.in._def, refs);\n } else if (refs.pipeStrategy === \"output\") {\n return parseDef(def.out._def, refs);\n }\n\n const a = parseDef(def.in._def, {\n ...refs,\n currentPath: [...refs.currentPath, \"allOf\", \"0\"],\n });\n const b = parseDef(def.out._def, {\n ...refs,\n currentPath: [...refs.currentPath, \"allOf\", a ? \"1\" : \"0\"],\n });\n\n return {\n allOf: [a, b].filter((x): x is JsonSchema7Type => x !== undefined),\n };\n};\n"],"mappings":";;;AAMA,MAAa,mBAAmB,CAC9BA,KACAC,SACuD;AACvD,KAAI,KAAK,iBAAiB,QACxB,QAAOC,0BAAS,IAAI,GAAG,MAAM,KAAK;UACzB,KAAK,iBAAiB,SAC/B,QAAOA,0BAAS,IAAI,IAAI,MAAM,KAAK;CAGrC,MAAM,IAAIA,0BAAS,IAAI,GAAG,MAAM;EAC9B,GAAG;EACH,aAAa;GAAC,GAAG,KAAK;GAAa;GAAS;EAAI;CACjD,EAAC;CACF,MAAM,IAAIA,0BAAS,IAAI,IAAI,MAAM;EAC/B,GAAG;EACH,aAAa;GAAC,GAAG,KAAK;GAAa;GAAS,IAAI,MAAM;EAAI;CAC3D,EAAC;AAEF,QAAO,EACL,OAAO,CAAC,GAAG,CAAE,EAAC,OAAO,CAAC,MAA4B,MAAM,OAAU,CACnE;AACF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { parseDef } from "../parseDef.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/zod-to-json-schema/parsers/pipeline.ts
|
|
4
|
+
const parsePipelineDef = (def, refs) => {
|
|
5
|
+
if (refs.pipeStrategy === "input") return parseDef(def.in._def, refs);
|
|
6
|
+
else if (refs.pipeStrategy === "output") return parseDef(def.out._def, refs);
|
|
7
|
+
const a = parseDef(def.in._def, {
|
|
8
|
+
...refs,
|
|
9
|
+
currentPath: [
|
|
10
|
+
...refs.currentPath,
|
|
11
|
+
"allOf",
|
|
12
|
+
"0"
|
|
13
|
+
]
|
|
14
|
+
});
|
|
15
|
+
const b = parseDef(def.out._def, {
|
|
16
|
+
...refs,
|
|
17
|
+
currentPath: [
|
|
18
|
+
...refs.currentPath,
|
|
19
|
+
"allOf",
|
|
20
|
+
a ? "1" : "0"
|
|
21
|
+
]
|
|
22
|
+
});
|
|
23
|
+
return { allOf: [a, b].filter((x) => x !== void 0) };
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { parsePipelineDef };
|
|
28
|
+
//# sourceMappingURL=pipeline.js.map
|