@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":"pipeline.js","names":["def: ZodPipelineDef<any, any>","refs: Refs"],"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,QAAO,SAAS,IAAI,GAAG,MAAM,KAAK;UACzB,KAAK,iBAAiB,SAC/B,QAAO,SAAS,IAAI,IAAI,MAAM,KAAK;CAGrC,MAAM,IAAI,SAAS,IAAI,GAAG,MAAM;EAC9B,GAAG;EACH,aAAa;GAAC,GAAG,KAAK;GAAa;GAAS;EAAI;CACjD,EAAC;CACF,MAAM,IAAI,SAAS,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,10 @@
|
|
|
1
|
+
const require_parseDef = require('../parseDef.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/utils/zod-to-json-schema/parsers/promise.ts
|
|
4
|
+
function parsePromiseDef(def, refs) {
|
|
5
|
+
return require_parseDef.parseDef(def.type._def, refs);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
exports.parsePromiseDef = parsePromiseDef;
|
|
10
|
+
//# sourceMappingURL=promise.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise.cjs","names":["def: ZodPromiseDef","refs: Refs","parseDef"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/promise.ts"],"sourcesContent":["import { ZodPromiseDef } from \"zod/v3\";\nimport { parseDef } from \"../parseDef.js\";\nimport { JsonSchema7Type } from \"../parseTypes.js\";\nimport { Refs } from \"../Refs.js\";\n\nexport function parsePromiseDef(\n def: ZodPromiseDef,\n refs: Refs\n): JsonSchema7Type | undefined {\n return parseDef(def.type._def, refs);\n}\n"],"mappings":";;;AAKA,SAAgB,gBACdA,KACAC,MAC6B;AAC7B,QAAOC,0BAAS,IAAI,KAAK,MAAM,KAAK;AACrC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { parseDef } from "../parseDef.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/zod-to-json-schema/parsers/promise.ts
|
|
4
|
+
function parsePromiseDef(def, refs) {
|
|
5
|
+
return parseDef(def.type._def, refs);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { parsePromiseDef };
|
|
10
|
+
//# sourceMappingURL=promise.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise.js","names":["def: ZodPromiseDef","refs: Refs"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/promise.ts"],"sourcesContent":["import { ZodPromiseDef } from \"zod/v3\";\nimport { parseDef } from \"../parseDef.js\";\nimport { JsonSchema7Type } from \"../parseTypes.js\";\nimport { Refs } from \"../Refs.js\";\n\nexport function parsePromiseDef(\n def: ZodPromiseDef,\n refs: Refs\n): JsonSchema7Type | undefined {\n return parseDef(def.type._def, refs);\n}\n"],"mappings":";;;AAKA,SAAgB,gBACdA,KACAC,MAC6B;AAC7B,QAAO,SAAS,IAAI,KAAK,MAAM,KAAK;AACrC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const require_parseDef = require('../parseDef.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/utils/zod-to-json-schema/parsers/readonly.ts
|
|
4
|
+
const parseReadonlyDef = (def, refs) => {
|
|
5
|
+
return require_parseDef.parseDef(def.innerType._def, refs);
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
exports.parseReadonlyDef = parseReadonlyDef;
|
|
10
|
+
//# sourceMappingURL=readonly.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readonly.cjs","names":["def: ZodReadonlyDef<any>","refs: Refs","parseDef"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/readonly.ts"],"sourcesContent":["import { ZodReadonlyDef } from \"zod/v3\";\nimport { parseDef } from \"../parseDef.js\";\nimport { Refs } from \"../Refs.js\";\n\nexport const parseReadonlyDef = (def: ZodReadonlyDef<any>, refs: Refs) => {\n return parseDef(def.innerType._def, refs);\n};\n"],"mappings":";;;AAIA,MAAa,mBAAmB,CAACA,KAA0BC,SAAe;AACxE,QAAOC,0BAAS,IAAI,UAAU,MAAM,KAAK;AAC1C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { parseDef } from "../parseDef.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/zod-to-json-schema/parsers/readonly.ts
|
|
4
|
+
const parseReadonlyDef = (def, refs) => {
|
|
5
|
+
return parseDef(def.innerType._def, refs);
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { parseReadonlyDef };
|
|
10
|
+
//# sourceMappingURL=readonly.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readonly.js","names":["def: ZodReadonlyDef<any>","refs: Refs"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/readonly.ts"],"sourcesContent":["import { ZodReadonlyDef } from \"zod/v3\";\nimport { parseDef } from \"../parseDef.js\";\nimport { Refs } from \"../Refs.js\";\n\nexport const parseReadonlyDef = (def: ZodReadonlyDef<any>, refs: Refs) => {\n return parseDef(def.innerType._def, refs);\n};\n"],"mappings":";;;AAIA,MAAa,mBAAmB,CAACA,KAA0BC,SAAe;AACxE,QAAO,SAAS,IAAI,UAAU,MAAM,KAAK;AAC1C"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_any = require('./any.cjs');
|
|
3
|
+
const require_branded = require('./branded.cjs');
|
|
4
|
+
const require_string = require('./string.cjs');
|
|
5
|
+
const require_parseDef = require('../parseDef.cjs');
|
|
6
|
+
const zod_v3 = require_rolldown_runtime.__toESM(require("zod/v3"));
|
|
7
|
+
|
|
8
|
+
//#region src/utils/zod-to-json-schema/parsers/record.ts
|
|
9
|
+
function parseRecordDef(def, refs) {
|
|
10
|
+
if (refs.target === "openAi") console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
|
|
11
|
+
if (refs.target === "openApi3" && def.keyType?._def.typeName === zod_v3.ZodFirstPartyTypeKind.ZodEnum) return {
|
|
12
|
+
type: "object",
|
|
13
|
+
required: def.keyType._def.values,
|
|
14
|
+
properties: def.keyType._def.values.reduce((acc, key) => ({
|
|
15
|
+
...acc,
|
|
16
|
+
[key]: require_parseDef.parseDef(def.valueType._def, {
|
|
17
|
+
...refs,
|
|
18
|
+
currentPath: [
|
|
19
|
+
...refs.currentPath,
|
|
20
|
+
"properties",
|
|
21
|
+
key
|
|
22
|
+
]
|
|
23
|
+
}) ?? require_any.parseAnyDef(refs)
|
|
24
|
+
}), {}),
|
|
25
|
+
additionalProperties: refs.rejectedAdditionalProperties
|
|
26
|
+
};
|
|
27
|
+
const schema = {
|
|
28
|
+
type: "object",
|
|
29
|
+
additionalProperties: require_parseDef.parseDef(def.valueType._def, {
|
|
30
|
+
...refs,
|
|
31
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
32
|
+
}) ?? refs.allowedAdditionalProperties
|
|
33
|
+
};
|
|
34
|
+
if (refs.target === "openApi3") return schema;
|
|
35
|
+
if (def.keyType?._def.typeName === zod_v3.ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
|
|
36
|
+
const { type,...keyType } = require_string.parseStringDef(def.keyType._def, refs);
|
|
37
|
+
return {
|
|
38
|
+
...schema,
|
|
39
|
+
propertyNames: keyType
|
|
40
|
+
};
|
|
41
|
+
} else if (def.keyType?._def.typeName === zod_v3.ZodFirstPartyTypeKind.ZodEnum) return {
|
|
42
|
+
...schema,
|
|
43
|
+
propertyNames: { enum: def.keyType._def.values }
|
|
44
|
+
};
|
|
45
|
+
else if (def.keyType?._def.typeName === zod_v3.ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === zod_v3.ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
|
|
46
|
+
const { type,...keyType } = require_branded.parseBrandedDef(def.keyType._def, refs);
|
|
47
|
+
return {
|
|
48
|
+
...schema,
|
|
49
|
+
propertyNames: keyType
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return schema;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
exports.parseRecordDef = parseRecordDef;
|
|
57
|
+
//# sourceMappingURL=record.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.cjs","names":["def: ZodRecordDef<ZodTypeAny, ZodTypeAny> | ZodMapDef","refs: Refs","ZodFirstPartyTypeKind","acc: Record<string, JsonSchema7Type>","key: string","parseDef","parseAnyDef","schema: JsonSchema7RecordType","parseStringDef","parseBrandedDef"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/record.ts"],"sourcesContent":["import {\n ZodFirstPartyTypeKind,\n ZodMapDef,\n ZodRecordDef,\n ZodTypeAny,\n} from \"zod/v3\";\nimport { parseDef } from \"../parseDef.js\";\nimport { JsonSchema7Type } from \"../parseTypes.js\";\nimport { Refs } from \"../Refs.js\";\nimport { JsonSchema7EnumType } from \"./enum.js\";\nimport { JsonSchema7ObjectType } from \"./object.js\";\nimport { JsonSchema7StringType, parseStringDef } from \"./string.js\";\nimport { parseBrandedDef } from \"./branded.js\";\nimport { parseAnyDef } from \"./any.js\";\n\ntype JsonSchema7RecordPropertyNamesType =\n | Omit<JsonSchema7StringType, \"type\">\n | Omit<JsonSchema7EnumType, \"type\">;\n\nexport type JsonSchema7RecordType = {\n type: \"object\";\n additionalProperties?: JsonSchema7Type | true;\n propertyNames?: JsonSchema7RecordPropertyNamesType;\n};\n\nexport function parseRecordDef(\n def: ZodRecordDef<ZodTypeAny, ZodTypeAny> | ZodMapDef,\n refs: Refs\n): JsonSchema7RecordType {\n if (refs.target === \"openAi\") {\n console.warn(\n \"Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.\"\n );\n }\n\n if (\n refs.target === \"openApi3\" &&\n def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum\n ) {\n return {\n type: \"object\",\n required: def.keyType._def.values,\n properties: def.keyType._def.values.reduce(\n (acc: Record<string, JsonSchema7Type>, key: string) => ({\n ...acc,\n [key]:\n parseDef(def.valueType._def, {\n ...refs,\n currentPath: [...refs.currentPath, \"properties\", key],\n }) ?? parseAnyDef(refs),\n }),\n {}\n ),\n additionalProperties: refs.rejectedAdditionalProperties,\n } satisfies JsonSchema7ObjectType as any;\n }\n\n const schema: JsonSchema7RecordType = {\n type: \"object\",\n additionalProperties:\n parseDef(def.valueType._def, {\n ...refs,\n currentPath: [...refs.currentPath, \"additionalProperties\"],\n }) ?? refs.allowedAdditionalProperties,\n };\n\n if (refs.target === \"openApi3\") {\n return schema;\n }\n\n if (\n def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodString &&\n def.keyType._def.checks?.length\n ) {\n const { type, ...keyType } = parseStringDef(def.keyType._def, refs);\n\n return {\n ...schema,\n propertyNames: keyType,\n };\n } else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) {\n return {\n ...schema,\n propertyNames: {\n enum: def.keyType._def.values,\n },\n };\n } else if (\n def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodBranded &&\n def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString &&\n def.keyType._def.type._def.checks?.length\n ) {\n const { type, ...keyType } = parseBrandedDef(\n def.keyType._def,\n refs\n ) as JsonSchema7StringType;\n\n return {\n ...schema,\n propertyNames: keyType,\n };\n }\n\n return schema;\n}\n"],"mappings":";;;;;;;;AAyBA,SAAgB,eACdA,KACAC,MACuB;AACvB,KAAI,KAAK,WAAW,UAClB,QAAQ,KACN,+FACD;AAGH,KACE,KAAK,WAAW,cAChB,IAAI,SAAS,KAAK,aAAaC,6BAAsB,QAErD,QAAO;EACL,MAAM;EACN,UAAU,IAAI,QAAQ,KAAK;EAC3B,YAAY,IAAI,QAAQ,KAAK,OAAO,OAClC,CAACC,KAAsCC,SAAiB;GACtD,GAAG;IACF,MACCC,0BAAS,IAAI,UAAU,MAAM;IAC3B,GAAG;IACH,aAAa;KAAC,GAAG,KAAK;KAAa;KAAc;IAAI;GACtD,EAAC,IAAIC,wBAAY,KAAK;EAC1B,IACD,CAAE,EACH;EACD,sBAAsB,KAAK;CAC5B;CAGH,MAAMC,SAAgC;EACpC,MAAM;EACN,sBACEF,0BAAS,IAAI,UAAU,MAAM;GAC3B,GAAG;GACH,aAAa,CAAC,GAAG,KAAK,aAAa,sBAAuB;EAC3D,EAAC,IAAI,KAAK;CACd;AAED,KAAI,KAAK,WAAW,WAClB,QAAO;AAGT,KACE,IAAI,SAAS,KAAK,aAAaH,6BAAsB,aACrD,IAAI,QAAQ,KAAK,QAAQ,QACzB;EACA,MAAM,EAAE,KAAM,GAAG,SAAS,GAAGM,8BAAe,IAAI,QAAQ,MAAM,KAAK;AAEnE,SAAO;GACL,GAAG;GACH,eAAe;EAChB;CACF,WAAU,IAAI,SAAS,KAAK,aAAaN,6BAAsB,QAC9D,QAAO;EACL,GAAG;EACH,eAAe,EACb,MAAM,IAAI,QAAQ,KAAK,OACxB;CACF;UAED,IAAI,SAAS,KAAK,aAAaA,6BAAsB,cACrD,IAAI,QAAQ,KAAK,KAAK,KAAK,aAAaA,6BAAsB,aAC9D,IAAI,QAAQ,KAAK,KAAK,KAAK,QAAQ,QACnC;EACA,MAAM,EAAE,KAAM,GAAG,SAAS,GAAGO,gCAC3B,IAAI,QAAQ,MACZ,KACD;AAED,SAAO;GACL,GAAG;GACH,eAAe;EAChB;CACF;AAED,QAAO;AACR"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { JsonSchema7EnumType } from "./enum.cjs";
|
|
2
|
+
import { JsonSchema7StringType } from "./string.cjs";
|
|
3
|
+
import { JsonSchema7Type } from "../parseTypes.cjs";
|
|
4
|
+
|
|
5
|
+
//#region src/utils/zod-to-json-schema/parsers/record.d.ts
|
|
6
|
+
type JsonSchema7RecordPropertyNamesType = Omit<JsonSchema7StringType, "type"> | Omit<JsonSchema7EnumType, "type">;
|
|
7
|
+
type JsonSchema7RecordType = {
|
|
8
|
+
type: "object";
|
|
9
|
+
additionalProperties?: JsonSchema7Type | true;
|
|
10
|
+
propertyNames?: JsonSchema7RecordPropertyNamesType;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { JsonSchema7RecordType };
|
|
14
|
+
//# sourceMappingURL=record.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.d.cts","names":["ZodMapDef","ZodRecordDef","ZodTypeAny","JsonSchema7Type","Refs","JsonSchema7EnumType","JsonSchema7StringType","JsonSchema7RecordPropertyNamesType","Omit","JsonSchema7RecordType","parseRecordDef"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/record.d.ts"],"sourcesContent":["import { ZodMapDef, ZodRecordDef, ZodTypeAny } from \"zod/v3\";\nimport { JsonSchema7Type } from \"../parseTypes.js\";\nimport { Refs } from \"../Refs.js\";\nimport { JsonSchema7EnumType } from \"./enum.js\";\nimport { JsonSchema7StringType } from \"./string.js\";\ntype JsonSchema7RecordPropertyNamesType = Omit<JsonSchema7StringType, \"type\"> | Omit<JsonSchema7EnumType, \"type\">;\nexport type JsonSchema7RecordType = {\n type: \"object\";\n additionalProperties?: JsonSchema7Type | true;\n propertyNames?: JsonSchema7RecordPropertyNamesType;\n};\nexport declare function parseRecordDef(def: ZodRecordDef<ZodTypeAny, ZodTypeAny> | ZodMapDef, refs: Refs): JsonSchema7RecordType;\nexport {};\n"],"mappings":";;;;;AAIoD,KAC/CO,kCAAAA,GAAqCC,IAAH,CAAQF,qBAAR,EAAA,MAAA,CAAA,GAAyCE,IAAzC,CAA8CH,mBAA9C,EAAA,MAAA,CAAA;AAAA,KAC3BI,qBAAAA,GAD2B;EAAA,IAAQH,EAAAA,QAAAA;EAAqB,oBAA1BE,CAAAA,EAGfL,eAHeK,GAAAA,IAAAA;EAAI,aAAuCH,CAAAA,EAIjEE,kCAJiEF;CAAmB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { JsonSchema7EnumType } from "./enum.js";
|
|
2
|
+
import { JsonSchema7StringType } from "./string.js";
|
|
3
|
+
import { JsonSchema7Type } from "../parseTypes.js";
|
|
4
|
+
import "zod/v3";
|
|
5
|
+
|
|
6
|
+
//#region src/utils/zod-to-json-schema/parsers/record.d.ts
|
|
7
|
+
type JsonSchema7RecordPropertyNamesType = Omit<JsonSchema7StringType, "type"> | Omit<JsonSchema7EnumType, "type">;
|
|
8
|
+
type JsonSchema7RecordType = {
|
|
9
|
+
type: "object";
|
|
10
|
+
additionalProperties?: JsonSchema7Type | true;
|
|
11
|
+
propertyNames?: JsonSchema7RecordPropertyNamesType;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { JsonSchema7RecordType };
|
|
15
|
+
//# sourceMappingURL=record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.d.ts","names":["ZodMapDef","ZodRecordDef","ZodTypeAny","JsonSchema7Type","Refs","JsonSchema7EnumType","JsonSchema7StringType","JsonSchema7RecordPropertyNamesType","Omit","JsonSchema7RecordType","parseRecordDef"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/record.d.ts"],"sourcesContent":["import { ZodMapDef, ZodRecordDef, ZodTypeAny } from \"zod/v3\";\nimport { JsonSchema7Type } from \"../parseTypes.js\";\nimport { Refs } from \"../Refs.js\";\nimport { JsonSchema7EnumType } from \"./enum.js\";\nimport { JsonSchema7StringType } from \"./string.js\";\ntype JsonSchema7RecordPropertyNamesType = Omit<JsonSchema7StringType, \"type\"> | Omit<JsonSchema7EnumType, \"type\">;\nexport type JsonSchema7RecordType = {\n type: \"object\";\n additionalProperties?: JsonSchema7Type | true;\n propertyNames?: JsonSchema7RecordPropertyNamesType;\n};\nexport declare function parseRecordDef(def: ZodRecordDef<ZodTypeAny, ZodTypeAny> | ZodMapDef, refs: Refs): JsonSchema7RecordType;\nexport {};\n"],"mappings":";;;;;;KAKKO,kCAAAA,GAAqCC,KAAKF,iCAAiCE,KAAKH;AAAhFE,KACOE,qBAAAA,GADPF;EAAkC,IAAA,EAAA,QAAA;EAAA,oBAAQD,CAAAA,EAGpBH,eAHoBG,GAAAA,IAAAA;EAAqB,aAA1BE,CAAAA,EAItBD,kCAJsBC;CAAI"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { parseAnyDef } from "./any.js";
|
|
2
|
+
import { parseBrandedDef } from "./branded.js";
|
|
3
|
+
import { parseStringDef } from "./string.js";
|
|
4
|
+
import { parseDef } from "../parseDef.js";
|
|
5
|
+
import { ZodFirstPartyTypeKind } from "zod/v3";
|
|
6
|
+
|
|
7
|
+
//#region src/utils/zod-to-json-schema/parsers/record.ts
|
|
8
|
+
function parseRecordDef(def, refs) {
|
|
9
|
+
if (refs.target === "openAi") console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
|
|
10
|
+
if (refs.target === "openApi3" && def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) return {
|
|
11
|
+
type: "object",
|
|
12
|
+
required: def.keyType._def.values,
|
|
13
|
+
properties: def.keyType._def.values.reduce((acc, key) => ({
|
|
14
|
+
...acc,
|
|
15
|
+
[key]: parseDef(def.valueType._def, {
|
|
16
|
+
...refs,
|
|
17
|
+
currentPath: [
|
|
18
|
+
...refs.currentPath,
|
|
19
|
+
"properties",
|
|
20
|
+
key
|
|
21
|
+
]
|
|
22
|
+
}) ?? parseAnyDef(refs)
|
|
23
|
+
}), {}),
|
|
24
|
+
additionalProperties: refs.rejectedAdditionalProperties
|
|
25
|
+
};
|
|
26
|
+
const schema = {
|
|
27
|
+
type: "object",
|
|
28
|
+
additionalProperties: parseDef(def.valueType._def, {
|
|
29
|
+
...refs,
|
|
30
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
31
|
+
}) ?? refs.allowedAdditionalProperties
|
|
32
|
+
};
|
|
33
|
+
if (refs.target === "openApi3") return schema;
|
|
34
|
+
if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
|
|
35
|
+
const { type,...keyType } = parseStringDef(def.keyType._def, refs);
|
|
36
|
+
return {
|
|
37
|
+
...schema,
|
|
38
|
+
propertyNames: keyType
|
|
39
|
+
};
|
|
40
|
+
} else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) return {
|
|
41
|
+
...schema,
|
|
42
|
+
propertyNames: { enum: def.keyType._def.values }
|
|
43
|
+
};
|
|
44
|
+
else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
|
|
45
|
+
const { type,...keyType } = parseBrandedDef(def.keyType._def, refs);
|
|
46
|
+
return {
|
|
47
|
+
...schema,
|
|
48
|
+
propertyNames: keyType
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return schema;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
export { parseRecordDef };
|
|
56
|
+
//# sourceMappingURL=record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.js","names":["def: ZodRecordDef<ZodTypeAny, ZodTypeAny> | ZodMapDef","refs: Refs","acc: Record<string, JsonSchema7Type>","key: string","schema: JsonSchema7RecordType"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/record.ts"],"sourcesContent":["import {\n ZodFirstPartyTypeKind,\n ZodMapDef,\n ZodRecordDef,\n ZodTypeAny,\n} from \"zod/v3\";\nimport { parseDef } from \"../parseDef.js\";\nimport { JsonSchema7Type } from \"../parseTypes.js\";\nimport { Refs } from \"../Refs.js\";\nimport { JsonSchema7EnumType } from \"./enum.js\";\nimport { JsonSchema7ObjectType } from \"./object.js\";\nimport { JsonSchema7StringType, parseStringDef } from \"./string.js\";\nimport { parseBrandedDef } from \"./branded.js\";\nimport { parseAnyDef } from \"./any.js\";\n\ntype JsonSchema7RecordPropertyNamesType =\n | Omit<JsonSchema7StringType, \"type\">\n | Omit<JsonSchema7EnumType, \"type\">;\n\nexport type JsonSchema7RecordType = {\n type: \"object\";\n additionalProperties?: JsonSchema7Type | true;\n propertyNames?: JsonSchema7RecordPropertyNamesType;\n};\n\nexport function parseRecordDef(\n def: ZodRecordDef<ZodTypeAny, ZodTypeAny> | ZodMapDef,\n refs: Refs\n): JsonSchema7RecordType {\n if (refs.target === \"openAi\") {\n console.warn(\n \"Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.\"\n );\n }\n\n if (\n refs.target === \"openApi3\" &&\n def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum\n ) {\n return {\n type: \"object\",\n required: def.keyType._def.values,\n properties: def.keyType._def.values.reduce(\n (acc: Record<string, JsonSchema7Type>, key: string) => ({\n ...acc,\n [key]:\n parseDef(def.valueType._def, {\n ...refs,\n currentPath: [...refs.currentPath, \"properties\", key],\n }) ?? parseAnyDef(refs),\n }),\n {}\n ),\n additionalProperties: refs.rejectedAdditionalProperties,\n } satisfies JsonSchema7ObjectType as any;\n }\n\n const schema: JsonSchema7RecordType = {\n type: \"object\",\n additionalProperties:\n parseDef(def.valueType._def, {\n ...refs,\n currentPath: [...refs.currentPath, \"additionalProperties\"],\n }) ?? refs.allowedAdditionalProperties,\n };\n\n if (refs.target === \"openApi3\") {\n return schema;\n }\n\n if (\n def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodString &&\n def.keyType._def.checks?.length\n ) {\n const { type, ...keyType } = parseStringDef(def.keyType._def, refs);\n\n return {\n ...schema,\n propertyNames: keyType,\n };\n } else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) {\n return {\n ...schema,\n propertyNames: {\n enum: def.keyType._def.values,\n },\n };\n } else if (\n def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodBranded &&\n def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString &&\n def.keyType._def.type._def.checks?.length\n ) {\n const { type, ...keyType } = parseBrandedDef(\n def.keyType._def,\n refs\n ) as JsonSchema7StringType;\n\n return {\n ...schema,\n propertyNames: keyType,\n };\n }\n\n return schema;\n}\n"],"mappings":";;;;;;;AAyBA,SAAgB,eACdA,KACAC,MACuB;AACvB,KAAI,KAAK,WAAW,UAClB,QAAQ,KACN,+FACD;AAGH,KACE,KAAK,WAAW,cAChB,IAAI,SAAS,KAAK,aAAa,sBAAsB,QAErD,QAAO;EACL,MAAM;EACN,UAAU,IAAI,QAAQ,KAAK;EAC3B,YAAY,IAAI,QAAQ,KAAK,OAAO,OAClC,CAACC,KAAsCC,SAAiB;GACtD,GAAG;IACF,MACC,SAAS,IAAI,UAAU,MAAM;IAC3B,GAAG;IACH,aAAa;KAAC,GAAG,KAAK;KAAa;KAAc;IAAI;GACtD,EAAC,IAAI,YAAY,KAAK;EAC1B,IACD,CAAE,EACH;EACD,sBAAsB,KAAK;CAC5B;CAGH,MAAMC,SAAgC;EACpC,MAAM;EACN,sBACE,SAAS,IAAI,UAAU,MAAM;GAC3B,GAAG;GACH,aAAa,CAAC,GAAG,KAAK,aAAa,sBAAuB;EAC3D,EAAC,IAAI,KAAK;CACd;AAED,KAAI,KAAK,WAAW,WAClB,QAAO;AAGT,KACE,IAAI,SAAS,KAAK,aAAa,sBAAsB,aACrD,IAAI,QAAQ,KAAK,QAAQ,QACzB;EACA,MAAM,EAAE,KAAM,GAAG,SAAS,GAAG,eAAe,IAAI,QAAQ,MAAM,KAAK;AAEnE,SAAO;GACL,GAAG;GACH,eAAe;EAChB;CACF,WAAU,IAAI,SAAS,KAAK,aAAa,sBAAsB,QAC9D,QAAO;EACL,GAAG;EACH,eAAe,EACb,MAAM,IAAI,QAAQ,KAAK,OACxB;CACF;UAED,IAAI,SAAS,KAAK,aAAa,sBAAsB,cACrD,IAAI,QAAQ,KAAK,KAAK,KAAK,aAAa,sBAAsB,aAC9D,IAAI,QAAQ,KAAK,KAAK,KAAK,QAAQ,QACnC;EACA,MAAM,EAAE,KAAM,GAAG,SAAS,GAAG,gBAC3B,IAAI,QAAQ,MACZ,KACD;AAED,SAAO;GACL,GAAG;GACH,eAAe;EAChB;CACF;AAED,QAAO;AACR"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const require_errorMessages = require('../errorMessages.cjs');
|
|
2
|
+
const require_parseDef = require('../parseDef.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/utils/zod-to-json-schema/parsers/set.ts
|
|
5
|
+
function parseSetDef(def, refs) {
|
|
6
|
+
const items = require_parseDef.parseDef(def.valueType._def, {
|
|
7
|
+
...refs,
|
|
8
|
+
currentPath: [...refs.currentPath, "items"]
|
|
9
|
+
});
|
|
10
|
+
const schema = {
|
|
11
|
+
type: "array",
|
|
12
|
+
uniqueItems: true,
|
|
13
|
+
items
|
|
14
|
+
};
|
|
15
|
+
if (def.minSize) require_errorMessages.setResponseValueAndErrors(schema, "minItems", def.minSize.value, def.minSize.message, refs);
|
|
16
|
+
if (def.maxSize) require_errorMessages.setResponseValueAndErrors(schema, "maxItems", def.maxSize.value, def.maxSize.message, refs);
|
|
17
|
+
return schema;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
exports.parseSetDef = parseSetDef;
|
|
22
|
+
//# sourceMappingURL=set.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set.cjs","names":["def: ZodSetDef","refs: Refs","parseDef","schema: JsonSchema7SetType","setResponseValueAndErrors"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/set.ts"],"sourcesContent":["import { ZodSetDef } from \"zod/v3\";\nimport { ErrorMessages, setResponseValueAndErrors } from \"../errorMessages.js\";\nimport { parseDef } from \"../parseDef.js\";\nimport { JsonSchema7Type } from \"../parseTypes.js\";\nimport { Refs } from \"../Refs.js\";\n\nexport type JsonSchema7SetType = {\n type: \"array\";\n uniqueItems: true;\n items?: JsonSchema7Type;\n minItems?: number;\n maxItems?: number;\n errorMessage?: ErrorMessages<JsonSchema7SetType>;\n};\n\nexport function parseSetDef(def: ZodSetDef, refs: Refs): JsonSchema7SetType {\n const items = parseDef(def.valueType._def, {\n ...refs,\n currentPath: [...refs.currentPath, \"items\"],\n });\n\n const schema: JsonSchema7SetType = {\n type: \"array\",\n uniqueItems: true,\n items,\n };\n\n if (def.minSize) {\n setResponseValueAndErrors(\n schema,\n \"minItems\",\n def.minSize.value,\n def.minSize.message,\n refs\n );\n }\n\n if (def.maxSize) {\n setResponseValueAndErrors(\n schema,\n \"maxItems\",\n def.maxSize.value,\n def.maxSize.message,\n refs\n );\n }\n\n return schema;\n}\n"],"mappings":";;;;AAeA,SAAgB,YAAYA,KAAgBC,MAAgC;CAC1E,MAAM,QAAQC,0BAAS,IAAI,UAAU,MAAM;EACzC,GAAG;EACH,aAAa,CAAC,GAAG,KAAK,aAAa,OAAQ;CAC5C,EAAC;CAEF,MAAMC,SAA6B;EACjC,MAAM;EACN,aAAa;EACb;CACD;AAED,KAAI,IAAI,SACNC,gDACE,QACA,YACA,IAAI,QAAQ,OACZ,IAAI,QAAQ,SACZ,KACD;AAGH,KAAI,IAAI,SACNA,gDACE,QACA,YACA,IAAI,QAAQ,OACZ,IAAI,QAAQ,SACZ,KACD;AAGH,QAAO;AACR"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ErrorMessages } from "../errorMessages.cjs";
|
|
2
|
+
import { JsonSchema7Type } from "../parseTypes.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/zod-to-json-schema/parsers/set.d.ts
|
|
5
|
+
type JsonSchema7SetType = {
|
|
6
|
+
type: "array";
|
|
7
|
+
uniqueItems: true;
|
|
8
|
+
items?: JsonSchema7Type;
|
|
9
|
+
minItems?: number;
|
|
10
|
+
maxItems?: number;
|
|
11
|
+
errorMessage?: ErrorMessages<JsonSchema7SetType>;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { JsonSchema7SetType };
|
|
15
|
+
//# sourceMappingURL=set.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set.d.cts","names":["ZodSetDef","ErrorMessages","JsonSchema7Type","Refs","JsonSchema7SetType","parseSetDef"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/set.d.ts"],"sourcesContent":["import { ZodSetDef } from \"zod/v3\";\nimport { ErrorMessages } from \"../errorMessages.js\";\nimport { JsonSchema7Type } from \"../parseTypes.js\";\nimport { Refs } from \"../Refs.js\";\nexport type JsonSchema7SetType = {\n type: \"array\";\n uniqueItems: true;\n items?: JsonSchema7Type;\n minItems?: number;\n maxItems?: number;\n errorMessage?: ErrorMessages<JsonSchema7SetType>;\n};\nexport declare function parseSetDef(def: ZodSetDef, refs: Refs): JsonSchema7SetType;\n"],"mappings":";;;;AAIYI,KAAAA,kBAAAA,GAAkB;EAAA,IAAA,EAAA,OAAA;EAAA,WAGlBF,EAAAA,IAAAA;EAAe,KAGME,CAAAA,EAHrBF,eAGqBE;EAAkB,QAAhCH,CAAAA,EAAAA,MAAAA;EAAa,QAAA,CAAA,EAAA,MAAA;iBAAbA,cAAcG"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ErrorMessages } from "../errorMessages.js";
|
|
2
|
+
import { JsonSchema7Type } from "../parseTypes.js";
|
|
3
|
+
import "zod/v3";
|
|
4
|
+
|
|
5
|
+
//#region src/utils/zod-to-json-schema/parsers/set.d.ts
|
|
6
|
+
type JsonSchema7SetType = {
|
|
7
|
+
type: "array";
|
|
8
|
+
uniqueItems: true;
|
|
9
|
+
items?: JsonSchema7Type;
|
|
10
|
+
minItems?: number;
|
|
11
|
+
maxItems?: number;
|
|
12
|
+
errorMessage?: ErrorMessages<JsonSchema7SetType>;
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { JsonSchema7SetType };
|
|
16
|
+
//# sourceMappingURL=set.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set.d.ts","names":["ZodSetDef","ErrorMessages","JsonSchema7Type","Refs","JsonSchema7SetType","parseSetDef"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/set.d.ts"],"sourcesContent":["import { ZodSetDef } from \"zod/v3\";\nimport { ErrorMessages } from \"../errorMessages.js\";\nimport { JsonSchema7Type } from \"../parseTypes.js\";\nimport { Refs } from \"../Refs.js\";\nexport type JsonSchema7SetType = {\n type: \"array\";\n uniqueItems: true;\n items?: JsonSchema7Type;\n minItems?: number;\n maxItems?: number;\n errorMessage?: ErrorMessages<JsonSchema7SetType>;\n};\nexport declare function parseSetDef(def: ZodSetDef, refs: Refs): JsonSchema7SetType;\n"],"mappings":";;;;;KAIYI,kBAAAA;EAAAA,IAAAA,EAAAA,OAAAA;EAAkB,WAAA,EAAA,IAAA;EAAA,KAGlBF,CAAAA,EAAAA,eAAAA;EAAe,QAGME,CAAAA,EAAAA,MAAAA;EAAkB,QAAhCH,CAAAA,EAAAA,MAAAA;EAAa,YAAA,CAAA,EAAbA,aAAa,CAACG,kBAAD,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { setResponseValueAndErrors } from "../errorMessages.js";
|
|
2
|
+
import { parseDef } from "../parseDef.js";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/zod-to-json-schema/parsers/set.ts
|
|
5
|
+
function parseSetDef(def, refs) {
|
|
6
|
+
const items = parseDef(def.valueType._def, {
|
|
7
|
+
...refs,
|
|
8
|
+
currentPath: [...refs.currentPath, "items"]
|
|
9
|
+
});
|
|
10
|
+
const schema = {
|
|
11
|
+
type: "array",
|
|
12
|
+
uniqueItems: true,
|
|
13
|
+
items
|
|
14
|
+
};
|
|
15
|
+
if (def.minSize) setResponseValueAndErrors(schema, "minItems", def.minSize.value, def.minSize.message, refs);
|
|
16
|
+
if (def.maxSize) setResponseValueAndErrors(schema, "maxItems", def.maxSize.value, def.maxSize.message, refs);
|
|
17
|
+
return schema;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { parseSetDef };
|
|
22
|
+
//# sourceMappingURL=set.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set.js","names":["def: ZodSetDef","refs: Refs","schema: JsonSchema7SetType"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/set.ts"],"sourcesContent":["import { ZodSetDef } from \"zod/v3\";\nimport { ErrorMessages, setResponseValueAndErrors } from \"../errorMessages.js\";\nimport { parseDef } from \"../parseDef.js\";\nimport { JsonSchema7Type } from \"../parseTypes.js\";\nimport { Refs } from \"../Refs.js\";\n\nexport type JsonSchema7SetType = {\n type: \"array\";\n uniqueItems: true;\n items?: JsonSchema7Type;\n minItems?: number;\n maxItems?: number;\n errorMessage?: ErrorMessages<JsonSchema7SetType>;\n};\n\nexport function parseSetDef(def: ZodSetDef, refs: Refs): JsonSchema7SetType {\n const items = parseDef(def.valueType._def, {\n ...refs,\n currentPath: [...refs.currentPath, \"items\"],\n });\n\n const schema: JsonSchema7SetType = {\n type: \"array\",\n uniqueItems: true,\n items,\n };\n\n if (def.minSize) {\n setResponseValueAndErrors(\n schema,\n \"minItems\",\n def.minSize.value,\n def.minSize.message,\n refs\n );\n }\n\n if (def.maxSize) {\n setResponseValueAndErrors(\n schema,\n \"maxItems\",\n def.maxSize.value,\n def.maxSize.message,\n refs\n );\n }\n\n return schema;\n}\n"],"mappings":";;;;AAeA,SAAgB,YAAYA,KAAgBC,MAAgC;CAC1E,MAAM,QAAQ,SAAS,IAAI,UAAU,MAAM;EACzC,GAAG;EACH,aAAa,CAAC,GAAG,KAAK,aAAa,OAAQ;CAC5C,EAAC;CAEF,MAAMC,SAA6B;EACjC,MAAM;EACN,aAAa;EACb;CACD;AAED,KAAI,IAAI,SACN,0BACE,QACA,YACA,IAAI,QAAQ,OACZ,IAAI,QAAQ,SACZ,KACD;AAGH,KAAI,IAAI,SACN,0BACE,QACA,YACA,IAAI,QAAQ,OACZ,IAAI,QAAQ,SACZ,KACD;AAGH,QAAO;AACR"}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
const require_errorMessages = require('../errorMessages.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/utils/zod-to-json-schema/parsers/string.ts
|
|
4
|
+
let emojiRegex = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* Generated from the regular expressions found here as of 2024-05-22:
|
|
7
|
+
* https://github.com/colinhacks/zod/blob/master/src/types.ts.
|
|
8
|
+
*
|
|
9
|
+
* Expressions with /i flag have been changed accordingly.
|
|
10
|
+
*/
|
|
11
|
+
const zodPatterns = {
|
|
12
|
+
cuid: /^[cC][^\s-]{8,}$/,
|
|
13
|
+
cuid2: /^[0-9a-z]+$/,
|
|
14
|
+
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
15
|
+
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
|
16
|
+
emoji: () => {
|
|
17
|
+
if (emojiRegex === void 0) emojiRegex = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
|
|
18
|
+
return emojiRegex;
|
|
19
|
+
},
|
|
20
|
+
uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
|
|
21
|
+
ipv4: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,
|
|
22
|
+
ipv4Cidr: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,
|
|
23
|
+
ipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,
|
|
24
|
+
ipv6Cidr: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,
|
|
25
|
+
base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
|
|
26
|
+
base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
|
|
27
|
+
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
28
|
+
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
29
|
+
};
|
|
30
|
+
function parseStringDef(def, refs) {
|
|
31
|
+
const res = { type: "string" };
|
|
32
|
+
if (def.checks) for (const check of def.checks) switch (check.kind) {
|
|
33
|
+
case "min":
|
|
34
|
+
require_errorMessages.setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
35
|
+
break;
|
|
36
|
+
case "max":
|
|
37
|
+
require_errorMessages.setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
38
|
+
break;
|
|
39
|
+
case "email":
|
|
40
|
+
switch (refs.emailStrategy) {
|
|
41
|
+
case "format:email":
|
|
42
|
+
addFormat(res, "email", check.message, refs);
|
|
43
|
+
break;
|
|
44
|
+
case "format:idn-email":
|
|
45
|
+
addFormat(res, "idn-email", check.message, refs);
|
|
46
|
+
break;
|
|
47
|
+
case "pattern:zod":
|
|
48
|
+
addPattern(res, zodPatterns.email, check.message, refs);
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
case "url":
|
|
53
|
+
addFormat(res, "uri", check.message, refs);
|
|
54
|
+
break;
|
|
55
|
+
case "uuid":
|
|
56
|
+
addFormat(res, "uuid", check.message, refs);
|
|
57
|
+
break;
|
|
58
|
+
case "regex":
|
|
59
|
+
addPattern(res, check.regex, check.message, refs);
|
|
60
|
+
break;
|
|
61
|
+
case "cuid":
|
|
62
|
+
addPattern(res, zodPatterns.cuid, check.message, refs);
|
|
63
|
+
break;
|
|
64
|
+
case "cuid2":
|
|
65
|
+
addPattern(res, zodPatterns.cuid2, check.message, refs);
|
|
66
|
+
break;
|
|
67
|
+
case "startsWith":
|
|
68
|
+
addPattern(res, RegExp(`^${escapeLiteralCheckValue(check.value, refs)}`), check.message, refs);
|
|
69
|
+
break;
|
|
70
|
+
case "endsWith":
|
|
71
|
+
addPattern(res, RegExp(`${escapeLiteralCheckValue(check.value, refs)}$`), check.message, refs);
|
|
72
|
+
break;
|
|
73
|
+
case "datetime":
|
|
74
|
+
addFormat(res, "date-time", check.message, refs);
|
|
75
|
+
break;
|
|
76
|
+
case "date":
|
|
77
|
+
addFormat(res, "date", check.message, refs);
|
|
78
|
+
break;
|
|
79
|
+
case "time":
|
|
80
|
+
addFormat(res, "time", check.message, refs);
|
|
81
|
+
break;
|
|
82
|
+
case "duration":
|
|
83
|
+
addFormat(res, "duration", check.message, refs);
|
|
84
|
+
break;
|
|
85
|
+
case "length":
|
|
86
|
+
require_errorMessages.setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
87
|
+
require_errorMessages.setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
88
|
+
break;
|
|
89
|
+
case "includes":
|
|
90
|
+
addPattern(res, RegExp(escapeLiteralCheckValue(check.value, refs)), check.message, refs);
|
|
91
|
+
break;
|
|
92
|
+
case "ip":
|
|
93
|
+
if (check.version !== "v6") addFormat(res, "ipv4", check.message, refs);
|
|
94
|
+
if (check.version !== "v4") addFormat(res, "ipv6", check.message, refs);
|
|
95
|
+
break;
|
|
96
|
+
case "base64url":
|
|
97
|
+
addPattern(res, zodPatterns.base64url, check.message, refs);
|
|
98
|
+
break;
|
|
99
|
+
case "jwt":
|
|
100
|
+
addPattern(res, zodPatterns.jwt, check.message, refs);
|
|
101
|
+
break;
|
|
102
|
+
case "cidr":
|
|
103
|
+
if (check.version !== "v6") addPattern(res, zodPatterns.ipv4Cidr, check.message, refs);
|
|
104
|
+
if (check.version !== "v4") addPattern(res, zodPatterns.ipv6Cidr, check.message, refs);
|
|
105
|
+
break;
|
|
106
|
+
case "emoji":
|
|
107
|
+
addPattern(res, zodPatterns.emoji(), check.message, refs);
|
|
108
|
+
break;
|
|
109
|
+
case "ulid":
|
|
110
|
+
addPattern(res, zodPatterns.ulid, check.message, refs);
|
|
111
|
+
break;
|
|
112
|
+
case "base64":
|
|
113
|
+
switch (refs.base64Strategy) {
|
|
114
|
+
case "format:binary":
|
|
115
|
+
addFormat(res, "binary", check.message, refs);
|
|
116
|
+
break;
|
|
117
|
+
case "contentEncoding:base64":
|
|
118
|
+
require_errorMessages.setResponseValueAndErrors(res, "contentEncoding", "base64", check.message, refs);
|
|
119
|
+
break;
|
|
120
|
+
case "pattern:zod":
|
|
121
|
+
addPattern(res, zodPatterns.base64, check.message, refs);
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
break;
|
|
125
|
+
case "nanoid":
|
|
126
|
+
addPattern(res, zodPatterns.nanoid, check.message, refs);
|
|
127
|
+
break;
|
|
128
|
+
case "toLowerCase":
|
|
129
|
+
case "toUpperCase":
|
|
130
|
+
case "trim": break;
|
|
131
|
+
default:
|
|
132
|
+
/* c8 ignore next */
|
|
133
|
+
((_) => {})(check);
|
|
134
|
+
}
|
|
135
|
+
return res;
|
|
136
|
+
}
|
|
137
|
+
function escapeLiteralCheckValue(literal, refs) {
|
|
138
|
+
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric(literal) : literal;
|
|
139
|
+
}
|
|
140
|
+
const ALPHA_NUMERIC = /* @__PURE__ */ new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
141
|
+
function escapeNonAlphaNumeric(source) {
|
|
142
|
+
let result = "";
|
|
143
|
+
for (let i = 0; i < source.length; i++) {
|
|
144
|
+
if (!ALPHA_NUMERIC.has(source[i])) result += "\\";
|
|
145
|
+
result += source[i];
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
function addFormat(schema, value, message, refs) {
|
|
150
|
+
if (schema.format || schema.anyOf?.some((x) => x.format)) {
|
|
151
|
+
if (!schema.anyOf) schema.anyOf = [];
|
|
152
|
+
if (schema.format) {
|
|
153
|
+
schema.anyOf.push({
|
|
154
|
+
format: schema.format,
|
|
155
|
+
...schema.errorMessage && refs.errorMessages && { errorMessage: { format: schema.errorMessage.format } }
|
|
156
|
+
});
|
|
157
|
+
delete schema.format;
|
|
158
|
+
if (schema.errorMessage) {
|
|
159
|
+
delete schema.errorMessage.format;
|
|
160
|
+
if (Object.keys(schema.errorMessage).length === 0) delete schema.errorMessage;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
schema.anyOf.push({
|
|
164
|
+
format: value,
|
|
165
|
+
...message && refs.errorMessages && { errorMessage: { format: message } }
|
|
166
|
+
});
|
|
167
|
+
} else require_errorMessages.setResponseValueAndErrors(schema, "format", value, message, refs);
|
|
168
|
+
}
|
|
169
|
+
function addPattern(schema, regex, message, refs) {
|
|
170
|
+
if (schema.pattern || schema.allOf?.some((x) => x.pattern)) {
|
|
171
|
+
if (!schema.allOf) schema.allOf = [];
|
|
172
|
+
if (schema.pattern) {
|
|
173
|
+
schema.allOf.push({
|
|
174
|
+
pattern: schema.pattern,
|
|
175
|
+
...schema.errorMessage && refs.errorMessages && { errorMessage: { pattern: schema.errorMessage.pattern } }
|
|
176
|
+
});
|
|
177
|
+
delete schema.pattern;
|
|
178
|
+
if (schema.errorMessage) {
|
|
179
|
+
delete schema.errorMessage.pattern;
|
|
180
|
+
if (Object.keys(schema.errorMessage).length === 0) delete schema.errorMessage;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
schema.allOf.push({
|
|
184
|
+
pattern: stringifyRegExpWithFlags(regex, refs),
|
|
185
|
+
...message && refs.errorMessages && { errorMessage: { pattern: message } }
|
|
186
|
+
});
|
|
187
|
+
} else require_errorMessages.setResponseValueAndErrors(schema, "pattern", stringifyRegExpWithFlags(regex, refs), message, refs);
|
|
188
|
+
}
|
|
189
|
+
function stringifyRegExpWithFlags(regex, refs) {
|
|
190
|
+
if (!refs.applyRegexFlags || !regex.flags) return regex.source;
|
|
191
|
+
const flags = {
|
|
192
|
+
i: regex.flags.includes("i"),
|
|
193
|
+
m: regex.flags.includes("m"),
|
|
194
|
+
s: regex.flags.includes("s")
|
|
195
|
+
};
|
|
196
|
+
const source = flags.i ? regex.source.toLowerCase() : regex.source;
|
|
197
|
+
let pattern = "";
|
|
198
|
+
let isEscaped = false;
|
|
199
|
+
let inCharGroup = false;
|
|
200
|
+
let inCharRange = false;
|
|
201
|
+
for (let i = 0; i < source.length; i++) {
|
|
202
|
+
if (isEscaped) {
|
|
203
|
+
pattern += source[i];
|
|
204
|
+
isEscaped = false;
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
if (flags.i) {
|
|
208
|
+
if (inCharGroup) {
|
|
209
|
+
if (source[i].match(/[a-z]/)) {
|
|
210
|
+
if (inCharRange) {
|
|
211
|
+
pattern += source[i];
|
|
212
|
+
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
213
|
+
inCharRange = false;
|
|
214
|
+
} else if (source[i + 1] === "-" && source[i + 2]?.match(/[a-z]/)) {
|
|
215
|
+
pattern += source[i];
|
|
216
|
+
inCharRange = true;
|
|
217
|
+
} else pattern += `${source[i]}${source[i].toUpperCase()}`;
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
} else if (source[i].match(/[a-z]/)) {
|
|
221
|
+
pattern += `[${source[i]}${source[i].toUpperCase()}]`;
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (flags.m) {
|
|
226
|
+
if (source[i] === "^") {
|
|
227
|
+
pattern += `(^|(?<=[\r\n]))`;
|
|
228
|
+
continue;
|
|
229
|
+
} else if (source[i] === "$") {
|
|
230
|
+
pattern += `($|(?=[\r\n]))`;
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (flags.s && source[i] === ".") {
|
|
235
|
+
pattern += inCharGroup ? `${source[i]}\r\n` : `[${source[i]}\r\n]`;
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
pattern += source[i];
|
|
239
|
+
if (source[i] === "\\") isEscaped = true;
|
|
240
|
+
else if (inCharGroup && source[i] === "]") inCharGroup = false;
|
|
241
|
+
else if (!inCharGroup && source[i] === "[") inCharGroup = true;
|
|
242
|
+
}
|
|
243
|
+
try {
|
|
244
|
+
new RegExp(pattern);
|
|
245
|
+
} catch {
|
|
246
|
+
console.warn(`Could not convert regex pattern at ${refs.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`);
|
|
247
|
+
return regex.source;
|
|
248
|
+
}
|
|
249
|
+
return pattern;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
//#endregion
|
|
253
|
+
exports.parseStringDef = parseStringDef;
|
|
254
|
+
exports.zodPatterns = zodPatterns;
|
|
255
|
+
//# sourceMappingURL=string.cjs.map
|